Skip to content

refactor(sessions): run reset operations in the agent executor (compound 1b) - #163930

Merged
steipete merged 9 commits into
mainfrom
dbasync/compound1b
Oct 3, 2026
Merged

steipete merged 9 commits into
mainfrom
dbasync/compound1b

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #163889

The C1 prerequisite merged as ca77256127e6ba13c00d68bca42194d1b9e2a780. This C2 reset follow-up targets main. Current head b4ffdb59da3ed7912e1b12cf7f6ddb3e0fb93534 incorporates main 9c1e4ce252738c1504182f41ef79379af2e39079 without rebasing, including the current Security Review publisher and the upstream byte-size and startup-fixture repairs.

What Problem This Solves

Single-entry session resets still scanned transcripts and ran the boundary append, entry write, and collaboration cleanup on the Gateway thread.

Why This Change Was Made

Register a typed reset kernel in the existing agent executor and reuse C1/S10 preparation, live grants, candidate transfer, COMMIT receipts, error hydration, and publication. The host builds the replacement once; the worker rereads the complete target and commits the boundary, collaboration cleanup, and entry together. Progress and identity notifications precede the reset callback, and accepted callbacks retain physical FIFO ordering. Lost replies publish the acknowledged candidate without replaying the builder or SQL; uncertain outcomes remain fenced.

Cold restoration retains the captured physical path. Dirty transcript reconciliation is returned to its existing host owner after acknowledgment. Reset conflicts retain their error-class identity through a leaf error module included in the wrapper inventory. Remove the superseded host comparison helper and extract the bundled reply initialization/upsert descriptor needed by C4.

User Impact

Durable reset storage work moves off the caller thread. Schemas, stored formats, retention, permissions, configuration, and update behavior are unchanged; no migration or operator action is needed. The diff adds zero OPENCLAW_* names.

C3 rewind/branch, native-binding settlement, fork/deletion, and actor activation remain outside this PR. Process-held incognito retains its documented native owner until that cutover. Opaque released SDK transaction callbacks retain their explicit compatibility path. P4b's captureSettlement remains the sole native companion settlement owner; ordinary C2 reset introduces no second participant owner.

Production LOC: +349 / −76 / net +273, 425 changed production lines, across 22 total files including tests, docs, and wrapper inventory.

Evidence

  • Caller-thread SQL for reset storage: 137 before → 0 after. Real worker coverage includes acknowledged COMMIT with a lost reply, rollback, transaction/COMMIT revocation, physical FIFO, conflict identity, dirty-history reconciliation, and progress-card lifetime.
  • Exact current-tree integration proof: 124/124 passed, 592.01s wall, all with --maxWorkers=1: 67 reset/publication and 57 worker-error transport cases. Wrapper inventory passed (one selected case, 64.54s, 16 unselected). Both bind tree 42b1f90cd01073c04c36d2410a15ff2e84e5999b.
  • The latest main merge preserves main's MESSAGE_ONLY_ERRORS refactor. The parameter-bearing reset conflict remains beside session-goal errors and retains its validator, payload, constructor and import. No C2 behavior changed. Formatting and whitespace checks pass. Previous integration proof also passed the four secret-metadata worker and 12 transcript SDK cases, and the selected skill-library permission/error boundary.
  • Main's startup fault-injection fix 7a635c2117ea6743ccf2b36e1fde56d45e614063 is incorporated and passed 8/8, 354.38s wall on the prior integrated tree. Main's byte-size assertion fix 7e67fe7d18ecbe1b226a90062807913adcc47416 is also retained; earlier focused proof passed 20/20, 138.14s. Focused runtime is Node 24.21.0 / SQLite 3.53.4.
  • Released SDK reachability checked against v2026.9.8: changed reset/reply helpers are internal; released callback signatures and native transaction visibility remain unchanged. Original production head 60a5900752417fea7ad8aba7f1042a238e422e30 received clean isolated review through P2, retained for the mechanical main integrations and conflict resolutions. The introduced delta remains 22 files, +884 / -238.
  • ClawSweeper completed exact-head review at 2026-10-03T11:22:25.972Z with no code or security findings and no before-merge items. Exact-head CI run 37119170550, attempt 1, completed successfully: 103 successful jobs and 20 skipped, including passing security-fast and openclaw/ci-gate. No jobs were rerun. This head uses ordinary native landing, with no inherited-failure exception.
  • Preceding-head CI 37115561644, attempt 1, completed with 96 successful jobs, 20 skipped, one failed root and its downstream gate, zero cancellations, and passing security-fast. It tested merge c95baff3bf7ee3783ae110d7ac93969b550edc0a, whose tree matches Git's recomputed merge. The sole root was the independently proven main terminal-fixture defect below. Inspection of main 9c1e4ce252738c1504182f41ef79379af2e39079 at 2026-10-03T10:58:27Z found no fixture fix; all five causal blobs remained identical. Any native inherited-failure admission must be refreshed for the new exact head and completed CI attempt.

The preceding head's CI run 37112781425, attempt 1, failed only the four terminal-output cases in attempt-stream-prepare.test.ts (job 111173954646), plus the downstream gate. Main commit aff22764a883286f7ad20af771b28c2302e3cce1 introduced terminal.readSanitizedResult(), while the unchanged subscription fixture omitted it on both success and error terminals. Five runs on actual CI merge 1174d26d41e507a949539b21c5ccbea5f8ec1cc6 and five on its main parent 2a58339e793171ad389db75e6815757037180adc each reproduce exactly four failures / 47 passes. Scheduled main run 37113342869, job 111175455568, independently matches all four. The failing fixture uses an in-memory manager and does not require C1b reset/database work. Branch-only replay was not substituted for the executed CI tree. Main subsequently repaired both missing terminal accessors in b1c49290c8d5335331c63fc176d75a80805fa953, preserving the four cases. Current exact-head CI passes. No CI job was rerun and no inherited-failure exception is needed for the final head.

An earlier CI attempt reported AgentDatabaseRegistryChangedError in the SDK's concurrent first-write case. Five head and five main-baseline runs passed all 12 cases, and the current integration's SDK run also passes. The original log cannot identify the precise registry invalidator, so this remains an unreproduced timing-sensitive refusal, with no claim that passing replays fixed it. No SDK source change or CI rerun was made for that observation.

Initial PR CI exposed two reset-cleanup fixture assumptions. All five original-head runs failed those cases and all five C1-base runs passed. Repair 01e664751e259cfac55fc7473467010bc7f3e90e moves fault injection to worker-local TEMP triggers and joins scoped cleanup before reopen, preserving error, rollback, revocation and reopen assertions. No cases were added; the repaired file originally passed 20/20 in 186.99s (original CI case cost 48.834s).

Historical main-only byte-size and startup failures were incorporated from their upstream fixes. An older auth-failover mock failure also matched five prior-head, five main-baseline runs and scheduled main CI. A native admission stopped before dispatch on stale Security Review publisher source; a legitimate main merge refreshed it. Subsequent actual worker-error conflicts were resolved while retaining all main and reset identities. No CI job was rerun merely to obtain green.

Move durable reset boundary, collaboration cleanup, and entry writes into
one typed executor transaction using the existing transfer and COMMIT
receipt owner. Preserve host builder/callback order, physical FIFO, live
grants, and reset conflict identity. Keep native and opaque compatibility
paths and extract the reply initialization descriptor for the next cutover.

Reset boundary SQL observations: 137 on the caller thread before, zero
after. Focused reset, entry-patch, cold-storage, and SDK proof: 69 passed.
@clawsweeper

clawsweeper Bot commented Oct 3, 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 docs Improvements or additions to documentation scripts Repository scripts size: XL labels Oct 3, 2026
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 7:40 AM ET / 11:40 UTC (Revision 17).

ClawSweeper review

What this changes

Moves durable session-reset storage into the existing agent database worker while preserving callbacks, notifications, and reply initialization.

Merge readiness

✅ Ready for maintainer review

This remains useful work: current main has not moved durable resets into the executor. The pinned patch has no actionable correctness or security findings, and the supplied production-worker evidence covers the changed boundary.

Priority: P2
Reviewed head: b4ffdb59da3ed7912e1b12cf7f6ddb3e0fb93534

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker cutover with strong boundary evidence and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The reported after-fix runs exercise resetSessionEntryLifecycle through the real executor, worker transport, and SQLite writer, demonstrating lost-reply recovery, refusal after revocation, atomic rollback, and FIFO publication. Inspected harnesses match those claims; no stored-data contract changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported after-fix runs exercise resetSessionEntryLifecycle through the real executor, worker transport, and SQLite writer, demonstrating lost-reply recovery, refusal after revocation, atomic rollback, and FIFO publication. Inspected harnesses match those claims; no stored-data contract changes require migration.
Evidence reviewed 8 items Pinned introduction: Inspected the verified introduced delta from 9c1e4ce to b4ffdb5. The supplied stale test merge was not used to infer removal of current-main behavior.
Still necessary on main: Fetched main still performs reset snapshot reads, boundary append, and entry writes through the native host lifecycle path. Neither fetched main nor v2026.9.8 contains the new session-reset facade. The merged prerequisite #163889 explicitly reserves reset for this follow-up.
Authority and atomicity: The reset facade supplies the caller guard to the existing executor admission owner, which checks live authority at transaction and COMMIT grants. The kernel rereads the selected entry and performs boundary append and entry replacement in the same transaction; the existing entry writer retains collaboration cleanup and stored-value normalization.
Findings None None.
Security None None.

How this fits together

Session reset replaces the active conversation entry and records a transcript boundary. The Gateway prepares the replacement, the database worker commits it, and acknowledged results update session readers and lifecycle observers.

flowchart TD
  A[Session reset request] --> B[Gateway prepares replacement]
  B --> C[Live authority checks]
  C --> D[Agent database worker]
  D --> E[Atomic reset transaction]
  E --> F[Commit receipt]
  F --> G[Publish session and notify observers]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +273, Tests +360, Docs +12, Other +1. Total +646 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 16 349 76 +273
Tests 4 520 160 +360
Docs 1 14 2 +12
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 22 884 238 +646

Review metrics

Metric Value Why it matters
Production and regression growth production +349/-76, net +273; tests +520/-160, net +360 Production growth supports the typed reset cutover; added coverage exercises worker authority, atomicity, and publication contracts.

Technical review

Best possible solution:

Keep durable reset execution under the existing worker, receipt, and publication owners while preserving the documented native compatibility paths.

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

Not applicable as a bug reproduction: this is an internal execution cutover. The supplied real-worker scenarios directly exercise reset writes, revocation, rollback, and lost-reply recovery.

Is this the best way to solve the issue?

Yes. Reusing the existing executor and commit-receipt owner preserves one authoritative reset transaction without adding a competing worker or persistence contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded session-storage improvement with meaningful concurrency validation and no demonstrated urgent user regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 reported after-fix runs exercise resetSessionEntryLifecycle through the real executor, worker transport, and SQLite writer, demonstrating lost-reply recovery, refusal after revocation, atomic rollback, and FIFO publication. Inspected harnesses match those claims; no stored-data contract changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported after-fix runs exercise resetSessionEntryLifecycle through the real executor, worker transport, and SQLite writer, demonstrating lost-reply recovery, refusal after revocation, atomic rollback, and FIFO publication. Inspected harnesses match those claims; no stored-data contract changes require migration.

Evidence

What I checked:

  • Pinned introduction: Inspected the verified introduced delta from 9c1e4ce to b4ffdb5. The supplied stale test merge was not used to infer removal of current-main behavior. (b4ffdb59da3e)
  • Still necessary on main: Fetched main still performs reset snapshot reads, boundary append, and entry writes through the native host lifecycle path. Neither fetched main nor v2026.9.8 contains the new session-reset facade. The merged prerequisite refactor(sessions): run turn append+entry operations in the agent executor (compound 1a) #163889 explicitly reserves reset for this follow-up. (src/config/sessions/session-accessor.sqlite-lifecycle.ts:107, c81d86e82f60)
  • Authority and atomicity: The reset facade supplies the caller guard to the existing executor admission owner, which checks live authority at transaction and COMMIT grants. The kernel rereads the selected entry and performs boundary append and entry replacement in the same transaction; the existing entry writer retains collaboration cleanup and stored-value normalization. (src/config/sessions/session-reset.ts:23, b4ffdb59da3e)
  • Production-boundary proof: The captured PR body reports 124 passing reset/publication and worker-error cases on tree 42b1f90cd01073c04c36d2410a15ff2e84e5999b under Node 24.21.0 and SQLite 3.53.4. Inspected harnesses delegate to the real executor and worker connection, inject lost replies and revoked grants, and assert durable rollback, single publication, FIFO completion, dirty-history reconciliation, and zero host reset SQL. These are production-worker boundary scenarios, not substituted transport results. (src/config/sessions/session-compound-worker.test.ts:226, b4ffdb59da3e)
  • Exact-head CI: GitHub confirms run 37119170550, attempt 1, completed successfully for the exact reviewed head. This corroborates the body’s current-head CI claim; earlier failed runs remain historical evidence. (b4ffdb59da3e)
  • Compatibility boundary: The patch retains the existing entry writer and transcript format, adds no schema or configuration changes, and preserves the native incognito and opaque callback paths. The documented cutover expressly leaves native-binding settlement and activation to later work. Public docs: docs/reference/database-schemas/worker-access.md. (docs/reference/database-schemas/worker-access.md:320, b4ffdb59da3e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Kiran V K: 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 (16 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-03T08:20:25.855Z sha 06f24d0 :: needs changes before merge. :: none
  • reviewed 2026-10-03T08:41:26.741Z sha 79051e1 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T08:59:24.453Z sha 79051e1 :: needs changes before merge. :: none
  • reviewed 2026-10-03T09:27:11.470Z sha 196972c :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T10:00:43.419Z sha 196972c :: needs changes before merge. :: none
  • reviewed 2026-10-03T10:16:48.468Z sha 7924609 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T10:39:17.138Z sha 7924609 :: blocked before merge. :: none
  • reviewed 2026-10-03T11:22:25.972Z sha b4ffdb5 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
Keep reset cleanup rollback proof on the admitted writer connection after the reset executor cutover. Use worker-local TEMP triggers and await scoped resource drainage before fixture reopen. Both faults reproduced in five approved-head runs; all five C1 baseline runs passed, and the repaired file passes all 20 cases.
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 3, 2026
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Base automatically changed from dbasync/compound1 to main October 3, 2026 05:05
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 3, 2026
Integrate compound turn repairs while preserving the reviewed reset delta. Resolve the squashed-stack conflicts with the landed main implementations, retaining both worker error identities and the reset preparation hook. The delta against main remains the same 22 files, with no additional production changes.

Validation: 66 reset, compound-worker, entry-publication and Gateway cleanup cases passed (1290.78s wall). Wrapper import inventory passed (31.87s wall). Formatting and whitespace checks passed for the PR delta. Original P2 production review is retained for this mechanical merge.
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge current main to carry the current Security Review publisher source and the upstream byte-size test correction. Preserve the reviewed 22-file reset delta without rebasing or adding production behavior.

Validation on the unchanged candidate tree: 67 reset and publication cases passed in 566.09s; all 20 byte-size cases passed under Node 24.21.0 in 138.14s; the wrapper import inventory check passed in 41.69s. Formatting and whitespace checks passed for the PR delta.
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit 850c49c into main Oct 3, 2026
201 checks passed
@steipete
steipete deleted the dbasync/compound1b branch October 3, 2026 11:51
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…und 1b) (openclaw#163930)

* refactor(sessions): run turn append+entry operations in the agent executor (compound 1a)

* refactor(sessions): run reset operations in the agent executor

Move durable reset boundary, collaboration cleanup, and entry writes into
one typed executor transaction using the existing transfer and COMMIT
receipt owner. Preserve host builder/callback order, physical FIFO, live
grants, and reset conflict identity. Keep native and opaque compatibility
paths and extract the reply initialization descriptor for the next cutover.

Reset boundary SQL observations: 137 on the caller thread before, zero
after. Focused reset, entry-patch, cold-storage, and SDK proof: 69 passed.

* test(sessions): inject reset failures on worker connections

Keep reset cleanup rollback proof on the admitted writer connection after the reset executor cutover. Use worker-local TEMP triggers and await scoped resource drainage before fixture reopen. Both faults reproduced in five approved-head runs; all five C1 baseline runs passed, and the repaired file passes all 20 cases.
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 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. scripts Repository scripts 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