Modules · Open Code Review (OCR)

Module: tool

↩ architecture.html · generated 2026-08-14

Open Code Review (OCR) — Tools

flowchart LR IN["Input\na tool call's JSON arguments from the model"] --> ACT["Tools\nThe fixed toolset: file_read, file_find, file_read_diff, code_search, code_comment, task_done — plus the Registry that can also hold MCP-provided tools."] ACT --> OUT["Output\na result string appended back into the conversation"]

The fixed toolset: file_read, file_find, file_read_diff, code_search, code_comment, task_done — plus the Registry that can also hold MCP-provided tools. Package: internal/tool/.

What flows through it

flowchart LR IN["a tool call's JSON arguments from the model"] --> MOD["Tools"] MOD --> OUT["a result string appended back into the conversation"]

Technical details

Package: internal/tool/ Depends on: (none — leaf package) Depended on by: CLI, LLM loop (Runner), MCP client, Review agent, Scan agent

What actually happens here

definitions.go defines the reserved Tool set and a Registry (Register/Get/Freeze — frozen once dispatch starts so no tool can be added mid-run). file_read.go / file_find.go / code_search.go implement local, read-only filesystem access scoped to the repo (via internal/pathutil). file_read_diff.go answers questions about other changed files using the DiffMap injected by agent.injectDiffMap. code_comment.go + comment_collector.go parse and accumulate the model's findings.

How the LLM / model version is chosen

No model calls inside any tool implementation — every tool is a synchronous, local operation. (The one exception, the re-location LLM call for a comment whose line number can't be resolved deterministically, lives in internal/diff/internal/llmloop, not here.)

Deterministic (non-LLM) work in this module

Every built-in tool is fully deterministic: file reads are path-validated (pathutil.WithinBase, both pre- and post-symlink-resolution — the same mitigation the ASSURANCE_CASE.md cites for path traversal), code_comment argument parsing and validation is deterministic, and the Registry's known-name/frozen-state checks are deterministic.


Part of the module docs index. Full interactive version, with every module side by side: architecture.html §7. Cross-cutting mechanisms this module participates in (retry, compression, manifest, resume, hashing): LLD.