Conversation
Adopts the engine's new `onIter` hook (turing-machine-js v6.4.0,
PR #164) to fix a pre-existing `arrivalPath` ordering bug.
The bug: since v6.1.0 the internal `onStep` wrapper advanced `prev`
mid-iter, which races engine v6.0.0+'s per-iter `before β step β
after` dispatch on the same yield. By the time `onPause(after, K)`
fired, `prev` was already iter K β so `m.arrivalPath` resolved to
iter K+1's instruction. Worse: the registry-aware
`#shouldFireOnPause` filter then saw the wrong path and silently
dropped user-registered `{ after: true }` breakpoints.
The fix: move `advanceTracking` from the internal `onStep` wrapper
to a new internal `onIter` wrapper. `onIter` fires at end-of-iter,
after both `onPause` dispatches on the same yield have already read
their iter-correct prev. Required engine v6.4.0.
Also:
- New `pm.run({ onIter })` parameter β forwards to engine's
`onIter` with PostMachine's wrapped MachineState. Awaited inline.
- Engine peer-dep widened `^6.0.0` β `^6.4.0` (required for `onIter`).
- Internal `onStep` wrapper now conditional (only registered when
user provides onStep), since it no longer carries always-on
advanceTracking side-effect.
Version skips 6.2.0 and 6.3.0 β both were prepared but neither
shipped (see CHANGELOG history note).
Regression test added in `test/breakpoints.spec.ts`: an `{ after:
true }` breakpoint must report the firing iter's instructionIndex,
not the next iter's.
NOT YET PUSHED β engine v6.4.0 must be published to npm first so CI
can resolve the peer dep range `^6.4.0`.
- `vitest.config.ts`: statements/branches/functions/lines thresholds
95/90/95/95 β 100/100/100/100. Pin to current actuals (266 tests
hit every branch). Any new code path must be exercised; future
regressions surface in CI as the threshold violation they are.
- `CLAUDE.md`: reflect the new floors.
- `test/machine-state.spec.ts`: new test for `onIter` receiving wrapped
`MachineState` with `arrivalPath` + `candidatePaths`. Closes the
lines 157-158 gap that previously had no test exercising the
user-`onIter` forward path.
- `PostMachine.ts`:
- Rename `anyCallback` β `isAnyCallbackProvided`. Clearer at the
call site β boolean intent reads at a glance.
- `await super.run({...})` β `return super.run({...})`. Forwards the
Promise directly, saves one microtask, no behavior change. V8's
zero-cost async stack traces keep this function in the trace
regardless, so debugging context is unchanged.
Coverage: 267/267 tests, 100% / 100% / 100% / 100%.
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.
Summary
Adopts `@turing-machine-js/machine` v6.4.0's new `onIter` hook to fix a pre-existing `arrivalPath` ordering bug that's been latent since v6.1.0. Also surfaces `onIter` as a new `pm.run()` parameter forwarded to the engine.
Version skips 6.2.0 and 6.3.0 β both were prepared but neither shipped to npm (see CHANGELOG history note).
The bug
Since v6.1.0 the internal `onStep` wrapper advanced `prev` mid-iter, which races engine v6.0.0+'s per-iter `before β step β after` dispatch order on the same yield. By the time `onPause(after, K)` fired:
Regression test added in `test/breakpoints.spec.ts` β fails on master, passes after the fix.
The fix
Move `advanceTracking` from the internal `onStep` wrapper to a new internal `onIter` wrapper. `onIter` fires at end-of-iter β after both `onPause` dispatches on the same yield have already read their iter-correct `prev` β so the advance no longer races them. Required the new `onIter` engine hook (turing-machine-js v6.4.0).
Also added
Three-hook contract recap (matches engine v6.4.0)
Compatibility
Release plan after merge
Test plan