Repository navigation
fix(query): JOURNAL must read spanned_directives (BQL compat 77%->93%) - #1531
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a BQL JOURNAL regression where Executor::new_with_sources (CLI/LSP path) left directives empty, causing JOURNAL to return zero rows by iterating the wrong directive source.
Changes:
- Added
Executor::resolved_directives()to centralize “pick the populated directive source” logic. - Updated
JOURNAL,BALANCES, andPRINTdirective-walking to useresolved_directives(). - Added a regression test ensuring
JOURNALreturns rows when executing vianew_with_sources.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/rustledger-query/src/executor/mod.rs | Adds resolved_directives() and refactors BALANCES to use it; adds a JOURNAL regression unit test. |
| crates/rustledger-query/src/executor/execution.rs | Switches JOURNAL and PRINT to iterate via resolved_directives() to work under new_with_sources. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Benchmark Results
vs main branch (2026-06-22)
What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
robcohen
added a commit
that referenced
this pull request
Jun 22, 2026
Copilot on #1531: avoid the per-call Vec<&Directive> allocation. The two directive sources are mutually exclusive, so chaining them yields the populated one with zero allocation; all three callers only iterate. Co-Authored-By: Claude Opus 4.8 <[email protected]>
robcohen
force-pushed
the
fix/journal-query-regression
branch
from
June 22, 2026 22:23
ea10d4b to
bd67a8c
Compare
execute_journal iterated self.directives directly, but new_with_sources (CLI/LSP) leaves that empty and stores directives in spanned_directives — so JOURNAL returned zero rows in the CLI, regressing BQL JOURNAL compat 90/90 -> 12/90 from #1506. SELECT/PRINT/BALANCES already had inline fallbacks; JOURNAL was missed. Add a resolved_directives() accessor and route JOURNAL + SELECT + PRINT through it so it cannot recur. Adds a source-mapped JOURNAL regression test. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot on #1531: avoid the per-call Vec<&Directive> allocation. The two directive sources are mutually exclusive, so chaining them yields the populated one with zero allocation; all three callers only iterate. Co-Authored-By: Claude Opus 4.8 <[email protected]>
robcohen
force-pushed
the
fix/journal-query-regression
branch
from
June 22, 2026 23:05
bd67a8c to
fe2afa7
Compare
robcohen
added a commit
that referenced
this pull request
Jun 23, 2026
The executor had ~10 copy-pasted spanned/unspanned dispatch blocks — the pattern that caused the JOURNAL regression (a walk forgetting the spanned_directives fallback returns empty under new_with_sources). #1531 fixed 3; collapse the rest (5 system-table builders, #accounts, 2 transaction collectors, #entries) onto resolved_directives, which now yields &\x27a Directive so callers can collect. Add a source-mapped system-table test. Architecture-roadmap item [M/BR5]. Co-Authored-By: Claude Opus 4.8 <[email protected]>
robcohen
added a commit
that referenced
this pull request
Jun 23, 2026
#1535) * refactor(query): route all directive walks through resolved_directives The executor had ~10 copy-pasted spanned/unspanned dispatch blocks — the pattern that caused the JOURNAL regression (a walk forgetting the spanned_directives fallback returns empty under new_with_sources). #1531 fixed 3; collapse the rest (5 system-table builders, #accounts, 2 transaction collectors, #entries) onto resolved_directives, which now yields &\x27a Directive so callers can collect. Add a source-mapped system-table test. Architecture-roadmap item [M/BR5]. Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(query): exercise a refactored system table (#entries), not BALANCES Copilot on #1535: BALANCES is a statement on a different path; query #entries (a system-table builder collapsed onto resolved_directives in this PR) so the test actually guards the refactored builders under new_with_sources. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
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.
What
Fixes a BQL
JOURNALregression: BQL compatibility dropped 93% → 77% (JOURNAL 90/90 → 12/90, ~78 queries) starting with #1506 (058f3cf5, "resolve filename/lineno columns in the CLI").Root cause
The
Executorhas two directive sources —directivesandspanned_directives. The source-location-aware constructornew_with_sources(used by the CLI and LSP) stores directives inspanned_directivesand leavesdirectivesempty.SELECT,PRINT, andBALANCESwere each updated to fall back tospanned_directives— butexecute_journalstill iteratedself.directivesdirectly, so under that constructor (i.e. every CLI query) JOURNAL walked an empty slice and returned zero rows. #1506 switched the CLI to that constructor, exposing the latent bug.Reproduced on
main:JOURNAL 'Assets'→ 0 rows whileSELECT … WHERE account ~ 'Assets'→ 2 rows.Fix (+ recurrence guard)
This bug had already hit SELECT/PRINT/BALANCES via copy-pasted inline fallbacks — JOURNAL was the one generic walk that was missed. So rather than add a fourth copy:
Executor::resolved_directives()accessor that returns the populated source.execute_journal(the fix) and routeSELECTandPRINTthrough it (collapsing their inline copies). Any future directive-walking command now can't silently regress the same way.Tests
test_journal_via_source_mapped_executor_returns_rows: builds an Executor vianew_with_sourcesand assertsJOURNAL 'Assets'returns the Assets posting (was 0 rows). Fails on the pre-fix code.Verification: rustledger-query suite green;
clippy --all-features --all-targets -D warnings+ fmt clean. CI compat should return to ~93% BQL.🤖 Generated with Claude Code