Skip to content

say an earlier line's alias read as a named by key when a later for line's whose leaves no item - #959

Draft
jbpros wants to merge 23 commits into
mainfrom
for-alias-keys-later-line
Draft

jbpros wants to merge 23 commits into
mainfrom
for-alias-keys-later-line

Conversation

@jbpros

@jbpros jbpros commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #957, merge in order. The diff against main holds #957's commits until it merges.

ergo.rego now says an earlier line's alias read as a named by key under a second for line with , if any, whose whose leaves no item, as for.pass and for.if_any say. _for_second_has_items in engines/rego/src/lines/for_lines.rego counts only the items the later line's whose keeps (or can't decide), so a whose that leaves nothing is treated like an empty list.

Changes the report: for: every ys as y, every xs whose v is 1, if any, as x with count of zw.k that is in $params.m named by y named by x is at most 5, ys [3], xs [{"v": 2}] used to pass in ergo.rego and now fails as unusable with item 1 of ys: y is 3, which isn't text, as the Rust engine already did. Other changes the review probed: without , if any,, every ys as y, every xs whose v is 1 as x with ys [3] and xs [{"v": 2}] was value with item 1 of ys is 3 and is now unusable with item 1 of ys: y is 3, which isn't text; item 1 of ys is 3, and a single key named by y with y null adds item 1 of ys: y is null to the message.

  • Removes the three for cases "an earlier line's alias read as a named by key that isn't text, under a second for line with if any whose whose leaves no item, …" from known_differences, and their entry from spec/OPEN.md.

The Rust engine now fails a count of whose that reads an earlier line's alias as the named by key when an item can't be decided, even when the later list is empty and the earlier item isn't an object, as for.roots says. item_roots in engines/rust/engine/src/ops/for_line.rs dropped every not_an_object root when the earlier item isn't an object, and now drops only those of a sentence or whose that reads into the alias, like y.k.

Changes the report: for: every ys as y, every xs, if any, as x with count of zw.k that is in $params.m named by y is at most x.n, ys ["a"], xs [], zw [{"k": 1}, 5] and the params {"m": {"a": [1]}} used to pass in the Rust engine and now fails as not_an_object with item 1 of ys: item 2 of zw is 5, which isn't an object, as ergo.rego already did. With ys [3] and xs [], named by y and named by y.k were unusable with only y is 3, which isn't text and are now not_an_object with , and item 2 of zw is 5, which isn't an object added. Without , if any,, every ys as y, every xs as x with xs [] was value with xs is [] and is now not_an_object with xs is []; item 1 of ys: item 2 of zw is 5, which isn't an object.

  • Removes the type 1 entry for it from spec/OPEN.md. Its sentences case still fails in both engines, only on wording: it also expects item 1 of ys: the check is false, which no rule gives. So it stays in engines/rust/known-failures.txt and in known_differences, under the type 3 entry in spec/OPEN.md.

Added after review: a guard test, test_a_count_whose_key_from_the_first_lines_alias_is_left_to_the_items_when_the_whose_of_the_second_list_fails_one_condition_and_leaves_another_undecided, which covers the line _for_second_whose_keeps(wh) if wh.undecided != [] and passes on the existing behaviour. A type 1 found by the review, on the base of #957 too, has a hand-written sentences case and a known_differences row for ergo.rego and an entry in spec/OPEN.md: for: every ys as y, every xs, if any, as x with count of zw.k that is in $params.m named by y named by x is at most 5, ys ["a"], xs [], zw [{"k": 1}, 5] and the params {"m": {"a": {"a": [1]}}} fails in ergo.rego as not_an_object with item 2 of zw is 5, which isn't an object, and passes in the Rust engine, which is right (for.roots, for.if_any). The case's inputs are copied from the Rust engine, because no rule decides them. Three more differences found by the review are listed in spec/OPEN.md (type 2, type 3, type 2). No engine code changed.

cuts: Rust 27 to 27, Rego 82 to 82

Wasm budgets (ERGO_WASM_BUDGETS_ONLY=1): 28.9 of 29 MB, 19.4 of 20 MB, 42.0 of 45 MB, for 114.4 of 118 MB (as on main), 52.3 of 53 MB.

Sweep (python3 spec/sweep.py --limit 500, 477 cells), on this branch and on main: 296 cells differ between the engines on both, type 1: 0, type 2: 15, type 3: 281, and the lists of cells are the same on both, so the sweep shows no change.

.github/pr-facts.sh:

## Rust report changes

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

- sentences 629, 739

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: 4 new, 0 removed.

## Known failures

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

No case started or stopped passing.

Run: the full opa test engines/rego dist/ergo.rego spec:spec examples:examples --ignore src --timeout 900s --coverage (no line listed as not covered by .github/build-ergo.sh where; I did not keep its exit code), opa eval --strict-builtin-errors ... 'count(data) > 0' (true), the three opa check --strict forms, opa fmt --list, regal lint bugs (no violations), python3 spec/check_rules.py, .github/rego-layers.py, .github/no-inline-tests.sh, the comment listing (none), .github/message-cuts.sh --against origin/main, the oracle validate (0 differ), cargo test --workspace (2795 pass, 0 fail), cargo clippy --all-targets -D warnings, cargo fmt --check. Not run: the Docker checks, the Wasm opa test --target wasm runs, the other .github/*_test.sh scripts, spec/check_grammar.py, spec/sweep_test.py, the packages checks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn

jbpros and others added 17 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
@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 02:58
…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

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