interplane.Get Omega
Read in your language

hive-view

aien-dev/hive-view

Brought by drakestapleton

hive-view v1: no-script dashboard of every hive, in pure seeded Omega

open 77cd165e47162ae4 #1 · opened 2026-11-07 08:08 UTC

Imported from GitHub aien-dev/hive-view#1, by drakestapleton

Base e17acf9bcd535302ad8fb8a9fe6a8e43c7172d17 · Head 0971680f4cb07049bea8f515f8d15626933b4731

drakestapleton wrote on 2026-11-07 08:08 UTC

What

One browser page showing every hive on the Spark, with an input box per session. Native program in pure seeded Omega, built by aien-dev/omega-mv@943d9555 seed/out/omc (sha256 5f90edea…f6df). The browser runs no script: the server renders HTML, and panels refresh with <meta refresh> inside iframes. Brief: ~/handoffs/hive/hiveview/BRIEF.md. Directive: ~/handoffs/hive/queen/DIRECTIVE-20261107-pure-omega.md.

  • Panels: queen (omp-queen) with input, one tile per omp session from tmux ls, Hermes (gateway, PAUSE, kanban counts, running cards), lead-* tiles, machine (load, memory, CPU %, GPU from the spark-sensors log, spark-window, pool locks, Pearl ledger verbatim), BOARD (newest first, lane filter), QUESTIONS, DECISIONS, CLAIMS.
  • Freshness: panes every 2 to 3 s, the rest every 10 s. Each panel shows its age and stale or down state. A "NOT LIVE" bar appears when the browser stops refreshing.
  • The only write: tmux send-keys -l of the typed text (≤ 4096 bytes, printable UTF-8), or one Enter or one Escape, into a session present in a live tmux ls.
    • Each attempt is logged with time, session, bytes and sha256. The text itself is never logged.
  • Access: binds 127.0.0.1 and 100.64.0.2:18190.
    • Pages need the token cookie, set through /?t= from ~/.config/hive-view/token (mode 600).
    • /send also needs the page's own Origin and the form key.
    • The CSP has no script-src.
  • Machine impact: one shared poller at nice 10 on cores 0 to 2. No GPU queries, no pool locks.

Evidence (evidence/2026-11-07-v1.md)

CheckResult
gate run 18190 (tests/gate.om, 52 checks, real tmux and tee sink)EXERCISED: 52 passed, 0 failed
Negative control: server without the trailing-; escape in vwchunk46 passed, 6 failed, exactly the ; chunk-end cases
CPU, two pages open, 60 sMEASURED: 182 and 76 ticks, i.e. 3.03 % and 1.27 % of one core (Wolfram)
Chrome: desktop, 390 px phone, a form send, server-down viewEXERCISED
Two buildsbyte-identical; build.json pins compiler, sources and binaries

CI (gate-arm64) rebuilds on ubuntu-24.04-arm with the pinned omc, checks the binaries against build.json byte for byte, and runs the gate against a live server.

Not in this PR

  • Deployment as hive-view.service. The unit is in deploy/ and is installed after merge.
  • Outside programs still used at run time, recorded in README with their Omega replacement (proposed, not built):
    • tmux 3.4;
    • hermes CLI v0.22.5 (kanban list).

Apply it

git checkout -b patch-77cd165e47162ae4 e17acf9bcd535302ad8fb8a9fe6a8e43c7172d17
curl -fsSL https://interplane.io/drakestapleton/hive-view/patches/77cd165e47162ae4.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/hive-view
1
0971680f4cb07049bea8f515f8d15626933b4731
{"kind":"github-import","owner":"aien-dev","repo":"hive-view","number":1,"url":"https://github.com/aien-dev/hive-view/pull/1","export_sha256":"b3200e35c2cc053cbbcdd2d57964912ca94a7d3b49a7204fc76223ab8a576d5a","imported_utc":"2026-11-18T16:40:00Z"}

Changes

diff --git a/.crumb b/.crumb
new file mode 100644
index 0000000..37798a4
--- /dev/null
+++ b/.crumb
@@ -0,0 +1,87 @@
+{
+  "below": [
+    {
+      "name": "deploy",
+      "role": "systemd user unit"
+    },
+    {
+      "name": "src",
+      "role": "the Omega server: poller, HTTP, pages, send pipeline"
+    },
+    {
+      "name": "tests",
+      "role": "the Omega acceptance gate and CPU meter"
+    },
+    {
+      "name": "web",
+      "role": "the stylesheet"
+    }
+  ],
+  "extensions": {
+    "generated": {
+      "children": [
+        {
+          "digest": "6d4f086d745a5963040e86fea4a8396d5f31fe4b25358aec184892343581a8f6",
+          "last_commit": "4c211f8",
+          "name": "deploy",
+          "purpose": "The systemd user unit hive-view.service: nice 10, cores 0-2, restart on failure, run directory $"
+        },
+        {
+          "digest": "1d0c4725bc2d3044352b5a971f2da1639cdca11080621a78754aeb68680e224a",
+          "last_commit": "551b10f",
+          "name": "src",
+          "purpose": "The hive-view server in seeded Omega, concatenated in the order util, run, poll, web, page, rout"
+        },
+        {
+          "digest": "df49ed1d5aac308410cb69b54d02f1725f9798179603b44219504f3e134ac6be",
+          "last_commit": "4c211f8",
+          "name": "tests",
+          "purpose": "gate.om, the acceptance gate in Omega: 52 checks against a running server through a tee sink ses"
+        },
+        {
+          "digest": "75fe0e0530b97483a04ac5eb4dcb53a30a757697ff50e271804d2dbf1f7feffe",
+          "last_commit": "999ab19",
+          "name": "web",
+          "purpose": "app.css, the only static file the server sends; presentation only, no script."
+        }
+      ],
+      "children_root": "sha256:4adb2fa773ee9eaecc8840bbde02cbfec03b700665a358af39cfe9b2009ac117",
+      "compiled_at": "2026-11-07T08:22:22Z",
+      "compiler": "crumb-compile/1",
+      "digest": "sha256:0ea0d96ac15b5320f24bc21a8e9a7eb6376cc861256da864c515a20c61502834",
+      "evidence_files": 7,
+      "evidence_root": "sha256:3ca16e97ebf4a20dfb8bf7d74721d1b1dc1457644b0d26fdb93654b1058e8173",
+      "files": 24,
+      "generated_at_commit": "81edf3ede775eb7b8450e50fdd166d386fdb32e6",
+      "source_tree": "sha256:0aeb78fed7d9d5c66e9cabe1f931bcc16b038dd7dac75209e5094b47616e10e3"
+    },
+    "owner_lane": "hiveview",
+    "parent": {
+      "commit": "943d955531b9d4d9f70deb41756c0b46441dd5e0",
+      "omc_sha256": "5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df",
+      "repo": "aien-dev/omega-mv"
+    },
+    "seed": {
+      "files": [
+        "README.md"
+      ],
+      "git": {
+        "branch": "main",
+        "head": "",
+        "remote": ""
+      },
+      "purpose_auto": "Repository root hive-view. Purpose not yet described by a human."
+    }
+  },
+  "invariants": [
+    "All first-party implementation is .om built by the pinned omega-mv seed/out/omc; no C, shell, Python or JavaScript implementation or test driver.",
+    "The only side effect on the hive is tmux send-keys -l of the typed text, Enter or Escape into a session present in a live tmux ls; every attempt is logged with bytes and sha256, never the text.",
+    "Binds only 127.0.0.1 and 100.64.0.2; every page except /health needs the token cookie; /send also needs the page Origin and the form key.",
+    "One shared poller at nice 10 on cores 0-2; it never queries the GPU and takes no pool lock.",
+    "Cached data is never shown as live: every panel shows its age and stale or down state."
+  ],
+  "layer": "tool",
+  "name": "hive-view",
+  "purpose": "One browser dashboard of every hive on the Spark (queen, omp sessions, Hermes, lead sessions, machine, BOARD, QUESTIONS, DECISIONS, CLAIMS), served by a native pure seeded Omega program built by the pinned omc from aien-dev/omega-mv. The browser runs no script. Its only write is Drake's literal typed text (or one Enter or Escape) sent into a live tmux session.",
+  "schema_version": "1.0.0"
+}
diff --git a/.crumbignore b/.crumbignore
new file mode 100644
index 0000000..19993ca
--- /dev/null
+++ b/.crumbignore
@@ -0,0 +1 @@
+evidence
diff --git a/.github/workflows/gate-arm64.yml b/.github/workflows/gate-arm64.yml
new file mode 100644
index 0000000..6941a3e
--- /dev/null
+++ b/.github/workflows/gate-arm64.yml
@@ -0,0 +1,61 @@
+# gate-arm64: build hive-view and its gate with the pinned omc on a GitHub-hosted ARM64 machine,
+# check the binaries match build.json byte for byte, then run the 52-check gate against a live
+# server (127.0.0.1 only) with a real tmux. The steps below are glue around the Omega programs;
+# every check lives in tests/gate.om.
+name: gate-arm64
+on:
+  pull_request:
+  push:
+    branches: [main]
+permissions:
+  contents: read
+jobs:
+  gate:
+    runs-on: ubuntu-24.04-arm
+    timeout-minutes: 20
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+      - name: omega-mv at omega-mv.lock
+        run: |
+          sha=$(awk 'NF && $1 !~ /^#/ {print $1; exit}' omega-mv.lock)
+          git clone --quiet --filter=blob:none https://github.com/aien-dev/omega-mv.git ../omega-mv
+          git -C ../omega-mv checkout --quiet --detach "$sha"
+          want=$(awk 'NF && $1 !~ /^#/ {print $2; exit}' omega-mv.lock)
+          got=$(sha256sum < ../omega-mv/seed/out/omc | cut -c1-64)
+          echo "omc sha256 $got"; test "$got" = "$want"
+      - name: tmux
+        run: sudo apt-get install -y -q tmux >/dev/null && tmux -V && uname -a && nproc
+      - name: build server and gate
+        run: |
+          O=../omega-mv
+          { 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
+          sha256sum server gate
+          for b in server gate; do
+            want=$(grep -A3 "\"$b\"" build.json | sed -n 's/.*"binary_sha256": "\([0-9a-f]*\)".*/\1/p')
+            got=$(sha256sum < $b | cut -c1-64)
+            echo "$b build.json $want built $got"; test "$got" = "$want"
+          done
+      - name: gate nolog (no ~/.local/state/hive-view yet, so a send must be refused with code 8)
+        run: |
+          ./server mktoken
+          test ! -e ~/.local/state/hive-view
+          mkdir -p "$RUNNER_TEMP/hv-run"
+          (cd web && exec ../server serve "$RUNNER_TEMP/hv-run" 18190 127.0.0.1 > "$RUNNER_TEMP/server-nolog.log" 2>&1) &
+          for i in $(seq 50); do curl -fs http://127.0.0.1:18190/health && break; sleep 0.2; done
+          ./gate nolog 18190
+          pkill -f 'server serve' && sleep 1
+      - name: start the server (state directory created as the README install does)
+        run: |
+          install -d -m 700 ~/.local/state/hive-view
+          (cd web && exec nohup ../server serve "$RUNNER_TEMP/hv-run" 18190 127.0.0.1 > "$RUNNER_TEMP/server.log" 2>&1) &
+          for i in $(seq 50); do curl -fs http://127.0.0.1:18190/health && break; sleep 0.2; done
+      - name: gate
+        run: ./gate run 18190
+      - name: stop
+        if: always()
+        run: pkill -f 'server serve' || true; cat "$RUNNER_TEMP"/server*.log || true
diff --git a/.goals.json b/.goals.json
new file mode 100644
index 0000000..95caac5
--- /dev/null
+++ b/.goals.json
@@ -0,0 +1,36 @@
+{
+  "project_name": "hive-view",
+  "parent": {
+    "repo": "aien-dev/omega-mv",
+    "commit": "943d955531b9d4d9f70deb41756c0b46441dd5e0"
+  },
+  "goals": [
+    {
+      "id": "v1",
+      "title": "V1: one no-script dashboard of every hive, in pure seeded Omega",
+      "description": "Queen with input, one tile per omp session from tmux ls, Hermes, lead sessions, machine, BOARD, QUESTIONS, DECISIONS, CLAIMS; ages and stale/down state; literal typed text into a live session as the only write.",
+      "status": "Active",
+      "milestones": [
+        {"id": 1, "description": "server, poller and pages in .om; browser runs no script", "completed": true},
+        {"id": 2, "description": "gate.om 52/52 on the Spark, negative control fails as expected, CPU measured", "completed": true},
+        {"id": 3, "description": "checked in real Chrome (desktop, phone width, server down)", "completed": true},
+        {"id": 4, "description": "CI green on the exact head; independent signed review", "completed": false},
+        {"id": 5, "description": "merged by the desk; deployed as hive-view.service; URL posted", "completed": false}
+      ],
+      "created_at": "2026-11-07T00:00:00Z",
+      "updated_at": "2026-11-07T08:10:00Z"
+    },
+    {
+      "id": "v2",
+      "title": "V2: drop the remaining outside programs from the poll path",
+      "description": "Proposed, not built: an Omega client of tmux control mode instead of one tmux process per poll, and an Omega SQLite page reader for kanban.db instead of the hermes CLI.",
+      "status": "Proposed",
+      "milestones": [
+        {"id": 1, "description": "tmux control-mode client in .om (persistent connection)", "completed": false},
+        {"id": 2, "description": "read-only SQLite page reader in .om for the kanban board", "completed": false}
+      ],
+      "created_at": "2026-11-07T08:10:00Z",
+      "updated_at": "2026-11-07T08:10:00Z"
+    }
+  ]
+}
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..52e9ce3
--- /dev/null
+++ b/README.md
@@ -0,0 +1,177 @@
+# 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`](https://github.com/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=<token>`, where
+  `<token>` 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.
+- 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. 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.
+- The send log is opened before anything is typed. If it cannot be opened (for example the
+  directory `~/.local/state/hive-view` is missing), the send is refused and nothing is typed.
+- Every attempt 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.
+
+## Security
+
+- Listens only on `127.0.0.1:18190` and `100.64.0.2:18190` (the Spark's Tailscale address). 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` needs the cookie `hv=<token>`; 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.
+
+## 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), two runs:
+
+| 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 % |
+| tmux server with hive-view running (run 1, run 2) | 292, 255 | | |
+| 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`); 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:
+
+```sh
+{ 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
+
+```sh
+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:
+
+```sh
+./gate run 18190        # 52 checks; prints PASS/FAIL per check, exit 0 only when all pass
+./gate nolog 18190      # against a server whose HOME has no ~/.local/state/hive-view (run the gate
+                        # with that same HOME): a send must be refused with code 8, nothing typed
+./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), Enter and
+Escape, 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, 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 52
+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 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 |
diff --git a/build.json b/build.json
new file mode 100644
index 0000000..70c2e70
--- /dev/null
+++ b/build.json
@@ -0,0 +1,92 @@
+{
+  "compiler": "aien-dev/omega-mv@943d955531b9d4d9f70deb41756c0b46441dd5e0 seed/out/omc",
+  "compiler_sha256": "5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df",
+  "build": "printf 'om2\\n' then cat the sources in the listed order, piped into omc; output is the ELF binary",
+  "reproducible": "two builds on the Spark gave byte-identical binaries",
+  "binaries": {
+    "server": {
+      "binary_sha256": "f86347591c5e51f172eb12eca7c95b65efa13ee43a14c61385e1f2938b161349",
+      "binary_bytes": 291136,
+      "compile_rc": 0,
+      "sources": [
+        {
+          "path": "(first line: om2)"
+        },
+        {
+          "path": "omega-mv:seed/net/http.om",
+          "sha256": "7bf2aa428b6c2f4524ac97a6f372434230a530cf2e15844cd393abe4f7ea141a"
+        },
+        {
+          "path": "omega-mv:seed/net/notls.om",
+          "sha256": "f6d30fb97893b795338a447ada6be447755250c4a9d479c4a019ac7d8ee166eb"
+        },
+        {
+          "path": "omega-mv:om/tls/sha2.om",
+          "sha256": "5cf0f98116def6917d3a373f2bd4c3932d46e3ff84d9567bbae9e720366fdb33"
+        },
+        {
+          "path": "src/util.om",
+          "sha256": "016eda20b11fff486e3c3efd3e8448d6378c59aa349e771550a078950cc48577"
+        },
+        {
+          "path": "src/run.om",
+          "sha256": "95f59510ba00b6c111949009b9b831f9b05670fe278c195e2a50884ad87f3cfe"
+        },
+        {
+          "path": "src/poll.om",
+          "sha256": "0566e1f7af464022a0dae023c6e7fe9a2c2aa7e75cc70c9795f6e6abaf73773d"
+        },
+        {
+          "path": "src/web.om",
+          "sha256": "28612a2cbbf2d7e290b0771a9043153a1f7f65e4b683b6adbf12b5ac2aaacffb"
+        },
+        {
+          "path": "src/page.om",
+          "sha256": "a5a11ad8e1cf1050ad33a03a1effde6756222caac7e6f64a0552e6db815c8565"
+        },
+        {
+          "path": "src/route.om",
+          "sha256": "87f4a1f620e4ecf2bba41fa666526049b6f680ffdf92e87d2c6cbaef6dbbc0be"
+        },
+        {
+          "path": "src/main.om",
+          "sha256": "2dbe3636229d0d116bceb01a6457167cc4ed94ab15ee4623b045ae9d2a0e1916"
+        }
+      ]
+    },
+    "gate": {
+      "binary_sha256": "ce990ebb6aaa937b3d281f3374226215668561a272e9393cfe8522c9a1455e83",
+      "binary_bytes": 152400,
+      "compile_rc": 0,
+      "sources": [
+        {
+          "path": "(first line: om2)"
+        },
+        {
+          "path": "omega-mv:seed/net/http.om",
+          "sha256": "7bf2aa428b6c2f4524ac97a6f372434230a530cf2e15844cd393abe4f7ea141a"
+        },
+        {
+          "path": "omega-mv:seed/net/notls.om",
+          "sha256": "f6d30fb97893b795338a447ada6be447755250c4a9d479c4a019ac7d8ee166eb"
+        },
+        {
+          "path": "omega-mv:om/tls/sha2.om",
+          "sha256": "5cf0f98116def6917d3a373f2bd4c3932d46e3ff84d9567bbae9e720366fdb33"
+        },
+        {
+          "path": "src/util.om",
+          "sha256": "016eda20b11fff486e3c3efd3e8448d6378c59aa349e771550a078950cc48577"
+        },
+        {
+          "path": "src/run.om",
+          "sha256": "95f59510ba00b6c111949009b9b831f9b05670fe278c195e2a50884ad87f3cfe"
+        },
+        {
+          "path": "tests/gate.om",
+          "sha256": "678c6e531c8553616d81b192847d5cebd4260405b65949c3587a0ecf45cd56cf"
+        }
+      ]
+    }
+  }
+}
diff --git a/deploy/.crumb b/deploy/.crumb
new file mode 100644
index 0000000..6c8887c
--- /dev/null
+++ b/deploy/.crumb
@@ -0,0 +1,31 @@
+{
+  "above": {
+    "name": "hive-view",
+    "path": ".."
+  },
+  "extensions": {
+    "generated": {
+      "children": [],
+      "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "compiled_at": "2026-11-07T08:14:29Z",
+      "compiler": "crumb-compile/1",
+      "digest": "sha256:6d4f086d745a5963040e86fea4a8396d5f31fe4b25358aec184892343581a8f6",
+      "evidence_files": 0,
+      "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "files": 1,
+      "generated_at_commit": "999ab195c49c95eed49c01c1e0506ca21ef0f411",
+      "source_tree": "sha256:bf69607970858f8a34185aece0ac1cca6f929c0c7c9082ae3e31fcef11eb9484"
+    },
+    "owner_lane": "",
+    "seed": {
+      "files": [
+        "hive-view.service"
+      ],
+      "purpose_auto": "Directory deploy. Purpose not yet described by a human."
+    }
+  },
+  "layer": "deploy",
+  "name": "deploy",
+  "purpose": "The systemd user unit hive-view.service: nice 10, cores 0-2, restart on failure, run directory $XDG_RUNTIME_DIR/hive-view, port 18190 on 127.0.0.1 and 100.64.0.2.",
+  "schema_version": "1.0.0"
+}
diff --git a/deploy/hive-view.service b/deploy/hive-view.service
new file mode 100644
index 0000000..1b1ce77
--- /dev/null
+++ b/deploy/hive-view.service
@@ -0,0 +1,23 @@
+# hive-view: the hive dashboard (pure seeded Omega). Install: see README.md "Install".
+[Unit]
+Description=hive-view dashboard of every hive (127.0.0.1 and 100.64.0.2, port 18190)
+After=network-online.target
+StartLimitIntervalSec=0
+
+[Service]
+Type=simple
+WorkingDirectory=%h/.local/share/hive-view/web
+ExecStart=%h/.local/share/hive-view/server serve %t/hive-view 18190 127.0.0.1 100.64.0.2
+RuntimeDirectory=hive-view
+RuntimeDirectoryMode=0700
+StateDirectory=hive-view
+StateDirectoryMode=0700
+Nice=10
+CPUAffinity=0 1 2
+Restart=on-failure
+RestartSec=10
+UMask=0077
+NoNewPrivileges=yes
+
+[Install]
+WantedBy=default.target
diff --git a/evidence/2026-11-07-v1.md b/evidence/2026-11-07-v1.md
new file mode 100644
index 0000000..12aae7a
--- /dev/null
+++ b/evidence/2026-11-07-v1.md
@@ -0,0 +1,88 @@
+# hive-view v1 evidence, 2026-11-07 (Spark, GB10, Ubuntu arm64)
+
+Binaries (built by omega-mv@943d9555 `seed/out/omc`, sha256 `5f90edea…f6df`; two builds byte-identical):
+
+| Binary | sha256 |
+|---|---|
+| server (committed head) | `f86347591c5e51f172eb12eca7c95b65efa13ee43a14c61385e1f2938b161349` |
+| server before the mktoken message change | `796d96c67968c88231f292c05e2ffed81d95f0791b415b0d8f078c618d81b3ed` |
+| gate | `ce990ebb6aaa937b3d281f3374226215668561a272e9393cfe8522c9a1455e83` |
+| negative-control server (no `;` escape in `vwchunk`) | `732c2bc3f2a1e01f452f467058c349703c18f0bc6fcfdac370a9613b2e2598d2` |
+
+`gate-run.txt`, the negative control and `gate-nolog.txt` ran against server `796d96c6…` (its
+sources differ from the head only in `vwmktok`'s error message). The local CI replay and the
+deployed service below ran the head server `f8634759…`. The Chrome checks ran against server
+`9f70b61b…3ef41` and CPU run 2 against `8e4ca0a1…d802`; the head sources differ from those only by
+removed unused names, the send-log change and the mktoken message.
+
+## GitHub CI: NOT_RUN for the head (commits after `551b10f` change only `evidence/` and the generated block of the root `.crumb`)
+
+The first run (head `999ab19`) failed 2 of 52 and found the two defects described below. No run
+started for later heads: GitHub Actions has been blocked org-wide since about 08:16Z (BOARD
+2026-11-07T08:20:48Z, "owner marked spammy"). Local replay of `.github/workflows/gate-arm64.yml` at
+head `551b10f` on the Spark (fresh clone, omc taken from omega-mv `943d9555` git objects and checked
+against `omega-mv.lock`, a fresh HOME holding only `~/.config`, port 18196): server and gate sha256
+equal `build.json` (MATCH, MATCH); `mktoken` exit 0; `gate nolog` 5 passed, 0 failed; after
+`install -d -m 700 ~/.local/state/hive-view`, `gate run` 52 passed, 0 failed. This is a local
+replay, not a GitHub result.
+
+## Deployed (DEPLOYED on the Spark, not merged)
+
+`deploy/hive-view.service` installed as a systemd user unit with the head server; `systemctl --user`
+shows active, the main process has nice 10 and `Cpus_allowed_list 0-2`; `/health` answers on
+127.0.0.1 and 100.64.0.2. `kill -KILL` of the main process: restarted after RestartSec (NRestarts=1),
+`/health` ok. `gate run 18190` against the deployed service: 52 passed, 0 failed. Chrome on
+`http://spark.hub.internal:18190/` showed the live queen screen and the omp tiles.
+
+## Gate (EXERCISED)
+
+`gate run 18190` against the server above, started as
+`taskset -c 0-2 nice -n 10 server serve RUNDIR 18190 127.0.0.1 100.64.0.2` from `web/`:
+52 passed, 0 failed, exit 0. Output: `gate-run.txt`.
+
+Negative control: the same gate against the negative-control server on port 18198: 46 passed,
+6 failed, exit 1. The six failures are exactly the cases where a chunk ends in `;`
+(`semi;`, `;`, `;;`, `\;`, `bs\;`, the 4096-byte text with `;` at both chunk ends). Output:
+`gate-negative-control.txt`.
+
+Send log unavailable (found by the first CI run): the first runner had no `~/.local/state/hive-view`,
+and the server then typed the text and only failed to log it afterwards. The server now opens the
+log before typing and refuses with code 8 when it cannot. `gate nolog`, run with a HOME holding only
+the token, against the server binary from before the change: 4 passed, 1 failed (the text was
+typed); against the server above: 5 passed, 0 failed (`gate-nolog.txt`). CI runs the same check
+before creating the state directory.
+
+Gate fix (also found by the first CI run): the "wrong cookie" check replaced the token's first
+character with `0`, which is the real token whenever that already starts with `0` (1 token in 16;
+inferred cause of the CI failure, since the runner's token is not shown). It now writes `1` in that case.
+
+## CPU (MEASURED)
+
+`gate cpu PID 60` (USER_HZ 100), two dashboard pages open in Chrome (1400x1000 and a 390x844 phone
+viewport) for the whole minute. Run 1 used server `9f70b61b…`, run 2 the committed server:
+
+| What | Run 1, ticks in 60 s | Run 2, ticks in 60 s |
+|---|---|---|
+| hive-view main + poller + connection handlers (with reaped children) | 182 | 76 |
+| tmux server, hive-view running | 292 | 255 |
+| tmux server, hive-view stopped (baseline, minute after run 1) | 269 | |
+
+WolframLanguageEvaluator: `N[182/(60*100)*100] -> 3.03` and `N[76/(60*100)*100] -> 1.27` (% of one
+core); `N[182/(60*100*20)*100] -> 0.152` and `N[76/(60*100*20)*100] -> 0.0633` (% of 20 cores);
+`N[(292-269)/(60*100)*100] -> 0.383`. Likely cause of the spread (inferred, not measured): how many
+session screens changed during the minute, since unchanged panes are not captured again.
+
+## Chrome (EXERCISED, headless Chromium managed by omp)
+
+- `http://spark.hub.internal:18190/?t=<token>` signed in (302, cookie) and showed the queen screen with
+  colours, the omp tiles in a grid, Hermes (gateway up, PAUSE line verbatim, kanban chips, running
+  card), lead tiles, machine (load, memory, CPU %, GPU power/utilization from spark-sensors, GPU holders,
+  spark-window holder and queue, pool locks, Pearl ledger absent), BOARD, QUESTIONS, DECISIONS,
+  CLAIMS and other sessions.
+- `/s/hv-test` form: "chrome says hi; ünï <b>" arrived in the sink byte for byte followed by LF; the
+  page showed "Sent 25 bytes to hv-test, then pressed Enter."
+- The queen form on `/` targets `omp-queen` (hidden field checked; nothing was sent to the queen).
+- Phone width 390 px: no horizontal page scroll (scrollWidth 390), terminal panes scroll inside
+  their box, buttons full height.
+- Server stopped with the page open: after 15 s the status bar and every panel showed the browser's
+  "can't be reached" page; no panel kept showing old data as live.
diff --git a/evidence/ci-replay-gate-nolog.txt b/evidence/ci-replay-gate-nolog.txt
new file mode 100644
index 0000000..7ac5ce8
--- /dev/null
+++ b/evidence/ci-replay-gate-nolog.txt
@@ -0,0 +1,6 @@
+PASS the one-time link answers 302 and sets the token cookie
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS with the send log unwritable the send is refused (m=8), nothing typed
+PASS test session hv-test deleted
+gate: 5 passed, 0 failed
diff --git a/evidence/ci-replay-gate-run.txt b/evidence/ci-replay-gate-run.txt
new file mode 100644
index 0000000..1d99114
--- /dev/null
+++ b/evidence/ci-replay-gate-run.txt
@@ -0,0 +1,53 @@
+PASS health answers 200 without auth
+PASS GET / without the cookie is refused (403)
+PASS a panel without the cookie is refused (403)
+PASS a wrong cookie is refused (403)
+PASS a wrong one-time link is refused (403)
+PASS the one-time link answers 302 and sets the token cookie
+PASS a foreign Host header is refused (400)
+PASS GET /send is refused (405)
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS POST /send without the cookie is refused (403)
+PASS POST /send without an Origin header is refused (403)
+PASS POST /send from a foreign Origin is refused (403)
+PASS POST /send with a wrong form key is refused (403)
+PASS nothing reached the session from the refused posts
+PASS semi;
+PASS ;
+PASS ;;
+PASS -n
+PASS --
+PASS $(id) `id` 'q' "dq" & | > <
+PASS é ü 漢字 🐝
+PASS <script>alert(1)</script>
+PASS    leading and trailing spaces   
+PASS %41+%20&a=escape
+PASS send-keys -t =omp-queen: Enter
+PASS literal backslash-semicolon inside the text
+PASS literal backslash-semicolon alone
+PASS text ending in backslash-semicolon
+PASS 4096-byte text (the limit) with semicolons at the chunk edges
+PASS Enter button sends one Enter
+PASS Escape button sends one Escape
+PASS marker text typed
+PASS send log names the byte count and sha256 of the text
+PASS send log never contains the text
+PASS 4097-byte text refused (m=7), nothing typed
+PASS control byte 0x01 refused (m=4), nothing typed
+PASS newline inside the text refused (m=4), nothing typed
+PASS DEL refused (m=4), nothing typed
+PASS invalid UTF-8 byte 0xff refused (m=4), nothing typed
+PASS overlong UTF-8 refused (m=4), nothing typed
+PASS carriage return refused (m=4), nothing typed
+PASS tab refused (m=4), nothing typed
+PASS escape byte inside the text refused (m=4), nothing typed
+PASS unknown action refused (m=3), nothing typed
+PASS malformed and forged session names refused (m=2), nothing typed
+PASS duplicate or unknown form fields refused (m=1), nothing typed
+PASS a body over 16 KiB is refused (413), nothing typed
+PASS <script> on a session screen is shown escaped, never as markup
+PASS test session hv-test deleted
+PASS typing into the deleted session is refused (m=5)
+PASS hv-test no longer exists
+gate: 52 passed, 0 failed
diff --git a/evidence/deployed-gate-run.txt b/evidence/deployed-gate-run.txt
new file mode 100644
index 0000000..1d99114
--- /dev/null
+++ b/evidence/deployed-gate-run.txt
@@ -0,0 +1,53 @@
+PASS health answers 200 without auth
+PASS GET / without the cookie is refused (403)
+PASS a panel without the cookie is refused (403)
+PASS a wrong cookie is refused (403)
+PASS a wrong one-time link is refused (403)
+PASS the one-time link answers 302 and sets the token cookie
+PASS a foreign Host header is refused (400)
+PASS GET /send is refused (405)
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS POST /send without the cookie is refused (403)
+PASS POST /send without an Origin header is refused (403)
+PASS POST /send from a foreign Origin is refused (403)
+PASS POST /send with a wrong form key is refused (403)
+PASS nothing reached the session from the refused posts
+PASS semi;
+PASS ;
+PASS ;;
+PASS -n
+PASS --
+PASS $(id) `id` 'q' "dq" & | > <
+PASS é ü 漢字 🐝
+PASS <script>alert(1)</script>
+PASS    leading and trailing spaces   
+PASS %41+%20&a=escape
+PASS send-keys -t =omp-queen: Enter
+PASS literal backslash-semicolon inside the text
+PASS literal backslash-semicolon alone
+PASS text ending in backslash-semicolon
+PASS 4096-byte text (the limit) with semicolons at the chunk edges
+PASS Enter button sends one Enter
+PASS Escape button sends one Escape
+PASS marker text typed
+PASS send log names the byte count and sha256 of the text
+PASS send log never contains the text
+PASS 4097-byte text refused (m=7), nothing typed
+PASS control byte 0x01 refused (m=4), nothing typed
+PASS newline inside the text refused (m=4), nothing typed
+PASS DEL refused (m=4), nothing typed
+PASS invalid UTF-8 byte 0xff refused (m=4), nothing typed
+PASS overlong UTF-8 refused (m=4), nothing typed
+PASS carriage return refused (m=4), nothing typed
+PASS tab refused (m=4), nothing typed
+PASS escape byte inside the text refused (m=4), nothing typed
+PASS unknown action refused (m=3), nothing typed
+PASS malformed and forged session names refused (m=2), nothing typed
+PASS duplicate or unknown form fields refused (m=1), nothing typed
+PASS a body over 16 KiB is refused (413), nothing typed
+PASS <script> on a session screen is shown escaped, never as markup
+PASS test session hv-test deleted
+PASS typing into the deleted session is refused (m=5)
+PASS hv-test no longer exists
+gate: 52 passed, 0 failed
diff --git a/evidence/gate-negative-control.txt b/evidence/gate-negative-control.txt
new file mode 100644
index 0000000..e772fb0
--- /dev/null
+++ b/evidence/gate-negative-control.txt
@@ -0,0 +1,53 @@
+PASS health answers 200 without auth
+PASS GET / without the cookie is refused (403)
+PASS a panel without the cookie is refused (403)
+PASS a wrong cookie is refused (403)
+PASS a wrong one-time link is refused (403)
+PASS the one-time link answers 302 and sets the token cookie
+PASS a foreign Host header is refused (400)
+PASS GET /send is refused (405)
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS POST /send without the cookie is refused (403)
+PASS POST /send without an Origin header is refused (403)
+PASS POST /send from a foreign Origin is refused (403)
+PASS POST /send with a wrong form key is refused (403)
+PASS nothing reached the session from the refused posts
+FAIL semi;
+FAIL ;
+FAIL ;;
+PASS -n
+PASS --
+PASS $(id) `id` 'q' "dq" & | > <
+PASS é ü 漢字 🐝
+PASS <script>alert(1)</script>
+PASS    leading and trailing spaces   
+PASS %41+%20&a=escape
+PASS send-keys -t =omp-queen: Enter
+PASS literal backslash-semicolon inside the text
+FAIL literal backslash-semicolon alone
+FAIL text ending in backslash-semicolon
+FAIL 4096-byte text (the limit) with semicolons at the chunk edges
+PASS Enter button sends one Enter
+PASS Escape button sends one Escape
+PASS marker text typed
+PASS send log names the byte count and sha256 of the text
+PASS send log never contains the text
+PASS 4097-byte text refused (m=7), nothing typed
+PASS control byte 0x01 refused (m=4), nothing typed
+PASS newline inside the text refused (m=4), nothing typed
+PASS DEL refused (m=4), nothing typed
+PASS invalid UTF-8 byte 0xff refused (m=4), nothing typed
+PASS overlong UTF-8 refused (m=4), nothing typed
+PASS carriage return refused (m=4), nothing typed
+PASS tab refused (m=4), nothing typed
+PASS escape byte inside the text refused (m=4), nothing typed
+PASS unknown action refused (m=3), nothing typed
+PASS malformed and forged session names refused (m=2), nothing typed
+PASS duplicate or unknown form fields refused (m=1), nothing typed
+PASS a body over 16 KiB is refused (413), nothing typed
+PASS <script> on a session screen is shown escaped, never as markup
+PASS test session hv-test deleted
+PASS typing into the deleted session is refused (m=5)
+PASS hv-test no longer exists
+gate: 46 passed, 6 failed
diff --git a/evidence/gate-nolog.txt b/evidence/gate-nolog.txt
new file mode 100644
index 0000000..7ac5ce8
--- /dev/null
+++ b/evidence/gate-nolog.txt
@@ -0,0 +1,6 @@
+PASS the one-time link answers 302 and sets the token cookie
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS with the send log unwritable the send is refused (m=8), nothing typed
+PASS test session hv-test deleted
+gate: 5 passed, 0 failed
diff --git a/evidence/gate-run.txt b/evidence/gate-run.txt
new file mode 100644
index 0000000..1d99114
--- /dev/null
+++ b/evidence/gate-run.txt
@@ -0,0 +1,53 @@
+PASS health answers 200 without auth
+PASS GET / without the cookie is refused (403)
+PASS a panel without the cookie is refused (403)
+PASS a wrong cookie is refused (403)
+PASS a wrong one-time link is refused (403)
+PASS the one-time link answers 302 and sets the token cookie
+PASS a foreign Host header is refused (400)
+PASS GET /send is refused (405)
+PASS test session hv-test created (tee into the sink, raw terminal)
+PASS the form key is on the session page
+PASS POST /send without the cookie is refused (403)
+PASS POST /send without an Origin header is refused (403)
+PASS POST /send from a foreign Origin is refused (403)
+PASS POST /send with a wrong form key is refused (403)
+PASS nothing reached the session from the refused posts
+PASS semi;
+PASS ;
+PASS ;;
+PASS -n
+PASS --
+PASS $(id) `id` 'q' "dq" & | > <
+PASS é ü 漢字 🐝
+PASS <script>alert(1)</script>
+PASS    leading and trailing spaces   
+PASS %41+%20&a=escape
+PASS send-keys -t =omp-queen: Enter
+PASS literal backslash-semicolon inside the text
+PASS literal backslash-semicolon alone
+PASS text ending in backslash-semicolon
+PASS 4096-byte text (the limit) with semicolons at the chunk edges
+PASS Enter button sends one Enter
+PASS Escape button sends one Escape
+PASS marker text typed
+PASS send log names the byte count and sha256 of the text
+PASS send log never contains the text
+PASS 4097-byte text refused (m=7), nothing typed
+PASS control byte 0x01 refused (m=4), nothing typed
+PASS newline inside the text refused (m=4), nothing typed
+PASS DEL refused (m=4), nothing typed
+PASS invalid UTF-8 byte 0xff refused (m=4), nothing typed
+PASS overlong UTF-8 refused (m=4), nothing typed
+PASS carriage return refused (m=4), nothing typed
+PASS tab refused (m=4), nothing typed
+PASS escape byte inside the text refused (m=4), nothing typed
+PASS unknown action refused (m=3), nothing typed
+PASS malformed and forged session names refused (m=2), nothing typed
+PASS duplicate or unknown form fields refused (m=1), nothing typed
+PASS a body over 16 KiB is refused (413), nothing typed
+PASS <script> on a session screen is shown escaped, never as markup
+PASS test session hv-test deleted
+PASS typing into the deleted session is refused (m=5)
+PASS hv-test no longer exists
+gate: 52 passed, 0 failed
diff --git a/src/.crumb b/src/.crumb
new file mode 100644
index 0000000..66d16f0
--- /dev/null
+++ b/src/.crumb
@@ -0,0 +1,37 @@
+{
+  "above": {
+    "name": "hive-view",
+    "path": ".."
+  },
+  "extensions": {
+    "generated": {
+      "children": [],
+      "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "compiled_at": "2026-11-07T08:20:58Z",
+      "compiler": "crumb-compile/1",
+      "digest": "sha256:1d0c4725bc2d3044352b5a971f2da1639cdca11080621a78754aeb68680e224a",
+      "evidence_files": 0,
+      "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "files": 7,
+      "generated_at_commit": "4c211f8d004668ffadf6024f1bf92e116d400317",
+      "source_tree": "sha256:aed7f023503561bfc9dc12f952af9232b6eb4d633b6890ceced44c214359e2e7"
+    },
+    "owner_lane": "",
+    "seed": {
+      "files": [
+        "main.om",
+        "page.om",
+        "poll.om",
+        "route.om",
+        "run.om",
+        "util.om",
+        "web.om"
+      ],
+      "purpose_auto": "Directory src. Purpose not yet described by a human."
+    }
+  },
+  "layer": "src",
+  "name": "src",
+  "purpose": "The hive-view server in seeded Omega, concatenated in the order util, run, poll, web, page, route, main after omega-mv http.om, notls.om and sha2.om: the shared poller, request checks, HTML rendering and the send pipeline.",
+  "schema_version": "1.0.0"
+}
diff --git a/src/main.om b/src/main.om
new file mode 100644
index 0000000..0e6872a
--- /dev/null
+++ b/src/main.om
@@ -0,0 +1,407 @@
+note hive-view src/main.om: entry points.
+note   server serve RUNDIR PORT ADDR [ADDR]   listen on each IPv4 ADDR:PORT (127.0.0.1 or the
+note                                          Tailscale range 100.64.0.0/10 only), fork the
+note                                          shared poller and one process per connection
+note   server mktoken                         create ~/.config/hive-view/token (mode 600, 64 hex)
+note   server poll-once RUNDIR                one full poller pass, then exit (tests)
+note Exit codes: 2 usage, 3 token missing or unsafe, 4 address refused, 5 listen failed,
+note 6 HOME unset, 17 token already exists, 18 token could not be created or written.
+global gpoll uchar 32
+global glf ulong 4
+global glfn ulong 1
+text tserve "serve"
+text tmktok "mktoken"
+text tpoll1 "poll-once"
+text tenvh "HOME="
+text tcfgd "/.config/hive-view"
+text ttokf "/.config/hive-view/token"
+text tstd1 "/.local/state"
+text tstd2 "/.local/state/hive-view"
+text tlhost "localhost:"
+text tlspark "spark.hub.internal:"
+text tlspk "spark:"
+text tmsgtok "token written to ~/.config/hive-view/token (mode 600)\n"
+text tmsgex "refused: ~/.config/hive-view/token already exists\n"
+text tmsgcr "refused: cannot create ~/.config/hive-view/token (does ~/.config exist and is it writable?)\n"
+fn vwhome to bool
+eb = new uchar 600 0
+for i ulong ulong envcnt
+n = envread i eb 0 600
+if gt n 5
+if heq view part eb 0 5 tenvh
+k = hmin sub ulong n 5 511
+for j ulong k
+put ghome j get eb add 5 j
+end
+put ghomel 0 k
+ret gt k 0
+end
+end
+end
+ret false
+end
+note vwarg: argument i into ab; its length, or 0
+fn vwarg i ulong ab edit uchar 512 to ulong
+if ge i ulong argcnt
+ret 0
+end
+n = argread i ab 0 512
+if le n 0
+ret 0
+end
+ret ulong n
+end
+fn vwargis ab edit uchar 512 n ulong t view uchar * to bool
+ret heq view part ab 0 n t
+end
+note vwtokld: the token file is ours, mode 0600 (no group/other bits), and 64 lowercase hex
+fn vwtokld to bool
+vwhpath ttokf
+fd = vwfopen
+if lt fd 0
+ret false
+end
+r = fstat int fd gstb 0 128
+if lt r 0
+x = fclose int fd
+ret false
+end
+mode = vwst32 16
+uid = vwst32 24
+size = vwst64 48
+ok = and eq and mode 63 0 eq uid ulong getuid
+ok = and ok or eq size 64 eq size 65
+if ok
+r = read int fd gtok 0 64
+ok = eq r 64
+end
+x = fclose int fd
+if not ok
+ret false
+end
+for i ulong 64
+if not vwhex get gtok i
+ret false
+end
+end
+ret true
+end
+fn vwmktok to int
+vwhpath tcfgd
+r = makedir gpth 0 get gpl 0 448
+vwhpath ttokf
+fd = fopen gpth 0 get gpl 0 524481 384
+if lt fd 0
+if eq fd -17
+x = write 2 tmsgex 0 len tmsgex
+ret 17
+end
+x = write 2 tmsgcr 0 len tmsgcr
+ret 18
+end
+rb = new uchar 32 0
+hx = new uchar 65 0
+k = random rb 0 32 0
+if ne k 32
+x = fclose int fd
+ret 18
+end
+for i ulong 32
+c = get rb i
+put hx mul i 2 get thexd shr c 4
+put hx add mul i 2 1 get thexd and c 15
+end
+put hx 64 10
+w = write int fd hx 0 65
+s = fsync int fd
+x = fclose int fd
+if ne w 65
+ret 18
+end
+x = write 1 tmsgtok 0 len tmsgtok
+ret 0
+end
+note vwip: dotted IPv4 in ab[0, n) as a host-order uint, or 0 when malformed
+fn vwip ab edit uchar 512 n ulong to ulong
+v = ulong 0
+part8 = ulong 0
+digs = ulong 0
+dots = ulong 0
+for i ulong n
+c = get ab i
+if eq c 46
+if or eq digs 0 gt part8 255
+ret 0
+end
+v = or shl v 8 part8
+part8 = 0
+digs = 0
+dots = add dots 1
+else
+if not vwdig c
+ret 0
+end
+part8 = add mul part8 10 ulong sub c 48
+digs = add digs 1
+if gt digs 3
+ret 0
+end
+end
+end
+if or or ne dots 3 eq digs 0 gt part8 255
+ret 0
+end
+ret or shl v 8 part8
+end
+note vwipok: loopback 127.0.0.1 or the Tailscale CGNAT range 100.64.0.0/10; never 0.0.0.0
+fn vwipok ip ulong to bool
+if eq ip 2130706433
+ret true
+end
+ret eq shr ip 22 401
+end
+fn vwahadd ab edit uchar 512 n ulong to void
+k = get gahn 0
+if ge k 8
+ret
+end
+b = ulong 0
+if gt k 0
+b = add get gaho sub k 1 get gahl sub k 1
+end
+if gt add b add n 6 len gah
+ret
+end
+for i ulong n
+put gah add b i get ab i
+end
+put gaho k b
+put gahl k n
+put gahn 0 add k 1
+end
+fn vwahport t view uchar * to void
+ab = new uchar 512 0
+n = ulong 0
+for i ulong len t
+put ab n get t i
+n = add n 1
+end
+vwahtail ab n
+end
+note vwahtail: append ":PORT" (unless already ends in ':') and add as an allowed Host
+fn vwahtail ab edit uchar 512 n ulong to void
+m = n
+if gt m 0
+if ne get ab sub m 1 58
+put ab m 58
+m = add m 1
+end
+end
+d = new uchar 20 0
+i = ulong 20
+x = get gport 0
+for it ulong 20
+i = sub i 1
+put d i uchar add rem x 10 48
+x = div x 10
+if eq x 0
+break
+end
+end
+for k ulong sub 20 i
+put ab m get d add i k
+m = add m 1
+end
+vwahadd ab m
+end
+fn vwlisten ab edit uchar 512 n ulong tail bool to int
+ip = vwip ab n
+if eq ip 0
+ret 4
+end
+if not vwipok ip
+ret 4
+end
+a = new uchar 16 0
+r = haddr4 a uint ip get gport 0
+lf = hlisten a 64
+if lt lf 0
+ret 5
+end
+k = get glfn 0
+put glf k ulong lf
+put glfn 0 add k 1
+vwahtail ab n
+if tail
+vwahport tlspark
+vwahport tlspk
+end
+ret 0
+end
+fn vwclosel to void
+for k ulong get glfn 0
+x = fclose int get glf k
+end
+end
+fn vwspawn to long
+pid = fork
+if eq pid 0
+vwclosel
+vwpoll
+exit 0
+end
+ret pid
+end
+fn vwpollset to ulong
+for k ulong get glfn 0
+b = mul k 8
+fd = get glf k
+put gpoll b uchar and fd 255
+put gpoll add b 1 uchar and shr fd 8 255
+put gpoll add b 2 0
+put gpoll add b 3 0
+put gpoll add b 4 1
+put gpoll add b 5 0
+put gpoll add b 6 0
+put gpoll add b 7 0
+end
+ret mul get glfn 0 8
+end
+fn vwaccept1 k ulong to long
+if eq and get gpoll add mul k 8 6 1 0
+ret 0
+end
+c = accept int get glf k 526336
+if lt c 0
+ret 0
+end
+pid = fork
+if eq pid 0
+vwclosel
+vwconn c
+exit 0
+end
+x = fclose int c
+if gt pid 0
+ret 1
+end
+ret 0
+end
+fn vwserve to int
+ab = new uchar 512 0
+n = vwarg 2 ab
+if or eq n 0 gt n 400
+ret 2
+end
+for i ulong n
+put grun i get ab i
+end
+put grunl 0 n
+n = vwarg 3 ab
+if not hdigits view part ab 0 n
+ret 2
+end
+port = hdecv view part ab 0 n
+if or eq port 0 gt port 65535
+ret 2
+end
+put gport 0 port
+if not vwtokld
+ret 3
+end
+put gahn 0 0
+vwahport tlhost
+argn = ulong argcnt
+if or lt argn 5 gt argn 6
+ret 2
+end
+for i ulong sub argn 4
+n = vwarg add i 4 ab
+r = vwlisten ab n not eq vwip ab n 2130706433
+if ne r 0
+ret r
+end
+end
+vwhpath tstd1
+r = makedir gpth 0 get gpl 0 448
+vwhpath tstd2
+r = makedir gpth 0 get gpl 0 448
+r = makedir grun 0 get grunl 0 448
+ret vwloop
+end
+fn vwloop to int
+poller = vwspawn
+backoff = long 0
+active = ulong 0
+np = vwpollset
+for it ulong 9223372036854775807
+for k ulong 128
+w = waitpid -1 gwst 0 4 1
+if le w 0
+break
+end
+if eq w poller
+poller = -1
+backoff = add long monons 2000000000
+else
+if gt active 0
+active = sub active 1
+end
+end
+end
+if and lt poller 0 gt long monons backoff
+poller = vwspawn
+end
+if ge active 48
+x = sleepns 50000000
+continue
+end
+for k ulong 4
+put gpoll add mul k 8 6 0
+end
+r = pollfds gpoll 0 np 500000000
+if le r 0
+continue
+end
+for k ulong get glfn 0
+active = add active ulong vwaccept1 k
+end
+end
+ret 0
+end
+fn vwpollonce to int
+ab = new uchar 512 0
+n = vwarg 2 ab
+if or eq n 0 gt n 400
+ret 2
+end
+for i ulong n
+put grun i get ab i
+end
+put grunl 0 n
+r = makedir grun 0 get grunl 0 448
+vwinitsec
+put ggen 0 vwnowms
+vwpanes
+vwslow
+vwkanban
+vwindex 0
+ret 0
+end
+fn main to int
+if not vwhome
+ret 6
+end
+ab = new uchar 512 0
+n = vwarg 1 ab
+if vwargis ab n tserve
+ret vwserve
+end
+if vwargis ab n tmktok
+ret vwmktok
+end
+if vwargis ab n tpoll1
+ret vwpollonce
+end
+ret 2
+end
diff --git a/src/page.om b/src/page.om
new file mode 100644
index 0000000..e03b16a
--- /dev/null
+++ b/src/page.om
@@ -0,0 +1,2746 @@
+note ==== page.om: every page and panel is drawn here, by Omega, as escaped HTML. The browser runs
+note no script at all (CSP has no script source): panels are iframes that re-fetch themselves with
+note <meta http-equiv=refresh>, and typing goes through a plain HTML form to POST /send.
+note All text that came from outside (pane captures, files, command output, query values) goes
+note through vwhe, which writes & < > " ' as entities and drops control bytes.
+global gh uchar 262144
+global ghl ulong 1
+global gix uchar 32768
+global gixl ulong 1
+global gq uchar 1024
+global gql ulong 1
+global gnow ulong 1
+global gcsrf uchar 64
+global gcsrfk ulong 1
+global gst ulong 4
+global gsp ulong 4
+global gsv ulong 16
+global gsvn ulong 1
+global gtl uchar 4096
+global gtll ulong 1
+global gpp ulong 8
+global gks uchar 768
+global gksl ulong 16
+global gkc ulong 16
+global gkn ulong 1
+global glan uchar 3072
+global glanl ulong 64
+global glann ulong 1
+text thamp "&amp;"
+text thlt "&lt;"
+text thgt "&gt;"
+text thquo "&quot;"
+text thapo "&#39;"
+text tdoc1 "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta http-equiv=\"refresh\" content=\""
+text tdoc2 "\"><link rel=\"stylesheet\" href=\"/app.css\"><link rel=\"stylesheet\" href=\"/palette.css\"></head><body class=\"frame\"><div class=\"lost l"
+text tdoc3 "\">NOT LIVE: this panel has not refreshed for a while (server down, or the browser paused it). Reload the page.</div>\n"
+text tdocend "</body></html>\n"
+text tpage1 "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>"
+text tpage2 "</title><link rel=\"stylesheet\" href=\"/app.css\"><link rel=\"stylesheet\" href=\"/palette.css\"></head><body>\n"
+text tspage0 "<span class=\"age"
+text tcdown " down"
+text tcstale " stale"
+text tqgt "\">"
+text tspend "</span>"
+text tago " ago"
+text tsago "s ago"
+text tafail " · last refresh failed ("
+text tastale " · STALE"
+text tefile "file missing"
+text teperm "permission denied"
+text tetmo "command timed out"
+text tenost "command could not start"
+text tesig "command killed by a signal"
+text texit "command exit "
+text terr "error "
+text tspc "<span class=\""
+text tspf "f"
+text tspb " b"
+text tspbo " B"
+text tspdi " D"
+text tspit " I"
+text tspun " U"
+text tsnone "No sessions in this group right now."
+text ttile1 "<a class=\"tile\" target=\"_top\" href=\"/s/"
+text ttile2 "\"><div class=\"head\"><span class=\"name\">"
+text ttile3 "</span> "
+text tdivc "</div>"
+text tptitle "<div class=\"ptitle\">"
+text tpstl "<div class=\"pstatus\">"
+text tpmeta "<div class=\"meta\">"
+text tpterm "<pre class=\"term\">"
+text tpterb "<pre class=\"term big\">"
+text tpreend "</pre>"
+text tpreo "<pre>"
+text taend "</a>\n"
+text tdot " · "
+text tattach " · attached"
+text tphead "<div class=\"phead\"><span class=\"name\">"
+text tnosessn "No tmux session has that name right now."
+text tpane "/p/pane"
+text ttiles "/p/tiles"
+text thermp "/p/hermes"
+text tmachp "/p/machine"
+text tboardp "/p/board"
+text tentp "/p/entries"
+text tstatp "/p/status"
+text tpalp "/palette.css"
+text tqn "n"
+text tqg "g"
+text tqf "f"
+text tqlane "lane"
+text tqq "q"
+text tqm "m"
+text tqa "a"
+text tqb "b"
+text tqs "s"
+text tpalc1 ".f"
+text tpalc2 "{color:#"
+text tpalc3 "}.b"
+text tpalc4 "{background:#"
+text tpalc5 "}\n"
+text tbase16 "000000cd31310dbc79e5e5102472c8bc3fbc11a8cde5e5e5666666f14c4c23d18bf5f5433b8eead670d629b8dbffffff"
+text tcube "005f87afd7ff"
+text th3 "<h3>"
+text th3e "</h3>\n"
+text tkv1 "<div class=\"kv\"><div class=\"k\">"
+text tkv2 "</div><div class=\"v"
+text tkv3 "</div></div>\n"
+text tkverr " err"
+text tgateway "Gateway"
+text tup "up"
+text tdownc "DOWN"
+text tqpause "Queen PAUSE"
+text tpaused "PAUSED: "
+text tnotp "not paused"
+text tkanh "Kanban (aien-hive board)"
+text tchip1 "<span class=\"chip "
+text tchip2 "\">"
+text tchips "<div class=\"chips\">"
+text trunh "Running cards"
+text tnorun "No running cards."
+text tcard1 "<div class=\"card\"><code>"
+text tcard2 "</code> "
+text trunning "running"
+text tmuted "<div class=\"muted\">"
+text thmach "Machine"
+text tload "Load (1/5/15 min)"
+text tmemk "Memory"
+text tgibu " GiB used of "
+text tgiba " GiB ("
+text tgibv " GiB available)"
+text tcpuk "CPU busy (all cores)"
+text tcpuv "% over the last 10 s"
+text tmeas "measuring"
+text thgpu "GPU"
+text tpowk "Power"
+text twatt " W"
+text tutilk "Utilization"
+text tpct " %"
+text tsampk "Sample"
+text tsamp "spark-sensors row "
+text tnosamp "no spark-sensors sample found"
+text tpowu "Power / utilization"
+text ttempk "Temperature"
+text ttempv "not shown: hive-view never queries the GPU itself (only spark-window holders may)"
+text tgproc "GPU processes"
+text tnone "none"
+text tpidk "pid "
+text thwin "spark-window"
+text topenw "Open window"
+text tqueued "queued"
+text tgone " (waiter gone)"
+text thalive "holder alive"
+text thpool "Pool locks"
+text tcores "cores "
+text tpidm " · pid "
+text thledg "Pearl ledger (newest first, verbatim)"
+text tledgk "Ledger"
+text tnoledg "none yet (~/work/pearl/economics/ledger.jsonl does not exist)"
+text tvfull "<div class=\"v full\">"
+text tolb "<ol class=\"board\">"
+text tole "</ol>\n"
+text tli1 "<li><span class=\"ts\">"
+text tli2 "</span> <span class=\"lane\">"
+text tli3 "</span> "
+text tli "<li>"
+text tlie "</li>\n"
+text tnomatch "No BOARD line matches this filter."
+text tdoc1q "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta http-equiv=\"refresh\" content=\"10;url=/p/board?lane="
+text tampq "&amp;q="
+text tent1 "<div class=\"entry\"><h4>"
+text tent2 "</h4><pre>"
+text tent3 "</pre></div>\n"
+text tqfile "questions"
+text tdfile "decisions"
+text tcfile "claims"
+text tlive "<span class=\"badge live\">live</span> server time "
+text tzsp "Z · "
+text tpok "poller ok"
+text tpstall "<span class=\"badge down\">poller stalled "
+text ttfail "<span class=\"badge down\">tmux list failed</span>"
+text tnoix "<span class=\"badge down\">no poller data yet</span>"
+text ttrunc "\n… (shortened)"
+note ---- the HTML builder: gh[0, ghl), flushed to the connection by vwflush
+fn vwhc c uchar to void
+n = get ghl 0
+if lt n 262144
+put gh n c
+put ghl 0 add n 1
+end
+end
+fn vwht t view uchar * to void
+for i ulong len t
+vwhc get t i
+end
+end
+fn vwhd v ulong to void
+if ge v 10
+vwhd div v 10
+end
+vwhc uchar add rem v 10 48
+end
+fn vwhd2 v ulong to void
+if lt v 10
+vwhc 48
+end
+vwhd v
+end
+note vwhe: one untrusted byte as HTML text (also safe inside a quoted attribute)
+fn vwhe c uchar to void
+if eq c 38
+vwht thamp
+ret
+end
+if eq c 60
+vwht thlt
+ret
+end
+if eq c 62
+vwht thgt
+ret
+end
+if eq c 34
+vwht thquo
+ret
+end
+if eq c 39
+vwht thapo
+ret
+end
+if or lt c 32 eq c 127
+if or eq c 10 eq c 9
+vwhc c
+end
+ret
+end
+vwhc c
+end
+fn vwheo a ulong n ulong to void
+for i ulong n
+vwhe get gob add a i
+end
+end
+fn vwhei a ulong n ulong to void
+for i ulong n
+vwhe get gix add a i
+end
+end
+fn vwheq to void
+for i ulong get gql 0
+vwhe get gq i
+end
+end
+fn vwhet t view uchar * to void
+for i ulong len t
+vwhe get t i
+end
+end
+fn vwflush cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+n = get ghl 0
+for i ulong n
+put buf i get gh i
+end
+put ghl 0 0
+if eq n 0
+ret 0
+end
+ret hput cs io view part buf 0 n
+end
+fn vwfin cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+r = vwflush cs io buf
+ret hfe r hwfin cs io
+end
+note vwhtml: a 200 text/html response with the security headers, body chunked (or close-delimited)
+fn vwhtml cs edit ulong 320 io edit uchar 131072 to long
+put ghl 0 0
+put gnow 0 vwnowms
+r = hrspst cs io 200
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io tthtml
+ret hfe r hhend cs io 1 0
+end
+note vwdoc: a self-refreshing panel document; the "lost" banner fades in by CSS alone after lost s
+fn vwdoc refr ulong lost ulong to void
+vwht tdoc1
+vwhd refr
+vwht tdoc2
+vwhd lost
+vwht tdoc3
+end
+fn vwpage t view uchar * to void
+vwht tpage1
+vwhet t
+vwht tpage2
+end
+note ---- ages
+fn vwhagt ms ulong to void
+s = div add ms 500 1000
+if lt s 60
+vwhd s
+vwht tsago
+ret
+end
+if lt s 3600
+vwhd div s 60
+vwhc 109
+vwhc 32
+vwhd rem s 60
+vwht tsago
+ret
+end
+vwhd div s 3600
+vwhc 104
+vwhc 32
+vwhd div rem s 3600 60
+vwhc 109
+vwht tago
+end
+fn vwherr st ulong to void
+if eq st 2
+vwht tefile
+ret
+end
+if eq st 13
+vwht teperm
+ret
+end
+if ge st 1000
+if eq st 1009
+vwht tetmo
+ret
+end
+if eq st 1008
+vwht tenost
+ret
+end
+if eq st 1007
+vwht tesig
+ret
+end
+vwht texit
+if ge st 1010
+vwhd sub st 1010
+ret
+end
+vwhc 45
+vwhd sub 1010 st
+ret
+end
+vwht terr
+vwhd st
+end
+note vwage: the age badge for refresh time t (ms) and status st; stale past lim ms
+fn vwage t ulong st ulong lim ulong to void
+ag = ulong 0
+if gt get gnow 0 t
+ag = sub get gnow 0 t
+end
+bad = gt ag lim
+vwht tspage0
+if ne st 0
+vwht tcdown
+else
+if bad
+vwht tcstale
+end
+end
+vwht tqgt
+vwhagt ag
+if ne st 0
+vwht tafail
+vwherr st
+vwhc 41
+end
+if bad
+vwht tastale
+end
+vwht tspend
+end
+note ---- the poller's index: "P<TAB>now<TAB>tmux_st<TAB>tick" then "SLOT<TAB>GEN<TAB>TMS<TAB>ST<TAB>KIND<TAB>NAME"
+fn vwrdix to bool
+put gixl 0 0
+vwpb
+vwpr
+vwpt tindex
+fd = vwfopen
+if lt fd 0
+ret false
+end
+for it ulong 1000
+n = get gixl 0
+if ge n 32768
+break
+end
+r = read int fd gix n sub 32768 n
+if le r 0
+break
+end
+put gixl 0 add n ulong r
+end
+x = fclose int fd
+ret gt get gixl 0 0
+end
+fn vwixe a ulong to ulong
+n = get gixl 0
+for i ulong sub n a
+if eq get gix add a i 10
+ret add a i
+end
+end
+ret n
+end
+note vwixf: start of tab-separated field k of the index line [a, e)
+fn vwixf a ulong e ulong k ulong to ulong
+if eq k 0
+ret a
+end
+c = ulong 0
+for i ulong sub e a
+if eq get gix add a i 9
+c = add c 1
+if eq c k
+ret add add a i 1
+end
+end
+end
+ret e
+end
+fn vwixn p ulong to ulong
+v = ulong 0
+for i ulong 20
+if ge add p i get gixl 0
+ret v
+end
+c = get gix add p i
+if not vwdig c
+ret v
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+note vwixis: the index line [a, e) field k equals t
+fn vwixis a ulong e ulong k ulong t view uchar * to bool
+p = vwixf a e k
+q = vwixf a e add k 1
+if lt q e
+q = sub q 1
+end
+if ne sub q p len t
+ret false
+end
+for i ulong len t
+if ne get gix add p i get t i
+ret false
+end
+end
+ret true
+end
+note vwixisq: field k equals the decoded query value gq
+fn vwixisq a ulong e ulong k ulong to bool
+p = vwixf a e k
+q = vwixf a e add k 1
+if lt q e
+q = sub q 1
+end
+if ne sub q p get gql 0
+ret false
+end
+for i ulong get gql 0
+if ne get gix add p i get gq i
+ret false
+end
+end
+ret true
+end
+note vwixfind: the index line of section or session named gq (kind sec when sec), else gixl
+fn vwixfind sec bool to ulong
+a = vwixe 0
+a = add a 1
+for it ulong 128
+if ge a get gixl 0
+break
+end
+e = vwixe a
+if vwixisq a e 5
+if eq sec vwixis a e 4 tksec
+ret a
+end
+end
+a = add e 1
+end
+ret get gixl 0
+end
+fn vwixage a ulong lim ulong to void
+e = vwixe a
+vwage vwixn vwixf a e 2 vwixn vwixf a e 3 lim
+end
+note vwsnap: read the snapshot of the slot on index line a into gob; returns the body start
+note (just past the "NAME<TAB>KIND<TAB>GEN" line) or gol when unreadable
+fn vwsnap a ulong to ulong
+vwpslot vwixn a
+r = vwrdall 262144
+if lt r 0
+put gol 0 0
+ret 0
+end
+ret vwlend 0 get gol 0
+end
+note vwsecq: look up section t (as gq) and read it; returns the index line or gixl
+fn vwsecq t view uchar * to ulong
+n = hmin len t 1024
+for i ulong n
+put gq i get t i
+end
+put gql 0 n
+ret vwixfind true
+end
+note ---- query strings: ?name=value&... ; values are percent-decoded ('+' is a space) into gq
+fn vwamp io edit uchar 131072 p ulong e ulong to ulong
+for i ulong sub e p
+if eq get io add p i 38
+ret add p i
+end
+end
+ret e
+end
+fn vwqnm io edit uchar 131072 p ulong q ulong nm view uchar * to bool
+k = len nm
+if le sub q p k
+ret false
+end
+for i ulong k
+if ne get io add p i get nm i
+ret false
+end
+end
+ret eq get io add p k 61
+end
+fn vwqdec io edit uchar 131072 p ulong q ulong to bool
+n = ulong 0
+i = p
+for it ulong 4096
+if ge i q
+break
+end
+if ge n 1024
+ret false
+end
+c = get io i
+if eq c 43
+c = 32
+end
+if eq c 37
+if gt add i 3 q
+ret false
+end
+h = hhexv get io add i 1
+l = hhexv get io add i 2
+if or gt h 15 gt l 15
+ret false
+end
+c = uchar add mul h 16 l
+i = add i 2
+end
+put gq n c
+n = add n 1
+i = add i 1
+end
+put gql 0 n
+ret true
+end
+fn vwqget cs edit ulong 320 io edit uchar 131072 nm view uchar * to bool
+put gql 0 0
+tg = get cs HTOFF
+tl = get cs HTLEN
+pl = hplen cs io
+if ge pl tl
+ret false
+end
+p = add add tg pl 1
+e = add tg tl
+for it ulong 64
+if ge p e
+ret false
+end
+q = vwamp io p e
+if vwqnm io p q nm
+ret vwqdec io add add p len nm 1 q
+end
+p = add q 1
+end
+ret false
+end
+fn vwqis t view uchar * to bool
+if ne get gql 0 len t
+ret false
+end
+for i ulong len t
+if ne get gq i get t i
+ret false
+end
+end
+ret true
+end
+note vwqname: gq is a session name the dashboard may address (1..63 of [A-Za-z0-9._-])
+fn vwqname to bool
+n = get gql 0
+if or eq n 0 gt n 63
+ret false
+end
+for i ulong n
+if not vwnamec get gq i
+ret false
+end
+end
+ret true
+end
+note vwqnum: gq as a small decimal (0 when absent or not a number)
+fn vwqnum to ulong
+v = ulong 0
+for i ulong hmin get gql 0 9
+c = get gq i
+if not vwdig c
+ret 0
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+note ---- ANSI SGR to classes. gst: 0 fg (0 default, else 1 + xterm-256 index), 1 bg, 2 flags
+note (1 bold, 2 dim, 4 italic, 8 underline, 16 reverse). gsp: the span now open (fg, bg, flags, open).
+note Truecolor is drawn with the nearest colour of the xterm-256 cube.
+fn vwcubei v ulong to ulong
+if lt v 48
+ret 0
+end
+if lt v 115
+ret 1
+end
+ret hmin 5 div sub v 35 40
+end
+fn vwsgrc c ulong to void
+f = get gst 2
+if eq c 0
+put gst 0 0
+put gst 1 0
+put gst 2 0
+ret
+end
+if eq c 1
+put gst 2 or f 1
+end
+if eq c 2
+put gst 2 or f 2
+end
+if eq c 3
+put gst 2 or f 4
+end
+if eq c 4
+put gst 2 or f 8
+end
+if eq c 7
+put gst 2 or f 16
+end
+if eq c 22
+put gst 2 and f 28
+end
+if eq c 23
+put gst 2 and f 27
+end
+if eq c 24
+put gst 2 and f 23
+end
+if eq c 27
+put gst 2 and f 15
+end
+if and ge c 30 le c 37
+put gst 0 sub c 29
+end
+if and ge c 90 le c 97
+put gst 0 sub c 81
+end
+if and ge c 40 le c 47
+put gst 1 sub c 39
+end
+if and ge c 100 le c 107
+put gst 1 sub c 91
+end
+if eq c 39
+put gst 0 0
+end
+if eq c 49
+put gst 1 0
+end
+end
+note vwsgrx: 38/48 extended colour at parameter i; returns how many parameters it used after i
+fn vwsgrx i ulong to ulong
+n = get gsvn 0
+w = ulong 0
+if eq get gsv i 48
+w = 1
+end
+v = ulong 0
+used = ulong 0
+if and lt add i 2 n eq get gsv add i 1 5
+v = add and get gsv add i 2 255 1
+used = 2
+end
+if and lt add i 4 n eq get gsv add i 1 2
+r = vwcubei and get gsv add i 2 255
+g = vwcubei and get gsv add i 3 255
+b = vwcubei and get gsv add i 4 255
+v = add add add 16 add mul r 36 mul g 6 b 1
+used = 4
+end
+put gst w v
+ret used
+end
+fn vwsgr to void
+n = get gsvn 0
+if eq n 0
+vwsgrc 0
+ret
+end
+i = ulong 0
+for it ulong 16
+if ge i n
+ret
+end
+c = get gsv i
+if or eq c 38 eq c 48
+i = add i vwsgrx i
+else
+vwsgrc c
+end
+i = add i 1
+end
+end
+fn vwspclose to void
+if eq get gsp 3 1
+vwht tspend
+put gsp 3 0
+end
+end
+note vwspan: make the open span match gst before the next text byte
+fn vwspan to void
+fg = get gst 0
+bg = get gst 1
+f = get gst 2
+if ne and f 16 0
+fg = get gst 1
+bg = get gst 0
+if eq fg 0
+fg = 1
+end
+if eq bg 0
+bg = 8
+end
+end
+f = and f 15
+op = ne add add fg bg f 0
+if eq get gsp 3 1
+if and and eq get gsp 0 fg eq get gsp 1 bg eq get gsp 2 f
+ret
+end
+end
+vwspclose
+if not op
+ret
+end
+vwht tspc
+if ne fg 0
+vwht tspf
+vwhd sub fg 1
+end
+if ne bg 0
+vwht tspb
+vwhd sub bg 1
+end
+vwspfl f
+vwht tqgt
+put gsp 0 fg
+put gsp 1 bg
+put gsp 2 f
+put gsp 3 1
+end
+fn vwspfl f ulong to void
+if ne and f 1 0
+vwht tspbo
+end
+if ne and f 2 0
+vwht tspdi
+end
+if ne and f 4 0
+vwht tspit
+end
+if ne and f 8 0
+vwht tspun
+end
+end
+note vwesc: the escape sequence starting at gob[i] (ESC); applies SGR; returns the index after it
+fn vwesc i ulong b ulong to ulong
+if ge add i 1 b
+ret b
+end
+c = get gob add i 1
+if eq c 91
+ret vwcsi add i 2 b
+end
+if eq c 93
+for k ulong sub b add i 2
+p = add add i 2 k
+d = get gob p
+if eq d 7
+ret add p 1
+end
+if and eq d 27 lt add p 1 b
+if eq get gob add p 1 92
+ret add p 2
+end
+ret p
+end
+end
+ret b
+end
+ret add i 2
+end
+fn vwcsi p ulong b ulong to ulong
+put gsvn 0 0
+v = ulong 0
+dig = false
+for k ulong sub b p
+c = get gob add p k
+if and ge c 64 le c 126
+if dig
+vwsvpush v
+end
+if eq c 109
+vwsgr
+end
+ret add add p k 1
+end
+if vwdig c
+v = add mul v 10 ulong sub c 48
+if gt v 100000
+v = 100000
+end
+dig = true
+else
+if dig
+vwsvpush v
+end
+v = 0
+dig = false
+end
+end
+ret b
+end
+fn vwsvpush v ulong to void
+n = get gsvn 0
+if lt n 16
+put gsv n v
+put gsvn 0 add n 1
+end
+end
+note vwansi: gob[a, b) as escaped HTML text with colour spans
+fn vwansi a ulong b ulong to void
+put gst 0 0
+put gst 1 0
+put gst 2 0
+put gsp 3 0
+i = a
+for it ulong 1000000
+if ge i b
+break
+end
+c = get gob i
+if eq c 27
+i = vwesc i b
+continue
+end
+if eq c 10
+vwhc 10
+else
+if and ge c 32 ne c 127
+vwspan
+vwhe c
+end
+end
+i = add i 1
+end
+vwspclose
+end
+note ---- pane parts: title and status lines taken from the plain (escape-free) text
+note vwplain: gob[a, b) without escapes and control bytes into gtl; spaces trimmed
+fn vwplain a ulong b ulong to void
+put gtll 0 0
+i = a
+for it ulong 100000
+if ge i b
+break
+end
+c = get gob i
+if eq c 27
+i = vwesc2 i b
+continue
+end
+if and ge c 32 ne c 127
+n = get gtll 0
+if lt n 4096
+put gtl n c
+put gtll 0 add n 1
+end
+end
+i = add i 1
+end
+vwtltrim
+end
+note vwesc2: like vwesc but without touching the SGR state
+fn vwesc2 i ulong b ulong to ulong
+s0 = get gst 0
+s1 = get gst 1
+s2 = get gst 2
+r = vwesc i b
+put gst 0 s0
+put gst 1 s1
+put gst 2 s2
+ret r
+end
+fn vwtltrim to void
+n = get gtll 0
+s = ulong 0
+for i ulong n
+if ne get gtl s 32
+break
+end
+s = add s 1
+end
+e = n
+for i ulong n
+if le e s
+break
+end
+if ne get gtl sub e 1 32
+break
+end
+e = sub e 1
+end
+for i ulong sub e s
+put gtl i get gtl add s i
+end
+put gtll 0 sub e s
+end
+note vwruleat: 1 or 3 when gtl[i] starts a rule character ('-', U+2500, U+2501), else 0
+fn vwruleat i ulong to ulong
+n = get gtll 0
+if ge i n
+ret 0
+end
+if eq get gtl i 45
+ret 1
+end
+if and lt add i 2 n eq get gtl i 226
+if and eq get gtl add i 1 148 le get gtl add i 2 129
+if ge get gtl add i 2 128
+ret 3
+end
+end
+end
+ret 0
+end
+fn vwruleend e ulong to ulong
+if eq e 0
+ret 0
+end
+if eq get gtl sub e 1 45
+ret 1
+end
+if ge e 3
+if eq vwruleat sub e 3 3
+ret 3
+end
+end
+ret 0
+end
+note vwisrule: gtl starts with 3 rule characters and has a letter or digit; then strip the rule
+fn vwisrule to bool
+i = ulong 0
+for k ulong 3
+w = vwruleat i
+if eq w 0
+ret false
+end
+i = add i w
+end
+an = false
+for k ulong get gtll 0
+c = get gtl k
+if or vwdig c or and ge c 65 le c 90 and ge c 97 le c 122
+an = true
+end
+end
+if not an
+ret false
+end
+s = ulong 0
+for k ulong get gtll 0
+w = vwruleat s
+if and eq w 0 ne get gtl s 32
+break
+end
+s = add s hmax w 1
+end
+e = get gtll 0
+for k ulong get gtll 0
+if le e s
+break
+end
+w = vwruleend e
+if and eq w 0 ne get gtl sub e 1 32
+break
+end
+e = sub e hmax w 1
+end
+for k ulong sub e s
+put gtl k get gtl add s k
+end
+put gtll 0 sub e s
+ret true
+end
+fn hmax a ulong b ulong to ulong
+if gt a b
+ret a
+end
+ret b
+end
+note vwlstart: the start of the gob line that ends at p (p is at its LF or the end)
+fn vwlstart c0 ulong p ulong to ulong
+q = p
+for it ulong 1000000
+if le q c0
+ret c0
+end
+if eq get gob sub q 1 10
+ret q
+end
+q = sub q 1
+end
+ret c0
+end
+note vwparts: capture gob[c0, n): gpp 0/1 status line, 2/3 title line (plain text is redone by
+note vwplain when drawn), 4 end of the last non-blank line, 5 status found, 6 title is a rule
+fn vwparts c0 ulong n ulong to void
+for i ulong 8
+put gpp i 0
+end
+put gpp 4 c0
+p = n
+if and gt p c0 eq get gob sub p 1 10
+p = sub p 1
+end
+for it ulong 400
+s = vwlstart c0 p
+vwplain s p
+if gt get gtll 0 0
+put gpp 0 s
+put gpp 1 p
+put gpp 4 p
+put gpp 5 1
+vwtitle c0 s
+ret
+end
+if le s c0
+ret
+end
+p = sub s 1
+end
+end
+fn vwtitle c0 ulong s0 ulong to void
+if le s0 c0
+ret
+end
+p = sub s0 1
+fb = false
+for it ulong 8
+s = vwlstart c0 p
+vwplain s p
+if gt get gtll 0 0
+if vwisrule
+put gpp 2 s
+put gpp 3 p
+put gpp 6 1
+ret
+end
+if not fb
+put gpp 2 s
+put gpp 3 p
+fb = true
+end
+end
+if le s c0
+ret
+end
+p = sub s 1
+end
+end
+note vwhtitle / vwhstat: the title (rule stripped) and status line as escaped text
+fn vwhtitle to void
+if eq get gpp 3 0
+ret
+end
+vwplain get gpp 2 get gpp 3
+if eq get gpp 6 1
+b = vwisrule
+end
+for i ulong get gtll 0
+vwhe get gtl i
+end
+end
+fn vwhstat to void
+if eq get gpp 5 0
+ret
+end
+vwplain get gpp 0 get gpp 1
+for i ulong get gtll 0
+vwhe get gtl i
+end
+end
+note vwlomp: the status line looks like omp's (ctx:, (adv), [high]/[medium]/[low])
+text tmk1 "ctx:"
+text tmk2 "(adv)"
+text tmk3 "[high]"
+text tmk4 "[medium]"
+text tmk5 "[low]"
+fn vwtlhas t view uchar * to bool
+n = get gtll 0
+if lt n len t
+ret false
+end
+for i ulong add sub n len t 1
+ok = true
+for k ulong len t
+if ne get gtl add i k get t k
+ok = false
+break
+end
+end
+if ok
+ret true
+end
+end
+ret false
+end
+fn vwlomp to bool
+if eq get gpp 5 0
+ret false
+end
+vwplain get gpp 0 get gpp 1
+if or vwtlhas tmk1 vwtlhas tmk2
+ret true
+end
+ret or vwtlhas tmk3 or vwtlhas tmk4 vwtlhas tmk5
+end
+note vwback: the start of the last k lines that end at p (content start c0)
+fn vwback c0 ulong p ulong k ulong to ulong
+q = p
+for i ulong k
+s = vwlstart c0 q
+if le s c0
+ret c0
+end
+q = sub s 1
+end
+ret add q 1
+end
+note ---- panes and tiles
+note vwgf: start of '|'-field k of gob[a, e)
+fn vwgf a ulong e ulong k ulong to ulong
+if eq k 0
+ret a
+end
+c = ulong 0
+for i ulong sub e a
+if eq get gob add a i 124
+c = add c 1
+if eq c k
+ret add add a i 1
+end
+end
+end
+ret e
+end
+fn vwgfe a ulong e ulong k ulong to ulong
+q = vwgf a e add k 1
+if lt q e
+ret sub q 1
+end
+ret e
+end
+note vwmeta: "cmd · WxH[ · attached]" from the list line gob[a, e)
+fn vwmeta a ulong e ulong to void
+p = vwgf a e 1
+vwheo p sub vwgfe a e 1 p
+vwht tdot
+p = vwgf a e 4
+vwheo p sub vwgfe a e 4 p
+p = vwgf a e 2
+if lt p e
+if ne get gob p 48
+vwht tattach
+end
+end
+end
+note vwpanebd: for the snapshot in gob (body at b0): sets gpp and returns the capture start
+fn vwpanebd b0 ulong to ulong
+n = get gol 0
+c0 = vwlend b0 n
+vwparts c0 n
+ret c0
+end
+note vwtile: one session tile for index line a (snapshot already in gob, body at b0)
+fn vwtile a ulong b0 ulong c0 ulong to void
+e = vwixe a
+p = vwixf a e 5
+vwht ttile1
+vwhei p sub e p
+vwht ttile2
+vwhei p sub e p
+vwht ttile3
+vwixage a 10000
+vwht tdivc
+vwht tptitle
+vwhtitle
+vwht tdivc
+vwht tpstl
+vwhstat
+vwht tdivc
+vwht tpmeta
+vwmeta b0 sub c0 1
+vwht tdivc
+vwht tpterm
+x = get gpp 4
+vwansi vwback c0 x 14 x
+vwht tpreend
+vwht taend
+end
+note vwgroup: which tile group index line a belongs in: 1 omp, 2 lead, 3 other, 0 none (queen, sections)
+fn vwgroup a ulong e ulong to ulong
+if vwixis a e 4 tkomp
+ret 1
+end
+if vwixis a e 4 tklead
+ret 2
+end
+if vwixis a e 4 tkother
+if vwlomp
+ret 1
+end
+ret 3
+end
+ret 0
+end
+note GET /p/tiles?g=omp|lead|other
+fn vwptiles cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+want = ulong 3
+if vwqget cs io tqg
+if vwqis tkomp
+want = 1
+end
+if vwqis tklead
+want = 2
+end
+end
+r = vwhtml cs io
+vwdoc 3 12
+shown = ulong 0
+if vwrdix
+a = add vwixe 0 1
+for it ulong 128
+if ge a get gixl 0
+break
+end
+e = vwixe a
+if not vwixis a e 4 tksec
+b0 = vwsnap a
+c0 = vwpanebd b0
+if eq vwgroup a e want
+vwtile a b0 c0
+shown = add shown 1
+r = hfe r vwflush cs io buf
+end
+end
+a = add e 1
+end
+end
+if eq shown 0
+vwht tmuted
+vwht tsnone
+vwht tdivc
+end
+vwht tdocend
+r = hfe r vwfin cs io buf
+ret r
+end
+note GET /p/pane?n=NAME: one session's whole screen
+fn vwppane cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+have = vwqget cs io tqn
+r = vwhtml cs io
+vwdoc 2 8
+a = get gixl 0
+if and have vwrdix
+a = vwixfind false
+end
+if ge a get gixl 0
+vwht tmuted
+vwht tnosessn
+vwht tdivc
+else
+b0 = vwsnap a
+c0 = vwpanebd b0
+vwht tphead
+vwheq
+vwht ttile3
+vwixage a 10000
+vwht tdot
+vwmeta b0 sub c0 1
+vwht tdivc
+vwht tptitle
+vwhtitle
+vwht tdivc
+vwht tpstl
+vwhstat
+vwht tdivc
+vwht tpterb
+vwansi c0 get gpp 4
+vwht tpreend
+end
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note GET /p/status: the feed's own heartbeat; a browser error page here means the server is down
+fn vwpstat cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+r = vwhtml cs io
+vwdoc 2 8
+vwht tlive
+s = rem div get gnow 0 1000 86400
+vwhd2 div s 3600
+vwhc 58
+vwhd2 div rem s 3600 60
+vwhc 58
+vwhd2 rem s 60
+vwht tzsp
+if vwrdix
+e = vwixe 0
+t = vwixn vwixf 0 e 1
+ts = vwixn vwixf 0 e 2
+ag = ulong 0
+if gt get gnow 0 t
+ag = sub get gnow 0 t
+end
+if gt ag 12000
+vwht tpstall
+vwhagt ag
+vwht tspend
+else
+if ne ts 0
+vwht ttfail
+else
+vwht tpok
+end
+end
+else
+vwht tnoix
+end
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note ---- sections
+fn vwgsp p ulong e ulong to ulong
+x = p
+for s ulong 65536
+if ge x e
+ret x
+end
+c = get gob x
+if and ne c 32 ne c 9
+ret x
+end
+x = add x 1
+end
+ret x
+end
+fn vwgtok p ulong e ulong to ulong
+x = p
+for s ulong 65536
+if ge x e
+ret x
+end
+c = get gob x
+if or eq c 32 eq c 9
+ret x
+end
+x = add x 1
+end
+ret x
+end
+note vwtabf: start of tab field k of gob[a, e)
+fn vwtabf a ulong e ulong k ulong to ulong
+if eq k 0
+ret a
+end
+c = ulong 0
+for i ulong sub e a
+if eq get gob add a i 9
+c = add c 1
+if eq c k
+ret add add a i 1
+end
+end
+end
+ret e
+end
+fn vwtabe a ulong e ulong k ulong to ulong
+q = vwtabf a e add k 1
+if lt q e
+ret sub q 1
+end
+ret e
+end
+fn vwgis p ulong q ulong t view uchar * to bool
+if ne sub q p len t
+ret false
+end
+for i ulong len t
+if ne get gob add p i get t i
+ret false
+end
+end
+ret true
+end
+fn vwkvo k view uchar * err bool to void
+vwht tkv1
+vwhet k
+vwht tkv2
+if err
+vwht tkverr
+end
+vwht tqgt
+end
+fn vwkvoo a ulong n ulong to void
+vwht tkv1
+vwheo a n
+vwht tkv2
+vwht tqgt
+end
+fn vwkve to void
+vwht tkv3
+end
+fn vwkvt k view uchar * v view uchar * err bool to void
+vwkvo k err
+vwhet v
+vwkve
+end
+fn vwh3 t view uchar * a ulong lim ulong to void
+vwht th3
+vwhet t
+vwhc 32
+if lt a get gixl 0
+vwixage a lim
+end
+vwht th3e
+end
+note vwsecrd: index line and body start for section t; gob holds it (gol 0 when absent)
+fn vwsecrd t view uchar * to ulong
+a = vwsecq t
+put gol 0 0
+if lt a get gixl 0
+b = vwsnap a
+put goa 0 b
+end
+ret a
+end
+text tgwkey "gateway"
+text tpkey "pause"
+text tabsent2 "absent"
+fn vwhermes2 to void
+a = vwsecrd tnherm
+vwh3 tnherm a 45000
+b0 = get goa 0
+n = get gol 0
+p = b0
+for it ulong 16
+if ge p n
+break
+end
+e = sub vwlend p n 1
+f1 = vwtabf p e 1
+if vwgis p sub f1 1 tgwkey
+up = vwgis f1 vwtabe p e 1 tup
+vwkvo tgateway not up
+if up
+vwht tup
+else
+vwht tdownc
+end
+vwkve
+end
+if vwgis p sub f1 1 tpkey
+yes = vwgis f1 vwtabe p e 1 tyes
+vwkvo tqpause yes
+if yes
+vwht tpaused
+f2 = vwtabf p e 2
+vwheo f2 sub e f2
+else
+vwht tnotp
+end
+vwkve
+end
+p = add e 1
+end
+end
+note ---- kanban: lines "<marker> t_<id> <status> <assignee> <title>"; counts kept sorted by name
+fn vwkline p ulong e ulong to ulong
+a = vwgtok vwgsp p e e
+s1 = vwgsp a e
+if gt add s1 2 e
+ret e
+end
+if or ne get gob s1 116 ne get gob add s1 1 95
+ret e
+end
+ret s1
+end
+fn vwkcount p ulong q ulong to void
+n = get gkn 0
+l = hmin sub q p 47
+for i ulong n
+if vwkseq i p l
+put gkc i add get gkc i 1
+ret
+end
+end
+if ge n 16
+ret
+end
+ix = n
+for i ulong n
+if vwkslt p l i
+ix = i
+break
+end
+end
+k = n
+for it ulong 16
+if le k ix
+break
+end
+vwkmove sub k 1 k
+k = sub k 1
+end
+for i ulong l
+put gks add mul ix 48 i get gob add p i
+end
+put gksl ix l
+put gkc ix 1
+put gkn 0 add n 1
+end
+fn vwkmove s ulong d ulong to void
+for i ulong 48
+put gks add mul d 48 i get gks add mul s 48 i
+end
+put gksl d get gksl s
+put gkc d get gkc s
+end
+fn vwkseq i ulong p ulong l ulong to bool
+if ne get gksl i l
+ret false
+end
+for k ulong l
+if ne get gks add mul i 48 k get gob add p k
+ret false
+end
+end
+ret true
+end
+note vwkslt: gob[p, p+l) sorts before entry i
+fn vwkslt p ulong l ulong i ulong to bool
+m = get gksl i
+for k ulong hmin l m
+a = get gob add p k
+b = get gks add mul i 48 k
+if ne a b
+ret lt a b
+end
+end
+ret lt l m
+end
+fn vwkchips to void
+vwht tchips
+for i ulong get gkn 0
+vwht tchip1
+vwkname i
+vwht tchip2
+vwkname i
+vwhc 32
+vwhd get gkc i
+vwht tspend
+end
+end
+fn vwkname i ulong to void
+b = mul i 48
+for k ulong get gksl i
+vwhe get gks add b k
+end
+end
+fn vwkanb2 to void
+put gkn 0 0
+a = vwsecrd tnkan
+vwh3 tkanh a 45000
+b0 = get goa 0
+n = get gol 0
+p = b0
+for it ulong 4096
+if ge p n
+break
+end
+e = sub vwlend p n 1
+s1 = vwkline p e
+if lt s1 e
+s2 = vwgsp vwgtok s1 e e
+vwkcount s2 vwgtok s2 e
+end
+p = add e 1
+end
+vwkchips
+if and eq get gkn 0 0 gt n b0
+vwheo b0 hmin sub n b0 300
+end
+vwht tdivc
+vwkrun b0 n
+end
+fn vwkrun b0 ulong n ulong to void
+vwht th3
+vwht trunh
+vwht th3e
+p = b0
+c = ulong 0
+for it ulong 4096
+if ge p n
+break
+end
+e = sub vwlend p n 1
+s1 = vwkline p e
+if lt s1 e
+t1 = vwgtok s1 e
+s2 = vwgsp t1 e
+t2 = vwgtok s2 e
+if vwgis s2 t2 trunning
+vwht tcard1
+vwheo s1 sub t1 s1
+vwht tcard2
+s3 = vwgsp t2 e
+vwheo s3 sub e s3
+vwht tdivc
+c = add c 1
+end
+end
+p = add e 1
+end
+if eq c 0
+vwht tmuted
+vwht tnorun
+vwht tdivc
+end
+end
+note GET /p/hermes: gateway, queen PAUSE, kanban counts and running cards
+fn vwphermes cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+r = vwhtml cs io
+vwdoc 10 35
+ok = vwrdix
+vwhermes2
+r = hfe r vwflush cs io buf
+vwkanb2
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note ---- machine, GPU, spark-window, pools, ledger
+note vwhash: the line after "#name" in gob[b0, n) (its start), or n
+fn vwhash b0 ulong n ulong t view uchar * to ulong
+p = b0
+for it ulong 4096
+if ge p n
+ret n
+end
+e = sub vwlend p n 1
+if and gt sub e p 0 eq get gob p 35
+if vwgis add p 1 e t
+ret add e 1
+end
+end
+p = add e 1
+end
+ret n
+end
+fn vwlinee p ulong n ulong to ulong
+if ge p n
+ret n
+end
+ret sub vwlend p n 1
+end
+note vwgib: kB as GiB with one decimal
+fn vwgib kb ulong to void
+t = div add mul kb 10 524288 1048576
+vwhd div t 10
+vwhc 46
+vwhd rem t 10
+end
+fn vwmemv p ulong n ulong t view uchar * to ulong
+q = p
+for it ulong 8
+if ge q n
+ret 0
+end
+e = vwlinee q n
+if vwgis q add q len t t
+s = vwgsp add q len t e
+v = ulong 0
+for i ulong sub e s
+c = get gob add s i
+if not vwdig c
+break
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+q = add e 1
+end
+ret 0
+end
+text tmtot "MemTotal:"
+text tmavl "MemAvailable:"
+text tcpu "cpu"
+text tload2 "load"
+text tmem2 "mem"
+text tsens2 "sensors"
+text tapps2 "apps"
+fn vwmach2 to void
+a = vwsecrd tnmach
+vwh3 thmach a 45000
+b0 = get goa 0
+n = get gol 0
+p = vwhash b0 n tload2
+if lt p n
+vwkvo tload false
+e = vwlinee p n
+q = p
+for k ulong 3
+t = vwgtok q e
+vwheo q sub t q
+vwhc 32
+vwhc 32
+q = vwgsp t e
+end
+vwkve
+end
+p = vwhash b0 n tmem2
+tot = vwmemv p n tmtot
+av = vwmemv p n tmavl
+if gt tot 0
+vwkvo tmemk false
+vwgib sub tot hmin av tot
+vwht tgibu
+vwgib tot
+vwht tgiba
+vwgib av
+vwht tgibv
+vwkve
+end
+p = vwhash b0 n tcpu
+vwkvo tcpuk false
+e = vwlinee p n
+if and lt p n vwdig get gob p
+vwheo p sub e p
+vwht tcpuv
+else
+vwht tmeas
+end
+vwkve
+end
+fn vwgpu2 to void
+a = vwsecrd tngpu
+vwh3 thgpu a 45000
+b0 = get goa 0
+n = get gol 0
+p = vwhash b0 n tsens2
+e = vwlinee p n
+f3 = vwcsvf p e 3
+if and lt p n lt f3 e
+vwkvo tpowk false
+vwheo f3 sub vwcsve p e 3 f3
+vwht twatt
+vwkve
+f4 = vwcsvf p e 4
+vwkvo tutilk false
+vwheo f4 sub vwcsve p e 4 f4
+vwht tpct
+vwkve
+vwsensag p e
+else
+vwkvt tpowu tnosamp true
+end
+vwkvt ttempk ttempv false
+p = vwhash b0 n tapps2
+c = ulong 0
+for it ulong 64
+if ge p n
+break
+end
+e = vwlinee p n
+if or eq e p eq get gob p 35
+break
+end
+t = vwtabe p e 0
+vwht tkv1
+vwht tpidk
+vwheo p sub t p
+vwht tkv2
+vwht tqgt
+f1 = vwtabf p e 1
+vwheo f1 sub e f1
+vwkve
+c = add c 1
+p = add e 1
+end
+if eq c 0
+vwkvt tgproc tnone false
+end
+end
+fn vwsensag p ulong e ulong to void
+ep = ulong 0
+for i ulong sub vwcsve p e 0 p
+c = get gob add p i
+if not vwdig c
+break
+end
+ep = add mul ep 10 ulong sub c 48
+end
+ms = mul ep 1000
+ag = ulong 0
+if gt get gnow 0 ms
+ag = sub get gnow 0 ms
+end
+bad = gt ag 15000
+vwkvo tsampk bad
+vwht tsamp
+vwhagt ag
+if bad
+vwht tastale
+end
+vwkve
+end
+fn vwcsvf a ulong e ulong k ulong to ulong
+if eq k 0
+ret a
+end
+c = ulong 0
+for i ulong sub e a
+if eq get gob add a i 44
+c = add c 1
+if eq c k
+ret add add a i 1
+end
+end
+end
+ret e
+end
+fn vwcsve a ulong e ulong k ulong to ulong
+q = vwcsvf a e add k 1
+if lt q e
+ret sub q 1
+end
+ret e
+end
+text twqk "queue"
+text twok "open"
+text twak "alive"
+text twnk "none"
+text tpoolk "pool"
+fn vwwin2 to void
+a = vwsecrd tnwin
+vwh3 thwin a 45000
+b0 = get goa 0
+n = get gol 0
+p = b0
+for it ulong 64
+if ge p n
+break
+end
+e = vwlinee p n
+vwwinl p e
+p = add e 1
+end
+end
+fn vwwinl p ulong e ulong to void
+if eq e p
+ret
+end
+k = vwtabe p e 0
+f1 = vwtabf p e 1
+e1 = vwtabe p e 1
+if vwgis p k twqk
+vwkvo tqueued false
+f3 = vwtabf p e 3
+if lt f3 e
+vwheo f3 sub e f3
+else
+vwheo f1 sub e1 f1
+end
+f2 = vwtabf p e 2
+if not vwgis f2 vwtabe p e 2 tyes
+vwht tgone
+end
+vwkve
+ret
+end
+if vwgis p k twok
+vwkvo topenw false
+vwheo f1 sub e1 f1
+vwkve
+ret
+end
+if vwgis p k twak
+vwkvo thalive not vwgis f1 e1 tyes
+vwheo f1 sub e1 f1
+vwkve
+ret
+end
+if vwgis p k twnk
+ret
+end
+vwkvoo p sub k p
+for i ulong sub e f1
+c = get gob add f1 i
+if eq c 9
+c = 32
+end
+vwhe c
+end
+vwkve
+end
+fn vwpool2 to void
+a = vwsecrd tnpool
+vwh3 thpool a 45000
+b0 = get goa 0
+n = get gol 0
+p = b0
+for it ulong 128
+if ge p n
+break
+end
+e = vwlinee p n
+if vwgis p vwtabe p e 0 tpoolk
+vwpooll p e
+end
+p = add e 1
+end
+end
+fn vwpooll p ulong e ulong to void
+f1 = vwtabf p e 1
+e1 = vwtabe p e 1
+s = f1
+if gt sub e1 s 5
+if vwgis s add s 5 tpoolp
+s = add s 5
+end
+end
+x = e1
+if gt sub x s 5
+if vwgis sub x 5 x tlockx
+x = sub x 5
+end
+end
+vwht tkv1
+vwht tcores
+vwheo s sub x s
+vwht tkv2
+vwht tqgt
+f2 = vwtabf p e 2
+e2 = vwtabe p e 2
+vwheo f2 sub e2 f2
+if not vwgis f2 e2 tfree
+vwht tpidm
+f3 = vwtabf p e 3
+vwheo f3 sub vwtabe p e 3 f3
+vwht tdot
+f4 = vwtabf p e 4
+vwheo f4 sub e f4
+end
+vwkve
+end
+fn vwledg2 to void
+a = vwsecrd tnledg
+vwh3 thledg a 45000
+b0 = get goa 0
+n = get gol 0
+if vwgis b0 vwlinee b0 n tabsent2
+vwkvt tledgk tnoledg false
+ret
+end
+e = n
+c = ulong 0
+for it ulong 4096
+if or le e b0 ge c 8
+break
+end
+if eq get gob sub e 1 10
+e = sub e 1
+continue
+end
+s = vwlstart b0 e
+vwht tvfull
+vwheo s sub e s
+vwht tdivc
+c = add c 1
+e = s
+end
+end
+note GET /p/machine
+fn vwpmach cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+r = vwhtml cs io
+vwdoc 10 35
+ok = vwrdix
+vwmach2
+vwgpu2
+r = hfe r vwflush cs io buf
+vwwin2
+vwpool2
+r = hfe r vwflush cs io buf
+vwledg2
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note ---- BOARD: newest first, filtered by lane and by text (case-insensitive)
+global glq uchar 64
+global glql ulong 1
+global gqq uchar 256
+global gqql ulong 1
+global gbp ulong 4
+fn vwlower c uchar to uchar
+if and ge c 65 le c 90
+ret uchar add c 32
+end
+ret c
+end
+note vwbparse: "TIMESTAMP LANE rest" in gob[s, e): gbp 0 ts end, 1 lane start, 2 lane end, 3 rest
+fn vwbparse s ulong e ulong to bool
+t = vwgtok s e
+if lt sub t s 11
+ret false
+end
+for i ulong 4
+if not vwdig get gob add s i
+ret false
+end
+end
+if or ne get gob add s 4 45 ne get gob add s 10 84
+ret false
+end
+l0 = vwgsp t e
+l1 = vwgtok l0 e
+if eq l0 l1
+ret false
+end
+put gbp 0 t
+put gbp 1 l0
+x = l1
+if eq get gob sub x 1 58
+x = sub x 1
+end
+put gbp 2 x
+r = l1
+if lt r e
+r = add r 1
+end
+put gbp 3 r
+ret true
+end
+fn vwblane to bool
+n = get glql 0
+if eq n 0
+ret true
+end
+p = get gbp 1
+if ne sub get gbp 2 p n
+ret false
+end
+for i ulong n
+if ne get gob add p i get glq i
+ret false
+end
+end
+ret true
+end
+fn vwbtext s ulong e ulong to bool
+n = get gqql 0
+if eq n 0
+ret true
+end
+if lt sub e s n
+ret false
+end
+for i ulong add sub sub e s n 1
+ok = true
+for k ulong n
+if ne vwlower get gob add add s i k get gqq k
+ok = false
+break
+end
+end
+if ok
+ret true
+end
+end
+ret false
+end
+fn vwbli s ulong e ulong to void
+if vwbparse s e
+vwht tli1
+vwheo s sub get gbp 0 s
+vwht tli2
+p = get gbp 1
+vwheo p sub get gbp 2 p
+vwht tli3
+p = get gbp 3
+vwheo p sub e p
+else
+vwht tli
+vwheo s sub e s
+end
+vwht tlie
+end
+fn vwbshow s ulong e ulong to bool
+if gt get glql 0 0
+if not vwbparse s e
+ret false
+end
+if not vwblane
+ret false
+end
+end
+ret vwbtext s e
+end
+fn vwpct c uchar to void
+if or vwdig c or and ge c 65 le c 90 and ge c 97 le c 122
+vwhc c
+ret
+end
+vwhc 37
+vwhc hhexd shr ulong c 4
+vwhc hhexd and ulong c 15
+end
+fn vwbdoc to void
+vwht tdoc1q
+for i ulong get glql 0
+vwpct get glq i
+end
+vwht tampq
+for i ulong get gqql 0
+vwpct get gqq i
+end
+vwht tdoc2
+vwhd 35
+vwht tdoc3
+end
+fn vwbq cs edit ulong 320 io edit uchar 131072 to void
+put glql 0 0
+put gqql 0 0
+if vwqget cs io tqlane
+n = hmin get gql 0 64
+for i ulong n
+put glq i get gq i
+end
+put glql 0 n
+end
+if vwqget cs io tqq
+n = hmin get gql 0 256
+for i ulong n
+put gqq i vwlower get gq i
+end
+put gqql 0 n
+end
+end
+note GET /p/board?lane=LANE&q=TEXT
+fn vwpboard cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+vwbq cs io
+r = vwhtml cs io
+vwbdoc
+ok = vwrdix
+a = vwsecrd tnboard
+vwh3 tnboard a 45000
+b0 = get goa 0
+e = get gol 0
+vwht tolb
+c = ulong 0
+for it ulong 100000
+if or le e b0 ge c 300
+break
+end
+if eq get gob sub e 1 10
+e = sub e 1
+continue
+end
+s = vwlstart b0 e
+if vwbshow s e
+vwbli s e
+c = add c 1
+if eq rem c 40 0
+r = hfe r vwflush cs io buf
+end
+end
+e = s
+end
+vwht tole
+if eq c 0
+vwht tmuted
+vwht tnomatch
+vwht tdivc
+end
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note vwlanes: the distinct BOARD lanes (sorted) for the filter's list; from gob (board section)
+fn vwlanes to void
+put glann 0 0
+b0 = get goa 0
+n = get gol 0
+p = b0
+for it ulong 100000
+if ge p n
+break
+end
+e = vwlinee p n
+if vwbparse p e
+vwlanead get gbp 1 get gbp 2
+end
+p = add e 1
+end
+end
+fn vwlanead p ulong q ulong to void
+l = sub q p
+if or eq l 0 gt l 47
+ret
+end
+n = get glann 0
+ix = n
+for i ulong n
+c = vwlancmp i p l
+if eq c 0
+ret
+end
+if eq c 1
+ix = i
+break
+end
+end
+if ge n 64
+ret
+end
+k = n
+for it ulong 64
+if le k ix
+break
+end
+vwlanmv sub k 1 k
+k = sub k 1
+end
+for i ulong l
+put glan add mul ix 48 i get gob add p i
+end
+put glanl ix l
+put glann 0 add n 1
+end
+fn vwlanmv s ulong d ulong to void
+for i ulong 48
+put glan add mul d 48 i get glan add mul s 48 i
+end
+put glanl d get glanl s
+end
+note vwlancmp: 0 equal, 1 gob[p, p+l) sorts before lane i, 2 after
+fn vwlancmp i ulong p ulong l ulong to ulong
+m = get glanl i
+for k ulong hmin l m
+a = get gob add p k
+b = get glan add mul i 48 k
+if lt a b
+ret 1
+end
+if gt a b
+ret 2
+end
+end
+if eq l m
+ret 0
+end
+if lt l m
+ret 1
+end
+ret 2
+end
+text topt1 "<option value=\""
+text topt2 "</option>"
+fn vwlanopt to void
+for i ulong get glann 0
+vwht topt1
+vwlanname i
+vwht tqgt
+vwlanname i
+vwht topt2
+end
+end
+fn vwlanname i ulong to void
+b = mul i 48
+for k ulong get glanl i
+vwhe get glan add b k
+end
+end
+note ---- QUESTIONS / DECISIONS (latest 6 "## " entries, newest first) and CLAIMS (whole file)
+fn vwisent p ulong n ulong to bool
+if gt add p 3 n
+ret false
+end
+if ne get gob p 35
+ret false
+end
+if ne get gob add p 1 35
+ret false
+end
+ret eq get gob add p 2 32
+end
+fn vwent1 s ulong x ulong to void
+e = vwlinee s x
+vwht tent1
+vwheo add s 3 sub e add s 3
+vwht tent2
+b = vwgsp2 add e 1 x
+t = x
+for it ulong 100000
+if le t b
+break
+end
+c = get gob sub t 1
+if and and ne c 10 ne c 32 ne c 13
+break
+end
+t = sub t 1
+end
+if lt b t
+if gt sub t b 16384
+vwheo b 16384
+vwht ttrunc
+else
+vwheo b sub t b
+end
+end
+vwht tent3
+end
+fn vwgsp2 p ulong x ulong to ulong
+q = p
+for it ulong 100000
+if ge q x
+ret x
+end
+c = get gob q
+if and and ne c 10 ne c 32 ne c 13
+ret q
+end
+q = add q 1
+end
+ret q
+end
+fn vwents cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+st = new ulong 1024 0
+b0 = get goa 0
+n = get gol 0
+k = ulong 0
+p = b0
+for it ulong 100000
+if ge p n
+break
+end
+if and vwisent p n lt k 1024
+put st k p
+k = add k 1
+end
+p = add vwlinee p n 1
+end
+r = long 0
+if eq k 0
+vwht tpreo
+vwheo hmax b0 sub n 4000 sub n hmax b0 sub n 4000
+vwht tpreend
+ret r
+end
+for i ulong hmin k 6
+j = sub sub k 1 i
+x = n
+if lt add j 1 k
+x = get st add j 1
+end
+vwent1 get st j x
+r = hfe r vwflush cs io buf
+end
+ret r
+end
+note GET /p/entries?f=questions|decisions|claims
+fn vwpents cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+w = ulong 0
+if vwqget cs io tqf
+if vwqis tqfile
+w = 1
+end
+if vwqis tdfile
+w = 2
+end
+if vwqis tcfile
+w = 3
+end
+end
+r = vwhtml cs io
+vwdoc 10 35
+ok = vwrdix
+if eq w 0
+vwht tmuted
+vwht tnosessn
+vwht tdivc
+end
+if eq w 1
+a = vwsecrd tnques
+vwh3 tnques a 45000
+r = hfe r vwents cs io buf
+end
+if eq w 2
+a = vwsecrd tndec
+vwh3 tndec a 45000
+r = hfe r vwents cs io buf
+end
+if eq w 3
+a = vwsecrd tnclaim
+vwh3 tnclaim a 45000
+vwht tpreo
+b0 = get goa 0
+vwheo b0 sub get gol 0 b0
+vwht tpreend
+end
+vwht tdocend
+ret hfe r vwfin cs io buf
+end
+note ---- GET /palette.css: the xterm-256 colours as classes .fN (text) and .bN (background)
+fn vwhex2 v ulong to void
+vwhc hhexd shr v 4
+vwhc hhexd and v 15
+end
+fn vwcol n ulong to void
+if lt n 16
+for i ulong 6
+vwhc get tbase16 add mul n 6 i
+end
+ret
+end
+if lt n 232
+m = sub n 16
+vwcubeh div m 36
+vwcubeh rem div m 6 6
+vwcubeh rem m 6
+ret
+end
+g = add 8 mul 10 sub n 232
+vwhex2 g
+vwhex2 g
+vwhex2 g
+end
+fn vwcubeh k ulong to void
+vwhc get tcube mul k 2
+vwhc get tcube add mul k 2 1
+end
+fn vwpal cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+put ghl 0 0
+for n ulong 256
+vwht tpalc1
+vwhd n
+vwht tpalc2
+vwcol n
+vwht tpalc3
+vwhd n
+vwht tpalc4
+vwcol n
+vwht tpalc5
+end
+m = get ghl 0
+for i ulong m
+put buf i get gh i
+end
+put ghl 0 0
+r = hrspst cs io 200
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io ttcss
+r = hfe r hhend cs io 0 m
+r = hfe r hput cs io view part buf 0 m
+ret hfe r hwfin cs io
+end
+note ---- the pages Drake opens: / (every hive) and /s/NAME (one session with its input box)
+text ttitle "hive-view"
+text ttop1 "<header class=\"top\"><h1>hive-view</h1><iframe class=\"fstatus\" src=\"/p/status\" title=\"feed status\"></iframe></header>\n<p class=\"note\">Every panel refreshes itself: session screens every 2 to 3 seconds, everything else every 10 seconds. A panel that stops refreshing says NOT LIVE. If panels show a browser error page, the server is down: reload this page when it is back.</p>\n"
+text ttop2 "<section class=\"panel queen\"><h2>Queen · omp-queen <a href=\"/s/omp-queen\">open on its own page</a></h2><iframe class=\"fqueen\" src=\"/p/pane?n=omp-queen\" title=\"omp-queen\"></iframe>\n"
+text ttop3 "</section>\n<section class=\"panel\"><h2>omp sessions <span class=\"muted\">click a tile to open that session with its own input box</span></h2><iframe class=\"ftiles\" src=\"/p/tiles?g=omp\" title=\"omp sessions\"></iframe></section>\n<div class=\"cols\"><section class=\"panel\"><h2>Hermes</h2><iframe class=\"fhermes\" src=\"/p/hermes\" title=\"Hermes\"></iframe><h2>lead sessions</h2><iframe class=\"fleads\" src=\"/p/tiles?g=lead\" title=\"lead sessions\"></iframe></section>\n<section class=\"panel\"><h2>Machine</h2><iframe class=\"fmach\" src=\"/p/machine\" title=\"machine\"></iframe></section></div>\n"
+text ttop4 "<section class=\"panel\"><h2>BOARD <span class=\"muted\">newest first</span></h2><form class=\"filter\" method=\"get\" action=\"/p/board\" target=\"board\"><select name=\"lane\"><option value=\"\">all lanes</option>"
+text ttop5 "</select><input name=\"q\" placeholder=\"text filter\" autocomplete=\"off\"><button>Filter</button></form><iframe name=\"board\" class=\"fboard\" src=\"/p/board\" title=\"BOARD\"></iframe></section>\n<div class=\"cols\"><section class=\"panel\"><h2>Latest QUESTIONS</h2><iframe class=\"fent\" src=\"/p/entries?f=questions\" title=\"questions\"></iframe></section>\n<section class=\"panel\"><h2>Latest DECISIONS</h2><iframe class=\"fent\" src=\"/p/entries?f=decisions\" title=\"decisions\"></iframe></section></div>\n<section class=\"panel\"><h2>CLAIMS</h2><iframe class=\"fent\" src=\"/p/entries?f=claims\" title=\"claims\"></iframe></section>\n<section class=\"panel\"><h2>Other tmux sessions</h2><iframe class=\"ftiles\" src=\"/p/tiles?g=other\" title=\"other sessions\"></iframe></section>\n</body></html>\n"
+text tses1 "<header class=\"top\"><a class=\"back\" href=\"/\">← all hives</a><h1>"
+text tses2 "</h1><iframe class=\"fstatus\" src=\"/p/status\" title=\"feed status\"></iframe></header>\n"
+text tses3 "<section class=\"panel\"><iframe class=\"fbig\" src=\"/p/pane?n="
+text tses4 "\" title=\"session screen\"></iframe>\n"
+text tses5 "</section>\n</body></html>\n"
+text tfrm1 "<form class=\"send\" method=\"post\" action=\"/send\"><input type=\"hidden\" name=\"s\" value=\""
+text tfrm2 "\"><input type=\"hidden\" name=\"k\" value=\""
+text tfrm3 "\"><input type=\"hidden\" name=\"r\" value=\""
+text tfrm4 "\"><div class=\"target\">Types into tmux session “"
+text tfrm5 "” exactly as written, then presses Enter.</div><div class=\"row\"><input class=\"text\" name=\"t\" maxlength=\"4096\" autocomplete=\"off\" spellcheck=\"false\" placeholder=\"type here, then Send\"><button name=\"a\" value=\"line\">Send + Enter</button><button name=\"a\" value=\"enter\">Enter</button><button name=\"a\" value=\"escape\">Escape</button></div></form>\n"
+text tsignout "<header class=\"top\"><h1>hive-view</h1></header><div class=\"msg bad\">Not signed in on this device. Open the one-time link (it contains the access token) once on this device, then this page works.</div></body></html>\n"
+text tmsgok "<div class=\"msg ok\">"
+text tmsgbad "<div class=\"msg bad\">"
+text tsentn "Sent "
+text tsentb " bytes to "
+text tsente ", then pressed Enter."
+text tpressen "Pressed Enter in "
+text tpresesc "Pressed Escape in "
+text tdotend "."
+text tqr "q"
+text tsr "s"
+text tcsrfp "hive-view form key\n"
+fn vwcsrfk to void
+if eq get gcsrfk 0 1
+ret
+end
+src = new uchar 96 0
+pre = ulong 0
+for i ulong len tcsrfp
+put src i get tcsrfp i
+pre = add pre 1
+end
+for i ulong 64
+put src add pre i get gtok i
+end
+dg = new uchar 32 0
+k = sha2_digest 256 view part src 0 add pre 64 dg
+for i ulong 32
+c = get dg i
+put gcsrf mul i 2 get thexd shr c 4
+put gcsrf add mul i 2 1 get thexd and c 15
+end
+put gcsrfk 0 1
+end
+fn vwform r view uchar * to void
+vwcsrfk
+vwht tfrm1
+vwheq
+vwht tfrm2
+for i ulong 64
+vwhc get gcsrf i
+end
+vwht tfrm3
+vwht r
+vwht tfrm4
+vwheq
+vwht tfrm5
+end
+note vwmsg: the result of the last send, from ?m=CODE&a=ACTION&b=BYTES&s=NAME (all checked)
+fn vwmsg cs edit ulong 320 io edit uchar 131072 to void
+if not vwqget cs io tqm
+ret
+end
+m = vwqnum
+if gt get gql 0 2
+ret
+end
+if eq get gql 0 0
+ret
+end
+act = ulong 0
+if vwqget cs io tqa
+act = vwqnum
+end
+nb = ulong 0
+if vwqget cs io tqb
+nb = vwqnum
+end
+if not vwqget cs io tqs
+put gql 0 0
+end
+if not vwqname
+put gql 0 0
+end
+if eq m 0
+vwht tmsgok
+vwmsgok act nb
+else
+vwht tmsgbad
+vwmsgbad m
+end
+vwht tdivc
+end
+fn vwmsgok act ulong nb ulong to void
+if eq act 0
+vwht tsentn
+vwhd nb
+vwht tsentb
+vwheq
+vwht tsente
+ret
+end
+if eq act 1
+vwht tpressen
+else
+vwht tpresesc
+end
+vwheq
+vwht tdotend
+end
+fn vwmsgbad m ulong to void
+if eq m 1
+vwhet tbadbody
+end
+if eq m 2
+vwhet tbadname
+end
+if eq m 3
+vwhet tbadact
+end
+if eq m 4
+vwhet tbadtext
+end
+if eq m 5
+vwhet tnosess
+end
+if eq m 6
+vwhet ttmuxbad
+end
+if eq m 7
+vwhet tbigbody
+end
+if eq m 8
+vwhet tlogbad
+end
+if gt m 8
+vwhet tbadbody
+end
+end
+note GET / (signed in): every hive on one page
+fn vwptop cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+r = vwhtml cs io
+vwpage ttitle
+vwht ttop1
+vwmsg cs io
+vwht ttop2
+n = len tompq
+for i ulong n
+put gq i get tompq i
+end
+put gql 0 n
+vwform tqr
+vwht ttop3
+vwht ttop4
+ok = vwrdix
+a = vwsecrd tnboard
+vwlanes
+vwlanopt
+vwht ttop5
+ret hfe r vwfin cs io buf
+end
+fn vwpsignout cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+put ghl 0 0
+r = hrspst cs io 403
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io tthtml
+r = hfe r hhend cs io 1 0
+vwpage ttitle
+vwht tsignout
+ret hfe r vwfin cs io buf
+end
+note GET /s/NAME: one session, large, with its own input box. gq holds the checked NAME.
+fn vwpsess cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+keep = new uchar 64 0
+n = get gql 0
+for i ulong n
+put keep i get gq i
+end
+r = vwhtml cs io
+vwht tpage1
+vwheq
+vwht tpage2
+vwht tses1
+vwheq
+vwht tses2
+vwmsg cs io
+for i ulong n
+put gq i get keep i
+end
+put gql 0 n
+vwht tses3
+vwheq
+vwht tses4
+vwform tsr
+vwht tses5
+ret hfe r vwfin cs io buf
+end
+note vwsname: the path is /s/NAME with a valid NAME; it is left in gq
+fn vwsname cs edit ulong 320 io edit uchar 131072 to bool
+tg = get cs HTOFF
+pl = hplen cs io
+if lt pl 4
+ret false
+end
+if ne get io tg 47
+ret false
+end
+if ne get io add tg 1 115
+ret false
+end
+if ne get io add tg 2 47
+ret false
+end
+n = sub pl 3
+if gt n 63
+ret false
+end
+for i ulong n
+put gq i get io add add tg 3 i
+end
+put gql 0 n
+ret vwqname
+end
diff --git a/src/poll.om b/src/poll.om
new file mode 100644
index 0000000..9624307
--- /dev/null
+++ b/src/poll.om
@@ -0,0 +1,1575 @@
+note hive-view src/poll.om: the one shared poller. Every 2 s it lists tmux sessions and captures
+note each pane once; every 10 s it reads the shared files, GPU, window, pool locks and machine
+note state; every 30 s the Hermes kanban list. It only reads hive state: the single write it makes
+note is its own snapshot files under the run directory (<run>/s<slot>, <run>/index).
+note Slots 0..47 are tmux sessions, 48..63 fixed sections. Each snapshot file is
+note "NAME<TAB>KIND<TAB>GEN<LF>" followed by the body; GEN is unique per content change.
+global gsnam uchar 4096
+global gsnl ulong 64
+global gsgen ulong 64
+global gshash ulong 64
+global gstms ulong 64
+note gscs: when a pane was last captured (unix s); gslh: hash of its tmux list line then
+global gscs ulong 48
+global gslh ulong 48
+global gkbsig ulong 1
+global gkbrun ulong 1
+note gcq: pane captures queued this tick, 4 words each (slot, list line start, name length, line end)
+global gcq ulong 192
+global gcqn ulong 1
+global gnonce uchar 16
+global gsst ulong 64
+global gskind ulong 64
+global gslive ulong 64
+global ggen ulong 1
+global glsb uchar 32768
+global glsl ulong 1
+global gtmux ulong 1
+global gfdent uchar 16384
+global gsnm uchar 16
+global gsnml ulong 1
+global gnvn ulong 1
+global gwid uchar 64
+global gwidl ulong 1
+global gdent uchar 16384
+global glk uchar 65536
+global glkw ulong 1
+global glkp ulong 1
+global glkl ulong 1
+global gpln uchar 1024
+global gplnl ulong 16
+global gplino ulong 16
+global gpln_n ulong 1
+text ttmux "/usr/bin/tmux"
+text tlsess "list-sessions"
+text tdashf "-F"
+note tmux replaces a tab in -F output with '_' for this client, so fields are split by '|'
+note (refused in the session names we accept)
+note #{window_activity} moves whenever the window's panes print output (tested on tmux 3.4)
+text tlsfmt "#{session_name}|#{pane_current_command}|#{session_attached}|#{window_activity}|#{window_width}x#{window_height}"
+text tcapt "capture-pane"
+text tdmsg "display-message"
+text tsemi ";"
+text tmarkp "@@hv-"
+text tdashe "-e"
+text tdashp "-p"
+text tdasht "-t"
+text tompq "omp-queen"
+text tomp "omp"
+text tleadp "lead-"
+text tksec "sec"
+text tkqueen "queen"
+text tkomp "omp"
+text tklead "lead"
+text tkother "other"
+text tnkan "kanban"
+text tnherm "hermes"
+text tnboard "board"
+text tnques "questions"
+text tndec "decisions"
+text tnclaim "claims"
+text tngpu "gpu"
+text tnwin "window"
+text tnpool "pools"
+text tnmach "machine"
+text tnledg "ledger"
+text thermes "/.local/bin/hermes"
+text tkdb "/.hermes/kanban/boards/aien-hive/kanban.db"
+text tkwal "/.hermes/kanban/boards/aien-hive/kanban.db-wal"
+text tkanban "kanban"
+text tdboard "--board"
+text taienh "aien-hive"
+text tlist "list"
+text tcg1 "/sys/fs/cgroup/user.slice/user-"
+text tcg2 ".slice/user@"
+text tcg3 ".service/app.slice/hermes-gateway.service/cgroup.events"
+text tpopul "populated 1"
+text tgwup "gateway\tup\n"
+text tgwdown "gateway\tdown\n"
+text tpause "/handoffs/hive/queen/PAUSE"
+text tpyes "pause\tyes\t"
+text tpno "pause\tno\n"
+text tpboard "/handoffs/BOARD.md"
+text tpques "/handoffs/hive/queen/QUESTIONS.md"
+text tpdec "/handoffs/hive/queen/DECISIONS.md"
+text tpclaim "/handoffs/hive/CLAIMS.md"
+text tpledg "/work/pearl/economics/ledger.jsonl"
+text tabsent "absent\n"
+text tploadav "/proc/loadavg"
+text tpmem "/proc/meminfo"
+text tpstat "/proc/stat"
+text thload "#load\n"
+text thmem "#mem\n"
+text thstat "#cpu\n"
+note GPU: hive-view sends the GB10 no queries of its own (BOARD 2026-11-07T07:12:00Z: no GPU-bound
+note queries outside an authorized spark-window). Power and utilization come from the newest row of
+note the existing spark-sensors log; GPU users are the processes holding /dev/nvidia* open.
+text tsensd "/yardsticks/sensors"
+text thsens "#sensors\n"
+text thapps "#apps\n"
+text tdevnv "/dev/nvidia"
+text tfdsl "/fd/"
+text tfd "/fd"
+text tproc0 "/proc"
+text twin "/yardsticks/windows/"
+text twopen "OPEN"
+text twqueue "QUEUE"
+text twnone "open\tnone\n"
+text twopenl "open\t"
+text twk0 "name"
+text twk1 "owner"
+text twk2 "gb10"
+text twk3 "quiet"
+text twk4 "held"
+text twk5 "requested"
+text twk6 "lease"
+text twk7 "holder.pid"
+text tqline "queue\t"
+text talive "alive\t"
+text tyes "yes"
+text tno "no"
+text tproc "/proc/"
+text tcmdl "/cmdline"
+text tqueen "/handoffs/hive/queen"
+text tpoolp "pool-"
+text tlockx ".lock"
+text tplocks "/proc/locks"
+text tpooll "pool\t"
+text tholds "holds"
+text twaits "waits"
+text tfree "free"
+text tindex "/index"
+text thdrp "P\t"
+note ---- slots
+fn vwkindt k ulong to void
+if eq k 1
+vwsbt tkqueen
+ret
+end
+if eq k 2
+vwsbt tkomp
+ret
+end
+if eq k 3
+vwsbt tklead
+ret
+end
+if eq k 4
+vwsbt tkother
+ret
+end
+vwsbt tksec
+end
+fn vwsetnm slot ulong t view uchar * to void
+b = mul slot 64
+n = hmin len t 63
+for i ulong n
+put gsnam add b i get t i
+end
+put gsnl slot n
+put gskind slot 0
+end
+fn vwinitsec to void
+rb = new uchar 8 0
+r = random rb 0 8 0
+for i ulong 8
+put gnonce mul i 2 get thexd shr get rb i 4
+put gnonce add mul i 2 1 get thexd and get rb i 15
+end
+vwsetnm 48 tnkan
+vwsetnm 49 tnherm
+vwsetnm 50 tnboard
+vwsetnm 51 tnques
+vwsetnm 52 tndec
+vwsetnm 53 tnclaim
+vwsetnm 54 tngpu
+vwsetnm 55 tnwin
+vwsetnm 56 tnpool
+vwsetnm 57 tnmach
+vwsetnm 58 tnledg
+end
+fn vwfnv a ulong n ulong to ulong
+h = ulong 14695981039346656037
+for i ulong n
+h = xor h ulong get gsb add a i
+h = mul h 1099511628211
+end
+ret h
+end
+note vwhdr: "NAME<TAB>KIND<TAB>GEN<LF>" into ghd (built with gsb as scratch after the body)
+fn vwhdr slot ulong g ulong to void
+keep = get gsl 0
+b = mul slot 64
+for i ulong get gsnl slot
+vwsbc get gsnam add b i
+end
+vwsbc 9
+vwkindt get gskind slot
+vwsbc 9
+vwsbd g
+vwsbc 10
+n = sub get gsl 0 keep
+m = hmin n 255
+for i ulong m
+put ghd i get gsb add keep i
+end
+put ghdl 0 m
+put gsl 0 keep
+end
+note vwcommit: publish gsb[0, gsl) for slot when it changed; st != 0 marks the slot stale (old
+note snapshot and its time are kept, so the page shows its real age)
+fn vwcommit slot ulong st ulong to void
+if ne st 0
+put gsst slot st
+ret
+end
+h = vwfnv 0 get gsl 0
+h = mul xor h add get gskind slot 1 1099511628211
+if or eq get gsgen slot 0 ne h get gshash slot
+g = add get ggen 0 1
+put ggen 0 g
+vwhdr slot g
+if not vwwsec slot
+put gsst slot 5
+ret
+end
+put gsgen slot g
+put gshash slot h
+end
+put gstms slot vwnowms
+put gsst slot 0
+end
+note ---- tmux sessions and panes
+fn vwnmeq slot ulong a ulong n ulong to bool
+b = mul slot 64
+for i ulong n
+if ne get gsnam add b i get glsb add a i
+ret false
+end
+end
+ret true
+end
+fn vwslot a ulong n ulong to ulong
+for s ulong 48
+if eq get gsnl s n
+if vwnmeq s a n
+ret s
+end
+end
+end
+for s ulong 48
+if eq get gsnl s 0
+b = mul s 64
+for i ulong n
+put gsnam add b i get glsb add a i
+end
+put gsnl s n
+put gsgen s 0
+put gshash s 0
+put gstms s 0
+put gscs s 0
+put gslh s 0
+put gsst s 0
+ret s
+end
+end
+ret 64
+end
+fn vwlbeq a ulong n ulong t view uchar * to bool
+if ne n len t
+ret false
+end
+for i ulong n
+if ne get glsb add a i get t i
+ret false
+end
+end
+ret true
+end
+fn vwkindof a ulong n ulong c ulong m ulong to ulong
+if vwlbeq a n tompq
+ret 1
+end
+if vwlbeq c m tomp
+ret 2
+end
+if gt n len tleadp
+if vwlbeq a len tleadp tleadp
+ret 3
+end
+end
+ret 4
+end
+note ---- pane captures, batched: one tmux client per batch of up to 6 panes instead of one per
+note pane (a tmux client start costs ~5 ms of CPU, measured). Each capture is preceded by a
+note display-message printing "@@hv-<nonce>-<slot>@@"; the nonce is random per poller, so pane
+note text cannot fake a boundary. tmux stops a command sequence at the first failing command,
+note so after a nonzero exit the last started segment is discarded, never shown as empty.
+fn vwcapq slot ulong a ulong n ulong e ulong to void
+k = get gcqn 0
+if ge k 48
+ret
+end
+b = mul k 4
+put gcq b slot
+put gcq add b 1 a
+put gcq add b 2 n
+put gcq add b 3 e
+put gcqn 0 add k 1
+end
+fn vwcapall to void
+k = ulong 0
+for it ulong 48
+if ge k get gcqn 0
+ret
+end
+m = hmin 6 sub get gcqn 0 k
+vwcapb k m
+k = add k m
+end
+end
+fn vwmark slot ulong to void
+vwkopen
+vwkc 64
+vwkc 64
+vwkc 104
+vwkc 118
+vwkc 45
+for i ulong 16
+vwkc get gnonce i
+end
+vwkc 45
+vwkd slot
+vwkc 64
+vwkc 64
+end
+fn vwkd v ulong to void
+if ge v 10
+vwkd div v 10
+end
+vwkc uchar add rem v 10 48
+end
+fn vwcapb k ulong m ulong to void
+vwkb
+vwka ttmux
+for j ulong m
+if gt j 0
+vwka tsemi
+end
+vwcapent mul add k j 4
+end
+r = vwrun 5000000000
+vwsegs k m eq r 0
+end
+fn vwcapent b ulong to void
+vwka tdmsg
+vwka tdashp
+vwmark get gcq b
+vwka tsemi
+vwka tcapt
+vwka tdashe
+vwka tdashp
+vwka tdasht
+vwkopen
+vwkc 61
+a = get gcq add b 1
+for i ulong get gcq add b 2
+vwkc get glsb add a i
+end
+vwkc 58
+end
+note vwsegs: split gob[goa, gol) at marker lines and commit each complete segment to its slot
+fn vwsegs k ulong m ulong ok bool to void
+a = get goa 0
+e = get gol 0
+cur = ulong 64
+cs = ulong 0
+p = a
+for it ulong 1000000
+if ge p e
+break
+end
+q = vwlend p e
+s = vwmarkat p q
+if lt s 64
+if lt cur 64
+vwseg1 k m cur cs p
+end
+cur = s
+cs = q
+end
+p = q
+end
+if and ok lt cur 64
+vwseg1 k m cur cs e
+end
+end
+note vwlend: the index just past the LF ending the line at p (or e)
+fn vwlend p ulong e ulong to ulong
+for i ulong sub e p
+if eq get gob add p i 10
+ret add add p i 1
+end
+end
+ret e
+end
+note vwmarkat: the slot named by a marker line gob[p, q), else 64
+fn vwmarkat p ulong q ulong to ulong
+if lt sub q p 25
+ret 64
+end
+if ne get gob sub q 1 10
+ret 64
+end
+for i ulong 5
+if ne get gob add p i get tmarkp i
+ret 64
+end
+end
+for i ulong 16
+if ne get gob add add p 5 i get gnonce i
+ret 64
+end
+end
+if ne get gob add p 21 45
+ret 64
+end
+v = ulong 0
+d = ulong 0
+for i ulong sub sub q p 25
+c = get gob add add p 22 i
+if not vwdig c
+ret 64
+end
+v = add mul v 10 ulong sub c 48
+d = add d 1
+end
+if or eq d 0 gt d 2
+ret 64
+end
+if ne get gob sub q 3 64
+ret 64
+end
+if ne get gob sub q 2 64
+ret 64
+end
+if ge v 48
+ret 64
+end
+ret v
+end
+note vwseg1: commit capture gob[s, x) to slot when that slot is in batch [k, k+m)
+fn vwseg1 k ulong m ulong slot ulong s ulong x ulong to void
+for j ulong m
+b = mul add k j 4
+if eq get gcq b slot
+vwsegc b s x
+ret
+end
+end
+end
+fn vwsegc b ulong s ulong x ulong to void
+slot = get gcq b
+la = get gcq add b 1
+lz = get gcq add b 3
+put gsl 0 0
+for i ulong sub lz la
+vwsbc get glsb add la i
+end
+vwsbc 10
+vwsbo s sub x s
+vwcommit slot 0
+put gscs slot div vwnowms 1000
+put gslh slot vwlhash la lz
+end
+fn vwtabat a ulong e ulong to ulong
+for i ulong sub e a
+if eq get glsb add a i 124
+ret add a i
+end
+end
+ret e
+end
+fn vwnameok a ulong n ulong to bool
+if or eq n 0 gt n 63
+ret false
+end
+for i ulong n
+if not vwnamec get glsb add a i
+ret false
+end
+end
+ret true
+end
+fn vwline a ulong e ulong to void
+t1 = vwtabat a e
+n = sub t1 a
+if not vwnameok a n
+ret
+end
+if ge t1 e
+ret
+end
+t2 = vwtabat add t1 1 e
+slot = vwslot a n
+if ge slot 48
+ret
+end
+put gslive slot 1
+put gskind slot vwkindof a n add t1 1 sub t2 add t1 1
+h = vwlhash a e
+if vwfresh slot h vwactof a e
+put gstms slot vwnowms
+ret
+end
+vwcapq slot a n e
+end
+note vwfresh: the last capture is still exact, so tmux need not be asked again: it succeeded,
+note the list line (command, clients, size, activity) is unchanged, the window's last output
+note is older than the second before that capture, and the capture is under 20 s old
+fn vwfresh slot ulong h ulong act ulong to bool
+cs = get gscs slot
+if or eq get gsgen slot 0 ne get gsst slot 0
+ret false
+end
+if or ne h get gslh slot eq cs 0
+ret false
+end
+if ge add act 1 cs
+ret false
+end
+ret lt div vwnowms 1000 add cs 20
+end
+fn vwlhash a ulong e ulong to ulong
+h = ulong 14695981039346656037
+for i ulong sub e a
+h = mul xor h ulong get glsb add a i 1099511628211
+end
+ret h
+end
+note vwactof: the 4th '|' field of the list line glsb[a, e) as a number (0 when malformed)
+fn vwactof a ulong e ulong to ulong
+p = a
+for k ulong 3
+p = add vwtabat p e 1
+end
+v = ulong 0
+for i ulong 20
+if ge add p i e
+ret v
+end
+c = get glsb add p i
+if not vwdig c
+ret v
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+fn vwpanes to void
+vwkb
+vwka ttmux
+vwka tlsess
+vwka tdashf
+vwka tlsfmt
+r = vwrun 3000000000
+if ne r 0
+put gtmux 0 ulong add r 10
+for s ulong 48
+if eq get gslive s 1
+put gsst s 2
+end
+end
+ret
+end
+put gtmux 0 0
+n = hmin get gol 0 len glsb
+for i ulong n
+put glsb i get gob i
+end
+put glsl 0 n
+for s ulong 48
+put gslive s 0
+end
+put gcqn 0 0
+a = ulong 0
+for i ulong n
+if eq get glsb i 10
+vwline a i
+a = add i 1
+end
+end
+vwcapall
+for s ulong 48
+if eq get gslive s 0
+put gsnl s 0
+put gsgen s 0
+put gshash s 0
+end
+end
+end
+note ---- file sections
+fn vwfsec slot ulong tail bool cap ulong to void
+put gsl 0 0
+r = long 0
+if tail
+r = vwrdtail cap
+else
+r = vwrdall cap
+end
+if lt r 0
+vwcommit slot ulong neg r
+ret
+end
+vwsbol
+vwcommit slot 0
+end
+fn vwhpath t view uchar * to void
+vwpb
+vwph
+vwpt t
+end
+fn vwfind t view uchar * to bool
+a = get goa 0
+b = get gol 0
+m = len t
+if gt m sub b a
+ret false
+end
+for i ulong add sub sub b a m 1
+if vwmatch add a i t
+ret true
+end
+end
+ret false
+end
+fn vwmatch p ulong t view uchar * to bool
+for j ulong len t
+if ne get gob add p j get t j
+ret false
+end
+end
+ret true
+end
+note vwsbl1: append the first line of gob[goa, gol) (without its LF)
+fn vwsbl1 to void
+a = get goa 0
+b = get gol 0
+for i ulong sub b a
+c = get gob add a i
+if eq c 10
+ret
+end
+vwsbc c
+end
+end
+note vwsblines: append the first k lines of gob[goa, gol) (with their LF)
+fn vwsblines k ulong to void
+a = get goa 0
+b = get gol 0
+seen = ulong 0
+for i ulong sub b a
+c = get gob add a i
+vwsbc c
+if eq c 10
+seen = add seen 1
+if ge seen k
+ret
+end
+end
+end
+end
+fn vwhermes to void
+put gsl 0 0
+vwpb
+vwpt tcg1
+uid = ulong getuid
+vwpd uid
+vwpt tcg2
+vwpd uid
+vwpt tcg3
+r = vwrdall 4096
+if and ge r 0 vwfind tpopul
+vwsbt tgwup
+else
+vwsbt tgwdown
+end
+vwhpath tpause
+r = vwrdall 2048
+if ge r 0
+vwsbt tpyes
+vwsbl1
+vwsbc 10
+else
+vwsbt tpno
+end
+vwcommit 49 0
+end
+fn vwledger to void
+vwhpath tpledg
+put gsl 0 0
+r = vwrdtail 16384
+if eq r -2
+vwsbt tabsent
+vwcommit 58 0
+ret
+end
+if lt r 0
+vwcommit 58 ulong neg r
+ret
+end
+vwsbol
+vwcommit 58 0
+end
+fn vwmach to void
+put gsl 0 0
+vwsbt thload
+vwpb
+vwpt tploadav
+r = vwrdall 256
+if lt r 0
+vwcommit 57 ulong neg r
+ret
+end
+vwsbl1
+vwsbc 10
+vwsbt thmem
+vwpb
+vwpt tpmem
+r = vwrdall 4096
+vwsblines 3
+vwsbt thstat
+vwpb
+vwpt tpstat
+r = vwrdall 4096
+vwcpupct
+vwcommit 57 0
+end
+note vwcpupct: "#cpu" then the busy percentage of all cores since the previous sample (from the
+note first /proc/stat line: idle = idle + iowait, total = the first 8 fields); "measuring" first
+global gcpu ulong 2
+text tmeasr "measuring\n"
+fn vwcpupct to void
+n = get gol 0
+p = ulong 3
+tot = ulong 0
+idl = ulong 0
+for k ulong 8
+for s ulong 64
+if or ge p n ne get gob p 32
+break
+end
+p = add p 1
+end
+v = ulong 0
+for s ulong 24
+if ge p n
+break
+end
+c = get gob p
+if not vwdig c
+break
+end
+v = add mul v 10 ulong sub c 48
+p = add p 1
+end
+tot = add tot v
+if or eq k 3 eq k 4
+idl = add idl v
+end
+end
+pt = get gcpu 0
+pi = get gcpu 1
+put gcpu 0 tot
+put gcpu 1 idl
+if or eq pt 0 le tot pt
+vwsbt tmeasr
+ret
+end
+dt = sub tot pt
+di = sub idl pi
+if gt di dt
+di = dt
+end
+vwsbd div add mul sub dt di 100 div dt 2 dt
+vwsbc 10
+end
+fn vwgpu to void
+put gsl 0 0
+vwsbt thsens
+vwsensor
+vwsbt thapps
+put gnvn 0 0
+vwpb
+vwpt tproc0
+fd = fopen gpth 0 get gpl 0 540672 0
+if lt fd 0
+vwcommit 54 ulong neg fd
+ret
+end
+for it ulong 64
+n = getdnts int fd gdent 0 len gdent
+if le n 0
+break
+end
+vwgpuls ulong n
+end
+x = fclose int fd
+vwcommit 54 0
+end
+note vwgpuls: each numeric /proc entry in gdent[0, n) that holds a /dev/nvidia* descriptor
+fn vwgpuls n ulong to void
+p = ulong 0
+for it ulong 4096
+if ge add p 19 n
+break
+end
+rl = or ulong get gdent add p 16 shl ulong get gdent add p 17 8
+if eq rl 0
+break
+end
+pid = vwdentn 0 add p 19 add p rl
+if and gt pid 0 lt get gnvn 0 16
+if vwnvpid pid
+put gnvn 0 add get gnvn 0 1
+vwsbd pid
+vwsbc 9
+vwcmdl pid
+vwsbc 10
+end
+end
+p = add p rl
+end
+end
+note vwdentn: the all-digit entry name in gdent (f 0) or gfdent (f 1) [a, NUL or e) as a number, else 0
+fn vwdentn f ulong a ulong e ulong to ulong
+v = ulong 0
+for i ulong sub e a
+c = get gdent add a i
+if eq f 1
+c = get gfdent add a i
+end
+if eq c 0
+ret v
+end
+if not vwdig c
+ret 0
+end
+v = add mul v 10 ulong sub c 48
+if gt v 4194304
+ret 0
+end
+end
+ret v
+end
+fn vwnvpid pid ulong to bool
+vwpb
+vwpt tproc
+vwpd pid
+vwpt tfd
+fd = fopen gpth 0 get gpl 0 540672 0
+if lt fd 0
+ret false
+end
+hit = false
+for it ulong 64
+n = getdnts int fd gfdent 0 len gfdent
+if le n 0
+break
+end
+if vwnvfds pid ulong n
+hit = true
+break
+end
+end
+x = fclose int fd
+ret hit
+end
+fn vwnvfds pid ulong n ulong to bool
+lb = new uchar 64 0
+p = ulong 0
+for it ulong 4096
+if ge add p 19 n
+break
+end
+rl = or ulong get gfdent add p 16 shl ulong get gfdent add p 17 8
+if eq rl 0
+break
+end
+if vwdig get gfdent add p 19
+vwpb
+vwpt tproc
+vwpd pid
+vwpt tfdsl
+vwpd vwdentn 1 add p 19 add p rl
+k = readlnk gpth 0 get gpl 0 lb 0 64
+if ge k long len tdevnv
+if heq view part lb 0 len tdevnv tdevnv
+ret true
+end
+end
+end
+p = add p rl
+end
+ret false
+end
+note vwsensor: the last complete row of the newest ~/yardsticks/sensors/YYYY-MM-DD.csv
+fn vwsensor to void
+put gsnml 0 0
+vwhpath tsensd
+fd = fopen gpth 0 get gpl 0 540672 0
+if lt fd 0
+vwsbc 10
+ret
+end
+for it ulong 64
+n = getdnts int fd gdent 0 len gdent
+if le n 0
+break
+end
+vwsnpick ulong n
+end
+x = fclose int fd
+if ne get gsnml 0 14
+vwsbc 10
+ret
+end
+vwhpath tsensd
+vwpc 47
+for i ulong 14
+vwpc get gsnm i
+end
+r = vwrdtail 1024
+if lt r 0
+vwsbc 10
+ret
+end
+vwsblast
+end
+fn vwsnpick n ulong to void
+p = ulong 0
+for it ulong 4096
+if ge add p 19 n
+break
+end
+rl = or ulong get gdent add p 16 shl ulong get gdent add p 17 8
+if eq rl 0
+break
+end
+if vwsnname add p 19 add p rl
+if or ne get gsnml 0 14 vwsnnewer add p 19
+for i ulong 14
+put gsnm i get gdent add add p 19 i
+end
+put gsnml 0 14
+end
+end
+p = add p rl
+end
+end
+note vwsnname: gdent[a..] is "DDDD-DD-DD.csv" followed by NUL
+fn vwsnname a ulong e ulong to bool
+if lt sub e a 15
+ret false
+end
+for i ulong 10
+c = get gdent add a i
+if or eq i 4 eq i 7
+if ne c 45
+ret false
+end
+else
+if not vwdig c
+ret false
+end
+end
+end
+if ne get gdent add a 10 46
+ret false
+end
+ret eq get gdent add a 14 0
+end
+fn vwsnnewer a ulong to bool
+for i ulong 10
+c = get gdent add a i
+d = get gsnm i
+if gt c d
+ret true
+end
+if lt c d
+ret false
+end
+end
+ret false
+end
+note vwsblast: append the last LF-terminated line of gob[goa, gol)
+fn vwsblast to void
+a = get goa 0
+e = get gol 0
+if le e a
+vwsbc 10
+ret
+end
+if ne get gob sub e 1 10
+vwsbc 10
+ret
+end
+s = a
+for i ulong sub sub e a 1
+if eq get gob add a i 10
+s = add add a i 1
+end
+end
+vwsbo s sub e s
+end
+note vwkanban: `hermes kanban list` costs about 0.6 s of CPU (measured), so it runs only when the
+note board's SQLite files changed (mtime or size of kanban.db / kanban.db-wal; listing does not
+note touch them, tested), and at least every 5 minutes; otherwise the last list is still current
+fn vwkanban to void
+sig = xor vwstsig tkdb mul vwstsig tkwal 31
+if and eq sig get gkbsig 0 ne sig 0
+if and eq get gsst 48 0 gt get gsgen 48 0
+if lt sub vwnowms get gkbrun 0 300000
+put gstms 48 vwnowms
+ret
+end
+end
+end
+put gkbsig 0 sig
+put gkbrun 0 vwnowms
+vwkb
+vwhpath thermes
+vwkopen
+for i ulong get gpl 0
+vwkc get gpth i
+end
+vwka tkanban
+vwka tdboard
+vwka taienh
+vwka tlist
+r = vwrun 15000000000
+put gsl 0 0
+if ne r 0
+vwcommit 48 ulong add 1000 add r 10
+ret
+end
+vwsbol
+vwcommit 48 0
+end
+note vwstsig: a hash of the mtime (s, ns) and size of ~/<t>; 0 when it cannot be read
+fn vwstsig t view uchar * to ulong
+vwhpath t
+r = stat gpth 0 get gpl 0 gstb 0 128
+if ne r 0
+ret 0
+end
+h = mul xor vwst64 88 vwst64 96 1099511628211
+ret add mul h 1099511628211 vwst64 48
+end
+note ---- spark-window state, read directly (no spark-window process: its status verb deletes
+note dead queue tickets, which would be a write)
+fn vwwinp to void
+vwpb
+vwph
+vwpt twin
+end
+fn vwidok to bool
+n = get gwidl 0
+if or eq n 0 gt n 63
+ret false
+end
+for i ulong n
+c = get gwid i
+if not or vwnamec c eq c 46
+ret false
+end
+end
+ret true
+end
+fn vwwkey t view uchar * to bool
+vwwinp
+for i ulong get gwidl 0
+vwpc get gwid i
+end
+vwpc 47
+vwpt t
+vwsbt t
+vwsbc 9
+r = vwrdall 512
+if ge r 0
+vwsbl1
+end
+vwsbc 10
+ret ge r 0
+end
+note vwalive: /proc/<pid> exists for the first decimal number in gob[goa, gol)
+fn vwpidof to ulong
+a = get goa 0
+b = get gol 0
+v = ulong 0
+for i ulong sub b a
+c = get gob add a i
+if not vwdig c
+break
+end
+v = add mul v 10 ulong sub c 48
+if gt v 4194304
+ret 0
+end
+end
+ret v
+end
+fn vwpalive pid ulong to bool
+if eq pid 0
+ret false
+end
+vwpb
+vwpt tproc
+vwpd pid
+r = stat gpth 0 get gpl 0 gstb 0 128
+ret eq r 0
+end
+fn vwwindow to void
+put gsl 0 0
+vwwinp
+vwpt twopen
+r = vwrdall 128
+put gwidl 0 0
+if ge r 0
+a = get goa 0
+for i ulong sub get gol 0 a
+c = get gob add a i
+if or eq c 10 eq c 32
+break
+end
+if lt i 63
+put gwid i c
+put gwidl 0 add i 1
+end
+end
+end
+if not vwidok
+vwsbt twnone
+else
+vwsbt twopenl
+for i ulong get gwidl 0
+vwsbc get gwid i
+end
+vwsbc 10
+ok = vwwkey twk0
+ok = vwwkey twk1
+ok = vwwkey twk2
+ok = vwwkey twk3
+ok = vwwkey twk4
+ok = vwwkey twk5
+ok = vwwkey twk6
+ok = vwwkey twk7
+vwsbt talive
+if and ok vwpalive vwpidof
+vwsbt tyes
+else
+vwsbt tno
+end
+vwsbc 10
+end
+vwqueue
+vwcommit 55 0
+end
+fn vwqueue to void
+vwwinp
+vwpt twqueue
+fd = fopen gpth 0 get gpl 0 540672 0
+if lt fd 0
+ret
+end
+n = getdnts int fd gdent 0 len gdent
+x = fclose int fd
+if le n 0
+ret
+end
+p = ulong 0
+for it ulong 4096
+if ge add p 19 ulong n
+break
+end
+rl = or ulong get gdent add p 16 shl ulong get gdent add p 17 8
+if eq rl 0
+break
+end
+vwqent add p 19 add p rl
+p = add p rl
+end
+end
+note vwqent: one ticket "<ns>-<pid>" (name bytes gdent[a, NUL)): its line and whether pid lives
+fn vwqent a ulong e ulong to void
+n = ulong 0
+for i ulong sub e a
+c = get gdent add a i
+if eq c 0
+break
+end
+if not or vwdig c eq c 45
+ret
+end
+n = add n 1
+end
+if eq n 0
+ret
+end
+vwsbt tqline
+for i ulong n
+vwsbc get gdent add a i
+end
+vwsbc 9
+pid = ulong 0
+for i ulong n
+c = get gdent add a i
+if eq c 45
+pid = ulong 0
+else
+pid = add mul pid 10 ulong sub c 48
+if gt pid 4194304
+pid = ulong 0
+end
+end
+end
+if vwpalive pid
+vwsbt tyes
+else
+vwsbt tno
+end
+vwsbc 9
+vwwinp
+vwpt twqueue
+vwpc 47
+for i ulong n
+vwpc get gdent add a i
+end
+r = vwrdall 512
+if ge r 0
+vwsbl1
+end
+vwsbc 10
+end
+note ---- pool locks: holders from the kernel lock table (/proc/locks), never by taking the lock
+fn vwpools to void
+put gsl 0 0
+put gpln_n 0 0
+vwhpath tqueen
+fd = fopen gpth 0 get gpl 0 540672 0
+if lt fd 0
+vwcommit 56 ulong neg fd
+ret
+end
+n = getdnts int fd gdent 0 len gdent
+x = fclose int fd
+p = ulong 0
+for it ulong 4096
+if ge add p 19 ulong n
+break
+end
+rl = or ulong get gdent add p 16 shl ulong get gdent add p 17 8
+if eq rl 0
+break
+end
+vwplent add p 19 add p rl
+p = add p rl
+end
+vwpb
+vwpt tplocks
+r = vwrdall len glk
+k = hmin sub get gol 0 get goa 0 len glk
+for i ulong k
+put glk i get gob i
+end
+put glkl 0 k
+for j ulong get gpln_n 0
+vwplone j
+end
+vwcommit 56 0
+end
+fn vwplent a ulong e ulong to void
+n = ulong 0
+for i ulong sub e a
+if eq get gdent add a i 0
+break
+end
+n = add n 1
+end
+m = len tpoolp
+x = len tlockx
+if or le n add m x gt n 63
+ret
+end
+for i ulong m
+if ne get gdent add a i get tpoolp i
+ret
+end
+end
+for i ulong x
+if ne get gdent add a add sub n x i get tlockx i
+ret
+end
+end
+for i ulong n
+c = get gdent add a i
+if not or vwnamec c eq c 46
+ret
+end
+end
+j = get gpln_n 0
+if ge j 16
+ret
+end
+vwhpath tqueen
+vwpc 47
+for i ulong n
+vwpc get gdent add a i
+put gpln add mul j 64 i get gdent add a i
+end
+r = stat gpth 0 get gpl 0 gstb 0 128
+if ne r 0
+ret
+end
+put gplnl j n
+put gplino j vwst64 8
+put gpln_n 0 add j 1
+end
+fn vwplname j ulong to void
+for i ulong get gplnl j
+vwsbc get gpln add mul j 64 i
+end
+end
+note vwplone: every /proc/locks line whose inode is pool j's, as holds|waits PID CMDLINE
+fn vwplone j ulong to void
+ino = get gplino j
+any = false
+n = get glkl 0
+a = ulong 0
+for i ulong n
+if eq get glk i 10
+if vwlkline a i ino j
+any = true
+end
+a = add i 1
+end
+end
+if not any
+vwsbt tpooll
+vwplname j
+vwsbc 9
+vwsbt tfree
+vwsbc 10
+end
+end
+note vwlkline: fields of one /proc/locks line glk[a, e): "N: [->] TYPE MODE RW PID MAJ:MIN:INO S E".
+note Field scan state lives in glkw (waits) and glkp (the number before the device field).
+fn vwlkline a ulong e ulong ino ulong j ulong to bool
+put glkw 0 0
+put glkp 0 18446744073709551615
+pid = ulong 18446744073709551615
+p = a
+for it ulong 64
+p = vwskipsp p e
+if ge p e
+break
+end
+q = vwtokend p e
+if eq vwcolons p q 2
+if ne vwlastnum p q ino
+ret false
+end
+pid = get glkp 0
+break
+end
+vwtokstep p q
+p = q
+end
+if or eq pid 18446744073709551615 eq pid 0
+ret false
+end
+vwsbt tpooll
+vwplname j
+vwsbc 9
+if eq get glkw 0 1
+vwsbt twaits
+else
+vwsbt tholds
+end
+vwsbc 9
+vwsbd pid
+vwsbc 9
+vwcmdl pid
+vwsbc 10
+ret true
+end
+fn vwskipsp p ulong e ulong to ulong
+x = p
+for s ulong 4096
+if ge x e
+ret x
+end
+if ne get glk x 32
+ret x
+end
+x = add x 1
+end
+ret x
+end
+fn vwtokend p ulong e ulong to ulong
+x = p
+for s ulong 4096
+if ge x e
+ret x
+end
+if eq get glk x 32
+ret x
+end
+x = add x 1
+end
+ret x
+end
+fn vwtokstep p ulong q ulong to void
+if eq sub q p 2
+if eq get glk p 45
+put glkw 0 1
+end
+end
+put glkp 0 vwdecn p q
+end
+fn vwcolons p ulong q ulong to ulong
+c = ulong 0
+for i ulong sub q p
+if eq get glk add p i 58
+c = add c 1
+end
+end
+ret c
+end
+note vwdecn: decimal value of glk[p, q), or all ones when it is not a plain number
+fn vwdecn p ulong q ulong to ulong
+if or eq p q gt sub q p 19
+ret 18446744073709551615
+end
+v = ulong 0
+for i ulong sub q p
+c = get glk add p i
+if not vwdig c
+ret 18446744073709551615
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+fn vwlastnum p ulong q ulong to ulong
+s = q
+for i ulong sub q p
+if eq get glk sub sub q i 1 58
+s = sub q i
+break
+end
+end
+ret vwdecn s q
+end
+fn vwcmdl pid ulong to void
+vwpb
+vwpt tproc
+vwpd pid
+vwpt tcmdl
+r = vwrdall 200
+if lt r 0
+ret
+end
+a = get goa 0
+for i ulong sub get gol 0 a
+c = get gob add a i
+if or lt c 32 eq c 127
+vwsbc 32
+else
+vwsbc c
+end
+end
+end
+note ---- the index: one line per published slot, and the poller's heartbeat
+fn vwindex tick ulong to void
+put gsl 0 0
+vwsbt thdrp
+vwsbd vwnowms
+vwsbc 9
+vwsbd get gtmux 0
+vwsbc 9
+vwsbd tick
+vwsbc 10
+for s ulong 64
+show = false
+if lt s 48
+show = and eq get gslive s 1 gt get gsgen s 0
+else
+show = or gt get gsgen s 0 ne get gsst s 0
+end
+if show
+vwixl s
+end
+end
+put ghdl 0 0
+vwpb
+vwpr
+vwpt tindex
+ok = vwwpath
+end
+fn vwixl s ulong to void
+vwsbd s
+vwsbc 9
+vwsbd get gsgen s
+vwsbc 9
+vwsbd get gstms s
+vwsbc 9
+vwsbd get gsst s
+vwsbc 9
+vwkindt get gskind s
+vwsbc 9
+b = mul s 64
+for i ulong get gsnl s
+vwsbc get gsnam add b i
+end
+vwsbc 10
+end
+fn vwslow to void
+vwhermes
+vwhpath tpboard
+vwfsec 50 true 65536
+vwhpath tpques
+vwfsec 51 true 32768
+vwhpath tpdec
+vwfsec 52 true 32768
+vwhpath tpclaim
+vwfsec 53 false 131072
+vwwindow
+vwgpu
+vwpools
+vwmach
+vwledger
+end
+fn vwpoll to void
+vwinitsec
+put ggen 0 vwnowms
+pp = getppid
+for tick ulong 9223372036854775807
+t0 = monons
+if ne getppid pp
+exit 0
+end
+vwpanes
+if eq rem tick 5 0
+vwslow
+end
+if eq rem tick 5 0
+vwkanban
+end
+vwindex tick
+el = sub long monons long t0
+if lt el 2000000000
+x = sleepns sub 2000000000 el
+end
+end
+end
diff --git a/src/route.om b/src/route.om
new file mode 100644
index 0000000..6f5d8f3
--- /dev/null
+++ b/src/route.om
@@ -0,0 +1,430 @@
+note ==== route.om: POST /send from the HTML form, the route table and the per-connection loop
+note ---- POST /send: application/x-www-form-urlencoded fields s (session), k (form key), r (return
+note page: q = the overview, s = the session page), a (line, enter, escape) and t (the text). The
+note decoded fields are laid out as "NAME<LF>ACTION<LF>TEXT" for vwsendp (which checks the name,
+note the action, the text and the live session, types it and logs it); the browser is then sent
+note back to the page it came from with the result in the query (?m=CODE&a=ACTION&b=BYTES).
+global gfl ulong 8
+global gres ulong 3
+text tfns "s"
+text tfnk "k"
+text tfnr "r"
+text tfna "a"
+text tfnt "t"
+text tlocq "/?m="
+text tlocs "/s/"
+text tlocm "?m="
+text tloca "&a="
+text tlocb "&b="
+text tlocn "&s="
+note vwfdst / vwfcap: where field k is decoded inside buf (past the 16384-byte body) and its limit
+fn vwfdst k ulong to ulong
+if eq k 4
+ret 24576
+end
+ret add 20000 mul k 256
+end
+fn vwfcap k ulong to ulong
+if eq k 4
+ret 8192
+end
+if eq k 2
+ret 4
+end
+if eq k 3
+ret 8
+end
+ret 64
+end
+note vwfdec: percent-decode buf[p, q) ('+' is a space) to buf[d, ...); 1000000 when malformed or over cap
+fn vwfdec buf edit uchar 262144 p ulong q ulong d ulong cap ulong to ulong
+n = ulong 0
+i = p
+for it ulong 65536
+if ge i q
+ret n
+end
+if ge n cap
+ret 1000000
+end
+c = get buf i
+if eq c 43
+c = 32
+end
+if eq c 37
+if gt add i 3 q
+ret 1000000
+end
+h = hhexv get buf add i 1
+l = hhexv get buf add i 2
+if or gt h 15 gt l 15
+ret 1000000
+end
+c = uchar add mul h 16 l
+i = add i 2
+end
+put buf add d n c
+n = add n 1
+i = add i 1
+end
+ret 1000000
+end
+fn vwfidx buf edit uchar 262144 p ulong to ulong
+c = get buf p
+if eq c get tfns 0
+ret 0
+end
+if eq c get tfnk 0
+ret 1
+end
+if eq c get tfnr 0
+ret 2
+end
+if eq c get tfna 0
+ret 3
+end
+if eq c get tfnt 0
+ret 4
+end
+ret 9
+end
+note vwfparse: every field is one of s k r a t, present at most once, and decodes cleanly
+fn vwfparse buf edit uchar 262144 n ulong to bool
+for i ulong 8
+put gfl i 0
+end
+p = ulong 0
+for it ulong 16
+if ge p n
+ret true
+end
+q = n
+for i ulong sub n p
+if eq get buf add p i 38
+q = add p i
+break
+end
+end
+if or lt sub q p 2 ne get buf add p 1 61
+ret false
+end
+k = vwfidx buf p
+if gt k 4
+ret false
+end
+if ne get gfl k 0
+ret false
+end
+l = vwfdec buf add p 2 q vwfdst k vwfcap k
+if ge l 1000000
+ret false
+end
+put gfl k add l 1
+p = add q 1
+end
+ret false
+end
+note vwfkey: field k is exactly the form key (compared in time independent of the contents)
+fn vwfkey buf edit uchar 262144 to bool
+if ne get gfl 1 65
+ret false
+end
+vwcsrfk
+d = uchar 0
+b = vwfdst 1
+for i ulong 64
+d = or d xor get buf add b i get gcsrf i
+end
+ret eq d 0
+end
+fn vwfis buf edit uchar 262144 k ulong t view uchar * to bool
+if ne get gfl k add len t 1
+ret false
+end
+b = vwfdst k
+for i ulong len t
+if ne get buf add b i get t i
+ret false
+end
+end
+ret true
+end
+note vwfact: 0 line, 1 enter, 2 escape, 9 anything else
+fn vwfact buf edit uchar 262144 to ulong
+if vwfis buf 3 taline
+ret 0
+end
+if vwfis buf 3 taenter
+ret 1
+end
+if vwfis buf 3 taesc
+ret 2
+end
+ret 9
+end
+note vwfbuild: "NAME<LF>ACTION<LF>TEXT" at buf[0, ...) from the decoded fields; the text is kept
+note only for a line (the Enter and Escape buttons ignore whatever is in the box). Returns its length.
+fn vwfbuild buf edit uchar 262144 act ulong to ulong
+m = ulong 0
+ns = vwfdst 0
+nl = sub hmax get gfl 0 1 1
+for i ulong nl
+put buf m get buf add ns i
+m = add m 1
+end
+put buf m 10
+m = add m 1
+as = vwfdst 3
+al = sub hmax get gfl 3 1 1
+for i ulong al
+put buf m get buf add as i
+m = add m 1
+end
+put buf m 10
+m = add m 1
+if eq act 0
+ts = vwfdst 4
+tl = sub hmax get gfl 4 1 1
+for i ulong tl
+put buf m get buf add ts i
+m = add m 1
+end
+end
+ret m
+end
+fn vwnameb buf edit uchar 262144 to bool
+n = sub hmax get gfl 0 1 1
+if or eq n 0 gt n 63
+ret false
+end
+b = vwfdst 0
+for i ulong n
+if not vwnamec get buf add b i
+ret false
+end
+end
+ret true
+end
+fn vwlc2 loc edit uchar 256 n ulong t view uchar * to ulong
+k = n
+for i ulong len t
+if lt k 256
+put loc k get t i
+k = add k 1
+end
+end
+ret k
+end
+fn vwld2 loc edit uchar 256 n ulong v ulong to ulong
+d = new uchar 20 0
+k = ulong 0
+x = v
+for it ulong 20
+put d k uchar add rem x 10 48
+k = add k 1
+x = div x 10
+if eq x 0
+break
+end
+end
+m = n
+for i ulong k
+if lt m 256
+put loc m get d sub sub k 1 i
+m = add m 1
+end
+end
+ret m
+end
+fn vwlname loc edit uchar 256 n ulong buf edit uchar 262144 to ulong
+m = n
+b = vwfdst 0
+for i ulong sub hmax get gfl 0 1 1
+if lt m 256
+put loc m get buf add b i
+m = add m 1
+end
+end
+ret m
+end
+fn vwsendf cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+if not vworigin cs io
+ret vwtext cs io 403 tnoorig
+end
+n = hbodyall cs io buf
+if lt n 0
+if eq n HEBIG
+ret vwtext cs io 413 tbigbody
+end
+ret vwtext cs io 400 tbadbody
+end
+ok = vwfparse buf ulong n
+if and ok not vwfkey buf
+ret vwtext cs io 403 tbadkey
+end
+code = ulong 1
+act = ulong 9
+nb = ulong 0
+if ok
+act = vwfact buf
+if eq act 0
+nb = sub hmax get gfl 4 1 1
+end
+code = vwsendp buf vwfbuild buf act
+end
+put gres 0 code
+put gres 1 act
+put gres 2 nb
+ret vwredir cs io buf ok
+end
+note vwredir: 302 back to the page the form was on, with gres (code, action, bytes) in the query
+fn vwredir cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 ok bool to long
+okn = false
+tos = false
+if ok
+okn = vwnameb buf
+tos = vwfis buf 2 tfns
+end
+code = get gres 0
+act = get gres 1
+nb = get gres 2
+loc = new uchar 256 0
+k = ulong 0
+if and okn tos
+k = vwlc2 loc k tlocs
+k = vwlname loc k buf
+k = vwlc2 loc k tlocm
+else
+k = vwlc2 loc k tlocq
+end
+k = vwld2 loc k code
+if lt act 3
+k = vwlc2 loc k tloca
+k = vwld2 loc k act
+end
+k = vwlc2 loc k tlocb
+k = vwld2 loc k nb
+if okn
+k = vwlc2 loc k tlocn
+k = vwlname loc k buf
+end
+r = hrspst cs io 302
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tloc
+r = hfe r hhval cs io view part loc 0 k
+r = hfe r hhend cs io 0 0
+ret hfe r hwfin cs io
+end
+note ---- routing
+note vwlogq: the request target is "/?t=..." (the one-time link), not a result query like "/?m=0"
+fn vwlogq cs edit ulong 320 io edit uchar 131072 to bool
+tg = get cs HTOFF
+tl = get cs HTLEN
+if lt tl 3
+ret false
+end
+return = false
+if and eq get io add tg 1 63 eq get io add tg 2 116
+return = true
+end
+ret return
+end
+fn vwpanel cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+if hispath cs io tstatp
+ret vwpstat cs io buf
+end
+if hispath cs io tpane
+ret vwppane cs io buf
+end
+if hispath cs io ttiles
+ret vwptiles cs io buf
+end
+if hispath cs io thermp
+ret vwphermes cs io buf
+end
+if hispath cs io tmachp
+ret vwpmach cs io buf
+end
+if hispath cs io tboardp
+ret vwpboard cs io buf
+end
+if hispath cs io tentp
+ret vwpents cs io buf
+end
+if vwsname cs io
+ret vwpsess cs io buf
+end
+ret vwtext cs io 404 tnotfnd
+end
+fn vwroute cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+if not vwhostok cs io
+ret vwtext cs io 400 tbadhost
+end
+isget = hismeth cs io tget
+if hispath cs io tphealth
+ret vwtext cs io 200 tok200
+end
+if hispath cs io tpsend
+if not hismeth cs io tpost
+ret vwtext cs io 405 tmeth
+end
+if not vwauth cs io
+ret vwtext cs io 403 tnoauth
+end
+ret vwsendf cs io buf
+end
+if not isget
+ret vwtext cs io 405 tmeth
+end
+if hispath cs io tpcss
+ret vwcss cs io buf
+end
+if hispath cs io tpalp
+ret vwpal cs io buf
+end
+if hispath cs io troot
+if vwlogq cs io
+ret vwlogin cs io
+end
+if not vwauth cs io
+ret vwpsignout cs io buf
+end
+ret vwptop cs io buf
+end
+if not vwauth cs io
+ret vwpsignout cs io buf
+end
+ret vwpanel cs io buf
+end
+fn vwconn c long to void
+cs = new ulong 320 0
+io = new uchar 131072 0
+buf = new uchar 262144 0
+r = hinit cs io int c 1
+if lt r 0
+x = hclose cs
+ret
+end
+hsettmo cs 30000000000 10000000000
+hsetbdl cs 10000000000
+note the only request body hive-view accepts is the 16 KiB send form; a larger declared
+note Content-Length is refused with 413 as soon as the head is read
+put cs HBCAP 16384
+for k ulong 1000
+r = hreqrd cs io
+if le r 0
+if lt r 0
+x = hreject cs io r
+end
+break
+end
+r = vwroute cs io buf
+if lt r 0
+break
+end
+if eq hnext cs io 0
+break
+end
+end
+x = hclose cs
+end
diff --git a/src/run.om b/src/run.om
new file mode 100644
index 0000000..52cf2c9
--- /dev/null
+++ b/src/run.om
@@ -0,0 +1,273 @@
+note hive-view src/run.om: run one program with an exact argument list (gpk), no shell, no PATH
+note search, empty environment (execprog), stdin and stderr on /dev/null, stdout into gob,
+note a monotonic deadline, SIGKILL on overrun, and reaping. File reads into gob, atomic writes.
+fn vwchild wfd int to void
+nul = fopen tdevnul 0 len tdevnul 2 0
+if lt nul 0
+exit 126
+end
+x = dupfd int nul 0 0
+x = dupfd wfd 1 0
+x = dupfd int nul 2 0
+x = execprog gpk 0 get gpkl 0
+exit 127
+end
+note vwdrain: read the pipe into gob until end of file; false on deadline or read error
+fn vwdrain fd int dl long to bool
+for it ulong 1000000
+left = sub dl long monons
+if le left 0
+ret false
+end
+w = waitio fd 1 left
+if lt w 0
+if ne w -4
+ret false
+end
+continue
+end
+if eq w 0
+continue
+end
+n = get gol 0
+if ge n len gob
+put gotr 0 1
+r = read fd gjunk 0 4096
+if eq r 0
+ret true
+end
+if lt r 0
+if and ne r -4 ne r -11
+ret false
+end
+end
+continue
+end
+r = read fd gob n sub len gob n
+if eq r 0
+ret true
+end
+if lt r 0
+if and ne r -4 ne r -11
+ret false
+end
+continue
+end
+put gol 0 add n ulong r
+end
+ret false
+end
+note vwreap: wait for pid until dl, then SIGKILL and wait; returns the exit code, or -3 when signalled
+fn vwreap pid int dl long to long
+for it ulong 100000
+w = waitpid pid gwst 0 4 1
+if eq w long pid
+s = or ulong get gwst 0 shl ulong get gwst 1 8
+if eq and s 127 0
+ret long and shr s 8 255
+end
+ret -3
+end
+if lt w 0
+if ne w -4
+ret -4
+end
+continue
+end
+if gt long monons dl
+x = killpid pid 9
+w = waitpid pid gwst 0 4 0
+ret -1
+end
+x = sleepns 2000000
+end
+ret -4
+end
+note vwrun: run gpk with timeout tmo ns. Output in gob[0, gol). Returns the exit status 0..255,
+note -1 timeout (killed), -2 could not start, -3 killed by a signal, -4 wait failure.
+fn vwrun tmo long to long
+put gol 0 0
+put goa 0 0
+put gotr 0 0
+r = pipefds gpfd 0 8 524288
+if lt r 0
+ret -2
+end
+rfd = vwpfd 0
+wfd = vwpfd 1
+dl = add long monons tmo
+pid = fork
+if lt pid 0
+x = fclose rfd
+x = fclose wfd
+ret -2
+end
+if eq pid 0
+vwchild wfd
+exit 127
+end
+x = fclose wfd
+ok = vwdrain rfd dl
+x = fclose rfd
+if not ok
+x = killpid int pid 9
+end
+st = vwreap int pid dl
+if not ok
+ret -1
+end
+ret st
+end
+note ---- file reads into gob. Path in gpth[0, gpl). Results: bytes in gob[goa, gol), or -errno.
+fn vwfopen to long
+ret fopen gpth 0 get gpl 0 524288 0
+end
+note vwrdall: up to cap bytes from the start (also for /proc files, whose stat size is 0)
+fn vwrdall cap ulong to long
+put gol 0 0
+put goa 0 0
+put gotr 0 0
+fd = vwfopen
+if lt fd 0
+ret fd
+end
+c = cap
+if gt c len gob
+c = len gob
+end
+for it ulong 100000
+n = get gol 0
+if ge n c
+put gotr 0 1
+break
+end
+r = read int fd gob n sub c n
+if le r 0
+break
+end
+put gol 0 add n ulong r
+end
+x = fclose int fd
+ret long get gol 0
+end
+note vwrdtail: the last cap bytes; when that starts mid-file, goa skips the partial first line
+fn vwrdtail cap ulong to long
+put gol 0 0
+put goa 0 0
+put gotr 0 0
+fd = vwfopen
+if lt fd 0
+ret fd
+end
+r = fstat int fd gstb 0 128
+if lt r 0
+x = fclose int fd
+ret r
+end
+size = vwst64 48
+c = cap
+if gt c len gob
+c = len gob
+end
+pos = ulong 0
+if gt size c
+pos = sub size c
+put gotr 0 1
+end
+for it ulong 100000
+n = get gol 0
+if ge n c
+break
+end
+k = pread int fd gob n sub c n long add pos n
+if le k 0
+break
+end
+put gol 0 add n ulong k
+end
+x = fclose int fd
+if gt pos 0
+vwskipl
+end
+ret long sub get gol 0 get goa 0
+end
+fn vwskipl to void
+n = get gol 0
+for i ulong n
+if eq get gob i 10
+put goa 0 add i 1
+ret
+end
+end
+put goa 0 n
+end
+note ---- atomic write of ghd[0, ghdl) + gsb[0, gsl) to <run>/s<slot>: write s<slot>.t, then rename
+fn vwwgob fd int a ulong n ulong to bool
+p = ulong 0
+for it ulong 100000
+if ge p n
+ret true
+end
+w = write fd gsb add a p sub n p
+if le w 0
+ret false
+end
+p = add p ulong w
+end
+ret false
+end
+fn vwwhd fd int to bool
+n = get ghdl 0
+p = ulong 0
+for it ulong 1000
+if ge p n
+ret true
+end
+w = write fd ghd p sub n p
+if le w 0
+ret false
+end
+p = add p ulong w
+end
+ret false
+end
+fn vwpslot slot ulong to void
+vwpb
+vwpr
+vwpc 47
+vwpc 115
+vwpd slot
+end
+fn vwwsec slot ulong to bool
+vwpslot slot
+ret vwwpath
+end
+note vwwpath: final path in gpth[0, gpl); writes gpth + ".t" then renames it over the final path
+fn vwwpath to bool
+n = get gpl 0
+vwpc 46
+vwpc 116
+fd = fopen gpth 0 get gpl 0 524865 384
+if lt fd 0
+ret false
+end
+ok = vwwhd int fd
+if ok
+ok = vwwgob int fd 0 get gsl 0
+end
+x = fclose int fd
+if not ok
+ret false
+end
+vwkb
+vwkopen
+for i ulong add n 2
+vwkc get gpth i
+end
+vwkopen
+for i ulong n
+vwkc get gpth i
+end
+r = renames gpk 0 get gpkl 0 0
+ret eq r 0
+end
diff --git a/src/util.om b/src/util.om
new file mode 100644
index 0000000..8c27d3e
--- /dev/null
+++ b/src/util.om
@@ -0,0 +1,194 @@
+note hive-view src/util.om: process-wide buffers and small byte helpers (names vw*, globals g*).
+note Composed after seed/net/http.om, seed/net/notls.om and om/tls/sha2.om; see build.sh.
+note Globals are never passed as arguments (omc error 19): helpers name them directly.
+global ghome uchar 512
+global ghomel ulong 1
+global grun uchar 512
+global grunl ulong 1
+global gpth uchar 4096
+global gpl ulong 1
+global gpk uchar 4096
+global gpkl ulong 1
+global gpkr ulong 1
+global gob uchar 262144
+global gol ulong 1
+global goa ulong 1
+global gotr ulong 1
+global gsb uchar 393216
+global gsl ulong 1
+global gstb uchar 128
+global gpfd uchar 8
+global gwst uchar 4
+global ghd uchar 256
+global ghdl ulong 1
+global gjunk uchar 4096
+global gtok uchar 64
+global gport ulong 1
+text tdevnul "/dev/null"
+text thexd "0123456789abcdef"
+note ---- section builder gsb
+fn vwsbc c uchar to void
+n = get gsl 0
+if lt n len gsb
+put gsb n c
+put gsl 0 add n 1
+end
+end
+fn vwsbt t view uchar * to void
+for i ulong len t
+vwsbc get t i
+end
+end
+fn vwsbd v ulong to void
+d = new uchar 20 0
+i = ulong 20
+x = v
+for it ulong 20
+i = sub i 1
+put d i uchar add rem x 10 48
+x = div x 10
+if eq x 0
+break
+end
+end
+for k ulong sub 20 i
+vwsbc get d add i k
+end
+end
+note vwsbo: append gob[a, a+n) to gsb
+fn vwsbo a ulong n ulong to void
+for i ulong n
+vwsbc get gob add a i
+end
+end
+note vwsbol: append the command/file output gob[goa, gol) to gsb
+fn vwsbol to void
+a = get goa 0
+b = get gol 0
+if gt b a
+vwsbo a sub b a
+end
+end
+note ---- path builder gpth (at most 4095 bytes; longer paths are cut and refused by fopen)
+fn vwpb to void
+put gpl 0 0
+end
+fn vwpc c uchar to void
+n = get gpl 0
+if lt n 4095
+put gpth n c
+put gpl 0 add n 1
+end
+end
+fn vwpt t view uchar * to void
+for i ulong len t
+vwpc get t i
+end
+end
+fn vwph to void
+for i ulong get ghomel 0
+vwpc get ghome i
+end
+end
+fn vwpr to void
+for i ulong get grunl 0
+vwpc get grun i
+end
+end
+fn vwpd v ulong to void
+d = new uchar 20 0
+i = ulong 20
+x = v
+for it ulong 20
+i = sub i 1
+put d i uchar add rem x 10 48
+x = div x 10
+if eq x 0
+break
+end
+end
+for k ulong sub 20 i
+vwpc get d add i k
+end
+end
+note ---- packed argument list gpk (u16 count, then u16 length + bytes per record)
+fn vwkb to void
+put gpk 0 0
+put gpk 1 0
+put gpkl 0 2
+end
+fn vwkopen to void
+n = get gpkl 0
+put gpkr 0 n
+put gpk n 0
+put gpk add n 1 0
+put gpkl 0 add n 2
+c = add or ulong get gpk 0 shl ulong get gpk 1 8 1
+put gpk 0 uchar and c 255
+put gpk 1 uchar shr c 8
+end
+fn vwkc c uchar to void
+n = get gpkl 0
+if lt n 4095
+put gpk n c
+put gpkl 0 add n 1
+r = get gpkr 0
+k = add or ulong get gpk r shl ulong get gpk add r 1 8 1
+put gpk r uchar and k 255
+put gpk add r 1 uchar shr k 8
+end
+end
+fn vwka t view uchar * to void
+vwkopen
+for i ulong len t
+vwkc get t i
+end
+end
+note ---- little-endian reads of the small global byte buffers
+fn vwpfd i ulong to int
+b = mul i 4
+v = or ulong get gpfd b shl ulong get gpfd add b 1 8
+v = or v shl ulong get gpfd add b 2 16
+v = or v shl ulong get gpfd add b 3 24
+ret int v
+end
+fn vwst64 o ulong to ulong
+v = ulong 0
+for i ulong 8
+v = or v shl ulong get gstb add o i mul i 8
+end
+ret v
+end
+fn vwst32 o ulong to ulong
+v = ulong 0
+for i ulong 4
+v = or v shl ulong get gstb add o i mul i 8
+end
+ret v
+end
+fn vwnowms to ulong
+ret div ulong realns 1000000
+end
+note ---- byte classes
+fn vwdig c uchar to bool
+ret and ge c 48 le c 57
+end
+fn vwhex c uchar to bool
+if vwdig c
+ret true
+end
+ret and ge c 97 le c 102
+end
+note vwnamec: a byte allowed in a session name we will target (tmux names are wider; we refuse the rest)
+fn vwnamec c uchar to bool
+if vwdig c
+ret true
+end
+if and ge c 65 le c 90
+ret true
+end
+if and ge c 97 le c 122
+ret true
+end
+ret or eq c 45 eq c 95
+end
diff --git a/src/web.om b/src/web.om
new file mode 100644
index 0000000..c35e192
--- /dev/null
+++ b/src/web.om
@@ -0,0 +1,678 @@
+note hive-view src/web.om: HTTP routes. One forked process per browser connection (keep-alive).
+note Reads need the session cookie; the only write, POST /send, also needs the X-Hive-View header,
+note a same-origin Origin, a session name present in a fresh `tmux list-sessions`, and text that
+note is valid UTF-8 without control characters. It types that text literally (send-keys -l)
+note and then Enter, or sends Enter or Escape alone, and logs one line without the text.
+global gah uchar 1024
+global gaho ulong 8
+global gahl ulong 8
+global gahn ulong 1
+global glog uchar 1024
+global glogl ulong 1
+global glfd long 1
+text tget "GET"
+text tpost "POST"
+text troot "/"
+text tpcss "/app.css"
+text tpsend "/send"
+text tphealth "/health"
+text tfcss "app.css"
+text tctype "Content-Type"
+text tthtml "text/html; charset=utf-8"
+text ttcss "text/css; charset=utf-8"
+text tttext "text/plain; charset=utf-8"
+text tcc "Cache-Control"
+text tnostore "no-store"
+text tcsp "Content-Security-Policy"
+text tcspv "default-src 'none'; style-src 'self'; img-src 'self'; frame-src 'self'; form-action 'self'; frame-ancestors 'self'; base-uri 'none'"
+text txcto "X-Content-Type-Options"
+text tnosniff "nosniff"
+text trefp "Referrer-Policy"
+text tnoref "same-origin"
+text txfo "X-Frame-Options"
+text tdeny "SAMEORIGIN"
+text tsetck "Set-Cookie"
+text tckpre "hv="
+text tckattr "; Path=/; HttpOnly; SameSite=Strict; Max-Age=31536000"
+text tloc "Location"
+text thhost "host"
+text thcook "cookie"
+text thorig "origin"
+text thttp "http://"
+text tqt "/?t="
+text tok200 "ok\n"
+text tbadlink "This link is not valid. Ask for the current link (the token is in ~/.config/hive-view/token on the Spark).\n"
+text tnoauth "Not signed in: open the one-time link once on this device.\n"
+text tbadkey "Refused: the form key is wrong. Reload the page and try again.\n"
+text tnoorig "Refused: cross-origin request.\n"
+text tbadbody "Refused: malformed request.\n"
+text tbigbody "Refused: the text is longer than 4096 bytes.\n"
+text tbadname "Refused: that is not a session name the dashboard can type into.\n"
+text tnosess "Refused: no tmux session has that name right now.\n"
+text tbadact "Refused: unknown action (allowed: line, enter, escape).\n"
+text tbadtext "Refused: the text must be one line of printable characters (no control keys).\n"
+text ttmuxbad "tmux did not accept the keys; nothing more was sent.\n"
+text tlogbad "Refused: the send log ~/.local/state/hive-view/sends.log cannot be written, so nothing was sent.\n"
+text tnotfnd "Not found.\n"
+text tmeth "Method not allowed.\n"
+text tbadhost "Refused: unknown Host.\n"
+text tsendk "send-keys"
+text tdashl "-l"
+text tdd "--"
+text tenter "Enter"
+text tescape "Escape"
+text taline "line"
+text taenter "enter"
+text taesc "escape"
+text tlogp "/.local/state/hive-view/sends.log"
+text tlsfmt1 "#{session_name}"
+text tlsessn "session="
+text tlact " action="
+text tlbytes " bytes="
+text tlsha " sha256="
+text tlres " result="
+text tlok "ok"
+text tlnosess "refused-no-session"
+text tlbadtx "refused-text"
+text tlfail "tmux-failed"
+note ---- request checks
+fn vwhostok cs edit ulong 320 io edit uchar 131072 to bool
+i = hhfind cs io thhost
+if lt i 0
+ret false
+end
+vo = hhvoff cs ulong i
+vl = hhvlen cs ulong i
+for k ulong get gahn 0
+if vwahis io vo vl k
+ret true
+end
+end
+ret false
+end
+fn vwahis io edit uchar 131072 vo ulong vl ulong k ulong to bool
+if ne vl get gahl k
+ret false
+end
+b = get gaho k
+for i ulong vl
+if ne get io add vo i get gah add b i
+ret false
+end
+end
+ret true
+end
+note vwtokeq: io[off, off+64) equals the token; the comparison time does not depend on where it differs
+fn vwtokeq io edit uchar 131072 off ulong to bool
+if gt add off 64 len io
+ret false
+end
+d = uchar 0
+for i ulong 64
+d = or d xor get io add off i get gtok i
+end
+ret eq d 0
+end
+note vwauth: any Cookie header carries hv=<token> as one of its cookies
+fn vwauth cs edit ulong 320 io edit uchar 131072 to bool
+ok = false
+for i ulong get cs HHN
+if hieqm view part io hhnoff cs i hhnlen cs i thcook
+if vwckval io hhvoff cs i hhvlen cs i
+ok = true
+end
+end
+end
+ret ok
+end
+fn vwckval io edit uchar 131072 vo ulong vl ulong to bool
+p = ulong 0
+for it ulong 4096
+for s ulong 4096
+if ge p vl
+break
+end
+if ne get io add vo p 32
+break
+end
+p = add p 1
+end
+if le add p 67 vl
+if vwckat io add vo p
+if eq add p 67 vl
+ret vwtokeq io add add vo p 3
+end
+if eq get io add add vo p 67 59
+ret vwtokeq io add add vo p 3
+end
+end
+end
+for s ulong 4096
+if ge p vl
+ret false
+end
+if eq get io add vo p 59
+break
+end
+p = add p 1
+end
+p = add p 1
+end
+ret false
+end
+fn vwckat io edit uchar 131072 o ulong to bool
+if ne get io o 104
+ret false
+end
+if ne get io add o 1 118
+ret false
+end
+ret eq get io add o 2 61
+end
+note vworigin: the Origin header is present and exactly "http://" + the (already checked) Host.
+note Browsers send it on every form POST (Referrer-Policy same-origin keeps it from being "null").
+fn vworigin cs edit ulong 320 io edit uchar 131072 to bool
+i = hhfind cs io thorig
+if lt i 0
+ret false
+end
+h = hhfind cs io thhost
+if lt h 0
+ret false
+end
+oo = hhvoff cs ulong i
+ol = hhvlen cs ulong i
+ho = hhvoff cs ulong h
+hl = hhvlen cs ulong h
+m = len thttp
+if ne ol add m hl
+ret false
+end
+if not heq view part io oo m thttp
+ret false
+end
+ret vwioeq io add oo m ho hl
+end
+fn vwioeq io edit uchar 131072 a ulong b ulong n ulong to bool
+for i ulong n
+if ne get io add a i get io add b i
+ret false
+end
+end
+ret true
+end
+note ---- responses
+fn vwsech cs edit ulong 320 io edit uchar 131072 to long
+r = hhname cs io tcc
+r = hfe r hhval cs io tnostore
+r = hfe r hhname cs io txcto
+r = hfe r hhval cs io tnosniff
+r = hfe r hhname cs io trefp
+r = hfe r hhval cs io tnoref
+r = hfe r hhname cs io txfo
+r = hfe r hhval cs io tdeny
+r = hfe r hhname cs io tcsp
+ret hfe r hhval cs io tcspv
+end
+fn vwtext cs edit ulong 320 io edit uchar 131072 code ulong t view uchar * to long
+r = hrspst cs io code
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io tttext
+r = hfe r hhend cs io 0 len t
+r = hfe r hput cs io t
+ret hfe r hwfin cs io
+end
+fn vwcss cs edit ulong 320 io edit uchar 131072 buf edit uchar 262144 to long
+vwpb
+vwpt tfcss
+n = vwrdbuf buf
+if lt n 0
+ret vwtext cs io 404 tnotfnd
+end
+r = hrspst cs io 200
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io ttcss
+r = hfe r hhend cs io 0 ulong n
+r = hfe r hput cs io view part buf 0 ulong n
+ret hfe r hwfin cs io
+end
+note vwrdbuf: the whole file at gpth into buf (refused when it does not fit)
+fn vwrdbuf buf edit uchar 262144 to long
+fd = fopen gpth 0 get gpl 0 524288 0
+if lt fd 0
+ret fd
+end
+n = ulong 0
+for it ulong 100000
+if ge n len buf
+x = fclose int fd
+ret -27
+end
+r = read int fd buf n sub len buf n
+if lt r 0
+x = fclose int fd
+ret r
+end
+if eq r 0
+break
+end
+n = add n ulong r
+end
+x = fclose int fd
+ret long n
+end
+note vwlogin: GET /?t=<64 hex> sets the HttpOnly SameSite=Strict cookie and redirects to /
+fn vwlogin cs edit ulong 320 io edit uchar 131072 to long
+tg = get cs HTOFF
+tl = get cs HTLEN
+ok = false
+if eq tl add len tqt 64
+if heq view part io tg len tqt tqt
+ok = vwtokeq io add tg len tqt
+end
+end
+if not ok
+ret vwtext cs io 403 tbadlink
+end
+ck = new uchar 160 0
+n = ulong 0
+for i ulong len tckpre
+put ck n get tckpre i
+n = add n 1
+end
+for i ulong 64
+put ck n get gtok i
+n = add n 1
+end
+for i ulong len tckattr
+put ck n get tckattr i
+n = add n 1
+end
+r = hrspst cs io 302
+r = hfe r vwsech cs io
+r = hfe r hhname cs io tsetck
+r = hfe r hhval cs io view part ck 0 n
+r = hfe r hhname cs io tloc
+r = hfe r hhval cs io troot
+r = hfe r hhend cs io 0 0
+ret hfe r hwfin cs io
+end
+fn vwnlat buf edit uchar 262144 p ulong n ulong to ulong
+for i ulong sub n p
+if eq get buf add p i 10
+ret add p i
+end
+end
+ret n
+end
+fn vwbeq buf edit uchar 262144 a ulong n ulong t view uchar * to bool
+if ne n len t
+ret false
+end
+for i ulong n
+if ne get buf add a i get t i
+ret false
+end
+end
+ret true
+end
+note vwsendp: body "NAME<LF>ACTION<LF>TEXT". Returns 0 sent, 1 malformed, 2 bad name,
+note 3 bad action, 4 bad text, 5 no such session, 6 tmux failed, 7 text too long, 8 send log
+note cannot be opened (checked before anything is typed, so no keys go out unlogged)
+fn vwsendp buf edit uchar 262144 n ulong to ulong
+e1 = vwnlat buf 0 n
+if ge e1 n
+ret 1
+end
+e2 = vwnlat buf add e1 1 n
+if ge e2 n
+ret 1
+end
+if or eq e1 0 gt e1 63
+ret 2
+end
+for i ulong e1
+if not vwnamec get buf i
+ret 2
+end
+end
+act = ulong 9
+if vwbeq buf add e1 1 sub sub e2 e1 1 taline
+act = 0
+end
+if vwbeq buf add e1 1 sub sub e2 e1 1 taenter
+act = 1
+end
+if vwbeq buf add e1 1 sub sub e2 e1 1 taesc
+act = 2
+end
+if eq act 9
+ret 3
+end
+t0 = add e2 1
+tn = sub n t0
+if gt tn 4096
+ret 7
+end
+if ne act 0
+if ne tn 0
+ret 4
+end
+end
+vwhpath tlogp
+lf = fopen gpth 0 get gpl 0 525377 384
+if lt lf 0
+ret 8
+end
+put glfd 0 lf
+if not vwutf8 view part buf t0 tn
+vwlogl buf e1 act t0 tn 1
+ret 4
+end
+if not vwlive buf e1
+vwlogl buf e1 act t0 tn 2
+ret 5
+end
+ok = vwtype buf e1 act t0 tn
+if ok
+vwlogl buf e1 act t0 tn 0
+ret 0
+end
+vwlogl buf e1 act t0 tn 3
+ret 6
+end
+note vwutf8: well-formed UTF-8 with no C0 control, DEL or C1 control character
+fn vwutf8 a view uchar * to bool
+n = len a
+i = ulong 0
+for it ulong 8192
+if ge i n
+ret true
+end
+c = get a i
+if lt c 128
+if or lt c 32 eq c 127
+ret false
+end
+i = add i 1
+continue
+end
+k = vwu8len a i
+if eq k 0
+ret false
+end
+i = add i k
+end
+ret false
+end
+note vwu8len: length of the well-formed multi-byte sequence at a[i], or 0 (RFC 3629 table 3-7)
+fn vwu8len a view uchar * i ulong to ulong
+n = len a
+c = get a i
+lo = uchar 128
+hi = uchar 191
+k = ulong 0
+if and ge c 194 le c 223
+k = 2
+if eq c 194
+lo = 160
+end
+end
+if and ge c 224 le c 239
+k = 3
+if eq c 224
+lo = 160
+end
+if eq c 237
+hi = 159
+end
+end
+if and ge c 240 le c 244
+k = 4
+if eq c 240
+lo = 144
+end
+if eq c 244
+hi = 143
+end
+end
+if eq k 0
+ret 0
+end
+if gt add i k n
+ret 0
+end
+b = get a add i 1
+if or lt b lo gt b hi
+ret 0
+end
+for j ulong sub k 2
+b = get a add i add j 2
+if or lt b 128 gt b 191
+ret 0
+end
+end
+ret k
+end
+note vwlive: buf[0, e1) is exactly one line of a fresh `tmux list-sessions -F #{session_name}`
+fn vwlive buf edit uchar 262144 e1 ulong to bool
+vwkb
+vwka ttmux
+vwka tlsess
+vwka tdashf
+vwka tlsfmt1
+r = vwrun 3000000000
+if ne r 0
+ret false
+end
+a = ulong 0
+n = get gol 0
+for i ulong n
+if eq get gob i 10
+if vwobeq buf e1 a i
+ret true
+end
+a = add i 1
+end
+end
+ret false
+end
+fn vwobeq buf edit uchar 262144 e1 ulong a ulong b ulong to bool
+if ne sub b a e1
+ret false
+end
+for i ulong e1
+if ne get gob add a i get buf i
+ret false
+end
+end
+ret true
+end
+note vwtarget: the packed argument "=NAME:" (exact session match, its active pane)
+fn vwtarget buf edit uchar 262144 e1 ulong to void
+vwkopen
+vwkc 61
+for i ulong e1
+vwkc get buf i
+end
+vwkc 58
+end
+fn vwkey buf edit uchar 262144 e1 ulong key view uchar * to bool
+vwkb
+vwka ttmux
+vwka tsendk
+vwka tdasht
+vwtarget buf e1
+vwka key
+ret eq vwrun 5000000000 0
+end
+note vwtype: send-keys -l in chunks of at most 2048 bytes cut at character boundaries (a packed
+note argument list holds 4096 bytes), then Enter. tmux reads an argument ending in ';' as a
+note command separator; such a chunk is sent as "...\;", which tmux turns back into "...;".
+fn vwtype buf edit uchar 262144 e1 ulong act ulong t0 ulong tn ulong to bool
+if eq act 1
+ret vwkey buf e1 tenter
+end
+if eq act 2
+ret vwkey buf e1 tescape
+end
+p = t0
+e = add t0 tn
+for it ulong 8
+if ge p e
+break
+end
+q = hmin e add p 2048
+for s ulong 4
+if ge q e
+break
+end
+if ne and get buf q 192 128
+break
+end
+q = sub q 1
+end
+if not vwchunk buf e1 p q
+ret false
+end
+p = q
+end
+ret vwkey buf e1 tenter
+end
+fn vwchunk buf edit uchar 262144 e1 ulong p ulong q ulong to bool
+vwkb
+vwka ttmux
+vwka tsendk
+vwka tdasht
+vwtarget buf e1
+vwka tdashl
+vwka tdd
+vwkopen
+for i ulong sub q p
+if and eq add p i sub q 1 eq get buf add p i 59
+vwkc 92
+end
+vwkc get buf add p i
+end
+ret eq vwrun 5000000000 0
+end
+note ---- the send log: one line per attempt that reached the session check (never the text)
+fn vwlc c uchar to void
+n = get glogl 0
+if lt n len glog
+put glog n c
+put glogl 0 add n 1
+end
+end
+fn vwlt t view uchar * to void
+for i ulong len t
+vwlc get t i
+end
+end
+fn vwld v ulong w ulong to void
+d = new uchar 20 0
+i = ulong 20
+x = v
+for it ulong 20
+i = sub i 1
+put d i uchar add rem x 10 48
+x = div x 10
+if and eq x 0 ge sub 20 i w
+break
+end
+end
+for k ulong sub 20 i
+vwlc get d add i k
+end
+end
+note vwltime: realns as UTC YYYY-MM-DDTHH:MM:SSZ (civil-from-days, proleptic Gregorian)
+fn vwltime to void
+s = div ulong realns 1000000000
+vwldate div s 86400
+sec = rem s 86400
+vwlc 84
+vwld div sec 3600 2
+vwlc 58
+vwld div rem sec 3600 60 2
+vwlc 58
+vwld rem sec 60 2
+vwlc 90
+end
+fn vwldate days ulong to void
+z = add days 719468
+era = div z 146097
+doe = sub z mul era 146097
+yoe = vwyoe doe
+doy = sub doe sub add mul 365 yoe div yoe 4 div yoe 100
+mp = div add mul 5 doy 2 153
+m = add mp 3
+if ge mp 10
+m = sub mp 9
+end
+y = add yoe mul era 400
+if le m 2
+y = add y 1
+end
+vwld y 4
+vwlc 45
+vwld m 2
+vwlc 45
+vwld add sub doy div add mul 153 mp 2 5 1 2
+end
+fn vwyoe doe ulong to ulong
+a = sub doe div doe 1460
+b = add a div doe 36524
+ret div sub b div doe 146096 365
+end
+fn vwlres res ulong to void
+if eq res 0
+vwlt tlok
+ret
+end
+if eq res 1
+vwlt tlbadtx
+ret
+end
+if eq res 2
+vwlt tlnosess
+ret
+end
+vwlt tlfail
+end
+fn vwlogl buf edit uchar 262144 e1 ulong act ulong t0 ulong tn ulong res ulong to void
+put glogl 0 0
+vwltime
+vwlc 32
+vwlt tlsessn
+for i ulong e1
+vwlc get buf i
+end
+vwlt tlact
+if eq act 0
+vwlt taline
+end
+if eq act 1
+vwlt taenter
+end
+if eq act 2
+vwlt taesc
+end
+vwlt tlbytes
+vwld tn 1
+vwlt tlsha
+dg = new uchar 32 0
+k = sha2_digest 256 view part buf t0 tn dg
+for i ulong 32
+c = get dg i
+vwlc get thexd shr c 4
+vwlc get thexd and c 15
+end
+vwlt tlres
+vwlres res
+vwlc 10
+fd = get glfd 0
+w = write int fd glog 0 get glogl 0
+x = fclose int fd
+end
diff --git a/tests/.crumb b/tests/.crumb
new file mode 100644
index 0000000..066a4dd
--- /dev/null
+++ b/tests/.crumb
@@ -0,0 +1,31 @@
+{
+  "above": {
+    "name": "hive-view",
+    "path": ".."
+  },
+  "extensions": {
+    "generated": {
+      "children": [],
+      "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "compiled_at": "2026-11-07T08:14:29Z",
+      "compiler": "crumb-compile/1",
+      "digest": "sha256:df49ed1d5aac308410cb69b54d02f1725f9798179603b44219504f3e134ac6be",
+      "evidence_files": 0,
+      "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "files": 1,
+      "generated_at_commit": "999ab195c49c95eed49c01c1e0506ca21ef0f411",
+      "source_tree": "sha256:1b853165bbd2b5abc2eb07e7108ab5848b23c12b05694390fb5361aab0b734ce"
+    },
+    "owner_lane": "",
+    "seed": {
+      "files": [
+        "gate.om"
+      ],
+      "purpose_auto": "Directory tests. Purpose not yet described by a human."
+    }
+  },
+  "layer": "tests",
+  "name": "tests",
+  "purpose": "gate.om, the acceptance gate in Omega: 52 checks against a running server through a tee sink session, plus a CPU tick meter. Python and shell drivers are not allowed here.",
+  "schema_version": "1.0.0"
+}
diff --git a/tests/gate.om b/tests/gate.om
new file mode 100644
index 0000000..3c616a4
--- /dev/null
+++ b/tests/gate.om
@@ -0,0 +1,1212 @@
+note hive-view tests/gate.om: the acceptance gate, in pure Omega. Built like the server, with
+note src/util.om and src/run.om (no shell, exact argument lists) and this file as the entry:
+note   gate run PORT        drive a running server on 127.0.0.1:PORT through every check below;
+note                        prints one PASS/FAIL line per check, exit 0 only when all pass
+note   gate cpu PID SECS    CPU ticks (USER_HZ) used by server PID with its children and by the
+note                        tmux server over SECS seconds
+note The run mode creates its own tmux session hv-test whose only program is
+note `/usr/bin/tee -a /tmp/hv-gate-sink` on a raw (-icanon -echo) terminal, so every byte the
+note dashboard types is recorded exactly; it is deleted at the end (which is itself a check).
+global gaport ulong 1
+global gax uchar 64
+global gaxl ulong 1
+global gatg uchar 1024
+global gatgl ulong 1
+global gabd uchar 40000
+global gabdl ulong 1
+global garb uchar 262144
+global garbl ulong 1
+global galoc uchar 1024
+global galocl ulong 1
+global gack ulong 1
+global gakey uchar 64
+global gatx uchar 8192
+global gatxl ulong 1
+global gapass ulong 1
+global gafail ulong 1
+global gatk ulong 4
+text tget "GET"
+text tpost "POST"
+text tenvh "HOME="
+text ttokf "/.config/hive-view/token"
+text tlogf "/.local/state/hive-view/sends.log"
+text tsink "/tmp/hv-gate-sink"
+text ttmux "/usr/bin/tmux"
+text tstty "/usr/bin/stty"
+text ttee "/usr/bin/tee"
+text tnew "new-session"
+text tdd "-d"
+text tds "-s"
+text tdx "-x"
+text tdy "-y"
+text t120 "120"
+text t30 "30"
+text tdash "-a"
+text tkill "kill-session"
+text tdt "-t"
+text tdisp "display-message"
+text tdp "-p"
+text tptty "#{pane_tty}"
+text tpid "#{pid}"
+text tsessn "hv-test"
+text tsesst "=hv-test:"
+text tsesk "=hv-test"
+text tdf "-F"
+text ticanon "-icanon"
+text techo "-echo"
+text thost "Host"
+text tcook "Cookie"
+text torig "Origin"
+text tctype "Content-Type"
+text tform "application/x-www-form-urlencoded"
+text tckpre "hv="
+text thttp "http://"
+text tevil "http://evil.example"
+text tevilh "evil.example"
+text tlocn "location"
+text tsetck "set-cookie"
+text tphealth "/health"
+text troot "/"
+text tqt "/?t="
+text tpsend "/send"
+text tpses "/s/hv-test"
+text tpane "/p/pane?n=hv-test"
+text tkpat "name=\"k\" value=\""
+text tline "line"
+text tenter "enter"
+text tescape "escape"
+text tps "s"
+text tpq "q"
+text tpass "PASS "
+text tfail "FAIL "
+text tsum "gate: "
+text tsum2 " passed, "
+text tsum3 " failed\n"
+text tsha "sha256="
+text tbyt "bytes="
+text tmark "gate-secret-marker-5c1e"
+text tescs "&lt;script&gt;alert(1)&lt;/script&gt;"
+text tscr "<script>"
+text tcpu1 "hive-view ticks "
+text tcpu2 " tmux-server ticks "
+text tcpu3 " over "
+text tcpu4 " s (USER_HZ 100)\n"
+text tstat "/stat"
+text tproc "/proc/"
+text tchild "/task/"
+text tchild2 "/children"
+note ---- the cases typed literally: each must arrive byte for byte, followed by Enter (LF)
+text c01 "semi;"
+text c02 ";"
+text c03 ";;"
+text c04 "-n"
+text c05 "--"
+text c06 "$(id) `id` 'q' \"dq\" & | > <"
+text c07 "é ü 漢字 🐝"
+text c08 "<script>alert(1)</script>"
+text c09 "   leading and trailing spaces   "
+text c10 "%41+%20&a=escape"
+text c11 "send-keys -t =omp-queen: Enter"
+text n01 "send ;semi"
+note ---- output
+fn gaout to void
+n = get gsl 0
+p = ulong 0
+for it ulong 1000
+if ge p n
+break
+end
+w = write 1 gsb p sub n p
+if le w 0
+break
+end
+p = add p ulong w
+end
+put gsl 0 0
+end
+fn gachk ok bool name view uchar * to void
+if ok
+vwsbt tpass
+put gapass 0 add get gapass 0 1
+else
+vwsbt tfail
+put gafail 0 add get gafail 0 1
+end
+vwsbt name
+vwsbc 10
+gaout
+end
+note ---- environment
+fn gahome to bool
+eb = new uchar 600 0
+for i ulong ulong envcnt
+n = envread i eb 0 600
+if gt n 5
+if heq view part eb 0 5 tenvh
+k = hmin sub ulong n 5 511
+for j ulong k
+put ghome j get eb add 5 j
+end
+put ghomel 0 k
+ret gt k 0
+end
+end
+end
+ret false
+end
+fn gatok to bool
+vwpb
+vwph
+vwpt ttokf
+r = vwrdall 128
+if lt r 64
+ret false
+end
+for i ulong 64
+put gtok i get gob i
+end
+ret true
+end
+fn gadec a view uchar * to ulong
+v = ulong 0
+for i ulong len a
+c = get a i
+if not vwdig c
+ret v
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+note ---- HTTP client: one connection per request. fl: 1 cookie, 2 good Origin, 4 foreign Origin,
+note 8 foreign Host, 16 bad cookie. The response body lands in garb, Location in galoc, and gack
+note is 1 when Set-Cookie carried hv=<token>.
+fn gaxbuf to void
+put gaxl 0 0
+s = new uchar 24 0
+p = ulong 0
+put s 0 49
+put s 1 50
+put s 2 55
+put s 3 46
+put s 4 48
+put s 5 46
+put s 6 48
+put s 7 46
+put s 8 49
+put s 9 58
+p = 10
+for i ulong 10
+put gax i get s i
+end
+d = new uchar 20 0
+k = ulong 0
+x = get gaport 0
+for it ulong 20
+put d k uchar add rem x 10 48
+k = add k 1
+x = div x 10
+if eq x 0
+break
+end
+end
+for i ulong k
+put gax add p i get d sub sub k 1 i
+end
+put gaxl 0 add p k
+end
+fn gahdrs cs edit ulong 320 io edit uchar 131072 fl ulong to long
+hb = new uchar 64 0
+ck = new uchar 67 0
+o = new uchar 96 0
+n = get gaxl 0
+for i ulong n
+put hb i get gax i
+end
+r = hhname cs io thost
+if ne and fl 8 0
+r = hfe r hhval cs io tevilh
+else
+r = hfe r hhval cs io view part hb 0 n
+end
+if ne and fl 17 0
+for i ulong 3
+put ck i get tckpre i
+end
+for i ulong 64
+put ck add 3 i get gtok i
+end
+if ne and fl 16 0
+put ck 3 48
+if eq get gtok 0 48
+put ck 3 49
+end
+end
+r = hfe r hhname cs io tcook
+r = hfe r hhval cs io ck
+end
+if ne and fl 2 0
+for i ulong 96
+put o i 0
+end
+for i ulong 7
+put o i get thttp i
+end
+n = get gaxl 0
+for i ulong n
+put o add 7 i get gax i
+end
+r = hfe r hhname cs io torig
+r = hfe r hhval cs io view part o 0 add 7 n
+end
+if ne and fl 4 0
+r = hfe r hhname cs io torig
+r = hfe r hhval cs io tevil
+end
+ret r
+end
+fn gawreq cs edit ulong 320 io edit uchar 131072 post bool fl ulong to long
+tg = new uchar 1024 0
+bd = new uchar 40000 0
+r = long 0
+if post
+r = hreqst cs io tpost
+else
+r = hreqst cs io tget
+end
+tn = get gatgl 0
+for i ulong tn
+put tg i get gatg i
+end
+r = hfe r hreqtg cs io view part tg 0 tn
+r = hfe r gahdrs cs io fl
+bl = ulong 0
+if post
+r = hfe r hhname cs io tctype
+r = hfe r hhval cs io tform
+bl = get gabdl 0
+end
+r = hfe r hhend cs io 0 bl
+if post
+for i ulong bl
+put bd i get gabd i
+end
+r = hfe r hput cs io view part bd 0 bl
+end
+ret hfe r hwfin cs io
+end
+fn garbody cs edit ulong 320 io edit uchar 131072 to void
+rb = new uchar 262144 0
+put cs HBCAP 262144
+n = hbodyall cs io rb
+m = ulong 0
+if gt n 0
+m = ulong n
+end
+for i ulong m
+put garb i get rb i
+end
+put garbl 0 m
+end
+fn gareq post bool fl ulong to long
+a = new uchar 16 0
+cs = new ulong 320 0
+io = new uchar 131072 0
+put garbl 0 0
+put galocl 0 0
+put gack 0 0
+r = haddr4 a uint 2130706433 get gaport 0
+fd = hdial a 3000000000
+if lt fd 0
+ret fd
+end
+r = hinit cs io int fd 0
+hsettmo cs 10000000000 10000000000
+hsetbdl cs 10000000000
+r = hfe r gawreq cs io post fl
+if lt r 0
+x = hclose cs
+ret r
+end
+s = hrsprd cs io
+if lt s 0
+x = hclose cs
+ret s
+end
+garesp cs io
+garbody cs io
+x = hclose cs
+ret s
+end
+fn garesp cs edit ulong 320 io edit uchar 131072 to void
+i = hhfind cs io tlocn
+if ge i 0
+vo = hhvoff cs ulong i
+vl = hmin hhvlen cs ulong i 1024
+for k ulong vl
+put galoc k get io add vo k
+end
+put galocl 0 vl
+end
+j = hhfind cs io tsetck
+if ge j 0
+vo = hhvoff cs ulong j
+vl = hhvlen cs ulong j
+if ge vl 67
+ok = heq view part io vo 3 tckpre
+for k ulong 64
+if ne get io add add vo 3 k get gtok k
+ok = false
+end
+end
+if ok
+put gack 0 1
+end
+end
+end
+end
+fn gatgt t view uchar * to void
+for i ulong len t
+put gatg i get t i
+end
+put gatgl 0 len t
+end
+fn gaget t view uchar * fl ulong to long
+gatgt t
+ret gareq false fl
+end
+fn hmax2 a long b long to long
+if gt a b
+ret a
+end
+ret b
+end
+fn garbat a ulong t view uchar * to bool
+if gt add a len t get garbl 0
+ret false
+end
+for i ulong len t
+if ne get garb add a i get t i
+ret false
+end
+end
+ret true
+end
+fn gaobat a ulong t view uchar * to bool
+if gt add a len t get gol 0
+ret false
+end
+for i ulong len t
+if ne get gob add a i get t i
+ret false
+end
+end
+ret true
+end
+note gahas: garb contains t
+fn gahas t view uchar * to bool
+n = get garbl 0
+m = len t
+if gt m n
+ret false
+end
+for i ulong add sub n m 1
+if garbat i t
+ret true
+end
+end
+ret false
+end
+note ---- form bodies
+fn gabc c uchar to void
+n = get gabdl 0
+if lt n len gabd
+put gabd n c
+put gabdl 0 add n 1
+end
+end
+fn gabt t view uchar * to void
+for i ulong len t
+gabc get t i
+end
+end
+note gabe: percent-encode every byte except ASCII letters and digits
+fn gabe a view uchar * to void
+for i ulong len a
+c = get a i
+if or vwdig c or and ge c 65 le c 90 and ge c 97 le c 122
+gabc c
+else
+gabc 37
+gabc get thexd ulong shr ulong c 4
+gabc get thexd and ulong c 15
+end
+end
+end
+fn gafld k uchar v view uchar * to void
+if gt get gabdl 0 0
+gabc 38
+end
+gabc k
+gabc 61
+gabe v
+end
+note gaform: s, k, r, a and t (the text is gatx[0, gatxl)); badk 1 sends a wrong key
+fn gaform sn view uchar * act view uchar * badk ulong to void
+z = new uchar 64 48
+kk = new uchar 64 0
+tx = new uchar 8192 0
+put gabdl 0 0
+gafld 115 sn
+if eq badk 1
+gafld 107 z
+else
+for i ulong 64
+put kk i get gakey i
+end
+gafld 107 kk
+end
+gafld 114 tps
+gafld 97 act
+n = get gatxl 0
+for i ulong n
+put tx i get gatx i
+end
+gafld 116 view part tx 0 n
+end
+fn gapost fl ulong to long
+gatgt tpsend
+ret gareq true fl
+end
+note galq: the number after "<c>=" in the Location query, or 999999
+fn galq c uchar to ulong
+n = get galocl 0
+for i ulong n
+if and eq get galoc i c lt add i 1 n
+if eq get galoc add i 1 61
+p = add i 2
+if or eq i 0 or eq get galoc sub i 1 63 eq get galoc sub i 1 38
+v = ulong 0
+ok = false
+for k ulong 20
+if ge add p k n
+break
+end
+d = get galoc add p k
+if not vwdig d
+break
+end
+v = add mul v 10 ulong sub d 48
+ok = true
+end
+if ok
+ret v
+end
+end
+end
+end
+end
+ret 999999
+end
+note ---- the sink file written by tee inside hv-test
+fn gasinkp to void
+vwpb
+vwpt tsink
+end
+fn gasize to ulong
+gasinkp
+fd = vwfopen
+if lt fd 0
+ret 0
+end
+r = fstat int fd gstb 0 128
+x = fclose int fd
+if lt r 0
+ret 0
+end
+ret vwst64 48
+end
+fn gawait want ulong to bool
+for it ulong 60
+if ge gasize want
+ret true
+end
+x = sleepns 50000000
+end
+ret ge gasize want
+end
+note gasink: the sink from offset off holds exactly gatx[0, gatxl) followed by the byte tail
+fn gasink off ulong tail long to bool
+gasinkp
+r = vwrdall 262144
+if lt r 0
+ret false
+end
+n = get gatxl 0
+want = n
+if ge tail 0
+want = add n 1
+end
+if ne get gol 0 add off want
+ret false
+end
+for i ulong n
+if ne get gob add off i get gatx i
+ret false
+end
+end
+if ge tail 0
+ret eq get gob add off n uchar tail
+end
+ret true
+end
+fn gasett t view uchar * to void
+for i ulong len t
+put gatx i get t i
+end
+put gatxl 0 len t
+end
+note gatype: type gatx with action act; true when the redirect reports m=0, the byte count, and the
+note sink received exactly the text plus tail (LF for a line, ESC for Escape, LF for Enter)
+fn gatype act view uchar * tail long to bool
+s0 = gasize
+gaform tsessn act 0
+st = gapass2
+if ne st 302
+ret false
+end
+nb = ulong 0
+if heq act tline
+nb = get gatxl 0
+end
+if ne galq 109 0
+ret false
+end
+if ne galq 98 nb
+ret false
+end
+want = add s0 add nb 1
+if not gawait want
+ret false
+end
+if heq act tline
+ret gasink s0 tail
+end
+gasinkp
+r = vwrdall 262144
+if ne get gol 0 want
+ret false
+end
+ret eq get gob s0 uchar tail
+end
+fn gapass2 to long
+ret gapost 3
+end
+note garef: the send is refused with code m and nothing reaches the sink
+fn garef act view uchar * m ulong to bool
+s0 = gasize
+gaform tsessn act 0
+st = gapost 3
+if ne st 302
+ret false
+end
+if ne galq 109 m
+ret false
+end
+x = sleepns 300000000
+ret eq gasize s0
+end
+note ---- tmux and the sink session
+fn gatmux to void
+vwkb
+vwka ttmux
+end
+fn gamkses to bool
+gatmux
+vwka tkill
+vwka tdt
+vwka tsesk
+r = vwrun 5000000000
+gasinkp
+u = unlink gpth 0 get gpl 0
+gatmux
+vwka tnew
+vwka tdd
+vwka tds
+vwka tsessn
+vwka tdx
+vwka t120
+vwka tdy
+vwka t30
+vwka ttee
+vwka tdash
+vwka tsink
+r = vwrun 5000000000
+if ne r 0
+ret false
+end
+gatmux
+vwka tdisp
+vwka tdp
+vwka tdt
+vwka tsesst
+vwka tptty
+r = vwrun 5000000000
+if ne r 0
+ret false
+end
+n = get gol 0
+if and gt n 0 eq get gob sub n 1 10
+n = sub n 1
+end
+if or eq n 0 gt n 200
+ret false
+end
+vwkb
+vwka tstty
+vwka tdf
+vwkopen
+for i ulong n
+vwkc get gob i
+end
+vwka ticanon
+vwka techo
+r = vwrun 5000000000
+x = sleepns 300000000
+ret eq r 0
+end
+fn gakilss to bool
+gatmux
+vwka tkill
+vwka tdt
+vwka tsesk
+r = vwrun 5000000000
+ret eq r 0
+end
+note gakey: the form key from the hv-test page
+fn gagetk to bool
+st = gaget tpses 1
+if ne st 200
+ret false
+end
+n = get garbl 0
+m = len tkpat
+if lt n add m 64
+ret false
+end
+for i ulong sub sub n m 63
+if garbat i tkpat
+for k ulong 64
+put gakey k get garb add add i m k
+end
+ret true
+end
+end
+ret false
+end
+note ---- send log: the newest line names the bytes and the sha256 of the text; the file never
+note contains the marker text
+fn galogok to bool
+dg = new uchar 32 0
+tx = new uchar 8192 0
+tn = get gatxl 0
+for i ulong tn
+put tx i get gatx i
+end
+k = sha2_digest 256 view part tx 0 tn dg
+hx = new uchar 71 0
+for i ulong 7
+put hx i get tsha i
+end
+for i ulong 32
+put hx add 7 mul i 2 get thexd ulong shr ulong get dg i 4
+put hx add 8 mul i 2 get thexd and ulong get dg i 15
+end
+vwpb
+vwph
+vwpt tlogf
+r = vwrdtail 4096
+if lt r 0
+ret false
+end
+e = get gol 0
+if eq e 0
+ret false
+end
+if eq get gob sub e 1 10
+e = sub e 1
+end
+b = e
+for it ulong 4096
+if eq b 0
+break
+end
+if eq get gob sub b 1 10
+break
+end
+b = sub b 1
+end
+ok = false
+for i ulong sub e b
+if gt add add b i 71 e
+break
+end
+if gaobat add b i hx
+ok = true
+end
+end
+ret ok
+end
+fn galogno to bool
+vwpb
+vwph
+vwpt tlogf
+r = vwrdall 262144
+n = get gol 0
+m = len tmark
+if lt n m
+ret true
+end
+for i ulong add sub n m 1
+if gaobat i tmark
+ret false
+end
+end
+ret true
+end
+text tbadact "type"
+text thc01 "health answers 200 without auth"
+text thc02 "GET / without the cookie is refused (403)"
+text thc03 "a panel without the cookie is refused (403)"
+text thc04 "a wrong cookie is refused (403)"
+text thc05 "a wrong one-time link is refused (403)"
+text thc06 "the one-time link answers 302 and sets the token cookie"
+text thc07 "a foreign Host header is refused (400)"
+text thc08 "GET /send is refused (405)"
+text thc09 "test session hv-test created (tee into the sink, raw terminal)"
+text thc10 "the form key is on the session page"
+text thc11 "POST /send without the cookie is refused (403)"
+text thc12 "POST /send without an Origin header is refused (403)"
+text thc13 "POST /send from a foreign Origin is refused (403)"
+text thc14 "POST /send with a wrong form key is refused (403)"
+text thc15 "nothing reached the session from the refused posts"
+text thc16 "literal backslash-semicolon inside the text"
+text thc17 "literal backslash-semicolon alone"
+text thc18 "text ending in backslash-semicolon"
+text thc19 "4096-byte text (the limit) with semicolons at the chunk edges"
+text thc20 "Enter button sends one Enter"
+text thc21 "Escape button sends one Escape"
+text thc22 "marker text typed"
+text thc23 "send log names the byte count and sha256 of the text"
+text thc24 "send log never contains the text"
+text thc25 "4097-byte text refused (m=7), nothing typed"
+text thc26 "control byte 0x01 refused (m=4), nothing typed"
+text thc27 "newline inside the text refused (m=4), nothing typed"
+text thc28 "DEL refused (m=4), nothing typed"
+text thc29 "invalid UTF-8 byte 0xff refused (m=4), nothing typed"
+text thc30 "overlong UTF-8 refused (m=4), nothing typed"
+text thc31 "carriage return refused (m=4), nothing typed"
+text thc32 "tab refused (m=4), nothing typed"
+text thc33 "escape byte inside the text refused (m=4), nothing typed"
+text thc34 "unknown action refused (m=3), nothing typed"
+text thc35 "malformed and forged session names refused (m=2), nothing typed"
+text thc36 "duplicate or unknown form fields refused (m=1), nothing typed"
+text thc37 "a body over 16 KiB is refused (413), nothing typed"
+text thc38 "<script> on a session screen is shown escaped, never as markup"
+text thc39 "test session hv-test deleted"
+text thc40 "typing into the deleted session is refused (m=5)"
+text thc41 "hv-test no longer exists"
+text thc42 "with the send log unwritable the send is refused (m=8), nothing typed"
+fn gareq2 t view uchar * to long
+gatgt t
+ret gareq false 0
+end
+note gafbad: forged names (shell metacharacters, a tmux target, path, empty, too long) get m=2
+text nb1 "hv-test;ls"
+text nb2 "=omp-queen:"
+text nb3 "../hv-test"
+text nb4 "hv test"
+text nb5 "omp-queen:0.1"
+fn gafbn n view uchar * to bool
+s0 = gasize
+gasett c01
+gaform n tline 0
+st = gapost 3
+if or ne st 302 ne galq 109 2
+ret false
+end
+ret eq gasize s0
+end
+fn gafbad to bool
+e = new uchar 1 0
+l = new uchar 64 97
+ok = gafbn nb1
+ok = and ok gafbn nb2
+ok = and ok gafbn nb3
+ok = and ok gafbn nb4
+ok = and ok gafbn nb5
+ok = and ok gafbn view part e 0 0
+ok = and ok gafbn l
+ret ok
+end
+note gafdup: a repeated field, an unknown field, a field without '=', a bad percent escape
+text db1 "&s=hv-test"
+text db2 "&x=1"
+text db3 "&t"
+text db4 "&t=%zz"
+fn gafdb t view uchar * to bool
+s0 = gasize
+gasett c01
+gaform tsessn tline 0
+gabt t
+st = gapost 3
+if or ne st 302 ne galq 109 1
+ret false
+end
+ret eq gasize s0
+end
+fn gafdup to bool
+ok = gafdb db1
+ok = and ok gafdb db2
+ok = and ok gafdb db3
+ok = and ok gafdb db4
+ret ok
+end
+fn gafbig to bool
+s0 = gasize
+gasett c01
+gaform tsessn tline 0
+for i ulong 16400
+gabc 120
+end
+st = gapost 3
+x = sleepns 300000000
+ret and eq st 413 eq gasize s0
+end
+note gapane: type gatx (a <script> line) again so it is on the visible screen, wait for the poller
+note to capture it, then read the pane panel: the markup must arrive escaped
+fn gapane to bool
+if not gatype tline 10
+ret false
+end
+for it ulong 20
+x = sleepns 500000000
+st = gaget tpane 1
+if eq st 200
+if gahas tescs
+ret not gahas tscr
+end
+end
+end
+ret false
+end
+note ---- the run mode
+fn garun to int
+gaxbuf
+if not gatok
+ret 3
+end
+gachk eq gaget tphealth 0 200 thc01
+gachk eq gaget troot 0 403 thc02
+gachk eq gaget tpane 0 403 thc03
+gachk eq gaget troot 16 403 thc04
+z = new uchar 68 48
+for i ulong 4
+put z i get tqt i
+end
+gachk eq gareq2 z 403 thc05
+for i ulong 64
+put z add 4 i get gtok i
+end
+st = gareq2 z
+gachk and eq st 302 eq get gack 0 1 thc06
+gachk eq gaget troot 9 400 thc07
+gachk eq gaget tpsend 1 405 thc08
+gachk gamkses thc09
+gachk gagetk thc10
+gasett c01
+gaform tsessn tline 0
+gachk eq gapost 0 403 thc11
+gachk eq gapost 1 403 thc12
+gachk eq gapost 5 403 thc13
+gaform tsessn tline 1
+gachk eq gapost 3 403 thc14
+gachk eq gasize 0 thc15
+gasett c01
+gachk gatype tline 10 c01
+gasett c02
+gachk gatype tline 10 c02
+gasett c03
+gachk gatype tline 10 c03
+gasett c04
+gachk gatype tline 10 c04
+gasett c05
+gachk gatype tline 10 c05
+gasett c06
+gachk gatype tline 10 c06
+gasett c07
+gachk gatype tline 10 c07
+gasett c08
+gachk gatype tline 10 c08
+gasett c09
+gachk gatype tline 10 c09
+gasett c10
+gachk gatype tline 10 c10
+gasett c11
+gachk gatype tline 10 c11
+gasett n01
+put gatx 4 92
+gachk gatype tline 10 thc16
+put gatx 0 92
+put gatx 1 59
+put gatxl 0 2
+gachk gatype tline 10 thc17
+put gatx 0 98
+put gatx 1 115
+put gatx 2 92
+put gatx 3 59
+put gatxl 0 4
+gachk gatype tline 10 thc18
+for i ulong 4096
+put gatx i uchar add 97 rem i 26
+end
+put gatx 2047 59
+put gatx 4095 59
+put gatxl 0 4096
+gachk gatype tline 10 thc19
+put gatxl 0 0
+gachk gatype tenter 10 thc20
+gachk gatype tescape 27 thc21
+gasett tmark
+gachk gatype tline 10 thc22
+gachk galogok thc23
+gachk galogno thc24
+for i ulong 4097
+put gatx i 120
+end
+put gatxl 0 4097
+gachk garef tline 7 thc25
+gasett c01
+put gatx 2 1
+gachk garef tline 4 thc26
+put gatx 2 10
+gachk garef tline 4 thc27
+put gatx 2 127
+gachk garef tline 4 thc28
+put gatx 2 255
+gachk garef tline 4 thc29
+put gatx 1 192
+put gatx 2 175
+gachk garef tline 4 thc30
+put gatx 2 13
+gachk garef tline 4 thc31
+put gatx 2 9
+gachk garef tline 4 thc32
+put gatx 2 27
+gachk garef tline 4 thc33
+gasett c01
+gachk garef tbadact 3 thc34
+gachk gafbad thc35
+gachk gafdup thc36
+gachk gafbig thc37
+gasett c08
+gachk gapane thc38
+gachk gakilss thc39
+gasett c01
+gachk garef tline 5 thc40
+gachk not gakilss thc41
+gaend
+ret garc
+end
+note gaend / garc: delete the sink file, print the summary; exit 0 only when nothing failed
+fn gaend to void
+gasinkp
+u = unlink gpth 0 get gpl 0
+vwsbt tsum
+vwsbd get gapass 0
+vwsbt tsum2
+vwsbd get gafail 0
+vwsbt tsum3
+gaout
+end
+fn garc to int
+if eq get gafail 0 0
+ret 0
+end
+ret 1
+end
+note ganolog: against a server whose HOME has no writable ~/.local/state/hive-view, a send is
+note refused with code 8 before anything is typed (the gate runs with that same HOME)
+fn ganolog to int
+gaxbuf
+if not gatok
+ret 3
+end
+z = new uchar 68 48
+for i ulong 4
+put z i get tqt i
+end
+for i ulong 64
+put z add 4 i get gtok i
+end
+st = gareq2 z
+gachk and eq st 302 eq get gack 0 1 thc06
+gachk gamkses thc09
+gachk gagetk thc10
+gasett c01
+gachk garef tline 8 thc42
+gachk gakilss thc39
+gaend
+ret garc
+end
+note ---- the cpu mode: utime + stime + cutime + cstime (fields 14..17 of /proc/PID/stat)
+fn gastat pid ulong to ulong
+vwpb
+vwpt tproc
+vwpd pid
+vwpt tstat
+r = vwrdall 4096
+if lt r 0
+ret 0
+end
+n = get gol 0
+p = ulong 0
+for i ulong n
+if eq get gob i 41
+p = i
+end
+end
+f = ulong 2
+v = ulong 0
+s = ulong 0
+for i ulong sub n p
+c = get gob add p i
+if eq c 32
+if and ge f 14 le f 17
+s = add s v
+end
+f = add f 1
+v = 0
+else
+if vwdig c
+v = add mul v 10 ulong sub c 48
+end
+end
+end
+ret s
+end
+note gatree: ticks of pid plus its direct children (the poller and the connection handlers)
+fn gatree pid ulong to ulong
+t = gastat pid
+vwpb
+vwpt tproc
+vwpd pid
+vwpt tchild
+vwpd pid
+vwpt tchild2
+r = vwrdall 4096
+if lt r 0
+ret t
+end
+n = get gol 0
+kids = new ulong 256 0
+k = ulong 0
+v = ulong 0
+for i ulong add n 1
+c = uchar 32
+if lt i n
+c = get gob i
+end
+if vwdig c
+v = add mul v 10 ulong sub c 48
+else
+if and gt v 0 lt k 256
+put kids k v
+k = add k 1
+end
+v = 0
+end
+end
+for i ulong k
+t = add t gastat get kids i
+end
+ret t
+end
+fn gatmxp to ulong
+gatmux
+vwka tdisp
+vwka tdp
+vwka tpid
+r = vwrun 5000000000
+if ne r 0
+ret 0
+end
+v = ulong 0
+for i ulong get gol 0
+c = get gob i
+if not vwdig c
+break
+end
+v = add mul v 10 ulong sub c 48
+end
+ret v
+end
+fn gacpu pid ulong secs ulong to int
+tp = gatmxp
+a0 = gatree pid
+b0 = gastat tp
+x = sleepns long mul secs 1000000000
+a1 = gatree pid
+b1 = gastat tp
+da = ulong 0
+if gt a1 a0
+da = sub a1 a0
+end
+db = ulong 0
+if gt b1 b0
+db = sub b1 b0
+end
+vwsbt tcpu1
+vwsbd da
+vwsbt tcpu2
+vwsbd db
+vwsbt tcpu3
+vwsbd secs
+vwsbt tcpu4
+gaout
+ret 0
+end
+text trun "run"
+text tcpu "cpu"
+text tnolog "nolog"
+fn main to int
+if not gahome
+ret 6
+end
+ab = new uchar 512 0
+n = argread 1 ab 0 512
+if lt argcnt 3
+ret 2
+end
+if heq view part ab 0 ulong hmin ulong n 512 trun
+m = argread 2 ab 0 512
+put gaport 0 gadec view part ab 0 ulong m
+ret garun
+end
+if heq view part ab 0 ulong hmin ulong n 512 tcpu
+if lt argcnt 4
+ret 2
+end
+m = argread 2 ab 0 512
+pid = gadec view part ab 0 ulong m
+m = argread 3 ab 0 512
+secs = gadec view part ab 0 ulong m
+ret gacpu pid secs
+end
+if heq view part ab 0 ulong hmin ulong n 512 tnolog
+m = argread 2 ab 0 512
+put gaport 0 gadec view part ab 0 ulong m
+ret ganolog
+end
+ret 2
+end
diff --git a/web/.crumb b/web/.crumb
new file mode 100644
index 0000000..a804224
--- /dev/null
+++ b/web/.crumb
@@ -0,0 +1,31 @@
+{
+  "above": {
+    "name": "hive-view",
+    "path": ".."
+  },
+  "extensions": {
+    "generated": {
+      "children": [],
+      "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "compiled_at": "2026-11-07T08:08:30Z",
+      "compiler": "crumb-compile/1",
+      "digest": "sha256:75fe0e0530b97483a04ac5eb4dcb53a30a757697ff50e271804d2dbf1f7feffe",
+      "evidence_files": 0,
+      "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+      "files": 1,
+      "generated_at_commit": "e17acf9bcd535302ad8fb8a9fe6a8e43c7172d17",
+      "source_tree": "sha256:a775d9909c75ee13fce79e9ab31e71328e2d2fe07062589c5b04ce7e8a17381e"
+    },
+    "owner_lane": "",
+    "seed": {
+      "files": [
+        "app.css"
+      ],
+      "purpose_auto": "Directory web. Purpose not yet described by a human."
+    }
+  },
+  "layer": "web",
+  "name": "web",
+  "purpose": "app.css, the only static file the server sends; presentation only, no script.",
+  "schema_version": "1.0.0"
+}
diff --git a/web/app.css b/web/app.css
new file mode 100644
index 0000000..7e64fe9
--- /dev/null
+++ b/web/app.css
@@ -0,0 +1,94 @@
+/* hive-view styling. Static presentation only: every page is drawn by the Omega server and the
+   browser runs no script (the CSP allows none). Terminal colours come from /palette.css. */
+:root {
+  --bg: #0f1115; --panel: #171a21; --line: #2a2f3a; --fg: #d7dae0; --muted: #8a919e;
+  --ok: #3fb950; --warn: #d29922; --bad: #f85149; --accent: #58a6ff;
+  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
+}
+* { box-sizing: border-box; }
+html, body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
+body.frame { background: var(--panel); padding: .1rem; }
+a { color: var(--accent); }
+.top { position: sticky; top: 0; z-index: 5; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
+  padding: .4rem .8rem; background: #0b0d11; border-bottom: 1px solid var(--line); }
+.top h1 { font-size: 1.05rem; margin: 0 .4rem 0 0; }
+.back { text-decoration: none; }
+.note { margin: .5rem .8rem; font-size: .8rem; color: var(--muted); }
+.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; margin: .6rem .8rem; min-width: 0; }
+.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
+.cols > .panel { margin-right: .4rem; }
+h2 { font-size: 1rem; margin: 0 0 .3rem; } h2 a { font-size: .8rem; font-weight: 400; margin-left: .6rem; }
+h3 { font-size: .9rem; margin: .4rem 0 .2rem; color: var(--muted); }
+iframe { display: block; width: 100%; border: 0; background: var(--panel); }
+.fstatus { width: 34rem; max-width: 100%; height: 2rem; }
+.fqueen { height: 60vh; }
+.ftiles { height: 30rem; }
+.fhermes { height: 18rem; } .fleads { height: 22rem; }
+.fmach { height: 40rem; }
+.fboard { height: 55vh; }
+.fent { height: 26rem; }
+.fbig { height: 72vh; }
+.muted { color: var(--muted); }
+.badge { padding: .1rem .5rem; border-radius: 1rem; font-size: .8rem; border: 1px solid var(--line); margin-right: .4rem; }
+.badge.live { color: var(--ok); border-color: var(--ok); }
+.badge.down { color: var(--bad); border-color: var(--bad); }
+.age { font-size: .78rem; color: var(--muted); white-space: nowrap; font-weight: 400; }
+.age.stale { color: var(--warn); font-weight: 600; } .age.down { color: var(--bad); font-weight: 600; }
+/* A panel document that is still on screen after its refresh time plus a margin was not replaced:
+   the banner appears by itself, with no script. */
+.lost { position: fixed; top: 0; left: 0; right: 0; z-index: 9; visibility: hidden; padding: .3rem .5rem;
+  background: #3a1d1d; color: #ffd7d5; border-bottom: 1px solid var(--bad); font-weight: 600; font-size: .8rem; }
+.l8 { animation: lostshow 0s linear 8s forwards; }
+.l12 { animation: lostshow 0s linear 12s forwards; }
+.l35 { animation: lostshow 0s linear 35s forwards; }
+@keyframes lostshow { to { visibility: visible; } }
+pre { margin: 0; font-family: var(--mono); }
+.term { background: #000; color: #ccc; padding: .4rem; border-radius: 4px; overflow: auto; font-size: 12px; line-height: 1.25; white-space: pre; }
+.term.big { min-height: 12rem; }
+.phead { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; font-size: .85rem; margin-bottom: .2rem; }
+.phead .name { font-weight: 600; }
+.ptitle, .pstatus { font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
+.tile { display: block; color: var(--fg); text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: .4rem;
+  background: #11141a; margin: 0 0 .5rem; min-width: 0; }
+.tile:hover { border-color: var(--accent); }
+.tile .head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
+.tile .name { font-weight: 600; } .tile .meta { font-size: .75rem; color: var(--muted); }
+.tile .term { font-size: 9px; max-height: 13rem; overflow: hidden; }
+body.frame:has(> a.tile) { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: .5rem; align-content: start; }
+body.frame:has(> a.tile) > .tile { margin: 0; }
+.send { margin: .5rem 0 0; display: grid; gap: .35rem; }
+.send .target { font-size: .78rem; color: var(--muted); }
+.send .row { display: flex; gap: .4rem; flex-wrap: wrap; }
+.send .text { flex: 1 1 20rem; min-width: 0; padding: .55rem; font: 14px var(--mono); background: #0b0d11; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; }
+.send .text:focus { outline: 2px solid var(--accent); }
+button { background: #222834; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: .4rem .8rem; font: inherit; cursor: pointer; min-height: 2.4rem; }
+button:hover { border-color: var(--accent); }
+.msg { margin: .5rem .8rem; padding: .5rem .7rem; border-radius: 6px; font-weight: 600; }
+.msg.ok { background: #12301b; color: #b7f5c4; border: 1px solid var(--ok); }
+.msg.bad { background: #3a1d1d; color: #ffd7d5; border: 1px solid var(--bad); }
+.filter { display: flex; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .4rem; font-size: .85rem; }
+.filter select, .filter input { background: #0b0d11; color: var(--fg); border: 1px solid var(--line); border-radius: 4px; padding: .3rem; font: inherit; min-height: 2.2rem; }
+.kv { display: grid; grid-template-columns: max-content 1fr; gap: .15rem .7rem; font-size: .85rem; }
+.kv .k { color: var(--muted); } .kv .v { font-family: var(--mono); word-break: break-word; min-width: 0; }
+.kv .full, .v.full { grid-column: 1 / -1; font-family: var(--mono); font-size: .8rem; word-break: break-word; border-bottom: 1px dashed var(--line); padding: .15rem 0; }
+.err { color: var(--bad); font-weight: 600; }
+.chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: .2rem 0; }
+.chip { border: 1px solid var(--line); border-radius: 1rem; padding: .05rem .55rem; font-size: .8rem; }
+.chip.running { border-color: var(--ok); color: var(--ok); } .chip.blocked { border-color: var(--bad); color: var(--bad); }
+.card { font-size: .82rem; padding: .2rem 0; border-bottom: 1px dashed var(--line); word-break: break-word; }
+.card code { color: var(--accent); }
+ol.board { list-style: none; margin: 0; padding: 0; font: 12px/1.35 var(--mono); }
+ol.board li { padding: .2rem 0; border-bottom: 1px solid #20242d; word-break: break-word; white-space: pre-wrap; }
+.ts { color: var(--muted); } .lane { color: var(--accent); font-weight: 600; }
+.entry { border-bottom: 1px solid var(--line); padding: .3rem 0; }
+.entry h4 { margin: 0 0 .2rem; font-size: .85rem; }
+.entry pre, body.frame > pre:not(.term) { white-space: pre-wrap; word-break: break-word; font-size: 12px; color: #c4c8cf; }
+/* SGR attributes; colours are .fN / .bN in /palette.css */
+.B { font-weight: 700; } .D { opacity: .7; } .I { font-style: italic; } .U { text-decoration: underline; }
+@media (max-width: 640px) {
+  .panel { margin: .4rem; padding: .4rem; }
+  .fqueen { height: 50vh; } .ftiles { height: 26rem; }
+  .term { font-size: 10px; } .tile .term { font-size: 8px; max-height: 9rem; }
+  .kv { grid-template-columns: 1fr; } .kv .k { margin-top: .3rem; }
+  .fstatus { height: 3.2rem; }
+}