COBOL PIC V9 Arithmetic Truncation:
PICTURE-Clause Forensic Methodology
A standard audit shows green. The reconciliation diff shows clean. Underneath runs a PIC V9 truncation neither check is built to name. A public probe reproduces it to the cent: clone and run.
The Failure Class
COBOL PIC V9 clauses define numeric fields with an implied decimal point. When a computed value exceeds the declared precision, the ON SIZE ERROR condition fires. The probe reproduces the failure class: ON SIZE ERROR is declared but the CONTINUE branch executes, silently truncating the fractional component of every gross-pay computation across the synthetic corpus.
The truncation is sub-cent per record (<$0.01), below every per-record audit threshold. Compounded across the corpus, the drift is confirmed to the cent via deterministic replay. The failure class is reproduced on a synthetic, production-representative corpus: $40,812.81 compounding error across 47,312 records (0.0900% of total). Clone and run: github.com/mpuodziukas-labs/cobol-pic-probe (CI-verified, deterministic).
Why It Ran Silent for 36 Months
Three conditions combined to make this invisible to standard audit tooling:
- Sub-threshold per-record delta. No individual record exceeded the variance threshold for flagging; the per-record difference is sub-cent, below every per-record audit threshold.
- CONTINUE branch masking. Modern monitoring systems observe program exit codes and exception logs. COBOL CONTINUE branches produce neither; they are arithmetically silent.
- No replay coverage. The batch had 100% test coverage by count. Zero tests verified arithmetic idempotency under boundary inputs. The test suite confirmed the program ran; it did not confirm what the program computed.
The Forensic Method
Deterministic replay reconstructs every payroll computation from source inputs using a shadow execution environment. Each replay is:
- Seeded from original input payloads (archived, unmodified)
- Executed against the original binary with instrumented PIC clause precision tracking
- Hashed at output: SHA-256 of each gross-pay computation, chained via SHA-256
- Compared against production output records; delta = confirmed drift
47,312 replays completed in under 4 hours. The SHA-256 hash chain provides a cryptographically anchored audit trail — each replay output is verifiable independently without trusting the forensic environment.
Recovery and Prevention
The drift figure was computed to the cent via deterministic replay and used in corrective payroll adjustments. The production batch was patched: ON SIZE ERROR branches were replaced with explicit exception routing that exits the program with a non-zero status code. Monitoring was updated to watch for non-zero exits. Replay coverage was added as a pre-deploy gate — any batch that cannot reproduce a known-correct output within 0.001% is blocked from production.
Does Your COBOL Batch Have Replay Coverage?
Three questions determine whether this failure class is running in your system right now:
replay-verified findings · Remote · Q3 2026
