Repository navigation
fix(parser): a query refuses tags and links instead of dropping them - #2198
Conversation
`query` was in neither camp. It did not keep tags and links the way a
transaction, note or document does, and it did not refuse them the way
the other seven directives do -- so it took them and discarded them,
`Query` having no field to hold one, while the message the refusal arm
emits states the very rule its omission broke.
I filed this rather than fixing it because the direction needed
beancount and the container would not build here. It does now, via
`nix shell nixpkgs#python3 nixpkgs#uv` and `uv pip install beancount`,
and 3.2.3 settles it:
2024-01-01 query "n" "SELECT date" #qtag
-> syntax error, unexpected TAG, expecting end of file or EOL
Its `Query` namedtuple is `(meta, date, name, query_string)`, with
nowhere to keep one either. So refusing matches both beancount's grammar
and its model, and joins the seven directives already refusing.
The reason I backed this out the first time is now answered too. A
corpus file uses the form --
`parser-lima/examples_data_full.beancount:111` -- and I could not tell
whether that meant beancount accepted it. It does not: beancount reports
TAG syntax errors on that file at lines 15, 19, 28, 31, 65, 68, 96 and
111. The file is a parser-lima corpus carrying forms lima accepts, and
our accepting line 111 was the divergence, not our rejecting it.
Cache versions move because parser output does: loader 33 -> 34, wasm
18 -> 19, pin 34. A stale blob holds a `Query` directive for input this
build refuses.
The census in `parser_integration_test` moves `query` out of its
known-gap arm and into the refusing set, where each entry is also
checked against its tag-free form -- a refusal that rejected valid input
would satisfy an assertion that only looked for an error. Verified to
fail: removing the refusal reports `query accepted #atag it has no field
to hold`.
Closes #2194
There was a problem hiding this comment.
🟡 Changes recommended
Several newly updated cache/fixture comments state that tagged query directives are dropped/refused (no directive produced), but the implementation records an error while still producing the directive, so the documentation should be corrected to match actual behavior.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Aligns query directive parsing with beancount by diagnosing (rejecting) header tags/links instead of silently accepting and discarding them, and updates caches/tests/baselines to reflect the changed parser output.
Changes:
- Add tag/link rejection for
queryduring CST→AST conversion. - Update integration census test to include
queryin the “refuses tags/links” set. - Bump loader/WASM cache versions and update the parser corpus baseline manifest hash.
File summaries
| File | Description |
|---|---|
| tests/baselines/parser-corpus.manifest | Updates the stored baseline hash for the affected parser-lima corpus file. |
| crates/rustledger-wasm/src/cache.rs | Bumps WASM cache version and pins the loader cache version. |
| crates/rustledger-parser/tests/parser_integration_test.rs | Moves query into the “refuses tags/links” census and keeps the tag-free control. |
| crates/rustledger-parser/src/cst/convert.rs | Calls reject_tags_and_links for query during conversion. |
| crates/rustledger-loader/src/cache.rs | Bumps loader cache version and updates fixture-version pins/comments. |
Review details
- Files reviewed: 5/5 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! |
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
Review caught three comments claiming a tagged `query` is "refused outright" and "produces no directive". It is not, and it does. `reject_tags_and_links` records an error and conversion still emits the `Query`, exactly as it does for the other seven directives that refuse tags. What moves is the error list, not the archived data. That is still enough to need the bump, and "enough" deserved measuring rather than asserting. A file with a tagged query used to parse clean and was therefore cacheable, so a v33 blob exists for it, and replaying that blob skips the parse that would now complain. Run against a pre-#2194 binary's cache: without the bump 0 parse errors <- diagnostic silently hidden with the bump 2 parse errors So the bump is load-bearing rather than precautionary, and the comments now say which of the two things it protects.
6b35f2b to
d0e65df
Compare
|
Good catch, and it was wrong in three places, not one. You're right that Your reading of the actual hazard is right too, and I measured it rather than just rewording. A file with a tagged query used to parse clean and was therefore cacheable, so a v33 blob exists for it; replaying that blob skips the parse that would now complain. Against a cache written by a pre-#2194 binary: So the bump is load-bearing rather than precautionary, and that is now what the comments say. One thing your comment surfaced indirectly: |
Closes #2194.
The gap
querywas in neither camp. It did not keep tags and links the waytransaction,noteanddocumentdo, and it did not refuse them the way the other seven directives do — so it took them and discarded them,Queryhaving no field to hold one. Meanwhile the message the refusal arm emits states the very rule its omission broke:The direction, now settled
I filed this rather than fixing it because deciding needed
bean-checkand the compat container would not build here. It does now —nix shell nixpkgs#python3 nixpkgs#uvplusuv pip install beancount— and 3.2.3 answers it:Its
Querynamedtuple is(meta, date, name, query_string)— nowhere to keep one either. So refusing matches beancount's grammar and its model.The reason I backed this out before is answered too
A corpus file uses the form,
parser-lima/examples_data_full.beancount:111, and I could not tell whether that meant beancount accepted it. It does not. beancount reports TAG syntax errors on that file at lines 15, 19, 28, 31, 65, 68, 96 and 111.That file is a parser-lima corpus carrying forms lima accepts. Our accepting line 111 was the divergence — not our rejecting it. The single baseline hash that moves is that file.
Verification
parser_integration_testmovesqueryout of its known-gap arm into the refusing set, where every entry is also checked against its tag-free form — a refusal that rejected valid input would satisfy an assertion that only looked for an error.query accepted #atag it has no field to hold.Querydirective for input this build refuses.corpus_parityclean against a freshly built wasip2 component.Remaining in this family
#2190 (
MetaValue::Tag/Linkunreachable;customemits a value it errored on) and #2193 (tolerance ignores a second number; a mismatched tolerance currency is erased byformat). Both now have a local beancount to settle direction against.🤖 Generated with Claude Code
https://claude.ai/code/session_012nNGPA44Dt32NyxWem26xr