Skip to content

fix(session): add step-provenance lifecycle and call-identity tracking (#1177-#1185, #1190) - #1217

Merged
debugmcpdev merged 2 commits into
mainfrom
fix/step-provenance-lifecycle
Nov 22, 2026
Merged

debugmcpdev merged 2 commits into
mainfrom
fix/step-provenance-lifecycle

Conversation

@debugmcpdev

Copy link
Copy Markdown
Collaborator

📋 Description

Introduces a unified, pure step-provenance and call-identity layer (src/session/execution/step-provenance.ts) wired across step execution, stop landings, and stop snapshots to resolve a 10-issue cluster in stepping lifecycle, stop provenance, and variable-diff accuracy across adapters:

  • Terminal step reporting (#1177): Replaces "Step completed as session exited." with explicit ErrorMessages.stepSessionEnded copy ("The step did not pause. The program ran to completion (exit code N).", signal, or adapter exit) and hoists exitCode onto terminal step_over / step_into / step_out tool responses.
  • In-flight step tracking across grace windows (#1178): Rewrites ErrorMessages.stepStillRunning for step semantics (instead of continue_execution boilerplate), tracks session.inFlightStep across session-store and session-manager-core, and surfaces the pending step in wait_for_stop (ErrorMessages.waitForStopPending).
  • Rejected DAP step state recovery (#1179): Catches DapResponseError in ExecutionController.executeStep, reverts session.state back to PAUSED (clearing inFlightStep so subsequent inspection and execution tools continue working), and extends DotnetAdapterPolicy.explainRequestFailure to translate netcoredbg 0x80004005 top-level stepOut / next refusals into actionable guidance.
  • Origin-vs-landing step provenance disclosures (#1180): Captures StepOrigin from one unfiltered stackTrace read before sending any step command (reproducing #672 keep-top-frame filtering in memory with zero extra DAP round trips) and compares it against reason: 'step' landings via compareStepOriginAndLanding — disclosing step_out re-entry at the same depth (e.g. [11, 21].map(key)), step_out multi-frame unwinds, step_into advancing without entering a callee, and disjoint stack switches (e.g. Ruby fiber switches), while normalizing COBOL (PERFORM ...) caller suffixes and allowing step_into bar(foo()) return-into-sibling transitions.
  • Paused frame & unwound stack notes on stop landings (#1181): Surfaces StackTraceResult.pausedFrameNote on describeStopLocation while paused (e.g. Python generator StopIteration unwinds) and deduplicates snapshot.note via stripLandingNotesFromAnchorNote.
  • Meaningful adapter step descriptions (#1182): Preserves non-boilerplate adapter stopped.description text on reason: 'step' stops (such as COBOL PERFORM step summaries) while filtering generic echoes ("Paused", "Paused on step", "step").
  • Call-identity keys & broken-unwind guard for StopSnapshot.changedVariables (#1183): Replaces the shallow name|file|depth snapshot diff key with buildSnapshotFrameKey (incorporating the live caller chain name@file:line), plus stepOutReenteredOriginFrame and hasUnresolvedCallerUnwind guards (catching raw hex / @symbol caller frames such as MinGW g++ epilogue stops) so distinct invocations emit full locals rather than false variable diffs.
  • Library/runtime step-in filter disclosures (#1184): Adds AdapterPolicy.describeStepInFilter in @debugmcp/shared and implements .NET (enableStepFiltering: true default + dapLaunchArgs: { enableStepFiltering: false } opt-out) and Rust (CodeLLDB default std/core/alloc step-avoid, including Drop::drop) hints when step_into enters no callee.
  • Cross-language step reference & Dart token-repeat exhaustion (#1185, #1190): Splits Dart repeatWhileOnOriginLine exhaustion messages by actual outcome (callerOnSameLine, locationUnknown, and stepRepeatedThenEnded), adds a cross-language stepping matrix to docs/KNOWN_ISSUES.md and docs/tool-reference.md, updates per-language guides, and adds changelog.d/1179-step-provenance.fixed.md.

Fixes #1177
Fixes #1178
Fixes #1179
Fixes #1180
Fixes #1181
Fixes #1182
Fixes #1183
Fixes #1184
Fixes #1185
Fixes #1190

🔄 Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📚 Documentation update
  • 🧪 Test improvement

✅ Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

🧪 Testing

Verified the full Dev-Loop Gate, static PR checks, and live self-dogfooding through mcp-debugger:

pnpm run lint
pnpm run typecheck:all
pnpm run check:docs
pnpm run changelog:check
pnpm run clean && pnpm run build
pnpm run test:unit
pnpm run test:integration
  • Unit suite: 434 test files passed (9,529 passed, 7 skipped, 0 failed), including 23 new pure specs in tests/core/unit/session/execution/step-provenance.test.ts and expanded coverage across session-manager-dap.test.ts, stop-snapshot.test.ts, stop-location.test.ts, session-manager-wait-for-stop.test.ts, server-control-tools.test.ts, adapter-policy-dotnet.test.ts, and error-messages.test.ts.
  • Integration suite: 47 test files passed (243 passed, 1 skipped, 0 failed).
  • Live MCP dogfooding: Reloaded the HTTP server (2026-07-28 era) and verified step_into no-entry notes, [11, 21].map(key) step_out re-entry disclosures + full snapshot.locals (instead of bogus changedVariables), and terminal step_over exitCode: 0 hoisting end-to-end.

Test Configuration:

  • OS: Windows 11 (win32 x64)
  • Node version: v24.14.1

🔗 Related Issues


Reviewer: @debugmcp

#1177-#1185, #1190)

- Introduce pure step-provenance engine (captureStepOrigin, compareStepOriginAndLanding, meaningfulStepStopDescription, buildSnapshotFrameKey, hasUnresolvedCallerUnwind, stepOutReenteredOriginFrame) so step answers compare origin vs landing stacks and StopSnapshot keys changedVariables on live caller identity rather than name|file|depth alone (#1180, #1182, #1183, #1184).
- Revert session.state back to PAUSED when a DAP step request is rejected (DapResponseError) and surface adapter policy refusal guidance (DotnetAdapterPolicy.explainRequestFailure for 0x80004005) (#1179).
- Report terminal step completions honestly (stepSessionEnded) and hoist exitCode onto terminal step tool responses (#1177).
- Track session.inFlightStep across grace timeouts and surface step-specific pending copy on both step tools and wait_for_stop (#1178).
- Surface pausedFrameNote on paused stop landings while deduplicating snapshot.note (#1181).
- Add AdapterPolicy.describeStepInFilter for .NET (enableStepFiltering) and Rust (std/core/alloc step-avoid), split Dart repeatWhileOnOriginLine exhaustion copy by outcome (#1190), and update cross-language docs and changelog (#1185).
@codecov

codecov Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.52507% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/session/execution/execution-controller.ts 96.40% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

Preserve observed stops during terminal races, scope delayed refusals to the current request, and keep provenance and variable diffs within a thread and resolved caller chain.

Add regression coverage for late responses, terminal events, thread switches, unresolved unwinds, and step-filter policies.
@debugmcpdev
debugmcpdev merged commit 58f4014 into main Nov 22, 2026
16 checks passed
@debugmcpdev
debugmcpdev deleted the fix/step-provenance-lifecycle branch November 22, 2026 04:28
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.

A step that stops inside JDK or runtime code says so only inside the snapshot: with the snapshot off, the answer is a bare "Stepped into" whose location is a JDK file Step answers never compare where the step started with where it stopped, so "Stepped out" can be answered for a stop still inside the function stepped out of When the debug adapter refuses a step, the session is put in an error state although the program is still paused, and every later inspect, step and continue is refused A pending step answer promises the step "will become 'paused' when it completes" even when the engine has dropped it, and wait_for_stop does not mention the step A step whose program then ends answers "Step completed as session exited.", with no exit code, whether the step ran the program to its end or the engine lost it

2 participants