{"record":{"id":"9fedc9d70aa75291","repo":"Hmbown/CodeWhale","slug":"codewhale-stream-json-schema-did-not-match-v0-9-1","errorCode":null,"errorMessage":"Codewhale stream-json schema did not match v0.9.1","messagePattern":"Codewhale stream-json schema did not match v0\\.9\\.1","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"integrations/verifiers-codewhale/codewhale_harness/harness.py","lineNumber":365,"sourceCode":"    terminal: dict[str, Any] | None = None\n    ordered_types: list[str] = []\n    for line_number, line in enumerate(stdout.splitlines(), start=1):\n        if not line.strip():\n            continue\n        try:\n            event = json.loads(line)\n        except json.JSONDecodeError as error:\n            raise RuntimeError(\n                f\"Codewhale stream-json line {line_number} was not valid JSON\"\n            ) from error\n        if not isinstance(event, dict):\n            raise RuntimeError(\n                f\"Codewhale stream-json line {line_number} was not an object\"\n            )\n        if event.get(\"schema\") != STREAM_SCHEMA or event.get(\n            \"schema_version\"\n        ) != STREAM_SCHEMA_VERSION:\n            raise RuntimeError(\"Codewhale stream-json schema did not match v0.9.1\")\n        event_type = event.get(\"type\")\n        if event_type not in _EVENT_TYPES:\n            raise RuntimeError(\"Codewhale stream-json contained an unknown event type\")\n        counts[event_type] += 1\n        ordered_types.append(event_type)\n        if event_type == \"metadata\":\n            if terminal is not None:\n                raise RuntimeError(\"Codewhale emitted more than one terminal metadata receipt\")\n            meta = event.get(\"meta\")\n            if not isinstance(meta, dict) or meta.get(\"receipt_kind\") != \"terminal\":\n                raise RuntimeError(\"Codewhale metadata event was not a terminal receipt\")\n            terminal = _bounded_terminal(meta)\n\n    if terminal is None:\n        raise RuntimeError(\"Codewhale stream-json omitted terminal metadata\")\n    if counts[\"done\"] != 1 or not ordered_types or ordered_types[-1] != \"done\":\n        raise RuntimeError(\"Codewhale stream-json did not end with exactly one done event\")\n    if ordered_types[-2:-1] != [\"metadata\"]:","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/integrations/verifiers-codewhale/codewhale_harness/harness.py#L347-L383","documentation":"Every stream event must carry schema == \"codewhale.exec-stream\" and schema_version == 1 (STREAM_SCHEMA_VERSION). This error means a parsed event object is missing those keys or carries different values, so the harness rejects the whole stream as not conforming to the v0.9.1 contract it is built against.","triggerScenarios":"Running a Codewhale binary whose stream schema name or version differs from the harness constants: a newer release that bumped schema_version, a facade that omits the schema envelope, or a hand-rolled emitter that only sends type/payload without the schema fields.","commonSituations":"Version skew between the harness (pinned to release 0.9.1 via CodewhaleHarnessConfig.version) and a binary_path override pointing at a locally built or newer/older facade; third-party tools that mimic the event format but not the envelope; forgetting the envelope in a custom stub used for local candidate testing.","solutions":["Check the first parsed event in stdout: it must contain \"schema\": \"codewhale.exec-stream\" and \"schema_version\": 1.","Use the harness-pinned Codewhale release (version='0.9.1') instead of an untested binary_path build.","If you control the facade, stamp every emitted line with the exact schema and schema_version constants the harness expects.","If you intentionally upgraded the stream schema, update STREAM_SCHEMA/STREAM_SCHEMA_VERSION in harness.py in the same change and re-run the harness tests."],"exampleFix":"# before: event lacks the envelope\n{\"type\": \"content\", \"text\": \"hi\"}\n\n# after: event carries the v0.9.1 envelope\n{\"schema\": \"codewhale.exec-stream\", \"schema_version\": 1, \"type\": \"content\", \"text\": \"hi\"}","handlingStrategy":"validation","validationCode":"def events_match_schema(stdout: str) -> bool:\n    for line in stdout.splitlines():\n        if not line.strip():\n            continue\n        event = json.loads(line)\n        if not isinstance(event, dict):\n            return False\n        if event.get(\"schema\") != \"codewhale.exec-stream\" or event.get(\"schema_version\") != 1:\n            return False\n    return True","typeGuard":"def is_enveloped_event(event: object) -> bool:\n    return (\n        isinstance(event, dict)\n        and event.get(\"schema\") == \"codewhale.exec-stream\"\n        and event.get(\"schema_version\") == 1\n    )","tryCatchPattern":null,"preventionTips":["Keep the harness's pinned Codewhale version and the facade's schema constants in lockstep; change them in one commit.","Stamp every emitted line with the schema envelope from shared constants, not by copy-pasting strings.","Run the harness's stream-contract tests whenever the facade's output format is touched."],"tags":["schema","version-skew","validation","stream-json","codewhale-harness"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}