Skip to content

feat(checkins): add cron and background-job monitoring - #783

Merged
unjica merged 8 commits into
developfrom
codex/cron-checkins
Oct 12, 2026
Merged

unjica merged 8 commits into
developfrom
codex/cron-checkins

Conversation

@unjica

@unjica unjica commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Scheduled jobs previously had no per-job deadline or runtime monitoring. This adds Check-ins: a missing completion, explicit failure, or timed-out run creates one outage alert; the next success creates one recovery through existing channels.

  • Interval (at least five minutes) and five-field cron schedules with IANA zones and tested DST semantics; grace and optional maximum runtime.
  • GET/POST secret URLs and recommended X-TT-Checkin-Token or Authorization: Bearer authentication on /checkin and action paths. Strict token/action validation, UUID run IDs, retry dedupe, ignored HEAD/preview bots and independent limits. Pings do not consume ingest quota.
  • Additive monitor, history, run and alert-outbox tables. Transactional row locks serialize rotation and state transitions; durable intent plus existing AlertEvent dedupe protects dispatch.
  • Retrievable AES-256-GCM secrets, indexed SHA-256 lookup, immediate rotation, owner/editor management and viewer-safe status/history. Fastify omits request headers and redacts token strings; API/dashboard Sentry remove authentication headers.
  • Trusted client-IP identity for the ping scope using the existing Railway/Cloudflare resolver. Monitor/project limits remain shared across authentication forms.
  • Existing evaluator with stale/global-gap deferral and nightly age/1,000-row retention. Free/Pro/Business caps are 5/50/500.
  • Dashboard management, history, evaluator warning, recommended header curl examples and proxy/CDN URL exposure guidance. Node withCheckIn uses headers by default for valid token URLs; tokenTransport: "url" retains path authentication.

Validation:

  • pnpm lint and full pnpm build: pass.
  • pnpm test: 1,688 passed, 175 DB-gated tests skipped, zero failures. API: 1,204; dashboard: 330; Node: 33; other SDKs and publish guards: 121.
  • Disposable Docker Postgres 16 only (localhost:55433/ci): prisma migrate deploy applies all migrations, including 20261012133000_checkin_monitors, cleanly. Full API tests with RUN_DB_INTEGRATION_TESTS=true: 1,371 passed, 8 skipped, zero failures; all 12 check-in integration tests pass. Container stopped and removed afterwards.
  • API production and Node standalone type-checks pass. Dashboard standalone type-check has six existing test-file errors (four readonly NODE_ENV assignments and two ES2018 regex flags); verified identical errors against the original HEAD snapshot. Next production type validation passes.
  • Reviewed the existing diff against origin/develop and the uncommitted hardening diff; git diff --check passes. Existing commits and develop merges preserved.

Operational notes: API needs a backed-up CHECKIN_ENCRYPTION_KEY; dashboard may need CHECKIN_PUBLIC_BASE_URL. Limits are per process. Path-token URLs remain visible to proxy/CDN logs; use header authentication to keep secrets out of request URLs. Alerts retain existing best-effort email semantics. CodeQL alert #12 clearance remains dependent on CI after runner publication; no local CodeQL CLI verification was performed.

Update existing PR #783 only, base develop, preserving its non-draft state. No merge, deploy, production data access or SDK publication. Source changes are left uncommitted for the external runner.

Migration timestamp follow-up (2026-10-12):

  • Renamed the check-in migration from 20261012120000_checkin_monitors to 20261012133000_checkin_monitors; SQL is byte-for-byte unchanged. Updated the migration safety test path; no stale repository references remain.
  • Fresh disposable Docker Postgres 16 (localhost:55434/ci): all 54 migrations deploy cleanly, with signup_funnel before checkin_monitors.
  • DB-enabled API suite: 1,383 passed, 8 skipped, zero failures across 167 passing files (one skipped). Includes checkins.integration 12/12; signup attribution route 5/5, signup attribution library 13/13, signup funnel 1/1, and ingest integration 1/1. Initial default-concurrency run had two unrelated five-second timeouts; rerun with vitest run --maxWorkers=4 passed without changing tests or timeouts.
  • pnpm lint and pnpm --filter api build (including TypeScript build check) pass; git diff --check passes.
  • Requested Prisma migration/schema drift check returns exit code 2: three legacy index-name differences and three updated_at defaults. Repeating against an exact origin/develop migration/schema snapshot reports the same six differences. No check-in drift; unrelated migrations/schema left unchanged. Therefore a globally zero-drift result remains unfulfilled due to existing develop drift.
  • Disposable container stopped and removed; no production data, merge, deployment or publication. Preserve PR feat(checkins): add cron and background-job monitoring #783 as non-draft.

unjica and others added 8 commits October 12, 2026 12:06
Add interval and timezone-aware cron monitors with encrypted secret ping URLs,
run-aware runtime deadlines, atomic outage transitions and durable alert intents.
Reuse the scheduled evaluator, existing alert channels and nightly retention;
keep pings outside ingest quota with independent monitor and project limits.

Add role-aware dashboard management, Node withCheckIn support, recipes and
unit, HTTP, privacy, migration and database integration coverage.
Validate monitor IDs with the shared strict UUID parser and encode the resource
segment before fetching. Select action suffixes from fixed literals and reject
resource actions without a monitor. Add regression coverage for valid paths,
malformed UUIDs and route-injection attempts.
Accept X-TT-Checkin-Token and Bearer authentication on the existing check-in
surface while preserving path-token URLs and shared validation/limits.
Use trusted client IPs for the ping scope and scrub the new sensitive header
from API and dashboard Sentry events. Send header pings by default in the
Node helper, with an explicit URL transport option, and document the safer
curl form in the dashboard and check-in guides.

Cover header actions, invalid tokens, no-op previews, log privacy and visitor
rate-limit identity. Verify migration and integration tests on disposable
Postgres 16 without production database access.
Rename the unapplied check-in migration to 20261012133000 so it sorts
after the deployed signup funnel migration. Preserve SQL byte-for-byte
and update the migration safety test reference.
@unjica
unjica merged commit 669b1d7 into develop Oct 12, 2026
7 checks passed
@unjica unjica mentioned this pull request Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant