Repository navigation
fix(ci): the BQL harness compares column names - #2223
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new CSV-based comparison still has correctness holes (ambiguous row/header re-serialization and wildcard entries not being stale-checked), which can allow false matches and weaken the harness’s guarantees.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens the BQL compatibility harness so it can detect user-visible column-name divergences that were previously invisible, by switching both tools to CSV output and comparing headers in addition to data rows. It also introduces a wildcard mechanism to register divergences that are properties of the query across the whole corpus.
Changes:
- Switches bean-query and
rledger queryinvocations to-f csv, parses results as CSV, and normalizes fields before comparison. - Adds explicit header extraction/comparison and includes header mismatch details in JSONL output only when they differ.
- Extends
KNOWN_RUST_DIVERGENCESto support("*", query_name)entries and exempts"*"from the bare-filename registry guard.
File summaries
| File | Description |
|---|---|
| scripts/compat-bql-test.py | Convert harness comparison from tabular line-based parsing to CSV field-based parsing, add header comparison, and support query-wide divergence registry entries. |
Review details
Suppressed comments (2)
scripts/compat-bql-test.py:1050
- Data rows are re-serialized with
",".join(...), which reintroduces ambiguity when any field contains a comma (the exact case CSV parsing was meant to handle) and can yield false matches/mismatches.
data = [",".join(r) for r in rows[1:]]
scripts/compat-bql-test.py:995
_SEPARATOR_REand the preceding comment describe tabular (dashed-separator) parsing, but the harness now parses CSV and no longer uses this regex; leaving it behind makes the extraction logic look more complex than it is.
_SEPARATOR_RE = re.compile(r"^[-\s]+$")
- Files reviewed: 1/1 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Column names are user-visible output and nothing compared them: the harness dropped everything above the tabular separator, so a run whose headers differed reported a clean match. The pivot-header divergence in #2217 sat in the corpus and passed. Closes #2220. Headers are read from a second, CSV-formatted invocation. The default table truncates a header to its data column width -- `sum(number)` over five-character values prints `sum(n` -- so tabular headers disagree for reasons that say nothing about either tool's column naming. Values stay on the TEXT surface. The two are not interchangeable: CSV is a machine surface, so `DisplayContext::for_surface` suppresses thousands separators there absolutely (#1892). An earlier revision of this commit compared values as CSV, which stopped exercising every `render_commas` divergence in the registry and turned nine of those masks stale -- not because rledger and bean-query had come to agree, but because the harness had stopped looking. Verified against main over 71 corpus files / 1349 runs: verdicts are identical pair-for-pair, and 204 header divergences are newly detected across four queries. Known header divergences live in their own registry. An entry there excuses a differing header and nothing else; the row comparison for the same run still gates. Putting them in `KNOWN_RUST_DIVERGENCES` -- as the first revision did -- masks the whole run, so a future DATA regression in `JOURNAL` on any of the 735 corpus files would have been absorbed by a mask only ever meant to cover a column's name. Also fixes the stale-mask check, which resolved only `(file, "*")` and not `("*", query)`. Every wildcard entry of that shape was reported dangling on each run and never stale-checked, so it could outlive its divergence indefinitely -- the exact failure the check exists to prevent. Both directions now resolve, and the bare-name guard derives its registry list from the same table so a registry added later cannot escape it. Each new behavior has a negative control in `--self-test`: mutating the wildcard resolution, the header predicate wiring, the skipped-header rule, or the guard's registry list makes the suite fail.
50aaafc to
4938c43
Compare
|
All four review findings were real and are fixed — and chasing the first one surfaced a defect in the PR's own premise that CI had already caught. The compat job was failing, and it was right to. Switching the value comparison to Values are back on the text surface; only the header pass uses CSV, as a second invocation. Verified against main over 71 corpus files / 1349 runs: verdicts identical pair-for-pair (0 differences), and 204 header divergences newly detected across four queries. Runtime ~1.7x, not 2x — the header pass is skipped when either tool already failed. Findings
One more, self-inflicted. Parking the header wildcards in Only four of the original nine wildcards survive. The other five were the #2222 inventory-slot padding, which the text surface legitimately does not see. Negative controls. Every new behavior has one in |
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
…ort (#2247) * fix(ci): restore the nightly compat budget and stop a false stale report Two unrelated problems behind the same health issue (#2232). ## compat.yml was timing out -- my regression #2223 added a second CSV invocation per run to compare column names. Measured at ~1.7x on a 71-file sample and judged acceptable; I never checked it against the job's cap. On the full corpus the BQL step went 18m37s -> 34m36s and the job hit `timeout-minutes: 45`. The 09-02 and 09-03 nightlies were killed after BQL and never reached "Commit results to compatibility branch", so the trend lost two days -- the exact failure the concurrency comment in that workflow warns about. Headers are compared on a SAMPLE of files per query now. A header is the rendered target expression, so it depends on the query and not the ledger: measured across the corpus, every query yields exactly one distinct header pair however many files it runs on, which is also why the divergence registry keys these `("*", query)`. The cost is `queries x N` regardless of corpus size -- 380 header passes against 735 files rather than ~14000 -- so the sample is generous rather than minimal. Two guards, because a cap that hides a divergence is worse than the runtime it saves: * If a query's sampled files disagree about its headers, the property the sample rests on is false and the run errors. That is what would happen if a `PIVOT BY` query were added, since a pivot names its columns after the data. * If a query ends up with NO usable comparison -- every sampled file failing in one of the tools, which ~28% of runs do -- the run errors rather than reporting a silent zero. Verified: verdicts unchanged (58/0/21 over 71 files), the same four queries still report header divergences, and both guards fire when forced. Runtime went from 1m44s back to 1m10s against a 1m02s baseline. ## nightly-health called a healthy workflow stale Separately, the report claimed `bench.yml` had not run in 10 days and linked a real run from 2026-08-24. It had in fact run six hours earlier, successfully, as it had every day. `latest_scheduled_run` took element zero of `gh run list`; it now takes the maximum by `createdAt`. This does NOT claim to fix a diagnosed bug: the same command by hand returns the correct run, so the cause was not reproducible. What it removes is the dependence on list ORDER, the only assumption that could produce that output. The self-test feeds a deliberately out-of-order page, since a correctly-ordered fixture cannot tell the two implementations apart. A false alarm matters more here than the diff size suggests: a health reporter exists to be believed, and one that cries wolf gets muted -- which is the failure it was written to prevent. * fix(ci): the header-sampling guards fail the run, not just annotate it Both guards printed `::error::` and returned 0. An annotation does not fail a GitHub Actions step, so a run whose header sampling was unsound would have reported SUCCESS -- and the comments I wrote beside them said "the run errors", which was simply untrue. That is the failure this harness exists to prevent, reintroduced by the change meant to protect it: a check that cannot fail. `main` now returns 1 when either guard trips, last so every other diagnostic still prints. Verified by exit code rather than by reading the output: a healthy run exits 0, a query with no usable header comparison exits 1, and headers varying across sampled files exits 1. Caught in review of #2247.
Closes #2220.
The harness diffed bean-query against rledger row by row and dropped the header before comparing, so any difference in column names passed as a match. Column names are user-visible output, and every piece of work this repo has done on them — #2164, #2175, #2176, #2217 — was invisible to the corpus that exists to catch exactly that.
The obvious fix doesn't work
The default table truncates a header to its data column width:
Our number padding differs from bean-query's, so comparing tabular headers would manufacture mismatches that are not divergences.
So both tools are asked for
-f csv, which never truncates — same number of invocations. Rows are now parsed as CSV and normalized per field rather than per line, which is strictly better: a value containing a comma stays intact because the reader has already split on the right ones.Two real divergence classes were hiding under the old comparison
Both filed, not papered over:
#2221 —
BALANCES/JOURNALcolumn naming. bean-query headsSUM((position))andMAXWIDTH(payee, 48); ours are the plain names. Rows agree. Worth noting: ourAT UNITSandAT COSTheaders are identical to each other, where bean-query's record which valuation ran — so that pair loses information regardless of which convention wins.#2222 — multi-currency
SUM(position). bean-query returns one field holding a slot per currency seen across the whole result, empties included (100 CORP { 1 USD},against our100 CORP { 1 USD}). Whitespace collapsing in the tabular reader hid it entirely.Registering them needed a query wildcard
("*", query)marks a divergence that is a property of the query rather than any ledger. A column-naming difference holds on all 735 corpus files, and spelling that as 735 paths would be mass-masking wearing a list.The pre-existing bare-name guard — which catches registry keys that could never match — now exempts
"*"while still flagging a genuinely bare filename. Verified both ways.The design already prevents these entries from becoming permanent cover:
stale_divergence_entriesfails the run if a registered pair starts matching again.Validation
Against a baseline, which is what the gate actually uses:
My first attempt at that control ran without
--baselineand returned 0 either way, so it proved nothing. Worth stating because the harness only gates on baseline regressions, not on absolute mismatches — a run with no baseline never fails.Harness self-test passes;
py_compileandtyposclean.🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr