fix(editor): guard document departure on failed flushes [museion/failed-flush-discarded-on-document-switch] #198
2 Participants
Notifications
Due Date
No due date set.
Blocks
#200 Gate quit-time flushes through the departure gate
AlexKucera/museion
#201 Apply consented brief-25 AGENTS.md sentences post-merge
AlexKucera/museion
Reference: AlexKucera/museion#198
Reference in new issue
Block a user
Finding — museion/failed-flush-discarded-on-document-switch
EditorSession.flush()returns false after a write failure (saveState.failed), but document-departure paths calledteardown(flushFirst:)and discarded the result — the outgoing session was torn down even when its flush FAILED, and the navigation then replaced the only retained copy of the unsaved prose. Structural ops (move/archive/rename/convert) already aborted throughflushOrAbort; ordinary departure did not.Evidence at base
11b196d(file:line in the pre-split PostsModel.swift; symbols relocated by trunk's #193, see integration below):newPost:271,newOutline:287,dismissExternal:302,select:359,openExternal:620 (PostsModel.swift);openUnguardedPostsModelOutline.swift :72 — each tore down unconditionally. Finding source: argus cycle-4 dedicated bugs pass, finding 1 (~/argus-audits/audit/2026-11-16/museion-bugs.md).Fix
sessionMayDepart(_:)— the departure gate for ONE outgoing session:flushOrAbort's two gates (unanswered #67 conflict holds; failed flush holds) lifted to document departure, message strings byte-identical.flushOrAbortroutes through it (pure refactor, same contract).dismissExternal() -> Bool— the guest departs only when its flush lands; on failure the guest, its buffer, AND its watcher stay live; returns false so callers abort before clearing anything.departOpenDocuments()— the full-switch composition (guest + post session, each gated, thenteardown(flushFirst: false)— the gate already flushed) behindnewPost/newOutline/openExternal.select/openUnguarded— gate the guest unconditionally at head (reselect-as-return still dismisses it, now guarded); gate their same-id-conditional session teardowns throughsessionMayDepart.MuseionTests/PostsModelDepartureTests.swift, 6 pins): both navigation families (saved-post session, external guest) with injected write failures (read-only piece folder / read-only guest directory; FixCardApplyTests' permission-injection convention), the #67 conflict hold, and retry-after-writability-restored proving the edits land and the switch then completes.Site re-derivation (implementer, from root cause at the pinned base): all production
teardown(call sites re-enumerated — the six exposed sites above, matching the seed list exactly, no seventh; trash/archivePost/convert/rescan areflushFirst: falsebehindflushOrAbortor a vanished post (correctly unguarded). Reviewer's independent rail-wide grep at the integrated head: everydismissExternalcaller guards; zero unguarded departure sites remain.Disclosed semantic addition (in-scope by pre-committed brief scope), verbatim from the devlog
Trunk integration (#193 PostsModel split) — this PR is the INTEGRATED head
Trunk moved after the branch was cut (
main11b196d→bb4bfa2): #193 split PostsModel.swift into Watcher/Writes/Imports files — the exact file this fix modified. Per repo precedent (7cd5e69), currentmainwas merged into the branch. PR head =ffb9457(merge of9497661+bb4bfa2), pushed. Branch commits:ecd14d1RED tests →250a662fix →9497661devlog →ffb9457integration merge.Hand-resolved conflict files (sentinel + both-parents checks passed on each):
Museion/PostsModel.swift— both conflicts took main's deletions; the fix's guarded bodies relocated with the split:dismissExternal+openExternal→ PostsModelImports.swift;flushOrAbort+sessionMayDepart+departOpenDocuments→ PostsModelWrites.swift (original adjacency preserved).newPost/newOutline/selectauto-merged with guards intact.docs/devlog/INDEX.md— chronological union of trunk's four 2026-11-17 rows and this branch's 2026-11-16 row.Post-integration sentinels, all verified at
ffb9457:sessionMayDepartgate engine (PostsModelWrites.swift:146);departOpenDocumentsbehind newPost (PostsModel.swift:179) / newOutline (:193) / openExternal (PostsModelImports.swift:47);dismissExternal() -> Boolfailure-return contract (PostsModelImports.swift:23); guardedselect(PostsModel.swift:245, 256) +openUnguarded(PostsModelOutline.swift:69, 73); 6 test pins present.Mergeability:
git merge-tree --write-treeclean vsmain@bb4bfa2(moment-scoped to that SHA — re-probe if trunk moves in this seam before merge).Verify
Evidence classes: "reviewer" = this seat's own runs on the integrated head
ffb9457tonight (2026-11-17); "implementer" = pre-integration runs at the fix tree250a662, quoted, non-authoritative.ecd14d1(=11b196d+ tests-only commit), focused-only-testing:MuseionTests/PostsModelDepartureTests— 6 failed / 0 passed,** TEST FAILED **. The pins bite a live defect.ffb9457— 6/6 passed, 0 failed,** TEST SUCCEEDED **(xcresultTest-Museion-2026.11.17_20-15-19-+0100.xcresult: totalTestCount 6, passed 6, failed 0, skipped 0).xcodebuild -project Museion.xcodeproj -scheme Museion -destination 'platform=macOS' testatffb9457— 699 passed / 1 failed / 0 skipped (xcresultTest-Museion-2026.11.17_20-15-35-+0100.xcresult: totalTestCount 700, passedTests 699, failedTests 1, skippedTests 0). The 1 is theMuseionUITests-Runnerbundle failing at INIT ("Timed out while enabling automation mode", zero assertions executed); zero unit test-case failures (699 pass lines counted in the run log). 699 = trunk's 693 + 6 new pins — the implementer's full-suite number reproduces exactly at the integrated head.ffb9457(reviewer): 0/150 files require formatting.ffb9457(reviewer): 0 violations, 0 serious in 139 files — trunk's repo-wide-green contract (#197) holds over the integrated tree.MuseionUITests-Runnerfailing at INIT ("Timed out while enabling automation mode"), a System Failure node, zero assertions executed; 699 = 693 trunk executions + 6 new pins.Unverified — keyed by slug
museion/failed-flush-discarded-on-document-switch— UI smoke: UNVERIFIED on this machine. Implementer's environmental wall, verbatim from the devlog:Reviewer re-run at
ffb9457(Tuesday 20:16 CET) hits the identical runner-INIT wedge — recorded as the disclosed environmental wall (machine not rebooted since Monday night), not a new finding. The unit and focused numbers above all reproduce; the post-reboot UI smoke remains owed and is the only outstanding verification item for this PR.AGENTS.md owner-apply patch (consent-gated)
git apply brief-25-agents-md-owner-apply.patchStatus (both seats verified at
ffb9457): the original patch — built against the pre-#193 AGENTS.md text — went stale at the integrated head (git apply --checkfailed atMuseion/AGENTS.md:36; trunk's #193 rewrote the same PostsModel bullet and added three split-file bullets). The implementer regenerated it the same night (round 1, 2026-11-17 20:22): consented sentences extracted byte-verbatim from the old patch, woven into the PostsModelImports/PostsModelWrites bullets, plus two accuracy extensions (dismissExternal(-> Bool— false holds the departure); gates namedsessionMayDepart/departOpenDocuments), one disclosed 1-char paren deviation (self-contained "(brief-25)."), and an index line so--3waycan rescue future drift. Reviewer independently atffb9457:git apply --checkexit 0;git apply --check --3wayexit 0 ("Applied patch to 'Museion/AGENTS.md' cleanly"); sentence content verified in the patch lines; review clone clean. Moment-scoped toffb9457— ifmainrewrites those bullets before you apply, use the 3-way fallback or request a regen.Scope
ffb9457and the verify numbers stay head-pinned. Zero branch-code findings. Converged in 1 round.museion/home-repoint-retains-old-editor-targetis HELD behind this PR's merge and rebases onto this branch's merged state (sessionMayDepart/departOpenDocumentsare its departure seam). This PR's merge-clean state atmain@bb4bfa2is that brief's release gate.[Generated by AI]
/review
Failed to review PR