Private local-first Memex prototype with macOS Seatbelt Qwen inference
README.md

trifecta-memex #

A private, local-first assistant for searching and reasoning over personal data on a MacBook.

The idea is to download data from services I use—calendar events, Bank of America transactions, health insurance records, and personal notes—using small, trusted scripts. A local AI model then reads the downloaded copies and answers questions without network access. When data is stale, the assistant may request a refresh through a narrowly defined interface; the refresh script runs outside the model's sandbox.

Status: Project concept. This README describes the intended architecture, not an implemented security guarantee.

Current model choice #

Start with Qwen 3.5 9B for answers and Qwen3 Embedding 0.6B when semantic search is added. Model and runtime notes, including alternatives, are in docs/model-notes.md. The Apple Silicon Nix environment is in flake.nix.

The flake provides Ollama, Python, and memex-seatbelt-check on Apple Silicon. It uses a checksum-pinned official macOS Ollama archive because the nixpkgs Ollama build lacks the MLX runtime needed by qwen3.5:9b. Model weights are downloaded into local state by a setup script that must run inside the network-enabled agent Seatbelt profile. Inference uses this project's separate offline Seatbelt profile. Follow the commands below before using private data. The Nix Ollama backend may differ from the Homebrew MLX backend that passed in Tart, so confirm GPU use on the host Mac.

Seatbelt inference smoke test #

This project includes its own memex_seatbelt.py and tests. They do not import files from the agent-sandbox repository. The default profile denies external networking; --loopback-all --gpu grants the local Ollama API, dynamic MLX worker port, and Metal runtime used in the Tart guest test. The launcher starts with an empty environment-file source and does not inherit host API keys unless explicitly passed with --env.

First, start your usual network-enabled Seatbelt session in the Memex directory. This project's agent launcher grants loopback port 11434 with --network. The session also needs Ollama and Python on PATH and a writable model directory. Inside that session, run:

./scripts/download-qwen-mac.sh

The script verifies it is inside Seatbelt, starts a temporary Ollama server, downloads qwen3.5:9b only if missing, and stops the server. Weights go to ~/.local/state/memex-seatbelt/models by default. Port 11434 must be free. This is the only networked preparation step; Memex's inference launcher has no general-network option.

Then leave that session. From a normal Mac terminal in the Memex directory, run the offline inference smoke test:

python3 tests/seatbelt_qwen_smoke.py

If the model is stored elsewhere, use the same path in both sessions:

# Inside the networked Seatbelt session:
./scripts/download-qwen-mac.sh --models /path/to/models

# Later, from a normal Mac terminal:
python3 tests/seatbelt_qwen_smoke.py --models /path/to/models

The smoke script finds prepared weights under the normal home directory, the agent Seatbelt home directory, or ~/.ollama/models, and enters the pinned Nix shell automatically if Ollama is not on PATH. To enter the dev shell manually for the full regression check, use nix develop path:. followed by memex-seatbelt-check. Plain nix develop cannot see this copy's untracked flake inside the parent Git repository. The command uses this project's smoke and regression tests, and saves its generated profile and server log under ~/.local/state/qwen-seatbelt-smoke. Read docs/seatbelt-tart-results.md for the passing Tart guest run and its limits. The same test still needs to pass on the actual Mac host before private data is used. The host's Nix Ollama runtime may use a different GPU backend from the Homebrew MLX runtime that passed in Tart.

Offline Qwen folder chat #

From a normal Mac terminal, run this script in the folder Qwen may access:

/path/to/memex/scripts/qwen-folder-shell-mac.sh

You can pass a folder path as the first argument instead. The script enters the pinned Nix shell, starts Ollama inside the offline Seatbelt profile, and opens a Qwen chat with list, read, search, and write tools limited to that folder. Type /exit to stop the chat and server. The folder is writable; the model directory is read-only. General outbound networking is denied, while loopback is available to Ollama and its MLX worker. No host API credentials are passed through. The agent does not have a shell command tool.

If the downloaded model is stored in another directory, run:

./scripts/qwen-folder-shell-mac.sh --models /absolute/path/to/models

What I want it to do #

  • Answer questions across sources, such as “What did I spend on medical care last quarter?” or “Which appointments might relate to this insurance claim?”
  • Show the records behind an answer, including source and retrieval date.
  • Keep downloaded data and model inference on my MacBook.
  • Refresh selected sources on demand or on a daily schedule.

Architecture #

External services
      │
      ▼
Trusted fetch scripts (network access; scheduled or manually invoked)
      │
      ▼
Local data store (source snapshots + metadata)
      │ read-only
      ▼
Sandboxed local model (no network access)
      │
      ├── answers with citations to local records
      └── requests an allowlisted refresh ──► trusted refresh broker ──► fetch script

The model should receive only the data needed for a question. Fetchers normalize downloaded records into a documented local format, retain provenance, and record when each source was last refreshed. The model can read those records but cannot modify the source snapshots.

Trust boundary #

The security goal is to prevent untrusted text in downloaded data from causing the model to disclose private information or run arbitrary commands. This is the “lethal trifecta” concern: an assistant that has access to private data, encounters untrusted instructions, and can send data outward.

The model cannot edit the refresh scripts. If those scripts are well designed, invoking them does not give the model a way to send private data out of the sandbox: each script contacts only its preconfigured source and accepts no model-controlled URL, request body, destination, or arbitrary command arguments. A small broker accepts only fixed source identifiers (for example, calendar or bank_transactions) and runs the corresponding script. It does not pass model-written text to the script. The broker returns only refresh status and the identifier of the new local snapshot.

This boundary depends on the scripts and broker actually enforcing those restrictions. Network isolation blocks direct outbound connections from the model; the fixed refresh interface blocks indirect ones.

Other boundaries to enforce during implementation:

  • Run the model process without network access, including loopback where practical, and verify that the restriction actually applies to child processes and tools.
  • Mount snapshots read-only for the model. Keep credentials and fetcher configuration outside its sandbox.
  • Expose no shell, browser, arbitrary file write, or general-purpose HTTP tool to the model.
  • Treat all downloaded content, including notes and document text, as data rather than instructions.
  • Review any future tool that can write files or contact a service as a possible exfiltration route.
  • Keep an audit log of refresh requests and source updates without logging secrets or unnecessary record contents.

Sandboxing also does not prevent an inaccurate answer, accidental disclosure in the user interface, or compromise of the trusted fetchers. Those need separate controls and testing.

Planned components #

Component Responsibility
Fetchers Authenticate to each source and download data on a schedule or through the broker.
Normalizer Convert source exports into consistent local records with timestamps and provenance.
Local store Hold snapshots and indexes with appropriate file permissions and encryption at rest.
Query runner Retrieve relevant records and pass a bounded context to the local model.
Refresh broker Map allowlisted source names to fixed fetch scripts and report their status.
Interface Accept questions and display answers with links to the underlying local records.

First implementation milestones #

  1. Build one read-only source pipeline using sample data, with provenance and refresh timestamps.
  2. Run a local model in a verified network-disabled sandbox and test that it cannot reach the network or fetcher credentials.
  3. Add retrieval and answers that cite local records; make uncertainty and stale data visible.
  4. Add the fixed-command refresh broker and test prompt-injection attempts embedded in source records.
  5. Add real source connectors one at a time, starting with the least sensitive data.

Data handling #

Personal financial and health records are sensitive. The project should keep raw downloads out of version control, restrict local file access, encrypt stored data where appropriate, and provide a way to delete snapshots and indexes together. Backups and model logs need the same protection as the source data. Connector credentials should use the macOS Keychain or another dedicated secret store, not files readable by the model.

Name #

“Memex” refers to a personal knowledge system. “Trifecta” is a reminder to keep private-data access, untrusted content, and outbound capabilities from combining in the model's environment.