feat(mentor): dismiss & decay Learnings (#27)
CI / ci (push) Canceled after 0s
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:
1 parent
0e5c28ad95
commit
78c8844184
15 files changed
+911
-66
No files matched your search
@@ -25,7 +25,7 @@ private func makeHome(_ write: (URL) throws -> Void) throws -> URL {
|
||||
}
|
||||
|
||||
/// Seeds <home>/learnings/<type>/<file> with raw markdown.
|
||||
private func writeLearning(_ home: URL, _ type: String, _ file: String, _ markdown: String) throws {
|
||||
func writeLearning(_ home: URL, _ type: String, _ file: String, _ markdown: String) throws {
|
||||
let dir = home.appendingPathComponent("learnings/\(type)", isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
try markdown.write(to: dir.appendingPathComponent(file), atomically: true, encoding: .utf8)
|
||||
@@ -123,4 +123,67 @@ struct LearningsPaneTests {
|
||||
let home = try makeHome { _ in }
|
||||
#expect(LearningsIndex.scan(home: home).isEmpty)
|
||||
}
|
||||
|
||||
// MARK: Decay surface (#27, S4.2)
|
||||
|
||||
/// Scenario: Entry carries the decay verdict — visible learnings read
|
||||
/// resurfacesIn nil; a dismissed one (anchor 2, once-dismissed =
|
||||
/// interval 10) at pass 5 has 7 passes left; a twice-dismissed one
|
||||
/// (interval 20) has 17.
|
||||
@Test func `entry resurfacesIn pins the remaining-pass math`() {
|
||||
#expect(LearningsIndex.Entry(
|
||||
file: "20261021-fold-the-ladder.md",
|
||||
text: "---\npattern: Fold the ladder\n---\n",
|
||||
).resurfacesIn == nil)
|
||||
|
||||
#expect(LearningsIndex.Entry(
|
||||
file: "20261020-hedging.md",
|
||||
text: "---\npattern: Hedging\ndismiss_count: 1\ndismissed_at_pass: 2\n---\n",
|
||||
currentPass: 5,
|
||||
).resurfacesIn == 7)
|
||||
|
||||
#expect(LearningsIndex.Entry(
|
||||
file: "20261020-hedging.md",
|
||||
text: "---\npattern: Hedging\ndismiss_count: 2\ndismissed_at_pass: 2\n---\n",
|
||||
currentPass: 5,
|
||||
).resurfacesIn == 17)
|
||||
}
|
||||
|
||||
/// Scenario: scan feeds the pass clock from pass-counts.json — the
|
||||
/// dismissed fixture computes against the Home's counts, not zero.
|
||||
/// Foreign (unclocked) dirs carry NO verdict even when hand-edited
|
||||
/// decay state sits in the file — their clock never advances, a
|
||||
/// countdown would lie (the store refuses to dismiss there; #27 audit).
|
||||
@Test func `scan carries the pass clock into entries`() throws {
|
||||
let home = try makeHome { home in
|
||||
try writeLearning(home, "posts", "20261020-hedging.md", """
|
||||
---
|
||||
pattern: Hedging
|
||||
dismiss_count: 1
|
||||
dismissed_at_pass: 2
|
||||
---
|
||||
|
||||
# Hedging
|
||||
""")
|
||||
try writeLearning(home, "posts", "20261021-fold.md", "---\npattern: Fold\n---\n")
|
||||
try writeLearning(home, "essays", "20261019-musing.md", """
|
||||
---
|
||||
pattern: Musing
|
||||
dismiss_count: 1
|
||||
dismissed_at_pass: 2
|
||||
---
|
||||
""")
|
||||
}
|
||||
try "{\"outlines\": 99, \"posts\": 5}".write(
|
||||
to: home.appendingPathComponent("learnings/pass-counts.json"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
|
||||
let posts = try #require(LearningsIndex.scan(home: home).first { $0.type == "posts" })
|
||||
#expect(posts.entries.first { $0.id == "20261020-hedging.md" }?.resurfacesIn == 7)
|
||||
#expect(posts.entries.first { $0.id == "20261021-fold.md" }?.resurfacesIn == nil)
|
||||
let essays = try #require(LearningsIndex.scan(home: home).first { $0.type == "essays" })
|
||||
#expect(essays.entries.first?.resurfacesIn == nil) // foreign: no verdict, no lying countdown
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user