diff --git a/.agents/skills/archie-diagnostics-and-tooling/scripts/delivery-snapshot.sh b/.agents/skills/archie-diagnostics-and-tooling/scripts/delivery-snapshot.sh index 66a8a86f3..ea2f40573 100755 --- a/.agents/skills/archie-diagnostics-and-tooling/scripts/delivery-snapshot.sh +++ b/.agents/skills/archie-diagnostics-and-tooling/scripts/delivery-snapshot.sh @@ -65,7 +65,7 @@ scan_literal github_container_publish github-workflows 'docker build|docker push # every row below -- which reads as "no composition root" rather than "wrong # file". The wiring lives in internal/app/archied. scan_literal production_config_resolve composition-root 'configuration\.New\(' internal/app/archied -scan_literal production_config_overlay composition-root 'ApplyOverlayValues\(|loadConfig\(' internal/app/archied +scan_literal production_config_load composition-root 'loadConfig\(|loadRuntimeConfig\(' internal/app/archied scan_literal production_sqlite_store composition-root 'openProductionTaskStore\(|openStateStore\(' internal/app/archied scan_literal production_daemon composition-root '&daemon\.Daemon\{' internal/app/archied scan_literal production_rpc_servers composition-root 'registerTaskRPCServers\(' internal/app/archied diff --git a/docs/architecture/configuration.md b/docs/architecture/configuration.md index 3317fc3dd..4d8d8077f 100644 --- a/docs/architecture/configuration.md +++ b/docs/architecture/configuration.md @@ -244,10 +244,8 @@ The application currently changes behavioural values through unrelated paths: | Active provider selection | `chatModelManager.SetActiveProvider` changes provider selection. | A conversation/session command changing runtime state, with the same distinction from provider-instance configuration. | | Persona selection | `PersonaRegistry.SetActive` mutates an in-memory per-session choice. | Agent-system session state. Persistence and audit requirements are owned by that domain, not the configuration loader. | | File and environment overlays | Applied while loading `internal/config`; defaults are filled by mutation in `finalize`. | Configuration-infrastructure input processing that produces separately typed candidates. Defaults and derivations remain visible in provenance. | -| SIGHUP config reload (2026-08) | Re-resolves the file config (+ the runtime overlay), validates, then atomically republishes through `config.Holder`. A failed reload keeps the running config and records `last_error`/`last_error_at` in `/api/config`. | Candidate promotion with last-known-good retention: the running snapshot is untouched on failure. A bounded observation period and actor audit are not yet implemented. | -| Dashboard PATCH `/api/config` (2026-08) | Applies dotted-key updates to a deep copy of the published config, validates the materialised result, persists to the runtime overlay, then republishes. Denylisted keys (`db_path`, `work_dir`) return 400; a rejected candidate never reaches `Set`. | The universal change protocol's validate-stage-promote path with the overlay store as persistence. Actor is recorded as `dashboard`; no per-field health observation or versioned audit trail yet. | -| Dashboard reset `POST /api/config/reset` (2026-08) | Deletes one overlay row after resolving and validating the target state, then republishes file + remaining overlay, so a dashboard-created override can be removed without editing SQL. | Remediation/rollback: the last-known-good (file) value is restored for that key. | -| Runtime config overlay store (2026-08) | Dashboard-edited overrides in `cfg.DBPath + "-config.sqlite"` (own `user_version`, own migrator), layered over the file config at boot and on every reload. A broken overlay degrades to file config alone, surfaced via `ReloadStatus.OverlayUnavailable`. | External configuration storage for runtime-tunable values, separate from the task/conversation stores so each file owns its migration. The `--no-config-overlay` / `ARCHIE_SKIP_CONFIG_OVERLAY=1` recovery hatch skips it entirely. | +| SIGHUP config reload (2026-08) | Re-resolves the file config, validates, then atomically republishes through `config.Holder`. A failed reload keeps the running config and records `last_error`/`last_error_at` in `/api/config`. It does not re-read the control plane, so database-owned settings revert to their file values until restart (`archie-core-ju85`). | Candidate promotion with last-known-good retention: the running snapshot is untouched on failure. Reload must re-apply the database layer. A bounded observation period and actor audit are not yet implemented. | +| Control-plane resource command (2026-09) | `ControlPlaneService.Command` validates a whole resource document against its owning feature, then writes it with an audit record (actor, source, request ID, expected version) under optimistic concurrency. Hosted on the State Store's gRPC server; the Web UI and messaging channels are its only clients. See `docs/prds/runtime-control-plane.md`. | Met for validate-stage-promote, actor audit and versioned history. Per-field health observation and validate-before-switch on live apply are not yet implemented. | Any further mutation seam discovered during migration MUST be added here before it is changed. Direct field assignment on a live settings object is prohibited. @@ -278,13 +276,12 @@ Settings that cannot safely reload in-process are marked restart-required. The change may still be validated and versioned immediately, but promotion occurs through a controlled restart with the same health and rollback semantics. -## Implemented runtime reload and config overlay (2026-08) +## Implemented runtime reload and settings writes (2026-09) -A first implementation of the universal change protocol now exists for the -runtime-tunable surface: SIGHUP reload, the dashboard PATCH, and the runtime -config overlay. The mechanics below are the current implementation; the -aspirational protocol (bounded observation, versioned audit trail, per-actor -audit) remains future work. +Two mechanisms change behavioural values at runtime: SIGHUP re-reads the file +config, and the control plane owns every database-backed setting. The dashboard +runtime overlay that used to sit between them was deleted once the control plane +covered its surface; `-config-overlay` names a file overlay and is unrelated. ### Published snapshot: `config.Holder` @@ -310,48 +307,29 @@ deliberately. A reload that changes any non-allowlisted field logs ### SIGHUP reload -SIGHUP re-resolves the file config (plus the runtime overlay), validates, and -atomically republishes through the shared Holder. A failed reload — bad file, -bad overlay — keeps the running config and records `last_error`/`last_error_at` -in `/api/config` so the stale state is visible where the operator is looking. -The three poll tickers re-read `PollInterval` per iteration and reset on change, +SIGHUP re-resolves the file config, validates, and atomically republishes +through the shared Holder. A failed reload keeps the running config and records +`last_error`/`last_error_at` in `/api/config` so the stale state is visible +where the operator is looking. The three poll tickers re-read `PollInterval` per iteration and reset on change, so a reloaded interval genuinely takes effect. -### The runtime config overlay +### Settings writes go through the control plane -The dashboard's edits persist to a dedicated SQLite file -(`cfg.DBPath + "-config.sqlite"`, its own `user_version` and migrator — no -contention with the task or conversation stores). The `config_overlay` table -stores dotted-path keys with JSON-encoded values; the daemon layers them over -the file config at boot and on every reload, with the same field-level -precedence as a file overlay. +Database-backed settings are read and written through +`ControlPlaneService` on the State Store's gRPC server: catalog, query, +command, watch. Each feature owns its resource's validation and commands; +storage writes versions and audit records only. `docs/prds/runtime-control-plane.md` +is the specification. -- **Denylist:** `db_path` and `work_dir` cannot be set (the daemon must read them - before it can open the overlay store; changing them could break the next - boot). Enforced at write time with a 400 and in the store. -- **Bootstrap degrade:** a broken overlay (unopenable store, unreadable value, - values failing validation) degrades to file config alone — it must not brick -the daemon. The reason is surfaced via `ReloadStatus.OverlayUnavailable` in -`/api/config` and rendered as a banner by the dashboard. -- **Recovery hatch:** `--no-config-overlay` / `ARCHIE_SKIP_CONFIG_OVERLAY=1` - skips the overlay entirely; removing the `-config.sqlite` file is the -documented manual recovery. See safe-change-and-recovery.md. -- **Shadowed file edits are visible:** `/api/config` reports which dotted keys -the overlay currently sets (`overridden`), so the dashboard marks those rows and -offers a per-row reset. +Two properties matter to anyone changing this area: -### Dashboard PATCH and reset - -`PATCH /api/config` receives `{"updates": {"dotted.key": value}}`. It applies the -updates to a deep copy of the published config, validates the materialised -result, persists to the overlay, then republishes — it never calls Set directly -from the handler, since the dashboard shares the daemon's Holder. Dotted keys -are nested before decode (yaml cannot decode a dotted key as a struct field). -Error classification: 400 for a denylisted key or failed validation, 503 when -the overlay is disabled, 500 for a persistence failure. `POST /api/config/reset` -deletes one overlay row after resolving and validating the target state, -restoring the file value — the answer to "my file edit isn't taking effect -because an override shadows it". +- **Bootstrap stays file-owned.** The daemon reads the file config first and + layers database resources over it at boot (`boot.loadRuntimeConfig`). Values + the daemon needs before it can reach the State Store — the database path, + listen addresses, credentials — stay file-only by design. +- **Reload does not re-read them.** SIGHUP republishes the file document alone, + which reverts database-owned settings until restart. Tracked as + `archie-core-ju85`; see the ledger above. ## Completion criteria diff --git a/docs/architecture/migration-decisions.md b/docs/architecture/migration-decisions.md index dc4a97b94..4d9629590 100644 --- a/docs/architecture/migration-decisions.md +++ b/docs/architecture/migration-decisions.md @@ -517,6 +517,22 @@ kept deliberately for it; `ConfigView.Editable` follows whichever process holds Implementation belongs to `archie-core-8cda.5.4`, the cutover that removes the daemon's own dashboard. Nothing here is built yet. +**Superseded 2026-09-21 by the runtime control plane.** The open question this +descope left -- which process serves the policy and what transport carries the +write -- was answered by `docs/prds/runtime-control-plane.md`: neither a daemon +admin service nor a revival of the daemon-local policy. `ControlPlaneService` on +the State Store's existing gRPC server owns every database-backed setting, and +each feature validates its own resource, so there is no daemon-local policy left +to contract. `archie-core-j28m` is closed. + +Consequently the three write seams described above no longer exist. +`PATCH /api/config`, `POST /api/config/reset` and +`PATCH /api/config/repos/{owner}/{name}`, the `UpdateConfig`/`ResetConfig`/ +`UpdateRepoField` fields on `webui.Server`, and `ConfigView.Editable` were +deleted in `31622ec5` along with the runtime overlay store they wrote to. +`GET /api/config` remains a read of the published projection, as this decision +always intended. + ### 7. Shared mechanics The following cross-domain mechanics require exact contracts before dependent diff --git a/docs/architecture/safe-change-and-recovery.md b/docs/architecture/safe-change-and-recovery.md index 519bf8fc6..d3f3bae6a 100644 --- a/docs/architecture/safe-change-and-recovery.md +++ b/docs/architecture/safe-change-and-recovery.md @@ -1,6 +1,6 @@ # Safe Change and Recovery -**Status:** Requirements approved; mechanics are under design. The runtime config overlay subset is implemented (2026-08): see the degrade/recovery section below. The full runtime-supervision protocol (bounded observation, versioned audit trail) remains under design. +**Status:** Requirements approved; mechanics are under design. Database-backed settings are implemented through the control plane (2026-09): see the degrade/recovery section below, which records a gap rather than a solution. The full runtime-supervision protocol (bounded observation, versioned audit trail) remains under design. **Date:** 2026-07-28 **Tracking issue:** [#73](https://github.com/samcharles93/archie-core/issues/73) @@ -100,40 +100,41 @@ capabilities continue operating. Remediation MUST be bounded, observable, and policy-driven. Recovery MUST NOT silently oscillate between versions or retry forever. -## Runtime config overlay: degrade paths and recovery (2026-08) +## Database settings: degrade paths and recovery (2026-09) -The dashboard edits runtime-tunable settings into a dedicated overlay store -(`cfg.DBPath + "-config.sqlite"`), layered over the file config at boot and on -reload. The file remains the authoritative, editor-reachable source; the overlay -is a runtime-tunable overlay on top of it. A broken overlay must never brick -the daemon, for the same reason a bad file edit must not: the operator needs a -path back that does not depend on the daemon's health. +The control plane owns runtime-tunable settings and stores them in `archie.db`. +This replaced a dashboard overlay store that degraded to file config on any +failure and had three documented ways back. The replacement has none, and the +posture is the opposite: **the daemon fails closed.** -### Degrade paths (all verified by the reload design) +### Degrade paths | Failure | Boot behaviour | Where the operator sees it | | --- | --- | --- | -| Overlay store cannot be opened (permissions, corrupt file) | Boots on file config alone; logs at error level | `/api/config` → `reload.overlay_unavailable` → dashboard banner | -| Overlay snapshot unreadable (a row holds invalid JSON) | Boots on file config alone | Same | -| Overlay values fail validation | Boots on file config alone; the overlay is rejected wholesale, never partially applied | Same | -| SIGHUP reload with a bad file or bad overlay | Running config is kept; the reload records `last_error` / `last_error_at` | `/api/config` → `reload.last_error` → dashboard banner | +| State Store unreachable | `boot.loadRuntimeConfig` returns the dial error and `archied` exits non-zero | stderr: `runtime settings unavailable` | +| A stored resource fails validation | Same: `validate database settings` wraps the error and the daemon exits | Same | +| SIGHUP reload with a bad file | Running config is kept; the reload records `last_error` / `last_error_at` | `/api/config` → `reload.last_error` → dashboard banner | -The overlay degrade paths never partially apply: `Loader.ApplyOverlay` decodes -into a deep copy (`config.Clone`) and validates before anything is published, -so a rejected overlay leaves the boot config exactly as the file produced it. +Failing closed is deliberate for settings the database owns: falling back to the +file values would restore the second source of truth the control plane exists to +remove. The cost is that a bad stored value stops the daemon starting, and the +value can only be corrected through the daemon's own API. -### Recovery +### Recovery: not yet built -1. **`--no-config-overlay`** (or `ARCHIE_SKIP_CONFIG_OVERLAY=1`) boots the -daemon on file config alone, ignoring the overlay entirely. This is the escape -hatch that works when the daemon will not start. -2. **Remove the overlay file** (`rm -config.sqlite`) — the overlay is -recreated empty on next boot, so the daemon returns to pure file config. -3. **Dashboard reset** (`POST /api/config/reset`) removes a single override -whose file edit is shadowed, without stopping the daemon. +There is no escape hatch. Nothing skips the control plane at boot, and the only +writer for a resource is `ControlPlaneService.Command` on a running State Store. +An operator whose stored settings will not validate has no supported path back +short of editing `archie.db` by hand. -These are the documented recovery paths; they are deliberate, bounded, and do -not require hand-editing SQL in a shared database. +`archie-core-6zw0` is the missing piece: offline commands that back up, restore, +validate and roll back the database without `archied` or the Web UI. Until it +lands, treat a settings change that requires a restart as a change that can +prevent one, and take a copy of `archie.db` first. + +Resource history is the in-band remedy and does exist: every write records its +prior value, so an edit made through the dashboard or a channel can be restored +by replaying an earlier revision while the State Store is up. ## Gateway restart: two constraints learned the hard way diff --git a/ui/src/settings/ConfigNotices.vue b/ui/src/settings/ConfigNotices.vue index 965c40a34..2fbc826fd 100644 --- a/ui/src/settings/ConfigNotices.vue +++ b/ui/src/settings/ConfigNotices.vue @@ -5,19 +5,14 @@ import { Alert, AlertDescription } from "@/components/ui/alert"; import { config } from "./state"; /** - * What the running configuration says about itself: whether the runtime - * overlay is in effect, and whether the last reload was applied. The running - * config is unchanged after a failed reload, so the notice is a statement - * about state rather than a warning about the values below it. + * What the running configuration says about itself: whether the last reload was + * applied. The running config is unchanged after a failed reload, so the notice + * is a statement about state rather than a warning about the values below it. */ -const overlayUnavailable = computed(() => config.value?.reload?.overlay_unavailable ?? ""); const lastError = computed(() => config.value?.reload?.last_error ?? "");