feat(mentor): research & library-light (S8) (#29)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
The mentor researches mid-pass and its findings arrive as candidate
source-notes with provenance inside their Session. A third museion-
tools tool, submit_research_notes, is the typed rail (ADR-0006
posture): decode-validate only, reply {"received": N}, write NOTHING
— the session is the holding area, and keeping is the writer's act.
Candidates ride the transcript as first-class rows (researchNote):
parsed from the tool call's rawInput by payload shape — the notes
array routes before the fix-card parse, titles are display text —
one row per note, all-or-nothing per batch, the wire's whitespace
rule mirrored so both boundaries agree. Resume re-materializes them
for free: replays re-run the same parse; dispositions reset honestly
(they were never persisted — engine-owned cargo, ADR-0007).
The writer curates in place (full cards in the shared transcript, no
palette — a handful curates where it lands): Keep opens the
ask-before sheet (G9; PromoteAskSheet posture — inline refusal,
buttons kept) and ONE confirm lands one plain markdown note with
provenance into the piece's research/ via writeResearchNote — the
one folder(of:) id lookup anchors it inside this Home, a symlinked
research/ refuses, collision -2; Reject vanishes, recording nothing.
The pass stub names the rail and forbids the engine writing
candidates itself; kept notes flip hasResearch, so every later pass
sees the research/ path (S8.3 at v1 depth).
Finish-audit (three reviewers) drove the whitespace-parity and
shape-routing fixes, the ResearchNoteContent dedup, and a poll-loop
fix for the debounce rig's sidecar half that the larger suite's load
had pushed past its fixed sleep — full suite green (373 tests).
Closes #29
This commit is contained in:
1 parent
9895614b7e
commit
b02d36bb5d
22 files changed
+977
-33
No files matched your search
+82
-3
@@ -96,6 +96,10 @@ nonisolated enum MCPServer {
|
||||
}
|
||||
}
|
||||
|
||||
// The dispatcher's body IS the tool catalog — it grows one case per
|
||||
// tool. ponytail: split per-tool handlers out only when a second
|
||||
// dimension (not more tools) forces it.
|
||||
// swiftlint:disable:next function_body_length
|
||||
private static func toolCall(id: Any?, params: [String: Any]) -> String {
|
||||
let name = params["name"] as? String ?? ""
|
||||
let arguments = params["arguments"] as? [String: Any] ?? [:]
|
||||
@@ -147,6 +151,28 @@ nonisolated enum MCPServer {
|
||||
"text": jsonString(payload) ?? "{}",
|
||||
]] as [[String: Any]],
|
||||
])
|
||||
case "submit_research_notes":
|
||||
// #29 (S8.1): the candidates rail — DECODE-VALIDATE ONLY.
|
||||
// Findings are engine-owned cargo in their session; the reply
|
||||
// is a received count, never storage. The ONLY path to disk is
|
||||
// the writer's keep (PostStore.writeResearchNote).
|
||||
let args = try FixCardStore.decoder.decode(
|
||||
ResearchNotesArgs.self, from: JSONSerialization.data(withJSONObject: arguments),
|
||||
)
|
||||
for note in args.notes {
|
||||
guard !note.title.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
throw FixCardStore.CardError(message: "note title must not be empty")
|
||||
}
|
||||
guard !note.url.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty else {
|
||||
throw FixCardStore.CardError(message: "note url must not be empty")
|
||||
}
|
||||
}
|
||||
return reply(id: id, result: [
|
||||
"content": [[
|
||||
"type": "text",
|
||||
"text": jsonString(["received": args.notes.count]) ?? "{}",
|
||||
]] as [[String: Any]],
|
||||
])
|
||||
default:
|
||||
return failure(FixCardStore.CardError(message: "Unknown tool: \(name)"))
|
||||
}
|
||||
@@ -164,11 +190,27 @@ nonisolated enum MCPServer {
|
||||
var cards: [FixCardStore.Input]
|
||||
}
|
||||
|
||||
/// #29 (S8.1): one candidate source-note — quote/note optional on the
|
||||
/// wire (they arrive as "" at the keep write when absent).
|
||||
private struct ResearchNoteArgs: Decodable {
|
||||
var title: String
|
||||
var url: String
|
||||
var quote: String?
|
||||
var note: String?
|
||||
}
|
||||
|
||||
/// #29 (S8.1): the research rail's wire shape — ONE shape, no legacy
|
||||
/// fallback; a missing field fails decode = the trust boundary.
|
||||
private struct ResearchNotesArgs: Decodable {
|
||||
var piecePath: String
|
||||
var notes: [ResearchNoteArgs]
|
||||
}
|
||||
|
||||
// MARK: - Tools
|
||||
|
||||
/// The two tools (#23). The submit schema IS the fix-card schema
|
||||
/// (ADR-0006): it serves the card UI, the apply-write, and learning
|
||||
/// promotion.
|
||||
/// The tools (#23 cards + learnings; #29 the research rail). The submit
|
||||
/// schema IS the fix-card schema (ADR-0006): it serves the card UI, the
|
||||
/// apply-write, and learning promotion.
|
||||
private static var tools: [[String: Any]] {
|
||||
[
|
||||
[
|
||||
@@ -252,6 +294,43 @@ nonisolated enum MCPServer {
|
||||
"required": ["piece_path", "cards"],
|
||||
] as [String: Any],
|
||||
],
|
||||
[
|
||||
"name": "submit_research_notes",
|
||||
"description": "Deliver research findings as candidate source-notes for a piece — "
|
||||
+ "candidates only: the notes arrive in the session, nothing is written to disk. "
|
||||
+ "The writer keeps or rejects each note in Museion; keeping writes the plain "
|
||||
+ "markdown note (with provenance) into the piece's research/ folder.",
|
||||
"inputSchema": [
|
||||
"type": "object",
|
||||
"properties": [
|
||||
"piece_path": [
|
||||
"type": "string",
|
||||
"description": "Path to the piece folder or its post.md.",
|
||||
],
|
||||
"notes": [
|
||||
"type": "array",
|
||||
"description": "Candidate source-notes with provenance.",
|
||||
"items": [
|
||||
"type": "object",
|
||||
"properties": [
|
||||
"title": ["type": "string"],
|
||||
"url": ["type": "string"],
|
||||
"quote": [
|
||||
"type": "string",
|
||||
"description": "Verbatim quotation from the source, when there is one.",
|
||||
],
|
||||
"note": [
|
||||
"type": "string",
|
||||
"description": "The finding — why this source matters to the piece.",
|
||||
],
|
||||
] as [String: Any],
|
||||
"required": ["title", "url"],
|
||||
] as [String: Any],
|
||||
] as [String: Any],
|
||||
] as [String: Any],
|
||||
"required": ["piece_path", "notes"],
|
||||
] as [String: Any],
|
||||
],
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user