D1 Schema
The cube-ledger D1 database is shared between the gate worker and ledger worker.
Tables
Section titled “Tables”site_tokens
Section titled “site_tokens”Token records. Primary key: token_hash.
site_sections
Section titled “site_sections”Section metadata. Maps section keys to display names and descriptions.
site_persons
Section titled “site_persons”Person records. Links token holders to identities for TOTP enrollment.
totp_enrollments
Section titled “totp_enrollments”TOTP state: secret, verified status, recovery codes.
totp_sessions
Section titled “totp_sessions”Active TOTP sessions (24h TTL). Keyed by session ID stored in cc_sid cookie.
auth_pheromones
Section titled “auth_pheromones”Security escalation markers. Time-limited TOTP enforcement.
feedback
Section titled “feedback”User feedback submissions. Indexed by page and creation time.
access_events
Section titled “access_events”Audit log of section access attempts. Non-blocking write via ctx.waitUntil.
analytics_daily
Section titled “analytics_daily”Aggregated daily metrics. Populated by nightly cron job.