Repository navigation
fix(session-tree): a child session reads its own connection and its tree's run (#1211, #1220, #1214, #1222) - #1229
Merged
Merged
Conversation
… own connection (#1211, #1220) A fork adopted as a child session was read with the launch root's DAP client behaviour. js-debug's root connection adopts the program in-session and mirrors breakpoints to it, so its own answers are provisional; every other connection of the worker runs the child-safe derivative of the policy, where the adapter's answers are the truth. The session layer asked the language's policy, got the root's behaviour for the child, and never stamped an adapter id on a child's records: one that bound on the line it was asked for was verified by its location, one that bound on another line stayed verified:false at the asked line after it had paused the child. The session layer now reads client behaviour in one place, connectionBehaviorOf(session, policy): the policy's for a root, the child-safe derivative's for a child. A guard test holds the session and server layers to it, and a pin test fails if the derivative ever changes anything else those layers read. The first-stop rule keeps the root's reading for a child, on purpose and said where it is. Trusting a child's ids needed one more rule (#1220). js-debug numbers a pending target's breakpoints from one counter before its attach and from another after it, so a breakpoint added to a paused child can come back with the id an earlier one still holds, and its bind event and its stop name both. An adapter id now names a record only while exactly one record holds it: an event under a shared id goes by its location, and no hit is credited by it. The setBreakpoints answer is positional, so each record still gets its own state. Measured on a real fork (Windows, Node 24.14.1, js-debug v1.140.0), a breakpoint asked for on a comment line: before, the child lists line 5 / verified false / no adapter id while paused on line 6; after, line 6 / requestedLine 5 / verified / adapterId 1. With an exact-line first breakpoint js-debug answers id 1 for both, and both records keep their own lines through the event and the stop. Tests: four unit cases on the child view (the recorded sequence), the id lookups, the derivative pin, the seam guard, and two real-adapter cases with a new fixture (child_shifted.js). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tarted from its tree (#1214, #1222) A launch or an attach is called on one session, and what it decides is written there: launch or attach, where an attach's target lives, what the adapter's transform handed the engine, what the caller asked for, the run directory the worker logs into. A child the adapter reports is adopted, never launched, and has none of those fields. They are facts of the run, the same for every session of the tree, and every reader that asked the session it was handed got "nothing was launched" for a child: - under vitest, tsx and other runners that load sources themselves, each stop, step and get_stack_trace on a worker carried the stale-build note for a dist/ the run never loads (#1214): the check exempts a runner under node_modules and could not see one; - a child of an attach to another host was read as local; - a child's step_into and pending-step sentences did not know what the launch had asked for; - a child's proxy-log resource read empty, and its failure pointers named a file nobody writes: one worker serves a tree and writes one log, named after the root (#1222). Those readers now go through one view, runFactsOf(session, lookup) in src/session/run-facts.ts, which reads the tree's root. It is computed from the session lookup the handlers already use, so no test double needed a new method. A guard test confines reads of the four run fields to the modules that write them and to the view; the view's members have names of their own so the guard can tell the two apart. Measured on Windows, Node 24.14.1: a unit test launched under vitest with its source newer than dist/: before, the worker's stop, step and stack each carry the note; after, none does. A fork's proxy-log resource: before 0 characters, after the tree's log. The storage itself moves into a run record in a later change; this one changes who reads, not where the facts live. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s for nine untested claims (#1211, #1220, #1214, #1222) An independent review with a mutation pass found no critical defect, two places to harden, and nine claims of the two commits before this one that no test held. Sources: - A breakpoint event whose id two function records share now ends in the function branch. It fell through to the line branch's location match, where a line breakpoint sitting at the function's bound location would have been verified by it and stamped with its id. - runFactsOf names no proxy log when the tree's root can no longer be reached from the session (a parent's row is gone, or the chain loops). It named a log after whatever the walk ended on, a child: the file nobody writes (#1222). Tests, each shown to fail under the mutation it is there for: - the shared-id function event, and a hit naming an id two function records share (#1220); - the first-stop rule reads the launch's value where the child's own connection forces no pause (the deliberate root reading); - a child connection's failure points at its tree's one log, in the collected diagnostics and in the logged record (#1222); - a child of a remote attach skips the host file check and is worded as a remote attach; a child's pending step_into reads what its tree's launch asked for (#1214); - rootOfTree and runFactsOf with a lookup that throws, an orphan, a cycle; - the run-facts guard also catches indexed access and destructuring, with self-tests of what it must catch and what it must leave alone. Docs: the two known limits of reading the root's facts for a child. The stale-build check decides by the root's program, which is wrong under a process manager whose child runs compiled files (#1227); and a child's stop reasons are read as a launch's, also under an attach root (#1223). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
debugmcpdev
commented
Nov 23, 2026
debugmcpdev
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed #1229 (ix/child-session-own-facts):
- Verified connectionBehaviorOf across src/session/, src/server/, and src/proxy/, plus the architecture seam test (connection-behaviour-seam.test.ts) and child-safe-policy.test.ts invariants (#1211).
- Verified soleHolderOf in handleBreakpoint and �pplyHitBreakpointIds for shared adapter IDs on both line and function breakpoints (#1220).
- Verified
unFactsOf /
ootOfTree cycle and orphan handling across stale-build, foreign-attach, breakpoint file resolution, and proxy-log resource readers (#1214, #1222). - Follow-up alignment for orphan logOwner in collectProxyFailureDiagnostics and outputOnFor will be folded into stacked PR #1232.
All CI gates green; merging to main.
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.
Closes #1211, #1220, #1214, #1222.
What was wrong
A process the adapter reports (a forked Node process, a Python subprocess) is adopted as a debug session of its own. Parent-side code went on treating such a child as if it were the launch root, in two ways.
It read the root's connection behaviour for it (#1211). js-debug's root connection adopts the program in-session and mirrors breakpoints to it, so its own answers are provisional. Every other connection of the worker runs the child-safe derivative of the policy, where the adapter's answers are authoritative. The session layer picked the policy by language, so a child's answers were read as provisional and its breakpoint records never got an adapter id.
It read run facts off a session that has none (#1214, #1222). How the program was started (
attachMode,attachLocality,transformedLaunch,lastLaunch, the run directory) is written on the session the launch or attach was called on. A child's copies are empty.Measured on
main(58f4014; Windows 11, Node 24.14.1, js-debug v1.140.0):line 5,verified: false, noadapterIdline 6,requestedLine 5,verified: true,adapterId 1src/**/*.tsfile inside a vitest worker (#1214)proxy-<childId>.logis a file nobody writes)What changes
One reader for the connection's behaviour (
src/session/connection-behavior.ts):connectionBehaviorOf(session, policy)gives a root its policy's DAP client behaviour and a child the child-safe derivative's, the samecreateChildSafePolicythe worker runs. The session layer reads client behaviour in two places (handleBreakpoint/handleBreakpointsSyncedin the core,BreakpointController.mirrorsToChild), and both go through it. The child's first-stop rule (pauseAfterChildAttach) deliberately keeps reading the root's value, with the reason written at that site; whether it should follow the child's own is #1223.An adapter id names a record only while exactly one record holds it (
soleHolderOf,src/session/breakpoints/hit-verification.ts, #1220). js-debug numbers breakpoints from one counter before a pending target's attach and from another after it, so two live breakpoints can share an id. Events fall back to the location match and no hit is credited by a shared id. Adapter-neutral.One reader for the run's facts (
src/session/run-facts.ts):runFactsOf(session, lookup)reads them off the tree's root. Converted readers: the stale-build check, the foreign-attach check, the ended-session wording, the breakpoint echo,resolveBreakpointFileand its locality read, the step-in filter and pending-step sentences,liveSyncHint, the proxy-log resource and the failure pointer.Two guards (
tests/unit/architecture/): the session and server layers may read client behaviour only through the seam, and the four run fields only in the modules that write them.Python is unchanged: for a policy without in-session adoption the derivative is the policy itself.
Review
One independent review with a mutation pass (36 mutants and 4 controls). No critical finding.
node_modulesthat transforms nothing (nodemon, pm2) and the child runs compiled files: the note that used to appear there no longer does. The fact that decides it correctly is the child's own program, and js-debug's report carries only its basename. Read from the code, not reproduced.breakpointevent whose id two function records share now ends in the function branch instead of falling through to the line branch's location match;runFactsOfgives no log path when the tree's root can no longer be reached (it used to name a child's log, the file nobody writes).step_intoreading what its tree's launch asked for (javascript (session tree): adopted child sessions of exempt runners (vitest, tsx) lack transformedLaunch and emit false stale-build notes #1214);rootOfTree/runFactsOfwith a lookup that throws, an orphan and a cycle.liveSyncHintfires only for Ruby, which adopts no children), one predates this PR (no test checks the program handed toexplainRequestFailure).Not done here
Gates
typecheck:all,lint,check-docs,changelog:check. The pre-push run on the pushed commit: unit 439 files, 9613 passed and 7 skipped; integration 47 files, 245 passed and 1 skipped (the JavaScript and Python tree suites among them). The known flake #1119 (the cap-0 tree case exiting 0xC0000005) showed once on this branch in an earlier run of that file alone and not again in three repeats; a sighting is posted there.🤖 Generated with Claude Code