docs(adr): 0002 — Tool contract (v1)#270
Merged
EmersonBraun merged 1 commit intomainfrom Apr 14, 2026
Merged
Conversation
Formalizes the Tool contract. Defines 12 invariants (T1-T12) covering identity, schema validation, execution, lifecycle, and streaming: - Name is identity (T1) with strict regex - JSON Schema 7 as the authoritative arg description (T2) - Validation at the boundary before execute (T3) - Execute-optional (T4) enables MCP bridge and delegated tools - JSON-serializable output (T5) matches the wire format - Streaming via AsyncIterable mirrors Adapter (T6) - Idempotent init (T7), best-effort dispose (T8) - Explicit confirmation gate, no auto-approve timeout (T9) - Pure definitions, no side effects at construction (T10) - Error-as-status, throwing only for bugs (T11) Also updates ADR index (0001 + 0002 accepted). Builds on ADR 0001 (Adapter). Together they unblock the MCP bridge (#167), schema-to-type inference (#130), human-in-the-loop (#158), and the tool sandbox (#163). Refs #214
This was referenced Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second ADR of Phase 0 — formalizes the Tool contract implicit in
packages/core/src/types/tool.tsandpackages/tools/src/*.Builds on ADR 0001 (Adapter).
What's included
docs/architecture/adrs/0002-tool-contract.md— 3 core types, 12 invariants (T1-T12), stability tierstable, rationale, trade-offs, alternatives considered, open questions.Why now
Before Fase 3 adds dozens of tools (GitHub, Linear, Slack, Google Workspace, Stripe, Supabase, browser, etc.) and before the MCP bridge (#167) publishes/consumes tools across ecosystems, we need a contract that:
Key invariants (the important ones)
Trade-offs made explicit
ToolDefinition<TArgs, TResult>Unlocks
Test plan
packages/tools/src/?Refs #214 #211