Repository navigation
perf(sessions): reuse published warm-turn metadata and accounting - #174801
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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis PR reuses published ACP metadata and complete resident transcript accounting instead of repeating worker reads. Example: Read metadata twice for agent:main:acp:absent, then set and clear its ACP metadata.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this is a useful, owner-directed optimization, but an obsolete shared-state replacement assertion still fails exact-head CI. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway session readers consume lifecycle-bound ACP metadata and transcript accounting from existing owner publications, falling back to SQLite workers when coverage is unavailable or reads are fenced. flowchart TD
A[Gateway session readers] --> B[Published ACP metadata]
A --> C[Resident transcript replica]
B --> D[Covered result]
C --> D
B --> E[SQLite workers on cache miss]
C --> E
E --> F[Existing publication owners]
Technical reviewBest possible solution: Retain the owner-publication optimization and update the obsolete display-refresh assertion while preserving configured-alias revocation coverage. Do we have a high-confidence way to reproduce the issue? Source tracing explains the failing shared-state replacement assertion, and the exact-head CI annotation confirms it; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? Reusing existing owner publications is consistent with repository policy and avoids competing cache owners; the remaining correction belongs in the obsolete test expectation. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a1bb732d30bc. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +27, Tests +113, Docs +2. Total +142 across 7 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 16, 2026, 7:45 PM ET / 23:45 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 926e8c3a94
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| publishAcpMetadataRows( | ||
| db, | ||
| missing.map((key) => [key, rows.get(key)] as const), | ||
| true, | ||
| ); |
There was a problem hiding this comment.
Retain authority for published ACP cache hits
When a session-row refresh obtains all ACP metadata from this newly published receipt, prepareSessionRowSharedFacts returns no sharedRead, so withSessionRowDatabaseFacts performs no shared.admission.assertCurrent() after its subsequent awaited ownership/registry work. If the shared-state database is closed and replaced during that interval, the refresh can install metadata borrowed from the retired database instead of rejecting and retrying—the removed shared-state replacement test previously covered exactly this case. Keep an authority handle through installation even when the receipt fully satisfies the read.
AGENTS.md reference: AGENTS.md:L17-L20
Useful? React with 👍 / 👎.
…enclaw#174801) Reuse the Gateway's existing bounded ACP metadata receipt for read cohorts and committed postimages, and derive active transcript accounting from complete resident actor context. Remove the duplicate worker-local ACP caches and redundant warm metadata/accounting roundtrips while retaining cold, partial, pinned, transactional, and fenced read paths. A held internal display refresh may finish with already-published ACP metadata during shared-state replacement. Current authority remains required at real effects; agent-store alias revocation coverage stays. Validation: two completed Codex reviews; 13 focused owner tests and 16 Gateway projection tests; final-head types, lint, source contracts, architecture and database ratchets. Knip has only exact-main inherited findings. Six alternating performance arms are recorded separately; no unmeasured saving is asserted here. Changed async T1 paths remain zero; one shipped synchronous ACP compatibility call site remains.
Backport the ACP publication portion of main fix openclaw#174801 and its row-receipt prerequisite from openclaw#172557. Host readers can consume admitted rows and known absence without losing committed writer postimages; unrelated transcript-accounting and owner-fact optimizations remain out of this release branch. This fixes the release validation projection failure where committed membership was missing while rows were dirty. Main commits: 6ff4834, 744b172 Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Warmed agent turns request ACP metadata twice and read transcript accounting after completion even when the Gateway already holds the same committed facts.
User Impact
Reduces redundant worker roundtrips during ordinary turns while preserving transcript accounting, ACP lifecycle binding, and cold/fenced read behavior. No configuration, schema, SDK, or durability change.
Why This Change Was Made
ACP read cohorts now publish through the existing bounded metadata receipt, including known absence. Subsequent host reads reuse it; the existing writer replaces it with committed postimages. This removes two worker-local caches and their schema/receipt comparison path. Transactions, pinned snapshots, and authorizer-controlled reads retain direct reads.
Active accounting reads use the actor's existing complete resident context and context statistics. The existing accounting policy still determines usage and taint; absent/partial residency and fenced reads retain the worker path. No actor command, completion ordering, cross-store commit ordering, or late-recap behavior changes.
Removed redundant work and accepted limits:
T1: changed async paths remain 0 → 0 main-thread SQLite calls. The retained synchronous
selectAcpSessionRowsite remains 1 → 1: the shipped ACP SDK contract and a bundled cold fast-abort caller still use it. This PR preserves that public contract and does not claim file-wide T1 zero. The fast-abort caller is a follow-up outside the warmed-turn cutover.Evidence
Three alternating shared-harness v3 pairs completed in M1,C1,M2,C2,M3,C3 order. Base:
e69e34001fb5e5439dfac48f53e821d970112625; measured candidate:51dd9d0934c95e5266d00f401000c48784c6860d. Final head926e8c3a94c2663f6ee191dc9554900c70db3606differs only in the Gateway test repair; production code is identical. All six arms validated the exact head, ten warm turns, successful compaction/restart/shutdown, complete causal coverage, and zero native SQL/prepare errors. Node 24.22.0 and actual SQLite 3.54.0 were pinned, with executable/native-library hashes; compile caching was disabled. The shared workload is unchanged; a task-local observer patch adds only sanitized module/command labels. No wall-time claim on the busy host.Every one of the 30 matched warm turns saves exactly 3 SQL statements and 3 worker requests, with zero causal MAIN statements. This is 22 → 19 requests (−13.6%), so the ≤18-request aim is not reached. The SQL median is 67 → 64 (−4.5%). Raw windows include background work and also improve in median.
Removed warm requests (once each per base turn, absent in every candidate turn):
The remaining warm request-class count sequences are identical. The former SQL-free UNKNOWN publication is observed as
standing-intents.worker.js:matchand remains unchanged;recordProviderPromptremains a CPU task in its separate worker. Shared warm read families are unchanged: row facts 2 SQL/2 requests per turn; exact-entry facts, actor hydration, entry-cache snapshots and watermarks are zero.Whole-workload raw counts (SQL / requests / MAIN):
Background caveats remain in these totals. C1 contains one 34-SQL/1-request projection preflight during restart-first-turn; it is absent in all five other arms. Its exact initiating trigger is unresolved, so no causal explanation is claimed. MAIN variation is background work: 13 lease-expiry statements move between first-turn/warm windows, and the extra cold-boot timeout setter occurs on both M3 and C2. Whole MAIN has identical median/range on both sides. No statements or requests are unattributed.
All ten warm turns in all three pairs
Counts are SQL / requests / MAIN. Causal follows the initiating turn; raw includes all work in its execution window.
Phase-specific raw counts
Each cell is SQL / requests / MAIN, median [min–max] over three arms. Warm per-turn counts are above. Fixture construction is unmeasured, not zero; cron and compaction execute as background-attributed work in their named windows.
Validation and limitations
Two Codex autoreview rounds found no actionable P0–P2 defects. All three changed owner suites passed (13 tests), covering ACP cache/snapshot isolation, known absence followed by in-process set/clear, and resident accounting across appends/completion with cold/fenced fallback. The repaired Gateway projection file passed all 16 remaining tests, including agent-store alias revocation. Changed-file type-aware lint, formatting and diff checks passed.
Initial CI exposed an obsolete shared-state-replacement assertion: it expected a display refresh to make an extra admission read. The base passed and the candidate resolved using published metadata. The test-only repair removes that expectation and preserves agent-store revocation coverage. Two local repair replays stopped before assertions because the temporary checkout lacked workspace dependency links; the corrected setup passed 16/16.
Final-head CI run 38983288459 completed successfully, including types, lint, source contracts, architecture/Madge, T1/dialect/worker ratchets, owner tests and PostgreSQL conformance. Required CI, dependency and security-sensitive review gates were green at merge. Knip completed all three modes with 3 production / 11 full-tree / 2 script findings, all exact inherited matches to main run 38976134677; zero new findings. This is an inherited-only failure, not a clean scan. The test-only final repair changes no imports/exports/mocks. SDK API diff and the published-driver update cell do not apply: no SDK, update, Doctor, schema, plugin-loading or service-lifecycle change.
LOC against base: production +102/−75 (net +27), tests +191/−101, docs +7/−5. Growth is the accounting projection over the existing replica; ACP shrinks by 37 lines and removes both worker-local caches. Actor command/order, cross-store ordering and late recap are unchanged. A possible follow-up is fusing runtime-target resolution into turn preparation; it is unimplemented and unmeasured here.