Spec: provisioning — assign a connected device its role & services and keep the fleet current (P4 + P4b) #17

Closed
opened 2026-07-24 14:04:32 +00:00 by ben · 1 comment
Owner

Parent

Wayfinder map: Matou/ourcloud#7 — provisioning's definition was locked on ticket #9 (2026-07-21). This child spec inherits the map's cross-feature constraints (clan substrate behind the clan seam; kanidm/OIDC; the brandkit theming seam; the seeded-cache supply chain; the cross-cutting UX rulings — advice never veto, logging with drill-in, hardware minima + spec gate) and links back to it as the parent artifact. Grilled 2026-07-23 (/grill-ux-with-docs), both journeys: P4 setup/change (ADRs 0058–0064, both gates passed) and P4b updates (ADRs 0065–0068, auto-accept session signed off 2026-07-24).

Flows: docs/ux/flows/p4-provisioning.mermaid, docs/ux/flows/p4b-updates.mermaid.
Wireframes: docs/ux/wireframes/p4-provisioning/, docs/ux/wireframes/p4b-updates/.

Problem Statement

An operator has connected a device to their community's fleet (device-add left it connected — not set up and, for a full install, takeover-ready — its disk not yet touched). It is doing nothing. The operator — low-skill, low-time — now has to decide what job the machine should do, make it do that job safely over the connection already established, and then keep it and the rest of the fleet current with security patches and feature updates for the fleet's whole life. Left to raw tools this means: judging which services a machine can run against its specs, network and uptime; knowing which of the community's data has no second copy and no backup; triggering an irreversible disk wipe with full knowledge of what is lost; watching a deploy that can half-succeed; and, forever after, applying updates without breaking the services members depend on — with a real way to roll back and a real way to opt out. None of that should require systems expertise, and none of it should let the system quietly claim a safety (a backup, a second copy) the community does not actually have.

Solution

Provisioning is two operator journeys on the web dashboard, both driven by the community's own control plane over the established connection, so a closed browser never interrupts anything.

P4 — assign a device its role and services, and deploy them. The system assesses what the device offers (specs, reachability, uptime pattern) against what the community needs (HA gaps, backup gaps) and recommends the set that fills those gaps first; the operator accepts or adjusts freely (advice, never veto). It reviews the impact — what moves, what replicates, the new load — before anything runs. When the impact destroys something (a full-install device's disk is erased, or a removal drops the last copy of data), Review impact becomes a deliberate confirm that names the destruction and, for an erase, attributes the consent the device owner already gave at the machine. Deploy runs over the connection: a full-install device takes over to NixOS and joins the clan, a VM-mode device gets services only. Health checks run per service; the device goes active for the jobs that work, and any service that failed is named, retryable, and claims no coverage anywhere. P4 is also the standing surface for changing an active node later.

P4b — keep the fleet current. The control plane watches the pinned channel; security patches apply automatically in a community-chosen maintenance window while feature updates queue for one-click approval with plain-language release notes shipped signed with the release. Every update is a health-gated staged rollout — a canary chosen by rule (never the gateway, a quorum node, or the sole home of data), the gateway last — with automatic rollback at the matching scope on failure. A release that fails twice is quarantined and handed to the operator. The policy slider spans fully-automatic down to everything-manual; turning auto-security off is allowed and starts a standing, evidence-based indicator. Pin-or-fork the channel is the sovereignty exit.

User Stories

Acceptance criteria are Given/When/Then, sourced from the flow nodes and edges of p4-provisioning.mermaid and p4b-updates.mermaid, including the error, empty and partial branches.

P4 · Assess and recommend (P4-S1, P4-S1x)

  1. As an operator, I want the system to assess a newly connected device before I choose anything, so that my choices start from what the machine can actually do.

    • Given a connected — not set up device, When I open its setup, Then P4-S1 shows what the device offers — resources (a VM-mode device counts its allocated resources), network and public reachability, and uptime pattern — and what the community needs, as named HA and backup gaps.
    • Given the fleet's current state, When assess runs, Then the gaps shown are the community's gaps now (e.g. "Files & documents live on one device only", "Chat has no backup yet"), computed from live fleet state, not a fixed list.
  2. As an operator, I want the recommended role and services to fill my gaps first, so that the machine does the most useful thing without me working it out.

    • Given the assessment, When P4-S2 loads, Then the recommended services are pre-selected and each names the gap it closes ("closes the single-copy gap", "closes the no-backup gap").
    • Given a service the device cannot run, When it appears under Available, Then it is shown gated with the reason in the device's own numbers ("needs 8 GB — this device has 4", "needs a public address").
  3. As an operator whose device can run nothing useful, I want to be told plainly rather than dropped into a dead end, so that I am never stuck staring at a wiped or donated machine that can do nothing.

    • Given assess finds every catalogue service out of reach for the device, When setup proceeds, Then P4-S1x is shown instead of P4-S2, naming the device unusable in its own numbers with the reason each service is out of reach.
    • Given P4-S1x, When I decide, Then I always have a real next step: take the lowest-floor job the device can still do (an extra backup copy, never the sole copy of anything), or remove the device from the fleet.
  4. As an operator whose community already has no gaps, I want the recommendation to say so calmly, so that a fully-covered fleet does not look broken.

    • Given the community has no HA or backup gaps left, When P4-S2 loads, Then the recommended block is replaced by a plain "your community has no gaps right now — nothing needs filling", and I can still add any available service if I want.

P4 · Select role and services (P4-S2)

  1. As an operator, I want to accept the recommendation or adjust it freely, so that I stay in control while the system advises.

    • Given recommended and available services, When I add or remove any selection, Then the system never blocks the change (advice, never veto — ADR 0015); it only explains gated items.
  2. As an operator, I want to assign the device a fleet role, so that the machine takes a defined place in the fleet.

    • Given the role selector, When I pick a role, Then the available services update to those the role and the device's specs/access permit.

P4 · Review impact and the destructive confirm (P4-S3, P4-S3x)

  1. As an operator, I want to see the impact of my choices before anything runs, so that I am never surprised by what a deploy does.

    • Given a non-destructive selection, When I reach review, Then P4-S3 shows what moves, what replicates (with size and timing), how backup targets change, and the new steady-state load, and offers a plain Deploy.
  2. As an operator provisioning a full-install device, I want the erase named and confirmed deliberately, so that I never trigger an irreversible disk wipe without it being in front of me.

    • Given the device is full-install and still takeover-ready, When I reach review, Then P4-S3x is shown with an ⚠ ERASES row stating the disk is erased and replaced with NixOS, and the action reads "Erase & deploy", not "Deploy".
    • Given the erase, When P4-S3x shows it, Then it attributes the consent the device owner gave at the machine (who and when) and never re-asks for consent in the dashboard (ADR 0024); nothing has been erased until I confirm here.
  3. As an operator removing something that destroys data, I want the loss named and confirmed deliberately, so that I do not tear down a community's only copy on an ordinary-looking click.

    • Given a change whose impact drops the last copy of data or a dataset's last backup, When I reach review, Then P4-S3x is shown with an ⚠ LOSES row naming exactly what drops (e.g. "Chat drops to no backup — tōtara holds its only copy"), and the action reads "Remove & deploy".

P4 · Deploy and health checks (P4-S4)

  1. As an operator, I want the deploy to run over the connection already established, so that I do not repeat any enrollment step.

    • Given a confirmed deploy, When it runs, Then the community's own config repo drives it, progress streams to the dashboard as a checklist, and every step is logged with Open/Download.
  2. As an operator deploying a full-install device, I want the NixOS takeover to happen here, so that the machine becomes a real node.

    • Given a full-install takeover-ready device, When deploy runs, Then it takes the device over to NixOS, joins the clan, then deploys services — in that order.
  3. As an operator deploying a VM-mode device, I want only the services deployed, so that a machine already running the right OS is not needlessly rebuilt.

    • Given a VM-mode device (its NixOS VM already created at device-add), When deploy runs, Then services are deployed to the VM with no install/takeover phase.
  4. As an operator, I want a failed deploy to fail safely with a plain error, so that a broken deploy never strands the machine.

    • Given a deploy-itself failure (config, connectivity or disk), When it fails, Then I get a plain error and logs, and the recovery matches the mode: VM mode retries clean (delete, recreate); full install rolls the NixOS generation back once the new OS is on; and a failure of the takeover itself resumes or escalates to rescue.

P4 · Active, and partial success (P4-S5, P4-S5x)

  1. As an operator, I want a device to count as active only when its services are healthy, so that "active" means working.

    • Given a deploy where every service passed its health check, When it completes, Then P4-S5 shows the device active with its role and all its services, and monitoring (P5) picks it up.
  2. As an operator, I want a device whose deploy succeeded but one service failed to still do the jobs that work, so that one bad service does not throw away a successful takeover and a working service.

    • Given a successful deploy where a service fails its health check, When it completes, Then P4-S5x shows the device active for the passing services, nothing rolls back, and the failed service is named with its failure ("dry-run could not write to tōtara") and offered Retry or Remove.
  3. As a community, I want a failed service to claim no coverage, so that we are never told we have a backup or a second copy we do not have.

    • Given a service that failed its health check, When coverage is computed anywhere (Backups overview included), Then that service contributes no coverage and the data it was meant to protect still shows as an open gap.
  4. As an operator, I want the failed service carried into monitoring, so that it is not silently forgotten after setup.

    • Given P4-S5x, When provisioning completes, Then monitoring picks the device up including the failed service as a standing fault.

P4 · Changing an active node (P4-S5 → P4-S1)

  1. As an operator, I want to change an active node's role or services later, so that the fleet can grow and adapt without removing and re-adding machines.

    • Given an active node, When I choose to change its setup from the device page, Then the same five P4 screens re-run: P4-S1 re-assesses against today's fleet state, P4-S2 arrives pre-selected with the node's current role and services.
  2. As an operator changing a node, I want the impact shown as a delta, so that I see exactly what is added and removed.

    • Given a change, When I reach review, Then the impact shows ADDS and REMOVES alongside the usual moves/backups/load, and deploy is a plain clan.Deploy with no erase (the node is already NixOS).
  3. As an operator changing a node, I want a destructive removal to get the same deliberate confirm as an erase, so that removing the last copy of data is never a casual click.

    • Given a change whose removal destroys data, When I reach review, Then P4-S3x is shown with the LOSES row (per story 9).

P4b · Seeing update state (P4b-U1, P4b-U1x)

  1. As an operator, I want one surface that tells me the whole update story, so that I always know what is waiting on me, what is happening without me, and what the fleet is running.

    • Given the Updates screen, When I open it, Then P4b-U1 shows pending-my-decision updates, updates applying automatically, quarantined releases, and the revision the fleet is currently running, with the channel and last-checked time.
  2. As an operator, I want an "up to date" resting state, so that a quiet fleet reads as working rather than empty.

    • Given nothing pending and the fleet converged, When I open Updates, Then P4b-U1x states everything is up to date, names the channel, revision and last-checked time, and reassures what happens without me (security auto-applies in my window; features queue; a broken update rolls back).
    • Given a signed release appears on the pinned channel, When the control plane's own poll finds it, Then P4b-U1 surfaces it (moving off the resting state).
  3. As an operator, I want to drill into update history, so that "what changed just before this broke?" is always answerable.

    • Given past updates, When I drill in, Then each update, what it did, and its logs are available (ADR 0027).

P4b · Reviewing and approving (P4b-U2)

  1. As an operator, I want feature and major updates to wait for my approval, so that a change my members will notice does not apply itself.

    • Given a feature or major release (or any release while auto is off), When it arrives, Then it appears as pending-my-decision and I open it to decide.
  2. As an operator, I want plain-language release notes, so that I can decide without reading a changelog.

    • Given P4b-U2, When I review an update, Then it shows release notes written in plain language and shipped signed with the release (rendered verbatim, not generated per fleet), plus what it touches in my fleet's terms — which nodes, which services, when, and what happens if it fails.
  3. As an operator, I want to approve an update for the maintenance window, so that it applies when members are least affected.

    • Given a reviewed update, When I approve it, Then it is queued for the next maintenance window.
  4. As an operator, I want to skip an update and have it stay skipped, so that I am neither nagged nor overridden.

    • Given a pending update, When I skip it, Then it returns to the pending list and keeps saying so; nothing is lost and nothing applies itself (ADR 0015).

P4b · Automatic security (P4b-U1 → P4b-U3)

  1. As an operator, I want security and patch updates to apply automatically in my window, so that the fleet stays patched without my attention.
    • Given a security or patch release and auto-security on, When it arrives, Then it is not queued for my approval; it waits for the community's maintenance window and then rolls out.

P4b · Rolling out (P4b-U3)

  1. As an operator, I want every update staged and health-gated the same way, so that whether I approved it or it applied itself, it is equally protected.

    • Given an update applying (approved or automatic), When it rolls out, Then closures are seeded to every node first, a canary deploys and passes its health checks, then the rest follow, with the gateway last.
  2. As a community, I want the canary chosen by rule, so that a bad revision is proved on the node whose loss costs least.

    • Given a rollout, When the canary is chosen, Then it is never the gateway, never a quorum-role holder, and never the sole home of any dataset; the gateway is always updated last.
    • Given a fleet too small to have a qualifying canary, When a rollout runs, Then it says so and proceeds one node at a time with a health gate between each.
  3. As an operator, I want a retry to reuse the proven closure, so that a retry never rebuilds into something different.

    • Given a rollout or retry, When it applies, Then it applies the same exact revision/closure to every node.

P4b · Applied, rolled back, quarantine (P4b-U4, P4b-U4x)

  1. As an operator, I want "applied" to mean converged and healthy, so that a finished update is genuinely done.

    • Given a rollout where every service passed on every node, When it finishes, Then P4b-U4 shows the fleet converged on the new revision with the order it took, and monitoring watches it from here.
  2. As an operator, I want a failed update rolled back automatically, so that the fleet is never left on a bad revision.

    • Given a health-check failure during rollout, When it fails, Then the update is rolled back automatically at the matching scope — NixOS generation at the host, an earlier exact revision at the runner, a rolling container bump for a service — and the fleet returns to its previous revision, healthy.
  3. As an operator, I want a rolled-back update retried once, so that a transient failure does not need my attention.

    • Given a first rollback, When the next maintenance window comes, Then the same closure is retried once.
  4. As an operator, I want a repeatedly-failing update quarantined and handed to me, so that it does not re-break a node every window forever.

    • Given a second consecutive failure, When it rolls back again, Then the release is quarantined — no further automatic attempts — and surfaced at the top of Updates with the failing node and its logs.
    • Given a quarantined release, When later releases arrive on the channel, Then they are not blocked by it; and quarantine overrides auto-apply for the quarantined release.
    • Given a rolled-back update, When I choose, Then I can end the attempts early or retry it by hand without waiting for the second failure.

P4b · Policy and channel (P4b-U5, P4b-U5x)

  1. As an operator, I want to set update policy across the full range, so that the community decides how much is automatic.

    • Given update policy, When I set it, Then security/patch and feature/major each span apply-automatically · ask-me-first · never-apply-automatically, and I can set a maintenance window.
  2. As an operator, I want turning auto-security off to be allowed but visible, so that the choice stays informed rather than forgotten.

    • Given I turn auto-security off, When I save, Then it is allowed (no veto), and the dashboard begins carrying a standing, evidence-based indicator (P4b-U5x) — how many patches are pending, how old the oldest is, and whether the public gateway is affected.
    • Given the indicator, When I drill in, Then it takes me to the pending patches it is counting; and it disappears the moment auto-security is turned back on.
  3. As a community, I want pin-or-fork the channel to be a real setting, so that our sovereignty exit does not need a support ticket.

    • Given the channel setting, When I pin to an exact revision or point at a fork we control, Then the fleet stops receiving from Matou's channel — the exit is one setting (one flake input).

Implementation Decisions

  • Two orchestrators, two seams, both in the control plane. provision (ADR 0058) drives the P4 journey; update (ADR 0065) drives P4b. They are siblings, not one package — the journeys differ in object (one device vs one release), trigger (an operator clicking vs a scheduled channel poll), scope (one node vs the fleet in stages) and cadence. Both run server-side, so a closed browser interrupts neither. The Vue dashboard is thin UI over both; it renders states, it does not decide them.
  • Provisioning owns both clan hot paths; the two "enroll"s are different (ADR 0059). A full-install device's first deploy drives clan.Enrollment (the install --phases NixOS takeover that device-add only staged as takeover-ready); a VM-mode device or an already-active node drives clan.Deploy. Device-add drives neither — its enrollment is the separate enroll (agent↔control-plane) seam. provision reads the takeover-ready state to choose Enrollment vs Deploy and to read the already-captured install-mode consent; it never re-asks consent.
  • Health checks are per service (ADR 0061), and a catalogue port ships three parts (ADR 0062). A port is daemon+secrets, its out-of-band reconciler contract, and its own HealthCheck — the additive amendment to the confirmed clan seam (Config.AttachService admits all three; a HealthCheck type added). provision and update both gate on it per service and know nothing about what a service does. Binding invariant: a service that has not passed its check contributes no coverage anywhere.
  • Review impact computes destructiveness (ADR 0060). provision must know whether a selection erases a disk (full-install takeover-ready) or whether a removal drops a last copy of data or a dataset's last backup, because that decision routes the operator to P4-S3 (plain) or P4-S3x (deliberate confirm). Impact is computed as a diff against current state; a first setup is the special case where current state is empty.
  • The spec gate's floor is pinned to the cheapest real service (ADR 0064). Device-add's spec-gate floor for a role equals the floor of the cheapest service that role can run, sourced from the catalogue's per-service minima — so the gate and provisioning's available-list cannot disagree. Where fleet state has moved since pairing, P4-S1x is the never-dead-end backstop.
  • Update policy split and staged rollout (ADR 0017, inherited). Security/patch auto-apply in a maintenance window; feature/major queue for one-click approval. Rollout is caller-scripted by the deploy runner (clan has no built-in canary): seed → canary → health gate → rest, gateway last. Canary is chosen by rule (ADR 0066). Rollback is scope-matched: host generation, runner exact-revision, service container bump — never a git revert of a non-tip.
  • Retry budget then quarantine (ADR 0067). Two attempts (same closure), then quarantine: no further automatic attempts, surfaced to the operator, overriding auto-apply for that release, never blocking later releases. Attempt state is durable (survives a control-plane restart).
  • Release notes ship signed; the indicator is split (ADR 0068). Release notes are authored by Matou and shipped signed as part of the release artifact, rendered verbatim — no LLM in the update path at runtime. The dashboard adds only local framing (which of this fleet's nodes/services are touched). The auto-security-off indicator is provisioning's content rendered in shell's chrome — a cross-feature slot shell's grill must reserve.
  • Shared readers. provision and update share one fleet-state reader (specs, reachability, uptime, roles, quorum membership, dataset homes, coverage/HA gaps) and the same per-service HealthCheck machinery. Supply.Seed is a precondition of every deploy and every rollout — a drifted unfed node cannot deploy offline (S13 Q4/Q9).
  • Portal service-links follow health. A service appears on the portal when it passes its health check and goes when it is removed or fails — the ticket-#9 boundary ("provisioning keeps service links current") made precise by the per-service decision. brandkit applies to the service surfaces provisioning stands up.

Testing Decisions

  • What a good test is here: it drives one of the two seams and asserts external behaviour — the flow-node state reached, the coverage claimed (or not), the clan workflow chosen, the operator-facing failure and remedy — never an internal step ordering. Fakes simulate the world (clan, channel, clock, health checks); the state machines under test are real.
  • provision (P4) — THE seam for the setup/change journey (ADR 0058). Driven headless in-process against a fake clan.Clan exercising both hot paths (Enrollment for the takeover, Deploy for services-only, including blocked/resume/remedy and generation rollback), a fake fleet-state reader, per-service HealthCheck fakes that pass/fail independently, a fake portal-link updater, and real brandkit (pure — faking it would be waste). Every P4 acceptance criterion executes here: assess/recommend with gated-service reasons; both empty states (nothing available; no gaps to fill); impact for a first setup and a change; the destructive confirm's two triggers (ERASES/LOSES); full-install takeover vs VM-mode services-only; all-healthy → active; partial failure → active-for-what-works with no coverage claimed; the deploy-itself failures classified by the clan seam with the VM clean-retry / generation-rollback / rescue branches; and re-provisioning including destructive removals.
  • update (P4b) — THE seam for the updates journey (ADR 0065). Driven headless against a fake channel (signed release metadata + notes), a fake clock (maintenance windows; the indicator's "oldest 12 days" evidence), a fake clan.Clan (Deploy plus the three rollback scopes), per-service HealthCheck fakes that fail on command, and a fake Supply reporting unfed nodes. Every P4b acceptance criterion executes here: the policy split (auto-security applies unattended in-window; features queue); skip-and-stay-skipped; canary-by-rule and the tiny-fleet fallback; gateway-last; health-gated automatic rollback at each scope; the two-attempt retry budget → quarantine (fail→retry→succeed, fail→retry→fail→quarantine, quarantine overriding auto-apply, a later release applying cleanly over a quarantined one); the evidence the indicator counts; and pin-or-fork.
  • Below each seam: one thin HTTP round-trip test against the real control-plane binary, mirroring founding's stdio round-trip (ADR 0052) and device-add's socket round-trip (ADR 0057). Above the seams: nothing — Vue renders states, it does not decide them.
  • Prior art to copy: founding's fake harness (in-memory enroll ledger + clock, ADR 0052), device-add's both-ends seam driving (ADR 0057), and the S13 prototype's clan fakes (spikes/S13-clan-orchestration/).
  • Non-gating real-lab smoke (fake-drift insurance), mirroring founding's and device-add's spec pattern: a scheduled clan-lab provisioning smoke — a real deploy of a service to a lab node with its real health check, and a real update rollout + rollback on the lab fleet — explicitly not an acceptance gate. The actual disk-overwrite takeover stays spike #12's.

Out of Scope

  • The update engine's supply-chain internals. The signed channel, the required binary cache, and the build host are settled in ADR 0017 and docs/architecture/11-update-supply-chain.md; this spec consumes them, it does not redesign them.
  • Catalogue growth. v1 ships a fixed catalogue (ticket #8); adding a service is OurCloud-side engineering delivered through the update channel, not a provisioning surface. Provisioning runs whatever health check a port ships (ADR 0062), so a new service needs no provisioning change.
  • Monitoring's steady-state watching. Deploy-time and update-time health checks are provisioning's gate; watching the same services forever after is monitoring's (P5). The failed-service standing fault is handed off, not owned here.
  • Rescue. A failure of the takeover itself escalates to rescue (P8); provisioning names the escalation, it does not implement the rescue tracks.
  • Backups' own surfaces. Provisioning attaches backup-target services and computes destructiveness against coverage, but the backup policy/runs/restore surfaces are the backups feature's.

Further Notes

  • needs_human_decision carried, not re-derived: multi-arch fleet support (aarch64 nodes change every service build and the cache) — inherited from device-add's spec and the map's §12 leftovers; decide at or before the slice-map.
  • Cross-feature edges for the slice-map (the coupling this spec makes explicit):
    • backups — Coverage must read per-service health, not what was attached (ADR 0061); provisioning and backups share the coverage/gap model.
    • shell — must reserve a chrome slot for feature-supplied standing indicators; the auto-security-off indicator (ADR 0068) is the first tenant. Shell has not been grilled yet, so this is an obligation to record, not yet agreed on the other side.
    • device-add — the spec-gate floor pin (ADR 0064) couples device-add's gate to the catalogue's per-service minima; #13 has been amended to carry it.
    • monitoring — a port's HealthCheck is defined once and reused by monitoring for steady-state watching.
  • Provenance note on P4b: the update surfaces were produced by an auto-accept session (agent recommendations, no live grill), then reviewed and signed off by Ben on 2026-07-24 with the two-attempt retry budget kept. The decisions are on the record as agent-originated (ADRs 0065–0068) but accepted.
## Parent Wayfinder map: https://git.matou.nz/Matou/ourcloud/issues/7 — provisioning's definition was locked on ticket #9 (2026-07-21). This child spec inherits the map's cross-feature constraints (clan substrate behind the `clan` seam; kanidm/OIDC; the `brandkit` theming seam; the seeded-cache supply chain; the cross-cutting UX rulings — advice never veto, logging with drill-in, hardware minima + spec gate) and links back to it as the parent artifact. Grilled 2026-07-23 (`/grill-ux-with-docs`), both journeys: P4 setup/change (ADRs 0058–0064, both gates passed) and P4b updates (ADRs 0065–0068, auto-accept session signed off 2026-07-24). Flows: `docs/ux/flows/p4-provisioning.mermaid`, `docs/ux/flows/p4b-updates.mermaid`. Wireframes: `docs/ux/wireframes/p4-provisioning/`, `docs/ux/wireframes/p4b-updates/`. ## Problem Statement An operator has connected a device to their community's fleet (device-add left it `connected — not set up` and, for a full install, `takeover-ready` — its disk not yet touched). It is doing nothing. The operator — low-skill, low-time — now has to decide what job the machine should do, make it do that job safely over the connection already established, and then keep it and the rest of the fleet current with security patches and feature updates for the fleet's whole life. Left to raw tools this means: judging which services a machine can run against its specs, network and uptime; knowing which of the community's data has no second copy and no backup; triggering an irreversible disk wipe with full knowledge of what is lost; watching a deploy that can half-succeed; and, forever after, applying updates without breaking the services members depend on — with a real way to roll back and a real way to opt out. None of that should require systems expertise, and none of it should let the system quietly claim a safety (a backup, a second copy) the community does not actually have. ## Solution Provisioning is two operator journeys on the web dashboard, both driven by the community's own control plane over the established connection, so a closed browser never interrupts anything. **P4 — assign a device its role and services, and deploy them.** The system assesses what the device offers (specs, reachability, uptime pattern) against what the community needs (HA gaps, backup gaps) and recommends the set that fills those gaps first; the operator accepts or adjusts freely (advice, never veto). It reviews the impact — what moves, what replicates, the new load — before anything runs. When the impact destroys something (a full-install device's disk is erased, or a removal drops the last copy of data), Review impact becomes a deliberate confirm that names the destruction and, for an erase, attributes the consent the device owner already gave at the machine. Deploy runs over the connection: a full-install device takes over to NixOS and joins the clan, a VM-mode device gets services only. Health checks run per service; the device goes active for the jobs that work, and any service that failed is named, retryable, and claims no coverage anywhere. P4 is also the standing surface for changing an active node later. **P4b — keep the fleet current.** The control plane watches the pinned channel; security patches apply automatically in a community-chosen maintenance window while feature updates queue for one-click approval with plain-language release notes shipped signed with the release. Every update is a health-gated staged rollout — a canary chosen by rule (never the gateway, a quorum node, or the sole home of data), the gateway last — with automatic rollback at the matching scope on failure. A release that fails twice is quarantined and handed to the operator. The policy slider spans fully-automatic down to everything-manual; turning auto-security off is allowed and starts a standing, evidence-based indicator. Pin-or-fork the channel is the sovereignty exit. ## User Stories Acceptance criteria are Given/When/Then, sourced from the flow nodes and edges of `p4-provisioning.mermaid` and `p4b-updates.mermaid`, including the error, empty and partial branches. ### P4 · Assess and recommend (P4-S1, P4-S1x) 1. As an operator, I want the system to assess a newly connected device before I choose anything, so that my choices start from what the machine can actually do. - Given a `connected — not set up` device, When I open its setup, Then P4-S1 shows what the device offers — resources (a VM-mode device counts its *allocated* resources), network and public reachability, and uptime pattern — and what the community needs, as named HA and backup gaps. - Given the fleet's current state, When assess runs, Then the gaps shown are the community's gaps *now* (e.g. "Files & documents live on one device only", "Chat has no backup yet"), computed from live fleet state, not a fixed list. 2. As an operator, I want the recommended role and services to fill my gaps first, so that the machine does the most useful thing without me working it out. - Given the assessment, When P4-S2 loads, Then the recommended services are pre-selected and each names the gap it closes ("closes the single-copy gap", "closes the no-backup gap"). - Given a service the device cannot run, When it appears under Available, Then it is shown gated with the reason in the device's own numbers ("needs 8 GB — this device has 4", "needs a public address"). 3. As an operator whose device can run nothing useful, I want to be told plainly rather than dropped into a dead end, so that I am never stuck staring at a wiped or donated machine that can do nothing. - Given assess finds every catalogue service out of reach for the device, When setup proceeds, Then P4-S1x is shown instead of P4-S2, naming the device unusable in its own numbers with the reason each service is out of reach. - Given P4-S1x, When I decide, Then I always have a real next step: take the lowest-floor job the device can still do (an extra backup copy, never the sole copy of anything), or remove the device from the fleet. 4. As an operator whose community already has no gaps, I want the recommendation to say so calmly, so that a fully-covered fleet does not look broken. - Given the community has no HA or backup gaps left, When P4-S2 loads, Then the recommended block is replaced by a plain "your community has no gaps right now — nothing needs filling", and I can still add any available service if I want. ### P4 · Select role and services (P4-S2) 5. As an operator, I want to accept the recommendation or adjust it freely, so that I stay in control while the system advises. - Given recommended and available services, When I add or remove any selection, Then the system never blocks the change (advice, never veto — ADR 0015); it only explains gated items. 6. As an operator, I want to assign the device a fleet role, so that the machine takes a defined place in the fleet. - Given the role selector, When I pick a role, Then the available services update to those the role and the device's specs/access permit. ### P4 · Review impact and the destructive confirm (P4-S3, P4-S3x) 7. As an operator, I want to see the impact of my choices before anything runs, so that I am never surprised by what a deploy does. - Given a non-destructive selection, When I reach review, Then P4-S3 shows what moves, what replicates (with size and timing), how backup targets change, and the new steady-state load, and offers a plain Deploy. 8. As an operator provisioning a full-install device, I want the erase named and confirmed deliberately, so that I never trigger an irreversible disk wipe without it being in front of me. - Given the device is full-install and still `takeover-ready`, When I reach review, Then P4-S3x is shown with an ⚠ ERASES row stating the disk is erased and replaced with NixOS, and the action reads "Erase & deploy", not "Deploy". - Given the erase, When P4-S3x shows it, Then it attributes the consent the device owner gave at the machine (who and when) and never re-asks for consent in the dashboard (ADR 0024); nothing has been erased until I confirm here. 9. As an operator removing something that destroys data, I want the loss named and confirmed deliberately, so that I do not tear down a community's only copy on an ordinary-looking click. - Given a change whose impact drops the last copy of data or a dataset's last backup, When I reach review, Then P4-S3x is shown with an ⚠ LOSES row naming exactly what drops (e.g. "Chat drops to no backup — tōtara holds its only copy"), and the action reads "Remove & deploy". ### P4 · Deploy and health checks (P4-S4) 10. As an operator, I want the deploy to run over the connection already established, so that I do not repeat any enrollment step. - Given a confirmed deploy, When it runs, Then the community's own config repo drives it, progress streams to the dashboard as a checklist, and every step is logged with Open/Download. 11. As an operator deploying a full-install device, I want the NixOS takeover to happen here, so that the machine becomes a real node. - Given a full-install `takeover-ready` device, When deploy runs, Then it takes the device over to NixOS, joins the clan, then deploys services — in that order. 12. As an operator deploying a VM-mode device, I want only the services deployed, so that a machine already running the right OS is not needlessly rebuilt. - Given a VM-mode device (its NixOS VM already created at device-add), When deploy runs, Then services are deployed to the VM with no install/takeover phase. 13. As an operator, I want a failed deploy to fail safely with a plain error, so that a broken deploy never strands the machine. - Given a deploy-itself failure (config, connectivity or disk), When it fails, Then I get a plain error and logs, and the recovery matches the mode: VM mode retries clean (delete, recreate); full install rolls the NixOS generation back once the new OS is on; and a failure of the takeover itself resumes or escalates to rescue. ### P4 · Active, and partial success (P4-S5, P4-S5x) 14. As an operator, I want a device to count as active only when its services are healthy, so that "active" means working. - Given a deploy where every service passed its health check, When it completes, Then P4-S5 shows the device active with its role and all its services, and monitoring (P5) picks it up. 15. As an operator, I want a device whose deploy succeeded but one service failed to still do the jobs that work, so that one bad service does not throw away a successful takeover and a working service. - Given a successful deploy where a service fails its health check, When it completes, Then P4-S5x shows the device active for the passing services, nothing rolls back, and the failed service is named with its failure ("dry-run could not write to tōtara") and offered Retry or Remove. 16. As a community, I want a failed service to claim no coverage, so that we are never told we have a backup or a second copy we do not have. - Given a service that failed its health check, When coverage is computed anywhere (Backups overview included), Then that service contributes no coverage and the data it was meant to protect still shows as an open gap. 17. As an operator, I want the failed service carried into monitoring, so that it is not silently forgotten after setup. - Given P4-S5x, When provisioning completes, Then monitoring picks the device up including the failed service as a standing fault. ### P4 · Changing an active node (P4-S5 → P4-S1) 18. As an operator, I want to change an active node's role or services later, so that the fleet can grow and adapt without removing and re-adding machines. - Given an active node, When I choose to change its setup from the device page, Then the same five P4 screens re-run: P4-S1 re-assesses against today's fleet state, P4-S2 arrives pre-selected with the node's current role and services. 19. As an operator changing a node, I want the impact shown as a delta, so that I see exactly what is added and removed. - Given a change, When I reach review, Then the impact shows ADDS and REMOVES alongside the usual moves/backups/load, and deploy is a plain `clan.Deploy` with no erase (the node is already NixOS). 20. As an operator changing a node, I want a destructive removal to get the same deliberate confirm as an erase, so that removing the last copy of data is never a casual click. - Given a change whose removal destroys data, When I reach review, Then P4-S3x is shown with the LOSES row (per story 9). ### P4b · Seeing update state (P4b-U1, P4b-U1x) 21. As an operator, I want one surface that tells me the whole update story, so that I always know what is waiting on me, what is happening without me, and what the fleet is running. - Given the Updates screen, When I open it, Then P4b-U1 shows pending-my-decision updates, updates applying automatically, quarantined releases, and the revision the fleet is currently running, with the channel and last-checked time. 22. As an operator, I want an "up to date" resting state, so that a quiet fleet reads as working rather than empty. - Given nothing pending and the fleet converged, When I open Updates, Then P4b-U1x states everything is up to date, names the channel, revision and last-checked time, and reassures what happens without me (security auto-applies in my window; features queue; a broken update rolls back). - Given a signed release appears on the pinned channel, When the control plane's own poll finds it, Then P4b-U1 surfaces it (moving off the resting state). 23. As an operator, I want to drill into update history, so that "what changed just before this broke?" is always answerable. - Given past updates, When I drill in, Then each update, what it did, and its logs are available (ADR 0027). ### P4b · Reviewing and approving (P4b-U2) 24. As an operator, I want feature and major updates to wait for my approval, so that a change my members will notice does not apply itself. - Given a feature or major release (or any release while auto is off), When it arrives, Then it appears as pending-my-decision and I open it to decide. 25. As an operator, I want plain-language release notes, so that I can decide without reading a changelog. - Given P4b-U2, When I review an update, Then it shows release notes written in plain language and shipped signed with the release (rendered verbatim, not generated per fleet), plus what it touches in *my* fleet's terms — which nodes, which services, when, and what happens if it fails. 26. As an operator, I want to approve an update for the maintenance window, so that it applies when members are least affected. - Given a reviewed update, When I approve it, Then it is queued for the next maintenance window. 27. As an operator, I want to skip an update and have it stay skipped, so that I am neither nagged nor overridden. - Given a pending update, When I skip it, Then it returns to the pending list and keeps saying so; nothing is lost and nothing applies itself (ADR 0015). ### P4b · Automatic security (P4b-U1 → P4b-U3) 28. As an operator, I want security and patch updates to apply automatically in my window, so that the fleet stays patched without my attention. - Given a security or patch release and auto-security on, When it arrives, Then it is not queued for my approval; it waits for the community's maintenance window and then rolls out. ### P4b · Rolling out (P4b-U3) 29. As an operator, I want every update staged and health-gated the same way, so that whether I approved it or it applied itself, it is equally protected. - Given an update applying (approved or automatic), When it rolls out, Then closures are seeded to every node first, a canary deploys and passes its health checks, then the rest follow, with the gateway last. 30. As a community, I want the canary chosen by rule, so that a bad revision is proved on the node whose loss costs least. - Given a rollout, When the canary is chosen, Then it is never the gateway, never a quorum-role holder, and never the sole home of any dataset; the gateway is always updated last. - Given a fleet too small to have a qualifying canary, When a rollout runs, Then it says so and proceeds one node at a time with a health gate between each. 31. As an operator, I want a retry to reuse the proven closure, so that a retry never rebuilds into something different. - Given a rollout or retry, When it applies, Then it applies the same exact revision/closure to every node. ### P4b · Applied, rolled back, quarantine (P4b-U4, P4b-U4x) 32. As an operator, I want "applied" to mean converged and healthy, so that a finished update is genuinely done. - Given a rollout where every service passed on every node, When it finishes, Then P4b-U4 shows the fleet converged on the new revision with the order it took, and monitoring watches it from here. 33. As an operator, I want a failed update rolled back automatically, so that the fleet is never left on a bad revision. - Given a health-check failure during rollout, When it fails, Then the update is rolled back automatically at the matching scope — NixOS generation at the host, an earlier exact revision at the runner, a rolling container bump for a service — and the fleet returns to its previous revision, healthy. 34. As an operator, I want a rolled-back update retried once, so that a transient failure does not need my attention. - Given a first rollback, When the next maintenance window comes, Then the same closure is retried once. 35. As an operator, I want a repeatedly-failing update quarantined and handed to me, so that it does not re-break a node every window forever. - Given a second consecutive failure, When it rolls back again, Then the release is quarantined — no further automatic attempts — and surfaced at the top of Updates with the failing node and its logs. - Given a quarantined release, When later releases arrive on the channel, Then they are not blocked by it; and quarantine overrides auto-apply for the quarantined release. - Given a rolled-back update, When I choose, Then I can end the attempts early or retry it by hand without waiting for the second failure. ### P4b · Policy and channel (P4b-U5, P4b-U5x) 36. As an operator, I want to set update policy across the full range, so that the community decides how much is automatic. - Given update policy, When I set it, Then security/patch and feature/major each span apply-automatically · ask-me-first · never-apply-automatically, and I can set a maintenance window. 37. As an operator, I want turning auto-security off to be allowed but visible, so that the choice stays informed rather than forgotten. - Given I turn auto-security off, When I save, Then it is allowed (no veto), and the dashboard begins carrying a standing, evidence-based indicator (P4b-U5x) — how many patches are pending, how old the oldest is, and whether the public gateway is affected. - Given the indicator, When I drill in, Then it takes me to the pending patches it is counting; and it disappears the moment auto-security is turned back on. 38. As a community, I want pin-or-fork the channel to be a real setting, so that our sovereignty exit does not need a support ticket. - Given the channel setting, When I pin to an exact revision or point at a fork we control, Then the fleet stops receiving from Matou's channel — the exit is one setting (one flake input). ## Implementation Decisions - **Two orchestrators, two seams, both in the control plane.** `provision` (ADR 0058) drives the P4 journey; `update` (ADR 0065) drives P4b. They are siblings, not one package — the journeys differ in object (one device vs one release), trigger (an operator clicking vs a scheduled channel poll), scope (one node vs the fleet in stages) and cadence. Both run server-side, so a closed browser interrupts neither. The Vue dashboard is thin UI over both; it renders states, it does not decide them. - **Provisioning owns both `clan` hot paths; the two "enroll"s are different (ADR 0059).** A full-install device's first deploy drives `clan.Enrollment` (the `install --phases` NixOS takeover that device-add only staged as `takeover-ready`); a VM-mode device or an already-active node drives `clan.Deploy`. Device-add drives neither — its enrollment is the separate `enroll` (agent↔control-plane) seam. `provision` reads the `takeover-ready` state to choose Enrollment vs Deploy and to read the already-captured install-mode consent; it never re-asks consent. - **Health checks are per service (ADR 0061), and a catalogue port ships three parts (ADR 0062).** A port is daemon+secrets, its out-of-band reconciler contract, and its own `HealthCheck` — the additive amendment to the confirmed `clan` seam (`Config.AttachService` admits all three; a `HealthCheck` type added). `provision` and `update` both gate on it per service and know nothing about what a service does. Binding invariant: a service that has not passed its check contributes no coverage anywhere. - **Review impact computes destructiveness (ADR 0060).** `provision` must know whether a selection erases a disk (full-install `takeover-ready`) or whether a removal drops a last copy of data or a dataset's last backup, because that decision routes the operator to P4-S3 (plain) or P4-S3x (deliberate confirm). Impact is computed as a diff against current state; a first setup is the special case where current state is empty. - **The spec gate's floor is pinned to the cheapest real service (ADR 0064).** Device-add's spec-gate floor for a role equals the floor of the cheapest service that role can run, sourced from the catalogue's per-service minima — so the gate and provisioning's available-list cannot disagree. Where fleet state has moved since pairing, P4-S1x is the never-dead-end backstop. - **Update policy split and staged rollout (ADR 0017, inherited).** Security/patch auto-apply in a maintenance window; feature/major queue for one-click approval. Rollout is caller-scripted by the deploy runner (clan has no built-in canary): seed → canary → health gate → rest, gateway last. Canary is chosen by rule (ADR 0066). Rollback is scope-matched: host generation, runner exact-revision, service container bump — never a `git revert` of a non-tip. - **Retry budget then quarantine (ADR 0067).** Two attempts (same closure), then quarantine: no further automatic attempts, surfaced to the operator, overriding auto-apply for that release, never blocking later releases. Attempt state is durable (survives a control-plane restart). - **Release notes ship signed; the indicator is split (ADR 0068).** Release notes are authored by Matou and shipped signed as part of the release artifact, rendered verbatim — no LLM in the update path at runtime. The dashboard adds only local framing (which of this fleet's nodes/services are touched). The auto-security-off indicator is provisioning's content rendered in shell's chrome — a cross-feature slot shell's grill must reserve. - **Shared readers.** `provision` and `update` share one fleet-state reader (specs, reachability, uptime, roles, quorum membership, dataset homes, coverage/HA gaps) and the same per-service `HealthCheck` machinery. `Supply.Seed` is a precondition of every deploy and every rollout — a drifted unfed node cannot deploy offline (S13 Q4/Q9). - **Portal service-links follow health.** A service appears on the portal when it passes its health check and goes when it is removed or fails — the ticket-#9 boundary ("provisioning keeps service links current") made precise by the per-service decision. `brandkit` applies to the service surfaces provisioning stands up. ## Testing Decisions - **What a good test is here:** it drives one of the two seams and asserts *external behaviour* — the flow-node state reached, the coverage claimed (or not), the clan workflow chosen, the operator-facing failure and remedy — never an internal step ordering. Fakes simulate the world (clan, channel, clock, health checks); the state machines under test are real. - **`provision` (P4) — THE seam for the setup/change journey (ADR 0058).** Driven headless in-process against a fake `clan.Clan` exercising both hot paths (`Enrollment` for the takeover, `Deploy` for services-only, including blocked/resume/remedy and generation rollback), a fake fleet-state reader, per-service `HealthCheck` fakes that pass/fail independently, a fake portal-link updater, and **real** `brandkit` (pure — faking it would be waste). Every P4 acceptance criterion executes here: assess/recommend with gated-service reasons; both empty states (nothing available; no gaps to fill); impact for a first setup and a change; the destructive confirm's two triggers (ERASES/LOSES); full-install takeover vs VM-mode services-only; all-healthy → active; partial failure → active-for-what-works with no coverage claimed; the deploy-itself failures classified by the clan seam with the VM clean-retry / generation-rollback / rescue branches; and re-provisioning including destructive removals. - **`update` (P4b) — THE seam for the updates journey (ADR 0065).** Driven headless against a fake channel (signed release metadata + notes), a fake clock (maintenance windows; the indicator's "oldest 12 days" evidence), a fake `clan.Clan` (`Deploy` plus the three rollback scopes), per-service `HealthCheck` fakes that fail on command, and a fake `Supply` reporting unfed nodes. Every P4b acceptance criterion executes here: the policy split (auto-security applies unattended in-window; features queue); skip-and-stay-skipped; canary-by-rule and the tiny-fleet fallback; gateway-last; health-gated automatic rollback at each scope; the two-attempt retry budget → quarantine (fail→retry→succeed, fail→retry→fail→quarantine, quarantine overriding auto-apply, a later release applying cleanly over a quarantined one); the evidence the indicator counts; and pin-or-fork. - **Below each seam:** one thin HTTP round-trip test against the real control-plane binary, mirroring founding's stdio round-trip (ADR 0052) and device-add's socket round-trip (ADR 0057). Above the seams: nothing — Vue renders states, it does not decide them. - **Prior art to copy:** founding's fake harness (in-memory `enroll` ledger + clock, ADR 0052), device-add's both-ends seam driving (ADR 0057), and the S13 prototype's clan fakes (`spikes/S13-clan-orchestration/`). - **Non-gating real-lab smoke (fake-drift insurance), mirroring founding's and device-add's spec pattern:** a scheduled clan-lab provisioning smoke — a real deploy of a service to a lab node with its real health check, and a real update rollout + rollback on the lab fleet — explicitly *not* an acceptance gate. The actual disk-overwrite takeover stays spike #12's. ## Out of Scope - **The update engine's supply-chain internals.** The signed channel, the required binary cache, and the build host are settled in ADR 0017 and `docs/architecture/11-update-supply-chain.md`; this spec consumes them, it does not redesign them. - **Catalogue growth.** v1 ships a fixed catalogue (ticket #8); adding a service is OurCloud-side engineering delivered through the update channel, not a provisioning surface. Provisioning runs whatever health check a port ships (ADR 0062), so a new service needs no provisioning change. - **Monitoring's steady-state watching.** Deploy-time and update-time health checks are provisioning's gate; watching the same services forever after is monitoring's (P5). The failed-service standing fault is handed off, not owned here. - **Rescue.** A failure of the takeover itself escalates to rescue (P8); provisioning names the escalation, it does not implement the rescue tracks. - **Backups' own surfaces.** Provisioning attaches backup-target services and computes destructiveness against coverage, but the backup policy/runs/restore surfaces are the backups feature's. ## Further Notes - **`needs_human_decision` carried, not re-derived:** multi-arch fleet support (aarch64 nodes change every service build and the cache) — inherited from device-add's spec and the map's §12 leftovers; decide at or before the slice-map. - **Cross-feature edges for the slice-map (the coupling this spec makes explicit):** - **backups** — Coverage must read per-service health, not what was attached (ADR 0061); provisioning and backups share the coverage/gap model. - **shell** — must reserve a chrome slot for feature-supplied standing indicators; the auto-security-off indicator (ADR 0068) is the first tenant. Shell has not been grilled yet, so this is an obligation to record, not yet agreed on the other side. - **device-add** — the spec-gate floor pin (ADR 0064) couples device-add's gate to the catalogue's per-service minima; #13 has been amended to carry it. - **monitoring** — a port's `HealthCheck` is defined once and reused by monitoring for steady-state watching. - **Provenance note on P4b:** the update surfaces were produced by an auto-accept session (agent recommendations, no live grill), then reviewed and signed off by Ben on 2026-07-24 with the two-attempt retry budget kept. The decisions are on the record as agent-originated (ADRs 0065–0068) but accepted.
Author
Owner

Closed in the 2026-08-27 other-state sweep (Ben's ruling) — child spec complete: 16/16 provisioning slices done, all 27 derived tickets closed. #353 (move-off-gateway) stands alone as a later DDR 0145 slice.

Closed in the 2026-08-27 `other`-state sweep (Ben's ruling) — child spec complete: 16/16 provisioning slices done, all 27 derived tickets closed. #353 (move-off-gateway) stands alone as a later DDR 0145 slice.
ben closed this issue 2026-08-27 04:43:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#17
No description provided.