diff --git a/doc/fleet-schedule-registry.md b/doc/fleet-schedule-registry.md index eb76a9f4ce..20e0000f95 100644 --- a/doc/fleet-schedule-registry.md +++ b/doc/fleet-schedule-registry.md @@ -260,6 +260,13 @@ The OS-timer half of surface 2. Cadence is the unit's own `OnCalendar`/`OnUnitAc | `tldr-update.timer` | `OnCalendar=Mon` | `tldr-update.service` | laptop (user systemd) | not recorded | not recorded | not recorded | 2026-11-03 | | `worktree-reaper.timer` | `OnCalendar=*-*-*` | `worktree-reaper.service` | laptop (user systemd) | not recorded | not recorded | not recorded | 2026-11-03 | +Retired repository timer: `pm-stack/aggregator/systemd/kill-collector-drill.timer` +(weekly Sunday 04:17, sandbox system unit) was removed on 2026-11-04 because +it targeted the retired sandbox collector. The drill script is laptop-only +(`amd`) until a laptop-hosted schedule is deliberately installed; the live +sandbox's installed-unit state still requires the operator audit linked from +issue #1319. + ## Surface 3 — Jules schedules (1 entry, retired) | name/id | repo/scope | cadence | prompt (summary; verbatim in #2265) | budget expectation | owner | kill criteria | created | last review | state | diff --git a/pm-stack/README.md b/pm-stack/README.md index be95dc937f..3656a2f481 100644 --- a/pm-stack/README.md +++ b/pm-stack/README.md @@ -61,6 +61,36 @@ everything else is host-independent so the stack can move to the Kubernetes cluster later (the same values map onto a Secret + the upstream Helm chart's env). +## Sandbox posture and alignment + +The sandbox is for Muse sessions, SSH, and web browsing only. It is not a +PM-stack host: do not start or enable servers, proxies, containers, or +service timers there. PM-stack services and the fleet-feed collector run +on the laptop host `amd`; the old sandbox kill-collector timer has been +retired, and its script refuses to run unless `hostname -s` is `amd`. + +To align a sandbox checkout with the laptop's repository source, preserve +local work and fast-forward from `origin/main` (never reset or force a +checkout): + +```bash +cd ~/git/code +git status --short --branch +git fetch origin +git switch main +git merge --ff-only origin/main +git rev-parse HEAD +``` + +Compare that commit with the laptop's `git -C ~/git/code rev-parse HEAD` +using `~/tools/laptop-ssh.sh`. If the checkout has local changes or +cannot fast-forward, stop and preserve them for reconciliation; do not +reset it. Refresh repo-managed configuration from the aligned checkout, +but keep runtime deployment on the laptop: do not run `deploy.sh`, an +`install.sh`, `nixos-rebuild`, or any `systemctl enable/start` command on +the sandbox. Keep copied configuration source-aligned; do not copy +runtime state or rendered secret files as part of this alignment step. + ## GitHub Project #4 conventions The org Project **Developing Today** (#4) is the portfolio map; issues and @@ -118,7 +148,7 @@ instead). Changing `AUTH_SECRET` signs everyone out; changing `POSTGRES_PASSWORD` after first initialisation breaks the database login until the database password is changed to match. -## Bring it up (first time, on the host) +## Bring it up (first time, on laptop host `amd` only) ```bash # 1. Check out this repo (or copy this directory + ../secrets) and cd in diff --git a/pm-stack/SHARED-SCHEMA-MAP.md b/pm-stack/SHARED-SCHEMA-MAP.md index 1778949dee..bb359dae7b 100644 --- a/pm-stack/SHARED-SCHEMA-MAP.md +++ b/pm-stack/SHARED-SCHEMA-MAP.md @@ -38,7 +38,7 @@ service's current source of truth and native restore path. | `usage-snapshot-outbox.jsonl` ([producer handoff](../nixos/services/pm-stack/default.nix#L242-L244); [drain contract](aggregator/scripts/collect-fleet-feed.ts#L62-L64)) | usage writers / fleet-feed-collector | No for records not yet drained; source writers may not retain them | `shared_events` or `agg_` ingestion, final representation deferred | | `aa-last-good.json` beside the feed ([path and reuse contract](aggregator/scripts/collect-fleet-feed.ts#L401-L408)) | fleet-feed-collector | Yes as a cache; refreshed from Supabase and config when needed | `agg_` cache | | Supabase `alerts.incidents`, `alerts.incident_events`, `alerts.push_subscriptions`, `alerts.notification_sends` ([store and writes](aggregator/src/alerts.ts#L275-L310), [incident mutations](aggregator/src/alerts.ts#L340-L363), [send ledger](aggregator/src/alerts.ts#L448-L460); [schema/location](aggregator/README.md#L299-L310)) | aggregator alerts service | No; acknowledgement state, subscriptions, and delivery history are writable durable records | `agg_` alerts; `incident_events` maps to `shared_events` | -| Drill state under `~/.local/state/pm-drills/` ([default state path](aggregator/scripts/kill-collector-drill.sh#L41-L49); [unit](aggregator/systemd/kill-collector-drill.service#L1-L10)) | aggregator drill scripts | Yes; run results/locks/incident flags are operational drill artifacts | `agg_` operational, or omit from shared tables as ephemeral | +| Drill state under `~/.local/state/pm-drills/` ([default state path](aggregator/scripts/kill-collector-drill.sh#L41-L49)) | laptop-only aggregator drill script | Yes; run results/locks/incident flags are operational drill artifacts | `agg_` operational, or omit from shared tables as ephemeral | Read-only producer inputs (quota register/view, OpenChamber state, Cloudflare and Supabase exports, DNS/orchestration/charge/launch records) are not diff --git a/pm-stack/aggregator/scripts/kill-collector-drill.sh b/pm-stack/aggregator/scripts/kill-collector-drill.sh index 0c92ca2fef..76d4aaa17d 100755 --- a/pm-stack/aggregator/scripts/kill-collector-drill.sh +++ b/pm-stack/aggregator/scripts/kill-collector-drill.sh @@ -32,10 +32,9 @@ # the drill evidence (that is the drill doing its job: a silent # failure of the honesty signals is a finding, not a drill error). # -# Scheduling: systemd/kill-collector-drill.{service,timer} in this -# repo's pm-stack/aggregator/systemd/ directory (weekly, in the same -# style as fleet-feed-collector's units). The flock makes overlap -# impossible even if a manual run and the timer collide. +# The old sandbox systemd timer was retired when the collector moved to +# the laptop. This drill is laptop-only until a laptop-hosted schedule is +# deliberately installed; the host guard below also protects manual runs. # # Environment knobs: # PM_DRILL_STATE_DIR state/lock/result dir (default ~/.local/state/pm-drills) @@ -66,6 +65,12 @@ die() { exit 1 } +# The collector and aggregator now run on the laptop (amd), not on the +# sandbox. Never let a stale checkout or copied script stop a sandbox +# service by mistake. +HOST="$(hostname -s)" +[ "$HOST" = "amd" ] || die "must run on laptop host 'amd'; refusing on '$HOST'" + # --- interlock: one drill at a time --------------------------------------- exec 9>"$STATE_DIR/kill-collector.lock" if ! flock -n 9; then @@ -207,12 +212,12 @@ if [ "${PM_DRILL_NO_POST:-0}" != "1" ] && command -v gh >/dev/null 2>&1; then if [ "$OUTCOME" = "passed" ]; then gh issue comment "$ISSUE" --repo "$ISSUE_REPO" --body "✅ **Chaos drill passed — kill-collector** (queue task 2667, first slice of this issue, epic #$EPIC) -- Stopped \`$COLLECTOR_TIMER\` on the sandbox at $STARTED_AT; the aggregator's feed-age signal reached the 5-minute \`FEED_STALE_MS\` (#1148) threshold — the honesty signal fired instead of the dashboard presenting a dead feed as fine. Health payload at the signal moment was captured by the drill. +- Stopped \`$COLLECTOR_TIMER\` on laptop host amd at $STARTED_AT; the aggregator's feed-age signal reached the 5-minute \`FEED_STALE_MS\` (#1148) threshold — the honesty signal fired instead of the dashboard presenting a dead feed as fine. Health payload at the signal moment was captured by the drill. - Collector restored (timer restarted + immediate collection run) and restoration confirmed via \`/api/health\`: feed fresh again. -- Script: \`pm-stack/aggregator/scripts/kill-collector-drill.sh\` (interlocked: flock, incident-flag refusal, refuses to start on an already-stale feed; always restores via trap). Result JSON is written to \`~/.local/state/pm-drills/kill-collector-result.json\` on the sandbox per run." >/dev/null 2>&1 && +- Script: \`pm-stack/aggregator/scripts/kill-collector-drill.sh\` (interlocked: flock, incident-flag refusal, refuses to start on an already-stale feed; always restores via trap). Result JSON is written to \`~/.local/state/pm-drills/kill-collector-result.json\` on laptop host amd per run." >/dev/null 2>&1 && log "posted result comment on #$ISSUE" || log "WARN: gh comment on #$ISSUE failed" else - gh issue create --repo "$ISSUE_REPO" --title "chaos drill FINDING: kill-collector drill did not observe the expected honesty signal" --body "The kill-collector drill (first slice of #$ISSUE, epic #$EPIC) ran at $STARTED_AT and the expected signal did not complete cleanly: signal_fired=$SIGNAL, restoration_confirmed=$CONFIRMED (see \`~/.local/state/pm-drills/kill-collector-result.json\` and \`kill-collector-health-at-signal.json\` on the sandbox for the captured evidence). A dead collector presenting as 'everything is fine' is exactly what #$ISSUE exists to catch — investigate the aggregator's feed-staleness/health path (FEED_STALE_MS, src/health.ts, src/sources/live.ts) before the next drill." >/dev/null 2>&1 && + gh issue create --repo "$ISSUE_REPO" --title "chaos drill FINDING: kill-collector drill did not observe the expected honesty signal" --body "The kill-collector drill (first slice of #$ISSUE, epic #$EPIC) ran at $STARTED_AT and the expected signal did not complete cleanly: signal_fired=$SIGNAL, restoration_confirmed=$CONFIRMED (see \`~/.local/state/pm-drills/kill-collector-result.json\` and \`kill-collector-health-at-signal.json\` on laptop host amd for the captured evidence). A dead collector presenting as 'everything is fine' is exactly what #$ISSUE exists to catch — investigate the aggregator's feed-staleness/health path (FEED_STALE_MS, src/health.ts, src/sources/live.ts) before the next drill." >/dev/null 2>&1 && log "filed finding issue under epic #$EPIC" || log "WARN: gh issue create for the finding failed" fi fi diff --git a/pm-stack/aggregator/systemd/kill-collector-drill.service b/pm-stack/aggregator/systemd/kill-collector-drill.service deleted file mode 100644 index 0cc8361fb5..0000000000 --- a/pm-stack/aggregator/systemd/kill-collector-drill.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Chaos drill: kill the fleet-feed collector and verify the PM stack notices (#1283, epic #1184) -After=network.target - -[Service] -Type=oneshot -# Runs on the sandbox host, like the collector it kills. HOME is pinned -# for the same reason as fleet-feed-collector.service: the drill reads -# the aggregator health over the laptop ssh channel (~/tools) and keeps -# its state under ~/.local/state/pm-drills. -Environment=HOME=/home/hatch -ExecStart=/home/hatch/git/pm-feed/pm-stack/aggregator/scripts/kill-collector-drill.sh -# A drill that outlives its own max wait plus restore margin is stuck; -# the script's trap restores the collector on TERM. -TimeoutStartSec=45min diff --git a/pm-stack/aggregator/systemd/kill-collector-drill.timer b/pm-stack/aggregator/systemd/kill-collector-drill.timer deleted file mode 100644 index 3cc3695d88..0000000000 --- a/pm-stack/aggregator/systemd/kill-collector-drill.timer +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Weekly kill-collector chaos drill (#1283, epic #1184) - -[Timer] -# Sunday early morning, the stack's quietest window. The drill itself -# refuses to overlap (flock), refuses during a flagged incident, and -# refuses to start on an already-stale feed. -OnCalendar=Sun 04:17 -RandomizedDelaySec=15min -Persistent=false - -[Install] -WantedBy=timers.target diff --git a/pm-stack/aggregator/test/kill-collector-drill.test.ts b/pm-stack/aggregator/test/kill-collector-drill.test.ts index 25de8d1e99..fda63f7f3e 100644 --- a/pm-stack/aggregator/test/kill-collector-drill.test.ts +++ b/pm-stack/aggregator/test/kill-collector-drill.test.ts @@ -28,6 +28,7 @@ import { join } from "node:path"; const DRILL = join(import.meta.dir, "..", "scripts", "kill-collector-drill.sh"); interface Scenario { + host?: string; interruptStop?: boolean; // stub systemctl stop sends TERM to the drill, then fails timerActive: boolean; healthPlan: string[]; // per health-channel call: fresh | stale | fail @@ -51,6 +52,8 @@ function runDrill(scn: Scenario) { chmodSync(path, 0o755); }; + writeExe(join(bin, "hostname"), `#!/bin/sh\nprintf '%s\\n' "${scn.host ?? "amd"}"\n`); + writeExe( join(bin, "systemctl"), `#!/bin/sh @@ -145,6 +148,13 @@ function expectNoStart(log: string) { } describe("kill-collector drill: refusals touch nothing (#2865)", () => { + test("non-laptop host -> refuse before any systemctl call", () => { + const r = runDrill({ host: "sandbox", timerActive: true, healthPlan: ["fresh"] }); + expect(r.status).toBe(1); + expect(r.stdout).toContain("must run on laptop host 'amd'"); + expect(r.systemctlLog.trim()).toBe(""); + }); + test("collector timer inactive -> refuse, no systemctl start", () => { const r = runDrill({ timerActive: false, healthPlan: ["fresh"] }); expect(r.status).toBe(1);