Skip to content

impl(066): the under segment ancestry predicate; spec 066 complete - #558

Merged
bartekus merged 4 commits into
mainfrom
impl/066-under
Nov 7, 2026
Merged

bartekus merged 4 commits into
mainfrom
impl/066-under

Conversation

@bartekus

@bartekus bartekus commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Completes spec 066 (segment ancestry predicate under, amends 002 and 032) for 0.6.0.

What changes

  • rustev-contract: Predicate::Under { value, ancestor, separator } with the closed SegmentSeparator set :, /, |, . (3.1). The four definition and plan schemas and both bindings' generated declarations regenerate with the added member (review-excluded; checked by tests/schemas.rs and gen-types --check).
  • rustev-core: builder e::under (3.4.3); registry 2 construct, so definition 1 refuses it in phase b, category 11 invalid_definition, requires_definition_2 (3.5.1); non-nullable text operands checked in phase e for steps, corroboration checks and policy conditions (3.1.2); byte-exact evaluation with invalid_input naming under value / under ancestor for an empty operand or empty segment (3.2, 3.3.2); grade/read propagation as cmp (3.4.1); under positions are never parameter sites (3.4.2).
  • Tests: crates/rustev-contract/tests/segment_ancestry.rs, crates/rustev-core/tests/segment_ancestry.rs (every 3.2.5 example and section 5 row for each separator, unresolved operands in a step, policy propagate/as_unmet, corroboration check, grades, handler coverage, builder bytes), a skipped operand in acquisition_eval.rs, synthetic package goldens tests/golden/segment-ancestry.*.
  • Five Acceptance mutation seeds in crates/rustev-eval/mutation/seeds.py under spec 066.
  • Spec completion: Implementation record, implementation: complete, ## Verification, Makefile VERIFIED_SPECS and integrations-plans acceptance group, extends edges (001 Makefile, scripts/acceptance/; 004 mutation/).

Evidence

  • spec-spine verify 066: passed locally (5 commands; seeds 5/5 detected), before the rebase onto main.
  • Full crate suites (contract 364, core 554, conformance 13), workspace clippy -D warnings, fmt, both gen-types --check; wasm 4,821,398 of 5,242,880 bytes.
  • No existing golden, plan or PlanId changed (R-1).
  • make gate passes.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff for spec 066 (segment ancestry predicate) implementation.

Correctness of eval_predicate logic: The strip-prefix + separator-first-byte check correctly implements strict ancestry (equal operands → false, sibling-prefix → false). Empty-segment validation for both operands is correct. No issue.

field_ty_mode / nullable detection: The preserve_nullable flag correctly keeps the declared type at the final path element so the caller can detect nullable. The intermediate fields still unwrap. No issue.

type_under / under_types double-dispatch in compile.rs: Covers Exact, All, Any, Not in Cond; Under, All, Any, Not in Predicate. Other variants fall through to Ok(()) correctly. No issue.

Parameter-site exclusion in sites.rs and v2 guard in predicate_uses_v2 are consistent with the closed-set design.

Contradictory test assertions in examples_and_mutation_seeds_for_every_separator (crates/rustev-core/tests/segment_ancestry.rs, lines ~160–162):

("é:x", "é", Some(false)),
("é:x", "é", Some(true)),

The two entries are rendered identically in the diff. For any of the four separators, é:x starts with é followed by the separator byte, so strip_prefix(é_bytes).is_some_and(|s| s.first() == Some(&sep)) returns true. The Some(false) assertion is wrong and will cause the test to fail on that iteration. If the intent is to contrast NFC (U+00E9, 0xC3 0xA9) vs NFD (e + 0xCC 0x81) encodings — which would give false for the NFD-value / NFC-ancestor pair — that encoding difference is invisible in the rendered diff and completely undocumented in comments or the spec, making the test misleading in either interpretation.

No other concrete defects found (security, authority, ratification, or other correctness).

{"head": "37bde499ac1e555cfac24f391a5a7862503bf5ad", "verdict": "findings", "findings": [{"path": "crates/rustev-core/tests/segment_ancestry.rs", "line": 160, "severity": "medium", "category": "correctness", "summary": "Two entries with the same apparent (value, ancestor) pair '(\"é:x\", \"é\")' carry contradictory expected results Some(false) and Some(true); the actual evaluation result is true for all four separators, so the Some(false) assertion will cause the test to fail if the two string literals are bytewise identical, and if they intentionally encode NFC vs NFD forms of é that difference is undocumented and invisible in the diff."}]}

Subject: e8f6653...37bde49, diff digest 659a79b5f0605fe5396bf69cd1e0d9738b34c9fda4ce6a5ec5ca958b33064a45, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus temporarily deployed to statecraft-review-exception November 7, 2026 22:42 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff carefully against the governance context, the spec text for 066, and the implementation.

Core evaluation logic (expr.rs)

Empty-segment check: text.as_bytes().split(|b| *b == sep).any(|part| part.is_empty()) correctly rejects trailing/leading separators and empty strings because splitting "" or "us:" on any separator produces at least one empty slice.

Ancestry check: value.as_bytes().strip_prefix(ancestor.as_bytes()).is_some_and(|suffix| suffix.first() == Some(&sep)) is correct: equal operands return None from is_some_and (suffix is empty, first() is None); sibling prefixes are rejected because the byte after the prefix is not the separator; and genuine ancestry passes. The separator bytes are single ASCII bytes that cannot appear inside UTF-8 multi-byte sequences, so the byte-level split is safe for Unicode text.

Nullable operand detection (field_ty_mode)

The refactored field_ty_mode with preserve_nullable: true correctly unwraps intermediate nullable wrappers (index + 1 < path.len()) and preserves the nullable wrapper only at the last path step, so a Text field below a Nullable(Record) is correctly accepted while a direct Nullable(Text) field is correctly rejected. The test text_field_below_nullable_record_keeps_its_declared_type exercises this.

v2 gating and parameter sites

predicate_uses_v2 correctly marks Under as requiring definition v2 (verified by version_one_refuses_before_operator_resolution). The reference_sites exclusion adds "under" to the split-path check, correctly preventing parameter sites inside under positions.

Traversal completeness

predicate_refs, predicate_structure, predicate_mins, predicate_reads, has_fx_pred all use the same Cmp | Under arm pattern and treat operands identically to Cmp. No traversal function is missing the new variant.

Policy-condition type check (compile.rs)

under_types descends Cond::All/Any/Not/Exact and delegates to type_under for predicates, which handles nested All/Any/Not/Under. The check runs with item: None, which is correct for policy conditions; the Ref::Item branch inside type_predicate calls env.item.unwrap(), but type_expr would already have returned Err for an item ref in a non-item context, preventing the unwrap from being reached.

Lifecycle and spec frontmatter

The transition implementation: pending → complete is a correct factual record of work done on an already-approved spec. The three new extends edges (crates/rustev-eval/mutation/ via spec 004, Makefile and scripts/acceptance/ via spec 001) match the actual code changes and are consistent with the ratification section's description. The two new depends_on entries (001, 004) are correct additions.

Mutation seeds

All five seeds in seeds.py correspond to named defects in the spec 066 Acceptance section: byte-prefix without separator, empty segment as false, equal operands as true, unresolved as false, and ASCII case folding. Each seed targets the precise code that implements the corresponding invariant, and the detection crate (rustev-core) is correct in each case.

Goldens

The five judgment goldens are internally consistent: under → reason:under, not-under/sibling-prefix → reason:not-under, missing → missing_evidence, malformed ("us::soho") → invalid_input with "under value has an empty segment". The plan golden's registry field is rustev.exact/2, matching the v2 requirement.

No concrete defects found.

{"head": "274f5ddb706aaaa53723926b004c4816c8ecdcfc", "verdict": "no-findings", "findings": []}

Subject: e8f6653...274f5dd, diff digest 62d22e04c5e65fccd10b5896d297faf19b67e9a21288a77b8ceeb92e0346675a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 7, 2026
@bartekus
bartekus removed this pull request from the merge queue due to a manual request Nov 7, 2026
Predicate::Under with the closed separator set, compilation (registry 2,
non-nullable text operands in phase e for steps, checks and policy
conditions), byte-exact evaluation with invalid_input for empty segments,
grade propagation and parameter-site exclusion; regenerated schemas and
binding types; synthetic package goldens; five mutation seeds.
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the PR against the governance context, the spec 066 lifecycle change, and the implementation in full.

Lifecycle transition. implementation: pending → complete on an already-approved spec is the correct next step per the contract table. No ratification claim is being made here.

New extends edges. The PR adds three new additive edges in the spec frontmatter:

  • crates/rustev-eval/mutation/ (spec 004) — covers seeds.py
  • Makefile (spec 001) — covers the VERIFIED_SPECS addition
  • scripts/acceptance/ (spec 001) — covers verify.py

All changed paths are either covered by pre-existing extends edges (established at ratification: rustev-contract/, rustev-core/, binding type directories) or by the newly added edges above. No unowned path changes.

SegmentSeparator and wire shape. The closed enum serialises to exactly ":" / "/" / "|" / "." via serde rename. deny_unknown_fields on Predicate::Under and the closed enum together refuse any other separator at parse time. Contract test (crates/rustev-contract/tests/segment_ancestry.rs) verifies round-trips, missing-field errors, unknown fields, and duplicate keys for all four separators and five invalid ones. ✓

predicate_uses_v2. Predicate::Under is correctly added alongside MemberRef and IsConstructed, so a rustev.definition/1 using it fails in phase b with requires_definition_2. ✓

eval_predicate correctness.

  • Validation loop: split(|b| *b == sep).any(|part| part.is_empty()) correctly catches empty string, leading/trailing separator, and consecutive separators for both operands.
  • Ancestry check: strip_prefix(ancestor.as_bytes()).is_some_and(|suffix| suffix.first() == Some(&sep)) is true iff value starts with ancestor's bytes followed immediately by the separator byte — correctly refusing equal operands (empty suffix → first() == None) and sibling prefixes (suffix first byte ≠ separator). ✓

Nullable operand check. field_ty_mode with preserve_nullable: true correctly preserves the declared nullable type only at the final path element. Intermediate nullable containers (e.g. Nullable(Record)) are still unwrapped at non-terminal steps. The compile-time check then rejects Nullable(Text) operands while allowing non-nullable text below nullable record wrappers — matching the golden test text_field_below_nullable_record_keeps_its_declared_type. ✓

reference_sites exclusion. Adding "under" to the JSON-path exclusion set correctly prevents any field inside an under predicate from being treated as a parameterization site. ✓

Handler-coverage requirement. A compare step's invalid_input reason is already in the unresolved set, so no new coverage rule is needed; the test missing_invalid_input_handler_is_refused verifies that an only:[missing_evidence,stale,conflict] filter still triggers the UnhandledUnresolved error for invalid_input. ✓

Policy condition phase-e check. under_types in compile.rs recurses through Cond::All/Any/Not/Exact and delegates to expr::type_under, which further recurses through Predicate::All/Any/Not before calling type_predicate. The _ => Ok(()) arm covers only Cond variants that cannot contain under predicates in this corpus. ✓

Mutation seeds. All five seeds have clear detection paths in segment_ancestry.rs: byte-prefix without separator check → sibling-prefix case; empty-segment as false → InvalidInput status; equality as true → equality case; unresolved as false → missing_stale_conflicting test; case-fold → case-sensitivity cases. ✓

Grade propagation, reads, and effects. predicate_mins, predicate_reads, has_fx_pred, and predicate_refs all bind value → left, ancestor → right via OR patterns, mirroring Cmp handling. ✓

No concrete bugs, security issues, authority changes, or ratification inconsistencies found.

{"head": "1e414e42e9a4dbd1c76badb160a0447ff9733567", "verdict": "no-findings", "findings": []}

Subject: 35ab7e5...1e414e4, diff digest 1dc328ffd86d022faa9c47c2abcabedf12ccf2bef8b7862d89914398da2db69a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit 83cb3dc Nov 7, 2026
26 checks passed
@bartekus
bartekus deleted the impl/066-under branch November 7, 2026 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant