Repository navigation
feat(mcp): declare the current tool algebra - #3004
Conversation
Problem: The 104 live MCP tools were registered through separate decorators and hand-maintained inventories. This made discovery, contracts, role surfaces, and generated documentation drift independently. What changed: Add a storage-free declaration kernel and an MCP declaration registry. The registry validates each existing FastMCP handler at registration time, derives role inventories and an equivalence map, and leaves the existing handlers as the authority for execution, authorization, and errors. Compatibility/migration: No legacy tools are removed. Read-surface migration, runtime resources and prompts, cold-model trials, and tool retirement remain separate work under t46.8.2 and t46.8.3. Ref polylogue-t46.8.1. Co-Authored-By: ChatGPT Pro <[email protected]>
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (31)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d78469ae13
ℹ️ 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".
…nt kit (#3061) ## Summary Adds `polylogue.agent_integration`: a typed spec, generated manual/deep-reference/manifest/recipes assets, a native installer for Claude Code/Codex/Gemini/Hermes, a role-scoped runtime manifest, a `polylogue agent` CLI, and a Home Manager module. ## Problem The consumer-owned skill/SessionStart text agents currently see is stale, reports the wrong tool surface, and has no generated, verified, drift-checked path from the actual MCP declarations to what an agent is taught. Ref polylogue-3gd.2, polylogue-3gd.3. ## Solution The manual/reference are generated from the existing 104-tool declaration registry (`t46.8.1`, landed in #3004) and stage the target six-tool contract (`query`/`read`/`get`/`explain`/`context`/`status` + `write`/`judge`/`run`/`operate`) without claiming the cutover has landed — installation and instruction injection fail closed until exact role-scoped tool names and a `live-verified` schema marker both exist. Retains the beads-06 native installer architecture (managed MCP entries, idempotent upgrade, drift detection, lossless uninstall) rather than forking it. **External provenance:** recovered GPT Pro result package `mcp-01-agent-manual-r01.zip`, SHA-256 verified against snapshot commit `536a53efac0cbe4a2473ad379e4db49ef3fce74d`. The patch applied cleanly except the two generated topology files, which were regenerated locally (`devtools render topology-projection && devtools render topology-status`) rather than patched. Fixed post-apply: missing `-f`/`--format` short-flag aliases on all 6 new `agent` subcommands, a redundant `cast` flagged by mypy, and 5 undocumented CLI surfaces caught by `devtools verify docs-coverage` (added a CLI-commands section to the generated standing manual generator). ## Not claimed This is the installer/manual foundation, not the six-tool cutover itself: no compatibility tool is removed, FastMCP signatures are not yet `live-verified`, and instruction injection stays staged until `t46.8.2`/`t46.8.3` land the real read/context/judgment migration. ## Verification - `devtools test tests/unit/agent_integration/ tests/unit/mcp/test_server_surfaces.py tests/unit/cli/` — 2731 passed, 1 skipped. The 11 remaining failures are pre-existing on unpatched master (confirmed by rerunning them there): `read_timeout` TypeError in `test_diagnostics.py`/`test_json_output.py`, schema-version snapshot drift (37→39) in `test_plain_cli_snapshots.py`, and a `source_debt is locked` sqlite contention in `test_insights.py` — none related to this change. - `devtools verify --quick` — 16/16 steps passed (format, lint, mypy, render-all, topology, layering, closure-matrix, docs-coverage, manifests, ci-workflows, doc-commands, test-infra-currency, test-clock-hygiene, pytest-timeout-overrides, degrade-loudly). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <[email protected]>
…proof (#3241) ## Summary Completes the storage-free `polylogue/declarations` authoring kernel (polylogue-o21.1) against its acceptance criteria. The five-file package (`models.py`, `registry.py`, `derive.py`, `validation.py`) and its MCP pilot (`polylogue/mcp/declarations`, t46.8.1) were already on `master` (landed via #3004 as a side effect of the MCP tool-algebra declaration work); this PR closes the gaps between that existing implementation and the o21.1 AC: typed per-artifact derivation, a synthetic-domain proof with per-dimension incompatibility coverage, and a repo-level layering rule. ## Problem `polylogue/declarations/derive.py` exposed exactly one generic derivation shape — `DerivationInput.normalized`, a full `asdict()` blob of the whole `DeclarationSpec`. The o21.1 design explicitly calls for `derive.py` to "expose typed deriver protocols and stable artifact inputs for names, contracts, schemas, docs, examples, discovery text, and completeness projections" — i.e. narrow, source-provenanced, per-artifact-kind slices a domain renderer can depend on individually, not one undifferentiated blob. Separately, the AC requires a synthetic proof "asserting the diagnostic names the differing dimension" per axis; the existing test only exercised all five `CompatibilityKey` dimensions differing simultaneously, which does not prove the diagnostic isolates a *single* varying dimension. The import-hygiene AST test's forbidden-import list also omitted `polylogue.sources`/`polylogue.maintenance`, which the AC names explicitly ("no import from MCP, sources, storage, insights, maintenance, or other domain registry packages"). Finally, `docs/plans/layering.yaml` (the cross-package import gate enforced by `devtools verify layering`) had no entry for `polylogue/declarations` at all — the boundary was checked only by an in-package unit test. ## Solution - `polylogue/declarations/derive.py`: added `NameInput`/`ContractInput`/`SchemaDocInput`/`ExampleInput`/ `DiscoveryInput`/`CompletenessInput` dataclasses, each carrying `declaration_id` + `owner_path` (source provenance) plus exactly the fields that artifact kind needs. Added one typed `Protocol` deriver per kind (`NameDeriver`, `ContractDeriver`, `SchemaDocDeriver`, `ExampleDeriver`, `DiscoveryDeriver`, `CompletenessDeriver`) alongside the existing generic `DeclarationDeriver`/`DerivationInput`. Added a `normalized_*_bytes()` helper per kind for deterministic drift checks, reusing the registry's stable `declarations()` ordering so every projection is provably independent of registration order. Re-exported everything from `polylogue/declarations/__init__.py`. - **Design decision (underspecified in the bead):** kept the existing generic `DeclarationDeriver`/`DerivationInput` pair rather than deleting it — a domain renderer that legitimately needs the full declaration (e.g. a debug/audit dump) still has that option, while renderers that only need one artifact kind now have a narrower typed contract available. This is additive, not a replacement of the existing shape, since the existing shape is already consumed transitively by `normalized_derivation_bytes` used in the pre-existing registry test. - **Design decision:** `owner_path` alone stands in for "source provenance" on every new projection (matches the existing `DeclarationSpec.owner_path` field and the `Diagnostic.owner_path` convention in `validation.py`) — no new provenance concept was introduced. - `tests/unit/declarations/test_synthetic_domain.py` (new): a fake `widget` domain in the shape a real pilot (MCP) would use it. Proves (a) two legitimately compatible declarations unify into one family, (b) five parametrized cases — one per `CompatibilityKey` dimension — where a declaration differs on exactly that one axis, asserting `DeclarationConflictError.differences` names *only* that dimension and that the registry state is unchanged after the rejected registration (never coerces), and (c) order-independent derivation across every new typed artifact kind plus the existing full-declaration blob, under a seeded shuffle. - `tests/unit/declarations/test_registry.py`: widened the import-hygiene AST walk's forbidden tuple to include `polylogue.sources` and `polylogue.maintenance` (previously covered only implicitly, since no test exercised those specific forbidden imports). - `docs/plans/layering.yaml`: added a `polylogue/declarations` rule disallowing imports from every domain/surface package the AC names (`api`, `archive`, `cli`, `config`, `daemon`, `insights`, `maintenance`, `mcp`, `operations`, `sources`, `storage`, `ui`), enforced by `devtools verify layering` (part of `devtools verify --quick`). - No new module was added under `polylogue/`, so no topology-projection regeneration was required; `devtools render all --check` confirmed no drift. ## AC matrix (polylogue-o21.1) 1. **Satisfied.** `models.py`/`registry.py`/`derive.py`/`validation.py` expose typed, storage-free APIs; the AST import-hygiene test (widened this PR) plus the new `docs/plans/layering.yaml` rule both assert no import from MCP/sources/storage/insights/maintenance/other domain registries. 2. **Satisfied.** `CompatibilityKey` requires equality of all five dimensions before declarations share a family (pre-existing `registry.py`); the new synthetic-domain test proves the diagnostic names exactly one differing dimension in isolation for each of the five axes, and that an incompatible declaration is never coerced in. 3. **Satisfied.** `derive.py` now produces typed inputs for names/contracts/schema-doc fragments/examples/discovery/completeness, each with source provenance (`owner_path`); the synthetic-domain test proves shuffled registration order yields byte-equivalent normalized output for every one of those six kinds plus the full-declaration blob. 4. **Satisfied** (pre-existing `validation.py`, unchanged this PR — verified, not reimplemented). Missing producer/handler/role-gate/schema/example/ output/consumer-edge each produce one `Diagnostic` naming declaration id, owner path, and exact repair command. "Removing the real pilot declaration or handler fails anti-vacuously" is covered on the MCP side by `tests/unit/mcp/test_tool_declarations.py` (t46.8.1's own scope, out of this PR's file set — re-ran to confirm it still passes with the widened kernel). 5. **Satisfied, pre-existing.** `polylogue/mcp/declarations/{models,registry}.py` already import and build on `polylogue.declarations` (`DeclarationSpec`, `DeclarationRegistry`, `CompatibilityKey`, etc.) while owning all MCP-specific verb/role/result/registration semantics itself — verified by grep and by `mypy --strict` on both packages together. 6. **Satisfied.** Synthetic families, deterministic derivation, actionable diagnostics, and the real MCP pilot all pass; `devtools verify --quick` is green. ## Verification ``` nix develop --command mypy --strict polylogue/declarations tests/unit/declarations polylogue/mcp/declarations # Success: no issues found in 11 source files nix develop --command devtools test tests/unit/declarations tests/unit/mcp/test_tool_declarations.py # 18 passed in 5.12s nix develop --command python -m devtools verify layering # No layering violations found. nix develop --command devtools verify --quick # exit_code 0 (ruff format/check, mypy, render all, verify topology/layering/ # closure-matrix, lab schema roundtrip, verify manifests/ci-workflows/ # doc-commands/docs-coverage/test-infra-currency/test-clock-hygiene/ # pytest-timeout-overrides/degrade-loudly — all ok) ``` Not run: `devtools verify --all` (full non-integration suite) — the `--quick` gate plus focused `devtools test` on every touched/consuming module is the documented sufficient bar for this size of change; nothing in this diff touches schema, migrations, or cross-cutting runtime behavior that would justify the full run. ## Residual risk - The kernel's `DeclarationDeriver`/`DerivationInput` generic path and the six new typed paths are both live; nothing currently forces a domain package to prefer the typed path over the generic blob. o21.2/o21.3 (scaffolds + cross-family adoption, already tracked, out of this bead's scope) are the natural place to steer new domain declarations toward the typed projections. - AC 4's "removing the real pilot declaration or handler fails anti-vacuously" clause is proven by t46.8.1's own test suite (`tests/unit/mcp/test_tool_declarations.py`), not by a new test added in this PR — this bead does not own the MCP pilot's test file, and the existing coverage there was unaffected by this change (confirmed by running it green above). Ref polylogue-o21.1 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added category-specific declaration derivation for names, contracts, schemas, examples, discovery, and completeness. * Added deterministic normalized outputs for each declaration artifact type. * Expanded the public declarations package exports for these capabilities. * **Tests** * Added coverage for declaration family compatibility, isolated validation differences, registry safety, and order-independent derivation. * Strengthened import-boundary checks for the shared declarations layer. * **Refactor** * Formalized layering rules to keep the shared declarations kernel independent of domain, runtime, and storage components. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Introduce a typed declaration kernel and an executable MCP declaration registry
for the current 104-tool server surface.
Problem
The archive's continuity surface exposes a large, historically accumulated MCP
tool set without one generated, verified inventory tying implementation,
contract, discovery, and equivalence information together. The recovered
external
beads-02package supplied a narrowly scoped foundation, but it wasprepared against an older snapshot and required local integration and proof.
Ref polylogue-t46.8.1.
Solution
Add the storage-free
polylogue.declarationskernel and an MCP-specificregistry. Registration adapters retain the existing handlers while validating
that every registered name has an exact declaration, role, and contract.
Generated tool-index and equivalence artifacts now derive from the registry.
This is intentionally a foundation, not a claimed MCP migration: it neither
removes legacy tools nor wires URI resources/prompts at runtime. The preserved
beads-03andbeads-04packages remain reconciliation inputs forpolylogue-t46.8.2 and polylogue-t46.8.3.
Acceptance matrix:
External provenance: recovered standalone
PATCH.difffrom the operator'sdownloaded GPT Pro result, SHA-256
59d40d9e39f4cd97b35ef7c3e47f9efa9a0153c4766e091a7609091ba4397592.It was three-way applied and reviewed against current master rather than
accepted as an unreviewed stale-base patch.
Verification
POLYLOGUE_PYTEST_WORKERS=3 devtools test tests/unit/declarations/test_registry.py tests/unit/mcp/test_tool_declarations.py tests/unit/mcp/test_tool_discovery.py tests/unit/mcp/test_tool_contracts.py tests/unit/mcp/test_per_tool_contracts.py tests/unit/mcp/test_server_runtime.py— 384 passed.devtools verify --quick— all 16 steps passed locally and again in thepre-push hook.