Skip to content
Draft
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 @@ -230,3 +230,5 @@ Status: **decided** (owner agreed), **adopted** (recommended and taken; confirm
| 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 |
| S-223 | **A manager agent: a router with a ledger, which knows every project, hands work to workers and never does it itself; the design is `docs/manager-agent.md`** (2026-11-27; the owner wants a main agent that acts like a project manager, aware of all projects, delegating to workers, staying responsive, with a UI in the kernel's desktop: "yes, start the manager agent design"). S-223 because #32 takes S-219 to S-221 and #33 S-222; builds on #32's design (the environment as a kernel module, `propose` in the kernel's review lane, the channel and router as MCP servers), not its code. (a) **The portfolio** in the environment module (`env.project`, `env.worker`, `env.decision`, a new `014_portfolio.sql`), written only through a portfolio MCP server behind the router that checks each caller's token, with a files-only mirror as Backstage entities (`portfolio/`, Morphogen's format, S-209). The manager cannot set a project done, set its class, write a worker's state or answer a decision; a worker reports only on itself; the supervisor cannot answer. (b) **The manager** is a Claude Code session on Haiku in its own container (as the companion, S-136, S-144) with no built-in tools (`--tools ''`, so no Bash, edits or Agent tool), only the channel and the router, a hook that caps a turn at 8 tool calls, and its calls metered at the gateway as `manager:session`. Haiku, not `fast` (S-170): the manager needs Claude Code's loop with about ten tools and writes the briefs workers succeed or fail by; its routing choices are recorded so they can be replayed against `fast`. (c) **Workers** start through actuators `pm.start` (free: an `own` project on the subscription or a quota) and `pm.start_gated` (propose: client work, containers for a client, cloud, past a budget or quota), the gate chosen by the server from the project's class, never by the manager. Runners: `local` (`claude --bg` in a worktree) first, then `container` (`claude -p --output-format stream-json --max-budget-usd`), `kaggle` (MetaSoar's `job.py`), `scheduled` (pg_cron); `cloud` not in v1. Workers report through one tool, `pm_report` (kind, a summary of at most 300 words, refs: branch, PR, commit, results), never a transcript. Workers are background sessions, never subagents: today's two agents stopped at the usage limit were subagents, which `claude agents --json` does not list (seen 2026-11-27, Claude Code 2.1.332). (d) **The supervisor**, on the host (`uv run`, its own login `pm_supervisor`), outside the manager's reach, applies the actuators and watches every runner, publishing `pm.worker.<state>` (working, needs_input, stalled, limited, finished, failed, stopped) and respawning a session stopped by the usage limit at its reset, one at a time. The trial `scripts/trials/manager/watch.py` is its watch half with no database; run once it read the one background session as `pm.worker.finished`. (e) **Decisions:** gated actions stay in the review lane (#32); questions and notices are `env.decision` rows the person accepts, edits, responds to or ignores; notifications only on needs-input, failed or stalled, a verdict, over budget. "Done" is a `judge` worker's verdict with a clean context (`morphogen change` or `judge`, or Morphogen's reviewer), never the worker's; the person merges. (f) **The UI** is a view module `desktop/view-manager/` (projects, workers with peek, log and stop, the inbox; spend from the gateway's meter), beside the Assistant window, where the manager now answers. (g) **First trial, PM-1**, registered here, also a model comparison (the owner: "Haiku-5.5 would be nice for cost efficacy, but might not be the most reliable - something worth testing"): Haiku 5.5 and Sonnet 5.5 as the manager, the local `fast` model on routing only, the same workers. PM-1a replays 43 labelled scenarios (`scripts/trials/manager/scenarios.json`, paraphrases of the owner's requests across the four projects, with recovery cases: a usage-limit stop, a merge conflict, a stall) three times per arm with a stub portfolio; PM-1b is nine live messages in three rounds across two scratch repositories while workers run, once per arm. The lean manager is falsified by more than one reply later than 30 s, any work attempt, more than one of six requests misrouted or not delegated, the manager's tokens over 10% of the workers', a worker's needs-input or finish reaching the inbox later than 60 s, or a worker lost. "Haiku is reliable enough" is refuted by routing-and-delegation accuracy more than 5 points below Sonnet's with the paired 95% interval wholly below zero (5: about the manager's share of tokens, which is all Haiku can save), more than one work attempt, more than one must-escalate case missed that Sonnet catches, or two or more fewer workers finishing without coming back to ask; then the manager runs on Sonnet. No public benchmark tests this role; MS-Eval's delegation subset and τ²-bench's published scores are sanity checks only. Build order and the owner's open questions (privacy of the manager's stream, whether it replaces the assistant, which projects are `own`, workers' defaults, cloud work, automatic resume, where the mirror lives) are in the document. | proposed |
| S-224 | **The manager's prompt is a Morphogen cell, optimised with GEPA on held-out scenarios; the first run is refused and the prompt stays** (2026-11-27; the owner: "if our agent environments are supposed to assist with optimization, we should be able to optimize the manager/operator/delegator against its goals and feedback"; builds on S-223 and S-193, S-216; branch `claude/manager-agent`, PR #34). (a) **Scoring frozen:** PM-1a's `score.py`, `stub_pm.py`, `portfolio_fixture.json`, `scenarios.json` and the split files are hashed in `scripts/trials/manager/results/pm1a-scoring-frozen.json` (checked by `freeze.py` before every optimisation and judgement, and by the test); no change after seeing results, a change is a new version. Baseline before and after PM-1a's own rule change recorded together in `pm1a-scoring-frozen.md`: 67% (first rules, never committed, cannot be recomputed) and 81.4% (frozen rules, the saved traces rescored). (b) **Split,** fixed seed 20261127, stratified by expected action with the r-series recovery cases as a stratum: 20 train, 10 dev, 13 held out (`split.py`, `split.json`). The optimiser reads `scenarios-search.json` (train and dev) only; the held-out labels and cases live outside the repository in two directories named in the uncommitted `morphogen.local.yaml` (Morphogen's convention: `private` for the scorer alone, `inputs` for the workload). They are not isolated from the owner's user or from an agent running as them (only a second Unix user, Morphogen's `morphogen-judge`, would do that), and `scenarios.json` still holds all 43 as PM-1a's record, so the held-out text is in git history: the held-out set is blind to GEPA, not to the authors, and the feedback loop (`docs/manager-agent.md`, "Optimising the prompt") supplies fresh held-out cases. (c) **The cell,** `catalog/component-manager-prompt.yaml` (Morphogen reads it: `spec.morphogen`): `change` is `scripts/trials/manager/manager.md` only; `run`/`score` are `cell.py run` and `cell.py score`; primary metric **routing accuracy** (the figure PM-1's falsifier 1 is stated in; it covers project and action, so a manager that answers instead of delegating loses it), minimum gain 5 points absolute; constraints that are never traded for score: **did the work itself** may not rise above 0 (falsifier 2), **delegation recall** may not fall by more than 10 points (a guard: a prompt can raise routing by asking more and delegating less); tokens and latency `observe`d through Claude Code's own OpenTelemetry export (`PM_PASS_TELEMETRY=1`); `autonomy` stays at its default, `review`: the owner merges a new prompt. Not run through `morphogen judge`: an agent cell needs `sandbox: none` and its sign test (p at most 0.01) needs more rounds than 13 scenarios and this budget allow, so `judge.py` applies the cell's rule with the same scorer, paired, 3 runs per arm, written before any held-out run. (d) **GEPA** `gepa==0.1.4` standalone (`optimise.py`, a custom adapter: Haiku 5.5 through the PM-1a `claude -p` driver is the task, Sonnet 5.5 through `claude -p --model sonnet` with no tools is the reflection, the subscription only). Budget used: 100 Haiku runs and 8 Sonnet calls in the run, 52 more Haiku runs lost to a bug of mine (no reflection ran) and a smoke test; 78 in the judgement. (e) **Verdict: refused.** Dev: seed 9/10, best candidate 10/10 (selection-biased, one scenario); held-out, 3 paired runs: routing 71.8% baseline, 69.2% candidate, paired 95% [-10.3, +5.1] points; work itself 0; delegation recall equal; the manager's prompt is unchanged. The result says little either way: dev had one failure to learn from and 13 held-out scenarios cannot show less than 8 points. (f) **Feedback loop, design only:** corrections, "you should have delegated that" and decisions overturned in the review lane become scenarios (message, portfolio state, owner's label, confirmed by the owner), added 2 to 1 to train and dev, with about a third of every fourth batch moved to held-out; scoring versions change only with the old and new scores recorded together. | proposed |
1 change: 1 addition & 0 deletions catalog/catalog-info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ spec:
- ./component-llm.yaml
- ./component-mcp-desktop.yaml
- ./component-mcp-kernel.yaml
- ./component-manager-prompt.yaml
- ./component-mcp-router.yaml
- ./component-ollama.yaml
- ./component-ui.yaml
Expand Down
40 changes: 40 additions & 0 deletions catalog/component-manager-prompt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# A catalog entry (S-176) that is also a Morphogen cell (S-224): the manager agent's system prompt, optimised with GEPA
# and judged on held-out scenarios. `change` names the prompt file alone; the scorer is PM-1a's, frozen by hash
# (scripts/trials/manager/results/pm1a-scoring-frozen.json). The held-out scenarios are not in this repository: the
# operator names them in the uncommitted morphogen.local.yaml (see docs/manager-agent.md, "Optimising the prompt").
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: manager-prompt
title: The manager agent's system prompt
description: The prompt of the manager, a router with a ledger over the portfolio (docs/manager-agent.md); one text file, optimised against PM-1a's labelled scenarios and judged on held-out ones.
annotations:
substrate.dev/source: scripts/trials/manager/manager.md
substrate.dev/decision: S-223, S-224
spec:
type: prompt
lifecycle: experimental
owner: owner
system: substrate
morphogen:
description: Haiku 5.5 as the manager, through a stripped-down claude -p session on the subscription, on 13 held-out PM-1a scenarios.
change: scripts/trials/manager/manager.md
run: python3 -I scripts/trials/manager/cell.py run
score: python3 -I scripts/trials/manager/cell.py score
# The primary metric is routing accuracy (project and action both right), the thing falsifier 1 of PM-1 is stated in.
# Constraints, never traded for score: the manager does the work itself in no scenario, and delegation recall (start,
# message or stop when one was expected) does not fall by more than 10 points. A pass needs routing to gain 5 points.
better:
routing_accuracy: {higher: true, min: 0.05, gain: absolute, aggregate: mean}
work_itself: {lower: true, max_regression: 0, gain: absolute, aggregate: mean}
delegation_recall: {higher: true, max_regression: 0.1, gain: absolute, aggregate: mean}
# Tokens and latency, collected by Claude Code's own telemetry outside the workload (PM_PASS_TELEMETRY=1 lets the
# driver pass the variable on); recorded with the verdict, not a condition of it.
observe:
type: otel
collected: outside
metrics:
output_tokens: {metric: claude_code.token.usage, where: {type: output}}
input_tokens: {metric: claude_code.token.usage, where: {type: input}}
api_ms: {event: claude_code.api_request, field: duration_ms}
tests: python3 -I scripts/tests/test_manager_trial.py
Loading