Skip to content

fix(session): an answer that describes a stop describes one stop - #1378

Draft
debugmcpdev wants to merge 12 commits into
mainfrom
feat/stop-record
Draft

debugmcpdev wants to merge 12 commits into
mainfrom
feat/stop-record

Conversation

@debugmcpdev

Copy link
Copy Markdown
Collaborator

Stage "Stop record" of #1362, part 1 of 2. Closes #1348.

Draft: not ready to merge. What is still to come is listed at the end.

The class this stage removes

An answer that describes a stop is built from several requests to the adapter. A stop that is replaced by another while those run could leave the answer with one stop's reason beside the other's location, frames or snapshot. #1348 is one instance, in wait_for_stop.

What it does

  • Each stop has a record with an id (src/session/stop-record.ts), minted where the core applies the stop.
  • An answer is pinned to one record and checked against it as it is read (src/session/inspection/pinned-stop-read.ts). The pinned answers are wait_for_stop, the three step tools, pause_execution, a launch, restart or attach that answers paused (a launch's pausedChild included), hot_reload when it stops a running program, and get_stack_trace.
  • When the stop changes during the reads, the answer reads the new stop once, if the program is paused at one and time remains (35 s from the first read). When it changes again, or the time is used up, the answer leaves out the location, frames and snapshot, says which, and tells the caller to call get_stack_trace for the current stop.
  • The guarantee is consistency, not freshness: an answer describes one stop, as that stop was when the answer's reads completed. The program can still move before the answer is read.

What it is meant to rule out

One of the pinned answers carrying fields of two different stops. The mutation pass and the last review below are what this sentence still has to survive.

What it deliberately leaves alone

Review so far

  • The record and the pins were written by a Claude model. A GPT model reviewed them with probes and a mutation pass, and a Gemini model by reading every pinned read. Both found one route still open: a second stop that arrived during the read and then resumed or ended passed for the pinned one.
  • The GPT reviewer then wrote the fix. It closed that route and added machinery to keep an answer fresh up to the moment it is serialized. The Gemini reviewer read that and said do not merge: the machinery could not be made tight, and it reached answers it had no business with.
  • The manager session (a Claude model) narrowed the guarantee to the sentence above and had the machinery removed. The Gemini reviewer's read of that: merge.

Still to come before this is ready

  • CI on this head.
  • The end-to-end project on Windows and on Linux at this head.
  • A mutation pass on the fix by a reviewer that did not write it.
  • A read by a Claude model that has not worked on it. Its first question is whether the line between consistency and freshness is drawn in the right place.

The evidence and the full review record replace this list when it is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs

cynarlab and others added 8 commits November 28, 2026 22:48
… it describes

An answer that describes a stop could carry one stop's location and the
next stop's reason: the stop was read after an awaited stack read, so a
second stop that arrived during the read replaced it under the answer
(#1348). The same happened in step_over, pause_execution and
start_debugging, and inside the snapshot, which could carry one stop's
frames with another's exception.

A stop's identity used to be the identity of the `lastStop` object,
compared by reference in a dozen places. Now:

- Each stop the core applies gets a record with an id
  (`src/session/stop-record.ts`), which holds the only writers of
  `lastStop`. Every comparison of two stops is by that id: the step and
  pause bookkeeping, the snapshot's diff base, the exception-details
  merge, the frame-anchor resolver's gate and cache, the shadow table.
- An answer that describes a stop takes the stop's id when its reads
  start and checks each dependent read against it
  (`src/session/inspection/pinned-stop-read.ts`). If the stop changed, the
  reads are made again once. If it changed again, the answer gives the
  current stop's reason and state, no landing, and says the stop changed
  while it was read.
- Pinned: wait_for_stop, the steps (landing, snapshot, origin),
  pause_execution, start_debugging and a replayed restart, a launch's
  paused child, a hot restart, attach_to_process, a hot reload that stops
  the program, and get_stack_trace.

Not changed: the worker, the IPC envelope, the proxy's forwarding, the
adapter policy contract; no stop's reason; nothing is hidden or dropped.

Two existing expectations changed and are stated in the tests: a step
whose first landing read stalls now holds its answer for that read instead
of being settled by a later stop's reader, and an answer whose stop was
replaced during its reads now describes the newer stop, read again.

Not covered yet: get_local_variables, get_variables, get_scopes and
evaluate_expression take no pin.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
…eld it throughout

Two independent reviews of the stop record found the guarantee still
broken on one route, and five related things. Written by a GPT model (the
reviewer that had demonstrated each defect), tests first, from five
principles; committed by the manager session.

- A replacement stop that then resumed or ended passed for the pinned one:
  the check for a changed stop fired only while the session was paused, so
  an answer carried one stop's reason with the other's frames (shown
  through get_stack_trace and start_debugging). Identity is now checked
  independently of the state, where each read is made: after the landing's
  settle and after its stack read, in get_stack_trace's own handler, and
  in the frame-anchor resolver, which takes the caller's record as its
  gate instead of whatever stop is current when it starts.
- An older read can no longer move a newer stop's thread (explicit stack
  inspection, attach adoption, the resolver's sibling scan).
- A launch-shaped answer reads the session's state when it is built, so it
  no longer says "paused" with a landing for a session that has ended.
- Nothing is recorded as shown until the answer that shows it is the one
  returned: the snapshot's diff base and the step filter hint's delivered
  mark are staged and published with the serialized answer.
- One answer has one time budget: the re-read, the dependent reads and a
  step's grace share one deadline. Two 34 s landing reads used to take
  68 s against a stated 35 s ceiling.
- The note for a stop that changed while it was read no longer promises a
  reason that attach answers do not carry, nor that get_local_variables
  reads "that stop".
- Source and stale-build enrichment are part of the pinned read.

Tests: 24 of the new regression and boundary tests fail on the previous
head; the seven mutants the first builder called equivalent are told
apart; four tests that passed with their behaviour removed now fail under
it; 23 ordinary answers are frozen and match main, the previous head and
this one.

Not covered, and said so in the documents: get_local_variables,
evaluate_expression, get_scopes, get_variables and the thread a step
resumes (#1374).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
…l machinery comes out

The previous commit closed the route by which an answer could mix two
stops, and added a mechanism to keep an answer fresh up to serialization:
a per-call AsyncLocalStorage scope, answers refreshed and effects
published by the result path, source reads moved inside the pinned read,
one deadline shared by a wait and its read. A second reviewer read it and
found it could not be made tight (an event listener runs in its emitter's
context, not the call's) and that it reached answers it had no business
with: a dry run's or a refusal's message rewritten, a 120 s wait stalling
two minutes on a wedged read, a late stop returned with no location, and
budget sentences for things that had not happened.

The guarantee is now stated as what it is: an answer describes one stop,
as that stop was when the answer's reads completed. It may be out of date
by the time it is read; no answer can promise otherwise.

- Removed: stop-answer-effects.ts and its tests; the dispatch, the result
  path, the handlers' enrichment and the launch handlers are byte for byte
  what they were before the previous commit.
- Kept: the identity check independent of the session's state, the checks
  where each read is made, the resolver gated on the caller's pin, the
  guarded thread writes, the corrected sentences, and their tests.
- State is read where each pinned answer is built, in the session layer,
  after its pinned read has returned.
- The snapshot's diff base and a step hint's delivered mark are committed
  when the session layer selects the answer it returns, never when one is
  merely composed, and a base never moves back to an older stop.
- Only a re-read gets a bound: what is left of 35 s counted from when the
  answer's reads began. An answer whose stop does not change takes exactly
  as long as before; a wait's timeout bounds the waiting only.

Written by a GPT model from the second review and a narrowing brief;
committed by the manager session.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
…rd's narrowing

An option nothing read any more is removed; the thread list read for a sibling scan takes the same 30 s per-request cap during a re-read as the other reads (a first read keeps its timeout); the probe for one mutant gives the first stop a thread of its own, so borrowing it would fail the test (shown by mutation).

Written by a GPT model from the reviewer's optional list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
The entry listed the mechanism (identity checks, where state is sampled, when a diff base is committed). It now says what was wrong, which answers are covered, what an answer does when its stop changes, and what is not covered. Same facts as the tool reference; nothing else changes.

Mine (the manager session).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
@codecov

codecov Bot commented Nov 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.38717% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/session/execution/execution-controller.ts 94.81% 7 Missing ⚠️
src/server.ts 91.66% 1 Missing ⚠️
src/session/inspection/pinned-stop-read.ts 97.82% 1 Missing ⚠️
src/session/inspection/stop-snapshot.ts 97.61% 1 Missing ⚠️
src/session/session-manager-data.ts 92.85% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

cynarlab and others added 4 commits November 29, 2026 04:42
A reviewer that did not write the fix executed 23 mutants on it: 15 were killed and 8 survived the session and server unit folders. These are the eight tests. Four hold what an answer says (a step whose program resumed while its locals were read; a step that has used its one re-read and meets a third stop; a paused child's snapshot as the next step's diff base; a stack answer naming a last stop the session has left), four hold that nothing more is asked of the adapter once a pin is broken.

Each mutant is saved as a patch and killed by its test in the manager's own run; the unmutated code passes all eight. No source change. Tests written by a GPT model; mutants found by a Gemini model.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
… and that the record is internal

From the reviewer's sentence-by-sentence check of the changelog entry: a caller could look for a new id field (there is none), 'leaves out' the frames meant an empty list on get_stack_trace, and the note is given only while the session-layer answer is still about a paused program; otherwise that answer says running or ended, and get_stack_trace keeps the note.

Mine (the manager session). No code changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
The reviewer's read of the eight tests found a ninth mutant that survived when run, and named four more by reading. All five survived the session and server unit folders. These are their tests: a step whose program resumes during the snapshot's re-read, and one whose retried landing resumes while the snapshot uses up the window, each answer pending; no scopes asked of a caller frame once the stop is replaced; the attach answer's and the hot reload answer's snapshot as the next step's diff base.

Each mutant is saved as a patch and killed by its test in the manager's own run, with the first eight; the unmutated code passes all thirteen. No source change. Tests written by a GPT model; mutants found by a Gemini model.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
A third pass by the reviewer ran seven more mutants beside the last ones and all survived: the three snapshot commits still without a test (hot restart, the launch's root, pause), the three checks that a step whose program ended during the snapshot read says it ended and not that it resumed, and the snapshot's guard after a locals read that timed out or failed while the stop was replaced. These are their tests.

Twenty mutants in all are saved as patches; each is killed by its test in the manager's own run, and the unmutated code passes all twenty. No source change. Tests written by a GPT model; mutants found by a Gemini model.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs
@debugmcpdev

Copy link
Copy Markdown
Collaborator Author

Parked. This branch is correct as far as three reviews and twenty targeted tests can tell, but its correctness rests on about twenty separate checks, and four review passes each found more of them. That points at the approach, not at the lines, so the approach is being reconsidered from the problem before anything merges. The tests here stay as the acceptance suite for whatever replaces it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wait_for_stop can answer with one stop's location and the next stop's record when the stop changes during the landing read

2 participants