Skip to content

feat(match): add schema-loose matcher tier#17

Merged
protosphinx merged 1 commit into
mainfrom
bot/schema-loose-matcher
Jun 2, 2026
Merged

feat(match): add schema-loose matcher tier#17
protosphinx merged 1 commit into
mainfrom
bot/schema-loose-matcher

Conversation

@protosphinx

Copy link
Copy Markdown
Member

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 the MatchStrategy union
  • src/match.ts: adds schemaLooseMatch() (matches on method + sorted top-level params key set, ignores values) and wires it into findMatch as the fourth built-in tier, between fuzzy and the null return
  • test/match.schema.test.ts: 17 new tests covering schemaLooseMatch directly and the full findMatch fallthrough chain through to the schema-loose tier

Tests

  • npm run lint (tsc --noEmit): passes
  • npm run build: passes
  • npm test (vitest run): 153 tests, all passing (136 pre-existing + 17 new)

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed)
  • no public-API surface change
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended

Generated by Claude Code

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.
@protosphinx protosphinx added the automated Opened by the daily bot label Jun 2, 2026 — with Claude
@protosphinx protosphinx merged commit 7fa9cc5 into main Jun 2, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/match.ts

function paramsKeySet(params: unknown): string {
if (params == null) return "null";
if (Array.isArray(params)) return "array";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant