Repository navigation
fix(process): observe already-due trailing callbacks before settling the capture journal - #1700
Conversation
…the capture journal A stalled event loop can leave the settle wake-up and a trailing observation callback due at the same resume. The earlier wake-up runs first, declares silence, and the capture becomes immutable before the trailing callback appends its observation. Drain the loop turn after the quiet sleep so timer and poll callbacks that were already due run before silence is judged, and cover the stalled-loop case with a deterministic regression test. Fixes morluto#1697
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Fixes #1697. Process-capture Evidence can silently drop the terminal tail when the host stalls the event loop around exit:
settleProcessCaptureJournaljudged the journal quiet by wall-clock time alone, so a trailing observation callback that was already due ran after the settle returned and never reached the immutable capture. PTY capture results now retain the trailing observations they were always meant to keep.Problem and expected behavior
When the event loop stalls longer than the quiet window (
quietMs, 25 ms by default) and then resumes, the settle's own wake-up timer and a trailing observation callback are both overdue. Due timers run in expiry order, so the earlier wake-up evaluates the journal before the trailing callback has appended its observation, decides the journal is quiet, and finalizes the capture. The trailing observation is dropped without any truncation flag.Smallest trigger (unit level, deterministic): a trailing 12 ms timer that appends to the journal, plus a 40 ms synchronous stall right after starting
settleProcessCaptureJournal(journal, 20, 200).Expected: the settle does not declare silence while callbacks that were already due are still queued; trailing observations delivered before the capture becomes immutable are retained.
Change and scope
settleProcessCaptureJournalnow awaitssetImmediate()after each quiet-window sleep, so timer and poll callbacks that were already due run before silence is judged.does not settle while a trailing observation is already due behind a stalled event loopinsrc/process/capture/ProcessHarness.test.ts.Intentionally not included: no change to quiet/max-wait defaults, no rework of capture finalization, no new APIs.
Contract and boundary impact
docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
Evidence is executed on the change branch and on the base revision.
src/process/capture/ProcessHarness.test.ts. The existingwaits for terminal observations delivered after the exit callbackstarted failing 1 in 5 standalone runs (and reliably in a 65-file run) on Windows; it passes 6/6 runs after this change.For evidence-bearing changes:
Validation performed
npm run test:focused -- src/process/capture/ProcessHarness.test.ts src/process/capture/ProcessCaptureLifecycle.test.ts— 55 passednpm run check:fast— typecheck and lint passed (also ran in the pre-push hook)npx oxfmt --check src/process/capture/ProcessHarness.test.ts src/process/capture/ProcessCaptureLifecycle.ts— cleanwin32platform paths, missing locally built native artifact). This change removes the one failure it targets.Compatibility, safety, and release
Review checklist
type(scope): outcome.AI disclosure: this change was drafted with AI assistance at my request, under my direction and review.