museion/postsmodel-write-rail: one seam pairs every library write with the rescan (#179) #185

Closed
AlexKucera wants to merge 4 commits from fix/postsmodel-write-rail into main
pull from: fix/postsmodel-write-rail
Owner

Closes #179

Finding — museion/postsmodel-write-rail

Ticket #179 (2026-11-09 architecture review, content line step 1 of 2): every library verb hand-copied the same write-then-rescan-then-strip choreography — ~a dozen sites on base 627ecf5 (saveDraft, newPostFromSession, rename, trash, createProject, moveToProject, archivePost, restorePost, unarchiveProject, importFiles, convertToPost, runPass's pass-state advance). Every future copy is a silent stale-library bug: a verb whose write loses its paired rescan (or doubles it) ships invisibly. PostsModel also threaded a home: parameter through every public verb although the model already owns exactly one Home (the watcher's).

Evidence at base 627ecf5: Task { await rescan() } appeared in 12 verb bodies across Museion/PostsModel.swift, PostsModelOutline.swift, PostsModelPasses.swift, each paired by hand with lastError = nil / lastError = error.localizedDescription.

Fix (branch fix/postsmodel-write-rail, 627ecf5..3bef1d1)

  • New Museion/PostsModelRail.swift — ONE seam, three NAMED routings: railWrite (strip-routed default: success clears the strip + pairs exactly one rescan; a throw routes localizedDescription into the strip), railWriteReturningReason (createProject — the sheet owns its inline reason, the strip behind it must not double-message), railWriteKeepingStrip (importFiles — per-file failures continue inside the op, the strip keeps the verb's own message, ONE paired rescan for the whole batch). The pairing is pinned once in pairRailRescan. Observability: PostsModelRailEvent (.write / .pairedRescan / .writeFailed) through onRailEvent, nil in production. Deliberately NOT overloads: a shared base name let unlabeled trailing-closure calls silently resolve to the reason-returning path (found live by the trash-twice failure pin) — distinct names make the routing unambiguous at every call site.
  • 12 write sites routed. Deliberate exclusions: pass-substrate snapshotPass/stats writes (never library-regrouping), stampMicropubURL (wire-owned, deliberately quiet), writeResearchNote (mentor-owned research/), ingestImage (assets/), and the editor flush overwrite (the ticket's own exclusion — editor-owned error semantics).
  • The model owns the Home — watchedHome became private(set) var boundHome, set by bind(home:) alone (app construction + Settings repoint); every public verb dropped its home: parameter. Views + 11 test files swept (160 call sites).
  • Intended behavior deltas, AC-pinned: createProject now pairs one rescan on success (an empty-folder scan — no visible change); importFiles' trailing unconditional rescan became the rail's paired one (identical). Everything else byte-equivalent.
  • Post-refactor invariant: Task { await rescan() } exists at exactly two sites in Museion/ — bind's initial scan and the rail's pairRailRescan.

New tests — MuseionTests/PostsModelWriteRailTests.swift

Three pins: every write verb records exactly [.write, .pairedRescan] (incl. the runPass advance over the scripted-engine rig); a failed write rides once as [.write, .writeFailed] with no paired rescan, strip owning the reason. RED first at 8c5ceff (nothing rode the seam), GREEN at 06283b6.

Verify — independently re-run by reviewer @athena (04:07–04:16 CET, own clone)

  • RED @ 8c5ceff: xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' build-for-testing → ** TEST BUILD SUCCEEDED **; test-without-building -only-testing:MuseionTests/PostsModelWriteRailTests → executed 3 / passed 0 / failed 3 — xcresult failureText confirms events → [] at every verb.
  • GREEN @ branch head 3bef1d1: same two commands → executed 3 / passed 3 / failed 0.
  • Full unit suite: test-without-building -only-testing:MuseionTests → executed 654 / passed 654 / failed 0 / skipped 0 (result: Passed; xcresult Test-Museion-2026.11.10_04-10-31-+0100; main's 651 + the 3 new pins). EditorSessionTests debounce flake did not fire.
  • swiftformat --lint . → 0/135 files require formatting. swiftlint → 279 violations / 60 serious — identical counts to base main 627ecf5 (279/60 in 133 files; the branch's two new files add zero).
  • Reviewer seat machine state: testmanagerd clean (the handoff's wedge did not reproduce); whole-target filter used throughout (a targeted rail-suite filter with backticks/spaces matched zero tests at the implementer's seat — the backtick-free spelling dispatched 3 non-zero cases here).

Unverified — keyed museion/postsmodel-write-rail

  • UITests target not run (unit suite is the gate; the UITests-Runner automation-mode wedge is the known machine-state baseline) — both implementer and reviewer.
  • GitNexus figures (pre-edit impact PostsModel = CRITICAL, 144 upstream — the panes + rigs this refactor sweeps, acknowledged; post-edit detect-changes = 23 files / 79 symbols / 81 flows, all in the expected verb surface) are the implementer's run, quoted not re-run — the reviewer made no repo edits.
  • The "160 call sites" sweep count is compiler-certified (any missed site fails the build) but not hand-recounted.

Implementer disclosures (verbatim, @daedalus)

  1. "testmanagerd was wedged on slot arrival (stuck _XCT_enableAutomationModeWithReply transactions) — kill -9 + launchd respawn cleared it; if hosted tests hang at automation-mode init at your seat, that's machine state, not the branch."
  2. "Suite-member -only-testing filters containing backticks/spaces matched ZERO tests and "passed" vacuously (exit 0, empty counts) — the whole-target filter -only-testing:MuseionTests is the reliable spelling."
  3. Analyzer's self-written AGENTS.md counter delta from the GitNexus run was reverted, not committed.

Owner apply (AGENTS.md counter patch — staged, consent timed out in the night slot)

git apply ~/daedalus-builds/museion/brief-14-agentsmd-owner-apply.patch

git apply --check CLEAN against branch head 3bef1d1 (touches Museion/AGENTS.md, MuseionTests/AGENTS.md, AGENTS.md — 3 counter lines).

Scope notes

  • Disjoint from open PR #184 (brief-13): zero file overlap; both branch off 627ecf5.
  • museion/library-search-stale-after-mutation is a separate menu item GATED ON THIS PR's merge — intentionally untouched here.
Closes #179 ## Finding — museion/postsmodel-write-rail Ticket #179 (2026-11-09 architecture review, content line step 1 of 2): every library verb hand-copied the same write-then-rescan-then-strip choreography — ~a dozen sites on base 627ecf5 (saveDraft, newPostFromSession, rename, trash, createProject, moveToProject, archivePost, restorePost, unarchiveProject, importFiles, convertToPost, runPass's pass-state advance). Every future copy is a silent stale-library bug: a verb whose write loses its paired rescan (or doubles it) ships invisibly. PostsModel also threaded a `home:` parameter through every public verb although the model already owns exactly one Home (the watcher's). Evidence at base 627ecf5: `Task { await rescan() }` appeared in 12 verb bodies across Museion/PostsModel.swift, PostsModelOutline.swift, PostsModelPasses.swift, each paired by hand with `lastError = nil` / `lastError = error.localizedDescription`. ## Fix (branch fix/postsmodel-write-rail, 627ecf5..3bef1d1) - **New `Museion/PostsModelRail.swift`** — ONE seam, three NAMED routings: `railWrite` (strip-routed default: success clears the strip + pairs exactly one rescan; a throw routes `localizedDescription` into the strip), `railWriteReturningReason` (createProject — the sheet owns its inline reason, the strip behind it must not double-message), `railWriteKeepingStrip` (importFiles — per-file failures continue inside the op, the strip keeps the verb's own message, ONE paired rescan for the whole batch). The pairing is pinned once in `pairRailRescan`. Observability: `PostsModelRailEvent` (.write / .pairedRescan / .writeFailed) through `onRailEvent`, nil in production. Deliberately NOT overloads: a shared base name let unlabeled trailing-closure calls silently resolve to the reason-returning path (found live by the trash-twice failure pin) — distinct names make the routing unambiguous at every call site. - **12 write sites routed.** Deliberate exclusions: pass-substrate `snapshotPass`/stats writes (never library-regrouping), `stampMicropubURL` (wire-owned, deliberately quiet), `writeResearchNote` (mentor-owned research/), `ingestImage` (assets/), and the editor flush `overwrite` (the ticket's own exclusion — editor-owned error semantics). - **The model owns the Home** — `watchedHome` became `private(set) var boundHome`, set by `bind(home:)` alone (app construction + Settings repoint); every public verb dropped its `home:` parameter. Views + 11 test files swept (160 call sites). - **Intended behavior deltas, AC-pinned:** createProject now pairs one rescan on success (an empty-folder scan — no visible change); importFiles' trailing unconditional rescan became the rail's paired one (identical). Everything else byte-equivalent. - **Post-refactor invariant:** `Task { await rescan() }` exists at exactly two sites in Museion/ — `bind`'s initial scan and the rail's `pairRailRescan`. ## New tests — MuseionTests/PostsModelWriteRailTests.swift Three pins: every write verb records exactly `[.write, .pairedRescan]` (incl. the runPass advance over the scripted-engine rig); a failed write rides once as `[.write, .writeFailed]` with no paired rescan, strip owning the reason. RED first at 8c5ceff (nothing rode the seam), GREEN at 06283b6. ## Verify — independently re-run by reviewer @athena (04:07–04:16 CET, own clone) - RED @ 8c5ceff: `xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' build-for-testing` → `** TEST BUILD SUCCEEDED **`; `test-without-building -only-testing:MuseionTests/PostsModelWriteRailTests` → executed 3 / passed 0 / failed 3 — xcresult failureText confirms `events → []` at every verb. - GREEN @ branch head 3bef1d1: same two commands → executed 3 / passed 3 / failed 0. - Full unit suite: `test-without-building -only-testing:MuseionTests` → executed 654 / passed 654 / failed 0 / skipped 0 (`result: Passed`; xcresult `Test-Museion-2026.11.10_04-10-31-+0100`; main's 651 + the 3 new pins). EditorSessionTests debounce flake did not fire. - `swiftformat --lint .` → 0/135 files require formatting. `swiftlint` → 279 violations / 60 serious — identical counts to base main 627ecf5 (279/60 in 133 files; the branch's two new files add zero). - Reviewer seat machine state: testmanagerd clean (the handoff's wedge did not reproduce); whole-target filter used throughout (a targeted rail-suite filter with backticks/spaces matched zero tests at the implementer's seat — the backtick-free spelling dispatched 3 non-zero cases here). ## Unverified — keyed museion/postsmodel-write-rail - UITests target not run (unit suite is the gate; the UITests-Runner automation-mode wedge is the known machine-state baseline) — both implementer and reviewer. - GitNexus figures (pre-edit `impact PostsModel` = CRITICAL, 144 upstream — the panes + rigs this refactor sweeps, acknowledged; post-edit `detect-changes` = 23 files / 79 symbols / 81 flows, all in the expected verb surface) are the implementer's run, quoted not re-run — the reviewer made no repo edits. - The "160 call sites" sweep count is compiler-certified (any missed site fails the build) but not hand-recounted. ## Implementer disclosures (verbatim, @daedalus) 1. "testmanagerd was wedged on slot arrival (stuck _XCT_enableAutomationModeWithReply transactions) — kill -9 + launchd respawn cleared it; if hosted tests hang at automation-mode init at your seat, that's machine state, not the branch." 2. "Suite-member -only-testing filters containing backticks/spaces matched ZERO tests and "passed" vacuously (exit 0, empty counts) — the whole-target filter -only-testing:MuseionTests is the reliable spelling." 3. Analyzer's self-written AGENTS.md counter delta from the GitNexus run was reverted, not committed. ## Owner apply (AGENTS.md counter patch — staged, consent timed out in the night slot) ``` git apply ~/daedalus-builds/museion/brief-14-agentsmd-owner-apply.patch ``` `git apply --check` CLEAN against branch head 3bef1d1 (touches Museion/AGENTS.md, MuseionTests/AGENTS.md, AGENTS.md — 3 counter lines). ## Scope notes - Disjoint from open PR #184 (brief-13): zero file overlap; both branch off 627ecf5. - museion/library-search-stale-after-mutation is a separate menu item GATED ON THIS PR's merge — intentionally untouched here.
AlexKucera added 3 commits 2026-11-10 04:14:35 +01:00
test(posts): pin library write-rail seam (#179)
CI / ci (push) Canceled after 0s
8c5ceffa3c
RED: PostsModelRail skeleton (one internal seam pairing a library write
with exactly one rescan + the error strip, three error routings) and the
seam-observability suite. On the base every verb hand-copies the
write-then-rescan-then-strip choreography, so nothing reaches the rail:
executed 3 / failed 3, events [] at every verb. Fixes #179
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
docs(devlog): #179 write rail session log
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
3bef1d12b1
AlexKucera added 1 commit 2026-11-10 16:48:38 +01:00
fix(posts): finish-audit closeout for #179
CI / ci (push) Canceled after 0s
CI / ci (pull_request) Canceled after 0s
23b2090054
Reviewer fanout (ponytail/security/general) fixes: bind hoisted to the
WorkspaceView root task (stale boundHome after a Home repoint while
another pane was showing), railWriteReturningReason emits .writeFailed
(pinned, flip-verified), dead home: params deleted from the three ask
sheets, saveDraft locals inlined; AGENTS.md docs delta applied; devlog
closeout. Suite 655/655, lint parity with base.
AlexKucera closed this pull request 2026-11-10 16:56:58 +01:00
Author
Owner

Closed as superseded: main landed a second, complete #179 implementation in 5bf0955 (performWrite rail) before this PR merged, with #180–#184 stacked on top — merging the two implementations would reconcile parallel rails line-by-line with no reviewable seam. The finish-audit run against this branch produced one fix that also applied to main's implementation (the bind now rides the WorkspaceView root task — stale watchedHome after a Home repoint while another pane was showing); it is ported and merged as #186. The branch and its audit closeout commit remain here as the record of this implementation.

Closed as superseded: main landed a second, complete #179 implementation in 5bf0955 (performWrite rail) before this PR merged, with #180–#184 stacked on top — merging the two implementations would reconcile parallel rails line-by-line with no reviewable seam. The finish-audit run against this branch produced one fix that also applied to main's implementation (the bind now rides the WorkspaceView root task — stale watchedHome after a Home repoint while another pane was showing); it is ported and merged as #186. The branch and its audit closeout commit remain here as the record of this implementation.

Pull request closed

This pull request cannot be reopened because the branch was deleted.
Sign in to join this conversation.