Build tool calls through ToolId instead of name literals#4156

open
main
t3/untangle-t11-f11
opened30m agobyNNick
View on GitHubGitHub import enabledPR last imported 18m ago

Why

The program goal is to untangle core/ so agents read less per change, break less without noticing, and debug faster. The tool catalog names the same tool in two ways: the tools! macro generates ToolId and ToolId::name(), while about 30 call sites in ployz-store/src/tools/ spell the same wire name as a string literal (Call::new("server_show", ..), the CLI_NEXT and NOT_SETTINGS tables, LOCAL_NEXT). Renaming or adding a tool meant finding every literal by grep, and a typo only showed up as a refusal an agent could not follow.

What changed

  • Call::to(ToolId, input) builds a Call from ToolId::name(). Call::new(&str, ..) stays for the sites that carry a name the caller was given (&call.tool, &state.tool).
  • Every production Call::new("<literal>", ..) in tools/ now uses Call::to: act, copies, deployment, environment, github, metrics, project, release, removal, runtime, machine.
  • The name tables hold ToolId instead of &str: CLI_NEXT rows (CliNext::Tool), NOT_SETTINGS, not_setting, not_setting_sentence, Tool::LOCAL_NEXT and Cx::local_next, removal::Target::tool, the stale read in machine.rs.
  • New tools/tool_id_tests.rs: ToolId::name() equals the registered Tool::NAME for every tool, in catalog order, with unique names; and every string literal that is the first argument of a Call::new in tools/ equals some ToolId::name().
  • ToolId variants are not renamed, there is no ToolId::of<T>, the dashboard OPERATION_TOOLS is untouched, and tool_input! (F10b) is not started.

Bets

None touched.

Behavior

Unchanged. Tool names on the wire are byte-identical: Call::to goes through Tool::NAME, and the tests that pin the wire literals (refusal_tests, machine_tests, removal_tests, agent_tool_calls) still spell the names as strings and pass untouched, apart from the two assertions on not_setting, which now compare ToolId::name to the same literals.

Proof

Baseline on the unmodified base, then the same on the branch head:

  • cargo test -p ployz-store --test agent_tool_calls --test agent_tools: 92 passed and 3 passed, both before and after.
  • cargo test -p ployz-store --lib tools::: 56 passed before, 58 after (the two new tests).
  • cargo clippy -p ployz-store --all-targets -- -D warnings: clean. cargo fmt --check: clean.
  • Sweep of the checkout for skill, verify-model, ployz-verify and doc citations into the touched files: none cite ployz-store/src/tools/*.rs by line. dashboard/src/modules/agent/agent-secrets.ts cites tools/service.rs by symbol (secret_value), which is untouched.

Residuals

  • core/crates/ployz/src/handlers/mcp.rs still builds a tools::Call::new(..) from a literal (outside this PR's file list).
  • The new literal scan reads Call::new( followed by a string literal; a name built another way (a variable, a format!) is not scanned.
  • tools/*_tests.rs keep their Call::new("..") literals on purpose, as independent wire pins.

Checks

15 successful · 9 skipped
All checks passed
41bf2c0
Synced from GitHub

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

External image Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e5d57b1d-5ed1-4dc8-bf94-902b2e6f3747

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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