Skip to content

improve(sessions): reduce pending-input read work - #148208

Merged
steipete merged 1 commit into
mainfrom
codex/sqlite-pending-inputs-landing-0914
Sep 14, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sqlite-pending-inputs-landing-0914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Pending-message lookups and reset reconciliation fetch data their callers do not use.

User Impact

No intended behavior change. Messages retain their full content, pagination, cancellation, and session ownership behavior with less SQLite read work.

Why This Change Was Made

Exact-ID reads skip an unused count. Reset reconciliation rereads only the four custody fields it needs, retaining its fresh transaction and owner checks.

Evidence

72/72 tests pass across all three owner, consumed-input, and registered Gateway handler files on Node 26.8.2, without filtering or an overlay, on main 37f2b34992ff plus this exact patch. The corrected counter from merged #148144 is committed in that base, satisfying the requested integration proof.

Measured flow SELECT executions before → after Rows before → after Returned text bytes before → after
Present, absent, wrong-session point lookups 7 → 4 5 → 2 288 → 288
Reset reconciliation 4 → 4 7 → 7 124,040 → 62,244

Two extended cases fail at the intended budgets on original code and verify complete stored-row parity and rollback after the second interruption update fails. Measurements cover pending-table SELECTs and returned text, with no latency or whole-Gateway claim; Gateway tests use isolated SQLite through registered handlers.

Original static proof is a completed composite: 21 canonical commands passed before two line-limit failures; after the repair, four-file lint, 72 tests, the affected config-cli graph and all eight remaining commands passed. Those receipts and clean four-file independent review remain applicable to the unchanged patch after current-context assessment. The fresh 30-command plan was inspected, not executed as another full suite. Original failures and temporary-helper runs remain preserved.

Exact published-head CI passed. These hosted results and the current-main integration runs are separate evidence; native maintainer validation and landing gates still apply.

@clawsweeper

clawsweeper Bot commented Sep 14, 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.

@steipete
steipete marked this pull request as ready for review September 14, 2026 11:29
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 9:56 AM ET / 13:56 UTC (Revision 2).

ClawSweeper review

What this changes

Reduces SQLite work when reading pending messages while preserving message content, pagination, and session ownership checks.

Merge readiness

✅ Ready for maintainer review

The optimization remains useful on current main, and no introduced correctness defect was found. Updated integration evidence resolves the previous counter-prerequisite concern.

Priority: P2
Reviewed head: 246a3d5be78fb9362d8b1d32c3d83c9262b9736b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful resource and rollback coverage, resolved integration context, and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored internal optimization is exempt from external-contributor live proof; reported SQLite owner and registered Gateway tests support the changed read paths, with no material authority change requiring additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored internal optimization is exempt from external-contributor live proof; reported SQLite owner and registered Gateway tests support the changed read paths, with no material authority change requiring additional proof.
Evidence reviewed 7 items Introduced production changes: The pinned merge-base-to-head diff skips counts only for exact-ID reads and narrows the reconciliation reread to the four fields consumed by the unchanged ownership predicate. Existing query filters, fresh write transaction, and interruption update remain intact.
Current main still performs the extra reads: Fetched main still counts pending inputs during point lookups and selects complete candidate rows during interruption reconciliation. The related publication optimization does not implement this pending-input change. Inspection of the latest release's source failed because its blob was unavailable; no shipped-version claim is made.
Meaningful regression coverage: Extended tests bound point-lookup executions and returned rows, preserve complete stored rows and message content, and verify rollback when interruption fails on the second input. The closed-custody persistence test moves to the consumed-input suite without removing its assertions.
Findings None None.
Security None None.

How this fits together

Pending-input storage holds accepted messages before they enter the conversation transcript. Gateway message lookups and pending-message lists read this storage, which also records interruptions when a session no longer owns queued input.

flowchart TD
  A[Accepted messages] --> B[Pending-input storage]
  C[Gateway message requests] --> D{Single message or list}
  D --> E[Bounded SQLite reads]
  B --> E
  E --> F[Current ownership check]
  F --> G[Record stale interruptions]
  F --> H[Return messages and page metadata]
  G --> H
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +2, Tests +64. Total +66 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 14 12 +2
Tests 2 102 38 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 116 50 +66

Review metrics

Metric Value Why it matters
Reported point-lookup work SELECTs 7 → 4; returned rows 5 → 2 The present, absent, and wrong-session scenarios show reduced database work without changing returned message bytes.
Reported reset read volume Returned text 124,040 → 62,244 bytes Reconciliation avoids fetching the large message payload a second time; this is not a latency or heap measurement.

Technical review

Best possible solution:

Keep the optimization in the existing pending-input owner, preserving full payload reads for callers and fresh custody checks during reconciliation.

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

Not applicable to a functional bug: this is a read-work optimization, and current source confirms both unnecessary reads.

Is this the best way to solve the issue?

Yes. Removing unused query results inside the existing owner is a narrow solution that preserves public results, persisted formats, and transaction semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded performance improvement to pending-message reads with no intended user-visible behavior change.
  • 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 member-authored internal optimization is exempt from external-contributor live proof; reported SQLite owner and registered Gateway tests support the changed read paths, with no material authority change requiring additional proof.

Evidence

What I checked:

  • Introduced production changes: The pinned merge-base-to-head diff skips counts only for exact-ID reads and narrows the reconciliation reread to the four fields consumed by the unchanged ownership predicate. Existing query filters, fresh write transaction, and interruption update remain intact. (src/config/sessions/session-accessor.pending-inputs.ts:467, 246a3d5be78f)
  • Current main still performs the extra reads: Fetched main still counts pending inputs during point lookups and selects complete candidate rows during interruption reconciliation. The related publication optimization does not implement this pending-input change. Inspection of the latest release's source failed because its blob was unavailable; no shipped-version claim is made. (src/config/sessions/session-accessor.pending-inputs.ts:469, 36a725a599bc)
  • Meaningful regression coverage: Extended tests bound point-lookup executions and returned rows, preserve complete stored rows and message content, and verify rollback when interruption fails on the second input. The closed-custody persistence test moves to the consumed-input suite without removing its assertions. (src/config/sessions/session-accessor.pending-inputs.test.ts:834, 246a3d5be78f)
  • Merged measurement prerequisite: GitHub confirms improve(gateway): reduce publication receipt fetches #148144 merged at 00dd4f1. Its counter adds StatementSync.all instrumentation, and the fetched main source contains that correction. (test/helpers/sqlite-statement-execution-counter.ts:56, 00dd4f1738db)
  • Re-review evidence and prior request: The supplied body snapshot, sourceRevision 8da0963d00e7bf0aa844364f0045c14d9579856a4e81a1d663f9d3788f8fec05, reports 72/72 tests on Node 26.8.2 with main 37f2b34 plus the unchanged patch, without an overlay. This addresses the previous integration blocker. A fresh Node 24 run is not claimed; repeating both runtimes is not required here because contribution policy permits either supported runtime and this patch does not change the runtime adapter. Tests were not executed during this read-only review. (246a3d5be78f)
  • Published-head CI identity: The linked CI gate job reports success for the exact reviewed head; this supports validation identity without treating CI as live runtime proof. (246a3d5be78f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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 (1 earlier review cycle)
  • reviewed 2026-09-14T11:51:25.219Z sha 246a3d5 :: blocked before merge. :: none

@steipete
steipete merged commit 7169383 into main Sep 14, 2026
262 checks passed
@steipete
steipete deleted the codex/sqlite-pending-inputs-landing-0914 branch September 14, 2026 14:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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