Repository navigation
refactor(session): the facts of a run live in one record its tree shares - #1232
Open
debugmcpdev wants to merge 3 commits into
Open
debugmcpdev wants to merge 3 commits into
debugmcpdev wants to merge 3 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
How a program was started is a fact of the run, the same for every session of the tree: launch or attach, where an attach's target lives, the launch the adapter's transform produced, the request a restart replays, the exception arming, the debugger-off decision, the notes and the toolchain verdict of the start. They were thirteen fields of ManagedSession, written on the root and empty on a child, and #1214 and #1222 were readers that asked the session they were handed. The previous change gave those readers a view that walks to the root. This one gives the facts storage of their own: a Run record (session.run), created with the session, which adoption hands to the child by reference (child.run = parent.run). A reader holding any session of a tree reads the same object. What moved and how: - The thirteen fields, with their comments, from ManagedSession into Run. - Every write stays where it was and resets what it reset: the launcher, the proxy launcher and the attach controller write session.run.<field>. Four writes went through SessionStore.update with other fields; they are direct now, and the two toolchain-verdict writes still touch the row through the store, which is what moves updatedAt and what throws when the session was closed during a long compile. - runFactsOf keeps its signature and reads the session's record; the root's row still supplies the root id and the run directory. - Adoption no longer copies the two arming facts it used to copy. What a child reads differently, reader by reader: - isDebuggerOff: the run's decision, where a child read "not recorded". - A stop in a child that proves the debugger on clears the run's decision. - The seeding of launch notices into the output buffer stays the root's: guarded, with a test, because a child now holds the same notes. - Everything else already went through the view. One thing the compiler did not catch: DebuggerOffView declared the moved field as optional, so a session without it still satisfied the type and the decision silently read as "on". The view now names the record. The other optional-field views in the sources were read through; this was the only one. Tests: hand-built sessions give their facts as `run: { ... }`; the run-facts guard is removed (there is no wrong session to read any more); three new cases hold the sharing, the per-session empty record and the root-only notes. One existing expectation changed, and is right now: a Ruby attach's refused breakpoint re-send always carried a path hint in production, which that test's mocked store hid by swallowing the write that said "attached". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…for a row without one
An independent review with a mutation pass (18 mutants on the hand-edited
lines) found the storage move neutral for roots and nothing critical or
important in it. What it asked for, and what the integration run found:
- The two readers that tolerated a row without a record (runFactsOf, the
debugger-off view) require one now. The tolerance existed for hand-built
sessions in the unit tests; a real session always has a record, and the
next caller to hand in a projection would have read "nothing started" or
"debugger on" in silence, which is the kind of bug the first commit had to
fix in the debugger-off view. About 120 stand-ins in the tests carry
`run: {}` instead.
- The launch-shaped operations refuse a child session at the session layer
too (refuseChildSession, in the in-flight guard every one of them passes).
Until now only the tool handlers refused, and the session layer was safe
by accident: a child had no lastLaunch to replay and no ownership to judge
by. With the tree's record on the child, restart would have found the
root's launch and detach the root's ownership. No caller reaches them
today except through the handlers.
- A test for the reset the launcher does when a launch supersedes an attach
(a mutant that dropped it survived): the session is a launch again and
restart replays it (#238).
- The self-debugging integration test evaluates an expression inside the
debugged server that named the old field; it names the record now. Nothing
else reaches the moved fields by name at run time.
- Docs and comments: the record is also written by the core (a stop that
proves the debugger on); a failed real start has already reset what it
resets, only a dry run leaves the record as it was; it is mutated in
place, so a child row that outlives its run reads what its root reads;
the stale mentions of the removed guard and of the old field paths.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…quest (#1214, #1222) - collectProxyFailureDiagnostics: omit proxyLogPath/proxyLogResource when logOwner still carries parentSessionId (orphan or cycled child), matching runFactsOf (#1222). - outputOnFor: omit the launch-session pointer when the root walk stopped below the root (orphaned grandchild). - runFactsOf: clear request alongside launch when attached is true so a prior launch on the root cannot leak into attach-mode readers. - Add unit coverage for orphan diagnostics, orphaned grandchild outputOnFor, attach runFactsOf.request, and undefined policy in connectionBehaviorOf.
debugmcpdev
force-pushed
the
refactor/run-record
branch
from
November 23, 2026 05:58
59ef7c8 to
3734c14
Compare
debugmcpdev
commented
Nov 23, 2026
debugmcpdev
left a comment
Collaborator
Author
There was a problem hiding this comment.
Reviewed #1232 (
efactor/run-record), rebased onto main (5fdbf9b), and pushed 3734c14 after passing the full local pre-push gate (lint, ypecheck:all, clean build, 438/438 unit files, 47/47 integration files):
- Verified all 13 Run fields across launch, dryRun, cold/hot
estartDebugging, �ttachToProcess, detachFromProcess, closeSession, isDebuggerOff, and
efuseChildSession. - Added hardening commit 3734c14:
- collectProxyFailureDiagnostics: guard logOwner.parentSessionId === undefined so orphaned/cycled children never emit a nonexistent proxy-.log path or invalid proxy-log resource URI (#1222).
- outputOnFor: guard
eachedRoot so an orphaned grandchild never points at an intermediate child session.
unFactsOf: gate
equest alongside launch when �ttached is rue so a prior launch on the root never leaks into attach-mode readers.
- Added unit tests covering all three cases plus connectionBehaviorOf with an undefined policy.
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.
Stacked on #1229: the first three commits listed here are that PR's, and this one is to be read as its last two commits only. It needs a rebase onto
mainonce #1229 merges.What this is
The storage half of the decision taken for #1214 ("view now, storage next"). How a program was started is a fact of the run, the same for every session of a tree. Those facts were thirteen fields of
ManagedSession, written on the launch root and empty on a child, and #1214 and #1222 were readers that asked the session they were handed. #1229 gave such readers a view that walks to the root. This gives the facts storage of their own:Every session has
run: Run, created with it. Adoption gives a child its parent's by reference (child.run = parent.run). A reader holding any session of a tree reads the same object, so there is no wrong session to ask.What moved, and what did not change
logDirstays on the session (the view serves the log path).session.run.<field>at the same points. This PR does not turn the scattered per-launch resets into "a new record per launch": a dry run and a failed preparation must leave the record as it was (A dryRunSpawn on a finished session discards that run's output and exit code (it is a launch attempt) #812), and that is easiest to keep true by not moving any reset.SessionStore.updatetogether with other fields. They are direct now. The two toolchain-verdict writes still touch the row through the store (updateSession(id, {})): that is what movesupdatedAt, and what throws when the session was closed during a long compile, which gives the adapter lease back (the test for that still holds, on the touch instead of on the key).runFactsOfkeeps its signature. It reads the session's own record; the root's row still supplies the root id and the run directory.What a child reads differently
isDebuggerOff(thenoDebugsentences,debuggerDisabledin the listing)noDebugwas not determined. The proof by a verified breakpoint stays each session's own, so a root and its child can answer differently until the child's breakpoints bindsetupProxyEventHandlers)describeLaunchArming)runFactsOfOne thing the compiler did not catch
DebuggerOffViewdeclaredlaunchDebuggerOff?as an optional property, so a session without the field still satisfied the type and the decision silently read as "on". The unit tests caught it. The view now names the record (run?: { launchDebuggerOff? }). I read through the other places in the sources that mention the thirteen names withoutrun.; this was the only one of its kind.Tests
run: { … }.tests/unit/architecture/run-facts-seam.test.ts) is removed: it held readers to the view because a child's own fields were empty, and a child's record is its tree's now.session-manager-child-sessions.test.ts: a child's record is its root's (the same object, and a later write by the root is seen by the child); a session nothing was started on has an empty record of its own; the root's launch notes are not seeded into a child's output. The first and third fail under the two mutations I tried (a copy instead of the reference; seeding without the guard).runFactsOfandisDebuggerOffrequire the record. My first commit let them accept a row without one, for the minimal stand-ins the server tests hand over; the review pointed out that this is the same silent "nothing started" that theDebuggerOffViewbug was, waiting for the next caller. About 120 stand-ins carryrun: {}now.run.attachMode = falsein the launcher, [FEATURE] restart_debugging tool — relaunch the current session in one call #238) had no test before or after the move; it has one now.The launch-shaped operations refuse a child at the session layer
Until now only the tool handlers refused a child id (
childSessionRefusal), and the session layer was safe by accident: a child had nolastLaunchto replay and no ownership to be judged by. With the tree's record on the child,restartDebugging(childId)would have found the root's launch anddetachFromProcess(childId)the root's ownership.refuseChildSession(in the in-flight guard that all four operations pass) gives the handlers' answer to any caller. Nothing reaches these with a child id today except through the handlers.Review
One independent review with a mutation pass on the hand-edited lines (18 mutants, 15 killed). It found the move neutral for roots, the child-side changes real and deliberate, and nothing critical or important in the commit. Its points are answered in the second commit: the strict readers, the session-layer refusal, the reset test, and corrections to what the docs claimed (the core also writes the record, at a stop that proves the debugger on; a failed real start has already reset what it resets, only a dry run leaves the record as it was; the record is mutated in place). Of the three surviving mutants, one is the reset that now has a test, and two are equivalent in production (the
attachModefall-back inborrowsProgram, and clearingattachLocalityat a launch, whose readers are all gated onattached).The integration run found what neither the compiler nor the unit suite could: the self-debugging test evaluates an expression inside the debugged server that named the old field. The reviewer then searched tests, docs, skills, tools and scripts for other names reached at run time and found none.
It also came across a bug that predates this work, filed as #1231: after the proxy worker dies as a process, a relaunch keeps the previous run's child rows, and the root's
wait_for_stopcan answer with one of them.Not done here
no-changeloglabel; say if you would rather have a fragment.Gates
typecheck:all,lint,check-docs. The pre-push run on the pushed commit (Windows 11, Node 24.14.1): unit 438 files, 9602 passed and 7 skipped; integration 47 files, 245 passed and 1 skipped, the self-debugging and the JavaScript and Python tree suites among them. A vitest worker's stop on this build still carries no stale-build note and its breakpoint is verified with the adapter's id (the #1214 and #1211 rows of #1229, re-run).🤖 Generated with Claude Code