hive-view
One browser page that shows every hive running on the Spark and lets Drake type into any of them.
It is a native program written in seeded Omega (.om), built by the pinned omc compiler from
aien-dev/omega-mv. The browser runs no script at all: every
page is HTML drawn by the server, and each panel refreshes itself.
Parent: aien-dev/omega-mv @ 943d955531b9d4d9f70deb41756c0b46441dd5e0 (compiler seed/out/omc,
sha256 5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df).
Using it
- Address:
http://spark.hub.internal:18190/(Tailscale) orhttp://127.0.0.1:18190/on the Spark. - Sign in once per browser with the one-time link
http://spark.hub.internal:18190/?t=<token>, where<token>is the 64 characters in~/.config/hive-view/tokenon the Spark. The link sets a cookie and sends you to the dashboard. Without that cookie every page answers "Not signed in". - The page shows, top to bottom:
- the queen (
omp-queen): its live screen and an input box; - one tile per
ompsession (found fromtmux lseach poll, never a fixed list): title, status line and last screenful. Clicking a tile opens/s/NAME: that session large, with its own input box; - Hermes: gateway up or down, the queen PAUSE file (shown verbatim), kanban counts per status and
the running cards; the
lead-*sessions as tiles; - Machine: load, memory, CPU busy %, GPU power and utilization from the spark-sensors log, the processes holding the GPU, the spark-window holder and queue, the core pool locks, and the Pearl ledger (newest entries verbatim);
- the BOARD (newest first, with a lane and text filter), the latest QUESTIONS and DECISIONS entries,
CLAIMS, and every other tmux session whose name uses only letters, digits,
-and_(others are skipped, since they could not be addressed safely).
- the queen (
- Freshness: session screens refresh every 2 to 3 seconds, the rest every 10 seconds. Every panel prints the age of its data and turns amber ("stale") or red ("down") when the poller stopped updating it. A panel the browser stops refreshing shows a red "NOT LIVE" bar after a few seconds; when the server is down each panel shows the browser's error page. Cached data is never shown as live.
Typing into a session
The input box sends exactly what you typed, then Enter ("Send + Enter"). The "Enter" and "Escape" buttons send that one key only; any text in the box is not typed. Nothing else can be sent: no other control keys, no commands.
- Text is one line of printable UTF-8, at most 4096 bytes. Control characters (including tab, newline, carriage return, Escape and DEL) and invalid UTF-8 are refused before anything is typed.
- The session must exist in a live
tmux lsat the moment of sending, and its name may only contain letters, digits,-and_. The text goes in withtmux send-keys -l(literal), in chunks of at most 2048 bytes; a chunk that ends in;is escaped so tmux does not treat it as a command separator. - After a send the page shows a green "Sent N bytes to NAME" or a red reason.
- Every send is logged to
~/.local/state/hive-view/sends.log: UTC time, session, action, byte count, sha256 of the text and the result. The text itself is never written anywhere. - Before anything is typed, the log is opened and an
attemptline is written in full; if either fails (directory missing, disk full, write error) the send is refused with code 8 and nothing is typed. After typing, a second line records the outcome (okortmux-failed). Bad text and a missing session are refused after the log is opened and logged as one line. A malformed request, a bad session name or action, and text over 4096 bytes are refused before the log is opened and are not logged (nothing about them reaches tmux).
Security
- The service listens only on
127.0.0.1:18190and100.64.0.2:18190(the Spark's Tailscale address): the unit passes exactly those two. The binary itself accepts only loopback127.0.0.1and addresses in Tailscale's100.64.0.0/10range (exit 4 for anything else). The Host header must be one of127.0.0.1:18190,100.64.0.2:18190,localhost:18190,spark.hub.internal:18190,spark:18190. - Every page except
/health,/app.cssand/palette.css(static stylesheets, no hive data) needs the cookiehv=<token>; the token file must be mode 600 and owned by the user, or the server refuses to start (exit 3). POST /sendadditionally needs anOriginheader equal to the page's own origin and a form key (sha256 of a fixed label and the token) that only the dashboard's own pages carry. Bodies over 16 KiB are refused with 413.- Responses carry `Content-Security-Policy: default-src 'none'; style-src 'self'; img-src 'self';
frame-src 'self'; form-action 'self'; frame-ancestors 'self'; base-uri 'none'` (no script can run),
X-Frame-Options: SAMEORIGIN,Referrer-Policy: same-origin,Cache-Control: no-store. - Session screens are rendered with every
& < > " 'escaped; terminal colours become CSS classes. - The machine panel names the processes that hold the GPU or a pool lock with their command line
(first 200 bytes). Any argument containing
key,token,secret,passw,authorcred(any case) is shown as***(after its=when it has one), and so is the argument that follows such a flag.
Load on the machine
One shared poller (nice 10, cores 0 to 2) refreshes everything, whatever the number of open pages.
It never queries the GPU (GPU numbers come from the existing spark-sensors log) and takes no pool
lock. It captures up to six panes per tmux call and skips panes whose activity time did not change;
it runs hermes kanban list only when the kanban database file changes (or every 5 minutes).
Measured on the Spark (gate cpu, 60 s, USER_HZ 100, two dashboard pages open). Runs 1 and 2 are
earlier builds of the same poller (server 9f70b61b… and 8e4ca0a1…); run 3 is server 12672fd8…
(deployed; the poller is unchanged in the current build):
| What | Ticks in 60 s | Share of one core | Share of the 20-core machine |
|---|---|---|---|
| hive-view (server, poller, handlers, their tmux clients), run 1 | 182 | 3.03 % | 0.15 % |
| hive-view, run 2 | 76 | 1.27 % | 0.063 % |
hive-view, run 3 (server 12672fd8…) | 171 | 2.85 % | 0.14 % |
| tmux server with hive-view running (runs 1, 2, 3) | 292, 255, 305 | ||
| tmux server with hive-view stopped (baseline) | 269 |
The tmux-server difference is within the run-to-run noise of the busy hive. Percentages computed
with Wolfram (N[182/(60*100)*100] -> 3.03, N[76/(60*100)*100] -> 1.27,
N[171/(60*100)*100] -> 2.85); the arithmetic and rounding are proven in Lean 4 in
evidence/cpu-shares.lean (toolchain and Mathlib pin in its header); details in evidence/.
Build
The build is one omc pass over the concatenated sources (the order matters: a name must be
defined before it is used). With O pointing at an aien-dev/omega-mv checkout at the pinned commit:
{ printf 'om2\n'; cat $O/seed/net/http.om $O/seed/net/notls.om $O/om/tls/sha2.om \
src/util.om src/run.om src/poll.om src/web.om src/page.om src/route.om src/main.om; } \
| $O/seed/out/omc > server && chmod +x server
{ printf 'om2\n'; cat $O/seed/net/http.om $O/seed/net/notls.om $O/om/tls/sha2.om \
src/util.om src/run.om tests/gate.om; } \
| $O/seed/out/omc > gate && chmod +x gate
build.json records the compiler, its sha256, the sha256 of each concatenated source and of the
resulting binaries for the committed revision.
Install, start, stop, roll back
install -d -m 700 ~/.local/share/hive-view/web ~/.local/state/hive-view
install -m 755 server ~/.local/share/hive-view/server
install -m 644 web/app.css ~/.local/share/hive-view/web/app.css
~/.local/share/hive-view/server mktoken # only if ~/.config/hive-view/token does not exist
install -m 644 deploy/hive-view.service ~/.config/systemd/user/hive-view.service
systemctl --user daemon-reload
systemctl --user enable --now hive-view.service
curl -s http://127.0.0.1:18190/health # prints ok
- Stop:
systemctl --user stop hive-view.service(nothing else depends on it; the hives keep running). - Restart after an upgrade: install the new
serverandapp.css, thensystemctl --user restart hive-view.service. - Roll back: keep the previous binary as
~/.local/share/hive-view/server.prev; to roll back,install -m 755 ~/.local/share/hive-view/server.prev ~/.local/share/hive-view/serverand restart. - Remove:
systemctl --user disable --now hive-view.service, delete the unit file and~/.local/share/hive-view. The token and the send log stay unless deleted by hand. - New token (signs every browser out): stop the service, delete
~/.config/hive-view/token, runserver mktoken, start the service.
The unit runs with Nice=10, CPUAffinity=0 1 2, Restart=on-failure, UMask=0077 and
NoNewPrivileges=yes; its run directory is $XDG_RUNTIME_DIR/hive-view and StateDirectory=hive-view
creates ~/.local/state/hive-view (mode 700) for the send log.
The gate
tests/gate.om is the acceptance gate, in Omega. Against a running server:
./gate run 18190 # 56 checks; prints PASS/FAIL per check, exit 0 only when all pass
./gate nolog 18190 # against a server whose send log cannot be used (run the gate with the
# server's HOME): a send must be refused with code 8, nothing typed. Two
# setups: no ~/.local/state/hive-view at all, and sends.log -> /dev/full
# (opens, every write fails with ENOSPC)
./gate cpu PID 60 # CPU ticks of server PID (with children) and of the tmux server over 60 s
gate run creates a tmux session hv-test whose program is /usr/bin/tee -a /tmp/hv-gate-sink on a
raw terminal, so every byte the dashboard types is recorded exactly. It checks sign-in, Host and
Origin checks, the form key, literal delivery of tricky texts (;, \;, -n, --, $(id), quotes,
UTF-8 and emoji, <script>, leading spaces, a 4096-byte text with ; at both chunk ends, a 4096-byte
text of 3-byte characters with one split by the chunk edge), Enter and Escape (also with text in the
box, which must not be typed), the send log (sha256 and byte count present, text absent), every
refusal (4097 bytes, control bytes, invalid and overlong UTF-8, unknown action, forged names,
duplicate or unknown fields, a body over 16 KiB), that <script> on a session screen is shown
escaped, that the QUESTIONS and DECISIONS panels answer with the whole page (with a fresh HOME this
covers a missing file), and that a deleted session is refused. It deletes hv-test and the sink at
the end.
Negative control: a server built without the ; escape in vwchunk (src/web.om) fails 6 of the 56
checks (every case that ends a chunk in ;). Results for the committed revision are in evidence/.
Outside programs
hive-view is pure Omega; at run time it starts these programs with exact argument lists (no shell):
| Program | Version on the Spark | What hive-view uses it for | Omega replacement |
|---|---|---|---|
/usr/bin/tmux | 3.4 | list sessions, capture panes, send-keys -l | none needed for observing the hive's own tmux; a persistent Omega client of tmux control mode (tmux -C) would remove the per-poll process start |
~/.local/bin/hermes | Hermes Agent v0.22.5 | hermes kanban list for the kanban counts and running cards | read kanban.db directly with an Omega SQLite page reader (proposal, not built) |
The service manager is outside hive-view too: deploy/hive-view.service is a systemd user unit
(systemd 255 on the Spark). systemd starts the server with the user manager (at boot, since linger
is on for this user), restarts it on failure, pins it to
cores 0 to 2 at nice 10 and creates ~/.local/state/hive-view (mode 700). Omega replacement: an
Omega supervisor (fork, wait, restart with backoff, sched_setaffinity, setpriority, makedir)
started from the user's session; proposal, not built. Note that omega-mv's standing rules say "No
systemd"; the hive-view brief asked for a systemd user unit, and that conflict is open with the queen.
The gate additionally starts /usr/bin/tee and /usr/bin/stty inside its own test session only.
No ORACLE is used or shipped.
Files
| Path | What |
|---|---|
src/util.om | buffers, paths, argument lists |
src/run.om | run a program (fork, execprog, pipes, deadline, reaping), read and atomically write files |
src/poll.om | the shared poller: writes one snapshot file per panel plus an index |
src/web.om | request checks, headers, sign-in, the send pipeline and its log |
src/page.om | HTML: pages, panels, terminal colours, the BOARD and entries, palette CSS |
src/route.om | POST /send form handling, the route table, the per-connection loop |
src/main.om | entry points: serve, mktoken, poll-once |
web/app.css | the stylesheet |
tests/gate.om | the acceptance gate |
deploy/hive-view.service | systemd user unit |
evidence/ | gate, negative-control and CPU results for a revision |