Repository navigation
Commit 0436793
authored
fix(replay): extend resume.from record-and-heal shape to caution/manual (#1267)
* fix(replay): extend resume.from record-and-heal shape to caution/manual (#1262)
caution/manual divergences kept resume.from unshifted (correct — per
resolution item 1, N stays unconditionally legal) but never offered a
concrete N+1 continuation for their record-and-heal-shaped alternate
repair, and a last-step caution/manual divergence repaired by a
recorded action was a dead end: pendingRecordAndHeal was only ever
stamped for record-and-heal, so the N+1 empty-tail resume was
unauthorized (out of range) and close on the not-yet-COMPLETE
transaction discarded the just-recorded corrective action — the same
trap #1260 closed only for record-and-heal.
- buildRepairHintGuidance (src/replay/divergence.ts) now renders BOTH
concrete commands for caution/manual when resume.allowed: --from N
for a --no-record state fix, --from N+1 for a recorded corrective
action.
- stampPendingRecordAndHealWatermark (session-replay-resume.ts) now
also stamps for caution/manual, but only when the diverged step is
the plan's LAST one and N+1 is independently preflight-safe — a
mid-plan --from N+1 was already unconditionally legal and un-gated
for these hints (unlike record-and-heal, they never mandate a
corrective action), so that pre-existing pattern stays un-gated.
* fix(replay): add resume.alternateFrom so caution/manual dual-path never advertises a --from the daemon refuses (#1262)
The dual-path text guidance offered `--from N + 1` whenever resuming AT `N`
was allowed, but `--from N + 1` needs its OWN preflight — which additionally
requires the diverged step `N` to be skip-safe. When `N` is a runScript
(outputEnv producer) or inside runtime control flow, preflight(N) passes
while preflight(N+1) fails, so the text advertised a command the daemon then
refused (the text-vs-structured disagreement #1260 blocker 2 banned).
- Add optional `resume.alternateFrom` to the decision-4 wire shape
(`ReplayDivergenceResume`). The daemon populates it (`N + 1`) for
caution/manual ONLY when `evaluateReplayResumePreflight({ from: N + 1 })`
passes — the same acceptance condition on both the mid-plan (un-gated,
in range) and last-step (watermark-stamp) paths. Its checked range is a
strict superset of `from`'s, so alternateFrom present implies allowed.
- The text renderer gates the `N + 1` command on `alternateFrom`'s PRESENCE
and renders its value verbatim, never re-deriving resumability — so text
and the structured wire can never disagree on the advertised next command.
- This also closes a parity gap: a JSON/MCP caller now gets both ordinals
(previously the dual-path was text-only, structured callers saw only `from`).
- ADR-0012 decision-4 documents alternateFrom as additive/optional; projection
and trigger tests cover both positions (runScript/control-flow → no
alternateFrom, no `--from N + 1`; skip-safe → alternateFrom present).
* fix(replay): withhold empty-tail alternateFrom when no session can stamp the watermark (#1262)
The empty-tail alternate (`alternateFrom > actions.length`) is accepted by
the range check ONLY when it matches a stamped `pendingRecordAndHeal`
watermark, and that watermark can only be stamped on a live session. For a
last-step caution/manual failure with no active session — a one-step `open`
failure, or a session closed mid-replay — the watermark can never be stamped,
so the advertised `--from length+1` is then rejected as out of range,
re-introducing the text/structured mismatch this arc fixed.
- Thread `sessionExists` into `buildReplayDivergenceResume`; gate the
one-past-the-end `alternateFrom` on it (mid-plan alternate stays in-range and
session-independent). Both divergence sites pass `session !== undefined`.
- At the last step this makes `computeReplayResumeAlternateFrom`'s emit
condition exactly `computeRecordAndHealWatermark`'s stamp condition, so
alternateFrom present ⟺ the watermark gets stamped in the same request.
- ADR-0012 decision 4: reword the mechanical resume.from parity statement for
the dual-path hints (from=N + optional alternateFrom=N+1); update the
empty-tail paragraph to cover caution/manual last-step stamping and the
no-session withholding.
- Tests: unit (last-step no-session → no alternateFrom; mid-plan no-session →
still present) + integration (single-step failure, no session → no
alternateFrom on the wire, no --from length+1 in text).1 parent 236016e commit 0436793
12 files changed
Lines changed: 1340 additions & 130 deletions
File tree
- docs/adr
- src
- daemon
- handlers
- __tests__
- mcp/__tests__
- replay
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
489 | 508 | | |
490 | 509 | | |
491 | 510 | | |
492 | 511 | | |
493 | 512 | | |
494 | 513 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
501 | 525 | | |
502 | 526 | | |
503 | 527 | | |
| |||
0 commit comments