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
@@ -19,7 +19,7 @@ extension PostsModel {
|
||||
/// engine's turn ends normally — never on cancel, refusal, or crash,
|
||||
/// and never when fix cards resolve. Passes run in any order
|
||||
/// (advancePassState is monotonic).
|
||||
func runPass(_ kind: PassKind, home: URL, mentor: MentorSessionModel) async {
|
||||
func runPass(_ kind: PassKind, mentor: MentorSessionModel) async {
|
||||
guard runningPass == nil, !runningBlindRead else {
|
||||
lastError = "A pass is already running."
|
||||
return
|
||||
@@ -42,7 +42,8 @@ extension PostsModel {
|
||||
// The pass targets the open Piece: a never-saved draft has no
|
||||
// folder, and the external guest and a held #111 guard ask are
|
||||
// not Pieces.
|
||||
guard let session,
|
||||
guard let home = boundHome,
|
||||
let session,
|
||||
let id = session.postID,
|
||||
id == selectedPostID,
|
||||
draft == nil,
|
||||
@@ -82,12 +83,11 @@ extension PostsModel {
|
||||
guard case let .ended(stopReason) = outcome, stopReason != "refusal" else {
|
||||
return // cancelled / refused / failed — the transcript tells the story
|
||||
}
|
||||
do {
|
||||
// #179: the library-visible write of a completed pass — Pass State
|
||||
// advance — rides the write rail; the snapshot/stats/lint writes
|
||||
// above never do (they don't regroup the library).
|
||||
railWrite {
|
||||
_ = try PostStore.advancePassState(id: id, kind: kind, home: home)
|
||||
lastError = nil
|
||||
Task { await rescan() } // the library regroups by Pass State
|
||||
} catch {
|
||||
lastError = error.localizedDescription
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ extension PostsModel {
|
||||
/// advance, no cards, no Learnings — the verdict and the reveal live in
|
||||
/// the transient transcript and die with it. The writer stays judge of
|
||||
/// record.
|
||||
func blindRead(home: URL, mentor: MentorSessionModel) async {
|
||||
func blindRead(mentor: MentorSessionModel) async {
|
||||
guard runningPass == nil else {
|
||||
lastError = "A pass is already running."
|
||||
return
|
||||
@@ -127,7 +127,8 @@ extension PostsModel {
|
||||
return
|
||||
}
|
||||
// Same open-piece rule as a pass: the read judges ONE saved piece.
|
||||
guard let session,
|
||||
guard let home = boundHome,
|
||||
let session,
|
||||
let id = session.postID,
|
||||
id == selectedPostID,
|
||||
draft == nil,
|
||||
|
||||
Reference in new issue
Block a user