Repository navigation
perf(state): reuse committed agent deletion status on turn admission - #169738
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: needs real behavior proof before merge. What this changesThis PR reuses committed agent-deletion status during session admission instead of repeatedly querying SQLite. Example: Agent doomed admits another turn after its deletion status was loaded.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep this useful maintainer-directed optimization open; prior findings are resolved, and no new discrete code defect was identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherJournal writers publish committed per-agent facts through the physical database owner; session admission consumes them before admitting work. flowchart LR
A[Journal writers] --> B[SQLite transaction]
B --> C[Committed database facts]
C --> D[Session admission]
E[Deletion ingress closure] --> D
D --> F[Session work]
Technical reviewBest possible solution: Reuse the existing committed-fact transport and deletion closure while preserving final-effect refusal and recovery behavior. Do we have a high-confidence way to reproduce the issue? Current main visibly repeats deletion-status worker reads during admission; the reported eight-per-turn cost was not independently measured in this read-only review. Is this the best way to solve the issue? The existing physical-database fact owner fits the documented writer contract and avoids introducing another synchronization owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7c4ff5ae0a4c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +97, Tests +160, Docs +8, Other +1. Total +266 across 19 files. Added test files: 1. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 HistoryReview history (2 earlier review cycles)
Reviewed October 12, 2026, 4:52 AM ET / 08:52 UTC (Revision 3). |
|
The latest completed ClawSweeper review has no code findings. Its earlier wrapper-inventory and worker-test-pool findings are fixed. CI passed all 129 cases across the 11 changed test files, including native-worker deletion publication, queued-work rejection, next-turn rejection without journal requests, rollback, and tombstone reload. Existing final-effect and destructive-cleanup guards remain unchanged. The final PR run's only failing test is the rewind query-count assertion, which fails identically on main run 38216343022. The two Knip findings also match current main exactly. The suppression-inventory failure was fixed by integrating main. The requested additional combined live recording of surviving-agent work, deleted-agent refusal, and tool execution remains a follow-up. No demonstrated defect requires extending this patch; the changed admission boundary is covered by the passing owner regressions. The completed SQL run confirms journal work fell from eight statements and eight requests per warmed turn to zero; full measurement attribution and the update-cell result are being recorded in the PR body. |
…penclaw#169738) Warm session admission added eight deletion-journal statements and eight worker requests per turn after openclaw#168199. Reuse committed per-agent facts through the existing database admission transport, and publish or invalidate them at every journal writer. Preserve queued-work revocation, active-run draining, persisted tombstones, and final cleanup authority. The live comparison removes all eight statements and requests from warmed turns; whole-workload deletion-status calls fall from 124 to one. Owner regressions cover native-worker deletion, queued and next-turn refusal, commit/rollback, completion/removal, and reload. Full measurement attribution, static-check evidence, inherited CI failures, and update proof are recorded in the PR.
What Problem This Solves
Session admission rereads the agent deletion journal eight times per warmed turn, adding eight SQLite statements and eight worker requests after #168199.
User Impact
Admission now reuses the Gateway's committed deletion status. Pending and completed deletion still refuse new runs, queued work is revoked, active runs retain their existing drain/settlement owner, and persisted tombstones survive restart. No schema, retention, durability, permission, or update-policy change.
Why This Change Was Made
The existing physical-database fact owner retains one status per agent. First admission loads it; journal writers publish replacements through the existing commit/rollback and worker transport. Execution workers consume those transferred facts. No new polling, generation, timer, or cross-thread handshake.
Writer coverage:
beginAgentDeletionJournalInDatabase,completeAgentDeletionJournalInDatabase, anddeleteAgentDeletionJournalInDatabasepublish pending, complete, and absent respectively. These leaf writers cover native workers, Claw removal, CLI, and journal helpers; rollback retains the previous fact.Removed checks and accepted edges:
Uncached execution-worker reads remain only in deferred startup preparation. Current journal/lease checks at destructive cleanup and cancellation boundaries remain intact.
Evidence
One live baseline/candidate pair used isolated state and the shared SQL workload. Baseline:
cdb57ac7acdc; candidate:87010686ac26. Later corrections only register the test pool/wrapper and invalidate offline Doctor facts; they do not change the measured warmed path. Final head1422875e896falso merges main without conflicts to include its tooling inventory fix.Whole-workload deletion-status SQL and worker requests both fell from 124 to 1, with only first admission reading the journal.
The candidate's warmed turns took 7.5× longer on the loaded host (one-minute load 146.4 versus 59.9). Raw counts increased in unchanged work; the changed journal operation adds none. Mean per-turn attribution reconciles the full increase:
The retained
agentDatabaseDeletion.snapshotoperation also runs more often in the longer windows (+1.2 SQL/+0.2 requests per warmed turn); its snapshot reader is unchanged and remains outside the removed status-read family.The four extra warmed MAIN statements are unchanged scheduled GitHub OAuth maintenance reads. First-turn SQL/requests/MAIN: 1,029/209/40 → 822/177/40. Whole-workload SQL/requests/MAIN: 9,233/1,654/1,983 → 10,191/1,909/1,996.
All 13 chat turns, child work, cron, compaction, and shutdown completed. The harness wrapper returned 1 because the auxiliary
mentions.dismissRPC returned retryableUNAVAILABLE; its unchanged owner swallows the underlying cause, so this is not claimed as a fully passing harness. Shutdown also logged an agent-database lease-releaseBEGIN IMMEDIATElock refusal. Neither diagnostic adds journal work; both are retained as proof limitations.T1: the status-read family is worker tier W (0 → 0 T1). Two existing T1 calls in the broader touched journal modules—deletion-history and path-fence reads—remain 2 → 2; this lane changes no T1 callsite.
Validation and CI disposition
64f11ced232c7, fixing the inherited Bun suppression inventory mismatch.pnpm deadcode:full. Its only findings are unusedgateway-prewarm.mjsand unusedrenderPublicSessionCardSvginsrc/gateway/control-ui-public-session-card-render.ts. Current main, atb82b033920ee, reports the exact same rule/file set. Remaining manual jobs were cancelled after the required scan.391d4ca5dfea: published driver 2026.10.2, all 22 phases successful, readiness HTTP 200, running version verified, and durable/incognito state checks passed. The canonical fixture relabeled candidate version 2026.10.1 to 2026.10.2 while retaining the tested source SHA. Lane time: 661 s; update command: 544.23 s. Doctor's writer is touched, so this cell is required; the conflict-free main integration does not change this lane's Doctor behavior.LOC: +278/−12 across 19 files (production +107/−10, tests +162/−2, docs +8, wrapper inventory +1). No dependency or SDK change.