Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/hive-view/patches/77cd165e47162ae4
# hive-view
aien-dev/hive-view
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
## 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 `` 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`)
Check Result
`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 `vwchunk` 46 passed, 6 failed, exactly the `;` chunk-end cases
CPU, two pages open, 60 s MEASURED: 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 view EXERCISED
Two builds byte-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=`, where
+ `` is the 64 characters in `~/.config/hive-view/token` on the Spark. The link sets a cookie and
+ sends you to the dashboard. Without that cookie every page answers "Not signed in".
+- The page shows, top to bottom:
+ - the queen (`omp-queen`): its live screen and an input box;
+ - one tile per `omp` session (found from `tmux ls` each poll, never a fixed list): title, status line
+ and last screenful. Clicking a tile opens `/s/NAME`: that session large, with its own input box;
+ - Hermes: gateway up or down, the queen PAUSE file (shown verbatim), kanban counts per status and
+ the running cards; the `lead-*` sessions as tiles;
+ - Machine: load, memory, CPU busy %, GPU power and utilization from the spark-sensors log, the
+ processes holding the GPU, the spark-window holder and queue, the core pool locks, and the Pearl
+ ledger (newest entries verbatim);
+ - the BOARD (newest first, with a lane and text filter), the latest QUESTIONS and DECISIONS entries,
+ CLAIMS, and every other tmux session.
+- 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=`; 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, `
+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
+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
+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
+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 "
+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=.
+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 "=" 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 "