Repository navigation
fix(proxy-capture): make path-based session cleanup atomic - #98852
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:29 PM ET / 17:29 UTC. ClawSweeper reviewWhat this changesMakes path-based proxy-capture session cleanup atomic by wrapping related SQLite event/session deletions in the existing immediate transaction helper and adds rollback-and-retry regression coverage. Merge readinessThis PR remains necessary: current main still performs the two path-based cleanup deletes outside a transaction, while the branch applies the repository’s existing synchronous transaction owner to both affected cleanup paths. The patch is correct on source review, includes direct fault-and-retry proof, and needs only the normal exact-head CI/merge gate before landing. Priority: P2 Review scores
Verification
How this fits togetherProxy capture stores diagnostic sessions, captured events, and payload blobs in SQLite plus a path-based blob directory. Cleanup receives a session selection or purge request, removes the database records, then removes unreferenced payload files; the database portion must not partially commit. flowchart LR
A[Cleanup request] --> B[Path-based proxy capture store]
B --> C[Read sessions, events, and blob references]
C --> D[Immediate SQLite transaction]
D --> E[Delete events and sessions together]
E --> F[Find unreferenced payload blobs]
F --> G[Remove payload files]
G --> H[Return cleanup counts]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +4, Tests +61. Total +65 across 2 files. View PR surface stats
Review metricsNone. 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: Land the focused transactional repair after the current head passes required checks, preserving filesystem cleanup outside the committed SQL transaction. Do we have a high-confidence way to reproduce the issue? Yes. Current main visibly executes the path-based delete pairs outside a transaction, and the PR supplies a real file-backed Node SQLite authorizer failure/retry run that demonstrates the resulting partial state and its rollback after the fix. Is this the best way to solve the issue? Yes. Reusing the existing synchronous immediate-transaction helper at the database owner boundary is narrower and safer than compensating after partial deletion; the paired test covers both cleanup siblings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 586e1fe10e11. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
@clawsweeper re-review |
1 similar comment
|
@clawsweeper re-review |
|
@clawsweeper re-review |
93514ba to
ceefb52
Compare
Maintainer real SQLite crash-atomicity verificationPreserved the original @zhangLei99586 contributor and original first human authorship for #98959, refreshed the previously conflicting branch, and fixed both path-based cleanup siblings at their canonical synchronous SQLite owner. Exact real file-backed production store, actual payload files, actual Node SQLite authorizer fault, and retry proof: node --import tsx --input-type=module -e 'import {constants} from "node:sqlite";import {existsSync,mkdtempSync,rmSync} from "node:fs";import {tmpdir} from "node:os";import {join} from "node:path";import {acquireDebugProxyCaptureStore} from "./src/proxy-capture/store.sqlite.ts";const results=[];for(const operation of ["deleteSessions","purgeAll"]){const directory=mkdtempSync(join(tmpdir(),"openclaw-proxy-98852-"));const databasePath=join(directory,"capture.sqlite");const blobDirectory=join(directory,"blobs");const lease=acquireDebugProxyCaptureStore(databasePath,blobDirectory);try{lease.store.upsertSession({id:"session",startedAt:1,mode:"sdk",sourceScope:"openclaw",sourceProcess:"plugin",dbPath:databasePath,blobDir:blobDirectory});const blob=lease.store.persistPayload(Buffer.from("rollback payload"),"text/plain");lease.store.recordEvent({sessionId:"session",ts:2,sourceScope:"openclaw",sourceProcess:"plugin",protocol:"https",direction:"outbound",kind:"request",flowId:"proof-flow",dataBlobId:blob.blobId,dataSha256:blob.sha256});const cleanup=()=>operation==="deleteSessions"?lease.store.deleteSessions(["session"]):lease.store.purgeAll();lease.store.db.setAuthorizer((action,table)=>action===constants.SQLITE_DELETE&&table==="capture_sessions"?constants.SQLITE_DENY:constants.SQLITE_OK);let failure;try{cleanup()}catch(error){failure=error.message}lease.store.db.setAuthorizer(null);const afterFailure={error:failure,sessions:lease.store.listSessions().length,events:lease.store.getSessionEvents("session").length,blobExists:existsSync(blob.path),transactionActive:lease.store.db.isTransaction};const retry=cleanup();const afterRetry={result:retry,sessions:lease.store.listSessions().length,events:lease.store.getSessionEvents("session").length,blobExists:existsSync(blob.path),schemaVersion:lease.store.db.prepare("PRAGMA user_version").get().user_version};results.push({operation,afterFailure,afterRetry})}finally{lease.store.db.setAuthorizer(null);lease.release();rmSync(directory,{recursive:true,force:true})}}process.stdout.write(JSON.stringify({node:process.version,dependency:"node:sqlite DatabaseSync.setAuthorizer SQLITE_DELETE/SQLITE_DENY",results})+"\n")'Before, current main: {"node":"v26.5.0","dependency":"node:sqlite DatabaseSync.setAuthorizer SQLITE_DELETE/SQLITE_DENY","results":[{"operation":"deleteSessions","afterFailure":{"error":"not authorized","sessions":1,"events":0,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":0,"blobs":0},"sessions":0,"events":0,"blobExists":true,"schemaVersion":1}},{"operation":"purgeAll","afterFailure":{"error":"not authorized","sessions":1,"events":0,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":0,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}}]}After, exact contributor head b13ba94: {"node":"v26.5.0","dependency":"node:sqlite DatabaseSync.setAuthorizer SQLITE_DELETE/SQLITE_DENY","results":[{"operation":"deleteSessions","afterFailure":{"error":"not authorized","sessions":1,"events":1,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":1,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}},{"operation":"purgeAll","afterFailure":{"error":"not authorized","sessions":1,"events":1,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":1,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}}]}Both real operations previously left one session but zero events after the second delete failed; deleteSessions retry also orphaned its on-disk blob. Both now roll back the SQL pair, preserve session/event/blob, and retry safely removes all three. Blob filesystem I/O stays outside and after the synchronous SQL-only transaction; user_version stays 1. OPENCLAW_VITEST_FS_MODULE_CACHE_PATH=/private/tmp/openclaw-vitest-s02-98852-b13ba942 node scripts/run-vitest.mjs src/proxy-capture/store.sqlite.test.tsFocused owner suite passes (independent exact owner run: 13 tests), targeted formatting and git diff --check pass, and fresh Codex Sol xhigh autoreview is clean. Exactly two owner paths changed, +4 net production lines, no schema migration. Both ClawSweeper rank-up moves are satisfied. Rebased the exact same two-file owner patch over the already-landed unrelated main tooling fix |
ceefb52 to
b13ba94
Compare
|
Merged via squash.
|
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
Fixes #98959
Original contributor and issue reporter: @zhangLei99586. The original human Git author, email, and first authored timestamp are preserved.
What Problem This Solves
The shipped path-based Plugin SDK proxy-capture store deleted capture events and capture sessions in separate SQLite auto-commit operations. A real failure on the second delete permanently removed the events while leaving the session behind; retrying
deleteSessionscould also strand the real payload blob. The sibling path-basedpurgeAllhad the same atomicity defect.Why This Change Was Made
Use the already-existing synchronous
runSqliteImmediateTransactionSyncowner around only the SQL deletes in both path-baseddeleteSessionsandpurgeAll. All blob filesystem inspection and deletion remains outside and after the committed SQLite transaction. The non-path-based/shared-state implementations already own equivalent transactional behavior.The original contributor branch predated a major store rewrite and no longer merged. This takeover reapplies the same original architectural fix onto current main, covers the sibling with the identical violated invariant, and adds actual fault-injection regression coverage. Production delta is four net lines; there is no schema migration, schema-version bump, configuration, dependency, or public API change.
User Impact
Interrupted or failed path-based diagnostic cleanup can no longer silently corrupt session/event relationships or orphan capture payloads. Successful cleanup retains its existing counts and behavior.
Evidence
Real production
acquireDebugProxyCaptureStore, actual file-backed Node SQLite, actual on-disk payload blobs, and realDatabaseSync.setAuthorizer(SQLITE_DELETE => SQLITE_DENY)fault injection on the second SQL delete, with the same failure-then-retry execution order for both cleanup operations:Before, current main:
{"node":"v26.5.0","dependency":"node:sqlite DatabaseSync.setAuthorizer SQLITE_DELETE/SQLITE_DENY","results":[{"operation":"deleteSessions","afterFailure":{"error":"not authorized","sessions":1,"events":0,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":0,"blobs":0},"sessions":0,"events":0,"blobExists":true,"schemaVersion":1}},{"operation":"purgeAll","afterFailure":{"error":"not authorized","sessions":1,"events":0,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":0,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}}]}After, exact refreshed contributor head
b13ba9423a39540e012f61f0a4ecfe07e0fbf3bf:{"node":"v26.5.0","dependency":"node:sqlite DatabaseSync.setAuthorizer SQLITE_DELETE/SQLITE_DENY","results":[{"operation":"deleteSessions","afterFailure":{"error":"not authorized","sessions":1,"events":1,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":1,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}},{"operation":"purgeAll","afterFailure":{"error":"not authorized","sessions":1,"events":1,"blobExists":true,"transactionActive":false},"afterRetry":{"result":{"sessions":1,"events":1,"blobs":1},"sessions":0,"events":0,"blobExists":false,"schemaVersion":1}}]}Before, both operations persist
sessions=1, events=0after the injected failure, and a retry ofdeleteSessionsalso leaves its payload blob orphaned. After, both operations roll back tosessions=1, events=1, blobExists=true, leave no active transaction, and a safe retry deletes one session, one event, and one blob.PRAGMA user_versionremains exactly1.Focused owner suite passes, including both new real SQLite authorizer regressions; independent repeated proof reports 13 passing tests. Targeted oxfmt and
git diff --checkpass. Fresh Codex Sol xhigh autoreview reports no accepted or actionable findings.Both ClawSweeper rank-up moves are complete: the conflict is resolved on current main, only synchronous SQL statements are inside the transaction, blob filesystem work remains outside it, and the focused path-based owner suite passes.
The exact unchanged two-file owner patch was rebased over the already-landed main fix
a14ada134f91c92f76d2bc886ae75b7c7dc0cc0dafter an unrelated CI tooling baseline failure. Both formerly failing oxlint shard-routing owner expectations now pass (2/2); the focused proxy-capture owner suite passes 13/13 again; fresh Codex Sol xhigh commit review is clean.