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
2 changes: 2 additions & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,5 @@ Status: **decided** (owner agreed), **adopted** (recommended and taken; confirm
| S-173 | **Our own light runtime on Postgres, MCP as every component's interface, one agent loop of ours, other harnesses as agent instances** (2026-11-22; the owner's direction; supersedes S-162's narrower own-loop pick by widening it, and parks S-172's trial; `docs/plan.md` "The runtime, components and agents"). Postgres is the backbone (pgmq queues, the `env` gates and record, the kernel as catalog). A block is an MCP tool and a registered MCP server's tools are components, both ways, behind the environment's gates. Blocks run on demand by default (measured 2026-11-22 in the tools container: a Python block per call with JSON in and out 18.8 ms median, a bare `python3 -I` 10.2 ms, a process spawn 0.6 ms, about 8 MB idle), with a `hot` toggle for a supervised persistent process. A process supervisor runs processes in one small container; **Nomad is out by default: its LICENSE is the Business Source License** (read 2026-11-22), so process-compose (Apache-2.0, Go, v1.124.0 of 2026-10-26) is the lead candidate, to be picked with the research skill against s6, supervisord and systemd units. One agent loop (the worker's, generalised) with M-17's gate at the model endpoint; Claude Code and other harnesses join as agent instances (tasks from a queue, tools from the MCP endpoint, models through the gateway, `task.done` back). | decided |
| S-174 | **Describe, check, decode: Substrate builds no runtime and does not mediate links; runtimes are pluggable, Compose first; the kernel as a symbolic latent space** (2026-11-22; the owner's direction; supersedes S-173's runtime engine, its bindings and its blocks MCP server as a requirement; `docs/plan.md` "Describe, check, decode"). Components talk to each other directly in the protocols they already speak; their interfaces are described in a WoT Thing Description's shape (affordance, schema, forms with protocol and address); two parts fit when one provides what the other requires, and otherwise a translator from the catalog goes between them. Substrate decodes the map into existing runtimes' native formats and encodes their state back (the kernel's D-41: automations stay in their runners' formats; D-36: chain runners parked). **The kernel's boundary is already decided there:** queues belong to a distribution in its own database (the kernel's D-94 c), signals and telemetry are observations, not claims (D-101), and the catalog entry becomes D-101's first content type, the proof that proposed framing waits on. **The kernel as a symbolic latent space** (the owner's words): one universal symbolic representation that systems are interpreted into and out of. **Compatibility list** (`docs/compatibility/README.md` and `runtimes.json`, read 2026-11-22 from each project's docs and GitHub by three Haiku subagents): 10 service and process runtimes, 15 workflow orchestrators, 7 cloud services, 13 interchange standards, each with its native format, API and licence; a licence decides only whether a part can be a default (open: Compose, Podman, process-compose, systemd, Kubernetes, Flowable, Kestra, Argo, Conductor, Node-RED, Airflow, Prefect, Dagster, Temporal, Hatchet), the rest are targets (Nomad and Restate BUSL-1.1, Inngest SSPL, n8n Sustainable Use, Camunda License, Windmill AGPL plus proprietary EE, cloud services). **Found:** P-Plan, whose terms blocks' plans use (S-164) and the kernel's chain model maps to, is CC BY-NC-SA 2.0, a non-commercial licence: the owner to decide how they refer to it. Next: the catalog entry content type with a compatibility check, then the Compose decoder and encoder tested on Substrate's own `deploy/compose.yaml`. | decided |
| S-175 | **Vocabularies: standards first and a thin profile of our own, no custom ontology; plans in PROV-O, not P-Plan** (2026-11-22; the owner: "alternative ontologies are fine ... it's your call"; the kernel's D-124, which closes its O-13). P-Plan's licence is CC BY-NC-SA 2.0 (non-commercial, found by S-174). A full custom ontology was weighed and set aside: owning every modelling decision would fight the kernel as a symbolic latent space (S-174, the kernel's D-122), which carries formats in and out best when its middle speaks the vocabularies they map to. So the kernel's D-40 stands (standard vocabularies first), with a thin profile of our own terms only where none fits, each mapped (SKOS). Blocks' plans keep their JSON shape; in the kernel a plan is `prov:Plan` and a run a `prov:Activity` with `prov:hadPlan`, with the profile's terms for steps, order and variables (mapped to BBO/BPMN where they overlap). `blocks/__init__.py` and `blocks/executor.yaml` no longer call the format P-Plan. P-Plan's IRIs already in kernel v0 stay until the owner schedules that migration. Also done this day, with the owner's go-ahead: the kernel's branches cleaned (27 deleted: 24 merged or squash-merged, and three early `*_iteration` branches first kept as `archive/*` tags). | decided |
| S-176 | **The catalog entry: Substrate's parts as Backstage entity files, read into the kernel by encoder-backstage; a fit check over files, compose and the kernel** (2026-11-22; plan step 1 of S-174; the kernel's D-101 first content type, D-123). **Format chosen, not invented:** Backstage's entity format (`backstage.io/v1alpha1`), which the kernel already reads (`encoder-backstage`, the kernel's D-100) and `map-drift` already compares with observed calls; one file per entity in `catalog/` (47: 22 components including jobs, agents, blocks, a plan and two external services, 22 APIs, the database, the system, the owner), so each file is one item's version. Interfaces are `API` entities, `spec.type` the protocol (`openapi`, `asyncapi` for pgmq queues, `mcp`, `websocket`, `http`, `wot-td`), `spec.definition` the contract (a block's is a WoT Thing Description action from its `block.yaml`); licence, image, compose service and decision as `substrate.dev/*` annotations. A queue is provided by the component that receives on it (AsyncAPI's sense). **`scripts/catalog.py`:** `check` (every consumed API has a provider, every reference resolves, compose matched both ways), `apis`, and `check --kernel` (the same fit from the kernel's usable claims under the read model's role, `kkm_view_substrate`, and drift between files and kernel). **Into the kernel:** compose job `kernel-catalog` (profile kernel-admin; `scripts/kernel.sh catalog`), the volume `kernel-artifacts` as the artifact store. **Seen:** 47 change sets applied; every claim cites its file and line (each file an artifact, `application/yaml`); 45 provides and consumes links, no gap, no drift; a second run submitted only the one new file. **Found on the way:** the first entries modelled the worker's queue backwards and missed two compose jobs, both caught by the check; my own `kernel-catalog` job was flagged until it had an entry. `scripts/check.sh` now runs the check; `scripts/tests/test_catalog.py` (9 checks). **For the kernel, follow-ups:** `encoder-backstage` reports every cross-file reference as `dangling-ref` (it resolves within one file, though the claims point at the right IRIs), and writes no current-version link from an item to its artifact (D-101's `kkt:hasArtifact`, or a standard term, `docs/content.md`'s open question); D-101's per-type items view is not built yet. | adopted |
| S-177 | **Compose into the kernel and back: the kernel's `encoder-compose` and `decoder-compose`** (2026-11-22; plan step 2 of S-174; the kernel's D-125, PR OpenReplicant/kernel#134, stacked on #133). Built as kernel modules, not in Substrate, because the kernel's architecture puts encoders and decoders in modules and Compose is any distribution's concern; they generalise the self-encoder's `encode_compose` (which reads only the kernel's own files). A compose file becomes a service template whose version is the file (D-101) and node templates `urn:kk:node:<service>` with node type, image, profiles, ports, volumes, environment variable names (never values) and dependencies, each claim citing its lines; the decoder renders the file from that version and the current claims, so a changed claim changes the file. **Seen in this stack's kernel:** `deploy/compose.yaml`'s 17 services became 242 claims and decoded back equal as compose reads it; the catalog's components and compose's services meet on the same nodes (the voice head: 20 claims from the catalog, 28 from compose). **Found and fixed:** the catalog called the database `postgres` and compose `db`, so their nodes did not meet: the entry is now `resource:db`; the old file's claims stayed current until the kernel encoders gained `--prune` (retract what removed or renamed files said); a run from another working directory re-keyed every file (456 claims retracted and re-added, nothing lost), so the `kernel-catalog` job now passes `--root /`. **Not yet:** a `scripts/kernel.sh compose` job (it waits for a published kernel image with the modules), running state encoded back (`compose ps` as observations), and the decoder writing the stack's compose file in use. | adopted |
23 changes: 23 additions & 0 deletions catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Substrate's catalog

Substrate's own parts, one file per entity, in **Backstage's entity format** (`backstage.io/v1alpha1`): components
(services, jobs, agents, blocks, plans, external services), the APIs they provide and consume, the database, the
system and its owner (S-176). It is the first content type of the kernel's D-101: each entity is an item, each file a
version kept as an artifact, and the kernel's claims about it (each citing its file and line) are its fields.

- **Interfaces** are `API` entities: `spec.type` names the protocol (`openapi`, `asyncapi` for a pgmq queue, `mcp`,
`websocket`, `http`, `wot-td` for blocks and plans) and `spec.definition` holds the contract; a block's is a
WoT Thing Description action read from its `block.yaml`.
- **Annotations** (`substrate.dev/*`): `licence`, `image`, `compose-service`, `decision`, `source`, `gate`,
`otel-service`, `trigger`.
- **A queue's provider** is the component that receives on it (the worker provides `worker-tasks`; the voice head
and the UI consume it by publishing to it), as in AsyncAPI.

```sh
bin/in-tools python3 scripts/catalog.py check --compose deploy/compose.yaml # every consumed API provided, compose matched
bin/in-tools python3 scripts/catalog.py apis # each API, its providers and consumers
scripts/kernel.sh catalog # into the kernel (encoder-backstage)
bin/in-tools python3 scripts/catalog.py check --kernel # the same fit from the kernel's claims, and drift
```

`scripts/check.sh` runs the first; a compose service added without an entry fails it.
26 changes: 26 additions & 0 deletions catalog/api-anthropic-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: anthropic-api
title: Anthropic's API
spec:
type: openapi
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"openapi": "3.1.0",
"info": {
"title": "api.anthropic.com",
"version": "0"
},
"paths": {
"/v1/messages": {
"post": {
"summary": "api.anthropic.com"
}
}
}
}
26 changes: 26 additions & 0 deletions catalog/api-anthropic-messages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: anthropic-messages
title: Anthropic Messages at the gateway
spec:
type: openapi
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"openapi": "3.1.0",
"info": {
"title": "Messages API, and the pass-through route for a Claude login",
"version": "0"
},
"paths": {
"/anthropic/v1/messages": {
"post": {
"summary": "Messages API, and the pass-through route for a Claude login"
}
}
}
}
45 changes: 45 additions & 0 deletions catalog/api-block-note-with-count.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: block-note-with-count
title: The note_with_count plan
description: Count the words of a text and save it as a note.
annotations:
substrate.dev/trigger: '(?is)^save a note called (?P<name>[\w-]+): (?P<text>.+)$'
spec:
type: wot-td
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "note_with_count",
"actions": {
"note_with_count": {
"input": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"text": {
"type": "string"
}
},
"required": [
"name",
"text"
]
},
"safe": false,
"forms": [
{
"href": "substrate:blocks/run.py",
"subprotocol": "substrate-plan"
}
]
}
}
}
53 changes: 53 additions & 0 deletions catalog/api-block-word-count.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: block-word-count
title: The word_count block
description: Counts the words in a text.
annotations: {}
spec:
type: wot-td
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "word_count",
"actions": {
"word_count": {
"input": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
},
"required": [
"text"
]
},
"output": {
"type": "object",
"properties": {
"words": {
"type": "integer"
}
},
"required": [
"words"
]
},
"safe": true,
"idempotent": true,
"forms": [
{
"href": "stdio:python -I word_count:run",
"contentType": "application/json",
"subprotocol": "substrate-block-stdio"
}
]
}
}
}
58 changes: 58 additions & 0 deletions catalog/api-block-write-note.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: block-write-note
title: The write_note block
description: Writes a note into the worker's workspace (WORKER_WORKSPACE, default /workspace) as notes/<name>.txt.
annotations:
substrate.dev/gate: blocks.write_note
spec:
type: wot-td
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "write_note",
"actions": {
"write_note": {
"input": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"text": {
"type": "string"
}
},
"required": [
"name",
"text"
]
},
"output": {
"type": "object",
"properties": {
"path": {
"type": "string"
}
},
"required": [
"path"
]
},
"safe": false,
"idempotent": true,
"forms": [
{
"href": "stdio:python -I write_note:run",
"contentType": "application/json",
"subprotocol": "substrate-block-stdio"
}
]
}
}
}
18 changes: 18 additions & 0 deletions catalog/api-companion-channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: companion-channel
title: The channel into Claude Code
spec:
type: mcp
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"protocol": "model-context-protocol",
"transport": "stdio",
"tools": [],
"note": "the claude/channel contract: signals in, archived only on ack (S-143)"
}
26 changes: 26 additions & 0 deletions catalog/api-companion-session.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: companion-session
title: The companion's session queue
spec:
type: asyncapi
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"asyncapi": "3.0.0",
"info": {
"title": "signals for the companion's Claude Code session",
"version": "0"
},
"channels": {
"companion_session": {
"address": "companion_session",
"description": "signals for the companion's Claude Code session"
}
},
"x-transport": "pgmq (Postgres), the env schema's topics and queues (S-143)"
}
26 changes: 26 additions & 0 deletions catalog/api-embeddings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: embeddings
title: Embeddings at the gateway
spec:
type: openapi
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"openapi": "3.1.0",
"info": {
"title": "ollama/qwen3-embedding:0.6b",
"version": "0"
},
"paths": {
"/v1/embeddings": {
"post": {
"summary": "ollama/qwen3-embedding:0.6b"
}
}
}
}
23 changes: 23 additions & 0 deletions catalog/api-kernel-mcp-memory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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-mcp-memory
title: The kernel's memory profile
spec:
type: mcp
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"protocol": "model-context-protocol",
"transport": "stdio",
"tools": [
"remember",
"recall",
"explain",
"changes_since"
],
"note": "KK_PROFILE=memory"
}
29 changes: 29 additions & 0 deletions catalog/api-kernel-mcp-substrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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-mcp-substrate
title: The kernel's substrate profile
spec:
type: mcp
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"protocol": "model-context-protocol",
"transport": "stdio",
"tools": [
"search",
"read",
"expand",
"locate",
"path",
"alternatives",
"violations",
"create_item",
"say",
"deprecate"
],
"note": "KK_PROFILE=substrate"
}
26 changes: 26 additions & 0 deletions catalog/api-llama-chat-fast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# A catalog entry (S-176): Backstage's entity format, read into the kernel by encoder-backstage.
apiVersion: backstage.io/v1alpha1
kind: API
metadata:
name: llama-chat-fast
title: llama-server, the fast model
spec:
type: openapi
lifecycle: experimental
owner: owner
system: substrate
definition: |-
{
"openapi": "3.1.0",
"info": {
"title": "llama.cpp's OpenAI-compatible server at llm-fast:8080",
"version": "0"
},
"paths": {
"/v1/chat/completions": {
"post": {
"summary": "llama.cpp's OpenAI-compatible server at llm-fast:8080"
}
}
}
}
Loading