feat(controlplane): runtime administration over the State Store's gRPC server

The Web UI and messaging channels now read and write Archie's runtime
settings through one versioned, audited control-plane API hosted on the
State Store's existing gRPC server: catalog, query, command, watch. Each
feature owns its resource, validation and commands; storage only writes
versions and audit records.

Workflows move with it. Definitions become portable YAML compiled through
a closed, typed step registry and stored as a control-plane resource, so
the yaegi interpretation paths (internal/gate, wfeval, wfextract,
gateeval, gateextract, skillbuild) are deleted rather than carried.

The UI process reads definitions as data: the JSON projection lives in
internal/domain/workflow/task so a dashboard decodes the stored
collection without linking the workflow engine, which cmd/archie-ui's
deletion gate forbids. Shipped definitions ride the catalog descriptor
rather than a bespoke REST route, keeping the API to its four operations.

archie-messaging gains -state-store-target/-state-store-token and reads
channel settings from the database, failing closed when the State Store
is unreachable: the database is authoritative for those settings.
This commit is contained in:
sam committed 2026-09-21 08:17:42 +10:00
1 parent 2e172c679c
commit 924b02a1b0
131 files changed
+8510 -3371

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
# PRD writing rules
These rules apply to every file in `docs/prds/`.
- Search existing PRDs, issues, architecture records, and code first. Do not ask
the maintainer to repeat recorded requirements.
- A newer maintainer decision overrides an older design. Mark the old design as
superseded instead of preserving or defending it.
- Write plain English. Use a technical term only when the reader needs that
exact contract or concept.
- Use the shortest direct sentence. Write “When upgraded, existing instances
are migrated to the database,” not a description of an importer seeding
absent resources.
- State each fact once. Do not repeat a heading, summarize a list before showing
it, or restate a decision afterward.
- Every sentence must add a decision, requirement, constraint, evidence, or
verification step. Delete narration and explanations of obvious text.
- Do not turn a requested outcome into extra product features. Keep inferences
open until the maintainer or repository evidence settles them.
- Do not create a process for a logical boundary. Add one only when it must
deploy, scale, start, secure, or fail separately.
- Describe working behavior, not explanatory UI around missing behavior. State
what users can do and how success is proved.
- Before approval, use independent read-only reviewers to check a cross-cutting
PRD for missing behavior and exaggerated claims. Verify and synthesize their
findings; do not copy their prose.
- Before requesting approval, review every sentence for complexity, repetition,
and unsupported scope.
- Mark a draft as unapproved until the maintainer explicitly approves it.
+125
View File
@@ -0,0 +1,125 @@
# Runtime control plane
**Status:** Draft — not approved
**Date:** 2026-09-20
**Tracking:** `archie-core-j28m`, `archie-core-1786637498420-327-bacadaae`
## Outcome
Archie can be managed from the Web UI or a messaging channel. Both use the same
API.
## Model
Each feature owns its settings and commands. The database stores them. There is
no global configuration document.
This includes:
- workflows;
- identities and bindings;
- providers and models;
- repository policies;
- channels and schedules;
- capture mappings and bindings;
- tool settings;
- prompts and personas;
- plugin settings.
Plugin code remains installed code. Only its settings are stored in the
database.
Each feature defines its data, validation, permissions, editor fields, and how
changes take effect. Each feature also defines its allowed actions. For example,
identities can be created, suspended, and retired.
Repository and identity settings remain separate. They are not stored as large
records that unrelated features must share.
The State Store process hosts the control-plane API on its existing gRPC server.
No new process is added. Feature code validates changes. Storage code only
writes versions and audit records.
Every write records who made it, where it came from, a request ID, and the
version being edited. The API layer sets the actor; the request body cannot.
The server validates the change, then writes it with its audit record. It rejects
edits to an old version.
## API
The API has four operations:
1. **Catalog** tells clients what can be viewed or changed and how to edit it.
2. **Query** reads data and versions without exposing secrets.
3. **Command** asks the owning feature to make a change.
4. **Watch** streams changes and errors to clients.
Complex features can use custom screens. They still use the same commands.
A dashboard session or channel sender must map to an Archie identity before it
can run a command. Messaging syntax maps to the same commands as the Web UI.
`archie-ui` receives only an API client. It does not receive a database handle,
daemon pointer, global configuration object, or secret value.
The database stores the requested settings. Each process reports the version it
is using or why it failed. The UI shows both.
Some changes require a restart. The UI shows them as pending. When a live change
replaces a running component, Archie starts and checks the new one before
switching. If the check fails, the old one keeps running.
## Bootstrap, migration, and recovery
Bootstrap contains only the database path, listen addresses, credentials, TLS,
and encryption-key references. State Store and control-plane RPCs use the same
endpoint.
When upgraded, existing instances are migrated to the database. Existing
database values are not overwritten. After migration, settings in TOML are
ignored and cannot block State Store startup.
The Web UI remains available when `archied` or Gateway is down. It shows failed
changes and can correct or roll them back.
Offline commands can back up, restore, validate, and roll back the database.
Recovery does not require `archied` or the Web UI. The database stores secret
references, not secret values.
## Workflows
Users create and edit workflows in the Web UI. Workflows are stored as versioned
YAML. Built-in workflows can be overridden and restored.
A workflow is a list of steps. Each step has a known type and its own settings.
Plugins can add step types. Each run keeps the workflow version it started with.
Yaegi, `.archie/stages/*.go`, and `.archie/gate.go` will be removed. Their useful
behavior must first be available as normal workflow steps.
## First implementation
The first implementation makes task limits editable: maximum model steps,
maximum runtime, and maximum consecutive gate failures.
It includes:
- validated task-limit fields;
- version history and audit records;
- the four API operations;
- authenticated Web UI and messaging access;
- live updates and apply status;
- a Pinia-backed editor in the Web UI;
- a messaging command using the same API;
- migration of existing `[budgets]` values;
- an end-to-end restart test.
Running tasks keep the limits they started with. New tasks use the latest applied
version. This replaces the old settings overlay instead of extending it.
## Not included in the first implementation
- Moving bootstrap or secret values into normal settings.
- A generic JSON editor.
- Rebuilding every settings screen at once.
- Changing the limits of a running task.