fix: derived-state determinism, error visibility, metrics naming, HTTP hardening #5
Reference in New Issue
Block a user
Delete Branch "fix/review-hardening-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Second batch from the codebase review — deterministic derived state, error visibility, metrics convention, and HTTP hardening.
Deterministic rebuild (gossip spec §6.2)
RebuildEntriesFromObservationsnow folds per fingerprint in a total order (hcl DESC, node_id DESC, id DESC) via a window function: two nodes holding identical observation logs now rebuild identical entries. Previously bareGROUP BYcolumns picked an arbitrary, merge-order-dependent row.Concurrency
CreateThreadClusteris an atomicINSERT OR IGNORE+ existing-id fallback under the partial unique index — concurrent auto-threaders (thread ticker + post-pull reconcile, or two converged gossip nodes) converge instead of one erroring on UNIQUE.Error visibility (errors are surfaced, not swallowed)
scanEntriesreturnsrows.Err()(silent truncation of search results no longer possible)Stats()fails fast on query errors instead of reporting zeros on a broken DBAutoLinkThreadObservations/linkTemporalNeighbors/ golden-thread auto-linking propagate failuresAddThreadNote+LinkObservationToThreadwrite both rows under one transactioningestlogs failed source sweeps (obsidian/browser/gitea);watch --quietfatal errors go to stderr instead ofio.DiscardGossip client
Pushchecks the HTTP status and reports errors — a broken push direction no longer looks like a silent successknox gossip diffgets a 10s timeout; a dead peer can no longer hang the CLI indefinitelyPrometheus convention (breaking for dashboards)
_totalsuffix (reserved for counters):knox_observations,knox_entries,knox_projects,knox_sessions,knox_peers,knox_threads. Counters keep_total. Update any dashboards/alerts accordingly.HTTP hardening
ReadHeaderTimeout(10s) +IdleTimeout(60s) on the gossip, metrics, and web servers (slowloris posture)CLI UX
SilenceErrors/SilenceUsage: errors print once, runtime failures no longer dump usage textknox mcpexits 0 on SIGINT/SIGTERM instead of "Error: context canceled" + exit 1ingest -dhelp now states it scopes file-based sources onlyTests — concurrent cluster-create idempotency; HCL-order rebuild fold in both insertion orders (catches the old non-determinism); push HTTP-error surfacing. Full suite +
-racepass; gofmt clean.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.