Skip to content

fix(sqlite): preserve settlement after writer admission errors - #169113

Merged
steipete merged 4 commits into
mainfrom
fix/session-actor-soak-admission
Oct 11, 2026
Merged

steipete merged 4 commits into
mainfrom
fix/session-actor-soak-admission

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A cold writable connection can throw while discovering its physical database admission. Native mutation depth was incremented before that fallible step, leaving no native operation to decrement it. Later writes commit without publishing their receipt revision, leaving cached rows stale.

User Impact

A rejected writer discovery no longer prevents subsequent committed writes from invalidating cached rows. Active native writes and explicit transactions retain their settlement behavior.

Why This Change Was Made

Increment mutation depth only after writer discovery succeeds. Production TypeScript: +1 net line, the ordering comment; three changed files. No schema, protocol, configuration, dependency, or update migration change.

Main removed writer registration in #168859, so the original test's registration-publication fault stopped being reachable. The revised regression opens a cold writable handle before a sibling admits the file, refuses discovery through the existing exchange hook, proves the rejected insert had no effect, then requires the next committed insert to advance the sibling receipt.

The separate actor stale-version repair from #169107 is included through main; this PR does not replace it.

Evidence

  • The cold-discovery regression fails at unchanged receipt on the original ordering and passes with the repair.
  • Native suite: 50/50 on macOS (26.54 s wall). On the updated Linux head: 47 passed, three unsupported statement-finalization cases skipped.
  • Focused actor tests: 30/30 passed. Combined native/actor run: 59.91 s wall.
  • Fresh independent review: no actionable P0/P1 findings. Main integration left the production fix and regression byte-identical.
  • Core and all core-test typechecks, type-aware lint, export-name collision checks, and remaining schema/loader/import/security guards passed.
  • Production and script Knip scans pass. Full-tree Knip reports the same unrelated loadSubagentMaintenanceCandidatesInDatabase (store) namespace export on current main (4f4741bfe2b6); no suppression added.
  • CI run 38148270956 fails an unchanged mocked-Gateway UI layout case waiting for a terminal canvas. The SQLite writer path is not exercised. Landing uses the coordinator-authorized inherited-CI route with the exact tested merge and cancellation evidence.
  • The accelerated live soak is requested after landing. Any recurrence of the earlier closed-admission failure will be reported to its owner; it is not being patched here.

Release-note context: preserve database receipt invalidation after writer discovery fails before native execution.

Post-merge live verification

The exact landed revision 5da9eae07c5a6c79eac2ccf0e930c18cd3052d3f ran six concurrent local sessions for 902.7 seconds: 935/936 exact replies with successful completion. One turn failed with Session actor changed while hydrating; the next turn and all later cycles recovered. The earlier Agent database execution admission is closed failure did not recur. The actor owner follow-up is recorded separately; the 30-minute three-route soak was skipped because the accelerated run was not clean.

Use the existing current-preimage actor contract for input and terminal bookkeeping while retaining domain predicates and live authority. Prevent rejected writer preparation from leaking mutation depth. Preserve concurrent input, lifecycle, writer, and model-selection guards with regression coverage.
@clawsweeper

clawsweeper Bot commented Oct 11, 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 size: M labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR increments native mutation depth only after SQLite writer discovery succeeds.

Example: Writer discovery rejects INSERT INTO proof VALUES (1), then INSERT INTO proof VALUES (2) succeeds.

  • Before: The rejected operation leaks mutation depth, preventing the successful write from advancing the sibling reader's receipt.
  • After: The successful write advances the receipt, allowing cached rows to invalidate.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair is correct and supported by a meaningful native regression; runtime confidence remains bounded by the supplied harness evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored internal repair is outside the ordinary contributor proof gate; supplied validation exercises native SQLite through an in-process regression rather than a shipped Gateway flow.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: After rejected database writer discovery, later committed writes can leave reader caches stale.
Reason: The maintainer-authored repair restores the established invalidation contract with a minimal change at its existing owner.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a current-main settlement defect with a focused regression, and no actionable correctness or security findings remain; current-head CI still requires native landing handling.

Priority: P2
Reviewed head: a74edc348e1b11899b820de5387c504d6e82d8b7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway trace demonstrates discovery refusal followed by successful receipt recovery; the supplied native regression and baseline failure are reported.
Agent review details

How this fits together

The native SQLite observer brackets database statements and publishes settled write revisions that invalidate reader caches.

flowchart TD
A[Database caller] --> B[Native statement observer]
B --> C[Writer discovery]
C --> D[Mutation accounting]
D --> E[SQLite execution]
E --> F[Statement settlement]
F --> G[Reader cache receipts]
Loading

Technical review

Best possible solution:

Retain the exception-safe ordering repair and cold-discovery regression within the existing receipt owner.

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

Current-main source exposes the leaked increment, and the revised native regression reaches that boundary with reported before-and-after failure evidence.

Is this the best way to solve the issue?

Moving the increment after discovery restores exception-safe accounting at its producer without additional coordination or changes to transaction and cursor settlement.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native mutation-depth accounting keeps the original intent (c828f7e: Prevent reuse of row facts while native mutations remain active.)
  • Committed write settlement keeps the original intent (069a5b8: Release settled write receipts independently of parked read cursors while retaining active mutation and transaction accounting.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 069a5b8 adds src/infra/sqlite-schema-facts.ts:400 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 069a5b81e3e2; files: src/infra/sqlite-schema-facts.ts)

PR surface

Source +1, Tests +29, Docs +2. Total +32 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 3 +1
Tests 1 29 0 +29
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 35 3 +32

Review metrics

Metric Value Why it matters
Production versus test LOC Production +4/−3; tests +29/−0 Production growth is one ordering comment; the regression protects subsequent receipt publication after discovery failure.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs SQLite exception recovery and stale cache invalidation without evidence of an ordinary-user outage attributable to the remaining defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-11T13:03:05.630Z sha 93a4860 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T13:13:20.614Z sha 93a4860 :: needs changes before merge. :: [P2] Adapt the custody regression to the merged writer simplification
  • reviewed 2026-10-11T13:55:49.592Z sha 440208e :: needs changes before merge. :: [P2] Retarget the regression to a surviving admission failure
  • reviewed 2026-10-11T14:14:05.023Z sha 24560b8 :: needs changes before merge. :: none

Reviewed October 11, 2026, 10:57 AM ET / 14:57 UTC (Revision 5).

@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
Merge current main and retain its actor admission recovery. Narrow this lane to the independent native mutation-depth leak, its regression and documentation.
@steipete steipete changed the title fix(sessions): keep actor commands live across unrelated writes fix(sqlite): preserve settlement after writer admission errors Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P1 High-priority user-facing bug, regression, or broken workflow. labels Oct 11, 2026
Merge current main. Replace the retired registration-failure fixture with cold-handle discovery through the existing admission exchange. Verify the rejected insert has no effect and the next committed write advances its sibling receipt.
@steipete
steipete marked this pull request as ready for review October 11, 2026 13:59
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Oct 11, 2026
Merge the landed Solid export cleanup required by the static gate. The native settlement fix and its regression are unchanged.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete
steipete merged commit 5da9eae into main Oct 11, 2026
115 of 132 checks passed
@steipete
steipete deleted the fix/session-actor-soak-admission branch October 11, 2026 15:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…claw#169113)

Use the existing current-preimage actor contract for input and terminal bookkeeping while retaining domain predicates and live authority. Prevent rejected writer preparation from leaking mutation depth. Preserve concurrent input, lifecycle, writer, and model-selection guards with regression coverage.
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 20, 2026
First-parent upstream 19fe879..0bc7491 (100 commits, including
openclaw#169090 entry-writer postimages, openclaw#169201 transcript projection facts,
openclaw#169113/openclaw#169107/openclaw#169125 session-actor admission, openclaw#169110 bounded worker
heaps, openclaw#169130 inter-session provenance, openclaw#168931 Solid session UI).

Conflicts:
- session-accessor.sqlite-entry-mutation.ts: openclaw#169090 moved postimage
  publication into writeSessionEntry and replaced the revision-equality
  no-op check with postimages.changed. Took upstream's form; kept our
  recipient-authority advance on visibility narrowing (same transaction,
  after the write, before the no-op return).
- session-accessor.sqlite-entry-store.ts: import union (upstream dropped
  withProjectedParticipants/SessionEntryWindowFacts imports; ours adds the
  recipient-authority advance). Overlay vs upstream is now 2 lines.
- openclaw-tools.types.ts: import union (our RequestCompactionToolOpts,
  upstream's SessionsYieldRuntimeClaim).
- plugin-sdk-surface-report.mts: upstream raised the budgets to 3672/2133;
  ours stays +11/+4 on top (3683/2137).
- worker-access-inventory.md: regenerated on the merged tree.

Auto-merged files that carry continuation overlay (21) keep the overlay
byte-for-byte (interdiff of the +/- lines vs upstream before and after).

Refs #1475

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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