Repository navigation
improve: avoid full session scans during Gateway admission - #149388
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 16, 2026, 12:05 AM ET / 04:05 UTC (Revision 6). ClawSweeper reviewWhat this changesThe PR tracks changed session rows in SQLite and validates them through the existing worker, reducing Gateway admission scans while adding schema-21 migration and backup-restoration coverage. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 3 items remain This PR remains necessary: current main still repeats validation for fresh connections. No blocking defect was found, and the accepted schema decision plus updated compatibility evidence resolve the earlier review concern without requiring renewed approval. Priority: P2 Review scores
Verification
How this fits togetherGateway admission checks saved session metadata before authorizing requests. This change lets fresh database readers reuse validation of unchanged rows while session permissions and identity remain freshly checked. flowchart TD
A[Gateway request] --> B[Reader admission]
B -->|Already certified| E[Read current session]
B -->|Validation needed| C[Pending session keys]
C --> D[Existing SQLite worker]
D -->|Certify current rows| E
E --> F[Recheck live authorization]
F --> G[Dispatch allowed request]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1316, Tests +2008, Docs +62, Config 0, Generated +5, Other +745. Total +4136 across 74 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep incremental validation with the existing database and worker owners, preserving the accepted backup-based upgrade contract and fresh authorization at dispatch and commit. Do we have a high-confidence way to reproduce the issue? Yes, from source: a fresh connection on current main misses connection-local validation and scans unrelated session rows before admission; the supplied benchmark exercises that path, but this review did not rerun it. Is this the best way to solve the issue? Yes. The accepted design addresses validation lifetime through the existing owners, with transactional invalidation and current authorization rather than cached permission results. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against c4a6c17dafbf. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
f4f96c1 to
3d3e4b5
Compare
7923f33 to
f8a2ce1
Compare
Track canonical validation with the physical database verification owner and certify schema-21 pending rows in bounded retained-worker batches. Keep native reader admission keyed to its exact handle, main-key policy, and physical receipt while selected session reads and synchronous commit guards stay current. Preserve warm transcript-root policy reuse and validation-before-key-refusal ordering. Keep legacy Workshop catalog repair owned by Doctor, and retain the published-updater schema migration and backup rollback proof. Accepted design: #149323.
f8a2ce1 to
e716a8f
Compare
|
Compatibility verification is complete for A fresh paired Testbox run exercised the actual published All 152 captured raw files and hashes were independently checked. The evidence includes the schema-19 → 21 update, candidate turns/Doctor, verified backup restoration, schema-19 no-write preflight, original conversation read, and all five required Workshop process witnesses. The pinned helper compared 26 logical tables/six transcript events and preserved the absent agent database. Database archives were not exported for a second offline hash pass. The scope limits remain explicit: rollback restores the backup point, the packaged conversation is a single-conversation cell, and the component benchmark establishes no production latency or memory bound. These limits are not claims of in-place downgrade, volume rollback, or restored Gateway history rendering. Exact-head CI is also successful, and independent full-candidate review has no P0–P2 findings. |
|
Merged via squash.
|
Reuse the entry already read in the current write transaction when capturing previous session identity. Preserve the other lookup keys, current authority checks, post-write identity reads, and canonical certification. This resolves the interaction between #149537 and #149388 without changing the existing query budget. The unchanged test reproduces on their combined main state; all 38 Goal, identity, and canonical-validation tests pass after repair.
* fix(cron): normalize current-session completion payloads * fix(cron): account for completed interim retry prompts * fix(cron): preserve final context after retry accounting * refactor(cron): centralize stale delivery policy * fix(cron): clear stale billing after context-only retries * fix(sessions): reuse the admitted entry during Goal edits Reuse the entry already read in the current write transaction when capturing previous session identity. Preserve the other lookup keys, current authority checks, post-write identity reads, and canonical certification. This resolves the interaction between #149537 and #149388 without changing the existing query budget. The unchanged test reproduces on their combined main state; all 38 Goal, identity, and canonical-validation tests pass after repair. * refactor(ui): simplify chat pane callbacks Keep the existing progress-dismiss and agent-change callbacks as explicit void expressions, preserving their undefined returns and side effects. This brings the renderer back within its existing max-lines limit after #149384 without changing UI behavior. * fix(ci): accept file paths in extension packing fixtures
Use the existing two-agent preflight budget and scoped reclamation workers to overlap first-admission certification. Retain each worker across its agent's batches, join native close before downstream consumers, and drain active tasks before surfacing a refusal. Keep ordinary archive FIFO and runtime worker reuse intact. Preserve process-local physical proof and per-agent write authority. Keep legacy-main and managed-worktree startup detection-only after #150110, report pending worktree repairs from awaited found counts, and leave repair writes with Doctor. Related: #149538, #148529, #149323, #150110. Trigger: #149388. Reported by @609NFT.
Use the existing two-agent preflight budget and scoped reclamation workers to overlap first-admission certification. Retain each worker across its agent's batches, join native close before downstream consumers, and drain active tasks before surfacing a refusal. Keep ordinary archive FIFO and runtime worker reuse intact. Preserve process-local physical proof and per-agent write authority. Keep legacy-main and managed-worktree startup detection-only after #150110, report pending worktree repairs from awaited found counts, and leave repair writes with Doctor. Related: #149538, #148529, #149323, #150110. Trigger: #149388. Reported by @609NFT.
…enclaw#149388) Track canonical validation with the physical database verification owner and certify schema-21 pending rows in bounded retained-worker batches. Keep native reader admission keyed to its exact handle, main-key policy, and physical receipt while selected session reads and synchronous commit guards stay current. Preserve warm transcript-root policy reuse and validation-before-key-refusal ordering. Keep legacy Workshop catalog repair owned by Doctor, and retain the published-updater schema migration and backup rollback proof. Accepted design: openclaw#149323.
…49697) * fix(cron): normalize current-session completion payloads * fix(cron): account for completed interim retry prompts * fix(cron): preserve final context after retry accounting * refactor(cron): centralize stale delivery policy * fix(cron): clear stale billing after context-only retries * fix(sessions): reuse the admitted entry during Goal edits Reuse the entry already read in the current write transaction when capturing previous session identity. Preserve the other lookup keys, current authority checks, post-write identity reads, and canonical certification. This resolves the interaction between openclaw#149537 and openclaw#149388 without changing the existing query budget. The unchanged test reproduces on their combined main state; all 38 Goal, identity, and canonical-validation tests pass after repair. * refactor(ui): simplify chat pane callbacks Keep the existing progress-dismiss and agent-change callbacks as explicit void expressions, preserving their undefined returns and side effects. This brings the renderer back within its existing max-lines limit after openclaw#149384 without changing UI behavior. * fix(ci): accept file paths in extension packing fixtures
…aw#150188) Use the existing two-agent preflight budget and scoped reclamation workers to overlap first-admission certification. Retain each worker across its agent's batches, join native close before downstream consumers, and drain active tasks before surfacing a refusal. Keep ordinary archive FIFO and runtime worker reuse intact. Preserve process-local physical proof and per-agent write authority. Keep legacy-main and managed-worktree startup detection-only after openclaw#150110, report pending worktree repairs from awaited found counts, and leave repair writes with Doctor. Related: openclaw#149538, openclaw#148529, openclaw#149323, openclaw#150110. Trigger: openclaw#149388. Reported by @609NFT.
Closes #149323
What Problem This Solves
Initial session authorization and new SQLite readers can stall the Gateway while validating every saved session, including large prompt metadata, even when the physical database was already verified.
User Impact
Session admission reuses validation of unchanged rows across connection lifetimes. Startup and initial Gateway authorization validate pending rows in the existing session mutation worker, then reread current authorization before dispatch. Warm reader behavior, selected-row freshness, write ordering, transcript bytes, and retention remain unchanged.
This requires agent schema 21. Maintenance atomically installs the required pending-key table and invalidation triggers and marks existing rows pending without rewriting their JSON. Older builds refuse the migrated database. Rollback requires a verified pre-migration backup and its matching build, returning state to that backup point and excluding subsequent work. Changing schema markers or deleting the derived table is not a supported downgrade. The accepted design is recorded in #149323.
Worker startup increases elapsed readiness time and memory use. Writes perform additional validation and trigger work. The measurements below are component measurements; they do not establish production latency, memory bounds, or a fixed event-loop pause ceiling.
Why This Change Was Made
The existing database-validation owner retains first-proof status for the physical database; SQLite triggers record later canonical changes transactionally. Canonical writers certify pending stored metadata inside their existing transaction without decoding saved prompts again. The retained worker drains other changes in bounded batches and rejoins FIFO admission between them. Replacement, invalidation, and rolled-back work cannot publish successful proof.
Native admission remains keyed to the exact handle, normalized main-key policy, and physical receipt. Exact reads open a snapshot only when their guard needs new admission, so warm reads avoid extra transactions. Selected rows are read freshly; no authorization result is cached. After awaited readiness, the Gateway repeats method, profile binding, startup, and session authorization, and commit guards remain synchronous and current.
The final integration preserves main's validated-policy reuse for transcript-root writes and its
excluded-value upserts. Cold validation retains its existing post-validation policy read and error order. Legacy catalog repair remains owned by Doctor, including its newly landed migration ordering.Evidence
The combined candidate
e716a8fbc203includes landed Doctor #148834. 299 focused tests pass, covering canonical admission, physical receipts, root-policy ordering, writes, Gateway reauthorization, migration/rollback helpers, and the Doctor Workshop cases. The full selected changed-code gate passes across TypeScript, lint, dead exports, and runtime import cycles. Fresh independent review of the full combined candidate is clean through P2. Earlier composed reader/search/send integration passed 238 tests, including current visibility, async scope retirement, and accepted-send settlement.The preceding reviewed head
f8a2ce1ab4a4passed full CI. The combined heade716a8fbc203also passed its own CI.Fresh paired package proof passed in Testbox run 35051588915, pinned to source
e716a8fbc203and treea8a7f657e3adcff4e812c55e51e9b16bf60d454c. Bothlegacy-operator-stateandworkshop-doctor-recoverypassed on their first attempts using published[email protected], one package, and no live provider credentials. The complete pack/run took 603 seconds. The Testbox command exited successfully before cleanup; its carrier workflow may display cancelled when the lease is stopped.All 152 captured raw files and their hashes were checked independently. Legacy-state proof used the actual published updater, migrated agent schema 19 → 21, exercised candidate turns and Doctor without recovery, restored a verified backup, and read the original conversation with the retained schema-19 reader. The pinned rollback helper compared 26 logical tables and six transcript events against the captured baseline and preserved the absent agent database. Those database hashes were checked by the executed helper; databases were not exported for a second offline hash pass.
Workshop proof verified the original refusal left malformed state unchanged, explicit published Doctor repaired it, the published updater then ran candidate Doctor successfully, and fresh-seed standalone candidate Doctor also repaired it. All five required process witnesses matched their raw start/exit records, build identities, state flags, and parent relationships; extra continuation processes were distinguished from those witnesses.
The shared tarball SHA-256 is
d0addd76bdb876630a93f58735c30b54e68600a560ac41dcb5e6864989242608, with state schema 17 / agent schema 21. Its embedded build commit is Testbox materialization5a8c350f4278c4812d72600b0e55bb2992febeb8, whose complete source tree was verified identical to the published candidate tree above. This proof preserves one conversation; it does not claim restored Gateway history rendering or volume rollback.The earlier completed Package Acceptance run, pinned to
a1d892cada28, exercised the actual published updater: agent schema 19 → 21, candidate turns and Doctor, backup restoration, and the retained baseline's session reader. Its Docker artifact records successful rollback, restored schema-19 preflight, one readable conversation, six transcript events, and 26 matching logical-table hashes. The absent agent database remained absent. The single runtime attempt passed in 409 seconds. This proves one-conversation preservation, not restored Gateway history rendering or volume rollback.The package artifact declares state schema 17 / agent schema 21 and embeds tested commit
a1d892cada28. Its tarball SHA-256 is83814885bf119ad69b72bdf1398388f9bbf3a0b6ca47900d6ccbbf9f74e10b92. Package metadata, build identity, downloaded artifact hashes, and raw rollback receipts were independently checked. Installer and package-integrity jobs passed.Synthetic source-runtime measurements use 3,706 sessions with 32 KiB of saved prompt metadata per session and actual accessor/authorization entry points on Node 26.8.2. They compare base
14b8ad1d1871witha1d892cada28in separate processes with a warm OS cache. Parent build/test work was paused; unrelated host load was uncontrolled. This benchmark predates the final integration above.Normal writes added about 0.118 ms (28.7%). Cold-worker readiness took 1.62 seconds, with a 72.6 ms maximum loop delay and 7.3 ms p99. Cold logging and mandatory commit settlement remain sources of pauses. Full inventories retain their scan path; their separate single-sample probe is not a steady-state throughput comparison.