Realign code with the 2026-07-31 findings-resolution rulings
The full bullet list from Implementation card bf080d9a — both ruling batches, including the three appended mid-session by16ef377: - Restore subjects compose the inverse, never nest: crossing "Undo: S" emits "Redo: S" and vice versa; parity, not stack depth, reads a legacy double prefix (GitHistoryProvider.restoreSubject). - Git-operation failures join the one-shot failure banner tier: BannerCenter.GitFailureBanner (undo/redo/branchSwitch/addGit), error tone at failure rank merged with write one-shots by recency; the postLoss compromise is retired at both AppModel wirings. - order/schema optional below the board root: append-at-end reading (ordered siblings first, folder-name tie-break among the order-less), schema reads 1, both coerce-tier logged; the root keeps its requirements. Ranks.resolvedOrders materializes finite ranks so models and placement math stay untouched; first Writer rewrite stamps a real rank on touch, placement against an order-less sibling stamps that sibling inline in the same bracket. Agent guide v10 teaches optional keys and zero-read filing. Hostile-YAML order shapes become coercion tests; Fixtures/Valid/optional-keys.kanban replaces the four retired Malformed boards. - .gitignore is the relocation-heal noise gate: GitignoreRules pure matcher (standard semantics, board-root file only), loader consults it once per walk so matched loose files keep the stray posture; seeded (.DS_Store + .*.lanework-*) at board creation and template instantiation, healed in when missing at open — repo-nested included; empty file honored, existing files never edited; the committer's obedience via libgit2 status is pinned by test. - Comments crash-residue sweep gates on step ownership: HistoryStep derives backing from its own undo expectations, backedContent unions both stacks, the sweep purges per-entry only what no live step owns. - Skip-purge decoupled (16ef377): a stale-skipped coarse step strands whole in NativeHistoryProvider.strandedSteps — still backing, retired only at session end; clean exits purge as before. - Coarse close step named "Changes to '<card>'"; the fine body-edit wording never leaks onto the board menu. - Branch-switch settle clears every open card window's fine stack on Save All and Discard alike; the empty fold registers no coarse step. - Close flush awaits its covering snapshot (quiesce + one generation bump, 1s bound), and an explicit flush now queues behind an in-flight one instead of skipping — the audit-caught interleaving could lose a close flush permanently when the debounce fired inside the close sequence; regression tests force both races. - Commit comment bullets sort chronologically by created, not UUID. - The production-unwired CardBodyEditSession.editSessionDidChange seam is deleted with its seam-only tests. - Composition-root pins: beginSession composes the committer with the store's own EchoLedger and binds the announcer (the miswire class). - Deliberate 06 conformance pass over every 2026-07-31-tagged sentence: fixed Change-custom-key subjects (the retired named generic was the only producer), the unbuilt Replace attachment vocabulary, heal commits now authored Lanework Integrity, the config reader scopes identity to plain [user] sections, add-git re-runs detection at create (a stale mode-none could initialize inside the user's repo), and add-git failures answer at the form or the banner. Structural residue filed on the Redesign board. 2554 tests / 439 suites green. Claude-Session: https://claude.ai/code/session_01CqjXB7ASoWtbyoGod68k97
This commit is contained in:
@@ -62,6 +62,49 @@ private func openBoard(_ model: AppModel, at url: URL) throws -> BoardWindowRef
|
||||
return ref
|
||||
}
|
||||
|
||||
/// The same board with a **real repository** at its root, root commit and all — what a Pro session
|
||||
/// detects as mode `git`, and therefore the only shape that composes a branch switcher to test the
|
||||
/// settle step's seams through.
|
||||
@MainActor
|
||||
private func makeProGitBoard() throws -> WriterFixture {
|
||||
let fixture = try makeMixedBoard()
|
||||
guard case .success = GitRepository.create(at: fixture.root) else {
|
||||
fixture.tearDown()
|
||||
Issue.record("could not initialize a repository for the fixture board")
|
||||
throw CocoaError(.fileWriteUnknown)
|
||||
}
|
||||
return fixture
|
||||
}
|
||||
|
||||
/// Opens a card window the way its host does — registered with the board's session — and leaves it
|
||||
/// holding one fine step and an open Edit session, so it both *has* a stack to lose and answers the
|
||||
/// save-or-discard step's `needsSettling` with `true`.
|
||||
///
|
||||
/// The step is registered through `BoardStore.registerStep` rather than pushed onto the provider, so
|
||||
/// it is routed by the same line production routes a card-window gesture with (`on:` → the window's
|
||||
/// stack) and carries the raw write the close fold would look for.
|
||||
@MainActor
|
||||
@discardableResult
|
||||
private func openCardWindow(
|
||||
_ model: AppModel,
|
||||
board: BoardWindowRef,
|
||||
card id: String,
|
||||
store: BoardStore
|
||||
) -> CardWindowSession {
|
||||
let window = CardWindowSession()
|
||||
model.registerCardWindow(CardWindowRef(board: board, cardID: ItemID(rawValue: id)), session: window)
|
||||
window.body.beginEditSession()
|
||||
store.registerStep(
|
||||
"Edit Card",
|
||||
on: window.undo,
|
||||
undoExpects: [.present(.card(ItemID(rawValue: id)), .body("after\n"))],
|
||||
redoExpects: [.present(.card(ItemID(rawValue: id)), .body("before\n"))],
|
||||
undo: { _ in },
|
||||
redo: { _ in }
|
||||
)
|
||||
return window
|
||||
}
|
||||
|
||||
// MARK: - Tests
|
||||
|
||||
@MainActor
|
||||
@@ -276,6 +319,101 @@ struct AppModelTests {
|
||||
model.storeRegistry.release(try #require(model.session(for: ref)?.store))
|
||||
}
|
||||
|
||||
// MARK: The branch switch's settle
|
||||
|
||||
/// **"The settle also clears each open card window's fine undo stack"** (06-history-undo.md
|
||||
/// ▸ Branch switching, ruled 2026-07-31): "pre-switch steps describe the branch being left — Save
|
||||
/// All and Discard alike end with every window's stack empty … the windows stay open, following
|
||||
/// their cards onto the new branch with fresh stacks."
|
||||
///
|
||||
/// This is an `AppModel` test rather than a `GitBranchSwitcher` one because the clear is a fact
|
||||
/// about the **composition**: the switcher's settle seam, the card-window registry and the stacks
|
||||
/// themselves only meet in `wireBranchSwitching`, and a switcher wired by hand would be a test
|
||||
/// asserting its own wiring (the `a381fac` lesson, applied one card later).
|
||||
@Test(
|
||||
"The branch switch's settle empties every open card window's fine stack",
|
||||
arguments: [SessionSettleChoice.saveAll, .discard]
|
||||
)
|
||||
func theSettleClearsEveryFineStack(answering choice: SessionSettleChoice) async throws {
|
||||
let board = try makeProGitBoard()
|
||||
defer { board.tearDown() }
|
||||
let (model, tearDown) = try makeModel()
|
||||
defer { tearDown() }
|
||||
model.currentTier = { .pro }
|
||||
|
||||
let ref = try openBoard(model, at: board.root)
|
||||
let session = try #require(model.session(for: ref))
|
||||
let switcher = try #require(session.git?.switcher)
|
||||
|
||||
let windows = [Ident.card1, Ident.card2].map { id in
|
||||
openCardWindow(model, board: ref, card: id, store: session.store)
|
||||
}
|
||||
#expect(windows.allSatisfy { $0.undo.stack.canUndo })
|
||||
#expect(windows.allSatisfy { $0.undo.netEffect() != nil }, "a session with a net effect to fold")
|
||||
|
||||
model.settleAsk = { _ in choice }
|
||||
#expect(await switcher.settleSessions?() == .proceed)
|
||||
|
||||
for window in windows {
|
||||
#expect(!window.undo.stack.canUndo, "the stack describes the branch being left")
|
||||
#expect(!window.undo.manager.canUndo, "and ⌘Z in that window answers with it")
|
||||
}
|
||||
// "The windows stay open, following their cards onto the new branch with fresh stacks."
|
||||
#expect(model.session(for: ref)?.cardRefs.count == 2)
|
||||
}
|
||||
|
||||
/// **Closing the stack is not closing the window.** The coarse step a card window owes its board is
|
||||
/// registered at *close*, folded from this stack (13-native-undo.md ▸ Rules ▸ "Window close
|
||||
/// coarsens"); a settle clear registers nothing at all, which is exactly what
|
||||
/// `registerCardSession` answering `false` — and the deferred purge staying the caller's — says.
|
||||
@Test("A settle clear registers no coarse step — the fold that would have run finds nothing")
|
||||
func theClearRegistersNoCoarseStep() async throws {
|
||||
let board = try makeProGitBoard()
|
||||
defer { board.tearDown() }
|
||||
let (model, tearDown) = try makeModel()
|
||||
defer { tearDown() }
|
||||
model.currentTier = { .pro }
|
||||
|
||||
let ref = try openBoard(model, at: board.root)
|
||||
let session = try #require(model.session(for: ref))
|
||||
let switcher = try #require(session.git?.switcher)
|
||||
let window = openCardWindow(model, board: ref, card: Ident.card1, store: session.store)
|
||||
|
||||
model.settleAsk = { _ in .saveAll }
|
||||
#expect(await switcher.settleSessions?() == .proceed)
|
||||
|
||||
#expect(window.undo.netEffect() == nil, "nothing left to fold")
|
||||
var purged = false
|
||||
let registered = session.store.registerCardSession(
|
||||
window.undo,
|
||||
inCard: ItemID(rawValue: Ident.card1),
|
||||
retiring: { purged = true }
|
||||
)
|
||||
#expect(!registered, "a close arriving right after the switch registers nothing")
|
||||
#expect(!purged, "and the deferred purge is still the caller's, not a step's")
|
||||
}
|
||||
|
||||
/// "**Cancel** keeps the current branch and the sessions" — and now their stacks with them. The
|
||||
/// same `if` that withholds the staging release withholds this.
|
||||
@Test("Cancel clears nothing")
|
||||
func cancelKeepsTheFineStacks() async throws {
|
||||
let board = try makeProGitBoard()
|
||||
defer { board.tearDown() }
|
||||
let (model, tearDown) = try makeModel()
|
||||
defer { tearDown() }
|
||||
model.currentTier = { .pro }
|
||||
|
||||
let ref = try openBoard(model, at: board.root)
|
||||
let session = try #require(model.session(for: ref))
|
||||
let switcher = try #require(session.git?.switcher)
|
||||
let window = openCardWindow(model, board: ref, card: Ident.card1, store: session.store)
|
||||
|
||||
model.settleAsk = { _ in .cancel }
|
||||
#expect(await switcher.settleSessions?() == .cancelled)
|
||||
#expect(window.undo.stack.canUndo)
|
||||
#expect(window.undo.netEffect() != nil)
|
||||
}
|
||||
|
||||
// MARK: Launch restoration
|
||||
|
||||
/// App ▸ Settings…'s "Restore open boards at launch" (11-command-nexus.md) gates the flagged set
|
||||
|
||||
Reference in New Issue
Block a user