Skip to content

chore(http-recorder): remove content-matching dispatch mode#26792

Merged
kitlangton merged 1 commit into
devfrom
chore/http-recorder-sequential-only
May 11, 2026
Merged

chore(http-recorder): remove content-matching dispatch mode#26792
kitlangton merged 1 commit into
devfrom
chore/http-recorder-sequential-only

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Why

The dispatch: "match" default in @opencode-ai/http-recorder is a silent record/replay divergence footgun. For tests that send the same request shape twice (cache-hit tests, retry tests, polling loops), the real network during RECORD=true produces two distinct responses — but on replay the content-matcher returns the first recorded response for both calls. Assertions that verify state change pass during recording and quietly fail later.

Audit of the repo turned up zero explicit "match" callers — every recorded test either set dispatch: "sequential" explicitly or accidentally relied on the buggy default. The "reorder a test without re-recording" convenience the mode was designed for is rare; the silent divergence cost is real.

What changed

  • Removed the dispatch?: "match" | "sequential" option from RecordReplayOptions.
  • Replay now always walks the cassette in record order via the existing sequential cursor.
  • Removed selectMatch and mismatchDetail from src/matching.ts. RequestMatcher, defaultMatcher, canonicalSnapshot, requestDiff, and selectSequential stay — sequential replay still validates each interaction's request against the incoming request.
  • Dropped now-pointless { dispatch: "sequential" } overrides in the package's own tests, removed the test that asserted the deleted content-matching behavior, and removed the test that documented the buggy "same request twice returns first match" outcome.
  • Updated packages/http-recorder/README.md and packages/llm/AGENTS.md to describe the single behavior.

No production code outside packages/http-recorder/src and the docs in packages/llm/AGENTS.md was touched. No downstream provider test passed dispatch on this branch, so no test files in packages/llm/test/provider needed changes.

Migration

If you reorder requests in a test, re-record the cassette (delete the JSON fixture and run with RECORD=true). The cassette JSON format is unchanged.

Test plan

  • bun run --cwd packages/http-recorder test — 15 pass, 0 fail
  • bun run --cwd packages/http-recorder typecheck — clean
  • bun run --cwd packages/llm test — 171 pass, 31 skip, 0 fail
  • bun run --cwd packages/llm typecheck — clean

Sequential cursor replay is now the only behavior. The previous default
("match") returned the first recorded response for any subsequent
byte-identical request, silently passing cache-hit, retry, and polling
tests during RECORD=true (where the real network produced distinct
responses) and breaking them on replay.

Audit found zero explicit "match" callers across the repo. Re-recording
after a test reorders requests is the right discipline; the silent
record/replay divergence is not worth the rare reorder-without-rerecord
convenience.
@kitlangton kitlangton marked this pull request as ready for review May 11, 2026 15:09
@kitlangton kitlangton merged commit f240bba into dev May 11, 2026
12 checks passed
@kitlangton kitlangton deleted the chore/http-recorder-sequential-only branch May 11, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant