Skip to content

🤖 refactor: derive tool dispatch tables from the TOOL_DEFINITIONS catalog - #4003

Merged
ibetitsmike merged 15 commits into
mainfrom
mike/deep-tool-modules
Aug 29, 2026
Merged

🤖 refactor: derive tool dispatch tables from the TOOL_DEFINITIONS catalog#4003
ibetitsmike merged 15 commits into
mainfrom
mike/deep-tool-modules

Conversation

@ibetitsmike

Copy link
Copy Markdown
Contributor

Summary

Makes TOOL_DEFINITIONS the single self-describing per-tool catalog (input schema + result schema + PTC bridging metadata) and rebuilds the parallel per-tier dispatch tables as derived views of it. Five hand-maintained tables are deleted outright, the browser registry loses its duplicated schema column, and the branch is a net simplification: 1321 insertions, 1586 deletions, net -265 lines (production and tests, vs merge base).

Background

The tool seam was fragmented into parallel string-keyed switchboards that restate what TOOL_DEFINITIONS already knows: the browser TOOL_REGISTRY duplicated every tool's zod schema, the CLI kept three separate name-keyed maps, toolDefinitions.ts kept a hand-written BridgeableToolName union next to a parallel RESULT_SCHEMAS table, and the PTC bridge kept its own EXCLUDED_TOOLS literal. Each table could silently drift from the spine, and one tool change was a shotgun edit across tiers. This PR deepens the existing catalog seam per-switchboard rather than introducing per-tool scaffolding.

Implementation

Deleted (derived from the catalog instead):

  • RESULT_SCHEMAS table: each definition entry now carries its resultSchema directly.
  • Hand-written BridgeableToolName union: now a mapped type derived from which entries declare resultSchema.
  • EXCLUDED_TOOLS literal in the PTC bridge: entries declare ptcExcluded with their why-reason; the bridge derives the set (one inline special case for the dynamic status_set, which has no definition entry).
  • CLI startFormatters + endFormatters maps and the MULTILINE_RESULT_TOOLS set: merged into one binding table.
  • TOOL_REGISTRY's schema column: lookup derives the render schema from TOOL_DEFINITIONS by name; entries collapse to bare component bindings.

Surviving additions, each justified:

  • Small renderer schema-override map in getToolComponent.ts: only genuine divergences from the definition schema (legacy history-only names such as task_terminate, agent_report's legacy file-backed args union, dynamic status_set, and task_workspace_lifecycle's historical args so old transcripts keep their proper card).
  • One merged CLI binding table: the irreducible name-to-formatter binding; formatter functions themselves are unchanged.
  • TOOL_NAME_TO_ICON deliberately stays in ToolPrimitives.tsx: generic chrome needs a name-keyed icon lookup from a leaf module that every tool card imports, so folding it into the component catalog would create a browser module cycle. It is already the irreducible one-line-per-tool form.

Diff-shape note: toolDefinitions.ts shows large +/- churn because the result-schema consts had to move above TOOL_DEFINITIONS (const ordering); the file is net -18 lines and the schemas themselves are unchanged.

Out of scope (parallel architecture PRs touch adjacent seams): assembly in tools.ts/toolAssembly.ts, per-tool execution factories, view components and stories.

Validation

  • Remote dogfood UAT (Coder Agents, adversarial runner): PASS on this exact head. Verified tool cards (bash, file_read, edit diff, todo), legacy-name and MCP generic-fallback rendering, CLI formatting, plan-mode edit rejection, and the PTC sandbox exclusion set from inside code_execution.
  • Wiring-only registry tests were deleted per the catalog derivation; behavioral tests kept (generic fallback, legacy agent_report routing, schema-mismatch fallback) plus a new red-green regression test for historical task_workspace_lifecycle rendering.
  • Full bun suite: 13726 pass; the 8 failures are pre-existing (5 reproduce byte-identically on origin/main in a clean worktree; the 3 WorkspaceFooterBar failures pass in isolation on both main and this branch, a known full-suite interference flake).

Risks

Low. Behavior-preserving derivations with identical inputs and outputs; the riskiest surface is transcript rendering of historical tool calls, which is covered by the restored override map and its regression test. PTC sandbox type generation is guarded by the unchanged typeGenerator test suite.


Generated with xum • Model: anthropic:claude-fable-5 • Thinking: xhigh

@ibetitsmike

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 64e9d2769e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

This comment has been minimized.

_Generated with `xum` • Model: `openai:gpt-5.6-sol` • Thinking: `high`_

<!-- mux-attribution: model=openai:gpt-5.6-sol thinking=high -->
Review follow-up: the four per-command handlers are only reachable through
processSlashCommand now, and /plan open lost its dedicated tests in the
result-based rewrite.

_Generated with `xum` • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_

<!-- mux-attribution: model=anthropic:claude-fable-5 thinking=xhigh -->
Codex P1: getDraft captured at command invocation reports that render's
input, so async commands cleared newer drafts on consume and never fired
restore-if-empty.

_Generated with `xum` • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_

<!-- mux-attribution: model=anthropic:claude-fable-5 thinking=xhigh -->
Codex P2: text equality cannot distinguish a retyped identical draft from
the original invocation. Commands already clear through their own
clear-input actions (matching trunk), so the terminal clear was additive
and could only destroy mid-phase drafts.

_Generated with `xum` • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_

<!-- mux-attribution: model=anthropic:claude-fable-5 thinking=xhigh -->
Codex P2 follow-up: with the terminal consume-path clear gone, /dream and
/refine left the executed command re-runnable in the composer. Emit
clear-input from the handlers so commands own their composer effects.

_Generated with `xum` • Model: `anthropic:claude-fable-5` • Thinking: `xhigh`_

<!-- mux-attribution: model=anthropic:claude-fable-5 thinking=xhigh -->
@ibetitsmike
ibetitsmike changed the base branch from main to mike/runtime-deepening August 28, 2026 19:22
@ibetitsmike
ibetitsmike force-pushed the mike/deep-tool-modules branch from 64e9d27 to ef30fa2 Compare August 28, 2026 19:22
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Aug 29, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Aug 29, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Aug 29, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 29, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to invalid changes in the merge commit Aug 29, 2026
@ibetitsmike
ibetitsmike deleted the branch main August 29, 2026 03:30
@ibetitsmike ibetitsmike reopened this Aug 29, 2026
@ibetitsmike
ibetitsmike changed the base branch from mike/runtime-deepening to main August 29, 2026 03:32
@ibetitsmike
ibetitsmike enabled auto-merge August 29, 2026 03:33
auto-merge was automatically disabled August 29, 2026 04:21

Pull request was closed

@ibetitsmike ibetitsmike reopened this Aug 29, 2026
@ibetitsmike
ibetitsmike enabled auto-merge August 29, 2026 04:22
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 29, 2026
@ibetitsmike
ibetitsmike added this pull request to the merge queue Aug 29, 2026
Merged via the queue into main with commit b5630ce Aug 29, 2026
112 of 148 checks passed
@ibetitsmike
ibetitsmike deleted the mike/deep-tool-modules branch August 29, 2026 05:45
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