Riot Services
Service Loop
- Use
riot-contributorfirst for repo workflow, dirty-worktree handling, and validation expectations. - Work from the specific site/service directory; every service owns its own
package.json,bun.lock,tsconfig.json, and usuallywrangler.toml. - Use
bun run <script>instead of invoking tools directly when a script exists. - Preserve per-service lockfiles. Do not add a repo-root JS workspace unless explicitly asked.
- Treat deploys, remote migrations, live e2e tests, token changes, DNS changes, and production data changes as explicit-user-approval operations.
- Prefer local checks and fakes first; live tests are opt-in through service-specific env vars.
Service Map
sites/api.pkgs.ml: package registry control-plane Worker. Owns publish/auth/search/views/events, D1 migrations, Drizzle schema, R2 storage keys, queues, Durable Object publication coordination, and D1 backup workflow.sites/cdn.pkgs.ml: CDN Worker over package artifacts, sparse index documents, Riot/OCaml binary metadata, and access analytics. Reuses registry types/storage helpers from../api.pkgs.ml/src.sites/docs.pkgs.ml: generated package-docs service. Serves docs from R2, consumes package-published/processing queues, records pipeline runs/events in registry D1, and uses Cloudflare Sandbox containers for docs/build verification.sites/pkgs.ml: public package registry web app, Astro + Cloudflare adapter + React islands. Reads registry view APIs and sparse index documents.sites/riot.ml: main static Riot website, Astro + Tailwind, Pages-style deploy.sites/get.riot.ml: install-script redirect/proxy Worker.
Cloudflare Tooling
- Use Wrangler for Worker/Astro service lifecycle:
wrangler dev,wrangler deploy,wrangler d1 migrations apply,wrangler pages deploy,wrangler types, and config-driven local development. - Keep the service-local
wranglerdependency current and pinned by lockfile rather than relying on a global install. - Use the unified
cfCLI only for API/resource inspection or operations it currently exposes, especially account, zone, DNS, D1 API, R2 API, queues API, workers API metadata, and schema discovery. - Before using
cffor real Cloudflare mutations, runnpx cf auth whoamiand inspect command shape withnpx cf agent-context <product>ornpx cf schema <command...>. - Do not replace Wrangler deploy/dev/migration scripts with
cfunless the service-specific command has been verified locally and supports the same config-driven behavior.
Config And Bindings
- Keep
wrangler.toml, exportedEnvTypeScript interfaces, and test fake environments in sync. - Prefer explicit
Envinterfaces in Worker entrypoints and shared modules. - Put non-secret defaults in
[vars]; keep secrets in.env, Wrangler secrets, or Cloudflare-managed secrets. - For D1 schema changes in
api.pkgs.ml, add SQL migrations undersites/api.pkgs.ml/migrations/and updatesrc/schema.ts/DB helpers together. - Runtime D1 access goes through Drizzle helpers in
api.pkgs.ml/src/db.ts,metadata-db.ts,pipeline-db.ts,access-db.ts, or a narrowly named sibling. - R2 object key contracts live in
api.pkgs.ml/src/storage.ts; update CDN/API/web consumers and tests together when changing keys. - Registry event payload shape is user-facing service history. Add new event types to
api.pkgs.ml/src/types.ts, DB serialization, views, and tests.
Testing
- Run the changed service's
bun run checkbefore finishing. - Run
bun run testwhen the service defines local tests. - Do not run
bun run deploy,bun run migrate:remote, or livetest:e2eunless explicitly requested. - For
api.pkgs.ml, local tests useFakeR2Bucket,FakeD1Database,FakeQueue, andFakeExecutionContextfromtests/helpers.ts. - For
cdn.pkgs.ml, reuse registry test fakes instead of inventing Cloudflare SDK mocks. - For
docs.pkgs.ml, prefer fake pipeline executors and queue drain helpers; assert durable ordering by database sequence when testing event streams. - For Astro services, run
bun run check; expect Astro to regenerate.astrotype files as part of checking.
Web Work
- Match each service's existing UI stack.
pkgs.mluses Astro server output, React islands, Tailwind, and Cloudflare adapter;docs*.mluse Starlight where applicable;riot.mlis a static Astro site. - Keep first screens as actual product/service surfaces, not marketing placeholders.
- Use existing components, layouts, CSS tokens, fonts, and route conventions before adding abstractions.
- For registry web changes, prefer registry view APIs in
sites/pkgs.ml/src/lib/web-views.tsand sparse index helpers inpackage-index.ts.
Operational Safety
- Treat production endpoints as real:
api.pkgs.ml,registry.pkgs.ml,cdn.pkgs.ml,pkgs.ml,docs.pkgs.ml,docs.riot.ml,play.riot.ml,riot.ml, andget.riot.ml. - Never run remote D1 restore/export/import, DNS writes, route/domain writes, deploys, or token operations without explicit user direction.
- If a live smoke test is requested, read that service README/env gates first and state which env vars make the test destructive or authenticated.