# Replay protocol 1. Input is UTF-8 ASCII command lines. Horizontal space, tab, and CR separate tokens; blank lines and lines whose first token begins `#` are ignored. An inline comment begins at a `#` token. Decimal operands consist only of ASCII digits and fit in a signed 32-bit integer; leading zeros are allowed. The program exits 2 for a malformed command, without an observation for it. Tests send syntactically valid commands. 2. `T owner lock` and `D owner lock` print `R status`. `B owner lock...` and `A owner` also print `R status`. `Z` prints `Z 0`. 3. `V owner` prints `V owner top_level depth lock...`, with `depth` lock IDs in acquisition order. `P lock` prints `P lock actual_owner`. `C` prints `C occupied_count`. 4. `S` prints one line: `S occupied_count port0 port1 port2 port3 port4 port5 top1 depth1 locks1... top2 depth2 locks2... top3 depth3 locks3... top4 depth4 locks4...`. Depth controls the number of lock tokens in each variable-length portion. 5. Each observation ends with LF. Normal completion exits 0. The program may write diagnostic text to stderr; only the documented stdout and exit status are observations. No output line may be skipped or duplicated. Output integer tokens are ASCII decimal with an optional leading sign and any number of leading zeros; one or more spaces, tabs, or CR bytes separate output fields. The field values, line tags, and line order carry the meaning. 6. `I` prints `I occupied mismatches inversions duplicates mask1 mask2 mask3 mask4`. The audit walks each owner's reported stack and the actual port slots: a mismatch counts a stack item whose port owner differs, a port-held lock missing from its owner's stack, an invalid item, or a reported top level inconsistent with its stack; an inversion counts each nonincreasing adjacent stack level; duplicates count stack entries after the first use of a lock. Each mask has bit `lock ID` set for an item in that owner's stack. A healthy state has zero mismatches, inversions, and duplicates. 7. `F owner` prints `F owner result0 result1 result2 result3 result4 result5`: each result is the status that a `T` by that owner would return for that lock, without changing state. `G owner` prints `G owner eligible_count first_eligible_id`, where eligible means `F` result 0, and first is the lowest eligible lock ID or -1. An invalid owner has six -22 results, count 0 and first -1. 8. `E owner` prints `E owner result0 result1 result2 result3 result4 result5`: each result is the status that a `D` by that owner would return for that lock, without changing state. An invalid owner has six -22 results. 9. `J` prints `J attempts successes failures reads resets` for this process since startup. `T`, `D`, `B`, and `A` each count once as an attempt; their 0 results are successes. `V`, `P`, `C`, `S`, `I`, `F`, `G`, and `E` each count as a read. `J` itself does not change counters. `Z` increments resets but does not clear counters.