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
3 changes: 3 additions & 0 deletions .claude/skills/setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ again. Known causes:
data: set the role to `.env`'s value over the container's socket, never printing it (`podman exec -i
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 gateway answers 400 to every call**: it knows no provider. With only local models, `.env` needs
`OLLAMA_URL=http://ollama:11434`.

Expand Down
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ 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)
DESKTOP_PORT=8080

# ---- 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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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, 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) 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 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 rules in `environment/sql/010_mcp.sql` | 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 on the router's page (S-203, S-205) |
| 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) |
Expand Down
1 change: 1 addition & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,4 @@ Status: **decided** (owner agreed), **adopted** (recommended and taken; confirm
| S-215 | **The documentation follows the re-cut: a new `docs/framework.md`, the old one archived; the README, `CLAUDE.md`, `docs/repos.md` and the plan's intro rewritten** (2026-11-24; the owner: "Update all readmes and strategy documentation"). The shape S-209 to S-214 decided is now what the docs say: two products (Morphogen, the kit; the kernel) and the default distribution (Substrate), with MetaSoar the research. The S-185 framework (objects and traits, the orchestrator, slots, OpenEnv adopted fully) is kept whole as `docs/archive/framework-s185.md`; earlier rows that cite `docs/framework.md` sections mean that file. The other repositories' READMEs and strategy documents follow by their own pull requests (Morphogen #102, MetaSoar #11, a kernel docs PR). | done |
| S-216 | **Substrate on the kit: its rules in the catalog, Morphogen's plugin repinned, its own `map`, `catalog` and `research` skills removed** (2026-11-25; after Morphogen #102 and #103 merged; the owner: "what's next?"; plan "The re-cut" steps 1 and 2). (a) `morphogen.yaml` is gone (Morphogen #103 reads every rule from the catalog): a root `catalog-info.yaml` is a Location naming `catalog/catalog-info.yaml`, and the settings it held (`sandbox: podman`, the sandbox image) are on the System entity under `spec.morphogen`. Morphogen at `63648ca` reads all of Substrate's catalog with no errors (`structure check`: 17 interfaces untested, 6 unused, warnings only), and its `status` says the next step is this catalog on `main`. (b) **The plugin is pinned to `63648ca`** (`.claude/settings.json`, and `repos.yaml`'s `checked`), Morphogen's `main` after #103. (c) **Substrate uses Morphogen's skills like any user:** `.claude/skills/{map,catalog,research}` are removed; rule 3 names `morphogen:research`. Picks are still recorded in `DECISIONS.md` (rule 1). `setup` and `upstream` stay. (d) The operator's `morphogen.local.yaml` still names the retired cell `voice-route`; it is uncommitted and the operator's to tidy. | done |
| S-217 | **The demo engagement is done with the kit alone; the plugin is pinned to Morphogen `d945a9c` (0.9.0)** (2026-11-24; the owner: "merged 104 ...continue"; plan "The re-cut" steps 1 and 3). (a) Morphogen #104 adds `demos/fernhill`: a made-up 11-person kitchen firm's material (documents, a job log of 121 jobs, an interview), the first run's map (Backstage entities, 40 evidence quotes, all found on their lines), its quote calculator as a judged cell (held-out cost error 12.4% to 3.4% after `tune`; pass, 7 runs, p = 0.008, Podman), four options for job scheduling quoted from the vendors' pages, and a report of four implementation projects. No kernel and no stack ran. (b) **Step 3's done-when is met:** `run.sh` ran Claude Code on sonnet with only the plugin and the material, and `check.py`'s eight checks passed with no help (its report in `demos/fernhill/runs/`). (c) **The pin moves to `d945a9c`** (`.claude/settings.json`, `repos.yaml`). Morphogen #102 and #103 changed the plugin under version 0.8.0, so `claude plugin update` kept the code from before them, and S-216's pin never reached the install; #104 bumps it to 0.9.0. A plugin repin is checked by the install's `gitCommitSha` in `~/.claude/plugins/installed_plugins.json`, not by the settings file. (d) Four kit findings are listed in the demo's README for issues in Morphogen. (e) The business session (S-188 c) can start from the report. | done |
| S-218 | **The stack on kernel `e4ed8e2`; an MCP tool's gate follows its annotations until a person sets it; the desktop's host port is a setting** (2026-11-24; the owner, on port 8080 taken: "use any other available port, i'm working with 8080 right now"; on the gates: "Free, and change the rule"). (a) **The kernel pin moves to `e4ed8e2`** (main after #140, with #138 / its D-128: every MCP tool says whether it writes; `repos.yaml`); the published image's revision is the same commit; `scripts/check.sh` passes and every suite passes on it (catalog 9, environment 41, gateway 15, kernel 27, UI 36, the router's Go tests). (b) **The gate rule** (`environment/sql/012_mcp_gates.sql`, superseding the "a connector registering again never changes a gate" of `010_mcp.sql` and S-205): the kernel's tools were registered before #138, so its 14 read-only tools kept `propose` and every read waited for a person. Now each registration sets again a gate whose `set_by` is the registering connector (no person has set it since): from `env.mcp_policy` first, else readOnlyHint true is `free` and anything else `propose`, in both directions. A gate a person set is kept (`recall`, set by `person_owner`). On this machine the 14 are `free` by the rule (set_by `connector:kernel`, no decision made in the owner's name); the 5 writers stay `propose`. Seven new checks in `scripts/tests/test_environment.py`; three of them fail without 012. (c) **`DESKTOP_PORT`** (default 8080) is the desktop's port on the host: compose maps it to Caddy's 8080, and the Caddyfile's and the router's `frame-ancestors`, `check.sh`, `kernel.sh person` and `assistant.sh` name it; the framed apps stay on 8081 to 8083 (S-200). This machine uses 8180. The `setup` skill names a taken port as a known cause. | done |
4 changes: 2 additions & 2 deletions deploy/caddy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
encode zstd gzip
reverse_proxy gateway:8080 {
header_down -X-Frame-Options
header_down Content-Security-Policy "frame-ancestors 'none'" "frame-ancestors http://127.0.0.1:8080 http://localhost:8080"
header_down Content-Security-Policy "frame-ancestors 'none'" "frame-ancestors http://127.0.0.1:{$DESKTOP_PORT} http://localhost:{$DESKTOP_PORT}"
}
}

:8082 {
encode zstd gzip
reverse_proxy ui:8100 {
header_down Content-Security-Policy "frame-ancestors 'none'" "frame-ancestors http://127.0.0.1:8080 http://localhost:8080"
header_down Content-Security-Policy "frame-ancestors 'none'" "frame-ancestors http://127.0.0.1:{$DESKTOP_PORT} http://localhost:{$DESKTOP_PORT}"
}
}

Expand Down
7 changes: 5 additions & 2 deletions deploy/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ services:
DATABASE_URL: postgresql://mcp_router:${MCP_ROUTER_DB_PASSWORD:?set in .env}@db:5432/kernel
KK_JWT_SECRET: ${KK_JWT_SECRET:?set in .env}
LISTEN: ":8090"
FRAME_ANCESTORS: "http://127.0.0.1:${DESKTOP_PORT:-8080} http://localhost:${DESKTOP_PORT:-8080}"
depends_on:
db: {condition: service_healthy}

Expand Down Expand Up @@ -248,14 +249,16 @@ services:
cap_add: [NET_BIND_SERVICE]
tmpfs: [/data, /config]
environment:
DESKTOP_PORT: ${DESKTOP_PORT:-8080} # the desktop's origin, in frame-ancestors
XDG_DATA_HOME: /data
XDG_CONFIG_HOME: /config
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile:ro
- ./caddy/apps.json:/etc/caddy/apps.json:ro
# the desktop, then its framed apps on origins of their own (S-200); the Caddyfile and apps.json name these ports
# the desktop (DESKTOP_PORT on the host), then its framed apps on origins of their own (S-200); the Caddyfile and
# apps.json name these ports
ports:
- "127.0.0.1:8080:8080"
- "127.0.0.1:${DESKTOP_PORT:-8080}:8080"
- "127.0.0.1:8081:8081"
- "127.0.0.1:8082:8082"
- "127.0.0.1:8083:8083"
Expand Down
47 changes: 47 additions & 0 deletions environment/sql/012_mcp_gates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
-- A tool's gate follows its annotations until a person sets it (S-218). 010 and 011 gave a tool its gate once, at its
-- first registration, and never changed it: tools registered before their server marked them read-only (the kernel's
-- D-128) stayed `propose`, so every read waited for a person. Now, on each registration, a gate whose `set_by` is the
-- registering connector (no person has set it since) is set again from the policy (env.mcp_policy), else from the
-- annotations: readOnlyHint true is `free`, anything else `propose`, in both directions. A gate a person set is kept.

create or replace function env.mcp_register(p_server text, p_transport text, p_target jsonb, p_info jsonb, p_tools jsonb, p_by text)
returns table (tool text, actuator text, queue text, gate text)
language plpgsql security definer set search_path = pg_catalog, public as $$
declare t jsonb; tid bigint; act text; q text; g text;
begin
insert into env.mcp_server (name, transport, target, info, registered_by)
values (p_server, p_transport, coalesce(p_target, '{}'), coalesce(p_info, '{}'), p_by)
on conflict (name) do update set transport = excluded.transport, target = excluded.target, info = excluded.info,
registered_by = excluded.registered_by, login = session_user, seen_at = now();
update env.mcp_tool set present = false, updated_at = now()
where server = p_server and present and name not in (select x->>'name' from jsonb_array_elements(p_tools) x);
for t in select * from jsonb_array_elements(p_tools) loop
select id, env.mcp_tool.actuator into tid, act from env.mcp_tool where server = p_server and name = t->>'name';
if tid is null then
tid := nextval(pg_get_serial_sequence('env.mcp_tool', 'id'));
act := 'mcp.tool_' || tid;
select p.gate into g from env.mcp_policy p where p.server = p_server and p.tool = t->>'name';
g := coalesce(g, case when (t->'annotations'->>'readOnlyHint')::boolean then 'free' else 'propose' end);
perform env.actuator(act, g, p_by, 'MCP tool ' || env.mcp_exposed(p_server, t->>'name'));
insert into env.mcp_tool (id, server, name, title, description, input_schema, output_schema, annotations, actuator)
values (tid, p_server, t->>'name', t->>'title', t->>'description', coalesce(t->'inputSchema', '{"type": "object"}'),
t->'outputSchema', coalesce(t->'annotations', '{}'), act);
else
update env.mcp_tool set title = t->>'title', description = t->>'description',
input_schema = coalesce(t->'inputSchema', '{"type": "object"}'), output_schema = t->'outputSchema',
annotations = coalesce(t->'annotations', '{}'), present = true, updated_at = now()
where id = tid;
-- A gate no person has set (the connector that registers set it) follows the policy, then the annotations.
select p.gate into g from env.mcp_policy p where p.server = p_server and p.tool = t->>'name';
g := coalesce(g, case when (t->'annotations'->>'readOnlyHint')::boolean then 'free' else 'propose' end);
if exists (select 1 from env.actuator a where a.name = act and a.set_by = p_by and a.gate <> g) then
perform env.actuator(act, g, p_by);
end if;
end if;
select a.queue into q from env.actuator a where a.name = act;
perform env.allow(q, session_user);
tool := env.mcp_exposed(p_server, t->>'name'); actuator := act; queue := q;
gate := (select a.gate from env.actuator a where a.name = act);
return next;
end loop;
end $$;
2 changes: 1 addition & 1 deletion repos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ morphogen:
kernel:
url: https://github.com/OpenReplicant/kernel
branch: main
checked: c443238d77a6a003c0c02adf3f7f823634a8c4b2 # 2026-11-24 main after #139 (D-127 the desktop, D-129 KK.open); the image's revision; all suites, the desktop (23) and assistant (11) trials pass
checked: e4ed8e28356a9cc8e5a2a268a637ecd0ade76251 # 2026-11-24 main after #140 (#138, D-128: every MCP tool says whether it writes); the image's revision; all suites pass, its 14 read-only tools free in the router (S-218)
3 changes: 2 additions & 1 deletion scripts/assistant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ You are the assistant in Substrate's desktop (S-206). A person talks to you in t
TXT
sed -i "s/^You are the assistant in Substrate's desktop (S-206). A person talks to you in the desktop's Assistant window./You are the assistant in Substrate's desktop (S-206). $who talks to you in the desktop's Assistant window./" "$dir/prompt.txt"
[ "${ASSISTANT_DRY:-}" = 1 ] && { echo "dry run: .state/assistant/ written"; exit 0; }
echo "The assistant: open Assistant in the desktop (http://127.0.0.1:8080/) and say something."
port=$(env_value DESKTOP_PORT)
echo "The assistant: open Assistant in the desktop (http://127.0.0.1:${port:-8080}/) and say something."
cd "$ROOT"
exec claude --mcp-config "$dir/mcp.json" --strict-mcp-config --append-system-prompt "$(cat "$dir/prompt.txt")" \
--dangerously-load-development-channels server:desktop
5 changes: 3 additions & 2 deletions scripts/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ case "$hdr" in
*) bad "the UI does not answer at $ui/api/wholes (scripts/logs.sh ui)" ;;
esac
# The front door (S-199): Caddy to the kernel's shell, with the kernel's own security headers on it
desk=http://127.0.0.1:8080 # fixed: the apps.json origins and frame-ancestors name it (S-200)
dport=$(env_value DESKTOP_PORT); dport=${dport:-8080}
desk=http://127.0.0.1:$dport # DESKTOP_PORT; the apps stay on 8081 to 8083, which apps.json names (S-200)
hdr=$(curl -s -D - -o /dev/null "$desk/ui/" 2>/dev/null | tr -d '\r')
case "$hdr" in
*" 200 "*"frame-src http://127.0.0.1:8081 http://127.0.0.1:8082 http://127.0.0.1:8083;"*"frame-ancestors 'none'"*)
Expand All @@ -99,7 +100,7 @@ for app in 8081:gateway 8082:maps 8083:mcp; do
hdr=$(curl -s -D - -o /dev/null "http://127.0.0.1:${app%%:*}/" 2>/dev/null | tr -d '\r')
case "$hdr" in
*[Xx]-[Ff]rame-[Oo]ptions*) bad "app ${app#*:} at :${app%%:*} still sends X-Frame-Options (deploy/caddy/Caddyfile)" ;;
*" 200 "*"frame-ancestors http://127.0.0.1:8080 http://localhost:8080"*) ok "app ${app#*:} http://127.0.0.1:${app%%:*}/ (framable by the desktop only)" ;;
*" 200 "*"frame-ancestors http://127.0.0.1:$dport http://localhost:$dport"*) ok "app ${app#*:} http://127.0.0.1:${app%%:*}/ (framable by the desktop only)" ;;
*) bad "app ${app#*:} at :${app%%:*} does not answer with frame-ancestors for the desktop (scripts/logs.sh caddy)" ;;
esac
done
Expand Down
2 changes: 1 addition & 1 deletion scripts/kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ print(" login %s: .state/kernel/%s.env; .mcp.json has the `kernel` server (tool
;;
person)
name=${2:?usage: scripts/kernel.sh person NAME}
port=8080
port=$(env_value DESKTOP_PORT); port=${port:-8080}
mkdir -p "$ROOT/.state/kernel"
out=$(compose run --rm --no-deps -T kernel-init kk person add "$name" | grep '^{' | tail -1)
printf '%s' "$out" | python3 -c '
Expand Down
Loading