Skip to content

refactor(tools): replace positional definitions with named declarations - #1404

Merged
yyjeqhc merged 2 commits into
mainfrom
codex/name-tool-definition-fields
Nov 9, 2026
Merged

yyjeqhc merged 2 commits into
mainfrom
codex/name-tool-definition-fields

Conversation

@swjnxyf

@swjnxyf swjnxyf commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Tool definitions used a 13-argument def(...) constructor, with positional booleans for Project requirements, destructive intent and shell-like execution. Replace it with a private ToolDeclaration whose fields are all required and named, so reviewers can read each setting directly and omissions remain compile errors. No Default or new policy presets are introduced.

Migrate all 109 calls: 99 become named declarations and 10 reuse the existing narrow control_def constructor after verifying that their fixed fields match its contract. Keep canonical ToolDefinition construction, existing modifiers and the shared Runner-read/Control contracts. This is a maintenance simplification with essentially flat size: net +4 lines across 24 declaration-layer files.

Validation:

  • cargo test --locked -p webcodex-tool-contracts --lib -- --quiet — 348 passed, 1 existing ignored.
  • cargo test --locked -p webcodex-tool-contracts --lib --all-features -- --quiet — 353 passed, 1 existing ignored.
  • cargo test --locked -p webcodex --lib -- tool_runtime::tests::metadata tool_runtime::tests::permission_gate mcp::tests::oauth_scope mcp::tests::tool_exposure --quiet — 98 passed. The same three pre-existing unused-code warnings remain.
  • Package formatting and git diff --check passed.
  • A temporary compiled exporter produced byte-identical complete ToolDefinition and registered ToolSpec output before/after for default features (186 definitions) and all features (194). The exporter and snapshots are not included in the PR.
  • A separate field-by-field source comparison verified all 109 migrated calls and existing Control calls retain their values. Existing tests are unchanged.

Tool order, descriptions, schemas, annotations, scopes, capabilities, audit and Session evidence policies remain unchanged.

@yyjeqhc
yyjeqhc merged commit 28552aa into main Nov 9, 2026
4 of 5 checks passed
@yyjeqhc
yyjeqhc deleted the codex/name-tool-definition-fields branch November 9, 2026 07:35
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.

2 participants