Skip to content

test(cli): add AiTool registry conformance suite - #516

Merged
blafourcade merged 1 commit into
nextfrom
fix/e9-aitool-contract-verifiable
Jul 27, 2026
Merged

blafourcade merged 1 commit into
nextfrom
fix/e9-aitool-contract-verifiable

Conversation

@blafourcade

Copy link
Copy Markdown
Contributor

🎯 What & why

Closes the goal this whole cartography backlog was built around: "adding an AI tool is adding one file" is now guaranteed by a test that fails when it isn't, rather than by human discipline. Today, forgetting to add a new tool to AI_TOOL_IDS, to the build target list, or to the marketplace probe table produces no error — just silently wrong behavior at runtime.

🛠️ How it works

Every assertion iterates getAllRegisteredTools() rather than a hardcoded list, so a new tool file is automatically subject to all of them. Guards:

  • AiTool<C> shape and the three required content methods
  • registry ↔ AI_TOOL_IDS agreement, both directions
  • every registered tool reachable by at least one framework build target/mode
  • every plugins-capable tool present in MARKETPLACE_PROBES
  • no probe-table or build entry naming an unregistered tool (stale-entry guard)

Assertions were chosen against the live registry, not invented. Probing found opencode is deliberately absent from PLUGIN_MANIFEST_PROBES (flat plugin mode — no per-plugin manifest directories), so per-tool manifest-probe coverage is explicitly not asserted. A naive "every tool must be in both probe tables" test would have been wrong.

All five guards were verified to actually fail on a deliberate mutation — removed tool id, removed build entry, removed marketplace probe, typo'd probe format, malformed directory field — each with a message naming the tool, the field, and the file to fix. A conformance test that can't fail is worthless, so this was checked rather than assumed.

🧪 How to verify

pnpm --filter cli test — 2088/2088 (2059 + 29 new), tsc clean, zero production files changed.

To see it bite: delete any entry from AI_TOOL_IDS, FRAMEWORK_BUILD_TARGET_MODES, or MARKETPLACE_PROBES and re-run.

⚠️ Heads-up

Deliberate scope reduction of US-E9-02/03, user-confirmed before planning — not a silent reinterpretation. Those tickets asked to derive the probe tables and adapter dispatch from the tool contract. The spike found PluginFormat ("a native on-disk layout aidd can read") and AiToolId ("a tool aidd installs into") are distinct concepts that merely coincide in membership today. Deriving one from the other would couple them permanently, force a parser function reference into an otherwise pure-data contract, and touch all 5 tool files plus PluginsCapability — for a guarantee this test delivers with zero production change. Same outcome shape as the #514 review.

Also recorded in spike-findings.md for separate triage, deliberately not fixed here:

  • MARKETPLACE_PROBES's copilot entry points at a manifest filename (.github/plugin/plugin.json) — possibly intentional, possibly a copy-paste bug
  • PLUGIN_MANIFEST_PATHS in plugin-content-translator.ts is a third hand-maintained manifest-path list that has already diverged (omits copilot's two paths)
  • --help strings in framework.ts / ai.ts hardcode the five tool names in prose

Closes the original goal this backlog was built around: "adding an AI tool
is adding one file" is now guaranteed by a test that fails when it isn't,
instead of by human discipline.

Every assertion iterates getAllRegisteredTools() rather than a hardcoded
list, so a new tool file is automatically subject to all of them. Guards:
AiTool<C> shape and required methods; registry <-> AI_TOOL_IDS agreement
both ways; every tool reachable by at least one framework build
target/mode; every plugins-capable tool present in MARKETPLACE_PROBES; and
no probe/build entry naming an unregistered tool (stale-entry guard).

Scope note (user-confirmed before planning, not a silent reinterpretation):
US-E9-02/03 asked to *derive* the probe tables and adapter dispatch from
the tool contract. The spike found PluginFormat ("a native on-disk layout
aidd can read") and AiToolId ("a tool aidd installs into") are distinct
concepts that merely coincide in membership today — deriving one from the
other would couple them permanently and force a parser function reference
into an otherwise pure-data contract, for a guarantee this test delivers
with zero production change. Same shape as the #514 review outcome.

Assertions were chosen against the live registry, not invented: opencode
is deliberately absent from PLUGIN_MANIFEST_PROBES (flat plugin mode, no
per-plugin manifest dirs), so per-tool manifest-probe coverage is NOT
asserted. All five guards were verified to fail on a deliberate mutation
(removed tool id, removed build entry, removed marketplace probe, typo'd
probe format, malformed directory field) with messages naming the tool,
the field, and the file to fix.

2088/2088 tests pass (2059 + 29 new), tsc clean, zero production files
changed.
@blafourcade
blafourcade merged commit 26e9241 into next Jul 27, 2026
14 checks passed
blafourcade added a commit that referenced this pull request Jul 31, 2026
Closes the original goal this backlog was built around: "adding an AI tool
is adding one file" is now guaranteed by a test that fails when it isn't,
instead of by human discipline.

Every assertion iterates getAllRegisteredTools() rather than a hardcoded
list, so a new tool file is automatically subject to all of them. Guards:
AiTool<C> shape and required methods; registry <-> AI_TOOL_IDS agreement
both ways; every tool reachable by at least one framework build
target/mode; every plugins-capable tool present in MARKETPLACE_PROBES; and
no probe/build entry naming an unregistered tool (stale-entry guard).

Scope note (user-confirmed before planning, not a silent reinterpretation):
US-E9-02/03 asked to *derive* the probe tables and adapter dispatch from
the tool contract. The spike found PluginFormat ("a native on-disk layout
aidd can read") and AiToolId ("a tool aidd installs into") are distinct
concepts that merely coincide in membership today — deriving one from the
other would couple them permanently and force a parser function reference
into an otherwise pure-data contract, for a guarantee this test delivers
with zero production change. Same shape as the #514 review outcome.

Assertions were chosen against the live registry, not invented: opencode
is deliberately absent from PLUGIN_MANIFEST_PROBES (flat plugin mode, no
per-plugin manifest dirs), so per-tool manifest-probe coverage is NOT
asserted. All five guards were verified to fail on a deliberate mutation
(removed tool id, removed build entry, removed marketplace probe, typo'd
probe format, malformed directory field) with messages naming the tool,
the field, and the file to fix.

2088/2088 tests pass (2059 + 29 new), tsc clean, zero production files
changed.
blafourcade added a commit that referenced this pull request Jul 31, 2026