feat(parser): add opt-in GTIN check-digit validation #42
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 225 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.324
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #42"
general
weight: 0.35
Boulea7
Summary
Add opt-in GTIN check-digit validation for AI 01 and AI 02, including supported bare GTIN and retail-carrier inputs. Go callers can set
ParseOptions.ValidateCheckDigits, the CLI accepts-check-digits, and WASM acceptsvalidateCheckDigits.Default parsing stays lenient. The existing
-strict/strictoptions continue to validate associations only, and both checks can be enabled independently.Barcode.Validate()now runs association checks followed by GTIN checks against its current elements. The ADR documents error priority and UPC-E / stripped ITF check-digit handling.Closes #6. This covers the check-digit validation paths while preserving the existing association-only strict options; it does not adopt the same strict flag proposed in that issue.
Specification reference
The GS1 Syntax Dictionary, release 2026-01-27, AI 01 (
GTIN) and AI 02 (CONTENT) entries, specifiesN14with thecsumconstraint. This change reuses the package's existingValidateGTINimplementation.Validation
make all,make race,GOMAXPROCS=4 make fuzz(30 seconds),make bench,make build, andmake wasmpass.node wasm/check-digits.test.mjspasses against the built WASM module, including all four combinations of the two validation options.BenchmarkParseIntoremains at 0 B/op and 0 allocs/op.Checklist
make allpasses (vet, lint, tests)CHANGELOG.mdupdated under Unreleased