Skip to content

test(infra): synchronize approval shutdown races at callback entry - #134284

Merged
steipete merged 1 commit into
mainfrom
codex/test-approval-shutdown-phase-gates
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-approval-shutdown-phase-gates

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Three approval shutdown race tests use two zero-delay timers each to guess when delivery or binding has reached its suspended phase. Scheduler turns do not establish that phase.

Why This Change Was Made

Signal entry directly from the controlled delivery or binding callback, then await that signal before stopping the runtime. Shared deferred helpers also replace three handwritten promise holders. The existing one-second test helper bounds a missing entry signal.

User Impact

More precise shutdown-race proof with six success-path timer callbacks removed. The same cancellation, unbinding, stopped-state and in-flight completion assertions remain; production behavior is unchanged.

Evidence

  • node scripts/run-vitest.mjs src/infra/approval-handler-runtime.test.ts src/infra/approval-native-runtime.test.ts passed all 19 tests before and after.
  • Full changed-file checks, formatting, diff checks and structured Codex autoreview passed.
  • Reviewed the handler, native adapter, bootstrap, execution-channel caller and deferred/timeout helpers. Each signal is emitted immediately before the callback awaits its release gate.
  • Production +0/-0. No elapsed-time speedup is claimed.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 16:49
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:56 PM ET / 16:56 UTC.

ClawSweeper review

What this changes

This test-only PR makes three approval-shutdown race tests wait for delivery or binding callbacks to enter their controlled paused phase before stopping the runtime.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. This focused maintainer-authored test PR replaces nondeterministic scheduler waits with callback-entry barriers; the current main test still has the timer-based version, and no functional or security defect was found in the introduced change.

Priority: P3
Reviewed head: ce436dfc11766a28dff0226fe546c1b701ba2f7e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only patch with deterministic phase control and no identified correctness or security concern.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR changes only internal tests and no user-visible runtime behavior; ordinary external real-behavior proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR changes only internal tests and no user-visible runtime behavior; ordinary external real-behavior proof is not applicable.
Evidence reviewed 7 items Introduced test synchronization: The PR-introduced hunk replaces two timer turns with an explicit deferred signal emitted immediately before each controlled callback waits, so shutdown begins only after the intended race phase is reached.
Current-main comparison: Current main still uses two zero-delay timers before each shutdown assertion; the central improvement is therefore not already implemented there.
Approval cleanup owner: The adapter checks the stopped state after delivery and after binding, then calls cancellation or unbinding before returning; the revised tests target those exact branches without changing production behavior.
Findings None None.
Security None None.

How this fits together

Approval handlers deliver pending approval prompts through a channel adapter, optionally bind interactions, and clean up entries when the approval runtime stops. The changed tests exercise that delivery/binding-to-shutdown boundary and assert cancellation or unbinding afterward.

flowchart LR
  Request[Approval request] --> Deliver[Deliver pending prompt]
  Deliver --> Bind[Bind interaction]
  Bind --> Active[Track active entry]
  Stop[Runtime stop] --> Cleanup[Cancel or unbind]
  Active --> Cleanup
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: this is an active focused maintainer PR with no actionable review finding.
Agent review details

Security

None.

PR surface

Tests -19. Total -19 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 20 39 -19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 20 39 -19

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +20/-39 The entire change is in one existing test file, so it improves race-test reliability without changing shipped runtime behavior.

Technical review

Best possible solution:

Land the deterministic callback-entry barriers while keeping the existing delivery, cancellation, and unbinding assertions as the approval cleanup contract.

Do we have a high-confidence way to reproduce the issue?

Not applicable: the central problem is nondeterministic test synchronization, and current main visibly uses scheduler delays where this PR uses callback-entry signals.

Is this the best way to solve the issue?

Yes. Signaling at the controlled callback boundary directly proves the desired race phase, unlike elapsed scheduler turns, while preserving the existing cleanup assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 194f06914102.

Labels

Label changes:

  • add P3: This is a bounded internal test-reliability improvement with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR changes only internal tests and no user-visible runtime behavior; ordinary external real-behavior proof is not applicable.

Label justifications:

  • P3: This is a bounded internal test-reliability improvement with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR changes only internal tests and no user-visible runtime behavior; ordinary external real-behavior proof is not applicable.

Evidence

What I checked:

  • Introduced test synchronization: The PR-introduced hunk replaces two timer turns with an explicit deferred signal emitted immediately before each controlled callback waits, so shutdown begins only after the intended race phase is reached. (src/infra/approval-handler-runtime.test.ts:464, ce436dfc1176)
  • Current-main comparison: Current main still uses two zero-delay timers before each shutdown assertion; the central improvement is therefore not already implemented there. (src/infra/approval-handler-runtime.test.ts:465, 194f06914102)
  • Approval cleanup owner: The adapter checks the stopped state after delivery and after binding, then calls cancellation or unbinding before returning; the revised tests target those exact branches without changing production behavior. (src/infra/approval-handler-runtime.ts:528, 194f06914102)
  • Caller and lifecycle boundary: The channel runtime awaits approval delivery, while stop marks the runtime inactive and invokes stopped cleanup; callback-entry signals correctly synchronize the test with that await boundary. (src/infra/exec-approval-channel-runtime.ts:167, ce436dfc1176)
  • Shared test-helper contract: The imported helper supplies a typed deferred promise and clears its timeout in a finally block, providing a bounded failure rather than scheduler guessing. (test/helpers/promise.ts:3, ce436dfc1176)
  • History routing: Recent history associates the approval runtime test path with steipete; the available blame boundary cannot establish original feature introduction, so routing remains conservative. (src/infra/approval-handler-runtime.ts:540, c09f1360bbe4)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer review is complete under the standing instruction to land this test-cleanup batch. The latest ClawSweeper review has no actionable findings or rank-up moves. Exact-head CI run 33416230174 passed.

All three races now establish callback entry immediately before the controlled suspension. Shutdown, cancellation/unbinding and final in-flight completion assertions remain. All 19 focused and native-adapter tests passed before and after; full changed-file checks and structured Codex autoreview passed. Production +0/-0; tests +20/-39. Proceeding through the native merge workflow.

@steipete
steipete merged commit d147d40 into main Aug 31, 2026
182 checks passed
@steipete
steipete deleted the codex/test-approval-shutdown-phase-gates branch August 31, 2026 17:02
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant