Skip to content

impl(070): exact-value conditions, vocabulary capture and its hint grade in the core (increment 2b) - #579

Merged
bartekus merged 1 commit into
mainfrom
impl/070-inc2b
Nov 9, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/070-inc2b

Conversation

@bartekus

@bartekus bartekus commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Spec 070 (rustev.extract-rules/2, #572), increment 2b of 3: exact-value conditions, vocabulary capture and its hint grade.

What changes

  • equals and one_of (3.4): text by bytes, integers, booleans and enum options by value; Source::Exact carries a non-text input value; an unreadable condition source ends the field source_unavailable and is never false, so not cannot turn it true; a condition source is a read for lineage and derivation. Binding: a non-nullable text, integer, bool or enum input or record field whose provenance excludes model-derived, values of its type, enum values among its options; a source read only by exact-value conditions need not be projected.
  • vocabulary_after (3.3.5): a letter-and-digit run of 1 to 64 bytes equal byte for byte to an option; fills text or the enum of its own vocabulary; vocabulary_unavailable when its input vocabulary was unavailable and no rule applied.
  • Grade (3.8): extraction_fallback::hint_paths; phase e2 gives the extract step a record tree with those fields at hint (quality::extract_tree), so an accept step over one is hint and a hard gate on it is refused with category 14 unless corroborated; every present value of such a field, model or rules, carries value metadata graded hint. Plans without vocabulary_after keep their bytes.
  • Tests: tests/extraction_rules_2.rs (each source type, no folding, unresolved under not, binding and vocabulary rows), tests/extraction_rules_2_grade.rs (static refusal, corroboration, dynamic grade).

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff against governance context. The changes implement spec 070 "Increment 2b" (exact-value conditions, vocabulary_after capture, and hint grading) across rustev-core source and test files, plus an annotation in the spec document.

Key areas examined:

extraction_fallback.rs — exact_conditions binding check
The function validates that condition sources exclude model-derived provenance and that values match declared types. For a source not found in program.sources, reference defaults to "", strip_prefix("input:") returns None, and input.is_none_or(...) correctly errors. Sources are guaranteed to start with "input:" by the earlier loop in bind_in, so the unwrap_or_default path is safe. The fits closure correctly rejects nullable types (no arm matches TypeDecl::Nullable) and record types. Test coverage (undeclared inputs, wrong types, nullable, model-derived) is complete.

extraction_fallback.rs — core_only projection logic
A source used only by exact-value conditions (exact_read but not text_read) is exempt from projection, consistent with spec 3.4.2. Sources used by vocabulary_after (via value_sources) are added to text_read and must be projected. This is verified by the test that shows a source used in both an exact condition and a text condition must be projected.

extraction_fallback.rs — condition evaluation: Equals/OneOf via ?
The ? propagates Err(Reason::SourceUnavailable) out of All/Any/Not on unavailable sources, consistent with spec 3.4.5 ("never false"). The test for any: [one_of(c, [7]), always] with unavailable c asserting SourceUnavailable confirms this design choice.

extraction_fallback.rs — vocabulary_unavailable flag scope
Reads is created fresh per field (confirmed by the diff), so vocabulary_unavailable correctly isolates per-field state. The flag is not reset between rules for the same field, which is intentional: a vocabulary_unavailable attribution for a field requires that ALL rules failed and at least one hit a missing vocabulary.

extraction_match.rs — word_after length bounds
(1..=64).contains(&n) enforces 1-to-64-byte inclusive range; only ASCII-alphanumeric bytes are captured. Correct.

quality.rs — extract_tree structure
Correctly returns a single Ungraded leaf when hints.is_empty(), and a full record ceiling tree otherwise. The rec.finish() call computes the ceiling from children, consistent with the existing Ceil pattern.

compile.rs — split of StepInfo::Extract
Extract steps now go through extraction_compile::hint_paths → quality::extract_tree, while Ranking and Generate remain Ungraded. This is exactly spec 3.8.3.

extraction_eval.rs — extract_hint_meta
The match arms correctly handle: absent/null fields (no grade), top-level hint fields (Some(_) with hints.contains(&(name, None))), record subfield hints (checked inside the Value::Record arm), and other non-hint fields (default Ungraded). The arm ordering is correct — a Value::Record whose top-level entry is in hints would hit arm 2 first, grading the whole record as hint (acceptable since VocabularyAfter can only produce Text or Enum, not Record).

Spec file — lifecycle
The diff adds increment notes to the "Pending with implementation" narrative section only. The frontmatter (status, implementation) is unchanged. No lifecycle claim is being made by this diff.

Governance conformance
No unsafe, no I/O, no async runtime, no forbidden dependencies introduced into rustev-core. Spec change accompanies code change. ✓

No concrete defects found.

{"head": "123d2cebfe97ad52e00b67d1198e7562532999c0", "verdict": "no-findings", "findings": []}

Subject: 6ebca0c...123d2ce, diff digest 7ecb8d82783acc499d2de57c9b3a3a1c1531251d95c3fe0f4914cd8a66a768b3, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit e11a8fc Nov 9, 2026
26 checks passed
@bartekus
bartekus deleted the impl/070-inc2b branch November 9, 2026 01:51
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