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
6.4 KiB
6.4 KiB
Build S1: storage substrate — projects/ + archive/, type frontmatter (#107)
Date: 2026-10-13 Type: issue Reference: #107 (map: #97, ADR-0012)
Goal
Re-root the piece storage substrate per #107 / ADR-0012: posts/<id>/ → projects/<name>/<id>/ + archive/<name>/<id>/ (two-level scan), global slug namespace across both roots, type: post frontmatter stamped by New/Import and read leniently, every PostStore write path deriving its folder from the id alone. No UI change beyond what the paths force.
What Was Done
PostLibrary.swift—Postgainstype(ContentTypepost|outline),project,isArchived;Post.scanwalks both roots (projects,archive) with the same skip guards at both levels;typeread leniently (absent/unknown → post); audit fix: first-wins dedupe by id in the same deterministic orderfolder(of:)resolves (projects-before-archive, name-sorted).PostStore.swift— newfolder(of:home:)id→folder resolver (every write path derives its target from the id; nothing threads(project, id));availableSlug(for:home:)over the global namespace (all entries underprojects/*/+archive/*/; archived slug never reused);writeNew(body:project:home:)+importFile(at:origin:project:home:)land under the selected project else defaultposts;stamped/mergedFrontmattercarrytype: postas the third our-key (first in the block, order pinned by tests);overwrite/readBody/cursor sidecar/rename/trashresolve viafolder(of:); audit fix:folder(of:)project loop applies scan's skip guards (dot-dirs, symlinks) so a hidden project can't shadow a visible piece;mergedFrontmatterkey-rewrite folded into one ordered-pairs loop (complexity 11 → lint-clean).PostsModel.swift—PostDraftcarriesproject; sharedtargetProject(selected non-archived post's project, else default) feedsnewPost()+importFiles; watcher roots →projects/+archive/(both created bybind);PostsWatcher.start(urls:)takes an array.EditorSession.swift—folderURLis a stored property resolved once at init viaPostStore.folder(of:)(fallbackprojects/posts/<id>for a vanished piece), + test pinning the fallback.PostEditorView.swift/PostsPaneView.swift/SettingsPaneView.swift— breadcrumb renders the real<root> / <project> / <id> / post.mdpath; empty-state + repoint copy updated.- Tests (4 files) — all fixtures re-rooted to
projects/posts/<id>/; new cases: two-level scan across projects+archive, lenienttype, archived-slug-never-reused,writeNew(project:)routing, rename-within-project + archive-stays-archived, trash-from-archive, externaltype: outlineoverwritten at import, unresolvable-id fallback, duplicate-id dedupe, hidden-project shadowing. - Manual step done: the 4 dev posts moved by hand to
~/Documents/Museion/projects/posts/<id>/, oldposts/root removed (no migration machinery — the app never reads it, #103). - DOX: Museion/AGENTS.md + MuseionTests/AGENTS.md truth-passed for the new layout.
Decisions & Rationale
| Decision | Rationale |
|---|---|
Write paths resolve folder from id (folder(of:)), never thread (project, id) |
ADR-0012: Piece ID is the durable identity; keeps sessions/sidecars/callers unchanged |
Duplicate-id dedupe in scan, first-wins in folder(of:)'s exact order |
Audit (security + general converged): a Finder copy across projects made every id-addressed write land on the sorted-first twin — silent wrong-piece edits/trash. One precedence, shared by row and write target |
folder(of:) skips dot-dirs/symlinks like scan |
Same audit: projects/.trash/<id> sorted before visible projects and captured all writes |
type: post stamped/normalized on save (unknown values → post) |
Same our-keys-win rule #59 pinned for pass_state/origin; lenient-read + normalize-on-save |
| Import lands in the selected project (not just New) | Consistency: both are "new piece lands somewhere"; one targetProject helper |
| Deferred: per-piece write-refusal on ambiguous ids | Dedupe removes the wrong-write defect for S1; refusal UX belongs to S2's in-app moves slice |
Gotchas & Fixes
| Problem | Root Cause | Fix |
|---|---|---|
One xcodebuild test run printed ** TEST FAILED ** mid-verification |
Every xcresult bundle in the window records 0 failing tests — runner-level flake (two parallel suite runs) | Re-ran; green ×3 since, incl. final full suite |
swiftformat . reformatted spike/, prototypes/, 3 unrelated app files |
Ran tree-wide instead of scoped | git checkout -- the strays; scoped format after (happened twice — child did it too) |
folder(of:) compile error: URL vs String |
Converted listing to URL-based but still appended project directly |
project.lastPathComponent |
| Dedupe guard placed before the post.md read | A lazy folder would consume the id before its readable twin | Moved seen.insert after the read |
Files Changed
| File | Change Summary |
|---|---|
Museion/PostLibrary.swift |
two-level scan, ContentType/project/isArchived, duplicate-id dedupe |
Museion/PostStore.swift |
folder(of:) resolver, global availableSlug, project-aware write paths, type stamping |
Museion/PostsModel.swift |
PostDraft.project, targetProject, watcher on both roots |
Museion/EditorSession.swift |
stored folderURL resolved at init |
Museion/PostEditorView.swift |
real-path breadcrumb |
Museion/PostsPaneView.swift |
header + empty-state copy |
Museion/SettingsPaneView.swift |
repoint copy |
MuseionTests/{PostLibrary,PostStore,EditorSession,ImportExternal}Tests.swift |
re-rooted fixtures + 10 new cases |
Museion/AGENTS.md, MuseionTests/AGENTS.md, AGENTS.md |
DOX truth-pass + log window |
Open Items & Next Steps
- S2 of map #97: library UI (variant B project sections, Archive nav-rail) + in-app project commands — the substrate carries
project/isArchivedfor it - Flag on #107 when closing: "selected project" reads as "selected non-archived post, else default" in the implementation
- Per-piece duplicate-id write-refusal (or in-app resolution UX) if S2's moves make duplicates reachable from the app
- Ceiling comments name the O(projects) walks (
folder(of:),availableSlug) — cache only if they ever measure hot
Log written by write-log skill