Wire IndicatorValidator + RecordStructureValidator at strict_marc (bd-0x73.1)#175
Merged
Conversation
…-0x73.1)
Resolves the four unwired validator structs from the v0.8 audit per
bd-0x73.1: format-semantic checks (`IndicatorValidator`,
`RecordStructureValidator`) now run automatically at
`validation_level="strict_marc"`; content/heuristic helpers
(`IsbnValidator`, `EncodingValidator`) remain user-callable opt-in
APIs documented in `docs/reference/validators.md`.
Per-tag MARC 21 indicator semantics (e.g., 245 ind1 ∈ {0,1}) and
leader-byte semantics (e.g., record_status ∈ {a,c,d,n,p}) reuse
existing error codes E201 and E002 with tag- or position-specific
`expected:` strings — granularity belongs at validation_level, not
at the error-code dimension. Both are recoverable in
`lenient`/`permissive`, consistent with .10's single rule.
`RecordStructureValidator::validate_leader` now fires `InvalidLeader`
(E002) instead of the misleading `InvalidField` it built before.
Test matrix extends `validation_level_matrix.rs` with two new
fixtures (per-tag indicator failure on 245, invalid record_status
in leader); `error_coverage.toml` carries both with
`validation_level = "strict_marc"`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Resolves bd-0x73.1 — the four unwired validator structs from the v0.8
audit. Decisions per validator:
IndicatorValidator→ wired atvalidation_level="strict_marc"(per-tag MARC 21 indicator rules;IsbnValidator/EncodingValidatorleft opt-in).RecordStructureValidator→ wired atvalidation_level="strict_marc"(MARC 21 leader-byte semantics).IsbnValidator→ opt-in callable API; documented in newdocs/reference/validators.md.EncodingValidator→ opt-in callable API; documented alongsideIsbnValidator. Heuristic detection deliberately stays out ofstrict_marcsince strict_marc must be deterministic.The principled split is format-semantic vs. content/heuristic, not a BC-driven carve-out (pre-1.0).
Design call worth flagging
Per-tag indicator violations and leader-byte semantic violations reuse existing error codes E201 and E002 with tag- or position-specific
expected:strings, rather than minting new variants. Granularity belongs atvalidation_level, not at the error-code dimension — same conceptual concern, same code, different sub-rule. This keeps the public error surface from fragmenting as more validators get wired.Both new failure shapes are recoverable in
lenient/permissive, consistent with bd-0x73.10's single rule.RecordStructureValidator::validate_leadernow firesInvalidLeader(E002) instead of the misleadingInvalidFieldit built before (drive-by fix).Test plan
cargo test --test validation_level_matrix— two new fixtures (e201_per_tag_indicator_245.bin,e002_invalid_record_status.bin) exercising the 2×3{validation_level} × {recovery_mode}matrix.tests/error_coverage.toml— both cases registered withvalidation_level = "strict_marc"; harness reports 20/20 wired (was 18/18)..cargo/check.sh(full): 538 lib/integration + 32 doc tests pass; clippy clean (core + python); ruff clean; maturin builds; mkdocs builds.Docs
docs/reference/validators.mdpage covering all four validators with auto-run vs opt-in classification, code examples, and the format-semantic / content-heuristic principle.docs/reference/error-codes.md— E002 and E201 entries describe both failure shapes.docs/reference/error-handling.md— validation-level table extended with the per-tag and leader-semantic rows.CHANGELOG.md [Unreleased]updated.🤖 Generated with Claude Code