feat(mentor): research & library-light (S8) (#29)
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:
AlexKucera committed 2026-10-22 14:06:16 +02:00
1 parent 9895614b7e
commit b02d36bb5d
22 files changed
+977 -33

No files matched your search

+112 -1
View File
@@ -19,6 +19,21 @@ struct SessionTranscriptView: View {
/// Raw session/tool rows, collapsed thinking, and live thinking render
/// only when on — the model keeps every row either way.
var showsDebugRows = false
/// #29 (S8.3): the Home a kept research note lands in — nil (previews)
/// hides the candidate card's Keep/Reject buttons.
var home: URL?
/// The ask-before keep (#29 G9): ONE blocking confirm per candidate,
/// presented over the transcript — never inside a lazy row.
@State private var pendingKeep: PendingKeep?
private struct PendingKeep: Identifiable {
let rowID: UUID
let candidate: ResearchCandidate
var id: UUID {
rowID
}
}
var body: some View {
ScrollView {
@@ -46,6 +61,11 @@ struct SessionTranscriptView: View {
// #24 fix: programmatic scrollTo raced the growing lazy rows and
// mislanded at the TOP; the native bottom anchor needs no scroll code.
.defaultScrollAnchor(.bottom)
.sheet(item: $pendingKeep) { pending in
if let home {
ResearchKeepSheet(model: model, rowID: pending.rowID, candidate: pending.candidate, home: home)
}
}
}
/// The writing-session filter: prose + card events stay; raw rows and
@@ -53,7 +73,7 @@ struct SessionTranscriptView: View {
/// any context.
nonisolated static func isWritingRow(_ row: SessionRow) -> Bool {
switch row.content {
case .text, .fixCard: true
case .text, .fixCard, .researchNote: true
case .thought, .raw: false
}
}
@@ -69,6 +89,13 @@ struct SessionTranscriptView: View {
// #23 follow-up: detail lives in the palette window — the
// transcript keeps a one-line event, not the card.
FixCardEventRow(pattern: card.pattern)
case let .researchNote(candidate):
ResearchNoteRow(
candidate: candidate,
actions: home != nil,
keep: { pendingKeep = PendingKeep(rowID: row.id, candidate: candidate) },
reject: { model.setResearchDisposition(rowID: row.id, .rejected) },
)
case let .raw(kind, json):
RawUpdateRow(kind: kind, json: json)
}
@@ -93,6 +120,61 @@ struct SessionTranscriptView: View {
}
}
/// #29 (S8.3): one candidate research-note card — serif title, mono
/// muted url, selectable note, muted-italic quote. Pending offers Keep
/// (ask-before) + Reject (no confirm — vanishes, nothing recorded);
/// kept/rejected dim 0.45 (closed-card voice) with their meta line.
private struct ResearchNoteRow: View {
let candidate: ResearchCandidate
let actions: Bool
let keep: () -> Void
let reject: () -> Void
var body: some View {
VStack(alignment: .leading, spacing: 6) {
ResearchNoteContent(candidate: candidate)
dispositionView
}
.frame(maxWidth: .infinity, alignment: .leading)
.opacity(dimmed)
}
@ViewBuilder
private var dispositionView: some View {
switch candidate.disposition {
case .pending:
if actions {
HStack(spacing: 8) {
Button("Keep", action: keep)
.buttonStyle(.bordered)
.controlSize(.small)
.font(.system(size: 11, design: DesignTokens.mono))
.help("Land this note in the piece's research/ folder")
Button("Reject", action: reject)
.buttonStyle(.bordered)
.controlSize(.small)
.font(.system(size: 11, design: DesignTokens.mono))
.help("Vanish the candidate — nothing is recorded")
}
}
case let .kept(fileName):
meta("kept · research/\(fileName)")
case .rejected:
meta("rejected")
}
}
private var dimmed: Double {
candidate.disposition == .pending ? 1 : 0.45
}
private func meta(_ text: String) -> some View {
Text(text)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
}
}
/// #24 fix: the engine's thinking, collapsed — a pass's thought stream
/// runs to hundreds of lines and is not the critique.
private struct ThoughtRow: View {
@@ -132,6 +214,35 @@ struct SessionTranscriptView: View {
}
}
/// #29 audit: the candidate's content block — title/url/note/quote — shared
/// by the transcript row and the keep sheet's preview, so a restyle edits
/// one place. File scope: ResearchKeepSheet reuses it.
struct ResearchNoteContent: View {
let candidate: ResearchCandidate
var body: some View {
VStack(alignment: .leading, spacing: 6) {
Text(candidate.title)
.font(.system(size: 13, design: DesignTokens.serif))
Text(candidate.url)
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.lineLimit(1)
.truncationMode(.middle)
if !candidate.note.isEmpty {
Text(candidate.note)
.textSelection(.enabled)
}
if !candidate.quote.isEmpty {
Text("“\(candidate.quote)”")
.italic()
.foregroundStyle(DesignTokens.muted)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}
#Preview {
SessionsPaneView(model: MentorSessionModel(), posts: nil, binaryPath: nil)
}