refactor(posts): route every library write through the write rail (#179)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
One internal seam (PostsModelRail.swift) now pairs every library verb store write with exactly one library rescan and owns the error strip: saveDraft, newPostFromSession, rename, trash, createProject, moveToProject, archivePost, restorePost, unarchiveProject, importFiles, convertToPost, and runPass pass-state advance (12 sites on this base; the pass snapshot/stats writes, the publish stamp, and the editor flush stay outside by design). The model owns the Home: boundHome is set by bind() alone (app construction + Settings repoint); every public verb lost its home: parameter (create post/outline/session-born, rename, move, archive, restore, trash, convert, project creation, import, select, cards, passes, blind read, publish). The three rail entries are railWrite/railWriteReturningReason/ railWriteKeepingStrip — deliberately NOT overloads: a shared base name let unlabeled trailing-closure calls resolve into the labeled non-generic entry (Swift binds trailing closures to labeled first parameters), silently bypassing the strip and the pairing. Views + 11 test files swept to the homeless signatures (160 sites). RED suite green: 3/3. Full unit suite: 654/654. Fixes #179
This commit is contained in:
1 parent
8c5ceffa3c
commit
06283b6287
23 files changed
+364
-363
No files matched your search
@@ -51,7 +51,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
let chatBefore = rig.mentor.host.chat
|
||||
let rosterBefore = rig.mentor.roster.count
|
||||
let post = try PostStore.writeNew(body: "# Own Engine\n\nVerdict me.", home: rig.home)
|
||||
rig.model.select(post.id, home: rig.home)
|
||||
rig.model.select(post.id)
|
||||
for _ in 0 ..< 250 where !rig.model.posts.contains(where: { $0.id == post.id }) {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
// In a Task — a full-mode scripted pass can complete inside one poll
|
||||
// sleep (no child-process latency anymore), so the pass ENGINE is
|
||||
// captured after the run from the spawn records, not polled mid-flight.
|
||||
let run = Task { await rig.model.runPass(.pass1, home: rig.home, mentor: rig.mentor) }
|
||||
let run = Task { await rig.model.runPass(.pass1, mentor: rig.mentor) }
|
||||
_ = await run.value
|
||||
let passEngine = rig.engines.engines.last { $0.spawnedProfile == "museion-pass1" }
|
||||
let passEngineClosed = try #require(passEngine, "pass engine never spawned")
|
||||
@@ -104,9 +104,9 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
await rig.mentor.openSession()
|
||||
let rosterBefore = rig.mentor.roster.count
|
||||
let post = try PostStore.writeNew(body: "# Held Pass\n\nCancel me.", home: rig.home)
|
||||
rig.model.select(post.id, home: rig.home)
|
||||
rig.model.select(post.id)
|
||||
|
||||
let run = Task { await rig.model.runPass(.pass1, home: rig.home, mentor: rig.mentor) }
|
||||
let run = Task { await rig.model.runPass(.pass1, mentor: rig.mentor) }
|
||||
let heldEngine = try #require(await pollOneShot(of: rig.mentor), "pass engine never spawned")
|
||||
#expect(rig.mentor.isPassEngineRunning)
|
||||
|
||||
@@ -291,7 +291,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
rig.mentor.passReadinessWriter = writer
|
||||
await rig.mentor.refreshPassReadiness()
|
||||
let post = try PostStore.writeNew(body: "# No Key\n\nPass me.", home: rig.home)
|
||||
rig.model.select(post.id, home: rig.home)
|
||||
rig.model.select(post.id)
|
||||
for _ in 0 ..< 250 where rig.model.session?.postID != post.id {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
@@ -299,7 +299,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
// this pin vacuously.
|
||||
try #require(rig.model.session?.postID == post.id)
|
||||
|
||||
await rig.model.runPass(.pass1, home: rig.home, mentor: rig.mentor)
|
||||
await rig.model.runPass(.pass1, mentor: rig.mentor)
|
||||
|
||||
#expect(rig.model.lastError == "Pass 1 needs a z.ai API key — add it in Settings → Provider Keys.")
|
||||
let piece = rig.home.appendingPathComponent("projects/posts/\(post.id)")
|
||||
@@ -320,7 +320,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
_ = await rig.mentor.newSession(name: "Second", pieceTitle: nil) // sess-2 active
|
||||
let target = try #require(rig.mentor.roster.last) // sess-1, NOT active
|
||||
let post = try PostStore.writeNew(body: "# Held Load\n\nResume races a pass.", home: rig.home)
|
||||
rig.model.select(post.id, home: rig.home)
|
||||
rig.model.select(post.id)
|
||||
for _ in 0 ..< 250 where !rig.model.posts.contains(where: { $0.id == post.id }) {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
@@ -338,7 +338,7 @@ private func pollOneShot(of mentor: MentorSessionModel) async throws -> Scripted
|
||||
// pass prompt then HOLDS, so isStreaming is guaranteed when the parked
|
||||
// load completes, and the #124 Cancel rail frees it afterwards.
|
||||
rig.engines.mode = "hangOnPrompt"
|
||||
let run = Task { await rig.model.runPass(.pass1, home: rig.home, mentor: rig.mentor) }
|
||||
let run = Task { await rig.model.runPass(.pass1, mentor: rig.mentor) }
|
||||
for _ in 0 ..< 250 where !rig.mentor.isPassEngineRunning {
|
||||
try await Task.sleep(nanoseconds: 20_000_000)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user