Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/fleet-schedule-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
32 changes: 31 additions & 1 deletion pm-stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pm-stack/SHARED-SCHEMA-MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 12 additions & 7 deletions pm-stack/aggregator/scripts/kill-collector-drill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'"
Comment on lines +71 to +72

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Target the laptop collector's user service manager

On the documented NixOS laptop deployment, the collector is declared under systemd.user.services and systemd.user.timers in nixos/services/pm-stack/default.nix, but this now laptop-only script still uses plain systemctl is-active and sudo -n systemctl for collector operations. Those address the system manager, so the drill refuses at its inactive-timer precondition even when the laptop's collector user timer is running. Local systemctl --help confirms that --user means “Connect to user service manager.” Migrate the check, stop, and restoration commands to systemctl --user without sudo alongside this host restriction.

Useful? React with 👍 / 👎.


# --- interlock: one drill at a time ---------------------------------------
exec 9>"$STATE_DIR/kill-collector.lock"
if ! flock -n 9; then
Expand Down Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions pm-stack/aggregator/systemd/kill-collector-drill.service

This file was deleted.

13 changes: 0 additions & 13 deletions pm-stack/aggregator/systemd/kill-collector-drill.timer

This file was deleted.

10 changes: 10 additions & 0 deletions pm-stack/aggregator/test/kill-collector-drill.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Loading