Skip to content

read a root through the item's key before any item in a one-line every - #961

Draft
jbpros wants to merge 56 commits into
mainfrom
e6-one-line-every-roots
Draft

jbpros wants to merge 56 commits into
mainfrom
e6-one-line-every-roots

Conversation

@jbpros

@jbpros jbpros commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #960 (which is stacked on #959 and #957). Merge in order. Until they merge, the diff against main includes their commits.

Fixes the type 1 entry in spec/OPEN.md (one-line every with , if any, whose whose reads a root through the item's own key). Both engines now read that root once, before any item, as tally.walk and for.roots say:

  • Rego: _keyed_whose_conds in engines/rego/src/lines/roots.rego adds the walk's own whose to the conditions _for_keyed_roots_said reads, so _walk_root_flaw sees the root.
  • Rust: whose_roots in engines/rust/engine/src/ops/walk.rs adds the key_base::base_of roots of the whose paths, read with the item's keys.

Changes the report: a one-line every or some … whose that reads a root through the item's own key on the left side of the comparison ($input.m named by key, $params.m named by key, $input.m.d named by key, and chains through $params.k or pr.key) now reads the root once, before any item. A root on the value side (v is in $params.m named by key, tags contains …, v is $params.m named by key, any comparison) is read with each item, as on #960's head, in both engines.

  • With , if any, and tests [], it fails as absent, null or unusable ($input.m is missing, is null, is 3, which isn't an object, and the same for a list and text) when the root is missing, null or not an object. Before, it passed. Probed with the chain named by $params.k named by key and pr.key too.
  • Without , if any, (every … exists, some … exists) over tests [], ergo.rego failed as value with tests is [] and now says the root's cause, like the Rust engine already did. The verdict is the same.
  • With items, ergo.rego said the root in each item (item 1 of tests: $input.m is null) and now says it once ($input.m is null). Same verdict and cause. The Rust engine did not change.
  • Rust changed only on an empty list with , if any,. Verdicts of non-empty lists did not change in either engine.
  • 100 probes (8 sentences, root from $input and $params, missing, null, 3, object, list and text, empty and one item) against read a keyed root through the subject's key before any item, so a root with no key for it fails on an empty list #960's head: no verdict differs between the engines.

Fixed after review (8329928): the root that a contains reads through the item's key (whose tags contains $input.m named by key) is left to each item, as in the Rust engine and the derived cases, so ergo.rego no longer says it twice; the seven derived rows passed again then. And a list before a field in such a root ($input.m.d named by key with m [], also $params) now fails as unusable with $input.m is [], which isn't an object in ergo.rego too, on an empty list and with items, like the Rust engine; its type 1 entry is out of spec/OPEN.md. A sentences case now pins it ($params.m.d named by key, m []), and both engines pass it.

Narrowed after the second review (362da8a): the branch also read the root on the value side of every comparison but contains before any item (Rego) and of every comparison but the list ones (Rust), so every tests whose v is in $params.m named by key, if any, exists with no m and tests [] failed in ergo.rego and passed in the Rust engine, a type 1. Now _keyed_walk_cond drops the right side of any comparison and Rust's whose_roots reads only left_path(), so only the left side's root is read before any item. Probed on #960's head and this branch, both engines, 40 value-side shapes (is, is not, is at least, is at most, is more than, is one of, is not one of, is in, starts with, is alphabetically before, contains, does not contain, contains all of, contains none of; every with , if any, and some; m missing and 3; tests []): no verdict differs from #960's head or between the engines. Only the three left-side $params.m.d shapes changed, in both engines.

Found, not fixed (both engines pass, the rules say fail; type 1 entries in spec/OPEN.md, with cases that are known failures in both lists): a root on the value side of a one-line every … whose over an empty list (two groups, is in and contains, m missing and 3), and a root from the subject (pr.m named by key, missing, null, 3). The derived case "… says the root and then the list's own problem / the root is null and the list is empty" pins every xs whose tags contains $input.m named by key, if any, exists as passing, the wrong verdict; it is unchanged and named in the entry. Also in spec/OPEN.md: a type 2 (the outcome of a root that isn't an object in a some without , if any,) and a type 3 (ergo.rego drops tests is [] there).
Cuts: Rust 27 to 27, Rego 82 to 82 (.github/message-cuts.sh --against origin/main passes).

Lists: the two $params.m null and not-an-object rows and the $params.m missing-key row are out of engines/rust/known-failures.txt. The five rows added in 4b32a0d (value-side $params.m missing and 3, subject pr.m missing, null and 3) are in both known_differences and known-failures.txt, and name real cases. Three rows stay in both lists: sentences "a root read through the item's own key, in a one-line every with if any, is read once, before any item, …" (missing, null, 3). They fail only on the order of inputs: both engines put $input.m before tests[], the case puts tests[] first, and walk.inputs doesn't decide the order. spec/OPEN.md has it as a type 2 entry, and the type 1 entry of this PR is gone.

Checks on 362da8a, after .github/build-ergo.sh:

  • Pass: the three opa check --strict forms, opa fmt --list, regal lint (no violations), python3 spec/check_rules.py, .github/rego-layers.py, .github/no-inline-tests.sh, no comments in .rego files, .github/message-cuts.sh --against origin/main, test_every_known_difference_names_a_case.
  • cargo test -j 2 --workspace --no-fail-fast: all pass (2799 tests, including --test cases). cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --check pass. The sentence oracle: 3533 checks, 0 differ from ergo.rego.
  • Wasm budgets (ERGO_WASM_BUDGETS_ONLY=1): 28.9 of 29 MB, 19.4 of 20, 42.0 of 45, for 114.4 of 118 (114.4 on main), 52.3 of 53.
  • python3 spec/sweep.py --limit 500 on this branch and on origin/main: the same 477 cells, 296 differing cells on each side, the output identical apart from the Rust commit line, 0 type 1, 15 type 2.
  • Full opa test engines/rego dist spec:spec examples:examples --ignore src --timeout 900s --coverage (about 35 minutes): exit 1, one failure, data.spec_test.test_the_derived_cases_pass_part_6_of_6. It passes on 8329928, so 362da8a broke it in ergo.rego only (the Rust --test cases passes). The case is the derived group "a count over a list reached through a list, whose whose compares the item's value with a root read through a key the item holds, puts in each item entry the field the whose read inside the item", check xsv (count of ys.v whose v is not $input.m named by key is 0), rows "the root is null / is missing / isn't an object and the items have the key but their own value is missing or null". The item entries' inputs are ys[0].v (usable, {"key": "a"}) where the case wants ys[0].v.v (absent, or null for item 2). Messages, causes and verdicts are the same. Cause: _keyed_walk_cond now drops the right side of every comparison, where it dropped it only for includes. As the run failed, there is no coverage JSON and no not-covered list.

.github/pr-facts.sh:

## Rust report changes

9 case reports changed between origin/main and the working tree.

- sentences 627, 629, 641, 643-647, 745

Passing cases whose report changed: 0 (information only: a case compares the fields it lists, so a passing case can change a field it doesn't list).

Cases only on one side: 14 new, 0 removed.

## Known failures

known-failures.txt had 573 lines and has 575 now.

Pass now, and did not before: 3
- sentences / a root from $params read through a named by key from the subject and then the item's key is read once, before any item, so a root that has no key for the subject's key fails the check on an empty list too / fails as absent naming the root through the subject's key when the params' m has no such key and tests is empty
- sentences / a root from $params read through the item's own key, in a one-line every with if any, is not an object, so it fails as unusable on an empty list / fails as unusable naming $params.m when tests is empty
- sentences / a root from $params read through the item's own key, in a one-line every with if any, is null, so it fails as null on an empty list / fails as null naming $params.m when tests is empty

Fail now, and did not before: 5
- sentences / a root from $params read through the item's own key on the value side of a whose, in a one-line every with if any, is read before any item, so it fails as unusable on an empty list when it is not an object / fails as unusable naming $params.m when tests is empty
- sentences / a root from $params read through the item's own key on the value side of a whose, in a one-line every with if any, is read before any item, so it fails on an empty list when it is missing / fails as absent naming $params.m when tests is empty
- sentences / a root from the subject read through the item's own key, in a one-line every with if any, is read before any item, so it fails on an empty list when it is missing, null or not an object / fails as absent naming pr.m when it is missing and tests is empty
- sentences / a root from the subject read through the item's own key, in a one-line every with if any, is read before any item, so it fails on an empty list when it is missing, null or not an object / fails as null naming pr.m when it is null and tests is empty
- sentences / a root from the subject read through the item's own key, in a one-line every with if any, is read before any item, so it fails on an empty list when it is missing, null or not an object / fails as unusable naming pr.m when it is 3 and tests is empty

Not run: coverage lines (see above), the Wasm run of the whole suite and wasm-tests.sh, the packages/ checks, spec/check_grammar.py, the Docker checks, docs-run.sh.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn

jbpros and others added 30 commits December 5, 2026 01:05
…m $params is read before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… comes after it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…he root read before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…nt of the item's key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…tem's key has its base read before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…nt of the item's key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… spec/OPEN.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…he root before any item of the walked list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… of the item's key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…d line alias is not read before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…line alias

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…m's key, and a bound alias in front of it (guards)

Guards that pass as they are: `m` null and 3, `k` missing, null, 3
and empty in both engines, and a bound line alias in the chain in the
Rust engine.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…puts entry in spec/OPEN.md

The entry for a root read through a key from $params and then the
item's key no longer says the row's inputs are settled: no rule decides
them, and two cases expect different inputs. The entry on a one-line
every with if any names the chain forms, and the entry on roots said
again for each item drops the count form, which ergo.rego now says once.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… key, in either order

With xs holding an item and no m in the params the check fails as absent naming item 1 of xs, and with xs empty and if any it passes, since the root is read with each item and not at all when there is none.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…st rows in spec/OPEN.md

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…d when the whose of the later line leaves no item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…se of the later line leaves no item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ck on an empty later list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ct on an empty later list

An item of a count of that the that can't decide was dropped as said
by the earlier item, because that item isn't an object, even when the
sentence reads the alias only whole, as a key.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…n empty later list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…s when a later whose fails one condition and leaves another undecided

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…st, which ergo.rego fails and Rust passes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…a that keyed by an earlier alias

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…t's key before the item's key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… a root with no key for it fails on an empty list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…t's key before the item's key

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ot with no key for the subject's key fails on an empty list

The test that pinned no fault for $params.m named by $params.k when m is
{} now says it is missing, as tally.walk and for.roots say.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ject's key before any item, and drop its open entry

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… that isn't an object fails as unusable

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ct, so the root fails as unusable on an empty list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
jbpros and others added 12 commits December 5, 2026 05:07
…ct fails the root as unusable on an empty list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…list the Rust engine's new causes as open

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…an object, and the null one, before the item's key on an empty list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… it among the known backward calls

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…e item's key before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…e item's key before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…e every or some

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…e every or some

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… any item, and drop the two cases Rust passes from its known failures

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
@jbpros jbpros added this to the 26.ac milestone Dec 5, 2026
@jbpros jbpros added bug Something isn't working core Relates to the ergo library or format themselves. rust labels Dec 5, 2026
jbpros and others added 6 commits December 5, 2026 06:52
… in OPEN.md what still differs after the one-line every fix

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…wn differences

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…h the item's key to each item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…em in a one-line every or some, so it is said once

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…e a field as a step that isn't an object

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
… a field, even on an empty list

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
jbpros and others added 6 commits December 5, 2026 08:20
…y comparison to each item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…item's key before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…s whose to each item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…item's key before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…one-line every, and pin the list-prefix root

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…he item's key before any item

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Relates to the ergo library or format themselves. rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant