Skip to content

fix: prevent deleted session groups from reappearing - #155288

Merged
roboclaw-bot merged 4 commits into
mainfrom
openclaw/session-groups-active-registration-custody
Sep 23, 2026
Merged

roboclaw-bot merged 4 commits into
mainfrom
openclaw/session-groups-active-registration-custody

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #142863

Reworked directly on main, replacing the retained foundation from #153828. This no longer depends on the defaults PR or the held migration drafts.

What Problem This Solves

Fixes deleted groups reappearing when deletion overtakes session creation or category assignment before catalog registration settles.

User Impact

Group deletion waits for earlier committed session writes and their registration. Bookkeeping failures warn and reload the catalog instead of falsely reporting that an already-saved session write failed. Reassigning the same category can repair missing bookkeeping. Session updates retain their place in the writer queue, and closing a session database no longer hangs behind revoked cleanup waiting for that same writer. Already-admitted writes still settle before close.

The catalog remains global. No agent-owned-group activation, schema change, new configuration, public RPC change, or Gateway deployment is included. Fresh creation remains isolated from unrelated archive-export failures; existing-session and alias adoption retain their historical retry and visible failure behavior. Canonical bytes, retention protection and explicit recovery are preserved.

Why This Change Was Made

Keep the original physical writer through commit settlement, existing publication and registration, with live authority checked before committing and installing results. Remove late duplicate registration and the redundant replacement wrapper.

Touched durable access now uses the existing history reader, agent executor and shared-state reader. Supported aliases retain canonical replacement and native deletion custody. CI-exposed custom-store and first-creation identity defects are repaired at those existing owners; no parallel registry, writer or archive-retry manager is introduced.

Evidence

  • Actual registered create/patch versus group-delete races demonstrate the original defect and its repair. Proof includes close joining, physical-path/environment changes, transaction/commit revocation, uncertain publication, native rollback and rejected/no-write suppression.

  • Unchanged guarded SDK suite: 24/24. Creation/replacement/archive owners: 36/36. Registered Gateway race/siblings: 14/14. Reclamation repair: 73/73, including the original board and Zalouser failures. These selections overlap earlier proof and are not combined into a larger total.

  • Historical adoption-triggered archive retry is restored. Real collision/recovery fixtures verify exact bytes/hash, attempts, retained transcript/metadata, publication ordering and zero host data SQL. Fresh creation and generic recovery controls remain intact.

  • Static dependency-cycle and test-inventory defects found by hosted CI are corrected. Architecture checks pass; both original routing suites pass 501/501.

  • Fresh independent review (R3) of the complete revised candidate is scoped-clean through P2, with no actionable findings. It reviewed source/evidence, not an independent execution of the tests. The subsequent mechanical removal of an unreachable snapshot wrapper migrated its three test callers to the existing connection-bound kernel; final snapshot/type/lint/export/build checks cover that cutover.

  • A subsequent hosted-CI teardown race is repaired: read-admission retirement no longer loses an already-acquired exact lease receipt needed after native exit. A real-worker regression fails on the published predecessor and passes with the base owner and repair; this substitutes one owner, not a full baseline. 109 focused tests pass, including original failing consumers, with core/test types and typed lint clean. Fresh independent R4 review of this two-file correction is scoped-clean through P2; it did not rerun tests.

  • The next hosted run exposed replacement callbacks losing their FIFO turn and a planning-close deadlock. Exact database locators now reserve the existing queue before worker-owned schema discovery; revocation removes only pending maintenance admissions. Unchanged original cases reproduce RED and pass after repair. Final-source ownership proof is 93/93, with production/test types, typed lint, formatting and delta ratchets clean. Independent R5 review of the 11-file correction is scoped-clean through P2; tests were not independently rerun by the reviewer. A separate final integration applied the frozen repair to the actual failing CI merge 27bf437c, including its main-side worker-runtime changes: the original config lane passed 90 files / 1,654 tests in 189.63s, on Node 24.19.0 with two workers and retries disabled. This is local exact-merge integration, not a substitute for current-head hosted CI.

Current-head Claw review (c3860f0, September 23 at 16:52 UTC): no actionable introduced or security defect was found. Its explicit source assessment withdraws the prior generic migration-proof request and confirms no schema, serialized representation, retention-policy or public-RPC change. The generated checklist still repeats that withdrawn request; it is not an unresolved source finding. Existing-state alias, archive-recovery, authority and lease-cleanup evidence above remains applicable. Current-head hosted CI and native merge gates remain required.

Qualified integration baseline (11cc34f): production and all source core-test type graphs, revised-candidate typed lint, all three canonical unused-export scans, and canonical build passed. After the final mechanical cutover, creation snapshots passed 13/13, production/session-test types and two-path typed lint passed, all three unused-export scans reported zero entries, and the final build passed in 225s. All 48 source hashes stayed unchanged through that baseline qualification and publication. The subsequent seven-line production receipt-lifetime correction and its regression have separate focused qualification above; at that stage the other 46 paths were unchanged. The later FIFO/cancellation correction has separate proof above; no fresh full local build is claimed for it. Current-head hosted CI remains required.

Retained limitation: the earlier full-tree core lint scan failed on unchanged src/cron/service/timer.test.ts (1,022 counted lines versus its 1,000-line allowance). Its Git blob is identical to the selected main base. No allowance was raised; the full changed-check wrapper is not claimed green. Earlier local proof used Node 26 versus hosted Node 24.19. New FIFO/cancellation reproduction and qualification use verified Node 24.19.0. No live-Gateway, native-platform or published-driver upgrade proof is claimed.

Unresolved timing evidence: hosted predecessor CI observed dirty session describe at 124.39ms against its unchanged 100ms assertion (zero transcript reads; 1,995 rows still pending). One original-order attempt stopped earlier in the separate cron process on six real-HTTP delivery cases, including a 120s timeout (1,567 passed); those failures remain unexplained and were not retried. The still-unexercised 89-selector Gateway plan was then run once, with unchanged assertions: describe 32.62ms, dirty describe 15.25ms, zero transcript reads and 1,983 rows pending. The Gateway shard itself was not green: 29 failed, 974 passed, one skipped and two unhandled errors; HTTP cases observed the host secret-egress proxy refusal/502 response rather than their expected local endpoint payload. That transport boundary was not bypassed. The latency case is a non-reproduction, not a timing fix or CI waiver. Local Node 26 differs from hosted Node 24.19; no timing limit was changed.

Regression attribution, review dispositions and measured costs

The custom-store transcript failure came from reinterpreting a prepared physical database as a logical store. Reading its already-resolved owner fixes the producer; transcript guards are unchanged.

The original board deletion failure directly showed an unresolved host shared-state identity versus the worker's first-created physical identity. Restoring only the baseline deletion lookup made the unchanged test pass. The repair publishes first creation through the canonical admission owner before unchanged receipt checks, and settles errors through existing failure/termination handling. This was a narrow counterfactual, not a whole-baseline run. Board 22/22, Zalouser 5/5, reclamation custody 33/33, shared-state lifecycle 11/11 and the extended owner file 2/2 pass.

The earlier Signal-alias P2 was reproduced at the actual admitted entry point and repaired. R2 alleged a newly missing original-snapshot CAS across an asynchronous creation callback. A deterministic comparison with the old entry/projection owners showed the same low-level lost-update behavior in both; newer persisted ownership survived. Normal Gateway create/patch retain the lifecycle fence and caller/session checks. That finding remains disposed as inherited, not claimed fixed; the comparison substituted two owners, not the entire baseline. The earlier archive comparison restored 22 production paths, likewise not a full-baseline run. Revised archive tests fail on the pre-repair candidate and pass after restoring the historical retry.

Measured standalone test commands use the canonical repository runner with --maxWorkers=1 (direct wrapper when avoiding dependency reconciliation):

  • Revised archive file: 8/8, 19.24s wall, including 2.505s warm worker preparation; canonical/alias adoption 2.368s/2.422s; max RSS 866,692 KiB.
  • Earlier reclamation file: 2/2, 38.70s wall, including 29.43s cold compilation; test bodies total 1.507s. No new test case or worker boot. The 71-case boundary batch took 96.02s.
  • Latest reclamation file: 3/3, 33.60s wall, including 26.148s cold compilation; new real-worker late-receipt regression 966ms. The 106-case sibling/consumer batch took 102.29s. Neither passing uncontrolled replay proves the CI interleaving was fixed; the deterministic RED/base-owner/GREEN regression establishes the repair.
  • New queue-cancellation case: changed file 12/12, 31.70s wall, cold compiler dominated; new case 1ms. Revised replacement-worker file: 7/7, 22.74s wall; new unkeyed shared-owner/zero-host-SQL case 1,656ms. Final 93-case owner batch took 51.99s. The real worker case proves schema discovery and the no-host-SQL boundary that a mocked publisher cannot. Hosted cost for these new cases is not yet available.
  • Creation-worker: 34.01s cold wall, including 18.074s preparation; its three alias cases total 4.011s. Prior unchanged-owner measurements: replacement-worker 14.64s, creation-snapshot 19.97s, create/category 23.58s, patch effects 2.69s, registration 24.10s, catalog 48.41s, create preparation 18.36s, atomic initialization 13.82s.

One counterfactual compiler subprocess exited 139 before tests. One prerequisite retry with supported bounded compiler concurrency completed. That tooling crash remains unexplained, not relabeled as a product failure or claimed fixed. No manual CI reruns, weaker assertions, relaxed limits or modified baselines were used. The isolated exact-merge proof initially lacked workspace-local quickjs-wasi/Markdown dependency links; its own frozen install repaired that setup, and the single prerequisite retry passed. Shared candidate dependencies and source were not changed.

55 files, +2,477/−460: production 42 files, +1,151/−331; tests/support 12 files, +1,315/−125; owning documentation 1 file, +11/−4. Growth comes from required worker adaptation, pending-admission cancellation at the existing queue owner, and lifecycle/data-preservation proof—not another queue or presentation-module extraction.

The failed predecessor run tested merge 27bf437c (2ab085b plus main 60d25b9). Its sole failed test job first showed three replacement FIFO failures, then a planning-close wait cycle and teardown cascades; this is not attributed to infrastructure or waived. The accepted auto-merge request was explicitly canceled through native recovery before repair. Current-head hosted CI and native replacement recovery remain required.

Historical CI run 35670778480 qualified the retired stacked head 57fecf53, not this rewrite. The first rewritten head 92fa7c88 passed its focused local selection/build, then hosted CI exposed the defects repaired here. Neither old head's checks qualify this revision.

Derived from the work requested by @vyctorbrzezowski; contributor credit is retained.

Work sessions

@clawsweeper

clawsweeper Bot commented Sep 22, 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 size: XL maintainer Maintainer-authored PR labels Sep 22, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 22, 2026 00:09
@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 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 23, 2026, 1:24 PM ET / 17:24 UTC (Revision 5).

ClawSweeper review

What this changes

Keeps session writes serialized through group registration so concurrent deletion cannot revive a deleted group, while preserving worker ordering and cleanup.

Merge readiness

⛔ Blocked before merge - 1 item remains

The repair remains useful on current main, and no actionable introduced defect was found. The previous generic migration-proof blocker should be withdrawn: this diff preserves stored formats and existing persistence contracts.

Priority: P2
Reviewed head: c3860f0fa973cf679fdea7d9fa248149d0b56a66

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with meaningful regression coverage and no actionable introduced findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer/bot workflow is exempt from ordinary external-contributor proof. Inspected evidence targets registered create/patch races and real SQLite worker revocation, publication and cleanup; no unresolved authority case requires an additional proof gate. No stored-data contract changes, so migration 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: The maintainer/bot workflow is exempt from ordinary external-contributor proof. Inspected evidence targets registered create/patch races and real SQLite worker revocation, publication and cleanup; no unresolved authority case requires an additional proof gate. No stored-data contract changes, so migration proof is not applicable.
Evidence reviewed 8 items Introduced change and review continuity: Reviewed the pinned merge-base-to-head changes, not endpoint drift. The preceding completed review used the same head and reported no findings. The supplied test merge has mismatched base parentage, so it was not used to infer removal of current-main behavior.
Repair remains necessary: Fetched main still performs category registration outside the retained commit continuation. Its registration helper matches the pre-change implementation. The supplied related merged defaults cleanup addresses a different concern; no verified merged replacement establishes that this race is fixed or released. The supplied latest-release object was unavailable locally, so no release-fix claim is made.
Writer custody and publication: Replacement execution now settles committed publication and awaits registration within the existing worker execution and physical writer scope. Gateway create and patch callers use that continuation; rejected or unapplied mutations do not register categories.
Findings None None.
Security None None.

How this fits together

Gateway session creation and category updates write agent databases, then update the shared group catalog. Retaining the original writer through registration keeps subsequent group deletion ordered behind those updates.

flowchart TD
  A[Create or categorize session] --> B[Agent database writer queue]
  B --> C[Commit session and publish changes]
  C --> D[Check original owner is current]
  D --> E[Register shared group]
  E --> F[Release writer]
  G[Concurrent group deletion] --> B
  F --> H[Delete membership and retire group]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +820, Tests +1190, Docs +7. Total +2017 across 55 files.

View PR surface stats
Area Files Added Removed Net
Source 42 1151 331 +820
Tests 12 1315 125 +1190
Docs 1 11 4 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 55 2477 460 +2017

Review metrics

Metric Value Why it matters
Production versus test growth Production +820 net lines; tests/support +1,190 net lines The body justifies production growth through existing-worker adaptation and lifecycle handling, with separate regression coverage for ordering and data preservation.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/gateway/server-methods/session-create-category.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #155288
Summary: This is the retained focused deletion-race repair; the broader ownership migration remains separate.

Members:

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

Technical review

Best possible solution:

Keep registration inside the existing writer lifecycle, preserving committed outcomes, revocation checks and existing archive recovery without adding a migration.

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

Yes, source establishes the race: delay registration after a committed create or category patch, then delete the group. Registered-handler regressions exercise that ordering; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Extending the existing physical writer through registration directly repairs the ordering invariant, while worker adapters preserve the established storage owners.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs a bounded session-organization race and associated writer cleanup behavior without evidence of an ongoing core-runtime emergency.
  • 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: The maintainer/bot workflow is exempt from ordinary external-contributor proof. Inspected evidence targets registered create/patch races and real SQLite worker revocation, publication and cleanup; no unresolved authority case requires an additional proof gate. No stored-data contract changes, so migration proof is not applicable.

Evidence

What I checked:

  • Introduced change and review continuity: Reviewed the pinned merge-base-to-head changes, not endpoint drift. The preceding completed review used the same head and reported no findings. The supplied test merge has mismatched base parentage, so it was not used to infer removal of current-main behavior. (c3860f0fa973)
  • Repair remains necessary: Fetched main still performs category registration outside the retained commit continuation. Its registration helper matches the pre-change implementation. The supplied related merged defaults cleanup addresses a different concern; no verified merged replacement establishes that this race is fixed or released. The supplied latest-release object was unavailable locally, so no release-fix claim is made. (src/gateway/server-methods/session-create-category.ts:6, c7bab50e6ed7)
  • Writer custody and publication: Replacement execution now settles committed publication and awaits registration within the existing worker execution and physical writer scope. Gateway create and patch callers use that continuation; rejected or unapplied mutations do not register categories. (src/config/sessions/session-accessor.sqlite-replacement-worker.ts:175, c3860f0fa973)
  • Authority and cancellation: Registration revalidates retained physical authority before dispatch, at transaction and commit admission, and before installing results. Worker tests cover revoked registration and close/reopen fencing. Queue cancellation removes waiting tasks only; executing writes retain their permit through settlement. (src/gateway/session-groups.registration.test.ts:8, c3860f0fa973)
  • No new stored-data contract: The patch reuses existing transcript initialization, replacement, owner-assignment and archive kernels. It changes no schema definition, serialized representation, retention policy, configuration or public RPC. Added alias and archive-collision cases check preserved transcript bytes, membership, recoverable export failures and explicit recovery. These support withdrawing the earlier generic migration-proof request. (src/config/sessions/session-accessor.sqlite-creation-worker.ts:93, c3860f0fa973)
  • Complete captured evidence inspected: Retrieved the omitted body ending and verified the full body matches captured SHA-256 04e68b431424849dc2f0ac143201b0ce39105d22d202747168fe22adc49ce18e, with 13,512 UTF-16 units. The body reports registered-handler races, real-worker revocation and cleanup checks, and 1,654 passing tests in the separately identified failing-merge integration. It explicitly distinguishes predecessor failures and does not claim live-Gateway or published-driver upgrade proof. Tests were inspected, not executed in this review. (c3860f0fa973)

Likely related people:

  • Peter Steinberger: Raw commit cf32d5a adds src/gateway/session-group-catalog.ts:214 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cf32d5a527d7; files: src/gateway/session-group-catalog.ts)

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-22T00:54:24.481Z sha 57fecf5 :: blocked before merge. :: none
  • reviewed 2026-09-23T13:50:33.168Z sha 92fa7c8 :: blocked before merge. :: none
  • reviewed 2026-09-23T15:14:06.710Z sha 2ab085b :: blocked before merge. :: none
  • reviewed 2026-09-23T16:52:04.224Z sha c3860f0 :: blocked before merge. :: none

@roboclaw-bot
roboclaw-bot force-pushed the openclaw/session-groups-active-defaults-snapshot branch from d17b963 to 900f2d1 Compare September 23, 2026 06:31
Keep original SQLite writer custody through committed publication and group bookkeeping. Move touched creation reads and writes through the existing workers, preserving supported aliases, native rollback and explicit archive recovery.

Independent review found and repaired the admitted-alias regression. A later initial-snapshot CAS concern was source-traced and reproduced on both baseline and candidate owners; it is inherited low-level storage behavior, not a new guarantee introduced here.

Discussion: https://team.openclaw.ai/chat/roboclaw/dashboard/28feaf46-a23c-468e-bfad-ab44a1d5ac7b
Implementation and verification: https://team.openclaw.ai/chat/roboclaw/dashboard/77bcdbfb-d371-44a4-b5fb-71982a391c73

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: shakkernerd <[email protected]>
@roboclaw-bot
roboclaw-bot marked this pull request as draft September 23, 2026 13:39
@roboclaw-bot roboclaw-bot self-assigned this Sep 23, 2026
@roboclaw-bot
roboclaw-bot changed the base branch from openclaw/session-groups-active-defaults-snapshot to main September 23, 2026 13:39
@roboclaw-bot
roboclaw-bot force-pushed the openclaw/session-groups-active-registration-custody branch from 57fecf5 to 92fa7c8 Compare September 23, 2026 13:39
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 23, 2026 13:42
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 23, 2026
roboclaw-bot and others added 2 commits September 23, 2026 14:35
Read native creation snapshots through the resolved physical owner. Retain
historical archive publication after existing-session and alias adoption using
the existing publisher and private worker storage adapters.

Publish first-created shared-state identity before reclamation lease validation;
keep exact receipt checks and failure settlement. Move the unchanged repository
workspace record to a leaf type and restore the test inventory order.

Preserves the registration-custody cleanup requested by the credited contributors.
No schema, public RPC, retention, configuration, or group-ownership activation.

Original discussion:
https://team.openclaw.ai/chat/roboclaw/dashboard/28feaf46-a23c-468e-bfad-ab44a1d5ac7b
Transcript and archive implementation:
https://team.openclaw.ai/chat/roboclaw/~key/subagent/efba26c0-af82-4536-9304-fc99efa8f5d1
Reclamation implementation:
https://team.openclaw.ai/chat/roboclaw/~key/subagent/b6e66b22-c1f6-4497-9a12-8a90796014e3

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: shakkernerd <[email protected]>
Keep exact native lease receipts available for cleanup when publication loses
read admission. Record the original failure and terminate as before; all receipt
guards and native-exit cleanup ownership remain enforced.

A deterministic real-worker regression fails before this repair and passes
with the baseline owner and repaired owner. Scoped siblings and original failing
consumers pass; no claim that a passing uncontrolled replay fixes CI.

Original discussion:
https://team.openclaw.ai/chat/roboclaw/dashboard/28feaf46-a23c-468e-bfad-ab44a1d5ac7b
Late-receipt implementation and verification:
https://team.openclaw.ai/chat/roboclaw/~key/subagent/04bbd182-7274-4ed0-b7ac-63095b94a425

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: shakkernerd <[email protected]>
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) September 23, 2026 15:19
Reserve exact physical writers before asynchronous owner discovery and cancel only revoked pending cleanup admissions. Keep admitted writes, publication, and cleanup receipts owned through settlement.

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: shakkernerd <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Sep 23, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 23, 2026
@roboclaw-bot
roboclaw-bot merged commit 4615e44 into main Sep 23, 2026
234 checks passed
@roboclaw-bot
roboclaw-bot deleted the openclaw/session-groups-active-registration-custody branch September 23, 2026 17:35
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
Related: openclaw#142863

Reworked directly on main, replacing the retained foundation from openclaw#153828. This no longer depends on the defaults PR or the held migration drafts.

## What Problem This Solves

Fixes deleted groups reappearing when deletion overtakes session creation or category assignment before catalog registration settles.

## User Impact

Group deletion waits for earlier committed session writes and their registration. Bookkeeping failures warn and reload the catalog instead of falsely reporting that an already-saved session write failed. Reassigning the same category can repair missing bookkeeping. Session updates retain their place in the writer queue, and closing a session database no longer hangs behind revoked cleanup waiting for that same writer. Already-admitted writes still settle before close.

The catalog remains global. No agent-owned-group activation, schema change, new configuration, public RPC change, or Gateway deployment is included. Fresh creation remains isolated from unrelated archive-export failures; existing-session and alias adoption retain their historical retry and visible failure behavior. Canonical bytes, retention protection and explicit recovery are preserved.

## Why This Change Was Made

Keep the original physical writer through commit settlement, existing publication and registration, with live authority checked before committing and installing results. Remove late duplicate registration and the redundant replacement wrapper.

Touched durable access now uses the existing history reader, agent executor and shared-state reader. Supported aliases retain canonical replacement and native deletion custody. CI-exposed custom-store and first-creation identity defects are repaired at those existing owners; no parallel registry, writer or archive-retry manager is introduced.

## Evidence

- Actual registered create/patch versus group-delete races demonstrate the original defect and its repair. Proof includes close joining, physical-path/environment changes, transaction/commit revocation, uncertain publication, native rollback and rejected/no-write suppression.
- Unchanged guarded SDK suite: **24/24**. Creation/replacement/archive owners: **36/36**. Registered Gateway race/siblings: **14/14**. Reclamation repair: **73/73**, including the original board and Zalouser failures. These selections overlap earlier proof and are not combined into a larger total.
- Historical adoption-triggered archive retry is restored. Real collision/recovery fixtures verify exact bytes/hash, attempts, retained transcript/metadata, publication ordering and zero host data SQL. Fresh creation and generic recovery controls remain intact.
- Static dependency-cycle and test-inventory defects found by hosted CI are corrected. Architecture checks pass; both original routing suites pass **501/501**.
- Fresh independent review (R3) of the complete revised candidate is **scoped-clean through P2**, with no actionable findings. It reviewed source/evidence, not an independent execution of the tests. The subsequent mechanical removal of an unreachable snapshot wrapper migrated its three test callers to the existing connection-bound kernel; final snapshot/type/lint/export/build checks cover that cutover.

- A subsequent hosted-CI teardown race is repaired: read-admission retirement no longer loses an already-acquired exact lease receipt needed after native exit. A real-worker regression fails on the published predecessor and passes with the base owner and repair; this substitutes one owner, not a full baseline. **109 focused tests pass**, including original failing consumers, with core/test types and typed lint clean. Fresh independent R4 review of this two-file correction is **scoped-clean through P2**; it did not rerun tests.

- The next hosted run exposed replacement callbacks losing their FIFO turn and a planning-close deadlock. Exact database locators now reserve the existing queue before worker-owned schema discovery; revocation removes only pending maintenance admissions. Unchanged original cases reproduce RED and pass after repair. Final-source ownership proof is **93/93**, with production/test types, typed lint, formatting and delta ratchets clean. Independent R5 review of the 11-file correction is **scoped-clean through P2**; tests were not independently rerun by the reviewer. A separate final integration applied the frozen repair to the actual failing CI merge `27bf437c`, including its main-side worker-runtime changes: the original config lane passed **90 files / 1,654 tests in 189.63s**, on Node 24.19.0 with two workers and retries disabled. This is local exact-merge integration, not a substitute for current-head hosted CI.

**Current-head Claw review (c3860f0, September 23 at 16:52 UTC):** no actionable introduced or security defect was found. Its explicit source assessment withdraws the prior generic migration-proof request and confirms no schema, serialized representation, retention-policy or public-RPC change. The generated checklist still repeats that withdrawn request; it is not an unresolved source finding. Existing-state alias, archive-recovery, authority and lease-cleanup evidence above remains applicable. Current-head hosted CI and native merge gates remain required.

**Qualified integration baseline (11cc34f):** production and all source core-test type graphs, revised-candidate typed lint, all three canonical unused-export scans, and canonical build passed. After the final mechanical cutover, creation snapshots passed **13/13**, production/session-test types and two-path typed lint passed, all three unused-export scans reported zero entries, and the final build passed in **225s**. All 48 source hashes stayed unchanged through that baseline qualification and publication. The subsequent seven-line production receipt-lifetime correction and its regression have separate focused qualification above; at that stage the other 46 paths were unchanged. The later FIFO/cancellation correction has separate proof above; no fresh full local build is claimed for it. Current-head hosted CI remains required.

**Retained limitation:** the earlier full-tree core lint scan failed on unchanged `src/cron/service/timer.test.ts` (1,022 counted lines versus its 1,000-line allowance). Its Git blob is identical to the selected main base. No allowance was raised; the full changed-check wrapper is not claimed green. Earlier local proof used Node 26 versus hosted Node 24.19. New FIFO/cancellation reproduction and qualification use verified Node 24.19.0. No live-Gateway, native-platform or published-driver upgrade proof is claimed.

**Unresolved timing evidence:** hosted predecessor CI observed dirty session describe at 124.39ms against its unchanged 100ms assertion (zero transcript reads; 1,995 rows still pending). One original-order attempt stopped earlier in the separate cron process on six real-HTTP delivery cases, including a 120s timeout (1,567 passed); those failures remain unexplained and were not retried. The still-unexercised 89-selector Gateway plan was then run once, with unchanged assertions: describe 32.62ms, dirty describe 15.25ms, zero transcript reads and 1,983 rows pending. The Gateway shard itself was not green: 29 failed, 974 passed, one skipped and two unhandled errors; HTTP cases observed the host secret-egress proxy refusal/502 response rather than their expected local endpoint payload. That transport boundary was not bypassed. The latency case is a non-reproduction, not a timing fix or CI waiver. Local Node 26 differs from hosted Node 24.19; no timing limit was changed.

<details>
<summary>Regression attribution, review dispositions and measured costs</summary>

The custom-store transcript failure came from reinterpreting a prepared physical database as a logical store. Reading its already-resolved owner fixes the producer; transcript guards are unchanged.

The original board deletion failure directly showed an unresolved host shared-state identity versus the worker's first-created physical identity. Restoring only the baseline deletion lookup made the unchanged test pass. The repair publishes first creation through the canonical admission owner before unchanged receipt checks, and settles errors through existing failure/termination handling. This was a narrow counterfactual, not a whole-baseline run. Board 22/22, Zalouser 5/5, reclamation custody 33/33, shared-state lifecycle 11/11 and the extended owner file 2/2 pass.

The earlier Signal-alias P2 was reproduced at the actual admitted entry point and repaired. R2 alleged a newly missing original-snapshot CAS across an asynchronous creation callback. A deterministic comparison with the old entry/projection owners showed the same low-level lost-update behavior in both; newer persisted ownership survived. Normal Gateway create/patch retain the lifecycle fence and caller/session checks. That finding remains disposed as inherited, not claimed fixed; the comparison substituted two owners, not the entire baseline. The earlier archive comparison restored 22 production paths, likewise not a full-baseline run. Revised archive tests fail on the pre-repair candidate and pass after restoring the historical retry.

Measured standalone test commands use the canonical repository runner with `--maxWorkers=1` (direct wrapper when avoiding dependency reconciliation):

- Revised archive file: 8/8, **19.24s wall**, including 2.505s warm worker preparation; canonical/alias adoption 2.368s/2.422s; max RSS 866,692 KiB.
- Earlier reclamation file: 2/2, **38.70s wall**, including 29.43s cold compilation; test bodies total 1.507s. No new test case or worker boot. The 71-case boundary batch took 96.02s.
- Latest reclamation file: 3/3, **33.60s wall**, including 26.148s cold compilation; new real-worker late-receipt regression 966ms. The 106-case sibling/consumer batch took 102.29s. Neither passing uncontrolled replay proves the CI interleaving was fixed; the deterministic RED/base-owner/GREEN regression establishes the repair.
- New queue-cancellation case: changed file **12/12, 31.70s wall**, cold compiler dominated; new case **1ms**. Revised replacement-worker file: **7/7, 22.74s wall**; new unkeyed shared-owner/zero-host-SQL case **1,656ms**. Final 93-case owner batch took **51.99s**. The real worker case proves schema discovery and the no-host-SQL boundary that a mocked publisher cannot. Hosted cost for these new cases is not yet available.
- Creation-worker: 34.01s cold wall, including 18.074s preparation; its three alias cases total 4.011s. Prior unchanged-owner measurements: replacement-worker 14.64s, creation-snapshot 19.97s, create/category 23.58s, patch effects 2.69s, registration 24.10s, catalog 48.41s, create preparation 18.36s, atomic initialization 13.82s.

One counterfactual compiler subprocess exited 139 before tests. One prerequisite retry with supported bounded compiler concurrency completed. That tooling crash remains unexplained, not relabeled as a product failure or claimed fixed. No manual CI reruns, weaker assertions, relaxed limits or modified baselines were used. The isolated exact-merge proof initially lacked workspace-local `quickjs-wasi`/Markdown dependency links; its own frozen install repaired that setup, and the single prerequisite retry passed. Shared candidate dependencies and source were not changed.

55 files, +2,477/−460: production 42 files, +1,151/−331; tests/support 12 files, +1,315/−125; owning documentation 1 file, +11/−4. Growth comes from required worker adaptation, pending-admission cancellation at the existing queue owner, and lifecycle/data-preservation proof—not another queue or presentation-module extraction.

The [failed predecessor run](https://github.com/openclaw/openclaw/actions/runs/35878886549) tested merge 27bf437c (2ab085b plus main fe14430). Its sole failed test job first showed three replacement FIFO failures, then a planning-close wait cycle and teardown cascades; this is not attributed to infrastructure or waived. The accepted auto-merge request was explicitly canceled through native recovery before repair. Current-head hosted CI and native replacement recovery remain required.

Historical [CI run 35670778480](https://github.com/openclaw/openclaw/actions/runs/35670778480) qualified the retired stacked head `57fecf53`, not this rewrite. The first rewritten head `92fa7c88` passed its focused local selection/build, then hosted CI exposed the defects repaired here. Neither old head's checks qualify this revision.

</details>

Derived from the work requested by @vyctorbrzezowski; contributor credit is retained.

## Work sessions

- [Original discussion](https://team.openclaw.ai/chat/roboclaw/dashboard/28feaf46-a23c-468e-bfad-ab44a1d5ac7b)
- [Implementation and verification](https://team.openclaw.ai/chat/roboclaw/dashboard/77bcdbfb-d371-44a4-b5fb-71982a391c73)
- [Earlier registration implementation](https://team.openclaw.ai/chat/roboclaw/070c58af)
- [Transcript and archive compatibility repair](https://team.openclaw.ai/chat/roboclaw/~key/subagent/efba26c0-af82-4536-9304-fc99efa8f5d1)
- [Reclamation diagnosis and repair](https://team.openclaw.ai/chat/roboclaw/~key/subagent/b6e66b22-c1f6-4497-9a12-8a90796014e3)
- [Late-lease cleanup repair](https://team.openclaw.ai/chat/roboclaw/~key/subagent/04bbd182-7274-4ed0-b7ac-63095b94a425)
- [FIFO and handle-lifecycle repair and verification](https://team.openclaw.ai/chat/roboclaw/~key/subagent/95ed6726-6bcd-4cf0-88d9-608a6cd292d1)

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: shakkernerd <[email protected]>
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
amittell added a commit to amittell/openclaw that referenced this pull request Oct 2, 2026
Ayaan Zaidi's upstream fix, merged to main 2026-09-25, after the 9.6
tag. Automatic session maintenance rejects a plan whose inputs change
before commit and reschedules after the write quiet window; the Worker
diagnostics could not tell that refusal from a crash, so each one was
logged at warn as "SQLite reclamation Worker failed". The deployed bot
logs that line about 95 times a day, and the runs it names are retries
that succeed. The commit guards now throw a typed
SqliteReclamationInputsChangedError, and the diagnostics log a fast
superseded Worker at debug as "SQLite reclamation Worker superseded by
newer inputs". Real Worker failures, slow-Worker warnings and the
"paused after repeated input changes" warning are unchanged.

Applied without upstream openclaw#155988 (1ed98e6), which this commit
follows on main. That refactor's archive half queues writer admissions
with openclaw#155288's cancellable signal; carried without it, two of its own
tests fail ("close waited on an unrelated queue owner"), so it is not
carried. Conflict resolution against the pre-openclaw#155988 code:
- maintenance-kick.ts: the two commit guards that exist here ("inputs
  changed before commit", "age fact changed before commit") throw the
  typed error. openclaw#155988's no-op planning checks, the other two sites
  upstream typed, are not present and are not added. The in-process
  skip path's "database path changed" guard never reaches the Worker
  diagnostics and is left as it is.
- reclamation-worker.test.ts: imports only; the tag's first test is
  kept as it is (upstream's version comes from openclaw#155288).
The diagnostics module now equals upstream's blob; docs/logging.md
auto-merged.

Tests on the branch: session-accessor.sqlite-reclamation-worker 3/3,
including "reschedules maintenance superseded by a write during Worker
planning without a Worker failure warning". With the kick module
restored to its previous blob, that test fails: the run rejects with a
plain Error.

(cherry picked from commit f583397)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation 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: XL 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