refactor(posts): one frontmatter read/write codec
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
#180: one PostFrontmatter module now owns the lenient read (parse/split/decoded) and every write posture — fresh stamp, merge-import, update-keys — behind one known-key table (type, pass_state, origin; one insertion order). The three near-twin walkers are deleted byte-identically: PostStore.stamped/splitFrontmatter/ mergedFrontmatter, LearningDecay.stampingFrontmatter, Post.frontmatter(of:) — 21 call sites swept across seven production files and eight test files. The Unaided First Draft eligibility is named once and consumed by both gates: isUnaidedFirstDraftPair (writer ∧ post — the scan's read-back gate) and isCaptureEligible (pair ∧ First Draft — the capture gate at pass invocation). The lenient ?? default stamp decode is extracted with it (the third copy's deferred extraction). One deliberate divergence from the absorbed writer, doc-commented and pinned: mergingImport now preserves hand-edit lines above the opening --- on import where the old split-first shape silently dropped them — lossless through every posture is the ticket's contract. Seven codec pins (PostFrontmatterTests) cover the posture round-trip (foreign keys verbatim through import → save → advance → micropub), the lenient unknown-type decode, and the predicates' truth table. Existing pieces are untouched on disk: every posture moved verbatim and the full suite pins the byte shapes (664/664 green; the one under-load flake in the #179 repoint pin is pre-existing on main, proven by a stashed-tree control run). Closes #180
This commit is contained in:
1 parent
5bf09552f6
commit
218e2db397
22 files changed
+479
-221
No files matched your search
@@ -259,7 +259,7 @@ func textRows(of model: MentorSessionModel) -> [String] {
|
||||
contentsOf: home.appendingPathComponent("projects/posts/\(post.id)/post.md"), encoding: .utf8,
|
||||
)
|
||||
// Capture fired at the invocation — the five keys ride post.md…
|
||||
let matter = Post.frontmatter(of: onDisk)
|
||||
let matter = PostFrontmatter.parse(onDisk)
|
||||
#expect(matter["stats_captured"] != nil)
|
||||
#expect(matter["stats_burstiness"] != nil)
|
||||
#expect(matter["stats_type_token_ratio"] != nil)
|
||||
@@ -283,7 +283,7 @@ func textRows(of model: MentorSessionModel) -> [String] {
|
||||
contentsOf: home.appendingPathComponent("projects/posts/\(post.id)/post.md"), encoding: .utf8,
|
||||
)
|
||||
// Stats fire at INVOCATION, not completion — a cancelled pass has them anyway…
|
||||
let matter = Post.frontmatter(of: onDisk)
|
||||
let matter = PostFrontmatter.parse(onDisk)
|
||||
#expect(matter["stats_captured"] != nil)
|
||||
#expect(matter["stats_burstiness"] != nil)
|
||||
// …while the Pass State never advanced.
|
||||
@@ -308,7 +308,7 @@ func textRows(of model: MentorSessionModel) -> [String] {
|
||||
// The pass ran (origin alone decides, never the outcome)…
|
||||
#expect(onDisk.contains("pass_state: Pass-1 Done"))
|
||||
// …but nothing was stamped — ai-origin is never stats-eligible.
|
||||
let matter = Post.frontmatter(of: onDisk)
|
||||
let matter = PostFrontmatter.parse(onDisk)
|
||||
#expect(matter["stats_captured"] == nil)
|
||||
#expect(matter["stats_burstiness"] == nil)
|
||||
}
|
||||
@@ -339,7 +339,7 @@ struct DeslopLintWiringTests {
|
||||
#expect(cards.contains { $0.pattern == "utilize" && $0.lane == .mechanical })
|
||||
// Stats capture fired at the same invocation — both hooks, one seam.
|
||||
let onDisk = try String(contentsOf: piece.appendingPathComponent("post.md"), encoding: .utf8)
|
||||
let matter = Post.frontmatter(of: onDisk)
|
||||
let matter = PostFrontmatter.parse(onDisk)
|
||||
#expect(matter["stats_captured"] != nil)
|
||||
#expect(onDisk.contains("pass_state: Pass-1 Done"))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user