Commit graph

1,696 commits

Author SHA1 Message Date
atlas
fe17b5f8a7 feat(matrix): auto-create a hive chat room as a child of the hive Space
The hive Space was created empty — joining it surfaced no rooms because
Matrix doesn't auto-join a Space's children. Provision a default
"hive-chat" room on the matrix sweep, wire it bidirectionally to the
Space (m.space.child on the Space, m.space.parent on the room), and
invite @hive + every agent. The room uses a restricted join rule
allowing any Space member to join, so the operator (a Space member) can
join it from the Space hierarchy without an explicit invite.

Idempotent, mirroring ensure_hive_space: persisted chat-room-id wins,
else rediscover a non-space room named hive-chat, else createRoom. The
space-child link is re-applied each sweep (idempotent PUT) so a
recovered room reconverges its hierarchy link. Room id persisted to
matrix/chat-room-id (0600, survives destroy --purge).
2026-06-06 07:59:24 +02:00
damocles
6e39515669 feat: type-scope events vacuum to prune only stream rows (14d) + drop turn-stats vacuum 2026-06-06 07:57:27 +02:00
iris
f8cf76b62d docs(web-ui): document the new per-agent /stats chips + result trend
Backfills the agent /stats page docs after the P1 stats enrichments:
the result-trend stacked bar (per-bucket result outcomes over time) and
the cache hit-rate + tokens/turn summary chips.
2026-06-06 07:56:43 +02:00
iris
a5914274ba feat(stats): surface "favorite tools" (most-run bash commands) on /stats
The surfacing half of the per-agent favorite-tools stat. Reads a
`bash_commands(ts INTEGER NOT NULL, head TEXT NOT NULL)` table from the
per-agent turn-stats.sqlite — one row per bash task, written by
hive-bash-mcp (the capture half, landing separately) — and rolls up the
top-10 command heads for a doughnut, mirroring the existing
tool_breakdown.

- stats.rs: new `Snapshot.bash_breakdown` + `read_bash_breakdown()`.
  The read is guarded: a missing `bash_commands` table (capture hasn't
  shipped / agent hasn't run a bash task) maps to an empty list, never
  an error — the snapshot degrades gracefully. Unit tests cover both
  the absent-table and populated cases (incl. window cutoff + ordering).
- frontend: a "favorite tools (bash)" doughnut card on the agent /stats
  page, kept hidden until bash_breakdown has data so it never shows a
  permanently-empty doughnut while capture is pending.

Part of #1433 (does not close it — pairs with the hive-bash-mcp capture
half). Inert until the capture lands; merge order with it is irrelevant.
2026-06-06 00:53:12 +02:00
damocles
1569d55f78 feat: capture normalised bash command heads for the favorite-tools stat 2026-06-06 00:52:56 +02:00
atlas
48b7c24265 fix(nix): emit explicit port in .well-known/matrix/server delegation
The matrix server-server spec resolves a portless m.server delegated
host to the federation default port 8448 (not 443 — the URL convention
that https implies 443 does not apply to the m.server field). The
gateway reused publicPortSuffix, which intentionally drops :443 for the
client base_url, so .well-known/matrix/server advertised the bare
gateway host. Peers then federated to <gatewayHost>:8448, which nothing
listens on, while the federation endpoint actually lives on the gateway
443 vhost (/_matrix/ proxied to tuwunel). Always emit the explicit port
in the federation delegation so peers reach the live 443 endpoint.
2026-06-06 00:37:07 +02:00
damocles
31d9cb561a fix: hive-forge agit pr-create sets multi-line body via rest patch 2026-06-06 00:36:29 +02:00
damocles
57b1a2d3ea docs: clarify certFingerprint does not govern matrix federation tls 2026-06-06 00:21:52 +02:00
damocles
e029944cb3 docs: specify certFingerprint format and generation recipe 2026-06-05 23:38:54 +02:00
damocles
c5c47b29b4 fix: own /run/hive-agent as hive-core so the unprivileged daemon can create per-agent socket dirs on first launch 2026-06-05 23:30:50 +02:00
damocles
4c8e916ae6 fix: add /run/lock to hive-priv ReadWritePaths so nixos-container can lock on first launch 2026-06-05 23:20:35 +02:00
iris
dbb9f2a787 stats(p3): normalise cpu% against host CPU count, not process affinity
Per review: available_parallelism() respects the hive-core process's
CPU affinity, so if it's ever affinity-pinned the denominator would
under-count and inflate cpu_pct. Read the online host CPUs from
/sys/devices/system/cpu/online instead (fall back to the process count,
then 1) so the 'percent of total host CPU' definition holds regardless.
2026-06-05 23:06:33 +02:00
iris
03ea6d1bda feat(stats): per-container cpu/mem load (#1424 p3)
C0NT41N3R L04D on the SYST3M tab + GET /api/container-resources.

Backend (hive-c0re/src/container_stats.rs): reads cgroup v2 cpu.stat +
memory.{current,peak,max} for each running agent machine
(machine-h\x2d<name>.scope under machine.slice), read-only/world-
readable so no hive-priv. CPU is a two-sample (~200ms) host-normalised
percentage; one shared sleep covers all agents. Skips agents whose
scope dir is absent (= not running). Network omitted: agents share the
host netns, no per-container counter.

Frontend: a polled C0NT41N3R L04D table on SYST3M (agent / cpu / mem /
peak / limit with meter bars), reusing the ST4TS table style. Polls
/api/container-resources every 5s only while the tab is active.

Backend reviewed-in-principle by damocles (path escaping + cpu delta
math); ping for the on-host sign-off.
2026-06-05 23:06:33 +02:00
damocles
14c7b0d406 feat: group host-side /var/lib/hyperhive state into db/ forge/ matrix/ run/ subdirs with startup migration 2026-06-05 23:01:47 +02:00
iris
cfafc9d93d docs(dashboard): add /api/stats-hive to the endpoint reference 2026-06-05 22:51:11 +02:00
iris
a8a30dd39b docs(dashboard): document the ST4TS hive-wide stats tab
Adds the ST4TS tab to the strip list + a section covering the swarm
rollup, the /api/stats-hive endpoint shape, the read-only/skip-missing
aggregation, pull-on-activation, and the labelled cost estimate. Ships
with the feature (this branch / PR).
2026-06-05 22:51:11 +02:00
iris
8e74dda4c5 feat(dashboard): ST4TS tab — hive-wide stats view
Builds the dashboard UI on the /api/stats-hive endpoint: a new ST4TS
tab showing swarm totals (active agents, turns, tokens, labelled est
cost), a busiest-first per-agent table, and a model-mix bar list.
Plain tables/CSS bars — no chart lib in the dashboard bundle; per-agent
trend charts stay on each agent's own /stats page. Fetched on tab
activation + window change (pull-only, no SSE).

Also adds conn.busy_timeout(500ms) in hive_stats read_agent per review:
turn_stats is rollback-journal, so a read landing mid-INSERT would hit
SQLITE_BUSY and silently drop that active agent — wait the write out.
2026-06-05 22:51:11 +02:00
iris
447a84e8a6 feat(c0re): /api/stats-hive — hive-wide turn-stats rollup
#1424 P2 backend. New hive_stats module aggregates every agent's
turn-stats.sqlite read-only (reusing Coordinator::kept_state_names +
agent_harness_dir, skipping missing/unreadable dbs) into swarm totals,
a busiest-first per-agent rollup, swarm model mix, and a labelled USD
cost estimate (rough model->price table; can move to a nix option
later). Exposed as GET /api/stats-hive?window=. Dashboard UI follows.
2026-06-05 22:51:11 +02:00
damocles
07e8f442cb fix: hivectl choom passes the harness --settings/--mcp-config/--system-prompt-file so claude gets settings + tools + persona 2026-06-05 22:48:34 +02:00
iris
ded7474b2b feat(stats): cache hit-rate, tokens/turn, and result trend over time
First slice of #1424 (per-agent /stats enrichments):

- Backend: add per-bucket result_counts to the stats Snapshot (mirrors
  model_counts), so result outcomes can be charted over time, not just
  as a window total.
- Frontend: two new summary chips — cache hit-rate % (cached input vs
  all input-side tokens) and avg tokens/turn — both derived from the
  existing per-bucket token sums. Plus a stacked result-trend chart so
  error / rate-limit / compaction spikes are visible across the window.

Hive-wide aggregate, cost estimate, and container resource load land in
follow-up PRs.
2026-06-05 22:22:48 +02:00
damocles
86f0de751f feat(matrix mcp): add resolve_invite tool to accept or reject pending invites 2026-06-05 21:55:04 +02:00
damocles
c59a0de01e fix: hivectl choom enters as the agent user from the state dir so claude gets creds + session 2026-06-05 21:41:50 +02:00
damocles
d25f2779e8 docs: note that linking workspace binaries locally needs nix develop (libsqlite3) 2026-06-05 21:30:57 +02:00
damocles
44678ec6ee fix: regenerate hivectl-cli.md to include the merged matrix invite subcommand 2026-06-05 21:28:40 +02:00
damocles
fac5437508 docs: commit generated hivectl cli reference + flake freshness check 2026-06-05 21:07:51 +02:00
damocles
ad8a3a8cbf feat: hidden hivectl markdown-docs subcommand emitting the cli reference as commonmark 2026-06-05 21:07:51 +02:00
iris
d952e7ac01 docs(knowledge): document the hive-forge AGit no-fork contribution flow
Replaces the fork-and-PR instructions with the supported no-fork path
now that the CLI helper shipped: hive-forge clone + pr-create --agit.
Agents are read-only collaborators, so they push HEAD to
refs/for/<base>/<topic> via AGit instead of forking. Same --topic
updates the open PR.
2026-06-05 20:54:25 +02:00
damocles
79101edc2f address argus: drop issue tags from clone/pr-create module docs, fix stale knowledge wording 2026-06-05 20:51:50 +02:00
damocles
c103ae5f10 feat(#1399): hive-forge clone verb + pr-create --agit for no-fork PRs 2026-06-05 20:51:50 +02:00
damocles
e7a68472fd fix: reject bare --room value in hivectl matrix invite with a clear hint 2026-06-05 20:51:31 +02:00
damocles
e8d5eee659 feat: hivectl matrix invite — add a user to the hive Space or a room (closes #1402) 2026-06-05 20:51:31 +02:00
iris
153870ec3a test: drop unnecessary Result wrap in bash status test helper
clippy::unnecessary_wraps — the helper always returns Ok. Build the
DaemonResponse directly and wrap with Ok() at the call sites. Fixes the
CI clippy failure on this PR.
2026-06-05 20:50:44 +02:00
iris
d34c594f2b feat: hint to do other work when recv/bash_status waits time out
When an agent parks on a long-poll that expires with nothing to show,
nudge it to spend the idle time on other useful work instead of
immediately re-blocking on the same call.

- recv: when wait_seconds > 0 and the inbox is empty at timeout, the
  '(empty)' result now carries IDLE_WAIT_HINT. Immediate peeks
  (no/zero wait) are unchanged.
- bash_status: when wait_seconds > 0 and the task is still
  pending/running at timeout, append BASH_IDLE_WAIT_HINT. Finished
  tasks and no-wait calls are unchanged.

Both thread a 'waited' flag into the formatter so the hint only fires
on an actual wait-timeout. Unit tests cover both. Implements #1411.
2026-06-05 20:50:44 +02:00
damocles
0749cb37ab docs: delete obsolete damocles migration plan (closes #1406) 2026-06-05 20:05:49 +02:00
damocles
7031f57c14 feat(#1409): hive-forge pr-status verb (mergeable, CI, reviews, last comment) 2026-06-05 19:53:20 +02:00
iris
60042d877e docs(options): emit markdown only, render HTML in website
Per #1407 review: the options reference should be markdown here; the
HTML + CSS belongs in the website repo where the theme lives and the
stylesheet can be shared with /docs.

- nix/docs/default.nix: drop the cmark-gfm HTML rendering, the inline
  <style>, and the HTML index. Emit index.md + host.md + agent.md only
  (CommonMark from nixosOptionsDoc).
- Remove nix/docs/style.css.
- Update docs/gotchas.md + CLAUDE.md to describe the md-only output and
  point at the website for HTML rendering.

The website (hyperhive/website#26) renders these .md to themed HTML for
/options/, sharing one docs.css with the prose /docs/ tree.
2026-06-05 19:36:54 +02:00
iris
9f06899238 docs(web-ui): move css-vars.md into web-ui/
The CSS theme-variable reference documents the dashboard/agent web-UI
stylesheets, so it belongs under docs/web-ui/ alongside shape/dashboard/
agent. Wire it into the web-ui.md index (split list + reading path) and
the CLAUDE.md file map. Closes #1405.
2026-06-05 19:21:43 +02:00
iris
f84336b287 docs(gateway): drop openFirewall default-change note
Per review: remove the 'used to default to true' breaking-change
paragraph from the forge openFirewall section.
2026-06-05 19:06:10 +02:00
iris
093116f5e1 docs(gateway): document forge httpPort, sshPort, openFirewall, rootUrl options
The "hive-forge container shape" section described the container
isolation model but omitted the port and firewall knobs that operators
need when exposing forge externally or overriding the Forgejo ROOT_URL.

Add two subsections:

"Network and port configuration" — covers httpPort (default 3000),
sshPort (default 2222), and openFirewall (default false, was previously
true — breaking change note included). Explains the shared-netns
rationale for why openFirewall is safe to leave off for agent use but
must be set for browser/external-git-client access. Clarifies that
forge.behindGateway obviates forge.openFirewall for HTTP reach.

"rootUrl override" — documents forge.rootUrl (default null) with the
auto-derivation table (behindGateway ? http://domain/ : http://domain:port/)
and explains when to override (TLS, https:// clone URLs, bespoke shapes).
Notes the auto-derivation always produces http://, so TLS operators must
set rootUrl explicitly.
2026-06-05 19:06:10 +02:00
damocles
782438be89 fix(#1374): make /shared writable by all agents (sticky world-writable) 2026-06-05 18:46:16 +02:00
iris
f2d57c8538 fix: drop stale claim that ruth is always reachable in allowedRecipients
The sentence 'ruth is always reachable regardless of the list' documents
a bug in check_send_allowed (name-based carve-out), not intended
behavior. The structural parent carve-out is fine to mention since it's
topology-based, not name-based.

Updated example to show [ "operator" ] (restrict to operator-only)
and replaced the ruth-name claim with a note about the parent carve-out.
2026-06-05 18:45:06 +02:00
iris
da8892aac2 fix(docs/turn-loop): correct allowedRecipients example name to ruth
The manager's logical name is 'ruth' (MANAGER_AGENT post-#954).
The example used the stale 'manager' placeholder.
2026-06-05 18:45:06 +02:00
iris
3328b396e7 docs(turn-loop): document allowedRecipients, claudePlugins, cargo.shortMessages
Five per-agent agent.nix options were undocumented:

- hyperhive.allowedRecipients — restricts which peers send() accepts;
  note added inline to the send tool description
- hyperhive.claudeMarketplaces — Claude Code plugin marketplace sources
  (default: official Anthropic marketplace)
- hyperhive.claudePlugins — plugin specs installed at harness boot
- hyperhive.claudePluginsAutoUpdate — pull latest marketplace index
  before install; off by default
- hyperhive.cargo.shortMessages — shell wrapper injecting
  --message-format short on cargo compile subcommands; on by default
2026-06-05 18:45:06 +02:00
iris
9a19919943 fix: correct auto-accept invites claim — daemon wakes agent, agent decides
The daemon does not call join_room_by_id. It fires a wake and writes
to mcp-loose-ends/matrix.json; the agent calls list_invites + join_room.

Replace the inaccurate 'Auto-accept invites' paragraph with 'Invite
wakes' describing the actual flow. Merge the pending-invites paragraph
into a single accurate block.
2026-06-05 18:43:41 +02:00
iris
19a09c865e docs(tools/matrix): document auto-accept invites and pending-invite loose ends 2026-06-05 18:43:41 +02:00
iris
010d0a422a docs(matrix): document trustedServers and maxRequestSize options
The matrix.md provisioning section mentioned trustedServers in passing
("wired up later by extending trustedServers") but never explained it
as a configurable option, and maxRequestSize was undocumented entirely.

Add a "Configuration tuning" subsection before "Assertion rationale":
- trustedServers (default []) — list of peer homeserver names to trust;
  federation is protocol-on but no peer trusted until listed; link to
  swarm.md for the multi-hive use case.
- maxRequestSize (default 20 MB) — request body limit matching the
  matrix-spec recommendation; when and why to raise or lower it.
2026-06-05 18:40:52 +02:00
iris
09e2ad326c fix: update PrivRequest table to match actual hive-sh4re::priv_proto variants
Replace stale AddBindMount/RemoveBindMount/SetNetworkIsolation/ReloadGateway
entries with the actual current variants from hive-sh4re/src/priv_proto.rs:

- WriteNspawnFlags (replaces AddBindMount/RemoveBindMount/SetNetworkIsolation)
- WriteResourceLimits (new)
- RemoveServiceDropin (new)
- DaemonReload (new)
- ChownSocketDir / ChmodSocketDir (new)
- RunForgeAdmin (new)
- RestartMatrixDaemon (new)
- ReloadGatewayNginx (renamed from ReloadGateway)
2026-06-05 18:40:44 +02:00
iris
a960dcf91a docs(boundary): rewrite sequencing list as prose, drop checklist markers 2026-06-05 18:40:44 +02:00
iris
28df69286d docs(security): document hive-priv privilege separation model 2026-06-05 18:40:44 +02:00
damocles
b33b3f315c fix(#1397): point send-refused message at <parent> sentinel not stale manager name 2026-06-05 18:36:42 +02:00