Skip to content

rego: read the field in front of a list through one rule that says where each kept item's field comes from - #962

Draft
jbpros wants to merge 41 commits into
mainfrom
b3-field-source-seam
Draft

jbpros wants to merge 41 commits into
mainfrom
b3-field-source-seam

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.

B3 is a sibling of #961 on #960. Merge order: #957, #959, #960, #961, then this; rebase onto main after #961's squash and resolve OPEN.md and the lists by hand.

This is the first of two pull requests for the type 1 entries in spec/OPEN.md about a field in front of a list with a whose, named like a for alias (the every form and the tally form). The fix comes in the next pull request. This one only adds the seam it needs.

  • The first commit carries the spec/OPEN.md correction from the closed spec: say the Rego engine also reads the item's field in a tally of a field named like a for alias #958: the tally entry is a type 1 in both engines, because ergo.rego also reads each test's own d.
  • The Rego engine now has one rule, _walk_field_source, that says where each kept item's field is read from: today always the item itself, along the steps of the field. _walk_read_path and _walk_judgement (the part along the field) read the field through it, in place of their own check.path ++ field.path. The fix adds the alias as a second source there.
  • _walk_field_inputs reads no path of its own (it takes the kept items the walk read through _walk_read_path), so it is unchanged.
  • The Rust engine gets no seam here. It reads field.path in about eight places in engines/rust/engine/src/ops/walk.rs (Walk::leaf, field_item, leaf_path, and the helpers at the walk.field lines near 1706, 1724, 1758, 1815 and 1965), so one function for the source would be more than a few dozen lines. The fix pull request covers it.

Behaviour is unchanged: no report changes, no case changes state, and both lists of known failures are unchanged. No changelog line, for the same reason.

cuts: Rust 27 to 27, Rego 82 to 82 (the functions touched cut no message text)

Ran: the new unit test red, then green; opa test engines/rego/src engines/rego/tests/support_test.rego engines/rego/tests/lines engines/rego/tests/sentences engines/rego/tests/messages (546/546); the six field_of spec case tests on dist/ergo.rego; opa fmt --list engines/rego; python3 .github/rego-layers.py; python3 spec/check_rules.py.

Not run: the full opa test with coverage, the other spec case tests, the Rust workspace and Clippy (Rust is unchanged), Wasm, the sweep and pr-facts.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 11 commits December 5, 2026 05:03
…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
… field named like a for alias, and name its case, in spec/OPEN.md

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

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzW4N4nUhpU9sV5yVyXkyn
…ere each kept item's field is read from

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 core Relates to the ergo library or format themselves. label Dec 5, 2026

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

core Relates to the ergo library or format themselves.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant