From d16cbaa8570734b59eadea1361ee37846bdb3c66 Mon Sep 17 00:00:00 2001 From: sergiudm Date: Tue, 17 Nov 2026 20:37:19 -0800 Subject: [PATCH] Memory: a shared wiki about the user, and a switch for what each app may do with it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LaunchX now keeps one memory for the user: Markdown pages (profile, preferences, schedule, resume, projects, people) that their apps and agents read and write together. The user sets Off, Read or Read & write for each app, on its card, in the page's new Memory view, or with `lx memory access `. Everything starts off, and the launcher checks the switch on every request. It follows the components of agent memory: a log of every write (memory/log.jsonl), linked pages (memory/pages/), and a short index of one line per page for an app or agent to load at the start of a session. Updates name the revision they read, so a stale write is refused with the current page instead of silently undoing someone else's change. The version each write replaces is kept, and the page can show and restore it. Each managed service gets LAUNCHX_MEMORY_URL and its own LAUNCHX_MEMORY_TOKEN, which opens /api/memory and nothing else and is never handed to dependents, so writes are logged under the caller's id. A manifest may ask for access with [service..memory] wants/reason. Agents learn about memory from a generated launchx-memory skill, while the user allows it. `lx memory` (ls, show, write, append, rm, history, log, search, lint, index, access, open) works with or without a running launcher. SPEC.md §12 is the contract. Co-Authored-By: Claude Opus 5.5 --- README.md | 32 +- SPEC.md | 177 +++++- src/agents.rs | 53 +- src/check.rs | 2 +- src/client.rs | 6 + src/gateway.rs | 65 ++- src/home.rs | 15 + src/main.rs | 493 ++++++++++++++++- src/manifest.rs | 14 + src/memory.rs | 1205 +++++++++++++++++++++++++++++++++++++++++ src/supervisor.rs | 101 +++- src/util.rs | 10 + tests/end_to_end.rs | 110 +++- tests/fixtures/svc.py | 28 +- ui/app.js | 493 ++++++++++++++++- ui/index.html | 28 +- ui/style.css | 117 ++++ 17 files changed, 2885 insertions(+), 64 deletions(-) create mode 100644 src/memory.rs diff --git a/README.md b/README.md index 1e117c8..0ca3d26 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Eight ideas shape the contract. Each is a claim about how software should be bui **8. No side taken on models or harnesses.** The contract asks nothing of an agent except that it can run a command and read JSON, so whichever model and harness you use next year will work. It asks little of software too: an app that has never heard of LaunchX joins with a manifest and no code changes. -The two pictures show where this is heading. Draft 0.1 of the contract already requires ideas 1, 2, 4 and 6, and is built around 7 and 8. For idea 3 it has one switch per app, and that switch decides what agents are told, not what they can reach; a switch for each part of an app is not there yet. Idea 5 is up to each app today: buttons, switches and drags work, and the pen and the shortcut keys are still plans. +The two pictures show where this is heading. Draft 0.1 of the contract already requires ideas 1, 2, 4 and 6, and is built around 7 and 8. For idea 3 it has two switches per app: whether agents are told about it, which decides what they are told rather than what they can reach, and what it may do with your [shared memory](#shared-memory), which LaunchX enforces on every request. A switch for each part of an app is not there yet. Idea 5 is up to each app today: buttons, switches and drags work, and the pen and the shortcut keys are still plans. ## What the contract asks @@ -105,6 +105,8 @@ LaunchX is the only app: services stay in the browser, where they get tabs, book | `lx state` | The launcher's full state document as JSON. | | `lx up` / `lx down` | Register or remove the launcher as a login service, and start or stop it. | | `lx agents` / `lx agents on ` / `lx agents off ` | What your AI agents can discover, and the switch for each service (see below). | +| `lx memory` | Your shared memory: `ls`, `show`, `write`, `append`, `rm`, `history`, `log`, `search`, `lint`, `index`, `open` (see below). | +| `lx memory access` / `lx memory access none\|read\|write` | Which apps, and whether your agents, may read or write your memory. | Every page of the launcher is also an API: `GET /api/state`, `GET /api/events` (server-sent events), `POST /api/services//start`. Programs reach it at `http://127.0.0.1:7600` with the token in `~/.launchx/run/launchx.json`. @@ -118,6 +120,29 @@ Each service has a **Discoverable by agents** switch: on its card, in the menu b Switching a service off removes what LaunchX put there; LaunchX never touches skills it did not create. The switch controls what agents are told, not what they can reach: an agent runs as you, so it could still find a hidden service if it went looking. +## Shared memory + +Every app you run should not have to ask who you are. LaunchX keeps one memory for you, a small wiki of Markdown pages (your profile, preferences, schedule, resume, projects, the people you work with) that your apps and agents read and write together. You decide, per app, whether it may read it, read and write it, or neither: on the app's card, in the page's **Memory** view, or with `lx memory access read`. Every app starts with no access. + +```sh +lx memory write profile --summary "PhD student in computer science, Pacific time" < profile.md +lx memory access rmd write # Schedule Everything keeps the schedule page +lx memory access papers read # the paper reader picks papers from your profile +lx memory access agents write # publish the launchx-memory skill to your agents +lx memory log # who changed what, and why +lx memory open # browse, edit, see history and restore in the browser +``` + +It is built from the components of agent memory: a **log** of every write (the transcript), **pages** linked with `[[page]]` (the representation), and a short **index** of one line per page that an app or agent loads at the start of a session (the injected context). What keeps it trustworthy when many writers share it: + +- **Nobody overwrites anyone by accident.** An update names the revision it read; if the page changed since, it is refused with the current page, and the writer merges. The page does the same for you while you edit. +- **Each app writes as itself.** An app gets its own memory token (`LAUNCHX_MEMORY_TOKEN`), which opens memory and nothing else, and its writes are logged under its id. +- **Nothing is lost.** The version a write replaces is kept; `lx memory history ` and the page's History button show and restore the last 20. +- **It stays small.** Pages hold up to 64 KB, the index up to 200 lines, and `lx memory lint` points out broken links, missing summaries, and duplicate, large or stale pages. Tidying is an agent's job, with your model: an agent with write access is told how in its skill. +- **It is yours.** The pages are plain files in `~/.launchx/memory`, editable with anything, and `lx memory` works when LaunchX is not running. + +An app reaches memory through `LAUNCHX_MEMORY_URL` with its token (`GET /api/memory/index`, `GET /api/memory/pages/profile`, `PUT` with `base`, `POST /api/memory/append/`), and can ask for access in its manifest with `[service..memory] wants = "read"` and a `reason` you see on its card. [SPEC.md §12](SPEC.md#12-shared-memory) has the details. + ## Files `~/.launchx` (or `$LAUNCHX_HOME`), mode 0700: @@ -128,7 +153,8 @@ services/ links to registered manifests run/.json URL, token and pid of each running service (mode 0600) logs/.log captured output, rotated at 5 MB agents/skills/ skills published to your agents, linked from their skill folders -state.json assigned ports and tokens, the session secret, and the agents switches (mode 0600) +memory/ your shared memory: pages/, history/ and log.jsonl +state.json assigned ports and tokens, the session secret, and the agents and memory switches (mode 0600) ``` ## Development @@ -137,7 +163,7 @@ state.json assigned ports and tokens, the session secret, and the agents cargo test # unit tests and an end-to-end run against fixture services ``` -The end-to-end test starts a real daemon on a spare port with fixture services and covers dependency order, sign-in, the token swap, the Origin check, streaming and Upgrade through the gateway, restart back-off, `lx check`, the agents switch, and shutdown. +The end-to-end test starts a real daemon on a spare port with fixture services and covers dependency order, sign-in, the token swap, the Origin check, streaming and Upgrade through the gateway, restart back-off, `lx check`, the agents switch, shared memory (an app reading and writing with its own token under each access level, refused stale writes, the memory skill, `lx memory` without a launcher), and shutdown. ## License diff --git a/SPEC.md b/SPEC.md index f6ff8c4..8ffffa5 100644 --- a/SPEC.md +++ b/SPEC.md @@ -1,6 +1,6 @@ # LaunchX Service Contract -Version 0.1 — draft, 2026-11-10 +Version 0.1 — draft, 2026-11-17 ## 1. What this is @@ -134,6 +134,21 @@ skills = "plugins/schedule-everything/skills" The manifest says what is on offer. Whether agents are told about it is the user's choice (§10.7). +### 4.8 Memory fields + +The optional `[service..memory]` table says what the service would like to do with the user's shared memory (§12), and why. It grants nothing: it is shown to the user next to the switch they set. + +| Key | Type | Meaning | +|---|---|---| +| `wants` | `"read"` or `"write"` | The access the service asks for. | +| `reason` | string | One line the user sees, for example "Keeps your schedule page current". | + +```toml +[service.rmd.memory] +wants = "write" +reason = "Keeps your schedule page current and suggests tasks that fit your profile" +``` + ## 5. Process contract (level 1) ### 5.1 Foreground @@ -154,6 +169,8 @@ The service inherits the user's login environment, then the manifest's `env`, th | `LAUNCHX_URL` | The service's browser URL, for example `http://vmc.localhost:7600`. Use it to build links shown to people. | | `LAUNCHX_DEP__URL` | Direct URL of a required service (§9). `` is the id in upper case with `-` replaced by `_`. | | `LAUNCHX_DEP__TOKEN` | That service's token. | +| `LAUNCHX_MEMORY_URL` | The shared memory's API (§12.4), for example `http://127.0.0.1:7600/api/memory`. | +| `LAUNCHX_MEMORY_TOKEN` | The service's own memory token (§12.3). Given to every managed service, with or without HTTP. | The port and token of a service stay the same across restarts until the user resets them. @@ -319,8 +336,10 @@ services/ registered manifests (links or files) run/.json one per running service, mode 0600 logs/.log captured output, rotated agents/skills/ skills published to agents (§10.7) -state.json assigned ports and tokens, which services the user left running - and which are discoverable by agents; mode 0600 +memory/ the user's shared memory (§12.1) +state.json assigned ports and tokens, which services the user left running, + which are discoverable by agents and what each may do with + memory; mode 0600 ``` The launcher runs services with the `PATH` of the user's login shell, not the bare one that launchd or systemd provide. @@ -393,6 +412,9 @@ POST /api/services/{id}/start POST /api/services/{id}/stop POST /api/services/{id}/restart POST /api/services/{id}/agents body {"discoverable": true|false} (§10.7) +POST /api/services/{id}/memory body {"access": "none"|"read"|"write"} (§12.3) +POST /api/memory/agents body {"access": "none"|"read"|"write"} (§12.6) +* /api/memory/… the shared memory (§12.4) GET /api/services/{id}/logs?tail=200 GET /api/agents what agents are told (§10.7) POST /api/link one-time sign-in link; body {"service": id?, "next": path?} @@ -421,9 +443,11 @@ Its state document: "since": "2026-11-10T16:40:02Z", "restarts": 0, "last_exit": null, - "agents": { "discoverable": false, "skills": [] } + "agents": { "discoverable": false, "skills": [] }, + "memory": { "access": "read", "wants": "read", "reason": "Shows the machines your profile names" } } - ] + ], + "memory": { "agents": "none", "pages": 6, "dir": "/Users/me/.launchx/memory" } } ``` @@ -442,6 +466,8 @@ Its CLI: | `lx state` | Print the launcher's state document. | | `lx agents` | List the services agents can discover (§10.7). | | `lx agents on …` / `lx agents off …` | Make services discoverable by agents, or hide them. | +| `lx memory` | The shared memory (§12.7): `ls`, `show`, `write`, `append`, `rm`, `history`, `log`, `search`, `lint`, `index`, `open`. | +| `lx memory access [\|agents ]` | Who may use memory, or set it. | Every command that reads takes `--json`. @@ -477,17 +503,150 @@ The switch decides what agents are told, not what they can reach. An agent runs | A web page sending requests to localhost | The gateway's Origin check; no CORS on services. | | DNS rebinding | The gateway routes by Host; services require a token the attacker's page cannot have. | | One service reaching into another | Tokens are per service; only declared dependencies receive one (§9). | +| A service reading or changing memory the user did not allow | The service's memory token, and the user's switch, checked on every request (§12.3). | +| One service using memory under another's name | Memory tokens are per service and never handed to dependents; writes are logged under the caller's id, whatever it claims. | +| A lost update to a shared page | Every update names the revision it was based on; a stale one is refused (§12.5). | | Other devices on the network | Everything binds to loopback by default. | -Out of scope: a hostile process running as the same user. It can read the run files, as it can read everything else the user owns. This includes an AI agent the user runs: hiding a service from agents (§10.7) keeps it out of what they are told, and a well-behaved agent stays away, but only running the agent as another user, or in a sandbox, keeps it out. +Out of scope: a hostile process running as the same user. It can read the run files, as it can read everything else the user owns. This includes an AI agent the user runs: hiding a service from agents (§10.7) keeps it out of what they are told, and a well-behaved agent stays away, but only running the agent as another user, or in a sandbox, keeps it out. The same holds for memory: its files are the user's, so a service that reads them directly, rather than through the API, is not stopped by the switch. + +Memory is read by agents, so it is a path for prompt injection: a service with write access could write instructions where an agent will read them. The memory skill (§12.6) tells agents to treat pages as information, not instructions, and every page and log entry says who wrote it. Give write access to services you trust with that. + +## 12. Shared memory + +The launcher keeps one memory for the user: a small wiki of pages about the person (who they are, how they like to work, their schedule, resume and projects) that their services and agents read and write together, so that the person does not have to tell each of them the same things. The user decides, for each service and for their agents, whether it may read memory, read and write it, or neither. + +Its design follows the components of agent memory: a log of every write (the transcript), linked pages (the representation), and a short index meant to be loaded at the start of every session (the injected context). + +### 12.1 Store + +`$LAUNCHX_HOME/memory`, mode `0700`: + +``` +pages/.md one page per topic; may hold '/' (projects/thesis) +history// the versions writes replaced: