# The demo site

The demo at forget.stellarminds.ai is a Starlette app in the format of
[act.stellarminds.ai](https://act.stellarminds.ai): it serves the landing page and the console, two
sample hosts, the public documentation, and Pim's side of the ForgetMe button. This page shows you how
it is put together, how to run and test both services locally, how to record the examples the pages
show, what the landing page runs, and how it is deployed.

Status: deployed from `main` by Railway as two services, `site` and `company`.

Pim is the demo's fictional personal agent and the **host**: the server behind the button. Bay Parcel is
the **Company** it shared an address with, the [reference Company](/docs/company) on its own
origin. Every run builds real stores for a fictional user and ends with signed **receipts** the browser
verifies. The [glossary](/docs/glossary) has the rest.

## The files

- `world.py`: John, his agent Pim, and the four stores a run builds fresh: Chroma, a mem0 history,
  SQLite notes, a JSONL knowledge graph. Pim's Chroma steps run in a child process, as a real agent's would.
- `stories.py`: the eight stories and their checks. Each check reads the files.
- `forgetme.py`: Pim's side of the button. Scenarios (a fresh world per visitor, with a synthetic
  signed-in session for the fictional John), the opaque references Pim issues per memory item, the host
  contract under `/forget-me/v1/` (preview, submit, operation status, evidence), durable at-most-once
  operations under the runs directory, retrieval stopped at accept, portable receipts signed with the
  site key, restart reconciliation, and the courier (the reference Company when one is configured, else
  simulated). `python -m demo.forgetme <out.json>` records the landing page's example; it starts a
  Company on a loopback port, and `--local-only` does not.
- `recipients.py`: the cross-provider level: who Pim shared a memory with, and how it asks them. Bay
  Parcel is the reference Company, its own process and origin; Harbor Pharmacy (API-only) and Oakland
  Utilities (offline, then without ForgetMe) are simulated inside Pim's process and labelled so. On only
  when `FORGETME_COMPANY_URL` points at a Company. Toward the Company Pim is a Poppy 1.0 Personal Agent:
  discovery with the checks of spec 3, a Session per scenario, an access token from the Company's token
  endpoint, and the person's approval of the Company's exact terms sent with the request (Operations
  extension, version 3).
- `poppy_agent.py`: Pim's Poppy identity: the P-256 key (`FORGETPROOF_HOME/pim-poppy-es256.pem`), the
  client metadata document and key set served at `/poppy/agent.json` and `/poppy/jwks.json`, delegated
  keys and delegations, a Session JWT per request, client assertions, the `Poppy-Extensions` and
  `Poppy-Approval` headers. Written with `cryptography` only; checked against the Poppy kit's schemas.
- `server.py`: the Starlette app: pages, `/api/runs`, SSE events, `/api/latest`, each hosted run's
  fictional provider (Pim Cloud) under `/runs/<id>/pim/…`, Pim's UI API under `/pim/*` (sessions,
  memory, deliveries, recipients, `share`), the ForgetMe contract routes (the index at `/forget-me/v1`
  lists the site's keys), the sample hosts at `/hosts/memory-list` and `/hosts/chat`, the button package
  at `/forget-me/button/`, the public documentation (`/docs`, `/docs/<slug>`, `/schemas/…`, `/verify`),
  deep links (`/stories/<name>` to `/console?story=<name>`; `/#story-<name>` and `/#try` on the landing
  page), shareable results (`/runs/<id>` for a story run, `/s/<id>` for a ForgetMe result the owner
  published) and the recorded withdrawals (`/recorded/withdrawal-*.json`). `/health` and `/config` carry
  the commit (`RAILWAY_GIT_COMMIT_SHA` in production).
- `chrome.py`: the header and footer every public page shares, rendered once from here into the
  `<!--@chrome:header-->` and `<!--@chrome:footer-->` markers of the static pages and into the docs
  frame: the three audiences and the docs as primary links, a burger menu (a `<details>`, so it works
  without JavaScript) grouped by what a visitor came to do, and a footer in four columns. One place to
  add a link. The stylesheet is `static/chrome.css`.
- `audiences.py`: the three audience pages, `/for/personal-agents`, `/for/small-businesses` and
  `/for/enterprises`: what each reader gets and where it stops. The landing page opens with the
  three-way split (`/#who`).
- `docs.py`: the documentation the demo serves: a small Markdown renderer over the repository's own
  files, with links rewritten to the routes that serve each file, or shown as plain text when nothing
  serves it, and the package status table (every package is unreleased; checked 2026-11-21).
- `retention.py`: the retention and cleanup job for synthetic run data on the volume: public artifacts
  (`public/runs/<id>.json` after `RUNS_RETENTION_DAYS`, default 7; `public/shares/<id>.json` at their
  `expires_at`, `SHARE_TTL_DAYS`, default 7), orphaned run directories after a day, expired ForgetMe
  scenarios. Runs at start and every `RETENTION_SWEEP_SECONDS` (600) from the lifespan, and by hand:
  `python -m demo.retention [--dry-run]`. Public artifacts stay apart from private receipts (the run
  directory, `forget-me/<scenario>/pim/receipts`). Shares are capped per scenario.
- `record_stories.py`: `python -m demo.record_stories` records one run of each story for
  `public/recorded/stories.json`, so a first visit after an empty restart still shows an illustrative,
  labelled result per story (served by `/api/latest` with `source: "recorded"` until a live run replaces
  it). Run it, like `python -m demo.forgetme`, inside the Docker image so no local path ends up in the file.
- `public/`: the pages (`index.html`, `console.html`, `verify.html`, `share.html`, `hosts/memory-list.html`,
  `hosts/chat.html`) and the recorded examples (`recorded/forget-me.json`, the landing page's cross-provider
  example; `recorded/withdrawal-local-only.json` and `recorded/withdrawal-cross-provider.json`, the audit
  hand-off's two withdrawals from click to signed outcome, with a `steps` list each; `recorded/stories.json`).
- `static/`: the JavaScript verifier (a copy of `packages/forgetproof-verify/src`, refreshed by the
  Dockerfile at build time, and checked byte for byte by `tests/test_public.py`), `site.css` and
  `chrome.css`. The Dockerfile also copies `packages/forgetme-button/src` to `static/forget-me-button/`;
  when run from the source tree the server serves the package's files directly instead.

## Run it locally

Both origins, the Company first, then Pim pointed at it:

```bash
uv sync --all-extras
COMPANY_DEV_CLIENTS=1 uv run python -m company &                      # http://localhost:8090, the reference Company
FORGETME_COMPANY_URL=http://localhost:8090 PIM_ORIGIN=http://127.0.0.1:8080 uv run python -m demo.server   # http://localhost:8080
```

Each ends its start with `Uvicorn running on`; `curl -s http://localhost:8080/health` answers
`{"ok": true, …, "cross_provider": true}`. On Windows in PowerShell:

```powershell
$env:COMPANY_DEV_CLIENTS="1"; Start-Process uv -ArgumentList "run python -m company"
$env:FORGETME_COMPANY_URL="http://localhost:8090"; $env:PIM_ORIGIN="http://127.0.0.1:8080"; uv run python -m demo.server
```

`COMPANY_DEV_CLIENTS=1` lets the Company accept Pim's loopback client id; never set it in production.
Without `FORGETME_COMPANY_URL` Pim runs the local-only level, with the courier simulated and labelled,
and `/health` reports `"cross_provider": false`. `PIM_ORIGIN` is where the Company fetches Pim's client
metadata document (`/poppy/agent.json`); it defaults to `http://127.0.0.1:$PORT`, and on Railway to
`https://$RAILWAY_PUBLIC_DOMAIN`, so set it to the custom domain there (`https://forget.stellarminds.ai`).

## Record the examples

The pages show recorded examples until a live run replaces them. Record them inside the image, so the
files carry no local path or user name:

```bash
docker build -t forgetproof-demo . && mkdir -p out
docker run --rm -e FORGETPROOF_HOME=/tmp/rec-home -e FORGETPROOF_SITE_RUNS=/tmp/rec-runs -v "$PWD/out:/out" forgetproof-demo python -m demo.forgetme /out/forget-me.json
docker run --rm -e FORGETPROOF_HOME=/tmp/rec-home -e FORGETPROOF_SITE_RUNS=/tmp/rec-runs -v "$PWD/out:/out" forgetproof-demo python -m demo.forgetme /out/withdrawal-local-only.json --local-only
docker run --rm -e FORGETPROOF_HOME=/tmp/rec-home -e FORGETPROOF_SITE_RUNS=/tmp/rec-runs -v "$PWD/out:/out" forgetproof-demo python -m demo.record_stories /out/stories.json
cp out/forget-me.json demo/public/recorded/withdrawal-cross-provider.json && cp out/*.json demo/public/recorded/
```

Each recording run prints its steps and ends with the path it wrote; `out/` then holds three JSON files,
and `tests/test_public.py` checks that none carries a local path or a personal identifier.

## Tests

```bash
uv run pytest tests/test_site.py             # every story in-process, plus the HTTP surface and the shared chrome (several minutes)
uv run pytest tests/test_public.py           # the public docs, deep links, shares, retention, exported examples
uv run pytest tests/test_forgetme.py         # the ForgetMe contract: owners, references, idempotency, concurrency, restart, the lease choice
uv run pytest tests/test_forgetme_schemas.py # every fixture, and both parties' live answers, against the v1 schemas
uv run pytest tests/test_company.py          # the reference Company's conformance set, over Poppy
uv run pytest tests/test_poppy.py            # negotiation, identity, the approval exchange; both parties' documents against the Poppy kit's schemas
uv run pytest tests/test_cross_provider.py   # Pim's aggregate with the Company (own thread and port; Pim on a port too) and the simulated recipients
uv run pytest tests/test_wire.py             # a public-contract client over real HTTP, Pim and the Company as separate processes
uv run --extra browser python -m playwright install chromium
uv run --extra browser pytest tests/test_browser.py   # the button in Chromium: cancel, double click, pending then resolved, keyboard, labels, 375 px
node packages/forgetme-button/example/walkthrough.mjs http://localhost:8080   # the headless host, from Node
```

Each `pytest` run ends with a `passed` count and no `failed`; the walkthrough ends with a `courier` line.

## ForgetMe on the landing page

The first visit shows a recorded run (both lease-note choices), from `public/recorded/forget-me.json`;
nothing runs until "Run it fresh" is clicked. A fresh scenario builds Pim's real stores in
`FORGETPROOF_SITE_RUNS/forget-me/<scenario>/`, issues the synthetic session as an HttpOnly cookie
(`fm_session`; headless clients send it as a Bearer token), and puts the real `<forget-me-button>`
beside each of John's memories. Scenario starts count against the same per-visitor limits as story runs,
at most `FORGETME_MAX_SCENARIOS` (12) scenarios are live at a time, and each expires after
`FORGETME_SCENARIO_TTL` seconds (30 minutes), world and all. What is simulated, and labelled on the
page: the session, the courier, the recorded example. Not simulated: authorization (checked on every
call against the session that owns the reference or operation), the stores, the erasure, the receipts.

Integration steps for a host, the contract and the outcome vocabulary: [`forgetme-button`](/docs/button).

## The cross-provider level

With `FORGETME_COMPANY_URL` set, every scenario opens a synthetic account for John at the reference
Company with his old address already shared, the way a courier he used months ago would hold it. The
fixture mints the refresh token a sign-in would have produced, for Pim's client identity; Pim exchanges
it at the Company's token endpoint with a client assertion, and from then on every request to the
Company carries a Session JWT (one Session per scenario: a random `sid` and User ID, never derived from
John's details), `Poppy-Version: 1.0`, `Poppy-Extensions: "stellarminds.ai/forget-me";v="1", "operations";v="3"`
and the access token; tokens and the Session id stay private to the scenario (`recipients.json`).

The preview of the old address lists the recipients as holders and as choices, and for Bay Parcel the
exact terms it stated when Pim asked (a preview and a submit without an approval, which the Company
answers with `403 approval_required`); the button shows them word for word. Confirming with Bay Parcel
chosen is John's approval of that revision: Pim records it in the scenario's ledger (`pim/approvals.json`)
and sends it with the request as `Poppy-Approval`; the Company performs the withdrawal once. Pim never
approves on John's behalf; a recipient whose terms changed, or that asks for an approval of terms John
has not seen, ends `error` with that sentence. The result shows one row per holder of every party with
action, evidence, unresolved item and time. Bay Parcel's receipts are re-served as received and verified
by Pim against the keys Bay Parcel publishes; the browser verifies them again. Each booking shares Pim's
current address with the Company, so after the forget the Company's own records hold the new one.

Tunables: `FORGETME_RECIPIENT_TIMEOUT` (8 s), `FORGETME_RECIPIENT_POLL` (20 s per ask),
`FORGETME_RECIPIENT_RETRY` (3 s before an unreachable recipient is tried again, on status reads).

## Deploy

The root `Dockerfile` builds one image for both services; the Railway settings are in
`.railway/railway.ts` (`site` and `company`, each with its own volume at `/data` and its own domain;
applied with `railway config apply`). `demo/entrypoint.sh` hands the volume to the unprivileged user
`fp` on start. Variables: on `site`, `FORGETME_COMPANY_URL=https://company.forget.stellarminds.ai` and
`PIM_ORIGIN=https://forget.stellarminds.ai` (and `ADMIN_TOKEN` to lift the rate limits from the console);
on `company`, `COMPANY_DATA=/data/company` and `COMPANY_ORIGIN=https://company.forget.stellarminds.ai`
(never `COMPANY_DEV_CLIENTS` in production). `RUNS_RETENTION_DAYS`, `SHARE_TTL_DAYS` and
`RETENTION_SWEEP_SECONDS` have defaults, and the commit shown by `/health` comes from Railway's own
`RAILWAY_GIT_COMMIT_SHA`. Merging to `main` deploys; `GET /health` on each service names the live commit.

## Next steps

- [Bay Parcel, the reference Company](/docs/company): the second service, its stores and its fixtures.
- [Audit hand-off](/docs/audit): the tested commit, the recorded withdrawals and the release matrix.
- [forgetme-button](/docs/button): the element and the host contract Pim serves.
- [ForgetMe v1, the wire contract](/docs/spec): what Pim and Bay Parcel speak to each other.
