Fix materialization order: depth-first preorder#11
Merged
Conversation
.expand_recurring previously emitted ancestors and descendants in manifest-walk order. With a manifest like: * cornball.ai * House * cornball.ai > Lil Casey > Countdown the output had House at order=8 and Lil Casey at order=9, so the rendered file showed Lil Casey indented one level under House instead of cornball.ai. Data was structurally fine (parent_id pointed at cornball.ai) but the visual rendering misled both human readers and the parse_todo round-trip. Now expand uses a two-pass approach: first collect every path (declared + ancestors) with first-seen manifest position, then emit via depth-first preorder with siblings ranked by manifest position. Children of cornball.ai now emit immediately after cornball.ai, before House. Regression test added in test_recurring.R. Bump version to 0.2.1.
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
The recurring-manifest materializer was emitting ancestors and descendants in manifest-walk order. With a manifest like:
the rendered output put `Lil Casey`/`Countdown` after `House` (because they were declared in entry 3, after House at entry 2). The data was right — `parent_id` pointed at cornball.ai — but the indented visual rendering placed Lil Casey nested under House. parse_todo round-trips would assign the wrong parent.
Fixed with a two-pass DFS preorder: collect every path (declared + ancestors) with first-seen manifest position, then emit via depth-first traversal where siblings rank by manifest position.
Test plan