Repository navigation
fix: report session changes during deletion - #125188
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 6:14 AM ET / 10:14 UTC. ClawSweeper reviewWhat this changesThe PR reports a retryable session-changed result when SQLite session deletion detects a concurrent replacement during archival or final deletion, rather than returning a successful no-op. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep this fresh maintainer-owned PR open for normal merge review. The new lifecycle-owner result converts each guarded deletion race into the existing Gateway retry signal, and focused owner plus Gateway regressions cover the late materialization path; exact-head checks are still running. Priority: P1 Review scores
Verification
How this fits togetherA Gateway sessions.delete request enters the SQLite session lifecycle, which snapshots the target, archives generations outside short transactions, then deletes the authoritative row. The result controls client retry behavior and subsequent session cleanup events. flowchart LR
A[Gateway delete request] --> B[Session lifecycle admission]
B --> C[SQLite target snapshot]
C --> D[Archive historical generations]
D --> E{Snapshot and transcript still match?}
E -->|yes| F[Delete session state]
E -->|no| G[Retryable session-changed response]
F --> H[Gateway session events]
Decision needed
Why: The patch is a focused owner-boundary fix with no remaining code finding, but the protected maintainer label and pending exact-head validation require a human merge decision. Before merge
Agent review detailsSecurityNone. PR surfaceSource +23, Tests +184. Total +207 across 8 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the lifecycle owner as the single translator of late snapshot conflicts, then merge after exact-head checks confirm the focused race coverage and changed gate remain green. Do we have a high-confidence way to reproduce the issue? Yes, from source and focused regression tests: replace the guarded entry or transcript after archive materialization and invoke sessions.delete; current main can return deleted false as a successful response, while this branch produces session-changed. Is this the best way to solve the issue? Yes. Translating conflicts at the SQLite lifecycle owner covers every late deletion checkpoint and lets the existing Gateway error projection remain the only client-facing translation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7efd0f0feb66. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
6ff4725 to
38dcdc6
Compare
11120ae to
648f019
Compare
Land-ready proofExact head:
Pre-fix proof: the original Gateway regression returned false success; the added post-materialization owner and Gateway regressions failed on the intermediate head with LOC: production +69/-46 (net +23); tests +302/-118 (net +184); PR tooling +0/-0. Mainline ratchet maintenance #125185 is tooling-only and is reflected by the green 501/501 gate. Known gap: no live proof was run. This is a deterministic internal SQLite lifecycle race covered at the direct owner and Gateway RPC boundaries; ClawSweeper also marked external real-setup proof not applicable. Native landing evidence:
|
|
Merged via squash.
|
* fix(sessions): report deletion lifecycle mismatches * fix(sessions): translate late deletion conflicts * refactor(sessions): move lifecycle snapshot equality
What Problem This Solves
Fixes an issue where a concurrent session replacement after delete validation could silently return
ok: truewithdeleted: falsewhile the session survived. That false success was indistinguishable from the intentional missing-session no-op and gave operators and clients no signal to retry.Why This Change Was Made
The SQLite session lifecycle now records an expected-entry mismatch at every guarded deletion phase, including target-snapshot changes after transcript materialization, preserves any historical archives already committed before a later mismatch, and keeps only the authoritative-entry-absent case benign. The producerless file-era
deletedSessionFileresult field and gateway consumer were removed.During landing, mainline maintenance PR #125185 independently restored the
OPENCLAW_*shrink-only ratchet to the actual 501-name production surface. This branch is rebased onto that maintenance; it is not part of the product behavior change.User Impact
Operators and clients now receive the retryable
session-changederror when a session is replaced during deletion instead of receiving false success.Evidence
Before the initial fix, the gateway boundary regression expected
ok: falsebut receivedok: trueafter replacing the exact row once cleanup had captured the expected entry. The added post-materialization owner and Gateway regressions then failed on the intermediate patch withSqliteSessionMutationConflictError, proving the late snapshot conflict identified by ClawSweeper; both pass after translating that conflict at the lifecycle owner.node scripts/run-vitest.mjs src/gateway/server.sessions.delete-lifecycle.test.ts src/gateway/server.sessions.delete-worktree-lifecycle.test.ts src/config/sessions/session-accessor.sqlite-cleanup-race.test.ts— 44 tests passed across two shards (28 gateway, 16 runtime-config).node scripts/check-changed.mjs --dry-run -- <eight changed files>— selected core and coreTests lanes.node scripts/check-changed.mjs -- <eight changed files>— exit 0; the environment ratchet reportsOPENCLAW_* count 501/501, with format, type, lint, max-lines, dead-code, database-first, import-cycle, and boundary guards green.git diff --check origin/main...HEAD— passed..agents/skills/autoreview/scripts/autoreview --mode uncommitted— clean after the ClawSweeper repair, no accepted/actionable findings.Production LOC: +69/-46 (net +23). Tests: +302/-118 (net +184, including the existing worktree deletion test move). PR tooling LOC: +0/-0. The positive production delta adds one reusable snapshot predicate in the mainline equality owner and complete mismatch propagation at the three late lifecycle checkpoints; placing it there also preserves the 700-line entry-store ceiling after #125057. The absorbed mainline ratchet maintenance in #125185 was tooling-only +2/-2 and is verified here by the green 501/501 gate.
Regression provenance: PR #113075 / commit c440ae3 removed the legacy producer on 2026-07-23; PR #113233 / commit 4273ca9 carried the stale file-era
deletedSessionFileresidue forward.No live proof was run: this is a deterministic internal lifecycle ownership race covered at both the direct SQLite owner boundary and the Gateway RPC boundary.
AI Assistance
AI-assisted. I reviewed and understand the change. No transcript or session logs are included.