feat: always-on remote node — MCP over HTTP, TLS/token, Docker, CI, sqlc #9

Merged
david merged 14 commits from feat/remote-node into main 2026-11-05 02:14:34 +00:00

14 Commits

Author SHA1 Message Date
david 24d28c4cc5 fix: derive threads and snippets on replicate-only nodes (#8)
KNOX_LOCAL_SOURCES=none disabled the auto-threader and snippet extractor along
with the ingesters. Both derive from rows already in the log, so a replica has
everything they need: the dhg.lol node held 11.5k observations and 4.9k entries
but only 2 of the origin's 28 threads, quietly degrading half the MCP surface.

Ingestion stays gated; derivation always runs.
2026-11-04 18:13:21 -08:00
david 2ef8782869 fix: rebuild derived state on startup when the log has data but entries do not (#8)
A replica that restarts with a populated observation log and an empty entries
cache had no trigger to reconcile: pushes and pulls only fire on *new* rows,
and the node is already in sync. It now rebuilds once at startup.
2026-11-04 18:13:21 -08:00
david 120f64c3db perf: cache go modules and build output in CI (#8)
The Dockerfile uses BuildKit cache mounts so module downloads and compiled
packages survive a go.sum bump, and the test job restores the runner-local
cache server that act_runner already exposes.
2026-11-04 18:13:21 -08:00
david b02271f033 fix: batch pushes by size, not just row count (#8)
A 500-row batch of content-heavy observations exceeded the receiver's 4 MiB
body limit and returned 400, so the sender retried the same batch on every
sweep and the log stalled. Pushes now trim to a 2 MiB budget (rows are ordered
by HCL, so the tail simply arrives next time) and the receiver accepts up to
8 MiB.
2026-11-04 18:13:21 -08:00
david 906712cf9a fix: reconcile pushes even when this node has no seed peers (#8)
The sweep returned early on an empty peer list, which is precisely the
replica case: dhg.lol configures no peers, receives pushes, and never rebuilt
entries. Check for pending pushes before bailing out.
2026-11-04 18:13:21 -08:00
david 201a49208a ci: mount the real CasaOS app dir so the restart step can find knox (#8) 2026-11-04 18:13:21 -08:00
david 7b92b411a5 fix: reconcile after a peer push, not only after a pull (#8)
A push-only node — a replica with no peers of its own, which is exactly the
dhg.lol deployment — received observations but never rebuilt entries, so search
returned nothing while the log filled up. The batch handler now signals the
sweep, and reconcile runs when either direction changed the log.
2026-11-04 18:13:21 -08:00
david cbe42b7900 fix: separate the gossip listen address from the advertised one (#8)
KNOX_PEER_ADDR doubled as the bind address, so a container tried to bind the
host's overlay IP and the gossip server never started. KNOX_LISTEN_ADDR now
controls the bind (defaulting to KNOX_PEER_ADDR for compatibility) and the
advertised address stays what peers dial.
2026-11-04 18:13:21 -08:00
david 31fd0d8957 ci: drop the explicit docker socket mount (runner already injects it) (#8) 2026-11-04 18:13:21 -08:00
david 2421efe706 ci: install node in the job containers so actions/checkout can run (#8) 2026-11-04 18:13:21 -08:00
david 4c207fe2b3 ci: use debian-based job images so act_runner can inject node (#8) 2026-11-04 18:13:21 -08:00
david 089355708f ci: build the image on the host daemon via the runner socket (#8)
Builds on dhg.lol's daemon (the runner whitelists /var/run/docker.sock and
/apps), tags :latest plus the commit SHA, and restarts the compose stack only
when apps/knox is already installed. No registry credentials: the registry
requires htpasswd auth and self-built apps are consumed with pull_policy never.
2026-11-04 18:13:21 -08:00
david c13ac12d97 feat: mcp over http on the official sdk, tls/token transport, docker, sqlc (#8)
MCP moves from mark3labs/mcp-go v0.17 (stdio only, 5 releases behind) to the
official modelcontextprotocol/go-sdk with typed tool inputs, and gains a
Streamable HTTP transport so a remote node can serve agents.

Transport security works without a public DNS name: KNOX_AUTH_TOKEN guards
every endpoint, KNOX_TLS_CERT/KEY serve TLS from a self-signed cert, and
`knox tls init` mints one whose SANs are whatever addresses clients dial.

Daemon hygiene for an always-on host: SIGTERM shutdown of the gossip and
metrics servers, --version reporting the VCS revision, KNOX_LOCAL_SOURCES=none
for a replicate-only node (no ingest tickers, no Obsidian vault adoption), and
default watch dirs that skip paths which do not exist.

Packaging: multi-stage Dockerfile (static, non-root, /data volume).

sqlc pilot: schema moved to internal/db/schema.sql (embedded) and the read
paths behind the MCP tools are now generated. The pilot found real drift —
entries.created_at existed only as a runtime ALTER — so the column is declared
in schema.sql and a parity test fails if generated code disagrees with db.Open.

Conformance: scripts/conformance.sh runs the official suite against a throwaway
node; conformance-baseline.yml records the capabilities knox deliberately does
not implement (resources, prompts, completions, fixture tools).

Refs #8
2026-11-04 18:13:21 -08:00
david 1f35b7eea4 Merge commit '52c4d1f' into feat/remote-node
# Conflicts:
#	internal/db/db.go
2026-11-04 18:13:14 -08:00