Commit graph hyperhive/hive-matrix-mcp
Author SHA1 Message Date
damocles
aca39072d5 fix(#3072): stop waking every agent on a re-applied m.space.child state event 2026-08-19 17:12:01 +02:00
atlas
be3411e180 feat(#3245): gate rustdoc in nix flake check, and clear the workspace
Nothing in the gate read doc-comments: clippy doesn't check intra-doc
links, cargo test doesn't, and no check built docs. So a [`Foo`] pointing
at a renamed, moved or deleted item rendered as plain text and had no
discoverer but a human happening to read the comment.

That matters here more than in most repos, because the convention is to
put a thing's authoritative description in one doc-comment and point at
it from everywhere else -- the design leans on the pointers being real,
and a dangling link is worse than no link since it names something and
sends the reader looking.

Adds `docs-rustdoc` to nix/checks.nix: craneLib.cargoDoc over
--workspace --no-deps --document-private-items, denying six rustdoc
lints. Listed explicitly rather than -D warnings so a new lint appearing
upstream cannot red the build on a class nobody has triaged.

--document-private-items is load-bearing rather than thoroughness for
its own sake: most of this workspace's doc-comments live on private
items and //! module headers, so without it rustdoc checks a small
fraction of the links and the gate sits green while the rot continues.

Then fixes every error it reports, 40 to 0 across nine crates. The
classes differ and so do the fixes:

- public item, wrong scope -> qualify. Node and Node::parent are both
  public; the link failed only because scheduler.rs does not import
  Node. Six sites become [`crate::Node::parent`].
- private item -> downgrade to backticks. Nothing was made public to
  satisfy a lint; changing API surface to appease a doc check would be
  the tail wagging the dog.
- genuinely dead -> [`JobBuilder::insert_into`] names a method that does
  not exist. Insertion is Scheduler::insert_job.
- prose that looks like markup -> argv[0] parsed as a link, and
  <args>/<hex>/<name> parsed as HTML tags.

Note for future fixes: pub(crate) resolves in an intra-doc link, a plain
private fn in a binary crate does not (wait_for_nodes resolved,
connect_hint did not, same crate, same shape).

The check does not ride the clippy/test artifact cache. It takes
cargoArtifacts, but rustdoc needs its own flavour of dependency
metadata, which cargo build does not produce, so a --no-deps docs build
still compiles dependencies it never documents. Measured at 6m47s cold;
that reasoning is recorded in the check's own comment so the next reader
does not re-derive it.

Verified by running the check's exact command against the pre-cleanup
tree first: 40 errors, build failed. A gate that cannot fail is not
evidence, and building it before the cleanup makes that proof free.
2026-08-14 02:30:55 +02:00
atlas
0e9b1c563d fix(#2860): no loopback default for the matrix homeserver
Third and last of #2860's agent-facing URL fallbacks. The operator's
ruling was "any special casing is done on the nix side - same binaries,
no hard coded fallback", so the default is deleted rather than replaced.

Every layer guessed the same wrong thing, and each guess was only ever
correct for a process sharing the host netns:

- nix/agent-modules/matrix.nix: matrixUrlDefault = localhost:8008, both
  as the option's default and as a sentinel the daemon unit compared
  against to decide whether to write HIVE_MATRIX_URL. Now nullOr str,
  default null, the guard is != null, and the doc says what forge.url's
  already says: null means "no matrix", not "guess one".
- nix/host-modules/hive-c0re/environment.nix: forwarded
  http://127.0.0.1:<port> when no gatewayHost was set. hive-c0re shares
  the host netns so it reads as harmless, but the value is handed to
  agents, which do not -- there it names the agent itself. Now forwarded
  only when there is a gateway vhost to name, matching the guard
  HIVE_MATRIX_PUBLIC_URL already uses twelve lines below.
- hive-matrix-mcp: paths::DEFAULT_HOMESERVER was the same address
  compiled in, so dropping the nix defaults alone would have left the
  daemon dialling loopback inside the agent's own netns -- the very bug,
  one layer down. homeserver_url() is now Option, and an account with no
  homeserver is skipped with a log, exactly as one with no token is.
  discover_token_accounts already refused to guess for the same reason.

Two comments taught the assumption back to the next reader ("shared host
netns means every agent container resolves localhost to the same
machine"); both now say which side of the netns boundary they describe.
MATRIX_HTTP keeps its value -- hive-c0re really does share the host
netns -- but no longer claims agents do.

Gated with nix eval against the extended agent-base config, as a pair:
with no url set the daemon unit carries no HIVE_MATRIX_URL, and with one
set it carries exactly that. Either check alone passes on a broken guard.
2026-08-03 20:34:36 +02:00
damocles
772529b7b5 matrix: drop dead unread_count handler 2026-08-03 17:41:24 +02:00
damocles
1192c4e4c7 matrix: wake and unread-guard on own read receipt, not push-rule count 2026-08-03 17:41:24 +02:00
atlas
7a826f9ee2 refactor(sock): one socket client, retry as a policy value
Six places in the tree hand-rolled the same connect / write one JSON
line / read one JSON line back. Two of them — the harness serve loop's
client and the MCP server's — were byte-identical apart from a six-line
wrapper, ~145 lines of literal copy-paste. The other four each
reimplemented a subset, and the subsets had drifted: some named the
socket path in their errors and some did not, one classified transient
against fatal failures and the rest retried nothing at all, two drained
the response and two decoded it.

That duplication was defended when the daemons were split out, on the
grounds that a daemon's socket etiquette should stay visible in the
crate that depends on it. The etiquette genuinely does differ. The code
does not, and five copies is where "each daemon documents its own
etiquette" stops paying for itself.

`hive-sock-client` now owns the transport once, generic over the
request and response types so it is protocol-agnostic: the host-served
control socket and the harness's in-agent socket both use it with their
own wire-type crates. The two real differences become values instead of
forks. Retry is `Retry::RideOutRestart` (2/4/8/16/30s, sized to ride out
a service restart) for callers with no natural retry of their own, or
`Retry::None` for callers already inside a poll loop where the poll
interval is the retry — and the reason each caller picked one is a
comment at the call site rather than a reimplementation. The response is
either decoded (`request`) or half-closed and drained (`notify`, where
the drain exists so the server's write-back doesn't land on a closed
socket). Whether a failure propagates or is logged and swallowed stays
at the call site, because that is the caller's choice and not a property
of the transport.

Errors always name the socket path now, everywhere. That detail is
load-bearing: a permission problem on a socket that reads as "is the
daemon running?" sends the operator to fix the wrong thing.

The transient-against-fatal enum is gone rather than moved. Serialising
happens before the retry loop and deserialising after it, so only
connect, I/O and short-read failures can reach the loop at all — a
deterministic failure is now unretryable by construction instead of by
classification.

It is deliberately a new crate and not part of `hive-agent-sock`. The
`*-sock` crates are pure wire types by convention — `hive-agent-sock`
depends on serde and nothing else — and the two largest copies talk to
the host socket, whose types live in a different crate entirely. A
transport in either wire-type crate would drag tokio into it and point
the wrong way besides.

No wire-format change: same JSON line in, same line out.
2026-07-26 22:44:48 +02:00
damocles
a66b7ab298 feat(#2659): serve hive-matrix-mcp over persistent streamable-http, drop stdio bridge 2026-07-24 12:44:39 +02:00
damocles
b68d91269f refactor(#2629): fix stale self-filter doc comments + flatten the sender-check let-chain 2026-07-22 17:51:34 +02:00
bitburner
71cc545cb2 fix(#2629): exclude agent's own messages from unread sweep
Gate the unread sweep on sender: skip rooms where the latest unread message
was sent by the agent itself. This prevents self-authored messages from
triggering an unread notification and causing a self-wake loop.

Fixes: #2629
2026-07-22 17:49:45 +02:00
damocles
21f1569a04 feat(#2569): migrate matrix producer to the in-agent todo socket (unread + invites); drop dead mcp.sock/wake plumbing 2026-07-20 23:29:26 +02:00
damocles
795dd882bb refactor(#2569): rename hive-agent-sock to hive-core-agent-sock 2026-07-20 21:58:28 +02:00
damocles
144912f8e0 address review: drop backwards-compat request/response aliases, use canonical names 2026-07-19 15:53:09 +02:00
damocles
d0beec8a40 refactor(#2581): carve per-agent mcp.sock protocol into hive-agent-sock crate 2026-07-19 15:53:09 +02:00
damocles
8149dc7633 fix(#2569): wake body points at get_loose_ends (get_todos rename is a later increment); strip tracker tags from source comments per hive-rules 2026-07-19 13:28:17 +02:00
damocles
711e0ece2a feat(#2569): matrix producer — sweep_unread pushes per-room todos instead of direct wakes 2026-07-19 13:28:17 +02:00
damocles
742ed51d57 fix(#2557): sweep unread rooms post-sync so a dropped matrix wake self-heals 2026-07-17 16:42:39 +02:00
damocles
5b7904eeb6 bump matrix-sdk 0.14 → 0.18 (#2529) 2026-07-16 14:02:03 +02:00
damocles
001b1dae37 feat(#2479): add from/until event-id cursors to read_room 2026-07-15 18:43:31 +02:00
damocles
0d40583991 feat(#2482): bootstrap cross-signing so agent matrix devices show verified 2026-07-15 18:17:40 +02:00
damocles
741852a8b4 fix(#2468,#2473): matrix read_room exposes in_reply_to + gates UTD sentinel on encryption 2026-07-15 17:06:13 +02:00
damocles
3f1643c594 refactor(#2464): rename hive-ag3nt crate to hive-agent, collapse lib into main 2026-07-15 16:09:39 +02:00
damocles
7069732e01 fix(#2369): skip statically-configured accounts in matrix token discovery to silence spurious sidecar warning 2026-07-11 10:17:48 +02:00
atlas
8d2ebcf51f fix(clippy): wrap PermanentBringUpError in backticks in doc comment (main.rs:59) 2026-07-09 00:47:32 +02:00
atlas
793f6ce185 fix(fmt): split method chain in bring_up_secondary_with_retry for treefmt 2026-07-09 00:47:32 +02:00
atlas
3de576141b refactor: extract bring_up_secondary_with_retry (fix clippy too_many_lines + needless_continue) 2026-07-09 00:47:32 +02:00
atlas
317e545d7c fix: wrap M_UNKNOWN_TOKEN in backticks in doc comment (clippy::doc_markdown) 2026-07-09 00:47:32 +02:00
atlas
a1cd50610a fix(#2095): retry secondary matrix account bring-up on transient failure
On a transient error (network blip, DNS not ready, homeserver 5xx) a
secondary account's bring-up was immediately skipped for the entire
daemon lifetime. This bit janet's catgirl account repeatedly when the
host DNS resolver wasn't ready at daemon start — the account would
silently disappear until the next restart.

Add a PermanentBringUpError sentinel in client.rs so callers can
distinguish M_UNKNOWN_TOKEN (stale/expired token — permanent, don't
retry) from transient network/homeserver errors.

In main.rs, replace the immediate skip with a bounded retry loop for
secondary accounts: up to 4 attempts with 2s/5s/15s/30s backoffs
(~52s total wait). On a transient error the daemon now stays alive
serving the primary and any other healthy accounts while the failing
secondary gets another chance. Permanent failures (PermanentBringUpError)
still skip immediately with no retry.

The primary account keep its existing behaviour: fatal on non-permanent
error so systemd restarts the whole daemon (systemd is the right retry
mechanism for primary bring-up failure).
2026-07-09 00:47:32 +02:00
iris
a35fd1dcf2 docs(matrix-mcp): document send_file, download_file, and unread guard in server instructions
The MCP server instructions string omitted three behaviours added in
earlier PRs, leaving agents without context on them:

- send_file / download_file tools (#1829, #1830)
- [file:]/[image:]/[audio:]/[video:] attachment markers in read_room (#1830)
- unread guard: send_message, send_dm, send_file, send_reply all
  reject if the room has unread messages; read_room + mark_read
  are required first (#1828)

Closes #1828. Closes #1829. Closes #1830.
2026-07-01 19:05:54 +02:00
damocles
db3249a390 fix(#2050): use stable fnv-1a for avatar idempotency hash 2026-06-28 01:38:21 +02:00
damocles
c99fa714d9 feat(#2050): set matrix avatar in the daemon over the live client 2026-06-28 01:38:21 +02:00
damocles
52de0ca648 feat(#2038): hint matrix bridge errors may be a daemon restart 2026-06-27 11:46:47 +02:00
damocles
f477a2f901 feat(#2039): require explicit account when multiple matrix accounts configured 2026-06-27 11:45:57 +02:00
damocles
8aba2e5509 fix(#2033): drop tracker tag from code comment (tracker-tag lint) 2026-06-27 00:33:58 +02:00
damocles
652acf8c6e fix(#2033): gate matrix mcp bridge startup on token, not daemon socket 2026-06-27 00:33:58 +02:00
damocles
3b0a914487 feat(#2035): auto-discover dashboard-provisioned matrix accounts via token+homeserver sidecar 2026-06-27 00:30:04 +02:00
damocles
d5202ebf60 heartbeat the matrix-accounts snapshot so as_of tracks daemon liveness 2026-06-22 13:30:07 +02:00
damocles
f38bc13293 matrix-accounts dashboard: live status + homeserver from daemon snapshot (be-4) 2026-06-22 13:02:43 +02:00
damocles
f5003fd1bb hive-matrix-mcp: remove planted marker from send_redact comment, fix concurrent-delivery wording 2026-06-19 13:46:50 +02:00
damocles
68b0894f5b add list_accounts daemon op to hive-matrix-mcp 2026-06-18 14:00:44 +02:00
damocles
8799a9aa11 hive-matrix-mcp: document redaction power-level + concurrency semantics 2026-06-16 11:06:39 +02:00
damocles
55ba30aa18 hive-matrix-mcp: cover send_redact reason=None in round-trip test (argus note) 2026-06-16 11:03:53 +02:00
damocles
1c0f7a72f7 hive-matrix-mcp: add send_redact tool to delete matrix events 2026-06-16 10:58:34 +02:00
damocles
e5cd4e58f1 matrix multi-account: isolate per-account stale-token failure so a bad secondary token doesn't kill the daemon 2026-06-15 23:13:45 +02:00
damocles
36fb041c55 matrixAccounts: hive 'main' is implicit primary, option declares extras only 2026-06-15 21:24:16 +02:00
damocles
3b26f58a00 docs: note ping arm in dispatch_op is unreachable 2026-06-15 20:28:31 +02:00
damocles
8e79eb4f26 feat: multi-account matrix daemon (account-routed mcp surface) 2026-06-15 20:23:42 +02:00
damocles
73c53c7d4a feat(#1685): surface attachments in read_room + add download_file 2026-06-15 18:17:35 +02:00
damocles
801b886a4c drop stale send_file_dm doc refs (per review) 2026-06-15 17:59:02 +02:00
damocles
07941421c1 replace send_file_dm with open_dm resolver (per review) 2026-06-15 17:59:02 +02:00
damocles
19f1fa4f28 rustfmt send_file handlers 2026-06-15 17:59:02 +02:00