Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR passes the latest session entry into the guarded binding clear so an expired CLI session can retry fresh despite an older cached writer ID. Example: The cache names writer prior-run, the stored row names current-admitted-run, and expired-native-session returns session_expired.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR addresses a concrete recovery failure still present on current main; no introduced correctness defect was established. Reviewed head: Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe command agent adapter connects admitted turns to CLI backends; recovery reads session state, clears invalid native continuity through the session-store owner, and lets the runner retry with saved history. flowchart TD
A[Admitted command turn] --> B[CLI runner]
B --> C[Expired session recovery]
C --> D[Latest session entry]
D --> E[Guarded binding clear]
E --> F[Fresh CLI attempt]
F --> G[Persist replacement binding]
Technical reviewBest possible solution: Use the latest matching session entry for the existing guarded clear while preserving lifecycle, writer, native-binding, and media-replay protections. Do we have a high-confidence way to reproduce the issue? Current source establishes the failure when the persisted writer advances beyond the cache: the clear returns no committed entry and recovery declines the retry; this read-only review ran no target code. Is this the best way to solve the issue? Forwarding the already-read latest entry repairs the incorrect expected-session input without another database read or weakening the store's compare-and-swap checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 36149f5adba2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +78, Tests +230. Total +308 across 3 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 Reviewed November 29, 2026, 7:10 AM ET / 12:10 UTC. |
|
Added an unmocked multi-turn |
Closes #208264
What Problem This Solves
When a resumed CLI session fails with a recoverable session-expired error,
onBeforeFreshCliSessionRetryreads the latest session entry from the store (readConsistency: "latest"), verifies that the failingretry.sessionIdis still bound, and then callsclearCliBinding(retry.sessionId)without forwardingcurrentEntry.clearCliSessionInStorethen falls back to the stale cachedparams.sessionStore[params.sessionKey]entry, which can still hold an earlieractiveWriterRunIdfrom before run admission.patchCliSessionBindingInStorecomparessameCliSessionWriter(entry, expected)and rejects the clear, returningundefinedsoonBeforeFreshCliSessionRetryreturnsfalseand skips the fresh CLI session retry.User Impact
CLI turns whose expired native session binding should be cleared and retried fresh now recover cleanly instead of aborting when the live store entry's
activeWriterRunIdhas advanced past the stale in-memory cache. Concurrent or unrelated writer runs remain protected and cannot have their CLI session bindings cleared.Why This Change Was Made
canClearCliSessionEntryForFreshRetryandcreateBeforeFreshCliSessionRetryHandlerinsrc/agents/command/attempt-execution.helpers.tsto validatecurrentEntryagainstexpectedSessionId,lifecycleRevision,activeWriterRunId(must matchparams.runIdorcachedEntry.activeWriterRunIdwhen present), andretry.sessionId.clearCliBindinginsrc/agents/command/attempt-execution.tsto accept an optionalactiveSessionEntryand forward a mutable clone (structuredClone(currentEntry)) intoclearCliSessionInStore, avoiding frozen-object mutation inclearCachedEntrieswhile preserving the latest writer identity.src/agents/command/attempt-execution.cli-fresh-retry.test.ts(withimportOriginalmock-factory spreads) and an unmockedrunCliAgentchild-process end-to-end recovery test insrc/agents/command/attempt-execution.cli-fresh-retry.real.test.ts.Evidence
runCliAgentmulti-turn recovery proof (src/agents/command/attempt-execution.cli-fresh-retry.real.test.ts, commit0b229d1aea): exercises realrunAgentAttempt→runCliAgent→runWithCliSessionRecovery→ child CLI process + SQLite session store and transcript:expired-native-session) in SQLite.activeWriterRunId: "prior-run"), advances SQLiteactiveWriterRunIdto"current-admitted-run"on execution start, spawns--resume expired-native-session-> fails (session expired), triggersonBeforeFreshCliSessionRetry-> clears stale binding -> retries fresh (resumeId: null) with<conversation_history>(hasPriorTurn: true) -> recovers"recovered after fresh retry"and persists"fresh-native-session"in SQLite.--resume fresh-native-sessionand completes with"resumed:fresh-native-session"(4 real CLI subprocess invocations verified).0b229d1aea):node --import tsx scripts/check-test-mock-exports.mts --base upstream/main->Mock factory ratchet OK: 6074 grandfathered factories.pnpm exec oxfmt --check src/agents/command/attempt-execution.cli-fresh-retry.test.ts src/agents/command/attempt-execution.cli-fresh-retry.real.test.ts-> clean.pnpm exec oxlint src/agents/command/attempt-execution.ts src/agents/command/attempt-execution.helpers.ts src/agents/command/attempt-execution.cli-fresh-retry.test.ts src/agents/command/attempt-execution.cli-fresh-retry.real.test.ts-> 0 warnings, 0 errors.pnpm vitest run src/agents/command/attempt-execution.cli-fresh-retry.test.ts src/agents/command/attempt-execution.cli-fresh-retry.real.test.ts->Test Files 2 passed (2),Tests 4 passed (4)(79.74s).85ced7dc8d(source unchanged in0b229d1aea):pnpm tsgo:core-> exit 0.pnpm vitest run src/agents/cli-session-store.test.ts src/agents/command/attempt-execution.cli.test.ts -t "fresh|clear|binding|retry" --maxWorkers=2-> 2 test files passed, 31 passed.