Skip to content

fix(ci): restore the nightly compat budget and stop a false stale report - #2247

Merged
robcohen merged 2 commits into
mainfrom
fix/compat-header-sampling
Sep 3, 2026
Merged

robcohen merged 2 commits into
mainfrom
fix/compat-header-sampling

Conversation

@robcohen

@robcohen robcohen commented Sep 3, 2026

Copy link
Copy Markdown
Member

Two unrelated problems behind the same health issue (#2232).

1. compat.yml was timing out — my regression

#2223 added a second CSV invocation per run to compare column names. I measured ~1.7× on a 71-file sample, judged it acceptable, and never checked it against the job's cap. On the full corpus:

BQL step job
Sep 1 (before #2223) 18m37s 29 min, success
Sep 2 / Sep 3 (after) 34m36s hit timeout-minutes: 45, cancelled

Both 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 now compared on a sample of files per query. A header is the rendered target expression, so it depends on the query, 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) rather than enumerating files.

The cost is queries × N regardless of corpus size — 380 header passes against 735 files instead of ~14,000 — so the sample is generous rather than minimal. That property is what makes this a fix rather than a trade.

Two guards, because a cap that hides a divergence is worse than the runtime it saves:

  • Sampled files disagreeing about a query's headers means the property the sample rests on is false → the run errors. That is what would happen if a PIVOT BY query were added, since a pivot names its columns after the data.
  • A query with no usable comparison — every sampled file failing in one of the tools, which ~28% of runs do — errors rather than reporting a silent zero. My first attempt sampled 4 files and hit exactly this: 19 usable comparisons out of 76 budgeted.

Verified: verdicts unchanged (58/0/21 over 71 files), the same four queries still report header divergences, and both guards fire when forced. Runtime 1m44s → 1m10s against a 1m02s baseline. A pleasant accident: forcing zero coverage also trips the existing stale-mask check, so that registry independently notices a query losing header coverage.

2. nightly-health called a healthy workflow stale

Separately, the report claimed bench.yml had not run in 10 days, linking a real run from 2026-08-24. It had in fact run six hours earlier, successfully, as it had every day for weeks.

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 I could not reproduce the cause and I am not going to invent one. 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; reverting to runs[0] fails it.

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.

Note

The issue closes itself when everything is green, so it should clear on the next nightly if both fixes hold. Worth watching the next compat.yml scheduled run to confirm the job completes and publishes.

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.
@robcohen
robcohen requested a review from a team as a code owner September 3, 2026 20:53
Copilot AI lite review requested due to automatic review settings September 3, 2026 20:53
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new header-sampling “guards” in compat-bql-test.py currently only print ::error:: annotations and do not reliably fail the step with a non-zero exit code when they trigger.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR addresses two CI reliability issues affecting scheduled workflow health: it reduces the runtime cost of the nightly BQL compatibility header comparison (to stay within the job timeout budget) and fixes a false “stale workflow” report by selecting the newest scheduled run by timestamp rather than list position.

Changes:

  • Sample CSV header comparisons per query in compat-bql-test.py to avoid an expensive full corpus cross-product while adding guards for sampling soundness.
  • Update nightly-health.py to pick the latest scheduled run via max(createdAt) (with a self-test for out-of-order results).
  • Improve reporting around header-check coverage and sampling assumptions.
File summaries
File Description
scripts/nightly-health.py Fetches multiple scheduled runs and selects the newest by createdAt, plus a self-test to prevent regressions due to run-list ordering.
scripts/compat-bql-test.py Samples per-query header comparisons to restore nightly runtime budget; adds reporting and guardrails around header sampling coverage/validity.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/compat-bql-test.py Resolved
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

✅ Compatibility Test Results

Metric Result
Check Compatibility 100%
BQL Compatibility 99% (raw 93%, 169 masked)
Full AST Match 100%
Total Files 812
What's tested
  • Check: Exit codes and error counts match bean-check
  • BQL: Query results match bean-query
    The headline is the EFFECTIVE rate, after pairs where beanquery
    itself is wrong are masked. raw is the same run with nothing
    masked. A widening gap means the registry grew, not that rledger
    changed.
  • Files: ~800 test files downloaded from 10+ beancount repositories

Full results available in workflow artifacts

@robcohen

robcohen commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

Ran the full uncapped corpus locally, because the PR's own compat run does not prove this: PR and push runs pass --max-files 150 while only the scheduled run is uncapped, so the green check above is on a fifth of the files.

Full corpus, 735 files:

total runs:     13965
Header checks:  380 of 13965   (19 queries x 20 files)
::error lines:  0
header divergences still detected across:
  balances-by-account, journal-assets, journal-assets-at-cost, journal-assets-at-units

380 rather than ~10,000 is the whole point — the header cost is queries x N and does not grow with the corpus, so it stays ~26x smaller at full scale rather than only on the sample I developed against. The same four queries still report their divergences, and neither guard fired.

Sizing the nightly from the measured numbers: the header pass added ~16 minutes for ~10,000 successful runs, so ~0.1s each; 380 of them is roughly 36 seconds. That puts the BQL step back near its 18m37s baseline and the job near 29 minutes against the 45-minute cap.

I am calling that a well-grounded prediction rather than a fact — the nightly runs on GitHub's runners, not mine. The real confirmation is the next scheduled compat.yml completing and reaching "Commit results to compatibility branch", which is the step the last two nightlies never got to.

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.
@robcohen

robcohen commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

You're right, and it's the worst version of the mistake: the comments I wrote beside those guards said "the run errors" and it didn't. A guard that only annotates is a check that cannot fail — which is the exact failure this harness exists to prevent, reintroduced by the change meant to protect it.

Fixed in a2c9fea. main now returns 1 when either guard trips, placed last so every other diagnostic still prints first.

Verified by exit code, not by reading the output — which is the only way this could have been caught in the first place:

healthy run                              exit 0
query with no usable header comparison   exit 1
headers varying across sampled files     exit 1

@robcohen
robcohen merged commit efe3839 into main Sep 3, 2026
43 of 45 checks passed
@robcohen
robcohen deleted the fix/compat-header-sampling branch September 3, 2026 22:19
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.

2 participants