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
5 changes: 3 additions & 2 deletions .claude/skills/setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ again. Known causes:
substrate-db-1 psql -U postgres` with `\set pw '…'` and `alter role postgres password :'pw'` on stdin), then
run `scripts/up.sh` again; it resets the gateway's roles itself.
- **A port is taken** ("address already in use"): another program has it. Do not stop it; it is the owner's. Set
the service's port in `.env`: `DB_PORT`, `GATEWAY_PORT`, `UI_PORT`, `DESKTOP_PORT` (the desktop; its framed apps
stay on 8081 to 8083). Find the holder by process name and working directory, never its arguments.
the service's port in `.env`: `DB_PORT`, `GATEWAY_PORT`, `UI_PORT`, `OLLAMA_PORT`, `DESKTOP_PORT` (the desktop) and
`DESKTOP_GATEWAY_PORT`, `DESKTOP_MAPS_PORT`, `DESKTOP_ROUTER_PORT` (its framed apps; S-222). A second copy on one
machine also needs its own `COMPOSE_PROJECT_NAME`, `TOOLS_CONTAINER` and volumes (the README). Find the holder by process name and working directory, never its arguments.
- **The gateway answers 400 to every call**: it knows no provider. With only local models, `.env` needs
`OLLAMA_URL=http://ollama:11434`.

Expand Down
21 changes: 17 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ CONTAINER_ENGINE=podman
# Where the secrets in deploy/secrets.txt live. env (this file) is the one backend; scripts read them only
# through env_value and sec_*, so a store can sit behind the same calls later.
SECRETS=env
# the compose project: its containers are named after it (PROJECT-db-1, ...). A second instance on one machine needs a
# name of its own here, its own TOOLS_CONTAINER, volumes (DB_VOLUME, OLLAMA_VOLUME, KERNEL_ARTIFACTS_VOLUME) and ports
COMPOSE_PROJECT_NAME=substrate
# the tools container (scripts/tools.sh), which bin/ runs commands in
TOOLS_CONTAINER=substrate-tools
# the optional services compose starts beside the core: llm (the local models); comma-separated, e.g. llm; empty:
# the core only
COMPOSE_PROFILES=
Expand All @@ -19,6 +24,8 @@ POSTGRES_PASSWORD=
DB_PORT=5432
# the volume its data lives in; a second instance on one machine needs its own
DB_VOLUME=substrate_db-data
# the kernel's artifact store (catalog files as they were read); a second instance needs its own
KERNEL_ARTIFACTS_VOLUME=substrate_kernel-artifacts

# ---- models (S-75, S-77)
# OpenRouter's API key; empty: no OpenRouter
Expand All @@ -43,8 +50,13 @@ GATEWAY_IMAGE=docker.io/maximhq/bifrost:v2.3.2
GATEWAY_PORT=8090
# the UI (S-140) on the host; change it if 8100 is taken
UI_PORT=8100
# the desktop (Caddy, S-199) on the host; change it if 8080 is taken (its framed apps stay on 8081 to 8083)
# the desktop (Caddy, S-199) on the host; change it if 8080 is taken
DESKTOP_PORT=8080
# the desktop's framed apps on the host, each on an origin of its own (S-200): the gateway's dashboard, the map pages,
# the MCP router (its page, and its MCP endpoint at /mcp); change one if it is taken
DESKTOP_GATEWAY_PORT=8081
DESKTOP_MAPS_PORT=8082
DESKTOP_ROUTER_PORT=8083

# ---- the Knowledge Kernel (S-153, S-154): the store, in its own database `kernel` in this Postgres
# the kernel's database as the UI reaches it; empty: the `kernel` database in this Postgres, as the kernel's
Expand Down Expand Up @@ -92,8 +104,9 @@ LLM_FAST_ALIAS=fast
LLM_FAST_ARGS=-ngl 999 -t 2 -c 32768 -fa on -ctk q8_0 -ctv q8_0

# ---- published images (S-167): scripts/up.sh pulls ghcr.io/openreplicant/substrate-* and the kernel's image, and builds only what did not pull
# the tag of Substrate's images, and of the kernel's (main, a v-tag, or a short commit)
SUBSTRATE_IMAGE_TAG=main
KERNEL_IMAGE_TAG=main
# the tag of Substrate's images, and of the kernel's: this release's and the kernel release it was tested with (VERSION);
# main follows the main branches (what a working checkout wants), a short commit pins one build
SUBSTRATE_IMAGE_TAG=0.1.0-preview.1
KERNEL_IMAGE_TAG=0.1.0
# 1: build every image here instead of pulling
SUBSTRATE_BUILD=
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ dependency is a contract, never another project's code. Name parts by their role
| 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 (`DESKTOP_PORT`), 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) |
| The desktop | compose service `caddy` (`deploy/caddy/Caddyfile`, `deploy/caddy/apps.json`) on 127.0.0.1:8080 (`DESKTOP_PORT`), in front of the kernel's `kk serve`; its framed apps on 8081 (the gateway's dashboard), 8082 (the map pages) and 8083 (the router; `DESKTOP_GATEWAY_PORT`, `DESKTOP_MAPS_PORT`, `DESKTOP_ROUTER_PORT`, S-222) | 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) |
| The MCP router | `mcp-router/` (Go), compose services `mcp-router` (its endpoint and page, 127.0.0.1:8083 through Caddy) and one connector per server (`mcp-kernel`); its registry and rules in the environment module's schema (`environment/sql/010_mcp.sql` to `013`) | one MCP endpoint for agents and the desktop in front of every connected MCP server; each server and tool registered in the environment, each tool an actuator behind its gate, each call an action recorded and, when it changes the world, waiting for a person in the desktop's Review (S-203, S-205, S-219) |
| The desktop and the assistant | `desktop/` (`server.py`; the Assistant view module, mounted into the kernel's container), compose services `desktop` and its connector `mcp-desktop`; `environment/sql/011_desktop.sql`; `scripts/assistant.sh` | the conversation between a person and the agents as signals: the person talks in the desktop's Assistant window, an agent (a Claude Code session started by `scripts/assistant.sh`) hears it on the channel and answers, shows and asks through the router (S-206) |
| 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) |
| Images | `.github/workflows/images.yml`, `image_ref` in `scripts/lib.sh` | `ghcr.io/openreplicant/substrate-{db,tools,mcp-router}` and the kernel's image are pulled (tags `SUBSTRATE_IMAGE_TAG`, `KERNEL_IMAGE_TAG`; by default the release in `VERSION` and the kernel release it pins, S-222; `main` follows the main branches); compose keeps `build:` as the fallback (S-167) |
| Glue | `scripts/`, `deploy/` | brings the parts up and connects them |

`deploy/ontop` (SPARQL) is kept and not started yet.
Expand All @@ -48,7 +48,7 @@ dependency is a contract, never another project's code. Name parts by their role
lists every setting, empty; `deploy/secrets.txt` says how each secret is made.
5. **One tested path.** Compose with Podman. Scripts call only the runtime's four verbs (`rt_up`, `rt_down`,
`rt_status`, `rt_logs`) and keep engine-specific code in `scripts/lib.sh`.
6. **Nothing installed on the host** beyond git, python3 (standard library), the engine and its compose, Claude Code,
6. **Nothing installed on the host** beyond git, python3 (standard library), curl, the engine and its compose, Claude Code,
and uv, which Claude Code plugins such as Morphogen's run their MCP servers with (S-196). A tool goes into a
container (`deploy/tools/Containerfile`).
7. **Licences:** permissive or LGPL for what the repository contains or links into Substrate's code. A GPL part may
Expand Down
1 change: 1 addition & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,4 @@ Status: **decided** (owner agreed), **adopted** (recommended and taken; confirm
| S-219 | **The environment is a kernel module: a proposed action waits in the kernel's review lane, and the decision made there is the action's** (2026-11-27; `docs/parts.md` "Order" step 2, first part; S-212, S-213 (a), S-214: a part is a kernel module when it needs the kernel's database, a role and the review lane). (a) **Through the kernel's module contract** (its `kernel/schemas/module.schema.json`, `modules/_template`, `kk module install`, read at kernel `e4ed8e2`): `environment/module.yaml` (`urn:kk:module:environment`, kind `control`, slots `trigger` and `actuator`, requires `review-lane`, role `kkm_environment`, runtime a python-service) and `environment/migration.sql` (the role, its agent row, the role granted to the kernel's login, as `actuator-compose` does). `scripts/kernel.sh init` runs `kk module install` on it after `kk init`, so the kernel checks the manifest and its licence and applies the migration once. The environment's own schema `env` stays migrated by `environment/db.py` (numbered files, each once): the kernel's contract applies a module's migration once and has no upgrade step, and `env` has seven files already; `013_review_lane.sql` gives the module's role `env.review_waiting()` and `env.decide` and nothing else in `env`. (b) **Its service** (`environment/review.py`; compose `environment`, in the kernel's image with `../environment` mounted, so it uses the kernel's `kk.lib` as every kernel module does: the kernel's login `kk_authenticator`, switched to `kkm_environment`): each waiting action becomes one change set in the review lane, keyed `environment:action:<id>`, in scope `urn:kk:scope:default`: `urn:kk:environment:action:<id>` a `sosa:Actuation`, `sosa:madeByActuator` its actuator, `as:actor` the caller's kernel agent when it is one, an `rdfs:label` (an MCP tool by the name its caller used, the caller, the action's id) and `dcterms:description` its input in full; standard terms from the kernel's packs, no new vocabulary. The kernel validates it and holds it for a reviewer, so the person decides it in the desktop's Review with everything else. Approved, the kernel applies it (the approved request is kept as claims, five per action) and the service calls `env.decide(approve, the reviewer, the note)`: queued for its actuator; rejected, refused with the reviewer's note. The kernel refuses a change set's approval by its submitter (the module) and the environment a proposal's by its caller, so a person who approves a request they made has it refused, with the reason. It wakes on `env_action` and `kernel_change_set` and looks every 5 s (`KK_SWEEP_SECONDS`), because a rejection sends no notification. (c) **One place to decide:** the router decides nothing any more (its `/api/decide` and the page's Approve and Reject buttons are gone; its Waiting list says to decide in Review; `env.decide` is revoked from `env_router`), and `scripts/env.py decide` is gone. (d) **Checked:** `scripts/tests/test_review.py`, 19/19 in a throwaway kernel (the install and its repeat; one change set per waiting action, held for review, saying what, by whom, with the input; approval, rejection with a note, self-approval refused; the router may not decide; the module may decide and may not act or set a gate); every suite passes (environment 44, review 19, kernel 27, UI 36, gateway 15, catalog 9, the router's Go tests). End to end on a throwaway stack (compose project `recut`, its own ports and volumes): an agent's `kernel_remember` through the router waited, appeared in the kernel's `review_queue` for `person_owner`, was approved with the kernel's own `review` tool and carried out by the kernel's connector; a second was rejected and the router's `router_outcome` said refused, by `person_owner`, "not now". (e) **Found, for the kernel:** `kk module install` gives a python-service module's role a login with a new random password on every run, even when the module is installed (unused here: the service switches from the kernel's login); there is no upgrade path for a module's migration; a rejection sends no `kernel_change_set` notification. Each is a small kernel pull request when wanted, none needed now. (f) **Privacy:** an approved request's input is now a claim in the default scope, which every agent with default clearance can read; before, it was only in `env.action`. Whether proposals go to a scope of their own is the owner's call (`docs/privacy.md`). | adopted |
| S-220 | **The channel and the MCP router are MCP servers on the environment module; the channel connects as its own login** (2026-11-27; `docs/parts.md` "Order" step 2, second part). (a) **The channel** (`environment/channel.py`, stdio, started by the harness) was already an MCP server reading the environment's queues, but it connected as Postgres's superuser. It now connects with `DATABASE_URL`, its own login `mcp_channel` (role `env_agent`: publish, act through the gates, read and acknowledge the queues it subscribed; it cannot decide, set a gate or read another's queue), password `MCP_CHANNEL_DB_PASSWORD` (`deploy/secrets.txt`, made by `scripts/settings.sh`, the login by `scripts/db.py init`). `scripts/assistant.sh` writes it into the channel's MCP entry (`.state/assistant/mcp.json`, mode 600, beside the token it already held); `013_review_lane.sql` gives the login the assistant's queues made before. Without `DATABASE_URL` it still falls back to `ENV_URL`, `STORE_URL`, then the superuser, for a person at the command line. It stays in the `environment` package: it is a few lines over the module's functions, not a part with code of its own. (b) **The router** (`mcp-router/`, Go) is already a compose-service MCP server whose registry (`env.mcp_server`, `env.mcp_tool`, `env.mcp_policy`) and gates are the environment module's schema; it now decides nothing (S-219 c). S-205 (g)'s question, whether it moves into the kernel's core, stays open. (c) **The catalog:** `component:environment` is now a service with its compose service, `component:channel` is new. (d) **Checked:** four new checks in `scripts/tests/test_environment.py` (the channel's session runs on an `env_agent` login; that login may not decide, set a gate or read a queue it did not subscribe), and the channel started from `assistant.sh`'s dry-run settings on the throwaway stack initialised as `mcp_channel` and acted through the gates. | adopted |
| S-221 | **The assistant's conversation is already a view in the kernel's desktop; nothing more is built for it until a use case asks, and `ui/` stays** (2026-11-27; `docs/parts.md` "Order" step 2, third part: "built as far as a use case needs"). The Assistant view (`desktop/view-assistant/`, a view module in the kernel's contract, mounted into the kernel's container, S-206) and its messages as signals in `env` (`011_desktop.sql`) are the target shape already; its server `desktop/server.py` is an MCP server through the router, as S-213 (a) wants. What it lacks (a chat library picked with the `research` skill, S-208) waits for the next use of the assistant. `ui/` is not retired: the kernel's Map view draws one map, and Substrate's many maps (S-207: a map as an item, one marked self) are not in the kernel yet. | adopted |
| S-222 | **A preview release, v0.1.0-preview.1: images pinned to the release, a fresh install tested, a second copy on one machine possible** (2026-11-27; the owner wants projects released, Morphogen first, Substrate as a clearly labelled preview while the re-cut is under way; numbered after the re-cut's S-219 to S-221, PR #32). (a) **Versions:** `VERSION` holds the release (`0.1.0-preview.1`); `deploy/compose.yaml`'s image defaults, `image_ref` in `scripts/lib.sh` (`SUBSTRATE_VERSION`, `KERNEL_VERSION`) and `.env.example` name it and the kernel release it pins (`0.1.0`, the kernel's tag on `e4ed8e2`'s code), no longer `main`; `scripts/tests/test_release.py` keeps them equal, checks the images workflow publishes `v*` tags (it already did: the tag as pushed and the version without the v) and that release notes exist (`docs/release-notes/`). A kernel image that does not pull is built from its tag `v<version>`; `scripts/build.sh` pulls or builds the router's image too. A working checkout that wants `main` sets the tags in `.env` (an existing `.env` keeps what it has). (b) **The fresh install** (a clone in a temporary folder, the README only, beside other stacks on the owner's machine): it failed three ways, each fixed: the desktop's framed-app ports 8081 to 8083 were fixed and taken on this machine (now `DESKTOP_GATEWAY_PORT`, `DESKTOP_MAPS_PORT`, `DESKTOP_ROUTER_PORT`: compose maps them to Caddy's fixed 8081 to 8083, the Caddyfile's frame-src names them, `apps.json` is rendered by Caddy's `templates` with `{{env}}`, `check.sh` and `assistant.sh` read them); a first `up.sh` stopped in `gateway.py prune` while Bifrost was still making its tables (prune now waits for none of them: with any missing there is nothing stale); and a second copy would have shared the first one's data and tools container (`COMPOSE_PROJECT_NAME`, `TOOLS_CONTAINER`, `KERNEL_ARTIFACTS_VOLUME` are settings beside `DB_VOLUME` and `OLLAMA_VOLUME`; `tools.sh` refuses to replace another checkout's container, which it did before: the test removed the owner's stopped `substrate-tools`, which `scripts/tools.sh start` recreates). `bootstrap.sh` checks for curl (rule 6 names it). With those, bootstrap, up, check and every test suite passed on the fresh clone. (c) **The README** says what the preview is, what works, what is moving and what it needs; release notes are `docs/release-notes/v0.1.0-preview.1.md`. (d) **The owner releases** (not done here): the kernel's `v0.1.0` first, then this repository's `v0.1.0-preview.1`, each pushed tag publishing its images. | adopted — confirm |
Loading