feat(match): add schema-loose matcher tier#17
Conversation
Implements the schema-loose strategy documented in the README but missing from the code. The new tier matches when method and top-level params key set are identical regardless of values. It sits between fuzzy and the no-match return in findMatch, giving replay one extra chance to find a pair when all value-aware tiers fail. Adds MatchStrategy union member "schema-loose" and 17 new tests covering schemaLooseMatch directly and the full findMatch fallthrough chain.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb92b03294
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| function paramsKeySet(params: unknown): string { | ||
| if (params == null) return "null"; | ||
| if (Array.isArray(params)) return "array"; |
There was a problem hiding this comment.
Preserve array arity in schema-loose keys
For JSON-RPC methods that use positional params, this collapses every array to the same schema key, so after the stricter tiers fail an incoming call like method(["repo", {page: 2}]) can replay a recording for method(["repo"]). That is not the same (method, paramsKeys) shape for array params because the positional key set/arity changed; include the array indices or length in this key instead of returning a single sentinel for all arrays.
Useful? React with 👍 / 👎.
Why
The README documents four matching tiers for
findMatch: Exact, Normalized, Fuzzy, and Schema-loose. The first three are implemented; the fourth ("Schema-loose: match(method, paramsKeys)only") was listed in the roadmap docs but never wired up. This PR closes that gap so replay has one more fallback before returning a mismatch error.The schema-loose tier is useful when param values change completely across re-records but the call structure is stable: same method, same top-level key names. A common example is a search tool where the query string changes every run but the request always has
{ name, args }.What
src/types.ts: adds"schema-loose"to theMatchStrategyunionsrc/match.ts: addsschemaLooseMatch()(matches on method + sorted top-level params key set, ignores values) and wires it intofindMatchas the fourth built-in tier, between fuzzy and the null returntest/match.schema.test.ts: 17 new tests coveringschemaLooseMatchdirectly and the fullfindMatchfallthrough chain through to the schema-loose tierTests
npm run lint(tsc --noEmit): passesnpm run build: passesnpm test(vitest run): 153 tests, all passing (136 pre-existing + 17 new)Self-merge gate
Generated by Claude Code