Repository navigation
fix(core): two ordering/lookup bugs the first real consumer hit - #4
Merged
Merged
Conversation
Building a document layer on the planner (fw-graph: leaves fetch, an assembly step composes) surfaced two defects that only appear once steps have DEPENDENCIES and deduplication removes one of them. Both were invisible while nothing planned. 1. THE EXECUTOR IGNORED THE DEDUP REMAP A step OWNS its dependency ids. Dedup removes the duplicate and rebuilds graph EDGES, but surviving steps still name the id they were built with. The executor looked those raw ids up in `outputs`, so an assembler whose dependency was deduplicated away found nothing. Worse, the lookup was `filter_map(|id| outputs.get(id).cloned())` — silently DROPPING a missing dependency. `StepInputs` is positional and steps downcast by position, so a drop shifted every later input down one slot and handed a step the wrong value at the wrong type. The symptom surfaced three layers away as a downcast failure in a GraphQL resolver. Dependency ids are now resolved through `remap` before lookup, and a genuinely missing output is a hard error naming both steps. 2. UNARY HOISTING VIOLATED TOPOLOGICAL ORDER `hoist_unary_steps` partitioned into unary/non-unary and concatenated. Its own comment asserted "a unary step should never depend on a non-unary step... We verify this at placement time" — nothing verified it, and the assumption is false in practice: a document assembler is unary (one document) and legitimately depends on a BATCHED, therefore non-unary, read. Concatenation placed the assembler before its input. Hoisting now places a unary step only once every dependency it names is already placed, deferring the rest in their existing (topologically valid) order. The result is a valid topological order by construction, and independent unary steps still move forward. REGRESSION TEST `an_assembler_whose_dependency_was_deduped_still_gets_its_input` builds the exact shape: two roots, a shared leaf that dedupes, and per-root assemblers depending on it. The leaf is deliberately NON-unary — the realistic case, a batched PgSelectStep under a unary assembler — so the test pins both fixes at once. Plus an optimizer-level invariant test asserting every remap target survives, every remap source is gone, and no step is ordered before a dependency. Workspace: 407 passed, 0 failed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
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.
Building a document layer on the planner (fw-graph — leaves fetch, an assembly step composes) surfaced two defects that only appear once steps have dependencies and deduplication removes one of them. Both were invisible while nothing planned.
1. The executor ignored the dedup remap
A step owns its dependency ids. Dedup removes the duplicate and rebuilds graph edges, but surviving steps still name the id they were built with. The executor looked those raw ids up in
outputs, so an assembler whose dependency was deduplicated away found nothing.Worse, the lookup was:
— silently dropping a missing dependency.
StepInputsis positional and steps downcast by position, so a drop shifted every later input down one slot and handed a step the wrong value at the wrong type. The symptom surfaced three layers away as a downcast failure in a GraphQL resolver.Dependency ids are now resolved through
remapbefore lookup, and a genuinely missing output is a hard error naming both steps.2. Unary hoisting violated topological order
hoist_unary_stepspartitioned into unary/non-unary and concatenated. Its own comment asserted:Nothing verified it — and the assumption is false in practice. A document assembler is unary (one document) and legitimately depends on a batched, therefore non-unary, read. Concatenation placed the assembler before its input.
Hoisting now places a unary step only once every dependency it names is already placed, deferring the rest in their existing (topologically valid) order. Valid topological order by construction; independent unary steps still move forward.
Regression test
an_assembler_whose_dependency_was_deduped_still_gets_its_inputbuilds the exact shape — two roots, a shared leaf that dedupes, per-root assemblers depending on it. The leaf is deliberately non-unary: the realistic case is a batchedPgSelectStepunder a unary assembler, and that combination pins both fixes at once.Plus an optimizer-level invariant test: every remap target survives, every remap source is gone, and no step is ordered before a dependency.
Workspace: 407 passed, 0 failed.
🤖 Generated with Claude Code