Skip to content

fix: settle task notification fixture lifetimes - #157589

Merged
steipete merged 2 commits into
mainfrom
codex/cron-delivery-fixture-settlement-20260924
Sep 24, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/cron-delivery-fixture-settlement-20260924

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Related: #156547

What Problem This Solves

Fixes test fixtures releasing their task stores while notification cleanup still holds a Gateway root, which can contaminate a later root-count assertion.

User Impact

No user-visible behavior changes. This repairs test lifetime ownership while preserving production's early delivery result, the cron assertion's exact count, and independently held work.

Why This Change Was Made

The existing fixture joined a delivery's result, which intentionally precedes its enclosing async scope's cleanup. It now joins only the actual scopes belonging to captured deliveries. A shared passive observer lets overlapping fixtures retain their observations until their last subscriber finishes. The one test that deliberately checks the early result uses an explicit result-only wait; teardown still joins the complete lifetime.

Evidence

  • A held-cleanup control in the original cron case reproduced the exact count failure and identified the third root as tasks:delivery. The permanent terminal/state regression failed with the old fixture and passes with the repair, including an unrelated real scope that remains held throughout settlement.
  • Before main integration, focused validation passed 82 cases across eight affected files, all nine affected TypeScript graphs, selected guards, formatting, lint, and the line-cap ratchet. The final lineage cleanup change additionally passed all 16 lineage cases.
  • Integrated fixed main 5048811d36871c898badf94c6174287c0ab661c2 to resolve the task-history import conflict, preserving its new transcript coverage. The normal frozen install's complete application lock matched, and the resulting eight-file focused run passed all 91 cases with clean cleanup in 418.64 seconds.
  • The complete selected check:changed run then passed on the integrated source, including all nine TypeScript graphs, formatting, lint, and every selected guard; no checks were skipped.
  • The original repair passed independent review through P2. The integration review reported hypothetical nested delivery-capture recursion; both parent-source inspection and an independent call-site audit showed the same pattern already exists on main and this patch introduces no nested captures. That finding is rejected as inherited and outside the demonstrated repair; the distinct overlapping scope observers are covered by the regression.
  • The original 110-file CI selector order and effective eight-worker policy were replayed before editing. The unforced target passed locally; that baseline replay had seven other test failures and six teardown errors. The original CI's third-root identity therefore remains unproven; this change fixes the independently demonstrated fixture defect rather than claiming statistical elimination of that CI failure.
  • Local proof used Node 24.21 on macOS; the reported CI failure used Node 24.19 on Linux. This test-only change does not require a product build.

Measured file costs

Pre-integration single-worker pnpm test <file> --maxWorkers=1 process-wall measurements include maintained worker preparation. Task history measured 78.91 seconds before and 156.28 seconds after; compilation/preparation dominated, so no performance improvement is claimed. Cron, delivery lifetime, lineage, and state-notification runs measured 94.46, 61.04, 68.04, and 96.82 seconds respectively. All 23 state-notification cases passed with clean command completion.

All five publication tests passed in an 83.83-second invocation, but the command then failed during generated-worker-cache removal with ENOTEMPTY. Only a late .DS_Store remained and no holder was found after join; that invocation is not reported as a clean command. The earlier focused publication run passed normally. The same cleanup error was retained from the baseline replay and is outside this fixture patch.

Join captured notification cleanup before root assertions and fixture teardown. Preserve result-only publication checks and share scope observation across fixture subscribers.
@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.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 5:32 PM ET / 21:32 UTC (Revision 2).

ClawSweeper review

What this changes

The branch makes task-notification test fixtures wait for captured delivery cleanup and updates related cron, task, subagent, and Gateway tests.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main and the latest release still have the fixture that waits only for delivery results; the branch addresses a concrete test isolation defect, and review found no actionable introduced bug.

Priority: P2
Reviewed head: 79045554551932479da46c6620f349aa8170a3f6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair has relevant before/after fixture evidence and no identified correctness or security defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body reports a before/after held-cleanup control through the actual fixture, Gateway admission, and detached scope, plus 91 passing focused cases on the integrated head; this directly exercises the changed test behavior. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports a before/after held-cleanup control through the actual fixture, Gateway admission, and detached scope, plus 91 passing focused cases on the integrated head; this directly exercises the changed test behavior. No stored-data contract changes.
Evidence reviewed 8 items Introduced fixture change: The pinned base-to-head diff adds a shared scope observer and changes settlement to join only scopes whose signals belong to captured deliveries.
Production lifetime boundary: Detached work resolves the caller's result before draining its AsyncWorkScope and releasing the retained Gateway root, supporting the fixture's distinction between result and full lifetime.
Focused regression: The added case holds delivery cleanup, checks that settlement remains pending, then verifies settlement releases only the delivery root while an unrelated root stays held.
Findings None None.
Security None None.

How this fits together

Task notifications can finish their delivery result before their detached Gateway work scope releases its root. Test fixtures must wait for that cleanup before tearing down task state or asserting root counts.

flowchart LR
  A[Task or cron event] --> B[Notification delivery]
  B --> C[Detached Gateway scope]
  C --> D[Delivery result]
  C --> E[Cleanup and root release]
  D --> F[Test fixture]
  E --> F
  F --> G[State teardown and root assertion]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +126. Total +126 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 9 161 35 +126
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 161 35 +126

Review metrics

Metric Value Why it matters
Code ownership delta production +0; tests and test support +126 net The added code stays within fixture ownership and the focused lifecycle regression.

Technical review

Best possible solution:

Keep fixture settlement tied to captured delivery scope lifetimes, while preserving a separate result-only wait for tests that intentionally inspect early publication.

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

Yes, from source: the old fixture joins the delivery result while detached scope cleanup can still hold a Gateway root. The PR body reports a held-cleanup control and a before/after regression, though this read-only review did not run them.

Is this the best way to solve the issue?

Yes. Joining only the captured delivery scopes addresses fixture teardown without changing production delivery timing or waiting on unrelated roots.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 25f07e880f5d.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a before/after held-cleanup control through the actual fixture, Gateway admission, and detached scope, plus 91 passing focused cases on the integrated head; this directly exercises the changed test behavior. No stored-data contract changes.

Label justifications:

  • P2: This is a bounded test reliability repair with no reported user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body reports a before/after held-cleanup control through the actual fixture, Gateway admission, and detached scope, plus 91 passing focused cases on the integrated head; this directly exercises the changed test behavior. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a before/after held-cleanup control through the actual fixture, Gateway admission, and detached scope, plus 91 passing focused cases on the integrated head; this directly exercises the changed test behavior. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Dallin Romney: 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-24T21:05:11.476Z sha 493f57c :: needs changes before merge. :: none

Preserve main's expanded task-history coverage while composing the shared
scope observer import. Keep the notification fixture lifetime repair scoped
to its original nine test and support files.
@steipete
steipete marked this pull request as ready for review September 24, 2026 21:22
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S labels Sep 24, 2026
@steipete
steipete enabled auto-merge (squash) September 24, 2026 21:29
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 24, 2026
@steipete
steipete merged commit f8e5e7b into main Sep 24, 2026
192 of 197 checks passed
@steipete
steipete deleted the codex/cron-delivery-fixture-settlement-20260924 branch September 24, 2026 21:45
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
Join captured notification cleanup before root assertions and fixture teardown. Preserve result-only publication checks and share scope observation across fixture subscribers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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