Repository navigation
fix(session): an answer that describes a stop describes one stop - #1378
Draft
debugmcpdev wants to merge 12 commits into
Draft
debugmcpdev wants to merge 12 commits into
debugmcpdev wants to merge 12 commits into
Conversation
… 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
…feat/stop-record
…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 Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
src/session/stop-record.ts), minted where the core applies the stop.src/session/inspection/pinned-stop-read.ts). The pinned answers arewait_for_stop, the three step tools,pause_execution, a launch, restart or attach that answers paused (a launch'spausedChildincluded),hot_reloadwhen it stops a running program, andget_stack_trace.get_stack_tracefor the current stop.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
get_local_variables,evaluate_expression,get_scopesandget_variablesare not pinned, and which thread a step resumes is unchanged (An inspection answer can mix two stops: get_local_variables and evaluate_expression read a frame under one stop and its values under the next #1374).wait_for_stop's timeout bounds the waiting only.Review so far
Still to come before this is ready
The evidence and the full review record replace this list when it is done.
🤖 Generated with Claude Code
https://claude.ai/code/session_015BDrn82vMcRzWFDD9aUbZs