feat/go-daemon-passive-service #192
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/go-daemon-passive-service"
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?
Step 2 of docs/wiki/go-migration.md: a small Go service alongside Rust. It is read-only by construction and owns no canonical state. Service: - cmd/colibri-daemon with --socket/COLIBRI_SOCKET, --data-dir/COLIBRI_DATA_DIR, --oxigraph/COLIBRI_OXIGRAPH, --verbose, --read-timeout, --shutdown-grace. The default socket lives under a uid-scoped colibri-go directory, deliberately distinct from the Rust daemon's colibri.sock so both can run on one host. - internal/daemon: config, protocol, readiness probes, and the server. Boundaries this relies on: - Socket directory is created 0700 and refused rather than tightened if it already exists with group/other bits. The socket is chmod 0600 and the mode is re-read after bind, so a umask cannot quietly widen it. - Duplicate-bind is decided by dialling the path: a live listener yields ErrAlreadyRunning, ECONNREFUSED means a stale socket is reclaimed, and a non-socket or symlink at the path is refused instead of removed. - Peer authentication reads the kernel's own record: SO_PEERCRED on Linux and LOCAL_PEERCRED/xucred on FreeBSD. Peer UID must equal the daemon UID; root is not special-cased because the service is read-only. A platform without a peer credential API fails closed. - SIGINT/SIGTERM stop accepting, drain within the grace budget, force-close what remains, and unlink the socket. Protocol is line-oriented JSON in the Rust reference envelope: {"cmd":...} in, {"ok":true,"data":...} or {"ok":false,"error":...} out. "method" is accepted as an alias and an "id" is echoed when supplied. Commands are version, capabilities, readiness, ping, and health. Mutation verbs are an explicit deny-list returning unsupported_mutation, so a refusal is specific rather than a fallthrough. Unknown verbs are echoed only when they match a safe pattern. Readiness fails closed on either dependency: the canonical store must exist and its recorded schema version must match, and Oxigraph must answer one bounded query. A missing store is reported, never created, because a passive service must not conjure canonical state. This adds StoredSchemaVersion to the SQLite store as a read-only accessor. Tests: 35 daemon tests plus 2 store tests, race-clean, covering permission enforcement, duplicate bind, stale-socket reclaim, insecure directory refusal, foreign-UID rejection, unverifiable peer rejection, unsupported mutations, non-reflection of unsafe verbs, readiness fail-closed behaviour on both probes, shutdown, and concurrency. Verified end to end: 0600 socket, duplicate instance exits 1 while the first keeps serving, SIGTERM exits 0 and removes the socket, and a restart rebinds the same path. Native FreeBSD runtime proof is not claimed: the package cross-builds clean for freebsd/amd64 with peer credentials compiled in, and the runtime proof stays a separate gate.When the daemon rejects an unverifiable peer, it sends an immediate refusal NDJSON response and closes the connection without reading any command payload. TestServeRejectsUnverifiablePeer previously used roundTrip(), which attempted to write {"cmd":"version"} before reading. Under high concurrency or race detection on CI runners, the server closed the socket before the client's write dispatched, triggering an EPIPE broken pipe failure. Extract an expectRejection() helper that dials and reads the immediate rejection line followed by EOF, matching TestServeRejectsForeignUID.