Repository navigation
fix(worker): verify completion before a timed-out job is recollected - #46
Open
alphastorm wants to merge 16 commits into
Open
alphastorm wants to merge 16 commits into
alphastorm wants to merge 16 commits into
Conversation
Keep the original timeout failure until the bound reply passes completion detection and collection. Record the verification receipt atomically with completion; preserve no-send recovery and existing lease, cleanup, and notification semantics.
Require the existing widget completion marker and nonempty report in regression coverage. Document the unchanged sixty-second research recollection deadline; no runtime behavior changes.
Observe generation and the bound reload capture together, retaining the Stop fallback. Bind research output to verified visible report text and retain unbound exports only as optional evidence. Give native export setup, activation, retrieval and restoration one deadline. Bound timeout recovery from process startup, drain owned heartbeat and deadline writes, and preserve the existing complete-job read allowance. Return durable job state alongside unsuccessful subprocess exits. Document UI-proof limits, hard-exit behavior, field preservation and shared budget arithmetic. Add guard-sensitive offline regressions.
Join one runtime cleanup and one recollection finalizer, including pending cleanup heartbeats. Signals stop heartbeat and deadline producers and drain only writes already in flight, never the foreground task. Arm the existing sixty-second finalization reserve on either recollection path, retaining any earlier hard deadline. Keep complete-job normal execution and its ten-minute read setting unchanged. Document signal-to-child-close timing and provenance ownership. Exercise ordinary signal callers, real synthetic child termination, cleanup interleavings and guard-removal regressions offline.
Recheck shutdown ownership after the normal recorder drain before clearing its timer. A signal may have replaced that timer while the write was pending. Qualify cleanup finalization after rejection and optional subprocess errors after gracefully handled read timeouts.
Owner
Author
|
Parked on 2026-11-14. The review of this pull request did not come back clean, and two attempts at narrow corrections were each found not ready by an independent read: the first blocked a healthy retry, the second lost the content binding of a saved reply in the ordinary path. Nothing from those attempts is pushed; the branch stays as it is. It returns as smaller pull requests, in the order given at the top of the description. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect and behavior
In 0.4.15, recollecting a timed-out job acquired its saved reply, collected it immediately, and marked the job complete. Acquisition checked identity, not whether generation had finished. If you recollected a reply after a timeout with 0.4.15, check that the saved reply is complete.
Timed-out ChatGPT recollection now uses the ordinary completion detector on the bound turn, then requires a successful reload and two identical non-empty bound captures. Each capture shares one page evaluation with the saved-conversation and rendered-generation observation; active generation resets stability, and the snapshot Stop-label fallback is retained. Collection saves that second capture, not a later read or streamed lower bound.
The archive-bearing user turn initially identifies the reply. Learned message identity is saved immediately and survives failed attempts and shifted indices. A later turn cannot substitute its text; a conversation-wide Stop conservatively delays verification. Recollection never sends a prompt or clicks Retry.
Proof limit: this is UI evidence—stable non-empty bound text with no rendered generation after reload—not a provider-side finality attestation. Existing Copy/action labels are not reliable positive finality markers. Before release, live validation must establish whether a real reloaded page can hide ongoing generation.
The job remains
failedwith its original timeout error andcompletedAtwhile waiting. Failed verification leaves that failure intact; the attempt recordsrecollectionError, and cleanup permits another recollection. Success createsrecollectionCompletionVerifiedAtonce at the completion transition, possiblycomplete_with_artifact_errors. Already-complete artifact recollection neither creates nor rewrites the field.For Deep Research, the proof is the bound widget's completion marker and a non-empty report. Collection rechecks the parsed report after whitespace normalization. DOM Markdown may replace the verified text only when its co-captured visible body matches that text after the same normalization. Otherwise the verified text is saved; mismatched DOM and unbound widget/native exports remain optional unconfirmed artifacts, never replacement response bodies. A timed-out research job must finish within the existing sixty-second report wait; chat recollection waits up to its saved completion timeout. The research wait duration is unchanged.
Timed-out Grok recollection is unsupported and refused before leases, worker identity or job fields change. The tool refuses an explicit timed-out
messageId; the direct worker ignores that argument and uses saved/learned identity. A vanished saved ID is refused, not replaced by a positional neighbor or hash fallback.Deadlines and readers
The read is synchronous. After child settlement, including a handled timeout signal, it rereads and returns the durable job state with any subprocess error reported by that settlement; a graceful exit 0 can report no subprocess error. It does not infer job failure or completion from the exit. Files may already exist before a completion transition, so file existence alone is not proof.
Timeout recovery has a five-minute startup deadline armed before the lock/first read, charging process bootstrap time; the saved chat completion wait (default 90 minutes) or shared 60-second research wait; and one ten-minute post-wait budget. That last budget reserves one minute for persistence/cleanup. Native setup, activation, retrieval and restoration consume the same absolute remaining deadline. Download exhaustion preserves the verified response and reports artifact errors. Heartbeat and deadline-record writes drain before hard timers are cleared; signals do not extend the ceiling.
A hung filesystem/transport/cleanup may instead reach hard exit. Its last error write is best effort; pending cleanup can remain. The read reports the last durable state, including a completed job if completion was already persisted. These are scheduled deadlines, not protection against event-loop or OS suspension.
At the default, the timeout-recovery worker ceiling is 5 + 90 + 10 = 105 minutes, versus the read's configured child timeout of 106 minutes; research is 16 versus 17 minutes. A wait-failure path has at most startup + wait + the one-minute finalization reserve. Once the first read identifies an already-complete job, its entry timer is cleared: artifact recollection keeps its existing ten-minute read allowance, not these stage ceilings. These read settings send SIGTERM rather than immediately settling the child; on either path child closure can take another 60 seconds, or less when an earlier worker deadline applies. Subsequent host-side job/file reads are outside the child timeout.
extensions/oracle/lib/jobs.ts:452requires a terminal, cleanup-pending job and useslastCleanupAt, thenheartbeatAt, for freshness. Admission retires the old cleanup timestamp. A fresh matching live worker is left alone (jobs.ts:633); tests cover startup and the full completion wait.shared/job-coordination-helpers.mjs:59,lib/runtime.ts:415and worker lease admission block on active status,cleanupPending, or a live worker. Published leases have no age expiry (shared/state-coordination-helpers.mjs:291-398). A second recollection is refused; other jobs see occupied capacity and same-thread follow-ups cannot acquire the conversation.lib/jobs.ts:420-421first testsif (!isActiveOracleJob(job)) return undefined; a still-failed job is excluded.lib/jobs.ts:753andlib/poller.ts:327retain and honornotifiedAt. A session already told that the job failed receives nothing when recollection later succeeds—no second wake-up. The caller learns the outcome from the read itself.Submit completion detection, model/preset selection and the research wait duration are unchanged. The shared native helper now budgets the whole export operation, and the shared heartbeat wrapper drains its pending write. Native restoration preserves the original export error instead of replacing it with a cleanup deadline.
Offline coverage
Signal cleanup now has one owner. Concurrent
cleanupRuntimecallers await the same attempt and receive the same warning result or rejection, rather than an empty warning list while cleanup is running. Normal recollection and its signal handler share one cleanup/finalization promise, including the cleanup heartbeat drain. Finalization also handles rejection before lease release: it records a warning and keeps cleanup pending, without claiming every cleanup step ran. Predecessor identity is restored only after warning-free teardown settles.Signals stop heartbeat timers and the deadline recorder, drain only writes already in flight, and proceed to cleanup without waiting for foreground work. Both recollection paths arm one shutdown deadline at the earlier of the existing hard deadline and 60 seconds after the signal. Repeated signals do not extend it. The normal path rechecks shutdown after its recorder drain before clearing a timer, so it cannot cancel a signal's replacement deadline. An already-complete job gets no other new worker ceiling.
The shared cleanup fix also makes ordinary SIGTERM/SIGINT callers wait for an already-running teardown before exiting; ordinary signal policy otherwise remains unchanged. New tests gate browser close, lease release and the final cleanup heartbeat, and prove finalization happens once. A real provider-free Node child also demonstrates that the read's timeout signal reaches the production handler and the child closes under its shutdown timer.
Eight additional isolated mutations—cleanup join, finalizer ownership, shutdown timer, earlier-deadline preference, heartbeat stop, recorder stop, write drain and direct-write tracking—each fail their intended assertion.
The outer-drain regression executes the full production recollection path: normal finalization finishes while a recorder write remains pending, a signal arrives, the recorder settles, and only the signal log stays blocked. It failed before the post-await ownership guard and now proves hard exit at signal +60,000ms even after normal
finallyreturns.Production-function tests cover streaming → finished, expiry → retry, interruption/browser loss, later-turn identity and shifted indices, atomic reload observations, generation reset and Stop fallback, empty/whitespace evidence, same-report research renderings and mismatched bodies, native export exhaustion, durable reads after unsuccessful exits, startup/lock/bootstrap deadlines, complete-job exemption, and pending-write tails. Thirty-two isolated guard-removal mutations each fail their intended assertion, including the non-empty reload, research-body equality, saved index/ID, and rich-body guards.
The capture proof uses its own headless Chrome and local fixtures, with zero sends. It exercises real capture, binding, downloads and recollection against a streaming bound reply with a later reply. No live profile, real prompt, publication, version bump, tag or merge was used.
Both required commands ran once on final signed head
1ff2ce4116f37bfa90ec931c3fac85a0d3ceaa21:npm run verify:oraclepassed, 2026-11-14 09:27:01–09:28:16 UTC: 204 helper tests, site/docs tests, all three typechecks, ordinary signal/cancellation sanity, syntax/bundling and package validation.npm run proof:capturepassed, 2026-11-14 09:27:01–09:27:05 UTC: synthetic-only, zero sends.local-gatecompleted SUCCESS on that head at 2026-11-14 09:30:52 UTC; exact head and ready/open PR state observed at 09:30:56 UTC.An earlier gate caught a test double still recording the old teardown transport. Updating it also exposed teardown expiry masking the original export error; a failing regression was committed first, then the production fix, retaining the native-export assertions. The signal fixture now executes actual cleanup and records pending state at hard exit rather than assuming its simulated exit exception escapes cleanup's catch; the real-child test separately proves process termination.
Cheapest live checks before release