Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ removed on 2026-11-23 (S-194): the assistant starts again from scratch, not port
| Local models | container `ollama`; containers `llm` and `llm-fast` (llama.cpp, profile `llm`) | Ollama for the store's embeddings; two chat models (S-169): the slow capable one, Inkling 2 Mini on the CPU, at the gateway as `local/slow`; the fast one, LFM3 1.7B on the GPU, as `fast/fast` (the alias names the role, not the model; Gemma is retired) |
| Tools | `bin/`, container `substrate-tools` | the scripts' Python and gitleaks, run in a container as you (S-19) |
| The UI | `ui/` (`ui/server.py`, `ui/static`), compose service `ui` on 127.0.0.1:8100 | the store's pages and maps as diagrams (S-140), read-only; v1's Workbench rebuilt, with no name of its own (S-141) |
| The desktop | compose service `caddy` (`deploy/caddy/Caddyfile`, `deploy/caddy/apps.json`) on 127.0.0.1:8080, in front of the kernel's `kk serve`; its framed apps on 8081 (the gateway's dashboard) and 8082 (the map pages) | the kernel's UI shell as a desktop (the kernel's D-127): a launcher and windows for search, review, change sets, the graph, the view modules and framed apps, each app on an origin of its own with its headers rewritten in the proxy; MCP over HTTP at `/mcp`; a person signs in with `scripts/kernel.sh person NAME` (S-199, S-200) |
| Images | `.github/workflows/images.yml`, `image_ref` in `scripts/lib.sh` | `ghcr.io/openreplicant/substrate-{db,tools}` and the kernel's image are pulled (tags `SUBSTRATE_IMAGE_TAG`, `KERNEL_IMAGE_TAG`); compose keeps `build:` as the fallback (S-167) |
| Glue | `scripts/`, `deploy/` | brings the parts up and connects them |

`deploy/caddy` (in front of the UI) and `deploy/ontop` (SPARQL) are kept and not started yet.
`deploy/ontop` (SPARQL) is kept and not started yet.

## Rules

Expand Down Expand Up @@ -71,9 +72,9 @@ scripts/up.sh # the stack (db, gateway, ollama, ui), the tools cont
scripts/check.sh # is everything up and wired
scripts/test.sh [FILE...] # the test suites, in the tools container
scripts/build.sh [db|tools|kernel] # none: pull published images, build what did not pull; SUBSTRATE_BUILD=1 builds all
scripts/logs.sh SERVICE # db, gateway, ollama, kernel, ui, llm, llm-fast
scripts/logs.sh SERVICE # db, gateway, ollama, kernel, ui, caddy, llm, llm-fast
scripts/tools.sh start|stop|status
scripts/kernel.sh init|catalog|login NAME|mcp NAME # the Knowledge Kernel: its schema, the catalog into it, an agent's login and its MCP server
scripts/kernel.sh init|catalog|login NAME|mcp NAME|person NAME # the Knowledge Kernel: its schema, the catalog into it, an agent's login, its MCP server, a person's sign-in
scripts/down.sh [--volumes] # stop (deleting data asks first)
python3 scripts/gateway.py render|keys # the gateway's config from .env and its callers
bin/in-tools python3 scripts/db.py init # the databases and the environment's schema (environment/sql/)
Expand Down
4 changes: 4 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,7 @@ Status: **decided** (owner agreed), **adopted** (recommended and taken; confirm
| S-194 | **The assistant starts again from scratch; nothing of it is ported** (2026-11-23; the owner, after using the voice interface: "please stop the voice head and its secondary model... its pretty fucked up. we'll need to completely restart on what we've just put together"; then "rt_down then... i'm not impressed with how the assistant works and we'll want to start from scratch rather than porting it"). Supersedes plan step 3's porting of the assistant's parts (S-185, S-186: the companion, the voice head and avatar, the worker, blocks and the skill gate, the ladder's code) into `distributions/assistant/`. (a) **The stack is down** (`scripts/down.sh`, data kept); the voice head and the fast model were stopped first. (b) **Nothing is ported:** `distributions/assistant/` will be designed anew, on the settled shape (OpenEnv environments, the kernel, Morphogen as its judge), when the owner says what it should do; until then the old parts stay in the tree, unused, and are removed in one commit once the owner agrees (git keeps them). (c) **What stands:** Substrate's own parts (the stack, the gateway and its meter, the kernel, the catalog, the skills, OpenEnv per S-192, Morphogen per S-193); the ladder's design (S-178 to S-183) and the OpenEnv findings are inputs to the new assistant, not commitments. The first Morphogen cell, `voice-route`, measured the old voice head: it stays as the worked example of the judge until a cell on a part that stays replaces it. | decided |
| S-195 | **The old assistant's code is removed; the old store's export step goes with it** (2026-11-23; the owner: "yes, remove the old assistant code"; follows S-194). On branch `claude/retire-assistant`. (a) **Removed:** `voice/`, `blocks/`, `judge/`, `deploy/companion`, `deploy/worker`, `deploy/searxng`, `environment/{companion,worker,author,judge,experience}.py`, `environment/sql/007_components.sql` and `008_experience.sql`, `scripts/companion.sh`, the trials `decider`, `voice-gpu`, `voice-head`, `voice-route`, `offline-agent`, their test suites (`test_blocks`, `test_companion`, `test_components`, `test_experience`, `test_voice_route`, `test_worker`, and `stub_memory_mcp.py`); compose services `environment`, `companion`, `judge`, `tts`, `voice`, `search`, `worker` and their volumes; the images `companion` and `worker` (workflow and `scripts/build.sh`); the gateway's callers `companion:*`, `voice:head`, `judge:voice`, `worker:loop` (left: `store:embed`, `morphogen:judge`); the database logins in `scripts/db.py`; 21 catalog entries; the UI's `#/companion` and `#/worker` pages and every write it had (it is now read-only, on the kernel only); their settings in `.env.example` and `deploy/secrets.txt` (`COMPANION_MODELS` becomes `ANTHROPIC_MODELS`, the old name still read). The first Morphogen cell `voice-route` (S-193) went with the voice head; its verdict stays in the evidence log. (b) **Data:** the `env` and `pgmq` schemas were dumped first (`.state/backups/substrate-env-pgmq-20261123-125241.sql`: 438 signals, 60 actions, 3 components, 2 verdicts, no experience); migration `009_retire_assistant.sql` drops 007's and 008's tables and functions, the old actuators and their queues, readers and bindings, and the logins `companion`, `worker`, `judge` and role `env_judge`; dry-run in a rolled-back transaction, then applied. The environment itself stays (005, 006: signals, subscribers, actuators behind gates, the channel); `test_environment` now uses the namespace `home`. (c) **Kept:** both local models (`llm`, `llm-fast`, the stack's `slow` and `fast` roles), the Anthropic provider in the gateway (no caller reaches it now), the channel. (d) **Found on the way:** `scripts/up.sh` still ran `scripts/kernel.sh export`, the one-off export of the `store` schema dropped in S-191, so `up.sh` failed from then on; the step, the `export` verb, the `kernel-export` service and its catalog entry are removed. `scripts/check.sh` and all five remaining suites pass (catalog 9, environment 36, gateway 15, kernel 27, UI 36). | done |
| S-196 | **envkit is retired; uv is allowed on the host; the machine and the repository tidied** (2026-11-23; the owner: "why keep envkit if we're using openenv? cleanup companion-home, remove unused images, clean .env, clean git. rule 6 is your call"). (a) **envkit removed** (`envkit/`, its `CLAUDE.md` row): OpenEnv is the environment standard (S-184, S-192), and MetaSoar's `main` does not import it (only its unmerged `claude/envkit` branch does); git keeps it. (b) **Rule 6 amended:** the host may also have **uv**, because Claude Code plugins run their MCP servers with it (Morphogen's `plugin.json` runs `uv run ... morphogen-mcp`) and containerising that would mean our own plugin configuration outside Morphogen's contract; `scripts/bootstrap.sh` shows it. (c) **The OpenEnv trial's image** stands alone (Python 3.13.17, psycopg 3.3.6, openenv 0.12.0, Claude Code 2.1.311 by the same pinned checksum), no longer built on the retired companion image. (d) **This machine:** volume `substrate_companion-home` deleted (it held the companion's Claude login); 37 image tags removed, images 40.05 GB to 12.75 GB, keeping the stack's (Bifrost v2.3.2, Ollama 0.40.12, llama.cpp b12627, kernel, substrate-db, substrate-tools), their bases, Caddy and Ontop (kept parts), the OpenEnv trial and MetaSoar's two; `.env` backed up (`.state/backups/env-before-s196-*`, mode 600), then 30 old assistant settings and their comments removed, `COMPANION_MODELS` renamed `ANTHROPIC_MODELS`, `COMPOSE_PROFILES=llm`. The volumes `voice-models`, `worker-workspace` and `search-cache` and about 55 anonymous ones remain until the owner says. (e) **Git:** merged branches deleted (their only commits beyond `main` are merge commits with no file difference); `seed`, `direction/experiment-first` and `game-catalogs` (unique work, no merged pull request) kept as tags `archive/*` before their branches went; PR #23 retargeted to `main` (PR #22 was merged before the S-193 and S-194 commits were pushed, so #23 carries them). | done |
| S-197 | **The pins moved to what runs; Morphogen's clone in `repos/`; the dropped `store` schema has no readers left** (2026-11-23; the handoff's loose ends 1 to 3; the owner: "work the handoff's loose ends in order"). (a) **Kernel:** PR #136 (D-125, D-126 onto `main`) merged as `e176b03`; its published image `ghcr.io/openreplicant/kernel:main` carries that revision (label `org.opencontainers.image.revision`), `scripts/up.sh` applied its schema 003 to 006, and `check.sh` and all five suites pass on it, so `repos.yaml`'s kernel `checked` is `e176b03`; `repos/kernel` moved from `claude/one-database` to `main`. (b) **Morphogen's one location is `repos/morphogen`** (S-11, the `upstream` skill): cloned there from GitHub at `9769a0b`, the commit the plugin is pinned to in `.claude/settings.json` (S-193), and `repos.yaml`'s `checked` is that commit; the two pins move together. `~/Projects/Morphogen` is the owner's own checkout, no longer named by Substrate. (c) **No old schema in the tests:** `test_kernel` and `test_ui` build their fixtures in memory (`scripts/tests/seed.py`, the plain rows the kernel's encoder-substrate takes) and submit them into the throwaway kernel through the encoder's own `export`, in its role (`kernelfx.Kernel.seed`); `scripts/tests/oldschema/` (the old schema's SQL and writer) is removed, and no throwaway `store` database is made; same checks, same counts (27, 36). The encoder stays because the kernel's `substrate` MCP profile writes claims in its shapes. (d) **Trials:** `embedding-model` removed (parked, S-142; it read `store.page`; git keeps it); `map-diagram/cases.py` reads Substrate's map through the UI's API (`/api/map/Q10`) and is kept, because `ui/static/vendor/VENDOR.md` cites its `fetch.py`. Left for step 4: `environment/db.py`'s carry-over of `public.store_migration` records. Empty leftover folders `blocks/`, `store/`, `voice/` (only `__pycache__`) deleted. | done |
| S-198 | **The optimiser is a slot with two fillers: Morphogen for files and settings, OpenEnv's rubrics for behaviour** (2026-11-23; the owner: "sounds like morphogen isn't the only optimization method in the system now that we integrated openenv", then "yes, record it"). Amends S-185's slot table (`docs/framework.md`, "Slots" and "Optimise"). (a) **Morphogen** (its cell contract, S-193) changes what a cell's `change` names, files and settings, and its judge scores a candidate by the cell's tests and measure. (b) **An OpenEnv environment** (S-184, S-192) scores a model's or a policy's episodes by its rubrics; a trainer (reinforcement learning, distillation) learns from those scores, and the result (weights, a compiled skill, a router) is judged on held-out episodes before it is used. S-192's point 7 (a rubric's score attached to every model call of its episode) is what makes this possible. (c) **One rule over both:** whatever is changed cannot edit what judges it (a cell's tests and scorer, an environment's rubric and held-out episodes), and a winner is a proposal the person approves. (d) **The `optimize` skill** (plan step 5) picks which one for a target: a change to text or configuration goes to Morphogen; a change to how a model behaves on a task family goes to an environment and a trainer. Nothing is built by this row; the trainer is picked with the `research` skill when a step needs one (plan step 9, M-17, is the first candidate). | decided |
| S-199 | **The front door: Caddy in front of the kernel's UI shell, the first step to one pluggable desktop** (2026-11-23; the owner: "i want to see a web UI... maybe all we need is a UI for kernel that's pluggable (i had a fascination with desktop WM styling, which requires iframes with proper security headers)", then "yes... start step 1"). (a) **One UI, the kernel's** (recommended and taken): the kernel's shell (`modules/ui`, the kernel's D-44: an MCP client with the person's own token; search, review, change sets, the graph; view modules that register themselves) grows into the desktop, in the kernel's repository by pull request; Substrate's `ui/` folds into it later as a view module or a framed app. (b) **This step:** the `kernel` service now runs `kk serve --host 0.0.0.0 --port 8000 --only mcp,validator` (it ran only the validator), and a new compose service `caddy` (`docker.io/library/caddy:2.11.7-alpine`, the version the kernel's own deploy pins; `deploy/caddy/Caddyfile` replaces v1's Workbench file) serves it on `127.0.0.1:${DESKTOP_PORT:-8080}`: `/` goes to `/ui/`, `/mcp*` and the rest to the kernel. Locked like the other services (read-only, no-new-privileges, `cap_drop: ALL`), with `/data` and `/config` on tmpfs and `admin off`; it keeps one capability, `NET_BIND_SERVICE`, as the container's root (the owner's user under rootless Podman), because the image's binary carries that file capability and an unprivileged user cannot exec it under no-new-privileges (found: `exec /usr/bin/caddy: operation not permitted`). (c) **Checked:** `/ui/` answers 200 with the kernel's own headers (its CSP with `frame-ancestors 'none'`, nosniff, no-referrer); `/ui/views.json` lists view-bpm, view-devops, view-map, view-modules; `/mcp` lists tools without a token but refuses a call ("no bearer token"); `/ui/login` refuses a wrong password (401). `scripts/check.sh` checks the shell through the door, `caddy` is in its core, and the catalog has `component:caddy` and `api:kernel-http` (provided by the kernel). (d) **Signing in:** `scripts/kernel.sh person NAME` (`kk person add`: a reviewer's login) keeps the password in `.state/kernel/person-NAME.password` (mode 600) and prints only where it is, because `kk person add` prints it. (e) **Next (the spike):** windows and a launcher in the shell; framed apps each on an origin of their own (a site block each in the Caddyfile: a sandboxed frame on the shell's own origin with scripts and same-origin allowed could undo its sandbox), the shell's CSP `frame-src` naming them, each sending `frame-ancestors` for the shell (Caddy adds it for apps that do not), the person's token never in a frame and a small message bridge granting what a frame may do; an app that refuses framing opens in its own window; three apps first (a view module, Bifrost's dashboard, Substrate's map), checked by the kernel's browser test for headers and no CSP violations. The shell's CSP needs `'unsafe-eval'` for Alpine.js today; Alpine's CSP build would drop it (to check in the spike). | done |
| S-200 | **The desktop: the kernel's shell with windows, and framed apps behind the proxy on origins of their own** (2026-11-23; the owner: "signed in, start the spike ... the UI looks bad, but we'll work on it", then "caddy should be able to fix headers via proxy"; follows S-199 (e)). (a) **The kernel's part** is its D-127 (kernel PR #137, branch `claude/desktop`, `modules/ui` 0.3.0): a launcher (Kernel, Views, Apps) and windows (move, resize, front, minimise, maximise, close, places kept); framed apps from `/ui/apps.json` when the front door serves one; an app on the shell's own origin refused; the sandboxed frame, no referrer, no permissions; a bridge taking only `title` and `open` from an app's own frame and origin; the token box a plain text box with autofill off (the owner's "invalid token: Not enough segments" was a password manager filling it). Found on the way and fixed there: an Alpine `:style` string replaces the whole style attribute and wiped `x-show`'s `display:none`, so closed windows showed (an object binding now). (b) **Substrate's part, all in the proxy** (the owner's point: no app's code changes): Caddy serves `deploy/caddy/apps.json` at `/ui/apps.json` and rewrites the shell's CSP to add `frame-src http://127.0.0.1:8081 http://127.0.0.1:8082`; `:8081` proxies Bifrost's dashboard, deleting its `X-Frame-Options: DENY` and replacing only `frame-ancestors 'none'` with the desktop's origins (`http://127.0.0.1:8080 http://localhost:8080`); `:8082` does the same for the map pages (`ui/`), whose CSP is otherwise unchanged. Caddy's `header_down` replaces by an RE2 expression (its reverse_proxy docs, read 2026-11-23); the patterns have no special characters. The ports are fixed (8080, 8081, 8082, all on 127.0.0.1), because the origins are named in apps.json and the headers; `DESKTOP_PORT` (S-199) is dropped. (c) **Checked:** the trial `scripts/trials/desktop/` (`run.sh`, the map-diagram trial's pinned Playwright 1.64.1 image, host network, the person's password passed by name) passes 23/23 against the stack with the kernel serving the branch's shell (a local compose override, `.state/trials/desktop/dev.yaml`, not committed): sign-in, the launcher's three groups, windows opening in front, focus, moving, minimising, restoring, closing, no closed window showing, a view module in its window, both apps loaded from their own origins in sandboxed frames, the bridge renaming an app's window and ignoring the same message from the shell's own page, the token in no frame, an unlisted origin (the gateway's own port 8090) refused by the CSP, Chromium's sandbox warning once per app frame and for nothing else, no page errors, no other CSP violations; results and screenshots in `.state/trials/desktop/`. `scripts/check.sh` checks the shell's `frame-src` and each app's headers. (d) **Left:** the look (the owner: "we'll work on it"); Alpine's CSP build to drop `'unsafe-eval'`; Substrate's `ui/` as a view module rather than a framed app, when the map pages are rebuilt on the kernel; once kernel PR #137 is merged and its image published, the stack runs it without the override. | done |
31 changes: 31 additions & 0 deletions catalog/api-kernel-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: kernel-http
title: The kernel over HTTP
spec:
type: http
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"openapi": "3.1.0",
"info": {
"title": "kk serve: the UI shell and its view modules under /ui, MCP (streamable HTTP) at /mcp",
"version": "0"
},
"paths": {
"/ui/": {
"get": {
"summary": "the UI shell (the kernel's D-44)"
}
},
"/mcp": {
"post": {
"summary": "MCP over streamable HTTP, with the caller's bearer token"
}
}
}
}
2 changes: 2 additions & 0 deletions catalog/catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
- ./api-anthropic-api.yaml
- ./api-anthropic-messages.yaml
- ./api-embeddings.yaml
- ./api-kernel-http.yaml
- ./api-kernel-mcp-memory.yaml
- ./api-kernel-mcp-substrate.yaml
- ./api-llama-chat-fast.yaml
Expand All @@ -18,6 +19,7 @@ spec:
- ./api-ollama-api.yaml
- ./api-ui-http.yaml
- ./component-anthropic.yaml
- ./component-caddy.yaml
- ./component-environment.yaml
- ./component-gateway.yaml
- ./component-kernel-catalog.yaml
Expand Down
Loading