Skip to content

fix: prevent Codex settlement cleanup from hanging - #156868

Closed
steipete wants to merge 1 commit into
mainfrom
codex/native-acquisition-clock601
Closed

steipete wants to merge 1 commit into
mainfrom
codex/native-acquisition-clock601

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Codex settlement tests hanging during cleanup when a contended SQLite coordinator wait outlives the simulated turn clock.

User Impact

There is no intended user-visible behavior change. This removes a shared source of CI stalls without changing execution budgets, SQLite admission, cancellation, or test assertions. No migration or operator action is required.

Why This Change Was Made

Coordinator acquisition measured its deadline with the native monotonic clock but scheduled its abortable backoff through global timers. A settlement test could finish its assertions and restore real timers while history maintenance was waiting on a simulated 25 ms backoff. The discarded wakeup left maintenance holding the archive queue, and session-owner cleanup could never finish.

Use Node's native abortable timer for both coordinator acquisition paths, matching the existing acquisition helper's default clock. The retry interval, deadline, authority checks, abort reason, and process-lifetime behavior stay intact. The focused acquisition unit test explicitly simulates this native sleeper alongside its simulated monotonic clock; the Codex settlement tests remain unchanged.

Evidence

The failure was observed on the merge refs for #156764 and #156758; this is not a claim that their branch changes introduced it or that a main CI run was red. All affected owner files and the failing tests remained identical on main at 2512775add63106306e7ee5ad40324143f5abe86.

  • Original bundle-8 job failed after 55 minutes, including the runner's inherited automatic retry. No manual rerun was used. The corresponding fix(codex): large document uploads are unavailable to local file tools #156758 job had the same first-attempt failure before an inherited replay passed.
  • The original protocol-validation → settlement order reproduced the 180-second cleanup hook failure locally. Trace evidence isolated the stranded 25 ms coordinator backoff and the archive queue it retained.
  • With the repair, those unchanged tests pass: 23 tests, 47.96 seconds including cold compilation. The full 12-file group also passes: 107 tests, 133.73 seconds of Vitest time; that run used local timing-cache ordering.
  • Acquisition retry, deadline, cancellation, and live-authority tests plus the native SQLite worker-preparation sibling pass: 18 tests, 15.66 seconds total. The modified unit file's test cases take approximately 64 ms; the native worker sibling protects FIFO, cancellation, refusal recovery, and cleanup custody.
  • On fresh main plus this repair, the exact original hosted 12-file execution order passes: 107 tests, 172.92 seconds including cold compilation. An external proof sequencer enforced the original order while retaining the repository configuration, isolation, setup files, and timeouts.
  • Local proof used pnpm 12.4.2, Vitest 5.0.1, and Node 26.7.0. The failing hosted job used the same Vitest version on Node 24.19.0; the new PR keeps the normal hosted CI gate.
  • Independent managed review found no actionable P0–P2 issue. Selected preflights, compiler graph boundary, production core typechecking, and five core-test graphs passed. A subsequent shard was canceled when concurrent host workloads exhausted memory; the remaining 20 canonical graphs are running, and selected lint/guards remain pending. This draft does not claim the complete static gate.
  • The current fix(codex): large document uploads are unavailable to local file tools #156758 bundle-18 job independently repeats the same settlement cleanup failure: the 60,000 ms and maximum-budget cases and the held assistant-start case each reach the unchanged 180-second hook timeout. This is streamed job evidence while that run remains active, not a completed job result.

@clawsweeper

clawsweeper Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #156801, merged as adf4aff. Its CI repair already switches coordinator backoff to the same native abortable timer while keeping the monotonic deadline, and its final CI passed all 145 executed jobs.

Our independent reproduction traced the same stranded 25 ms fake timer holding the archive queue. The same correction passed the unchanged original 12-file order (107 tests), the protocol/settlement pair (23 tests), and acquisition/worker siblings (18 tests), with no actionable review findings. Partial static proof is retained for the ongoing affected PR recovery; it was stopped once the upstream fix was verified, so this draft does not claim a complete static gate.

The remaining worker-lifecycle timer change is unnecessary for this failure: that acquisition runs inside the SQLite worker, whose global timers are isolated from the parent test's fake clock. No separate defect was established there, so this draft will not duplicate the landed fix or broaden it speculatively.

@steipete steipete closed this Sep 24, 2026
@RomneyDa
RomneyDa deleted the codex/native-acquisition-clock601 branch October 22, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant