Skip to content

fix(debug): stepInstruction nested-calls + 100% coverage#107

Merged
mellonis merged 2 commits into
v7from
fix/step-instruction-coverage
Jun 2, 2026
Merged

fix(debug): stepInstruction nested-calls + 100% coverage#107
mellonis merged 2 commits into
v7from
fix/step-instruction-coverage

Conversation

@mellonis

@mellonis mellonis commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

CI on the v7→master integration PR (action run) caught two issues in alpha.7's stepInstruction() (#101):

  1. Nested calls (foo calls bar from inside foo): the helper's scope-name comparison surfaced at bar::2 instead of running through bar's body to land at foo::3. Cause: arrivalPath.scope is the immediate callee (not the full stack), so "sibling scope at same depth" (bar from foo's POV) was misclassified as "different instruction".
  2. Coverage dropPostDebugSession.ts at 97.5% (lines 251, 258 uncovered). The two branches needed non-empty click.scope to exercise; existing tests all clicked at main-scope.

Fix

Classify scope changes by length relative to click, using Post's call-stack discipline (returns always go through ancestor scopes):

  • cur.length > click.length → deeper, keep stepping.
  • cur.length < click.length → shallower, surface (returned past click).
  • Equal length: scope-content match → sub-step / land by index; scope-content differ → sibling callee at same depth, keep stepping.

This recovers the user's "next numbered in current scope" semantics for nested calls without needing engine-internal stack access.

Tests

  • nested call from non-main scope — covers the bar-from-foo case (foo::2 calls bar; stepInstruction lands at foo::3 after bar completes).
  • mid-group → next numbered — covers the same-scope, same-index sub-step transition (10.2 → 10.3 → 20). Uses 20: right, 30: stop because the engine doesn't pause before terminal stops.
  • Existing inside callee at last numbered test simplified to use foo: {1: stop} — exercises the shallower-scope return path directly.

Verification

  • Full suite: 332 tests pass (was 330; +2)
  • npm run test:coverage100% across statements / branches / functions / lines (was 97.5% statements / 97.14% branches in PostDebugSession.ts)
  • npm run check / lint clean

Sequencing

Should land on v7 before alpha.7 is published — current alpha.7 source on v7 has the bug. After this merges, the publish from packages/machine/ ships the fixed version.

CI on the v7→master integration PR caught two issues in alpha.7's
stepInstruction implementation:

1. Nested calls (foo calls bar from inside foo): the helper's
   scope-name comparison surfaced at bar::2 instead of running through
   bar's body to land at foo::3. Cause: arrivalPath.scope is the
   immediate callee (not the full stack), so 'sibling scope at same
   depth' (bar from foo's POV) was misclassified as 'different
   instruction.'

2. PostDebugSession.ts coverage dropped to 97.5% (lines 251, 258
   uncovered) — branches that exercise non-empty click.scope weren't
   reached by the existing tests.

Fix: classify scope changes by length relative to click, using Post's
call stack discipline (returns always go through ancestor scopes):
- cur.length > click.length → deeper, keep stepping
- cur.length < click.length → shallower, surface (returned past click)
- equal length: scope-content match → sub-step / land by index;
  scope-content differ → sibling callee at same depth, keep stepping

New tests cover both nested-call (foo→bar→foo::3) and mid-group
(10.2→10.3→20) cases, exercising the previously uncovered branches.

Existing 'inside callee at last' test simplified to use foo: {1: stop}
(single-instruction subroutine) so the test reflects the helper's
shallower-scope detection path.
…lpha.8

Engine alpha.8 (TapeSnapshot + tapeViewport move, #227) shipped on npm
next today. Bump post's peer-dep widening for alpha.7 to track the
latest engine alpha at ship time. Updates: package.json peer dep,
package-lock.json, CHANGELOG entry, CLAUDE.md narrative + #stillIn-
ClickTimeInstruction algorithm description.
@mellonis mellonis merged commit 7de497d into v7 Jun 2, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in @mellonis's machines Jun 2, 2026
@mellonis mellonis deleted the fix/step-instruction-coverage branch June 2, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant