Skip to content

test(routing): lock policy evidence parity across inbound protocols - #1280

Merged
Wibias merged 2 commits into
devfrom
test/routing-policy-surface-parity
Aug 8, 2026
Merged

test(routing): lock policy evidence parity across inbound protocols#1280
Wibias merged 2 commits into
devfrom
test/routing-policy-surface-parity

Conversation

@Wibias

@Wibias Wibias commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • lock routing-policy request evidence parity across Responses, Chat Completions, and Claude Messages
  • cover both tool+image requirements and plain-text/no-tool requests
  • no production behavior change: current dev already passes translated bodies through evidenceFromBody() on all three surfaces

Why

The earlier audit identified cross-surface policy evidence as a risk. Current dev already fixed the production call sites, so this PR adds regression coverage instead of duplicating routing logic.

Scope

  • new focused Bun test only
  • no router, adapter, or API behavior changes

Verification

CI should run the new tests/routing-policy-surface-parity.test.ts with the normal suite.

Base inspected: dev at 3ad5bb6bd3f76f6879d84b78ea39edd3e01ec296.

Summary by CodeRabbit

  • Tests
    • Added coverage to verify consistent routing behavior across Responses, Chat Completions, and Claude Messages.
    • Confirmed that tool use with image input provides equivalent routing details across interfaces.
    • Confirmed that plain-text requests without tools do not produce definitive routing evidence.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds routing-policy parity tests for Responses, Chat Completions, and Claude Messages. The tests compare rich routing evidence for tool-and-image requests and verify no hard evidence for plain-text requests.

Changes

Routing policy parity

Layer / File(s) Summary
Cross-surface routing evidence validation
tests/routing-policy-surface-parity.test.ts
Adds tests for tool-and-image requests across Responses, Chat Completions, and Claude Messages. Adds plain-text coverage that expects no hard routing evidence.

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

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the added routing-policy parity tests across inbound protocols.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/routing-policy-surface-parity

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.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Aug 8, 2026
@Wibias
Wibias marked this pull request as ready for review August 8, 2026 11:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/routing-policy-surface-parity.test.ts`:
- Around line 73-101: Update the routing policy parity tests to exercise each
surface through its actual routing entry point rather than calling
evidenceFromBody directly. For Responses, Chat Completions, and Claude Messages,
send representative requests through their dev handlers and assert the evidence
received by policy evaluation, while retaining translator unit coverage where
useful.
🪄 Autofix

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8c2e379f-6b88-429e-b608-bbaccf38f4f0

📥 Commits

Reviewing files that changed from the base of the PR and between 3ad5bb6 and b8bfa2c.

📒 Files selected for processing (1)
  • tests/routing-policy-surface-parity.test.ts

Comment on lines +73 to +101
expect(evidenceFromBody(responsesBody)).toEqual(EXPECTED_RICH_EVIDENCE);
expect(evidenceFromBody(chatBody)).toEqual(EXPECTED_RICH_EVIDENCE);
expect(evidenceFromBody(claudeBody)).toEqual(EXPECTED_RICH_EVIDENCE);
});

test("plain text without tools produces no hard routing evidence on every surface", () => {
const responsesBody = {
model: MODEL,
input: [{
type: "message",
role: "user",
content: [{ type: "input_text", text: "hello" }],
}],
};

const chatBody = chatCompletionsToResponsesBody({
model: MODEL,
messages: [{ role: "user", content: "hello" }],
});

const claudeBody = anthropicToResponsesTranslation({
model: MODEL,
max_tokens: 128,
messages: [{ role: "user", content: "hello" }],
}).body;

expect(evidenceFromBody(responsesBody)).toEqual({});
expect(evidenceFromBody(chatBody)).toEqual({});
expect(evidenceFromBody(claudeBody)).toEqual({});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Exercise each routing entry point.

These assertions call evidenceFromBody() directly after calling the translators. They cannot fail if a Responses, Chat Completions, or Claude Messages dev handler stops passing its normalized body to evidenceFromBody(), passes the raw body, or drops the resulting evidence before policy evaluation.

Drive one request for each surface through its routing entry point. Assert the evidence received by the routing policy. Keep these assertions as translator unit tests if they are useful.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/routing-policy-surface-parity.test.ts` around lines 73 - 101, Update
the routing policy parity tests to exercise each surface through its actual
routing entry point rather than calling evidenceFromBody directly. For
Responses, Chat Completions, and Claude Messages, send representative requests
through their dev handlers and assert the evidence received by policy
evaluation, while retaining translator unit coverage where useful.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Fixes Applied Successfully

Fixed 1 file(s) based on 1 unresolved review comment.

Files modified:

  • tests/routing-policy-surface-parity.test.ts

Commit: 130165818fbb3c8c94df9821dc16620ada5bb85d

The changes have been pushed to the test/routing-policy-surface-parity branch.

Time taken: 18m 40s

Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@Wibias
Wibias merged commit 3a8fdb1 into dev Aug 8, 2026
45 of 49 checks passed
@Wibias
Wibias deleted the test/routing-policy-surface-parity branch August 8, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant