CI / ci (push) Canceled after 0s
SessionRow text rows carry (body, speaker, notice) as data — agent/
user/system plus refused/interrupted/connectionLost/kickoff/failed/
plain — typed at every append site; no stored row holds a speaker
prefix (pinned). The two wire-only classifications are sniffed once at
the append seam: a replayed pass kick-off ('Pass Pass N…') and the
engine's 'Operation interrupted:' notice. The transcript view, the
writing-session filter, and the New Post prefill switch on typed data;
rendering is identical (refusal/connection-lost rows stay agent prose
by pinned render).
Fix Card and Research Note payloads decode through one shared
ToolPayloads decoder: lenient for the transcript rail (both the nested
card-rail shape and the flat #14-era fake kept), strict for the
museion-tools MCP trust boundary with named CardErrors. Three
intentional wire tightenings at the strict entry: empty cards/notes
arrays throw instead of no-op succeeding, the camelCase
diagnosticQuestion alias is rejected (schema is snake_case), and
decode failures answer short named errors instead of DecodingError
dumps. quote/note type parity restored (present-but-wrong-type throws).
Every wire-shape fact is pinned in ToolPayloadsTests.
Full suite 653/653, swiftformat/swiftlint clean. Audit flip-verified.
Closes #177
84 lines
3.6 KiB
Swift
84 lines
3.6 KiB
Swift
//
|
|
// TranscriptRailTests.swift
|
|
// MuseionTests
|
|
//
|
|
// #177 (S2): the typed transcript rail's pins, own file — ACPClientTests
|
|
// crossed its type-body ceiling with them (MCPToolsPromoteTests split
|
|
// precedent; the shared fake-ACP helpers stay in ACPClientTests).
|
|
//
|
|
// ## Scenario: typed transcript rail (mirror — source: MentorSessionModel.swift)
|
|
// From #177
|
|
//
|
|
// Given a session transcript built from live turns and engine replay
|
|
// When rows are appended
|
|
// Then every text row carries its speaker and notice as data — no stored row
|
|
// holds a "Mentor: "/"You: " prefix — the replayed pass kick-off is typed at
|
|
// the append seam, and the transcript view, writing-session filter, and New
|
|
// Post prefill switch on typed data with identical rendering.
|
|
//
|
|
|
|
import Foundation
|
|
@testable import Museion
|
|
import Testing
|
|
|
|
struct TranscriptRailTests {
|
|
/// #177 (S2): the typed rail's type-fact pins, driven through the fake
|
|
/// ACP — a completed turn's rows carry speaker and notice as data: the
|
|
/// prompt renders as the user row (unprefixed), the streamed reply as
|
|
/// agent conversation, and NO stored body holds a speaker prefix.
|
|
@MainActor
|
|
@Test func `completed turn types rows and stores no speaker prefix`() async {
|
|
let fake = makeFakeACP(at: acpTempDir("typed-turn"))
|
|
let model = MentorSessionModel(binaryPath: fake)
|
|
defer { model.shutdown() }
|
|
await model.openSession()
|
|
await model.sendPrompt("hello mentor")
|
|
#expect(model.rows.contains { row in
|
|
row.content == .text("hello mentor", .user, .plain)
|
|
})
|
|
#expect(model.rows.contains { row in
|
|
row.content == .text("Hello mentor.", .agent, .plain)
|
|
})
|
|
// The scenario's core invariant: prefixes are display-only, never stored.
|
|
#expect(!model.rows.contains { row in
|
|
if case let .text(body, _, _) = row.content {
|
|
return body.hasPrefix("Mentor: ") || body.hasPrefix("You: ")
|
|
}
|
|
return false
|
|
})
|
|
}
|
|
|
|
/// #177 (S2): the refusal mode lands the typed refusal row — agent voice
|
|
/// with a .refused notice (renders serif prose; pure consumers exclude it
|
|
/// by data).
|
|
@MainActor
|
|
@Test func `refusal mode lands the typed agent refusal row`() async {
|
|
let fake = makeFakeACP(at: acpTempDir("typed-refusal"), mode: "refuseOnPrompt")
|
|
let model = MentorSessionModel(binaryPath: fake)
|
|
defer { model.shutdown() }
|
|
await model.openSession()
|
|
let outcome = await model.sendPrompt("hello mentor")
|
|
#expect(outcome == .ended(stopReason: "refusal"))
|
|
#expect(model.rows.contains { row in
|
|
row.content == .text("(refused the prompt)", .agent, .refused)
|
|
})
|
|
}
|
|
|
|
/// #177 (S2): the append seam's pure classifiers — the pass kick-off
|
|
/// sniff (moved to the model) and the shared agent-text sniff.
|
|
@Test func `append seam classifiers type kickoff and interrupted bodies`() {
|
|
#expect(MentorSessionModel.isPassKickoff("Pass Pass 1 — bold. The rest of the prompt."))
|
|
#expect(!MentorSessionModel.isPassKickoff("Pass 1 — bold"))
|
|
#expect(!MentorSessionModel.isPassKickoff("an ordinary ask"))
|
|
// The replayed user turn's append seam: a kick-off body lands
|
|
// (.system, .kickoff); any other body (.user, .plain).
|
|
#expect(MentorSessionModel.replayedUserContent("Pass Pass 1 — bold.\nThe rest.")
|
|
== .text("Pass Pass 1 — bold.\nThe rest.", .system, .kickoff))
|
|
#expect(MentorSessionModel.replayedUserContent("an ordinary ask") == .text("an ordinary ask", .user, .plain))
|
|
#expect(MentorSessionModel.agentSpeakerNotice("Operation interrupted: waiting for model response (61.6s elapsed).")
|
|
== (speaker: .system, notice: .interrupted))
|
|
#expect(MentorSessionModel.agentSpeakerNotice("The opening earns its place.")
|
|
== (speaker: .agent, notice: .plain))
|
|
}
|
|
}
|