Commit graph hyperhive/hive-c0re
Author SHA1 Message Date
atlas
aae4be19bd fix(#962): remove hardcoded "root" string from docstrings and tests
Replace literal "root" with MANAGER_NAME constant in role tests;
update ROLE_CAN_MANAGE_TOP_LEVEL_AGENTS docstring to say "manager"
not "root/manager agent".
2026-06-01 19:19:24 +02:00
atlas
a4e0628ba1 fix(#962): top_level_agents_in delegates to children_of(MANAGER_NAME)
The previous parent=None heuristic was wrong — the manager is not
required to be the structural topology root (it can have a parent).
Delegate to children_of_in(MANAGER_NAME) directly; topology.rs is the
right place for this knowledge. Update comment in lifecycle.rs to say
"direct child of the manager" instead of "direct child of root".
2026-06-01 19:19:24 +02:00
atlas
828be8e2c8 refactor(#962): replace children_of(MANAGER_NAME) with top_level_agents()
Add topology::top_level_agents_in(topo) and top_level_agents() which
find the topology root by structure (parent=None) rather than by name,
then return its children. Lifecycle.rs role logic now uses this instead
of children_of(MANAGER_NAME), removing the hardcoded manager-name
reference from the bind-mount logic.

Also adds two unit tests for top_level_agents_in.
2026-06-01 19:19:24 +02:00
atlas
d79df752d6 fix(#962): keep empty role entries as tombstone; add role unit tests
set_role previously removed empty entries after revoke, causing
reconcile_roles to re-seed the role on the next tick (absent key =
never seen = seed). Fix: never remove empty entries; an empty list
is a tombstone meaning "explicitly revoked".

Also adds unit tests for has_role_in, set_role revoke semantics, and
the reconcile_roles seed/no-seed distinction (pure in-memory, no disk).
2026-06-01 19:19:24 +02:00
atlas
6d2d0ed847 feat(#962): topology-driven child bind mounts + can_manage_top_level_agents role
Removes the MANAGER_NAME special-case from set_nspawn_flags in favour of
two general mechanisms:

1. Topology-driven child mounts: every agent now gets its direct children's
   state, harness, and config dirs bind-mounted (RW). Root's children are
   the top-level agents, so root gets the same access it did before via the
   old /agents blob bind — but derived from topology, not a hardcoded name
   check.

2. can_manage_top_level_agents role: agents holding this role additionally
   get every top-level agent treated as a virtual child (same RW mounts)
   plus /applied and /meta as RO. Designed for recovery: a role holder can
   update a top-level agent's config even when that agent is down.
   Root receives this role by default on first reconcile_roles call.
   Operator can revoke it with set_role.

Every agent (including root) now gets its own state/harness/config dirs via
the standard path. Roles are stored in meta/roles.json (same dir as
topology.json); reconcile_roles is called from reconcile so both files stay
in sync.
2026-06-01 19:19:24 +02:00
iris
ab278affc7 rename(#162): scrub remaining hm1nd references from comments and MCP instructions
All functional renames (MANAGER_NAME, MANAGER_AGENT → "root") were done in
earlier commits. This cleans up the stale `hm1nd` strings that remained in
doc comments, test fixture labels, and the manager MCP server instructions
(which told the manager its config lived at /agents/hm1nd/config/agent.nix).
2026-06-01 19:18:02 +02:00
müde
f9de183f4e fix: strip /agent/<name>/ via rewrite in named location
nginx forbids a URI part on proxy_pass inside named locations, so the
split-mode `@<name>_dynamic` fallback (introduced when the gateway
started serving static dist directly) failed config-test with:

  "proxy_pass" cannot have URI part in location given by regular
  expression, or inside named location

Render two upstream forms: prefix locations keep the trailing slash so
nginx auto-strips the location prefix; the named-location path strips
`/agent/<name>/` via `rewrite ... break` and uses a bare upstream.
2026-06-01 19:10:38 +02:00
damocles
4d934748f7 fix(#977): abort phase 5 if stop fails; clean up old root.conf after rename 2026-06-01 18:32:19 +02:00
damocles
68cc433ac9 fix(#977): add MANAGER_CONTAINER=h-root, migrate root container name 2026-06-01 18:32:19 +02:00
atlas
286a7c8fd3 fix(#975): use hyperhive.local email domain to pass Forgejo validation
`@hyperhive` (no dot) is rejected by Forgejo's PATCH /admin/users API
with 422 Unprocessable Entity. Switch to `@hyperhive.local` across all
four files that construct hive-c0re/agent git emails and Forgejo account
emails, so both stay in sync and pass RFC-valid domain validation.
2026-06-01 18:28:22 +02:00
damocles
b83edc40c6 fix(#970,#973): retry gateway reload on failure; always enable HIVE_WEB_SOCKET 2026-06-01 18:18:45 +02:00
atlas
5cf18ad7c7 fix(#971): remove duplicate BindMount re-export in priv_client
BindMount was imported at line 10 via the priv_proto glob-style import,
then re-exported again with `pub use` at line 69. E0252: two definitions
of BindMount in the same type namespace. Remove the redundant pub use —
callers that need BindMount should import from hive_sh4re::priv_proto.
2026-06-01 18:05:43 +02:00
damocles
68fd7e08a5 fix(#948): pre-enqueue topology-sorted cascades on meta-update approval 2026-06-01 17:55:01 +02:00
damocles
11d74e1e17 fix(#947): include manager in gateway agents.conf routing 2026-06-01 17:46:10 +02:00
damocles
aa96d76e73 build-logs: extract compute_runtime_secs helper; clamp runtime in js 2026-06-01 17:42:35 +02:00
damocles
26c9c13cf5 build-logs: surface runtime_secs in header; show duration in dashboard row 2026-06-01 17:36:29 +02:00
iris
e162c1a1fa feat(#955): split agent page serving — statics from nix store, API proxied
gateway_nginx.rs reads HIVE_AGENT_FRONTEND_DIR (injected by hive-c0re.nix
as ${cfg.frontend}/agent). When set, agents.conf emits per-agent split
blocks instead of the old single proxy_pass:

  # Compiled assets — immutable nix store path, cache 1y
  location ^~ /agent/<name>/static/ {
      alias <frontend>/static/;
      expires 1y; add_header Cache-Control "public, immutable, ...";
  }
  # Static dist + proxy fallback
  location /agent/<name>/ {
      alias <frontend>/;
      try_files $uri $uri.html $uri/index.html @<name>_dynamic;
  }
  location @<name>_dynamic {
      proxy_pass <upstream>;   # api, events, icon, login, …
      …proxy headers unchanged…
  }

try_files path resolution (nginx applies alias mapping first):
  $uri           — exact file (/static/app.js → static/app.js)
  $uri.html      — bare-path fallback (/stats → stats.html)
  $uri/index.html — directory index (/ → index.html)
  @<name>_dynamic — proxy catchall for anything not in the dist

Adding pages to the frontend dist works automatically — no generator
change needed. Per-agent extraFiles (in mergedDist, not in the base
nix-store path) continue to proxy to the agent daemon.

frontend is a nix store path injected at build time — only [a-z0-9/._-],
no shell metacharacters — safe to interpolate without sanitization;
comment added documenting this assumption.

Without HIVE_AGENT_FRONTEND_DIR the existing single-proxy block is
emitted unchanged — backward-compatible for deployments without the env.

render() takes frontend_dir as a parameter so tests exercise both code
paths safely in parallel. 13 tests: 7 legacy, 6 split-mode. No clippy
warnings in changed files.

nix/modules/hive-c0re.nix: inject HIVE_AGENT_FRONTEND_DIR = "${cfg.frontend}/agent".
2026-06-01 17:35:28 +02:00
damocles
e7e0675d22 rename: role badge stays 'manager'; unify harness unit name to hive-ag3nt 2026-06-01 17:33:09 +02:00
damocles
1b4e9d0e2b rename(162): nixosConfigurations.manager -> root, hive-m1nd -> hive-root 2026-06-01 17:33:09 +02:00
damocles
9654315a20 rename(162): update manager test to use root 2026-06-01 17:33:09 +02:00
damocles
935f2011a0 rename(162): update hm1nd comment in ensure_manager 2026-06-01 17:33:09 +02:00
damocles
4c2398a38e rename(162): role badge manager -> root, update hm1nd comment 2026-06-01 17:33:09 +02:00
damocles
37b5335c27 rename(162): MANAGER_NAME hm1nd -> root 2026-06-01 17:33:09 +02:00
damocles
c9eb520e7c priv: WriteNspawnFlags takes Vec<BindMount> instead of raw flag strings 2026-06-01 17:27:14 +02:00
damocles
aa7f8e5553 priv: move shared consts to hive-sh4re; WriteNspawnFlags uses Vec<String> + per-flag validation 2026-06-01 17:27:14 +02:00
damocles
89d0937473 priv: derive flake ref from agent name; WriteNspawnFlags takes flags only 2026-06-01 17:27:14 +02:00
damocles
8d5e97ce9f fix(702): update priv_client to match narrowed PrivRequest variants 2026-06-01 17:27:14 +02:00
damocles
29926031ae fix(702): replace systemd_run_machine with reload_gateway_nginx in priv_client 2026-06-01 17:27:14 +02:00
damocles
c5cab732a2 feat(#702): priv_client - async client for hive-priv 2026-06-01 17:27:14 +02:00
damocles
138d9fdabe feat(#702): add priv_client module to hive-c0re 2026-06-01 17:27:14 +02:00
damocles
e8b24e7021 fix(948): topo-sort cascade agents in meta_update_cascade_agents 2026-06-01 16:50:41 +02:00
damocles
5dc31c1e13 fix(948): make topology_sort pub 2026-06-01 16:50:40 +02:00
damocles
eb108f9dd8 fix(947): trim prose in lifecycle.rs socket-dir block 2026-06-01 16:49:41 +02:00
damocles
e7a5718e83 fix(947): strip prose/issue-tags from agent_sockets.rs 2026-06-01 16:49:41 +02:00
damocles
7af29b3249 fix(#947): extend socket-dir bind to manager container 2026-06-01 16:49:41 +02:00
damocles
4435666c00 fix(#947): include manager in agent-sockets.json 2026-06-01 16:49:41 +02:00
damocles
8b946a67c6 fix(#947): extend socket-dir bind to manager container 2026-06-01 16:49:41 +02:00
atlas
f8c0f64fd4 feat: socket-activate the hive-c0re admin socket
Add a systemd.sockets.hive-c0re unit that holds /run/hyperhive/host.sock
before hive-c0re starts. hive-c0re serve() detects LISTEN_FDS via the
listenfd crate and accepts the systemd-handed fd instead of calling bind().
Falls back to the existing bind path when LISTEN_FDS is absent so direct
invocation and CI are unaffected.

Benefits: hivectl can connect the moment the socket unit activates (no
racy window), and a hive-c0re restart never drops the socket inode.
2026-06-01 16:29:41 +02:00
damocles
0f62eca356 fix(#942): wire bash_tasks_vacuum spawn into main.rs 2026-06-01 16:11:08 +02:00
damocles
5880328831 fix(#942): wire bash_tasks_vacuum into lib.rs + main.rs 2026-06-01 16:11:08 +02:00
damocles
38a5299183 fix(#942): host-side bash-tasks vacuum, 48h retention 2026-06-01 16:11:08 +02:00
damocles
8d2ae047b1 fix(#937): drop dead has_pending_from — superseded by has_pending_with_body 2026-06-01 15:39:26 +02:00
damocles
3283362b36 fix(#937): use has_pending_with_body in worker — mirrors broker change 2026-06-01 15:39:26 +02:00
damocles
ce27ef8b9e fix(#937): narrow skip to same-body pending — different schedules can still enqueue 2026-06-01 15:39:26 +02:00
damocles
bf4937d116 fix(#937): skip scheduled delivery if target already has pending scheduled message 2026-06-01 15:39:26 +02:00
damocles
044ff5523c fix: call matrix::sync_agent on rebuild, mirrors startup sweep 2026-06-01 14:37:22 +02:00
iris
188f3ea5ec chore: scrub #NNN issue references from code comments and nix descriptions
Part of the docs-migration chore (issue #708). Remove GitHub issue
numbers from inline comments, option descriptions, and rustdoc —
these are contextless noise for anyone reading the code without
access to the original discussions. Replace with prose that captures
the same rationale directly.

No functional change. Build still clean (cargo check passes).
2026-06-01 13:30:52 +02:00
damocles
9bd37d4df3 fix(#4): rename shared org from org-shared to internal 2026-06-01 13:27:47 +02:00
damocles
6044cd4d79 feat(#4): seed org-shared/docs repo, grant every agent read access 2026-06-01 13:27:47 +02:00
damocles
ae6d23594d feat(#2): split harness-internal state from agent-visible state 2026-06-01 13:27:35 +02:00