Skip to content

Fix materialization order: depth-first preorder#11

Merged
TroyHernandez merged 1 commit into
mainfrom
fix-materialize-order
Apr 28, 2026
Merged

Fix materialization order: depth-first preorder#11
TroyHernandez merged 1 commit into
mainfrom
fix-materialize-order

Conversation

@TroyHernandez
Copy link
Copy Markdown
Contributor

Summary

The recurring-manifest materializer was emitting ancestors and descendants in manifest-walk order. With a manifest like:

*   cornball.ai
*   House
*   cornball.ai > Lil Casey > Countdown

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

  • New regression test in `test_recurring.R` verifies the order
  • Smoke test on Troy's actual `recurring.txt` against May 4, 2026 produces correctly-nested Daily output
  • All 193 tests pass
  • Version bumped to 0.2.1

.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.
@TroyHernandez TroyHernandez merged commit 202840a into main Apr 28, 2026
0 of 4 checks passed
@TroyHernandez TroyHernandez deleted the fix-materialize-order branch April 28, 2026 02:50
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.

1 participant