@warmdrift/kgauto-compiler 2.0.0-alpha.79 → 2.0.0-alpha.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var LIBRARY_VERSION = "2.0.0-alpha.79";
2
+ var LIBRARY_VERSION = "2.0.0-alpha.80";
3
3
 
4
4
  // src/key-health.ts
5
5
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -1,4 +1,5 @@
1
1
  import {
2
+ allProfiles,
2
3
  tryGetProfile
3
4
  } from "./chunk-VVRDFE6T.mjs";
4
5
 
@@ -253,6 +254,63 @@ function getModelCompatibility(modelId, intent) {
253
254
  };
254
255
  }
255
256
 
257
+ // src/archetype-perf-brain.ts
258
+ function isPerfRow(x) {
259
+ if (!x || typeof x !== "object") return false;
260
+ const r = x;
261
+ return typeof r.model_id === "string" && typeof r.archetype === "string" && typeof r.perf_score === "number";
262
+ }
263
+ function mapRowsToPerfMap(rows) {
264
+ const out = /* @__PURE__ */ new Map();
265
+ for (const row of rows) {
266
+ if (!isPerfRow(row)) continue;
267
+ const existing = out.get(row.model_id) ?? {};
268
+ existing[row.archetype] = row.perf_score;
269
+ out.set(row.model_id, existing);
270
+ }
271
+ return out;
272
+ }
273
+ function mapRowsToNMap(rows) {
274
+ const out = /* @__PURE__ */ new Map();
275
+ for (const row of rows) {
276
+ if (!isPerfRow(row)) continue;
277
+ if (typeof row.n !== "number") continue;
278
+ const existing = out.get(row.model_id) ?? {};
279
+ existing[row.archetype] = row.n;
280
+ out.set(row.model_id, existing);
281
+ }
282
+ return out;
283
+ }
284
+ function bundledArchetypePerf() {
285
+ const out = /* @__PURE__ */ new Map();
286
+ for (const profile of allProfiles()) {
287
+ if (profile.archetypePerf) out.set(profile.id, profile.archetypePerf);
288
+ }
289
+ return out;
290
+ }
291
+ function bundledArchetypePerfN() {
292
+ return /* @__PURE__ */ new Map();
293
+ }
294
+ var loadArchetypePerfFromBrain = createBrainQueryCache({
295
+ table: "kgauto_archetype_perf",
296
+ mapRows: mapRowsToPerfMap,
297
+ bundledFallback: bundledArchetypePerf
298
+ });
299
+ var loadArchetypePerfNFromBrain = createBrainQueryCache(
300
+ {
301
+ table: "kgauto_archetype_perf",
302
+ mapRows: mapRowsToNMap,
303
+ bundledFallback: bundledArchetypePerfN
304
+ }
305
+ );
306
+ var MEASURED_GROUNDING_MIN_N = 10;
307
+ function getArchetypePerfScore(modelId, archetype) {
308
+ const score = loadArchetypePerfFromBrain().get(modelId)?.[archetype] ?? 5;
309
+ const n = loadArchetypePerfNFromBrain().get(modelId)?.[archetype] ?? 0;
310
+ const grounding = n >= MEASURED_GROUNDING_MIN_N ? "measured" : "judgment";
311
+ return { score, n, grounding };
312
+ }
313
+
256
314
  // src/env.ts
257
315
  var SUPPORTED_PROVIDERS = Object.freeze([
258
316
  "anthropic",
@@ -350,6 +408,26 @@ function isSameModelRetryEnabledFromEnv(envSource = defaultEnv()) {
350
408
  }
351
409
 
352
410
  // src/fallback.ts
411
+ var COST_RANKING_REFERENCE_SHAPE = {
412
+ inputTokens: 4e3,
413
+ outputTokens: 250
414
+ };
415
+ function estimateChainCostUsd(profile, shape = COST_RANKING_REFERENCE_SHAPE) {
416
+ return shape.inputTokens / 1e6 * profile.costInputPer1m + shape.outputTokens / 1e6 * profile.costOutputPer1m;
417
+ }
418
+ function buildCostOrderedChain(archetype) {
419
+ return allProfiles().filter((p) => p.status === "current").filter(
420
+ (p) => getArchetypePerfScore(p.id, archetype).score >= ARCHETYPE_FLOOR_DEFAULT
421
+ ).map((p) => ({ p, cost: estimateChainCostUsd(p) })).sort((a, b) => a.cost - b.cost || a.p.id.localeCompare(b.p.id)).map((e) => e.p.id);
422
+ }
423
+ function chainProviderSpread(chain) {
424
+ const providers = /* @__PURE__ */ new Set();
425
+ for (const id of chain) {
426
+ const p = tryGetProfile(id);
427
+ if (p) providers.add(p.provider);
428
+ }
429
+ return providers.size;
430
+ }
353
431
  var STARTER_CHAINS_GROUNDED = {
354
432
  // Reasoning floor — never degrade. Walk UP on 429 to Opus → cross-provider.
355
433
  critique: [
@@ -486,19 +564,28 @@ function resolveStarterForMode(archetype, toolOrchestration, allChains) {
486
564
  return allChains[archetype];
487
565
  }
488
566
  function getDefaultFallbackChain(opts) {
489
- const { archetype, primary, maxDepth = 4, policy, reachability, toolOrchestration } = opts;
567
+ const {
568
+ archetype,
569
+ primary,
570
+ maxDepth = 4,
571
+ policy,
572
+ reachability,
573
+ toolOrchestration,
574
+ optimizeFor = "quality"
575
+ } = opts;
490
576
  if (maxDepth < 1) {
491
577
  throw new Error(
492
578
  `getDefaultFallbackChain: maxDepth must be >= 1, got ${maxDepth}`
493
579
  );
494
580
  }
495
581
  const allChains = loadChainsFromBrain();
496
- const starter = resolveStarterForMode(archetype, toolOrchestration, allChains);
497
- if (!starter) {
582
+ const qualityStarter = resolveStarterForMode(archetype, toolOrchestration, allChains);
583
+ if (!qualityStarter) {
498
584
  throw new Error(
499
585
  `getDefaultFallbackChain: unknown archetype "${archetype}". Known: ${Object.keys(allChains).join(", ")}`
500
586
  );
501
587
  }
588
+ const starter = optimizeFor === "cost" ? buildCostOrderedChain(archetype) : qualityStarter;
502
589
  let chain;
503
590
  if (primary) {
504
591
  chain = [primary, ...starter.filter((id) => id !== primary)];
@@ -710,6 +797,10 @@ export {
710
797
  ARCHETYPE_FLOOR_DEFAULT,
711
798
  ABSOLUTE_FLOOR,
712
799
  getModelCompatibility,
800
+ loadArchetypePerfFromBrain,
801
+ loadArchetypePerfNFromBrain,
802
+ MEASURED_GROUNDING_MIN_N,
803
+ getArchetypePerfScore,
713
804
  PROVIDER_ENV_KEYS,
714
805
  resolveProviderKey,
715
806
  isProviderReachable,
@@ -719,6 +810,9 @@ export {
719
810
  readBrainReadEnv,
720
811
  isSameModelRetryEnabledFromEnv,
721
812
  loadChainsFromBrain,
813
+ COST_RANKING_REFERENCE_SHAPE,
814
+ estimateChainCostUsd,
815
+ chainProviderSpread,
722
816
  getDefaultFallbackChain,
723
817
  getStarterChain,
724
818
  getAllStarterChains,
@@ -1724,6 +1724,9 @@ function tryGetProfile(id) {
1724
1724
  const canonical = canonicalId(id);
1725
1725
  return brainHook.getProfile?.(canonical) ?? PROFILE_INDEX.get(canonical);
1726
1726
  }
1727
+ function allProfiles() {
1728
+ return PROFILES_RAW;
1729
+ }
1727
1730
 
1728
1731
  // src/env.ts
1729
1732
  var SUPPORTED_PROVIDERS = Object.freeze([
@@ -1888,7 +1891,79 @@ var loadChainsFromBrain = createBrainQueryCache({
1888
1891
  bundledFallback: getAllStarterChains
1889
1892
  });
1890
1893
 
1894
+ // src/archetype-perf-brain.ts
1895
+ function isPerfRow(x) {
1896
+ if (!x || typeof x !== "object") return false;
1897
+ const r = x;
1898
+ return typeof r.model_id === "string" && typeof r.archetype === "string" && typeof r.perf_score === "number";
1899
+ }
1900
+ function mapRowsToPerfMap(rows) {
1901
+ const out = /* @__PURE__ */ new Map();
1902
+ for (const row of rows) {
1903
+ if (!isPerfRow(row)) continue;
1904
+ const existing = out.get(row.model_id) ?? {};
1905
+ existing[row.archetype] = row.perf_score;
1906
+ out.set(row.model_id, existing);
1907
+ }
1908
+ return out;
1909
+ }
1910
+ function mapRowsToNMap(rows) {
1911
+ const out = /* @__PURE__ */ new Map();
1912
+ for (const row of rows) {
1913
+ if (!isPerfRow(row)) continue;
1914
+ if (typeof row.n !== "number") continue;
1915
+ const existing = out.get(row.model_id) ?? {};
1916
+ existing[row.archetype] = row.n;
1917
+ out.set(row.model_id, existing);
1918
+ }
1919
+ return out;
1920
+ }
1921
+ function bundledArchetypePerf() {
1922
+ const out = /* @__PURE__ */ new Map();
1923
+ for (const profile of allProfiles()) {
1924
+ if (profile.archetypePerf) out.set(profile.id, profile.archetypePerf);
1925
+ }
1926
+ return out;
1927
+ }
1928
+ function bundledArchetypePerfN() {
1929
+ return /* @__PURE__ */ new Map();
1930
+ }
1931
+ var loadArchetypePerfFromBrain = createBrainQueryCache({
1932
+ table: "kgauto_archetype_perf",
1933
+ mapRows: mapRowsToPerfMap,
1934
+ bundledFallback: bundledArchetypePerf
1935
+ });
1936
+ var loadArchetypePerfNFromBrain = createBrainQueryCache(
1937
+ {
1938
+ table: "kgauto_archetype_perf",
1939
+ mapRows: mapRowsToNMap,
1940
+ bundledFallback: bundledArchetypePerfN
1941
+ }
1942
+ );
1943
+ var MEASURED_GROUNDING_MIN_N = 10;
1944
+ function getArchetypePerfScore(modelId, archetype) {
1945
+ const score = loadArchetypePerfFromBrain().get(modelId)?.[archetype] ?? 5;
1946
+ const n = loadArchetypePerfNFromBrain().get(modelId)?.[archetype] ?? 0;
1947
+ const grounding = n >= MEASURED_GROUNDING_MIN_N ? "measured" : "judgment";
1948
+ return { score, n, grounding };
1949
+ }
1950
+
1951
+ // src/compatibility.ts
1952
+ var ARCHETYPE_FLOOR_DEFAULT = 6;
1953
+
1891
1954
  // src/fallback.ts
1955
+ var COST_RANKING_REFERENCE_SHAPE = {
1956
+ inputTokens: 4e3,
1957
+ outputTokens: 250
1958
+ };
1959
+ function estimateChainCostUsd(profile, shape = COST_RANKING_REFERENCE_SHAPE) {
1960
+ return shape.inputTokens / 1e6 * profile.costInputPer1m + shape.outputTokens / 1e6 * profile.costOutputPer1m;
1961
+ }
1962
+ function buildCostOrderedChain(archetype) {
1963
+ return allProfiles().filter((p) => p.status === "current").filter(
1964
+ (p) => getArchetypePerfScore(p.id, archetype).score >= ARCHETYPE_FLOOR_DEFAULT
1965
+ ).map((p) => ({ p, cost: estimateChainCostUsd(p) })).sort((a, b) => a.cost - b.cost || a.p.id.localeCompare(b.p.id)).map((e) => e.p.id);
1966
+ }
1892
1967
  var STARTER_CHAINS_GROUNDED = {
1893
1968
  // Reasoning floor — never degrade. Walk UP on 429 to Opus → cross-provider.
1894
1969
  critique: [
@@ -2025,19 +2100,28 @@ function resolveStarterForMode(archetype, toolOrchestration, allChains) {
2025
2100
  return allChains[archetype];
2026
2101
  }
2027
2102
  function getDefaultFallbackChain(opts) {
2028
- const { archetype, primary, maxDepth = 4, policy, reachability, toolOrchestration } = opts;
2103
+ const {
2104
+ archetype,
2105
+ primary,
2106
+ maxDepth = 4,
2107
+ policy,
2108
+ reachability,
2109
+ toolOrchestration,
2110
+ optimizeFor = "quality"
2111
+ } = opts;
2029
2112
  if (maxDepth < 1) {
2030
2113
  throw new Error(
2031
2114
  `getDefaultFallbackChain: maxDepth must be >= 1, got ${maxDepth}`
2032
2115
  );
2033
2116
  }
2034
2117
  const allChains = loadChainsFromBrain();
2035
- const starter = resolveStarterForMode(archetype, toolOrchestration, allChains);
2036
- if (!starter) {
2118
+ const qualityStarter = resolveStarterForMode(archetype, toolOrchestration, allChains);
2119
+ if (!qualityStarter) {
2037
2120
  throw new Error(
2038
2121
  `getDefaultFallbackChain: unknown archetype "${archetype}". Known: ${Object.keys(allChains).join(", ")}`
2039
2122
  );
2040
2123
  }
2124
+ const starter = optimizeFor === "cost" ? buildCostOrderedChain(archetype) : qualityStarter;
2041
2125
  let chain;
2042
2126
  if (primary) {
2043
2127
  chain = [primary, ...starter.filter((id) => id !== primary)];
@@ -2070,9 +2154,6 @@ function getAllStarterChains() {
2070
2154
  return out;
2071
2155
  }
2072
2156
 
2073
- // src/compatibility.ts
2074
- var ARCHETYPE_FLOOR_DEFAULT = 6;
2075
-
2076
2157
  // src/glassbox-routes/counterfactuals.ts
2077
2158
  var COUNTERFACTUAL_MIN_SAVINGS_RATIO = 0.1;
2078
2159
  var COUNTERFACTUAL_MAX_RESULTS = 2;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ARCHETYPE_FLOOR_DEFAULT,
3
3
  getDefaultFallbackChain
4
- } from "../chunk-FT2FN6ZP.mjs";
4
+ } from "../chunk-PMTT4H5W.mjs";
5
5
  import {
6
6
  tryGetProfile
7
7
  } from "../chunk-VVRDFE6T.mjs";
package/dist/index.d.mts CHANGED
@@ -1146,7 +1146,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
1146
1146
  * guard in `tests/version.test.ts` fails the suite (and therefore
1147
1147
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
1148
1148
  */
1149
- declare const LIBRARY_VERSION = "2.0.0-alpha.79";
1149
+ declare const LIBRARY_VERSION = "2.0.0-alpha.80";
1150
1150
 
1151
1151
  /**
1152
1152
  * Oracle contract — how an app tells the brain whether a response was good.
@@ -2391,12 +2391,35 @@ declare function readBrainReadEnv(envSource?: Record<string, string | undefined>
2391
2391
  * preferred — caller passes `primary`; chain returned is [primary, ...fallbacks]
2392
2392
  * open — caller passes no `primary`; chain returned is [best, ...fallbacks]
2393
2393
  *
2394
- * The chain at each step:
2395
- * 1. Costs strictly less than the previous (no expensive sideways moves)
2396
- * 2. Comes from a different provider than the previous step where possible
2394
+ * ## What the default chain optimizes for — READ THIS BEFORE CITING IT
2395
+ *
2396
+ * The default (`optimizeFor: 'quality'`) chain is ordered by **archetype
2397
+ * performance with provider diversity**, NOT by cost. It is a reliability
2398
+ * ladder: "if tier 0 fails, who else can do this job well."
2399
+ *
2400
+ * This docstring previously claimed each step "costs strictly less than the
2401
+ * previous." **That claim was false for all ten archetypes** (verified
2402
+ * 2026-07-29, alpha.80) and it was load-bearing — kgauto's own cost
2403
+ * advisories cited `posture: 'open'` as a cost remedy on the strength of it.
2404
+ * For `ask`, open posture leads with `claude-sonnet-4-6` at ~8.6x the cost
2405
+ * of the model the cost advisories recommend. tt-intel came within one
2406
+ * un-run function call of tripling their hottest path's spend by following
2407
+ * kgauto's own documented advice. See
2408
+ * `advisory/kgauto/from-tt-intelligence/2026-07-28_chain-builder-and-cost-advisories-give-opposite-answers.md`.
2409
+ *
2410
+ * Some non-monotone steps are deliberate and correct: `plan` walks UP to
2411
+ * Opus on 429, `critique`/`judge` never degrade below a reasoning floor,
2412
+ * and cross-provider anchors are chosen for outage-independence rather
2413
+ * than price. The defect was the unconditional claim, not the chains.
2414
+ *
2415
+ * The default chain at each step:
2416
+ * 1. Comes from a different provider than the previous step where possible
2397
2417
  * (correlated outages don't kill consecutive attempts)
2398
- * 3. Stays above the archetype's perf floor (skip models scored <baseline
2418
+ * 2. Stays above the archetype's perf floor (skip models scored <baseline
2399
2419
  * for archetypes where degradation would be unacceptable)
2420
+ * 3. Makes NO cost guarantee. Pass `optimizeFor: 'cost'` when cost order
2421
+ * is what you want — that mode DOES guarantee monotone-cheaper, and
2422
+ * `assertChainCostMonotonicity` pins it.
2400
2423
  *
2401
2424
  * In alpha.9 the chain is **hand-curated** per archetype (§3.3 starter
2402
2425
  * table). Brain-query mode lands in alpha.10. Policy.blockedModels filters
@@ -2475,7 +2498,58 @@ interface GetDefaultFallbackChainOpts {
2475
2498
  * pre-alpha.20 callers.
2476
2499
  */
2477
2500
  toolOrchestration?: 'parallel' | 'sequential' | 'either';
2501
+ /**
2502
+ * alpha.80 — what the chain ORDER optimizes for.
2503
+ *
2504
+ * 'quality' (default) — status quo, byte-for-byte. Hand-curated /
2505
+ * brain-loaded archetype ladder: best perf first, provider diversity
2506
+ * down the chain. Makes NO cost guarantee (see module docstring).
2507
+ *
2508
+ * 'cost' — cheapest-first among every `status: 'current'` model whose
2509
+ * `archetypePerf[archetype]` clears {@link ARCHETYPE_FLOOR_DEFAULT}.
2510
+ * Guarantees monotone-cheaper. Considers the WHOLE roster, not just
2511
+ * the curated chain — which is the point: `gemini-2.5-flash` ties
2512
+ * `claude-haiku-4-5` on `ask` perf at a third of the price and is
2513
+ * absent from the curated `ask` ladder entirely.
2514
+ *
2515
+ * The quality floor is what keeps 'cost' honest: a model with no evidence
2516
+ * scores the neutral 5 and is therefore excluded, so cost mode can never
2517
+ * bottom-feed into unmeasured models. Quality stays a binary floor; cost
2518
+ * optimizes only above it.
2519
+ *
2520
+ * Default 'quality' — existing consumers see zero change on bump.
2521
+ */
2522
+ optimizeFor?: 'quality' | 'cost';
2478
2523
  }
2524
+ /**
2525
+ * Reference call shape used to RANK models by cost. Deliberately a blend
2526
+ * rather than input-only: ranking by `costInputPer1m` alone (which the
2527
+ * advisor's `cost-mismatched-archetype` rule does) mis-orders any pair
2528
+ * whose output multiple differs, and real traffic runs input-heavy
2529
+ * (L-050: >85% input is the universal efficiency signal).
2530
+ *
2531
+ * This ranks; it does not bill. `estimateChainCostUsd` is exported so
2532
+ * callers who know their real shape can compute against it instead.
2533
+ */
2534
+ declare const COST_RANKING_REFERENCE_SHAPE: {
2535
+ readonly inputTokens: 4000;
2536
+ readonly outputTokens: 250;
2537
+ };
2538
+ /**
2539
+ * Estimated USD for one call at a given shape. Exported so the advisor and
2540
+ * consumer-side code share ONE derivation of "what does this model cost
2541
+ * here" — two independent derivations of one concept will drift (s75).
2542
+ */
2543
+ declare function estimateChainCostUsd(profile: ModelProfile, shape?: {
2544
+ inputTokens: number;
2545
+ outputTokens: number;
2546
+ }): number;
2547
+ /**
2548
+ * How many distinct providers a chain spans. `1` means every fallback shares
2549
+ * one provider's fate — the chain buys you retries, not outage independence.
2550
+ * Exported so a cost-mode consumer can check what they traded away.
2551
+ */
2552
+ declare function chainProviderSpread(chain: readonly string[]): number;
2479
2553
  /**
2480
2554
  * Returns the fallback chain for an archetype as a plain `string[]` of
2481
2555
  * model ids.
@@ -3680,4 +3754,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
3680
3754
  */
3681
3755
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
3682
3756
 
3683
- export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BRAIN_READ_ENV_NAMES, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
3757
+ export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BRAIN_READ_ENV_NAMES, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, COST_RANKING_REFERENCE_SHAPE, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, chainProviderSpread, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
package/dist/index.d.ts CHANGED
@@ -1146,7 +1146,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
1146
1146
  * guard in `tests/version.test.ts` fails the suite (and therefore
1147
1147
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
1148
1148
  */
1149
- declare const LIBRARY_VERSION = "2.0.0-alpha.79";
1149
+ declare const LIBRARY_VERSION = "2.0.0-alpha.80";
1150
1150
 
1151
1151
  /**
1152
1152
  * Oracle contract — how an app tells the brain whether a response was good.
@@ -2391,12 +2391,35 @@ declare function readBrainReadEnv(envSource?: Record<string, string | undefined>
2391
2391
  * preferred — caller passes `primary`; chain returned is [primary, ...fallbacks]
2392
2392
  * open — caller passes no `primary`; chain returned is [best, ...fallbacks]
2393
2393
  *
2394
- * The chain at each step:
2395
- * 1. Costs strictly less than the previous (no expensive sideways moves)
2396
- * 2. Comes from a different provider than the previous step where possible
2394
+ * ## What the default chain optimizes for — READ THIS BEFORE CITING IT
2395
+ *
2396
+ * The default (`optimizeFor: 'quality'`) chain is ordered by **archetype
2397
+ * performance with provider diversity**, NOT by cost. It is a reliability
2398
+ * ladder: "if tier 0 fails, who else can do this job well."
2399
+ *
2400
+ * This docstring previously claimed each step "costs strictly less than the
2401
+ * previous." **That claim was false for all ten archetypes** (verified
2402
+ * 2026-07-29, alpha.80) and it was load-bearing — kgauto's own cost
2403
+ * advisories cited `posture: 'open'` as a cost remedy on the strength of it.
2404
+ * For `ask`, open posture leads with `claude-sonnet-4-6` at ~8.6x the cost
2405
+ * of the model the cost advisories recommend. tt-intel came within one
2406
+ * un-run function call of tripling their hottest path's spend by following
2407
+ * kgauto's own documented advice. See
2408
+ * `advisory/kgauto/from-tt-intelligence/2026-07-28_chain-builder-and-cost-advisories-give-opposite-answers.md`.
2409
+ *
2410
+ * Some non-monotone steps are deliberate and correct: `plan` walks UP to
2411
+ * Opus on 429, `critique`/`judge` never degrade below a reasoning floor,
2412
+ * and cross-provider anchors are chosen for outage-independence rather
2413
+ * than price. The defect was the unconditional claim, not the chains.
2414
+ *
2415
+ * The default chain at each step:
2416
+ * 1. Comes from a different provider than the previous step where possible
2397
2417
  * (correlated outages don't kill consecutive attempts)
2398
- * 3. Stays above the archetype's perf floor (skip models scored <baseline
2418
+ * 2. Stays above the archetype's perf floor (skip models scored <baseline
2399
2419
  * for archetypes where degradation would be unacceptable)
2420
+ * 3. Makes NO cost guarantee. Pass `optimizeFor: 'cost'` when cost order
2421
+ * is what you want — that mode DOES guarantee monotone-cheaper, and
2422
+ * `assertChainCostMonotonicity` pins it.
2400
2423
  *
2401
2424
  * In alpha.9 the chain is **hand-curated** per archetype (§3.3 starter
2402
2425
  * table). Brain-query mode lands in alpha.10. Policy.blockedModels filters
@@ -2475,7 +2498,58 @@ interface GetDefaultFallbackChainOpts {
2475
2498
  * pre-alpha.20 callers.
2476
2499
  */
2477
2500
  toolOrchestration?: 'parallel' | 'sequential' | 'either';
2501
+ /**
2502
+ * alpha.80 — what the chain ORDER optimizes for.
2503
+ *
2504
+ * 'quality' (default) — status quo, byte-for-byte. Hand-curated /
2505
+ * brain-loaded archetype ladder: best perf first, provider diversity
2506
+ * down the chain. Makes NO cost guarantee (see module docstring).
2507
+ *
2508
+ * 'cost' — cheapest-first among every `status: 'current'` model whose
2509
+ * `archetypePerf[archetype]` clears {@link ARCHETYPE_FLOOR_DEFAULT}.
2510
+ * Guarantees monotone-cheaper. Considers the WHOLE roster, not just
2511
+ * the curated chain — which is the point: `gemini-2.5-flash` ties
2512
+ * `claude-haiku-4-5` on `ask` perf at a third of the price and is
2513
+ * absent from the curated `ask` ladder entirely.
2514
+ *
2515
+ * The quality floor is what keeps 'cost' honest: a model with no evidence
2516
+ * scores the neutral 5 and is therefore excluded, so cost mode can never
2517
+ * bottom-feed into unmeasured models. Quality stays a binary floor; cost
2518
+ * optimizes only above it.
2519
+ *
2520
+ * Default 'quality' — existing consumers see zero change on bump.
2521
+ */
2522
+ optimizeFor?: 'quality' | 'cost';
2478
2523
  }
2524
+ /**
2525
+ * Reference call shape used to RANK models by cost. Deliberately a blend
2526
+ * rather than input-only: ranking by `costInputPer1m` alone (which the
2527
+ * advisor's `cost-mismatched-archetype` rule does) mis-orders any pair
2528
+ * whose output multiple differs, and real traffic runs input-heavy
2529
+ * (L-050: >85% input is the universal efficiency signal).
2530
+ *
2531
+ * This ranks; it does not bill. `estimateChainCostUsd` is exported so
2532
+ * callers who know their real shape can compute against it instead.
2533
+ */
2534
+ declare const COST_RANKING_REFERENCE_SHAPE: {
2535
+ readonly inputTokens: 4000;
2536
+ readonly outputTokens: 250;
2537
+ };
2538
+ /**
2539
+ * Estimated USD for one call at a given shape. Exported so the advisor and
2540
+ * consumer-side code share ONE derivation of "what does this model cost
2541
+ * here" — two independent derivations of one concept will drift (s75).
2542
+ */
2543
+ declare function estimateChainCostUsd(profile: ModelProfile, shape?: {
2544
+ inputTokens: number;
2545
+ outputTokens: number;
2546
+ }): number;
2547
+ /**
2548
+ * How many distinct providers a chain spans. `1` means every fallback shares
2549
+ * one provider's fate — the chain buys you retries, not outage independence.
2550
+ * Exported so a cost-mode consumer can check what they traded away.
2551
+ */
2552
+ declare function chainProviderSpread(chain: readonly string[]): number;
2479
2553
  /**
2480
2554
  * Returns the fallback chain for an archetype as a plain `string[]` of
2481
2555
  * model ids.
@@ -3680,4 +3754,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
3680
3754
  */
3681
3755
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
3682
3756
 
3683
- export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BRAIN_READ_ENV_NAMES, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
3757
+ export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BRAIN_READ_ENV_NAMES, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, COST_RANKING_REFERENCE_SHAPE, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, chainProviderSpread, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };