Repository navigation
refactor: settle remaining single-deadline races through settleWithin - #4788
Conversation
Seven sites outside the daemon still raced work against a hand-rolled timer. Two of them never cleared the timer: the screen-recording stop wait and the snapshot bridge exit wait kept it armed for the full budget after the process had already exited. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
|
The change in 584e2ac looks right, but one test no longer guards what it says it guards. CI is green with 14 checks and none failing, and there are no conflicts. src/cli/process-exit.test.ts:4 mocks only Not blocking, take or leave: the PR body gives the R88 count as 38 -> 31, but the rule's own count (the "remaining" number Once the process-exit test discriminates between the two arms again, this is ready to merge. |
The test still mocked sleep, which exitAfterFlush no longer calls, so the drain case would have passed on the real 2 s deadline. It now fails when the drain wait is removed, and the never-drains case no longer spends 2 s. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Fixed at Test. PR body. Corrected to 41 → 34, and to three sites that left a timer armed, including the removed capture-fact-grace.ts:12 and recording/video.ts:178. Not in this PR. Both already clear their timer in |
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
This PR is ready at 3581b99. The process-exit test now runs on fake timers: the drain case advances to just short of Not blocking: the PR body's R88 count reads 38 -> 31, while the rule itself prints 41 -> 34 because it also counts |
* origin/main: (70 commits) refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (callstack#4774) fix(android): require acknowledgements for test IME typing (callstack#4722) feat(scroll): add scroll refresh for pull-to-refresh (callstack#4770) refactor(host-kit): add request Scope and use it for the wait capture deadline (callstack#4794) fix(android): let permission all change nothing on an app that declares no permissions (callstack#4796) fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (callstack#4797) fix(host-kit): accept a group-writable script directory the user owns (callstack#4799) fix(cli): escape control characters at the CLI's stdout and stderr writes (callstack#4778) fix(audit): do not report rows under a persistent bar that scrolling reveals (callstack#4775) fix(daemon): refuse an unsafe state directory before first use (callstack#4783) refactor: settle remaining single-deadline races through settleWithin (callstack#4788) refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet (callstack#4766) fix(android): authenticate and bound persistent snapshot helper sessions (callstack#4729) fix(daemon): bound upload ingress and finalization (callstack#4721) chore(gates): ratchet wire-published reason literals by value (R89) (callstack#4779) feat(audit): evaluate role-less clickable views on Android (callstack#4780) fix(mutation): keep umask-setting tests out of Stryker's thread pool (callstack#4785) feat(audit): report controls that share one accessible name (callstack#4771) fix(contracts): pair open runtime hints with their apply operation (callstack#4754) refactor(daemon): report startup progress over the launch channel instead of marker files (callstack#4777) ...
The primitive sat in retry.ts, so a caller that wanted only the deadline race also evaluated the retry policy, the deadline class, the diagnostics edge and the kernel error vocabulary. That is why #4788 reverted the capture-kit grace wait and both perf-xctrace waits: the eager-closure budget went up. settleWithin and its outcome type now live in host-kit/settle-within, which imports nothing. retry.ts re-exports them, so every importer of host-kit/retry keeps working and its closure is unchanged. Both migrated sites import the leaf. The capture-kit grace wait reaches it through the first call, which keeps that facade's closure at one module. The perf waits previously left the 45 s grace timer armed for its whole budget after xctrace had exited; the primitive clears it on every settle path. Behaviour is otherwise the same.
#4816) * refactor(host-kit): move settleWithin to a dependency-free leaf module The primitive sat in retry.ts, so a caller that wanted only the deadline race also evaluated the retry policy, the deadline class, the diagnostics edge and the kernel error vocabulary. That is why #4788 reverted the capture-kit grace wait and both perf-xctrace waits: the eager-closure budget went up. settleWithin and its outcome type now live in host-kit/settle-within, which imports nothing. retry.ts re-exports them, so every importer of host-kit/retry keeps working and its closure is unchanged. Both migrated sites import the leaf. The capture-kit grace wait reaches it through the first call, which keeps that facade's closure at one module. The perf waits previously left the 45 s grace timer armed for its whole budget after xctrace had exited; the primitive clears it on every settle path. Behaviour is otherwise the same. * chore(gates): name the settle-within subpath in the export surface and race guidance R11's host-kit export-surface enumeration lists the new subpath, and R88's guidance names the leaf as the deadline primitive's home. * refactor: import settleWithin from its leaf subpath and settle the validator compile wait through it Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Summary
Finishes the
settleWithinmigration that #4766 started in the daemon. Stacked on #4766; retarget tomainonce it merges.Seven more sites raced work against a hand-rolled timer and now settle through
settleWithin(@agent-device/host-kit/retry). Three of them left a timer armed for the full budget after the work had settled: the screen-recording stop wait (settlesWithin), the snapshot bridge exit wait (waitForProcess), and the CLI exit flush (sleep(FLUSH_TIMEOUT_MS)).Promise.race(count (R88): 41 → 34.provider-limrun(no host-kit dependency).capture-fact-grace.tsandperf-xctrace.ts. Importinghost-kit/retrythere grows a startup closure and the eager-closure budget refuses it.Validation
Tested head: 3581b99 (base 844e719). Device run and
vitest relatedwere at 584e2ac; the later commit changes onlyprocess-exit.test.ts, which fails when the drain wait is removed.pnpm typecheck: pass.vitest relatedon the 7 files: 1,230 files, 12,213 tests pass (the eager-closure budget passes after the two reverts).scripts/layering/check.ts: OK, R88 34 remaining.open com.apple.Preferences,record start --scope device --hide-touches,record stop(MP4 exported, 41 kB),snapshot -i,close,daemon stop(graceful). All succeeded.Risk: the abort-rollback path in the simulator recording host has unit coverage only.
🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.