Skip to content

[WRONG BRANCH] fix(tools): index tool-choice candidates to avoid quadratic catalog scans - #321

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-tool-choice-vulnerability
Closed

[WRONG BRANCH] fix(tools): index tool-choice candidates to avoid quadratic catalog scans#321
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-tool-choice-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent O(n^2) work when resolving allowed_tools against a request-supplied tool catalog, which could let an attacker-supplied large catalog block the event loop.

Description

  • Replace repeated full-catalog scans in toolChoiceCandidates with a cached index built once per catalog in src/types/tools.ts.
  • Preserve previous semantics including wire/dotted aliases, bare-name ambiguity rejection, and duplicate-identity suppression.
  • Add a performance/regression test tests/tool-choice-performance.test.ts that verifies ambiguous bare-name selectors are rejected while catalog accesses remain linear.
  • The change touches src/types/tools.ts and adds tests/tool-choice-performance.test.ts.

Testing

  • Ran the focused performance regression: bun test tests/tool-choice-performance.test.ts and the new test passed.
  • Ran type checking (bun run typecheck) and the repository privacy:scan (bun run privacy:scan) which both passed.
  • Started a broader test run; many suites exercised and passed, but unrelated environment-dependent failures (existing Lab tests / platform-specific harness, and a node:zlib missing symbol when invoking a particular test file) were observed and are not related to this change, so repository-wide CI should be used by maintainers as the final gate.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 977769af-ac29-4883-aa0a-b5648511ce4e


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

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 20, 2026
@github-actions github-actions Bot changed the title fix(tools): index tool-choice candidates to avoid quadratic catalog scans [WRONG BRANCH] fix(tools): index tool-choice candidates to avoid quadratic catalog scans Aug 20, 2026
@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft August 20, 2026 13:31
@luvs01 luvs01 closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant