Skip to content

fix(conformance): interop cross-check self-tests require the expected rejection class (LAB-8795) - #192

Merged
27b-merge-warden[bot] merged 1 commit into
mainfrom
lab-8795-expect-rejected-class
Oct 10, 2026
Merged

27b-merge-warden[bot] merged 1 commit into
mainfrom
lab-8795-expect-rejected-class

Conversation

@27Bslash6

Copy link
Copy Markdown
Contributor

What

expectRejected in tools/interop-crosscheck.mjs accepted any throw that was not a TypeError or ReferenceError. So a self-test could not tell the rejection it was testing from any other one: an encoder that threw new Error("x") where OutOfModelError belongs still printed OK.

  • expectRejected now takes the expected error class and requires err.constructor === errorClass. A different class counts as a failure and is reported as FAIL <test> (<case>): expected <class>, got <class>: <message>. TypeError and ReferenceError are still rethrown as harness bugs.
  • The match is exact, not instanceof: OutOfModelError extends Error, so instanceof Error would accept an OutOfModelError in the two self-tests that expect a plain Error.
  • All four callers pass their class: loneSurrogateSelftest and unsafeNumberSelftest pass Error; outOfModelSelftest and nonStringKeySelftest pass OutOfModelError.
  • The Symbol-key guard's two comment sentences no longer trail the key-sort comment, where "Its data" read as if it meant the byte comparison. They now open their own paragraph above the if, starting "A plain object's data is…". No other comment changes.

No change under spec/, test-vectors/ or tools/interop-reference.py, and no vector bytes change.

Verification

node tools/interop-crosscheck.mjs prints the same line as main: OK: 44 key, 6 value, 6 reader accept, 1 reader reject, 1 AAD, 1 encryption, 34 error vectors verified independently.

Each mutant below was run against this branch and against main's harness:

Mutant main this PR
Symbol-key guard throws new Error("x") exit 0, OK exit 1, 5 × FAIL nonStringKeySelftest (…): expected OutOfModelError, got Error: x
out-of-model fallthrough throws new Error("x") exit 1 on 2 reader vectors only exit 1, same 2 reader vectors plus 7 × FAIL outOfModelSelftest (…): expected OutOfModelError, got Error: x
lone surrogate throws OutOfModelError exit 0, OK exit 1, 6 × FAIL loneSurrogateSelftest (…): expected Error, got OutOfModelError: x
unsafe Number throws OutOfModelError exit 0, OK exit 1, 6 × FAIL unsafeNumberSelftest (…): expected Error, got OutOfModelError: x
Symbol-key guard removed exit 1, 5 × expected rejection, encoding succeeded unchanged
enumerable filter removed exit 1 on the non-enumerable control unchanged

python3 tools/conformance.py check OK; python3 tools/test_conformance.py: all 284 cases pass.

Closes LAB-8795

… rejection class

expectRejected accepted any throw that was not a TypeError or ReferenceError, so a self-test could not tell an OutOfModelError from a plain Error. It now takes the expected class and matches it exactly; instanceof cannot work, because OutOfModelError extends Error. Also moves the Symbol-key guard's comment out of the key-sort comment.
@kodus-27b

kodus-27b Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the `@kody start-review` command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Providing Context (Files & MCPs)

Add these hints in your PR description (or a comment) to unlock deeper checks:

  • Ticket / Acceptance Criteria: `Refs: ABC-123` (Linear/Jira/Asana/ClickUp/Trello) or a direct ticket link.
  • Bugfix Validation: a Sentry/Datadog/Bugsnag event link (or paste the stack trace/error message).
  • Endpoint Risk: mention the route (e.g., `POST /api/payments`) or controller/action name.
  • Attach a repo file as context: use an explicit marker like `@file:docs/guide.mdx#L10-L50` (replace with your real path).
  • API Contract Docs: include `@file:openapi.yaml` or `@file:swagger.json` when changing routes/schemas.
  • Definition of Done / Standards: include `@file:DOD.md` or `@file:CONTRIBUTING.md` if your repo has them.
  • Design System Source of Truth: include `@file:ui/index.ts` (replace with your DS entrypoint path).
  • Feature Flags: include the flag key/name and `@file:flags.ts` / `@file:config.json` (and optionally the PostHog flag name).
  • Edge/CDN Rules: link the Cloudflare rule/zone or describe the intended redirect/header behavior.
  • Attach an MCP tool output: use `@mcp<provider|tool>` (replace with an installed MCP provider + tool, e.g., `@mcp<sentry|events.search>`).
Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: cachekit-io/protocol/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9931ed6a-003f-466e-b79e-3298e0813b92

📥 Commits

Reviewing files that changed from the base of the PR and between 4369984 and 1294258.


📒 Files selected for processing (1)
  • tools/interop-crosscheck.mjs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



Summary by CodeRabbit

  • Tests
    • Interoperability checks now verify that invalid inputs produce the expected error types and report mismatches. Harness-level type and reference errors remain distinguishable from test failures. This makes test results clearer and easier to interpret. There are no changes to end-user functionality or public interfaces.

Walkthrough

The interop cross-check now validates rejected self-tests against an expected error class. It reports class mismatches and continues to treat TypeError and ReferenceError as harness errors.

Changes

Interop error checks

Layer / File(s) Summary
Match self-test errors by class
tools/interop-crosscheck.mjs
expectRejected now checks the exact error constructor and reports mismatches. The lone-surrogate and unsafe-number tests expect Error; the out-of-model and non-string-key tests expect OutOfModelError. Comments clarify UTF-8 byte ordering and map data.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 12942

The changed error checks match the rejection paths inspected, and no actionable merge-blocking issue remains.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: self-tests now require the expected rejection class. The issue identifier is relevant.
Description check Passed The description directly explains the implementation, expected error classes, comment adjustment, verification results, and scope of the change.
Docstring Coverage Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 1 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR


🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@27b-merge-warden
27b-merge-warden Bot merged commit de001f3 into main Oct 10, 2026
5 checks passed
@27b-merge-warden
27b-merge-warden Bot deleted the lab-8795-expect-rejected-class branch October 10, 2026 04:22
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