Postmortem: A Truncated Model Stream Passed the Patch Gate as Valid JSON A patch gate that streamed model reviewer verdicts and repaired truncated JSON merged one AI-authored patch into a protected branch without a full review pass, according to a MonkeyCode postmortem covering 19 days of faulty parsing. The four-line parser appended a closing brace to a stream cut mid-object, producing a parseable response with verdict "pass"; a replay on a healthy connection later returned "fail" with two blocking findings. The replacement parser fails closed unless the response carries a declared byte length, a SHA-256 digest, a terminal sentinel and the fields verdict, diff_sha and policy_version. Postmortem: A Truncated Model Stream Passed the Patch Gate as Valid JSON The gate said pass. The model never finished its sentence. This postmortem covers a patch gate that streamed a reviewer verdict from a model, then parsed it with a repair step. A cut stream produced a valid, complete, wrong decision. The failure is reproducible in under two minutes with the code bel ow. Scope note: the pipeline here is a reconstructed lab reproduction, not a vendor incident report. Every claim below is checked by the included test. Impact: one AI-authored patch reached the protected branch without a full review pass. Duration: the gate ran with the faulty parser for 19 days. Detection: a re-run on a different day returned fail for the same diff. The verdict was not stable. Blast radius: the bad patch itself was small. The dangerous part was the certificate attached to it. T+0 — A patch job submits a diff to the reviewer call. The gate streams the response. T+0.8s — An intermediary closes the connection early. The stream ends mid-object. T+0.9s — json.loads raises. The repair branch appends } and retries. T+0.95s — The repaired string parses. verdict is "pass". T+1.0s — The gate logs verdict=pass source=repaired and merges. T+19d — A replay on a healthy connection returns "fail" with two blocking findings. T+19d — Parser replaced. All prior source=repaired records are re-audited by hand. The original parser was four lines long. It looked defensive. import json def old verdict raw: str - str: try: return json.loads raw "verdict" except json.JSONDecodeError: repaired = raw.rstrip .rstrip "," + "}" return json.loads repaired "verdict" The repair assumed truncation happens at the end of a well-formed object. That assumption is false for streams. A cut can land after any field, and field order is not guaranteed. A cut after the first field yields this input: {"verdict": "pass", "diff sha": "9f2c The repair appends } and produces a parseable object with the verdict intact. Nothing else is required to pass the gate. The decision policy read one key, so one key was enough. Permissive repair. The catch branch converted an error into a decision instead of a retry. Field order dependence. verdict was emitted first, so the cheapest field to truncate was the one that mattered. No completeness check. The gate had no byte length, no digest, and no end marker to test against. Single-key policy. Any parsed object with a verdict key was trusted, regardless of diff sha or policy version. Free-tier routing. The reviewer call ran on free model access. The gate ran on the free server option, which restarts between jobs. Neither is inherently unsafe, but both add intermediaries and interrupts the gate did not model. Green dashboards. Every run exited 0. The repair path was counted as success, not as a degraded run. Disclosure: This article was prepared as part of MonkeyCode's product outreach. The gate now refuses anything it cannot prove is complete. The response must carry a declared byte length, a SHA-256 digest, and a terminal sentinel. The parser fails closed on all three checks. import hashlib import json import re ENVELOPE = re.compile rb"^MC1 ?P