Skip to content

Corgi join: consolidate compound values when advancing reorders product times - #905

Merged
frankmcsherry merged 1 commit into
master-nextfrom
corgi-join-time-order
Sep 27, 2026
Merged

frankmcsherry merged 1 commit into
master-nextfrom
corgi-join-time-order

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

SideScratch::stage_runs (interactive/src/corgi/join.rs) has a single-chunk path that assumes joining each time with the lower bound keeps a value's times in ascending order ("join is monotone"), so equal (coordinate, time) entries stay adjacent and adjacent consolidation suffices.

For partially ordered times that is false. With product times (0,2), (1,0), (1,2) and lower bound (1,0), the advanced times are (1,2), (1,0), (1,2). With diffs +1, +1, -1 for one compound value, the +1/-1 pair at (1,2) is not adjacent, so it survives staging, and the staged entries are no longer sorted:

left:  [(0, (1, 2), 1), (0, (1, 0), 1), (0, (1, 2), -1)]
right: [(0, (1, 0), 1)]

The fix checks for an inversion within a value coordinate after staging and consolidates only then; ordered runs keep the existing path. The primitive-value path already consolidated, so this covers compound values. +23 −3, one file.

  • New test compound_tokens_consolidate_after_product_time_reordering; it fails on master-next with the output above.
  • cargo test --release -p interactive: 104 passed, 5 ignored.
  • Found while profiling worldgen on DDIR (Astra). On that workload, with the fix, 27/27 tour steps and 13/13 warm-move reference checks agree with the native engine at 1 and 4 workers, and timing is flat (+0.2% / −0.2%).

🤖 Generated with Claude Code

…rders product times

SideScratch's single-chunk path assumed that joining each time with the lower
bound keeps a value's times in order, so equal (coordinate, time) entries stay
adjacent and consolidation can be adjacent. For partially ordered times that is
false: (0,2), (1,0), (1,2) joined with (1,0) become (1,2), (1,0), (1,2). With
diffs +1, +1, -1 the +1/-1 pair at (1,2) is not adjacent and survives, and the
staged entries are no longer sorted.

Detect an inversion within a value coordinate after staging and consolidate in
that case; ordered runs keep the existing path. The primitive-value path already
consolidated; this covers compound values. The new test fails before the fix.

Co-Authored-By: Astra (OpenAI Codex)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@frankmcsherry
frankmcsherry merged commit 9cfc909 into master-next Sep 27, 2026
6 checks passed
@frankmcsherry
frankmcsherry deleted the corgi-join-time-order branch September 27, 2026 11:52
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