Deterministic CSV batch upsert fix with 3-lane verification & anti-tamper gate
Real local execution of a deterministic repository bug fix demonstrating multi-round F2P/P2P verification, frozen test hashing, and a live anti-cheat counterexample where green pytest output is still rejected.
In `csv_upsert/importer.py`, `import_batch_csv()` retains the first seen row when duplicate `record_id` values appear in a batch and leaves `overwritten_count` at `0`. Update the implementation so later rows overwrite earlier ones and `overwritten_count` accurately counts duplicate overwrites without modifying frozen tests.
- • Only source files under `csv_upsert/` may be modified; `tests/test_importer.py` is frozen by SHA-256.
- • Must reproduce deterministically across 2 independent rounds per lane (baseline, gold_fix, counterexample).
- • Preserve insertion order for distinct keys and single-row import behavior (P2P regression checks).
- Target Source
- csv_upsert/importer.py
- Frozen Test SHA-256
- 6c9a813a9ae9e2c9…
- Gold Patch SHA-256
- bf1a2f88002c8296…
Baseline lane fails deterministically on `test_duplicate_id_uses_latest_row` across 2 rounds while both P2P regression tests pass.
{
"command": "pytest -q --tb=short tests/test_importer.py::test_duplicate_id_uses_latest_row"
}Confirm clean assertion failure (not an environment/import error) before editing source code.
F [100%]
=================================== FAILURES ===================================
______________________ test_duplicate_id_uses_latest_row _______________________
tests/test_importer.py:32: in test_duplicate_id_uses_latest_row
assert res.records["R-201"]["status"] == "settled"
E AssertionError: assert 'pending' == 'settled'
E
E - settled
E + pending
=========================== short test summary info ============================
FAILED tests/test_importer.py::test_duplicate_id_uses_latest_row - AssertionE...
1 failed in 0.02s
