diff --git a/pm-stack/aggregator/src/aa.ts b/pm-stack/aggregator/src/aa.ts index 2e5240d627..1e4473e116 100644 --- a/pm-stack/aggregator/src/aa.ts +++ b/pm-stack/aggregator/src/aa.ts @@ -23,6 +23,7 @@ import type { AaThreshold, } from "./model.ts"; import { isIsoDate } from "./validate.ts"; +import { serviceIdFor } from "./quota-gather-map.ts"; // --- scalar coercion --------------------------------------------------------- // The Supabase Management API serializes numeric columns as JSON @@ -758,7 +759,7 @@ interface RawModelEntry { } /** Route id -> the leaf model ids it reaches (nested routes expanded). */ -function routeLeafSets(cfg: { experimental?: { model_routes?: unknown } }): Map> { +export function routeLeafSets(cfg: { experimental?: { model_routes?: unknown } }): Map> { const routes = new Map(); const rawRoutes = cfg.experimental?.model_routes; if (typeof rawRoutes === "object" && rawRoutes !== null) { @@ -792,6 +793,63 @@ function routeLeafSets(cfg: { experimental?: { model_routes?: unknown } }): Map< return out; } +/** The major route sections the section-risk notification class + * (#8882) watches: exactly the sections Drew named — no scout. + * `small` reaches small-100k's leaves through its nested + * opencode-route/small-100k target, and the live leaf analysis + * (2026-11-12) shows small-100k's door set identical to small's, so + * small-100k rolls up under small with no extra mapping. Keep in + * sync with SECTION_RISK_SECTIONS in notifications.ts. */ +export const SECTION_RISK_SECTIONS = ["workhorse", "speed", "specialist", "summit", "small"] as const; + +/** Does quota pool `poolId` serve route door `door` (a leaf's + * provider part)? The join, pinned by #8882's unit tests: + * - exact: the gatherer's service-id spelling of the door is the + * pool id (serviceIdFor: _claude -> anthropic:claude-pro, + * _muse/meta -> meta, _openai -> _openai.main); + * - split pools: a pool id under the door with a dot suffix serves + * the door (_antigravity.gemini / _antigravity.claude-gpt serve + * _antigravity; opencode-go. serves opencode-go); + * - plan doors: *-plan pseudo-providers in routes map to the pools + * of their base provider (opencode-go-plans -> opencode-go.*, + * openai-plan -> _openai.main/_openai.alt, mistral-plan -> mistral). */ +export function poolServesDoor(poolId: string, door: string): boolean { + if (serviceIdFor(door) === poolId) return true; + if (poolId.startsWith(`${door}.`)) return true; + if (door.endsWith("-plan") || door.endsWith("-plans")) { + const base = door.replace(/-plans?$/, ""); + const bare = poolId.replace(/^_/, ""); + if (poolId === base || bare === base) return true; + if (poolId.startsWith(`${base}.`) || bare.startsWith(`${base}.`) || bare.startsWith(`${base}:`)) return true; + } + return false; +} + +/** Section -> quota pool ids serving it, from the deployed OpenCode + * config text (#8882). Unparseable config yields {} — the caller + * derives no section candidates, never a guessed membership. */ +export function sectionPoolIdsFromConfig(text: string, poolIds: readonly string[]): Record { + let cfg: unknown; + try { + cfg = JSON.parse(stripJsonComments(text)); + } catch { + return {}; + } + if (typeof cfg !== "object" || cfg === null) return {}; + const leafSets = routeLeafSets(cfg as { experimental?: { model_routes?: unknown } }); + const out: Record = {}; + for (const section of SECTION_RISK_SECTIONS) { + const leaves = leafSets.get(section); + if (!leaves) { + out[section] = []; + continue; + } + const doors = new Set([...leaves].map((leaf) => leaf.split("/")[0])); + out[section] = [...new Set(poolIds.filter((poolId) => [...doors].some((door) => poolServesDoor(poolId, door))))].sort(); + } + return out; +} + /** * Build the Model Explorer catalog from the repo config + the AA * measured rows (for the per-model AA match). Returns null when the diff --git a/pm-stack/aggregator/src/config.ts b/pm-stack/aggregator/src/config.ts index 32b450569e..a4f32961f7 100644 --- a/pm-stack/aggregator/src/config.ts +++ b/pm-stack/aggregator/src/config.ts @@ -86,6 +86,10 @@ export interface Config { /** The quota gatherer's latest-state file (#1151), written into the * aggregator's own data dir by scripts/gather-quota.ts. */ quotaCurrentFile: string; + /** The deployed OpenCode config (.opencode/opencode.jsonc of the + * code repo): the section-risk join (#8882) reads its model_routes + * leaf sets from here. */ + opencodeConfigFile: string; coverageSnapshotFile: string; /** OpenChamber managed-opencode state file (laptop attention source). */ openchamberStateFile: string; @@ -214,6 +218,10 @@ export function loadConfig(env: Record = process.env join(homedir(), "workspace/goals/keep-the-four-repos-healthy/hidden_files/provider-quota-registry.md"), ), quotaCurrentFile: s(env.PM_AGG_QUOTA_CURRENT_FILE, join(process.cwd(), "quota-current.json")), + opencodeConfigFile: s( + env.PM_AGG_OPENCODE_CONFIG_FILE, + join(homedir(), "git", "code", ".opencode", "opencode.jsonc"), + ), itemHistoryFile: s( env.PM_AGG_ITEM_HISTORY_FILE, join(homedir(), ".local", "state", "pm-aggregator", "item-history.jsonl"), diff --git a/pm-stack/aggregator/src/notifications.ts b/pm-stack/aggregator/src/notifications.ts index 046bd45550..8a2405b2de 100644 --- a/pm-stack/aggregator/src/notifications.ts +++ b/pm-stack/aggregator/src/notifications.ts @@ -36,6 +36,7 @@ export const NOTIFICATION_CLASS_DEFAULTS: Record = { "needs-drew": true, "quota-wall": true, "quota-near-wall": true, + "section-risk": true, "stack-health": true, "blocked-age": true, }; @@ -73,6 +74,11 @@ export const NOTIFICATION_CLASSES: NotificationClassMeta[] = [ label: "Quota near wall", blurb: "A sole-door pool crosses 85% of a window.", }, + { + id: "section-risk", + label: "Section failure / severe risk", + blurb: "A whole route section (workhorse, speed, specialist, summit, small) fails or is at severe risk. Shows the pools pending wall, which are walled, and the soonest resets.", + }, { id: "stack-health", label: "Stack health", @@ -121,6 +127,7 @@ export function notificationTestLanding( return `${origin}/alerts#incident-test`; case "quota-wall": case "quota-near-wall": + case "section-risk": return `${origin}/quota`; case "stack-health": return `${origin}/health`; @@ -141,7 +148,7 @@ export const BLOCKED_AGE_BREAKTHROUGH_MS = 48 * 60 * 60_000; export const QUOTA_WELL_BEFORE_RESET_MS = 24 * 60 * 60_000; export interface NotificationCandidate { - class: "needs-drew" | "blocked-age" | "quota-wall" | "quota-near-wall" | "stack-health"; + class: "needs-drew" | "blocked-age" | "quota-wall" | "quota-near-wall" | "section-risk" | "stack-health"; objectRef: string; stateFingerprint: string; title: string; @@ -191,6 +198,10 @@ export interface NotificationSnapshot { health: Pick; /** Pool ids identified as having no alternative route. */ soleDoorPoolIds?: ReadonlySet; + /** #8882: route section -> quota pool ids serving it, joined from + * the deployed OpenCode config's route leaf sets (server.ts via + * aa.ts sectionPoolIdsFromConfig). Absent = no section derivation. */ + sectionPools?: Readonly>; /** Drew-authored dashboard actions/comments, with their event times. */ drewActivity?: Array<{ objectRef: string; at: string }>; /** #8568: open needs-Drew questions (unanswered, < 7 days old). */ @@ -389,6 +400,24 @@ export function decideNotification( return "send"; } +/** #8882: the major route sections Drew named for the section-risk + * class — exactly these, no scout. Keep in sync with + * SECTION_RISK_SECTIONS in aa.ts (the config-side join). */ +export const SECTION_RISK_SECTIONS = ["workhorse", "speed", "specialist", "summit", "small"] as const; +/** Pending wall = a measured window at or over this percent (the + * existing near-wall threshold), on a pool that is not walled. */ +export const SECTION_RISK_PENDING_PERCENT = 85; + +const RESET_WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + +/** Compact UTC reset stamp for push bodies: "Fri 14:28Z". */ +export function formatResetCompact(ms: number): string { + const d = new Date(ms); + const hh = String(d.getUTCHours()).padStart(2, "0"); + const mm = String(d.getUTCMinutes()).padStart(2, "0"); + return `${RESET_WEEKDAYS[d.getUTCDay()]} ${hh}:${mm}Z`; +} + /** Derive stable, fixture-testable notifications from the same views the UI serves. */ export function buildNotificationCandidates(snapshot: NotificationSnapshot, now = Date.now()): NotificationCandidate[] { const attentionItems: Array = [ @@ -453,6 +482,106 @@ export function buildNotificationCandidates(snapshot: NotificationSnapshot, now } } + // #8882: section-risk — one candidate per major route section, and + // only when the section as a whole has FAILED (every serving pool + // walled) or is at SEVERE RISK (every non-walled serving pool is + // pending wall). Membership comes from the snapshot (the aa.ts leaf + // join over the deployed config); pools in error/stale/lapsed state + // never count as serving, exactly as in the per-pool quota loop. + for (const section of SECTION_RISK_SECTIONS) { + const memberIds = snapshot.sectionPools?.[section]; + if (!memberIds || memberIds.length === 0) continue; + const memberSet = new Set(memberIds); + interface ServingPool { + id: string; + walled: boolean; + wallResetAt: number | null; + pendingPct: number | null; + pendingResetAt: number | null; + } + const serving: ServingPool[] = []; + for (const pool of snapshot.quota.pools) { + if (!memberSet.has(pool.id)) continue; + if (pool.state === "error" || pool.state === "stale" || pool.state === "lapsed") continue; + const windows = pool.windows.filter((w) => w.limit !== null); + const percentOf = (w: (typeof windows)[number]) => w.percent ?? (w.used / (w.limit || 1)) * 100; + const walled = pool.state === "walled" || windows.some((w) => percentOf(w) >= 100); + let wallResetAt: number | null = null; + let pendingPct: number | null = null; + let pendingResetAt: number | null = null; + if (walled) { + // Same wall-lift computation as the quota-wall candidate: the + // pool's authoritative wallLiftsAt, else the soonest reset of + // the exhausted windows. + const lifts = pool.wallLiftsAt ? Date.parse(pool.wallLiftsAt) : NaN; + if (Number.isFinite(lifts)) { + wallResetAt = lifts; + } else { + const exhausted = windows.filter((w) => percentOf(w) >= 100); + const resets = (exhausted.length ? exhausted : windows) + .map((w) => Date.parse(w.resetsAt ?? "")) + .filter(Number.isFinite) + .sort((a, b) => a - b); + wallResetAt = resets[0] ?? null; + } + } else { + for (const w of windows) { + const pct = percentOf(w); + if (pct >= SECTION_RISK_PENDING_PERCENT && (pendingPct === null || pct > pendingPct)) { + pendingPct = Math.floor(pct); + const reset = Date.parse(w.resetsAt ?? ""); + pendingResetAt = Number.isFinite(reset) ? reset : null; + } + } + } + serving.push({ id: pool.id, walled, wallResetAt, pendingPct, pendingResetAt }); + } + if (serving.length === 0) continue; + const walledPools = serving.filter((entry) => entry.walled); + const pendingPools = serving.filter((entry) => !entry.walled && entry.pendingPct !== null); + const failed = walledPools.length === serving.length; + const severeRisk = !failed && pendingPools.length > 0 && pendingPools.length === serving.length - walledPools.length; + if (!failed && !severeRisk) continue; + const resetSort = (a: number | null, b: number | null) => (a ?? Infinity) - (b ?? Infinity); + const walledPart = walledPools + .slice() + .sort((a, b) => resetSort(a.wallResetAt, b.wallResetAt)) + .map((entry) => `${entry.id}${entry.wallResetAt !== null ? ` (resets ${formatResetCompact(entry.wallResetAt)})` : ""}`) + .join(", "); + const pendingPart = pendingPools + .slice() + .sort((a, b) => resetSort(a.pendingResetAt, b.pendingResetAt)) + .map( + (entry) => + `${entry.id} ${entry.pendingPct}%${entry.pendingResetAt !== null ? ` (resets ${formatResetCompact(entry.pendingResetAt)})` : ""}`, + ) + .join(", "); + const body = [walledPart ? `walled: ${walledPart}` : "", pendingPart ? `pending: ${pendingPart}` : ""] + .filter(Boolean) + .join(" \u00b7 "); + const soonestReset = + [...walledPools.map((entry) => entry.wallResetAt), ...pendingPools.map((entry) => entry.pendingResetAt)] + .filter((value): value is number => value !== null) + .sort((a, b) => a - b)[0] ?? null; + candidates.push( + candidate({ + class: "section-risk", + objectRef: `section:${section}`, + title: failed ? `Section failed: ${section}` : `Section at risk: ${section}`, + body, + url: "/quota", + observedAt: new Date(now).toISOString(), + state: { + state: failed ? "failed" : "severe-risk", + walled: walledPools.map((entry) => entry.id).sort(), + pending: pendingPools.map((entry) => [entry.id, entry.pendingPct]).sort(), + soonestReset: soonestReset !== null ? new Date(soonestReset).toISOString() : null, + }, + breakthrough: failed, + }), + ); + } + for (const service of snapshot.health.services) { if (service.ok !== false) continue; // #8568: the sentinel is authoritative for its service set — when diff --git a/pm-stack/aggregator/src/server.ts b/pm-stack/aggregator/src/server.ts index df0f43e9f3..5aa84d2f9d 100644 --- a/pm-stack/aggregator/src/server.ts +++ b/pm-stack/aggregator/src/server.ts @@ -6,7 +6,7 @@ // its result companion) on the same pattern. Everything underneath // (GitHub, Kaneo, Grist) stays read-only from here — the fleet jobs // apply actions; the dashboard only records them. -import { stat } from "node:fs/promises"; +import { readFile, stat } from "node:fs/promises"; import { createQuotaRefresher, systemdTrigger } from "./quota-refresh.ts"; import { decodePathSegment } from "./path-segment.ts"; import { errorBoundaryResponse, notFoundResponse } from "./error-boundary.ts"; @@ -54,7 +54,7 @@ import { import { loadConfig } from "./config.ts"; import { itemServiceLinks } from "./service-links.ts"; import { loadFeed } from "./feed.ts"; -import { AA_PLAN_FACTS } from "./aa.ts"; +import { AA_PLAN_FACTS, sectionPoolIdsFromConfig } from "./aa.ts"; import { getNeedsDrew, listOpenNeedsDrew, @@ -3507,18 +3507,31 @@ if (source.ingestSnapshots) { // The alert throat's engine (#3676): the ~60s delivery/escalation // tick (live mode only, fail-soft — see src/alerts.ts). startAlertEngine(cfg, async (): Promise => { - const [attention, quota, health, actions, comments, needsDrewRaised, decisionSets, stackHealthDown, stackHealthStates] = - await Promise.all([ - attentionContext(), - source.quota().catch(() => emptyQuotaView()), - healthContext(false), - actionsStore.all().catch(() => []), - commentsStore.all().catch(() => []), - listOpenNeedsDrew(cfg.needsDrewFile).catch(() => []), - listOpenDecisionSets(cfg.decisionsFile).catch(() => []), - listStackHealthDown(cfg.stackHealthFile).catch(() => []), - readStackHealthStates(cfg.stackHealthFile).catch(() => ({})), - ]); + const [ + attention, + quota, + health, + actions, + comments, + needsDrewRaised, + decisionSets, + stackHealthDown, + stackHealthStates, + opencodeConfigText, + ] = await Promise.all([ + attentionContext(), + source.quota().catch(() => emptyQuotaView()), + healthContext(false), + actionsStore.all().catch(() => []), + commentsStore.all().catch(() => []), + listOpenNeedsDrew(cfg.needsDrewFile).catch(() => []), + listOpenDecisionSets(cfg.decisionsFile).catch(() => []), + listStackHealthDown(cfg.stackHealthFile).catch(() => []), + readStackHealthStates(cfg.stackHealthFile).catch(() => ({})), + // #8882: the section-risk join reads the deployed config's route + // leaf sets; a missing/unreadable config yields no membership. + readFile(cfg.opencodeConfigFile, "utf8").catch(() => ""), + ]); const drewActivity = [ ...actions.filter((action) => action.author.kind === "drew").map((action) => ({ objectRef: action.objectRef, at: action.createdAt })), ...comments.filter((comment) => comment.author.kind === "drew").map((comment) => ({ objectRef: comment.objectRef, at: comment.createdAt })), @@ -3529,6 +3542,7 @@ startAlertEngine(cfg, async (): Promise => { health, drewActivity, soleDoorPoolIds: deriveSoleDoorPoolIds(quota), + sectionPools: sectionPoolIdsFromConfig(opencodeConfigText, quota.pools.map((pool) => pool.id)), needsDrewRaised, decisionSets, stackHealthDown, diff --git a/pm-stack/aggregator/test/alerts.test.ts b/pm-stack/aggregator/test/alerts.test.ts index 05fb57be5e..7e5bc605cf 100644 --- a/pm-stack/aggregator/test/alerts.test.ts +++ b/pm-stack/aggregator/test/alerts.test.ts @@ -101,6 +101,7 @@ describe("class + quiet merges (design §1/§2)", () => { "needs-drew": true, "quota-wall": true, "quota-near-wall": true, + "section-risk": true, "stack-health": true, "blocked-age": true, }); @@ -344,6 +345,7 @@ describe("validation", () => { "needs-drew": true, "quota-wall": true, "quota-near-wall": true, + "section-risk": true, "stack-health": true, "blocked-age": true, }); diff --git a/pm-stack/aggregator/test/section-risk-8882.test.ts b/pm-stack/aggregator/test/section-risk-8882.test.ts new file mode 100644 index 0000000000..3d47635209 --- /dev/null +++ b/pm-stack/aggregator/test/section-risk-8882.test.ts @@ -0,0 +1,160 @@ +// lane-scratch: any-d /tmp/lane-any-d-20261112-0202 task 15095 +import { describe, expect, test } from "bun:test"; +import { + buildNotificationCandidates, + isNotificationTestClass, + NOTIFICATION_CLASS_DEFAULTS, + NOTIFICATION_CLASSES, + notificationTestLanding, + type NotificationSnapshot, +} from "../src/notifications.ts"; +import { poolServesDoor, sectionPoolIdsFromConfig } from "../src/aa.ts"; + +// Thu 2026-11-12 08:00Z. Fri 2026-11-13 / Sat 2026-11-14 / Mon 2026-11-16 below. +const NOW = Date.parse("2026-11-12T08:00:00Z"); +const FRI = "2026-11-13T14:28:00Z"; +const SAT = "2026-11-14T09:00:00Z"; +const MON = "2026-11-16T11:04:00Z"; + +function pool(id: string, state: string, windows: Array<{ percent: number; resetsAt: string | null }>) { + return { + id, + provider: id, + plan: "", + state, + windows: windows.map((w, i) => ({ + name: `w${i}`, + unit: "tokens" as const, + limit: 100, + used: w.percent, + percent: w.percent, + resetsAt: w.resetsAt, + })), + }; +} + +function snapshot(pools: unknown[], sectionPools: Record): NotificationSnapshot { + return { + attention: { drew: [], drewExtra: [] } as unknown as NotificationSnapshot["attention"], + quota: { pools } as unknown as NotificationSnapshot["quota"], + health: { services: [] }, + sectionPools, + }; +} + +function sectionCandidates(pools: unknown[], sectionPools: Record) { + return buildNotificationCandidates(snapshot(pools, sectionPools), NOW).filter((c) => c.class === "section-risk"); +} + +describe("section-risk class registration (#8882)", () => { + test("the class is a default-on preference class landing on /quota", () => { + expect(NOTIFICATION_CLASS_DEFAULTS["section-risk"]).toBe(true); + const meta = NOTIFICATION_CLASSES.find((c) => c.id === "section-risk"); + expect(meta?.label).toBe("Section failure / severe risk"); + expect(isNotificationTestClass("section-risk")).toBe(true); + expect(notificationTestLanding("section-risk", "https://board.example")).toBe("https://board.example/quota"); + }); +}); + +describe("section-risk derivation (#8882)", () => { + test("every workhorse pool walled -> exactly one FAILED candidate, compact body, soonest reset first", () => { + const candidates = sectionCandidates( + [pool("pool-a", "healthy", [{ percent: 100, resetsAt: SAT }]), pool("pool-b", "walled", [{ percent: 100, resetsAt: FRI }])], + { workhorse: ["pool-a", "pool-b"] }, + ); + expect(candidates).toHaveLength(1); + expect(candidates[0].objectRef).toBe("section:workhorse"); + expect(candidates[0].title).toBe("Section failed: workhorse"); + expect(candidates[0].breakthrough).toBe(true); + expect(candidates[0].url).toBe("/quota"); + expect(candidates[0].body).toBe("walled: pool-b (resets Fri 14:28Z), pool-a (resets Sat 09:00Z)"); + }); + + test("only non-walled pool >=85% -> one SEVERE RISK candidate; stale pools never count as serving", () => { + const candidates = sectionCandidates( + [ + pool("pool-a", "healthy", [{ percent: 100, resetsAt: FRI }]), + pool("pool-b", "healthy", [{ percent: 97, resetsAt: MON }]), + pool("pool-c", "stale", [{ percent: 10, resetsAt: MON }]), + ], + { workhorse: ["pool-a", "pool-b", "pool-c"] }, + ); + expect(candidates).toHaveLength(1); + expect(candidates[0].title).toBe("Section at risk: workhorse"); + expect(candidates[0].breakthrough).toBe(false); + expect(candidates[0].body).toBe("walled: pool-a (resets Fri 14:28Z) · pending: pool-b 97% (resets Mon 11:04Z)"); + }); + + test("one healthy pool under 85% -> NO section candidate even with other pools walled/near", () => { + const candidates = sectionCandidates( + [ + pool("pool-a", "healthy", [{ percent: 100, resetsAt: FRI }]), + pool("pool-b", "healthy", [{ percent: 97, resetsAt: MON }]), + pool("pool-c", "healthy", [{ percent: 40, resetsAt: MON }]), + ], + { workhorse: ["pool-a", "pool-b", "pool-c"] }, + ); + expect(candidates).toHaveLength(0); + }); + + test("absent membership -> no section candidates (never guessed)", () => { + const candidates = sectionCandidates([pool("pool-a", "walled", [{ percent: 100, resetsAt: FRI }])], {}); + expect(candidates).toHaveLength(0); + }); +}); + +describe("section pool join from config leaf sets (#8882)", () => { + const CONFIG = `{ + "provider": {}, + "experimental": { "model_routes": { + "workhorse": { "targets": ["opencode-route/wk-plan", "_antigravity/claude-x"] }, + "wk-plan": { "targets": ["opencode-go-plans/deepseek-flash", "cline-pass/deepseek-flash"] }, + "speed": { "targets": ["_muse/muse-spark"] }, + "specialist": { "targets": ["mistral-plan/mistral-x"] }, + "summit": { "targets": ["openai-plan/gpt-luna"] }, + "small": { "targets": ["opencode-route/small-100k", "_claude/haiku"] }, + "small-100k": { "targets": ["_claude/haiku"] } + } } + }`; + const POOLS = [ + "opencode-go.drewrypope", + "opencode-go.popesdrew", + "cline-pass", + "_antigravity.gemini", + "_antigravity.claude-gpt", + "meta", + "anthropic:claude-pro", + "_openai.main", + "_openai.alt", + "mistral", + "deepseek", + ]; + + test("doors join to pools: service-id spellings, split pools, and plan doors", () => { + const membership = sectionPoolIdsFromConfig(CONFIG, POOLS); + expect(membership.workhorse).toEqual([ + "_antigravity.claude-gpt", + "_antigravity.gemini", + "cline-pass", + "opencode-go.drewrypope", + "opencode-go.popesdrew", + ]); + expect(membership.speed).toEqual(["meta"]); + expect(membership.specialist).toEqual(["mistral"]); + expect(membership.summit).toEqual(["_openai.alt", "_openai.main"]); + // small reaches small-100k's leaves through its nested route target. + expect(membership.small).toEqual(["anthropic:claude-pro"]); + }); + + test("poolServesDoor pins the three join rules", () => { + expect(poolServesDoor("anthropic:claude-pro", "_claude")).toBe(true); + expect(poolServesDoor("_antigravity.gemini", "_antigravity")).toBe(true); + expect(poolServesDoor("opencode-go.popesdrew", "opencode-go-plans")).toBe(true); + expect(poolServesDoor("deepseek", "opencode-go-plans")).toBe(false); + expect(poolServesDoor("meta", "_claude")).toBe(false); + }); + + test("unparseable config yields no membership", () => { + expect(sectionPoolIdsFromConfig("{not json", POOLS)).toEqual({}); + }); +});