feat(mentor): promote & consult Learnings (#26)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Only the writer's explicit confirmation promotes a Fix Card into a Learning — one confirm, one entry, never a repetition counter. The Learning is a plain markdown file under <home>/learnings/<type>s/ carrying the card's teaching fields (pattern, problem, diagnostic question, the demonstration example) plus promotion provenance; the instance-bound anchor and mechanical replacement stay on the card. Every pass consults these files via query_learnings; the Learnings pane replaces its placeholder. Promote consults the on-disk card as the truth and rejects symlinked learnings paths before any write (finish-audit round). Dismiss/decay follows in #27. Closes #26
This commit is contained in:
1 parent
154bb8a114
commit
0e5c28ad95
18 files changed
+1133
-82
No files matched your search
@@ -954,3 +954,33 @@ extension PostsModel {
|
||||
refreshCards(home: home)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Fix Card promote (#26, S4.1/S4.3)
|
||||
|
||||
/// #26 (S4.1): what Promote did — the Learning landed, or the operation
|
||||
/// refused with a reason (the ask sheet shows it; lastError carries it).
|
||||
enum FixCardPromoteOutcome: Equatable {
|
||||
case promoted
|
||||
case refused(String)
|
||||
}
|
||||
|
||||
extension PostsModel {
|
||||
/// #26 (S4.1/S4.3): Promote a card into ONE plain markdown Learning
|
||||
/// under `<home>/learnings/<type>s/` — the writer's EXPLICIT
|
||||
/// confirmation only (one confirm = one entry, never a repetition
|
||||
/// counter; the store guarantees the one-stamp rule). Touches no text
|
||||
/// and flushes nothing: this writes a Learning, not an edit.
|
||||
@discardableResult
|
||||
func promoteCard(_ card: FixCardStore.StoredFixCard, home: URL) -> FixCardPromoteOutcome {
|
||||
guard card.promotedAt == nil else { return .refused("card already promoted") }
|
||||
guard let session else { return .refused("open the piece to work its cards") }
|
||||
do {
|
||||
_ = try FixCardStore.promote(pieceURL: session.passPieceURL, card: card)
|
||||
} catch {
|
||||
lastError = "learning write failed: \(error.localizedDescription)"
|
||||
return .refused("learning write failed: \(error.localizedDescription)")
|
||||
}
|
||||
refreshCards(home: home)
|
||||
return .promoted
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user