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:
@@ -465,32 +465,54 @@ struct BoardWriterRenumberTests {
|
||||
#expect(try fixture.indexData("lane/notes") == stray)
|
||||
}
|
||||
|
||||
/// A renumber runs over loaded, valid children: one broken sibling fails the whole
|
||||
/// operation, and it fails before anything has been rewritten.
|
||||
@Test func aChildWithAMalformedOrderFailsTheWholeRenumber() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("lane/\(Child.a)", child(order: "1.0000001", title: "A"))
|
||||
try fixture.item("lane/\(Child.b)", "---\nschema: 1\norder: banana\ntitle: B\n---\nbody\n")
|
||||
let untouched = try fixture.indexData("lane/\(Child.a)")
|
||||
/// **An order-less sibling takes part in the rescale rather than stopping it**
|
||||
/// (01-storage-format.md § Ordering, re-ruled 2026-07-31): it joins the batch on its
|
||||
/// append-at-end reading, so it comes out of the renumber holding a real rank and sitting exactly
|
||||
/// where the board was already drawing it — last.
|
||||
@Test func aChildWithAnUnusableOrderJoinsTheRenumberAtTheEnd() throws {
|
||||
for unusable in ["order: banana", "order: .nan", "order:"] {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
// `b` sorts after `a` by folder name, but it is the *rank* that puts it last here: `a`
|
||||
// carries one and `b` does not.
|
||||
try fixture.item("lane/\(Child.a)", child(order: "1.0000001", title: "A"))
|
||||
try fixture.item("lane/\(Child.b)", "---\nschema: 1\n\(unusable)\ntitle: B\n---\nbody\n")
|
||||
|
||||
let error = writeFailure { try BoardWriter.renumberVisibleChildren(of: fixture.url("lane")) }
|
||||
#expect(error?.reason == .unreadable(message: "malformed 'order' field: banana"))
|
||||
#expect(error?.path.contains(Child.b) == true)
|
||||
#expect(error?.operation == .renumberChildren)
|
||||
#expect(try fixture.indexData("lane/\(Child.a)") == untouched)
|
||||
try BoardWriter.renumberVisibleChildren(of: fixture.url("lane"))
|
||||
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("lane/\(Child.a)")).order == .valid(1024), "\(unusable)")
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("lane/\(Child.b)")).order == .valid(2048), "\(unusable)")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func aChildWithNoOrderFailsTheWholeRenumber() throws {
|
||||
/// The order-less sibling sorts *after* every ranked one even when its folder name would put it
|
||||
/// first — the whole of the append-at-end reading, seen through the rescale.
|
||||
@Test func anOrderlessChildRenumbersLastRegardlessOfFolderName() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("lane/\(Child.a)", "---\nschema: 1\ntitle: A\n---\nbody\n")
|
||||
try fixture.item("lane/\(Child.b)", child(order: "512", title: "B"))
|
||||
try fixture.item("lane/\(Child.c)", child(order: "1536", title: "C"))
|
||||
|
||||
try BoardWriter.renumberVisibleChildren(of: fixture.url("lane"))
|
||||
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("lane/\(Child.b)")).order == .valid(1024))
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("lane/\(Child.c)")).order == .valid(2048))
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("lane/\(Child.a)")).order == .valid(3072))
|
||||
}
|
||||
|
||||
/// A renumber still runs over *readable* children: a sibling that refuses writes fails the whole
|
||||
/// operation before anything has been rewritten.
|
||||
@Test func aChildWithAnUnreadableIndexFailsTheWholeRenumber() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("lane/\(Child.a)", child(order: "1.0000001", title: "A"))
|
||||
try fixture.item("lane/\(Child.b)", "---\nschema: 1\ntitle: B\n---\nbody\n")
|
||||
try fixture.item("lane/\(Child.b)", bytes: Data([0xFF, 0xFE, 0x00]))
|
||||
let untouched = try fixture.indexData("lane/\(Child.a)")
|
||||
|
||||
let error = writeFailure { try BoardWriter.renumberVisibleChildren(of: fixture.url("lane")) }
|
||||
#expect(error?.reason == .unreadable(message: "missing required 'order' field"))
|
||||
#expect(error?.path.contains(Child.b) == true)
|
||||
#expect(error?.operation == .renumberChildren)
|
||||
#expect(try fixture.indexData("lane/\(Child.a)") == untouched)
|
||||
}
|
||||
|
||||
@@ -515,6 +537,155 @@ struct BoardWriterRenumberTests {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - The rank stamps
|
||||
|
||||
/// **The write side of the optional-`order` ruling** (01-storage-format.md § Ordering, re-ruled
|
||||
/// 2026-07-31): "The rank materializes on touch — the first Writer rewrite of the file stamps a real
|
||||
/// rank, and placement math that must rank an item *relative to* an order-less sibling stamps that
|
||||
/// sibling inline, inside the gesture's bracket and commit."
|
||||
///
|
||||
/// Both stamps write `Ranks.resolvedOrders`' own answer — the rank the loader was already rendering
|
||||
/// the file at — so every assertion here is also an assertion that nothing moved.
|
||||
struct BoardWriterRankStampTests {
|
||||
|
||||
private func order(_ fixture: WriterFixture, _ path: String) throws -> FieldValue<Double> {
|
||||
try FrontmatterDocument.parse(fixture.indexText(path)).order
|
||||
}
|
||||
|
||||
/// The on-touch half: any rewrite at all — here an ordinary title edit — stamps the rank.
|
||||
@Test func aRewriteOfAnOrderlessFileStampsItsRank() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\norder: 1024\ntitle: A\n---\nbody\n")
|
||||
let folder = try fixture.item("\(Ident.lane1)/\(Child.b)", "---\ntitle: Minimum\n---\nbody\n")
|
||||
|
||||
try BoardWriter.updateIndex(inItemFolder: folder, operation: .style(title: nil)) { document in
|
||||
document.set(FrontmatterKeys.title, to: .string("Renamed"))
|
||||
}
|
||||
|
||||
// 1024 (the ranked sibling) + one gap — where the board was already drawing it.
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.b)") == .valid(2048))
|
||||
// The `kind` backfill rides the same write, and the ranked sibling is untouched.
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText("\(Ident.lane1)/\(Child.b)")).kind == .valid("card"))
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.a)") == .valid(1024))
|
||||
}
|
||||
|
||||
/// An unusable value heals the same way — the reading is stated over usability, so the stamp is.
|
||||
@Test func aRewriteOfAnUnusableOrderStampsOverIt() throws {
|
||||
for unusable in ["order: banana", "order: .nan"] {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
let folder = try fixture.item(
|
||||
"\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\n\(unusable)\n---\nbody\n")
|
||||
|
||||
try BoardWriter.updateIndex(inItemFolder: folder, operation: .style(title: nil)) { document in
|
||||
document.set(FrontmatterKeys.title, to: .string("Renamed"))
|
||||
}
|
||||
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.a)") == .valid(1024), "\(unusable)")
|
||||
}
|
||||
}
|
||||
|
||||
/// **The board root never gains a rank** — it has no siblings to sit among, and `order` is
|
||||
/// meaningless there.
|
||||
@Test func theBoardRootIsNeverStamped() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
let root = try fixture.item("board", "---\nschema: 1\nkind: board\ntitle: Board\n---\nbody\n")
|
||||
|
||||
try BoardWriter.updateIndex(inItemFolder: root, kind: .board, operation: .style(title: nil)) { document in
|
||||
document.set(FrontmatterKeys.title, to: .string("Renamed"))
|
||||
}
|
||||
|
||||
#expect(try order(fixture, "board") == .missing)
|
||||
}
|
||||
|
||||
/// **The inline half**: a rank write is placement math landing, so the container's order-less
|
||||
/// siblings are stamped with the reading the placement was computed against — inside the same
|
||||
/// call, which is inside the caller's bracket and commit.
|
||||
@Test func aRankWriteStampsItsOrderlessSiblingsInline() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\norder: 1024\ntitle: A\n---\nbody\n")
|
||||
try fixture.item("\(Ident.lane1)/\(Child.b)", "---\nschema: 1\nkind: card\ntitle: B\n---\nbody\n")
|
||||
let c = try fixture.item("\(Ident.lane1)/\(Child.c)", "---\nschema: 1\nkind: card\ntitle: C\n---\nbody\n")
|
||||
|
||||
// The reading is A=1024, B=2048, C=3072. A drop between B and C is their midpoint — an
|
||||
// answer that is only true on disk if B and C hold those ranks.
|
||||
try BoardWriter.updateIndex(inItemFolder: c, operation: .reorder(title: nil)) { document in
|
||||
document.set(FrontmatterKeys.order, to: .double(2560))
|
||||
}
|
||||
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.a)") == .valid(1024))
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.b)") == .valid(2048))
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.c)") == .valid(2560))
|
||||
}
|
||||
|
||||
/// The pass is idempotent and silent on a board this app wrote: nothing order-less, nothing
|
||||
/// written, and no sibling's bytes touched.
|
||||
@Test func aRankWriteTouchesNoRankedSibling() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\norder: 1024\ntitle: A\n---\nbody\n")
|
||||
let b = try fixture.item("\(Ident.lane1)/\(Child.b)", "---\nschema: 1\nkind: card\norder: 2048\ntitle: B\n---\nbody\n")
|
||||
let untouched = try fixture.indexData("\(Ident.lane1)/\(Child.a)")
|
||||
|
||||
try BoardWriter.updateIndex(inItemFolder: b, operation: .reorder(title: nil)) { document in
|
||||
document.set(FrontmatterKeys.order, to: .double(512))
|
||||
}
|
||||
|
||||
#expect(try fixture.indexData("\(Ident.lane1)/\(Child.a)") == untouched)
|
||||
}
|
||||
|
||||
/// A create appends *after* the order-less sibling rather than above it — which needs that
|
||||
/// sibling stamped first, since `createChild` mints a file instead of rewriting one.
|
||||
@Test func aCreateStampsTheOrderlessSiblingItAppendsPast() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("", "---\nschema: 1\nkind: board\n---\n")
|
||||
let lane = try fixture.item(Ident.lane1, "---\nschema: 1\nkind: lane\norder: 1024\n---\n")
|
||||
try fixture.item("\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\norder: 1024\ntitle: A\n---\nbody\n")
|
||||
try fixture.item("\(Ident.lane1)/\(Child.b)", "---\nschema: 1\nkind: card\ntitle: B\n---\nbody\n")
|
||||
|
||||
let created = try BoardWriter.createCard(inLane: lane, title: "New")
|
||||
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.b)") == .valid(2048))
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(created.rawValue)") == .valid(3072))
|
||||
|
||||
let model = try BoardLoader.load(boardRoot: fixture.root).model
|
||||
#expect(model.lanes[0].cards.map(\.title.value) == ["A", "B", "New"])
|
||||
}
|
||||
|
||||
/// A move into a lane stamps the destination's order-less children **before the folder lands**,
|
||||
/// so the reading it stamps is the one the caller's placement was computed against — not one
|
||||
/// re-based against the arriving item's own foreign rank.
|
||||
@Test func aMoveStampsTheDestinationBeforeTheFolderArrives() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item("", "---\nschema: 1\nkind: board\n---\n")
|
||||
try fixture.item("\(Ident.lane1)", "---\nschema: 1\nkind: lane\norder: 1024\n---\n")
|
||||
try fixture.item("\(Ident.lane2)", "---\nschema: 1\nkind: lane\norder: 2048\n---\n")
|
||||
try fixture.item("\(Ident.lane1)/\(Child.a)", "---\nschema: 1\nkind: card\norder: 1024\ntitle: A\n---\nbody\n")
|
||||
try fixture.item("\(Ident.lane1)/\(Child.b)", "---\nschema: 1\nkind: card\ntitle: B\n---\nbody\n")
|
||||
// The arriving card carries a rank far above anything in the destination — the value that
|
||||
// would poison the reading if the stamp ran after the move.
|
||||
try fixture.item("\(Ident.lane2)/\(Child.c)", "---\nschema: 1\nkind: card\norder: 99999\ntitle: C\n---\nbody\n")
|
||||
|
||||
// The reading in lane1 is A=1024, B=2048; the drop between them is their midpoint.
|
||||
_ = try BoardWriter.moveItem(
|
||||
at: fixture.url("\(Ident.lane2)/\(Child.c)"),
|
||||
toParent: fixture.url("\(Ident.lane1)"),
|
||||
sourceBoardRoot: fixture.root,
|
||||
destinationBoardRoot: fixture.root,
|
||||
order: 1536
|
||||
)
|
||||
|
||||
#expect(try order(fixture, "\(Ident.lane1)/\(Child.b)") == .valid(2048))
|
||||
let model = try BoardLoader.load(boardRoot: fixture.root).model
|
||||
#expect(model.lanes[0].cards.map(\.title.value) == ["A", "C", "B"])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Loader integration
|
||||
|
||||
struct BoardWriterLoaderIntegrationTests {
|
||||
@@ -747,20 +918,24 @@ struct BoardWriterCreateChildTests {
|
||||
#expect(Set(result.model.lanes.map(\.id.rawValue)) == Set([Child.a, newID.rawValue]))
|
||||
}
|
||||
|
||||
@Test func aSiblingWithAMalformedOrderFailsTheCreateNamingTheSibling() throws {
|
||||
/// **A sibling with an unusable `order` no longer fails the create** (01-storage-format.md
|
||||
/// § Ordering, re-ruled 2026-07-31): it reads as append-at-end, gets stamped with that reading
|
||||
/// inline, and the new lane appends past it — which is what "append after the current visible
|
||||
/// siblings" has to mean for the result to survive a reload.
|
||||
@Test func aSiblingWithAnUnusableOrderIsStampedAndAppendedPast() throws {
|
||||
let fixture = try WriterFixture()
|
||||
defer { fixture.tearDown() }
|
||||
try fixture.item(Child.a, "---\nschema: 1\norder: banana\ntitle: A\n---\nbody\n")
|
||||
let before = try fixture.entryNames("")
|
||||
try fixture.item("", "---\nschema: 1\nkind: board\ntitle: Board\n---\n")
|
||||
try fixture.item(Ident.lane1, "---\nschema: 1\norder: 1024\ntitle: Ranked\n---\nbody\n")
|
||||
try fixture.item(Ident.lane2, "---\nschema: 1\norder: banana\ntitle: Unusable\n---\nbody\n")
|
||||
|
||||
let error = writeFailure {
|
||||
_ = try BoardWriter.createLane(inBoard: fixture.root, title: "New")
|
||||
}
|
||||
#expect(error?.reason == .unreadable(message: "malformed 'order' field: banana"))
|
||||
#expect(error?.path.contains(Child.a) == true)
|
||||
#expect(error?.operation == .createLane)
|
||||
// Nothing was minted: the scan fails before the new folder is ever created.
|
||||
#expect(try fixture.entryNames("") == before)
|
||||
let newID = try BoardWriter.createLane(inBoard: fixture.root, title: "New")
|
||||
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText(Ident.lane2)).order == .valid(2048))
|
||||
#expect(try FrontmatterDocument.parse(fixture.indexText(newID.rawValue)).order == .valid(3072))
|
||||
|
||||
let model = try BoardLoader.load(boardRoot: fixture.root).model
|
||||
#expect(model.lanes.map(\.title.value) == ["Ranked", "Unusable", "New"])
|
||||
}
|
||||
|
||||
@Test func aMissingParentFolderIsALoudUnreadableError() throws {
|
||||
|
||||
Reference in New Issue
Block a user