Compare commits

..

18 Commits

Author SHA1 Message Date
david 927e61fa45 fix: derive threads and snippets on replicate-only nodes (#8)
build / test (push) Successful in 3m20s
build / image (push) Successful in 27s
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:01:09 -08:00
david 10b0a3de6a fix: rebuild derived state on startup when the log has data but entries do not (#8)
build / test (push) Successful in 5m20s
build / image (push) Successful in 28s
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 17:48:16 -08:00
david fdd9f9cacd perf: cache go modules and build output in CI (#8)
build / test (push) Successful in 7m9s
build / image (push) Successful in 2m44s
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 17:37:05 -08:00
david 6f1fc5be84 fix: batch pushes by size, not just row count (#8)
build / test (push) Has been cancelled
build / image (push) Has been cancelled
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 17:36:36 -08:00
david 1328efa4f8 fix: reconcile pushes even when this node has no seed peers (#8)
build / test (push) Successful in 5m0s
build / image (push) Has been cancelled
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 17:28:29 -08:00
david dcb4e1e331 ci: mount the real CasaOS app dir so the restart step can find knox (#8)
build / test (push) Successful in 3m15s
build / image (push) Successful in 2m14s
2026-11-04 17:17:19 -08:00
david 39d970a7ea fix: reconcile after a peer push, not only after a pull (#8)
build / test (push) Successful in 3m2s
build / image (push) Successful in 2m10s
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 17:09:04 -08:00
david 92d2431fb9 fix: separate the gossip listen address from the advertised one (#8)
build / test (push) Successful in 3m46s
build / image (push) Successful in 2m39s
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-03 23:28:40 -08:00
david a5b067b895 ci: drop the explicit docker socket mount (runner already injects it) (#8)
build / test (push) Successful in 3m43s
build / image (push) Successful in 2m42s
2026-11-03 23:18:57 -08:00
david 3d866d1774 ci: install node in the job containers so actions/checkout can run (#8)
build / test (push) Successful in 3m46s
build / image (push) Failing after 0s
2026-11-03 23:10:31 -08:00
david a422de2ab6 ci: use debian-based job images so act_runner can inject node (#8)
build / test (push) Failing after 1m50s
build / image (push) Has been skipped
2026-11-03 23:05:39 -08:00
david d1e95ebd9a ci: build the image on the host daemon via the runner socket (#8)
build / test (push) Failing after 45s
build / image (push) Has been skipped
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-03 23:02:39 -08:00
david 02c2eb35f4 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-03 23:02:04 -08:00
david f80424d707 Merge commit '52c4d1f' into feat/remote-node
# Conflicts:
#	internal/db/db.go
2026-11-03 23:00:20 -08:00
david 6335670ddb style: gofmt internal/watch/gossip_test.go
Missed by the gofmt sweep in d6d2a24; `gofmt -l .` is now clean.
2026-11-01 13:48:27 -08:00
david e4f3618424 fix: read opencode sessions from session_v2/session_message
opencode 2.0.24 migrated its session store: the session, message and
part tables stopped being written, and sessions now live in session_v2
with messages in session_message. The ingest kept querying the abandoned
tables, so every sweep after the migration logged "0 new" and no error.

Session titles are nullable in session_v2, so keep the COALESCE and the
"Session <short id>" fallback.

Transcripts are rebuilt from both message shapes the new store uses:
user turns carry text at $.text, assistant turns carry a typed part list
at $.content of which only "text" parts are conversation (reasoning and
tool parts are not indexed). Rows are ordered by seq, then part index,
so a session reads in order.

Harness reminders arrive as synthetic messages now; drop <system-reminder>
text so it does not consume the 4000-byte summary budget.

Also stop skipping an entry purely on created_at: resuming a session
appends messages without touching the creation time, so the summary is
compared too and the entry refreshes.

Bump the ingester to opencode-db/v2 and cover both message shapes with a
test that builds the new schema in a temp database.

Fixes #6
2026-11-01 13:48:09 -08:00
david 0b8ac34aee chore: checkpoint uncommitted work before session store fix
Pre-existing work-in-progress in the tree: karakeep, snippets,
skills-health and redaction ingesters, the opencode.db session sweep,
gossip and metrics changes. Checkpointed as-is so the adapter fix in the
next commit stays reviewable on its own.
2026-11-01 13:48:09 -08:00
david 52c4d1f1e6 fix: derived-state determinism, error visibility, metrics naming, HTTP hardening
- rebuild: fold observations per fingerprint in a total order
  (hcl DESC, node_id DESC, id DESC) so two nodes with identical logs
  rebuild identical entries (was: arbitrary bare-column row, merge-order
  dependent)
- threads: CreateThreadCluster uses INSERT OR IGNORE + existing-id
  fallback — concurrent auto-threaders converge instead of hitting UNIQUE
- errors surfaced instead of swallowed: scanEntries returns rows.Err(),
  Stats() fails fast on query errors, AutoLinkThreadObservations /
  linkTemporalNeighbors / golden-thread linking propagate failures,
  AddThreadNote + LinkObservationToThread write under one tx,
  watch records session upsert failures
- gossip client: push checks HTTP status and reports errors (a broken
  push direction no longer looks like a silent success); gossip diff
  gets a 10s timeout so a dead peer cannot hang the CLI
- ingest: failed source sweeps (obsidian/browser/gitea) are logged,
  and -d's help text now states its file-only scope
- watch --quiet: fatal errors go to stderr instead of io.Discard
- main: cobra SilenceErrors/SilenceUsage (errors print once, usage is
  not dumped on runtime failures); knox mcp exits 0 on SIGINT/SIGTERM
- metrics: drop _total suffix from gauges (knox_observations,
  knox_entries, knox_projects, knox_sessions, knox_peers, knox_threads);
  _total stays on counters per Prometheus convention
- http: ReadHeaderTimeout + IdleTimeout on gossip, metrics, and web servers

tests: concurrent cluster-create idempotency, HCL-order rebuild fold
(both merge orders), push HTTP-error surfacing; full suite + -race pass,
gofmt clean
2026-09-17 02:28:08 -07:00

Diff Content Not Available