diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c5ee5c..3d19f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ First release. Human-readable notes: [docs/releases/0.1.0.md](docs/releases/0.1. ### Fixed +- **reading:** The bundled apex renderer is self-contained and notarizable. apex's release build links libyaml through CI/Homebrew rpaths, so on any Mac without Homebrew it failed to launch and reading mode silently fell back to the raw source — the bundle promised "no install gate" (ADR-0011) and didn't deliver; Apple's notary service also rejects an unsigned Mach-O in Resources, which is how the 0.1.0 release run found it. Now `Resources/apex` is the arm64 slice of apex 1.1.58 (the bundle had shipped 1.1.17), Developer ID–signed with the hardened runtime, with one rpath (`@executable_path/../Resources/libyaml.bundle`) that resolves in the bundle and in the checkout alike; `Resources/libyaml.bundle/libyaml-0.2.dylib` (0.2.5, MIT) rides beside it, same team signature — inside a `.bundle` folder because Xcode's synced-folder classifier silently links a bare dylib into the app. `release.sh` now proves the shipped layout: apex must run from the export and the app must not link libyaml, before anything is notarized. `THIRD-PARTY-NOTICES.md` ships in the bundle. - **editor:** A Home repoint is a guarded document departure (finding `museion/home-repoint-retains-old-editor-target`, argus cycle-5; unticketed fix, brief-28) — Settings → Choose… committed the new Home and flipped `watchedHome` without departing the open session: the session's immutable target kept the OLD Home, so a same-slug piece in the new library made the ID-only reselect return it (autosave/Save/quit wrote the old library while structural operations resolved against the new one), the new library's rescan raised a spurious reload conflict on it, a no-collision piece was torn down by the vanish path with its dirty buffer dropped, and a card scan from the old library could land on the new library's same-slug piece. #198's departure gate never saw this seam. Now `PostsModel.repoint(to:)` runs the SAME gate (`sessionMayDepart`'s three legs — unanswered conflict, failed flush, never-loaded retype; no parallel gate) BEFORE anything commits: a refusal changes nothing (preference, binding, the session's target and buffer stay; the #198 reason spoken once, the #200 quit-refusal posture, since no Posts strip is in sight from Settings), an acceptance lands the edits on the old library first and clears the departed piece's state — nothing auto-reopens. Document identity is (Home, ID) everywhere (`EditorSession.targets`, `PostsModel.openSessionTargets`): every bare `session.postID ==` comparison is retired across select, the structural rail, conversion, the pass guard, Micropub and the card refresh, and async continuations re-validate identity at COMPLETION (the card-scan hop-back; `rescan`'s stale-Home verdict is hoisted to cover the list, the revision and the #67 text, not just the vanish check). The in-memory draft survives a repoint (no Home until first save). +9 tests over a two-Home same-slug rig (the three refusal legs with ordering pinned, same-slug open + save on flush AND quit, no-collision cleanup, stale card scan via the per-model `scanPieceCards` seam — mutation-checked, pass after repoint; review r1: the hoisted `rescan` stale-Home verdict via the `scanLibrary` seam — mutation-checked — and the draft-survives repoint), RED-first 6/6 at the pin. Suite 717 (unticketed fix, brief-28) - **editor:** Quit no longer bypasses the document departure gate (#200, follow-up to the #198 audit) — `PostsModel.shutdown()` flushed both sessions best-effort and ignored the results, so quitting with an unanswered reload-conflict alert wrote the local text over the foreign disk body (`flush()` holds for conflicts only in the debounce, never itself), and a failed quit-time flush silently dropped the only copy of the edits. Quit now routes through the same departure gate as navigation (`documentsMayDepart` → `sessionMayDepart`): an unanswered conflict never writes over the foreign body, and the failed-flush-at-quit posture is BLOCK QUIT — `WritingLockAppDelegate.applicationShouldTerminate` refuses termination with one spoken reason (running before the Cold Turkey ask, so a refusal never strands a walked-away block), pinned at the pure `quitReply(posts:)` seam. Finish-audit additions: a never-loaded session's retyped words refuse too (their flush is a vacuous success — the same gap closed for navigation), and the external guest's quit-time flush is pinned. +5 tests, all flip-verified. Suite 708 diff --git a/Museion/AGENTS.md b/Museion/AGENTS.md index 945411d..08fdb9b 100644 --- a/Museion/AGENTS.md +++ b/Museion/AGENTS.md @@ -53,7 +53,7 @@ The map and the contracts, one bullet per file. Pin-level detail lives in the te - Prose list machinery — `ProseList.swift` (pure item scan/mutation over the plain buffer; every structural edit is ONE range replacement = single undo step); `ProseListTextView.swift` — folds are VIEW state (buffer never changes; hidden scopes styled via `foldedAttributes`), re-keyed to the nearest same-marker parent, dying when the marker text vanishes; single-line edits re-key in place (`rekey`), the newline gate is `\.isNewline` NEVER literal `\n`/`\r` compares (a CRLF pair is one grapheme); wholesale restyles self-heal into the full pass via a font probe. Fold chrome renders as tiny per-glyph CALayers in a click-through overlay — NEVER a document-sized bitmap. Image drops bridge through `ProseDropBridge` into `ingestDrop` (saved posts only, publishable files only, PLAIN files only — a dropped symlink refuses); the drop point is solved by the pure `dropIndex` (sampling + bracket + binary search; the SwiftUI closure's `location` is unusable under this hosting, off-screen rects return garbage). - Settings — `SettingsPaneView.swift` (sidebar + detail: Content · Pass 1 · Pass 2 · Chat · Provider Keys; the pane takes the gate's `binaryPath` and hydrates at open; detail forms left-anchored). `SettingsModel.swift` — #181: `ModelProvider` is the provider-descriptor TABLE — label, effort ladder, flagship, default endpoint, env var, wire `dialect` (chat/models paths + the SSE decoder selector), `authMode` (Bearer vs Anthropic's header pair), `keyless` (nous rides the shared Portal login); the keyless UI branch, the probe's selectors, and both credential consumers key off it. `ProviderCredential` = the ONE credential resolution (provider key, else the Portal session key for keyless providers — official endpoint ONLY, never a user-set URL) serving Test Connection and pass readiness. Writes COALESCE: the newer write queues past an in-flight one, superseded writes never spawn (partial key prefixes of a secret never reach `.env`); `hydrate` reads only and never stomps a pending edit. `HermesSettingsWriter.swift` — the real write path: surface writes and the base_url write-through ride the HermesConfigRail (#182 — the writer only builds its key list: provider, default, effort set-or-unset, base_url LAST); provider keys upsert into ALL THREE profiles' `.env` (foreign lines byte-preserved, 0600, line-broken values REFUSED — env injection; paths via ProfileLayout). `ProviderProbe.swift` — Test Connection: every request carries `Content-Type: application/json` (without it z.ai answers 200 with an error envelope); per-provider dialects (OpenAI speaks the Responses API, Anthropic `x-api-key` + pinned version + required max_tokens, zai thinking+reasoning_effort, nous plain chat-completions) — #181: URL paths, auth shape, and the SSE decoder SELECT by the descriptor's dialect, the per-dialect code stays separate functions; 512 token cap; errors riding a 2xx decode as the provider error. `onChatSurfaceWrite` → `requestRestart` (chat surface only — pass engines are one-shot). `PassReadiness.swift` — #181: the per-surface readiness module (ready / missingKey / unknown): reads each surface's provider + `.env` key through the settings seam and resolves credentials through `ProviderCredential` (the keyless fallback included); MentorSessionModel stores the verdicts and reads no keys or auth files itself. - Focus mode — transient per-launch (no persistence); `FocusChrome` hover zones + overlay panels float over the measure, never push it; `CaretCentering` is EDITOR-WIDE, not focus-gated; focus × reading are orthogonal axes. Cold Turkey chrome (`ColdTurkeySeat`/`ColdTurkeyDot`) mounts as overlays on the focused branch only. -- Reading mode (ADR-0011) — `ReadingPresenter.swift`: the bundled apex binary with `-t html --no-mixed-lists --embed-images` (no-mixed-lists REQUIRED — the default merges ordered-after-bullets, killing `1. 1. 1.` renumbering; embed-images inlines base64 so `loadHTMLString` needs no file access); `` sentinels rewritten to `data-source-line` stamps; `blocks(for:)` = the click→edit line map; stylesheet = `Resources/reading.css` read fresh per build (dev builds prefer the repo copy); fallback on apex failure = escaped source, never a second renderer. `ReadingSurface.swift` — ONE WKWebView reloaded in place (remount was the dominant switch cost); only our own about:blank main-frame load is allowed. +- Reading mode (ADR-0011) — `ReadingPresenter.swift`: the bundled apex binary (arm64, Developer ID–signed with the hardened runtime at commit time, beside `libyaml.bundle/libyaml-0.2.dylib` — self-contained through the single rpath `@executable_path/../Resources/libyaml.bundle`; the `.bundle` wrapper is load-bearing: a bare dylib in the synced folder (with or without extension — Xcode sniffs Mach-O content) becomes the APP's link target; re-sign both when the Developer ID certificate rotates) with `-t html --no-mixed-lists --embed-images` (no-mixed-lists REQUIRED — the default merges ordered-after-bullets, killing `1. 1. 1.` renumbering; embed-images inlines base64 so `loadHTMLString` needs no file access); `` sentinels rewritten to `data-source-line` stamps; `blocks(for:)` = the click→edit line map; stylesheet = `Resources/reading.css` read fresh per build (dev builds prefer the repo copy); fallback on apex failure = escaped source, never a second renderer. `ReadingSurface.swift` — ONE WKWebView reloaded in place (remount was the dominant switch cost); only our own about:blank main-frame load is allowed. - `AppGateState.museionHome` — fresh installs resolve once and PIN the winner: legacy `~/Documents/Museion` (dir-ness gated) → `/Museion` (resolved at the unprefixed path, never a hard-coded `iCloud~` form) → silent Documents fallback. Hosted tests take an early return — the machine's real iCloud state and defaults are never touched. ## Engine check (gateless launch) diff --git a/Museion/Resources/THIRD-PARTY-NOTICES.md b/Museion/Resources/THIRD-PARTY-NOTICES.md new file mode 100644 index 0000000..1816d59 --- /dev/null +++ b/Museion/Resources/THIRD-PARTY-NOTICES.md @@ -0,0 +1,41 @@ +# Third-Party Notices + +Museion is GPL-3.0-or-later. It bundles the two components below, both under +the MIT License; the full license text follows. + +## apex 1.1.58 (`apex`) + +Markdown → HTML converter, used for reading mode. +Copyright (c) 2026 Brett Terpstra — https://github.com/ApexMarkdown/apex +Redistributed as the arm64 slice of the v1.1.58 release binary (checksum +verified against the published `.sha256`), re-signed for Developer ID +distribution; rpath rewritten to load the libyaml beside it. + +## libyaml 0.2.5 (`libyaml.bundle/libyaml-0.2.dylib`) + +YAML parser linked by apex. +Copyright (c) 2017-2020 Ingy döt Net +Copyright (c) 2006-2016 Kirill Simonov — https://github.com/yaml/libyaml +Re-signed for Developer ID distribution (the hardened runtime's library +validation requires the team's own signature); shipped inside a `.bundle` +folder so Xcode copies it as a resource instead of linking it into the app. + +## MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Museion/Resources/apex b/Museion/Resources/apex index e36f68a..9be7698 100755 Binary files a/Museion/Resources/apex and b/Museion/Resources/apex differ diff --git a/Museion/Resources/libyaml.bundle/libyaml-0.2.dylib b/Museion/Resources/libyaml.bundle/libyaml-0.2.dylib new file mode 100644 index 0000000..6bbe36e Binary files /dev/null and b/Museion/Resources/libyaml.bundle/libyaml-0.2.dylib differ diff --git a/README.md b/README.md index 7e671fc..b42443c 100644 --- a/README.md +++ b/README.md @@ -137,4 +137,4 @@ swiftformat . && swiftlint . # lint ## License -GPL-3.0-or-later — see [LICENSE](LICENSE). +GPL-3.0-or-later — see [LICENSE](LICENSE). The bundled reading renderer (apex) and its libyaml are MIT; see [Museion/Resources/THIRD-PARTY-NOTICES.md](Museion/Resources/THIRD-PARTY-NOTICES.md). diff --git a/docs/adr/0011-apex-html-reading-pipeline.md b/docs/adr/0011-apex-html-reading-pipeline.md index c1e0bb9..770ec42 100644 --- a/docs/adr/0011-apex-html-reading-pipeline.md +++ b/docs/adr/0011-apex-html-reading-pipeline.md @@ -9,7 +9,7 @@ Reading mode renders markdown through apex (MIT, unified dialect) as an HTML fra ## Consequences -- **Bundling:** the prebuilt apex binary ships in app resources, signed + notarized. No source build in CI, no user install gate — a renderer must not grow a gate. +- **Bundling:** the prebuilt apex binary (arm64 slice) and a vendored libyaml ship in app resources, Developer ID–signed at commit time (apex with the hardened runtime), apex's rpaths replaced by the single `@executable_path/../Resources`, which resolves in the bundle and in the checkout alike; Xcode copies and seals both as resources untouched. The vendored copy lives in `Resources/libyaml.bundle/` ON PURPOSE: Xcode's synced-folder classifier sniffs Mach-O content and silently adds any bare dylib (extension or not) to the app's link phase; a `.bundle` folder is an opaque resource. apex's release build links libyaml through CI/Homebrew rpaths, so alone it only ever ran on developer machines — reading mode silently fell back to source for everyone else (surfaced by the 0.1.0 notarization, which also rejects an unsigned Mach-O in Resources). Re-sign both when the Developer ID certificate rotates (`codesign -f -s "" --options runtime --timestamp Resources/apex`; `codesign -f -s "" --timestamp Resources/libyaml.bundle/libyaml-0.2.dylib`). No source build in CI, no user install gate — a renderer must not grow a gate. Licenses: `Resources/THIRD-PARTY-NOTICES.md`. - **One WKWebView, reloaded in place.** Remounting per document (`.id(sel)`) was the dominant switch cost — hundreds of ms of web-process respawn; `loadHTMLString` on a retained view feels instant. - **`--no-mixed-lists` is required**, not tuning: apex's default merges an ordered list following a bullet list into one `
    `, killing `1. 1. 1.` auto-renumbering. - **Early handoff:** stdout EOF is conversion done; apex's ~65 ms teardown is reaped async via `terminationHandler` (the error path still waits for exit status).