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
149 lines
7.6 KiB
Swift
149 lines
7.6 KiB
Swift
import Foundation
|
|
|
|
// MARK: - Authorship
|
|
|
|
/// Which of the three classes a commit is — the axis the message engine is allowed to know about.
|
|
///
|
|
/// The composer receives it because 06-history-undo.md ▸ Commit messages gives one rule that turns
|
|
/// on it (the root commit's fixed subject) and one that deliberately does not: "**Foreign commits
|
|
/// speak the same vocabulary.** Origin lives in the author field (structural attribution), not in
|
|
/// message prose — a foreign move reads 'Move card …' exactly like an app-mediated one". The
|
|
/// composer card therefore gets the fact and is expected to ignore it for phrasing; having it means
|
|
/// it never has to be plumbed later, and having it *named* means the rule about not using it has
|
|
/// something to point at.
|
|
public enum CommitAuthorship: Sendable, Equatable {
|
|
/// The user acting through the app.
|
|
case user
|
|
/// A scheduled heal's own commit (ruled 2026-07-29).
|
|
case heal
|
|
/// Everything else, carrying the author it will be committed under.
|
|
case foreign(GitIdentity)
|
|
}
|
|
|
|
// MARK: - The request
|
|
|
|
/// Everything the message engine is handed for one commit.
|
|
///
|
|
/// **A struct rather than an argument list**, because the point of this seam is that the semantic
|
|
/// composer plugs into it without reshaping the engine: any input it turns out to need joins this
|
|
/// type rather than every call site. It did need two — `previousSnapshot` and `agentGuideText`, both
|
|
/// below — and that is exactly what this shape was for.
|
|
///
|
|
/// **Everything here is a value, and that is the design.** The composer (`CommitMessageEngine`) reads
|
|
/// no file and opens no repository: the flush resolves the environment once — the board as HEAD has
|
|
/// it, the board as the app has it, the guide's bytes — and the message is then a pure function of
|
|
/// this struct. Resolving once per *flush* rather than once per planned commit also means a
|
|
/// three-way-split window materializes HEAD's tree once, not three times.
|
|
public struct CommitMessageRequest: Sendable {
|
|
|
|
/// The board this is a commit in.
|
|
public let boardRoot: URL
|
|
|
|
/// **The changed-path list** (06 ▸ Commit messages ▸ Non-snapshot files commit too: "beside the
|
|
/// snapshot diff it receives the changed-path list, and non-snapshot paths compose *path-shaped
|
|
/// events*"), narrowed to the paths *this* commit stages.
|
|
public let changedPaths: [GitChangedPath]
|
|
|
|
/// Which class this commit is.
|
|
public let authorship: CommitAuthorship
|
|
|
|
/// Whether this is the repository's first commit — the one commit with a subject of its own
|
|
/// ("Initial board state", 06 ▸ Rules ▸ Abnormal repo states).
|
|
public let isRootCommit: Bool
|
|
|
|
/// **The current half** of the composer's "last-committed vs. current" diff — the board as the
|
|
/// app last read it, or, where no store is attached, as the flush read it off disk itself.
|
|
///
|
|
/// `nil` only when neither could answer: a board whose working tree does not load at all, which
|
|
/// is a commit that will have to be described by its paths.
|
|
public let snapshot: BoardModel?
|
|
|
|
/// **The last-committed half**: the board as HEAD's tree has it (`GitHeadSnapshot`).
|
|
///
|
|
/// `nil` on an unborn HEAD — where `isRootCommit` already says everything — and on a HEAD whose
|
|
/// tree does not load as a board. It is read from the repository rather than carried forward from
|
|
/// the last commit the app made, because the app is not the only writer and because launch
|
|
/// catch-up has no carried value to offer: see `GitHeadSnapshot` for the whole of that argument.
|
|
public let previousSnapshot: BoardModel?
|
|
|
|
/// **The board-root `CLAUDE.md` as it now reads**, when this commit touches it — the one
|
|
/// non-snapshot file with a subject of its own ("Update agent guide (vN)", 06 ▸ Commit messages).
|
|
///
|
|
/// The *text*, not the version: N is "a pure function of file content"
|
|
/// (`AgentGuide.installedVersion`), and keeping the parse on the composer's side is what keeps
|
|
/// that rule where the message vocabulary is. `nil` when the guide is not in this commit, cannot
|
|
/// be read, or has been deleted.
|
|
public let agentGuideText: String?
|
|
|
|
/// **When each of this commit's comments was created** — keyed by the comment folder's
|
|
/// board-root-relative path, as `CommitMessageEngine.commentFolder(of:)` spells it.
|
|
///
|
|
/// The second value on this struct that a *file* has to be read for, and it is here for
|
|
/// `agentGuideText`'s reason exactly: "a commit's comment bullets sort chronologically — by the
|
|
/// comments' own `created`, folder name on ties" (06 ▸ Rules ▸ Auto-commit, blessed 2026-07-31),
|
|
/// and `created` lives in a comment's own `index.md` because comments are window-scoped and the
|
|
/// board snapshot never carries them (01-storage-format.md § Enhanced schema). The flush resolves
|
|
/// it once (`GitAutoCommitter.commentTimestamps(for:boardRoot:)`) and the engine stays a pure
|
|
/// function of values.
|
|
///
|
|
/// **Missing is normal, not a defect.** A comment whose folder left the tree in this very commit
|
|
/// (the close purge), one whose `index.md` does not parse, one written by hand with no `created`
|
|
/// at all — each is simply absent here and sorts after its dated siblings in folder-name order,
|
|
/// which is `CommentThread.sorted`'s own fallback for the same field.
|
|
public let commentTimestamps: [String: Date]
|
|
|
|
public init(
|
|
boardRoot: URL,
|
|
changedPaths: [GitChangedPath],
|
|
authorship: CommitAuthorship,
|
|
isRootCommit: Bool,
|
|
snapshot: BoardModel?,
|
|
previousSnapshot: BoardModel? = nil,
|
|
agentGuideText: String? = nil,
|
|
commentTimestamps: [String: Date] = [:]
|
|
) {
|
|
self.boardRoot = boardRoot
|
|
self.changedPaths = changedPaths
|
|
self.authorship = authorship
|
|
self.isRootCommit = isRootCommit
|
|
self.snapshot = snapshot
|
|
self.previousSnapshot = previousSnapshot
|
|
self.agentGuideText = agentGuideText
|
|
self.commentTimestamps = commentTimestamps
|
|
}
|
|
}
|
|
|
|
// MARK: - The seam
|
|
|
|
/// **What a commit says** (06-history-undo.md ▸ Commit messages).
|
|
///
|
|
/// The implementation is `SemanticCommitMessage` below, over `CommitMessageEngine`: "a pure, testable
|
|
/// function" composing from a structural diff of two board snapshots, with the whole
|
|
/// Add/Delete/Move/Rename/Edit vocabulary, plural folding, path-shaped events for non-snapshot files,
|
|
/// and the trash pair. The protocol survives its interim purpose because it is still what lets a test
|
|
/// inject a fake and assert *when* a message was asked for without asserting what it said.
|
|
///
|
|
/// `Sendable` because composition runs off the main actor, inside the same detached task that stages
|
|
/// and commits — the message has to be in hand before `git_commit_create` is called, and none of the
|
|
/// work is main-actor work.
|
|
public protocol CommitMessageComposing: Sendable {
|
|
func message(for request: CommitMessageRequest) -> String
|
|
}
|
|
|
|
// MARK: - The wired composer
|
|
|
|
/// **The semantic composer**, and the committer's default (`GitAutoCommitter.composer`).
|
|
///
|
|
/// A one-line conformance over `CommitMessageEngine`, deliberately: the vocabulary is worth a file of
|
|
/// its own and nothing about it should have to know that a protocol exists. The type stays because
|
|
/// the seam takes an existential, and because a *named* default is what makes "the engine's composer
|
|
/// is the semantic one" assertable.
|
|
public struct SemanticCommitMessage: CommitMessageComposing {
|
|
|
|
public init() {}
|
|
|
|
public func message(for request: CommitMessageRequest) -> String {
|
|
CommitMessageEngine.message(for: request)
|
|
}
|
|
}
|