Skip to content

filter_relevant: clear TypeError mapping JS camelCase options to Python (parity with JS #7) - #15

Merged
mikkel merged 2 commits into
mainfrom
cursor/py-parity-js7
Oct 14, 2026
Merged

mikkel merged 2 commits into
mainfrom
cursor/py-parity-js7

Conversation

@mikkel

@mikkel mikkel commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Summary

Mirrors 255BITS/patchling #7 (ad02203) in reverse: filter_relevant raises a single TypeError before any model call when JS camelCase options are passed. The error names every bad key along with its Python translation.

Semantics verified in both codebases

  • retries → max_attempts: JS retries counts extra attempts (src/filter.js:1372 attempts = retries + 1). Python max_attempts counts total attempts (relevance.py:1237-1259). Message: retries=N (extra attempts) -> max_attempts=N+1 (total attempts).
  • retryBaseMs → retry_backoff: both are the base delay for exponential backoff (*2**attempt), with no jitter. JS uses ms and caps the wait at 30s (filter.js:1406). Python uses seconds and has no cap (relevance.py:1258). Message: retryBaseMs=M (milliseconds, base delay) -> retry_backoff=M/1000 (seconds, base delay). The defaults differ: 200 ms vs 0.5 s.
  • ignore → skip_patterns: both use the same 30 default globs, matched case-insensitively against the full path (** crosses /, * does not; neither regex nor substring). A JS array replaces the defaults, and false, null and [] classify every path. In Python, None applies the defaults, a sequence replaces them (it does not extend them), and []/() classify every path. Note that JS null corresponds to Python [], not None. The CLI --filter-skip-pattern flag appends instead, but this message covers only the library call.
  • onDecision, reasoningEffort: filter_relevant has no such parameters, so the message says not supported in Python filter_relevant and names no keyword argument. (After the call, FilterRelevantResult.decisions returns the decisions in input order, but it is not a keyword alternative. Reasoning effort is fixed at "low".)

Tests

  • tests/test_filter_options.py vendors the JS SNAKE_CASE_OPTIONS map. JS-only keys are listed explicitly as unsupported, and the remaining keys are asserted to be exact inverses. It also checks one error naming all bad keys, the error being raised before the model callable runs, and pins the skip_patterns behavior: None means defaults, []/() mean every path, a custom list replaces the defaults, and matching uses case-insensitive full-path globs.
  • Offline pytest -q tests in a venv with pip install -e .: 195 passed, 2 skipped (live LLM opt-in), 0 failed. LIVE_LLM was unset, and no model was called.
  • CI Core API Tests on 28d25a4: success.

No merge, no publish.

A camelCase kwarg from the JS filter raises TypeError before any model
call, naming every bad key and its Python spelling. retries is
max_attempts = retries + 1, retryBaseMs is retry_backoff in seconds,
and ignore is skip_patterns. Other unknown keywords still fail as before.
onDecision and reasoningEffort have no filter_relevant parameter, so the
TypeError now says they are not supported. retries (extra attempts) maps
to max_attempts (total attempts). retryBaseMs is a millisecond base delay
with no jitter, and retry_backoff is that base in seconds. ignore maps to
skip_patterns, which replaces the default globs; None keeps them and an
empty sequence classifies every path.
@mikkel
mikkel marked this pull request as ready for review October 14, 2026 17:24
@mikkel
mikkel merged commit 97896cd into main Oct 14, 2026
2 checks passed
@mikkel
mikkel deleted the cursor/py-parity-js7 branch October 14, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant