Skip to content

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

Draft
jbpros wants to merge 38 commits into
mainfrom
b8b-roots-before-item
Draft

jbpros wants to merge 38 commits into
mainfrom
b8b-roots-before-item

Conversation

@jbpros

@jbpros jbpros commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #959 (which is stacked on #957), merge in order. The diff against main includes their commits until they merge.

Fixes the type 1 difference in spec/OPEN.md "A chain of a key from the subject and then the item's own key, over an empty list". tally.walk says a root that's missing or null fails the check "even when the list is empty", and for.roots says "Each root is read once, before any item". Both engines read such a root only up to the first key that isn't plain text, so $params.m was read and $params.m named by pr.key wasn't.

Both engines now read the root up to the item's own key, in one place each:

  • Rego: _keyed_root_fault in engines/rego/src/lines/roots.rego reads each prefix up to the item's key when _keyed_root_path holds.
  • Rust: base_of in engines/rust/engine/src/ops/key_base.rs reads the path up to the item's key when the steps before it can be read.

The same holds for a key from $params in front of the item's key: with {"k": "a", "m": {}}, $params.m named by $params.k named by key on an empty list now fails as absent. A Rust unit test pinned no fault there, and it now says $params.m named by $params.k is missing, as the rules say.

The case row is gone from known_differences and from engines/rust/known-failures.txt, and the OPEN.md entry is deleted.

Changes the report: with the params {"m": {}}, key "a" for the subject and tests [], count of tests whose v equals $params.m named by pr.key named by key is 0 passed and now fails as absent with $params.m named by pr.key is missing. A root read through a key from $params and then the item's key changes the same way. So do sum of … whose and count of … that, roots from $input and from the subject (pr.m), keys from $input and chains of two keys from the subject. A null prefix fails as null, a subject key text that names nothing ("", "zz") fails as absent, and a prefix that isn't an object (3, a list, a text) fails as unusable, also in the middle of a chain like $params.m named by pr.k1 named by pr.k2 named by key, which passed in both engines. Under for: every xs, if any, as x with xs [], … named by pr.key named by key passed and now fails as absent; under for: every xs as x with xs [] the cause goes from value to absent or null; with xs ["a"], $params.m named by x named by key and $params.m named by pr.key named by x named by key go from pass to fail. In the Rust engine alone, a one-line some or every without , if any, on an empty list now takes the root's cause (value to absent), and count of tests.v that equals $params.m named by pr.key named by key is 0 with an item that isn't an object goes from absent to not_an_object; both are listed in spec/OPEN.md.

Spec cases: four groups in spec/cases/sentences/cases.json, written from tally.walk and for.roots, for count of tests whose v equals $params.m named by pr.key named by key is 0 with tests []: m null (null), {"a": 3} and {"a": []} (unusable, $params.m named by pr.key is 3, which isn't an object), and $params.m named by pr.k1 named by pr.k2 named by key with {"a": 3} (unusable, $params.m named by pr.k1 is 3, which isn't an object). The missing and {} forms were already cases. Both engines give the same verdict, cause and message for all four, and inputs and failures copy the Rust rows (said in spec/OPEN.md). In the last one ergo.rego gives the root entry the outcome absent and Rust unusable: type 2, listed in OPEN.md and in known_differences. spec/OPEN.md also lists the type 3 difference of sum of v of tests whose ... named by pr.key named by key (needs more than 15 digits in ergo.rego, $params.m named by pr.key is 3, which isn't an object in Rust), which main does not report: on main both engines pass that check (satisfied, no message), because neither reads the root before an item and the list is empty. One oracle row added. layers-known.txt gets _keyed_prefix_fault -> _m_isnt, which rego-layers.py failed on.

cuts: Rust 27 to 27, Rego 82 to 82 (no touched function cuts message text); message-cuts.sh --against origin/main passes.

Run, on head 572c62d: .github/build-ergo.sh; the three opa check --strict forms, opa fmt --list, regal lint (no violations), python3 spec/check_rules.py, rego-layers.py (and its test), no-inline-tests.sh, the no-comments listing (nothing); the full opa test engines/rego dist spec:spec examples:examples --ignore src --timeout 900s --coverage (exit 0, no line outside a test reached: none listed by build-ergo.sh where); cargo test -j 2 --workspace --no-fail-fast (all pass) and cargo fmt --check; python3 engines/rust/sentences/tests/oracle/validate.py (0 differ, row added); Wasm budgets (ERGO_WASM_BUDGETS_ONLY=1): 28.9/29, 19.4/20, 42.0/45, 114.4/118 (same as main), 52.3/53 MB; spec/sweep.py --limit 500 on this branch and on origin/main: identical output, 0 cells differ, so no verdict changes in the sample; pr-facts.sh, below.

Clippy: cargo clippy --workspace --all-targets -- -D warnings is clean after dropping a needless borrow in key_base.rs; cargo fmt --check, the key_base unit tests and --test cases pass.

Not run: opa eval --strict-builtin-errors separately (the full test run exited 0), the Wasm test runs of the whole suite, check_grammar.py, spec-schemas.py, the docs and other .github/*_test.sh scripts, the packages checks. E6 (one-line every with , if any,) is not in this pull request.

pr-facts (against origin/main, so it includes #957 and #959): 4 case reports changed (sentences 627, 629, 641, 739), 0 passing cases changed, 8 cases new on this side and 0 removed; known-failures.txt 573 lines to 572, one case passes now that did not before (the E1 case "a root that has no key for the subject's key").

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn

jbpros and others added 28 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
@jbpros jbpros added this to the 26.ac milestone Dec 5, 2026
@jbpros jbpros added the bug Something isn't working label Dec 5, 2026
@jbpros jbpros added core Relates to the ergo library or format themselves. rust labels Dec 5, 2026
jbpros and others added 10 commits December 5, 2026 05:01
… 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
…ads a keyed root

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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…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

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