feat(mentor): apply/skip fix cards (#25)
CI / ci (push) Canceled after 0s
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:
1 parent
5700264628
commit
4d33676a08
15 files changed
+1012
-74
No files matched your search
@@ -102,14 +102,21 @@ struct MCPServerWireTests {
|
||||
#expect(try #require(querySchema["required"] as? [String]) == ["piece_path"])
|
||||
}
|
||||
|
||||
@Test func `submit and query round trip through the wire`() throws {
|
||||
/// One throwaway wire piece: home + `projects/posts/<name>/post.md`
|
||||
/// (the round-trip test adds its learnings dir on top).
|
||||
private func seedWirePiece(_ name: String) throws -> (home: URL, piece: URL) {
|
||||
let home = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("mcp-wire-\(UUID().uuidString)", isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
|
||||
let piece = home.appendingPathComponent("projects/posts/test-piece", isDirectory: true)
|
||||
let piece = home.appendingPathComponent("projects/posts/\(name)", isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: piece, withIntermediateDirectories: true)
|
||||
try "---\ntype: post\n---\nThe repeated anchor line.\n"
|
||||
.write(to: piece.appendingPathComponent("post.md"), atomically: true, encoding: .utf8)
|
||||
return (home, piece)
|
||||
}
|
||||
|
||||
@Test func `submit and query round trip through the wire`() throws {
|
||||
let (home, piece) = try seedWirePiece("test-piece")
|
||||
let learnings = home.appendingPathComponent("learnings/posts", isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: learnings, withIntermediateDirectories: true)
|
||||
try "wire learning".write(to: learnings.appendingPathComponent("l.md"), atomically: true, encoding: .utf8)
|
||||
@@ -180,4 +187,41 @@ struct MCPServerWireTests {
|
||||
#expect(error["code"] as? Int == -32700)
|
||||
#expect(replies[0]["id"] is NSNull)
|
||||
}
|
||||
|
||||
/// #25 (S3.2): the ceiling backstop is honest on the wire — 11 valid cards
|
||||
/// submit, the ranked head (10) lands on disk, the reply says one dropped.
|
||||
@Test func `submit over the ceiling drops the tail and reports it`() throws {
|
||||
let (_, piece) = try seedWirePiece("ceiling-piece")
|
||||
|
||||
let cards = (1 ... 11).map { index in
|
||||
[
|
||||
"pattern": "Pattern \(index)",
|
||||
"problem": "The problem \(index).",
|
||||
"anchor": ["quote": "repeated anchor line"],
|
||||
"lane": "mechanical",
|
||||
"emitter": "lint",
|
||||
] as [String: Any]
|
||||
}
|
||||
let request: [String: Any] = [
|
||||
"jsonrpc": "2.0",
|
||||
"id": 12,
|
||||
"method": "tools/call",
|
||||
"params": ["name": "submit_fix_cards", "arguments": ["piece_path": piece.path, "cards": cards] as [String: Any]],
|
||||
]
|
||||
let line = try #require(String(data: JSONSerialization.data(withJSONObject: request), encoding: .utf8))
|
||||
|
||||
let replies = try runWire([line])
|
||||
let result = try #require(replies[0]["result"] as? [String: Any])
|
||||
#expect(result["isError"] == nil)
|
||||
let payload = try #require(
|
||||
try JSONSerialization.jsonObject(with: Data(toolText(result).utf8)) as? [String: Any],
|
||||
)
|
||||
let landed = try #require(payload["cards"] as? [[String: Any]])
|
||||
#expect(landed.count == 10)
|
||||
#expect(payload["dropped_over_ceiling"] as? Int == 1)
|
||||
let onDisk = ((try? FileManager.default.contentsOfDirectory(
|
||||
atPath: piece.appendingPathComponent("cards").path,
|
||||
)) ?? []).filter { $0.hasSuffix(".json") }
|
||||
#expect(onDisk.count == 10)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user