Expand description
Rig lifecycle actions (04-01, RIG-01): up / down / status —
serde models OUT, no printing (the TUI rides this layer in Phase 6).
Extended by 04-02 (reset/logs), 04-03 (trial), 04-04
(snapshot/restore, RIG-04).
Every action takes [&dyn ComposeRunner] (the Task-1 seam) so the
full decision tree is unit-testable without docker. rig_up
additionally takes an OPTIONAL gateway probe: the dispatch derives
the rig’s gateway URL (gateway_url_from) and builds a
HEADER-LESS client pointed at it — the commissioned wait probes
/StatusPing on the RIG’s own port, never the profile’s gateway.
§Uncommissioned is DATA, not failure (research Pattern 4)
A fresh-volume rig terminally reports "up, uncommissioned" — exit
0 with the wizard URL inside warnings (the version-command
degradation precedent). There is NO headless commissioning (verified:
no commissioning endpoints in 83-api); the wait deadline only covers
STARTING→RUNNING on an already-commissioned volume.
§The wait reuses poll.rs VERBATIM (locked)
crate::poll is THE wait engine — its retry set is LOCKED and
untouched. Probe translation (research Pattern 4): RUNNING →
Done; other states → Pending; GatewayNotCommissioned → the probe
ITSELF catches it and returns Pending with the wizard hint (never
aborts); Network/GatewayRestarting propagate for poll’s native
retry; Auth can’t fire (the probe is header-less).
Structs§
- Restore
Result ign rig restoreoutput model (04-04, RIG-04) — all keys always.- RigDown
Result ign rig downoutput model.- RigLogs
Result ign rig logsoutput model (04-02, RIG-02): only the count — the lines themselves already streamed through the sink (the third sanctioned stdout exception; the dispatch owns the printing, thelogs -fprecedent).- RigReset
Result ign rig resetoutput model (04-02, all keys always).- RigStatus
Result ign rig statusoutput model — an ALLOWLIST, never a compose config/inspect passthrough (the resolved config containsGATEWAY_ADMIN_PASSWORDetc.; research anti-pattern).- RigUp
Result ign rig upoutput model (all keys always present).- Snapshot
Result ign rig snapshotoutput model (04-04, RIG-04) — all keys always.- Status
Publisher - One published-port row in status output (allowlist only).
- Status
Service - One service row in status output (allowlist only).
- Trial
Banners - The banners cross-check block of
TrialStatusResult(all keys always; a failed banners fetch degrades to nulls + a warning — the trial endpoint is the primary truth). - Trial
Reset Result ign rig trial resetoutput model (04-03, RIG-03): the ladder’s outcome — which rung landed, and the before/after flip (the flip is REQUIRED for success; a bare 2xx never suffices).- Trial
Status Result ign rig trial statusoutput model (04-03, RIG-02): the trial endpoint re-exposed under unit-explicit keys (the two-layer naming LOCK) + the banners cross-check. All keys always present.
Constants§
- DEFAULT_
WAIT_ TIMEOUT_ S - Default wait budget for BOTH
up --wait-timeoutand the commissioned probe deadline (research Pitfall 3: healthchecks block--wait, and image pulls add minutes). - RESTORE_
TOKEN_ WARNING - The token-clobber warning (Pitfall 5, 83-api primary source): tokens stored under CORE config are “modified/cleared often by gwbk restores” — post-restore, stored profiles 401. It rides DATA (agents must see it), never stderr-only.
- RESTORE_
WAIT_ FLOOR_ S - The restore wait FLOOR: the gateway RESTARTS after a restore
(Pitfall 6), so the post-restore RUNNING wait never gets a shorter
deadline than this — an explicit
--timeout 30cannot buy an unknown-state mid-restart report (the RESTART_FLOOR precedent, restore edition).
Functions§
- gateway_
url_ from - Derive the rig’s gateway URL from the resolved port mappings — the
DOCUMENTED HEURISTIC: the first mapping targeting the gateway’s http
port (8088) wins, then its https port (443), else nothing.
datacarries what was derived (gateway_url), so agents can see the heuristic’s answer. - rig_
down ign rig down: version gate →down --remove-orphans(volumes KEPT — the-vteardown half belongs torig reset, 04-02).- rig_
logs ign rig logs(04-02, RIG-02): compose log PASSTHROUGH — a raw line stream throughsink, never an envelope-wrapped body. Compose log lines are not gateway JSON objects; wrapping would corrupt them, sorig logs --jsonis the SAME passthrough in every render mode (contrastlogs -f --json, whose entries ARE gateway NDJSON — the second exception). Follow mode rides the runner’s STREAMING shape (piped stdout forwarded as it arrives until EOF/child exit; Ctrl-C kills the foreground process group — README §Streaming, thelogs -fprecedent). Compose stderr (diagnostics) goes to OUR stderr via tracing::warn — never the data sink.- rig_
reset ign rig reset(04-02, RIG-01): the guarded teardown + bring-up cycle — NO stale project/trial state survives. The CLI guard (--yes, exit 2 before ANY resolution) lives in the dispatch (the sessions-terminate/project-delete layering); this action is the decision-complete cycle behind it:- rig_
restore ign rig restore(04-04, RIG-04): the guarded inverse —- rig_
snapshot ign rig snapshot(04-04, RIG-04): repeatable state, composed HONESTLY —- rig_
status ign rig status: version gate →psLDJSON →volume ls→ port occupancy — serialized as an ALLOWLIST (services’ state/health/ publishers, volume names, identity). Exit 0 even when the rig is down: state is data.- rig_up
ign rig up: version gate → port pre-flight →up -d --wait→ commissioned wait (poll.rs) with uncommissioned-as-data semantics.- trial_
reset ign rig trial reset(04-03, RIG-03): the evidence-chosen LADDER — tier 0 (token-authPOST /trialthrough the existing client, one cheap call) falls through to tier 1 (the native OIDC login → session+CSRF POST,crate::client::idp, live-verified end-to-end on 8.3.3 with theexpired:true → falseflip).- trial_
status ign rig trial status(04-03, RIG-02): the trial endpoint is the PRIMARY truth; the trial banner (type: "trial") is the cross-check, itsactiveflag computed per Pitfall 7 (severity=="info" && expireTime>now_ms— never the reverse derivation). A failed banners fetch degrades to nulls + a warning (the trial endpoint already answered; the cross-check is advisory).gatewayis a client pointed at the RIG’s URL — these endpoints answer unauthenticated (live-verified both rigs), so a fresh rig with no token reports its trial state fine.