feat(mentor): promote & consult Learnings (#26)
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:
AlexKucera committed 2026-10-21 12:13:24 +02:00
1 parent 154bb8a114
commit 0e5c28ad95
18 files changed
+1133 -82

No files matched your search

+10 -36
View File
@@ -12,8 +12,9 @@ import Foundation
@testable import Museion
import Testing
/// Throwaway Home in a temp dir (PostStoreTests convention).
private func toolsHome(_ write: (URL) throws -> Void = { _ in }) throws -> URL {
/// Throwaway Home in a temp dir (PostStoreTests convention). Internal —
/// MCPToolsPromoteTests shares it (cross-file convention).
func toolsHome(_ write: (URL) throws -> Void = { _ in }) throws -> URL {
let home = FileManager.default.temporaryDirectory
.appendingPathComponent("mcp-tools-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
@@ -22,9 +23,10 @@ private func toolsHome(_ write: (URL) throws -> Void = { _ in }) throws -> URL {
}
/// One piece under projects/posts/<id>/post.md; returns the piece folder.
/// `type: nil` writes no frontmatter block at all.
/// `type: nil` writes no frontmatter block at all. Internal —
/// MCPToolsPromoteTests shares it (cross-file convention).
@discardableResult
private func writePiece(
func writePiece(
_ home: URL,
id: String = "test-piece",
type: String? = "post",
@@ -39,7 +41,8 @@ private func writePiece(
/// One wire-shaped card with test-friendly defaults. Internal — shared
/// with PostsModelTests and FixCardApplyTests (review: a hand-copy drifted
/// here). #25: `fix`/`lane` feed the apply pins.
/// here). #25: `fix`/`lane` feed the apply pins; #26: `provenance` feeds
/// the promote pins.
func card(
pattern: String = "Hedging",
problem: String = "The hedge weakens the claim.",
@@ -48,6 +51,7 @@ func card(
quote: String = "repeated anchor line",
occurrence: Int = 1,
lane: FixCardStore.StoredFixCard.Lane = .mechanical,
provenance: FixCardStore.StoredFixCard.Provenance? = nil,
) -> FixCardStore.Input {
FixCardStore.Input(
pattern: pattern,
@@ -57,37 +61,7 @@ func card(
anchor: .init(quote: quote, occurrence: occurrence),
lane: lane,
emitter: .lint,
provenance: nil,
)
}
/// A fully-stamped card for hand-written fixtures (scan tests). Defaults
/// match the historical shape; apply tests override anchor/lane, the rank
/// pins override submittedAt/rank. Internal — FixCardApplyTests shares it
/// (the card()/makeModelHome cross-file convention).
func storedCard(
pattern: String = "P",
quote: String = "q",
occurrence: Int = 1,
fix: String = "",
lane: FixCardStore.StoredFixCard.Lane = .mechanical,
submittedAt: Date = Date(timeIntervalSince1970: 0),
rank: Int? = nil,
) -> FixCardStore.StoredFixCard {
FixCardStore.StoredFixCard(
id: UUID(),
submittedAt: submittedAt,
rank: rank,
pattern: pattern,
problem: "p",
diagnosticQuestion: "",
fix: fix,
anchor: .init(quote: quote, occurrence: occurrence),
lane: lane,
emitter: .lint,
provenance: nil,
status: .open,
anchorStatus: .valid,
provenance: provenance,
)
}