Skip to content

test(gateway): settle task events before registry cleanup - #153302

Merged
roboclaw-bot merged 4 commits into
mainfrom
upd/sessions-reset-registry-residue-flake
Sep 20, 2026
Merged

roboclaw-bot merged 4 commits into
mainfrom
upd/sessions-reset-registry-residue-flake

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #153147, #145335

What Problem This Solves

Gateway session-reset tests can fail with residual registry roots: tasks:agent-events when accepted task-event persistence finishes after reset and synchronous task reads.

User Impact

No user-visible behavior changes. This fixes a test-lifecycle race that can fail unrelated update PRs on contended CI workers.

Why This Change Was Made

The root belongs to a finite task-event persistence/publication batch, not the active continuation itself. The recently added teardown-only fence does not cover calls to the shared settlement helper inside test bodies: the untouched baseline still failed the terminal-capture and yielded-collector cases.

The shared persistence settlement helper now joins accepted events through the existing task-registry fence before checking the unchanged zero-root assertion. The reset fixture uses that same helper before restoring dependencies. Its existing same-turn test holds a real task-event publication across reset with an ordering gate and releases it when settlement captures the fence. No sleeps, new polling, weaker assertions, production seams, or production changes.

Evidence

The original Peter-authored head 2c2fe0163be562fce4867ae0291a53fb3ef5af84 is preserved through ordinary merges; no rebase or force push. Integrated head 5c6c17fe6e9b1220828c6a1feb8abf03efe5ab04 passed exact-head CI, including all 22 reset cases, 16 recursive-spawn cases, and the host-broker cleanup case.

Main subsequently made collector registration asynchronous and added three local fences, causing a merge conflict. The new integration retains every new await, keeps one shared settlement fence, and removes redundant local fences. The deterministic regression now arms its gate after registration and holds a real tool-progress event across reset. New integrated head: ab9ab92f828a0243dee78955f4e10c2d4eaa2afa. Current source base: 5f24bb2ae6770dafdd99d5db3c81e9a55756232d.

Fresh isolated conflict-resolution proof, with matched source, physical dependencies, and Node 24.19:

  • Removing only the shared fence reproduces the specific tasks:agent-events residual-root failure.
  • Restoring it passes the complete 22-case reset file in its original order.
  • Both changed files pass formatting. Complete changed-code checks passed, including all 23 core test typecheck shards, existing ratchets, dead-export scans, and lint.
  • Independent source review is P0–P2 clean. Fresh exact-head CI remains required after the integration push.

The canonical shared-helper repair here is the selected landing path; narrower duplicate #153412 will be closed only after this lands.

Original author evidence, before the integrations:

  • Untouched baseline: 20 passed, 2 failed, both with the same residual task-event root.
  • Deterministic pre-fix gate: the existing same-turn case failed with expected 1 to be +0 in the shared residual-root assertion.
  • Repaired full file: 3/3 runs passed, 22 tests per run (66 executions); two repetitions used OPENCLAW_VITEST_MAX_WORKERS=1.
  • Broader subagent-registry, session-reset, and task-event suites: 1,148 tests across 52 files passed with two workers.
  • node scripts/check-changed.mjs passed all selected checks, including core test types, unchanged ratchets, dead-export scans, and changed-file lint.
  • Fresh managed autoreview at P1: scoped-clean, no accepted/actionable findings.

Production delta: 0 lines. Tests and test support relative to the captured current main: +45/-15 lines (net +30).

Main fixture repair integration

The previous head failed the independent Doctor raw-database snapshot race. The canonical fixture repair is now on main. An ordinary merge of 63f5cc7103ceefceae339593fe7e5542c8affb50 produces 3a5ba320051ba95d93274b890bfe34a744b44fe6; both changed files and the entire two-file PR patch are byte-identical to the independently reviewed and tested ab9ab92 version. Contributor ancestry is preserved. Exact-head CI now passes on this integrated head, with a clean fresh ClawSweeper review.

Join accepted task-event publication in the shared persistence settlement helper before asserting zero roots. Pin the pending publication across same-turn reset with an ordering gate, covering settlement inside test bodies as well as teardown. Related: #153147, #145335.
@clawsweeper

clawsweeper Bot commented Sep 20, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 00:46
@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 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 2:58 AM ET / 06:58 UTC (Revision 5).

ClawSweeper review

What this changes

The PR makes shared subagent test cleanup await accepted task events and extends the session-reset regression to hold publication pending across reset.

Merge readiness

✅ Ready for maintainer review

Keep open as the selected, focused repair. Current main still lacks settlement in the shared helper, the latest integration preserves the previously reviewed changes, and no actionable correctness defect was found.

Priority: P2
Reviewed head: 3a5ba320051ba95d93274b890bfe34a744b44fe6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair using the existing settlement contract, with deterministic regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR changes only test settlement and regression coverage; no production or authority behavior changes require live proof. Its reported controlled regression exercises the real event and SQLite owners through the reset handler.
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 test settlement and regression coverage; no production or authority behavior changes require live proof. Its reported controlled regression exercises the real event and SQLite owners through the reset handler.
Evidence reviewed 7 items Introduced scope and review continuity: The pinned base-to-head diff matches the supplied introduction evidence and changes only test support and the reset test. Comparing both files with previously reviewed ab9ab92 produced no differences; git diff --check passed.
Existing event owner provides the required settlement: The fence snapshots accepted events for the current store and database identity, awaits their completion promises, and propagates failures. Event completion follows persistence and publication; synchronous consumption alone can leave that asynchronous tail pending. The helper retains its original zero-root assertion after joining this owner.
Deterministic regression preserves real operations: The existing same-turn test registers the collector before installing its gate, delegates snapshot loading to the real store, emits a tool-start event, and holds publication through the registered reset handler. It releases the gate when the shared helper captures the fence and retains finally cleanup plus all continuation and suppression assertions.
Findings None None.
Security None None.

How this fits together

Gateway session-reset tests exercise session and subagent cleanup against SQLite-backed task state. Their shared settlement helper must finish accepted background work before asserting that no work remains and releasing fixture resources.

flowchart TD
  A[Session reset test] --> B[Accepted task event]
  B --> C[SQLite write and publication]
  A --> D[Shared settlement helper]
  D --> E[Capture accepted event fence]
  C --> E
  E --> F[Assert zero residual work]
  F --> G[Release fixture resources]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +30. Total +30 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 45 15 +30
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 45 15 +30

Review metrics

None.

Root-cause cluster

Relationship: canonical
Canonical: #153302
Summary: The captured discussion selects this shared-helper repair for the accepted-event settlement race.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use the existing event owner's fence in shared test settlement, preserving strict residual-work assertions and deterministic reset coverage.

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

Yes, source establishes a deterministic path: hold accepted event publication across reset, then call the unfixed shared helper while its detached root remains active. The contributor reports the expected failure; this review did not execute it.

Is this the best way to solve the issue?

Yes. Reusing the existing owner-bound fence removes repeated local joins while retaining error propagation, original assertions, and real SQLite operations in the regression.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1b3f38e7e4ff.

Labels

Label justifications:

  • P2: This repairs a documented test-lifecycle race that disrupts validation without changing production behavior.
  • 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 test settlement and regression coverage; no production or authority behavior changes require live proof. Its reported controlled regression exercises the real event and SQLite owners through the reset handler.

Evidence

What I checked:

  • Introduced scope and review continuity: The pinned base-to-head diff matches the supplied introduction evidence and changes only test support and the reset test. Comparing both files with previously reviewed ab9ab92 produced no differences; git diff --check passed. (src/agents/subagents/registry/subagent-registry.persistence.test-support.ts:69, 3a5ba320051b)
  • Existing event owner provides the required settlement: The fence snapshots accepted events for the current store and database identity, awaits their completion promises, and propagates failures. Event completion follows persistence and publication; synchronous consumption alone can leave that asynchronous tail pending. The helper retains its original zero-root assertion after joining this owner. (src/tasks/task-registry-agent-events.ts:335, 3a5ba320051b)
  • Deterministic regression preserves real operations: The existing same-turn test registers the collector before installing its gate, delegates snapshot loading to the real store, emits a tool-start event, and holds publication through the registered reset handler. It releases the gate when the shared helper captures the fence and retains finally cleanup plus all continuation and suppression assertions. (src/gateway/server-methods/sessions-reset-subagent-cleanup.test.ts:334, 3a5ba320051b)
  • Current-main and release necessity check: Fetched main still has no task-event fence inside the shared helper, although the reset fixture already contains local fences. The v2026.9.5 helper also lacks the shared fence. Thus the central consolidation and deterministic regression remain distinct work. (src/agents/subagents/registry/subagent-registry.persistence.test-support.ts:67, 1b3f38e7e4ff)
  • Validation evidence and inspection limits: The captured PR body reports controlled failure without the fence and success for the complete 22-case reset file after restoration. GitHub confirms the earlier integrated-head run 35488796475 succeeded. The linked conflict-resolution Testbox run 35490698893 is cancelled; its raw logs redirected to a host blocked by this review environment, so those reported results were not independently verified. No tests were executed during this read-only review. (5c6c17fe6e9b)
  • Related work supports retaining this landing path: The captured body selects this shared-helper repair over the narrower open fix(test): await task events before session cleanup assertions #153412. The broader open fix: stabilize chat interactions and async tests #153277 overlaps settlement work but includes separate changes. Merged fix: stabilize database lifecycle test fixtures #153479 repairs different database fixtures and does not replace this change.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-20T00:52:57.367Z sha 2c2fe01 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T04:24:35.088Z sha 5c6c17f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T04:54:40.734Z sha 5c6c17f :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T05:35:15.106Z sha ab9ab92 :: needs maintainer review before merge. :: none

steipete added a commit that referenced this pull request Sep 20, 2026
Merge main while preserving virtualized rail markers and the same-frame navigation fix. Replace the redundant delayed reset fixture with the deterministic accepted-event ordering from PR #153302.
roboclaw-bot and others added 2 commits September 20, 2026 05:29
Preserve asynchronous collector registration and the shared settlement fence.
Use a real post-registration progress event for the deterministic regression.

Co-authored-by: steipete <[email protected]>
Preserve the reviewed reset settlement delta and contributor ancestry; incorporate the landed Doctor, artifact, and model-runtime fixture repairs.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit e5f7c62 into main Sep 20, 2026
179 of 180 checks passed
@roboclaw-bot
roboclaw-bot deleted the upd/sessions-reset-registry-residue-flake branch September 20, 2026 07:20
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…53302)

Join accepted task-event publication in the shared persistence settlement helper before asserting zero roots. Pin the pending publication across same-turn reset with an ordering gate, covering settlement inside test bodies as well as teardown. Related: openclaw#153147, openclaw#145335.

Co-authored-by: steipete <[email protected]>
roboclaw-bot added a commit to jjjhenriksen/openclaw that referenced this pull request Sep 21, 2026
Refresh the reviewed contributor branch with main repairs for the observed task-event settlement CI failure (openclaw#153302), preserving contributor ancestry.

Co-authored-by: Patrick-Erichsen <[email protected]>
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

2 participants