Repository navigation
Keep a decision linked when a document rewrite leaves its text unchanged - #664
Merged
Merged
Conversation
A whole-document rewrite through MCP update_document marked every answered decision's link as waiting for review, even when the blocks it pointed at were unchanged. Only a Planner turn's anchor_plan clears that state, MCP has no tool for it, and the automatic re-link turn runs only after a build, so answered Decision cards showed "Not linked yet" and lost "Show in document" after any later rewrite. A rewrite now keeps a link reviewed when it was reviewed before, points at one or more blocks, and every one of those blocks still exists with the same digest. A link whose text changed or was removed, one already waiting for review, and a deliberately unlinked decision wait for review as before. edit_plan is unchanged. Assistant-model: Claude Opus 5.5 (fast) Assistant-workflow: inline (fast subagents) Assistant-verification: red-before-fix: rewrite-links.test.ts "a rewrite that leaves a decision's blocks alone keeps its link reviewed" failed on the unfixed server (pending true); mcp-update.e2e.ts "an MCP rewrite of other prose keeps a linked decision's way to the document" failed on the unfixed server (the card showed "Not linked yet") Assistant-verification: after fix: bun test apps/server packages apps/web passed (5779 pass, 0 fail); bun run types and bun run ci passed; mcp-update, sidecar-card-states, decision-marker, decision-anchor-stress and sidecar e2e passed (83) Co-authored-by: Alex Lavaee <alexlavaee@microsoft.com>
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.
What was wrong
A whole-document rewrite through MCP
update_document(Plan.rewrite) calledQuestions.invalidate(..., "plan_changed"), which setpending: trueon every answered decision's link, even when the blocks the link pointed at were unchanged. Only a Planner turn'sanchor_planclearspending. MCP has no tool for it, and the automatic re-link turn runs only after a build. As a result, answered Decision cards showed "Not linked yet" and lost "Show in document" after any later rewrite. A hosted end-to-end run found this.Change
Plan.rewritenow takes a snapshot of each decision's links before it replaces the document. After the replace, a link stays reviewed only when all of these hold:Every other link still goes back to waiting for review, as before. That covers a link whose text changed, a link whose text was removed (it still shows "Related text was removed"), a link that was already waiting for review, and a decision that was deliberately left unlinked.
edit_planand comments are unchanged, and so is the connector. The MCP guide now says what happens to decision links after an update.Tests
apps/server/src/questions/rewrite-links.test.ts:e2e/mcp-update.e2e.ts: an answered, linked card still offers "Show in document" after an MCP rewrite of other text, including after a reload. This test failed before the fix: the card showed "Not linked yet".Run locally:
bun test apps/server packages apps/web,bun run types,bun run ci, and the mcp-update, sidecar-card-states, decision-marker, decision-anchor-stress and sidecar browser suites (83 passed).