fix: an ambiguous join is refused instead of guessed - #25
Merged
Conversation
ensureJoin matched on the table pair rather than the column, so a table with two foreign keys into the same target - billing region and shipping region - silently joined on whichever edge sorted first. That is the worst shape of bug this engine can have: the answer looks perfectly ordinary while answering a question the user never asked. It now refuses and names both candidate keys, so the agent can write the SQL it actually means. That matches how the compiler already handles fan-out and unknown metrics: refuse rather than guess. Reproduced on a fixture where both edges are inferred at 93% and the compiler picked billing without a word. Both engine suites are unchanged (18/18, 25/25) - neither committed dataset can trigger it through query_metric, since a lookup table's label is not a groupable dimension, which is also why the eval never caught this one. Found by reading the code path while closing out the defect list, not by measurement. This closes the engine-defect list the hard dataset opened.
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.
Why
ensureJoinmatched on the table pair rather than the column, so a table with two foreign keys into the same target -billing_region_idandshipping_region_idboth intoregions- silently joined on whichever edge sorted first.That is the worst shape of bug this engine can have: the answer looks perfectly ordinary while answering a question the user never asked.
Reproduced on a fixture where both edges are inferred at 93%:
What
It refuses and names both candidate keys, so the agent can write the SQL it actually means. That matches how the compiler already handles fan-out and unknown metrics: refuse rather than guess.
Verification
npm run checkexit 0;npm run test:cli148 pass / 0 failnpm run eval:engine18/18 andeval:engine:hard25/25, both unchangedWorth noting how this one was found: by reading the code path, not by measurement. Neither committed dataset can trigger it through
query_metric, because a lookup table's label is never a groupable dimension - so the eval was structurally blind to it. A useful reminder that a scoreboard only covers what its cases can reach.This closes the engine-defect list the hard dataset opened (ROADMAP step 6).
🤖 Generated with Claude Code
https://claude.ai/code/session_01CKZ9UVgw2Mhiu6T5YAG7k6