Skip to content

test(claude): pin listener policy propagation - #1548

Merged
Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/followup-claude-policy-doc-tests
Aug 12, 2026
Merged

Wibias merged 1 commit into
lidge-jun:devfrom
luvs01:agent/followup-claude-policy-doc-tests

Conversation

@luvs01

@luvs01 luvs01 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • correct the Japanese server reference so it states that candidate credentials are compared in constant time
  • pin both Anthropic handlers to the listener-effective request policy in the focused loopback policy contract

Why

The Japanese wording described a bounded time interval instead of the constant-time comparison guarantee. The existing listener-policy regression also covered final CORS handling but did not independently pin the policy argument passed into the two Anthropic handlers.

Impact

This is a documentation and regression-coverage follow-up only. Runtime behavior is unchanged.

Test plan

  • Bun 1.3.14: bun test --isolate tests/loopback-listener-admission.test.ts (17 pass)
  • Bun 1.4: bun test --isolate tests/loopback-listener-admission.test.ts (17 pass)
  • git diff --check

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • All CI tests are green on my local testing.
  • I pushed my PR to the latest dev commit.
  • I resolved all correct Codex and CodeRabbit findings.
  • My PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the chore Maintenance, CI, tests, refactors, or build changes (not a user-facing bug or feature). label Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 327c6be2-3712-4681-b89e-6579a1c07837

📥 Commits

Reviewing files that changed from the base of the PR and between c19f571 and 54776fc.

📒 Files selected for processing (2)
  • docs-site/src/content/docs/ja/reference/configuration/server.md
  • tests/loopback-listener-admission.test.ts

📝 Walkthrough

Walkthrough

The documentation now specifies constant-time authentication comparison. Tests now verify that both Anthropic route handlers receive the effective listener policy.

Changes

Listener policy behavior

Layer / File(s) Summary
Policy documentation and regression assertions
docs-site/src/content/docs/ja/reference/configuration/server.md, tests/loopback-listener-admission.test.ts
The documentation clarifies constant-time comparison at line 56. Tests add source-level assertions at lines 70–75 for policy propagation to the Anthropic count-tokens and messages handlers.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • lidge-jun/opencodex#1536: Adds the listener-specific policy propagation implemented by the tested Anthropic route handlers.

Suggested reviewers: lidge-jun

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: regression coverage for listener policy propagation to the Anthropic handlers.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

Review readiness checklist

  • ✅ All CI tests are green on my local testing.
  • ✅ I pushed my PR to the latest dev commit.
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

4/4 boxes ticked.

This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently. If no CodeRabbit review appears, comment @coderabbitai review to request one.
Maintainers: @lidge-jun @Ingwannu @Wibias

@github-actions
github-actions Bot marked this pull request as ready for review August 12, 2026 17:27
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. PR #1548 is marked ready for review at head SHA 54776fcfa21a91791fa500950dee57ce13a7cea4.

I am replying to the latest comment only. The complete earlier comment chain was not available.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

@luvs01
luvs01 force-pushed the agent/followup-claude-policy-doc-tests branch from 54776fc to ad79520 Compare August 12, 2026 17:42
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate is complete for head SHA 54776fcfa21a91791fa500950dee57ce13a7cea4. I will review PR #1548.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
github-actions Bot marked this pull request as draft August 12, 2026 17:42

@Wibias Wibias 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.

Reviewed. The Japanese wording now correctly states constant-time comparison, and the added assertions pin the listener-effective policy argument passed to both Anthropic handlers within the existing listener-policy source contract. No code findings.

@github-actions
github-actions Bot marked this pull request as ready for review August 12, 2026 17:52
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate is complete for head SHA ad795205f6d84054d1e761fa4c8af43274e066be. I will review PR #1548.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== HEAD and changed files =='
git rev-parse HEAD
git diff --name-status HEAD^ HEAD

echo '== Changed diff =='
git diff --check HEAD^ HEAD
git diff --unified=80 HEAD^ HEAD -- \
  docs-site/src/content/docs/ja/reference/configuration/server.md \
  tests/loopback-listener-admission.test.ts

echo '== Test file outline =='
ast-grep outline tests/loopback-listener-admission.test.ts --items all

echo '== Relevant policy and Anthropic handler references =='
rg -n -C 5 --glob '!node_modules/**' \
  'Anthropic|listener[-A-Za-z_ ]*policy|effective[-A-Za-z_ ]*policy|constant[-A-Za-z_ ]*time|timingSafeEqual' \
  . --glob '*.ts' --glob '*.tsx' --glob '*.js' --glob '*.mjs' --glob '*.md'

echo '== Japanese documentation context =='
nl -ba docs-site/src/content/docs/ja/reference/configuration/server.md | sed -n '1,260p'

Length of output: 191694


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Checked-out commit =='
git rev-parse HEAD

echo '== Parent and changed files =='
git rev-parse HEAD^
git diff --name-status HEAD^ HEAD

echo '== Whitespace validation =='
git diff --check HEAD^ HEAD

echo '== Exact PR diff =='
git diff --unified=100 HEAD^ HEAD -- \
  docs-site/src/content/docs/ja/reference/configuration/server.md \
  tests/loopback-listener-admission.test.ts

echo '== Changed test file with line numbers =='
sed -n '=' tests/loopback-listener-admission.test.ts | sed 'N;s/\n/\t/'

echo '== Credential comparison implementation =='
rg -n -C 12 --glob 'auth-cors.ts' \
  'timingSafeEqual|secretEquals|isDataPlaneAdmissionSecret|apiKeys' src

echo '== Anthropic handler definitions and listener policy call sites =='
rg -n -C 16 --glob '*.ts' \
  'handleAnthropic|Anthropic.*Handler|anthropic.*handler|listenerEffective|effectiveListener|listener.*policy' \
  src/server tests/loopback-listener-admission.test.ts

echo '== Japanese documentation with line numbers =='
sed -n '=' docs-site/src/content/docs/ja/reference/configuration/server.md | sed 'N;s/\n/\t/'

Length of output: 39626


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/server/index.ts"

echo '== Route locations =='
grep -nF \
  -e 'url.pathname === "/v1/messages/count_tokens"' \
  -e 'url.pathname === "/v1/messages"' \
  -e 'url.pathname === "/v1/chat/completions"' \
  -e 'function handleClaudeCountTokens' \
  -e 'function handleClaudeMessages' \
  "$file"

echo '== Count-tokens route branch =='
line=$(grep -nF 'url.pathname === "/v1/messages/count_tokens"' "$file" | head -n1 | cut -d: -f1)
sed -n "$((line-20)),$((line+65))p" "$file"

echo '== Messages route branch =='
line=$(grep -nF 'url.pathname === "/v1/messages"' "$file" | head -n1 | cut -d: -f1)
sed -n "$((line-20)),$((line+85))p" "$file"

echo '== Count-tokens handler =='
line=$(grep -nF 'function handleClaudeCountTokens' "$file" | head -n1 | cut -d: -f1)
sed -n "$((line-10)),$((line+180))p" "$file"

echo '== Messages handler =='
line=$(grep -nF 'function handleClaudeMessages' "$file" | head -n1 | cut -d: -f1)
sed -n "$((line-10)),$((line+260))p" "$file"

echo '== CORS-related calls in the handler ranges =='
grep -n -E 'handleClaude(CountTokens|Messages)|withCors|corsHeaders|RequestPolicyView' "$file" | head -n 160

Length of output: 10798


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="src/server/index.ts"

echo '== All handler references =='
grep -n -E 'handleClaudeCountTokens|handleClaudeMessages' "$file"

echo '== Declaration contexts =='
for symbol in handleClaudeCountTokens handleClaudeMessages; do
  echo "-- ${symbol} --"
  grep -n -E "(const|let|var|async)[[:space:]]+${symbol}[[:space:]]*=|${symbol}[[:space:]]*\\(" "$file" \
    | while IFS=: read -r line rest; do
        start=$((line - 8))
        if [ "$start" -lt 1 ]; then start=1; fi
        end=$((line + 120))
        sed -n "${start},${end}p" "$file"
        echo '----'
      done
done

echo '== Handler policy parameter and CORS uses =='
grep -n -E 'RequestPolicyView|withCors\(' "$file" | sed -n '1,220p'

Length of output: 25136


@github-actions Review complete for #1548.

I found no actionable findings.

Verified:

  • docs-site/src/content/docs/ja/reference/configuration/server.md now describes the timingSafeEqual credential comparison accurately.
  • tests/loopback-listener-admission.test.ts pins policy propagation to both Anthropic handlers.
  • src/server/index.ts passes policy to handleClaudeCountTokens and handleClaudeMessages.
  • Both route branches apply withCors(..., req, policy).
  • git diff --check reported no whitespace errors.

🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@github-actions[bot] The readiness gate is complete for head SHA ad795205f6d84054d1e761fa4c8af43274e066be. I will review PR #1548.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. PR #1548 is ready for review at head SHA ad795205f6d84054d1e761fa4c8af43274e066be.

The current head SHA was already reviewed. No actionable findings were identified.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@github-actions[bot] Acknowledged. PR #1548 is ready for review at head SHA ad795205f6d84054d1e761fa4c8af43274e066be.

CodeRabbit already reviewed this head SHA. The review found no actionable findings.


🧠 Learnings used
Learnt from: Wibias
Repo: lidge-jun/opencodex PR: 986
File: .github/workflows/enforce-pr-target.yml:631-636
Timestamp: 2026-08-04T06:41:30.089Z
Learning: For the PR readiness gate in `.github/workflows/enforce-pr-target.yml`, the required scope is to bind contributor checklist completion and maintainer notification to the exact PR head SHA, then reset them after a new head commit. Maintainer approval staleness is separate from this gate and should be enforced by GitHub branch protection, such as `dismiss-stale-reviews` or `require_last_push_approval`, when configured for `dev`.

You are interacting with an AI system.

@Wibias
Wibias merged commit f8d0c2c into lidge-jun:dev Aug 12, 2026
27 of 28 checks passed

Wibias commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Thanks @luvs01, merged. 🙌

This is a useful little guardrail: the new assertions make sure the listener-effective policy is actually propagated into both Anthropic handlers, not just applied later at the CORS layer. That gives us a focused regression test for the exact boundary that could otherwise drift during future server refactors. The Japanese wording fix is also worthwhile because "constant time" is a security property, not merely "within a fixed time".

Small diff, but it pins an important auth/policy invariant in a place where regressions would be easy to miss.

agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
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). review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants