Swamp Watch
@magistr/swamp-watchv2026.08.21.1
01README
Per-workflow observability for a swamp repo's own scheduled work.
swamp serve's scheduler is only observable in aggregate: "did ANY scheduled workflow fire recently" is satisfied forever by one chatty two-minute workflow, so a workflow that dies — or was never deployed at all — produces no signal.
Model:
@magistr/swamp-watch— reads what a repo DECLARES (trigger.schedule) and what actually HAPPENED (run history), and emits Prometheus exposition for@magistr/victoriametricspush. Methods:scan(per-workflow expected period, staleness budget and last success) anddrift(which declared workflows a server is actually missing).
Staleness budgets are derived from the LONGEST gap a cron can produce, not
its average, so an unevenly spaced schedule like 0 9,20 * * * does not
alert every night.
02Release Notes
2026.08.21.1 — first release
Initial model. Makes a swamp repo's own scheduled work observable per workflow rather than in aggregate.
scan— reads every workflow declaring atrigger.scheduleplus each one's run history in a single execution, and emits nine metric families as Prometheus exposition for@magistr/victoriametricspush.drift— probes aswamp servefor every workflow the repo declares and reports which are missing, separating genuine absence from a failed probe.
Design decisions worth keeping:
- Budgets come from the longest legal gap, not the average.
0 9,20 * * *fires twice daily but can go 13h between fires; a 12h budget pages nightly. - Day-of-month and day-of-week are ORed when both are restricted, per
Vixie-cron. ANDing them makes
0 0 1 * 0look monthly and inflates its budget roughly thirtyfold. - No last-success state is kept. swamp retains run history for about a day,
so a weekly workflow's last success is already evicted. Each scan pushes what
it can see (
0for none) and the alert reads it back withmax_over_time, making the time-series database the memory. - A per-workflow observation timestamp is emitted so the alert can require "we have been watching longer than the budget". Without it every weekly and monthly schedule pages the moment the model is switched on — verified against live data: the un-guarded rule matched four workflows, three of them healthy.
- History is read per workflow, by name. The global history response is capped, and a two-minute workflow emits enough records to evict every daily and weekly run from the window.
- A failed history read does not drop the workflow from the scan. Dropping it would take its series with it and silence the alert this model exists to raise.
- Only "not found" counts as drift. Auth failures and timeouts are the probe breaking; reporting those as missing manufactures a deploy-drift alert out of a flaky connection. Non-404 failures are retried once with backoff, and a 404 is not retried — retrying it doubles load on a server already refusing.
03Models
@magistr/swamp-watchv2026.08.21.1extensions/models/swamp_watch.ts
Global Arguments
| Argument | Type | Description |
|---|---|---|
| repoDir | string | Repository directory to read declared workflows from |
| repoLabel | string | Value of the `repo` label on every emitted series (e.g. mac, serve) |
| swampBinary | string | Path to the swamp CLI |
| server? | string | swamp serve URL to read run history from; omit to read the local repo |
| token? | string | Server token in <name>.<secret> form, used only with `server` |
| graceFactor | number | Extra staleness budget as a fraction of the schedule's longest gap |
| minGraceSeconds | number | Floor on the extra staleness budget, in seconds |
| budgetOverrides | record | Per-workflow staleness budget in seconds, overriding the cron-derived one. For workflows whose failures are usually an upstream outage rather than a fault worth paging about. |
| timeoutMs | number | Per-CLI-call timeout in milliseconds (0 disables) |
| concurrency | number | Concurrent server probes during drift; this server refuses auth well before a dozen |
| retryBackoffMs | number | Pause before re-probing a workflow whose first probe failed for a non-404 reason |
Resources
scan(infinite)— Per-workflow declared schedule and last-success state, with Prometheus exposition
drift(infinite)— Which declared workflows the server actually has, with Prometheus exposition
04Stats
A
100 / 100
Downloads
0
Archive size
25.5 KB
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License declared1/1earned
- Verified public repository2/2earned
Repository
https://github.com/umag/swamp-workspace05Platforms
06Labels