feat(mentor): dismiss & decay Learnings (#27)
CI / ci (push) Canceled after 0s

Dismissed patterns fade instead of haunting. Dismissing a Learning
stamps decay state into its own frontmatter (dismissed date,
dismiss_count, dismissed_at_pass — every other line preserved
verbatim, hand-editable, git-diffable) and hides it from every pass:
query_learnings serves only visible learnings. Resurfacing is an
output clock, not a calendar — a per-type counter under
<home>/learnings/pass-counts.json, ticked by every completed pass
(cancels and refusals never advance, so never tick), returns the
Learning after 10 subsequent passes of its content type; each
re-dismiss doubles the interval (10→20→40…), and a per-Learning
resurface_after frontmatter key overrides the base. Hand-edited decay
state reads leniently: garbage means visible, absurd values clamp, a
hand-edit can never trap the pane or the rail. The Learnings pane
rows dismiss (no confirm — low-stakes, self-healing), dim while
hidden with a resurfaces-in-N countdown, and foreign unclocked type
dirs neither offer Dismiss nor show a verdict — their clock can never
advance. Two review waves (two-axis implement review + three-reviewer
finish-audit: security clean) produced five fixes, each pinned or
noted in the session log.

Closes #27
This commit is contained in:
AlexKucera committed 2026-10-21 14:19:43 +02:00
1 parent 0e5c28ad95
commit 78c8844184
15 files changed
+911 -66

No files matched your search

+12 -10
View File
@@ -282,8 +282,9 @@ nonisolated enum FixCardStore {
}
/// en_US_POSIX date formatting, created per access — no non-Sendable
/// statics (repo convention). stamp() and promote's day stamps share it.
private static func formatted(_ date: Date, _ format: String) -> String {
/// statics (repo convention). stamp(), promote's day stamps, and
/// LearningDecay's dismiss stamp (#27) share it.
static func formatted(_ date: Date, _ format: String) -> String {
let formatter = DateFormatter()
formatter.dateFormat = format
formatter.locale = Locale(identifier: "en_US_POSIX")
@@ -393,22 +394,23 @@ nonisolated enum FixCardStore {
/// `<home>/learnings/<type>s/` (LITERAL plural — "posts", "outlines"),
/// name-sorted. Raw contents, no parsing — the pass rail consults
/// exactly these files (query_learnings; #26 promote writes them).
/// Missing dir → empty (fresh start is the correct v1 answer); a
/// missing piece still throws.
// ponytail: decay filtering is pass-through until a decay policy is
// defined on the #26 frontmatter fields.
/// #27 (S4.2): dismissed learnings stop feeding passes until their
/// decay interval elapses — LearningDecay.passesHidden filters them
/// out here. Missing dir → empty (fresh start is the correct v1
/// answer); a missing piece still throws.
static func learnings(piecePath: String) throws -> [(file: String, markdown: String)] {
let postURL = try resolvePostURL(piecePath)
let text = try String(contentsOf: postURL, encoding: .utf8)
let (home, type) = homeAndType(postURL: postURL, text: text)
let dir = learningsDir(home: home, type: type)
let currentPass = LearningDecay.passCounts(home: home)[LearningDecay.passKey(type)] ?? 0
let files = ((try? FileManager.default.contentsOfDirectory(atPath: dir.path)) ?? [])
.filter { $0.hasSuffix(".md") }
.sorted()
return files.compactMap { name in
guard let markdown = try? String(contentsOf: dir.appendingPathComponent(name), encoding: .utf8) else {
return nil
}
guard let markdown = try? String(contentsOf: dir.appendingPathComponent(name), encoding: .utf8),
LearningDecay.passesHidden(Post.frontmatter(of: markdown), currentPass: currentPass) == nil
else { return nil }
return (file: name, markdown: markdown)
}
}
@@ -417,7 +419,7 @@ nonisolated enum FixCardStore {
/// LITERAL plural ("posts", "outlines"). ADR-0005: Museion owns these
/// files, the engine profile never does.
static func learningsDir(home: URL, type: Post.ContentType) -> URL {
home.appendingPathComponent("learnings/\(type.rawValue)s", isDirectory: true)
home.appendingPathComponent("learnings/\(LearningDecay.passKey(type))", isDirectory: true)
}
/// post.md URL + its text → (Home, content type) — the ADR-0012 layout