Deterministic CSV batch upsert fix with 3-lane verification & anti-tamper gate
Reproducible local sandbox execution of a deterministic repository bug fix using structured JUnit XML parsing, frozen test SHA-256 verification, git-applicable patch diff, and an executed test-tampering counterexample.
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 pass structured JUnit XML verification across 2 independent rounds per lane.
- • 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
- e1077fc472dcafc0…
Structured JUnit XML confirms deterministic failure on `test_duplicate_id_uses_latest_row` across 2 rounds while both P2P regression tests pass.
{
"command": "python3 -m pytest -q --tb=short -p no:cacheprovider tests/test_importer.py::test_duplicate_id_uses_latest_row"
}Confirm clean assertion failure (not an import or environment 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.01s
