Commit graph

271 commits

Author SHA1 Message Date
iris
ce539559d5 forge: use base64 crate for avatar payload
Per @mara on #328: the hand-rolled encoder was over-cautious. Swap
for base64 = 0.22 from crates.io — a standard, widely-trusted dep,
no maintenance surface to carry. Drops the 15-line encoder and its
two RFC 4648 unit tests.
2026-05-23 01:15:16 +02:00
iris
dbb2ca4393 forge: upload hyperhive logo as the core user's avatar
The 'core' Forgejo user (hive-c0re's identity for commits in
core/meta + agent-configs/*) was showing the default hash identicon.
Adds a one-shot ensure_core_avatar in the ensure_all bootstrap that
POSTs the branding PNG to the admin avatar API and writes a marker
file (CORE_AVATAR_MARKER) so subsequent startups skip the call
(delete the marker to re-upload). Best-effort: a non-2xx is logged
and swallowed, doesn't gate startup.

PNG bytes baked in via include_bytes! from branding/hyperhive.png.
Base64 is hand-rolled (one small image in one cold path, not worth
a new workspace dep) with RFC 4648 §10 test vectors.

Closes #320.
2026-05-23 01:05:58 +02:00
iris
7f97acf19e dashboard: render META INPUTS as a full tree with bulk select
Remove the depth-2 cap in walk_meta_inputs so every fetched input
at every depth is surfaced, not just two levels (issue #275). The
uncapped walk needs a guard: a visited-node set makes it a spanning
tree — each fetched node walked once, at its shallowest path — so
shared subtrees don't re-walk and a cycle can't recurse forever.
A two-pass walk (claim a node's direct inputs before descending)
keeps shallow inputs at a shallow path.

Frontend: renderMetaInputs indents each row by its slash-path depth
and shows the leaf segment (full path on hover), plus a select-all /
select-none control so a long input list isn't ticked box by box.
2026-05-22 23:50:20 +02:00
iris
4a27ef7304 dashboard: derive ctx badge thresholds from the model context window 2026-05-22 22:32:32 +02:00
damocles
3e94914569 fix #289: full forge sync on rebuild (extract sync_agent, use in rebuild_agent)
extract per-agent forge logic from ensure_all() into sync_agent()
so both the startup sweep and rebuild_agent call identical code.
rebuild now runs: ensure_user_for + ensure_config_repo + push_config
+ meta_read_access + ensure_meta_remote — same as the boot sweep.
missing tokens and drift in any forge state are fixed by rebuild,
not just hive reboot.
2026-05-22 22:18:05 +02:00
damocles
7ad9809207 fix #289: re-seed forge token in rebuild_agent
if forge_after_first_spawn fails transiently on first spawn the
token is missing. rebuild_agent now calls ensure_user_for so
a manual rebuild (or the startup auto-update scan) recovers
the missing token — no full hive reboot needed.
2026-05-22 22:18:05 +02:00
iris
2f1b846baf dashboard: show meta-update progress in the META INPUTS panel
post_meta_update returns 200 immediately and runs the nix flake
update + agent-rebuild ripple in a background task, so the META
INPUTS panel looked idle for the whole multi-minute window (#259).

Track in-flight runs with a Coordinator atomic counter, exposed via
an RAII MetaUpdateGuard held across run_meta_update. Surface it as
the meta_update_running snapshot field plus a MetaUpdateRunning SSE
event (flipped only when the count crosses 0, so concurrent runs
flip the flag once). The panel shows a pulsing in-progress banner
and disables the update button while a run is active.
2026-05-22 21:54:28 +02:00
damocles
3f08051bda lifecycle: seed applied repo at template commit, not main, for first-spawn diff 2026-05-22 21:29:52 +02:00
iris
a9a10b631f dashboard: show when an approval was requested (closes #272) 2026-05-22 20:06:45 +02:00
damocles
748536203b refactor: split long functions per review feedback; remove all #[allow] attributes 2026-05-22 19:24:44 +02:00
damocles
bbe2112dc9 fix: use try_from for i64/u64 casts; split format_notification into helpers 2026-05-22 19:14:22 +02:00
damocles
484cea62c7 fix #265: resolve all remaining clippy warnings (cast, too_many_lines, doc nits) 2026-05-22 19:11:40 +02:00
damocles
30d82148e0 clippy: apply auto-fixable warnings across workspace (closes #265 partial) 2026-05-22 18:55:57 +02:00
damocles
b283768f26 forge: replace curl shell-outs with reqwest http helper (closes #249) 2026-05-22 16:26:44 +02:00
damocles
bbe4cdb872 add meta read access and remote for agents on forge 2026-05-22 15:28:06 +02:00
damocles
7426654a74 crash_watch: track prev_sub_agents to fix needs_login for newly spawned agents 2026-05-22 12:31:18 +02:00
damocles
55fe2856b9 actions: emit needs_login after first spawn, fix update_meta_inputs arity 2026-05-22 12:31:18 +02:00
damocles
66f1568e8f apply_commit handles first-time spawns, request_spawn deprecated 2026-05-22 10:52:02 +02:00
damocles
3e098c56ff update_meta_inputs: require operator approval, rename to request_update_meta_inputs 2026-05-22 10:49:20 +02:00
damocles
597e4ba03a manager: add update_meta_inputs tool to update flake.lock on demand (closes #235) 2026-05-22 10:49:20 +02:00
damocles
66c481a07a harness+dashboard: declarative dashboardLinks option (closes #191) 2026-05-21 23:20:13 +02:00
iris
f42ba9b561 dashboard file preview: markdown tabs + raster image rendering
Follow-up to #188. Two additions to the side-panel file preview:

- Markdown files get a rendered/plain tabbed view (was: always
  rendered, no way to see source) — same tab pattern as SVG.
- Raster images (png/jpg/gif/webp/bmp/ico/avif) render as an
  <img>. /api/state-file previously from_utf8_lossy-stringified
  every file and served text/plain, which corrupts binary; it
  now serves image files as raw bytes with their real
  content-type (over-cap images are rejected, not truncated —
  a clipped binary is corrupt).

buildSvgPanel generalised to buildTabbedPreview, shared by SVG +
markdown. .svg-host/.svg-render renamed .preview-host/.img-preview
since they now back images + md too.

closes #192
2026-05-21 21:49:15 +02:00
damocles
433bc85b91 auto_update: rebuild all on startup, needs_update = applied HEAD vs deployed sha 2026-05-21 19:47:01 +02:00
damocles
3b44410427 manager: receive forge notifications (ManagerRequest::Wake) 2026-05-21 19:05:53 +02:00
iris
d5009cd175 dashboard: add favicon (hyperhive mark)
The main dashboard had no favicon — PR #145 added them to the
per-agent pages but missed hive-c0re's index. Serve branding/
hyperhive.svg at /favicon.svg and declare it in the index head.
The dashboard represents the whole hive, so it uses the project
mark (per-agent pages keep their own configurable /icon).

closes #173
2026-05-21 18:58:05 +02:00
iris
fefa91a39e test: cover init_config approval deser + lenient row collection 2026-05-21 18:20:15 +02:00
iris
189fc587a4 fix: handle init_config approval kind in row deserializer
row_to_approval matched only apply_commit + spawn, so any approvals
row with kind=init_config (added by 80dd5bb's two-step spawn) failed
to deserialize. pending() / recent_resolved() collect all-or-nothing
via collect::<Result<Vec>>(), so one bad row errored the whole query;
api_state's log_default then swallowed the error and returned an empty
list — every pending approval vanished from the dashboard (issue #160).

- add the missing init_config arm to row_to_approval
- collect_lenient(): skip + log unparseable rows so a single bad row
  can never blank the whole approvals list again
- dashboard: label init_config approvals 'init' (was mislabeled
  'spawn' by the apply-vs-other fallthrough)

closes #160
2026-05-21 18:14:53 +02:00
damocles
3214328fd5 test: setup_proposed seeds both agent.nix and flake.nix (regression #146) 2026-05-21 17:39:30 +02:00
iris
1f52746bd9 manager: add optional agent param to reminder RPCs
CountPendingReminders and ReminderRollup were hardcoded to
MANAGER_AGENT. Both now take agent: Option<String> — None keeps the
current behavior (manager's own), Some(name) returns that agent's
reminder stats. The broker functions already take an agent name, so
this is a thin wire-protocol change. Callers (web UI stats page,
post-turn counts) pass None.

Closes #122
2026-05-20 22:14:09 +02:00
iris
d348ce885f manager: add optional agent param to GetLooseEnds
GetLooseEnds now takes agent: Option<String>:
- None   = manager's own loose ends (default; the bug fix)
- Some("*")    = hive-wide view (every approval/question/reminder)
- Some("name") = that agent's loose ends

The get_loose_ends MCP tool exposes this as an optional agent arg, so
the manager can still scan the whole swarm on demand. The web UI and
post-turn counts pass None (manager's own).
2026-05-20 21:44:17 +02:00
iris
873d5a083d manager: scope GetLooseEnds to manager's own items
hive_wide returns ALL agents' reminders and questions, causing other
agents' reminders (e.g. triage) to appear on the manager's web page
and in the get_loose_ends MCP tool. The MCP tool spec says it shows
your own pending items — switch to for_agent(MANAGER_AGENT) which
includes all approvals (manager is sole submitter), questions where
the manager is asker/target, and only the manager's own reminders.

Fixes #118
2026-05-20 21:44:17 +02:00
damocles
d8e64742f4 fix question answer sender and self-cancel feedback loop 2026-05-20 20:31:25 +02:00
damocles
0873159b9e fix: use combined_rev for needs_update dashboard badge 2026-05-20 20:00:38 +02:00
damocles
49caf6e539 fix: also add write:notification scope to mark notifications as read 2026-05-20 19:08:21 +02:00
damocles
72aef13eaf fix: add read:notification scope, always remint token on ensure_user_for 2026-05-20 19:06:32 +02:00
damocles
cddaacd12f feat: poll forge notifications in agent harness
Closes #27
2026-05-20 17:59:56 +02:00
damocles
1e325c84f2 fix: rebuild containers when meta flake changes, not only on hyperhive rev
Closes #78
2026-05-20 17:07:42 +02:00
damocles
a024ca65c0 fix: align forge user email to git user.email so commits link to profiles
agent users were created with {name}@hive.local but git commits use
{name}@hyperhive (set by meta::render_flake). forgejo matches by email,
so no profile link appeared on any commit.

- extract agent_email() helper returning {name}@hyperhive
- use it in ensure_user_exists (new users)
- add ensure_user_email() that runs gitea admin user edit to patch
  existing users; called from ensure_all on every startup sweep

Closes #64
2026-05-20 16:36:32 +02:00
damocles
4bcc8bf0b1 fix: import anyhow::Context for .context() on serde_json result 2026-05-20 16:01:47 +02:00
damocles
d3d52349c3 model/context: move context window config to host-level hive-c0re.nix 2026-05-20 15:49:03 +02:00
iris
b1f10b1d1b render message reply threads in dashboard and per-agent inbox
- MessageEvent and DashboardEvent Sent/Delivered now carry id and in_reply_to
- broker.send() includes last_insert_rowid in the emitted event
- recent_all() and recv_batch() include id and in_reply_to from the DB
- deliver_reminders_batch() tracks per-row rowids within the transaction
- dashboard message flow: reply rows are indented with a border-left and a
  clickable '↳ reply' tag that scroll-jumps + briefly highlights the parent
- per-agent inbox: reply messages get a '↳ reply ·' prefix and indent

Closes #26
2026-05-20 15:29:47 +02:00
iris
804875d670 surface rate_limited status as red badge on per-agent page and dashboard
- add rate_limited: Arc<AtomicBool> to Bus; set/cleared by emit_status
- write/remove sentinel file hyperhive-rate-limited in state dir so host-side
  dashboard can detect it without a live socket call
- api_state returns status=rate_limited when flag is set (cold-load accurate)
- ALIVE_LABELS gains rate_limited entry (⊘ red chip) on per-agent page
- ContainerView gains rate_limited: bool read from sentinel file
- dashboard container row shows ⊘ rate limited badge (red) ahead of needs_login

Closes #24
2026-05-20 15:16:00 +02:00
iris
270ef19920 dashboard: add per-agent ctx-window usage chip to container rows
Reads the most recent turn's context-window token count directly from
each agent's hyperhive-turn-stats.sqlite (same path the host-side
stats_vacuum uses). Adds ctx_tokens: Option<u64> to ContainerView;
populated in build_all via a single best-effort SQL query.

Dashboard app.js renders a 'ctx·Nk' badge colour-coded by harness
watermarks: green <100k (safe), yellow 100-150k (near auto-reset),
red ≥150k (compact territory). Badge only shown when ctx_tokens
is present (agent has run at least one turn).

Closes #17
2026-05-20 15:01:28 +02:00
damocles
80dd5bb69e two-step agent spawn: request_init_config + request_spawn 2026-05-20 14:40:15 +02:00
damocles
0b237d7d8c broker: skip broadcast self-delivery 2026-05-20 13:55:46 +02:00
damocles
931d4b26e7 broker: batch reminder delivery in single db transaction 2026-05-20 13:35:28 +02:00
damocles
c05a750409 enforce per-agent pending reminder cap (default 50, HIVE_REMIND_MAX_PENDING_PER_AGENT) 2026-05-20 13:35:28 +02:00
damocles
e27984b74c add graceful shutdown signal to coordinator and all background tasks 2026-05-20 13:35:28 +02:00
damocles
67b47872e0 add optional in_reply_to field on send for conversation threading 2026-05-20 13:35:27 +02:00
damocles
6f7cc6e77d add host-side turn-stats vacuum (90d retention, hourly sweep) 2026-05-20 13:35:27 +02:00