Skip to content

Unify tool-name classification constants - #589

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-6809-tool-name-classification-constants-diverge-three-read-tools-with
Aug 24, 2026
Merged

Unify tool-name classification constants#589
TheGreatAxios merged 1 commit into
mainfrom
cl-6809-tool-name-classification-constants-diverge-three-read-tools-with

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Closes CL-6809.

Before / after

Constant File Before After
READ_TOOLS (director surface) src/agent/directors/tool-sets.ts read_file, grep, search_files, list_dir, lsp, run_shell, web_fetch, web_search unchanged (base others derive from)
READ_ONLY_TOOLS (auto-allow gate) src/permission/classify.ts read_file, search_files, grep, list_dir, lsp, manage_tasks same membership, now imported as AUTO_ALLOW_READ_TOOLS from src/agent/tool-classification.ts (derived from director READ_TOOLS minus run_shell/web_fetch/web_search, plus manage_tasks)
READ_TOOLS (compaction re-read dedup) src/session/compactor.ts read_file now PATH_KEYED_READ_TOOLS (shared)
READ_TOOLS (thrash read tracking) src/subagent/thrash.ts read_file now PATH_KEYED_READ_TOOLS (shared, same value)
QUERY_TOOLS (compaction) src/session/compactor.ts grep, search_files, list_dir now SEARCH_QUERY_TOOLS (shared base) + list_dir, unchanged membership
SEARCH_TOOLS (thrash) src/subagent/thrash.ts grep, search_files now SEARCH_QUERY_TOOLS directly, unchanged membership

Auto-allow behavior

No change. AUTO_ALLOW_READ_TOOLS is derived from the director's READ_TOOLS (filtering out run_shell/web_fetch/web_search, which have their own narrower auto-allow rules) plus manage_tasks, and that derivation produces exactly the same six tools classify.ts already granted allow-tier to: read_file, search_files, grep, list_dir, lsp, manage_tasks. Verified by inspection and pinned by a new test (src/agent/tool-classification.test.ts) that asserts the exact set.

Deliberate vs. drift

  • compactor.ts and thrash.ts's READ_TOOLS ({read_file}) were identical — genuine duplication, now unified as PATH_KEYED_READ_TOOLS.
  • compactor.ts's QUERY_TOOLS includes list_dir; thrash.ts's SEARCH_TOOLS does not. This is a real conceptual difference: compaction treats any replayable query result (grep/search_files/list_dir) as supersedable by a later identical call, while thrash's read tracking is specifically about detecting stuck read/search loops, and a repeated directory listing isn't the same loop signal a repeated grep or read is. Kept separate, both built on the shared SEARCH_QUERY_TOOLS base, and documented in src/agent/tool-classification.ts.
  • READ_ONLY_TOOLS (auto-allow) is a strict subset of the director read surface (no shell/web) plus manage_tasks — a genuinely different concept ("never needs a prompt" vs. "read-capable leaf tool"), now expressed as a derivation instead of a hand-maintained duplicate list.

Testing

bun run check (lint, typecheck, build, test) green in the worktree: 5381 pass, 0 fail.

Three READ_TOOLS constants had drifted apart under the same name, one
of them (permission's auto-allow gate) security-relevant. Add
src/agent/tool-classification.ts as the single source of truth:

- AUTO_ALLOW_READ_TOOLS: derived from the director read surface minus
  run_shell/web_fetch/web_search (which have their own auto-allow
  rules) plus manage_tasks. Replaces classify.ts's inline
  READ_ONLY_TOOLS with the identical membership — no auto-allow
  behavior change.
- PATH_KEYED_READ_TOOLS: the {read_file} set that was defined
  identically in both compactor.ts and thrash.ts, now shared.
- SEARCH_QUERY_TOOLS: the {grep, search_files} base shared by
  compaction's QUERY_TOOLS (adds list_dir) and thrash's SEARCH_TOOLS
  (deliberately omits it — a repeated list_dir isn't the stuck
  read/search loop thrash watches for).

Adds a pinning test so future drift fails CI instead of spreading
silently.
@linear-code

linear-code Bot commented Aug 24, 2026

Copy link
Copy Markdown

CL-6809

@TheGreatAxios
TheGreatAxios merged commit 03933a4 into main Aug 24, 2026
5 checks passed
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