- dashboard/DESIGN.md: the update engine (releases/<sha>, a current symlink, a self-rollback) was never built and says so, with what an update really is; there is no Origin check, no action rate limit and no idempotency key (a CSRF token, one job at a time, a failed-login limit); the collectors read /server_info and /v1/loads, falling back to the /get_* routes only on a 404; custom recipes are JSON files (recipes.py reads *.json), not YAML. - dashboard/REVIEW.md: autoheal shipped off (COCKPIT_AUTOHEAL=0 in the v1.6 unit), a session lasts 12 h from its login (the cookie is issued once), and the sudoers allowlist has 26 lines, not nine for start and stop. - extras/gguf/README.md: the raw bench file is git-ignored, so the link was a 404; the proxy speaks /server_info and /v1/messages/count_tokens too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
24 KiB
Spark Cockpit: state at the v1.6 review
Written while this was the unreleased webapp branch; shipped in v1.6.
Everything below was built, run and validated
live on the reference box on 2026-08-28, with screenshots taken through a
CDP-driven Chromium at every step.
Run it
python3 dashboard/cockpit.py # dev: http://127.0.0.1:30090
bash dashboard/install-dashboard.sh # or as a systemd service (sudo asked once)
Login = the server API key (~/.config/qwen38/api-key). The sudoers allowlist
(exact argv lines, visudo-checked before install; 26 at v1.18.7: start, stop and restart of five units, boot enablement of the lanes, daemon-reload and the two installs a switch makes, the py-spy wrapper and the kernel journal) is what the
privileged actions need; everything else runs unprivileged.
What works today (all validated on screen)
- Live panels over SSE (1 s) with polling fallback and per-panel failure isolation: unified memory (the real GB10 gauge), CPU, GPU power/temp/ processes (with the documented GB10 quirks), serving engine identity (model, revision, quant, context, speculative, backends, radix cache), live requests (running/waiting/tokens/accept length), services with start/stop buttons, containers, repo state.
- Engine chip states: healthy / booting / down. "Booting" is inferred from health-down plus a container burning CPU: a journald-silent weight load is not an outage (field lesson learned the hard way).
- Actions with NASA rails: fixed-argv registry, closed-enum validation, CSRF, single-job lock, append-only audit log, confirm modal showing the exact command, live job log streaming. Security paths tested: 403 without CSRF, 400 out-of-enum, isolated 502 while the engine boots.
- Inventory panel: the uninstall --list scan rendered (units, backups, config, legacy files, images by tag AND digest, checkpoints with sizes, the PLE backing file).
- Live logs panel: container logs and keepalive journal tail.
- opencode card with the one-command handoff.
- Login page, house palette light/dark, version badge, canvas sparklines, zero external dependencies anywhere (stdlib backend, vanilla frontend).
- Hardening: CSP + nosniff + no-referrer on every response, login rate limiting (5 tries per minute per address, audited), tested live (5x403 then 429, lockout applies to the right key too).
- End-to-end action demo performed IN the UI: Run smoke clicked, confirm
modal, canary through the keepalive proxy, audit line
smoke ok:true.
Deliberately not done yet (needs your call or the next iteration)
- The atomic self-update engine for the app itself (release dirs + rollback): designed in DESIGN.md, waiting until the branch has a remote to update from.
- Structured per-request feed (parsing proxy lines into a table): the raw journal view covers it today.
- Bench runner and canary/needle buttons in the UI (backend patterns exist).
- HTTPS story. The bind is configurable since
DASH_BIND(loopback by default), but off-box access is plain HTTP, so it assumes a tailnet.
Field notes from building it
The cockpit caught real things while being built: a broken containers collector (docker stats with an absent name), the display:grid vs hidden modal bug, the engine restart of 17:34 whose clean-stop origin the tripwire now watches for, and the boot-is-not-a-freeze lesson now encoded in the UI.
Etape 1 livree: machine a etats + orchestrateur (29/08, nuit)
Validee par un test de torture REEL (stop puis start du 176B via l'API du cockpit, boot complet observe en direct dans un navigateur pilote).
Ce que l'etape apporte, tout verifie a l'ecran ou par sonde:
- Etats explicites par moteur avec barre de progression par etape (pilules init/weights/draft/KV/graphs/warmup, shimmer, elapsed vs ETA apprise).
- Verrou anti-deux-moteurs applique DES DEUX COTES: bouton start grise avec la raison imprimee, ET refus 409 serveur avec les memes raisons.
- Avertissements honnetes: stop du flash en plein boot = alerte table PLE dans la modale; stop d'un moteur pret = alerte clients :30001.
- Fil d'evenements (transitions d'etats, jobs) pousse en SSE.
- Apprentissage des durees de boot (buckets rebuild separes, mediane /12), garde anti-fausse-mesure (activation temoin obligatoire).
Bugs REELS attrapes par le test (tous corriges + tests de regression):
- parse sans marqueur pretendait toutes les etapes faites (queue de log d'un serveur mur = bruit decode pur).
- docker logs parle sur stderr: le parseur et la telemetrie decode lisaient du VIDE depuis le debut (run() stdout-only).
- le cockpit redemarre face a un moteur chaud enregistrait son uptime comme duree de boot (garde temoin ajoutee, historique purge).
- chaque restart du service deconnectait tout le monde (secret HMAC en memoire): secret persiste 0600, session prouvee survivante.
Decouverte niveau REPO (backlog v1.6, branche main): systemctl stop laisse l'unite en failed car le conteneur meurt en SIGKILL (exit 137); fix = SuccessExitStatus=137 143 dans les templates d'unites, a valider par un vrai cycle stop avant push.
Backlog court terme: persister le fil d'evenements (process-local aujourd'hui), page-iser les logs, refonte design (etape 2).
Etapes 2, 3 et 5 livrees (29/08, nuit, suite)
Etape 2, refonte design totale (verdict precedent: esthetique rejetee):
- Nouveau langage: fond encre a lueurs radiales, cartes verre en degrade, chips lumineuses, jauges en degrade, entree en cascade des cartes, point live qui bat, chiffres tabulaires. Sombre d'abord, clair via les memes tokens, prefers-reduced-motion respecte.
- Panneau moteurs promu en hero pleine largeur (la reponse au premier coup d'oeil), actions pleine largeur en bas. Login accorde.
- Methode: le bloc <script> est reste OCTET-IDENTIQUE (zero regression logique possible); les deux themes rendus et verifies en navigateur.
Etape 3, registre + veille upstream:
- /api/registry: scan du cache HF (metadata seulement, blobs dedupliques par inode), pins extraits generiquement des scripts du repo (le parseur a decouvert DRAFT2_REV tout seul), chaque revision classee pinned/stray/unmanaged, images moteurs docker. Cache 5 min.
- /api/upstream: chaque pin compare au main HF + tag local vs derniere release GitHub; cache 1 h; toute panne distante degrade en "offline" ligne par ligne. Premier run: il a affiche tout seul nos deux TODO v1.6 (stock 27B "moved" = revert README connu; DSpark "moved" = la v2).
- UI: panneau Registry pleine largeur (revisions, tailles logiques et disque physique, chips de statut, images) + sous-panneau Upstream.
Etape 5 (partiel, les morceaux testables ce soir):
- Timeline d'evenements persistante (jsonl borne, rechargee au demarrage).
- Suite smoke HTTP: 17 assertions vivantes en une commande (dashboard/tests/smoke-http.sh): auth, CSRF, enums fermes, gate 409 anti-deux-moteurs, anti-traversal statique, en-tetes. 17/17 vert.
Reste a construire (par choix, pas par oubli):
- Moteur de recipes custom (etape 4): le prochain grand chantier; la base (etats, gates, registre) est exactement ce qu'il lui fallait.
- Auto-update atomique de l'app: bloque tant que la branche est locale (il faut un remote pour verifier/telecharger des versions).
- Exposition LAN + HTTPS; actions de reclaim (suppression des revisions stray) avec double confirmation.
Ceintures anti-blocage (29/08, journee autonome)
Cas de terrain du matin: ordonnanceur SGLang en boucle (R, 100 % CPU) pendant 9 h avec /health a 200 et /get_load a 0 requete; le cockpit affichait « healthy ».
- Sonde de vraie generation (2 tokens, thinking off) toutes les 90 s, UNIQUEMENT quand un moteur se dit pret, qu'aucun job ne tourne et qu'AUCUNE requete n'est en cours ou en attente (sinon la sonde ferait la queue derriere une longue generation legitime; vu en vrai pendant un prefill de 140k tokens).
- Deux routes de decision (lifecycle.decide_wedge, pure, testee): idle = 0 requete et 3 sondes consecutives en echec; occupee = requetes en cours mais aucune ligne Prefill/Decode depuis 300 s. Jamais melangees.
- Etat « wedged » (rouge), compte comme occupe pour les gates; audit; autoheal (COCKPIT_AUTOHEAL=0 par defaut dans l'unite livree avec v1.6, a armer a la main; refroidissement 30 min) qui redemarre l'unite via le chemin d'action audite.
- 43 tests unitaires verts, smoke HTTP 17/17.
Passe de modernisation UI (29/08, apres-midi)
-
Identite ancree dans l'objet (graphite du chassis, or champagne du Spark, vert NVIDIA), theme clair = papier chaud. Cascade d'entree retiree.
-
Signature: le RESERVOIR KV en bande pleine largeur (tokens tenus / capacite reelle / tick « un prompt seul » / fenetre 262K hachuree = ce qui ne tient jamais). Jauge de pool normalisee aussi dans Live requests, avec phrase d'explication qui change au-dela de 70 %.
-
Pilule « un coup d'oeil » dans l'en-tete (lane, etat, pool %, requetes).
-
Feed des requetes (25 dernieres vues par le proxy: client, chemin, taille, duree, issue) et action « Abort all » (generations orphelines).
-
Hysteresis de l'etat ready (3 rates + aucune ligne de progression) apres un battement ready/starting observe sous prefill de 140k.
-
Plancher qualite: focus visible, Escape ferme la modale, mobile 390 px sans defilement horizontal (mesure: scrollWidth == clientWidth), squelettes sur tous les « ... », regions aria-live pour le journal d'evenements.
-
Lighthouse (snapshot desktop, 29/08 13:06): accessibilite 100, bonnes pratiques 100, SEO 100, agentic browsing 100, 36 audits passes, 0 echec. CSP: script-src 'self' (scripts servis en fichiers).
-
Action « diagnostics bundle »: tar.gz dans ~ avec journaux, logs conteneurs, nvidia-smi, unites, server-info (cle masquee), launcher (cle masquee), etat cockpit; pour les rapports d'issue.
-
Hysteresis « ready » mesuree: 25 battements ready/starting entre 12:50 et 12:52 sous prefill 140k avant le correctif, 0 depuis 13:00 sous la meme charge (aiguilles).
-
Sonde de generation: uniquement si 0 requete ET aucune ligne de progression depuis 60 s (entre deux requetes consecutives la charge lisait brievement zero).
-
Pool guard (13:25): 2e blocage du moteur reproduit en conditions controlees (prefill d'un prompt ~93k termine a 89 % de pool apres 4 prompts 80k caches, aucun decode ensuite) et ATTRAPE par l'autoheal en 5 min (audit: wedge progress_age 302 s -> restart). Le cockpit flush maintenant le radix cache quand le moteur est idle depuis 3 s et que la derniere lecture du pool depasse 60 % (ou 50 % des slots mamba). Meme famille qu'upstream sglang #30314. Ligne « Mamba state slots » ajoutee a Live requests. COCKPIT_POOL_GUARD=0 pour desactiver.
-
Forensique au blocage (13:50): wrapper root sans argument
/usr/local/bin/qwen38-pyspy-scheduler(installe par install-dashboard.sh, ligne sudoers dediee) que le cockpit lance des qu'il declare un moteur « wedged »: piles Python du scheduler (py-spy, non bloquant) dans ~/.config/qwen38/wedge-.txt AVANT tout restart.COCKPIT_AUTOHEAL_GRACE(s) retarde le restart pour laisser le temps d'une autopsie manuelle (600 s sur la box de reference via drop-in systemd, 0 par defaut). Pool guard: se tait sur « pending requests » (400) et purge ses lectures. -
Sessions: 12 h fixes a partir du login (le navigateur de test s'est retrouve sur /login a 13:50 apres un login a 00:53: comportement voulu, pas un bug).
-
Correctif critique (14:33): le patch « grace » avait place audit, dump et autoheal dans la branche NON figee (dumps toutes les 2 s en service normal, aucun autoheal pendant le blocage de 14:15). La decision est maintenant une fonction pure (
lifecycle.wedge_plan, 5 tests) que le collecteur applique. Evidence native du blocage (gdb): thread principal du scheduler dans zmq_msg_recv/poll, boucle d'evenements qui spinne avec une requete en file jamais admise. -
15:50: etat de wedge PAR ACTIVATION. Des echecs de sonde herites d'une vie precedente avaient declare « wedged » un moteur sain 40 s apres son retour et l'autoheal l'a arrete en pleine requete. Remise a zero (compteurs, horloge, marqueur de progression) a chaque changement d'activation systemd, et aucune decision de wedge avant 180 s de « ready » (COCKPIT_WEDGE_MIN_READY_S).
Ajouts du 29/08 soir (revue rapide)
- Ceinture « plancher memoire » :
lifecycle.decide_mem_floor(pure, 4 tests), evaluee au tier 1 s ; sousCOCKPIT_MEM_FLOOR_GIB(3.0) avec des requetes en cours,abort_all+ audit + evenement, cooldown 60 s. Motif : 177k tokens a fraction 0.81 = 0.8 GiB disponibles et 15 refus noyau NVRM (bord du livelock). - Compteur des refus d'allocation du pilote (journalctl -k via une ligne sudoers lecture seule), tier 30 s, evenement quand il augmente ; affiche dans « Unified memory ».
- Le plafond « un prompt » du reservoir suit l'unite keepalive deployee (
PROMPT_CEILING_TOKENS), a defaut la part du pool (OVERSIZE_MARGIN_FRAC, le meme bouton que le proxy). - Fil des requetes : parseur pur
lifecycle.parse_feed(tests sur les vraies lignes du journal), detail du garde-fou (tokens comptes vs limite) sous le resultat. - Recipes (etape 4, lecture seule) :
recipes.py+/api/recipes+ panneau ; verification headlesstests/headless-check.mjs(cookie injecte par CDP, 0 exception) ; maquettes de deux directions design. - Ligne keepalive : version du proxy deploye et derive vs la copie du repo. Limites connues : la ceinture memoire ne voit que MemAvailable (pas la pression de reclaim) ; le compteur NVRM depend de sudoers ; le fil ne couvre que les 200 dernieres lignes du journal.
2026-08-30: health probe cadence
GET /health on both lane images is /health_generate: when the engine is idle it runs a
one-token generation. Polled at 1 Hz it produced 2,394 generations in the last hour of the
2026-08-30 flash instance, and the 01:15 GPU fault (Xid 31, illegal memory access in the QSA
indexer prefill) happened inside one of them. The 1 s tier now derives liveness from
/get_load (a lost HTTP layer is seen within a second) and asks /health every 2 s only
until it answers 200, then every 30 s (COCKPIT_HEALTH_RECHECK_S). The 90 s canary is
unchanged and remains the probe that tells a wedged scheduler from a healthy one.
2026-08-30 afternoon: navigation rebuilt, monkey-proofing, ten real defects
The owner's brief: primary actions at the top (no scrolling to switch), a collapsible left rail with tabs, explicit loading and stopping animations, explicit messages everywhere, and an app that survives people clicking everything several times.
Shape
Sticky top bar (brand, the serving lane at a glance, the whole action set, connection), a job strip under it that every tab and every browser sees, a collapsible rail with seven sections (Overview, Engines, Requests, Machine, Models, Logs, Setup) and per-section badges, then panels that each declare which collectors feed them.
Defects found and fixed (each verified at the source before and after)
app.jsdied on load withReferenceError: Cannot access 'loaded' before initializationwhenever the URL carried#models:showTab()runs at parse time and read aconstdeclared 640 lines below. Proven in isolation with node, now a regression test (reload on every hash).- A busy engine was reported as
startingand its own identity panel went blank: on this buildGET /healthis a generation, it queues behind the running request and times out every time. Liveness now comes from/get_loadreporting work in flight; the generating probe is only asked when the engine is idle. /get_server_infointermittently exceeded its 6 s timeout under a long prefill (three in a row measured, while the same endpoint answered in 0.19 s between two requests). The timeout is now 10 s, and a timeout no longer erases the engine facts: they are kept and the panel ages visibly. Only lifecycle decides that a lane is gone.- Panels looked fresh over frozen data: the ages came from the collector's last RUN, even a failed one, and did not grow when the stream died. Ages now come from the last SUCCESSFUL sample plus the time since the last payload.
- Engine actions (flush, abort, smoke) were clickable with no engine running and could
only fail. They are disabled with the reason, and
askActionrefuses them too. - Empty states shimmered like a loading state:
Running ...next toTokens in KV 0. Every field now names its state (no engine,no pool,idle). - The pool guard wrote one event per attempt and retried every 38 s (20 identical "flush failed: timed out" lines in the journal). One event per failure streak, a backoff that grows to 4 minutes, a required quiet period in the engine's own log, and the guard now says what it costs (the next long prompt prefills from scratch).
- A page opened while the cockpit was restarting fell back to 2 s polling and never tried the live stream again; SSE handlers could also be replaced while still firing. Both fixed and covered by the resilience test.
- The log source picker overwrote the user's choice 3 s after load; button tooltips were lost for good when the page loaded during a job; the lane pill forced a 10 px horizontal scroll at 390 px.
update_stackwas a button that raninstall.sh, which needs an interactive sudo a service cannot give: a half-applied install is the one failure this cockpit must never cause. It is now the exact terminal command, printed in Setup.
Rails that were added
Every action is one supervised job with a server-side lock, so a second click, a second
tab or the autoheal belt gets 409 busy naming the running job. The job strip, its log and
the history come from the server, so a reload never loses a job. A dry-run mode
(COCKPIT_DRY_RUN=1) confirms, logs and audits every action without executing anything,
and without probing the real engine.
Tests (all green on 2026-08-30)
tests/monkey-check.mjs: 43 checks. Every tab, a reload on every hash, the modal, a triple click, a confirm storm, 35 random clicks, the engine gate in both directions, the rail memory, 390 px. It refuses to run against a cockpit that is not in dry run.tests/resilience-check.mjs: 16 checks. It spawns its own cockpit, kills it, reads what the user would see (header, banner, stale panels, disabled actions, a forced click), then restarts it and proves the page recovers to the live stream without a reload.tests/smoke-http.sh18/18 (19 with both lanes installed and one active), 70 unit tests,tests/headless-check.mjswith zero console exception.
2026-09-03 evening: the Agent tab (opencode in the cockpit)
Shape
agent_relay.py(stdlib): one gate (cockpit session cookie, Origin check), one forwarder (exact Content-Length passthrough, re-chunking for unknown lengths so an event reaches the browser when opencode emits it, close-delimited for a 1.0 client), one tunnel (WebSocket for the terminal panel). Request hygiene: Cookie, Authorization, Referer and Host never pass; the relay's Basic credentials are added. Response hygiene: hop-by-hop, Date and Server dropped, a Set-Cookie named like the session dropped,frame-ancestorsadded.opencode-web.service.template+install-agent.sh: loopback server as the user, credentials generated once (0600), the user's PATH and theocoutput cap in the unit.install-dashboard.shnow reads bind, port and relay settings from the installed unit when the variables are not given.- The tab: state chip, version line (with "binary X installed, restart to serve it"), Open in a tab, Reload, Restart server; the frame is created on first open and kept.
Defects found while building (each fixed with a test)
- A deep link to
#agentthrew at parse time (showTabran before the agent helpers existed) and killed the whole script. The monkey check's tab list did not include the new tab, so it passed; it does now, andshowTabonly mounts on a live click. - Browsers fetch the web app manifest without credentials: it went 401 through the
relay.
/site.webmanifest(GET) passes without a session; it holds a name and icons. cmd | grep -qunderpipefailin the installer turned a perfectly goodserve --helpinto "no --hostname option" (grep exits early, the writer gets SIGPIPE). Captured into variables instead.
Tests (all green on 2026-09-03)
tests/test_agent_relay.py: 25 tests with a fake opencode (Basic auth, plain, chunked, server-sent events, WebSocket echo). Run with-W error::ResourceWarning: clean.tests/agent-check.mjs: 24 checks against the live cockpit through the tailnet address (tab framed and loaded through the relay, event stream up, no 4xx, direct open, gates).tests/smoke-http.sh30/30 (eleven relay checks),tests/monkey-check.mjs43/43 including the#agentdeep link,tests/headless-check.mjszero exception, local CI 26/26.- End to end on the box: a prompt through the relay reached the flash lane and came
back; a
bashtool call ran (echo cockpit-ok) with no permission prompt under opencode 1.18.27's defaults; the relay refused from the LAN and the docker bridge (no listener), 401 on the tailnet address without a session.
2026-09-09: the cockpit in a hand
What a phone was getting
tests/mobile-check.mjs (new) emulates four iPhone geometries (SE 375x667,
15 393x852, 15 Pro Max 430x932, 15 landscape 852x393) with device metrics, touch
and the device pixel ratio, walks every tab and measures: document
overflow, every element wider than the viewport that is not inside a scroller of
its own, form controls under 16 px, touch targets under 44x44, and the Agent
frame's box. First run: 64 of 132. There was no horizontal overflow anywhere,
which is the check that already existed at 390 px; everything else was new.
Read from the screenshots rather than from the numbers: the top bar and the rail wrapped into three rows each and spent 620 px of an 852 px screen before the first card, and the Agent tab's frame started at y=615, so a phone saw a 240 px sliver of opencode.
What changed
- One identity row plus a sideways-scrolling action row; the rail is one
swipeable row of pills, and
revealNav()keeps the current one in view. - 44x44 targets and 16 px controls below 980 px or on any coarse pointer, plus the login field (15 px, the first thing a phone sees).
dvheverywhere a full-height box was written invh, and--vvh/--vvtopfromwindow.visualViewportfor the fullscreen frame, which is the only thing that follows the iOS keyboard.- The Agent tab opens fullscreen on a phone unless the panel cannot load. opencode's own interface is already responsive (its media queries at 600 and 640 px, no overflow at 393 px, a mobile layout rendered): it only needed the whole screen.
Defects found while building (each one fixed with a gate)
- CSS specificity, and it was not a phone bug:
.agentnote:not([hidden]) + .agentframeweighs (0,3,0) because:not()counts its argument, so it beatbody.agentmax .agentframe(0,2,1) and fullscreen kept the embedded height whenever the relay note was visible. Measured on a 900 px desktop window: 682 px of "fullscreen".agent-check.mjsgained the gate, verified against the old CSS. - Source order: the first phone rules for the Agent tab were written inside a media block that sits before the rules they override. A media query adds no specificity, so they lost. They now live after their targets.
- Grid minimum:
grid-template-rows: auto 1frstill grows past the viewport, because a row's automatic minimum is its content.minmax(0,1fr)is what gives the frame a box to fill. - Flex line breaking: a scroller with
flex:1 1 autotook a row of its own, because a line breaks on the hypothetical size before shrinking applies. Basis 0. - A test that failed for the wrong reason: the first fullscreen gate set the note visible, clicked, then measured, and a state tick re-hid the note in between. Shown, measured and hidden inside one synchronous block instead.
Tests (all green on 2026-09-09)
tests/mobile-check.mjs136/136 against the tailnet address (Agent fullscreen, opencode really loaded), 132/132 against 127.0.0.1 (relay elsewhere: the note is shown and the embedded frame stays usable).tests/monkey-check.mjs43/43,tests/resilience-check.mjs16/16,tests/agent-check.mjs31/31,tests/headless-check.mjszero exception,tests/smoke-http.sh32/32, 160 unit tests, local CI 27/27.