BC5 readiness: cross-language wire-replay decoders
Summary
Companion to #294 (TS canonical wire-capture canary). Adds wire-replay mode to the Ruby, Python, Go, and Kotlin runners so they consume the canonical wire snapshots TS captures against a live backend, decode each page through their SDK, and walk the raw JSON for required-field + extras detection. Swift remains excluded from the live canary surface.
The architecture pairs with §5e/5f of the BC5-readiness plan: TS is the only live HTTP runner; everyone else replays from disk. Decode-result snapshots land at <dir>/<backend>/decode/<lang>/ with schema_version: 1.
Per the cross-SDK omnibus pattern, this is one PR with one commit per SDK plus a TS amendment commit (operation field on snapshots) and one infrastructure commit (Make targets + CONTRIBUTING + gitignore).
What ships
- TS amendment — wire snapshots now carry
operationat the top level so replay runners dispatch without re-parsing the live fixture. Backwards compatible at the type level; runtime gates fail loud if a pre-PR3 snapshot shows up. - Ruby replay runner — decoder boundary is the SDK's actual production path (
JSON.parse + normalize_person_ids). - Python replay runner — decoder boundary is
json.loads + _normalize_person_ids. Same code path every SDK request runs in production. - Go replay runner — decoder boundary is the typed
generated.<Op>ResponseContenttypes fromgo/pkg/generated. Mode-gate prepended to existingmain(); mock-mode body untouched. - Kotlin replay runner — decoder boundary is
@Serializabledata classes via the sameJson { ignoreUnknownKeys = true }the mock runner uses. Separate:conformance:runReplayGradle task; existing:conformance:rununtouched. Four ops decode throughJsonElementbecause typedMyAssignment/Notificationmodels don't yet exist (TODO noted). - Schema walkers — hand-rolled per-language ports of
conformance/runner/typescript/schema-validator.ts's required + extras algorithm. No new library dependencies in any language; usingjson_schemer/jsonschema/santhosh-tekuri/networkntwould create divergent extras semantics across runners. - Three startup gates per runner: decoder coverage, snapshot completeness, snapshot recognition. Missing top-level
operationis a hard failure pointing at re-running the TS canary. - Make targets:
conformance-{ruby,python,go,kotlin}-replay, each with required-env preflight (WIRE_REPLAY_DIR,BASECAMP_BACKEND). None run as part ofmake check. - CONTRIBUTING.md gains a "Wire replay (cross-language)" subsection covering the two-stage flow and the five files to update when adding a new operation.
Verification
Cross-language walker parity confirmed end-to-end against synthetic snapshots covering all 10 ops in live-my-surface.json:
$ for lang in ruby python go kotlin; do
jq -s '[.[].pages[].missing_required] | flatten | sort | unique' \
tmp/canary/bc4/decode/$lang/*.json > /tmp/missing-$lang.json
done
$ diff /tmp/missing-ruby.json /tmp/missing-python.json # empty
$ diff /tmp/missing-ruby.json /tmp/missing-go.json # empty
$ diff /tmp/missing-ruby.json /tmp/missing-kotlin.json # empty
The synthetic GetProject {} body produces byte-identical missing_required ([app_url, created_at, id, name, status, updated_at, url]) across all four languages.
schema_version lock:
$ jq -s '[.[].schema_version] | unique' tmp/canary/bc4/decode/*/*.json
[1]
All four mock baselines preserved exactly: Ruby 59, Python 64, Go 68, Kotlin 58 (counts match those documented in #294's plan).
Coverage gate failure modes verified by injection (missing decoder, missing snapshot, unknown operation, pre-PR3 snapshot lacking operation field) — each emits an actionable message pointing at the right side to fix (TS dispatch, fixture, or this runner).
Test plan
-
make conformance-rubyshows 59/0/9 -
make conformance-pythonshows 64/0/4 -
make conformance-goshows 68/0/0 -
make conformance-kotlinshows 58/0/10 -
make conformance-typescriptpasses (TS amendment is back-compat) -
WIRE_REPLAY_DIR=<dir> BASECAMP_BACKEND=bc4 make conformance-<lang>-replayfor each language fails preflight when env unset, succeeds against TS-captured snapshots - All four runners reject pre-PR3 snapshots (no
operationfield) with a clear "Re-run the TS live canary" message
Sequencing
PR 4 (pairwise BC4↔BC5 comparison + check-bc5-compat orchestrator + scheduled CI) consumes both the TS canary's <backend>/wire/ snapshots and these decode-result snapshots; it lands separately.
Summary by cubic
Adds cross-language wire-replay for Ruby, Python, Go, and Kotlin using TS-captured snapshots with a top‑level operation. Runners decode via production SDK paths, walk JSON to flag missing required fields and extras, and write per‑test results to support BC5 readiness.
-
New Features
- TS live runner now persists
operationon wire snapshots; it remains authoritative in the payload. - Ruby/Python/Go/Kotlin replay runners read
<dir>/<backend>/wire/*.json, decode via production SDK paths, and write to<dir>/<backend>/decode/<lang>/withschema_version: 1. Walkers emitmissing_required(slash paths) andextras_seen(dot paths). Kotlin decodes fourMy*/notifications ops asJsonElement. - Make targets:
conformance-{ruby,python,go,kotlin}-replay(Kotlin also via:conformance:runReplay). CONTRIBUTING documents the two‑stage flow.
- TS live runner now persists
-
Bug Fixes
- Faithful empty‑body handling: Ruby now errors on empty
bodyText; Python/Go distinguish missing vs emptybodyTextso empty bodies trigger decode errors. - Gates and diagnostics: all runners surface snapshot read/parse errors; Python flags malformed UTF‑8; Kotlin treats blank env as missing, defensively reads non‑primitive
operation/bodyText, narrows decoder catch toException, and sorts snapshot files. All runners reject snapshots with missing/emptypagesorpages_countmismatches. - Response schema lookup precedence aligned across TS and all walkers: prefer 200–204, then any other 2xx, then
default.
- Faithful empty‑body handling: Ruby now errors on empty