Repository navigation
fix: Derive the agent manual's gate and tool count from declarations - #5209
Conversation
The standing agent manual told callers to "call maintenance with the declared operation in preview/dry-run mode" and that "a legacy confirm=true boolean is not the canonical gate". The live handler declares exactly three operations (rebuild_insights, recovery_status, recovery_adjudicate), has no preview or dry-run operation, and gates full-effect execution precisely on confirm. An agent following the manual's stated canonical flow was refused, and was told the one gate that works should not be used. The declaration is the intended contract: the maintenance tool row in polylogue/mcp/declarations/registry.py states the confirm gate, the handler and _dispatch_maintenance implement it, and polylogue-2x6xu already removed the phantom dry_run argument and operation="preview" example from the generated contract. The prose was the last remnant of a flow that never existed, so the prose is the defect. The gate is now declared once, as a ConfirmationGate on the maintenance tool contract, and the manual sentence is rendered from it. Two tests resolve that declaration and the rendered prose against the registered MCP handler's signature. Also documents the live `read` offset argument, which the generated contract omitted; that mismatch was failing test_generated_contract_arguments_match_the_live_mcp_signatures at the base commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
The standing manual injected into agent sessions claimed a "ten-tool MCP surface" and enumerated ten names, while declared_tool_names returns twelve. record_work_event and emit_decision are live, registered, write-gated handlers, so agents reading their own manual concluded two capabilities they actually had were unavailable. The count was hand-maintained in five places and had drifted in all of them. It is now derived: ALL_DECLARED_TOOLS comes from MCP_TOOL_DECLARATIONS, the manual's table and its spelled count render from that set, and no docstring, comment, or prose restates a number. Adding a tool row without a manual contract now fails closed at import with a named error rather than silently undercounting. The two event tools gain real manual contracts. Their target_visible=False is preserved and explained where it is declared: they are outside the target transaction algebra, which is not the same as not being tools. MCPToolDeclaration carries result_semantics directly so a tool without a target transaction can still be described. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (18)
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Two beads, one commit each. Both replace restated facts with derived ones, because a restated fact in a generated manual is what drifted in the first place.
polylogue-4u79w — the manual prescribed a flow the handler rejects
The manual was wrong, not the handler. Evidence, rather than a preference:
maintenance_ToolRow(mcp/declarations/registry.py:256-273) states "rebuild_insights and recovery_adjudicate require confirm=true and fail closed without it", and both the handler (server_cutover.py:2718-2745) and_dispatch_maintenanceimplement exactly that.Literal, the dispatcher, orAuditRepository.recovery_statusalready is the read-only inspection route the prose wanted.previewas phantom, removing thedry_runargument and theoperation="preview"example from the generated contract. The prose was the last surviving remnant, not a competing intent. Growing the handler a preview operation would have invented a declared operation and a target-algebra entry to satisfy stale text.The fix is not a reword: the gate is declared once as
ConfirmationGateon the maintenance contract and the manual sentence is rendered from it, with theoperationargument carrying derivedenum_values. The remaining preview vocabulary the same defect left behind is purged too — the capability-table row, the "stale destructive preview" recovery bullet, a regeneration-checklist item, and a stalesemantic:"preview-bound confirmation"example query.Anti-vacuity, executed twice: adding
"preview"to the handler'sLiteralfailed both the declared-gate and manual-prose tests; restoring the hand-written prose line in place of the derived sentence failed. Both reverted.Inherited failure fixed forward:
test_generated_contract_arguments_match_the_live_mcp_signatureswas already red at base —read: live but undocumented ['offset'], from #5184/#5202 adding the parameter. Thereadcontract now documents it.polylogue-nysan — "ten-tool surface" against twelve declared
The count is now derived:
ALL_DECLARED_TOOLScomes fromMCP_TOOL_DECLARATIONS, and the manual renders both its table rows and its spelled count word from that set. Every literal count is gone — renderer (5 sites),spec.pydocstring and fourClientDeliverydeltas,registry.pydocstring,declared_tool_names' own "twelve-tool" docstring,tests/infra/mcp.py,verify_agent_integration.py,cli/commands/agent.py, and thetest_assets_and_cliassertions.record_work_eventandemit_decisiongained real manual contracts with live-signature-exact arguments;MCPToolDeclarationnow carriesresult_semanticsso a tool with no target transaction can still be described, and a new test keeps "outside the target algebra" distinct from "not a tool".Anti-vacuity, executed: adding a 13th
_ToolRowmadedevtools render agent-manual --checkexit 1, failing closed withmissing=['probe_thirteenth']; after adding its contract the manual rendered## The thirteen toolsand "thirteen tools, of which six are available by default". Reverted.docs/atlas/mcp.md's DISCREPANCIES section documented both of these bugs and is now false — rewritten with re-resolved anchors.Verification
Every changed source file is out of the schema-identity closure. No devtools root verb added.
⚠ Overlaps operator work — do not lose it
A branch
docs/mcp-tool-countexists with no commits ahead of master; the actual work is parked instash@{0}("mcp-tool-count-wip", authored by Sinity 2026-09-14) on the same topic as nysan. That stash was not touched, popped, or inspected beyondgit stash list— it is operator WIP and the shared stash stack is unsafe to pop. This PR likely supersedes it, but that is the operator's call to confirm before dropping it.Residual
## Normal invocationsstill renders worked examples for the six default read tools only; the privileged four-plus-two are covered by the table, capability section and contract JSON. Extending worked examples to privileged tools is a separate judgment call, deliberately not made here.🤖 Generated with Claude Code
https://claude.ai/code/session_01DYUNBGoE652b3nfmq3CtqK