Commit graph

2,384 commits

Author SHA1 Message Date
atlas
3a4b8d9873 fix(#1748): route all nix invocations through the host daemon (NIX_REMOTE=daemon)
Root contexts (systemd services running as root, PID 1) default to
store=auto which resolves to the LOCAL nix store — bypassing the host
daemon, its remote builders (muede-pc2), and any prebuilt derivation
outputs already in the shared store. This causes spurious full
rebuilds of agent toplevels that the host already built and cached.

Two changes:

harness-base.nix:
- Add systemd.globalEnvironment.NIX_REMOTE = "daemon" — sets
  DefaultEnvironment in systemd.conf so every unit in the container
  inherits NIX_REMOTE=daemon. Non-root contexts already default to
  the daemon socket; this only matters for root services that would
  otherwise use the local store.
- Add NIX_REMOTE = "daemon" to environment.variables so interactive
  shells also have it set (redundant with /etc/profile.d/nix-daemon.sh
  but explicit and profile-agnostic).

hive-c0re.nix (hive-priv service):
- Add NIX_REMOTE = "daemon" to the service environment. hive-priv
  runs as root and invokes nixos-container update + nix prebuild; these
  must route through the host daemon so they see the shared store and
  remote builders, not a private local store.

The sandbox-fallback = true in harness-base.nix is kept as a belt-
and-suspenders fallback but becomes a no-op for the common case once
nix routes through the daemon (the daemon builds on the host where
sandboxing works).
2026-07-04 13:12:02 +02:00
atlas
3e5ddbd2c0 fix(#1845): add ProtectSystem=full to hive-c0re service hardening
ProtectSystem=full makes /usr, /etc, and /boot read-only. Safe for
hive-c0re because it never writes to those paths directly:
- /etc writes (e.g. /etc/nixos-containers) go through hive-priv
- /etc/hyperhive/serve.json reads are read-only
- All runtime writes go to StateDirectory (/var/lib/hyperhive) and
  RuntimeDirectory (/run/hyperhive), which remain writable under full

ProtectSystem=strict (everything read-only) is still deferred — it
requires auditing ReadWritePaths for every nix path c0re touches.
RestrictAddressFamilies deferred pending a watched deploy.

Also tightens the comment block to not mention a numbered issue.
2026-07-04 13:01:47 +02:00
atlas
ef2b3a735c fix: remove tracker tag from source comment (lint) 2026-07-04 13:01:47 +02:00
atlas
b3b1c7b288 fix(#1845): add safe systemd hardening directives to hive-c0re service
hive-c0re runs as the unprivileged hive-core user and delegates all
privileged operations to hive-priv via a Unix socket. Add the subset of
systemd sandboxing directives that are provably safe without a watched
deploy (no ProtectSystem / RestrictAddressFamilies, which require mapping
the full set of filesystem/network paths first):

- NoNewPrivileges: already unprivileged; no setuid/capability escalation
- PrivateTmp: nix subprocesses use StateDirectory temp paths, not /tmp
- ProtectHome: HOME is /var/lib/hyperhive (StateDirectory), not /home/*
- ProtectKernelTunables: no sysctl writes needed
- ProtectKernelLogs: logs via systemd-journal group, not /dev/kmsg
- ProtectControlGroups: cgroup writes go through hive-priv, not c0re
- RestrictNamespaces: namespace creation goes through hive-priv
- LockPersonality: no personality changes needed
- RestrictRealtime: no real-time scheduling

Follows the same pattern as hive-priv (PrivateTmp + ProtectHome already
present there). Deferred: ProtectSystem=strict + ReadWritePaths +
RestrictAddressFamilies — those need a watched deploy per the #1845 plan
since getting the ReadWritePaths wrong silently breaks runtime I/O.
2026-07-04 13:01:47 +02:00
atlas
ef4dd67e9a fix(#1747): stable hive-c0re ExecStart via /etc/hyperhive/serve.json
Previously, serveConfig was a pkgs.writeText store path embedded in
ExecStart. Any repo edit (gateway.nix, frontend, unrelated nix modules)
changes hyperhiveFlakeSource → serveConfig hash → ExecStart → systemd
restarts hive-c0re → StartupSweep → every agent rebuilt unnecessarily.

Fix: write the JSON to /etc/hyperhive/serve.json via environment.etc
(a managed /etc symlink to the store-path content). ExecStart now
references the stable /etc path, changing only when cfg.package (the
hive-c0re binary) changes. Unrelated module edits no longer bounce c0re
or trigger a cascade agent rebuild.

hive-c0re still restarts — and triggers the sweep — when its binary
changes, which is the correct invariant: a new release legitimately
needs to resync all agents with updated harness modules.
2026-07-04 12:52:47 +02:00
iris
94d537b7a9 feat(agent-term): show remind timing and message preview in tool row
`mcp__hyperhive__remind` calls previously rendered as the generic
`fmtArgsGeneric` output — with a multi-field input that showed
`message: "..." · delay_seconds: 300`, burying the message after
a verbose field name.

New format: `remind* +5m "check on PR..."` (or `at HH:MMZ` for
absolute timestamps). The timing renders first so it's scannable
at a glance, followed by the first 60 chars of the message body.
Works for all three input shapes: delay_seconds, at_unix_timestamp,
and file_path-only (shows the path as the preview).
2026-07-04 12:13:44 +02:00
damocles
77a9492a3f refactor(#1825): drop manager_dir/manager_socket_path, use the per-agent fns 2026-07-04 12:11:28 +02:00
damocles
a26bbb15fc feat(#2089): docs pointer via system-prompt line, drop CLAUDE.md mechanism 2026-07-04 12:07:17 +02:00
iris
fc415a72a5 docs: update stale tabs.js→swarm.js/call.js references
After the SW4RM and Y3R C4LL extractions from tabs.js (PRs merged
earlier), several docs still pointed at `assets/tabs.js::fn`. Update
them to the authoritative module:

- dashboard.md: renderContainers, buildAgentTree → swarm.js
                renderApprovals → call.js
                renderPeerHives → swarm.js
- shape.md: generic "tabs.js render function" → "domain module"
- conventions.md: clarify async-form listener lives in tabs.js (dashboard)
                  AND app.js (per-agent UI)
2026-07-04 12:07:14 +02:00
iris
0a9f9a4fa6 feat(agent-term): complete tool-icon and fmtToolUse coverage
Several MCP tools appeared with the generic wrench icon (🔧) making
them hard to identify in the scrollback. fmtToolUse also lacked
specific formatters for some frequently-used tools, falling through
to fmtArgsGeneric.

Icons added:
- ack_until  →   (mark-as-read semantics)
- get_logs   → 📜  (log viewer)
- get_host_journal → 📜  (journal reader)

fmtToolUse cases added:
- ack_until          → "ack_until* ≤N" (message-id bound)
- get_logs           → "get_logs* <agent> [NL]"
- get_host_journal   → "get_host_journal* <container|unit> [/grep/] [NL]"
- restart/start/update → "restart* <name>" etc. (previously used
                          fmtArgsGeneric; now match kill's pattern)

Closes #2188.
2026-07-04 12:07:14 +02:00
iris
1011428cc7 docs(terminal-rendering): document plugin_install, commands_changed, compact_boundary rows
The renderer dispatch section was missing entries for three system
subtypes that now have specific renderers (added in the preceding
commits on this branch). Update the row taxonomy table and the
numbered dispatch description to cover all four system-subtype
handlers (thinking_tokens was already documented; 1b–1e are new).
2026-07-04 11:59:37 +02:00
iris
1fe6783756 feat(agent-term): show compact_boundary details in per-agent terminal
compact_boundary events currently render as the generic "⚙ compact_boundary"
muted note. The event carries useful metadata — pre/post token counts,
duration and trigger — that are invisible to the operator.

With this change the row reads:
  · ⚙ compact · manual · 772k→6k tokens · 101s

Fields rendered (all guarded — missing fields are silently omitted):
- trigger ("manual" or "auto")
- pre_tokens→post_tokens (formatted with k/M suffixes)
- duration_ms (ms or s)

Closes #2187.
2026-07-04 11:59:37 +02:00
iris
44531820d0 feat(agent-term): show details for plugin_install and commands_changed
Currently both system subtypes fall through to the generic muted
note renderer (⚙ <subtype>), giving the operator no insight into
what is happening.

plugin_install:
  Render status explicitly — "loading…" on started, "✓ done" on
  completed — so a slow plugin boot is visible in the scrollback
  instead of two identical cryptic rows.

commands_changed:
  Render the count of available slash commands in the summary row
  and expand to the full list in a collapsible details block. The
  list is most useful right after a fresh plugin_install so the
  operator can see exactly which /commands are now on offer.

Both handlers sit immediately before the generic catch-all in the
system-subtype dispatch in renderStream, preserving the existing
fall-through for other subtypes (context_window_exceeded etc.).

Closes #2183.
2026-07-04 11:59:37 +02:00
damocles
b5acd60cf5 feat(#2170): split docs/ into its own meta-flake input 2026-07-04 11:47:07 +02:00
iris
9b607e2857 refactor(dashboard): extract SW4RM domain from tabs.js into swarm.js
tabs.js shrinks from 1651 to 457 lines. swarm.js is a new 1217-line
module that owns the containers/selection-bar/peer-hives domain:

- Container-state apply handlers (applyContainerStateChanged/Removed)
- Rebuild-queue sync + apply (syncRebuildQueueFromSnapshot, applyRebuildQueueChanged)
- Transient-state sync + apply (syncTransientsFromSnapshot, applyTransientSet/Cleared)
- renderContainersFromState (re-render from cached snapshot)
- Per-agent context menu (buildAgentMenu, agentMenuPost, closeAllAgentMenus)
- Topology tree builder (buildAgentTree, treePrefixDom)
- Container row (containerRowFingerprint, buildContainerLi, renderContainers)
- Selection bar (renderSelectionBar, addMoveActions, validReparentCandidates, addBulkButton)
- Peer hives section (renderPeerHives)
- Status-age ticker (30s setInterval for .status-age[data-set-at] spans)
- CTX_WARN/CTX_CAUTION constants
- Selection event listeners (Esc to clear, click on selection-clear)
- Agent-menu event listeners (click outside to close, Esc to close)

tabs.js (coordinator) retains:
- notifyDeltas + seenApprovals/seenQuestions/seededNotify
- bindAsyncForms
- Cross-domain ticker (approval request-age + reminder/schedule due-at)
- refreshState, pollTimer, operatorIsTyping, snapshotOpenDetails
- MUTATION_HANDLERS dispatch + bindDashboardStream
- activateTab, createTabStrip, initCall, refreshTabCounts, setTabCount

Behaviour-preserving code-move. Build verified.
2026-07-04 11:37:39 +02:00
damocles
6267bf56d0 feat(#2089): additive claude.md pointer to in-container docs 2026-07-04 11:30:33 +02:00
damocles
5d597d92ea fix(#2174): create operators team in agent-configs org too so config-repo branch protection applies 2026-07-03 22:40:38 +02:00
atlas
cb0a66147a fix(#2172): gate CLAUDE_CODE_OTEL_DIAG_STDERR on hyperhive.otel.debug
CLAUDE_CODE_OTEL_DIAG_STDERR was always set when OTEL is enabled, making
OTEL SDK errors (e.g. 404 from a misconfigured collector endpoint) appear
in every agent's stderr unconditionally. Move it behind a new opt-in flag.

Changes:
- nix/modules/hive-c0re.nix: add services.hyperhive.otel.debug (bool,
  default false); wire to HYPERHIVE_OTEL_DEBUG env on hive-c0re unit.
- hive-c0re/src/meta.rs: add debug field to OtelConfig; read
  HYPERHIVE_OTEL_DEBUG; emit hyperhive.otel.debug = true when set.
- nix/templates/harness-base.nix: add hyperhive.otel.debug internal
  option; move CLAUDE_CODE_OTEL_DIAG_STDERR out of otelSettingsEnv into
  a debug-gated lib.optionalAttrs block.

Default behaviour: OTEL exports silently (no stderr noise). Operators
troubleshooting collector connectivity set services.hyperhive.otel.debug
= true to re-enable the diagnostic output.
2026-07-03 22:12:56 +02:00
damocles
2c5d9ed336 wire types: use chrono DateTime<Utc> as the timestamp type throughout 2026-07-03 22:07:23 +02:00
damocles
1e205289c5 wire types: WireTime newtype for timestamps instead of adaptor-annotated i64 2026-07-03 22:07:23 +02:00
damocles
cf1f7288bf make agent_config_pending async — the sync git fork on every sweep starved the runtime under IO load 2026-07-03 21:42:45 +02:00
damocles
3d5957c87b web-ui: deadline-bound all broker-backed fetches so a busy hive-c0re can't hang api/state (closes #2148) 2026-07-03 21:42:45 +02:00
atlas
9496fb060b fix(forge): set mirror_interval so pull-mirrors sync periodically, not on-access
Forgejo's default mirror behaviour syncs on every git access, which
re-introduces external DNS latency at clone time. The hive-ci runner
shares the host netns, so a host-resolver blip turns an otherwise
local clone into a hard failure (data.forgejo.org DNS lookup that
has nothing to do with the repo being cloned).

Fix:
- New MIRROR_INTERVAL const (8h0m0s) used in ensure_mirror_repo.
- On creation: pass interval=MIRROR_INTERVAL in the migrate API body.
- On existing mirror: PATCH mirror_interval on every startup so repos
  seeded before this change converge without manual intervention.

A stale mirror (up to 8 hours old) is fine for CI; a broken clone
from a transient DNS blip is not. The actions/checkout mirror is
refreshed periodically rather than triggered by runner pulls.
2026-07-03 19:32:05 +02:00
damocles
7def514760 clippy: backtick socket_server in doc comment 2026-07-03 18:50:21 +02:00
damocles
0577c9e3fa drop tracker tags from rust doc comments (lint) 2026-07-03 18:50:21 +02:00
damocles
be5b36911a recv: hoist RECV_BATCH_MAX into hive-sh4re, drop magic 5 in wake hint 2026-07-03 18:50:21 +02:00
damocles
78396c8189 recv: cap batch size at 5, default stays 1 (#2150 clarified) 2026-07-03 18:50:21 +02:00
damocles
ee45db6323 Revert "recv mcp tool: default max to a small batch of 5 (wire default stays 1)"
This reverts commit b8d608d4b6a7ed95faffdec8d8b3167ae8f3b39e.
2026-07-03 18:50:21 +02:00
damocles
d46d3c261b recv mcp tool: default max to a small batch of 5 (wire default stays 1) 2026-07-03 18:50:21 +02:00
damocles
f310b1ce5a config mirror: never force-push — keep forge history on rolled-back deploys 2026-07-03 00:54:32 +02:00
iris
7391900b88 fix(web-ui/dashboard): correct BU1LDS stream paths — /dashboard/stream → /api/dashboard/stream and /build-logs/stream/{id} → /build-logs/id/{id}/stream 2026-07-03 00:50:32 +02:00
iris
a589acf4d1 docs(web-ui): update C0R3/L0GS/BU1LDS page docs to reflect build queue move
R3BU1LD QU3U3 and M3T4 1NPUTS moved from /core.html to /builds.html
(the BU1LDS page); the BUILD log tab moved from /logs.html to /builds.html.
dashboard.md still described the old 4-tab C0R3 page and 4-tab L0GS page.

Changes:
- C0R3 page section: update to the actual 2 tabs (K3PT ST4T3 +
  C0NT41N3R L04D); add pointer to BU1LDS page
- Add new BU1LDS page section: R3BU1LD QU3U3 (with all 9 queue kind
  glyphs + deferred-start parent_id note), M3T4 1NPUTS, BUILD L0GS
- L0GS page section: update to actual 3 tabs (AGENT / SYSTEM / AUDIT);
  remove BUILD sub-tab prose; add pointer to BU1LDS page
- Fix two stale 'C0R3 page R3BU1LD QU3U3' refs to 'BU1LDS page'
- web-ui.md index: mention BU1LDS alongside C0R3 and L0GS
2026-07-03 00:50:32 +02:00
damocles
7d35ad1751 fix(#2167): keep docs/ in hyperhive flake source — reference-docs builds from it 2026-07-03 00:50:08 +02:00
iris
b63c6c543d docs(web-ui/dashboard): document K3PT ST4T3 stale perms + active model badge
Two undocumented features from recent commits:

feat(core) 6ab0757cc6: K3PT ST4T3 now has two
sub-sections — tombstones (existing) and a new 'stale permission entries'
list showing agents with capability/tool-group JSON entries but no live
container. Lazy-loaded, auto-refreshes on capabilities_changed +
tool_groups_changed; each entry has a 'clear perms' button.

feat(dash) 4375ab6246: container rows show an
active model badge (blue) when the container is running and the harness has
persisted a model name in harness/hyperhive-model. Stale values suppressed
for stopped containers.
2026-07-03 00:13:13 +02:00
iris
2717c2f305 docs(web-ui/agent): add POST /api/effort and effort_changed to endpoint + event list 2026-07-02 23:34:13 +02:00
atlas
c0b4ca8662 ci: retrigger 2026-07-02 23:33:33 +02:00
atlas
e4889fdd2c fix(#2149): use - as session prefix separator (mara) 2026-07-02 23:33:33 +02:00
atlas
d5e0f680a5 fix(#2149): use hive display name + / sep in remote-control session prefix
CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX: hive+<agent> → <hiveName>/<agent>
(hiveDisplayName already available in scope from OTEL resource attrs)
2026-07-02 23:33:33 +02:00
atlas
04692871cf feat(#2149): set base claude-code env in managed settings
Add `baseClaudeEnv` (always-on) and extend `otelSettingsEnv` with the
env vars from #2149:

Always-on (every agent):
- CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
- CLAUDE_CODE_PLUGIN_PREFER_HTTPS=1
- CLAUDE_CODE_RESUME_INTERRUPTED_TURN=1  (recovers MCP-flap mid-turn)
- CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT=1
- CLAUDE_CODE_SYNC_PLUGIN_INSTALL=1
- CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX=hive+<agent>
- DISABLE_AUTOUPDATER=1 / DISABLE_UPDATES=1  (nix owns packages)
- DISABLE_INSTALL_GITHUB_APP_COMMAND=1
- DO_NOT_TRACK=1
- ENABLE_CLAUDEAI_MCP_SERVERS=0  (hive supplies its own)
- FORCE_AUTOUPDATE_PLUGINS=1

OTEL-gated (when hyperhive.otel.enable):
- CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTEL=1
- CLAUDE_CODE_OTEL_DIAG_STDERR=1
- OTEL_METRICS_INCLUDE_VERSION=1

Because baseClaudeEnv includes per-agent values
(CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX = "hive+${userName}"),
jq is now always run at build time — the OTEL-off branch that returned
the static asset verbatim is removed.
2026-07-02 23:33:33 +02:00
atlas
32a02640c1 ci: retrigger 2026-07-02 23:33:11 +02:00
atlas
1e373dcd63 fix(#1997): exclude docs/tools/forge.md from prettier (list-item continuations) 2026-07-02 23:33:11 +02:00
atlas
8406a45275 feat(#1997): add prettier markdown formatter to treefmt
- .prettierrc: proseWrap=preserve (no prose reflow)
- .prettierignore: exclude hivectl-cli.md (auto-generated) + 11 docs
  with multi-line list-item continuations prettier would strip to col 0
  (CommonMark limitation in prettier's list handling)
- format 16 markdown files: cosmetic only (*→_, table alignment,
  heading normalisation) — verified no broken continuations, idempotent
2026-07-02 23:33:11 +02:00
atlas
442efa76f2 temp: add prettier configs 2026-07-02 23:33:11 +02:00
iris
e5916f95a3 docs(web-ui/dashboard): fix wrong API paths and add missing build-log + schedule endpoints
Several paths in the dashboard docs had bugs:

- /dashboard/stream and /dashboard/history were missing the /api/
  prefix (7 occurrences). Verified correct paths from frontend source:
  flow.js:212 ('/api/dashboard/history'), core.js:305, tabs.js:1517,
  builds.js:624 (all '/api/dashboard/stream'); backend routes match.
- GET /api/build-logs/stream/{id} was wrong; the actual route (and
  what common.js:323 calls) is GET /api/build-logs/id/{id}/stream.

Also adds two missing endpoint entries to the API reference section:

- GET /api/build-logs/id/{id}/stream (the live SSE stream)
- GET /api/build-logs/id/{id}/raw (the plain-text download link)
- POST /api/schedules/{id}/pause and /resume (mentioned in prose at
  the SCH3DUL3S section but absent from the endpoint list)

The POST /meta-update prefix fix is already in-flight on a separate
branch; left untouched here to avoid conflict.
2026-07-02 23:20:36 +02:00
iris
7d8ca1f63a docs(web-ui/agent): add GET /api/bash-tasks and GET /icon to endpoint list 2026-07-02 22:30:50 +02:00
iris
6999217c29 docs(ci): document actions/checkout mirror + forge.mirrors option
feat(#2072) auto-seeded an actions/checkout pull-mirror when
forge.ci.enable is set, pointing Forgejo DEFAULT_ACTIONS_URL at the
local instance so CI uses: steps resolve on loopback. Also added a
general-purpose forge.mirrors option for pre-seeding any upstream
repo as a pull-mirror. Neither feature was documented in docs/ci.md.
2026-07-02 22:29:58 +02:00
iris
f90c4a0ca9 docs(web-ui/dashboard): document merge_config_pr approval card rendering
- Per-kind glyph/chip/sha table covers all 6 kinds: apply_commit (→,
  apply), merge_config_pr (⇒, merge-pr), update_meta_inputs (↻,
  meta-update), schedule_prompt (⏱, schedule), init_config (⊕, init),
  spawn (⊕, spawn)
- Document 'review PR on forge ↗' link in the what-changed body
- Clarify inline diff side-panel is apply_commit-only
- Supersedes #1939 (lexis's PR)

Closes #1939.
2026-07-02 22:29:12 +02:00
damocles
d13ed94309 docs: rfc3339 wire timestamps convention + audit-log field notes 2026-07-02 22:28:30 +02:00
damocles
cafef519a9 dashboard frontend: consume rfc3339 timestamps from the api 2026-07-02 22:28:30 +02:00
damocles
bac2c0a65e hive-c0re: rfc3339 timestamps on dashboard api + sse json 2026-07-02 22:28:30 +02:00