| 1 | # Deploy: wrangler d1 create reasonix-crash → paste database_id → wrangler deploy. |
| 2 | name = "reasonix-crash-report" |
| 3 | main = "src/index.ts" |
| 4 | compatibility_date = "2026-06-01" |
| 5 | |
| 6 | routes = [{ pattern = "crash.reasonix.io", custom_domain = true }] |
| 7 | |
| 8 | # First entry: daily retention purge (03:47 Beijing) — drops time-series rows |
| 9 | # past the dashboard's query horizon so the D1 database plateaus instead of |
| 10 | # hitting the size cap and failing every ingest write (purgeExpiredStatsRows). |
| 11 | # Second entry: ingest sentinel four times a day (runIngestSentinel) — canary |
| 12 | # write + checkpointed ping growth; alerts via the optional ALERT_WEBHOOK worker |
| 13 | # secret, log-only when unset. The secret is mirrored from the GitHub repo |
| 14 | # secret of the same name by deploy-crash-worker.yml on every deploy — set it |
| 15 | # under repo Settings → Secrets → Actions, no Cloudflare login needed. The |
| 16 | # sentinel expression must stay in sync with SENTINEL_CRON in src/index.ts. |
| 17 | # Third entry: hourly metric_user rollup (refreshMetricUserRollup) — the |
| 18 | # preferences module reads it instead of a 30-day query D1 will not finish. Each |
| 19 | # run advances a cursor through the signal list, so a full pass takes several |
| 20 | # hours. Must stay in sync with ROLLUP_CRON in src/index.ts. |
| 21 | [triggers] |
| 22 | crons = ["47 19 * * *", "17 1,7,13,19 * * *", "23 * * * *"] |
| 23 | |
| 24 | [vars] |
| 25 | # Emails force-promoted to dashboard admin — the owner is never locked out even |
| 26 | # if the role migration misses them. |
| 27 | ADMIN_EMAILS = "359807859@qq.com" |
| 28 | # Shared identity service (resolves the session) and the site hosting its login |
| 29 | # page. Override for local dev. |
| 30 | ID_ORIGIN = "https://id.reasonix.io" |
| 31 | APP_ORIGIN = "https://reasonix.io" |
| 32 | # Browsers allowed to call the folded registry API with credentials. |
| 33 | ALLOWED_ORIGINS = "https://reasonix.io,https://www.reasonix.io" |
| 34 | |
| 35 | [[d1_databases]] |
| 36 | binding = "DB" |
| 37 | database_name = "reasonix-crash" |
| 38 | database_id = "54825184-366f-4877-80fc-924efab0239b" |
| 39 | |
| 40 | # Skill/MCP registry data plane, folded in from the standalone worker. Before |
| 41 | # merging (the crash worker auto-deploys on push to main-v2): |
| 42 | # wrangler d1 create reasonix-registry # paste the id below |
| 43 | # wrangler d1 execute reasonix-registry --remote --file=registry-schema.sql |
| 44 | [[d1_databases]] |
| 45 | binding = "REGISTRY_DB" |
| 46 | database_name = "reasonix-registry" |
| 47 | database_id = "83786761-5cc5-487d-8624-5cf565d1a57c" |
| 48 | |
| 49 | [[unsafe.bindings]] |
| 50 | name = "RATE_LIMITER" |
| 51 | type = "ratelimit" |
| 52 | namespace_id = "1001" |
| 53 | simple = { limit = 5, period = 60 } |
| 54 | |
| 55 | # Looser than RATE_LIMITER: many installs can share one office/campus NAT IP. |
| 56 | [[unsafe.bindings]] |
| 57 | name = "PING_LIMITER" |
| 58 | type = "ratelimit" |
| 59 | namespace_id = "1002" |
| 60 | simple = { limit = 30, period = 60 } |
| 61 | |
| 62 | # Opt-in metrics flush fires once per launch like the ping; its own bucket so it |
| 63 | # never eats the ping budget on a shared NAT IP. |
| 64 | [[unsafe.bindings]] |
| 65 | name = "METRICS_LIMITER" |
| 66 | type = "ratelimit" |
| 67 | namespace_id = "1003" |
| 68 | simple = { limit = 30, period = 60 } |
| 69 | |
| 70 | # Per-IP throttle for registry writes (publish / install-ping / star). |
| 71 | [[unsafe.bindings]] |
| 72 | name = "WRITE_LIMITER" |
| 73 | type = "ratelimit" |
| 74 | namespace_id = "3001" |
| 75 | simple = { limit = 30, period = 60 } |
| 76 |