# Audit report

> Re-audit the viewer folder only (`build-lane.py` and its HTML output), at commit 716819c. It is a follow-up to audit job 114b644c, so check whether each of those findings is fixed. Cover how it handles missing or malformed data, the "not checked" versus failure states, and escaping of untrusted values in the HTML. Treat every other folder as out of scope. Work offline and read-only. Give each finding a file and line, its impact, and steps to reproduce it.

| | |
|---|---|
| Repository | https://github.com/uxp-labs/flop-devnet-lab.git |
| Commit | `716819c41f8c655d8305db2a382a6b4e356d9e80` |
| Job | `5505b809-65df-47b2-8009-645e6e3460ec` |
| Judged | 2026-11-10 15:17 UTC |
| Findings | 1 medium · 8 low · 5 info |

Four agents audited the code as it is at `716819c`, each in one area (math, permissions, economics, control flow),
and a judge reproduced, merged and ranked what they found, then read the code once more itself. Nothing in the repository was changed or deployed.

## Findings

### 1. Medium: A failed receipt read or refresh (error set, http not 200, state null or undocumented) renders as a clean 'gateway observed' / 'match matches' row with no flag

`viewer/build-lane.py:144`

```
    if r.get("flag") == "key_expired":
        chips.append(["red", "unknown"]); row["bad"] = True; row["flags"].append("key expired, can't re-check")
    elif r.get("stage") == "gateway observed":
        chips.append(["amber", "gateway observed"])
```

build_row decides the FLOP column from the receipt's state, settled, chain_final, flag and stage only. It never reads the receipt's `http` or `error` fields, and treats any receipt state outside settled/released (including null and arbitrary strings) as a healthy pending receipt. imd-flop's classifyReceipt (imd-flop/src/receipts.ts:53-76) writes a receipt file even when the gateway read failed: state null, http 404/500/0, error set, and stage always the literal 'gateway observed'; only a 401 api_key_expired sets flag. `imd-flop receipt --refresh` (cli.ts:410-428) likewise keeps the saved settled/state and writes the new error/http/last_known_at when no fresh receipt arrives. All of these render as `<div class="row">` (not bad), chips 'sent' + amber 'gateway observed', 'chain final: not checked yet', 'match matches', and no flag; a failed refresh of a settled receipt even keeps 'observed spend 0.198'. The same clean row appears for a receipt state 'bogus', a ledger state 'bogus', or a ledger line with no state key at all. So the 'not checked yet' state and the 'checked and failed' state are indistinguishable for every failure class except key expiry, and the committed HTML's Notes line 163 ('A timeout or 404 shows as unknown and gets flagged') is false for this lane. Merged from audit_flow (line 144), audit_permissions (line 126, and its info on HTML line 163), audit_math (line 146) and the unknown-state part of audit_economics (line 133). Fix: before line 144, if r.get('error') is not None, r.get('http') not in (None, 200), or receipt_state not in ('reserved','estimated','settled','released'), append ['red','unknown'], set bad, add a flag such as 'receipt read failed: HTTP {http} {error}' (escaped) with last_known_at when present, never emit 'match matches' or 'observed spend', and never emit the 'gateway observed' chip from the stage string alone; treat a ledger state outside imd-flop's documented set the same way. Then correct Notes line 163 or make it true.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. Case 1 (failed read): ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"sent","spend":null,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":null,"settled":null,"stage":"gateway observed","chain_final":false,"flag":null,"http":500,"error":"HTTP 500 from gateway"}. Expected: row marked bad with a red 'unknown' chip and a flag naming HTTP 500. Actual (reproduced): `<div class="row">` not bad, `<span class="chip c-grey">sent</span> <span class="chip c-amber">gateway observed</span>`, `<span class="k">match</span> matches`, `chain final not checked yet`, no `<div class="flag">`. Identical output with http 404 / error 'not found', with receipt state 'bogus', with ledger state 'bogus', and with the ledger line's state key removed. Case 2 (failed refresh of a settled receipt): ledger line with state 'settled' and spend 0.198; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"settled","settled":0.198,"stage":"gateway observed","chain_final":false,"flag":null,"http":503,"error":"HTTP 503","last_known_at":"2026-11-01T00:00:00Z"}. Expected: bad row saying the last re-check failed, last-known values only. Actual (reproduced): not-bad row, 'match matches', 'observed spend 0.198', no mention of 503 or the last_known_at date.

### 2. Low: 114b644c L9 only partly fixed: an invalid UTF-8 byte or over-nested JSON in ledger.jsonl, or a directory/over-nested file matching *.json, still aborts the whole rebuild and leaves the committed viewe

`viewer/build-lane.py:47`

```
        for n, line in enumerate(fh, 1):
            if not line.strip(): continue
            try:
                e = json.loads(line)
                if not isinstance(e, dict): raise ValueError("not an object")
            except ValueError as ex:
```

read_ledger decodes the file while iterating at line 47, outside the per-line try/except (lines 49-53) that is meant to turn a bad line into an 'unreadable' row, so one invalid UTF-8 byte (for example a torn append that cuts a multi-byte character in job or reason) raises UnicodeDecodeError out of from_files(). json.loads (line 50) and json.load (line 64) raise RecursionError, not ValueError, on deeply nested input, so the `except ValueError` handlers do not catch it. read_receipts (lines 62-66) opens every glob match and catches only ValueError, so a directory named like `archive.json` raises IsADirectoryError (any OSError, such as a permission error, aborts the same way). The guard at line 78 covers only build_row. In every case main() exits 1 with a traceback before the viewer is written, so the committed HTML keeps its previous rows with no sign it is stale, which is the outcome L9 ('one malformed item does not abort the rebuild', docstring at lines 43-44) was meant to remove. The committed test test_V_L9_one_malformed_item_does_not_abort_the_rebuild only covers a list receipt, a string daily_cap and a non-JSON ASCII line, so it passes while these abort. Merged from audit_flow (line 47), audit_permissions (line 47), audit_economics (lines 47 and 65) and audit_math (lines 47, 50, 64). Fix: open the ledger with errors='surrogateescape' (or read bytes and decode each line inside the try); catch Exception (at least ValueError, RecursionError, OSError) per ledger line and per receipt file, producing an unreadable row/receipt; skip non-regular files in read_receipts with os.path.isfile; extend the L9 test to these cases.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. (a) ledger.jsonl = the line {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"sent","spend":null,"reason":null} followed by the raw bytes 7b 22 6a 6f 62 22 3a 22 63 61 66 c3 0a ({"job":"caf<0xC3>\n); req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"estimated","settled":null,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null}. Expected: 'lane rebuilt: 2 receipt rows' with one red 'unreadable' row for ledger line 2. Actual (reproduced): exit 1, `UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 328: invalid continuation byte`, viewer HTML byte-identical to before. (b) valid ledger.jsonl + req-1.json, then `mkdir D/archive.json`. Actual: exit 1, `IsADirectoryError: [Errno 21] Is a directory: '.../archive.json'`, viewer untouched. (c) ledger.jsonl whose first line is 100000 '[' then 100000 ']' followed by the valid line, or a receipt file req-1.json with that content. Actual: exit 1, `RecursionError: Stack overflow ... while decoding a JSON array`, viewer untouched.

### 3. Low: A numeric `settled` on a non-settled receipt is shown as 'observed spend' with 'match matches', and the ledger's own spend is never checked on the pending path

`viewer/build-lane.py:152`

```
    row["flop"].append(["observed spend", settled])
```

`settled = amount(r.get("settled"))` (line 126) is rendered as 'observed spend' at line 152 whatever the receipt state is. On the pending branch (receipt state not settled/released) the only disagreement checks are `st in SETTLES or chain_final` (line 133), so a numeric settled on an estimated/reserved receipt, or a ledger spend that contradicts the receipt, passes as a clean row. imd-flop's own ledger logic only counts a settlement when the state settles (cli.ts stateSettles; run.ts settledKnown), so the viewer shows a spend the ledger never recorded, on a not-bad row, with no flag even when it is above the per-call cap. Merged from audit_flow (line 152) and audit_economics (line 133, parts 1 and 2). Fix: pass settled to 'observed spend' only when receipt_state in SETTLES, and on the pending branch set disagree when settled is not None or amount(e.get('spend')) is not None.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. Case 1: ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"sent","spend":null,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"estimated","settled":0.9,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null}. Expected: observed spend blank (not settled) or an amber disagree chip. Actual (reproduced): `<div class="row">` not bad, 'match matches', `<span class="k">observed spend</span> <span class="mono">0.9</span>` (above the 0.25 per-call cap, no flag). Case 2: same ledger line but state 'estimated' and spend 0.3; receipt settled 0.05. Expected: amber 'receipt and ledger disagree'. Actual: clean row showing 'observed spend 0.05', ledger figure ignored.

### 4. Low: Every refused_local row is labelled 'cap hit = stop', including estimate failures and pre-send provider refusals

`viewer/build-lane.py:101`

```
        row["spend_flags"] = ["cap hit = stop", esc(e.get("reason") or "")]
```

imd-flop writes state refused_local for three different causes: cap refusals (run.ts lockedCheck, lines 213-220), estimate failures ('estimate failed (...)' / 'estimate returned no usable cost', run.ts 198-200, quote_padded null) and a PreSendError after the sent line ('nothing sent: ...', run.ts 250, same request_id). build_row hard-codes the first spend flag 'cap hit = stop' for all of them, so a provider outage or a pre-send rejection is shown in red as a cap stop beside a reason that says otherwise, misreporting which guard stopped the call. Merged from audit_flow and audit_math (both line 101). Fix: derive the first flag from the reason (cap wording -> 'cap hit = stop', 'estimate failed' -> 'estimate failed = stop', 'nothing sent' -> 'refused before send'), or drop the fixed prefix and show only the escaped reason; have imd-flop record a refusal kind if a cleaner signal is wanted.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = {"job":"j","request_id":null,"seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":null,"cap_charge":0,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":null,"state":"refused_local","spend":null,"reason":"estimate failed (ECONNREFUSED)"}. Expected: a flag naming the estimate failure, no cap wording. Actual (reproduced): Spend column `<div class="flag">cap hit = stop</div><div class="flag">estimate failed (ECONNREFUSED)</div>`. Same with state refused_local, cap_charge 0, reason 'nothing sent: provider refused before mint' and request_id req-1: `cap hit = stop` then `nothing sent: provider refused before mint`.

### 5. Low: A ledger entry with no receipt file always shows 'last seen: sent' and prints the raw ledger state as the red flag

`viewer/build-lane.py:105`

```
        row["flop"] = [["last seen", "sent"], ["observed spend", None]]
```

When no receipt file exists for a request_id (r is None, lines 103-107) the row hard-codes 'last seen sent' whatever the ledger's latest state is, and unresolved_flag (line 98) falls back to the bare escaped state string for any state other than timeout_unknown. A ledger whose latest line is 'settled' (spend recorded), 'estimated' or 'released', with the receipt file missing or deleted, renders 'last seen sent' plus a red flag reading just 'settled'. The row contradicts the ledger it was built from and never says that the receipt file is missing, which is the actual failure. Keeping observed spend blank is correct. Merged from audit_flow, audit_economics and audit_math (all line 105). Fix: show esc(st) as 'last seen', and use an explicit 'no receipt file for this request: spend not confirmed' flag when st is not timeout_unknown/error.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"settled","spend":0.198,"reason":null} ; no req-1.json. Expected: 'last seen settled' and a flag such as 'receipt file missing'. Actual (reproduced): `<span class="k">last seen</span> sent` and `<div class="flag">settled</div>`, chips sent + red unknown.

### 6. Low: A missing receipts directory or missing ledger.jsonl silently rewrites the lane as 'No receipts found.' with exit 0, and receipt files with no ledger line are never shown

`viewer/build-lane.py:72`

```
    if not os.path.exists(led): return []
```

from_files returns [] when RDIR/ledger.jsonl does not exist, which covers a mistyped argv[1], a directory that does not exist, and a directory holding receipt files but no ledger. main() then rewrites the committed viewer, removing every existing row, prints 'lane rebuilt: 0 receipt rows' and exits 0, and the page states 'No receipts found.' even when receipt files are present. Rows are driven only by ledger entries (line 75), so a receipt whose request_id has no ledger line (ledger truncated, rotated or deleted after the run) is loaded by read_receipts and then dropped without trace, although a receipt is the gateway's own record that a paid call happened. Missing input thus becomes a confident 'nothing here' state. Merged from audit_flow (line 72), audit_permissions (line 72), audit_economics (line 77) and audit_math (line 72). Fix: exit non-zero without touching the viewer when RDIR is not a directory or has no ledger; after the ledger rows, emit a red 'receipt without ledger entry' row for each receipt key not consumed by a ledger entry and count them in the summary; show 'No receipts found.' only when there are no receipt files either.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. (a) `python3 build-lane.py $TMPDIR/no-such-dir`. Expected: non-zero exit, viewer untouched. Actual (reproduced): exit 0, 'lane rebuilt: 0 receipt rows, 6 example rows', and the viewer now contains `<p class="k">No receipts found.</p>` in place of the three demo rows. (b) D containing only req-9.json = {"request_id":"req-9","job":"j","seat":"1234","did":"did:key:z","state":"settled","settled":0.2,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null} and no ledger.jsonl. Actual: same 'No receipts found.' output. (c) ledger.jsonl with the req-1 line, req-1.json, plus that req-9.json. Expected: a red row for req-9. Actual: 'lane rebuilt: 1 receipt rows' and no 'req-9' in the HTML.

### 7. Low: amount() accepts negative values, so a negative settlement earns the green 'chain final' chip and negative charges inflate 'daily cap left'

`viewer/build-lane.py:23`

```
    if isinstance(v, bool) or not isinstance(v, (int, float)) or v != v or v in (float("inf"), float("-inf")): return None
```

amount() rejects bools, non-numbers, NaN and infinities but not negative numbers, while every other component treats a negative amount as unknown: imd-flop knownSettledSpend (receipts.ts:45-47) and usableCapCharge (ledger.ts) require value >= 0. In the viewer a receipt with settled -1 beside a ledger line with spend -1 passes the equality at line 130, is not 'disagree', and with chain_final true gets the green chip while printing 'observed spend -1'. A negative spent_before or cap_charge is subtracted at line 94, so 'daily cap left' can exceed the daily cap itself. Hand-edited or corrupted files therefore show a green settled row with a nonsensical amount instead of the blank 'unknown' slot the legend promises. Merged from audit_permissions, audit_economics and audit_math (all line 23). Fix: return None for v < 0 in amount(), matching knownSettledSpend.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. Case 1: ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":-0.05,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"settled","spend":-1,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"settled","settled":-1,"stage":"gateway observed","chain_final":true,"flag":null,"http":200,"error":null}. Expected: blank observed spend, amber disagree, no green. Actual (reproduced): chips sent, gateway observed, `<span class="chip c-green">chain final</span>`, `observed spend -1`, 'daily cap left 0.55', row not bad. Case 2: ledger line with spent_before -5 and cap_charge -5 (daily_cap 0.5) and the plain pending receipt. Expected: daily cap left blank. Actual: `daily cap left 10.5`.

### 8. Low: 'daily cap left' is computed from the holder daily cap for requester-paid rows (wrong budget), and a negative result is never flagged

`viewer/build-lane.py:94`

```
    row["daily_left"] = r6(daily - spent_before - cap_charge) if None not in (daily, spent_before, cap_charge) else None
```

imd-flop writes spent_before with two meanings (ledger.ts:32: holder = today's spend, requester = this job's spend) and always writes daily_cap, but for payer 'requester' run.ts (lines 216-220) checks job_budget and never the daily cap. build-lane.py ignores payer and job_budget and labels daily_cap - spent_before - cap_charge as 'daily cap left' on every row, so a requester row shows the holder's daily cap minus the job's spend, a number that exists in neither accounting, and the real constraint (job_budget - spent_before - cap_charge) is never shown. Separately, when the same formula goes negative on a holder row (spent_before already above daily_cap, or a charge above the padded quote) the value renders as a plain mono number on a not-bad row with no over-cap flag. Merged from audit_economics and audit_math (line 94, requester) and audit_flow (line 94, negative). Fix: when e.get('payer') == 'requester' compute and label the figure from amount(e.get('job_budget')) as 'job budget left' and leave 'daily cap left' blank; when the computed value is below 0 add a spend flag 'over daily cap' and set bad.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. Case 1: ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"requester","job_budget":2.0,"quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":1.5,"state":"sent","spend":null,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"estimated","settled":null,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null}. Expected: 'job budget left 0.302' (2.0-1.5-0.198) or a blank daily figure. Actual (reproduced): `<span class="k">daily cap left</span> <span class="mono">-1.198</span>` (0.5-1.5-0.198), no flag, row not bad. Case 2: holder ledger line with spent_before 2, state settled, spend 0.198 and a matching settled receipt (settled 0.198). Actual: `daily cap left -1.698`, row not bad, no flag.

### 9. Low: Lane heading 'mock provider · nothing spent' and outcome note 'mock job, no imd lookup' are hard-coded and shown for non-mock provider rows with real settled spend

`viewer/build-lane.py:180`

```
    out.append(f'<h3 class="lanesub">From <span class="mono">imd-flop</span> receipts <span class="ex">mock provider · nothing spent</span></h3>\n<div class="lane">\n{HDR}')
```

The sub-heading at line 180 and the outcome note at line 90 are literals; build_row never reads the ledger's `provider` or `mock` fields for them (provider is only echoed in the row's small text). A ledger produced with the real 'flop' provider (mock false) and a settled spend therefore renders under a heading asserting nothing was spent, and its outcome column says 'mock job'. The page then contradicts its own row ('observed spend 0.198' under 'nothing spent'). Merged from audit_permissions (line 180) and audit_math (line 90). Fix: derive the heading badge from the rows (omit 'nothing spent' unless every row has mock true / provider 'mock') and set the outcome note from e.get('mock').

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"flop","mock":false,"network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"settled","spend":0.198,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"settled","settled":0.198,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null},"mock":false. Expected: heading without 'nothing spent' and an outcome note that does not say 'mock job'. Actual (reproduced): `<span class="ex">mock provider · nothing spent</span>` above a row with `flop · devnet`, `<span class="k">observed spend</span> <span class="mono">0.198</span>` and `<div class="k">mock job, no imd lookup</div>`.

### 10. Info: The 'bypassed (mock)' link state is dead code: imd-flop never writes link_bypassed to the ledger

`viewer/build-lane.py:91`

```
    if e.get("link_bypassed") is True: row["link"] = ["grey", "bypassed (mock)", None]
```

LedgerEntry (imd-flop/src/ledger.ts) has no link_bypassed field; grep finds the name only in run.ts:51 and 326 (the run() return value) and cli.ts:338 (console line). So e.get('link_bypassed') is always None for a real ledger and every row, including --no-link mock runs, shows the grey 'not checked' chip; the branch is reachable only by hand-editing a ledger line. Nothing goes green, so this is not unsafe, but the Link column cannot tell a bypassed check from one never recorded. Merged from audit_permissions and audit_math (line 91). Fix: either record the link outcome in the ledger line (producer side) or drop the branch and say in the legend that the lane carries no link evidence.

**Reproduction**

`grep -n link_bypassed imd-flop/src/*.ts` returns run.ts:51, run.ts:326 and cli.ts:338 only; `grep -c link_bypassed imd-flop/src/ledger.ts` prints 0. The committed viewer/mock-receipts/ledger.jsonl (written by a --no-link mock demo) has no link_bypassed key and the committed HTML lines 95, 102, 109 all read `<span class="chip c-grey">not checked</span>`. Adding "link_bypassed":true to a ledger line by hand is the only way to reach the branch (reproduced: then the chip reads 'bypassed (mock)').

### 11. Info: A timestamp without a zone is rendered in the build machine's local zone, so the same ledger shows different times on different machines

`viewer/build-lane.py:33`

```
def when(ts): return datetime.fromisoformat(ts.replace("Z", "+00:00")).astimezone(ET).strftime("%b %-d, %-I:%M %p ET")
```

when() only maps a trailing Z to +00:00. A ts with no offset parses as a naive datetime and astimezone(ET) interprets it as system local time. imd-flop always writes toISOString() with Z, so this only affects hand-edited or foreign ledgers, but the result is a plausible wrong time with no indication. Merged from audit_permissions and audit_math (line 33). Fix: if the parsed datetime has tzinfo None, either treat it as UTC explicitly or raise so the row becomes unreadable.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00","payer":"holder","quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"sent","spend":null,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"estimated","settled":null,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null}. Expected: 'Nov 9, 7:00 PM ET' (as the Z form renders) or an unreadable row. Actual (reproduced): on this machine (UTC) 'Nov 9, 7:00 PM ET'; with `TZ=Asia/Tokyo python3 build-lane.py D` the same line renders 'Nov 9, 10:00 AM ET'.

### 12. Info: A missing or null payer is rendered as 'payer: holder'

`viewer/build-lane.py:88`

```
    row = dict(label=esc(e.get("job")), sub=sub, payer=esc(e.get("payer") or "holder"), flags=[], spend_flags=[], flop=[],
```

Line 88 substitutes 'holder' for any falsy payer (missing key, null, empty string). For a malformed line the viewer asserts who paid, contrary to its own rule of never inventing a value for unknown data. From audit_math. Fix: esc(e.get('payer')) if present(e.get('payer')) else '<span class="unk">unknown</span>'.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = {"job":"j","request_id":"req-1","seat":"1234","did":"did:key:z","provider":"mock","network":"devnet","ts":"2026-11-10T00:00:00.000Z","payer":null,"quote_padded":0.198,"cap_charge":0.198,"per_call_cap":0.25,"daily_cap":0.5,"spent_before":0,"state":"sent","spend":null,"reason":null} ; req-1.json = {"request_id":"req-1","job":"j","seat":"1234","did":"did:key:z","state":"estimated","settled":null,"stage":"gateway observed","chain_final":false,"flag":null,"http":200,"error":null}. Expected: payer unknown. Actual (reproduced): `<span class="tag">payer: holder</span>`.

### 13. Info: A missing or malformed ts turns the whole row into an 'unreadable' row, hiding its spend, caps, state and refusal reason

`viewer/build-lane.py:86`

```
           f"{esc(e.get('provider'))} · {esc(e.get('network'))} · {esc(when(e['ts']))}"]
```

ts is the only field read with e['ts'] rather than e.get(), and when() raises on anything fromisoformat cannot parse. The KeyError/ValueError is caught by the generic handler in from_files() (line 78) and the whole entry is replaced by unreadable(), which blanks est., per-call cap, daily cap left, request_id, state and the receipt comparison, and names only the exception type. A cosmetic field thus suppresses all the economic data of the row, including a settled spend or a refused_local reason. From audit_economics. Fix: compute the timestamp in its own try/except and render 'time unknown' in the sub line, leaving the rest of the row intact.

**Reproduction**

Run on a copy of the viewer folder (build-lane.py rewrites settlement-viewer-2026-11-09.html beside itself): cp -r viewer $TMPDIR/vc; then write the inputs below into a fresh directory D and run `python3 $TMPDIR/vc/viewer/build-lane.py D`. ledger.jsonl = the committed demo-job-3 refused_local line (viewer/mock-receipts/ledger.jsonl line 5) with the ts key removed. Expected: the refused row with est. 0.204, daily cap left 0.152 and the cap-hit reason, time shown as unknown. Actual (reproduced): `<div class="row bad">` labelled 'job j' with sub text 'ledger entry for none: KeyError', chip red 'unreadable', all three spend slots blank, no reason shown.

### 14. Info: Re-audit status of job 114b644c at 716819c: M1-M5, L6-L8, I10/I11/I13 fixed; L9 fixed only for the cases its test covers; escaping holds

`viewer/test_audit_v7.py:2`

```
"""Fail-first regressions for IMD re-audit 114b644c (viewer at 288a03e).
```

Each prior finding was re-checked against build-lane.py at 716819c and its fail-first test: M1 latest line per request_id with earlier attempts kept (read_ledger lines 54-58); M2 no green link chip anywhere (line 90, lane-examples.json); M3 html.escape on every file value including title attributes, flags and sub lines (esc, lines 84-86, 98, 101, 119); M4 chain_final never green without a settled receipt and a settled ledger line with equal numeric spend (lines 128-134, 148); M5 exact present-string identity on request_id, job, seat, did (lines 28-32); L6 chain_final must be boolean True (line 127); L7 unknown spent_before leaves daily cap left blank (line 94); L8 timeout/error ledger state stays red beside a receipt (lines 97, 123, 134-139); I10 head+tail short ids (line 27); I11 mismatch names fields and values (lines 118-119); I13 example mismatch row uses the shared IDENTITY string. L9 (one malformed item must not abort the rebuild) covers non-JSON lines, list receipts and string daily_cap, but the decode, recursion and OS-error paths still abort (separate low finding at line 47). Escaping check: a ledger line with job '<b>x</b>', seat '<q>', provider '<p>', payer '<s>p</s>', reason '<i>r</i>' and a receipt with seat '<q>', stage '<img>', flag '<x>', settled '<style>' renders every value as &lt;…&gt; entities, and the string-valued settled/stage/flag never reach the HTML (stage and flag are compared by equality only, settled is dropped by amount()). The committed HTML is byte-identical to a fresh rebuild from mock-receipts and lane-examples.json. From audit_math.

**Reproduction**

From a copy of the repo tree (viewer plus imd-flop/src/match.ts, which test_lane_disagree reads) run `python3 -m unittest test_audit_v7 test_lane_disagree` in the viewer directory: Ran 22 tests, OK. Then restore settlement-viewer-2026-11-09.html from the commit, run `python3 build-lane.py` (default mock-receipts), and `cmp` against the committed file: no differences. Escaping: run build-lane.py on the markup inputs above; the HTML contains `&lt;b&gt;x&lt;/b&gt;`, `seat #&lt;q&gt;`, `payer: &lt;s&gt;p&lt;/s&gt;`, and no raw `<b>`, `<img`, `<style` from file values.

---

Judge's submission `8785235c554abb485086af8aa95359fc0b974ede19257c945341ff3085c566e6`, accepted on the IdentityMD network. Acceptance means the report met the job's checks;
it is not a guarantee that the code has no other defects.
