@secondlayer/shared 15.6.1 → 17.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/src/archive/range-digest.d.ts +2 -36
  2. package/dist/src/archive/semantic-digest-builder.d.ts +2 -36
  3. package/dist/src/classify/index.js +1 -4
  4. package/dist/src/classify/index.js.map +3 -3
  5. package/dist/src/coverage/index.d.ts +2 -36
  6. package/dist/src/crypto/secondlayer-webhook.js +1 -4
  7. package/dist/src/crypto/secondlayer-webhook.js.map +3 -3
  8. package/dist/src/db/index.d.ts +8 -152
  9. package/dist/src/db/index.js +3 -70
  10. package/dist/src/db/index.js.map +6 -6
  11. package/dist/src/db/queries/chain-reorgs.d.ts +2 -36
  12. package/dist/src/db/queries/chain-reorgs.js +3 -70
  13. package/dist/src/db/queries/chain-reorgs.js.map +6 -6
  14. package/dist/src/db/queries/contracts.d.ts +2 -36
  15. package/dist/src/db/queries/contracts.js.map +2 -2
  16. package/dist/src/db/queries/instance.d.ts +2 -36
  17. package/dist/src/db/queries/instance.js +1 -4
  18. package/dist/src/db/queries/instance.js.map +3 -3
  19. package/dist/src/db/queries/integrity.d.ts +2 -36
  20. package/dist/src/db/queries/integrity.js +1 -4
  21. package/dist/src/db/queries/integrity.js.map +3 -3
  22. package/dist/src/db/queries/subgraph-gaps.d.ts +2 -36
  23. package/dist/src/db/queries/subgraph-operations.d.ts +2 -36
  24. package/dist/src/db/queries/subgraphs.d.ts +2 -36
  25. package/dist/src/db/queries/sync-scope.d.ts +2 -36
  26. package/dist/src/db/queries/webhook-replays.d.ts +2 -36
  27. package/dist/src/db/queries/webhooks.d.ts +2 -36
  28. package/dist/src/db/schema.d.ts +3 -37
  29. package/dist/src/db/schema.js.map +2 -2
  30. package/dist/src/email/index.js +1 -4
  31. package/dist/src/email/index.js.map +3 -3
  32. package/dist/src/env.d.ts +2 -8
  33. package/dist/src/env.js +1 -5
  34. package/dist/src/env.js.map +3 -3
  35. package/dist/src/index-http.d.ts +1 -0
  36. package/dist/src/index-http.js.map +2 -2
  37. package/dist/src/index.d.ts +13 -164
  38. package/dist/src/index.js +6 -81
  39. package/dist/src/index.js.map +8 -8
  40. package/dist/src/insights/index.d.ts +2 -36
  41. package/dist/src/insights/index.js +1 -4
  42. package/dist/src/insights/index.js.map +3 -3
  43. package/dist/src/leader.js +3 -70
  44. package/dist/src/leader.js.map +6 -6
  45. package/dist/src/logger.js +1 -4
  46. package/dist/src/logger.js.map +3 -3
  47. package/dist/src/node/local-client.d.ts +2 -36
  48. package/dist/src/node/tx-summary.js +1 -4
  49. package/dist/src/node/tx-summary.js.map +3 -3
  50. package/dist/src/queue/listener.js +3 -70
  51. package/dist/src/queue/listener.js.map +6 -6
  52. package/dist/src/runtime/index.js +1 -2
  53. package/dist/src/runtime/index.js.map +3 -3
  54. package/dist/src/schemas/chain-triggers.js +2 -8
  55. package/dist/src/schemas/chain-triggers.js.map +3 -3
  56. package/dist/src/schemas/index.d.ts +1 -2
  57. package/dist/src/schemas/index.js +4 -11
  58. package/dist/src/schemas/index.js.map +4 -4
  59. package/dist/src/schemas/webhooks.d.ts +1 -2
  60. package/dist/src/schemas/webhooks.js +4 -11
  61. package/dist/src/schemas/webhooks.js.map +4 -4
  62. package/migrations/0205_sbtc_deposit_recipient.ts +75 -0
  63. package/migrations/0206_drop_pox4_calls.ts +32 -0
  64. package/package.json +2 -2
@@ -4,17 +4,17 @@
4
4
  "sourcesContent": [
5
5
  "import postgres from \"postgres\";\nimport {\n\tdescribeDbUrl,\n\tresolveSourceUrl,\n\tresolveTargetUrl,\n} from \"../db/index.ts\";\nimport { logger } from \"../logger.ts\";\n\ninterface ListenOptions {\n\t/**\n\t * Connection string to LISTEN on. Defaults to `process.env.DATABASE_URL`.\n\t * In dual-DB mode, pass `SOURCE_DATABASE_URL` for indexer-fired channels\n\t * (`indexer:new_block`, `subgraph_reorg`, `tx:confirmed`) and\n\t * `TARGET_DATABASE_URL` for tenant-local channels (`subgraph_changes`).\n\t */\n\tconnectionString?: string;\n}\n\n/**\n * LISTEN/NOTIFY connection for indexer-fired channels (`indexer:new_block`,\n * `subgraph_reorg`, `tx:confirmed`, `index:tip`) — they fire wherever\n * `getSourceDb()` writes. Delegates to `resolveSourceUrl` (the same function\n * `getSourceDb()` calls) instead of re-deriving the env-var precedence here:\n * a hand-duplicated resolver previously skipped the `isPlatformMode()` gate\n * that `getSourceDb()` applies, so a process not in platform mode (but with\n * `SOURCE_DATABASE_URL` set anyway, e.g. inherited from a shared env\n * template) would LISTEN on a different database than the one the write\n * actually commits to — a NOTIFY that fires correctly on the writer's\n * connection then never reaches this listener. One resolver, used by both.\n */\nexport function sourceListenerUrl(): string {\n\treturn resolveSourceUrl();\n}\n\n/**\n * LISTEN/NOTIFY connection for control-plane channels (`webhooks:new_outbox`,\n * `webhooks:changed`, subgraph operations) — they fire wherever `getTargetDb()`\n * writes. See {@link sourceListenerUrl} for why this delegates instead of\n * re-deriving the precedence.\n */\nexport function targetListenerUrl(): string {\n\treturn resolveTargetUrl();\n}\n\nfunction resolveUrl(opts?: ListenOptions): string {\n\t// `||` not `??`: an empty-string connectionString (e.g. an unset\n\t// SOURCE_/TARGET_DATABASE_URL passed through docker-compose as \"\") must fall\n\t// back to DATABASE_URL, not be treated as a valid value.\n\tconst url = opts?.connectionString || process.env.DATABASE_URL;\n\tif (!url) {\n\t\tthrow new Error(\n\t\t\t\"listen/notify requires a connection string (opts.connectionString or DATABASE_URL)\",\n\t\t);\n\t}\n\treturn url;\n}\n\n/**\n * postgres.js's LISTEN connection already reconnects on its own (backoff,\n * re-issues `LISTEN` for every channel, `onlisten` fires again after each\n * reconnect) — see `node_modules/postgres/src/index.js`'s `listen()`, which\n * hardcodes `idle_timeout`/`max_lifetime` to `null` on its dedicated\n * connection regardless of what's passed here, so nothing we set can defeat\n * it. What it does NOT do is replay a NOTIFY that fired while the connection\n * was down. So on every reconnect (not the initial connect) we log it and\n * fire one synthetic call to `callback` with no payload — every caller here\n * treats a missing/unparseable payload as \"go re-check current state,\" which\n * is exactly right for \"a NOTIFY may have been missed.\"\n */\nexport async function listen(\n\tchannel: string,\n\tcallback: (payload?: string) => void,\n\topts?: ListenOptions,\n): Promise<() => Promise<void>> {\n\tconst url = resolveUrl(opts);\n\tconst client = postgres(url, {\n\t\tmax: 1,\n\t\tonnotice: () => {},\n\t});\n\n\tlet connectedOnce = false;\n\tawait client.listen(\n\t\tchannel,\n\t\t(payload) => {\n\t\t\tcallback(payload);\n\t\t},\n\t\t() => {\n\t\t\tif (connectedOnce) {\n\t\t\t\tlogger.info(\"LISTEN connection reconnected\", {\n\t\t\t\t\tevent: \"listener_reconnected\",\n\t\t\t\t\tchannel,\n\t\t\t\t\tdb: describeDbUrl(url),\n\t\t\t\t});\n\t\t\t\tcallback();\n\t\t\t}\n\t\t\tconnectedOnce = true;\n\t\t},\n\t);\n\n\treturn async () => {\n\t\tawait client.end();\n\t};\n}\n\n/** A shareable wake point: any number of callers can `wait()` for the next\n * NOTIFY on `channel`, each getting their own promise. One LISTEN connection\n * backs every waiter, so a decoder pool or an API replica needs only one\n * `createWakeBus` per process per channel, not one per caller. */\nexport type WakeBus = {\n\t/** Resolves on the next NOTIFY. A fresh promise every call — safe to call\n\t * again immediately after it resolves. */\n\twait: () => Promise<void>;\n\t/**\n\t * Monotonically increasing counter, bumped once per NOTIFY received —\n\t * before resolving any waiters pending at that moment — never decreasing,\n\t * never resetting, starting at 0. Lets a caller record \"the generation as\n\t * of some point in time\" and later ask \"has a NOTIFY landed since then\"\n\t * without having been an active `wait()`er when it happened. This closes\n\t * the check-then-wait race every poll-then-wait loop otherwise has: a\n\t * NOTIFY that fires between a caller checking for fresh state and it\n\t * registering a fresh `wait()` resolves zero waiters (nobody was\n\t * listening yet) and would otherwise be missed until the NEXT NOTIFY.\n\t */\n\tgeneration: () => number;\n\t/** Close the underlying LISTEN connection and resolve every pending waiter\n\t * (so nothing blocks forever on shutdown). */\n\tstop: () => Promise<void>;\n};\n\n/**\n * Start a `WakeBus` on `channel`. Callers that only need a fallback timer if\n * this fails should catch the rejection and keep polling — a wake bus is an\n * optimization, never the only path to progress.\n */\nexport async function createWakeBus(\n\tchannel: string,\n\topts?: ListenOptions,\n): Promise<WakeBus> {\n\tlet waiters = new Set<() => void>();\n\tlet generation = 0;\n\tconst stopListening = await listen(\n\t\tchannel,\n\t\t() => {\n\t\t\tgeneration++;\n\t\t\tconst pending = waiters;\n\t\t\twaiters = new Set();\n\t\t\tfor (const resolve of pending) resolve();\n\t\t},\n\t\topts,\n\t);\n\treturn {\n\t\twait: () => new Promise<void>((resolve) => waiters.add(resolve)),\n\t\tgeneration: () => generation,\n\t\tstop: async () => {\n\t\t\tconst pending = waiters;\n\t\t\twaiters = new Set();\n\t\t\tfor (const resolve of pending) resolve();\n\t\t\tawait stopListening();\n\t\t},\n\t};\n}\n\nexport async function notify(\n\tchannel: string,\n\tpayload?: string,\n\topts?: ListenOptions,\n): Promise<void> {\n\tconst client = postgres(resolveUrl(opts), { max: 1 });\n\n\ttry {\n\t\tif (payload) {\n\t\t\tawait client`SELECT pg_notify(${channel}, ${payload})`;\n\t\t} else {\n\t\t\tawait client`SELECT pg_notify(${channel}, '')`;\n\t\t}\n\t} finally {\n\t\tawait client.end();\n\t}\n}\n",
6
6
  "import { Kysely } from \"kysely\";\nimport { PostgresJSDialect } from \"kysely-postgres-js\";\nimport postgres from \"postgres\";\nimport { isProductionEnv } from \"../env.ts\";\nimport { logger } from \"../logger.ts\";\nimport { isPlatformMode } from \"../mode.ts\";\nimport { tlsOptions } from \"./tls.ts\";\nimport type { Database } from \"./types.ts\";\n\nexport type { Database } from \"./types.ts\";\n\nconst DEFAULT_URL =\n\t\"postgres://postgres:postgres@localhost:5432/secondlayer_dev\";\n\ninterface PoolEntry {\n\tdb: Kysely<Database>;\n\trawClient: ReturnType<typeof postgres>;\n\t/** Last access (ms) — drives LRU eviction of extra pools. */\n\tlastUsed: number;\n\t/** Monotonic counter as a tiebreaker; Date.now() can repeat under load. */\n\tseq: number;\n}\n\n/**\n * Cache of Kysely + raw postgres.js pools keyed by resolved URL.\n * Two getters resolving to the same URL share one entry (single pool) —\n * this is the single-DB backward-compat contract: when only `DATABASE_URL`\n * is set, `getSourceDb() === getTargetDb()` (zero regression vs. pre-dual-DB).\n *\n * Extra pools are bounded\n * (`DATABASE_MAX_POOLS`, default 25) with LRU eviction — the hot source/target\n * pools are never evicted.\n */\nconst pools = new Map<string, PoolEntry>();\nlet poolSeq = 0;\n\nfunction maxPools(): number {\n\treturn Number.parseInt(process.env.DATABASE_MAX_POOLS ?? \"25\", 10);\n}\n\n/** Close the least-recently-used non-(source/target) pool when over the cap. */\nfunction evictIfNeeded(): void {\n\tif (pools.size <= maxPools()) return;\n\tconst protectedUrls = new Set([resolveSourceUrl(), resolveTargetUrl()]);\n\tlet lruUrl: string | undefined;\n\tlet lruEntry: PoolEntry | undefined;\n\tfor (const [url, entry] of pools) {\n\t\tif (protectedUrls.has(url)) continue;\n\t\tif (\n\t\t\t!lruEntry ||\n\t\t\tentry.lastUsed < lruEntry.lastUsed ||\n\t\t\t(entry.lastUsed === lruEntry.lastUsed && entry.seq < lruEntry.seq)\n\t\t) {\n\t\t\tlruUrl = url;\n\t\t\tlruEntry = entry;\n\t\t}\n\t}\n\tif (!lruUrl || !lruEntry) return;\n\tpools.delete(lruUrl);\n\tconst evicted = lruEntry;\n\t// Close in the background — never block pool creation on teardown.\n\tvoid evicted.db\n\t\t.destroy()\n\t\t.catch(() => {})\n\t\t.then(() => evicted.rawClient.end({ timeout: 5 }))\n\t\t.catch(() => {});\n}\n\n/** OSS: one application URL. SOURCE_/TARGET_ are hosted split only. */\nexport function applicationDatabaseUrl(): string {\n\treturn process.env.DATABASE_URL || DEFAULT_URL;\n}\n\n/**\n * Canonical source-DB URL — the ONE place that decides it. Exported so a\n * LISTEN connection (`queue/listener.ts`) resolves the same database a write\n * through `getSourceDb()` commits to; a second, hand-duplicated resolution\n * that skips the `isPlatformMode()` gate silently listens on the wrong\n * database whenever a process isn't in platform mode but `SOURCE_DATABASE_URL`\n * happens to be set anyway (a shared env template, a staging box) — a NOTIFY\n * on the real (gated) URL then never reaches it.\n */\nexport function resolveSourceUrl(): string {\n\treturn configuredSourceUrl() ?? DEFAULT_URL;\n}\n\n/** Canonical target-DB URL — see {@link resolveSourceUrl}. */\nexport function resolveTargetUrl(): string {\n\treturn configuredTargetUrl() ?? DEFAULT_URL;\n}\n\n/** The source URL the environment actually names, or undefined: unlike\n * {@link resolveSourceUrl} it never falls back to the dev default, so a tool\n * that writes (migrate) can refuse instead of touching a database nobody\n * configured. */\nexport function configuredSourceUrl(): string | undefined {\n\tif (!isPlatformMode()) return process.env.DATABASE_URL || undefined;\n\treturn (\n\t\tprocess.env.SOURCE_DATABASE_URL || process.env.DATABASE_URL || undefined\n\t);\n}\n\n/** See {@link configuredSourceUrl}. */\nexport function configuredTargetUrl(): string | undefined {\n\tif (!isPlatformMode()) return process.env.DATABASE_URL || undefined;\n\treturn (\n\t\tprocess.env.TARGET_DATABASE_URL || process.env.DATABASE_URL || undefined\n\t);\n}\n\n/** Host[:port]/dbname for a connection URL — credentials stripped. Exported\n * so anything logging which database it connected to (a LISTEN channel's\n * startup log, an ops health check) can describe it without ever printing a\n * password. */\nexport function describeDbUrl(url: string): string {\n\ttry {\n\t\tconst u = new URL(url);\n\t\treturn `${u.hostname}${u.port ? `:${u.port}` : \"\"}${u.pathname}`;\n\t} catch {\n\t\treturn \"invalid-url\";\n\t}\n}\n\n/** Warn-once latch — one line per process, not one per import or connection. */\nlet warnedDefaultUrlFallthrough = false;\n\n/**\n * Test-run guard for the plain \"no DB env at all\" case, which `assertDbSplit`\n * deliberately does not cover (it only fires when a SPLIT is requested).\n *\n * Without any of the three URL vars, every getter resolves to the built-in\n * dev `DEFAULT_URL`. In a test run that means one of two silent outcomes: the\n * suite's own `skipIf(!process.env.DATABASE_URL)` guard disables it entirely,\n * or an unguarded test connects to whatever Postgres happens to be on\n * localhost:5432. Both exit 0 and read as \"tests passed\".\n *\n * Fires at MODULE LOAD, not from a getter: DB-backed suites guard `getDb()`\n * behind their own `skipIf`, so when the env is missing no getter is ever\n * called — import is the only point where this is still observable.\n *\n * Gated to `NODE_ENV=test` on purpose. `@secondlayer/shared` is published, and\n * end users running `sl local` / `sl dev` rely on `DEFAULT_URL` legitimately —\n * it matches what the CLI provisions. They must see nothing. Fail-soft: warns,\n * never throws, matching `assertDbSplit`'s contract.\n */\nfunction warnIfTestRunFallsThroughToDefault(): void {\n\tif (warnedDefaultUrlFallthrough) return;\n\t// Runtime read — inlining `process.env.NODE_ENV` gets constant-folded into\n\t// the shipped dist, freezing this to a build-time literal. See env.ts.\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler.\n\tif (process.env[\"NODE_ENV\"] !== \"test\") return;\n\tif (\n\t\tprocess.env.DATABASE_URL ||\n\t\tprocess.env.SOURCE_DATABASE_URL ||\n\t\tprocess.env.TARGET_DATABASE_URL\n\t) {\n\t\treturn;\n\t}\n\twarnedDefaultUrlFallthrough = true;\n\tconsole.warn(\n\t\t`⚠️ DATABASE_URL unset — falling through to the built-in DEFAULT_URL (${describeDbUrl(\n\t\t\tDEFAULT_URL,\n\t\t)}). Database-backed tests will skip or hit the wrong Postgres. Copy .env.example to .env in this package (see \\`bun run db\\`).`,\n\t);\n}\n\nwarnIfTestRunFallsThroughToDefault();\n\nexport interface DbSplitStatus {\n\t/** \"split\" when source/target resolve to different DBs, else \"single\". */\n\tmode: \"split\" | \"single\";\n\t/** True when the chain/control split is live (distinct DBs). */\n\tactive: boolean;\n\t/** SOURCE host[:port]/dbname (no credentials). */\n\tsourceDb: string;\n\t/** TARGET host[:port]/dbname (no credentials). */\n\ttargetDb: string;\n}\n\n/**\n * Resolved source/target DB identity for status/health surfaces. Lets operators\n * see whether the chain/control split is live or dormant (collapsed to one DB)\n * without shelling in. Credentials are never exposed — host/db only.\n *\n * `active` is a STRING-IDENTITY check on the two URLs: it can't catch two\n * distinct URLs that alias the same physical instance (e.g. `postgres` vs\n * `127.0.0.1`, or a swapped/wrong host). Treat `active: true` as \"configured\n * for split\", not a proof of physical isolation.\n */\nexport function getDbSplitStatus(): DbSplitStatus {\n\tconst source = resolveSourceUrl();\n\tconst target = resolveTargetUrl();\n\tconst active = source !== target;\n\treturn {\n\t\tmode: active ? \"split\" : \"single\",\n\t\tactive,\n\t\tsourceDb: describeDbUrl(source),\n\t\ttargetDb: describeDbUrl(target),\n\t};\n}\n\n/**\n * Boot guard for the chain/control DB split. Surfaces three misconfigurations\n * loudly (fail-soft — logs, never throws, so a misconfig can't brick startup):\n *\n * 1. Silent wrong-DB: a split is requested (one of SOURCE_/TARGET_ set) but\n * `DATABASE_URL` is absent (the split-prod default) and the OTHER var is\n * unset, so it falls through to the built-in dev `DEFAULT_URL` — about to\n * read/write a real-but-wrong database. This is the failure mode the\n * remove-DATABASE_URL decision creates; catch it.\n * 2. Collapsed split: both vars set but resolve to the same DB (typo, or a\n * stray `DATABASE_URL` masking the intent).\n * 3. Dormant split (prod only): neither var set, so all services share one\n * Postgres failure domain. Not an error, but no longer silent.\n */\nexport function assertDbSplit(): void {\n\t// Runtime read — inlining `process.env.NODE_ENV` gets constant-folded in the\n\t// shipped dist (this prod branch would die silently). See env.ts.\n\tconst isProd = isProductionEnv();\n\tconst wantsSplit = !!(\n\t\tprocess.env.SOURCE_DATABASE_URL || process.env.TARGET_DATABASE_URL\n\t);\n\tconst databaseUrlSet = !!process.env.DATABASE_URL;\n\tconst source = resolveSourceUrl();\n\tconst target = resolveTargetUrl();\n\n\tif (\n\t\twantsSplit &&\n\t\t!databaseUrlSet &&\n\t\t(source === DEFAULT_URL || target === DEFAULT_URL)\n\t) {\n\t\tconst which =\n\t\t\tsource === DEFAULT_URL ? \"SOURCE_DATABASE_URL\" : \"TARGET_DATABASE_URL\";\n\t\tconst msg = `${which} unset and DATABASE_URL absent — resolving to built-in DEFAULT_URL; refusing to silently use the wrong database`;\n\t\tif (isProd) console.error(`❌ ${msg}`);\n\t\telse console.warn(`⚠️ ${msg}`);\n\t\treturn;\n\t}\n\n\tif (!wantsSplit) {\n\t\tif (isProd) {\n\t\t\tconsole.warn(\n\t\t\t\t\"⚠️ DB split dormant — all services share one Postgres failure domain (SOURCE_/TARGET_DATABASE_URL unset)\",\n\t\t\t);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (source === target) {\n\t\tconst msg =\n\t\t\t\"DB split requested but SOURCE_DATABASE_URL === TARGET_DATABASE_URL (check for a typo or a stray DATABASE_URL fallback)\";\n\t\tif (isProd) console.error(`❌ ${msg}`);\n\t\telse console.warn(`⚠️ ${msg}`);\n\t}\n}\n\nfunction getOrCreatePool(url: string): PoolEntry {\n\tconst existing = pools.get(url);\n\tif (existing) {\n\t\texisting.lastUsed = Date.now();\n\t\texisting.seq = poolSeq++;\n\t\treturn existing;\n\t}\n\n\tconst poolMax = Number.parseInt(process.env.DATABASE_POOL_MAX ?? \"20\", 10);\n\t// Close idle connections so extra pools don't pin connections they no\n\t// longer need (0 = never; postgres.js default).\n\tconst idleTimeout = Number.parseInt(\n\t\tprocess.env.DATABASE_IDLE_TIMEOUT ?? \"300\",\n\t\t10,\n\t);\n\tconst rawClient = postgres(url, {\n\t\tmax: poolMax,\n\t\tidle_timeout: idleTimeout,\n\t\t...tlsOptions(url),\n\t});\n\tconst db = new Kysely<Database>({\n\t\tdialect: new PostgresJSDialect({ postgres: rawClient }),\n\t\t// Diagnostic hook: surface the failing SQL whenever postgres rejects\n\t\t// with code 42P10 (ON CONFLICT target doesn't match any unique\n\t\t// constraint). Temporary — remove once we've caught the culprit\n\t\t// query in prod logs and fixed the schema drift.\n\t\tlog: (event) => {\n\t\t\tif (event.level !== \"error\") return;\n\t\t\tconst err = event.error as {\n\t\t\t\tcode?: string;\n\t\t\t\tmessage?: string;\n\t\t\t} | null;\n\t\t\tif (err?.code !== \"42P10\") return;\n\t\t\tlogger.warn(\"db.on_conflict_constraint_missing\", {\n\t\t\t\tcode: err.code,\n\t\t\t\tmessage: err.message,\n\t\t\t\tsql: event.query.sql,\n\t\t\t\tparams: event.query.parameters,\n\t\t\t});\n\t\t},\n\t});\n\tconst entry: PoolEntry = {\n\t\tdb,\n\t\trawClient,\n\t\tlastUsed: Date.now(),\n\t\tseq: poolSeq++,\n\t};\n\tpools.set(url, entry);\n\tevictIfNeeded();\n\treturn entry;\n}\n\n/**\n * Kysely instance for the SOURCE DB (block/tx/event reads from the shared\n * indexer). Resolution: `SOURCE_DATABASE_URL || DATABASE_URL`.\n */\nexport function getSourceDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveSourceUrl()).db;\n}\n\n/**\n * Kysely instance for the TARGET DB (subgraph schemas, subgraphs table,\n * account-scoped data — tenant-side writes). Resolution:\n * `TARGET_DATABASE_URL || DATABASE_URL`.\n */\nexport function getTargetDb(): Kysely<Database> {\n\treturn getOrCreatePool(resolveTargetUrl()).db;\n}\n\n/**\n * Backward-compat alias for `getTargetDb()`. Accepts an optional\n * `connectionString` override used by seed/test helpers — when supplied,\n * bypasses env resolution and uses the provided URL directly (still cached).\n */\nexport function getDb(connectionString?: string): Kysely<Database> {\n\tif (connectionString) return getOrCreatePool(connectionString).db;\n\treturn getTargetDb();\n}\n\n/**\n * Raw postgres.js client for dynamic schema DDL (CREATE SCHEMA, DROP, etc.).\n * Defaults to the target role (tenant schemas live in the target DB).\n */\nexport function getRawClient(\n\trole: \"source\" | \"target\" = \"target\",\n): ReturnType<typeof postgres> {\n\tconst url = role === \"source\" ? resolveSourceUrl() : resolveTargetUrl();\n\treturn getOrCreatePool(url).rawClient;\n}\n\n/** Close all DB connection pools. Call in CLI commands to allow process exit. */\nexport async function closeDb(): Promise<void> {\n\tfor (const entry of pools.values()) {\n\t\tawait entry.db.destroy();\n\t\tawait entry.rawClient.end();\n\t}\n\tpools.clear();\n}\n\nconst DEFAULT_CLOSE_DB_TIMEOUT_MS = 30_000;\n\n/**\n * `closeDb()`, but never let it block process exit past `timeoutMs`.\n *\n * 2026-09-28: a canonical export printed its summary and then sat idle for 20\n * minutes — 0% CPU, `wchan=ep_poll`, one open socket — stuck in `await\n * closeDb()`. Only the wrapper's own 6h timeout moved things along. A driver\n * holding a socket open past `.destroy()`/`.end()` finishing (or never\n * finishing at all) must not stop a one-shot script from exiting once its\n * actual work is done.\n */\nexport async function closeDbOrTimeout(\n\ttimeoutMs: number = DEFAULT_CLOSE_DB_TIMEOUT_MS,\n\t/** Test seam; production callers leave this unset. */\n\tcloseFn: () => Promise<void> = closeDb,\n): Promise<void> {\n\tawait Promise.race([\n\t\tcloseFn(),\n\t\tnew Promise<void>((resolve) => setTimeout(resolve, timeoutMs)),\n\t]);\n}\n\nimport { sql } from \"kysely\";\nexport { sql };\nexport * from \"./types.ts\";\nexport type { DbReadRow, NumericAsText } from \"./read-row.ts\";\nexport {\n\tSOURCE_READ_COLUMNS,\n\tSOURCE_READ_TYPES,\n\tSOURCE_READ_PKS,\n\ttype IndexColumn,\n\ttype IndexColumnType,\n\ttype IndexPrimaryKey,\n} from \"./source-read-columns.ts\";\nexport { jsonb, parseJsonb } from \"./jsonb.ts\";\nexport {\n\tgetMigrationRole,\n\tonChainPlane,\n\tonControlPlane,\n\tsetMigrationRole,\n} from \"./migration-role.ts\";\nexport type { MigrationRole } from \"./migration-role.ts\";\nexport { TABLE_TO_DB } from \"./table-plane.ts\";\nexport type { DbPlane } from \"./table-plane.ts\";\n",
7
- "import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tconst named = stacksNetwork();\n\t\tenabledNetworks = named === \"testnet\" ? [\"testnet\"] : [\"mainnet\"];\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\nlet warnedNetworkFallback = false;\n\n/**\n * The Stacks network this process serves, and the only place that decides it:\n * `STACKS_NETWORK`, else the deprecated `NETWORK` (warned once so a deployment\n * that only sets it is not silently re-keyed), else mainnet. Not validated;\n * `instanceNetworkFromEnv` is the strict form.\n */\nexport function stacksNetwork(env: NodeJS.ProcessEnv = process.env): string {\n\tif (env.STACKS_NETWORK) return env.STACKS_NETWORK;\n\tif (env.NETWORK) {\n\t\tif (!warnedNetworkFallback) {\n\t\t\twarnedNetworkFallback = true;\n\t\t\tconsole.warn(\"NETWORK is deprecated: set STACKS_NETWORK instead\");\n\t\t}\n\t\treturn env.NETWORK;\n\t}\n\treturn \"mainnet\";\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\ntype EnvMap = NodeJS.ProcessEnv;\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n/**\n * PoX-5 print-event decoder is ON by default (mirrors pox-4/sBTC policy).\n * No activation gating needed: pox-5 events cannot exist before the Epoch 4.0\n * hard fork (Bitcoin block 960,230), so pre-activation the decoder idles at\n * tip. Opt out with `POX5_DECODER_ENABLED=false`.\n */\nexport function isPox5DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX5_DECODER_ENABLED !== \"false\";\n}\n\n/** Default ON. Opt out with `SBTC_DECODER_ENABLED=false`. */\nexport function isSbtcDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.SBTC_DECODER_ENABLED !== \"false\";\n}\n\n/** Default OFF. Opt in with `BNS_DECODER_ENABLED=true`. */\nexport function isBnsDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.BNS_DECODER_ENABLED === \"true\";\n}\n\n// Export for testing\nexport { envSchema };\n",
7
+ "import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tconst named = stacksNetwork();\n\t\tenabledNetworks = named === \"testnet\" ? [\"testnet\"] : [\"mainnet\"];\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\nlet warnedNetworkFallback = false;\n\n/**\n * The Stacks network this process serves, and the only place that decides it:\n * `STACKS_NETWORK`, else the deprecated `NETWORK` (warned once so a deployment\n * that only sets it is not silently re-keyed), else mainnet. Not validated;\n * `instanceNetworkFromEnv` is the strict form.\n */\nexport function stacksNetwork(env: NodeJS.ProcessEnv = process.env): string {\n\tif (env.STACKS_NETWORK) return env.STACKS_NETWORK;\n\tif (env.NETWORK) {\n\t\tif (!warnedNetworkFallback) {\n\t\t\twarnedNetworkFallback = true;\n\t\t\tconsole.warn(\"NETWORK is deprecated: set STACKS_NETWORK instead\");\n\t\t}\n\t\treturn env.NETWORK;\n\t}\n\treturn \"mainnet\";\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\ntype EnvMap = NodeJS.ProcessEnv;\n\n/**\n * PoX-5 print-event decoder is ON by default (mirrors the sBTC policy).\n * No activation gating needed: pox-5 events cannot exist before the Epoch 4.0\n * hard fork (Bitcoin block 960,230), so pre-activation the decoder idles at\n * tip. Opt out with `POX5_DECODER_ENABLED=false`.\n */\nexport function isPox5DecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.POX5_DECODER_ENABLED !== \"false\";\n}\n\n/** Default ON. Opt out with `SBTC_DECODER_ENABLED=false`. */\nexport function isSbtcDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.SBTC_DECODER_ENABLED !== \"false\";\n}\n\n/** Default OFF. Opt in with `BNS_DECODER_ENABLED=true`. */\nexport function isBnsDecoderEnabled(env: EnvMap = process.env): boolean {\n\treturn env.BNS_DECODER_ENABLED === \"true\";\n}\n\n// Export for testing\nexport { envSchema };\n",
8
8
  "import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
9
9
  "/**\n * Instance modes for the Secondlayer platform.\n *\n * - `oss`: self-hosted, single-tenant. No auth middleware, no platform routes\n * (projects, admin). Everything runs against a single `DATABASE_URL`.\n * Intended for `docker compose up`.\n *\n * - `platform`: the metered archive deployment. Magic-link auth, API keys,\n * accounts, credits, and metered `/v1` reads (Index + Streams + subgraphs)\n * against a single shared DB. No paid tier ladder — one metered `free`\n * tier plus first-party internal service credentials.\n */\n\nexport type InstanceMode = \"oss\" | \"platform\";\n\n/** What the operator wrote in the env — `archive` is the honest name for the\n * metered public-archive deployment and aliases `platform` behaviorally. */\nexport type DeclaredInstanceMode = InstanceMode | \"archive\";\n\nconst VALID_MODES: readonly DeclaredInstanceMode[] = [\n\t\"oss\",\n\t\"platform\",\n\t\"archive\",\n];\n\nfunction declaredMode(): DeclaredInstanceMode {\n\tconst raw = process.env.INSTANCE_MODE?.trim().toLowerCase();\n\tif (raw && (VALID_MODES as readonly string[]).includes(raw)) {\n\t\treturn raw as DeclaredInstanceMode;\n\t}\n\treturn \"oss\";\n}\n\n/**\n * Resolve the active instance mode from `process.env.INSTANCE_MODE`.\n * Defaults to `\"oss\"` — the safest default for self-hosters who deploy\n * without setting the variable. `archive` normalizes to `platform` here so\n * every behavioral branch stays a two-way choice; use\n * `getDeclaredInstanceMode()` for display surfaces.\n */\nexport function getInstanceMode(): InstanceMode {\n\tconst declared = declaredMode();\n\treturn declared === \"archive\" ? \"platform\" : declared;\n}\n\n/** The mode as declared in the env, for status/identity surfaces. */\nexport function getDeclaredInstanceMode(): DeclaredInstanceMode {\n\treturn declaredMode();\n}\n\n/**\n * True when public reads are credit-metered (the free window, retention, and\n * credits gates arm). Platform/archive deployments meter by default;\n * self-host never does unless the operator explicitly sets\n * `METERED_READS=true`. `METERED_READS=false` disarms a metered deployment.\n */\nexport function isMeteredReads(): boolean {\n\tconst override = process.env.METERED_READS?.trim().toLowerCase();\n\tif (override === \"true\") return true;\n\tif (override === \"false\") return false;\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"platform\"` (shared multi-tenant). */\nexport function isPlatformMode(): boolean {\n\treturn getInstanceMode() === \"platform\";\n}\n\n/** True when the active mode is `\"oss\"` (self-hosted). */\nexport function isOssMode(): boolean {\n\treturn getInstanceMode() === \"oss\";\n}\n\n/** The one shared testnet webhook stack (hosted). Off everywhere else. */\nexport function isTestnetWebhookStack(): boolean {\n\treturn process.env.TESTNET_WEBHOOK_STACK === \"true\";\n}\n\n/** Webhook rows are per-account: platform, or the shared testnet stack. */\nexport function isWebhookAccountScoped(): boolean {\n\treturn isPlatformMode() || isTestnetWebhookStack();\n}\n",
10
10
  "/**\n * TLS options for a postgres.js client, as a spread-able object.\n *\n * An explicit `sslmode` (or `ssl`) in the URL wins: we return no `ssl` key at\n * all, because postgres.js reads the URL only when the option is absent — even\n * `ssl: undefined` would mask it. Otherwise local hosts skip TLS (any Docker\n * service alias is a single-label hostname on an internal network) and every\n * other host requires it.\n */\nexport function tlsOptions(url: string): {\n\tssl?: { rejectUnauthorized: boolean };\n} {\n\tlet parsed: URL | null = null;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {}\n\tif (parsed?.searchParams.has(\"sslmode\") || parsed?.searchParams.has(\"ssl\")) {\n\t\treturn {};\n\t}\n\tconst host = parsed?.hostname ?? \"\";\n\tconst isLocal =\n\t\thost === \"localhost\" || host === \"127.0.0.1\" || !host.includes(\".\");\n\tif (isLocal) return {};\n\treturn {\n\t\tssl: {\n\t\t\trejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\",\n\t\t},\n\t};\n}\n",
11
- "import type {\n\tColumnType,\n\tGenerated,\n\tInsertable,\n\tSelectable,\n\tUpdateable,\n} from \"kysely\";\nimport type {\n\tFailureClass,\n\tFailureUnit,\n\tNativeClock,\n\tRepairMode,\n\tRetryState,\n\tRunStatus,\n\tStageKind,\n} from \"../coverage/constraints.ts\";\nimport type { BootstrapSource } from \"../coverage/evaluate.ts\";\nimport type {\n\tSubgraphStatus,\n\tSubgraphVerification,\n} from \"../schemas/subgraphs.ts\";\nimport type { WebhookPauseReason } from \"../webhooks/health.ts\";\n\nexport type {\n\tFailureClass,\n\tFailureUnit,\n\tNativeClock,\n\tRepairMode,\n\tRetryState,\n\tRunStatus,\n\tStageKind,\n} from \"../coverage/constraints.ts\";\n\n// ── Table interfaces ──────────────────────────────────────────────────\n\nexport interface BlocksTable {\n\theight: number;\n\thash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\t/** Nakamoto StacksBlockId. Null on rows ingested before it was persisted. */\n\tindex_block_hash: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\ttimestamp: number;\n\tcanonical: Generated<boolean>;\n\t/** Tx count `persistBlock` was handed for this height. Null on rows\n\t * ingested before this column existed. */\n\ttx_count: ColumnType<number | null, number | null | undefined, number | null>;\n\t/** Event count `persistBlock` was handed for this height. Null on rows\n\t * ingested before this column existed. */\n\tevent_count: ColumnType<\n\t\tnumber | null,\n\t\tnumber | null | undefined,\n\t\tnumber | null\n\t>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface TransactionsTable {\n\ttx_id: string;\n\tblock_height: number;\n\ttx_index: Generated<number>;\n\ttype: string;\n\tsender: string;\n\tstatus: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: Generated<unknown | null>;\n\traw_result: Generated<string | null>;\n\traw_tx: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface EventsTable {\n\tid: Generated<string>;\n\ttx_id: string;\n\tblock_height: number;\n\tevent_index: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Generated<Date>;\n}\n\n// Reorg archive (see migration 0084): orphaned transactions/events copied here\n// before a reused height is replaced, preserving the raw log instead of\n// deleting it.\nexport interface TransactionsArchiveTable {\n\tarchive_id: Generated<string>;\n\ttx_id: string;\n\tblock_height: number;\n\ttx_index: number;\n\ttype: string;\n\tsender: string;\n\tstatus: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: unknown | null;\n\traw_result: string | null;\n\traw_tx: string;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\nexport interface EventsArchiveTable {\n\tarchive_id: Generated<string>;\n\tid: string;\n\ttx_id: string;\n\tblock_height: number;\n\tevent_index: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Opt-in VM traces (migration 0131). Second clock: `ordinal` (array position\n// in `/new_block.vm_events`). Never mixed into `events.event_index`. Primary\n// key `(block_height, ordinal)` (migration 0153).\nexport interface VmEventsTable {\n\ttx_id: string;\n\tblock_height: number;\n\tordinal: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface VmEventsArchiveTable {\n\tarchive_id: Generated<string>;\n\t/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */\n\tid: string;\n\ttx_id: string;\n\tblock_height: number;\n\tordinal: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Opt-in node storage-layer writes (migration 0154): the exact MARF writes a\n// block committed, in node order. `tx_index` is null for block-level writes.\n// Primary key `(block_height, ordinal)`.\nexport interface StateWritesTable {\n\tblock_height: number;\n\tordinal: number;\n\ttx_index: number | null;\n\tkey: string;\n\tvalue_hex: string;\n}\n\nexport interface StateWritesArchiveTable {\n\tarchive_id: Generated<string>;\n\t/** `block_height:ordinal`. */\n\tid: string;\n\tblock_height: number;\n\tordinal: number;\n\ttx_index: number | null;\n\tkey: string;\n\tvalue_hex: string;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Dead-letter log (see migration 0085): events whose decoded payload failed\n// schema validation on ingest. Append-only diagnostic; the event still lands in\n// `events`, so chain data is never lost.\nexport interface DeadLetterEventsTable {\n\tid: Generated<string>;\n\tblock_height: number;\n\ttx_id: string;\n\tevent_index: number;\n\tevent_type: string;\n\tdata: unknown;\n\treason: string;\n\tcreated_at: Generated<Date>;\n}\n\n// Pending (unconfirmed) transactions (see migration 0086). Pre-chain, so no\n// block_height/tx_index/result/events and never canonical. tx_id is derived\n// from raw_tx; function_args holds hex-encoded ClarityValues (jsonb), like\n// `transactions`.\nexport interface MempoolTransactionsTable {\n\tseq: Generated<string>;\n\ttx_id: string;\n\traw_tx: string;\n\ttype: string;\n\tsender: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: unknown | null;\n\treceived_at: Generated<Date>;\n}\n\nexport interface IndexProgressTable {\n\tnetwork: string;\n\tlast_indexed_block: Generated<number>;\n\tlast_contiguous_block: Generated<number>;\n\thighest_seen_block: Generated<number>;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface SubgraphsTable {\n\tid: Generated<string>;\n\tname: string;\n\tversion: Generated<string>;\n\tstatus: Generated<SubgraphStatus>;\n\tdefinition: Record<string, unknown>;\n\tschema_hash: string;\n\thandler_path: string;\n\tschema_name: string | null;\n\tstart_block: Generated<number>;\n\tlast_processed_block: Generated<number>;\n\t/** Hash of the block at `last_processed_block`; NULL = unknown (see 0197). */\n\tlast_processed_block_hash: Generated<string | null>;\n\treindex_from_block: number | null;\n\treindex_to_block: number | null;\n\tlast_error: string | null;\n\tlast_error_at: Date | null;\n\ttotal_processed: Generated<number>;\n\ttotal_errors: Generated<number>;\n\taccount_id: string;\n\thandler_code: string | null;\n\tsource_code: string | null;\n\tproject_id: string | null;\n\t/** Set while the account's metered reads are refused (spend cap, credits).\n\t * Both columns are set or both null; `last_error` stays for real errors. */\n\tbilling_paused_at: Date | null;\n\tbilling_paused_code: string | null;\n\t/** (event type, contract) probe pairs persisted at deploy for weight classification. */\n\tsparse_probe_targets: unknown | null;\n\t/** sha256 over everything that shapes rows (schema, handler bundle,\n\t * startBlock, network, runtime). NULL for unbundled or older deploys. */\n\tpin: string | null;\n\t/** The canonical JSON `pin` hashes, so a client can recompute it. NULL\n\t * wherever `pin` is, and for deploys before migration 0158. */\n\tpin_preimage: string | null;\n\t/** Level derived at deploy. NULL (older deploys) = not verifiable. */\n\tverification: SubgraphVerification | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\n/** Mirrored by the CHECK on `contracts.abi_status`. */\nexport const ABI_STATUSES = [\n\t\"pending\",\n\t\"fetched\",\n\t\"unparseable\",\n\t\"failed\",\n] as const;\nexport type AbiStatus = (typeof ABI_STATUSES)[number];\n\nexport interface ContractsTable {\n\tcontract_id: string;\n\tdeployer: string;\n\tblock_height: number;\n\tcanonical: Generated<boolean>;\n\tabi: unknown | null;\n\tdeclared_traits: Generated<string[]>;\n\tinferred_standards: Generated<string[]>;\n\tabi_status: Generated<AbiStatus>;\n\tabi_fetched_at: Date | null;\n\t/** Failed fetches so far; `failed` re-polls until the registry's attempt cap. */\n\tabi_attempts: Generated<number>;\n\t/** When a `failed` row is next due; NULL once attempts are exhausted. */\n\tabi_next_attempt_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** The only reasons the runtime records; mirrored by a CHECK on `subgraph_gaps.reason`. */\nexport type GapReason = \"block_missing\" | \"processing_error\";\n\nexport interface SubgraphGapsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tgap_start: number;\n\tgap_end: number;\n\treason: GapReason;\n\tdetected_at: Generated<Date>;\n\tresolved_at: Date | null;\n}\n\n/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */\nexport interface SubgraphViolationsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tsource_name: string;\n\tblock_height: number;\n\ttx_id: string;\n\treason: string;\n\tsample_payload: Record<string, unknown>;\n\tseen_at: Generated<Date>;\n}\n\nexport type SubgraphOperationKind = \"reindex\" | \"backfill\";\nexport type SubgraphOperationStatus =\n\t| \"queued\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"cancelled\";\n\nexport interface SubgraphOperationsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\taccount_id: string | null;\n\tkind: ColumnType<\n\t\tSubgraphOperationKind,\n\t\tSubgraphOperationKind,\n\t\tSubgraphOperationKind\n\t>;\n\tstatus: ColumnType<\n\t\tSubgraphOperationStatus,\n\t\tSubgraphOperationStatus | undefined,\n\t\tSubgraphOperationStatus\n\t>;\n\tfrom_block: number | null;\n\tto_block: number | null;\n\tcancel_requested: Generated<boolean>;\n\tlocked_by: string | null;\n\tlocked_until: Date | null;\n\tstarted_at: Date | null;\n\tfinished_at: Date | null;\n\tprocessed_blocks: number | null;\n\terror: string | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n\t/** 'light' (contract-scoped sparse) | 'heavy' (broad). Claim budgets heavy. */\n\tweight: Generated<string>;\n\t/** Candidate-event denominator computed at enqueue (sparse ops only). */\n\testimated_events: string | number | bigint | null;\n\t/** Events processed so far — written by the progress flush. */\n\tprocessed_events: string | number | bigint | null;\n\t/** Backfill ops' own crash checkpoint — advanced conditionally in-tx with\n\t * each written block; replays skip at/below it. NULL for reindex ops\n\t * (those checkpoint on subgraphs.last_processed_block). */\n\tcursor_block: string | number | bigint | null;\n}\n\nexport type ApiKeyStatus = \"active\" | \"revoked\";\n\nexport interface ApiKeysTable {\n\tid: Generated<string>;\n\tkey_hash: string;\n\tkey_prefix: string;\n\tname: string | null;\n\tstatus: Generated<ApiKeyStatus>;\n\trate_limit: Generated<number>;\n\tip_address: string;\n\taccount_id: string;\n\tproduct: Generated<\n\t\t\"account\" | \"streams\" | \"index\" | \"sentinel\" | \"docs\" | \"tenant\"\n\t>;\n\t/** Sentinel permission areas; set only on `product = 'sentinel'` keys. */\n\tareas: unknown | null;\n\ttier: \"free\" | \"internal\" | null;\n\tlast_used_at: Date | null;\n\trevoked_at: Date | null;\n\t/** Set only on `docs` keys (24h). A key past this instant never authenticates. */\n\texpires_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** Singleton self-host / publisher identity. Network is immutable. */\nexport interface InstancesTable {\n\tid: Generated<string>;\n\tnetwork: string;\n\t/** `SECONDLAYER_SECRETS_KEY` sealed under itself; see `ensureSecretsKeyCanary`. */\n\tsecrets_key_canary: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface AccountsTable {\n\tid: Generated<string>;\n\t/** NULL for unclaimed ghost accounts (anonymous self-serve keys). */\n\temail: string | null;\n\t/** True for anonymous self-serve accounts until claimed via magic link. */\n\tghost: Generated<boolean>;\n\t/** First-party service account: usage priced at $0, never gated on\n\t * credits. Set by ops only. */\n\tinternal: Generated<boolean>;\n\t/** Stacks principal owning a wallet-ghost account. */\n\twallet_principal: string | null;\n\tdisplay_name: string | null;\n\tbio: string | null;\n\tavatar_url: string | null;\n\tstripe_customer_id: string | null;\n\t/** Opt-out toggle for the subgraph reindex-completion email. Defaults true. */\n\tnotify_reindex_complete: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SessionsTable {\n\tid: Generated<string>;\n\ttoken_hash: string;\n\ttoken_prefix: string;\n\taccount_id: string;\n\tip_address: string;\n\texpires_at: Generated<Date>;\n\trevoked_at: Date | null;\n\tlast_used_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface MagicLinksTable {\n\tid: Generated<string>;\n\temail: string;\n\ttoken: string;\n\tcode: string | null;\n\texpires_at: Date;\n\tused_at: Date | null;\n\tfailed_attempts: Generated<number>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SubgraphProcessingStatsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tapi_key_id: string | null;\n\tbucket_start: Date | null;\n\tbucket_end: Date | null;\n\tblocks_processed: number | null;\n\ttotal_time_ms: number | null;\n\thandler_time_ms: number | null;\n\tflush_time_ms: number | null;\n\tmax_block_time_ms: number | null;\n\tmax_handler_time_ms: number | null;\n\tavg_ops_per_block: number | null;\n\tis_catchup: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SubgraphHealthSnapshotsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\ttotal_processed: number;\n\ttotal_errors: number;\n\tlast_processed_block: number | null;\n\tchain_tip: string | number | null;\n\trows_written_total: string | number | null;\n\tstorage_bytes: string | number | null;\n\tcaptured_at: Generated<Date>;\n}\n\n/** Handler errors grouped by fingerprint. Cap 50/subgraph. */\nexport interface SubgraphErrorGroupsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tfingerprint: string;\n\tsource_name: string;\n\tevent_type: string | null;\n\tmessage: string;\n\tframe: string | null;\n\tcount: Generated<string | number>;\n\tsample_tx_id: string | null;\n\tsample_block_height: string | number | null;\n\tfirst_seen: Generated<Date>;\n\tlast_seen: Generated<Date>;\n}\n\n/**\n * One ranked dashboard insight. `account_id` is NULL on tenant and self-host\n * databases. `severity` is never \"recovered\": that is derived on read from\n * `resolved_at`.\n */\nexport interface InsightsTable {\n\tid: Generated<string>;\n\taccount_id: string | null;\n\tresource_kind: string;\n\tresource_id: string;\n\trule: string;\n\tseverity: string;\n\timpact: Generated<number>;\n\t/** resource, line, meta, lead, body, evidence, handoff, how. */\n\tpayload: unknown;\n\tfirst_seen_at: Generated<Date>;\n\tlast_seen_at: Generated<Date>;\n\tclear_streak: Generated<number>;\n\tresolved_at: Date | null;\n\tdismissed_at: Date | null;\n\tsnoozed_until: Date | null;\n}\n\n/** \"Expected\": mutes one rule for one resource until removed. */\nexport interface InsightMutesTable {\n\taccount_id: string | null;\n\tresource_kind: string;\n\tresource_id: string;\n\trule: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface ProcessedStripeEventsTable {\n\tevent_id: string;\n\tevent_type: string;\n\tprocessed_at: Generated<Date>;\n}\n\nexport interface DecodedEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: string;\n\tmicroblock_hash: string | null;\n\tcanonical: Generated<boolean>;\n\tcontract_id: string | null;\n\tsender: string | null;\n\trecipient: string | null;\n\tamount: string | null;\n\tasset_identifier: string | null;\n\tvalue: string | null;\n\tmemo: string | null;\n\t/** Decoded payload for event types that don't fit the flat columns\n\t * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */\n\tpayload: unknown | null;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface DecoderCheckpointsTable {\n\tdecoder_name: string;\n\tlast_cursor: string | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface ChainReorgsTable {\n\tid: Generated<string>;\n\tdetected_at: Generated<Date>;\n\tfork_point_height: number;\n\told_index_block_hash: string | null;\n\tnew_index_block_hash: string | null;\n\torphaned_from_height: number;\n\torphaned_from_event_index: number;\n\torphaned_to_height: number;\n\torphaned_to_event_index: number;\n\tnew_canonical_height: number;\n\tnew_canonical_event_index: number;\n\tcreated_at: Generated<Date>;\n}\n\n// ── L2 decoded tables: PoX-4 / sBTC / BNS ────────────────────────────\n\nexport type Pox4FunctionName =\n\t| \"stack-stx\"\n\t| \"delegate-stx\"\n\t| \"stack-extend\"\n\t| \"stack-increase\"\n\t| \"revoke-delegate-stx\"\n\t| \"delegate-stack-stx\"\n\t| \"delegate-stack-extend\"\n\t| \"delegate-stack-increase\"\n\t| \"stack-aggregation-commit\"\n\t| \"stack-aggregation-commit-indexed\"\n\t| \"stack-aggregation-increase\"\n\t| \"set-signer-key-authorization\";\n\nexport interface Pox4CallsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\tburn_block_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tfunction_name: Pox4FunctionName;\n\tcaller: string;\n\tstacker: string | null;\n\tdelegate_to: string | null;\n\tamount_ustx: string | null;\n\tlock_period: number | null;\n\tpox_addr_version: number | null;\n\tpox_addr_hashbytes: string | null;\n\tpox_addr_btc: string | null;\n\tstart_cycle: number | null;\n\tend_cycle: number | null;\n\tsigner_key: string | null;\n\tsigner_signature: string | null;\n\tauth_id: string | null;\n\tmax_amount: string | null;\n\treward_cycle: number | null;\n\taggregated_amount_ustx: string | null;\n\taggregated_signer_index: number | null;\n\tauth_period: number | null;\n\tauth_topic: string | null;\n\tauth_allowed: boolean | null;\n\tresult_ok: boolean;\n\tresult_raw: string;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type Pox5EventTopic =\n\t| \"set-bond-admin\"\n\t| \"set-pause-admin\"\n\t| \"pause-rewards\"\n\t| \"setup-bond\"\n\t| \"add-to-allowlist\"\n\t| \"register-for-bond\"\n\t| \"update-bond-registration\"\n\t| \"register-signer\"\n\t| \"stake\"\n\t| \"stake-update\"\n\t| \"announce-l1-early-exit\"\n\t| \"unstake-sbtc\"\n\t| \"unstake\"\n\t| \"calculate-rewards\"\n\t| \"bond-distribution\"\n\t| \"claim-rewards\"\n\t| \"claim-staker-rewards-for-signer\"\n\t| \"grant-signer-key\"\n\t| \"revoke-signer-grant\";\n\n// PoX-5 print events (SIP-045). Promoted columns cover hot query paths; the\n// full decoded tuple always lands in `data` (nested shapes: btc-lockup,\n// bond-rewards lists, bond-periods).\nexport interface Pox5EventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: Pox5EventTopic;\n\tstaker: string | null;\n\tsigner: string | null;\n\tsigner_manager: string | null;\n\tbond_index: number | null;\n\tamount_ustx: string | null;\n\tamount_sats: string | null;\n\treward_cycle: number | null;\n\tfirst_reward_cycle: number | null;\n\tunlock_cycle: number | null;\n\tunlock_burn_height: number | null;\n\tis_l1_lock: boolean | null;\n\tsigner_key: string | null;\n\tdata: unknown;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\n// Materialized per-cycle PoX-5 rollup (`rollupPox5Cycles`), maintained after\n// every committed pox5 decoder batch and after a pox5 reorg. Fully\n// rebuildable from `pox5_events` via `rebuild-pox5-cycles.ts --apply`.\nexport interface Pox5CyclesTable {\n\treward_cycle: number;\n\tstart_burn_height: number;\n\tprepare_start_burn_height: number;\n\tend_burn_height: number;\n\ttotal_stacked_ustx: string;\n\treward_eligible_ustx: string;\n\tstakers: number;\n\tsigners_in_set: number;\n\t/** bond index (as string) -> sats staked for this cycle. */\n\tbond_sats: unknown;\n\tbond_total_sats: string;\n\tsbtc_custodied_sats: string;\n\trewards_allocated_stx: string;\n\trewards_allocated_bond: string;\n\treserve_deposit: string;\n\trewards_per_token_stx: string | null;\n\t/** bond index (as string) -> cumulative rewards-per-sat for this cycle. */\n\trewards_per_token_bond: unknown;\n\tdistributions: number;\n\trewards_claimed: string;\n\tcomputed_through_height: number;\n\tupdated_at: Generated<Date>;\n}\n\n// Per-signer half of the pox-5 cycle rollup.\nexport interface Pox5CycleSignersTable {\n\treward_cycle: number;\n\tsigner: string;\n\tdelegated_ustx: string;\n\tstx_only_ustx: string;\n\treward_shares_ustx: string;\n\tin_set: boolean;\n\trewards_claimed: string;\n}\n\n// Actual BTC PoX payout — one row per reward slot (≤2 per burn block), from the\n// /new_burn_block reward_recipients array. `amount_sats`/`burn_amount` are sats.\nexport interface BurnBlockRewardsTable {\n\tcursor: string;\n\tburn_block_height: number;\n\tburn_block_hash: string;\n\treward_index: number;\n\trecipient_btc: string;\n\t// sats; TEXT to match the dataset amount convention (BIGINT returns as string).\n\tamount_sats: string;\n\tburn_amount: Generated<string>;\n\tcreated_at: Generated<Date>;\n}\n\n// Reward-set membership per burn block, from /new_burn_block reward_slot_holders.\nexport interface BurnBlockRewardSlotsTable {\n\tcursor: string;\n\tburn_block_height: number;\n\tburn_block_hash: string;\n\tslot_index: number;\n\tholder_btc: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type SbtcEventTopic =\n\t| \"completed-deposit\"\n\t| \"withdrawal-create\"\n\t| \"withdrawal-accept\"\n\t| \"withdrawal-reject\"\n\t| \"key-rotation\"\n\t| \"update-protocol-contract\";\n\nexport interface SbtcEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: SbtcEventTopic;\n\trequest_id: number | null;\n\tamount: string | null;\n\tsender: string | null;\n\trecipient_btc_version: number | null;\n\trecipient_btc_hashbytes: string | null;\n\tbitcoin_txid: string | null;\n\toutput_index: number | null;\n\tsweep_txid: string | null;\n\tburn_hash: string | null;\n\tburn_height: number | null;\n\tsigner_bitmap: string | null;\n\tmax_fee: string | null;\n\tfee: string | null;\n\tblock_height_at_request: number | null;\n\tgovernance_contract_type: number | null;\n\tgovernance_new_contract: string | null;\n\tsigner_aggregate_pubkey: string | null;\n\tsigner_threshold: number | null;\n\tsigner_address: string | null;\n\tsigner_keys_count: number | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type SbtcTokenEventType = \"transfer\" | \"mint\" | \"burn\";\n\nexport interface SbtcTokenEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: SbtcTokenEventType;\n\tsender: string | null;\n\trecipient: string | null;\n\tamount: string;\n\tmemo: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * BTC L1 settlement status for sBTC withdrawal sweeps. Filled by the indexer's\n * settlement-confirmer worker, which polls our own bitcoind for confirmations of\n * each `withdrawal-accept`'s `sweep_txid` and surfaces real settlement on the\n * withdrawal lifecycle (the API's `settlement.{btc_confirmations,\n * settlement_confirmed}` placeholder). Keyed on `sweep_txid` (not `request_id`):\n * a request can produce more than one sweep over its life (RBF/rebroadcast), so\n * each broadcast keeps its own confirmation history.\n */\nexport interface SbtcSettlementsTable {\n\tsweep_txid: string;\n\trequest_id: number;\n\tbtc_confirmations: Generated<number>;\n\tsettlement_confirmed: Generated<boolean>;\n\t/** Confirming Bitcoin block — null while the sweep is unconfirmed. */\n\tblock_hash: string | null;\n\tblock_height: number | null;\n\tfirst_seen_at: Generated<Date>;\n\tlast_checked_at: Generated<Date>;\n\t/** Set once, when `settlement_confirmed` first flips true. */\n\tconfirmed_at: Date | null;\n\t/** Monotonic stamp from `sbtc_settlements_seq`, retaken each time the sweep\n\t * becomes confirmed. The webhook scan's watermark. BIGINT: a string at\n\t * runtime. */\n\tseq: Generated<number | string>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type BnsNameEventTopic =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\nexport interface BnsNameEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: BnsNameEventTopic;\n\tnamespace: string;\n\tname: string;\n\tfqn: string;\n\towner: string | null;\n\tbns_id: string;\n\tregistered_at: number | null;\n\timported_at: number | null;\n\trenewal_height: number | null;\n\tstx_burn: string | null;\n\tpreordered_by: string | null;\n\thashed_salted_fqn_preorder: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type BnsNamespaceEventStatus =\n\t| \"launch\"\n\t| \"transfer-manager\"\n\t| \"freeze-manager\"\n\t| \"update-price-manager\"\n\t| \"freeze-price-manager\"\n\t| \"turn-off-manager-transfers\";\n\nexport interface BnsNamespaceEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tstatus: BnsNamespaceEventStatus;\n\tnamespace: string;\n\tmanager: string | null;\n\tmanager_frozen: boolean | null;\n\tmanager_transfers_disabled: boolean | null;\n\tprice_function: string | null;\n\tprice_frozen: boolean | null;\n\tlifetime: number | null;\n\trevealed_at: number | null;\n\tlaunched_at: number | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type BnsMarketplaceAction =\n\t| \"list-in-ustx\"\n\t| \"unlist-in-ustx\"\n\t| \"buy-in-ustx\";\n\nexport interface BnsMarketplaceEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\taction: BnsMarketplaceAction;\n\tbns_id: string;\n\tprice_ustx: string | null;\n\tcommission: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface BnsNamesTable {\n\tfqn: string;\n\tnamespace: string;\n\tname: string;\n\towner: string;\n\tbns_id: string;\n\tregistered_at: number | null;\n\trenewal_height: number | null;\n\tlast_event_cursor: string;\n\tlast_event_at: Date;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface BnsNamespacesTable {\n\tnamespace: string;\n\tmanager: string | null;\n\tmanager_frozen: Generated<boolean>;\n\tprice_frozen: Generated<boolean>;\n\tlifetime: number | null;\n\tlaunched_at: number | null;\n\tlast_event_cursor: string;\n\tlast_event_at: Date;\n\tname_count: Generated<number>;\n\tupdated_at: Generated<Date>;\n}\n\n// ── Database interface ────────────────────────────────────────────────\n\n/**\n * Memoized `ctx.client.readOnly()` results. Keyed on `index_block_hash` so a\n * reorg-replaced block never inherits the orphaned fork's answer; a NULL\n * `index_block_hash` marks a caller-declared contract-constant value, cached\n * once per contract+args instead of once per block.\n */\nexport interface ChainReadCacheTable {\n\tid: Generated<number>;\n\tcontract_id: string;\n\tfunction_name: string;\n\targs_hash: string;\n\tindex_block_hash: string | null;\n\tblock_height: ColumnType<\n\t\tnumber | null,\n\t\tnumber | null | undefined,\n\t\tnumber | null\n\t>;\n\tresult_hex: string;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A block that arrived for a height we already hold, staged until a later\n * block's `parent_hash` says which of the two the chain kept. See migration\n * 0112 — adopting on first sight picked the losing fork twice.\n */\nexport interface PendingForkBlocksTable {\n\theight: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\t/** The canonical hash we held at this height when the contender arrived. */\n\tincumbent_hash: string;\n\t/** The raw observer payload, replayed verbatim if this fork wins. */\n\tpayload: ColumnType<unknown, unknown, unknown>;\n\treceived_at: Generated<Date>;\n}\n\n/** Mirrored by the CHECK on `observer_journal.status`. */\nexport const OBSERVER_JOURNAL_STATUSES = [\n\t\"received\",\n\t\"processed\",\n\t\"failed\",\n\t\"retried\",\n\t\"poisoned\",\n\t\"skipped\",\n] as const;\nexport type ObserverJournalStatus = (typeof OBSERVER_JOURNAL_STATUSES)[number];\n\n/**\n * Exact observer callback receipt. `raw_body` is immutable evidence; the\n * processing columns are updated only after the current derived-state write\n * succeeds or fails.\n */\nexport interface ObserverJournalTable {\n\tsequence: Generated<string>;\n\tnetwork: string;\n\tpath: string;\n\tsource: string | null;\n\treceived_at: Generated<Date>;\n\traw_body: ColumnType<Buffer, Buffer, Buffer>;\n\traw_body_sha256: string;\n\tstatus: ColumnType<\n\t\tObserverJournalStatus,\n\t\tObserverJournalStatus | undefined,\n\t\tObserverJournalStatus\n\t>;\n\tsemantic_sha256: string | null;\n\tblock_height: number | null;\n\tblock_hash: string | null;\n\tburn_block_height: number | null;\n\tburn_block_hash: string | null;\n\tresult: unknown | null;\n\terror: string | null;\n\tprocessed_at: Date | null;\n}\n\n/** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */\nexport interface StageRegistryTable {\n\tid: string;\n\tkind: StageKind;\n\tdepends_on: string | null;\n\tnative_clock: NativeClock;\n\tproducer_version: string;\n\trepair_mode: RepairMode;\n\tenabled: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\n/** One versioned sweep of a stage. Nothing writes this table yet; kept because the receipts and failures tables reference it. */\nexport interface StageRunsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\tcode_hash: string;\n\tconfig_hash: string;\n\thandler_hash: string | null;\n\ttarget_height: number | null;\n\ttarget_cursor: string | null;\n\tstatus: RunStatus;\n\tcomplete_through: number | null;\n\tstarted_at: Generated<Date>;\n\tfinished_at: Date | null;\n}\n\n/** Per-block acknowledgement. Unique on (stage, height, hash). */\nexport interface StageBlockReceiptsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\trun_id: string | null;\n\tblock_height: number;\n\tblock_hash: string;\n\tinput_count: number;\n\tinput_digest: string;\n\teffect_digest: string;\n\tfinalized: Generated<boolean>;\n\tcompacted_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** Compacted finalized range. Only sealed after receipts in the range finalize. */\nexport interface CoverageSegmentsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\tfrom_height: number;\n\tto_height: number;\n\tchain_digest: string;\n\tinput_digest: string;\n\toutput_digest: string;\n\tsealed_at: Generated<Date>;\n}\n\n/** Exact unit or range that failed, plus retry/retention state. */\nexport interface StageFailuresTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\trun_id: string | null;\n\tunit_kind: FailureUnit;\n\tfrom_height: number | null;\n\tto_height: number | null;\n\tclass: FailureClass;\n\tretry_state: RetryState;\n\tretry_count: Generated<number>;\n\tlast_error: string | null;\n\tcreated_at: Generated<Date>;\n\tresolved_at: Date | null;\n\tretain_until: Generated<Date>;\n}\n\n/**\n * The instance's declared scope — one row per network. `start_height` is what\n * makes missing history below it deliberate rather than a gap.\n */\nexport interface SyncScopesTable {\n\tnetwork: string;\n\tstart_height: number;\n\ttarget_height: number | null;\n\tbootstrap_source: BootstrapSource;\n\tbootstrap_manifest_digest: string | null;\n\tgenesis_hash: string | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface Database {\n\tblocks: BlocksTable;\n\ttransactions: TransactionsTable;\n\tevents: EventsTable;\n\tvm_events: VmEventsTable;\n\tstate_writes: StateWritesTable;\n\ttransactions_archive: TransactionsArchiveTable;\n\tevents_archive: EventsArchiveTable;\n\tvm_events_archive: VmEventsArchiveTable;\n\tstate_writes_archive: StateWritesArchiveTable;\n\tdead_letter_events: DeadLetterEventsTable;\n\tmempool_transactions: MempoolTransactionsTable;\n\tindex_progress: IndexProgressTable;\n\tcontracts: ContractsTable;\n\tsubgraphs: SubgraphsTable;\n\tapi_keys: ApiKeysTable;\n\tinstances: InstancesTable;\n\taccounts: AccountsTable;\n\tsessions: SessionsTable;\n\tmagic_links: MagicLinksTable;\n\tsubgraph_health_snapshots: SubgraphHealthSnapshotsTable;\n\tsubgraph_processing_stats: SubgraphProcessingStatsTable;\n\tsubgraph_gaps: SubgraphGapsTable;\n\tsubgraph_violations: SubgraphViolationsTable;\n\tsubgraph_error_groups: SubgraphErrorGroupsTable;\n\tsubgraph_operations: SubgraphOperationsTable;\n\tprocessed_stripe_events: ProcessedStripeEventsTable;\n\taccount_spend_caps: AccountSpendCapsTable;\n\taccount_credits: AccountCreditsTable;\n\twebhooks: WebhooksTable;\n\twebhook_outbox: WebhookOutboxTable;\n\twebhook_deliveries: WebhookDeliveriesTable;\n\twebhook_delivery_hours: WebhookDeliveryHoursTable;\n\twebhook_replays: WebhookReplaysTable;\n\ttrigger_evaluator_state: TriggerEvaluatorStateTable;\n\tdecoded_events: DecodedEventsTable;\n\tdecoder_checkpoints: DecoderCheckpointsTable;\n\tchain_reorgs: ChainReorgsTable;\n\tpox4_calls: Pox4CallsTable;\n\tpox5_events: Pox5EventsTable;\n\tpox5_cycles: Pox5CyclesTable;\n\tpox5_cycle_signers: Pox5CycleSignersTable;\n\tburn_block_rewards: BurnBlockRewardsTable;\n\tburn_block_reward_slots: BurnBlockRewardSlotsTable;\n\tsbtc_events: SbtcEventsTable;\n\tsbtc_token_events: SbtcTokenEventsTable;\n\tsbtc_settlements: SbtcSettlementsTable;\n\tbns_name_events: BnsNameEventsTable;\n\tbns_namespace_events: BnsNamespaceEventsTable;\n\tbns_marketplace_events: BnsMarketplaceEventsTable;\n\tbns_names: BnsNamesTable;\n\tbns_namespaces: BnsNamespacesTable;\n\tservice_heartbeats: ServiceHeartbeatsTable;\n\tchain_read_cache: ChainReadCacheTable;\n\tpending_fork_blocks: PendingForkBlocksTable;\n\tobserver_journal: ObserverJournalTable;\n\tsync_scopes: SyncScopesTable;\n\tstage_registry: StageRegistryTable;\n\tstage_runs: StageRunsTable;\n\tstage_block_receipts: StageBlockReceiptsTable;\n\tcoverage_segments: CoverageSegmentsTable;\n\tstage_failures: StageFailuresTable;\n\tarchive_fetches: ArchiveFetchesTable;\n\tusage_ledger: UsageLedgerTable;\n\taccount_balance_alerts: AccountBalanceAlertsTable;\n\thosted_stack_state: HostedStackStateTable;\n\twebhook_incident_alerts: WebhookIncidentAlertsTable;\n\tcli_device_logins: CliDeviceLoginsTable;\n\toauth_clients: OauthClientsTable;\n\toauth_requests: OauthRequestsTable;\n\toauth_codes: OauthCodesTable;\n\toauth_grants: OauthGrantsTable;\n\toauth_tokens: OauthTokensTable;\n\toauth_refresh_retired: OauthRefreshRetiredTable;\n\tsentinel_accounts: SentinelAccountsTable;\n\twaitlists: WaitlistsTable;\n\twaitlist_signups: WaitlistSignupsTable;\n\tcontact_requests: ContactRequestsTable;\n\tupdate_subscribers: UpdateSubscribersTable;\n\tupdate_sends: UpdateSendsTable;\n\tapi_failed_requests: ApiFailedRequestsTable;\n\tapi_request_log: ApiRequestLogTable;\n\tinsights: InsightsTable;\n\tinsight_mutes: InsightMutesTable;\n\tfeedback_tickets: FeedbackTicketsTable;\n\tpush_subscriptions: PushSubscriptionsTable;\n\tpush_prefs: PushPrefsTable;\n\tpush_sent: PushSentTable;\n}\n\nexport interface ServiceHeartbeatsTable {\n\tname: string;\n\tupdated_at: Generated<Date>;\n}\n\n// --- Account spend caps (soft cap + threshold alerts) ---\n//\n// One row per account. Null caps = \"no cap\" for that dimension.\n// `monthly_cap_cents` caps this calendar month's pay-as-you-go credit spend.\n// The hard stop is enforced in real time on the read path (read-credits.ts);\n// `frozen_at` is a display/alert mirror set by the daily cron when the cap is\n// hit, and cleared on month rollover, on invoice.paid, or when the cap is raised.\n\nexport interface AccountSpendCapsTable {\n\taccount_id: string;\n\tmonthly_cap_cents: number | null;\n\tcompute_cap_cents: number | null;\n\tstorage_cap_cents: number | null;\n\talert_threshold_pct: Generated<number>;\n\talert_sent_at: Date | null;\n\tfrozen_at: Date | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport type AccountSpendCap = Selectable<AccountSpendCapsTable>;\nexport type InsertAccountSpendCap = Insertable<AccountSpendCapsTable>;\nexport type UpdateAccountSpendCap = Updateable<AccountSpendCapsTable>;\n\n/** Prepaid dev credits — card-funded balance per account. */\nexport interface AccountCreditsTable {\n\taccount_id: string;\n\tbalance_usd_micros: Generated<string | number | bigint>;\n\t/** Month bucket (\"YYYY-MM\") the spend counter applies to. */\n\tspent_month: string | null;\n\tspent_month_usd_micros: Generated<string | number | bigint>;\n\t/** Null = auto-refill off. */\n\trefill_below_usd_micros: string | number | bigint | null;\n\trefill_pack_usd: number | null;\n\trefill_last_at: Date | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport type AccountCredits = Selectable<AccountCreditsTable>;\nexport type InsertAccountCredits = Insertable<AccountCreditsTable>;\nexport type UpdateAccountCredits = Updateable<AccountCreditsTable>;\n\n/**\n * Archive fetch charge log. Append-only: one row per\n * priced attempt to fetch a partition object. `usd_micros` is 0 for\n * free rows (24h re-issue, monthly repair allowance).\n */\nexport interface ArchiveFetchesTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tpath: string;\n\tdataset: string;\n\tusd_micros: string | number | bigint;\n\tvia_allowance: Generated<boolean>;\n\tcharged_at: Generated<Date>;\n}\n\nexport type ArchiveFetch = Selectable<ArchiveFetchesTable>;\nexport type InsertArchiveFetch = Insertable<ArchiveFetchesTable>;\nexport type UpdateArchiveFetch = Updateable<ArchiveFetchesTable>;\n\n/**\n * One metered ledger for every billable unit (archive partitions, hosted\n * Index/Streams rows, and future hosted-stack meters). Append-only, written\n * only by `meter()`. `idempotency_key` is UNIQUE so a retried submission\n * no-ops instead of double-charging. `debited` is false when the balance\n * (or a spend cap) refused the charge — the row still exists so the gap is\n * visible, never silently dropped. `usd_micros` is negative for a Stripe\n * top-up (`unit: \"topup\"`).\n */\nexport interface UsageLedgerTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tunit: string;\n\tquantity: string | number | bigint;\n\t/** Raw sampled quantity before any floor (e.g. `memory.gb_hour`'s actual\n\t * RAM, before the 0.5 GB minimum). NULL for every unit that has no\n\t * floor to observe past. */\n\tobserved_quantity: string | number | null;\n\tusd_micros: string | number | bigint;\n\t/** True when the whole price was taken; derived from `debited_usd_micros`. */\n\tdebited: Generated<boolean>;\n\t/** Amount actually taken from the balance, `0..usd_micros` (bounded the\n\t * other way for a negative top-up/grant row). Unpaid = price - this. */\n\tdebited_usd_micros: Generated<string | number | bigint>;\n\tsource: string;\n\t/** API key behind a metered read; null for non-read units and older rows. */\n\tapi_key_id: string | null;\n\tidempotency_key: string;\n\toccurred_at: Generated<Date>;\n\trecorded_at: Generated<Date>;\n}\n\nexport type UsageLedgerRow = Selectable<UsageLedgerTable>;\nexport type InsertUsageLedgerRow = Insertable<UsageLedgerTable>;\nexport type UpdateUsageLedgerRow = Updateable<UsageLedgerTable>;\n\n/** Preferences + debounce state for the balance-runway email alerts. One\n * row per account; a missing row means both alerts are on (defaults). */\nexport interface AccountBalanceAlertsTable {\n\taccount_id: string;\n\tnotify_7d: Generated<boolean>;\n\tnotify_2d: Generated<boolean>;\n\tsent_7d_at: Date | null;\n\tsent_2d_at: Date | null;\n\tsent_stopped_at: Date | null;\n}\n\n/** The workload host's report of one account's hosted stack. Written only by\n * `POST /internal/stack-state`; `reported_at` is the host's observation time. */\nexport interface HostedStackStateTable {\n\taccount_id: string;\n\tstate: \"provisioning\" | \"running\" | \"stopped\" | \"destroyed\";\n\tstop_reason: \"credits\" | \"cap\" | \"idle\" | null;\n\treported_at: Date;\n}\n\n/** Debounce state for the webhook-down email: one row per incident, open\n * while `resolved_at` is null. No preference columns by design. */\nexport interface WebhookIncidentAlertsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\twebhook_id: string;\n\twebhook_name: string;\n\tfailing_since: Date;\n\topened_at: Generated<Date>;\n\temailed_at: Date | null;\n\temail_attempts: Generated<number>;\n\tresolved_at: Date | null;\n}\n\nexport type WebhookIncidentAlert = Selectable<WebhookIncidentAlertsTable>;\n\n/** One browser/device push subscription; the endpoint is unique. */\nexport interface PushSubscriptionsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tendpoint: string;\n\tp256dh: string;\n\tauth: string;\n\tuser_agent: string | null;\n\tcreated_at: Generated<Date>;\n\tlast_success_at: Date | null;\n\tfailed_count: Generated<number>;\n}\n\nexport type PushSubscription = Selectable<PushSubscriptionsTable>;\n\n/** Per-account push toggles. A missing row means the column defaults. */\nexport interface PushPrefsTable {\n\taccount_id: string;\n\twebhook_failing: Generated<boolean>;\n\tsubgraph_stopped: Generated<boolean>;\n\tsubgraph_not_serving: Generated<boolean>;\n\treplay_done: Generated<boolean>;\n\tspend_cap: Generated<boolean>;\n\tkey_repeat: Generated<boolean>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type PushPrefs = Selectable<PushPrefsTable>;\n\n/** A push already sent, keyed by what it was about; debounces repeat signals. */\nexport interface PushSentTable {\n\taccount_id: string;\n\tkey: string;\n\tkind: string;\n\tsent_at: Generated<Date>;\n}\n\nexport type CliDeviceLoginStatus =\n\t| \"pending\"\n\t| \"approved\"\n\t| \"denied\"\n\t| \"consumed\";\n\n/** The product that started a CLI sign-in; null is `sl login`. */\nexport type CliDeviceProduct = \"sentinel\";\n\n/** One browser sign-in attempt from `sl login` (or `sentinel login`). Only the\n * hash of the CLI's device code is stored; the session is opened when the CLI\n * polls after approval. */\nexport interface CliDeviceLoginsTable {\n\tid: Generated<string>;\n\tdevice_code_hash: string;\n\tuser_code: string;\n\tclient_name: string;\n\tproduct: CliDeviceProduct | null;\n\tstatus: Generated<CliDeviceLoginStatus>;\n\taccount_id: string | null;\n\tkey_name: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tapproved_at: Date | null;\n\tconsumed_at: Date | null;\n}\n\nexport type CliDeviceLogin = Selectable<CliDeviceLoginsTable>;\n\n// --- OAuth for the hosted MCP endpoint ---\n//\n// Codes and tokens are stored as SHA-256 hashes only. See migration\n// `0177_oauth_mcp` and `@secondlayer/platform/db/queries/oauth`.\n\n/** An app that registered itself (RFC 7591). Public clients only: no secret. */\nexport interface OauthClientsTable {\n\tid: string;\n\t/** The app's own claim, validated at registration; shown quoted. */\n\tname: string;\n\tredirect_uris: string[];\n\tcreated_ip: string | null;\n\tcreated_at: Generated<Date>;\n\t/** Set when it first gets tokens; never-used clients are purged. */\n\tlast_used_at: Date | null;\n}\n\nexport type OauthRequestStatus = \"pending\" | \"approved\" | \"denied\";\n\n/** One authorize request waiting for (or answered on) the consent page. */\nexport interface OauthRequestsTable {\n\tid: string;\n\tclient_id: string;\n\tredirect_uri: string;\n\tstate: string | null;\n\tcode_challenge: string;\n\tresource: string;\n\tstatus: Generated<OauthRequestStatus>;\n\taccount_id: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tanswered_at: Date | null;\n}\n\n/** A one-time authorization code, bound to its client, redirect, PKCE\n * challenge, resource and account. */\nexport interface OauthCodesTable {\n\tcode_hash: string;\n\tclient_id: string;\n\taccount_id: string;\n\tredirect_uri: string;\n\tcode_challenge: string;\n\tresource: string;\n\t/** The grant its one use made, so a replay can revoke it. */\n\tgrant_id: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tused_at: Date | null;\n}\n\n/** What a person allowed one app to do: use the hosted MCP as them. */\nexport interface OauthGrantsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tclient_id: string;\n\tscope: Generated<string>;\n\tresource: string;\n\tcreated_at: Generated<Date>;\n\tlast_used_at: Date | null;\n\trevoked_at: Date | null;\n}\n\nexport type OauthTokenKind = \"access\" | \"refresh\";\n\nexport interface OauthTokensTable {\n\ttoken_hash: string;\n\tgrant_id: string;\n\tkind: OauthTokenKind;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n}\n\n/** A refresh token a rotation replaced: presented again, it revokes the grant. */\nexport interface OauthRefreshRetiredTable {\n\ttoken_hash: string;\n\tgrant_id: string;\n\tretired_at: Generated<Date>;\n}\n\nexport type OauthClient = Selectable<OauthClientsTable>;\nexport type OauthGrant = Selectable<OauthGrantsTable>;\n\n/** Accounts Sentinel's service key may touch: created by Sentinel, or the\n * owner opted in. */\nexport interface SentinelAccountsTable {\n\taccount_id: string;\n\tlinked_at: Generated<Date>;\n\tvia: \"created\" | \"consent\";\n}\n\nexport type SentinelAccount = Selectable<SentinelAccountsTable>;\n\nexport type AccountBalanceAlerts = Selectable<AccountBalanceAlertsTable>;\nexport type InsertAccountBalanceAlerts = Insertable<AccountBalanceAlertsTable>;\nexport type UpdateAccountBalanceAlerts = Updateable<AccountBalanceAlertsTable>;\n\n// ── Convenience types ─────────────────────────────────────────────────\n\nexport type Block = Selectable<BlocksTable>;\nexport type InsertBlock = Insertable<BlocksTable>;\nexport type UpdateBlock = Updateable<BlocksTable>;\n\nexport type Transaction = Selectable<TransactionsTable>;\nexport type InsertTransaction = Insertable<TransactionsTable>;\nexport type UpdateTransaction = Updateable<TransactionsTable>;\n\nexport type MempoolTransaction = Selectable<MempoolTransactionsTable>;\nexport type InsertMempoolTransaction = Insertable<MempoolTransactionsTable>;\n\nexport type Event = Selectable<EventsTable>;\nexport type InsertEvent = Insertable<EventsTable>;\nexport type UpdateEvent = Updateable<EventsTable>;\n\nexport type VmEvent = Selectable<VmEventsTable>;\nexport type InsertVmEvent = Insertable<VmEventsTable>;\nexport type UpdateVmEvent = Updateable<VmEventsTable>;\nexport type StateWrite = Selectable<StateWritesTable>;\nexport type InsertStateWrite = Insertable<StateWritesTable>;\n\nexport type IndexProgress = Selectable<IndexProgressTable>;\nexport type InsertIndexProgress = Insertable<IndexProgressTable>;\nexport type UpdateIndexProgress = Updateable<IndexProgressTable>;\n\nexport type Subgraph = Selectable<SubgraphsTable>;\nexport type InsertSubgraph = Insertable<SubgraphsTable>;\nexport type UpdateSubgraph = Updateable<SubgraphsTable>;\n\nexport type Contract = Selectable<ContractsTable>;\nexport type InsertContract = Insertable<ContractsTable>;\nexport type UpdateContract = Updateable<ContractsTable>;\n\nexport type SubgraphOperation = Selectable<SubgraphOperationsTable>;\nexport type InsertSubgraphOperation = Insertable<SubgraphOperationsTable>;\nexport type UpdateSubgraphOperation = Updateable<SubgraphOperationsTable>;\n\nexport type ApiKey = Selectable<ApiKeysTable>;\nexport type InsertApiKey = Insertable<ApiKeysTable>;\nexport type UpdateApiKey = Updateable<ApiKeysTable>;\n\nexport type Account = Selectable<AccountsTable>;\nexport type InsertAccount = Insertable<AccountsTable>;\n\nexport type MagicLink = Selectable<MagicLinksTable>;\nexport type InsertMagicLink = Insertable<MagicLinksTable>;\n\nexport type Session = Selectable<SessionsTable>;\nexport type InsertSession = Insertable<SessionsTable>;\n\nexport type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;\nexport type InsertSubgraphHealthSnapshot =\n\tInsertable<SubgraphHealthSnapshotsTable>;\n\nexport type SubgraphGap = Selectable<SubgraphGapsTable>;\nexport type InsertSubgraphGap = Insertable<SubgraphGapsTable>;\n\n// ── Webhooks (chain event webhooks) ─────────────────────\n\nexport type WebhookStatus = \"active\" | \"paused\";\nexport type { WebhookPauseReason };\n\n/** Webhooks react to raw chain events matched directly off the Index/Streams\n * clock. `chain` is the only kind since migration 0159 removed subgraph-row\n * webhooks; the column stays as the discriminator. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat =\n\t| \"standard-webhooks\"\n\t| \"inngest\"\n\t| \"trigger\"\n\t| \"cloudflare\"\n\t| \"cloudevents\"\n\t| \"raw\";\n\nexport interface WebhooksTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tproject_id: string | null;\n\tname: string;\n\tstatus: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;\n\tkind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;\n\t/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Typed\n\t * loosely here to avoid a shared→subgraphs import cycle; the Zod schema in\n\t * schemas/webhooks.ts owns the shape. */\n\ttriggers: unknown;\n\tformat: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;\n\turl: string;\n\tsigning_secret_enc: Buffer;\n\tauth_config: Generated<unknown>;\n\tmax_retries: Generated<number>;\n\ttimeout_ms: Generated<number>;\n\tconcurrency: Generated<number>;\n\tcircuit_failures: Generated<number>;\n\tcircuit_opened_at: Date | null;\n\t/** Why a paused webhook is paused. Set exactly while `status` is `paused`. */\n\tpause_reason: WebhookPauseReason | null;\n\tlast_delivery_at: Date | null;\n\tlast_success_at: Date | null;\n\tlast_error: string | null;\n\t/** Receiver TLS leaf certificate expiry, from the emitter's periodic probe. */\n\treceiver_cert_expires_at: Date | null;\n\treceiver_cert_checked_at: Date | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type Webhook = Selectable<WebhooksTable>;\nexport type InsertWebhook = Insertable<WebhooksTable>;\nexport type UpdateWebhook = Updateable<WebhooksTable>;\n\nexport type OutboxStatus = \"pending\" | \"delivered\" | \"dead\";\n/** Why a row is dead: retries ran out, or a reorg removed its event. An\n * orphaned row stays dead; requeueing it would resend an event the chain no\n * longer contains. */\nexport type DeadReason = \"exhausted\" | \"orphaned\";\n\nexport interface WebhookOutboxTable {\n\tid: Generated<string>;\n\twebhook_id: string;\n\tkind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;\n\tblock_height: number | bigint;\n\ttx_id: string | null;\n\trow_pk: unknown;\n\tevent_type: string;\n\tpayload: unknown;\n\tdedup_key: string;\n\tattempt: Generated<number>;\n\tnext_attempt_at: Generated<Date>;\n\tstatus: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;\n\tis_replay: Generated<boolean>;\n\t/** The replay that created this row; null for live rows. */\n\treplay_id: string | null;\n\t/** The chain block_time of the matched event/tx. Null for rows written\n\t * before this column existed, and for the settlement scan path (not yet\n\t * wired). Lets `delivered_at - block_time` measure end-to-end webhook\n\t * latency without a join to SOURCE-plane `blocks`. */\n\tblock_time: Date | null;\n\tdelivered_at: Date | null;\n\tfailed_at: Date | null;\n\tlocked_by: string | null;\n\tlocked_until: Date | null;\n\t/** Set when a reorg marks an in-flight row `dead` instead of retrying it\n\t * into an orphaned fork. Null otherwise — delivery failures track their\n\t * history on `webhooks.last_error`, not per-row. */\n\tlast_error: string | null;\n\t/** Set exactly while `status` is `dead`. */\n\tdead_reason: DeadReason | null;\n\t/** Hash of the block a chain apply row was emitted for. Null on rows\n\t * written before the column existed (the payload carries it too). */\n\tblock_hash: string | null;\n\t/** Set when a reorg rollback recalled this delivered apply row, so a\n\t * later rollback for the same reorg skips it. */\n\trolled_back_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type WebhookReplayStatus = \"scanning\" | \"running\" | \"done\" | \"failed\";\n\nexport interface WebhookReplaysTable {\n\tid: string;\n\twebhook_id: string;\n\tfrom_block: number | bigint;\n\tto_block: number | bigint;\n\tstatus: WebhookReplayStatus;\n\tscanned_count: Generated<number>;\n\tenqueued_count: Generated<number>;\n\ttotal: number | null;\n\tdelivered: number | null;\n\tgave_up: number | null;\n\terror: string | null;\n\tstarted_at: Generated<Date>;\n\tfinished_at: Date | null;\n}\nexport type WebhookReplay = Selectable<WebhookReplaysTable>;\n\n/** `replay_id` is optional on the row type so hand-built rows (the test\n * delivery, fixtures) need not carry it; reads still return it. */\nexport type WebhookOutbox = Omit<\n\tSelectable<WebhookOutboxTable>,\n\t\"replay_id\"\n> & {\n\treplay_id?: string | null;\n};\nexport type InsertWebhookOutbox = Insertable<WebhookOutboxTable>;\nexport type UpdateWebhookOutbox = Updateable<WebhookOutboxTable>;\n\nexport interface WebhookDeliveriesTable {\n\tid: Generated<string>;\n\t/** Nullable after migration 0077 — outbox row may be cleaned up while\n\t * delivery telemetry is retained. */\n\toutbox_id: string | null;\n\twebhook_id: string;\n\tattempt: number;\n\tstatus_code: number | null;\n\tresponse_headers: unknown | null;\n\tresponse_body: string | null;\n\terror_message: string | null;\n\tduration_ms: number | null;\n\tdispatched_at: Generated<Date>;\n}\n\n/** Attempts per UTC hour, counted by a trigger on `webhook_deliveries`. */\nexport interface WebhookDeliveryHoursTable {\n\twebhook_id: string;\n\thour: Date;\n\t/** 2xx attempts. */\n\tdelivered: Generated<number>;\n\t/** Every other attempt. */\n\tfailed: Generated<number>;\n}\n\nexport type WebhookDelivery = Selectable<WebhookDeliveriesTable>;\nexport type InsertWebhookDelivery = Insertable<WebhookDeliveriesTable>;\n\n/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.\n * One loop serves all chain webhooks, so the cursor is global. */\nexport interface TriggerEvaluatorStateTable {\n\tid: Generated<boolean>;\n\tlast_processed_block: ColumnType<\n\t\tbigint,\n\t\tbigint | number | undefined,\n\t\tbigint | number\n\t>;\n\t/** Watermark for the async sBTC settlement-confirmed webhook scan; null until\n\t * the evaluator fast-forwards it on first run. */\n\tlast_settlement_scan_at: ColumnType<\n\t\tDate | null,\n\t\tDate | null | undefined,\n\t\tDate | null\n\t>;\n\t/** `sbtc_settlements.seq` watermark. Null until the first settlement row is\n\t * scanned; `last_settlement_scan_at` is the forward-only floor until then. */\n\tlast_settlement_scan_seq: ColumnType<\n\t\tbigint | null,\n\t\tbigint | number | null | undefined,\n\t\tbigint | number | null\n\t>;\n\t/** Counts reorg rewinds. The evaluator checks it under the row lock in the\n\t * transaction that emits a batch and advances the cursor, so a reorg that\n\t * lands mid-tick rolls the batch back. */\n\treorg_generation: ColumnType<\n\t\tbigint,\n\t\tbigint | number | undefined,\n\t\tbigint | number\n\t>;\n\t/** Streams cursor (`<block_height>:<event_index>`) for the Bitcoin (Runes)\n\t * chain-trigger evaluator (plan 060) — a separate clock from\n\t * `last_processed_block` (Stacks). Null until the evaluator fast-forwards\n\t * it to the Bitcoin Streams tip on first run. */\n\tbitcoin_last_cursor: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;\n\n/** A public waitlist page: what it is for and whether it takes signups. */\nexport interface WaitlistsTable {\n\tslug: string;\n\ttitle: string;\n\tdescription: string;\n\turl: string;\n\topened_at: Generated<Date>;\n\t/** Null while the list is open. */\n\tclosed_at: Date | null;\n}\n\n/**\n * One signup per (list, contact, token). `answers` holds the list's own\n * questions, validated per list by the API before insert.\n */\nexport interface WaitlistSignupsTable {\n\tid: Generated<string>;\n\tlist: string;\n\tcontact: string;\n\tanswers: Record<string, unknown>;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A \"Talk to us\" message. Stored before the operator is emailed;\n * `notified_at` stays null until the email goes out.\n */\nexport interface ContactRequestsTable {\n\tid: Generated<string>;\n\tname: string;\n\temail: string;\n\tcompany: string | null;\n\tvolume: \"lt10m\" | \"10m-100m\" | \"100m-1b\" | \"gt1b\" | \"unsure\" | null;\n\tmessage: string;\n\tsource_page: string | null;\n\taccount_id: string | null;\n\t/** Hex sha256 of the client IP, never the address. */\n\tip_hash: string | null;\n\tnotified_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A member of the email updates list. `pending` until the emailed link is\n * confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while\n * subscribed, `unsubscribed` after an opt-out. `token` is the secret in\n * confirm and unsubscribe links.\n */\nexport interface UpdateSubscribersTable {\n\tid: Generated<string>;\n\temail: string;\n\tstatus: Generated<\"pending\" | \"confirmed\" | \"unsubscribed\">;\n\ttoken: string;\n\tsource_page: string | null;\n\t/** Hex sha256 of the client IP, never the address. */\n\tip_hash: string | null;\n\tconfirm_sent_at: Date | null;\n\tconfirmed_at: Date | null;\n\tunsubscribed_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** One broadcast (`send_key`) delivered to one subscriber. */\nexport interface UpdateSendsTable {\n\tsend_key: string;\n\tsubscriber_id: string;\n\tsent_at: Generated<Date>;\n}\n\n/**\n * 24h hosted record of a failed API request, keyed by `request_id` and\n * scoped to the account that made it. `query` is redacted before insert.\n */\nexport interface ApiFailedRequestsTable {\n\trequest_id: string;\n\taccount_id: string;\n\tmethod: string;\n\tpath: string;\n\tstatus: number;\n\tcode: string;\n\tmessage: Generated<string>;\n\tquery: Record<string, unknown>;\n\torigin: string | null;\n\t/** Revoked account key the request presented (`KEY_REVOKED` only). */\n\tapi_key_id: string | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type ApiFailedRequest = Selectable<ApiFailedRequestsTable>;\nexport type InsertApiFailedRequest = Insertable<ApiFailedRequestsTable>;\n\n/**\n * 7-day hosted log of account-attributed Index/Streams reads. Query values\n * are stored only as hashes; never bodies, headers or tokens.\n */\nexport interface ApiRequestLogTable {\n\tid: Generated<string>;\n\trequest_id: string | null;\n\taccount_id: string;\n\tapi_key_id: string | null;\n\tmethod: string;\n\tpath: string;\n\tpath_template: string;\n\tparams_hash: string | null;\n\tcursor_hash: string | null;\n\tpage_size: number | null;\n\trows: number | null;\n\tstatus: number;\n\tduration_ms: number;\n\tcreated_at: Generated<Date>;\n}\n\nexport type ApiRequestLogRow = Selectable<ApiRequestLogTable>;\nexport type InsertApiRequestLogRow = Insertable<ApiRequestLogTable>;\n\n/**\n * Hosted problem report. `attempted` is the server's own copy of the failed\n * request (never caller-supplied); `status` starts `new` until classified.\n */\nexport interface FeedbackTicketsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tidempotency_key: string | null;\n\trequest_id: string | null;\n\tintent: string;\n\t/** Any JSON value the caller sent: a sentence or a shape. */\n\texpected: unknown;\n\tkind_hint: string | null;\n\tevidence: Record<string, unknown> | null;\n\tattempted: Record<string, unknown> | null;\n\torigin: string;\n\tstatus: Generated<\"new\" | \"classified\">;\n\troute: string | null;\n\tclassification: Record<string, unknown> | null;\n\tclassified_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type FeedbackTicket = Selectable<FeedbackTicketsTable>;\nexport type InsertFeedbackTicket = Insertable<FeedbackTicketsTable>;\n\nexport type Waitlist = Selectable<WaitlistsTable>;\nexport type WaitlistSignup = Selectable<WaitlistSignupsTable>;\nexport type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;\n\nexport type ContactRequest = Selectable<ContactRequestsTable>;\nexport type InsertContactRequest = Insertable<ContactRequestsTable>;\n\nexport type UpdateSubscriber = Selectable<UpdateSubscribersTable>;\nexport type InsertUpdateSubscriber = Insertable<UpdateSubscribersTable>;\n",
12
- "import type { Database } from \"./types.ts\";\n\n// The physical source-table columns the public read API (packages/api) actually\n// reads via getSourceDb(). This is the read contract between the indexer (which\n// owns the write schema) and the API (which reads it raw). A column rename or\n// removal on the producer side that isn't reflected here is caught by the\n// snapshot drift test; the `satisfies` clause guarantees every entry is a real\n// table + column today.\n//\n// Computed/aliased read expressions are intentionally excluded — they are not\n// part of the producer contract: `cursor`/`block_time` where derived in SQL\n// rather than stored, window ranks (stream_event_index), and JSONB extractions\n// from `events.data`. Generated bookkeeping columns (created_at/updated_at) are\n// excluded unless a read path selects them.\nexport const SOURCE_READ_COLUMNS = {\n\tblocks: [\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"canonical\",\n\t\t\"hash\",\n\t\t\"height\",\n\t\t\"parent_hash\",\n\t\t\"timestamp\",\n\t],\n\tdecoded_events: [\n\t\t\"amount\",\n\t\t\"asset_identifier\",\n\t\t\"block_height\",\n\t\t\"canonical\",\n\t\t\"contract_id\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"event_type\",\n\t\t\"memo\",\n\t\t\"payload\",\n\t\t\"recipient\",\n\t\t\"sender\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"value\",\n\t],\n\ttransactions: [\n\t\t\"block_height\",\n\t\t\"contract_id\",\n\t\t\"function_args\",\n\t\t\"function_name\",\n\t\t\"raw_result\",\n\t\t\"raw_tx\",\n\t\t\"sender\",\n\t\t\"status\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"type\",\n\t],\n\tmempool_transactions: [\n\t\t\"contract_id\",\n\t\t\"function_args\",\n\t\t\"function_name\",\n\t\t\"raw_tx\",\n\t\t\"received_at\",\n\t\t\"sender\",\n\t\t\"seq\",\n\t\t\"tx_id\",\n\t\t\"type\",\n\t],\n\tpox4_calls: [\n\t\t\"aggregated_amount_ustx\",\n\t\t\"aggregated_signer_index\",\n\t\t\"amount_ustx\",\n\t\t\"auth_allowed\",\n\t\t\"auth_id\",\n\t\t\"auth_period\",\n\t\t\"auth_topic\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"burn_block_height\",\n\t\t\"caller\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"delegate_to\",\n\t\t\"end_cycle\",\n\t\t\"function_name\",\n\t\t\"lock_period\",\n\t\t\"max_amount\",\n\t\t\"pox_addr_btc\",\n\t\t\"pox_addr_hashbytes\",\n\t\t\"pox_addr_version\",\n\t\t\"result_ok\",\n\t\t\"reward_cycle\",\n\t\t\"signer_key\",\n\t\t\"signer_signature\",\n\t\t\"source_cursor\",\n\t\t\"stacker\",\n\t\t\"start_cycle\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tpox5_events: [\n\t\t\"amount_sats\",\n\t\t\"amount_ustx\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bond_index\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"data\",\n\t\t\"event_index\",\n\t\t\"first_reward_cycle\",\n\t\t\"is_l1_lock\",\n\t\t\"reward_cycle\",\n\t\t\"signer\",\n\t\t\"signer_key\",\n\t\t\"signer_manager\",\n\t\t\"staker\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"unlock_burn_height\",\n\t\t\"unlock_cycle\",\n\t],\n\tsbtc_events: [\n\t\t\"amount\",\n\t\t\"bitcoin_txid\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"burn_hash\",\n\t\t\"burn_height\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"fee\",\n\t\t\"governance_contract_type\",\n\t\t\"governance_new_contract\",\n\t\t\"max_fee\",\n\t\t\"output_index\",\n\t\t\"recipient_btc_hashbytes\",\n\t\t\"recipient_btc_version\",\n\t\t\"request_id\",\n\t\t\"sender\",\n\t\t\"signer_address\",\n\t\t\"signer_aggregate_pubkey\",\n\t\t\"signer_bitmap\",\n\t\t\"signer_keys_count\",\n\t\t\"signer_threshold\",\n\t\t\"sweep_txid\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tsbtc_token_events: [\n\t\t\"amount\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"event_type\",\n\t\t\"memo\",\n\t\t\"recipient\",\n\t\t\"sender\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_name_events: [\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bns_id\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"fqn\",\n\t\t\"hashed_salted_fqn_preorder\",\n\t\t\"imported_at\",\n\t\t\"name\",\n\t\t\"namespace\",\n\t\t\"owner\",\n\t\t\"preordered_by\",\n\t\t\"registered_at\",\n\t\t\"renewal_height\",\n\t\t\"stx_burn\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_namespace_events: [\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"launched_at\",\n\t\t\"lifetime\",\n\t\t\"manager\",\n\t\t\"manager_frozen\",\n\t\t\"manager_transfers_disabled\",\n\t\t\"namespace\",\n\t\t\"price_frozen\",\n\t\t\"price_function\",\n\t\t\"revealed_at\",\n\t\t\"status\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_marketplace_events: [\n\t\t\"action\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bns_id\",\n\t\t\"canonical\",\n\t\t\"commission\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"price_ustx\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_names: [\n\t\t\"bns_id\",\n\t\t\"fqn\",\n\t\t\"last_event_at\",\n\t\t\"last_event_cursor\",\n\t\t\"name\",\n\t\t\"namespace\",\n\t\t\"owner\",\n\t\t\"registered_at\",\n\t\t\"renewal_height\",\n\t],\n\tbns_namespaces: [\n\t\t\"last_event_at\",\n\t\t\"last_event_cursor\",\n\t\t\"launched_at\",\n\t\t\"lifetime\",\n\t\t\"manager\",\n\t\t\"manager_frozen\",\n\t\t\"name_count\",\n\t\t\"namespace\",\n\t\t\"price_frozen\",\n\t],\n\tburn_block_rewards: [\n\t\t\"amount_sats\",\n\t\t\"burn_amount\",\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"cursor\",\n\t\t\"recipient_btc\",\n\t\t\"reward_index\",\n\t],\n\tburn_block_reward_slots: [\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"cursor\",\n\t\t\"holder_btc\",\n\t\t\"slot_index\",\n\t],\n\tevents: [\"block_height\", \"data\", \"event_index\", \"tx_id\", \"type\"],\n\tchain_reorgs: [\"detected_at\"],\n} as const satisfies {\n\treadonly [T in keyof Database]?: readonly (keyof Database[T])[];\n};\n\n/** Portable column type for the Index read domain (a lean, ORM-agnostic vocab). */\nexport type IndexColumnType =\n\t| \"text\"\n\t| \"int\"\n\t| \"boolean\"\n\t| \"timestamp\"\n\t| \"jsonb\";\n\nexport interface IndexColumn {\n\ttype: IndexColumnType;\n\t/** SELECT type includes `| null`. Omitted = NOT NULL. */\n\tnullable?: boolean;\n}\n\n// The portable TS/SQL type for every column in SOURCE_READ_COLUMNS, single-sourced\n// from the `Database` interface (the producer's typed schema). This is what lets\n// `sl codegen index` emit a typed ORM/JSON-Schema for the public Index domain so a\n// read mirror is fully typed and can't drift from the API. The drift test\n// (source-read-columns.test.ts) asserts this covers exactly SOURCE_READ_COLUMNS;\n// the `satisfies` clause guarantees a type entry for every read table.\n//\n// `string` amount/value columns (e.g. amount_ustx, fee, price_ustx) are NUMERIC in\n// Postgres surfaced as strings — `text` here is lossless for a read mirror. `number`\n// columns map to `int`. Enum string-unions (topic, status, …) map to `text`.\nexport const SOURCE_READ_TYPES = {\n\tblocks: {\n\t\tburn_block_hash: { type: \"text\", nullable: true },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\thash: { type: \"text\" },\n\t\theight: { type: \"int\" },\n\t\tparent_hash: { type: \"text\" },\n\t\ttimestamp: { type: \"int\" },\n\t},\n\tdecoded_events: {\n\t\tamount: { type: \"text\", nullable: true },\n\t\tasset_identifier: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tevent_type: { type: \"text\" },\n\t\tmemo: { type: \"text\", nullable: true },\n\t\tpayload: { type: \"jsonb\", nullable: true },\n\t\trecipient: { type: \"text\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\tvalue: { type: \"text\", nullable: true },\n\t},\n\ttransactions: {\n\t\tblock_height: { type: \"int\" },\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tfunction_args: { type: \"jsonb\", nullable: true },\n\t\tfunction_name: { type: \"text\", nullable: true },\n\t\traw_result: { type: \"text\", nullable: true },\n\t\traw_tx: { type: \"text\" },\n\t\tsender: { type: \"text\" },\n\t\tstatus: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tmempool_transactions: {\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tfunction_args: { type: \"jsonb\", nullable: true },\n\t\tfunction_name: { type: \"text\", nullable: true },\n\t\traw_tx: { type: \"text\" },\n\t\treceived_at: { type: \"timestamp\" },\n\t\tsender: { type: \"text\" },\n\t\tseq: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tpox4_calls: {\n\t\taggregated_amount_ustx: { type: \"text\", nullable: true },\n\t\taggregated_signer_index: { type: \"int\", nullable: true },\n\t\tamount_ustx: { type: \"text\", nullable: true },\n\t\tauth_allowed: { type: \"boolean\", nullable: true },\n\t\tauth_id: { type: \"text\", nullable: true },\n\t\tauth_period: { type: \"int\", nullable: true },\n\t\tauth_topic: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcaller: { type: \"text\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tdelegate_to: { type: \"text\", nullable: true },\n\t\tend_cycle: { type: \"int\", nullable: true },\n\t\tfunction_name: { type: \"text\" },\n\t\tlock_period: { type: \"int\", nullable: true },\n\t\tmax_amount: { type: \"text\", nullable: true },\n\t\tpox_addr_btc: { type: \"text\", nullable: true },\n\t\tpox_addr_hashbytes: { type: \"text\", nullable: true },\n\t\tpox_addr_version: { type: \"int\", nullable: true },\n\t\tresult_ok: { type: \"boolean\" },\n\t\treward_cycle: { type: \"int\", nullable: true },\n\t\tsigner_key: { type: \"text\", nullable: true },\n\t\tsigner_signature: { type: \"text\", nullable: true },\n\t\tsource_cursor: { type: \"text\" },\n\t\tstacker: { type: \"text\", nullable: true },\n\t\tstart_cycle: { type: \"int\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tpox5_events: {\n\t\tamount_sats: { type: \"text\", nullable: true },\n\t\tamount_ustx: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbond_index: { type: \"int\", nullable: true },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tdata: { type: \"jsonb\", nullable: true },\n\t\tevent_index: { type: \"int\" },\n\t\tfirst_reward_cycle: { type: \"int\", nullable: true },\n\t\tis_l1_lock: { type: \"boolean\", nullable: true },\n\t\treward_cycle: { type: \"int\", nullable: true },\n\t\tsigner: { type: \"text\", nullable: true },\n\t\tsigner_key: { type: \"text\", nullable: true },\n\t\tsigner_manager: { type: \"text\", nullable: true },\n\t\tstaker: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\tunlock_burn_height: { type: \"int\", nullable: true },\n\t\tunlock_cycle: { type: \"int\", nullable: true },\n\t},\n\tsbtc_events: {\n\t\tamount: { type: \"text\", nullable: true },\n\t\tbitcoin_txid: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tburn_hash: { type: \"text\", nullable: true },\n\t\tburn_height: { type: \"int\", nullable: true },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tfee: { type: \"text\", nullable: true },\n\t\tgovernance_contract_type: { type: \"int\", nullable: true },\n\t\tgovernance_new_contract: { type: \"text\", nullable: true },\n\t\tmax_fee: { type: \"text\", nullable: true },\n\t\toutput_index: { type: \"int\", nullable: true },\n\t\trecipient_btc_hashbytes: { type: \"text\", nullable: true },\n\t\trecipient_btc_version: { type: \"int\", nullable: true },\n\t\trequest_id: { type: \"int\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\tsigner_address: { type: \"text\", nullable: true },\n\t\tsigner_aggregate_pubkey: { type: \"text\", nullable: true },\n\t\tsigner_bitmap: { type: \"text\", nullable: true },\n\t\tsigner_keys_count: { type: \"int\", nullable: true },\n\t\tsigner_threshold: { type: \"int\", nullable: true },\n\t\tsweep_txid: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tsbtc_token_events: {\n\t\tamount: { type: \"text\" },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tevent_type: { type: \"text\" },\n\t\tmemo: { type: \"text\", nullable: true },\n\t\trecipient: { type: \"text\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_name_events: {\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbns_id: { type: \"text\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tfqn: { type: \"text\" },\n\t\thashed_salted_fqn_preorder: { type: \"text\", nullable: true },\n\t\timported_at: { type: \"int\", nullable: true },\n\t\tname: { type: \"text\" },\n\t\tnamespace: { type: \"text\" },\n\t\towner: { type: \"text\", nullable: true },\n\t\tpreordered_by: { type: \"text\", nullable: true },\n\t\tregistered_at: { type: \"int\", nullable: true },\n\t\trenewal_height: { type: \"int\", nullable: true },\n\t\tstx_burn: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_namespace_events: {\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tlaunched_at: { type: \"int\", nullable: true },\n\t\tlifetime: { type: \"int\", nullable: true },\n\t\tmanager: { type: \"text\", nullable: true },\n\t\tmanager_frozen: { type: \"boolean\", nullable: true },\n\t\tmanager_transfers_disabled: { type: \"boolean\", nullable: true },\n\t\tnamespace: { type: \"text\" },\n\t\tprice_frozen: { type: \"boolean\", nullable: true },\n\t\tprice_function: { type: \"text\", nullable: true },\n\t\trevealed_at: { type: \"int\", nullable: true },\n\t\tstatus: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_marketplace_events: {\n\t\taction: { type: \"text\" },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbns_id: { type: \"text\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcommission: { type: \"text\", nullable: true },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tprice_ustx: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_names: {\n\t\tbns_id: { type: \"text\" },\n\t\tfqn: { type: \"text\" },\n\t\tlast_event_at: { type: \"timestamp\" },\n\t\tlast_event_cursor: { type: \"text\" },\n\t\tname: { type: \"text\" },\n\t\tnamespace: { type: \"text\" },\n\t\towner: { type: \"text\" },\n\t\tregistered_at: { type: \"int\", nullable: true },\n\t\trenewal_height: { type: \"int\", nullable: true },\n\t},\n\tbns_namespaces: {\n\t\tlast_event_at: { type: \"timestamp\" },\n\t\tlast_event_cursor: { type: \"text\" },\n\t\tlaunched_at: { type: \"int\", nullable: true },\n\t\tlifetime: { type: \"int\", nullable: true },\n\t\tmanager: { type: \"text\", nullable: true },\n\t\tmanager_frozen: { type: \"boolean\" },\n\t\tname_count: { type: \"int\" },\n\t\tnamespace: { type: \"text\" },\n\t\tprice_frozen: { type: \"boolean\" },\n\t},\n\tburn_block_rewards: {\n\t\tamount_sats: { type: \"text\" },\n\t\tburn_amount: { type: \"text\" },\n\t\tburn_block_hash: { type: \"text\" },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcursor: { type: \"text\" },\n\t\trecipient_btc: { type: \"text\" },\n\t\treward_index: { type: \"int\" },\n\t},\n\tburn_block_reward_slots: {\n\t\tburn_block_hash: { type: \"text\" },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcursor: { type: \"text\" },\n\t\tholder_btc: { type: \"text\" },\n\t\tslot_index: { type: \"int\" },\n\t},\n\tevents: {\n\t\tblock_height: { type: \"int\" },\n\t\tdata: { type: \"jsonb\" },\n\t\tevent_index: { type: \"int\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tchain_reorgs: {\n\t\tdetected_at: { type: \"timestamp\" },\n\t},\n} as const satisfies Record<\n\tkeyof typeof SOURCE_READ_COLUMNS,\n\tRecord<string, IndexColumn>\n>;\n\nexport type IndexPrimaryKey = readonly string[] | null;\n\n// Primary key per read table, for codegen targets that require a model identity\n// (Prisma). Every listed column must be a read column (drift-tested). `null` = no\n// usable read-column key — the physical PK is a synthetic id excluded from the\n// read contract (chain_reorgs) — so Prisma omits the table. `events` uses its\n// natural unique (tx_id, event_index); its physical PK is a synthetic uuid not\n// surfaced in the read set.\nexport const SOURCE_READ_PKS = {\n\tblocks: [\"height\"],\n\tdecoded_events: [\"cursor\"],\n\ttransactions: [\"tx_id\"],\n\tmempool_transactions: [\"seq\"],\n\tpox4_calls: [\"cursor\"],\n\tpox5_events: [\"cursor\"],\n\tsbtc_events: [\"cursor\"],\n\tsbtc_token_events: [\"cursor\"],\n\tbns_name_events: [\"cursor\"],\n\tbns_namespace_events: [\"cursor\"],\n\tbns_marketplace_events: [\"cursor\"],\n\tbns_names: [\"fqn\"],\n\tbns_namespaces: [\"namespace\"],\n\tburn_block_rewards: [\"cursor\"],\n\tburn_block_reward_slots: [\"cursor\"],\n\tevents: [\"tx_id\", \"event_index\"],\n\tchain_reorgs: null,\n} as const satisfies Record<keyof typeof SOURCE_READ_COLUMNS, IndexPrimaryKey>;\n",
11
+ "import type {\n\tColumnType,\n\tGenerated,\n\tInsertable,\n\tSelectable,\n\tUpdateable,\n} from \"kysely\";\nimport type {\n\tFailureClass,\n\tFailureUnit,\n\tNativeClock,\n\tRepairMode,\n\tRetryState,\n\tRunStatus,\n\tStageKind,\n} from \"../coverage/constraints.ts\";\nimport type { BootstrapSource } from \"../coverage/evaluate.ts\";\nimport type {\n\tSubgraphStatus,\n\tSubgraphVerification,\n} from \"../schemas/subgraphs.ts\";\nimport type { WebhookPauseReason } from \"../webhooks/health.ts\";\n\nexport type {\n\tFailureClass,\n\tFailureUnit,\n\tNativeClock,\n\tRepairMode,\n\tRetryState,\n\tRunStatus,\n\tStageKind,\n} from \"../coverage/constraints.ts\";\n\n// ── Table interfaces ──────────────────────────────────────────────────\n\nexport interface BlocksTable {\n\theight: number;\n\thash: string;\n\tparent_hash: string;\n\tburn_block_height: number;\n\tburn_block_hash: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\t/** Nakamoto StacksBlockId. Null on rows ingested before it was persisted. */\n\tindex_block_hash: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\ttimestamp: number;\n\tcanonical: Generated<boolean>;\n\t/** Tx count `persistBlock` was handed for this height. Null on rows\n\t * ingested before this column existed. */\n\ttx_count: ColumnType<number | null, number | null | undefined, number | null>;\n\t/** Event count `persistBlock` was handed for this height. Null on rows\n\t * ingested before this column existed. */\n\tevent_count: ColumnType<\n\t\tnumber | null,\n\t\tnumber | null | undefined,\n\t\tnumber | null\n\t>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface TransactionsTable {\n\ttx_id: string;\n\tblock_height: number;\n\ttx_index: Generated<number>;\n\ttype: string;\n\tsender: string;\n\tstatus: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: Generated<unknown | null>;\n\traw_result: Generated<string | null>;\n\traw_tx: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface EventsTable {\n\tid: Generated<string>;\n\ttx_id: string;\n\tblock_height: number;\n\tevent_index: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Generated<Date>;\n}\n\n// Reorg archive (see migration 0084): orphaned transactions/events copied here\n// before a reused height is replaced, preserving the raw log instead of\n// deleting it.\nexport interface TransactionsArchiveTable {\n\tarchive_id: Generated<string>;\n\ttx_id: string;\n\tblock_height: number;\n\ttx_index: number;\n\ttype: string;\n\tsender: string;\n\tstatus: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: unknown | null;\n\traw_result: string | null;\n\traw_tx: string;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\nexport interface EventsArchiveTable {\n\tarchive_id: Generated<string>;\n\tid: string;\n\ttx_id: string;\n\tblock_height: number;\n\tevent_index: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Opt-in VM traces (migration 0131). Second clock: `ordinal` (array position\n// in `/new_block.vm_events`). Never mixed into `events.event_index`. Primary\n// key `(block_height, ordinal)` (migration 0153).\nexport interface VmEventsTable {\n\ttx_id: string;\n\tblock_height: number;\n\tordinal: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface VmEventsArchiveTable {\n\tarchive_id: Generated<string>;\n\t/** `block_height:ordinal`; rows archived before migration 0153 hold the old uuid. */\n\tid: string;\n\ttx_id: string;\n\tblock_height: number;\n\tordinal: number;\n\ttype: string;\n\tdata: unknown;\n\tcreated_at: Date;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Opt-in node storage-layer writes (migration 0154): the exact MARF writes a\n// block committed, in node order. `tx_index` is null for block-level writes.\n// Primary key `(block_height, ordinal)`.\nexport interface StateWritesTable {\n\tblock_height: number;\n\tordinal: number;\n\ttx_index: number | null;\n\tkey: string;\n\tvalue_hex: string;\n}\n\nexport interface StateWritesArchiveTable {\n\tarchive_id: Generated<string>;\n\t/** `block_height:ordinal`. */\n\tid: string;\n\tblock_height: number;\n\tordinal: number;\n\ttx_index: number | null;\n\tkey: string;\n\tvalue_hex: string;\n\torphaned_block_hash: string | null;\n\tarchived_at: Generated<Date>;\n}\n\n// Dead-letter log (see migration 0085): events whose decoded payload failed\n// schema validation on ingest. Append-only diagnostic; the event still lands in\n// `events`, so chain data is never lost.\nexport interface DeadLetterEventsTable {\n\tid: Generated<string>;\n\tblock_height: number;\n\ttx_id: string;\n\tevent_index: number;\n\tevent_type: string;\n\tdata: unknown;\n\treason: string;\n\tcreated_at: Generated<Date>;\n}\n\n// Pending (unconfirmed) transactions (see migration 0086). Pre-chain, so no\n// block_height/tx_index/result/events and never canonical. tx_id is derived\n// from raw_tx; function_args holds hex-encoded ClarityValues (jsonb), like\n// `transactions`.\nexport interface MempoolTransactionsTable {\n\tseq: Generated<string>;\n\ttx_id: string;\n\traw_tx: string;\n\ttype: string;\n\tsender: string;\n\tcontract_id: string | null;\n\tfunction_name: string | null;\n\tfunction_args: unknown | null;\n\treceived_at: Generated<Date>;\n}\n\nexport interface IndexProgressTable {\n\tnetwork: string;\n\tlast_indexed_block: Generated<number>;\n\tlast_contiguous_block: Generated<number>;\n\thighest_seen_block: Generated<number>;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface SubgraphsTable {\n\tid: Generated<string>;\n\tname: string;\n\tversion: Generated<string>;\n\tstatus: Generated<SubgraphStatus>;\n\tdefinition: Record<string, unknown>;\n\tschema_hash: string;\n\thandler_path: string;\n\tschema_name: string | null;\n\tstart_block: Generated<number>;\n\tlast_processed_block: Generated<number>;\n\t/** Hash of the block at `last_processed_block`; NULL = unknown (see 0197). */\n\tlast_processed_block_hash: Generated<string | null>;\n\treindex_from_block: number | null;\n\treindex_to_block: number | null;\n\tlast_error: string | null;\n\tlast_error_at: Date | null;\n\ttotal_processed: Generated<number>;\n\ttotal_errors: Generated<number>;\n\taccount_id: string;\n\thandler_code: string | null;\n\tsource_code: string | null;\n\tproject_id: string | null;\n\t/** Set while the account's metered reads are refused (spend cap, credits).\n\t * Both columns are set or both null; `last_error` stays for real errors. */\n\tbilling_paused_at: Date | null;\n\tbilling_paused_code: string | null;\n\t/** (event type, contract) probe pairs persisted at deploy for weight classification. */\n\tsparse_probe_targets: unknown | null;\n\t/** sha256 over everything that shapes rows (schema, handler bundle,\n\t * startBlock, network, runtime). NULL for unbundled or older deploys. */\n\tpin: string | null;\n\t/** The canonical JSON `pin` hashes, so a client can recompute it. NULL\n\t * wherever `pin` is, and for deploys before migration 0158. */\n\tpin_preimage: string | null;\n\t/** Level derived at deploy. NULL (older deploys) = not verifiable. */\n\tverification: SubgraphVerification | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\n/** Mirrored by the CHECK on `contracts.abi_status`. */\nexport const ABI_STATUSES = [\n\t\"pending\",\n\t\"fetched\",\n\t\"unparseable\",\n\t\"failed\",\n] as const;\nexport type AbiStatus = (typeof ABI_STATUSES)[number];\n\nexport interface ContractsTable {\n\tcontract_id: string;\n\tdeployer: string;\n\tblock_height: number;\n\tcanonical: Generated<boolean>;\n\tabi: unknown | null;\n\tdeclared_traits: Generated<string[]>;\n\tinferred_standards: Generated<string[]>;\n\tabi_status: Generated<AbiStatus>;\n\tabi_fetched_at: Date | null;\n\t/** Failed fetches so far; `failed` re-polls until the registry's attempt cap. */\n\tabi_attempts: Generated<number>;\n\t/** When a `failed` row is next due; NULL once attempts are exhausted. */\n\tabi_next_attempt_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** The only reasons the runtime records; mirrored by a CHECK on `subgraph_gaps.reason`. */\nexport type GapReason = \"block_missing\" | \"processing_error\";\n\nexport interface SubgraphGapsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tgap_start: number;\n\tgap_end: number;\n\treason: GapReason;\n\tdetected_at: Generated<Date>;\n\tresolved_at: Date | null;\n}\n\n/** Print-validate skips persisted for the authed violations GET. Cap 100/subgraph. */\nexport interface SubgraphViolationsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tsource_name: string;\n\tblock_height: number;\n\ttx_id: string;\n\treason: string;\n\tsample_payload: Record<string, unknown>;\n\tseen_at: Generated<Date>;\n}\n\nexport type SubgraphOperationKind = \"reindex\" | \"backfill\";\nexport type SubgraphOperationStatus =\n\t| \"queued\"\n\t| \"running\"\n\t| \"completed\"\n\t| \"failed\"\n\t| \"cancelled\";\n\nexport interface SubgraphOperationsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\taccount_id: string | null;\n\tkind: ColumnType<\n\t\tSubgraphOperationKind,\n\t\tSubgraphOperationKind,\n\t\tSubgraphOperationKind\n\t>;\n\tstatus: ColumnType<\n\t\tSubgraphOperationStatus,\n\t\tSubgraphOperationStatus | undefined,\n\t\tSubgraphOperationStatus\n\t>;\n\tfrom_block: number | null;\n\tto_block: number | null;\n\tcancel_requested: Generated<boolean>;\n\tlocked_by: string | null;\n\tlocked_until: Date | null;\n\tstarted_at: Date | null;\n\tfinished_at: Date | null;\n\tprocessed_blocks: number | null;\n\terror: string | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n\t/** 'light' (contract-scoped sparse) | 'heavy' (broad). Claim budgets heavy. */\n\tweight: Generated<string>;\n\t/** Candidate-event denominator computed at enqueue (sparse ops only). */\n\testimated_events: string | number | bigint | null;\n\t/** Events processed so far — written by the progress flush. */\n\tprocessed_events: string | number | bigint | null;\n\t/** Backfill ops' own crash checkpoint — advanced conditionally in-tx with\n\t * each written block; replays skip at/below it. NULL for reindex ops\n\t * (those checkpoint on subgraphs.last_processed_block). */\n\tcursor_block: string | number | bigint | null;\n}\n\nexport type ApiKeyStatus = \"active\" | \"revoked\";\n\nexport interface ApiKeysTable {\n\tid: Generated<string>;\n\tkey_hash: string;\n\tkey_prefix: string;\n\tname: string | null;\n\tstatus: Generated<ApiKeyStatus>;\n\trate_limit: Generated<number>;\n\tip_address: string;\n\taccount_id: string;\n\tproduct: Generated<\n\t\t\"account\" | \"streams\" | \"index\" | \"sentinel\" | \"docs\" | \"tenant\"\n\t>;\n\t/** Sentinel permission areas; set only on `product = 'sentinel'` keys. */\n\tareas: unknown | null;\n\ttier: \"free\" | \"internal\" | null;\n\tlast_used_at: Date | null;\n\trevoked_at: Date | null;\n\t/** Set only on `docs` keys (24h). A key past this instant never authenticates. */\n\texpires_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** Singleton self-host / publisher identity. Network is immutable. */\nexport interface InstancesTable {\n\tid: Generated<string>;\n\tnetwork: string;\n\t/** `SECONDLAYER_SECRETS_KEY` sealed under itself; see `ensureSecretsKeyCanary`. */\n\tsecrets_key_canary: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface AccountsTable {\n\tid: Generated<string>;\n\t/** NULL for unclaimed ghost accounts (anonymous self-serve keys). */\n\temail: string | null;\n\t/** True for anonymous self-serve accounts until claimed via magic link. */\n\tghost: Generated<boolean>;\n\t/** First-party service account: usage priced at $0, never gated on\n\t * credits. Set by ops only. */\n\tinternal: Generated<boolean>;\n\t/** Stacks principal owning a wallet-ghost account. */\n\twallet_principal: string | null;\n\tdisplay_name: string | null;\n\tbio: string | null;\n\tavatar_url: string | null;\n\tstripe_customer_id: string | null;\n\t/** Opt-out toggle for the subgraph reindex-completion email. Defaults true. */\n\tnotify_reindex_complete: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SessionsTable {\n\tid: Generated<string>;\n\ttoken_hash: string;\n\ttoken_prefix: string;\n\taccount_id: string;\n\tip_address: string;\n\texpires_at: Generated<Date>;\n\trevoked_at: Date | null;\n\tlast_used_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface MagicLinksTable {\n\tid: Generated<string>;\n\temail: string;\n\ttoken: string;\n\tcode: string | null;\n\texpires_at: Date;\n\tused_at: Date | null;\n\tfailed_attempts: Generated<number>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SubgraphProcessingStatsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tapi_key_id: string | null;\n\tbucket_start: Date | null;\n\tbucket_end: Date | null;\n\tblocks_processed: number | null;\n\ttotal_time_ms: number | null;\n\thandler_time_ms: number | null;\n\tflush_time_ms: number | null;\n\tmax_block_time_ms: number | null;\n\tmax_handler_time_ms: number | null;\n\tavg_ops_per_block: number | null;\n\tis_catchup: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface SubgraphHealthSnapshotsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\ttotal_processed: number;\n\ttotal_errors: number;\n\tlast_processed_block: number | null;\n\tchain_tip: string | number | null;\n\trows_written_total: string | number | null;\n\tstorage_bytes: string | number | null;\n\tcaptured_at: Generated<Date>;\n}\n\n/** Handler errors grouped by fingerprint. Cap 50/subgraph. */\nexport interface SubgraphErrorGroupsTable {\n\tid: Generated<string>;\n\tsubgraph_id: string;\n\tsubgraph_name: string;\n\tfingerprint: string;\n\tsource_name: string;\n\tevent_type: string | null;\n\tmessage: string;\n\tframe: string | null;\n\tcount: Generated<string | number>;\n\tsample_tx_id: string | null;\n\tsample_block_height: string | number | null;\n\tfirst_seen: Generated<Date>;\n\tlast_seen: Generated<Date>;\n}\n\n/**\n * One ranked dashboard insight. `account_id` is NULL on tenant and self-host\n * databases. `severity` is never \"recovered\": that is derived on read from\n * `resolved_at`.\n */\nexport interface InsightsTable {\n\tid: Generated<string>;\n\taccount_id: string | null;\n\tresource_kind: string;\n\tresource_id: string;\n\trule: string;\n\tseverity: string;\n\timpact: Generated<number>;\n\t/** resource, line, meta, lead, body, evidence, handoff, how. */\n\tpayload: unknown;\n\tfirst_seen_at: Generated<Date>;\n\tlast_seen_at: Generated<Date>;\n\tclear_streak: Generated<number>;\n\tresolved_at: Date | null;\n\tdismissed_at: Date | null;\n\tsnoozed_until: Date | null;\n}\n\n/** \"Expected\": mutes one rule for one resource until removed. */\nexport interface InsightMutesTable {\n\taccount_id: string | null;\n\tresource_kind: string;\n\tresource_id: string;\n\trule: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface ProcessedStripeEventsTable {\n\tevent_id: string;\n\tevent_type: string;\n\tprocessed_at: Generated<Date>;\n}\n\nexport interface DecodedEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: string;\n\tmicroblock_hash: string | null;\n\tcanonical: Generated<boolean>;\n\tcontract_id: string | null;\n\tsender: string | null;\n\trecipient: string | null;\n\tamount: string | null;\n\tasset_identifier: string | null;\n\tvalue: string | null;\n\tmemo: string | null;\n\t/** Decoded payload for event types that don't fit the flat columns\n\t * (e.g. `print`: { topic, value, raw_value }). Null for transfer types. */\n\tpayload: unknown | null;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface DecoderCheckpointsTable {\n\tdecoder_name: string;\n\tlast_cursor: string | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface ChainReorgsTable {\n\tid: Generated<string>;\n\tdetected_at: Generated<Date>;\n\tfork_point_height: number;\n\told_index_block_hash: string | null;\n\tnew_index_block_hash: string | null;\n\torphaned_from_height: number;\n\torphaned_from_event_index: number;\n\torphaned_to_height: number;\n\torphaned_to_event_index: number;\n\tnew_canonical_height: number;\n\tnew_canonical_event_index: number;\n\tcreated_at: Generated<Date>;\n}\n\n// ── L2 decoded tables: sBTC / BNS ────────────────────────────\n\nexport type Pox5EventTopic =\n\t| \"set-bond-admin\"\n\t| \"set-pause-admin\"\n\t| \"pause-rewards\"\n\t| \"setup-bond\"\n\t| \"add-to-allowlist\"\n\t| \"register-for-bond\"\n\t| \"update-bond-registration\"\n\t| \"register-signer\"\n\t| \"stake\"\n\t| \"stake-update\"\n\t| \"announce-l1-early-exit\"\n\t| \"unstake-sbtc\"\n\t| \"unstake\"\n\t| \"calculate-rewards\"\n\t| \"bond-distribution\"\n\t| \"claim-rewards\"\n\t| \"claim-staker-rewards-for-signer\"\n\t| \"grant-signer-key\"\n\t| \"revoke-signer-grant\";\n\n// PoX-5 print events (SIP-045). Promoted columns cover hot query paths; the\n// full decoded tuple always lands in `data` (nested shapes: btc-lockup,\n// bond-rewards lists, bond-periods).\nexport interface Pox5EventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: Pox5EventTopic;\n\tstaker: string | null;\n\tsigner: string | null;\n\tsigner_manager: string | null;\n\tbond_index: number | null;\n\tamount_ustx: string | null;\n\tamount_sats: string | null;\n\treward_cycle: number | null;\n\tfirst_reward_cycle: number | null;\n\tunlock_cycle: number | null;\n\tunlock_burn_height: number | null;\n\tis_l1_lock: boolean | null;\n\tsigner_key: string | null;\n\tdata: unknown;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\n// Materialized per-cycle PoX-5 rollup (`rollupPox5Cycles`), maintained after\n// every committed pox5 decoder batch and after a pox5 reorg. Fully\n// rebuildable from `pox5_events` via `rebuild-pox5-cycles.ts --apply`.\nexport interface Pox5CyclesTable {\n\treward_cycle: number;\n\tstart_burn_height: number;\n\tprepare_start_burn_height: number;\n\tend_burn_height: number;\n\ttotal_stacked_ustx: string;\n\treward_eligible_ustx: string;\n\tstakers: number;\n\tsigners_in_set: number;\n\t/** bond index (as string) -> sats staked for this cycle. */\n\tbond_sats: unknown;\n\tbond_total_sats: string;\n\tsbtc_custodied_sats: string;\n\trewards_allocated_stx: string;\n\trewards_allocated_bond: string;\n\treserve_deposit: string;\n\trewards_per_token_stx: string | null;\n\t/** bond index (as string) -> cumulative rewards-per-sat for this cycle. */\n\trewards_per_token_bond: unknown;\n\tdistributions: number;\n\trewards_claimed: string;\n\tcomputed_through_height: number;\n\tupdated_at: Generated<Date>;\n}\n\n// Per-signer half of the pox-5 cycle rollup.\nexport interface Pox5CycleSignersTable {\n\treward_cycle: number;\n\tsigner: string;\n\tdelegated_ustx: string;\n\tstx_only_ustx: string;\n\treward_shares_ustx: string;\n\tin_set: boolean;\n\trewards_claimed: string;\n}\n\n// Actual BTC PoX payout — one row per reward slot (≤2 per burn block), from the\n// /new_burn_block reward_recipients array. `amount_sats`/`burn_amount` are sats.\nexport interface BurnBlockRewardsTable {\n\tcursor: string;\n\tburn_block_height: number;\n\tburn_block_hash: string;\n\treward_index: number;\n\trecipient_btc: string;\n\t// sats; TEXT to match the dataset amount convention (BIGINT returns as string).\n\tamount_sats: string;\n\tburn_amount: Generated<string>;\n\tcreated_at: Generated<Date>;\n}\n\n// Reward-set membership per burn block, from /new_burn_block reward_slot_holders.\nexport interface BurnBlockRewardSlotsTable {\n\tcursor: string;\n\tburn_block_height: number;\n\tburn_block_hash: string;\n\tslot_index: number;\n\tholder_btc: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type SbtcEventTopic =\n\t| \"completed-deposit\"\n\t| \"withdrawal-create\"\n\t| \"withdrawal-accept\"\n\t| \"withdrawal-reject\"\n\t| \"key-rotation\"\n\t| \"update-protocol-contract\";\n\nexport interface SbtcEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: SbtcEventTopic;\n\trequest_id: number | null;\n\tamount: string | null;\n\tsender: string | null;\n\t/** Stacks principal a `completed-deposit` minted sBTC to. */\n\trecipient: string | null;\n\trecipient_btc_version: number | null;\n\trecipient_btc_hashbytes: string | null;\n\tbitcoin_txid: string | null;\n\toutput_index: number | null;\n\tsweep_txid: string | null;\n\tburn_hash: string | null;\n\tburn_height: number | null;\n\tsigner_bitmap: string | null;\n\tmax_fee: string | null;\n\tfee: string | null;\n\tblock_height_at_request: number | null;\n\tgovernance_contract_type: number | null;\n\tgovernance_new_contract: string | null;\n\tsigner_aggregate_pubkey: string | null;\n\tsigner_threshold: number | null;\n\tsigner_address: string | null;\n\tsigner_keys_count: number | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type SbtcTokenEventType = \"transfer\" | \"mint\" | \"burn\";\n\nexport interface SbtcTokenEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: SbtcTokenEventType;\n\tsender: string | null;\n\trecipient: string | null;\n\tamount: string;\n\tmemo: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * BTC L1 settlement status for sBTC withdrawal sweeps. Filled by the indexer's\n * settlement-confirmer worker, which polls our own bitcoind for confirmations of\n * each `withdrawal-accept`'s `sweep_txid` and surfaces real settlement on the\n * withdrawal lifecycle (the API's `settlement.{btc_confirmations,\n * settlement_confirmed}` placeholder). Keyed on `sweep_txid` (not `request_id`):\n * a request can produce more than one sweep over its life (RBF/rebroadcast), so\n * each broadcast keeps its own confirmation history.\n */\nexport interface SbtcSettlementsTable {\n\tsweep_txid: string;\n\trequest_id: number;\n\tbtc_confirmations: Generated<number>;\n\tsettlement_confirmed: Generated<boolean>;\n\t/** Confirming Bitcoin block — null while the sweep is unconfirmed. */\n\tblock_hash: string | null;\n\tblock_height: number | null;\n\tfirst_seen_at: Generated<Date>;\n\tlast_checked_at: Generated<Date>;\n\t/** Set once, when `settlement_confirmed` first flips true. */\n\tconfirmed_at: Date | null;\n\t/** Monotonic stamp from `sbtc_settlements_seq`, retaken each time the sweep\n\t * becomes confirmed. The webhook scan's watermark. BIGINT: a string at\n\t * runtime. */\n\tseq: Generated<number | string>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type BnsNameEventTopic =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\nexport interface BnsNameEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\ttopic: BnsNameEventTopic;\n\tnamespace: string;\n\tname: string;\n\tfqn: string;\n\towner: string | null;\n\tbns_id: string;\n\tregistered_at: number | null;\n\timported_at: number | null;\n\trenewal_height: number | null;\n\tstx_burn: string | null;\n\tpreordered_by: string | null;\n\thashed_salted_fqn_preorder: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type BnsNamespaceEventStatus =\n\t| \"launch\"\n\t| \"transfer-manager\"\n\t| \"freeze-manager\"\n\t| \"update-price-manager\"\n\t| \"freeze-price-manager\"\n\t| \"turn-off-manager-transfers\";\n\nexport interface BnsNamespaceEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tstatus: BnsNamespaceEventStatus;\n\tnamespace: string;\n\tmanager: string | null;\n\tmanager_frozen: boolean | null;\n\tmanager_transfers_disabled: boolean | null;\n\tprice_function: string | null;\n\tprice_frozen: boolean | null;\n\tlifetime: number | null;\n\trevealed_at: number | null;\n\tlaunched_at: number | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport type BnsMarketplaceAction =\n\t| \"list-in-ustx\"\n\t| \"unlist-in-ustx\"\n\t| \"buy-in-ustx\";\n\nexport interface BnsMarketplaceEventsTable {\n\tcursor: string;\n\tblock_height: number;\n\tblock_time: Date;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\taction: BnsMarketplaceAction;\n\tbns_id: string;\n\tprice_ustx: string | null;\n\tcommission: string | null;\n\tcanonical: Generated<boolean>;\n\tsource_cursor: string;\n\tcreated_at: Generated<Date>;\n}\n\nexport interface BnsNamesTable {\n\tfqn: string;\n\tnamespace: string;\n\tname: string;\n\towner: string;\n\tbns_id: string;\n\tregistered_at: number | null;\n\trenewal_height: number | null;\n\tlast_event_cursor: string;\n\tlast_event_at: Date;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface BnsNamespacesTable {\n\tnamespace: string;\n\tmanager: string | null;\n\tmanager_frozen: Generated<boolean>;\n\tprice_frozen: Generated<boolean>;\n\tlifetime: number | null;\n\tlaunched_at: number | null;\n\tlast_event_cursor: string;\n\tlast_event_at: Date;\n\tname_count: Generated<number>;\n\tupdated_at: Generated<Date>;\n}\n\n// ── Database interface ────────────────────────────────────────────────\n\n/**\n * Memoized `ctx.client.readOnly()` results. Keyed on `index_block_hash` so a\n * reorg-replaced block never inherits the orphaned fork's answer; a NULL\n * `index_block_hash` marks a caller-declared contract-constant value, cached\n * once per contract+args instead of once per block.\n */\nexport interface ChainReadCacheTable {\n\tid: Generated<number>;\n\tcontract_id: string;\n\tfunction_name: string;\n\targs_hash: string;\n\tindex_block_hash: string | null;\n\tblock_height: ColumnType<\n\t\tnumber | null,\n\t\tnumber | null | undefined,\n\t\tnumber | null\n\t>;\n\tresult_hex: string;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A block that arrived for a height we already hold, staged until a later\n * block's `parent_hash` says which of the two the chain kept. See migration\n * 0112 — adopting on first sight picked the losing fork twice.\n */\nexport interface PendingForkBlocksTable {\n\theight: number;\n\tblock_hash: string;\n\tparent_hash: string;\n\t/** The canonical hash we held at this height when the contender arrived. */\n\tincumbent_hash: string;\n\t/** The raw observer payload, replayed verbatim if this fork wins. */\n\tpayload: ColumnType<unknown, unknown, unknown>;\n\treceived_at: Generated<Date>;\n}\n\n/** Mirrored by the CHECK on `observer_journal.status`. */\nexport const OBSERVER_JOURNAL_STATUSES = [\n\t\"received\",\n\t\"processed\",\n\t\"failed\",\n\t\"retried\",\n\t\"poisoned\",\n\t\"skipped\",\n] as const;\nexport type ObserverJournalStatus = (typeof OBSERVER_JOURNAL_STATUSES)[number];\n\n/**\n * Exact observer callback receipt. `raw_body` is immutable evidence; the\n * processing columns are updated only after the current derived-state write\n * succeeds or fails.\n */\nexport interface ObserverJournalTable {\n\tsequence: Generated<string>;\n\tnetwork: string;\n\tpath: string;\n\tsource: string | null;\n\treceived_at: Generated<Date>;\n\traw_body: ColumnType<Buffer, Buffer, Buffer>;\n\traw_body_sha256: string;\n\tstatus: ColumnType<\n\t\tObserverJournalStatus,\n\t\tObserverJournalStatus | undefined,\n\t\tObserverJournalStatus\n\t>;\n\tsemantic_sha256: string | null;\n\tblock_height: number | null;\n\tblock_hash: string | null;\n\tburn_block_height: number | null;\n\tburn_block_hash: string | null;\n\tresult: unknown | null;\n\terror: string | null;\n\tprocessed_at: Date | null;\n}\n\n/** Declared coverage stage. Identity is the `id` string (`raw`, `decode:stx`, …). */\nexport interface StageRegistryTable {\n\tid: string;\n\tkind: StageKind;\n\tdepends_on: string | null;\n\tnative_clock: NativeClock;\n\tproducer_version: string;\n\trepair_mode: RepairMode;\n\tenabled: Generated<boolean>;\n\tcreated_at: Generated<Date>;\n}\n\n/** One versioned sweep of a stage. Nothing writes this table yet; kept because the receipts and failures tables reference it. */\nexport interface StageRunsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\tcode_hash: string;\n\tconfig_hash: string;\n\thandler_hash: string | null;\n\ttarget_height: number | null;\n\ttarget_cursor: string | null;\n\tstatus: RunStatus;\n\tcomplete_through: number | null;\n\tstarted_at: Generated<Date>;\n\tfinished_at: Date | null;\n}\n\n/** Per-block acknowledgement. Unique on (stage, height, hash). */\nexport interface StageBlockReceiptsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\trun_id: string | null;\n\tblock_height: number;\n\tblock_hash: string;\n\tinput_count: number;\n\tinput_digest: string;\n\teffect_digest: string;\n\tfinalized: Generated<boolean>;\n\tcompacted_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** Compacted finalized range. Only sealed after receipts in the range finalize. */\nexport interface CoverageSegmentsTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\tfrom_height: number;\n\tto_height: number;\n\tchain_digest: string;\n\tinput_digest: string;\n\toutput_digest: string;\n\tsealed_at: Generated<Date>;\n}\n\n/** Exact unit or range that failed, plus retry/retention state. */\nexport interface StageFailuresTable {\n\tid: Generated<string>;\n\tstage_id: string;\n\trun_id: string | null;\n\tunit_kind: FailureUnit;\n\tfrom_height: number | null;\n\tto_height: number | null;\n\tclass: FailureClass;\n\tretry_state: RetryState;\n\tretry_count: Generated<number>;\n\tlast_error: string | null;\n\tcreated_at: Generated<Date>;\n\tresolved_at: Date | null;\n\tretain_until: Generated<Date>;\n}\n\n/**\n * The instance's declared scope — one row per network. `start_height` is what\n * makes missing history below it deliberate rather than a gap.\n */\nexport interface SyncScopesTable {\n\tnetwork: string;\n\tstart_height: number;\n\ttarget_height: number | null;\n\tbootstrap_source: BootstrapSource;\n\tbootstrap_manifest_digest: string | null;\n\tgenesis_hash: string | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\nexport interface Database {\n\tblocks: BlocksTable;\n\ttransactions: TransactionsTable;\n\tevents: EventsTable;\n\tvm_events: VmEventsTable;\n\tstate_writes: StateWritesTable;\n\ttransactions_archive: TransactionsArchiveTable;\n\tevents_archive: EventsArchiveTable;\n\tvm_events_archive: VmEventsArchiveTable;\n\tstate_writes_archive: StateWritesArchiveTable;\n\tdead_letter_events: DeadLetterEventsTable;\n\tmempool_transactions: MempoolTransactionsTable;\n\tindex_progress: IndexProgressTable;\n\tcontracts: ContractsTable;\n\tsubgraphs: SubgraphsTable;\n\tapi_keys: ApiKeysTable;\n\tinstances: InstancesTable;\n\taccounts: AccountsTable;\n\tsessions: SessionsTable;\n\tmagic_links: MagicLinksTable;\n\tsubgraph_health_snapshots: SubgraphHealthSnapshotsTable;\n\tsubgraph_processing_stats: SubgraphProcessingStatsTable;\n\tsubgraph_gaps: SubgraphGapsTable;\n\tsubgraph_violations: SubgraphViolationsTable;\n\tsubgraph_error_groups: SubgraphErrorGroupsTable;\n\tsubgraph_operations: SubgraphOperationsTable;\n\tprocessed_stripe_events: ProcessedStripeEventsTable;\n\taccount_spend_caps: AccountSpendCapsTable;\n\taccount_credits: AccountCreditsTable;\n\twebhooks: WebhooksTable;\n\twebhook_outbox: WebhookOutboxTable;\n\twebhook_deliveries: WebhookDeliveriesTable;\n\twebhook_delivery_hours: WebhookDeliveryHoursTable;\n\twebhook_replays: WebhookReplaysTable;\n\ttrigger_evaluator_state: TriggerEvaluatorStateTable;\n\tdecoded_events: DecodedEventsTable;\n\tdecoder_checkpoints: DecoderCheckpointsTable;\n\tchain_reorgs: ChainReorgsTable;\n\tpox5_events: Pox5EventsTable;\n\tpox5_cycles: Pox5CyclesTable;\n\tpox5_cycle_signers: Pox5CycleSignersTable;\n\tburn_block_rewards: BurnBlockRewardsTable;\n\tburn_block_reward_slots: BurnBlockRewardSlotsTable;\n\tsbtc_events: SbtcEventsTable;\n\tsbtc_token_events: SbtcTokenEventsTable;\n\tsbtc_settlements: SbtcSettlementsTable;\n\tbns_name_events: BnsNameEventsTable;\n\tbns_namespace_events: BnsNamespaceEventsTable;\n\tbns_marketplace_events: BnsMarketplaceEventsTable;\n\tbns_names: BnsNamesTable;\n\tbns_namespaces: BnsNamespacesTable;\n\tservice_heartbeats: ServiceHeartbeatsTable;\n\tchain_read_cache: ChainReadCacheTable;\n\tpending_fork_blocks: PendingForkBlocksTable;\n\tobserver_journal: ObserverJournalTable;\n\tsync_scopes: SyncScopesTable;\n\tstage_registry: StageRegistryTable;\n\tstage_runs: StageRunsTable;\n\tstage_block_receipts: StageBlockReceiptsTable;\n\tcoverage_segments: CoverageSegmentsTable;\n\tstage_failures: StageFailuresTable;\n\tarchive_fetches: ArchiveFetchesTable;\n\tusage_ledger: UsageLedgerTable;\n\taccount_balance_alerts: AccountBalanceAlertsTable;\n\thosted_stack_state: HostedStackStateTable;\n\twebhook_incident_alerts: WebhookIncidentAlertsTable;\n\tcli_device_logins: CliDeviceLoginsTable;\n\toauth_clients: OauthClientsTable;\n\toauth_requests: OauthRequestsTable;\n\toauth_codes: OauthCodesTable;\n\toauth_grants: OauthGrantsTable;\n\toauth_tokens: OauthTokensTable;\n\toauth_refresh_retired: OauthRefreshRetiredTable;\n\tsentinel_accounts: SentinelAccountsTable;\n\twaitlists: WaitlistsTable;\n\twaitlist_signups: WaitlistSignupsTable;\n\tcontact_requests: ContactRequestsTable;\n\tupdate_subscribers: UpdateSubscribersTable;\n\tupdate_sends: UpdateSendsTable;\n\tapi_failed_requests: ApiFailedRequestsTable;\n\tapi_request_log: ApiRequestLogTable;\n\tinsights: InsightsTable;\n\tinsight_mutes: InsightMutesTable;\n\tfeedback_tickets: FeedbackTicketsTable;\n\tpush_subscriptions: PushSubscriptionsTable;\n\tpush_prefs: PushPrefsTable;\n\tpush_sent: PushSentTable;\n}\n\nexport interface ServiceHeartbeatsTable {\n\tname: string;\n\tupdated_at: Generated<Date>;\n}\n\n// --- Account spend caps (soft cap + threshold alerts) ---\n//\n// One row per account. Null caps = \"no cap\" for that dimension.\n// `monthly_cap_cents` caps this calendar month's pay-as-you-go credit spend.\n// The hard stop is enforced in real time on the read path (read-credits.ts);\n// `frozen_at` is a display/alert mirror set by the daily cron when the cap is\n// hit, and cleared on month rollover, on invoice.paid, or when the cap is raised.\n\nexport interface AccountSpendCapsTable {\n\taccount_id: string;\n\tmonthly_cap_cents: number | null;\n\tcompute_cap_cents: number | null;\n\tstorage_cap_cents: number | null;\n\talert_threshold_pct: Generated<number>;\n\talert_sent_at: Date | null;\n\tfrozen_at: Date | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport type AccountSpendCap = Selectable<AccountSpendCapsTable>;\nexport type InsertAccountSpendCap = Insertable<AccountSpendCapsTable>;\nexport type UpdateAccountSpendCap = Updateable<AccountSpendCapsTable>;\n\n/** Prepaid dev credits — card-funded balance per account. */\nexport interface AccountCreditsTable {\n\taccount_id: string;\n\tbalance_usd_micros: Generated<string | number | bigint>;\n\t/** Month bucket (\"YYYY-MM\") the spend counter applies to. */\n\tspent_month: string | null;\n\tspent_month_usd_micros: Generated<string | number | bigint>;\n\t/** Null = auto-refill off. */\n\trefill_below_usd_micros: string | number | bigint | null;\n\trefill_pack_usd: number | null;\n\trefill_last_at: Date | null;\n\tupdated_at: Generated<Date>;\n}\n\nexport type AccountCredits = Selectable<AccountCreditsTable>;\nexport type InsertAccountCredits = Insertable<AccountCreditsTable>;\nexport type UpdateAccountCredits = Updateable<AccountCreditsTable>;\n\n/**\n * Archive fetch charge log. Append-only: one row per\n * priced attempt to fetch a partition object. `usd_micros` is 0 for\n * free rows (24h re-issue, monthly repair allowance).\n */\nexport interface ArchiveFetchesTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tpath: string;\n\tdataset: string;\n\tusd_micros: string | number | bigint;\n\tvia_allowance: Generated<boolean>;\n\tcharged_at: Generated<Date>;\n}\n\nexport type ArchiveFetch = Selectable<ArchiveFetchesTable>;\nexport type InsertArchiveFetch = Insertable<ArchiveFetchesTable>;\nexport type UpdateArchiveFetch = Updateable<ArchiveFetchesTable>;\n\n/**\n * One metered ledger for every billable unit (archive partitions, hosted\n * Index/Streams rows, and future hosted-stack meters). Append-only, written\n * only by `meter()`. `idempotency_key` is UNIQUE so a retried submission\n * no-ops instead of double-charging. `debited` is false when the balance\n * (or a spend cap) refused the charge — the row still exists so the gap is\n * visible, never silently dropped. `usd_micros` is negative for a Stripe\n * top-up (`unit: \"topup\"`).\n */\nexport interface UsageLedgerTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tunit: string;\n\tquantity: string | number | bigint;\n\t/** Raw sampled quantity before any floor (e.g. `memory.gb_hour`'s actual\n\t * RAM, before the 0.5 GB minimum). NULL for every unit that has no\n\t * floor to observe past. */\n\tobserved_quantity: string | number | null;\n\tusd_micros: string | number | bigint;\n\t/** True when the whole price was taken; derived from `debited_usd_micros`. */\n\tdebited: Generated<boolean>;\n\t/** Amount actually taken from the balance, `0..usd_micros` (bounded the\n\t * other way for a negative top-up/grant row). Unpaid = price - this. */\n\tdebited_usd_micros: Generated<string | number | bigint>;\n\tsource: string;\n\t/** API key behind a metered read; null for non-read units and older rows. */\n\tapi_key_id: string | null;\n\tidempotency_key: string;\n\toccurred_at: Generated<Date>;\n\trecorded_at: Generated<Date>;\n}\n\nexport type UsageLedgerRow = Selectable<UsageLedgerTable>;\nexport type InsertUsageLedgerRow = Insertable<UsageLedgerTable>;\nexport type UpdateUsageLedgerRow = Updateable<UsageLedgerTable>;\n\n/** Preferences + debounce state for the balance-runway email alerts. One\n * row per account; a missing row means both alerts are on (defaults). */\nexport interface AccountBalanceAlertsTable {\n\taccount_id: string;\n\tnotify_7d: Generated<boolean>;\n\tnotify_2d: Generated<boolean>;\n\tsent_7d_at: Date | null;\n\tsent_2d_at: Date | null;\n\tsent_stopped_at: Date | null;\n}\n\n/** The workload host's report of one account's hosted stack. Written only by\n * `POST /internal/stack-state`; `reported_at` is the host's observation time. */\nexport interface HostedStackStateTable {\n\taccount_id: string;\n\tstate: \"provisioning\" | \"running\" | \"stopped\" | \"destroyed\";\n\tstop_reason: \"credits\" | \"cap\" | \"idle\" | null;\n\treported_at: Date;\n}\n\n/** Debounce state for the webhook-down email: one row per incident, open\n * while `resolved_at` is null. No preference columns by design. */\nexport interface WebhookIncidentAlertsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\twebhook_id: string;\n\twebhook_name: string;\n\tfailing_since: Date;\n\topened_at: Generated<Date>;\n\temailed_at: Date | null;\n\temail_attempts: Generated<number>;\n\tresolved_at: Date | null;\n}\n\nexport type WebhookIncidentAlert = Selectable<WebhookIncidentAlertsTable>;\n\n/** One browser/device push subscription; the endpoint is unique. */\nexport interface PushSubscriptionsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tendpoint: string;\n\tp256dh: string;\n\tauth: string;\n\tuser_agent: string | null;\n\tcreated_at: Generated<Date>;\n\tlast_success_at: Date | null;\n\tfailed_count: Generated<number>;\n}\n\nexport type PushSubscription = Selectable<PushSubscriptionsTable>;\n\n/** Per-account push toggles. A missing row means the column defaults. */\nexport interface PushPrefsTable {\n\taccount_id: string;\n\twebhook_failing: Generated<boolean>;\n\tsubgraph_stopped: Generated<boolean>;\n\tsubgraph_not_serving: Generated<boolean>;\n\treplay_done: Generated<boolean>;\n\tspend_cap: Generated<boolean>;\n\tkey_repeat: Generated<boolean>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type PushPrefs = Selectable<PushPrefsTable>;\n\n/** A push already sent, keyed by what it was about; debounces repeat signals. */\nexport interface PushSentTable {\n\taccount_id: string;\n\tkey: string;\n\tkind: string;\n\tsent_at: Generated<Date>;\n}\n\nexport type CliDeviceLoginStatus =\n\t| \"pending\"\n\t| \"approved\"\n\t| \"denied\"\n\t| \"consumed\";\n\n/** The product that started a CLI sign-in; null is `sl login`. */\nexport type CliDeviceProduct = \"sentinel\";\n\n/** One browser sign-in attempt from `sl login` (or `sentinel login`). Only the\n * hash of the CLI's device code is stored; the session is opened when the CLI\n * polls after approval. */\nexport interface CliDeviceLoginsTable {\n\tid: Generated<string>;\n\tdevice_code_hash: string;\n\tuser_code: string;\n\tclient_name: string;\n\tproduct: CliDeviceProduct | null;\n\tstatus: Generated<CliDeviceLoginStatus>;\n\taccount_id: string | null;\n\tkey_name: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tapproved_at: Date | null;\n\tconsumed_at: Date | null;\n}\n\nexport type CliDeviceLogin = Selectable<CliDeviceLoginsTable>;\n\n// --- OAuth for the hosted MCP endpoint ---\n//\n// Codes and tokens are stored as SHA-256 hashes only. See migration\n// `0177_oauth_mcp` and `@secondlayer/platform/db/queries/oauth`.\n\n/** An app that registered itself (RFC 7591). Public clients only: no secret. */\nexport interface OauthClientsTable {\n\tid: string;\n\t/** The app's own claim, validated at registration; shown quoted. */\n\tname: string;\n\tredirect_uris: string[];\n\tcreated_ip: string | null;\n\tcreated_at: Generated<Date>;\n\t/** Set when it first gets tokens; never-used clients are purged. */\n\tlast_used_at: Date | null;\n}\n\nexport type OauthRequestStatus = \"pending\" | \"approved\" | \"denied\";\n\n/** One authorize request waiting for (or answered on) the consent page. */\nexport interface OauthRequestsTable {\n\tid: string;\n\tclient_id: string;\n\tredirect_uri: string;\n\tstate: string | null;\n\tcode_challenge: string;\n\tresource: string;\n\tstatus: Generated<OauthRequestStatus>;\n\taccount_id: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tanswered_at: Date | null;\n}\n\n/** A one-time authorization code, bound to its client, redirect, PKCE\n * challenge, resource and account. */\nexport interface OauthCodesTable {\n\tcode_hash: string;\n\tclient_id: string;\n\taccount_id: string;\n\tredirect_uri: string;\n\tcode_challenge: string;\n\tresource: string;\n\t/** The grant its one use made, so a replay can revoke it. */\n\tgrant_id: string | null;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n\tused_at: Date | null;\n}\n\n/** What a person allowed one app to do: use the hosted MCP as them. */\nexport interface OauthGrantsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tclient_id: string;\n\tscope: Generated<string>;\n\tresource: string;\n\tcreated_at: Generated<Date>;\n\tlast_used_at: Date | null;\n\trevoked_at: Date | null;\n}\n\nexport type OauthTokenKind = \"access\" | \"refresh\";\n\nexport interface OauthTokensTable {\n\ttoken_hash: string;\n\tgrant_id: string;\n\tkind: OauthTokenKind;\n\tcreated_at: Generated<Date>;\n\texpires_at: Date;\n}\n\n/** A refresh token a rotation replaced: presented again, it revokes the grant. */\nexport interface OauthRefreshRetiredTable {\n\ttoken_hash: string;\n\tgrant_id: string;\n\tretired_at: Generated<Date>;\n}\n\nexport type OauthClient = Selectable<OauthClientsTable>;\nexport type OauthGrant = Selectable<OauthGrantsTable>;\n\n/** Accounts Sentinel's service key may touch: created by Sentinel, or the\n * owner opted in. */\nexport interface SentinelAccountsTable {\n\taccount_id: string;\n\tlinked_at: Generated<Date>;\n\tvia: \"created\" | \"consent\";\n}\n\nexport type SentinelAccount = Selectable<SentinelAccountsTable>;\n\nexport type AccountBalanceAlerts = Selectable<AccountBalanceAlertsTable>;\nexport type InsertAccountBalanceAlerts = Insertable<AccountBalanceAlertsTable>;\nexport type UpdateAccountBalanceAlerts = Updateable<AccountBalanceAlertsTable>;\n\n// ── Convenience types ─────────────────────────────────────────────────\n\nexport type Block = Selectable<BlocksTable>;\nexport type InsertBlock = Insertable<BlocksTable>;\nexport type UpdateBlock = Updateable<BlocksTable>;\n\nexport type Transaction = Selectable<TransactionsTable>;\nexport type InsertTransaction = Insertable<TransactionsTable>;\nexport type UpdateTransaction = Updateable<TransactionsTable>;\n\nexport type MempoolTransaction = Selectable<MempoolTransactionsTable>;\nexport type InsertMempoolTransaction = Insertable<MempoolTransactionsTable>;\n\nexport type Event = Selectable<EventsTable>;\nexport type InsertEvent = Insertable<EventsTable>;\nexport type UpdateEvent = Updateable<EventsTable>;\n\nexport type VmEvent = Selectable<VmEventsTable>;\nexport type InsertVmEvent = Insertable<VmEventsTable>;\nexport type UpdateVmEvent = Updateable<VmEventsTable>;\nexport type StateWrite = Selectable<StateWritesTable>;\nexport type InsertStateWrite = Insertable<StateWritesTable>;\n\nexport type IndexProgress = Selectable<IndexProgressTable>;\nexport type InsertIndexProgress = Insertable<IndexProgressTable>;\nexport type UpdateIndexProgress = Updateable<IndexProgressTable>;\n\nexport type Subgraph = Selectable<SubgraphsTable>;\nexport type InsertSubgraph = Insertable<SubgraphsTable>;\nexport type UpdateSubgraph = Updateable<SubgraphsTable>;\n\nexport type Contract = Selectable<ContractsTable>;\nexport type InsertContract = Insertable<ContractsTable>;\nexport type UpdateContract = Updateable<ContractsTable>;\n\nexport type SubgraphOperation = Selectable<SubgraphOperationsTable>;\nexport type InsertSubgraphOperation = Insertable<SubgraphOperationsTable>;\nexport type UpdateSubgraphOperation = Updateable<SubgraphOperationsTable>;\n\nexport type ApiKey = Selectable<ApiKeysTable>;\nexport type InsertApiKey = Insertable<ApiKeysTable>;\nexport type UpdateApiKey = Updateable<ApiKeysTable>;\n\nexport type Account = Selectable<AccountsTable>;\nexport type InsertAccount = Insertable<AccountsTable>;\n\nexport type MagicLink = Selectable<MagicLinksTable>;\nexport type InsertMagicLink = Insertable<MagicLinksTable>;\n\nexport type Session = Selectable<SessionsTable>;\nexport type InsertSession = Insertable<SessionsTable>;\n\nexport type SubgraphHealthSnapshot = Selectable<SubgraphHealthSnapshotsTable>;\nexport type InsertSubgraphHealthSnapshot =\n\tInsertable<SubgraphHealthSnapshotsTable>;\n\nexport type SubgraphGap = Selectable<SubgraphGapsTable>;\nexport type InsertSubgraphGap = Insertable<SubgraphGapsTable>;\n\n// ── Webhooks (chain event webhooks) ─────────────────────\n\nexport type WebhookStatus = \"active\" | \"paused\";\nexport type { WebhookPauseReason };\n\n/** Webhooks react to raw chain events matched directly off the Index/Streams\n * clock. `chain` is the only kind since migration 0159 removed subgraph-row\n * webhooks; the column stays as the discriminator. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat =\n\t| \"standard-webhooks\"\n\t| \"inngest\"\n\t| \"trigger\"\n\t| \"cloudflare\"\n\t| \"cloudevents\"\n\t| \"raw\";\n\nexport interface WebhooksTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tproject_id: string | null;\n\tname: string;\n\tstatus: ColumnType<WebhookStatus, WebhookStatus | undefined, WebhookStatus>;\n\tkind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;\n\t/** Chain-trigger filter array (the `SubgraphFilter` shape, JSON). Typed\n\t * loosely here to avoid a shared→subgraphs import cycle; the Zod schema in\n\t * schemas/webhooks.ts owns the shape. */\n\ttriggers: unknown;\n\tformat: ColumnType<WebhookFormat, WebhookFormat | undefined, WebhookFormat>;\n\turl: string;\n\tsigning_secret_enc: Buffer;\n\tauth_config: Generated<unknown>;\n\tmax_retries: Generated<number>;\n\ttimeout_ms: Generated<number>;\n\tconcurrency: Generated<number>;\n\tcircuit_failures: Generated<number>;\n\tcircuit_opened_at: Date | null;\n\t/** Why a paused webhook is paused. Set exactly while `status` is `paused`. */\n\tpause_reason: WebhookPauseReason | null;\n\tlast_delivery_at: Date | null;\n\tlast_success_at: Date | null;\n\tlast_error: string | null;\n\t/** Receiver TLS leaf certificate expiry, from the emitter's periodic probe. */\n\treceiver_cert_expires_at: Date | null;\n\treceiver_cert_checked_at: Date | null;\n\tcreated_at: Generated<Date>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type Webhook = Selectable<WebhooksTable>;\nexport type InsertWebhook = Insertable<WebhooksTable>;\nexport type UpdateWebhook = Updateable<WebhooksTable>;\n\nexport type OutboxStatus = \"pending\" | \"delivered\" | \"dead\";\n/** Why a row is dead: retries ran out, or a reorg removed its event. An\n * orphaned row stays dead; requeueing it would resend an event the chain no\n * longer contains. */\nexport type DeadReason = \"exhausted\" | \"orphaned\";\n\nexport interface WebhookOutboxTable {\n\tid: Generated<string>;\n\twebhook_id: string;\n\tkind: ColumnType<WebhookKind, WebhookKind | undefined, WebhookKind>;\n\tblock_height: number | bigint;\n\ttx_id: string | null;\n\trow_pk: unknown;\n\tevent_type: string;\n\tpayload: unknown;\n\tdedup_key: string;\n\tattempt: Generated<number>;\n\tnext_attempt_at: Generated<Date>;\n\tstatus: ColumnType<OutboxStatus, OutboxStatus | undefined, OutboxStatus>;\n\tis_replay: Generated<boolean>;\n\t/** The replay that created this row; null for live rows. */\n\treplay_id: string | null;\n\t/** The chain block_time of the matched event/tx. Null for rows written\n\t * before this column existed, and for the settlement scan path (not yet\n\t * wired). Lets `delivered_at - block_time` measure end-to-end webhook\n\t * latency without a join to SOURCE-plane `blocks`. */\n\tblock_time: Date | null;\n\tdelivered_at: Date | null;\n\tfailed_at: Date | null;\n\tlocked_by: string | null;\n\tlocked_until: Date | null;\n\t/** Set when a reorg marks an in-flight row `dead` instead of retrying it\n\t * into an orphaned fork. Null otherwise — delivery failures track their\n\t * history on `webhooks.last_error`, not per-row. */\n\tlast_error: string | null;\n\t/** Set exactly while `status` is `dead`. */\n\tdead_reason: DeadReason | null;\n\t/** Hash of the block a chain apply row was emitted for. Null on rows\n\t * written before the column existed (the payload carries it too). */\n\tblock_hash: string | null;\n\t/** Set when a reorg rollback recalled this delivered apply row, so a\n\t * later rollback for the same reorg skips it. */\n\trolled_back_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type WebhookReplayStatus = \"scanning\" | \"running\" | \"done\" | \"failed\";\n\nexport interface WebhookReplaysTable {\n\tid: string;\n\twebhook_id: string;\n\tfrom_block: number | bigint;\n\tto_block: number | bigint;\n\tstatus: WebhookReplayStatus;\n\tscanned_count: Generated<number>;\n\tenqueued_count: Generated<number>;\n\ttotal: number | null;\n\tdelivered: number | null;\n\tgave_up: number | null;\n\terror: string | null;\n\tstarted_at: Generated<Date>;\n\tfinished_at: Date | null;\n}\nexport type WebhookReplay = Selectable<WebhookReplaysTable>;\n\n/** `replay_id` is optional on the row type so hand-built rows (the test\n * delivery, fixtures) need not carry it; reads still return it. */\nexport type WebhookOutbox = Omit<\n\tSelectable<WebhookOutboxTable>,\n\t\"replay_id\"\n> & {\n\treplay_id?: string | null;\n};\nexport type InsertWebhookOutbox = Insertable<WebhookOutboxTable>;\nexport type UpdateWebhookOutbox = Updateable<WebhookOutboxTable>;\n\nexport interface WebhookDeliveriesTable {\n\tid: Generated<string>;\n\t/** Nullable after migration 0077 — outbox row may be cleaned up while\n\t * delivery telemetry is retained. */\n\toutbox_id: string | null;\n\twebhook_id: string;\n\tattempt: number;\n\tstatus_code: number | null;\n\tresponse_headers: unknown | null;\n\tresponse_body: string | null;\n\terror_message: string | null;\n\tduration_ms: number | null;\n\tdispatched_at: Generated<Date>;\n}\n\n/** Attempts per UTC hour, counted by a trigger on `webhook_deliveries`. */\nexport interface WebhookDeliveryHoursTable {\n\twebhook_id: string;\n\thour: Date;\n\t/** 2xx attempts. */\n\tdelivered: Generated<number>;\n\t/** Every other attempt. */\n\tfailed: Generated<number>;\n}\n\nexport type WebhookDelivery = Selectable<WebhookDeliveriesTable>;\nexport type InsertWebhookDelivery = Insertable<WebhookDeliveriesTable>;\n\n/** Single-row (id always TRUE) high-water mark for the chain-trigger evaluator.\n * One loop serves all chain webhooks, so the cursor is global. */\nexport interface TriggerEvaluatorStateTable {\n\tid: Generated<boolean>;\n\tlast_processed_block: ColumnType<\n\t\tbigint,\n\t\tbigint | number | undefined,\n\t\tbigint | number\n\t>;\n\t/** Watermark for the async sBTC settlement-confirmed webhook scan; null until\n\t * the evaluator fast-forwards it on first run. */\n\tlast_settlement_scan_at: ColumnType<\n\t\tDate | null,\n\t\tDate | null | undefined,\n\t\tDate | null\n\t>;\n\t/** `sbtc_settlements.seq` watermark. Null until the first settlement row is\n\t * scanned; `last_settlement_scan_at` is the forward-only floor until then. */\n\tlast_settlement_scan_seq: ColumnType<\n\t\tbigint | null,\n\t\tbigint | number | null | undefined,\n\t\tbigint | number | null\n\t>;\n\t/** Counts reorg rewinds. The evaluator checks it under the row lock in the\n\t * transaction that emits a batch and advances the cursor, so a reorg that\n\t * lands mid-tick rolls the batch back. */\n\treorg_generation: ColumnType<\n\t\tbigint,\n\t\tbigint | number | undefined,\n\t\tbigint | number\n\t>;\n\t/** Streams cursor (`<block_height>:<event_index>`) for the Bitcoin (Runes)\n\t * chain-trigger evaluator (plan 060) — a separate clock from\n\t * `last_processed_block` (Stacks). Null until the evaluator fast-forwards\n\t * it to the Bitcoin Streams tip on first run. */\n\tbitcoin_last_cursor: ColumnType<\n\t\tstring | null,\n\t\tstring | null | undefined,\n\t\tstring | null\n\t>;\n\tupdated_at: Generated<Date>;\n}\n\nexport type TriggerEvaluatorState = Selectable<TriggerEvaluatorStateTable>;\n\n/** A public waitlist page: what it is for and whether it takes signups. */\nexport interface WaitlistsTable {\n\tslug: string;\n\ttitle: string;\n\tdescription: string;\n\turl: string;\n\topened_at: Generated<Date>;\n\t/** Null while the list is open. */\n\tclosed_at: Date | null;\n}\n\n/**\n * One signup per (list, contact, token). `answers` holds the list's own\n * questions, validated per list by the API before insert.\n */\nexport interface WaitlistSignupsTable {\n\tid: Generated<string>;\n\tlist: string;\n\tcontact: string;\n\tanswers: Record<string, unknown>;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A \"Talk to us\" message. Stored before the operator is emailed;\n * `notified_at` stays null until the email goes out.\n */\nexport interface ContactRequestsTable {\n\tid: Generated<string>;\n\tname: string;\n\temail: string;\n\tcompany: string | null;\n\tvolume: \"lt10m\" | \"10m-100m\" | \"100m-1b\" | \"gt1b\" | \"unsure\" | null;\n\tmessage: string;\n\tsource_page: string | null;\n\taccount_id: string | null;\n\t/** Hex sha256 of the client IP, never the address. */\n\tip_hash: string | null;\n\tnotified_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/**\n * A member of the email updates list. `pending` until the emailed link is\n * confirmed (`confirm_sent_at` starts the 7-day window), `confirmed` while\n * subscribed, `unsubscribed` after an opt-out. `token` is the secret in\n * confirm and unsubscribe links.\n */\nexport interface UpdateSubscribersTable {\n\tid: Generated<string>;\n\temail: string;\n\tstatus: Generated<\"pending\" | \"confirmed\" | \"unsubscribed\">;\n\ttoken: string;\n\tsource_page: string | null;\n\t/** Hex sha256 of the client IP, never the address. */\n\tip_hash: string | null;\n\tconfirm_sent_at: Date | null;\n\tconfirmed_at: Date | null;\n\tunsubscribed_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\n/** One broadcast (`send_key`) delivered to one subscriber. */\nexport interface UpdateSendsTable {\n\tsend_key: string;\n\tsubscriber_id: string;\n\tsent_at: Generated<Date>;\n}\n\n/**\n * 24h hosted record of a failed API request, keyed by `request_id` and\n * scoped to the account that made it. `query` is redacted before insert.\n */\nexport interface ApiFailedRequestsTable {\n\trequest_id: string;\n\taccount_id: string;\n\tmethod: string;\n\tpath: string;\n\tstatus: number;\n\tcode: string;\n\tmessage: Generated<string>;\n\tquery: Record<string, unknown>;\n\torigin: string | null;\n\t/** Revoked account key the request presented (`KEY_REVOKED` only). */\n\tapi_key_id: string | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type ApiFailedRequest = Selectable<ApiFailedRequestsTable>;\nexport type InsertApiFailedRequest = Insertable<ApiFailedRequestsTable>;\n\n/**\n * 7-day hosted log of account-attributed Index/Streams reads. Query values\n * are stored only as hashes; never bodies, headers or tokens.\n */\nexport interface ApiRequestLogTable {\n\tid: Generated<string>;\n\trequest_id: string | null;\n\taccount_id: string;\n\tapi_key_id: string | null;\n\tmethod: string;\n\tpath: string;\n\tpath_template: string;\n\tparams_hash: string | null;\n\tcursor_hash: string | null;\n\tpage_size: number | null;\n\trows: number | null;\n\tstatus: number;\n\tduration_ms: number;\n\tcreated_at: Generated<Date>;\n}\n\nexport type ApiRequestLogRow = Selectable<ApiRequestLogTable>;\nexport type InsertApiRequestLogRow = Insertable<ApiRequestLogTable>;\n\n/**\n * Hosted problem report. `attempted` is the server's own copy of the failed\n * request (never caller-supplied); `status` starts `new` until classified.\n */\nexport interface FeedbackTicketsTable {\n\tid: Generated<string>;\n\taccount_id: string;\n\tidempotency_key: string | null;\n\trequest_id: string | null;\n\tintent: string;\n\t/** Any JSON value the caller sent: a sentence or a shape. */\n\texpected: unknown;\n\tkind_hint: string | null;\n\tevidence: Record<string, unknown> | null;\n\tattempted: Record<string, unknown> | null;\n\torigin: string;\n\tstatus: Generated<\"new\" | \"classified\">;\n\troute: string | null;\n\tclassification: Record<string, unknown> | null;\n\tclassified_at: Date | null;\n\tcreated_at: Generated<Date>;\n}\n\nexport type FeedbackTicket = Selectable<FeedbackTicketsTable>;\nexport type InsertFeedbackTicket = Insertable<FeedbackTicketsTable>;\n\nexport type Waitlist = Selectable<WaitlistsTable>;\nexport type WaitlistSignup = Selectable<WaitlistSignupsTable>;\nexport type InsertWaitlistSignup = Insertable<WaitlistSignupsTable>;\n\nexport type ContactRequest = Selectable<ContactRequestsTable>;\nexport type InsertContactRequest = Insertable<ContactRequestsTable>;\n\nexport type UpdateSubscriber = Selectable<UpdateSubscribersTable>;\nexport type InsertUpdateSubscriber = Insertable<UpdateSubscribersTable>;\n",
12
+ "import type { Database } from \"./types.ts\";\n\n// The physical source-table columns the public read API (packages/api) actually\n// reads via getSourceDb(). This is the read contract between the indexer (which\n// owns the write schema) and the API (which reads it raw). A column rename or\n// removal on the producer side that isn't reflected here is caught by the\n// snapshot drift test; the `satisfies` clause guarantees every entry is a real\n// table + column today.\n//\n// Computed/aliased read expressions are intentionally excluded — they are not\n// part of the producer contract: `cursor`/`block_time` where derived in SQL\n// rather than stored, window ranks (stream_event_index), and JSONB extractions\n// from `events.data`. Generated bookkeeping columns (created_at/updated_at) are\n// excluded unless a read path selects them.\nexport const SOURCE_READ_COLUMNS = {\n\tblocks: [\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"canonical\",\n\t\t\"hash\",\n\t\t\"height\",\n\t\t\"parent_hash\",\n\t\t\"timestamp\",\n\t],\n\tdecoded_events: [\n\t\t\"amount\",\n\t\t\"asset_identifier\",\n\t\t\"block_height\",\n\t\t\"canonical\",\n\t\t\"contract_id\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"event_type\",\n\t\t\"memo\",\n\t\t\"payload\",\n\t\t\"recipient\",\n\t\t\"sender\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"value\",\n\t],\n\ttransactions: [\n\t\t\"block_height\",\n\t\t\"contract_id\",\n\t\t\"function_args\",\n\t\t\"function_name\",\n\t\t\"raw_result\",\n\t\t\"raw_tx\",\n\t\t\"sender\",\n\t\t\"status\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"type\",\n\t],\n\tmempool_transactions: [\n\t\t\"contract_id\",\n\t\t\"function_args\",\n\t\t\"function_name\",\n\t\t\"raw_tx\",\n\t\t\"received_at\",\n\t\t\"sender\",\n\t\t\"seq\",\n\t\t\"tx_id\",\n\t\t\"type\",\n\t],\n\tpox5_events: [\n\t\t\"amount_sats\",\n\t\t\"amount_ustx\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bond_index\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"data\",\n\t\t\"event_index\",\n\t\t\"first_reward_cycle\",\n\t\t\"is_l1_lock\",\n\t\t\"reward_cycle\",\n\t\t\"signer\",\n\t\t\"signer_key\",\n\t\t\"signer_manager\",\n\t\t\"staker\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t\t\"unlock_burn_height\",\n\t\t\"unlock_cycle\",\n\t],\n\tsbtc_events: [\n\t\t\"amount\",\n\t\t\"bitcoin_txid\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"burn_hash\",\n\t\t\"burn_height\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"fee\",\n\t\t\"governance_contract_type\",\n\t\t\"governance_new_contract\",\n\t\t\"max_fee\",\n\t\t\"output_index\",\n\t\t\"recipient\",\n\t\t\"recipient_btc_hashbytes\",\n\t\t\"recipient_btc_version\",\n\t\t\"request_id\",\n\t\t\"sender\",\n\t\t\"signer_address\",\n\t\t\"signer_aggregate_pubkey\",\n\t\t\"signer_bitmap\",\n\t\t\"signer_keys_count\",\n\t\t\"signer_threshold\",\n\t\t\"sweep_txid\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tsbtc_token_events: [\n\t\t\"amount\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"event_type\",\n\t\t\"memo\",\n\t\t\"recipient\",\n\t\t\"sender\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_name_events: [\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bns_id\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"fqn\",\n\t\t\"hashed_salted_fqn_preorder\",\n\t\t\"imported_at\",\n\t\t\"name\",\n\t\t\"namespace\",\n\t\t\"owner\",\n\t\t\"preordered_by\",\n\t\t\"registered_at\",\n\t\t\"renewal_height\",\n\t\t\"stx_burn\",\n\t\t\"topic\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_namespace_events: [\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"canonical\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"launched_at\",\n\t\t\"lifetime\",\n\t\t\"manager\",\n\t\t\"manager_frozen\",\n\t\t\"manager_transfers_disabled\",\n\t\t\"namespace\",\n\t\t\"price_frozen\",\n\t\t\"price_function\",\n\t\t\"revealed_at\",\n\t\t\"status\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_marketplace_events: [\n\t\t\"action\",\n\t\t\"block_height\",\n\t\t\"block_time\",\n\t\t\"bns_id\",\n\t\t\"canonical\",\n\t\t\"commission\",\n\t\t\"cursor\",\n\t\t\"event_index\",\n\t\t\"price_ustx\",\n\t\t\"tx_id\",\n\t\t\"tx_index\",\n\t],\n\tbns_names: [\n\t\t\"bns_id\",\n\t\t\"fqn\",\n\t\t\"last_event_at\",\n\t\t\"last_event_cursor\",\n\t\t\"name\",\n\t\t\"namespace\",\n\t\t\"owner\",\n\t\t\"registered_at\",\n\t\t\"renewal_height\",\n\t],\n\tbns_namespaces: [\n\t\t\"last_event_at\",\n\t\t\"last_event_cursor\",\n\t\t\"launched_at\",\n\t\t\"lifetime\",\n\t\t\"manager\",\n\t\t\"manager_frozen\",\n\t\t\"name_count\",\n\t\t\"namespace\",\n\t\t\"price_frozen\",\n\t],\n\tburn_block_rewards: [\n\t\t\"amount_sats\",\n\t\t\"burn_amount\",\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"cursor\",\n\t\t\"recipient_btc\",\n\t\t\"reward_index\",\n\t],\n\tburn_block_reward_slots: [\n\t\t\"burn_block_hash\",\n\t\t\"burn_block_height\",\n\t\t\"cursor\",\n\t\t\"holder_btc\",\n\t\t\"slot_index\",\n\t],\n\tevents: [\"block_height\", \"data\", \"event_index\", \"tx_id\", \"type\"],\n\tchain_reorgs: [\"detected_at\"],\n} as const satisfies {\n\treadonly [T in keyof Database]?: readonly (keyof Database[T])[];\n};\n\n/** Portable column type for the Index read domain (a lean, ORM-agnostic vocab). */\nexport type IndexColumnType =\n\t| \"text\"\n\t| \"int\"\n\t| \"boolean\"\n\t| \"timestamp\"\n\t| \"jsonb\";\n\nexport interface IndexColumn {\n\ttype: IndexColumnType;\n\t/** SELECT type includes `| null`. Omitted = NOT NULL. */\n\tnullable?: boolean;\n}\n\n// The portable TS/SQL type for every column in SOURCE_READ_COLUMNS, single-sourced\n// from the `Database` interface (the producer's typed schema). This is what lets\n// `sl codegen index` emit a typed ORM/JSON-Schema for the public Index domain so a\n// read mirror is fully typed and can't drift from the API. The drift test\n// (source-read-columns.test.ts) asserts this covers exactly SOURCE_READ_COLUMNS;\n// the `satisfies` clause guarantees a type entry for every read table.\n//\n// `string` amount/value columns (e.g. amount_ustx, fee, price_ustx) are NUMERIC in\n// Postgres surfaced as strings — `text` here is lossless for a read mirror. `number`\n// columns map to `int`. Enum string-unions (topic, status, …) map to `text`.\nexport const SOURCE_READ_TYPES = {\n\tblocks: {\n\t\tburn_block_hash: { type: \"text\", nullable: true },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\thash: { type: \"text\" },\n\t\theight: { type: \"int\" },\n\t\tparent_hash: { type: \"text\" },\n\t\ttimestamp: { type: \"int\" },\n\t},\n\tdecoded_events: {\n\t\tamount: { type: \"text\", nullable: true },\n\t\tasset_identifier: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tevent_type: { type: \"text\" },\n\t\tmemo: { type: \"text\", nullable: true },\n\t\tpayload: { type: \"jsonb\", nullable: true },\n\t\trecipient: { type: \"text\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\tvalue: { type: \"text\", nullable: true },\n\t},\n\ttransactions: {\n\t\tblock_height: { type: \"int\" },\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tfunction_args: { type: \"jsonb\", nullable: true },\n\t\tfunction_name: { type: \"text\", nullable: true },\n\t\traw_result: { type: \"text\", nullable: true },\n\t\traw_tx: { type: \"text\" },\n\t\tsender: { type: \"text\" },\n\t\tstatus: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tmempool_transactions: {\n\t\tcontract_id: { type: \"text\", nullable: true },\n\t\tfunction_args: { type: \"jsonb\", nullable: true },\n\t\tfunction_name: { type: \"text\", nullable: true },\n\t\traw_tx: { type: \"text\" },\n\t\treceived_at: { type: \"timestamp\" },\n\t\tsender: { type: \"text\" },\n\t\tseq: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tpox5_events: {\n\t\tamount_sats: { type: \"text\", nullable: true },\n\t\tamount_ustx: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbond_index: { type: \"int\", nullable: true },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tdata: { type: \"jsonb\", nullable: true },\n\t\tevent_index: { type: \"int\" },\n\t\tfirst_reward_cycle: { type: \"int\", nullable: true },\n\t\tis_l1_lock: { type: \"boolean\", nullable: true },\n\t\treward_cycle: { type: \"int\", nullable: true },\n\t\tsigner: { type: \"text\", nullable: true },\n\t\tsigner_key: { type: \"text\", nullable: true },\n\t\tsigner_manager: { type: \"text\", nullable: true },\n\t\tstaker: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t\tunlock_burn_height: { type: \"int\", nullable: true },\n\t\tunlock_cycle: { type: \"int\", nullable: true },\n\t},\n\tsbtc_events: {\n\t\tamount: { type: \"text\", nullable: true },\n\t\tbitcoin_txid: { type: \"text\", nullable: true },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tburn_hash: { type: \"text\", nullable: true },\n\t\tburn_height: { type: \"int\", nullable: true },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tfee: { type: \"text\", nullable: true },\n\t\tgovernance_contract_type: { type: \"int\", nullable: true },\n\t\tgovernance_new_contract: { type: \"text\", nullable: true },\n\t\tmax_fee: { type: \"text\", nullable: true },\n\t\toutput_index: { type: \"int\", nullable: true },\n\t\trecipient: { type: \"text\", nullable: true },\n\t\trecipient_btc_hashbytes: { type: \"text\", nullable: true },\n\t\trecipient_btc_version: { type: \"int\", nullable: true },\n\t\trequest_id: { type: \"int\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\tsigner_address: { type: \"text\", nullable: true },\n\t\tsigner_aggregate_pubkey: { type: \"text\", nullable: true },\n\t\tsigner_bitmap: { type: \"text\", nullable: true },\n\t\tsigner_keys_count: { type: \"int\", nullable: true },\n\t\tsigner_threshold: { type: \"int\", nullable: true },\n\t\tsweep_txid: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tsbtc_token_events: {\n\t\tamount: { type: \"text\" },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tevent_type: { type: \"text\" },\n\t\tmemo: { type: \"text\", nullable: true },\n\t\trecipient: { type: \"text\", nullable: true },\n\t\tsender: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_name_events: {\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbns_id: { type: \"text\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tfqn: { type: \"text\" },\n\t\thashed_salted_fqn_preorder: { type: \"text\", nullable: true },\n\t\timported_at: { type: \"int\", nullable: true },\n\t\tname: { type: \"text\" },\n\t\tnamespace: { type: \"text\" },\n\t\towner: { type: \"text\", nullable: true },\n\t\tpreordered_by: { type: \"text\", nullable: true },\n\t\tregistered_at: { type: \"int\", nullable: true },\n\t\trenewal_height: { type: \"int\", nullable: true },\n\t\tstx_burn: { type: \"text\", nullable: true },\n\t\ttopic: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_namespace_events: {\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tlaunched_at: { type: \"int\", nullable: true },\n\t\tlifetime: { type: \"int\", nullable: true },\n\t\tmanager: { type: \"text\", nullable: true },\n\t\tmanager_frozen: { type: \"boolean\", nullable: true },\n\t\tmanager_transfers_disabled: { type: \"boolean\", nullable: true },\n\t\tnamespace: { type: \"text\" },\n\t\tprice_frozen: { type: \"boolean\", nullable: true },\n\t\tprice_function: { type: \"text\", nullable: true },\n\t\trevealed_at: { type: \"int\", nullable: true },\n\t\tstatus: { type: \"text\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_marketplace_events: {\n\t\taction: { type: \"text\" },\n\t\tblock_height: { type: \"int\" },\n\t\tblock_time: { type: \"timestamp\" },\n\t\tbns_id: { type: \"text\" },\n\t\tcanonical: { type: \"boolean\" },\n\t\tcommission: { type: \"text\", nullable: true },\n\t\tcursor: { type: \"text\" },\n\t\tevent_index: { type: \"int\" },\n\t\tprice_ustx: { type: \"text\", nullable: true },\n\t\ttx_id: { type: \"text\" },\n\t\ttx_index: { type: \"int\" },\n\t},\n\tbns_names: {\n\t\tbns_id: { type: \"text\" },\n\t\tfqn: { type: \"text\" },\n\t\tlast_event_at: { type: \"timestamp\" },\n\t\tlast_event_cursor: { type: \"text\" },\n\t\tname: { type: \"text\" },\n\t\tnamespace: { type: \"text\" },\n\t\towner: { type: \"text\" },\n\t\tregistered_at: { type: \"int\", nullable: true },\n\t\trenewal_height: { type: \"int\", nullable: true },\n\t},\n\tbns_namespaces: {\n\t\tlast_event_at: { type: \"timestamp\" },\n\t\tlast_event_cursor: { type: \"text\" },\n\t\tlaunched_at: { type: \"int\", nullable: true },\n\t\tlifetime: { type: \"int\", nullable: true },\n\t\tmanager: { type: \"text\", nullable: true },\n\t\tmanager_frozen: { type: \"boolean\" },\n\t\tname_count: { type: \"int\" },\n\t\tnamespace: { type: \"text\" },\n\t\tprice_frozen: { type: \"boolean\" },\n\t},\n\tburn_block_rewards: {\n\t\tamount_sats: { type: \"text\" },\n\t\tburn_amount: { type: \"text\" },\n\t\tburn_block_hash: { type: \"text\" },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcursor: { type: \"text\" },\n\t\trecipient_btc: { type: \"text\" },\n\t\treward_index: { type: \"int\" },\n\t},\n\tburn_block_reward_slots: {\n\t\tburn_block_hash: { type: \"text\" },\n\t\tburn_block_height: { type: \"int\" },\n\t\tcursor: { type: \"text\" },\n\t\tholder_btc: { type: \"text\" },\n\t\tslot_index: { type: \"int\" },\n\t},\n\tevents: {\n\t\tblock_height: { type: \"int\" },\n\t\tdata: { type: \"jsonb\" },\n\t\tevent_index: { type: \"int\" },\n\t\ttx_id: { type: \"text\" },\n\t\ttype: { type: \"text\" },\n\t},\n\tchain_reorgs: {\n\t\tdetected_at: { type: \"timestamp\" },\n\t},\n} as const satisfies Record<\n\tkeyof typeof SOURCE_READ_COLUMNS,\n\tRecord<string, IndexColumn>\n>;\n\nexport type IndexPrimaryKey = readonly string[] | null;\n\n// Primary key per read table, for codegen targets that require a model identity\n// (Prisma). Every listed column must be a read column (drift-tested). `null` = no\n// usable read-column key — the physical PK is a synthetic id excluded from the\n// read contract (chain_reorgs) — so Prisma omits the table. `events` uses its\n// natural unique (tx_id, event_index); its physical PK is a synthetic uuid not\n// surfaced in the read set.\nexport const SOURCE_READ_PKS = {\n\tblocks: [\"height\"],\n\tdecoded_events: [\"cursor\"],\n\ttransactions: [\"tx_id\"],\n\tmempool_transactions: [\"seq\"],\n\tpox5_events: [\"cursor\"],\n\tsbtc_events: [\"cursor\"],\n\tsbtc_token_events: [\"cursor\"],\n\tbns_name_events: [\"cursor\"],\n\tbns_namespace_events: [\"cursor\"],\n\tbns_marketplace_events: [\"cursor\"],\n\tbns_names: [\"fqn\"],\n\tbns_namespaces: [\"namespace\"],\n\tburn_block_rewards: [\"cursor\"],\n\tburn_block_reward_slots: [\"cursor\"],\n\tevents: [\"tx_id\", \"event_index\"],\n\tchain_reorgs: null,\n} as const satisfies Record<keyof typeof SOURCE_READ_COLUMNS, IndexPrimaryKey>;\n",
13
13
  "import { type RawBuilder, sql } from \"kysely\";\n\n/**\n * Safely encode a JS value as a JSONB literal for Kysely inserts/updates.\n * Kysely + postgres.js double-encodes JSON when using parameterized queries\n * with ::jsonb casts. This uses sql.raw to inline a properly escaped literal.\n *\n * Generic parameter lets callers set the RawBuilder's output type so they\n * don't need to cast at the insert site. Default is `unknown` — widen at\n * the call site when the column type is narrower, e.g. `jsonb<MyShape>(...)`.\n */\nexport function jsonb<T = unknown>(value: T): RawBuilder<T> {\n\tconst escaped = JSON.stringify(value, (_k, v) =>\n\t\ttypeof v === \"bigint\" ? v.toString() : v,\n\t).replace(/'/g, \"''\");\n\treturn sql`${sql.raw(`'${escaped}'::jsonb`)}`;\n}\n\n/**\n * Safely parse a JSONB value from the database.\n * Handles double-encoded strings where postgres.js returns a JSON string\n * instead of a parsed object.\n */\nexport function parseJsonb<T = unknown>(value: unknown): T {\n\tif (typeof value === \"string\") {\n\t\ttry {\n\t\t\treturn JSON.parse(value) as T;\n\t\t} catch {\n\t\t\treturn value as T;\n\t\t}\n\t}\n\treturn (value ?? {}) as T;\n}\n",
14
14
  "/**\n * Per-migration DB-plane gating for the source/target split.\n *\n * Under the split, SOURCE (chain DB) holds only chain+decoded tables — the\n * control-plane tables were dropped to reclaim space — while TARGET (platform\n * DB) holds the control plane. `migrate.ts` still runs EVERY migration on EVERY\n * database (kysely integrity: the provider set must never be filtered per-DB, or\n * kysely throws \"previously executed migration is missing\" because each DB's\n * `kysely_migration` already records all of them). Instead, `migrate.ts` sets a\n * role before each pass and a migration gates its DDL with the helpers below: a\n * control migration's `up()` is a no-op on SOURCE but is still recorded applied,\n * so there is no missing-migration error and no re-run.\n *\n * `'both'` is single-DB / collapsed-split mode (dev / OSS / CI): every helper\n * runs, identical to pre-split behavior.\n *\n * Authoring a new migration under the split:\n * export async function up(db: Kysely<unknown>): Promise<void> {\n * await onControlPlane(() => sql`ALTER TABLE accounts ADD COLUMN …`.execute(db));\n * await onChainPlane(() => sql`ALTER TABLE blocks ADD COLUMN …`.execute(db));\n * // schema-wide / mixed statements: leave unwrapped (run on both).\n * }\n */\n\nexport type MigrationRole = \"source\" | \"target\" | \"both\";\n\n// Module-level singleton: migrate runs sequentially in one process, one target\n// at a time, so there is no concurrency to guard.\nlet currentRole: MigrationRole = \"both\";\n\nexport function setMigrationRole(role: MigrationRole): void {\n\tcurrentRole = role;\n}\n\nexport function getMigrationRole(): MigrationRole {\n\treturn currentRole;\n}\n\n/** Run control-plane (TARGET) DDL only when this pass targets the control plane. */\nexport async function onControlPlane(fn: () => Promise<void>): Promise<void> {\n\tif (currentRole === \"target\" || currentRole === \"both\") await fn();\n}\n\n/** Run chain/decoded (SOURCE) DDL only when this pass targets the chain plane. */\nexport async function onChainPlane(fn: () => Promise<void>): Promise<void> {\n\tif (currentRole === \"source\" || currentRole === \"both\") await fn();\n}\n",
15
- "import type { Database } from \"./types.ts\";\n\nexport type DbPlane = \"source\" | \"target\" | \"both\";\n\n/**\n * Canonical table → DB-plane mapping for the source/target split.\n *\n * SOURCE = chain + decoded (the `postgres` instance); TARGET = control plane\n * (the `postgres-platform` instance). `both` = present/used on both planes\n * (`service_heartbeats`: the indexer writes its row on SOURCE, the\n * subgraph-processor writes its row on TARGET).\n *\n * `satisfies Record<keyof Database, DbPlane>` makes adding a table to `Database`\n * without classifying it here a COMPILE error. This is the single source of\n * truth for the split — `docker/SCHEMA_SPLIT.md` and the cutover script's\n * `CONTROL_TABLES` mirror the `target` set (guarded by `table-plane.test.ts`).\n * Use it to decide which migration helper a table's DDL belongs in\n * (`onControlPlane` for `target`, `onChainPlane` for `source`).\n *\n * Note: `kysely_migration` / `kysely_migration_lock` are kysely-managed (not in\n * `Database`) and exist on both — they are intentionally not listed here.\n */\nexport const TABLE_TO_DB = {\n\t// ── SOURCE: raw chain ──\n\tblocks: \"source\",\n\ttransactions: \"source\",\n\tevents: \"source\",\n\tvm_events: \"source\",\n\tstate_writes: \"source\",\n\ttransactions_archive: \"source\",\n\tevents_archive: \"source\",\n\tvm_events_archive: \"source\",\n\tstate_writes_archive: \"source\",\n\tdead_letter_events: \"source\",\n\tmempool_transactions: \"source\",\n\tindex_progress: \"source\",\n\tcontracts: \"source\",\n\tchain_reorgs: \"source\",\n\t// Chain-derived read memo — keyed on index_block_hash, lives with the\n\t// blocks it pins to.\n\tchain_read_cache: \"source\",\n\t// Staged fork contenders — raw chain data, resolved during ingest.\n\tpending_fork_blocks: \"source\",\n\t// Exact observer callback receipts — the replay authority sits with chain data.\n\tobserver_journal: \"source\",\n\t// Declared scope — belongs with the chain whose start it declares.\n\tsync_scopes: \"source\",\n\t// Coverage kernel — attests the chain it sits next to.\n\tstage_registry: \"source\",\n\tstage_runs: \"source\",\n\tstage_block_receipts: \"source\",\n\tcoverage_segments: \"source\",\n\tstage_failures: \"source\",\n\t// ── SOURCE: decoded ──\n\tdecoded_events: \"source\",\n\tdecoder_checkpoints: \"source\",\n\tpox4_calls: \"source\",\n\tpox5_events: \"source\",\n\tpox5_cycles: \"source\",\n\tpox5_cycle_signers: \"source\",\n\tburn_block_rewards: \"source\",\n\tburn_block_reward_slots: \"source\",\n\tsbtc_events: \"source\",\n\tsbtc_token_events: \"source\",\n\tsbtc_settlements: \"source\",\n\tbns_name_events: \"source\",\n\tbns_namespace_events: \"source\",\n\tbns_marketplace_events: \"source\",\n\tbns_names: \"source\",\n\tbns_namespaces: \"source\",\n\t// ── TARGET: accounts / auth / billing ──\n\tinstances: \"target\",\n\taccounts: \"target\",\n\tapi_keys: \"target\",\n\tsessions: \"target\",\n\tmagic_links: \"target\",\n\tcli_device_logins: \"target\",\n\toauth_clients: \"target\",\n\toauth_requests: \"target\",\n\toauth_codes: \"target\",\n\toauth_grants: \"target\",\n\toauth_tokens: \"target\",\n\toauth_refresh_retired: \"target\",\n\taccount_spend_caps: \"target\",\n\tprocessed_stripe_events: \"target\",\n\t// ── TARGET: webhooks ──\n\twebhooks: \"target\",\n\twebhook_outbox: \"target\",\n\twebhook_deliveries: \"target\",\n\twebhook_delivery_hours: \"target\",\n\twebhook_replays: \"target\",\n\ttrigger_evaluator_state: \"target\",\n\t// ── TARGET: subgraphs + metadata ──\n\tsubgraphs: \"target\",\n\tsubgraph_operations: \"target\",\n\tsubgraph_health_snapshots: \"target\",\n\tsubgraph_gaps: \"target\",\n\tsubgraph_violations: \"target\",\n\tsubgraph_error_groups: \"target\",\n\tsubgraph_processing_stats: \"target\",\n\taccount_credits: \"target\",\n\t// ── TARGET: archive fetch gate charge log ──\n\tarchive_fetches: \"target\",\n\t// ── TARGET: metered ledger (one append-only row per billable event) ──\n\tusage_ledger: \"target\",\n\taccount_balance_alerts: \"target\",\n\thosted_stack_state: \"target\",\n\twebhook_incident_alerts: \"target\",\n\t// ── TARGET: accounts Sentinel's service key may touch ──\n\tsentinel_accounts: \"target\",\n\t// ── TARGET: public waitlist pages ──\n\twaitlists: \"target\",\n\twaitlist_signups: \"target\",\n\tcontact_requests: \"target\",\n\tupdate_subscribers: \"target\",\n\tupdate_sends: \"target\",\n\t// ── TARGET: 24h hosted failed-request record (feedback evidence) ──\n\tapi_failed_requests: \"target\",\n\t// ── TARGET: 7-day account read log (dashboard insight evidence) ──\n\tapi_request_log: \"target\",\n\t// ── TARGET: ranked dashboard insights + \"expected\" mutes ──\n\tinsights: \"target\",\n\tinsight_mutes: \"target\",\n\t// ── TARGET: hosted problem reports ──\n\tfeedback_tickets: \"target\",\n\t// ── TARGET: web push subscriptions + per-account toggles ──\n\tpush_subscriptions: \"target\",\n\tpush_prefs: \"target\",\n\tpush_sent: \"target\",\n\t// ── BOTH ──\n\tservice_heartbeats: \"both\",\n} satisfies Record<keyof Database, DbPlane>;\n"
15
+ "import type { Database } from \"./types.ts\";\n\nexport type DbPlane = \"source\" | \"target\" | \"both\";\n\n/**\n * Canonical table → DB-plane mapping for the source/target split.\n *\n * SOURCE = chain + decoded (the `postgres` instance); TARGET = control plane\n * (the `postgres-platform` instance). `both` = present/used on both planes\n * (`service_heartbeats`: the indexer writes its row on SOURCE, the\n * subgraph-processor writes its row on TARGET).\n *\n * `satisfies Record<keyof Database, DbPlane>` makes adding a table to `Database`\n * without classifying it here a COMPILE error. This is the single source of\n * truth for the split — `docker/SCHEMA_SPLIT.md` and the cutover script's\n * `CONTROL_TABLES` mirror the `target` set (guarded by `table-plane.test.ts`).\n * Use it to decide which migration helper a table's DDL belongs in\n * (`onControlPlane` for `target`, `onChainPlane` for `source`).\n *\n * Note: `kysely_migration` / `kysely_migration_lock` are kysely-managed (not in\n * `Database`) and exist on both — they are intentionally not listed here.\n */\nexport const TABLE_TO_DB = {\n\t// ── SOURCE: raw chain ──\n\tblocks: \"source\",\n\ttransactions: \"source\",\n\tevents: \"source\",\n\tvm_events: \"source\",\n\tstate_writes: \"source\",\n\ttransactions_archive: \"source\",\n\tevents_archive: \"source\",\n\tvm_events_archive: \"source\",\n\tstate_writes_archive: \"source\",\n\tdead_letter_events: \"source\",\n\tmempool_transactions: \"source\",\n\tindex_progress: \"source\",\n\tcontracts: \"source\",\n\tchain_reorgs: \"source\",\n\t// Chain-derived read memo — keyed on index_block_hash, lives with the\n\t// blocks it pins to.\n\tchain_read_cache: \"source\",\n\t// Staged fork contenders — raw chain data, resolved during ingest.\n\tpending_fork_blocks: \"source\",\n\t// Exact observer callback receipts — the replay authority sits with chain data.\n\tobserver_journal: \"source\",\n\t// Declared scope — belongs with the chain whose start it declares.\n\tsync_scopes: \"source\",\n\t// Coverage kernel — attests the chain it sits next to.\n\tstage_registry: \"source\",\n\tstage_runs: \"source\",\n\tstage_block_receipts: \"source\",\n\tcoverage_segments: \"source\",\n\tstage_failures: \"source\",\n\t// ── SOURCE: decoded ──\n\tdecoded_events: \"source\",\n\tdecoder_checkpoints: \"source\",\n\tpox5_events: \"source\",\n\tpox5_cycles: \"source\",\n\tpox5_cycle_signers: \"source\",\n\tburn_block_rewards: \"source\",\n\tburn_block_reward_slots: \"source\",\n\tsbtc_events: \"source\",\n\tsbtc_token_events: \"source\",\n\tsbtc_settlements: \"source\",\n\tbns_name_events: \"source\",\n\tbns_namespace_events: \"source\",\n\tbns_marketplace_events: \"source\",\n\tbns_names: \"source\",\n\tbns_namespaces: \"source\",\n\t// ── TARGET: accounts / auth / billing ──\n\tinstances: \"target\",\n\taccounts: \"target\",\n\tapi_keys: \"target\",\n\tsessions: \"target\",\n\tmagic_links: \"target\",\n\tcli_device_logins: \"target\",\n\toauth_clients: \"target\",\n\toauth_requests: \"target\",\n\toauth_codes: \"target\",\n\toauth_grants: \"target\",\n\toauth_tokens: \"target\",\n\toauth_refresh_retired: \"target\",\n\taccount_spend_caps: \"target\",\n\tprocessed_stripe_events: \"target\",\n\t// ── TARGET: webhooks ──\n\twebhooks: \"target\",\n\twebhook_outbox: \"target\",\n\twebhook_deliveries: \"target\",\n\twebhook_delivery_hours: \"target\",\n\twebhook_replays: \"target\",\n\ttrigger_evaluator_state: \"target\",\n\t// ── TARGET: subgraphs + metadata ──\n\tsubgraphs: \"target\",\n\tsubgraph_operations: \"target\",\n\tsubgraph_health_snapshots: \"target\",\n\tsubgraph_gaps: \"target\",\n\tsubgraph_violations: \"target\",\n\tsubgraph_error_groups: \"target\",\n\tsubgraph_processing_stats: \"target\",\n\taccount_credits: \"target\",\n\t// ── TARGET: archive fetch gate charge log ──\n\tarchive_fetches: \"target\",\n\t// ── TARGET: metered ledger (one append-only row per billable event) ──\n\tusage_ledger: \"target\",\n\taccount_balance_alerts: \"target\",\n\thosted_stack_state: \"target\",\n\twebhook_incident_alerts: \"target\",\n\t// ── TARGET: accounts Sentinel's service key may touch ──\n\tsentinel_accounts: \"target\",\n\t// ── TARGET: public waitlist pages ──\n\twaitlists: \"target\",\n\twaitlist_signups: \"target\",\n\tcontact_requests: \"target\",\n\tupdate_subscribers: \"target\",\n\tupdate_sends: \"target\",\n\t// ── TARGET: 24h hosted failed-request record (feedback evidence) ──\n\tapi_failed_requests: \"target\",\n\t// ── TARGET: 7-day account read log (dashboard insight evidence) ──\n\tapi_request_log: \"target\",\n\t// ── TARGET: ranked dashboard insights + \"expected\" mutes ──\n\tinsights: \"target\",\n\tinsight_mutes: \"target\",\n\t// ── TARGET: hosted problem reports ──\n\tfeedback_tickets: \"target\",\n\t// ── TARGET: web push subscriptions + per-account toggles ──\n\tpush_subscriptions: \"target\",\n\tpush_prefs: \"target\",\n\tpush_sent: \"target\",\n\t// ── BOTH ──\n\tservice_heartbeats: \"both\",\n} satisfies Record<keyof Database, DbPlane>;\n"
16
16
  ],
17
- "mappings": ";AAAA;;;ACAA;AACA;AACA;;;ACFA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OA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A;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,aAAa;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,mBAAmB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,iBAAiB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,wBAAwB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAA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AA,EACD;AAAA,EACA,gBAAgB;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,cAAc;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,sBAAsB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,aAAa;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,aAAa;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,EACA,mBAAmB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAAA,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