Repository navigation
feat(routing): name the lines of an immediate routing cycle on its error - #390
Merged
Merged
Conversation
The routing cycle error named only the line the story was on when the effect budget ran out. It now also has `cycle`: the lines of the story's most recent turn around the cycle, starting with that line and in the order the story reached them, so a host can show every line involved. The existing `code`, `pointer` and message are unchanged. Bumps the version to 1.53.0.
The cycle was taken as the story's last trip from the line it stopped on back to that line. A story that passes one line twice in a turn, going on to a different line each time, got only half of its cycle. The engine now records every line the story enters, including a line entering itself, and reports the block of lines that keeps repeating, with each line listed once. A route that never repeats a block still falls back to the last trip, and a chain of lines that outruns the budget without entering a line twice reports an empty cycle instead of a one-line one.
# Conflicts: # src/RouteEngine.js
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.
What
When a story routes in an immediate cycle, the engine stops after 1,000 synchronous effect batches and throws an error with
code: "routing_cycle"andpointer, the one line it was on at that moment. A cycle usually involves more than one line, and the line it happens to stop on is not necessarily the one an author needs to change.The error now also has
cycle: an array of{ sectionId, lineId }for the lines of the cycle. It starts with the line the story stopped on and lists each other line once, in the order the story first reached it after that line.cycleof that one line.sectionTransition,jumpToLine, aconditionalbranch, or a conditional's continuation to the next line.cycleis the story's last trip from the line it stopped on back to that line.cycleis empty.code,pointerand the message are unchanged, so existing hosts are not affected.How
While draining pending effects, the engine records each line the story enters (a batch that queues a line's actions). When the budget runs out,
selectRoutingCycleinsrc/routingCycle.jsfinds the smallest block of entered lines that repeats at the end of that record, falling back to the last return to the final line. The record holds at most about 1,000 small entries and lives only for the drain; the search runs only when the error is raised.Version
Bumps the version to 1.54.0.
Testing
Unit tests for
selectRoutingCycle(spec/routingCycle.test.js), on records of entered lines:Integration tests through the engine (
spec/integration/projectRobustness.integration.test.js):jumpToLine,sectionTransition,conditional) now assert a one-linecycle, and the existing two-section reset case asserts both linesjumpToLine,sectionTransitionand aconditionalbranchcyclecycledoes not affect the enginebun run test: 105 files, 2,639 tests pass.bun run lint,bun run format:changedandbun run check:test-markerspass.