Repository navigation
refactor(session-signals): move adoption and cleanup into the worker - #165681
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 5, 2026, 3:17 PM ET / 19:17 UTC (Revision 3). ClawSweeper reviewWhat this changesMoves session-adoption recording and reset/delete signal cleanup into the existing database worker, with awaited callers and updated lifecycle tests and documentation. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still performs the targeted signal writes synchronously. The prior fixture finding is resolved, exact-head CI succeeded, and no new actionable defect was found. Priority: P2 Review scores
Verification
How this fits togetherSession signals record adoption and lifecycle changes in OpenClaw’s shared database. Watchers and prompt preparation consume these records; reset and deletion remove the corresponding watch state. flowchart TD
A[Catalog adoption] --> C[Session signal owner]
B[Session reset or deletion] --> C
C --> D[Captured database admission]
D --> E[Shared database worker]
E --> F[Signal records and watch cursors]
F --> G[Watcher notices and prompt reads]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +17, Tests +251, Docs +4, Other -5. Total +267 across 28 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep signal mutations with the existing shared-state worker while preserving lifecycle settlement, current database admission, and released compatibility surfaces. Do we have a high-confidence way to reproduce the issue? Not applicable to this refactor; current-main source confirms the synchronous operations being migrated. This read-only review did not execute tests. Is this the best way to solve the issue? Yes: reusing the existing worker and awaiting its results is a focused ownership cutover that preserves existing cleanup scope and lifecycle ordering. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 11d3d04a1279. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review Fixed the inventory fixture finding in e4df962. All four recorder calls are classified as worker-owned; anotherRecorder remains T1 and unrelated-runtime growth is still rejected. Five baseline runs passed and five original-head runs failed; the corrected focused suite, root test typechecks, database-worker ratchet, and fresh full-candidate P2 autoreview passed. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#165681) * refactor(session-signals): move adoption and cleanup into the worker * test(state): align ratchet fixture with worker-owned recorder
What Problem This Solves
Session adoption and reset/delete signal cleanup still ran SQLite transactions on the Gateway thread, despite an existing shared-state signal worker.
Why This Change Was Made
Route both catalog adoption producers through the awaited recorder and move signal cleanup into that same worker. Reset and deletion retain their existing lifecycle fences and post-commit ordering. The worker checks the captured database authority at transaction and commit admission; accepted work settles before teardown. Ambient-watch read invalidation remains held across overlapping pruning and cleanup. Remove the superseded synchronous recorder and migrate its fixtures.
User Impact
No user-facing API, schema, stored format, retention, or configuration change. The 30-day/50,000-event retention policy and reset/delete scope remain unchanged. The signal owner retires 10 counted T1 sites: 876 → 866 against
bb3a8a9ac304fbec8367fd64d9644bb12d956e9c. Production delta is +120/−103, net +17 (223 changed lines). Inventory tooling changes separately by +4/−6 lines.Upstream-link lifecycle is a pending follow-up awaiting an SDK surface-budget decision. Its released synchronous APIs and deletion order remain unchanged. The released synchronous ambient-watch reader also remains compatibility debt. This PR adds no SDK exports, deprecations, budgets, or environment-variable names.
Evidence
--maxWorkers=1; 320.04 s wrapper wall time, including 62.50 s worker compilation. The real worker tests cover retained scope, notices, foreign commits, transaction/commit refusal, and bounded retention. Their database lifetime checks require admitted workers; telemetry and cursor-batch fixtures now route to the host-owned project.reachablechanges reduce to two whole-module*sections: the existing indexed namespace type inAgentHarnessToolSurfaceOptionstriggers the renderer's recursive declaration fallback. Source audit confirms no public path exposes the removed recorder, cleanup signatures, or new private worker command.--maxWorkers=1.2026.9.8→ same-version candidate, update statusfinished,readyz=200, running version verified, durable session preserved, and expected incognito restart loss/artifact checks passed. The updater took 402.76 s; package preparation plus the cell took 1,220.92 s. The verified source capsule treeb35b1d659372b377fd49fe429e8054a0358274c5exactly matches commit6bedecbc7d71c. The lease was released. Testbox first stalled; an initial AWS cold-build attempt exhausted the outer envelope, so the successful run used the supported prebuilt-tarball input with the unchanged normal cell deadline.check-changedand full core lint expose inherited failures in unchanged base files: unusedsrc/plugins/config-policy.ts:24exportresolvePolicyPluginActivationState, seven existing re-exports insrc/media-understanding/defaults.ts, andsrc/gateway/server-methods.authorization.test.tsat 1,067 counted lines against its 1,000-line limit. All three files are byte-identical to the pinned base. The signal-owned unused export and cursor-test shadowing diagnostics were fixed. Other required checks passed, including core/test typechecks, script lint, schema/media/runtime-sidecar/import/auth guards; changed-file core lint passed in 107.57 s. Fullcheck-changedran for 747.50 s and stopped at those inherited dead exports; full core lint also reported the inherited authorization-test line cap. No guard is disabled. These are retained local baseline limitations; exact-head GitHub checks remain required for landing.6bedecbc7d71consumed 12,113 aggregate job seconds. Its only failing test was the inventory fixture described below; the corrected head subsequently passed its own CI gates.Direct overlap: #165521 changes the event kernel/tests. #162433 covers separate umbrella ownership work. Adjacent session-authority work (#165028, #165370, #165552, #165205) remains independent. The PR keeps changes within the signal owner and its callers.
Reproducible local test selections and wall times
These selections ran through
pnpm test ... --maxWorkers=1.src/sessions/session-state-events.{test,worker-boundary.test,cursor-batch.test,worker-control.test}.ts,src/agents/watched-sessions-prompt.test.ts,src/infra/telemetry.test.tssrc/gateway/server-methods/session-catalog{,-adoption,-gateway-copy}.test.ts,src/gateway/server.sessions.reset-acp-timeout.test.ts,src/gateway/server-lifecycle.catalog-write.test.ts, signal worker boundary,test/scripts/runtime-process-build-graph.test.ts,src/state/openclaw-state.worker.imports.test.ts,src/auto-reply/reply/get-reply.imports.test.tssrc/gateway/server-lifecycle.catalog-write.test.ts,src/gateway/server.sessions.delete-lifecycle.test.ts,src/gateway/server.sessions.reset-concurrency.test.ts,src/agents/subagents/spawn/subagent-spawn.preparation-authority.test.tssrc/sessions/session-state-events.cursor-batch.test.tsafter the binding renameThe long suites use real database workers and existing Gateway lifecycle fixtures to exercise foreign-commit authority, SQL-thread ownership, retention, reset/delete refusal ordering, and actual server-close settlement. The new catalog case reuses mocks; the close regression extends an existing server fixture rather than adding another boot. A 61-importer routing audit found no additional routing defect; existing Gateway and agents-support suites already use forks.
Landing correction and verification
ClawSweeper and CI identified a stale inventory regression expectation: the recorder is now wholly worker-owned, so the mixed-operation fixture must count all four recorder calls as worker calls. The correction changes only
test/scripts/check-database-worker-ratchet.test.ts; it explicitly retainsanotherRecorderas T1 and leaves unrelated-runtime growth rejection intact.The original fixture failed identically in five single-worker runs at
6bedecbc7d71and passed in five runs at merge basebb3a8a9ac304f. After correction,pnpm test test/scripts/check-database-worker-ratchet.test.ts --maxWorkers=1passed both tests in 10.48 s wrapper wall time. Root test typechecks, focused formatting/lint, the database-worker ratchet, andgit diff --checkpassed. A fresh P2 Codex autoreview of the complete candidate was scoped-clean with no actionable findings.Released SDK audit against
v2026.9.8: the removed recorder and async reset/delete helpers are internal; neither plugin SDK exports norapi.runtimeexposes them. The released ambient reader remains unchanged. An independent importer audit confirmed the worker-host routing and the existing runtime-process/import-closure proof; this correction adds no production import.The initial PR-context failure used the earlier
Problemheading. The corrected head passed the PR-context check with the current authored sections.Final head
e4df9621e9af69ba69bf071f1127ff78a3a01880: CI run 37359295318 completed successfully (11,676 aggregate job seconds; pinned watcher GREEN). ClawSweeper revision 2 completed on that head with no actionable findings and confirmed the prior fixture finding resolved. No CI rerun or inherited-failure bypass was used.