feat(wake): W4 — per-host delta-gated detector daemon (fail-loud source semantics, enqueues to W2 store) #907
Reference in New Issue
Block a user
Delete Branch "feat/wake-detector"
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?
W4 — per-host delta-gated detector daemon (A1)
Builds on merged W2 (store/ack/schema) + W3 (digest/sign) on main. The detector OBSERVES sources and ENQUEUES deltas to the W2 store via its public API — it does not reimplement store/ack/digest/sign.
Design map
detector.sh runis a per-host single-instance (non-blockingflock; a 2nd instance refuses loudly), long-lived service (not a timer). Serves local panes only; no cross-host waking. Generalizes the provenpoll → hash → deliver-only-on-deltapoller and adds (a) repo-section/anchor-scoped hashing (_scope_anchor) so human-decision FILE edits are caught, not just API-visible state.observed_seqandstore.sh enqueue --seq --class --locators --emit-ts(W2 store, not reimplemented). Class passes through from the watch-list source; absent ⇒ store defaults toactionable(fail-safe).observed_seqis a monotonic int assigned at observation (single global counter, authoritative); source SHAs are descriptors only. A per-watch last-observed hash is compared each poll, so a revert A→B→A across polls is caught as a delta.401/403/privacy-404/partial (adapter non-zero exit), or ambiguous-empty (exit 0 + empty output that might mean "hidden") fails loud, does NOT advanceobserved_seq, does NOT touch the last-observed hash, and is never treated as "no change." A missing anchor is treated the same way.schema_versionis validated against the component manifest's[schema_min, schema_max]; out of range ⇒ rejected (fail loud), never coerced.watches[].sources[]are polled; a referenced-but-undefined source id fails loud.The source adapter (
WAKE_DETECTOR_SOURCE_CMD) is pluggable so the framework bakes in no git/gitea/HTTP/file specifics (operator-agnostic firewall). All state is XDG/env; no operator paths/names/secrets/hosts.RED-first evidence
test-wake-detector.sh(wired intotest:framework-shell), fake/stub sources only, shellcheck clean:observed_seqobserved_seqNOT advanced (G2a)Teeth verified by mutation: breaking the delta-gate, silencing the G2a fail-loud, and removing the flock guard each turn the harness RED; restored = GREEN. The harness also caught two real bugs during development (a jq reserved-word
defcollision and apipefailSIGPIPE on the adapter stdin).Gates / firewall
detector.sh+ harness);format:check(prettier) passes.grep -niE 'jason|woltje|jarvis'= 0;verify-sanitized.shgate passed.Out of scope (untouched)
FN-oracle/reconciler (W5), off-host beacon (W6), installer (W7). store.sh/ack.sh/digest.sh/sign.sh called only via public APIs.
Contract note (flagged, not guessed)
First-seen baseline: on the first observation of a source (no prior hash) the detector establishes the baseline without a wake, matching the deliver-on-NEW exemplar §1.1 generalizes. Startup obligations that predate the detector are the reconciler's job (W5, out of scope). Flagged in case the canon intends first-seen to wake.
Part of #892
Record of Review — PR #907 W4 (per-host delta-gated detector daemon; Part of #892)
VERDICT: APPROVE (GO on CI terminal-green). Reviewer: independent subagent
abd9a153(opus, per CONVERGED-DESIGN §1.1/§1.2/§2.4/§4-G2a/Gate-B) — ≠ builder (mosaic-coder). REVIEWED-HEAD (full-40):2ea938efdd4222b71f0a4532f1b2bb628762700d.Per-criterion (all 10 PASS on merits; red-first teeth proven by 3 independent mutations)
Noted non-blocker (reviewer: NOT a change request)
_next_observed_seqincrements before store enqueue; on an (effectively-unreachable) enqueue failure a burned seq never reaches observed.set → a theoretical contiguous-prefix gap. Unreachable on the validated call path; monotonic-not-gapless arguably spec-compliant for observed_seq. Awareness only.GO for id-11 at FULL-40
2ea938efdd4222b71f0a4532f1b2bb628762700don CI terminal-green. Non-executor.GO — Gate-16 id-11 stamp, pinned to exact FULL head
2ea938efdd.Basis: verbatim RoR (comment 18933) — independent review APPROVE, all 10 criteria, red-first teeth proven via 3 mutations; FIRST-SEEN baseline adjudicated correct (do-not-wake, durable once-per-source baseline — pre-existing state is the W5 reconciler's job; waking would be the wake-storm class the design kills); G2a source fail-loud verified (401/403/ambiguous-empty never silently no-change, observed_seq not advanced); store-API discipline confirmed (prior W-layers byte-unchanged). Seq-burn wedge class tracked as #908 per Mos ruling. CI terminal-green. W4 of EPIC #892. Named executor: Mos (id-11), squash pinned.