Skip to content

Commit 2f796b1

Browse files
committed
Harden integrated US evidence review gates
1 parent 22a7c00 commit 2f796b1

5 files changed

Lines changed: 64 additions & 2 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Integrated sprint review — 2026-09-18
2+
3+
This private engineering review covers the integrated APHIS completeness
4+
accounting, FSIS stale-handoff guard, FSIS recall evidence parser, Brazil
5+
source documentation, and the shared country/source platform. No data was
6+
published or promoted.
7+
8+
## Fixes applied
9+
10+
- APHIS completeness now remains `incomplete` when duplicate export-page rows
11+
are present, even if the inflated input count reaches the operator-supplied
12+
displayed-row count. Duplicate observations remain quarantined.
13+
- FSIS recall establishment inference now requires an explicit `EST` marker
14+
in free text. Digits in firm names or reasons cannot create a source-local
15+
facility join.
16+
17+
## Validation
18+
19+
The focused package-qualified suite passed: 15 tests covering FSIS refresh,
20+
FSIS recall parsing, APHIS Wave 2 accounting, and the US refresh/rehearsal
21+
contracts. A direct `unittest discover -s pipeline/sources/us` invocation also
22+
ran 62 tests successfully but reported two loader errors for relative-import
23+
tests (`test_refresh` and `test_real_rehearsal`); running those modules with
24+
package-qualified names passed them. This is an invocation portability issue,
25+
not a product-test failure.
26+
27+
## Residual risks
28+
29+
The APHIS proof remains a bounded operator-saved subset, not a national
30+
completeness or currentness claim. FSIS recalls remain private, review-required
31+
evidence and source-local candidate edges; a recall is not itself a finding of
32+
wrongdoing. Registry coverage, source terms, privacy review, factual review,
33+
project approval, and publication remain separate gates. No public release or
34+
promotion was performed.

pipeline/sources/us/accountability/aphis_wave2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _coverage_accounting(
127127
"failed_export_count": len(failed),
128128
"failure_states": dict(sorted(Counter(str(item.get("state", "unclassified")) for item in failed).items())),
129129
"not_observed_rows": max(expected - observed, 0) if expected is not None else None,
130-
"accounting_state": "complete" if expected is not None and observed >= expected and not failed else "incomplete",
130+
"accounting_state": "complete" if expected is not None and observed >= expected and not failed and not manifest["duplicate_page_rows"] else "incomplete",
131131
"not_observed_semantics": "not observed by this acquisition; not closure, non-use, or evidence of absence",
132132
}
133133

pipeline/sources/us/accountability/test_aphis_wave2.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ def test_operator_expected_count_can_be_overridden_without_claiming_completion(s
6666
self.assertEqual(report["completeness"]["inspections"]["not_observed_rows"], 0)
6767
self.assertEqual(report["completeness"]["inspections"]["accounting_state"], "complete")
6868

69+
def test_duplicate_pages_do_not_claim_completeness(self):
70+
with tempfile.TemporaryDirectory() as directory:
71+
root = Path(directory)
72+
input_root = root / "inputs"
73+
input_root.mkdir()
74+
rows = {
75+
"ExportData-registrations.csv": "Account Name,Customer Number,Certificate Number,Registration Type,Certificate Status,Status Date\nA,2,00-R-0002,Class R - Research Facility,Active,2026-01-01\n",
76+
"ExportData-annual_reports.csv": "Customer Number,Certificate Number,Year,Dogs,Cats\n2,00-R-0002,2025,,1\n",
77+
"ExportData-inspections.csv": "Customer Number,Certificate Number,Inspection Date,Direct NCIs,Non-Critical NCIs,Critical NCIs,Teachable Moments,Site Name,Legal Name,License-Registration Type,City,State,Zip\n2,00-R-0002,2026-02-01,,,,,S,A,Class R - Research Facility,T,TX,75001\n",
78+
}
79+
for name, content in rows.items():
80+
(input_root / name).write_text(content, encoding="utf-8")
81+
(input_root / (Path(name).stem + "-page2.csv")).write_text(content, encoding="utf-8")
82+
report = run_wave2(input_root=input_root, run_dir=root / "run", expected_rows={"inspections": 1})
83+
self.assertGreater(report["completeness"]["inspections"]["duplicate_page_rows"], 0)
84+
self.assertEqual(report["completeness"]["inspections"]["accounting_state"], "incomplete")
85+
6986

7087
if __name__ == "__main__":
7188
unittest.main()

pipeline/sources/us/fsis/recall.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ def _establishment_number(row: dict[str, Any]) -> str | None:
4545
# Source text such as "EST. 1234" is retained as an explicit source clue,
4646
# but never treated as a join when multiple identifiers occur.
4747
import re
48-
matches = sorted(set(re.findall(r"\b(?:EST\.?\s*)?(\d{1,6})\b", text, re.I)))
48+
# Digits in names/reasons are not identity evidence. Require an explicit
49+
# establishment marker before creating a source-local join.
50+
matches = sorted(set(re.findall(r"\bEST\.?\s*(\d{1,6})\b", text, re.I)))
4951
return matches[0] if len(matches) == 1 else None
5052

5153

pipeline/sources/us/fsis/test_recall.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ def test_run_is_deterministic_and_row_free_manifest(self):
3434
self.assertEqual(json.loads((Path(left) / "aggregate-manifest.json").read_text())["quarantined_rows"], 1)
3535
self.assertFalse("records" in json.dumps(a))
3636

37+
def test_digits_in_free_text_do_not_create_establishment_join(self):
38+
parsed = parse_bytes(json.dumps({"results": [{
39+
"recall_number": "FSIS-2026-003",
40+
"firm": "Foods 123 LLC",
41+
"reason": "Product code 456",
42+
}]}).encode("utf-8"))
43+
self.assertEqual(len(parsed["accepted"]), 0)
44+
self.assertIn("unresolved_establishment_identifier", parsed["quarantined"][0]["reasons"])
45+
3746

3847
if __name__ == "__main__":
3948
unittest.main()

0 commit comments

Comments
 (0)