Ver código fonte

docs: plan stale replay token fix

Problem: Review found a stale replay invocation can advance the generation token and cancel the valid current-session replay.

Risk: The fix changes request-generation ordering and needs an executable reverse-order regression.
zhenyu.hu 2 semanas atrás
pai
commit
275dcae097

+ 25 - 0
docs/plans/todo-49.3-stale-replay-token-order.md

@@ -0,0 +1,25 @@
+# Todo 49.3 Stale Replay Token Order Plan
+
+**Status:** in_progress
+
+## Goal
+
+Make the replay generation guard directional: only a replay for the selected session may supersede the active replay.
+
+## Scope
+
+- Exit `loadSessionReplay()` before incrementing the generation token when `sessionId !== currentSessionId`.
+- Add an executable JS regression where the current replay starts first and a stale replay is invoked second.
+- Preserve the Todo 49.2 success/failure ordering coverage.
+
+## Files
+
+- Modify: `src/agent_lab/presentation/static/app.js`
+- Modify: `tests/test_websocket_api.py`
+
+## Verification
+
+- `uv run pytest tests/test_websocket_api.py -q`
+- `node --check src/agent_lab/presentation/static/app.js`
+- `uv run pytest`
+- `git diff --check`

+ 1 - 0
docs/plans/todos.md

@@ -95,5 +95,6 @@
 | 49 | in_progress | `docs/plans/todo-49-tool-mode-ui-session-restore.md` | Add UI mode selection, workspace/session restoration, and clear EventAgent applicability feedback. | Static/WebSocket tests prove requests, snapshots, loaded sessions, and audit context preserve the selected mode. |
 | 49.1 | in_progress | `docs/plans/todo-49.1-session-mode-and-atomic-transcript-safety.md` | Enforce persisted mode, atomically store direct tool rounds, repair incomplete legacy tails, serialize SQLite migration, and hide empty protocol bubbles. | Mode mismatches are rejected without config overwrite; disconnect cannot leave unresolved tool calls; concurrent migration succeeds; replay shows only visible assistant content. |
 | 49.2 | in_progress | `docs/plans/todo-49.2-session-load-race-and-visible-repair.md` | Prevent stale session loads from overwriting the selected session and preserve visible text while stripping incomplete tool protocol. | Out-of-order loads cannot mutate the active session UI; whitespace-only protocol bubbles stay hidden; incomplete tool rounds retain provider-valid visible content. |
+| 49.3 | in_progress | `docs/plans/todo-49.3-stale-replay-token-order.md` | Prevent a stale replay invocation from invalidating an already-running replay for the current session. | A late stale invocation exits before advancing the replay token; the current session still restores normally. |
 | 50 | pending | `docs/plans/todo-50-comparable-model-tool-metrics.md` | Record mode-aware model/tool spans and include EventAgent usage so both architectures can be compared fairly. | Persistence/API tests report agent, call kind, tokens, TTFT, tool latency, fallback usage, and total turn wall time without double counting. |
 | 51 | pending | `docs/plans/todo-51-comparison-matrix-closeout.md` | Add repeatable comparison fixtures, update project documentation, and close the experimental implementation. | Both modes pass the same scenario matrix; full tests, JS syntax, app import, and documentation checks pass. |