Merge m1-home-posts-list: M1 Home & Posts list (#17)
CI / ci (push) Canceled after 0s

Workspace shell from the design contract: nav rail, Posts pane mirroring
the Home's posts/ on disk, Settings repoint, finish-audit fixes (off-main
scan, parser edges, dead code out). 56/56 tests.

[Generated by AI]

# Conflicts:
#	AGENTS.md
#	docs/devlog/INDEX.md
This commit is contained in:
AlexKucera committed 2026-10-01 15:53:59 +02:00
commit e5490ed290
15 files changed
+838 -23

No files matched your search

+20 -18
View File
@@ -129,29 +129,30 @@ Single-context: `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/do
<!-- gitnexus:start -->
# GitNexus — Code Intelligence
This project is indexed by GitNexus as **museion** (965 symbols, 1676 relationships, 31 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
This project is indexed by GitNexus as **museion** (1308 symbols, 2519 relationships, 39 execution flows).
> Index stale? Run `node .gitnexus/run.cjs analyze` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? `npx gitnexus analyze` (npm 11 crash → `npm i -g gitnexus`; #1939).
> Index stale? Run `node .gitnexus/run.cjs analyze --index-only` from the project root — it auto-selects an available runner. No `.gitnexus/run.cjs` yet? Bootstrap with `npx`, `bunx`, or `pnpm dlx` — e.g. `bunx gitnexus@latest analyze` (npm 11 npx crash; #1939).
## Always Do
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run `impact({target: "symbolName", direction: "upstream"})` and report the blast radius (direct callers, affected processes, risk level) to the user.
- **MUST run `detect_changes()` before committing** to verify your changes only affect expected symbols and execution flows. For regression review, compare against the default branch: `detect_changes({scope: "compare", base_ref: "main"})`.
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
- When exploring unfamiliar code, use `query({query: "concept"})` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use `context({name: "symbolName"})`.
- **MUST run impact before editing.** Use `impact({target: "symbolName", direction: "upstream"})` or `node .gitnexus/run.cjs impact "symbolName" --direction upstream --repo .`; report callers, processes, and risk. Never substitute grep for graph analysis.
- **MUST analyze graph changes before committing.** Use `detect_changes({scope: "all"})` (MCP) or `node .gitnexus/run.cjs detect-changes --scope all --repo .` (CLI fallback). `partial: true` or `truncated: true` is not a clean check — a zero means unseen, not unaffected; re-run it. For regression review: `detect_changes({scope: "compare", base_ref: "main"})` or `node .gitnexus/run.cjs detect-changes --scope compare --base-ref "main" --repo .`.
- MUST warn on HIGH/CRITICAL `risk` pre-edit; never use `riskSharedAxes` to waive a HIGH/CRITICAL `risk` warning. Compare File/symbol: MCP File omits axes; Graph-RAG expands File.
- **MUST treat `risk: UNKNOWN` as unresolved, not as low.** An empty caller set is not evidence the symbol is unused — it can also mean the callers are not resolvable by the index (plain-object property access, dynamic dispatch, cross-language calls). `impact` pairs `UNKNOWN` with a `riskNote` saying so. Confirm with a text search before treating the symbol as safe to change or delete; do not proceed on the strength of a zero.
- **MUST use `query({search_query: "concept"})` for concepts/flows, `context({name: "symbolName"})` for a named symbol, or `impact` for blast radius, on read-only callers, dependencies, imports, or execution flow.** Graph first; text search only for empty/`UNKNOWN`/literals.
- For security review, `explain({target: "fileOrSymbol"})` lists taint findings (source→sink flows; needs `analyze --pdg`).
## Never Do
- NEVER edit a function, class, or method without first running `impact` on it.
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
- NEVER edit a function, class, or method before MCP/CLI impact analysis.
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis, and never read `UNKNOWN` as an all-clear — it means the walk could not answer, which is the one verdict that requires confirming by other means.
- NEVER rename symbols with find-and-replace — use `rename` which understands the call graph.
- NEVER commit changes without running `detect_changes()` to check affected scope.
- NEVER commit before MCP/CLI graph change analysis.
## Resources
| Resource | Use for |
|----------|---------|
| --- | --- |
| `gitnexus://repo/museion/context` | Codebase overview, check index freshness |
| `gitnexus://repo/museion/clusters` | All functional areas |
| `gitnexus://repo/museion/processes` | All execution flows |
@@ -160,13 +161,13 @@ This project is indexed by GitNexus as **museion** (965 symbols, 1676 relationsh
## CLI
| Task | Read this skill file |
|------|---------------------|
| Understand architecture / "How does X work?" | `.claude/skills/gitnexus/gitnexus-exploring/SKILL.md` |
| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md` |
| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus/gitnexus-debugging/SKILL.md` |
| Rename / extract / split / refactor | `.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md` |
| Tools, resources, schema reference | `.claude/skills/gitnexus/gitnexus-guide/SKILL.md` |
| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus/gitnexus-cli/SKILL.md` |
| --- | --- |
| Understand architecture / "How does X work?" | `.claude/skills/gitnexus-exploring/SKILL.md` |
| Blast radius / "What breaks if I change X?" | `.claude/skills/gitnexus-impact-analysis/SKILL.md` |
| Trace bugs / "Why is X failing?" | `.claude/skills/gitnexus-debugging/SKILL.md` |
| Rename / extract / split / refactor | `.claude/skills/gitnexus-refactoring/SKILL.md` |
| Tools, resources, schema reference | `.claude/skills/gitnexus-guide/SKILL.md` |
| Index, status, clean, wiki CLI commands | `.claude/skills/gitnexus-cli/SKILL.md` |
<!-- gitnexus:end -->
@@ -177,6 +178,7 @@ Session logs live in `docs/devlog/` (one per completed task/issue/milestone). Fu
<!-- write-log: window-start -->
| Date | Log |
|------|-----|
| 2026-10-01 | [20261001-issue17-home-posts-list_log.md](docs/devlog/20261001-issue17-home-posts-list_log.md) |
| 2026-10-01 | [20261001-issue55-verdict-substrate-adr-0010_log.md](docs/devlog/20261001-issue55-verdict-substrate-adr-0010_log.md) |
| 2026-09-25 | [20260925-issue50-profile-backup-s2-6_log.md](docs/devlog/20260925-issue50-profile-backup-s2-6_log.md) |
| 2026-09-16 | [20260916-issue14-acp-bridge-s2-2_log.md](docs/devlog/20260916-issue14-acp-bridge-s2-2_log.md) |
+2
View File
@@ -6,6 +6,8 @@ All notable changes to this project will be documented in this file. The format
### Added
- **workspace:** M1 Home & Posts list (PRD S1.1) — the post-gate main surface is now the workspace shell from the design contract: nav rail (Posts, Sessions, Learnings, Settings), a Posts pane that mirrors the Museion Home's `posts/` folder on disk (Pass State groups, origin meta, empty state, lazy folders skipped), a Settings pane where the Home can be repointed (repoint-only — Museion never moves content; NSOpenPanel picker, UserDefaults persistence, default `~/Documents/Museion`), and placeholder panes for Sessions/Learnings until their milestones; the M0 mentor pane becomes the workspace's fourth column (issue #17)
- **backup:** S2.6 daily profile backup — on launch, once per 24 h and only while the engine is idle (gateway.pid liveness + `ps` scan), Museion snapshots `~/.hermes/profiles/museion/` into a timestamped folder under `~/Library/Application Support/Museion/Backups/` (credentials included, logs/caches/locks excluded, last 7 kept); restore is manual Finder copy-back — Help → Open Backup Folder, `RESTORE.md` beside the snapshots (issue #50)
- **acp:** M0 ACP bridge (PRD S2.2) — the app spawns the Hermes engine (`hermes acp -p museion`) as a child process via a hand-rolled NDJSON JSON-RPC stdio client, opens a Session, streams mentor replies live in a debug pane, renders fix-card tool calls as structured cards, cancels turns via Stop, tears the child down on quit, and surfaces an in-pane restart prompt on engine crash — never data loss (issue #14)
- **provisioning:** S2.1 profile provisioning — idempotent per-gate pass creates the `museion` Hermes profile (`hermes profile create --no-alias --no-skills`) and additively seeds the bundled writing skills via `seed-manifest.txt`; existing skills are never overwritten (issue #47)
+10
View File
@@ -17,6 +17,16 @@ Owned by the root AGENTS.md contract. The `.xcodeproj` uses **filesystem-synchro
- No persistence layer yet — the SwiftData template was stripped; vault-vs-database gets an ADR when the need is real. Exception: the engine gate's `state.json` (see below).
- Tabs for indentation; SwiftFormat + SwiftLint must both stay clean.
## Workspace shell (M1, #17 / S1.1)
- `DesignTokens.swift` — palette/geometry from the design contract (`ref/Web-Prototype/museion-workspace.html` `:root` + grid): background/surface/foreground/muted/border/accent colors, radius 10, column widths (rail 56, library 232, mentor 356; the export's editor min 420 lands with #19's editor column), serif/mono font designs. Light-only — the export defines one palette.
- `WorkspaceView.swift` — post-gate main surface (replaces the M0 mentor pane as root): nav rail (Posts/Sessions/Learnings + Settings at bottom) + active pane. `RailButton` per the export (44×44, muted icon, hover wash, surface card + 2px edge bar when current). Sessions/Learnings are honest placeholders until #28/#26. Posts renders the full grid; **column collapse mirrors the export's media queries** (library hides < 1100 px, mentor hides < 920 px budget) as macOS pane collapse — never a fixed four-column minWidth that clips. `PaneHeader` = 52pt serif-15 title row + border.
- `PostsPaneView.swift` — Posts destination: library column (Pass State groups in mono-11 uppercase labels, post rows with title + passState/origin meta), empty state, editor placeholder until #19–#21, mentor column (`MentorPaneView`, fixed 356). Selecting a post sets `selectedPostID` (editor shows its title; no editing yet).
- `PostLibrary.swift` — `Post` (nonisolated: id/title/passState/origin) + `Post.scan(home:) -> [Post]`: reads `posts/<id>/post.md`, skips dirs without post.md (lazy folders), loose files, hidden dirs (dot-prefix), and symlinked dirs; Title = first non-empty line after frontmatter (`untitled` on blank, marker-only, or unterminated-frontmatter bodies); `pass_state`/`origin` frontmatter keys read leniently (First Draft/writer defaults, quoted YAML values unquoted, leading blank line before `---` tolerated — corpus posts ship bare; write-side key format pinned by #18). Read-only — lifecycle is #18. Scan runs off-main via `Task.detached` in PostsPaneView (big Homes must not freeze the UI).
- `SettingsPaneView.swift` — Home control (NSOpenPanel folder pick; files/canCreate on). Repoint-only semantics stated in-UI.
- `AppGateState.museionHome` — app-scoped Home (UserDefaults `museionHome`, default `~/Documents/Museion` = `defaultMuseionHome`; non-file URLs read back as nil — the Home is always a folder). Explicit init: `Self` in a stored-property initializer breaks `@ObservationTracked` (covariant-Self error).
- `MentorPaneView` no longer carries a root min-frame — it lives in the 356pt mentor column.
## Engine gate (launch gate, tickets #35–#41)
- `EngineGate.swift` — `EngineProbe` (nonisolated): six-path probe order, `acp --check` health (stdin closed, 5 s timeout, exit-status branching), `acp --version` version, `state.json` writer/reader. `EngineGateModel` (@MainActor @Observable): phases for the UI, `onPass` seam (fires provisioning, #47), `currentBinaryPath` handed to provisioning. `execute(_:timeout:)`/`ProcessOutput` are internal — shared child-process machinery.
+4 -4
View File
@@ -35,11 +35,11 @@ struct ContentView: View {
@Bindable var gate = gate
Group {
// #14: post-gate main surface is the mentor debug pane (M0 demo
// surface, map decision: pane placement). Gate pass hands over the
// probe's winning binary — no re-probe.
// #17: post-gate main surface is the workspace shell (nav rail +
// Posts/Sessions/Learnings/Settings). Gate pass hands over the probe's
// winning binary — no re-probe.
if gate.gateModel.currentBinaryPath != nil {
MentorPaneView(model: gate.mentor, binaryPath: gate.gateModel.currentBinaryPath)
WorkspaceView()
} else {
VStack(spacing: 8) {
Image(systemName: "books.vertical")
+33
View File
@@ -0,0 +1,33 @@
//
// DesignTokens.swift
// Museion
//
// Visual tokens from the design contract (ref/Web-Prototype/museion-workspace.html, #17).
//
import SwiftUI
/// Colors, radii, and column geometry extracted from the export's `:root`
/// and workspace grid. Light-only on purpose — the export defines one palette.
enum DesignTokens {
static let background = Color(red: 0xFA / 255, green: 0xFA / 255, blue: 0xF7 / 255)
static let surface = Color(red: 1, green: 1, blue: 1)
static let foreground = Color(red: 0x1A / 255, green: 0x19 / 255, blue: 0x16 / 255)
static let muted = Color(red: 0x6B / 255, green: 0x69 / 255, blue: 0x64 / 255)
static let border = Color(red: 0xE8 / 255, green: 0xE5 / 255, blue: 0xDF / 255)
static let accent = Color(red: 0xC9 / 255, green: 0x64 / 255, blue: 0x42 / 255)
static let radius: CGFloat = 10
/// The workspace grid: rail | posts library | editor | mentor (grid-template-columns
/// `56px 232px minmax(420px, 1fr) 356px`). Editor min (420) has no enforcement
/// yet — the editor column arrives with #19.
static let railWidth: CGFloat = 56
static let libraryWidth: CGFloat = 232
static let mentorWidth: CGFloat = 356
/// The serif display face maps to the system serif design (export stack:
/// Iowan Old Style / Charter / Georgia); mono to the system monospaced.
static let serif: Font.Design = .serif
static let mono: Font.Design = .monospaced
}
+2 -1
View File
@@ -37,7 +37,8 @@ struct MentorPaneView: View {
crashCard(lastPrompt: lastPrompt)
}
}
.frame(minWidth: 560, minHeight: 420)
// #17: the pane lives in the workspace's fixed 356pt mentor column —
// no root min frame (it was the full-window M0 surface).
.task {
model.binaryPath = binaryPath ?? model.binaryPath
// Hosted unit tests run this app as their runner — never spawn a
+21
View File
@@ -22,6 +22,27 @@ final class AppGateState {
let backup = BackupModel()
/// #14: the app-scoped mentor bridge — the pane renders it; quit tears it down.
let mentor = MentorSessionModel()
/// #17: the Museion Home — repoint-only (ADR-0004). Defaults to
/// `~/Documents/Museion`; UserDefaults is the persistence floor: a Home is
/// a plain folder, nothing app-owned to put in a database. Non-file URLs
/// read back as nil (the default wins) — the Home is always a folder.
var museionHome: URL {
didSet { UserDefaults.standard.set(museionHome.absoluteString, forKey: "museionHome") }
}
init() {
// Explicit init: `Self` in a stored-property initializer trips
// @ObservationTracked's macro expansion (covariant Self).
museionHome = UserDefaults.standard.string(forKey: "museionHome")
.flatMap(URL.init(string:))
.flatMap { $0.isFileURL ? $0 : nil }
?? Self.defaultMuseionHome
}
/// The default Home, absent a stored override — `~/Documents/Museion`
/// (b3daac9: Documents, not the account root; TCC note in ADR-0004).
nonisolated static let defaultMuseionHome = FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent("Documents/Museion", isDirectory: true)
}
@main
+109
View File
@@ -0,0 +1,109 @@
//
// PostLibrary.swift
// Museion
//
// #17 (S1.1): the Posts list mirrors what is on disk under the Museion Home.
//
import Foundation
/// One Post on disk: `<home>/posts/<id>/post.md` (ADR-0004 shape).
nonisolated struct Post: Identifiable, Equatable {
/// The post folder's name — the Post's durable identity (CONTEXT.md).
let id: String
/// The Post's Title: first non-empty line after any frontmatter, heading markers stripped.
var title: String
/// Pass State from frontmatter; First Draft when absent (explicit, never inferred).
var passState: PassState
/// Origin from frontmatter; writer when absent. Immutable once set (CONTEXT.md).
var origin: Origin
nonisolated enum PassState: String, Equatable, CaseIterable {
case firstDraft = "First Draft"
case pass1Done = "Pass-1 Done"
case pass2Done = "Pass-2 Done"
}
nonisolated enum Origin: String, Equatable {
case writer
/// PRD S5.1 pins the frontmatter vocabulary: `origin: writer|ai`.
// swiftlint:disable:next identifier_name
case ai
}
/// Reads every `posts/<id>/post.md` into Posts (sorted by title, Finder order).
/// Read-only for #17 — create/rename/delete round-trips are #18. Symlinks and
/// hidden dirs are skipped; folders without `post.md` (lazy) aren't Posts;
/// a malformed folder can't crash the list.
static func scan(home: URL) -> [Post] {
let postsURL = home.appendingPathComponent("posts", isDirectory: true)
guard let entries = try? FileManager.default.contentsOfDirectory(
at: postsURL,
includingPropertiesForKeys: [.isDirectoryKey, .isSymbolicLinkKey],
) else { return [] }
var posts: [Post] = []
for dir in entries {
let values = try? dir.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey])
guard values?.isDirectory ?? false, !(values?.isSymbolicLink ?? false),
!dir.lastPathComponent.hasPrefix(".") else { continue }
let fileURL = dir.appendingPathComponent("post.md")
guard let text = try? String(contentsOf: fileURL, encoding: .utf8) else { continue }
let frontmatter = frontmatter(of: text)
posts.append(
Post(
id: dir.lastPathComponent,
title: title(of: text),
passState: PassState(rawValue: frontmatter["pass_state"] ?? "") ?? .firstDraft,
origin: Origin(rawValue: frontmatter["origin"] ?? "") ?? .writer,
),
)
}
return posts.sorted { $0.title.localizedStandardCompare($1.title) == .orderedAscending }
}
/// The `---`-delimited frontmatter block if present; empty otherwise.
/// Quoted scalar values (`origin: "ai"`) are unquoted — lenient YAML.
static func frontmatter(of text: String) -> [String: String] {
let lines = text.split(separator: "\n", omittingEmptySubsequences: false)
guard lines.first(where: { !$0.trimmed().isEmpty })?.trimmed() == "---" else { return [:] }
var map: [String: String] = [:]
for line in lines.drop(while: { $0.trimmed() != "---" }).dropFirst() {
let trimmed = line.trimmed()
guard trimmed != "---" else { break }
guard let colon = trimmed.firstIndex(of: ":") else { continue }
let key = trimmed[..<colon].trimmingCharacters(in: .whitespaces)
let value = trimmed[trimmed.index(after: colon)...]
.trimmingCharacters(in: .whitespaces)
.trimmingCharacters(in: CharacterSet(charactersIn: "\"'"))
map[key] = value
}
return map
}
/// The Post's Title: first non-empty line after any frontmatter block,
/// `#` heading markers stripped; `untitled` when nothing readable remains.
static func title(of text: String) -> String {
var lines = text.split(separator: "\n", omittingEmptySubsequences: false)[...]
if let open = lines.firstIndex(where: { !$0.trimmed().isEmpty }), lines[open].trimmed() == "---" {
if let close = lines[(open + 1)...].firstIndex(where: { $0.trimmed() == "---" }) {
lines = lines[(close + 1)...]
} else {
return "untitled" // unterminated block: nothing trustworthy follows
}
}
for line in lines {
let trimmed = line.trimmed()
guard !trimmed.isEmpty else { continue }
let stripped = trimmed.trimmingCharacters(in: CharacterSet(charactersIn: "#").union(.whitespaces))
return stripped.isEmpty ? "untitled" : stripped
}
return "untitled"
}
}
private nonisolated extension Substring {
func trimmed() -> String {
trimmingCharacters(in: .whitespacesAndNewlines)
}
}
+168
View File
@@ -0,0 +1,168 @@
//
// PostsPaneView.swift
// Museion
//
// #17 (S1.1): the Posts pane — library column mirroring the Home's posts/
// on disk, editor placeholder until #19–#21, mentor column (#14).
//
import SwiftUI
/// The Posts destination: the workspace's full four-column layout
/// library 232 | editor ≥420 | mentor 356 (design contract grid).
struct PostsPaneView: View {
let home: URL
/// #14: the app-scoped mentor model + the gate's winning binary (no re-probe).
var mentor: MentorSessionModel
var mentorBinaryPath: String?
/// Width budget after the rail — drives column collapse (export media queries:
/// library hides ≤1100, mentor hides ≤920).
var availableWidth: CGFloat
@State private var posts: [Post] = []
@State private var selectedPostID: String?
private var showsLibrary: Bool {
availableWidth >= 1100 - DesignTokens.railWidth
}
private var showsMentor: Bool {
availableWidth >= 920 - DesignTokens.railWidth
}
var body: some View {
HStack(spacing: 0) {
if showsLibrary {
libraryColumn
paneBorder
}
editorPlaceholder
if showsMentor {
paneBorder
mentorColumn
}
}
.task(id: home) {
// Scan off-main: .task inherits MainActor; a big Home must not freeze the UI.
posts = await Task.detached(priority: .userInitiated) { Post.scan(home: home) }.value
}
}
private var paneBorder: some View {
Rectangle()
.fill(DesignTokens.border)
.frame(width: 1)
}
// MARK: Library column
private var libraryColumn: some View {
VStack(spacing: 0) {
// New Post arrives with #18 (Post lifecycle: lazy folder + slug).
PaneHeader(title: "Posts")
if posts.isEmpty {
emptyState
} else {
ScrollView {
LazyVStack(alignment: .leading, spacing: 4) {
ForEach(Post.PassState.allCases, id: \.self) { state in
let grouped = posts.filter { $0.passState == state }
if !grouped.isEmpty {
Text(state.rawValue.uppercased())
.font(.system(size: 11, design: DesignTokens.mono))
.kerning(0.6)
.foregroundStyle(DesignTokens.muted)
.padding(.horizontal, 14)
.padding(.top, 18)
.padding(.bottom, 7)
ForEach(grouped) { post in
PostRow(post: post, selected: post.id == selectedPostID) {
selectedPostID = post.id
}
}
}
}
}
.padding(.bottom, 12)
}
}
}
.frame(width: DesignTokens.libraryWidth)
}
private var emptyState: some View {
VStack(spacing: 8) {
Text("No posts yet")
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
Text("Posts in this Home's posts/ folder appear here.")
.font(.callout)
.foregroundStyle(DesignTokens.muted)
.multilineTextAlignment(.center)
}
.padding(38)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
// MARK: Editor + mentor columns
private var editorPlaceholder: some View {
VStack(spacing: 10) {
if let post = posts.first(where: { $0.id == selectedPostID }) {
Text(post.title)
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
}
Text("The editor arrives with S1.2 (#19–#21).")
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(DesignTokens.surface)
}
private var mentorColumn: some View {
MentorPaneView(model: mentor, binaryPath: mentorBinaryPath)
.frame(width: DesignTokens.mentorWidth)
}
}
/// One post row per the export: title, Pass State + Origin in mono 11.
private struct PostRow: View {
let post: Post
let selected: Bool
let select: () -> Void
@State private var hover = false
var body: some View {
Button(action: select) {
VStack(alignment: .leading, spacing: 5) {
Text(post.title)
.font(.callout.weight(.semibold))
.lineLimit(1)
.truncationMode(.tail)
.frame(maxWidth: .infinity, alignment: .leading)
HStack {
Text(post.passState.rawValue)
Text(post.origin.rawValue)
}
.font(.system(size: 11, design: DesignTokens.mono))
.foregroundStyle(DesignTokens.muted)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding(10)
}
.buttonStyle(.plain)
.foregroundStyle(DesignTokens.foreground)
.background {
if selected || hover {
RoundedRectangle(cornerRadius: DesignTokens.radius)
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
.overlay(
RoundedRectangle(cornerRadius: DesignTokens.radius)
.strokeBorder(selected ? DesignTokens.border : .clear),
)
}
}
.padding(.horizontal, 8)
.onHover { hover = $0 }
.accessibilityLabel("\(post.title), \(post.passState.rawValue), origin \(post.origin.rawValue)")
}
}
+51
View File
@@ -0,0 +1,51 @@
//
// SettingsPaneView.swift
// Museion
//
// #17 (S1.1): Settings — the Museion Home path, repoint-only (ADR-0004).
//
import AppKit
import SwiftUI
/// Settings pane. #17 scope: the Home control only — further settings arrive
/// with their tickets. Choosing a folder repoints Museion at that root;
/// content is never moved.
struct SettingsPaneView: View {
@Binding var home: URL
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Content")
.font(.system(size: 13, weight: .semibold))
HStack(spacing: 8) {
Text(home.path(percentEncoded: false))
.font(.system(size: 12, design: DesignTokens.mono))
.lineLimit(1)
.truncationMode(.middle)
.textSelection(.enabled)
Spacer(minLength: 12)
Button("Choose…") { chooseHome() }
}
Text(
"Repoint-only: Museion never moves content. The Posts list reads this folder's posts/ directory.",
)
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.padding(24)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
.background(DesignTokens.background)
}
private func chooseHome() {
let panel = NSOpenPanel()
panel.canChooseDirectories = true
panel.canChooseFiles = false
panel.canCreateDirectories = true
panel.message = "Choose the folder holding your posts. Museion never moves content."
if panel.runModal() == .OK, let url = panel.url {
home = url
}
}
}
+167
View File
@@ -0,0 +1,167 @@
//
// WorkspaceView.swift
// Museion
//
// #17 (S1.1): the workspace shell — nav rail + panes, built from the design
// contract's grid geometry (ref/Web-Prototype/museion-workspace.html):
// rail 56 | library 232 | editor min 420 | mentor 356.
//
import SwiftUI
/// The post-gate main surface. Posts shows the full four-column workspace;
/// Sessions/Learnings/Settings fill the space after the rail until their
/// tickets land (#28/#26; Settings is real here).
struct WorkspaceView: View {
@Environment(AppGateState.self) private var gate
@State private var selection: Pane = .posts
enum Pane: Hashable {
case posts
case sessions
case learnings
case settings
}
var body: some View {
@Bindable var gate = gate
return GeometryReader { geo in
HStack(spacing: 0) {
navRail
paneBorder
switch selection {
case .posts:
// #14: mentor column hands in the app-scoped model + gate's winner.
// Column collapse mirrors the export's media queries (library ≤1100,
// mentor ≤920) as macOS pane collapse per the PRD.
PostsPaneView(
home: gate.museionHome,
mentor: gate.mentor,
mentorBinaryPath: gate.gateModel.currentBinaryPath,
availableWidth: geo.size.width - DesignTokens.railWidth,
)
case .sessions:
PlaceholderPane(title: "Sessions", detail: "Session lifecycle arrives with S2.3 (#28).")
case .learnings:
PlaceholderPane(title: "Learnings", detail: "Promote, consult, and decay arrive with S4 (#26, #27).")
case .settings:
SettingsPaneView(home: $gate.museionHome)
}
}
.background(DesignTokens.background)
}
// Collapsed floor: rail 56 + editor placeholder (export ≤920 layout).
.frame(minWidth: 480, minHeight: 320)
}
/// 1px contract border between rail and pane (`.rail { border-right }`).
private var paneBorder: some View {
Rectangle()
.fill(DesignTokens.border)
.frame(width: 1)
}
// MARK: Nav rail
private var navRail: some View {
VStack(spacing: 8) {
RailButton(pane: .posts, selection: $selection, label: "Posts", systemImage: "doc.text")
RailButton(pane: .sessions, selection: $selection, label: "Sessions", systemImage: "bubble.left")
RailButton(pane: .learnings, selection: $selection, label: "Learnings", systemImage: "cube")
Spacer()
RailButton(pane: .settings, selection: $selection, label: "Settings", systemImage: "gearshape")
}
.padding(.horizontal, 4)
.padding(.vertical, 8)
.frame(width: DesignTokens.railWidth)
.frame(maxHeight: .infinity)
}
}
/// Rail button per the export: 44×44 muted icon, hover wash, and the current
/// pane raised as a surface card with a 2px selection bar on the rail's edge.
private struct RailButton: View {
let pane: WorkspaceView.Pane
@Binding var selection: WorkspaceView.Pane
let label: String
let systemImage: String
@State private var hover = false
var body: some View {
let selected = selection == pane
Button {
selection = pane
} label: {
Image(systemName: systemImage)
.frame(width: 44, height: 44)
}
.buttonStyle(.plain)
.foregroundStyle(selected ? DesignTokens.foreground : DesignTokens.muted)
.background {
if selected || hover {
RoundedRectangle(cornerRadius: DesignTokens.radius)
.fill(selected ? DesignTokens.surface : DesignTokens.foreground.opacity(0.06))
.overlay(
RoundedRectangle(cornerRadius: DesignTokens.radius)
.strokeBorder(selected ? DesignTokens.border : .clear),
)
}
}
.overlay(alignment: .leading) {
// Selection bar (`.rail-btn[aria-current]::before`); offset to sit
// on the rail's leading edge like the export's negative inset.
if selected {
Rectangle()
.fill(DesignTokens.foreground)
.frame(width: 2, height: 22)
.offset(x: -6)
}
}
.onHover { hover = $0 }
.help(label)
.accessibilityLabel(label)
}
}
/// Pane-head row per the export (52pt, serif 15 semibold title, bottom border).
/// Trailing slot returns with #18's New Post button.
struct PaneHeader: View {
let title: String
var body: some View {
VStack(spacing: 0) {
HStack {
Text(title)
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
Spacer()
}
.padding(.horizontal, 14)
.frame(minHeight: 52)
Rectangle()
.fill(DesignTokens.border)
.frame(height: 1)
}
}
}
/// Navigation-target placeholder (#17 AC: panes exist as targets; real content
/// arrives with their tickets — honest copy, no fake controls).
struct PlaceholderPane: View {
let title: String
let detail: String
var body: some View {
VStack(spacing: 10) {
Image(systemName: "hourglass")
.font(.largeTitle)
.foregroundStyle(DesignTokens.muted)
Text(title)
.font(.system(size: 16, weight: .semibold, design: DesignTokens.serif))
Text(detail)
.font(.callout)
.foregroundStyle(DesignTokens.muted)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
+1
View File
@@ -20,6 +20,7 @@ Owned by the root AGENTS.md contract.
- `EngineGateTests.swift` builds fake `hermes` shell scripts in temp dirs and runs them through the real `Process` path — copy that pattern for any future child-process testing.
- `ACPClientTests.swift` extends it into a full fake ACP *server*: a zsh script speaking real NDJSON JSON-RPC over stdio (`makeFakeACP`), with a per-binary mode file (`crashAfterHandshake`, `hangOnPrompt`, default full) and a base64-encoded fix-card payload — shell quoting can never break the wire JSON. Only `acpTempDir` remains as a helper; crash assertions use Swift Testing's `confirmation` (hook the callback BEFORE triggering the crash).
- `ProfileProvisionerTests.swift` extends it: the fake creates the profile at `<binaryDir>/profiles/<name>` (self-locating, race-free under parallel tests); payload dirs are built at runtime; the bundled-payload test asserts manifest ↔ payload correspondence. #48 failure-path tests live in `ProfileProvisionerFailureTests.swift` (own file — Not-Now defer + re-fail, config.yaml byte-identity + fresh-profile no-config (mcp_servers negative invariant), state.json engine-gate-only, copy-phase catch branch, path-traversal rejection, orphaned-temp sweep). Shared helpers (`makeFakeHermes`, `makePayload`, `defaultSkills`, `provTempDir`) are internal in `ProfileProvisionerTests.swift`. `ProfileBackupTests.swift` (own helpers `backupTempDir`/`makeProfileFixture`) injects profile/backups roots, a fixed clock, and a `psScan` stub — a dev machine may run the real engine, so the ps scan is never trusted in tests.
- `PostLibraryTests.swift` (#17) — throwaway Homes via `makeHome`/`writePost` in temp dirs: bare corpus posts (First Draft/writer defaults), lenient + quoted frontmatter (`pass_state`/`origin`), lazy folders / hidden dirs / symlinks / noise not surfacing, localizedStandardCompare title sort, `untitled` edges (blank, marker-only, unterminated frontmatter), leading-blank-line frontmatter, default Home = `~/Documents/Museion`.
## Verification
+154
View File
@@ -0,0 +1,154 @@
//
// PostLibraryTests.swift
// MuseionTests
//
// #17: the Posts list mirrors <home>/posts/ on disk.
//
import Foundation
@testable import Museion
import Testing
/// Builds throwaway Homes in a temp dir: posts written bare (corpus shape,
/// no frontmatter) or with frontmatter; noise entries that must not crash or
/// surface as Posts.
private func makeHome(_ write: (URL) throws -> Void) throws -> URL {
let home = FileManager.default.temporaryDirectory
.appendingPathComponent("postlib-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
try write(home)
return home
}
private func writePost(_ home: URL, _ id: String, _ body: String) throws {
let dir = home.appendingPathComponent("posts/\(id)", isDirectory: true)
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
try body.write(to: dir.appendingPathComponent("post.md"), atomically: true, encoding: .utf8)
}
@Test func `bare post is first draft writer with heading title`() throws {
let home = try makeHome { home in
try writePost(home, "the-new-reeder", "## The New Reeder\n\nBody text.")
}
let posts = Post.scan(home: home)
#expect(posts.count == 1)
let post = try #require(posts.first)
#expect(post.id == "the-new-reeder")
#expect(post.title == "The New Reeder")
#expect(post.passState == .firstDraft)
#expect(post.origin == .writer)
}
@Test func `frontmatter keys are read leniently`() throws {
let home = try makeHome { home in
try writePost(
home,
"a-short-defence-of-footnotes",
"---\npass_state: Pass-1 Done\norigin: ai\ntitle: ignored — body wins\n---\n\n# A Short Defence of Footnotes\n\nBody.",
)
}
let post = try #require(Post.scan(home: home).first)
#expect(post.passState == .pass1Done)
#expect(post.origin == .ai)
#expect(post.title == "A Short Defence of Footnotes")
}
@Test func `quoted frontmatter values are unquoted`() throws {
let home = try makeHome { home in
try writePost(home, "quoted", "---\npass_state: \"Pass-2 Done\"\norigin: 'ai'\n---\n\n## Quoted\n")
}
let post = try #require(Post.scan(home: home).first)
#expect(post.passState == .pass2Done)
#expect(post.origin == .ai)
}
@Test func `empty home is empty and missing home is empty`() throws {
let empty = try makeHome { _ in }
#expect(Post.scan(home: empty).isEmpty)
let missing = FileManager.default.temporaryDirectory
.appendingPathComponent("postlib-missing-\(UUID().uuidString)")
#expect(Post.scan(home: missing).isEmpty)
}
@Test func `lazy folders, hidden dirs and noise are not posts`() throws {
let home = try makeHome { home in
try writePost(home, "one", "One")
// Lazy folder: no post.md yet (created lazily on first write, #18).
try FileManager.default.createDirectory(
at: home.appendingPathComponent("posts/not-yet", isDirectory: true),
withIntermediateDirectories: true,
)
// Hidden dir WITH a post.md — must not surface.
try writePost(home, ".trash", "---\n---\n## Hidden\n")
// Noise: loose file at posts/ root.
try "loose".write(
to: home.appendingPathComponent("posts/loose.md"),
atomically: true,
encoding: .utf8,
)
}
#expect(Post.scan(home: home).map(\.id) == ["one"])
}
@Test func `symlinked post dir is not followed`() throws {
let home = try makeHome { home in
try writePost(home, "one", "One")
// A post.md outside the Home, linked into posts/ by symlink.
let outside = home.deletingLastPathComponent()
.appendingPathComponent("postlib-outside-\(UUID().uuidString)", isDirectory: true)
try FileManager.default.createDirectory(at: outside, withIntermediateDirectories: true)
try "## Stolen\n".write(
to: outside.appendingPathComponent("post.md"),
atomically: true,
encoding: .utf8,
)
try FileManager.default.createSymbolicLink(
at: home.appendingPathComponent("posts/linked", isDirectory: true),
withDestinationURL: outside,
)
}
#expect(Post.scan(home: home).map(\.id) == ["one"])
}
@Test func `posts sort by title locally`() throws {
let home = try makeHome { home in
try writePost(home, "z-id", "## Alpha\n")
try writePost(home, "a-id", "## Beta 2\n")
try writePost(home, "m-id", "## beta 10\n")
}
// localizedStandardCompare: case-insensitive, numeric-aware (Finder order).
#expect(Post.scan(home: home).map(\.title) == ["Alpha", "Beta 2", "beta 10"])
}
@Test func `blank draft title is untitled`() {
#expect(Post.title(of: "\n\n \n") == "untitled")
#expect(Post.title(of: "---\npass_state: Pass-2 Done\n---\n") == "untitled")
#expect(Post.title(of: "") == "untitled")
#expect(Post.title(of: "#\n") == "untitled") // heading marker only, no text
// Frontmatter-first title: first non-empty line after the block.
#expect(Post.title(of: "---\norigin: writer\n---\n\n## Named\n\nBody") == "Named")
}
@Test func `unterminated frontmatter is untitled, never leaked`() {
// No closing ---: frontmatter lines must never leak as the Title.
#expect(Post.title(of: "---\npass_state: First Draft\norigin: writer\n") == "untitled")
#expect(Post.frontmatter(of: "---\npass_state: First Draft\n")["pass_state"] == "First Draft")
}
@Test func `leading blank line still opens frontmatter`() throws {
// A leading newline before --- must not defeat frontmatter detection.
let text = "\n---\npass_state: Pass-1 Done\n---\n\n## After Blank\n"
let home = try makeHome { try writePost($0, "blank-open", text) }
let post = try #require(Post.scan(home: home).first)
#expect(post.passState == .pass1Done)
#expect(post.title == "After Blank")
}
@Test func `home default is documents museion`() {
#expect(
AppGateState.defaultMuseionHome
== FileManager.default.homeDirectoryForCurrentUser
.appendingPathComponent("Documents/Museion", isDirectory: true),
)
}
@@ -0,0 +1,95 @@
# M1: Home & Posts list (#17)
> **Date:** 2026-10-01
> **Type:** issue
> **Reference:** https://git.babylondreams.de/AlexKucera/museion/issues/17
## Goal
Ship #17 (S1.1): the workspace shell from the design contract — nav rail (Posts, Sessions, Learnings, Settings), Posts pane mirroring the Home's `posts/` on disk with empty state, Home editable in Settings with repoint-only semantics, placeholder panes for Sessions/Learnings.
## What Was Done
- `DesignTokens.swift` — palette + geometry extracted from `museion-workspace.html` (`:root` vars, grid columns 56/232/min-420/356, radii 10/14, serif/mono designs).
- `WorkspaceView.swift` — post-gate root surface: nav rail + pane switch; `RailButton` with the export's selected-card + edge-bar treatment; honest placeholders for Sessions (#28) / Learnings (#26, #27).
- `PostsPaneView.swift` — Posts destination with Pass State group labels, post rows (title + mono meta), empty state, editor placeholder (#19–#21), mentor column (`MentorPaneView` at 356).
- `PostLibrary.swift` — `PostLibrary.scan(home:)`: mirrors `posts/` (dirs with `post.md` only — lazy folders and noise skipped), lenient frontmatter (`pass_state`/`origin`, First Draft/writer defaults), Title = first non-empty line after frontmatter with `#` stripped, `untitled` fallback.
- `SettingsPaneView.swift` — Home row + NSOpenPanel repoint; repoint-only copy in-UI.
- `AppGateState.museionHome` — UserDefaults-backed, default `~/Documents/Museion` (main's b3daac9 default, not the old `~/Museion` from the issue text).
- `MentorPaneView` root min-frame dropped (it's a column now).
- Tests (+7): PostLibraryTests — bare post defaults, lenient frontmatter, empty/missing home, lazy-folder + noise exclusion, title sort, untitled edges, default Home.
## Decisions & Rationale
| Decision | Rationale |
|----------|-----------|
| Column collapse instead of a fat minWidth | First build forced rail+library+editor+mentor minWidth (1064); the restored 900pt window clipped the rail and mentor off-screen (user hit it live). The export collapses at media-query thresholds (≤1100 library, ≤920 mentor); PRD says map that to macOS pane collapse. `GeometryReader` budget drives `showsLibrary`/`showsMentor`. |
| Lenient frontmatter read (`pass_state`/`origin` keys, defaults) | Corpus posts ship bare; the write-side key format is #18's to pin. CONTEXT.md: Pass State explicit, never inferred — First Draft default is the honest read of a bare post. |
| UserDefaults for the Home | A Home is a plain folder the user points at — nothing app-owned worth a database. Same floor as state.json reasoning. |
| NSOpenPanel over fileImporter | fileImporter's folder mode still shows files on macOS; one proven AppKit call beats bridging workarounds. |
| Explicit `AppGateState.init()` | `Self` in a stored-property initializer trips `@ObservationTracked` (covariant-Self compile error). |
| Scan on `.task(id: home)` only | #17 is read-only; no FS events yet — #18 adds lifecycle (create/rename/delete round-trips) and re-scan triggers. |
## Gotchas & Fixes
| Problem | Root Cause | Fix |
|---------|------------|-----|
| Empty posts list despite defaults write | `defaults write` from the agent's shell lives in a different cfprefsd context than the `open`-launched app; plist on disk never got the key | Verified scan logic standalone (swift REPL finds both posts); user-path verification (Settings → Choose…) is the honest route — CLI defaults injection is unreliable for GUI apps |
| Rail icons "invisible" in early screenshots | 900pt restored window < 1064 minWidth → HStack laid out at min size, clipping both edges | Column collapse (above) |
| `localizedStandardCompare` order surprise | It's Finder-like (case-insensitive, numeric-aware): "Beta 2" < "beta 10" | Test expectation corrected — the code is right |
| SwiftFormat reformatting drive-by (944-line prototype diff) | Ran `swiftformat .` repo-wide | Reverted untouched files; formatted only changed files after |
| AppleScript `by` reserved word | `set {bx, by} to position` — `by` is an AppleScript term | Renamed to `btnPos`/`btnSize` |
## Verification
- Build: `xcodebuild … build` → **BUILD SUCCEEDED**
- Tests: full suite → **TEST SUCCEEDED**, 52/52 passed (45 pre-existing + 7 new)
- Lint: `swiftlint Museion/ MuseionTests/` → 0 violations; SwiftFormat clean on changed files
- Live: app launched, gate sheet passed and dismissed via AX, workspace rendered (rail/Posts/editor/mentor verified by screenshot); window-resize collapse fix built but final visual pass blocked by a fullscreen break timer — needs one manual look
## Finish Audit (same day)
Three fresh-context reviewers (ponytail / security / general) over `804b588`. Accepted and fixed:
| Fix | Source |
|-----|--------|
| Scan off-main: `Task.detached { Post.scan(home:) }` in `.task(id:)` — MainActor-inherited synchronous scan froze the UI on big Homes | security MEDIUM-1 + review |
| `PostLibrary` struct → `Post.scan(home:) -> [Post]` (wrapper with one field, unused Equatable) | ponytail |
| Hidden-dir skip now real (dot-prefix guard) — the AGENTS.md claim was code-less and the test vacuous; test now writes a `post.md` into `.trash/` | review MEDIUM + security INFO-5 |
| Unterminated frontmatter returns `untitled` (was leaking `pass_state: …` as Title) | review MEDIUM |
| Quoted YAML values unquoted (`origin: "ai"` → `.ai`) | review MEDIUM |
| Leading blank line before `---` no longer defeats frontmatter detection (both parser funcs) | review LOW |
| `#`-only body → `untitled` (was empty string) | review LOW |
| Symlinked post dirs skipped (one resourceValues guard, single fetch) | security LOW-3 |
| Persisted home validated `isFileURL` (fails closed to default; hygiene) | security LOW-2 |
| Dead code out: `radiusLarge`, `editorMinWidth`, `homeKey`; `PaneHeader` trailing slot; Settings ScrollView; PostRow optional-fill dance; `availableWidth` default | ponytail |
Discarded as speculative: read-cap on file heads (detached hop fixes the hang; #18 owns growth), UserDefaults round-trip test (shared test host).
Tests 56/56 (4 new: quoted values, symlink, unterminated frontmatter, leading blank). Lint 0.
## Files Changed
| File | Change Summary |
|------|---------------|
| `Museion/DesignTokens.swift` | New — design-contract tokens |
| `Museion/WorkspaceView.swift` | New — nav rail + pane shell, collapse logic |
| `Museion/PostsPaneView.swift` | New — library column, groups, empty state, editor placeholder |
| `Museion/PostLibrary.swift` | New — disk scan + lenient frontmatter |
| `Museion/SettingsPaneView.swift` | New — Home repoint via NSOpenPanel |
| `Museion/MuseionApp.swift` | `AppGateState.museionHome` + default |
| `Museion/ContentView.swift` | Post-gate root → `WorkspaceView` |
| `Museion/MentorPaneView.swift` | Root min-frame dropped |
| `MuseionTests/PostLibraryTests.swift` | New — 7 tests |
| `Museion/AGENTS.md`, `MuseionTests/AGENTS.md` | Contracts updated |
## Open Items & Next Steps
- [ ] Manual look at the collapse behavior at narrow widths (break timer blocked the final screenshot pass)
- [ ] #18 Post lifecycle — New Post button, lazy folder creation, slug naming, rename/delete round-trips; pins the frontmatter key format written on save
- [ ] Mentor engine crash on workspace entry — pre-existing #14 behavior (drift note also visible); not #17 scope but worth a #28 look when Sessions land
---
*Log written by write-log skill*
+1
View File
@@ -5,6 +5,7 @@ Complete history of session logs in this directory, newest first. One-line summa
<!-- write-log: full-index -->
| Date | Type | File | Summary |
|------|------|------|---------|
| 2026-10-01 | issue | [20261001-issue17-home-posts-list_log.md](20261001-issue17-home-posts-list_log.md) | #17 shipped + finish-audit: workspace shell, Posts mirror, Home repoint — 56 tests green |
| 2026-10-01 | issue | [20261001-issue55-verdict-substrate-adr-0010_log.md](20261001-issue55-verdict-substrate-adr-0010_log.md) | #55 + map #16 closed: TextKit2 mode B wins, ADR-0010 drafted, typography/rendering stances locked |
| 2026-09-25 | issue | [20260925-issue50-profile-backup-s2-6_log.md](20260925-issue50-profile-backup-s2-6_log.md) | #50 S2.6 daily profile backup: liveness gate, curated copy, retention 7, RESTORE.md — 8 tests green |
| 2026-09-16 | issue | [20260916-issue14-acp-bridge-s2-2_log.md](20260916-issue14-acp-bridge-s2-2_log.md) | #14 M0 ACP bridge: NDJSON JSON-RPC client, mentor pane, fix-card round-trip, crash restart — 37 tests green |