Six runtime QA primitives, extracted from the production product-data enrichment engine behind unbin.io and published as a work sample by BARGO, SIA. These packages are the quality-assurance mechanisms that keep the engine's output defensible — per-field conflict resolution, confidence calibration, citation self-verification, regression and dead-seam alarms, a prompt-injection boundary, and an uncertainty-driven fetch policy. Every number in this repository comes from production telemetry or from the benchmark that judged the mechanism; one of the six is published because its own benchmark refused it.
Provenance: this repository was carved out of the engine's private monorepo in
August 2026 for publication — the git history here is the extraction, not the
build; the mechanisms' production history is narrated in the dated
notes (June–August 2026). Before publication the tree
went through a reproduction-gated review — every finding demonstrated failing,
fixed, and pinned by a regression test (the review: commit) — as a
publication-hardening gate, not a production incident log.
flowchart LR
AI["active-inference<br/>ranked fetch — off by default"] --> F[fetch]
F --> IF["injection-fence<br/>envelope + target gate"]
IF --> EX[extract]
EX --> FU["fusion<br/>per-field resolve"]
FU --> CA["calibration<br/>fitted confidence"]
CA --> SV["self-verify<br/>evidence join"]
SV --> OUT["ship the field — or ship blank"]
DA[determinism-alarm] -. "nightly sweep over run history" .-> OUT
| package | mechanism | prior-art lineage | receipts |
|---|---|---|---|
@bargo/fusion |
Trust-weighted per-field truth discovery: conflicting source values resolved by learned per-host reputation (Beta-Bernoulli posterior, deterministic UCB exploration), over an append-only observation store, with a gap/frontier computation for re-runs | TruthFinder/Accu-line truth discovery (Dong et al.) | 59 tests across 8 files; a load-bearing production quarantine of 81 poisoned weight observations understated 10× to 12,100× |
@bargo/calibration |
Fitted confidence calibrator — isotonic regression and Platt scaling — plus an ECE measure and a drift monitor; identity by default, refuses to persist a model that regresses | Isotonic/PAV (Zadrozny & Elkan 2002), Platt scaling (Platt 1999), ECE (Naeini, Cooper & Hauskrecht 2015) | 94-SKU non-circular benchmark: engine accuracy 82% (89/109 grounded verified fields), calibrated ECE 0.018; 19 tests |
@bargo/self-verify |
Deterministic citation self-verification: every cited value joined back to the evidence text the run actually read; null only on positive contradiction; identity gates for barcodes | Claim-verification evidence containment reduced to deterministic token matching; Fellegi–Sunter (1969) record linkage; GS1 check-digit and company-prefix rules | Closes a measured ~18% cited-but-wrong class from a 2026-07-09 audit; 34 tests over real scrubbed production incidents |
@bargo/determinism-alarm |
Peak-vs-latest completeness-regression detection plus dead-seam streak alarms (zero vision spend on images-expected runs, zero grounded attributes), swept nightly | None claimed — incident-driven engineering; cost telemetry reused as a liveness probe | Built from a real unalarmed 0.88 → 0.69 → 0.62 per-SKU regression that only a customer complaint surfaced; 16 tests, including that exact incident shape |
@bargo/injection-fence |
Deterministic prompt-injection boundary for crawled content: fenced envelope, attacker fence-token defanging, provenance gate on fetch targets; no LLM classifier anywhere | OWASP LLM Top 10 (2025), LLM01 Prompt Injection | 69-line zero-import production module, hardened in the review pass (Set-pool normalization, stateless exported regex, control-char-inert provenance attribute); 12 tests including the nested-closing-tag escape and the source_url attribute-injection breakout |
@bargo/active-inference |
Uncertainty-driven fetch ranking plus a break-even stop rule — refuted by its own paired 91-SKU A/B and reworked, not deleted | Weitzman (1979) Pandora's-box reservation-value rule; active inference / predictive processing (Friston 2010, Clark 2013) | Original stop rule refused: grounding −40%; rework: −4.7% grounding at −50.2% cost, still FAIL on the tail (25/91 SKUs losing >5 attrs); 12 tests; ships default OFF with the full 91-row A/B fixture |
pnpm install
pnpm -r test # 152 tests, all green on a cold clone
Each package's README documents its mechanism, design decisions, and receipts;
tests run standalone with no runtime dependencies. Before anything in this tree
is published, every commit passes a commit-blocking scrub gate
(scripts/scrub-gate.sh: a private banned-string list plus the committed
generic PII check in scripts/pii-check.sh) so customer, supplier, and
personal identifiers never reach the public tree.
Each primitive has a companion note on bargo.lv covering the mechanism, the production incidents behind it, and the decisions we would defend in review:
- primitive-fusion — why majority vote, whole-card "keep best", and "manufacturer wins" all fail in this domain
- primitive-calibration — making "confidence: 0.86" mean correct ~86% of the time, and noticing when it stops
- primitive-self-verify — the cited-but-wrong class, and refutation without a verifier model
- primitive-determinism-alarm — making quiet degradation loud
- primitive-injection-fence — a deterministic envelope for attacker-influenceable content
- primitive-active-inference — the primitive our own benchmark refuted; we reworked it and kept it, behind an explicit opt-in, with the paired A/B fixture included in the package so the refutation is checkable
This is published source, not open-source software. Copyright BARGO, SIA — all rights reserved; see NOTICE. We publish it for reading and evaluation: you are welcome to read the code, run the tests, and assess the work. No rights are granted to use, copy, modify, or redistribute any part of it.