Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hive-view/blob/main/README.md # hive-view aien-dev/hive-view Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `hive-view / README.md` 208 lines · 13308 bytes Raw Blame History Source # 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) or `http://127.0.0.1:18190/` on the Spark. - Sign in once per browser with the one-time link `http://spark.hub.internal:18190/?t=`, where `` is the 64 characters in `~/.config/hive-view/token` on 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 `omp` session (found from `tmux ls` each 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). - 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 ls` at the moment of sending, and its name may only contain letters, digits, `-` and `_`. The text goes in with `tmux 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 `attempt` line 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 (`ok` or `tmux-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:18190` and `100.64.0.2:18190` (the Spark's Tailscale address): the unit passes exactly those two. The binary itself accepts only loopback `127.0.0.1` and addresses in Tailscale's `100.64.0.0/10` range (exit 4 for anything else). The Host header must be one of `127.0.0.1:18190`, `100.64.0.2:18190`, `localhost:18190`, `spark.hub.internal:18190`, `spark:18190`. - Every page except `/health`, `/app.css` and `/palette.css` (static stylesheets, no hive data) needs the cookie `hv=`; the token file must be mode 600 and owned by the user, or the server refuses to start (exit 3). - `POST /send` additionally needs an `Origin` header 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`, `auth` or `cred` (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 `server` and `app.css`, then `systemctl --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/server` and 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`, run `server 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, `