You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
impl(070): token_after, token_matching and declared date formats in the core (increment 2a) - #578
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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), possessivetoken_matchingwith its occurrence, and everydateformat with declared month tables, proleptic Gregorian validity (a calendar-invalid match ends the search) andYYYY-MM-DDrendering, then validated by 038 3.4 (so pre-1970 isfallback_invalid). Integer and byte operations only.extraction_fallback::bind_intakes the definition's inputs and adds 3.5.1, 3.5.3 and 3.5.4 for these extractors: a projectedtextsource, the field type,monthsexactly for a name format and naming a declared table.bindwithout inputs binds no version 2 extractor.equals,one_ofandvocabulary_afterstay refused until 2b.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(goldentests/golden/extraction-rules-2.plan.jsonand its PlanId; identity over every program member; refusals in phase c).tools/rustev-release/archive-policy.jsonlists the new source file; spec 070 gains theextendsedge ontools/rustev-release/(031) and the 2a implementation record.Evidence