Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
ci(pricing): X1 recipe pricing coverage guard (D22)
time-attackd0c355b1ef48
diff --git a/package.json b/package.jsonindex b964debe7c..91d61e71fa 100644--- a/package.json+++ b/package.json@@ -120,6 +120,7 @@"check:test-env-opt-ins": "bun scripts/check-test-env-opt-ins.ts","check:postgres-lanes": "bun scripts/check-postgres-lane-coverage.ts","check:weight-coverage": "bun scripts/check-weight-coverage.ts",+ "check:recipe-pricing": "bun scripts/check-recipe-pricing.ts","check:fuzz-purity": "bash scripts/check-fuzz-purity.sh","check:operations-filter-bypass": "bash scripts/check-operations-filter-bypass.sh","check:fixture-privacy": "bash scripts/check-fixture-privacy.sh",diff --git a/scripts/check-recipe-pricing.ts b/scripts/check-recipe-pricing.tsnew file mode 100644index 0000000000..8fe00c7194--- /dev/null+++ b/scripts/check-recipe-pricing.ts@@ -0,0 +1,61 @@+#!/usr/bin/env bun+/**+ * X1 recipe pricing coverage guard (D22). Every model id a recipe lists in a+ * touchpoint (chat and expansion price as chat, embedding as embed, reranker+ * as rerank, decide as decide) must resolve to a price through the same+ * resolver the cost caps use (`isModelPriceable`), or be named in the+ * recipe's `unpriced_models`. A marker on a model that now prices, or that no+ * touchpoint lists, is stale and fails too. This is the class that hid the+ * DeepSeek S1: a recipe gained `deepseek-flash` while the table never did.+ *+ * Seam: GBRAIN_GUARD_ROOT (fixture root). There the recipes come from+ * `<root>/recipes.json` (an array of `{ id, unpriced_models?, touchpoints }`);+ * prices still come from the real tables.+ */+import { readFileSync } from 'node:fs';+import { join } from 'node:path';+import { listRecipes } from '../src/core/ai/recipes/index.ts';+import { isModelPriceable, type BudgetKind } from '../src/core/budget/reservation-cost.ts';++interface RecipeLike {+ id: string;+ unpriced_models?: string[];+ touchpoints: Record<string, { models?: string[] } | undefined>;+}++const KIND: Record<string, BudgetKind> = { chat: 'chat', expansion: 'chat', embedding: 'embed', reranker: 'rerank', decide: 'decide' };++const root = process.env.GBRAIN_GUARD_ROOT;+const recipes: RecipeLike[] = root+ ? JSON.parse(readFileSync(join(root, 'recipes.json'), 'utf8'))+ : listRecipes() as unknown as RecipeLike[];++const failures: string[] = [];+for (const recipe of recipes) {+ const marked = new Set(recipe.unpriced_models ?? []);+ const listed = new Set<string>();+ for (const [touchpoint, tp] of Object.entries(recipe.touchpoints)) {+ const kind = KIND[touchpoint];+ if (!kind) continue;+ for (const model of tp?.models ?? []) {+ listed.add(model);+ const priced = isModelPriceable(`${recipe.id}:${model}`, kind);+ if (!priced && !marked.has(model)) {+ failures.push(`${recipe.id}:${model} (${touchpoint}) has no price. Add a verified row (src/core/model-pricing.ts or src/core/embedding-pricing.ts) or name it in the recipe's unpriced_models.`);+ }+ if (priced && marked.has(model)) {+ failures.push(`${recipe.id}:${model} (${touchpoint}) is priced but still listed in unpriced_models; remove the stale marker.`);+ }+ }+ }+ for (const model of marked) {+ if (!listed.has(model)) failures.push(`${recipe.id}: unpriced_models names "${model}", which no touchpoint lists; remove the stale marker.`);+ }+}++if (failures.length > 0) {+ console.error(`check:recipe-pricing: ${failures.length} problem(s):`);+ for (const f of failures) console.error(` - ${f}`);+ process.exit(1);+}+console.log(`check:recipe-pricing: every recipe model is priced or marked unpriced (${recipes.length} recipes).`);diff --git a/scripts/guards-manifest.tsv b/scripts/guards-manifest.tsvindex 067c4b0366..34a956c509 100644--- a/scripts/guards-manifest.tsv+++ b/scripts/guards-manifest.tsv@@ -85,3 +85,4 @@ check-agent-contract.ts scanner yes agent operator contract v1 (B9): syntax-onlycheck-test-env-opt-ins.ts scanner yes D7 (GBRA-47): execution-gating process.env.GBRAIN_* reads in test/ and evals/ of names the operator-env preload strips (TS AST); policy shared with test/helpers/operator-env-policy.tscheck-postgres-lane-coverage.ts scanner yes GBRA-47 D8 (TS AST): a test file outside test/e2e/ with a DATABASE_URL-gated PostgreSQL arm (testBackends(), gated process.env.DATABASE_URL) must be named by a DATABASE_URL workflow step, a test/e2e registerPostgresTests wrapper, a tests/heavy script or the backend matrix; reasoned ALLOWLIST, stale rows failcheck-weight-coverage.ts scanner yes C2 (GBRA-47): weight-map entries naming missing files fail; unweighted share per lane warns, failing only on the scheduled run+check-recipe-pricing.ts scanner yes X1 (wave 9 lane A, D22): every model a recipe touchpoint lists resolves through isModelPriceable or is named in the recipe's unpriced_models; stale markers fail; GBRAIN_GUARD_ROOT seam reads <root>/recipes.json against the real price tablesdiff --git a/scripts/run-verify-parallel.sh b/scripts/run-verify-parallel.shindex 100a88bdbd..badec93fd4 100755--- a/scripts/run-verify-parallel.sh+++ b/scripts/run-verify-parallel.sh@@ -110,6 +110,8 @@ CHECKS=(# C2: weight maps name only existing files; the unweighted share per lane# warns (step summary) and fails only on the scheduled run."check:weight-coverage"+ # X1 (wave 9 lane A): every recipe model is priced or marked unpriced_models.+ "check:recipe-pricing"# ── light tail (sub-second greps; historical order) ──"check:proposal-pii""check:jsonb"diff --git a/src/core/ai/recipes/dashscope-rerank.ts b/src/core/ai/recipes/dashscope-rerank.tsindex 3c5eabc8e4..44aadac66f 100644--- a/src/core/ai/recipes/dashscope-rerank.ts+++ b/src/core/ai/recipes/dashscope-rerank.ts@@ -5,6 +5,11 @@ export const dashscopeRerank: Recipe = {name: 'Alibaba DashScope (灵积, reranker)',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'qwen3-rerank',+ ],base_url_default: 'https://dashscope-intl.aliyuncs.com/compatible-api/v1',auth_env: {required: ['DASHSCOPE_API_KEY'],diff --git a/src/core/ai/recipes/dashscope.ts b/src/core/ai/recipes/dashscope.tsindex 4c5c595ece..01f76ad1b3 100644--- a/src/core/ai/recipes/dashscope.ts+++ b/src/core/ai/recipes/dashscope.ts@@ -17,6 +17,12 @@ export const dashscope: Recipe = {name: 'Alibaba DashScope (灵积)',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'text-embedding-v3',+ 'text-embedding-v2',+ ],base_url_default: 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1',auth_env: {required: ['DASHSCOPE_API_KEY'],diff --git a/src/core/ai/recipes/groq.ts b/src/core/ai/recipes/groq.tsindex 0b72bf1c31..b8b6442968 100644--- a/src/core/ai/recipes/groq.ts+++ b/src/core/ai/recipes/groq.ts@@ -10,6 +10,14 @@ export const groq: Recipe = {name: 'Groq',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'llama-3.1-8b-instant',+ 'llama-3.3-70b-versatile',+ 'gpt-oss-20b',+ 'gpt-oss-120b',+ ],base_url_default: 'https://api.groq.com/openai/v1',auth_env: {required: ['GROQ_API_KEY'],diff --git a/src/core/ai/recipes/minimax.ts b/src/core/ai/recipes/minimax.tsindex 553ded55e8..411e3e2b08 100644--- a/src/core/ai/recipes/minimax.ts+++ b/src/core/ai/recipes/minimax.ts@@ -112,6 +112,19 @@ export const minimax: Recipe = {name: 'MiniMax (海螺AI)',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'embo-01',+ 'MiniMax-M3',+ 'MiniMax-M2.7',+ 'MiniMax-M2.7-highspeed',+ 'MiniMax-M2.5',+ 'MiniMax-M2.5-highspeed',+ 'MiniMax-M2.1',+ 'MiniMax-M2.1-highspeed',+ 'MiniMax-M2',+ ],base_url_default: 'https://api.minimaxi.com/v1',auth_env: {required: ['MINIMAX_API_KEY'],diff --git a/src/core/ai/recipes/mistral.ts b/src/core/ai/recipes/mistral.tsindex c22cce549e..3b0d235a81 100644--- a/src/core/ai/recipes/mistral.ts+++ b/src/core/ai/recipes/mistral.ts@@ -31,6 +31,16 @@ export const mistral: Recipe = {name: 'Mistral AI',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'ministral-3b-latest',+ 'mistral-small-latest',+ 'mistral-medium-latest',+ 'mistral-large-latest',+ 'ministral-8b-latest',+ 'magistral-small-latest',+ ],base_url_default: 'https://api.mistral.ai/v1',auth_env: {required: ['MISTRAL_API_KEY'],diff --git a/src/core/ai/recipes/moonshot.ts b/src/core/ai/recipes/moonshot.tsindex 859588c761..351975fd28 100644--- a/src/core/ai/recipes/moonshot.ts+++ b/src/core/ai/recipes/moonshot.ts@@ -13,6 +13,14 @@ export const moonshot: Recipe = {name: 'Moonshot AI / Kimi',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'kimi-k2.7-code',+ 'kimi-k2.7-code-highspeed',+ 'kimi-k2.6',+ 'kimi-k2.5',+ ],base_url_default: 'https://api.moonshot.ai/v1',auth_env: {required: ['MOONSHOT_API_KEY'],diff --git a/src/core/ai/recipes/nan.ts b/src/core/ai/recipes/nan.tsindex 58c30263a1..19c7428471 100644--- a/src/core/ai/recipes/nan.ts+++ b/src/core/ai/recipes/nan.ts@@ -30,6 +30,11 @@ export const nan: Recipe = {name: 'nan.builders (reranker)',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'rerank',+ ],base_url_default: 'https://api.nan.builders/v1',auth_env: {required: ['NAN_API_KEY'],diff --git a/src/core/ai/recipes/nvidia.ts b/src/core/ai/recipes/nvidia.tsindex bd833417aa..b20ca6e1b2 100644--- a/src/core/ai/recipes/nvidia.ts+++ b/src/core/ai/recipes/nvidia.ts@@ -18,6 +18,15 @@ export const nvidia: Recipe = {name: 'NVIDIA NIM',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'nvidia/nemotron-3-super-120b-a12b',+ 'nvidia/nv-embedqa-e5-v5',+ 'nvidia/llama-nemotron-embed-1b-v2',+ 'nvidia/nv-embed-v1',+ 'nvidia/nv-embedcode-7b-v1',+ ],base_url_default: 'https://integrate.api.nvidia.com/v1',auth_env: {required: ['NVIDIA_API_KEY'],diff --git a/src/core/ai/recipes/openrouter.ts b/src/core/ai/recipes/openrouter.tsindex 3b24636d8c..8749a0bfc2 100644--- a/src/core/ai/recipes/openrouter.ts+++ b/src/core/ai/recipes/openrouter.ts@@ -194,6 +194,22 @@ export const openrouter: Recipe = {name: 'OpenRouter',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'anthropic/claude-haiku-4.5',+ 'google/gemini-3-flash-preview',+ 'deepseek/deepseek-chat',+ 'openai/gpt-5.2',+ 'openai/gpt-5.2-chat',+ 'openai/gpt-5.5',+ 'anthropic/claude-sonnet-4.6',+ 'anthropic/claude-opus-4.7',+ 'cohere/rerank-v3.5',+ 'cohere/rerank-4-fast',+ 'cohere/rerank-4-pro',+ 'nvidia/llama-nemotron-rerank-vl-1b-v2:free',+ ],base_url_default: 'https://openrouter.ai/api/v1',auth_env: {required: ['OPENROUTER_API_KEY'],diff --git a/src/core/ai/recipes/together.ts b/src/core/ai/recipes/together.tsindex 59befd18db..0d5950ce86 100644--- a/src/core/ai/recipes/together.ts+++ b/src/core/ai/recipes/together.ts@@ -10,6 +10,13 @@ export const together: Recipe = {name: 'Together AI',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'Qwen/Qwen2.5-72B-Instruct-Turbo',+ 'deepseek-ai/DeepSeek-V3',+ 'mistralai/Mixtral-8x22B-Instruct-v0.1',+ ],base_url_default: 'https://api.together.xyz/v1',auth_env: {required: ['TOGETHER_API_KEY'],diff --git a/src/core/ai/recipes/voyage.ts b/src/core/ai/recipes/voyage.tsindex bdecdd03b0..811a80368a 100644--- a/src/core/ai/recipes/voyage.ts+++ b/src/core/ai/recipes/voyage.ts@@ -23,6 +23,11 @@ export const voyage: Recipe = {name: 'Voyage AI',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'voyage-4-nano',+ ],base_url_default: 'https://api.voyageai.com/v1',auth_env: {required: ['VOYAGE_API_KEY'],diff --git a/src/core/ai/recipes/zhipu.ts b/src/core/ai/recipes/zhipu.tsindex ef37ac0266..de3137de5f 100644--- a/src/core/ai/recipes/zhipu.ts+++ b/src/core/ai/recipes/zhipu.ts@@ -30,6 +30,17 @@ export const zhipu: Recipe = {name: 'Zhipu AI (智谱AI BigModel)',tier: 'openai-compat',implementation: 'openai-compatible',+ // No shipped rate for these yet: they warn and run under a default cap; a+ // user cap refuses them until `gbrain pricing set` registers one (X1 guard).+ unpriced_models: [+ 'glm-5.3',+ 'glm-5.3-flash',+ 'glm-5.1',+ 'glm-4.6',+ 'glm-4.5',+ 'embedding-3',+ 'embedding-2',+ ],base_url_default: 'https://open.bigmodel.cn/api/paas/v4',auth_env: {required: ['ZHIPUAI_API_KEY'],diff --git a/src/core/ai/types.ts b/src/core/ai/types.tsindex f200a9a9d2..007f2d230d 100644--- a/src/core/ai/types.ts+++ b/src/core/ai/types.ts@@ -352,6 +352,15 @@ export interface Recipe {* for every model of a per-token API).*/billing?: 'subscription';+ /**+ * Model ids this recipe lists in a touchpoint that gbrain ships no price+ * for. They run under a default cost cap with a warning; a cap the user+ * set refuses them with the no_pricing guidance until the operator+ * registers a rate (`gbrain pricing set`). `bun run check:recipe-pricing`+ * requires every listed model to be priced or named here, and fails on a+ * stale entry (now priced, or no longer listed).+ */+ unpriced_models?: string[];/** For openai-compatible tier: default base URL. May be overridden by env or wizard. */base_url_default?: string;/** Env var name(s) for auth; first is required, rest are optional. */diff --git a/test/fixtures/guards/check-recipe-pricing.ts/bad-orphan-marker/recipes.json b/test/fixtures/guards/check-recipe-pricing.ts/bad-orphan-marker/recipes.jsonnew file mode 100644index 0000000000..521a6a1169--- /dev/null+++ b/test/fixtures/guards/check-recipe-pricing.ts/bad-orphan-marker/recipes.json@@ -0,0 +1,3 @@+[+ { "id": "groq", "unpriced_models": ["model-no-touchpoint-lists"], "touchpoints": { "chat": { "models": [] } } }+]diff --git a/test/fixtures/guards/check-recipe-pricing.ts/bad-stale/recipes.json b/test/fixtures/guards/check-recipe-pricing.ts/bad-stale/recipes.jsonnew file mode 100644index 0000000000..4bca1a9331--- /dev/null+++ b/test/fixtures/guards/check-recipe-pricing.ts/bad-stale/recipes.json@@ -0,0 +1,3 @@+[+ { "id": "openai", "unpriced_models": ["gpt-5.5"], "touchpoints": { "chat": { "models": ["gpt-5.5"] } } }+]diff --git a/test/fixtures/guards/check-recipe-pricing.ts/bad/recipes.json b/test/fixtures/guards/check-recipe-pricing.ts/bad/recipes.jsonnew file mode 100644index 0000000000..db8db5c4fc--- /dev/null+++ b/test/fixtures/guards/check-recipe-pricing.ts/bad/recipes.json@@ -0,0 +1,3 @@+[+ { "id": "openai", "touchpoints": { "chat": { "models": ["gpt-5.5", "gpt-unpriced-example"] } } }+]diff --git a/test/fixtures/guards/check-recipe-pricing.ts/good/recipes.json b/test/fixtures/guards/check-recipe-pricing.ts/good/recipes.jsonnew file mode 100644index 0000000000..551396ee75--- /dev/null+++ b/test/fixtures/guards/check-recipe-pricing.ts/good/recipes.json@@ -0,0 +1,4 @@+[+ { "id": "openai", "touchpoints": { "chat": { "models": ["gpt-5.5"] }, "embedding": { "models": ["text-embedding-3-small"] } } },+ { "id": "groq", "unpriced_models": ["llama-3.1-8b-instant"], "touchpoints": { "chat": { "models": ["llama-3.1-8b-instant"] } } }+]