Core

Operations & state

Core route table, what persists between requests, and later options for cache and rate limits.

Operations & state

Verified against current HEAD of apps/core. Line numbers cited below — re-check if the tree moves.

Route table

RouteMethodWhat it doesState touchedPersistent between requests?
/GET/HEADBrowser HTML status page when Accept includes text/html: logo (links to https://ziteox.com; plain link, no animation, no JS), title, and environment·version pill only (no health indicator, no D1 access, no JavaScript); otherwise JSON 404 not_found (Vary: Accept)Optional version id from CF_VERSION_METADATANo
/favicon.icoGET/HEADZiteox JPEG favicon (no auth)NoneNo
/healthzGETLiveness; returns ok, env, github modeNoneNo
/v1/admin/projectsPOSTCreate project (project.create; optional portal_project_id)D1 projects (+ audit)D1 yes
/v1/admin/projectsGETList / lookup projects (project.list; optional ?portal_project_id=)D1 readD1 yes
/v1/admin/projects/:keyPATCHUpdate portal link (project.update; forge_admin only)D1 projects (+ audit)D1 yes
/v1/admin/tokensPOSTIssue project token (token.issue)D1 project_tokens, token_grants (+ audit)D1 yes
/v1/admin/tokens/:id/rotatePOSTRotate token (token.rotate)D1 tokens/grants (+ audit)D1 yes
/v1/admin/tokens/:id/revokePOSTRevoke token (token.revoke)D1 project_tokens.revoked_at (+ audit)D1 yes
/v1/admin/members/:id/tokensGETList member’s tokens across projectsD1 readD1 yes
/v1/admin/secretsPOSTSeal vault secret (vault.seal)D1 vault_secrets; uses KEK secretD1 + Worker secret
/v1/admin/auditGETPer-key audit feed (audit.read; filters + cursor; role-scoped)D1 audit_events readD1 yes
/v1/whoamiGETToken + project identityMay update last_used_at on authD1 yes
/v1/filesGETRead file via GitHub adapterAuth + audit; GitHub/mockD1 audit; GH upstream
/v1/treeGETList tree via GitHub adapterAuth + audit; GitHub/mockD1 audit; GH upstream
/v1/secrets/:labelGETUnseal project secret for callerD1 vault read; KEKD1 + Worker secret
/v1/publishPOSTPublish → branch/PR via GitHub adapterAuth + audit; GitHub/mockD1 audit; GH upstream
/npm/@ziteox%2f<pkg> or /npm/@ziteox/<pkg>GETPackument proxy (exact packages:read grant; that scope is opt-in and must be issued alone)Auth; upstream GH Packages; auditD1 + upstream
/npm/download/@ziteox/...GETTarball under /npmAuth; upstream + blob host; auditD1 + upstream
/download/@ziteox/...GETRoot tarball alias (lockfile shape)Same as tarballD1 + upstream

Unknown /v1/admin/*, /v1/*, /npm/*, or /download/* → 404. Non-GET on npm/download → method error. Admin routes require Ed25519 assertion; data-plane and npm require zxcore_… Bearer.

Production note: with GITHUB_MODE=app, the GitHub App adapter is a stub — /v1/files, /v1/tree, /v1/publish fail with not_configured. Npm + admin do not need it. See Go live.

Migrations (local D1)

Schema-only under apps/core/migrations/. Notable recent:

FileWhat
0004_environments.sqlallowed_environments; token/vault/audit environment
0007_packages_read_default.sqlIdempotent append of packages:read to project ceilings
0008_portal_project_id.sqlNullable unique projects.portal_project_id (portal ↔ Core link)
0009_audit_indexes.sqlAudit indexes: (token_id, id), (project_id, id), (actor_user_id, id), (action, id)

State inventory

StoreContents
D1projects (incl. optional portal_project_id), project_tokens (incl. last_used_at), token_grants, staff_roles, assertion_jti, vault_secrets, audit_events, plus local-only mock_github_*
Worker secrets / varsKEK (CORE_SECRETS_KEK), assertion public keys, upstream CORE_GITHUB_PACKAGES_TOKEN, issuer / CORE_PUBLIC_URL / GITHUB_MODE, etc.
Vault cryptoAES-GCM envelopes; KEK from secret; ciphertext in D1
GitHubMock tables in D1 (local) or App stub (production until wired)
npm upstreamGitHub Packages registry + blob host (pkg-npm.githubusercontent.com); Core does not cache today

last_used_at is written on successful project-token auth (apps/core/src/lib/auth-project.ts), throttled to ~once per 5 minutes.

Statelessness finding

Module-level values are only constant Sets / regexes / numbers — no mutable caches, counters, timers, or globals:

FileWhatLines (HEAD)
lib/assertion.tsADMIN_ONLY / OPERATOR_OK Sets; TTL/skew constants~L40–50
lib/audit.tsFORBIDDEN_META_KEYS Set~L17
lib/environments.tsENV_SET~L13
lib/scopes.tsPATH_SCOPE_RE (path scopes); packages:read exclusive check~L18 / exclusivity helper
lib/tokens.tsTOKEN_* prefix/regex constants~L7–10
routes/npm.tsPath regexes + redirect/timeout constants only~L15–28

The Map in routes/admin.ts (~L593) is created inside adminListMemberTokens (~L534) — per request, discarded after the response.

routes/npm.ts holds nothing between requests (no module Map/cache). So everything is stateless except D1 (plus Worker secrets/vars).

jti replay protection

Lives in D1 assertion_jti. Since pass 9 it is atomic: INSERT … ON CONFLICT(jti) DO NOTHING, then check changes; prune expired rows on the same write batch (DELETE FROM assertion_jti WHERE exp < ?) — see apps/core/src/lib/assertion.ts ~L169–188. Replay → 401 assertion_replay.

Workers-native

The npm proxy uses only fetch / Web Streams / WebCrypto. Tarball bodies are streamed; no Node APIs in the Worker path.

Later options (not at launch)

Package cache

OptionNotes
Cache APIPer-colo, free, key by tarball path. Immutable tarballs are safe to cache. Must cache after auth check; never cache packuments long; no cross-colo.
R2Global durable store; needs R2 binding + bucket + write-through on first fetch; pennies at this size; survives GitHub outage.

Rate limiting

OptionNotes
Workers Rate Limiting binding[[unsafe.bindings]] / ratelimits config; per-key e.g. token_id; eventually consistent; cheap.
Durable Object counterExact per-token; more code + DO billing.

Recommend: none needed at launch. Add Cache API for tarballs first if latency/upstream cost matters; add Rate Limiting binding keyed by token_id if abuse appears.