feat(mcp): user-initiated correction prompt#7
Merged
Conversation
Structurally enforce that only a user can trigger a memory correction (a belief-axis retraction, not a fact that merely changed) by exposing correct_memory as an MCP Prompt rather than a Tool — prompts are user-controlled by the protocol, so the agent can never invoke one autonomously. The prompt composes the existing remember_context and deprecate_context tools (supersession_reason: "corrected", initiator: "user") and is registered unconditionally for every client, since the underlying tools stay gated by each client's allowedTools. Also expose valid_from/valid_until on remember_context's MCP schema — the service layer already threaded them through metadata, they were just missing from the tool's Zod input schema. Implements INVEST #4 from metacortexplan.md.
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
correct_memory(viaserver.registerPrompt) that structurally enforces the "correction as a user-initiated action" design frommetacortexplan.mdINVEST fix(deploy): catch missing prod alias before functions deploy #4: prompts are user-controlled per the MCP protocol, so the agent can never invoke a correction autonomously the way it can a tool.incorrect_memory_idandcorrected_content(required), plus optionaltopic,valid_from,valid_until(all strings, per the MCP prompt-argument spec), and returns a single user-role message instructing the caller to: (1) callremember_contextwith the corrected content, (2) calldeprecate_contexton the old id withsupersession_reason: "corrected"andinitiator: "user", (3) report both ids back. It's registered unconditionally for every client — the underlyingremember_context/deprecate_contexttools stay gated by each client'sallowedTools.valid_from/valid_until(epoch-ms numbers) to theremember_contexttool's Zod input schema.service.rememberContext()already threaded these through to metadata (from the prior temporal-validity PR feat(memory): temporal validity and supersession reasons #6) — they were just missing from the MCP-facing schema.CLAUDE.md(MCP Prompts section,remember_contextnote,mcpServer.tsline count) andmetacortexplan.md(INVEST fix(deploy): catch missing prod alias before functions deploy #4 status → Implemented 2026-07-11).Test plan
npm --prefix functions run build— compiles cleannpm --prefix functions test— 59/59 passing, 74% overall coverage (≥60% required)mcp.integration.test.ts:prompts/listreturnscorrect_memorywith correctly required/optional argumentsprompts/getwith arguments returns the composed user message embedding all arguments verbatimallowedTools: ["search_context"]), proving unconditional registrationremember_contextacceptsvalid_from/valid_untilover MCP andsearch_context+valid_athonors the stored window (existing tests showbuildPublicMetadata()doesn't surface these fields directly, so behavior is verified functionally, matching the established pattern for the deprecate path)🤖 Generated with Claude Code