Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(minions): spend authorization schema and group budget key
garrytane42dfc948576
diff --git a/src/core/engine-sql/bootstrap.ts b/src/core/engine-sql/bootstrap.tsindex feddb1cdaa..351d3e5f6e 100644--- a/src/core/engine-sql/bootstrap.ts+++ b/src/core/engine-sql/bootstrap.ts@@ -166,6 +166,8 @@ const FORWARD_REFERENCE_PROBES: readonly Probe[] = [['minion_jobs_pq_lease_exists', 'minion_jobs', 'private_queue_lease_until'],['minion_jobs_submission_authority_exists', 'minion_jobs', 'submission_authority'],['minion_jobs_claim_generation_exists', 'minion_jobs', 'claim_generation'],+ ['minion_jobs_spend_authorization_exists', 'minion_jobs', 'spend_authorization'],+ ['minion_jobs_spend_claim_token_exists', 'minion_jobs', 'spend_claim_token'],['facts_exists', 'facts'],['facts_embedding_model_exists', 'facts', 'embedding_model'],['facts_embedded_text_hash_exists', 'facts', 'embedded_text_hash'],@@ -297,10 +299,12 @@ export function forwardReferenceGaps(probe: ProbeRow, dialect: ForwardReferenceBconst needsMinionJobsPrivateQueue = probe.minion_jobs_exists&& (!probe.minion_jobs_pq_owner_exists || !probe.minion_jobs_pq_token_exists|| !probe.minion_jobs_pq_lease_exists);- // v149: the schema-blob queue protocol references both fields. Repair either- // missing field without assigning authority to historical work.+ // v149/v201: the schema-blob queue protocol references these fields and the+ // blob indexes the spend group. Repair any missing field without assigning+ // authority to historical work.const needsMinionJobsAuthority = probe.minion_jobs_exists- && (!probe.minion_jobs_submission_authority_exists || !probe.minion_jobs_claim_generation_exists);+ && (!probe.minion_jobs_submission_authority_exists || !probe.minion_jobs_claim_generation_exists+ || !probe.minion_jobs_spend_authorization_exists || !probe.minion_jobs_spend_claim_token_exists);// v143 (dream_verdicts_ttl, #4657): the Postgres blob index// dream_verdicts_expires_idx references expires_at, but the column only// lands via migration v143 — a Postgres brain at schema v30-v142@@ -715,6 +719,8 @@ async function applyLaterColumnGaps(target: ForwardReferenceBootstrapTarget, gapawait exec(`ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS submission_authority JSONB;ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS claim_generation BIGINT NOT NULL DEFAULT 0;+ ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS spend_authorization JSONB;+ ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS spend_claim_token BIGINT;`);}}diff --git a/src/core/minions/budget-meter.ts b/src/core/minions/budget-meter.tsindex c45fb8f947..29c47120d6 100644--- a/src/core/minions/budget-meter.ts+++ b/src/core/minions/budget-meter.ts@@ -9,7 +9,7 @@* and both proceed, total spend = $8. That's the bug. The fix is atomic* check-and-reserve under pg_advisory_xact_lock.*- * The lock key is hashed from client_id. Stale reservations (worker+ * The lock key is hashed from client_id (or the group budget key). Stale reservations (worker* crashed before settle) become overdue after `RESERVATION_TTL_MS`.* Their liability remains reserved until actual usage is reconciled: a* timeout or UTC day change is not evidence that a provider did no work.@@ -164,6 +164,120 @@ export async function reserve(};}+/**+ * Why a group reservation was refused. `exhausted`: settled spend plus+ * overdue holds leave no room, so the group is done. `pressure`: only live+ * holds of concurrent attempts are in the way; a retry after they settle can+ * be admitted.+ */+export class GroupBudgetRefusal extends BudgetExceededError {+ constructor(+ readonly kind: 'exhausted' | 'pressure',+ readonly budgetKey: string,+ readonly spend: GroupSpend,+ capCents: number,+ ) {+ super(+ `budget ${kind === 'exhausted' ? 'exhausted' : 'under pressure'} for ${budgetKey}: ` ++ `committed=${spend.committedCents.toFixed(2)}¢, overdue=${spend.overdueCents.toFixed(2)}¢, ` ++ `live=${spend.liveCents.toFixed(2)}¢, cap=${capCents.toFixed(2)}¢`,+ spend.committedCents + spend.overdueCents,+ capCents,+ );+ this.name = 'GroupBudgetRefusal';+ }+}++/** A group budget's lifetime totals in cents. Overdue holds count as spent until reconciled. */+export interface GroupSpend {+ committedCents: number;+ overdueCents: number;+ liveCents: number;+}++/** Read-only group totals; a pending hold past its deadline reads as overdue. */+export async function readGroupSpend(engine: BrainEngine, budgetKey: string): Promise<GroupSpend> {+ assertNonEmpty('budgetKey', budgetKey);+ const sql = sqlQueryForEngine(engine);+ const rows = await sql`+ SELECT+ COALESCE((SELECT SUM(spend_cents)::text FROM mcp_spend_log WHERE budget_key = ${budgetKey}), '0') AS committed_text,+ COALESCE((SELECT SUM(estimated_cents)::text FROM mcp_spend_reservations+ WHERE budget_key = ${budgetKey}+ AND (status = 'expired' OR (status = 'pending' AND expires_at < now()))), '0') AS overdue_text,+ COALESCE((SELECT SUM(estimated_cents)::text FROM mcp_spend_reservations+ WHERE budget_key = ${budgetKey} AND status = 'pending' AND expires_at >= now()), '0') AS live_text+ `;+ return {+ committedCents: requiredFiniteTotal(rows[0]?.committed_text, 'committed spend'),+ overdueCents: requiredFiniteTotal(rows[0]?.overdue_text, 'overdue spend'),+ liveCents: requiredFiniteTotal(rows[0]?.live_text, 'pending spend'),+ };+}++/** A reservation against a command group's shared budget (`group:<group_id>`) instead of an OAuth client. */+export type GroupReserveOpts = Omit<ReserveOpts, 'clientId' | 'validateAdmission'> & { budgetKey: string };++/**+ * Group reservation: one approved total shared by every job of a command+ * group, summed over the group's lifetime (no daily window, no client row).+ * Under the same per-key advisory lock as client reservations:+ *+ * 1. Expire this key's pending holds past their deadline (overdue).+ * 2. Settled spend plus overdue holds at or over the cap → `exhausted`.+ * 3. The attempt reserves its maximum, bounded by the remaining headroom,+ * so one attempt can always run while nothing else is in flight; its+ * actual cost is charged at settle, and a settled total at the cap+ * refuses the next reservation.+ * 4. Live holds of concurrent attempts that leave no room → `pressure`.+ *+ * A null cap reserves without a check (spend is still ledgered). Unknown+ * estimates are admitted at their stated amount: the caller decides whether+ * an unpriced attempt may run.+ */+export async function reserveGroup(engine: BrainEngine, opts: GroupReserveOpts): Promise<Reservation> {+ const key = opts.budgetKey;+ assertNonEmpty('budgetKey', key);+ assertFiniteNonNegative('estimatedCents', opts.estimatedCents);+ if (opts.capCents !== null) assertFiniteNonNegative('capCents', opts.capCents);+ assertNonEmpty('model', opts.model);+ assertNonEmpty('provider', opts.provider);+ if (opts.jobId !== undefined && (!Number.isSafeInteger(opts.jobId) || opts.jobId <= 0)) {+ throw new TypeError('jobId must be a positive safe integer when provided');+ }+ const reservationId = randomUUIDv7();+ const expiresAt = new Date(Date.now() + RESERVATION_TTL_MS);+ let estimated = opts.estimatedCents;+ await engine.transaction(async (tx) => {+ const sql = sqlQueryForEngine(tx);+ if (tx.kind === 'postgres') {+ // Lock-census (PR6 D5): INTENTIONALLY per budget key — every job of a group shares one total regardless of source.+ await sql`SELECT pg_advisory_xact_lock(${BigInt(clientLockKey(key))})`;+ }+ await sql`+ UPDATE mcp_spend_reservations SET status = 'expired'+ WHERE budget_key = ${key} AND status = 'pending' AND expires_at < now()+ `;+ if (opts.capCents !== null) {+ const spend = await readGroupSpend(tx, key);+ const remaining = opts.capCents - spend.committedCents - spend.overdueCents;+ if (remaining <= 0) throw new GroupBudgetRefusal('exhausted', key, spend, opts.capCents);+ estimated = Math.min(estimated, remaining);+ if (spend.liveCents > 0 && spend.liveCents + estimated > remaining) {+ throw new GroupBudgetRefusal('pressure', key, spend, opts.capCents);+ }+ }+ await sql`+ INSERT INTO mcp_spend_reservations+ (reservation_id, client_id, budget_key, job_id, estimated_cents, model, provider, status, expires_at, estimate_known, usage_unknown_reason)+ VALUES+ (${reservationId}, ${null}, ${key}, ${opts.jobId ?? null},+ ${estimated}, ${opts.model}, ${opts.provider}, 'pending', ${expiresAt}, ${opts.estimateKnown !== false}, ${opts.estimateKnown === false ? 'pricing_or_bound_unknown' : null})+ `;+ });+ return { reservationId, estimatedCents: estimated, ttlMs: RESERVATION_TTL_MS };+}+/*** Settle a reservation with the actual spend. Idempotent — second call* on the same reservation_id no-ops. Also writes a row to `mcp_spend_log`@@ -195,7 +309,7 @@ export async function settle(settled_at = now()WHERE reservation_id = ${reservationId}AND status IN ('pending', 'expired')- RETURNING client_id, model, provider+ RETURNING client_id, budget_key, model, provider`;if (updated.length === 0) {const existing = await sql`@@ -210,9 +324,10 @@ export async function settle(// Mirror into mcp_spend_log so getTodaySpendCents/reserve sees it.await sql`INSERT INTO mcp_spend_log- (client_id, token_name, operation, spend_cents, provider, model)+ (client_id, budget_key, token_name, operation, spend_cents, provider, model)VALUES- (${String(row.client_id)}, ${tokenName}, ${operation}, ${actualCents},+ (${row.client_id == null ? null : String(row.client_id)}, ${row.budget_key == null ? null : String(row.budget_key)},+ ${tokenName}, ${operation}, ${actualCents},${String(row.provider)}, ${String(row.model)})`;});diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.tsindex f9af4910a2..02a9f6772e 100644--- a/src/core/pglite-schema.generated.ts+++ b/src/core/pglite-schema.generated.ts@@ -596,6 +596,8 @@ CREATE TABLE IF NOT EXISTS minion_jobs (priority INTEGER NOT NULL DEFAULT 0,submission_authority JSONB,claim_generation BIGINT NOT NULL DEFAULT 0,+ spend_authorization JSONB,+ spend_claim_token BIGINT,data JSONB NOT NULL DEFAULT '{}',max_attempts INTEGER NOT NULL DEFAULT 3,attempts_made INTEGER NOT NULL DEFAULT 0,@@ -651,6 +653,7 @@ CREATE INDEX IF NOT EXISTS idx_minion_jobs_delayed ON minion_jobs (delay_until)CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent ON minion_jobs(parent_job_id);CREATE INDEX IF NOT EXISTS idx_minion_jobs_timeout ON minion_jobs (timeout_at) WHERE status = 'active' AND timeout_at IS NOT NULL;CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent_status ON minion_jobs (parent_job_id, status) WHERE parent_job_id IS NOT NULL;+CREATE INDEX IF NOT EXISTS idx_minion_jobs_spend_group ON minion_jobs ((spend_authorization->>'group_id')) WHERE spend_authorization IS NOT NULL;CREATE UNIQUE INDEX IF NOT EXISTS uniq_minion_jobs_idempotency ON minion_jobs (idempotency_key) WHERE idempotency_key IS NOT NULL;CREATE INDEX IF NOT EXISTS idx_minion_jobs_queue_status_updated ON minion_jobs (queue, status, updated_at);CREATE INDEX IF NOT EXISTS idx_minion_jobs_private_queue_recovery@@ -985,6 +988,9 @@ BEGINIF NEW.submission_authority IS NULL OR NEW.claim_generation IS DISTINCT FROM OLD.claim_generation + 1 THENRAISE EXCEPTION 'Minion queue protocol 1 required: old workers cannot claim upgraded queue jobs';END IF;+ IF NEW.spend_authorization IS NOT NULL AND NEW.spend_claim_token IS DISTINCT FROM NEW.claim_generation THEN+ RAISE EXCEPTION 'Minion spend protocol 1 required: only upgraded workers can claim spend-authorized jobs; restart workers on the upgraded binary';+ END IF;ELSIF NEW.claim_generation IS DISTINCT FROM OLD.claim_generation THENRAISE EXCEPTION 'Minion queue claim generation may advance only with a claim';END IF;diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.tsindex 01044b0e99..82d8044148 100644--- a/src/core/schema-embedded.generated.ts+++ b/src/core/schema-embedded.generated.ts@@ -1072,6 +1072,8 @@ CREATE TABLE IF NOT EXISTS minion_jobs (priority INTEGER NOT NULL DEFAULT 0,submission_authority JSONB, -- NULL legacy rows require local authorization before workers startclaim_generation BIGINT NOT NULL DEFAULT 0, -- advanced atomically by protocol-aware claims+ spend_authorization JSONB, -- submit-time consent record of a paid producer; never read from data+ spend_claim_token BIGINT, -- per-acquisition fence: spend-aware claims set it to the new claim_generationdata JSONB NOT NULL DEFAULT '{}',max_attempts INTEGER NOT NULL DEFAULT 3,attempts_made INTEGER NOT NULL DEFAULT 0,@@ -1127,6 +1129,7 @@ CREATE INDEX IF NOT EXISTS idx_minion_jobs_delayed ON minion_jobs (delay_until)CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent ON minion_jobs(parent_job_id);CREATE INDEX IF NOT EXISTS idx_minion_jobs_timeout ON minion_jobs (timeout_at) WHERE status = 'active' AND timeout_at IS NOT NULL;CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent_status ON minion_jobs (parent_job_id, status) WHERE parent_job_id IS NOT NULL;+CREATE INDEX IF NOT EXISTS idx_minion_jobs_spend_group ON minion_jobs ((spend_authorization->>'group_id')) WHERE spend_authorization IS NOT NULL;CREATE UNIQUE INDEX IF NOT EXISTS uniq_minion_jobs_idempotency ON minion_jobs (idempotency_key) WHERE idempotency_key IS NOT NULL;-- WP4/WP5 (v127, ENG-10): wedge-signal index — covers the queue-health count-- FILTERs and max(updated_at) reads in queryWedgeSignals (supervisor.ts).@@ -1615,6 +1618,9 @@ BEGINIF NEW.submission_authority IS NULL OR NEW.claim_generation IS DISTINCT FROM OLD.claim_generation + 1 THENRAISE EXCEPTION 'Minion queue protocol 1 required: old workers cannot claim upgraded queue jobs';END IF;+ IF NEW.spend_authorization IS NOT NULL AND NEW.spend_claim_token IS DISTINCT FROM NEW.claim_generation THEN+ RAISE EXCEPTION 'Minion spend protocol 1 required: only upgraded workers can claim spend-authorized jobs; restart workers on the upgraded binary';+ END IF;ELSIF NEW.claim_generation IS DISTINCT FROM OLD.claim_generation THENRAISE EXCEPTION 'Minion queue claim generation may advance only with a claim';END IF;diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.tsindex 16ef4d9ecc..ceb887d5bb 100644--- a/src/core/schema-migrations/registry.generated.ts+++ b/src/core/schema-migrations/registry.generated.ts@@ -201,6 +201,7 @@ import { v197 } from './v197-managed-guard-null-source-fallback.ts';import { v198 } from './v198-publication-failure-detail.ts';import { v199 } from './v199-chronicle-page-state.ts';import { v200 } from './v200-sync-hold-page-index.ts';+import { v201 } from './v201-minion-spend-authorization.ts';// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the// runner sorts by version before applying.@@ -400,4 +401,5 @@ export const MIGRATIONS: Migration[] = [v198,v199,v200,+ v201,];diff --git a/src/core/schema-migrations/v201-minion-spend-authorization.ts b/src/core/schema-migrations/v201-minion-spend-authorization.tsnew file mode 100644index 0000000000..42e72c0ce5--- /dev/null+++ b/src/core/schema-migrations/v201-minion-spend-authorization.ts@@ -0,0 +1,59 @@+import type { Migration } from './types.ts';++// Applied by src/core/migrate.ts on the next initSchema(); see docs/ENGINES.md+// ("Canonical schema sources") for when schema.sql or a TS fragment also changes.+//+// Submit-time spend authorization on queued paid jobs+// (src/core/minions/spend-authorization.ts). `spend_authorization` holds the+// consent record a trusted producer stored; `spend_claim_token` is the+// per-acquisition fence: a claim of a spend-authorized row must set it to the+// new claim_generation, which only spend-aware workers do. The meter tables+// gain `budget_key` so a command group shares one lifetime total; each+// reservation names exactly one budget owner (an OAuth client or a group).+// No backfill: workers stamp legacy rows at claim time.+const MINION_QUEUE_PROTOCOL_FUNCTION_SQL = `+CREATE OR REPLACE FUNCTION enforce_minion_queue_protocol() RETURNS trigger SET search_path = pg_catalog, public AS $protocol$+BEGIN+ IF TG_OP = 'INSERT' THEN+ IF NEW.submission_authority IS NULL OR NEW.claim_generation <> 0 THEN+ RAISE EXCEPTION 'Minion queue protocol 1 required: upgrade every producer and worker before restart';+ END IF;+ ELSIF NEW.status = 'active' AND (OLD.status <> 'active' OR NEW.lock_token IS DISTINCT FROM OLD.lock_token) THEN+ IF NEW.submission_authority IS NULL OR NEW.claim_generation IS DISTINCT FROM OLD.claim_generation + 1 THEN+ RAISE EXCEPTION 'Minion queue protocol 1 required: old workers cannot claim upgraded queue jobs';+ END IF;+ IF NEW.spend_authorization IS NOT NULL AND NEW.spend_claim_token IS DISTINCT FROM NEW.claim_generation THEN+ RAISE EXCEPTION 'Minion spend protocol 1 required: only upgraded workers can claim spend-authorized jobs; restart workers on the upgraded binary';+ END IF;+ ELSIF NEW.claim_generation IS DISTINCT FROM OLD.claim_generation THEN+ RAISE EXCEPTION 'Minion queue claim generation may advance only with a claim';+ END IF;+ RETURN NEW;+END;+$protocol$ LANGUAGE plpgsql;`;++export const v201: Migration = {+ version: 201,+ name: 'minion_spend_authorization',+ idempotent: true,+ sql: `+ ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS spend_authorization JSONB;+ ALTER TABLE minion_jobs ADD COLUMN IF NOT EXISTS spend_claim_token BIGINT;+ CREATE INDEX IF NOT EXISTS idx_minion_jobs_spend_group+ ON minion_jobs ((spend_authorization->>'group_id')) WHERE spend_authorization IS NOT NULL;+ ALTER TABLE mcp_spend_reservations ADD COLUMN IF NOT EXISTS budget_key TEXT;+ ALTER TABLE mcp_spend_reservations ALTER COLUMN client_id DROP NOT NULL;+ ALTER TABLE mcp_spend_reservations DROP CONSTRAINT IF EXISTS mcp_spend_reservations_one_budget_owner;+ ALTER TABLE mcp_spend_reservations ADD CONSTRAINT mcp_spend_reservations_one_budget_owner+ CHECK ((client_id IS NULL) <> (budget_key IS NULL));+ CREATE INDEX IF NOT EXISTS idx_mcp_spend_reservations_budget_key+ ON mcp_spend_reservations (budget_key) WHERE budget_key IS NOT NULL;+ ALTER TABLE mcp_spend_log ADD COLUMN IF NOT EXISTS budget_key TEXT;+ ALTER TABLE mcp_spend_log DROP CONSTRAINT IF EXISTS mcp_spend_log_one_budget_owner;+ ALTER TABLE mcp_spend_log ADD CONSTRAINT mcp_spend_log_one_budget_owner+ CHECK (client_id IS NULL OR budget_key IS NULL);+ CREATE INDEX IF NOT EXISTS idx_mcp_spend_log_budget_key+ ON mcp_spend_log (budget_key) WHERE budget_key IS NOT NULL;+${MINION_QUEUE_PROTOCOL_FUNCTION_SQL}+ `,+};diff --git a/src/schema.sql b/src/schema.sqlindex 43fed65c5e..24b8ce7c84 100644--- a/src/schema.sql+++ b/src/schema.sql@@ -1068,6 +1068,8 @@ CREATE TABLE IF NOT EXISTS minion_jobs (priority INTEGER NOT NULL DEFAULT 0,submission_authority JSONB, -- NULL legacy rows require local authorization before workers startclaim_generation BIGINT NOT NULL DEFAULT 0, -- advanced atomically by protocol-aware claims+ spend_authorization JSONB, -- submit-time consent record of a paid producer; never read from data+ spend_claim_token BIGINT, -- per-acquisition fence: spend-aware claims set it to the new claim_generationdata JSONB NOT NULL DEFAULT '{}',max_attempts INTEGER NOT NULL DEFAULT 3,attempts_made INTEGER NOT NULL DEFAULT 0,@@ -1123,6 +1125,7 @@ CREATE INDEX IF NOT EXISTS idx_minion_jobs_delayed ON minion_jobs (delay_until)CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent ON minion_jobs(parent_job_id);CREATE INDEX IF NOT EXISTS idx_minion_jobs_timeout ON minion_jobs (timeout_at) WHERE status = 'active' AND timeout_at IS NOT NULL;CREATE INDEX IF NOT EXISTS idx_minion_jobs_parent_status ON minion_jobs (parent_job_id, status) WHERE parent_job_id IS NOT NULL;+CREATE INDEX IF NOT EXISTS idx_minion_jobs_spend_group ON minion_jobs ((spend_authorization->>'group_id')) WHERE spend_authorization IS NOT NULL;CREATE UNIQUE INDEX IF NOT EXISTS uniq_minion_jobs_idempotency ON minion_jobs (idempotency_key) WHERE idempotency_key IS NOT NULL;-- WP4/WP5 (v127, ENG-10): wedge-signal index — covers the queue-health count-- FILTERs and max(updated_at) reads in queryWedgeSignals (supervisor.ts).@@ -1611,6 +1614,9 @@ BEGINIF NEW.submission_authority IS NULL OR NEW.claim_generation IS DISTINCT FROM OLD.claim_generation + 1 THENRAISE EXCEPTION 'Minion queue protocol 1 required: old workers cannot claim upgraded queue jobs';END IF;+ IF NEW.spend_authorization IS NOT NULL AND NEW.spend_claim_token IS DISTINCT FROM NEW.claim_generation THEN+ RAISE EXCEPTION 'Minion spend protocol 1 required: only upgraded workers can claim spend-authorized jobs; restart workers on the upgraded binary';+ END IF;ELSIF NEW.claim_generation IS DISTINCT FROM OLD.claim_generation THENRAISE EXCEPTION 'Minion queue claim generation may advance only with a claim';END IF;diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.jsonindex 99a6d7000e..e21fe03931 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json@@ -95,8 +95,10 @@"loop_suppressions.loop_suppressions_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","loop_suppressions.loop_suppressions_uniq": "u UNIQUE (source_id, kind, value)","mcp_request_log.mcp_request_log_pkey": "p PRIMARY KEY (id)",+ "mcp_spend_log.mcp_spend_log_one_budget_owner": "c CHECK (((client_id IS NULL) OR (budget_key IS NULL)))","mcp_spend_log.mcp_spend_log_pkey": "p PRIMARY KEY (id)","mcp_spend_reservations.mcp_spend_reservations_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",+ "mcp_spend_reservations.mcp_spend_reservations_one_budget_owner": "c CHECK (((client_id IS NULL) <> (budget_key IS NULL)))","mcp_spend_reservations.mcp_spend_reservations_pkey": "p PRIMARY KEY (reservation_id)","mcp_spend_reservations.mcp_spend_reservations_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'settled'::text, 'expired'::text])))","migration_impact_log.migration_impact_log_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",@@ -303,7 +305,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d3359bcd09cccd881585abd9eee81c3dcf4161d935164f7953f2e9fdef73ed3e","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=78059745996cfbb72586a2e0e161635b96a62a5db9d0be5c710f4d437d994431",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_clear_atom_page_state()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7db0ef05d1220a579e64428b2dd7cf5183191da186fbe64b6496433a7a713d11",@@ -769,8 +771,10 @@"idx_links_to": "CREATE INDEX idx_links_to ON public.links USING btree (to_page_id)","idx_mcp_log_agent_time": "CREATE INDEX idx_mcp_log_agent_time ON public.mcp_request_log USING btree (agent_name, created_at DESC)","idx_mcp_log_time_agent": "CREATE INDEX idx_mcp_log_time_agent ON public.mcp_request_log USING btree (created_at, token_name)",+ "idx_mcp_spend_log_budget_key": "CREATE INDEX idx_mcp_spend_log_budget_key ON public.mcp_spend_log USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_log_client_time": "CREATE INDEX idx_mcp_spend_log_client_time ON public.mcp_spend_log USING btree (client_id, created_at)","idx_mcp_spend_log_token_time": "CREATE INDEX idx_mcp_spend_log_token_time ON public.mcp_spend_log USING btree (token_name, created_at)",+ "idx_mcp_spend_reservations_budget_key": "CREATE INDEX idx_mcp_spend_reservations_budget_key ON public.mcp_spend_reservations USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_reservations_client_time": "CREATE INDEX idx_mcp_spend_reservations_client_time ON public.mcp_spend_reservations USING btree (client_id, created_at)","idx_mcp_spend_reservations_pending_expires": "CREATE INDEX idx_mcp_spend_reservations_pending_expires ON public.mcp_spend_reservations USING btree (status, expires_at) WHERE (status = 'pending'::text)","idx_minion_attachments_job": "CREATE INDEX idx_minion_attachments_job ON public.minion_attachments USING btree (job_id)",@@ -784,6 +788,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stagger_key": "CREATE INDEX idx_minion_jobs_stagger_key ON public.minion_jobs USING btree (stagger_key) WHERE (stagger_key IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)",@@ -1715,14 +1720,15 @@"5 spend_cents numeric/numeric NOT NULL DEFAULT 0","6 provider text/text NULL","7 model text/text NULL",- "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},"mcp_spend_reservations": {"columns": ["1 reservation_id uuid/uuid NOT NULL",- "2 client_id text/text NOT NULL",+ "2 client_id text/text NULL","3 job_id bigint/int8 NULL","4 estimated_cents numeric/numeric NOT NULL","5 actual_cents numeric/numeric NULL",@@ -1733,7 +1739,8 @@"10 settled_at timestamp with time zone/timestamptz NULL","11 expires_at timestamp with time zone/timestamptz NOT NULL","12 estimate_known boolean/bool NOT NULL DEFAULT true",- "13 usage_unknown_reason text/text NULL"+ "13 usage_unknown_reason text/text NULL",+ "14 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1802,47 +1809,49 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "44 quiet_hours jsonb/jsonb NULL",- "45 stagger_key text/text NULL",- "46 budget_remaining_cents integer/int4 NULL",- "47 budget_owner_job_id bigint/int8 NULL",- "48 budget_root_owner_id bigint/int8 NULL"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "46 quiet_hours jsonb/jsonb NULL",+ "47 stagger_key text/text NULL",+ "48 budget_remaining_cents integer/int4 NULL",+ "49 budget_owner_job_id bigint/int8 NULL",+ "50 budget_root_owner_id bigint/int8 NULL"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.jsonindex db8a7c1b35..c6c8f17f18 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json@@ -95,8 +95,10 @@"loop_suppressions.loop_suppressions_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","loop_suppressions.loop_suppressions_uniq": "u UNIQUE (source_id, kind, value)","mcp_request_log.mcp_request_log_pkey": "p PRIMARY KEY (id)",+ "mcp_spend_log.mcp_spend_log_one_budget_owner": "c CHECK (((client_id IS NULL) OR (budget_key IS NULL)))","mcp_spend_log.mcp_spend_log_pkey": "p PRIMARY KEY (id)","mcp_spend_reservations.mcp_spend_reservations_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",+ "mcp_spend_reservations.mcp_spend_reservations_one_budget_owner": "c CHECK (((client_id IS NULL) <> (budget_key IS NULL)))","mcp_spend_reservations.mcp_spend_reservations_pkey": "p PRIMARY KEY (reservation_id)","mcp_spend_reservations.mcp_spend_reservations_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'settled'::text, 'expired'::text])))","migration_impact_log.migration_impact_log_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",@@ -303,7 +305,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d3359bcd09cccd881585abd9eee81c3dcf4161d935164f7953f2e9fdef73ed3e","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=78059745996cfbb72586a2e0e161635b96a62a5db9d0be5c710f4d437d994431",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_clear_atom_page_state()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7db0ef05d1220a579e64428b2dd7cf5183191da186fbe64b6496433a7a713d11",@@ -769,8 +771,10 @@"idx_links_to": "CREATE INDEX idx_links_to ON public.links USING btree (to_page_id)","idx_mcp_log_agent_time": "CREATE INDEX idx_mcp_log_agent_time ON public.mcp_request_log USING btree (agent_name, created_at DESC)","idx_mcp_log_time_agent": "CREATE INDEX idx_mcp_log_time_agent ON public.mcp_request_log USING btree (created_at, token_name)",+ "idx_mcp_spend_log_budget_key": "CREATE INDEX idx_mcp_spend_log_budget_key ON public.mcp_spend_log USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_log_client_time": "CREATE INDEX idx_mcp_spend_log_client_time ON public.mcp_spend_log USING btree (client_id, created_at)","idx_mcp_spend_log_token_time": "CREATE INDEX idx_mcp_spend_log_token_time ON public.mcp_spend_log USING btree (token_name, created_at)",+ "idx_mcp_spend_reservations_budget_key": "CREATE INDEX idx_mcp_spend_reservations_budget_key ON public.mcp_spend_reservations USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_reservations_client_time": "CREATE INDEX idx_mcp_spend_reservations_client_time ON public.mcp_spend_reservations USING btree (client_id, created_at)","idx_mcp_spend_reservations_pending_expires": "CREATE INDEX idx_mcp_spend_reservations_pending_expires ON public.mcp_spend_reservations USING btree (status, expires_at) WHERE (status = 'pending'::text)","idx_minion_attachments_job": "CREATE INDEX idx_minion_attachments_job ON public.minion_attachments USING btree (job_id)",@@ -784,6 +788,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stagger_key": "CREATE INDEX idx_minion_jobs_stagger_key ON public.minion_jobs USING btree (stagger_key) WHERE (stagger_key IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)",@@ -1715,14 +1720,15 @@"5 spend_cents numeric/numeric NOT NULL DEFAULT 0","6 provider text/text NULL","7 model text/text NULL",- "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},"mcp_spend_reservations": {"columns": ["1 reservation_id uuid/uuid NOT NULL",- "2 client_id text/text NOT NULL",+ "2 client_id text/text NULL","3 job_id bigint/int8 NULL","4 estimated_cents numeric/numeric NOT NULL","5 actual_cents numeric/numeric NULL",@@ -1733,7 +1739,8 @@"10 settled_at timestamp with time zone/timestamptz NULL","11 expires_at timestamp with time zone/timestamptz NOT NULL","12 estimate_known boolean/bool NOT NULL DEFAULT true",- "13 usage_unknown_reason text/text NULL"+ "13 usage_unknown_reason text/text NULL",+ "14 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1802,47 +1809,49 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "44 quiet_hours jsonb/jsonb NULL",- "45 stagger_key text/text NULL",- "46 budget_remaining_cents integer/int4 NULL",- "47 budget_owner_job_id bigint/int8 NULL",- "48 budget_root_owner_id bigint/int8 NULL"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "46 quiet_hours jsonb/jsonb NULL",+ "47 stagger_key text/text NULL",+ "48 budget_remaining_cents integer/int4 NULL",+ "49 budget_owner_job_id bigint/int8 NULL",+ "50 budget_root_owner_id bigint/int8 NULL"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.jsonindex 796685335b..a27124b4b6 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json@@ -95,8 +95,10 @@"loop_suppressions.loop_suppressions_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","loop_suppressions.loop_suppressions_uniq": "u UNIQUE (source_id, kind, value)","mcp_request_log.mcp_request_log_pkey": "p PRIMARY KEY (id)",+ "mcp_spend_log.mcp_spend_log_one_budget_owner": "c CHECK (((client_id IS NULL) OR (budget_key IS NULL)))","mcp_spend_log.mcp_spend_log_pkey": "p PRIMARY KEY (id)","mcp_spend_reservations.mcp_spend_reservations_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",+ "mcp_spend_reservations.mcp_spend_reservations_one_budget_owner": "c CHECK (((client_id IS NULL) <> (budget_key IS NULL)))","mcp_spend_reservations.mcp_spend_reservations_pkey": "p PRIMARY KEY (reservation_id)","mcp_spend_reservations.mcp_spend_reservations_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'settled'::text, 'expired'::text])))","migration_impact_log.migration_impact_log_job_id_fkey": "f FOREIGN KEY (job_id) REFERENCES minion_jobs(id) ON DELETE SET NULL",@@ -303,7 +305,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d3359bcd09cccd881585abd9eee81c3dcf4161d935164f7953f2e9fdef73ed3e","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=78059745996cfbb72586a2e0e161635b96a62a5db9d0be5c710f4d437d994431",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_clear_atom_page_state()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7db0ef05d1220a579e64428b2dd7cf5183191da186fbe64b6496433a7a713d11",@@ -767,8 +769,10 @@"idx_links_to": "CREATE INDEX idx_links_to ON public.links USING btree (to_page_id)","idx_mcp_log_agent_time": "CREATE INDEX idx_mcp_log_agent_time ON public.mcp_request_log USING btree (agent_name, created_at DESC)","idx_mcp_log_time_agent": "CREATE INDEX idx_mcp_log_time_agent ON public.mcp_request_log USING btree (created_at, token_name)",+ "idx_mcp_spend_log_budget_key": "CREATE INDEX idx_mcp_spend_log_budget_key ON public.mcp_spend_log USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_log_client_time": "CREATE INDEX idx_mcp_spend_log_client_time ON public.mcp_spend_log USING btree (client_id, created_at)","idx_mcp_spend_log_token_time": "CREATE INDEX idx_mcp_spend_log_token_time ON public.mcp_spend_log USING btree (token_name, created_at)",+ "idx_mcp_spend_reservations_budget_key": "CREATE INDEX idx_mcp_spend_reservations_budget_key ON public.mcp_spend_reservations USING btree (budget_key) WHERE (budget_key IS NOT NULL)","idx_mcp_spend_reservations_client_time": "CREATE INDEX idx_mcp_spend_reservations_client_time ON public.mcp_spend_reservations USING btree (client_id, created_at)","idx_mcp_spend_reservations_pending_expires": "CREATE INDEX idx_mcp_spend_reservations_pending_expires ON public.mcp_spend_reservations USING btree (status, expires_at) WHERE (status = 'pending'::text)","idx_minion_attachments_job": "CREATE INDEX idx_minion_attachments_job ON public.minion_attachments USING btree (job_id)",@@ -782,6 +786,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stagger_key": "CREATE INDEX idx_minion_jobs_stagger_key ON public.minion_jobs USING btree (stagger_key) WHERE (stagger_key IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)",@@ -1711,14 +1716,15 @@"5 spend_cents numeric/numeric NOT NULL DEFAULT 0","6 provider text/text NULL","7 model text/text NULL",- "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},"mcp_spend_reservations": {"columns": ["1 reservation_id uuid/uuid NOT NULL",- "2 client_id text/text NOT NULL",+ "2 client_id text/text NULL","3 job_id bigint/int8 NULL","4 estimated_cents numeric/numeric NOT NULL","5 actual_cents numeric/numeric NULL",@@ -1729,7 +1735,8 @@"10 settled_at timestamp with time zone/timestamptz NULL","11 expires_at timestamp with time zone/timestamptz NOT NULL","12 estimate_known boolean/bool NOT NULL DEFAULT true",- "13 usage_unknown_reason text/text NULL"+ "13 usage_unknown_reason text/text NULL",+ "14 budget_key text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1798,47 +1805,49 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "44 quiet_hours jsonb/jsonb NULL",- "45 stagger_key text/text NULL",- "46 budget_remaining_cents integer/int4 NULL",- "47 budget_owner_job_id bigint/int8 NULL",- "48 budget_root_owner_id bigint/int8 NULL"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "46 quiet_hours jsonb/jsonb NULL",+ "47 stagger_key text/text NULL",+ "48 budget_remaining_cents integer/int4 NULL",+ "49 budget_owner_job_id bigint/int8 NULL",+ "50 budget_root_owner_id bigint/int8 NULL"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json b/test/fixtures/goldens/catalog/pglite-schema-blob-default.jsonindex 3a33f51e94..3cdfb7edb8 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json@@ -240,7 +240,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c40a0a3b86e640b6c8979976173dd93ae92c8c1b9a9e3595cae2af1e265328fe","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c4135ae3f74177aa71313a6c73f22bda7a298bbf12435a8def390212ae11466a",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1",@@ -587,6 +587,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)","idx_minion_jobs_timeout": "CREATE INDEX idx_minion_jobs_timeout ON public.minion_jobs USING btree (timeout_at) WHERE ((status = 'active'::text) AND (timeout_at IS NOT NULL))",@@ -1307,42 +1308,44 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.jsonindex 358ba68154..da553e209c 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json@@ -240,7 +240,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c40a0a3b86e640b6c8979976173dd93ae92c8c1b9a9e3595cae2af1e265328fe","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c4135ae3f74177aa71313a6c73f22bda7a298bbf12435a8def390212ae11466a",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1",@@ -587,6 +587,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)","idx_minion_jobs_timeout": "CREATE INDEX idx_minion_jobs_timeout ON public.minion_jobs USING btree (timeout_at) WHERE ((status = 'active'::text) AND (timeout_at IS NOT NULL))",@@ -1307,42 +1308,44 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.jsonindex c53886296f..454ea7ec59 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json@@ -240,7 +240,7 @@"functions": {"bump_page_generation_clock_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c40a0a3b86e640b6c8979976173dd93ae92c8c1b9a9e3595cae2af1e265328fe","bump_page_generation_fn()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c4135ae3f74177aa71313a6c73f22bda7a298bbf12435a8def390212ae11466a",- "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e0b3db944d3b4281b9483ce77aa734e0c9aa5b0d46bb5dcb5284b6469441a1b8",+ "enforce_minion_queue_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=be82640d1979fc81dc812efb78bb3596ef536f656d20750e5e4aa19016bf4784","gbrain_advance_page_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=ae793ff5263f7b76311e0c22593fb658db9f82e7b3781914421d9508b6da0e88","gbrain_advance_tag_revision()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=7807b26b4933148aa63c67fca824a60d3492396728205d04e16c48c81174cbd5","gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=e8b5589dafd4a355106104daffdf57c7776d34fe18c5b5f5336a27de188688a1",@@ -586,6 +586,7 @@"idx_minion_jobs_private_queue_owner": "CREATE INDEX idx_minion_jobs_private_queue_owner ON public.minion_jobs USING btree (private_queue_owner_job_id) WHERE (private_queue_owner_job_id IS NOT NULL)","idx_minion_jobs_private_queue_recovery": "CREATE INDEX idx_minion_jobs_private_queue_recovery ON public.minion_jobs USING btree (queue, private_queue_lease_until) WHERE ((queue ~~ 'dream-inline-%'::text) AND (status = ANY (ARRAY['waiting'::text, 'active'::text, 'delayed'::text, 'waiting-children'::text, 'paused'::text])))","idx_minion_jobs_queue_status_updated": "CREATE INDEX idx_minion_jobs_queue_status_updated ON public.minion_jobs USING btree (queue, status, updated_at)",+ "idx_minion_jobs_spend_group": "CREATE INDEX idx_minion_jobs_spend_group ON public.minion_jobs USING btree (((spend_authorization ->> 'group_id'::text))) WHERE (spend_authorization IS NOT NULL)","idx_minion_jobs_stalled": "CREATE INDEX idx_minion_jobs_stalled ON public.minion_jobs USING btree (lock_until) WHERE (status = 'active'::text)","idx_minion_jobs_status": "CREATE INDEX idx_minion_jobs_status ON public.minion_jobs USING btree (status)","idx_minion_jobs_timeout": "CREATE INDEX idx_minion_jobs_timeout ON public.minion_jobs USING btree (timeout_at) WHERE ((status = 'active'::text) AND (timeout_at IS NOT NULL))",@@ -1306,42 +1307,44 @@"5 priority integer/int4 NOT NULL DEFAULT 0","6 submission_authority jsonb/jsonb NULL","7 claim_generation bigint/int8 NOT NULL DEFAULT 0",- "8 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",- "9 max_attempts integer/int4 NOT NULL DEFAULT 3",- "10 attempts_made integer/int4 NOT NULL DEFAULT 0",- "11 attempts_started integer/int4 NOT NULL DEFAULT 0",- "12 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",- "13 backoff_delay integer/int4 NOT NULL DEFAULT 1000",- "14 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",- "15 stalled_counter integer/int4 NOT NULL DEFAULT 0",- "16 max_stalled integer/int4 NOT NULL DEFAULT 5",- "17 lock_token text/text NULL",- "18 lock_until timestamp with time zone/timestamptz NULL",- "19 delay_until timestamp with time zone/timestamptz NULL",- "20 parent_job_id integer/int4 NULL",- "21 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",- "22 tokens_input integer/int4 NOT NULL DEFAULT 0",- "23 tokens_output integer/int4 NOT NULL DEFAULT 0",- "24 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",- "25 depth integer/int4 NOT NULL DEFAULT 0",- "26 max_children integer/int4 NULL",- "27 timeout_ms integer/int4 NULL",- "28 lock_duration_ms integer/int4 NULL",- "29 timeout_at timestamp with time zone/timestamptz NULL",- "30 remove_on_complete boolean/bool NOT NULL DEFAULT false",- "31 remove_on_fail boolean/bool NOT NULL DEFAULT false",- "32 idempotency_key text/text NULL",- "33 private_queue_owner_job_id integer/int4 NULL",- "34 private_queue_owner_token text/text NULL",- "35 private_queue_lease_until timestamp with time zone/timestamptz NULL",- "36 result jsonb/jsonb NULL",- "37 progress jsonb/jsonb NULL",- "38 error_text text/text NULL",- "39 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",- "40 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",- "41 started_at timestamp with time zone/timestamptz NULL",- "42 finished_at timestamp with time zone/timestamptz NULL",- "43 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"+ "8 spend_authorization jsonb/jsonb NULL",+ "9 spend_claim_token bigint/int8 NULL",+ "10 data jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "11 max_attempts integer/int4 NOT NULL DEFAULT 3",+ "12 attempts_made integer/int4 NOT NULL DEFAULT 0",+ "13 attempts_started integer/int4 NOT NULL DEFAULT 0",+ "14 backoff_type text/text NOT NULL DEFAULT 'exponential'::text",+ "15 backoff_delay integer/int4 NOT NULL DEFAULT 1000",+ "16 backoff_jitter real/float4 NOT NULL DEFAULT 0.2",+ "17 stalled_counter integer/int4 NOT NULL DEFAULT 0",+ "18 max_stalled integer/int4 NOT NULL DEFAULT 5",+ "19 lock_token text/text NULL",+ "20 lock_until timestamp with time zone/timestamptz NULL",+ "21 delay_until timestamp with time zone/timestamptz NULL",+ "22 parent_job_id integer/int4 NULL",+ "23 on_child_fail text/text NOT NULL DEFAULT 'fail_parent'::text",+ "24 tokens_input integer/int4 NOT NULL DEFAULT 0",+ "25 tokens_output integer/int4 NOT NULL DEFAULT 0",+ "26 tokens_cache_read integer/int4 NOT NULL DEFAULT 0",+ "27 depth integer/int4 NOT NULL DEFAULT 0",+ "28 max_children integer/int4 NULL",+ "29 timeout_ms integer/int4 NULL",+ "30 lock_duration_ms integer/int4 NULL",+ "31 timeout_at timestamp with time zone/timestamptz NULL",+ "32 remove_on_complete boolean/bool NOT NULL DEFAULT false",+ "33 remove_on_fail boolean/bool NOT NULL DEFAULT false",+ "34 idempotency_key text/text NULL",+ "35 private_queue_owner_job_id integer/int4 NULL",+ "36 private_queue_owner_token text/text NULL",+ "37 private_queue_lease_until timestamp with time zone/timestamptz NULL",+ "38 result jsonb/jsonb NULL",+ "39 progress jsonb/jsonb NULL",+ "40 error_text text/text NULL",+ "41 stacktrace jsonb/jsonb NULL DEFAULT '[]'::jsonb",+ "42 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "43 started_at timestamp with time zone/timestamptz NULL",+ "44 finished_at timestamp with time zone/timestamptz NULL",+ "45 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.jsonindex 190c942fa0..a7f4076a34 100644--- a/test/fixtures/goldens/migrations/records.json+++ b/test/fixtures/goldens/migrations/records.json@@ -1,6 +1,6 @@{"golden": {- "count": 195,+ "count": 196,"gaps": [17,18,@@ -28,7 +28,7 @@"slugifyPath": "401dbca23580865d8b168dd8d84db4a6c708c6610d7cb61abafc7d0ee9809063","verifyProjectionStatistics": "59d9ccfea1c53384d8607874a51209a9c2dfd51b2b85a2cb6269fa4120faf1f3"},- "latest": 200,+ "latest": 201,"records": [{"handler": {@@ -2968,6 +2968,19 @@"transaction": "absent","verify": "absent","version": 200+ },+ {+ "handler": "absent",+ "idempotent": true,+ "name": "minion_spend_authorization",+ "sql": {+ "length": 2517,+ "sha256": "2cbd58159c902a81c6364652154e2b09995714dfbd380d035eb3bdfc889c002b"+ },+ "sqlFor": "absent",+ "transaction": "absent",+ "verify": "absent",+ "version": 201}],"versions": [@@ -3165,7 +3178,8 @@197,198,199,- 200+ 200,+ 201]},"normalizer": "migrations-record-v1"diff --git a/test/minions/budget-meter.test.ts b/test/minions/budget-meter.test.tsindex 5e2d53e77b..0b815bc000 100644--- a/test/minions/budget-meter.test.ts+++ b/test/minions/budget-meter.test.ts@@ -9,6 +9,9 @@ import {clientLockKey,BudgetExceededError,RESERVATION_TTL_MS,+ GroupBudgetRefusal,+ readGroupSpend,+ reserveGroup,} from '../../src/core/minions/budget-meter.ts';let engine: PGLiteEngine;@@ -355,4 +358,63 @@ describe('minions/budget-meter (v0.38 Slice 2 — D3 reserve-then-settle)', () =).rejects.toThrow(BudgetExceededError);});});++ describe('group budget key (lifetime window)', () => {+ const key = 'group:0192a000-0000-7000-8000-000000000001';+ const hold = (estimatedCents: number, capCents: number | null = 1000) =>+ reserveGroup(engine, { budgetKey: key, estimatedCents, capCents, model: 'm', provider: 'p', jobId: undefined });++ it('sums settled spend over the group lifetime, not the UTC day', async () => {+ const r = await hold(300);+ await settle(engine, r.reservationId, 900);+ await engine.executeRaw(`UPDATE mcp_spend_log SET created_at = now() - interval '3 days' WHERE budget_key = $1`, [key]);+ expect((await readGroupSpend(engine, key)).committedCents).toBe(900);+ const next = await hold(300);+ expect(next.estimatedCents).toBe(100);+ await settle(engine, next.reservationId, 100);+ const refused = await hold(1).catch(e => e);+ expect(refused).toBeInstanceOf(GroupBudgetRefusal);+ expect((refused as GroupBudgetRefusal).kind).toBe('exhausted');+ });++ it('live holds of siblings are pressure; settled spend under the cap admits again', async () => {+ const a = await hold(800);+ const refused = await hold(800).catch(e => e);+ expect((refused as GroupBudgetRefusal).kind).toBe('pressure');+ await settle(engine, a.reservationId, 100);+ const b = await hold(800);+ await settle(engine, b.reservationId, 100);+ expect((await readGroupSpend(engine, key)).committedCents).toBe(200);+ });++ it('an overdue hold counts as spent until its usage is known', async () => {+ await hold(1000);+ await engine.executeRaw(`UPDATE mcp_spend_reservations SET expires_at = now() - interval '1 second' WHERE budget_key = $1`, [key]);+ const refused = await hold(200).catch(e => e);+ expect((refused as GroupBudgetRefusal).kind).toBe('exhausted');+ expect((await readGroupSpend(engine, key)).overdueCents).toBe(1000);+ });++ it('a null cap ledgers without a check and group rows carry no client', async () => {+ const r = await hold(5000, null);+ await settle(engine, r.reservationId, 4000);+ const rows = await engine.executeRaw<{ client_id: string | null; budget_key: string }>(+ `SELECT client_id, budget_key FROM mcp_spend_log WHERE budget_key = $1`, [key]);+ expect(rows).toEqual([{ client_id: null, budget_key: key }]);+ });++ it('a reservation names exactly one budget owner', async () => {+ await expect(engine.executeRaw(+ `INSERT INTO mcp_spend_reservations (reservation_id, client_id, budget_key, estimated_cents, model, provider, status, expires_at)+ VALUES (gen_random_uuid(), 'alice', $1, 1, 'm', 'p', 'pending', now())`, [key])).rejects.toThrow();+ });++ it('client budgets ignore group spend', async () => {+ await seedClient('alice', 1.00);+ const g = await hold(900);+ await settle(engine, g.reservationId, 900);+ await expect(reserve(engine, { clientId: 'alice', estimatedCents: 90, capCents: 100, model: 'm', provider: 'p' }))+ .resolves.toHaveProperty('reservationId');+ });+ });});diff --git a/test/schema-bootstrap-coverage.test.ts b/test/schema-bootstrap-coverage.test.tsindex f3824b72a4..51cd17326c 100644--- a/test/schema-bootstrap-coverage.test.ts+++ b/test/schema-bootstrap-coverage.test.ts@@ -232,6 +232,9 @@ const REQUIRED_BOOTSTRAP_COVERAGE: ForwardReference[] = [// Authority remains nullable: bootstrap must never authorize historical work.{ kind: 'column', table: 'minion_jobs', column: 'submission_authority' },{ kind: 'column', table: 'minion_jobs', column: 'claim_generation' },+ // v201 spend protocol: the fence trigger reads both; the group index reads the record.+ { kind: 'column', table: 'minion_jobs', column: 'spend_authorization' },+ { kind: 'column', table: 'minion_jobs', column: 'spend_claim_token' },];test('applyForwardReferenceBootstrap covers every forward reference declared in REQUIRED_BOOTSTRAP_COVERAGE', async () => {@@ -351,6 +354,9 @@ test('applyForwardReferenceBootstrap covers every forward reference declared inALTER TABLE minion_jobs DROP COLUMN IF EXISTS private_queue_lease_until;ALTER TABLE minion_jobs DROP COLUMN IF EXISTS submission_authority;ALTER TABLE minion_jobs DROP COLUMN IF EXISTS claim_generation;+ DROP INDEX IF EXISTS idx_minion_jobs_spend_group;+ ALTER TABLE minion_jobs DROP COLUMN IF EXISTS spend_authorization;+ ALTER TABLE minion_jobs DROP COLUMN IF EXISTS spend_claim_token;`);// Note: we don't strip sources.archived* here because they're inline in the@@ -455,6 +461,9 @@ test('after bootstrap, PGLITE_SCHEMA_SQL replays without crashing on missing forALTER TABLE minion_jobs DROP COLUMN IF EXISTS private_queue_lease_until;ALTER TABLE minion_jobs DROP COLUMN IF EXISTS submission_authority;ALTER TABLE minion_jobs DROP COLUMN IF EXISTS claim_generation;+ DROP INDEX IF EXISTS idx_minion_jobs_spend_group;+ ALTER TABLE minion_jobs DROP COLUMN IF EXISTS spend_authorization;+ ALTER TABLE minion_jobs DROP COLUMN IF EXISTS spend_claim_token;-- WP4 (v127) strip: surface columns + the wedge-signal index; replay-- must succeed from the pre-v127 shape.@@ -873,6 +882,11 @@ const COLUMN_EXEMPTIONS = new Set<string>([// columns from the migration chain.'takes.embedding_model','takes.embedded_text_hash',+ // Spend meter budget owner (v201): mcp_spend_reservations and mcp_spend_log+ // are migration-only tables (no CREATE TABLE in the schema blob), so there is+ // no blob forward reference; the migration chain adds the column and index.+ 'mcp_spend_reservations.budget_key',+ 'mcp_spend_log.budget_key',// T7 — search_telemetry rank-1 drift columns (migration v111). search_telemetry// is created entirely by migration v57 (not in the schema blob), so the v57+v111// chain handles fresh + upgrade; no CREATE INDEX references these columns, so