feat(go): fixture capture + characterization framework (M3)
All checks were successful
Deploy to K8s / deploy (push) Successful in 7s
All checks were successful
Deploy to K8s / deploy (push) Successful in 7s
Closes M3.1–M3.6. Parity safety net proving Go output matches Python
for every ported pure-domain function (M2.1–M2.9) and reconcile (M2.10).
Capture pipeline:
- scripts/capture_fixtures.py: calls each Python function with seeded
inputs, emits JSON fixtures to stdout (never writes files directly).
- scripts/scrub_fixtures.py: deterministic PII scrubber — SHA-256
pseudonyms for member names, digit-preserving hashes for VS/account/
bank_id, name-sweep in message text. Idempotent; no salt.
- scripts/_fixture_seeds.py: handcrafted seeds for all 11 functions;
synthetic names throughout (no real roster members).
- scripts/capture_all_fixtures.sh: convenience wrapper for full corpus
regeneration outside of make.
Fixture corpus (98 files, all PII-free):
- go/tests/fixtures/pure/<func>/<case>.json — 10 function directories.
- go/tests/fixtures/reconcile/<NN>_<case>.json — 10 branch-coverage
cases: greedy, overpayment credit, proportional remainder, even-split,
out-of-window, exception override, other: purpose, junior ?, multi-
person+month fan-out, unmatched.
Go parity tests (//go:build parity):
- go/tests/parity/parityio.go: generic LoadDir/RunAll helpers + typed
In/Out struct pairs for all 10 pure functions; Envelope decoder for
int/float/none disambiguation.
- 10 pure-function test packages + bespoke reconcile test with per-cell
float tolerance (math.Abs <= 0.01 for `paid` values).
Makefile: go-parity, go-test-all, capture-fixtures targets.
go/tests/fixtures/README.md: refresh workflow + PII audit guide.
Gate: make go-test green, make go-parity green (11/11 packages),
make go-lint clean (parity tag), make go-build clean.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
46
scripts/capture_all_fixtures.sh
Executable file
46
scripts/capture_all_fixtures.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate the full fixture corpus.
|
||||
# Safe to re-run — always overwrites.
|
||||
# Requires: tmp/*_cache.json present (for real-data seeds for parse_month_references and match_members).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
FIXTURES="$REPO/go/tests/fixtures"
|
||||
CAPTURE_CMD="PYTHONPATH=$REPO/scripts:. python3 $REPO/scripts/capture_fixtures.py"
|
||||
SCRUB_CMD="python3 $REPO/scripts/scrub_fixtures.py"
|
||||
|
||||
run_func() {
|
||||
local func="$1"
|
||||
local dir="$FIXTURES/pure/$func"
|
||||
mkdir -p "$dir"
|
||||
echo " Capturing $func..."
|
||||
eval "$CAPTURE_CMD --func $func --all" | while IFS= read -r line; do
|
||||
case_id="$(python3 -c "import sys,json; print(json.loads('''$line''')['case'])" 2>/dev/null || \
|
||||
echo "$line" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['case'])")"
|
||||
echo "$line" | python3 "$REPO/scripts/scrub_fixtures.py" > "$dir/${case_id}.json"
|
||||
done
|
||||
}
|
||||
|
||||
echo "==> Capturing pure-function fixtures..."
|
||||
|
||||
run_func normalize
|
||||
run_func parse_month_references
|
||||
run_func calculate_fee
|
||||
run_func calculate_junior_fee
|
||||
run_func parse_czk_amount
|
||||
run_func generate_sync_id
|
||||
run_func build_name_variants
|
||||
run_func match_members
|
||||
run_func infer_transaction_details
|
||||
run_func format_date
|
||||
|
||||
echo "==> Capturing reconcile fixtures..."
|
||||
mkdir -p "$FIXTURES/reconcile"
|
||||
eval "$CAPTURE_CMD --func reconcile --all" | while IFS= read -r line; do
|
||||
case_id="$(echo "$line" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['case'])")"
|
||||
echo "$line" | python3 "$REPO/scripts/scrub_fixtures.py" > "$FIXTURES/reconcile/${case_id}.json"
|
||||
done
|
||||
|
||||
echo "==> Done. Review with: git diff go/tests/fixtures/"
|
||||
echo "==> Audit PII: git ls-files go/tests/fixtures | xargs grep -l '<real name>' should return zero."
|
||||
Reference in New Issue
Block a user