Commit Graph
11 Commits
Author SHA1 Message Date
AlexKucera 218e2db397 refactor(posts): one frontmatter read/write codec
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
2026-11-10 10:21:32 +01:00
AlexKucera a2f6dc1653 perf(library): memoize scan parses per save (#143)
CI / ci (push) Canceled after 0s
Every FSEvents change — each 1 s autosave echo — ran Post.scan over the
whole library: read + frontmatter parse + title per post.md, O(library
bytes) per save cycle while writing, and the posts array was replaced
unconditionally, so every observing pane regrouped and re-rendered even
when nothing changed.

Post.scan now takes an optional PostScanCache (path+mtime+size-keyed
parse memo, nil default — every other caller unchanged): the readdir
walk stays the truth, only changed files are read and re-parsed. The
stamp is captured BEFORE the read and keys the store, so a mid-scan
rewrite can never be pinned as fresh — a late overlapping store keys
its own pre-read stamp and the next scan misses (review-caught race,
pinned by a same-size-rewrite test). rescan skips the posts assignment
when the scan equals the current list; @Observable invalidates on
assignment regardless of equality, so panes stop re-rendering on the
app's own autosave echoes.

Deliberately skipped (measured cold): folder(of:) caching (stat-only
walk) and refreshCards throttling (O(open piece), card surfacing
depends on it).

Closes #143
2026-11-03 11:19:50 +01:00
AlexKucera 414f1392ef feat(publish): Micropub draft → publish (#33)
CI / ci (push) Canceled after 0s
Two-step publish to Micro.blog over Micropub: Send as Draft (JSON
h=entry create — name = the Title, markdown content verbatim,
post-status draft), review via the preview link, then Publish (the
action=update post-status flip). The piece remembers its draft URL
as a frontmatter micropub_url stamp — in-place, body and foreign
keys byte-identical — so a draft survives a reopen; Send Again
re-drafts after edits. The app token lives in the Keychain (login
keychain; entered once in the sheet, re-offered only on auth
failure — ADR-0014's no-Keychain rule covers only provider keys
hermes reads from .env). Frontmatter category: is permitted but
never sent in v1 — pinned on the wire.

The draft URL is trust-boundary data landing in frontmatter, so
every URL passes a format gate (https + host, no line/control
characters) at BOTH ends: the response decode (Location header →
body url; the preview link is display-only, never the publish
target) and Post.scan's read-back — imported frontmatter rides
verbatim, and a newline--- rider would otherwise close the block
and reparse as attacker markdown in the writer's piece.

Twenty tests pin the wire contract, decode matrix, own-slot keychain
round-trip, stamp/scan, and the model flow (flush-first, refusal
guards, the category AC); all four audit guards are flip-verified.
Full suite 529 passed / 0 failed. Live end-to-end on a real post
(needs the owner's app token) remains open on the ticket.
2026-10-31 17:49:50 +01:00
AlexKucera 3ee6756467 feat(stats): trend view — the writer's arc (#32)
CI / ci (push) Canceled after 0s
A Trends pane (rail destination after Learnings — measurement beside
memory): one line chart per style metric (burstiness, type-token ratio,
sentence variation, trigram repetition) across unaided-first-draft
CAPTURES over time. Points are capture moments, never draft grades —
the pane answers "am I getting better," not "is this draft good." Each
card carries a first-to-last read (improving/steady/slipping at ±0.01,
direction inverted for trigram repetition — the one falling-is-better
metric; one capture shows its value with no verdict), an up/down-better
hint, and a one-line plain-language gloss of the term.

The edited-text leak is closed by construction: Post.scan reads the
five stats_* frontmatter keys into firstDraftStats only when every key
parses to a finite double AND the piece carries the capture gate's
immutable pair (origin writer, type post — not pass_state, which
legitimately advances after the capture). Import carries external YAML
verbatim, so imported ai pieces or outlines with hand-stamped keys
never render, while a migrated writer piece keeps its real arc. The
finite gate also kills a deterministic crash: Double("nan") parses, and
a non-finite peak traps the chart's y-domain construction.

The pane rides PostsModel's watched scan — no scan of its own — so it
refreshes with the library. Fixed y-domains keep single captures
visible (sentence variation scales to its peak); offset-keyed chart
identity and a title tie-break make same-second capture twins
deterministic; the empty state names how the data arrives.

Finish-audit (3 reviewers) fixed the nan/inf crash, the import leak,
same-second ordering, and cut the injectable tolerance parameter and a
label-switch enum down to raw values. Suite 508; the non-finite and
read-back-gate pins are flip-verified.

Closes #32
2026-10-31 15:12:45 +01:00
AlexKucera a4ea914690 style: swiftformat pass — drift from the format gate
CI / ci (push) Canceled after 0s
Whole-tree swiftformat/swiftlint run during #136 flagged 9 files
drifted (/// doc markers on private members, one force-unwrap to
#require). Comment- and lint-only, no code change.
2026-10-27 18:32:30 +01:00
AlexKucera 78c8844184 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
2026-10-21 14:19:43 +02:00
AlexKucera 3ca9d4e601 feat(library): projects & archive substrate — S1 (#107)
CI / ci (push) Canceled after 0s
Pieces re-root from posts/<id>/ to projects/<name>/<id>/ with an
archive/ twin root (ADR-0012): scan walks both levels, New Piece and
Import land in the selected project else the default posts, the slug
namespace is global across projects and archive (an archived slug is
never reused), and every piece carries type: post frontmatter —
stamped by New/Import, read leniently (absent or unknown reads as
post), the file stays post.md for every content type. Write paths
resolve the folder from the id alone (folder(of:)); sessions and
sidecars never thread (project, id).

Finish-audit hardening: duplicate ids on disk (Finder copy) dedupe in
scan to the same first-match folder(of:) writes to; folder(of:) skips
hidden/symlinked projects like scan does.

Dev posts moved by hand to projects/posts/ — no migration machinery,
the app never reads the old posts/ root (#103). Full suite green
(128 unit + UI), swiftlint clean on changed files.

Closes #107
2026-10-13 17:44:44 +02:00
AlexKucera 0f1c4ef4fe feat(posts): import & external markdown — S1.1 (#22)
CI / ci (push) Canceled after 0s
External .md/.markdown opens and edits as-is in a single guest slot
(File > Open... Cmd+O, drag-onto-window): SessionTarget extends
EditorSession to write in place verbatim, no cursor sidecar, the #67
conflict alert reused for foreign files. Import... (Shift+Cmd+O)
copies multi-select files in as Posts behind ONE Origin ask
(writer default, immutable); external frontmatter keys ride verbatim
with pass_state/origin set; slug/collision machinery shared with
writeNew.

Audit fixes folded in: BOM stripped + CRLF normalized at the trust
boundary (a CRLF pair is one Swift grapheme — \n splits saw one
line); unreadable files refuse to open (loadFailed — a failed read
never becomes a write); dropped web links and severed symlinks
guarded; ~24 lines of reviewer-flagged dead weight removed.

7 new tests; full unit + UI suite green; swiftlint clean.

Map #22 stays open pending the live calibration pass (#88 posture).
2026-10-12 17:00:03 +02:00
AlexKucera 530f852f75 feat(workspace): land Post lifecycle (S1.1)
CI / ci (push) Canceled after 0s
Posts become writable end to end per the #18 map decisions:
New Post holds an in-memory draft (folder appears only on first
save), first save stamps the flat frontmatter block the #17
reader already parses (pass_state First Draft, origin writer,
immutable after stamping), and the Post ID is the Title slug with
case-insensitive collision suffixes. Explicit Rename retitles the
# Title line and moves the folder (post.md stays); Delete goes to
Trash. A recursive FSEvents stream keeps the list mirroring
posts/ — external Finder edits included.

Editor is a deliberate TextEditor stub; #19's TextKit2 editor
replaces it in place while the lifecycle machinery below the view
survives the swap.

Two review rounds (standards/spec + finish-audit fanout) fixed:
watcher start-order bug, writeNew clobber race, overwrite
resurrecting vanished posts with reset origin, rename destroying
non-heading first lines, draft hijacking the editor, debounce
starvation under churn.

Tests: 75/75 (17 new). Closes #18.
2026-10-03 13:34:00 +02:00
AlexKucera 765d32d4d4 refactor(workspace): finish-audit fixes — off-main scan, parser edges, dead code out
Reviewers' findings on 804b588: scan moved off MainActor (Task.detached),
PostLibrary struct folded into Post.scan, hidden dirs and symlinked dirs
now actually skipped (test de-vacuated), unterminated frontmatter no longer
leaks as the Title, quoted YAML values unquoted, leading blank line before
--- tolerated, #-only body reads untitled, persisted Home validated
isFileURL. Dead code deleted: radiusLarge, editorMinWidth, homeKey,
PaneHeader trailing slot, Settings ScrollView, PostRow fill dance.
Tests 56/56, lint 0.

[Generated by AI]
2026-10-01 13:43:25 +02:00
AlexKucera 804b5889f6 feat(workspace): add M1 Home & Posts list — nav rail, posts mirror, Home repoint (fixes #17)
The post-gate main surface is the workspace shell from the design
contract: nav rail (Posts/Sessions/Learnings/Settings), Posts pane
mirroring <home>/posts/ on disk (Pass State groups, origin meta,
empty state; lazy folders skipped), Settings pane with repoint-only
Home picking (NSOpenPanel + UserDefaults, default ~/Documents/Museion
per b3daac9), placeholder panes until #28/#26. Column collapse
mirrors the export's media queries so narrow windows never clip.
Mentor pane becomes the fourth column (#14 surface preserved).

[Generated by AI]
2026-10-01 13:14:55 +02:00