feat(sessions): new post from session & drills (S2.7-8) (#30)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
A freeform Session births a Post. "New Post" in the Sessions pane opens an ask-before sheet prefilled with the session's last mentor reply (editable, G9); ONE confirm materializes the piece under projects/posts/ stamped origin: ai - immutable frontmatter, never stats-eligible - and opens it in Posts; a failed write keeps the sheet up with the reason inline and the draft intact. writeNew gains an origin parameter (additive default .writer, every existing caller compiles). "New Brainstorm" is a session started with an opener prompt - no new machinery (beginBrainstormSession over the normal new+prompt rails). The freeform composer (input, liveness, Stop) moved from MentorPaneView into the shared SessionTranscriptView: one conversation surface, two panes - the Sessions pane stops being a read-only transcript. Drill offers (S2.8) wire as one pass-persona section (v1.4): the seeded micro-drill doctrine owns the motivation moment, the two-minute bound, the single shelf, and the vanish - session flavor, no machinery beyond S2.3. Resume now speaks the real adapter wire. Live-probed against the engine: 0.21.5 answers session/load with the id at _meta.hermes.sessionProvenance.acpSessionId and NO top-level sessionId - resumeSession accepts both shapes; every prior real-engine resume misread as "engine does not know this session". The fake ACP server answers load in the real shape (a loadReplayLegacy knob pins the older contract), so the whole resume suite guards the live wire. New pins: draft-candidate extraction (last mentor row wins; thought/ card/research/raw lanes and refusal/connection rows never prefill), ai-stamp write + immutability through overwrite, brainstorm roster + labeled opener, legacy-shape resume. Finish-audit (three reviewers, parallel) converged on the confirm() dismissal that destroyed the edited draft on a failed write - fixed with sheet-local error state (stale-refusal re-show dies with the presentation) - and surfaced the missing brainstorm and legacy-shape pins; the resume fix was flip-verified (removing the provenance fallback fails the provenance pins). Full suite green (379 tests). Closes #30
This commit is contained in:
1 parent
b02d36bb5d
commit
ae234350ef
16 files changed
+521
-128
No files matched your search
@@ -150,6 +150,49 @@ private func readPost(_ home: URL, _ id: String) throws -> String {
|
||||
#expect(try readPost(home, post.id).hasPrefix("---\ntype: post\n"))
|
||||
}
|
||||
|
||||
// Scenario: New Post from Session — from #30 (S2.7). Given a freeform
|
||||
// session whose transcript holds mentor text, when the writer picks
|
||||
// "New Post from Session" and confirms the ask sheet, then a piece folder
|
||||
// materializes under projects/posts/ with the draft body and origin: ai
|
||||
// stamped, and Museion opens the piece in Posts.
|
||||
@Test func `writeNew origin ai stamps the session-born piece and scans back`() throws {
|
||||
let home = try storeHome()
|
||||
let post = try PostStore.writeNew(
|
||||
body: "# From the Session\n\nMentor text becomes the draft.",
|
||||
origin: .ai,
|
||||
home: home,
|
||||
)
|
||||
|
||||
#expect(post.origin == .ai)
|
||||
#expect(post.id == "from-the-session")
|
||||
#expect(post.project == Post.defaultProject) // default posts/ landing
|
||||
#expect(post.passState == .firstDraft)
|
||||
#expect(try readPost(home, post.id)
|
||||
== "---\ntype: post\npass_state: First Draft\norigin: ai\n---\n# From the Session\n\nMentor text becomes the draft.")
|
||||
|
||||
// The #17 reader reads it back as an ai piece.
|
||||
let scanned = try #require(Post.scan(home: home).first)
|
||||
#expect(scanned.origin == .ai)
|
||||
}
|
||||
|
||||
@Test func `writeNew default origin stays writer for existing callers`() throws {
|
||||
let home = try storeHome()
|
||||
// #30: the additive parameter — saveDraft's call shape is unchanged.
|
||||
let post = try PostStore.writeNew(body: "# Plain\n", home: home)
|
||||
#expect(post.origin == .writer)
|
||||
#expect(try readPost(home, post.id).contains("origin: writer"))
|
||||
}
|
||||
|
||||
@Test func `a session-born ai piece keeps origin ai through overwrite`() throws {
|
||||
// #30: immutability is the AC — the save path preserves the ai stamp.
|
||||
let home = try storeHome()
|
||||
let post = try PostStore.writeNew(body: "# From the Session\n\nv1", origin: .ai, home: home)
|
||||
try PostStore.overwrite(id: post.id, body: "# From the Session\n\nedited v2", home: home)
|
||||
let scanned = try #require(Post.scan(home: home).first)
|
||||
#expect(scanned.origin == .ai)
|
||||
#expect(try readPost(home, post.id).contains("origin: ai\n"))
|
||||
}
|
||||
|
||||
@Test func `rename retitles moves folder and keeps frontmatter`() throws {
|
||||
let home = try storeHome()
|
||||
let original = try PostStore.writeNew(body: "# Old Name\n\nBody.", home: home)
|
||||
|
||||
Reference in new issue
Block a user