Skip to content

impl(070): token_after, token_matching and declared date formats in the core (increment 2a) - #578

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

bartekus merged 1 commit into
mainfrom
impl/070-inc2a

Conversation

@bartekus

@bartekus bartekus commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Spec 070 (rustev.extract-rules/2, #572), increment 2a of 3: the token and date extractors in the core.

What changes

  • rustev-core/src/extraction_match.rs (new): the byte matchers of 3.2 and 3.3.1 to 3.3.3: earliest term with declared-order ties, the one-separator skip, byte classes, token boundaries (non-ASCII bytes bound a token), token_after's whole run or nothing (never cut short), possessive token_matching with its occurrence, and every date format with declared month tables, proleptic Gregorian validity (a calendar-invalid match ends the search) and YYYY-MM-DD rendering, then validated by 038 3.4 (so pre-1970 is fallback_invalid). Integer and byte operations only.
  • extraction_fallback::bind_in takes the definition's inputs and adds 3.5.1, 3.5.3 and 3.5.4 for these extractors: a projected text source, the field type, months exactly for a name format and naming a declared table. bind without inputs binds no version 2 extractor. equals, one_of and vocabulary_after stay refused until 2b.
  • Tests: crates/rustev-core/tests/extraction_rules_2.rs (section 5's extractor rows, every date format with valid, calendar-invalid and pre-1970 dates, a native byte-identity corpus standing in for wasm32), tests/extraction_compile.rs (golden tests/golden/extraction-rules-2.plan.json and its PlanId; identity over every program member; refusals in phase c).
  • tools/rustev-release/archive-policy.json lists the new source file; spec 070 gains the extends edge on tools/rustev-release/ (031) and the 2a implementation record.

Evidence

  • No existing golden, plan or PlanId changed (I-1).

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff carefully across all changed paths.

extraction_match.rs (new file)

  • first_term: uses text.windows(t.len()), which panics if t.len() == 0. An empty string in terms would panic at runtime. The schema almost certainly enforces minLength: 1 on terms (I cannot inspect the schema since it's in the excluded generated tree), so I cannot confirm this as a defect from the supplied evidence alone.

  • skip: correctly stops at \n (neither space nor tab, and not consumed as a separator). Tests confirm skip(b" \n X", 0) == 1.

  • nth_match: the end > start guard prevents an infinite loop for a zero-length shape match.

  • date: calendar-invalid match immediately returns None (terminates the entire search). The test "31/2/2026 1/3/2026" → None confirms this matches the spec.

  • calendar_valid: the classic proleptic Gregorian formula is correct (1900 not leap, 2000 is, 2024/02/29 valid). The _ => false arm covers months 0 and 13+.

  • digits with len = Some(4): accepts run ≥ 4 and consumes exactly 4, so "20261" leaves 1 unconsumed and the subsequent end_boundary check fails. ✓

extraction_fallback.rs

  • bind now delegates to bind_in(&[], ...), so all v2 extractors fail the text-source check (empty inputs → input_type always returns None). Correct per spec.

  • extractors_v2: the VocabularyAfter branch is dead code — the guard at the top of bind_in already refuses programs containing VocabularyAfter before extractors_v2 is ever called. This is harmless.

  • Month table lookup in value: self.program.month_tables.clone().unwrap_or_default() gives an empty map for v1 programs; named-format Date extractors can't reach eval without a declared table (binding rejects them), so the empty map is never queried for a named format. ✓

  • Ordering: extractors_v2 runs after the existing "undeclared source" check, so the unwrap_or_default() fall-through ("") in extractors_v2 is unreachable in practice.

extraction_compile.rs / extraction_eval.rs

Both pass &def.inputs / &self.compiled.plan.definition.inputs to bind_in. The .expect("compiled fallback") in eval is safe because compile-time rejection guarantees any plan reaching eval is already bound.

specs/070-extract-rules-2/spec.md

The new extends entry claims additive nature over tools/rustev-release/, which is consistent with the archive-policy addition. The increment description matches the code: bind_in added, extraction_match.rs new file, v2_value returning None for the three newly-bound extractors.

tools/rustev-release/archive-policy.json

Adds src/extraction_match.rs to the rustev-core source list. Consistent with the new file and the spec claim.

No concrete defects are supported by the supplied evidence.

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

Subject: cb12bdf...d8a70a8, diff digest f24f16e4e0412a644ea490beef1e5d05b2b3dcbe905e95738adb2cf0f282a39a, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 9, 2026
@bartekus
bartekus added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit 6ebca0c Nov 9, 2026
26 checks passed
@bartekus
bartekus deleted the impl/070-inc2a branch November 9, 2026 01:02
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