> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tuturuuu.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EduFest on-call sentinel

> The Cron Control job that watches the EduFest hall on event day, alerts Mira and the owner, and runs bounded automatic recovery, with its SLOs, guards, runbooks and game-day drills.

On event day Mira is the on-call operator for the EduFest hall
(`showcase.ieeai.net/edufest`). The `edufest-sentinel` job in
[Cron Control](https://docs.tuturuuu.com/build/devops/cloudflare-cron-control.md) reads hall health every
minute, turns SLO breaches into incidents, routes alerts, and runs bounded
automatic recovery. Mira handles every alert with the
`tuturuuu-edufest-oncall` skill (`plugins/tuturuuu/skills/tuturuuu-edufest-oncall`),
which has one runbook per scenario.

| Part | Where |
| - | - |
| Detection, incidents, alert routing, recovery planning, drills | `packages/edufest-ops` (framework-free, pure) |
| Cron Control job and its network edges | `apps/cron-control/src/processors/edufest-sentinel` |
| Runbooks and control commands | `plugins/tuturuuu/skills/tuturuuu-edufest-oncall` |

## Health contract

The hall serves `GET /api/obs/health` (bearer `EDUFEST_SENTINEL_OBS_TOKEN`,
JSON, at most 64 KiB, no personal data). Every section is optional; a missing
section leaves its incidents firing for alerting and provides no recovery authorization.
The producer supplies a strictly increasing sequence across deployments and stamps
each new observation with its server time. The sentinel rejects malformed reads,
sequences it has applied, and timestamps more than 45 seconds from its own clock.

| Section | Fields |
| - | - |
| top level | `at` (Unix milliseconds), `sequence` (nonnegative integer), `eventOpen` |
| `worker` | `requests5m`, `errors5m`, `p95Ms`, `versionId`, `versionSince` |
| `shards[]` | `id`, `connections`, `capacity`, `lastHeartbeatAt` (at most 512) |
| `voting` | `active`, `ballotsAccepted` (monotonic), `tallyVersion` (monotonic), `votes5m`, `maxQrNetworkVotes5m` |
| `ingress` | `requests1m`, `joins1m` |
| `movement` | `teleports1m`, `online` |
| `transcribe` | `usedSeconds`, `quotaSeconds` |
| `screen` | `expected`, `connected` |
| `admin` | `ok`, `latencyMs` |

The Hall and Mira desk implement the [receiver contracts](https://docs.tuturuuu.com/build/devops/edufest-receivers.md).

## SLOs

| Scenario | Warn | Critical |
| - | - | - |
| `worker-error-spike` | 5xx ≥ 2% of ≥ 200 requests in 5 min | ≥ 5% |
| `bad-deploy` | — | critical error rate within 30 min of a version change |
| `worker-latency` | p95 > 800 ms | > 2 s |
| `shard-dead` | — | heartbeat older than 90 s during the event |
| `shard-saturated` | ≥ 85% of capacity | ≥ 95% |
| `mass-disconnect` | −30% against the last two reads (≥ 50 connections) | −50% |
| `vote-tally-stuck` | ballots rising, tally unchanged 2 min (voting period) | 3 min |
| `vote-rate-anomaly` | votes/5 min ≥ 3× baseline (≥ 50) | ≥ 6×, or one QR network ≥ 50% of ≥ 30 votes |
| `flood` | requests or joins/min ≥ 3× baseline (floors 600 / 100) | ≥ 6× |
| `movement-anomaly` | > 2 teleports per online player per min (≥ 10 online) | > 6 |
| `transcribe-quota` | 70% used, or projected to run out before the event ends | 90% used and still burning |
| `screen-drop` | fewer screens than expected | fewer than half, or none |
| `admin-down` | one failed probe, or slower than 3 s | two failed probes in a row |
| `sentinel-blind` | — | two failed health reads in a row |
| `alert-channel-down` | two failed deliveries to `owner` or `whatsapp` | two failed deliveries to `mira` |

Rate baselines are EWMAs that learn only from calm reads, so a sustained
flood never becomes the new normal. An incident fires after two warn reads or
one critical read, escalates once to critical, and resolves after three clean
reads in a row, so a signal hovering at a threshold alerts once.

## Alerts

| Sink | Gets | Limit | Delivery |
| - | - | - | - |
| `mira` | every alert | 20 per 10 min | signed webhook to `EDUFEST_SENTINEL_MIRA_WEBHOOK_URL` |
| `owner` | critical and its resolve | 6 per 10 min | `private.send_root_operator_alert` (`view_infrastructure`), when `EDUFEST_SENTINEL_OWNER_ALERTS=1` |
| `whatsapp` | critical | 5 per hour | the same Mira webhook with `channel: "whatsapp"`; Mira's desk owns the provider call |

* **Dedupe:** each message id is delivered at most once per sink (12 hours).
* **Storm:** more than four new incidents in one tick collapse into one storm
  alert.
* **Rate limit:** a critical alert over the limit waits in the outbox; anything
  else is counted and folded into one digest when capacity returns.
* **Retries:** a failed delivery retries on the next ticks, at most three
  attempts.
* **Signature:** `X-Edufest-Signature` is the hex HMAC-SHA256 of
  `${X-Edufest-Timestamp}.${body}` with `EDUFEST_SENTINEL_MIRA_WEBHOOK_SECRET`
  (at least 32 characters). The receiver rejects stale timestamps and
  deduplicates on `Idempotency-Key`.

## Automatic recovery

| Scenario (critical only) | Action | Reverts |
| - | - | - |
| `shard-dead` | `shard.restart` | No automatic revert. Follow the [attendee rejoin procedure](#help-attendees-rejoin-after-a-shard-restart). |
| `flood` | `ratelimit.tighten` (factor 0.5) | after 15 min once resolved, at the latest after 60 min |
| `bad-deploy` | `worker.rollback` to `EDUFEST_SENTINEL_ROLLBACK_VERSION_ID` after two critical reads | never automatically; rolling forward is a release |

A new action requires a fresh critical observation of the affected service in
the current tick. Rollback uses the sentinel clock for deployment age.
Recovery stops starting new actions at the configured event end.

1. Writes persist before dispatch. The sentinel confirms each effect before
   adding a temporary action to active cleanup or starting effectiveness checks.
2. Reverts retain their original key until confirmed. After three attempts,
   the sentinel keeps the unresolved item and alerts the owner.
3. Reverts are exempt from the action enable list so existing leases can be
   cleaned up. Act mode and the human hold still apply.

The sentinel also enforces these operational guards.

1. **Mode** `EDUFEST_SENTINEL_MODE`: `observe` (default; alerts only),
   `dry-run` (plans and audits, executes nothing) or `act`.
2. **Human hold:** the store key `edufest:sentinel:hold`
   (`{ by, reason, until }`) blocks actions and reverts; alerts continue.
   The sentinel checks the hold again after the ledger fence and starts the request
   in that same continuation. An unreadable hold blocks dispatch.
   A hold cannot cancel a Hall or Cloudflare request whose fetch has already
   started. After placing a hold, check the sentinel log or ledger for an
   in-flight dispatch and, if one is present, verify or revert its effect manually.
3. **Enable list** `EDUFEST_SENTINEL_ACTIONS` (comma-separated kinds).
4. **Circuit breaker:** an action that failed, or whose incident is still
   critical three minutes later, counts once; two open the breaker for that
   kind until a human writes it to `edufest:sentinel:reset-breakers`. A rollback
   breaker re-arm requires explicit owner confirmation. The reset is consumed
   only after the sentinel state compare-and-set succeeds.
5. **Cooldown:** five minutes per kind and subject.
6. **Limit:** three shard actions, two rate-limit or kill-switch actions per
   30 minutes; one rollback per day.

### Reconcile an in-flight dispatch

Keep the hold in place while you reconcile. Match the active slot or most
recent run in the Cron Control ledger to `lastSlot` in
`edufest:sentinel:state`. Check all three recovery collections:

* `recovery.pending`: an entry with `attempts > 0` may have reached the receiver.
* `recovery.active[].revertAttempts`: a nonzero value means a revert was
  attempted. Look up the original action ID with the `:revert` suffix in
  the Hall audit and confirm whether it released the lease.
* `recovery.audit`: check this window for completed actions and reverts,
  including entries that have already left `recovery.pending`.

An empty `recovery.pending` list is not evidence that nothing reached a receiver.
For a pending or active record, use the request ID, action kind, subject,
and any stored parameters to check the Hall audit or Cloudflare deployment
history. For an audit-only record, correlate using only its request ID
(`id`), action kind (`kind`), and subject (`subject`). The request parameters
cannot be recovered from `recovery.audit` alone. Obtain them from the
matching receiver record if a manual change requires them.

#### Read-only fallback for the installed CLI

TTR 0.33.0 reports `Unknown help topic: edufest`. Until your installed
`ttr help edufest` lists `recover` and `ops`, use these read-only calls.
Set the origins and credentials from approved operator configuration.
The health origin includes the Hall base path, such as `/edufest`.
The Mastermind POST contains only an `mget` operation.

```bash theme={null}
printf 'Authorization: Bearer %s\n' "$CRON_CONTROL_OPERATOR_TOKEN" |
  curl -fsS --max-time 4 -H @- "${CRON_CONTROL_ORIGIN%/}/control/jobs"

printf 'Authorization: Bearer %s\n' "$MASTERMIND_STORE_TOKEN" |
  curl -fsS --max-time 4 -H @- -H 'Content-Type: application/json' \
    --data '{"v":1,"ops":[{"op":"mget","ks":["edufest:sentinel:state"]}]}' \
    "${MASTERMIND_STORE_URL%/}/v1/ops"

printf 'Authorization: Bearer %s\n' "$EDUFEST_SENTINEL_OBS_TOKEN" |
  curl -fsS --max-time 4 -H @- "${EDUFEST_SENTINEL_HALL_ORIGIN%/}/api/obs/health"

printf 'Authorization: Bearer %s\n' "$EDUFEST_SENTINEL_CF_DEPLOY_TOKEN" |
  curl -fsS --max-time 4 -H @- \
    "https://api.cloudflare.com/client/v4/accounts/${EDUFEST_SENTINEL_CF_ACCOUNT_ID}/workers/scripts/${EDUFEST_SENTINEL_CF_SCRIPT}/deployments"
```

If the CLI commands below are unavailable, ask the Hall owner to reconcile
limit and switch changes using the Hall operator controls and audit.
Use the existing Cloudflare release workflow for deployment changes. Every
manual rollback still requires explicit owner confirmation. When the CLI
commands are available, use `--confirm-production` and
`--reason "<incident and action ID>"` for production mutations, and add
`--yes` for destructive commands.

#### Help attendees rejoin after a shard restart

Hall health reports shard IDs, connections, capacity, and heartbeats
(`packages/edufest-ops/src/snapshot.ts:7`). The documented read-only
interfaces expose neither a room-to-shard mapping nor room join links.
Use health to verify the restarted shard and the organiser to recover the
attendee link.

1. Ask the room host to open the original attendee join link in an attendee
   session and confirm that it opens the intended room.
2. Once the host confirms it opens, have the organiser re-share the original
   link through the event's existing attendee channel.
3. If the link fails, keep the hold in place and escalate to the Hall owner
   with the shard ID and latest heartbeat.

| Action | Verify the effect | Revert or mitigate manually |
| - | - | - |
| `shard.restart` | Match the request ID in the Hall audit. Check the target shard for a heartbeat under 90 seconds and recovering connections. Hall health shows capacity at the shard level only. | A completed restart has no inverse. For rooms affected by a restart, follow the [attendee rejoin procedure](#help-attendees-rejoin-after-a-shard-restart). Check shard health again before releasing the hold. |
| `ratelimit.tighten` | Match the request ID to the Hall audit and compare the effective limits and lease expiry with the pre-action values. Check joins and error rate. | To undo the tighten, restore each affected limit with `ttr edufest ops limits <key> <pre-action-value>`. Use `default` only if the pre-action value was the default. If an in-flight revert released a limit that is still needed, restore the intended incident value instead. Preserve newer operator settings and verify the effective limits and traffic again. |
| `killswitch.flip` | For a pending feature action, match the request ID and feature in the Hall audit and verify its effective state in the Hall. A kill switch set to `on` disables the feature. | Restore its pre-action state with `ttr edufest ops kill <feature> on\|off`, preserving any newer operator setting. Obtain explicit owner confirmation before resuming voting. Verify the feature's effective state again. |
| `worker.rollback` | Match the request ID to the Cloudflare deployment annotation `edufest-sentinel rollback <request-id>`. Read the latest Cloudflare deployment with the request above and check that its `versions` contains only the pinned version at 100%. Check that 5xx stays below 2% for three reads. | If traffic needs to move again, capture the current version and mix and obtain explicit owner confirmation for the known-good target. Use `ttr edufest recover rollback <owner-approved-version-id>` for a manual rollback. Use the normal release process for a forward deployment. Verify the version, traffic mix, and error rate again. |

Record the verified outcome and any manual change in the incident before
releasing the hold.

## Cost and stop evidence

* One hall read, three Mastermind store calls (read, write-ahead, settle) and
  at most three actions and eight deliveries per tick; each call has a
  4-second timeout and no redirects. Response bodies are streamed with caps of
  64 KiB for health and Cloudflare deployment responses and 16 KiB for Hall actions. Each action adds two state writes and two hold reads. Calls stop six seconds before the
  25-second deadline, so the settle write always has time.
* One attempt per slot and a 55-second lease, inside the one-minute cadence.
* **Idempotent progress:** the planned state, including the slot, is written
  with compare-and-set before any side effect. A retried or concurrent run of
  the same slot is a no-op, and a lost settle write leaves undelivered alerts
  in the outbox and recovery intents available for reconciliation with the same keys.
* **Stop fence:** checked before the store read and before every action and
  delivery. `POST /control/jobs/edufest-sentinel/stop` (operator token) stops
  the job; `/resume` continues from the stored state.
* The job is off until `edufest-sentinel` is in `CRON_CONTROL_ENABLED_JOBS`.
  Enable it for the event window with `observe` first, then `act` after the
  rehearsal. Once the event ends plus one hour of grace, the processor
  dispatcher skips the job before claiming a ledger slot. Four consecutive unhealthy ticks
  or exhausted recovery attempts report a failed run to Cron Control and
  trigger a deduplicated owner alert.

## Configuration

| Name | Kind | Purpose |
| - | - | - |
| `MASTERMIND_STORE_URL`, `MASTERMIND_STORE_TOKEN` | existing | sentinel state, hold and breaker reset keys |
| `EDUFEST_SENTINEL_HALL_ORIGIN` | variable | hall origin (HTTPS) |
| `EDUFEST_SENTINEL_OBS_TOKEN` | secret | health read |
| `EDUFEST_SENTINEL_OPS_SECRET` | secret | 32-byte base64url Hall HMAC key |
| `EDUFEST_SENTINEL_MODE`, `EDUFEST_SENTINEL_ACTIONS` | variable | recovery mode and enable list |
| `EDUFEST_SENTINEL_ROLLBACK_VERSION_ID` | variable | last known good hall Worker version |
| `EDUFEST_SENTINEL_CF_ACCOUNT_ID`, `EDUFEST_SENTINEL_CF_SCRIPT` | variable | hall Worker for rollback |
| `EDUFEST_SENTINEL_CF_DEPLOY_TOKEN` | secret | Workers deployments only, scoped to the hall Worker |
| `EDUFEST_SENTINEL_MIRA_WEBHOOK_URL`, `EDUFEST_SENTINEL_MIRA_WEBHOOK_SECRET` | variable, secret | Mira desk webhook |
| `EDUFEST_SENTINEL_OWNER_ALERTS` | variable | `1` sends owner alerts |
| `EDUFEST_SENTINEL_EVENT_END` | variable | Required ISO event end for quota projection and the job cutoff |

## Game-day drills

Two suites inject every scenario and assert the result:

* `packages/edufest-ops/src/drill.test.ts` runs the pure sentinel against the
  simulated rehearsal hall on a virtual one-minute clock: an hour of a healthy
  hall sends nothing; every scenario is detected within two minutes (three for
  warn-level signals), Mira is alerted in the same tick with its runbook,
  recovery (automatic or a runbook fix three minutes after the alert) lands
  within ten minutes, the incident resolves, and it fires exactly once. It
  also covers the breaker opening on a stubborn fault, observe mode, a human
  hold, rate-limit revert and slot replay.
* `apps/cron-control/src/edufest-sentinel.test.ts` runs the real Cron Control
  dispatch against a local rehearsal stack (hall, hall ops endpoint,
  Mastermind store, signed Mira webhook, operator alert RPC and Cloudflare
  deployments API in one fetch): auto-recovery per action kind, rollback to
  the pinned version once, a stuck tally that never triggers an action, a blind
  sentinel, the operator stop fence and resume, the hold and breaker reset
  keys, a failing owner channel and the request budget per tick.

Run them with `bun run test` in each package. Before the event, repeat the
drills against the staged hall: set `EDUFEST_SENTINEL_HALL_ORIGIN` to the
rehearsal hall, the Mira webhook to a test sink, and leave
`EDUFEST_SENTINEL_OWNER_ALERTS` unset so no owner alert is sent.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.