interplane.Get Omega
Read in your language

hive-view

aien-dev/hive-view

Brought by drakestapleton

branch main Branches Tags History

hive-view / README.md

208 lines · 13308 bytes Raw Blame History Source

hive-view

One browser page that shows every hive running on the Spark and lets Drake type into any of them. It is a native program written in seeded Omega (.om), built by the pinned omc compiler from aien-dev/omega-mv. The browser runs no script at all: every page is HTML drawn by the server, and each panel refreshes itself.

Parent: aien-dev/omega-mv @ 943d955531b9d4d9f70deb41756c0b46441dd5e0 (compiler seed/out/omc, sha256 5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df).

Using it

Typing into a session

The input box sends exactly what you typed, then Enter ("Send + Enter"). The "Enter" and "Escape" buttons send that one key only; any text in the box is not typed. Nothing else can be sent: no other control keys, no commands.

Security

Load on the machine

One shared poller (nice 10, cores 0 to 2) refreshes everything, whatever the number of open pages. It never queries the GPU (GPU numbers come from the existing spark-sensors log) and takes no pool lock. It captures up to six panes per tmux call and skips panes whose activity time did not change; it runs hermes kanban list only when the kanban database file changes (or every 5 minutes).

Measured on the Spark (gate cpu, 60 s, USER_HZ 100, two dashboard pages open). Runs 1 and 2 are earlier builds of the same poller (server 9f70b61b… and 8e4ca0a1…); run 3 is server 12672fd8… (deployed; the poller is unchanged in the current build):

WhatTicks in 60 sShare of one coreShare of the 20-core machine
hive-view (server, poller, handlers, their tmux clients), run 11823.03 %0.15 %
hive-view, run 2761.27 %0.063 %
hive-view, run 3 (server 12672fd8…)1712.85 %0.14 %
tmux server with hive-view running (runs 1, 2, 3)292, 255, 305
tmux server with hive-view stopped (baseline)269

The tmux-server difference is within the run-to-run noise of the busy hive. Percentages computed with Wolfram (N[182/(60*100)*100] -> 3.03, N[76/(60*100)*100] -> 1.27, N[171/(60*100)*100] -> 2.85); the arithmetic and rounding are proven in Lean 4 in evidence/cpu-shares.lean (toolchain and Mathlib pin in its header); details in evidence/.

Build

The build is one omc pass over the concatenated sources (the order matters: a name must be defined before it is used). With O pointing at an aien-dev/omega-mv checkout at the pinned commit:

{ printf 'om2\n'; cat $O/seed/net/http.om $O/seed/net/notls.om $O/om/tls/sha2.om \
    src/util.om src/run.om src/poll.om src/web.om src/page.om src/route.om src/main.om; } \
  | $O/seed/out/omc > server && chmod +x server

{ printf 'om2\n'; cat $O/seed/net/http.om $O/seed/net/notls.om $O/om/tls/sha2.om \
    src/util.om src/run.om tests/gate.om; } \
  | $O/seed/out/omc > gate && chmod +x gate

build.json records the compiler, its sha256, the sha256 of each concatenated source and of the resulting binaries for the committed revision.

Install, start, stop, roll back

install -d -m 700 ~/.local/share/hive-view/web ~/.local/state/hive-view
install -m 755 server ~/.local/share/hive-view/server
install -m 644 web/app.css ~/.local/share/hive-view/web/app.css
~/.local/share/hive-view/server mktoken        # only if ~/.config/hive-view/token does not exist
install -m 644 deploy/hive-view.service ~/.config/systemd/user/hive-view.service
systemctl --user daemon-reload
systemctl --user enable --now hive-view.service
curl -s http://127.0.0.1:18190/health          # prints ok

The unit runs with Nice=10, CPUAffinity=0 1 2, Restart=on-failure, UMask=0077 and NoNewPrivileges=yes; its run directory is $XDG_RUNTIME_DIR/hive-view and StateDirectory=hive-view creates ~/.local/state/hive-view (mode 700) for the send log.

The gate

tests/gate.om is the acceptance gate, in Omega. Against a running server:

./gate run 18190        # 56 checks; prints PASS/FAIL per check, exit 0 only when all pass
./gate nolog 18190      # against a server whose send log cannot be used (run the gate with the
                        # server's HOME): a send must be refused with code 8, nothing typed. Two
                        # setups: no ~/.local/state/hive-view at all, and sends.log -> /dev/full
                        # (opens, every write fails with ENOSPC)
./gate cpu PID 60       # CPU ticks of server PID (with children) and of the tmux server over 60 s

gate run creates a tmux session hv-test whose program is /usr/bin/tee -a /tmp/hv-gate-sink on a raw terminal, so every byte the dashboard types is recorded exactly. It checks sign-in, Host and Origin checks, the form key, literal delivery of tricky texts (;, \;, -n, --, $(id), quotes, UTF-8 and emoji, <script>, leading spaces, a 4096-byte text with ; at both chunk ends, a 4096-byte text of 3-byte characters with one split by the chunk edge), Enter and Escape (also with text in the box, which must not be typed), the send log (sha256 and byte count present, text absent), every refusal (4097 bytes, control bytes, invalid and overlong UTF-8, unknown action, forged names, duplicate or unknown fields, a body over 16 KiB), that <script> on a session screen is shown escaped, that the QUESTIONS and DECISIONS panels answer with the whole page (with a fresh HOME this covers a missing file), and that a deleted session is refused. It deletes hv-test and the sink at the end.

Negative control: a server built without the ; escape in vwchunk (src/web.om) fails 6 of the 56 checks (every case that ends a chunk in ;). Results for the committed revision are in evidence/.

Outside programs

hive-view is pure Omega; at run time it starts these programs with exact argument lists (no shell):

ProgramVersion on the SparkWhat hive-view uses it forOmega replacement
/usr/bin/tmux3.4list sessions, capture panes, send-keys -lnone 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/hermesHermes Agent v0.22.5hermes kanban list for the kanban counts and running cardsread kanban.db directly with an Omega SQLite page reader (proposal, not built)

The service manager is outside hive-view too: deploy/hive-view.service is a systemd user unit (systemd 255 on the Spark). systemd starts the server with the user manager (at boot, since linger is on for this user), restarts it on failure, pins it to cores 0 to 2 at nice 10 and creates ~/.local/state/hive-view (mode 700). Omega replacement: an Omega supervisor (fork, wait, restart with backoff, sched_setaffinity, setpriority, makedir) started from the user's session; proposal, not built. Note that omega-mv's standing rules say "No systemd"; the hive-view brief asked for a systemd user unit, and that conflict is open with the queen.

The gate additionally starts /usr/bin/tee and /usr/bin/stty inside its own test session only. No ORACLE is used or shipped.

Files

PathWhat
src/util.ombuffers, paths, argument lists
src/run.omrun a program (fork, execprog, pipes, deadline, reaping), read and atomically write files
src/poll.omthe shared poller: writes one snapshot file per panel plus an index
src/web.omrequest checks, headers, sign-in, the send pipeline and its log
src/page.omHTML: pages, panels, terminal colours, the BOARD and entries, palette CSS
src/route.omPOST /send form handling, the route table, the per-connection loop
src/main.omentry points: serve, mktoken, poll-once
web/app.cssthe stylesheet
tests/gate.omthe acceptance gate
deploy/hive-view.servicesystemd user unit
evidence/gate, negative-control and CPU results for a revision