From d9147e137c4801b261d9d55888c3759619b2f0e9 Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 9 Oct 2026 07:03:00 -0500 Subject: [PATCH] fix(hermes): retain overall source download deadline Co-Authored-By: Paperclip --- doc/plans/2026-10-06-hermes-native-runner.md | 51 +++++++++++++++++++ .../scripts/hermes-source-download.test.mjs | 44 ++++++++++++++++ .../scripts/provision-hermes.mjs | 38 ++++++++++---- 3 files changed, 122 insertions(+), 11 deletions(-) diff --git a/doc/plans/2026-10-06-hermes-native-runner.md b/doc/plans/2026-10-06-hermes-native-runner.md index 5ac70eb2661..0f78b940bfc 100644 --- a/doc/plans/2026-10-06-hermes-native-runner.md +++ b/doc/plans/2026-10-06-hermes-native-runner.md @@ -2017,3 +2017,54 @@ The TypeScript builds and vendor dependency check pass; six selected vendored modules, including the sidecar, match the freshly built Runner byte-for-byte. No local Rust or Docker build runs. Another native browser attempt is required against these verified artifacts before accepting rendered steering behavior. + + +### 2026-10-09 native steering and queue browser acceptance + +A clean Mac production-path journey at `60aba2d58d79c0e8773f02bfe2de59df795fd9a9` +passes all 38 checks and six visual inspections. Reasoning and assistant text +reach the browser before completion. The canonical native event retains its +progress channel. The real Steer button delivers the correction to the same +active turn; the original commentary remains visible. A queued follow-up stays +deferred across reload, then runs only after the first turn ends. Both native +runs succeed with the same restored session. Authorized file downloads match, +and expanded read output retains the corrected file contents after reload. +The owned server exits cleanly. + +Evidence is retained in +`/private/tmp/hermes-retry-qa-20261008/ctrl59c5/proof.json`, with the script, +38-check evidence receipt, native events and six inspected screenshots beside +it. The script SHA-256 is +`170396b3f703d41194f6a3087c9e9f42712dbfea99a757a7cdcfc4eff6e4560f`. +The cloud-built binary has exactly the current Rust subtree. Its older artifact +closure and the independently verified current Mac materialization are recorded +separately. Inference is scripted and credential-free; this is real browser and +Runner-path proof, not paid-model or Daytona qualification. Earlier failures +remain failed. In particular, attempt four completed both turns but used +positional disclosure locators that shifted when panels opened. Attempt five +uses the current first collapsed disclosure and preserves the same assertions. + +### 2026-10-09 bounded native controls and setup review fixes + +Early steering waits for the owning native turn acknowledgement, with a +five-second timeout and immediate cancellation when the turn ends. Five new +regressions reproduce the prior rejection, then cover delayed acknowledgement, +foreign-session rejection, cancellation, stream closure, settlement and timeout. +Question forms reserve ACPX's 256 KiB encoded response budget before publication. +Their text limits account for all question/option IDs and worst-case JSON +escaping. Canonical validation uses that same persisted limit. Three regressions +reproduce oversized accepted responses, then prove all permitted text, custom +and multiple-choice responses fit the transport bound. All 107 focused Runner +assertions and Runner TypeScript pass. + +Source downloads keep one two-minute deadline across the request, body and +bounded retries. A progressing download is no longer cut off at 30 seconds. +Transport failures retry within the remaining budget; permanent failures and +digest mismatches do not retry. All eight download assertions pass. The full +messaging and legacy-continuation browser files pass 35 cases. Both sidebar +links handle the optional announcement through its normal dismissal button; +company isolation, history navigation and the original retry assertions remain. +The legacy continuation CI failure remains a separate failed measurement. +Current-head full CI, remaining review, paid/subscription credentials, clean +consumer and actual Daytona qualification are still required. No local Docker +or Rust build, provider credential or paid inference is used in these checks. diff --git a/packages/paperclip-runner/scripts/hermes-source-download.test.mjs b/packages/paperclip-runner/scripts/hermes-source-download.test.mjs index bd33554361d..fe671cf765a 100644 --- a/packages/paperclip-runner/scripts/hermes-source-download.test.mjs +++ b/packages/paperclip-runner/scripts/hermes-source-download.test.mjs @@ -68,3 +68,47 @@ test("long throttling delays fail visibly rather than running an unbounded setup }), /rate limit expires/); assert.equal(calls, 1); }); + +test("a progressing body may use the remaining overall download deadline", async () => { + let time = 0; + const allowances = []; + const bytes = await downloadPinnedHermesArchive(version, { + now: () => time, + timeout: milliseconds => { allowances.push(milliseconds); return new AbortController().signal; }, + request: async () => ({ ok: true, arrayBuffer: async () => { time = 60_000; return archive; } }), + }); + assert.deepEqual(bytes, archive); + assert.deepEqual(allowances, [120_000]); +}); + +test("transport failures during request and body reading retry within the same deadline", async () => { + let calls = 0; + let time = 0; + const allowances = []; + const bytes = await downloadPinnedHermesArchive(version, { + now: () => time, + timeout: milliseconds => { allowances.push(milliseconds); return new AbortController().signal; }, + request: async () => { + calls++; + time += 10_000; + if (calls === 1) throw new TypeError("fetch failed"); + if (calls === 2) return { ok: true, arrayBuffer: async () => { throw new TypeError("body interrupted"); } }; + return new Response(archive); + }, + wait: async milliseconds => { time += milliseconds; }, + }); + assert.deepEqual(bytes, archive); + assert.equal(calls, 3); + assert.deepEqual(allowances, [120_000, 109_000, 97_000]); +}); + +test("an expired transport deadline cannot open another request", async () => { + let calls = 0; + let time = 0; + await assert.rejects(downloadPinnedHermesArchive(version, { + now: () => time, + request: async () => { calls++; time = 120_000; throw new TypeError("fetch failed"); }, + wait: async () => assert.fail("The expired download cannot retry"), + }), /deadline exceeded/); + assert.equal(calls, 1); +}); diff --git a/packages/paperclip-runner/scripts/provision-hermes.mjs b/packages/paperclip-runner/scripts/provision-hermes.mjs index 4466cd7b373..26174fe11c2 100644 --- a/packages/paperclip-runner/scripts/provision-hermes.mjs +++ b/packages/paperclip-runner/scripts/provision-hermes.mjs @@ -10,19 +10,38 @@ import { hermesProvisioningConfig } from "./hermes-provisioning-config.mjs"; const digest = bytes => createHash("sha256").update(bytes).digest("hex"); /** Download the same pinned GitHub archive without the unauthenticated API quota. */ -export async function downloadPinnedHermesArchive(version, { request = fetch, wait = delay } = {}) { - const deadline = Date.now() + 120_000; +export async function downloadPinnedHermesArchive(version, { + request = fetch, wait = delay, now = Date.now, timeout = AbortSignal.timeout, +} = {}) { + const deadline = now() + 120_000; + const retryWait = async (waitMs, failure) => { + if (waitMs > 30_000) { + throw new Error(`${failure}; retry setup later after the download service's rate limit expires`); + } + if (waitMs + 1 >= deadline - now()) throw new Error(`${failure}; overall download deadline exceeded; retry setup later`); + await wait(waitMs); + }; const url = `https://codeload.github.com/NousResearch/hermes-agent/legacy.tar.gz/${version.commit}`; for (let attempt = 1; attempt <= 3; attempt++) { - const remaining = deadline - Date.now(); + const remaining = deadline - now(); if (remaining <= 0) throw new Error("Hermes source download deadline exceeded; retry setup later"); - const response = await request(url, { signal: AbortSignal.timeout(Math.min(30_000, remaining)) }); + let response; + let bytes; + try { + response = await request(url, { signal: timeout(remaining) }); + if (response.ok) bytes = Buffer.from(await response.arrayBuffer()); + } catch { + if (deadline <= now()) throw new Error("Hermes source download deadline exceeded; retry setup later"); + const failure = `Hermes source download failed: network error after ${attempt} attempts`; + if (attempt === 3) throw new Error(`${failure}; retry setup later`); + await retryWait(attempt * 1_000, failure); + continue; + } if (response.ok) { - const bytes = Buffer.from(await response.arrayBuffer()); if (digest(bytes) !== version.archiveSha256) throw new Error("Hermes source digest mismatch"); return bytes; } - await response.body?.cancel(); + await response.body?.cancel().catch(() => undefined); const failure = `Hermes source download failed: HTTP ${response.status}`; if (![429, 500, 502, 503, 504].includes(response.status) || attempt === 3) { throw new Error(`${failure}${attempt > 1 ? ` after ${attempt} attempts` : ""}; retry setup later`); @@ -31,11 +50,8 @@ export async function downloadPinnedHermesArchive(version, { request = fetch, wa const seconds = retryAfter === null ? NaN : Number(retryAfter); const retryAt = retryAfter === null ? NaN : Date.parse(retryAfter); const waitMs = Number.isFinite(seconds) ? Math.max(0, seconds * 1_000) - : Number.isFinite(retryAt) ? Math.max(0, retryAt - Date.now()) : attempt * 1_000; - if (waitMs > 30_000 || waitMs + 1 >= deadline - Date.now()) { - throw new Error(`${failure}; retry setup later after the download service's rate limit expires`); - } - await wait(waitMs); + : Number.isFinite(retryAt) ? Math.max(0, retryAt - now()) : attempt * 1_000; + await retryWait(waitMs, failure); } }