Skip to content

feat: add native read-only macOS experience - #18

Merged
karngyan merged 2 commits into
mainfrom
feat/alpha-macos-app
Jul 16, 2026
Merged

feat: add native read-only macOS experience#18
karngyan merged 2 commits into
mainfrom
feat/alpha-macos-app

Conversation

@karngyan

Copy link
Copy Markdown
Contributor

Claim

Alpha PR 5 — the complete local loop (sessions, deterministic findings, mutation candidates, and their lifecycle audit) is now inspectable in a native macOS app without JSON output or a raw SQLite browser, and the app never writes the database.

apps/macos is a SwiftPM package (no Xcode required): a testable AutophagyKit library plus a thin SwiftUI executable. It builds and tests under the Command Line Tools with swift build / swift test, and a small script wraps the binary into a launchable .app.

What it does

  • Read-only by construction. Every connection opens with SQLITE_OPEN_READONLY and sets PRAGMA query_only = ON; the app has no SQL write path.
  • Onboarding + selection. Resolves the same default path as the CLI (~/Library/Application Support/sh.autophagy.Autophagy/autophagy.db), lets the user pick another .db, validates it is an Autophagy database, and remembers the choice in UserDefaults only.
  • Views. Sessions + event timelines (exact event IDs); Patterns as the Evidence Packet preserved inside each registered candidate (exact supporting/counterexample IDs); Mutations with lifecycle state, evidence lineage, audit log, and read-only replay/shadow/installation records; a Privacy view showing on-disk location, schema compatibility, honest content counts, and the ingestion-time redaction/projection/retention posture.
  • Schema tolerance. Classifies the database (supported / older-readable / newer-than-known / not-Autophagy) from user_version + schema_migrations, and checks table existence before each query so an off-version database degrades to empty views and a clear message instead of crashing.
  • CLI-mediated deletion. Session and delete-all are delegated to the autophagy CLI behind multi-step confirmation (including the delete-all phrase mirroring the CLI guard). The exact command is shown and run via Process, or displayed when no binary is found.

Evidence

  • swift test23 tests pass (swift-testing) covering:
    • read-only guarantee (a write is rejected on the app's connection);
    • schema tolerance (older, newer, and non-Autophagy databases handled without crashing);
    • session/event reads with exact event IDs, evidence-packet extraction, mutation detail (lineage + audit + package decode), rejection reason, orphaned-evidence flagging, and overview counts;
    • default-path resolution matching the CLI, CLI-command construction/quoting, binary location, and startup-path selection.
  • swift build — exit 0 for both the library and the SwiftUI target.
  • mise run check — exit 0 (Rust untouched; docs/actionlint/fmt/lint/test stay green, including the new guide and workflow).
  • Smoke test. Imported evals/fixtures/** with the existing CLI into a demo database, then drove AutophagyKit against it: it reports schema v6 supported, 15 sessions, working event timelines, 3 findings, and 3 mutations. The SwiftUI executable launches and runs its event loop; the .app bundle produced by scripts/make-app-bundle.sh validates with plutil.

Privacy

The app is a read-only viewer: it opens a local database, sends nothing off the machine, adds no export path, and cannot mutate stored data. Deletion is delegated to the CLI, so the app never becomes an unaudited way to remove or leak evidence. Details in ADR docs/decisions/0005-macos-read-only-app.md.

Roadmap

Satisfies PR 5's exit criterion — "the complete local loop is inspectable without using JSON output or raw SQLite tools" — and marks that section complete.

🤖 Generated with Claude Code

karngyan and others added 2 commits July 17, 2026 00:58
Add apps/macos, a SwiftPM package that makes the complete local loop
inspectable natively without JSON output or a raw SQLite browser.

The app opens the database strictly read-only (SQLITE_OPEN_READONLY plus
PRAGMA query_only = ON) and holds no SQL write path of its own. It resolves
the same default database path as the CLI, validates the file is an Autophagy
database, and tolerates older/newer schema versions by classifying the schema
and checking table existence before every query.

Views cover sessions and their event timelines (with exact event IDs),
deterministic findings preserved inside registered candidates (with exact
supporting and counterexample event IDs), the mutation candidate registry with
lifecycle audit and read-only replay/shadow/installation records, and an honest
privacy view. Deletion is delegated to the autophagy CLI behind multi-step
confirmation: the exact command is shown and run via Process, or displayed when
no CLI binary is found.

Structured as a testable AutophagyKit library plus a thin SwiftUI executable.
Builds, tests (swift-testing), and bundles under the Command Line Tools with no
full Xcode. Adds a path-filtered macos-latest CI workflow, ADR 0005, a guide,
and repository-map and roadmap updates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Run the destructive-action subprocess off the main actor via
  Task.detached and marshal state back to @mainactor, so the spinner
  renders and a slow/hung CLI cannot freeze the UI. Mark CLICommand,
  DestructiveAction, and RunResult Sendable for the crossing.
- Add schema-tolerance tests with a v2-era foundation-only database
  (missing later mutation/conflict/signature tables) and a
  mutation_candidates table missing a selected column, asserting the
  reader degrades to empty instead of throwing.
- Make Database.execute() private so the no-write-path guarantee is
  enforced at the API surface, not only by connection flags; the
  read-only test now exercises the public query() path.
- Note in DatabaseReader.count() that table names are hardcoded
  constants (with a fixed-allow-list guard if that ever changes).
- Align ADR 0005 wording with swift-tools-version:6.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karngyan
karngyan merged commit a4ce1ef into main Jul 16, 2026
2 checks passed
@karngyan
karngyan deleted the feat/alpha-macos-app branch July 16, 2026 19:39
karngyan added a commit that referenced this pull request Jul 16, 2026
Prepare the repository for its first release without performing one. No tag,
published version, or version bump is created here.

- Add a Keep-a-Changelog `CHANGELOG.md` with a single `[Unreleased]` section
  summarizing pull requests #1#18 grouped by Added/Changed and by milestone.
- Add `.github/workflows/release.yml`, triggered only on `v*` tag pushes (plus a
  build-only `workflow_dispatch`). It builds the `autophagy` CLI for macOS
  (arm64) and Linux (x86_64) via the mise-pinned toolchain, builds the macOS app
  bundle with `swift build -c release` through `make-app-bundle.sh`, uploads
  everything as workflow artifacts, and creates a DRAFT GitHub release for a
  human to publish. All actions are SHA-pinned. It stays dormant until tagged.
- Update the README Status section to reflect the completed alpha (retrieval,
  synthesis boundary, macOS read-only app) and add an "Install / Build from
  source" section (mise + cargo + swift).
- Add a release-readiness closing note to the alpha roadmap.

Version audit: all 14 workspace crates use `version.workspace = true`, resolving
to `0.1.0-alpha.1` in the root `Cargo.toml`. Left unchanged.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant