Skip to content

fix: avoid waiting for the writer when finishing consumed chat input - #146795

Merged
steipete merged 1 commit into
mainfrom
codex/swarm-pending-input-release
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/swarm-pending-input-release

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #130741

What Problem This Solves

Fixes an issue where finishing or canceling a chat turn could wait for a busy database writer even after its accepted input had already been consumed into the transcript.

Why This Change Was Made

Record committed consumption on the existing private input owner, using the transaction owner's commit publication. Completion still revokes execution authority immediately, then skips the empty disposition write for consumed input. Rolled-back and unconsumed inputs retain their existing disposition persistence.

User Impact

Consumed-input cleanup no longer competes for the SQLite writer. Direct and collected inputs keep their existing transcript, cancellation, and recovery behavior.

Evidence

The regression reproduced four failures on unchanged main with a real foreign SQLite writer. The candidate passes all eight consumed-release and rollback cases, plus the pending-input, user-turn recorder, and transaction suites: 114 tests total. All selected canonical checks and fresh P1 review passed. This proves the bounded cleanup correction; the wider Swarm responsiveness target remains tracked in #130741.

@clawsweeper

clawsweeper Bot commented Sep 13, 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 size: M maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 06:16
@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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 2:24 AM ET / 06:24 UTC.

ClawSweeper review

What this changes

The PR prevents completed chat-input cleanup from waiting for SQLite’s writer lock by recording committed consumption on the existing private input owner.

Merge readiness

✅ Ready for maintainer review

Keep open: the cleanup defect remains on current main, and this focused patch preserves commit, rollback, and ownership semantics. No actionable correctness or security findings were identified.

Priority: P2
Reviewed head: aa118693fe56a16a560a2618eea09e1303218d17

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful contention and rollback coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored exemption applies. The reported validation exercises session staging, transcript append, and receipt completion against real SQLite contention; source inspection confirms relevant assertions, but no execution transcript was independently verified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored exemption applies. The reported validation exercises session staging, transcript append, and receipt completion against real SQLite contention; source inspection confirms relevant assertions, but no execution transcript was independently verified.
Evidence reviewed 8 items Current main still performs the unnecessary write: Completion releases the owner and unconditionally enters a write transaction, even when consumption already deleted the row or populated consumed_event_id.
Latest release retains the same cleanup behavior: Inspection of v2026.9.4 shows the unconditional disposition transaction after ownership release; the requested optimization is not present in the supplied latest release.
Consumption remains tied to the committed transaction: The complete consumption owner was inspected. It selects exact live owners by identity, database path, and input IDs, then publishes consumed only after successful row consumption. Existing append authorization and exact transcript checks remain unchanged.
Findings None None.
Security None None.

How this fits together

Accepted chat input is held in the session store until it is committed to the conversation transcript. Completion then releases execution ownership and records a terminal disposition only for input that remains unconsumed.

flowchart TD
  A[Accepted chat input] --> B[Private input owner]
  B --> C[Transcript transaction]
  C --> D{Transaction committed?}
  D -->|Yes| E[Record consumed fact]
  D -->|Rollback| F[Input remains pending]
  E --> G[Release ownership without write]
  F --> H[Release ownership and record disposition]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +27, Tests +169. Total +196 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 43 16 +27
Tests 1 169 0 +169
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 212 16 +196

Review metrics

Metric Value Why it matters
Commit-boundary regression coverage 8 cases The matrix distinguishes committed cleanup from rollback for both direct and collected input.

Technical review

Best possible solution:

Keep consumption bookkeeping with the existing transaction owner so committed inputs release without a write while pending inputs retain durable cancellation and interruption handling.

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

Yes: consume a staged input, hold BEGIN IMMEDIATE on another connection, then finish the receipt; current main still requests the writer lock. The new regression covers this path, but was not executed during this read-only review.

Is this the best way to solve the issue?

Yes: the patch reuses committed transaction publication and skips an otherwise empty write without changing persisted formats, replay checks, or execution revocation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded responsiveness fix for finishing chat turns during SQLite writer contention.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored exemption applies. The reported validation exercises session staging, transcript append, and receipt completion against real SQLite contention; source inspection confirms relevant assertions, but no execution transcript was independently verified.

Label justifications:

  • P2: This is a bounded responsiveness fix for finishing chat turns during SQLite writer contention.
  • 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-authored exemption applies. The reported validation exercises session staging, transcript append, and receipt completion against real SQLite contention; source inspection confirms relevant assertions, but no execution transcript was independently verified.

Evidence

What I checked:

  • Current main still performs the unnecessary write: Completion releases the owner and unconditionally enters a write transaction, even when consumption already deleted the row or populated consumed_event_id. (src/config/sessions/session-accessor.pending-inputs.ts:325, b2670d47f621)
  • Latest release retains the same cleanup behavior: Inspection of v2026.9.4 shows the unconditional disposition transaction after ownership release; the requested optimization is not present in the supplied latest release. (src/config/sessions/session-accessor.pending-inputs.ts, 3a9d69db306c)
  • Consumption remains tied to the committed transaction: The complete consumption owner was inspected. It selects exact live owners by identity, database path, and input IDs, then publishes consumed only after successful row consumption. Existing append authorization and exact transcript checks remain unchanged. (src/config/sessions/session-accessor.sqlite-pending-inputs.ts:401, aa118693fe56)
  • Publication ordering and rollback contract: The existing transaction-state owner discards nested rollback callbacks, waits for the outer commit, and publishes private state before fallible observers. Completion removes live execution ownership before checking the new consumed flag. (src/infra/sqlite-post-commit.ts:53, aa118693fe56)
  • Focused regression coverage: The eight new cases cover direct and collected inputs under a real foreign SQLite writer, observer failure after commit, outer rollback, and savepoint rollback. Assertions check owner revocation, retained writer contention, and durable disposition. The captured PR body reports four baseline failures and 114 passing candidate tests; this read-only review did not execute those tests. (src/config/sessions/session-accessor.pending-inputs-consumed.test.ts:81, aa118693fe56)
  • Verified introduced scope: The test merge has the pinned base followed by the exact PR head as its recorded parents. Its comparison against that base contains only the three supplied introduced files. The introduced diff also passes git diff --check. (1b20b17e976c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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.

@steipete
steipete merged commit 1cc5eea into main Sep 13, 2026
252 checks passed
@steipete
steipete deleted the codex/swarm-pending-input-release branch September 13, 2026 06:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '2acbeee461474b6ba41f5186ae1a4e0e80f4087a': (117 commits)
  fix(ui): import the shared deferred helper in sidebar scope tests (#146862)
  fix(ui): copy chat content from its context menu (#146679)
  perf(memory): defer legacy sidecar writer imports (#146815)
  fix(e2e): accept expected Kitchen Sink worker rejection (#146681)
  fix(ui): distinguish absolute and relative file links (#146572)
  feat(ui): keep file previews in tabs and render HTML (#146672)
  refactor: reuse shared deferred promises in UI tests (#146670)
  fix: gateway stop/restart refuses a healthy gateway when the Windows process snapshot misses (#146387)
  improve(crabbox): keep healthy cloud desktops warm on resume (#146816)
  fix: report blocked SQLite WAL checkpoints in status and doctor (#146775)
  feat: share browser dashboards with agents (#146702)
  fix(doctor): continue repairs after legacy agent directory collisions (#146092)
  feat(agents): retry cyber-refused embedded turns on Daybreak (#145291)
  fix: restore media uploads through protected egress (#144902)
  refactor(qa): share capture filter rendering (#146696)
  fix(cli): keep running stream jobs visible as running (#146793)
  refactor(parallels): share gateway readiness loop (#146694)
  fix(sessions): avoid rewriting already-consumed input on release (#146795)
  fix: preserve scheduled conversation delivery after Doctor (#146794)
  perf(ui): avoid redundant session-row provenance work (#146797)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
amittell pushed a commit to amittell/openclaw that referenced this pull request Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: M 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