feat(mentor): apply/skip fix cards (#25)
CI / ci (push) Canceled after 0s

Fix Cards become actionable. Mechanical cards offer Apply behind a
blocking ask-before sheet showing the exact edit (anchored quote ->
replacement, occurrence + context; empty fix cuts); the sheet is the
only path to a write, one card at a time, no apply-all. The edit
lands through the editing session (pending edits flush first, the
editor re-seeds via adoptText, the card closes applied); Skip and
Done close the card in place, recording nothing; demonstration
cards close Done/Skip only (ADR-0006). Cards arrive ranked
(store-stamped, scan-ordered, open-first palette) and capped at ten
per submit — the app keeps the ranked head and the wire reply
discloses the drop. Stale anchors re-validate at apply: no text
selected or changed, the card flags itself. Includes the
finish-audit round (11 fixes, 2 flip-verified pins); 316 tests
green.

Closes #25
This commit is contained in:
AlexKucera committed 2026-10-20 16:46:43 +02:00
1 parent 5700264628
commit 4d33676a08
15 files changed
+1012 -74

No files matched your search

+21 -7
View File
@@ -131,14 +131,20 @@ nonisolated enum MCPServer {
SubmitArgs.self, from: JSONSerialization.data(withJSONObject: arguments),
)
let written = try FixCardStore.submit(piecePath: args.piecePath, cards: args.cards)
var payload: [String: Any] = [
"cards": written.map {
["file": $0.file, "anchor_status": $0.card.anchorStatus.rawValue]
} as [[String: Any]],
]
// The ceiling backstop tells the truth on the wire (#25 S3.2):
// cards beyond the kept ranked head were dropped — say how many.
if args.cards.count > written.count {
payload["dropped_over_ceiling"] = args.cards.count - written.count
}
return reply(id: id, result: [
"content": [[
"type": "text",
"text": jsonString([
"cards": written.map {
["file": $0.file, "anchor_status": $0.card.anchorStatus.rawValue]
} as [[String: Any]],
]) ?? "{}",
"text": jsonString(payload) ?? "{}",
]] as [[String: Any]],
])
default:
@@ -181,7 +187,9 @@ nonisolated enum MCPServer {
],
[
"name": "submit_fix_cards",
"description": "Persist fix cards for a piece. Anchor-validated against post.md; stale anchors land flagged.",
"description": "Persist fix cards for a piece. Anchor-validated against post.md; "
+ "stale anchors land flagged. At most 10 cards per call — "
+ "the app keeps the ranked head and drops the rest.",
"inputSchema": [
"type": "object",
"properties": [
@@ -191,13 +199,19 @@ nonisolated enum MCPServer {
],
"cards": [
"type": "array",
"description": "Ranked most-important-first; at most 10 per call — "
+ "the app keeps the ranked head and drops the rest.",
"items": [
"type": "object",
"properties": [
"pattern": ["type": "string"],
"problem": ["type": "string"],
"diagnostic_question": ["type": "string"],
"fix": ["type": "string"],
"fix": [
"type": "string",
"description": "Mechanical cards: the exact replacement for the anchored span "
+ "(empty string = cut). Demonstration cards: the demonstration.",
] as [String: Any],
"anchor": [
"type": "object",
"properties": [