N-2: "Identity checks — evidence classes" — pinned (card hop-back,
rescan hoist, #179 guard) vs correct by construction (the Micropub
stamp) vs invariant-equivalent defensive depth (the synchronous sweep
and openPostID's gate: never independently observable under the
gate-first invariant — belt to the gate's suspenders, not
"every site test-verified"). Verify line for r1 at 92344e2: full rail
717/717, filtered 19/19, MF-1 mutation 9/8/1 restored byte-exact,
lint 0/0. Gotchas: the partial patch regeneration, the status/current
race. N-3 is the regenerated owner-apply patch beside the handoff.
21 KiB
brief-28 — Home repoint rides the departure gate (document identity is (Home, ID))
Date: 2026-11-23 Type: fix (unticketed) Reference: finding
museion/home-repoint-retains-old-editor-target(argus cycle-5 bugs pass,museion-bugs.mdfinding 1; HIGH, certain) — branchfix/home-repoint-retains-old-editor-targetoffmainatca265d3bd359e663216aa91d4778e2bdef8a36eb
Goal
Settings → Content → Choose… committed the new Home (preference + UserDefaults
through AppGateState.museionHome.didSet) and the root .task(id:) → bind →
startWatching flipped watchedHome WITHOUT departing the open session. The
session's immutable SessionTarget kept the OLD Home, so under the new UI:
- a same-slug piece in the new library made
select's ID-only reselect return the retained A session — autosave/Save/quit wrote A while structural operations resolved against B; - the new library's rescan read B's same-slug
post.mdfor the A session and raised a spurious #67 on it (differing bodies); - a no-collision piece was torn down by the vanish path with its dirty buffer dropped (data loss);
- a card scan started under A landed its cards on B's same-slug piece when it completed after a reselect (the ID-only hop-back guard).
#198's departure gate never saw this seam (it guards navigations, not the Home binding). Fix direction (argus, binding): repoint = a GUARDED DOCUMENT DEPARTURE before any commit; identity (Home, ID) everywhere, re-checked at async COMPLETION.
What Was Done
The gate (gate-first, commit-after):
PostsModel.repoint(to:) -> Bool(PostsModelWatcher.swift, besidebind):guard newHome != watchedHome(first bind / same folder: nothing departs) →departOpenDocuments()(the brief-25 gate —sessionMayDepart's three legs: unanswered #67, failed flush, never-loaded retype; NO parallel gate) → on true, the departed piece's state dies with it (selectedPostID,openPieceCards,openPieceHasSnapshot,outlineGuardPieceID,proseOverridePostID,pendingConversion,lastDraftWasOutline,pendingProject). On false NOTHING changed:lastErrorsays why (#198's strings), the preference/binding/target/buffer are untouched.AppGateState.repointMuseionHome(to:)(HomeResolution.swift):guard posts.repoint(to:)FIRST,museionHome = newHome(itsdidSetpersists) only after. The ONE runtime repoint entry.- WorkspaceView: the Settings Home control binds through
homeRepointBinding— the binding's setter IS the gate (repointMuseionHome, then nothing else: the root.task(id: museionHome)binds the model after the commit).$gate.museionHomeand the now-dead@Bindable var gateare gone frompaneContent. A refusal presents one hosted-guardedNSAlertcarryingposts.lastError(#200's quit-refusal posture — the Posts strip that shows it is not in sight from Settings). bindstays the dumb binder by design (see Decisions).
Document identity is (Home, ID) — the pattern-exhaustive sweep:
EditorSession.targets(postID:home:)/targets(home:)— the pair; the target is immutable, so a session born under another Home is a foreign document to a model whosewatchedHomemoved past it.PostsModelIdentity.swift(new):openSessionTargets(_:)— the model's ONE "is this piece open" question (session.targets(postID: watchedHome, id)).- Every model-side ID-only session comparison converted:
| Site | Was | Now |
|---|---|---|
PostsModel.select reselect no-op |
session.postID == id |
session.targets(postID: id, home: watchedHome) — a foreign session departs below |
PostsModel.canArmWritingLock / editorBodyText |
session.postID == selectedPostID |
openSessionTargets(id) |
PostsModelOutline.openUnguarded (depart test + reuse test) |
postID != id / id == postID |
!targets(postID:home:) / targets(postID:home:) |
PostsModelOutline.stageConversion / convertToPost |
session.postID == post.id |
openSessionTargets |
PostsModelWrites.flushOrAbort |
session.postID == postID |
openSessionTargets(postID) |
PostsModelWrites rename / trash / moveToProject / archivePost / restorePost / unarchiveProject's openPieceInArchivedProject |
session?.postID == post.id |
openSessionTargets(post.id) |
PostsModelPasses.guardOpenPieceRun |
id == selectedPostID (+ callers re-read watchedHome) |
session.targets(postID: id, home: watchedHome); the answer carries the validated home (3-tuple, callers stop re-reading) |
Micropub.micropubSendDraft launch |
id == selectedPostID, then watchedHome + folder(of:) |
identity at launch; the wire reads the session's OWN library |
PostsModelCards.refreshCards launch |
session?.postID + watchedHome |
session.targets(postID:home:) |
Async continuations re-validate at COMPLETION:
refreshCardshop-back:self.session?.targets(postID: id, home: home)— the seeded site (PostsModelCards:24-42). The scanner is now the per-model injectablescanPieceCards(never static — the hosted suite runs in parallel) so the deterministic stale-result pin can HOLD an old-library scan past a repoint.rescan(PostsModelWatcher): the stale-Home verdict is HOISTED —guard watchedHome == homeright after the detached scan, so a scan that outlived a repoint applies NOTHING (list, revision, vanish check, #67 text), not just the vanish check as before; the #67 disk read runs only for a session targeting the scan's own Home (openPostIDis identity-gated); the vanish teardown matches identity and still tears down the CURRENT session.Micropub's completion stamp (stampMicropubURL(id:home:)after the awaits) keeps the CAPTURED pair — the piece actually sent — by construction; re-validating against the live session would skip a correct write after a mid-send repoint. Disclosed, left as is.
Tests: PostsModelRepointTests (9, new file) over a two-Home same-slug
rig (projects/posts/shared/post.md in both, differing bodies); the #179
mid-pass repoint pin (PostsModelWriteRailTests) now drives the real Settings
path (repoint(to:) then bind). r1 (athena) added the two the review
asked for: the hoisted rescan verdict (MF-1, via the scanLibrary seam)
and the draft-survives decision (N-1).
Identity checks — evidence classes (r1, athena N-2)
"Identity everywhere" is NOT "every site test-verified". Three classes:
| Class | Sites | Proof |
|---|---|---|
| Pinned (failing-test / mutation proof) | refreshCards hop-back (the seeded site); rescan's hoisted stale-Home verdict; the #179 mid-pass advance guard (pre-existing, its lastError == line) |
Mutation checks: ID-only card guard → openPieceCards → ["Hedging"]; hoist removed → posts → ["alpha"] + contentRevision → 3 vs 2. Both restored byte-exact. |
| Correct by construction | Micropub's completion stamp — the captured (Home, ID) of the piece actually sent | Not independently pinnable: a re-validate against the live session would SKIP a correct write after a mid-send repoint. Disclosed, left as is. |
| Invariant-equivalent defensive depth — never independently observable under the gate-first invariant | The whole synchronous sweep: select reselect, openUnguarded×2, stageConversion, convertToPost, flushOrAbort, the six structural ops, guardOpenPieceRun, Micropub launch, refreshCards launch, canArmWritingLock/editorBodyText, the vanish teardown, AND rescan's openPostID identity gate (the #67 read) |
None possible while the gate holds: a live session always targets watchedHome, so the id-only and identity forms agree on every reachable state (athena's run removed openPostID's gate and reverted select to ID-only — the rail stayed green). They are belt to the gate's suspenders: any future path that bypasses repoint (a direct bind under a live session — what the mid-pass pin used to do) falls through to a departure instead of matching across libraries. Correct as design; not test-verified; say so. |
Decisions & Rationale
| Decision | Rationale |
|---|---|
Gate in the Settings binding's setter + repointMuseionHome, NOT in bind |
The gate must precede the preference commit (museionHome.didSet persists immediately). A gate inside bind would leave museionHome = B while watchedHome = A — the UI showing a Home the model isn't watching. bind is reached only after a passed gate (or the same Home / first frame), so it stays unconditional. |
sessionMayDepart via departOpenDocuments — no parallel gate |
The brief's acceptance (1) and brief-25's contract: one gate, three legs, #198's strings. The refusal tests prove the composition (PostsModelDepartureTests 10/10 stay green beside the new suite). |
| Nothing auto-reopens after an accepted repoint | The brief left it to the implementer within existing machinery. Auto-reopening B's same-slug piece would be a NEW UX (the writer never chose it) and cannot even be decided at gate time — B isn't scanned until bind + rescan land. selectedPostID = nil is the #198 departure semantics (newPost/openExternal do the same); the writer picks from the new list. |
| The in-memory draft survives a repoint | A draft has no Home until first save (#62); it lands in the new library. The only alternatives — dropping it (the only copy) or refusing the repoint (new UX) — are worse. Disclosed; pendingProject (a stale A project name) IS cleared. |
| A running pass / Blind Read is not cancelled by the repoint | sessionMayDepart flushes; the session departs; the engine turn keeps its own completion guard (#179: the advance refuses once watchedHome moved) — pinned by the mid-pass test. Cancelling would desync the pass bar's Cancel ↔ Run state. |
pendingImportURLs / askNewProject left alone |
Both are sheet-modal (OriginAsk / NewProject) — a repoint cannot be requested while either is up, and neither is piece-specific. An import batch landing in B after a repoint is the writer's chosen library. |
Refusal = one NSAlert (the #200 posture), not a Settings strip |
Settings shows no lastError strip (PostsPaneView owns it); a silent Choose… is the dishonest outcome. The alert carries the exact #198 lastError string; hosted-guarded like the quit refusal. |
openSessionTargets on the model + targets on the session (two helpers) |
The session owns the pair (it knows its target); the model owns "which Home is current". rescan needs the scan's captured home, not watchedHome, so the session-level predicate is public within the module. |
Rescan hoist of watchedHome == home |
The old inline guard covered only the vanish check; a stale list could still land under the new binding (and bump contentRevision). One verdict at the top covers everything the continuation writes. |
View-layer session.postID == selectedPostID (PostsPaneView:125) NOT converted |
A render gate on the same pair; with the model invariant (the open session always targets watchedHome) it is correct by construction, and the view has no Home-identity vocabulary. Other view reads are nil-checks (session?.postID != nil) or title lookups, not comparisons. Disclosed, not exposed. |
Gotchas & Fixes
| Problem | Root Cause | Fix |
|---|---|---|
| Stale-scan pin's park probe never passed (5 s poll timeout) | pollUntil re-evaluates its where !condition() per iteration WITHOUT sleeping when true, and DispatchSemaphore.wait consumes — two parked scans drained the count in two iterations, the final #expect(condition()) saw zero |
A non-consuming ParkedFlag (NSLock box, @unchecked Sendable); the park itself is a bounded release.wait(timeout: .now() + 30) so a failed test never leaks a parked cooperative thread |
-only-testing:MuseionTests/PostsModelTests matched ZERO tests in a filtered run (17 executed, not more) |
The filter names a FILE, not a suite: PostsModelTests.swift holds free-function @Tests (unfilterable by suite) AND the @Suite("write rail #179") struct PostsModelWriteRailTests; "PostsModelTests" matches neither, and the rail's zero-match guard stays silent when sibling filters match |
Filter by SUITE name (grep '@Suite(' <file>), never by file name. The mid-pass pin ran in the FULL rail (715) under its suite; no verification claim was taken from the filtered run for it |
| Vanish-path rewrite first tore down the CAPTURED session | openSessionTargets(id) reads session now while openSession?.teardown hit the pre-scan object — a same-id reopen mid-scan would leave the live session armed |
if let open = session, open.targets(postID: id, home: home) — the original shape (current session), identity-matched |
swiftlint:disable:next large_tuple flagged superfluous |
The return type sat on the ) -> line, not the func line the :next covers |
Signature on one line so the tuple starts on the covered line (PostStore.swift:259 precedent) |
| A context-fuzzy patch duplicated "The refusal" in a doc comment | The edit span started mid-line | Re-read and re-patched the two lines |
| Regenerating the owner-apply patch from FRESH scratch copies kept only the r1 edits (9 changed lines vs the reviewed 19) | The regeneration script carries the full edit set; a partial re-run silently drops the earlier anchors | Re-ran the FULL pair set from fresh a/ copies and compared hunk count/line count against the reviewed patch (69 lines / 5 hunks) before trusting it |
full-test.sh status reported the MUTATION run's 9 / 8 / 1 while the full rail was in flight |
status reads current, which a newer launch repoints; the loop broke on a finished-but-stale verdict |
Read each run's OWN summary.json by run dir — the per-dir numbers are the record (full: Passed / 717) |
Files Changed
| File | Change Summary |
|---|---|
Museion/PostsModelWatcher.swift |
repoint(to:) (the gate); bind documented as the dumb binder; rescan: identity-gated #67 read, hoisted stale-Home verdict, identity vanish teardown |
Museion/PostsModelIdentity.swift (new) |
openSessionTargets(_:) |
Museion/EditorSession.swift |
targets(postID:home:) / targets(home:) |
Museion/HomeResolution.swift |
AppGateState.repointMuseionHome(to:) |
Museion/WorkspaceView.swift |
homeRepointBinding (gate in the setter) + hosted-guarded refusal alert; import AppKit; dead @Bindable removed |
Museion/PostsModel.swift |
select reselect by identity; canArmWritingLock/editorBodyText by identity; scanPieceCards + scanLibrary (r1) seams |
Museion/PostsModelWrites.swift |
flushOrAbort + the six structural ops by identity |
Museion/PostsModelOutline.swift |
openUnguarded, stageConversion, convertToPost by identity |
Museion/PostsModelCards.swift |
identity at launch AND completion; scanner through the seam |
Museion/PostsModelPasses.swift |
guardOpenPieceRun identity + returns the validated Home; callers consume it |
Museion/Micropub.swift |
identity at launch |
MuseionTests/PostsModelRepointTests.swift (new) |
9 pins (7 + r1's two) |
MuseionTests/PostsModelTests.swift |
mid-pass pin drives repoint(to:) + bind |
CHANGELOG.md, docs/devlog/INDEX.md, this log |
docs |
AGENTS.md, Museion/AGENTS.md, MuseionTests/AGENTS.md |
OWNER-APPLY patch only (see Open Items) — never written by this session |
Open Items & Next Steps
- AGENTS.md DOX pass ships as an owner-apply patch:
~/daedalus-builds/museion/brief-28-agents-owner-apply.patch—git apply --checkclean at the r1 head (3 files, 5 hunks: the PostsModel/Watcher/Writes/Editor-core/Settings/WorkspaceView bullets, theAppGateState.museionHomebullet, the MuseionTests suite map row with the r1 pins and thescanLibraryseam, and the root 10-most-recent window row). Apply from the branch head withgit apply ~/daedalus-builds/museion/brief-28-agents-owner-apply.patch. - GitNexus
impact/detect_changeswere NOT run:.gitnexus/run.cjsis absent at base and no GitNexus capability is exposed (the argus cycle-5 audit hit the same wall). The blast radius was traced by hand instead — the table above IS the caller trace. The root AGENTS.md index-count line (7133 symbols …) is therefore NOT refreshed in the patch. - Coupled (HELD behind this PR's merge, per the brief):
museion/external-watch-compares-unnormalized-textdispatches from the merged state. This diff touchedrescan's :94-98 (identity-gated read) and the vanish block (:135-146 → hoisted verdict), NOT the normalization seam itself (readBody's representation at the former :107 and PostsModelImports.swift:69-70 are untouched) — the two changes are disjoint in mechanism. - Not in scope, observed while tracing:
newProjectPending(named:)setspendingProjectBEFOREnewPost()and leaves it set when the departure gate refuses the new post (a stale pending target with no draft). Reported to @aegis as an observation;repointclearspendingProjecton its own path regardless.
Verification
- Base / pin:
ca265d3bd359e663216aa91d4778e2bdef8a36eb= livemaintip at claim (tea api repos/AlexKucera/museion/branches/main, 20:05 CET) and still at r1 handoff (git ls-remote, 22:36 CET). Zero drift. Round 1 (athena) reviewed97712fb; this round appends92344e2(code) and the docs commit on top — 4 linear commits kept, no force-push. - r1 (athena MF-1/N-1), full rail at
92344e2(tree pristine vs the commit, watcher blob sha256 prefixd86ce09d6b7e6bd2): run dir_build/full-test/20261123T213424Z-Museion→717 executed / 717 passed / 0 failed / 0 skipped (xcodebuild exit 0),summary.jsonPassed / 717,** TEST SUCCEEDED **; 717 = 715 + the two r1 pins;PostsModelRepointTests9/9 (both r1 pins named passed),PostsModelDepartureTests10/10,PostsModelWriteRailTests5/5. Filtered GREEN (repoint + departure) → run dir…T213313Z19 / 19. - r1 mutation check (MF-1): hoisted
guard watchedHome == homeremoved → run dir…T213345Z9 executed / 8 passed / 1 failed (exit 65), ONLYa library scan from the old Home lands nothing under the new binding,posts.map(\.id) → ["alpha"]andcontentRevision → 3vsrevision → 2; restored byte-exact (prefixd86ce09d6b7e6bd2before and after), zeroMUTATION-CHECKtokens repo-wide. Lint at92344e2:swiftformat --lint .0/152,swiftlint0. - r1 owner-apply patch regenerated for the seam + the two pins (N-3):
69 lines / 5 hunks — the reviewed patch's shape —
git apply --checkCLEAN at the new head (re-checked after the docs commit). - Round 0 (first report) follows.
- RED first at the pin (commit
bce6abb), rail-filtered./scripts/full-test.sh start -- -only-testing:MuseionTests/PostsModelRepointTests:6 executed / 0 passed / 6 failed / 0 skipped (xcodebuild exit 65), zero compile errors — each on the finding's signature:session.text → "A body, typed in A"under the B binding,targets(postID: "shared", home: homeB) → false, B's edits landing on A's disk,watchedHome → …/Bdespite a refused flush / unanswered conflict / never-loaded retype, and the no-collision vanish path dropping the dirty buffer (readBody(A) → "# Unique \n\nA body\n"). - GREEN, full rail at
8b0d43a(the fix commit; tree clean at start):./scripts/full-test.sh start→./scripts/full-test.sh status→715 executed / 715 passed / 0 failed / 0 skipped (xcodebuild exit 0);summary.json→result: Passed, totalTestCount: 715;** TEST SUCCEEDED **; 715 = the cycle-5 baseline 708 + the 7 new pins, all 7 named passed in the log;PostsModelDepartureTests10/10 (#198 + #200 matrix green beside the new suite — the gates compose); the mid-passPostsModelWriteRailTestspin passed on its new path. - Mutation check (the stale card-scan pin's honest RED — its seam cannot
exist at base, so it is GREEN-only there): completion guard reverted to the
ID-only base form → rail-filtered
7 executed / 6 passed / 1 failed, ONLY that pin,openPieceCards → ["Hedging"](A's cards on B's piece); restored byte-exact (sha256 prefix9c8fb55264f5ac1cbefore and after), zeroMUTATION-CHECKtokens repo-wide. - Lint:
swiftformat --lint .→0/152 files require formatting;swiftlint lint --quiet→ zero violations (both at8b0d43a; the pre-push hook's scoped gate passed on both pushes). - Evidence types: see "Identity checks — evidence classes" above —
pinned (card hop-back, rescan hoist, #179 guard) vs by-construction
(Micropub stamp) vs invariant-equivalent defensive depth (the synchronous
sweep and
openPostID's gate). The preference leg is NOT unit-pinned:AppGateState'sdidSetwrites the REALUserDefaults.standard(MuseionTests/AGENTS.md: never touch the machine), so driving a repoint throughAppGateStatein a hosted test would point the owner's next launch at a temp dir. The view wiring is structural proof only (homeRepointBinding→repointMuseionHome→posts.repointprecedesmuseionHome = newHome). Unverified by design; disclosed. - Not run: the MuseionUITests smoke (outside the rail by design); no GUI
reproduction of the Settings flow (same posture as the scan — static trace
- model-level pins).
pool: 0 in flightat handoff — no subagents spawned (Z.ai draws: this main only).
Log written by daedalus (brief-28, profile daedalus) — format per the write-log skill