@warmdrift/kgauto-compiler 2.0.0-alpha.41 → 2.0.0-alpha.43

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,6 +1,6 @@
1
1
  import {
2
2
  tryGetProfile
3
- } from "./chunk-JQGRWJZO.mjs";
3
+ } from "./chunk-ZHUD3I52.mjs";
4
4
 
5
5
  // src/brain-query.ts
6
6
  var FRESH_SNAPSHOT = {
@@ -313,6 +313,16 @@ function getReachabilityDiagnostic(opts = {}) {
313
313
  }
314
314
  return out;
315
315
  }
316
+ function readBrainReadEnv(envSource = defaultEnv()) {
317
+ const endpoint = readKeyValue(envSource.KGAUTO_V2_BRAIN_SUPABASE_URL) ?? readKeyValue(envSource.KGAUTO_V2_BRAIN_URL);
318
+ const jwt = readKeyValue(envSource.KGAUTO_V2_BRAIN_JWT) ?? readKeyValue(envSource.GLASSBOX_BRAIN_JWT);
319
+ const anonKey = readKeyValue(envSource.KGAUTO_V2_BRAIN_ANON_KEY);
320
+ const missingEnv = [];
321
+ if (!endpoint) missingEnv.push("KGAUTO_V2_BRAIN_SUPABASE_URL");
322
+ if (!jwt) missingEnv.push("KGAUTO_V2_BRAIN_JWT");
323
+ if (!anonKey) missingEnv.push("KGAUTO_V2_BRAIN_ANON_KEY");
324
+ return { endpoint, jwt, anonKey, missingEnv };
325
+ }
316
326
 
317
327
  // src/fallback.ts
318
328
  var STARTER_CHAINS_GROUNDED = {
@@ -670,6 +680,7 @@ export {
670
680
  isProviderReachable,
671
681
  isModelReachable,
672
682
  getReachabilityDiagnostic,
683
+ readBrainReadEnv,
673
684
  loadChainsFromBrain,
674
685
  getDefaultFallbackChain,
675
686
  getStarterChain,
@@ -562,7 +562,21 @@ var PROFILES_RAW = [
562
562
  critique: 4,
563
563
  hunt: 4
564
564
  // sequential tool calls only — L-040
565
- }
565
+ },
566
+ // alpha.43 — family-level conventions for the `deepseek-chat` family
567
+ // (V4-Flash + future non-thinking-mode members). V4-Flash struggles
568
+ // with summarize-archetype + structured-output: 3 of 4 schema-attempted
569
+ // PB calls (2026-05-18 + 2026-05-22) hit `structured_output_parse_failed`.
570
+ // Surface the friction at compile time so consumers either drop the
571
+ // schema or route to a more schema-reliable family.
572
+ archetypeConventions: [
573
+ {
574
+ archetype: "summarize",
575
+ structuredOutputHint: "avoid",
576
+ cliffWarning: "deepseek-chat family schema compliance on summarize is weak (3 of 4 schema-attempted PB calls hit structured_output_parse_failed). Consider routing summarize+structured-output to a different family (claude-sonnet, gemini-pro, openai-gpt-5.4) or dropping the schema for free-text summaries.",
577
+ reason: "Brain evidence: PB compile_outcomes 2026-05-18 + 2026-05-22, error_type=structured_output_parse_failed on deepseek-v4-flash + summarize archetype."
578
+ }
579
+ ]
566
580
  },
567
581
  {
568
582
  id: "deepseek-v4-pro",
@@ -613,7 +627,51 @@ var PROFILES_RAW = [
613
627
  transform: 6,
614
628
  hunt: 4
615
629
  // sequential tools — same as V4-Flash
616
- }
630
+ },
631
+ // alpha.43 — family-level conventions for the `deepseek-reasoner` family
632
+ // (V4-Pro is the family rep; future thinking-mode members inherit).
633
+ //
634
+ // The decisive-archetype suffix is the load-bearing piece: 2026-05-28
635
+ // first real V4-Pro probe on tt-intel/classify (exclusion-finding ID 20)
636
+ // showed 8/10 judge rationales citing "candidate hedges and fails to
637
+ // commit to a single classification" or "candidate refuses to pick
638
+ // among the labels." Without the forcing-function suffix, every
639
+ // reasoner probe on classify/extract/ask verdicts stay-excluded for
640
+ // model-behavior reasons (epistemic humility is reasoner-shaped),
641
+ // NOT quality reasons. The suffix re-shapes the contract so the model
642
+ // is asked for what it's actually being measured on.
643
+ //
644
+ // The hunt-archetype cliffWarning is the L-040 architectural reading
645
+ // surfaced at compile time. Reasoners produce sequential reasoning
646
+ // chains by design; hunt archetypes with 3+ parallel tools lose
647
+ // substantial throughput (L-040 + L-041). The L-040 cliff in the
648
+ // `cliffs` array already trims to top-relevant tools; this warning
649
+ // tells the consumer the family is wrong for the shape so they can
650
+ // route to gemini-flash (parallel-strong) instead of accepting trimmed
651
+ // throughput silently.
652
+ archetypeConventions: [
653
+ {
654
+ archetype: "classify",
655
+ promptSuffix: "\n\nOutput exactly one classification label. Do not hedge, do not add preamble, do not explain your reasoning. If uncertain, pick the most likely label and commit to it.",
656
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: 2026-05-28 V4-Pro probe on tt-intel/classify (exclusion-finding ID 20, brain probe_outcomes); 8 of 10 judge rationales cited hedging or refusal-to-commit. Forcing-function suffix converts reasoner output to decisive labels."
657
+ },
658
+ {
659
+ archetype: "extract",
660
+ promptSuffix: "\n\nOutput exactly the requested structured fields. Do not hedge, do not add preamble, do not explain your reasoning. If a field is unknown, emit the field with a null/empty value and commit to that \u2014 do not refuse to extract.",
661
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: same family failure shape as classify (exclusion-finding ID 20, 2026-05-28). Forcing-function suffix asks for commitment instead of epistemic-humility hedging."
662
+ },
663
+ {
664
+ archetype: "ask",
665
+ promptSuffix: "\n\nAnswer the question directly. Do not hedge, do not add preamble, do not explain your reasoning unless explicitly asked. If uncertain, give your best answer and commit to it.",
666
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: same family failure shape as classify (exclusion-finding ID 20, 2026-05-28). Forcing-function suffix asks for commitment instead of epistemic-humility hedging."
667
+ },
668
+ {
669
+ archetype: "hunt",
670
+ whenToolCountAtLeast: 3,
671
+ cliffWarning: "Reasoners (deepseek-reasoner family) produce sequential reasoning chains by design; hunt archetypes with 3+ parallel tools lose substantial throughput. Consider gemini-flash family (parallel-strong) instead \u2014 see L-040 / L-041.",
672
+ reason: "L-040 + L-041 architectural reading; 2026-05-28 V4-Pro probe evidence (exclusion-finding ID 20) confirms reasoner-family hunt fit is structurally weak."
673
+ }
674
+ ]
617
675
  },
618
676
  // ── OpenAI ──
619
677
  // alpha.16 (2026-05-17): close the half-supported provider gap. env.ts
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-MkiWUPM8.mjs';
2
- export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-MkiWUPM8.mjs';
3
- import '../ir-D_kgJcaV.mjs';
1
+ import { G as GlassboxEvent } from '../types-acFM2-iZ.mjs';
2
+ export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-acFM2-iZ.mjs';
3
+ import '../ir-CSgyol5D.mjs';
4
4
  import '../dialect.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-DigtHnEt.js';
2
- export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-DigtHnEt.js';
3
- import '../ir-DYpvUSEw.js';
1
+ import { G as GlassboxEvent } from '../types-_1tcDEqa.js';
2
+ export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-_1tcDEqa.js';
3
+ import '../ir-MN9bGclm.js';
4
4
  import '../dialect.js';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-CYY769Ls.mjs';
2
- import '../ir-D_kgJcaV.mjs';
1
+ import { T as TraceHealth } from '../types-M48csxKK.mjs';
2
+ import '../ir-CSgyol5D.mjs';
3
3
  import '../dialect.mjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-C8gOJ7hV.js';
2
- import '../ir-DYpvUSEw.js';
1
+ import { T as TraceHealth } from '../types-uRIiYY_y.js';
2
+ import '../ir-MN9bGclm.js';
3
3
  import '../dialect.js';
4
4
 
5
5
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-MkiWUPM8.mjs';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-CYY769Ls.mjs';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-CYY769Ls.mjs';
4
- import '../ir-D_kgJcaV.mjs';
1
+ import { G as GlassboxEvent } from '../types-acFM2-iZ.mjs';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-M48csxKK.mjs';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-M48csxKK.mjs';
4
+ import '../ir-CSgyol5D.mjs';
5
5
  import '../dialect.mjs';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-DigtHnEt.js';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-C8gOJ7hV.js';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-C8gOJ7hV.js';
4
- import '../ir-DYpvUSEw.js';
1
+ import { G as GlassboxEvent } from '../types-_1tcDEqa.js';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-uRIiYY_y.js';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-uRIiYY_y.js';
4
+ import '../ir-MN9bGclm.js';
5
5
  import '../dialect.js';
6
6
 
7
7
  /**
@@ -627,7 +627,21 @@ var PROFILES_RAW = [
627
627
  critique: 4,
628
628
  hunt: 4
629
629
  // sequential tool calls only — L-040
630
- }
630
+ },
631
+ // alpha.43 — family-level conventions for the `deepseek-chat` family
632
+ // (V4-Flash + future non-thinking-mode members). V4-Flash struggles
633
+ // with summarize-archetype + structured-output: 3 of 4 schema-attempted
634
+ // PB calls (2026-05-18 + 2026-05-22) hit `structured_output_parse_failed`.
635
+ // Surface the friction at compile time so consumers either drop the
636
+ // schema or route to a more schema-reliable family.
637
+ archetypeConventions: [
638
+ {
639
+ archetype: "summarize",
640
+ structuredOutputHint: "avoid",
641
+ cliffWarning: "deepseek-chat family schema compliance on summarize is weak (3 of 4 schema-attempted PB calls hit structured_output_parse_failed). Consider routing summarize+structured-output to a different family (claude-sonnet, gemini-pro, openai-gpt-5.4) or dropping the schema for free-text summaries.",
642
+ reason: "Brain evidence: PB compile_outcomes 2026-05-18 + 2026-05-22, error_type=structured_output_parse_failed on deepseek-v4-flash + summarize archetype."
643
+ }
644
+ ]
631
645
  },
632
646
  {
633
647
  id: "deepseek-v4-pro",
@@ -678,7 +692,51 @@ var PROFILES_RAW = [
678
692
  transform: 6,
679
693
  hunt: 4
680
694
  // sequential tools — same as V4-Flash
681
- }
695
+ },
696
+ // alpha.43 — family-level conventions for the `deepseek-reasoner` family
697
+ // (V4-Pro is the family rep; future thinking-mode members inherit).
698
+ //
699
+ // The decisive-archetype suffix is the load-bearing piece: 2026-05-28
700
+ // first real V4-Pro probe on tt-intel/classify (exclusion-finding ID 20)
701
+ // showed 8/10 judge rationales citing "candidate hedges and fails to
702
+ // commit to a single classification" or "candidate refuses to pick
703
+ // among the labels." Without the forcing-function suffix, every
704
+ // reasoner probe on classify/extract/ask verdicts stay-excluded for
705
+ // model-behavior reasons (epistemic humility is reasoner-shaped),
706
+ // NOT quality reasons. The suffix re-shapes the contract so the model
707
+ // is asked for what it's actually being measured on.
708
+ //
709
+ // The hunt-archetype cliffWarning is the L-040 architectural reading
710
+ // surfaced at compile time. Reasoners produce sequential reasoning
711
+ // chains by design; hunt archetypes with 3+ parallel tools lose
712
+ // substantial throughput (L-040 + L-041). The L-040 cliff in the
713
+ // `cliffs` array already trims to top-relevant tools; this warning
714
+ // tells the consumer the family is wrong for the shape so they can
715
+ // route to gemini-flash (parallel-strong) instead of accepting trimmed
716
+ // throughput silently.
717
+ archetypeConventions: [
718
+ {
719
+ archetype: "classify",
720
+ promptSuffix: "\n\nOutput exactly one classification label. Do not hedge, do not add preamble, do not explain your reasoning. If uncertain, pick the most likely label and commit to it.",
721
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: 2026-05-28 V4-Pro probe on tt-intel/classify (exclusion-finding ID 20, brain probe_outcomes); 8 of 10 judge rationales cited hedging or refusal-to-commit. Forcing-function suffix converts reasoner output to decisive labels."
722
+ },
723
+ {
724
+ archetype: "extract",
725
+ promptSuffix: "\n\nOutput exactly the requested structured fields. Do not hedge, do not add preamble, do not explain your reasoning. If a field is unknown, emit the field with a null/empty value and commit to that \u2014 do not refuse to extract.",
726
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: same family failure shape as classify (exclusion-finding ID 20, 2026-05-28). Forcing-function suffix asks for commitment instead of epistemic-humility hedging."
727
+ },
728
+ {
729
+ archetype: "ask",
730
+ promptSuffix: "\n\nAnswer the question directly. Do not hedge, do not add preamble, do not explain your reasoning unless explicitly asked. If uncertain, give your best answer and commit to it.",
731
+ reason: "Reasoners (deepseek-reasoner family) hedge on decisive-output archetypes by design. Evidence: same family failure shape as classify (exclusion-finding ID 20, 2026-05-28). Forcing-function suffix asks for commitment instead of epistemic-humility hedging."
732
+ },
733
+ {
734
+ archetype: "hunt",
735
+ whenToolCountAtLeast: 3,
736
+ cliffWarning: "Reasoners (deepseek-reasoner family) produce sequential reasoning chains by design; hunt archetypes with 3+ parallel tools lose substantial throughput. Consider gemini-flash family (parallel-strong) instead \u2014 see L-040 / L-041.",
737
+ reason: "L-040 + L-041 architectural reading; 2026-05-28 V4-Pro probe evidence (exclusion-finding ID 20) confirms reasoner-family hunt fit is structurally weak."
738
+ }
739
+ ]
682
740
  },
683
741
  // ── OpenAI ──
684
742
  // alpha.16 (2026-05-17): close the half-supported provider gap. env.ts
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  ARCHETYPE_FLOOR_DEFAULT,
3
3
  getDefaultFallbackChain
4
- } from "../chunk-XJZRDGHF.mjs";
4
+ } from "../chunk-6MSJQCAP.mjs";
5
5
  import {
6
6
  tryGetProfile
7
- } from "../chunk-JQGRWJZO.mjs";
7
+ } from "../chunk-ZHUD3I52.mjs";
8
8
  import {
9
9
  subscribe,
10
10
  subscribeApp
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as TraceDetail } from '../../types-CYY769Ls.mjs';
3
- import '../../ir-D_kgJcaV.mjs';
2
+ import { a as TraceDetail } from '../../types-M48csxKK.mjs';
3
+ import '../../ir-CSgyol5D.mjs';
4
4
  import '../../dialect.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as TraceDetail } from '../../types-C8gOJ7hV.js';
3
- import '../../ir-DYpvUSEw.js';
2
+ import { a as TraceDetail } from '../../types-uRIiYY_y.js';
3
+ import '../../ir-MN9bGclm.js';
4
4
  import '../../dialect.js';
5
5
 
6
6
  /**
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, S as SystemModelMessage, e as CompileResult, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, B as BestPracticeAdvisory, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-D_kgJcaV.mjs';
2
- export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, r as MutationApplied, s as NormalizedTokens, t as OutcomeKind, u as PerAxisMetricsByModel, v as PromptSection, w as SectionKind, T as ToolCall, x as ToolDefinition } from './ir-D_kgJcaV.mjs';
3
- import { ModelProfile } from './profiles.mjs';
1
+ import { C as CompilePolicy, N as NormalizedResponse, A as ApiKeys, P as ProviderOverrides, a as CompiledRequest, b as PromptIR, c as CallOptions, d as CallResult, S as SystemModelMessage, e as CompileResult, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, B as BestPracticeAdvisory, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-CSgyol5D.mjs';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, F as FallbackReason, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, r as MutationApplied, s as NormalizedTokens, t as OutcomeKind, u as PerAxisMetricsByModel, v as PromptSection, w as SectionKind, T as ToolCall, x as ToolDefinition } from './ir-CSgyol5D.mjs';
3
+ import { ModelProfile, ArchetypeConvention } from './profiles.mjs';
4
4
  export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.mjs';
5
5
  import { IntentArchetypeName } from './dialect.mjs';
6
6
  export { ALL_ARCHETYPES, ContextBucket, DIALECT_VERSION, HistoryDepth, INTENT_ARCHETYPES, OutputMode, ShapeSignature, ToolCountBucket, bucketContext, bucketHistory, bucketToolCount, hashShape, isArchetype, learningKey } from './dialect.mjs';
@@ -387,6 +387,34 @@ interface LLMJudgeOptions {
387
387
  */
388
388
  declare function buildLLMJudge(opts: LLMJudgeOptions): AppOracle;
389
389
 
390
+ /**
391
+ * Resolve the effective ArchetypeConvention[] for a given selected profile,
392
+ * walking family inheritance once. Model-specific entries on the selected
393
+ * profile take precedence over family-level entries for the same archetype.
394
+ *
395
+ * Pure; safe to call from any context (probe-watcher uses the same logic
396
+ * via `applyArchetypeConvention`).
397
+ */
398
+ declare function resolveConventionsForProfile(profile: ModelProfile): ArchetypeConvention[];
399
+ /**
400
+ * Pure helper: apply the matching ArchetypeConvention's suffix (and
401
+ * prefix, when meaningful) to a plain prompt-text string. Used by the
402
+ * exclusion-probe-watcher (`probeOne`) so probe calls carry the same
403
+ * forcing-function shape consumers see at compile time. Without this,
404
+ * every reasoner probe on a decisive archetype gets unfairly stay-excluded
405
+ * for hedging — as ID 20 demonstrated on 2026-05-28.
406
+ *
407
+ * Resolution: looks up the family-rep profile for `family` and reads its
408
+ * `archetypeConventions`. Returns the original text unchanged when no
409
+ * convention matches or when the suffix is already present.
410
+ *
411
+ * @param promptText raw user-prompt text (or prompt_preview from outcome)
412
+ * @param archetype intent_archetype from the finding row
413
+ * @param family family tag from deriveFamilyFromModelId / brain row
414
+ * @returns text with prefix/suffix applied (idempotent)
415
+ */
416
+ declare function applyArchetypeConvention(promptText: string, archetype: string, family: string): string;
417
+
390
418
  /**
391
419
  * Tokenizer abstraction.
392
420
  *
@@ -410,6 +438,75 @@ declare function resetTokenizer(): void;
410
438
  */
411
439
  declare function countTokens(text: string): number;
412
440
 
441
+ /**
442
+ * archetype-fits — alpha.43.
443
+ *
444
+ * Static table of "this archetype tends to be a better fit for this family"
445
+ * recommendations. Powers the `cross-family-fit-candidate` compile-time
446
+ * advisor (see `advisor-rules/cross-family-fit.ts`).
447
+ *
448
+ * Strategic framing (Sacha, 2026-05-28): "If we get better results and
449
+ * better price then we do. Even if volume is currently low, that's not an
450
+ * argument to not do it. Volume can increase quickly if tools is great to
451
+ * use, let's not create future bottlenecks because we could have wired in
452
+ * better solution at moment of knowing."
453
+ *
454
+ * The convention substrate (passApplyConventions) is the NEGATIVE side:
455
+ * make a family usable on archetypes it currently fails. This table is the
456
+ * POSITIVE side: actively surface that a different family is the better
457
+ * fit for the archetype's shape — even when current volume is low.
458
+ *
459
+ * Entries are added only when:
460
+ * - the archetype's shape and the family's behavior have a clear
461
+ * architectural fit (not vibes)
462
+ * - real-world evidence (brain rows, probe outcomes, or published
463
+ * benchmark) backs the claim, OR the reasoning is structurally so clear
464
+ * that "wait for volume" would create a future bottleneck
465
+ *
466
+ * Alpha.43 ships two entries — `plan` and `critique`. Both fit the
467
+ * reasoner-family architectural read: plan is multi-step reasoning;
468
+ * critique rewards epistemic humility and explicit reasoning. Other
469
+ * archetype-family-fits ride later alphas as evidence accumulates.
470
+ *
471
+ * Anti-pattern: do NOT add archetype-family-fits for archetypes where the
472
+ * fit is unclear (summarize, classify, extract, hunt with parallel tools).
473
+ * The advisor only earns trust when its recommendations land.
474
+ */
475
+
476
+ /**
477
+ * One archetype-family-fit recommendation. Read by the compile-time
478
+ * `cross-family-fit-candidate` advisor to decide when to surface a positive
479
+ * recommendation. The advisor pulls `costGuidance` verbatim into the
480
+ * advisory message.
481
+ */
482
+ interface ArchetypeFamilyFit {
483
+ /** Intent archetype this fit applies to. */
484
+ archetype: IntentArchetypeName;
485
+ /** Family tag that fits the archetype better than alternatives. Matches the
486
+ * same family taxonomy used by `family-resolution.deriveFamilyFromModelId`
487
+ * (e.g. `'deepseek-reasoner'`, `'gemini-flash'`, `'claude-opus'`). */
488
+ betterFitFamily: string;
489
+ /** Architectural / evidentiary justification. Appears in the advisor's
490
+ * internal logs and the advisory `evidence` payload, NOT verbatim in the
491
+ * consumer-facing message. */
492
+ reason: string;
493
+ /** Cost-context clause surfaced VERBATIM in the consumer-facing advisory
494
+ * message (e.g. "substantially cheaper at current pricing"). Keep
495
+ * declarative; the advisor wraps this into the larger sentence. */
496
+ costGuidance: string;
497
+ }
498
+ /**
499
+ * Frozen registry. Add entries by extending the array. Order is irrelevant
500
+ * — the advisor filters by `(archetype, currentFamily)` independently.
501
+ */
502
+ declare const ARCHETYPE_FAMILY_FITS: readonly ArchetypeFamilyFit[];
503
+ /**
504
+ * Pure lookup: does `(archetype, currentFamily)` have a better-fit family?
505
+ * Returns the fit entry when the current family is NOT the better fit; null
506
+ * otherwise. Used by the advisor to decide whether to fire.
507
+ */
508
+ declare function findBetterFit(archetype: string, currentFamily: string): ArchetypeFamilyFit | null;
509
+
413
510
  /**
414
511
  * Best-practice advisor — alpha.6 Phase 1.
415
512
  *
@@ -467,6 +564,31 @@ interface RunAdvisorPhase2Context {
467
564
  */
468
565
  sectionRewritesApplied?: SectionRewrite[];
469
566
  }
567
+ /**
568
+ * alpha.42 — rule codes whose advisories are positioned for kgauto (not
569
+ * the consumer) to act on. Used by `compile()` to default the `ownership`
570
+ * stamp on each advisory when the rule didn't self-declare. Consumer-side
571
+ * rules don't need to be listed — they default to `'consumer-actionable'`
572
+ * via fall-through.
573
+ *
574
+ * - `model-stale-evidence`: kgauto's profile data is out of date; the
575
+ * consumer can't fix that, kgauto needs to update profiles or refresh
576
+ * archetypePerf scores.
577
+ * - `promote-ready`: kgauto's promotion-probe-watcher detected a
578
+ * candidate model worth promoting; consumer-side adoption is downstream
579
+ * of kgauto adding it to the chain / family taxonomy.
580
+ *
581
+ * Frozen so consumers and tests can't mutate the global ownership map.
582
+ */
583
+ declare const PRODUCER_OWNED_RULE_CODES: ReadonlySet<string>;
584
+ /**
585
+ * alpha.42 — pure function used by `compile()` to decide ownership for an
586
+ * advisory. Rule-self-declared wins; falls back to the static map; defaults
587
+ * `consumer-actionable`. Exported so consumer-side code (or a Glass-Box
588
+ * renderer) can derive the same classification from a rule code alone
589
+ * without needing the advisory object.
590
+ */
591
+ declare function deriveOwnership(code: string, selfDeclared?: 'consumer-actionable' | 'producer-owned'): 'consumer-actionable' | 'producer-owned';
470
592
  /**
471
593
  * Run all phased rules and return collected advisories. Order is fixed so
472
594
  * output is stable across runs. The `policy` argument is alpha.9 — the
@@ -1152,6 +1274,71 @@ interface ProviderReachability {
1152
1274
  * Does NOT log the key value itself — only the env var name that supplied it.
1153
1275
  */
1154
1276
  declare function getReachabilityDiagnostic(opts?: ReachabilityOpts): Record<SupportedProvider, ProviderReachability>;
1277
+ /**
1278
+ * Brain-read env contract — canonical names + accepted fallbacks for the
1279
+ * env vars kgauto's brain-read APIs need.
1280
+ *
1281
+ * Affected APIs: `getActionableAdvisories`, `markAdvisoryResolved`,
1282
+ * `markExclusionFindingHandled`, `markPromoteReadyHandled`,
1283
+ * `getStaleExclusionFindings`, and future brain-read surfaces. Each accepts
1284
+ * `brainEndpoint`/`brainJwt`/`brainAnonKey` as call-site arguments; this
1285
+ * helper centralizes resolution from the consumer's environment.
1286
+ *
1287
+ * Resolution order (first-truthy-trimmed wins):
1288
+ * endpoint = KGAUTO_V2_BRAIN_SUPABASE_URL ?? KGAUTO_V2_BRAIN_URL
1289
+ * jwt = KGAUTO_V2_BRAIN_JWT ?? GLASSBOX_BRAIN_JWT
1290
+ * anonKey = KGAUTO_V2_BRAIN_ANON_KEY (no fallback)
1291
+ *
1292
+ * Why fallbacks exist:
1293
+ *
1294
+ * 1. Pre-alpha.42, some consumers set `KGAUTO_V2_BRAIN_URL` pointing at
1295
+ * the kgauto-dashboard URL (write target). The canonical
1296
+ * `KGAUTO_V2_BRAIN_SUPABASE_URL` is the Supabase project URL (read
1297
+ * target — PostgREST against `/rest/v1/`). Until consumers split the
1298
+ * two names, the fallback grabs whichever URL is set. When BOTH are
1299
+ * set, canonical wins (the consumer has explicitly split).
1300
+ *
1301
+ * 2. The s33 Glass-Box ship provisioned `GLASSBOX_BRAIN_JWT` across all
1302
+ * consumers with the same `app_id` claim shape, signed by the same
1303
+ * JWT_SECRET. Reusing it for brain-read avoids re-minting + re-pasting
1304
+ * a second JWT per consumer per surface.
1305
+ *
1306
+ * `missingEnv` lists the CANONICAL names that aren't satisfied by either
1307
+ * canonical OR fallback. Consumer policy: if `missingEnv.length > 0`,
1308
+ * render `not_configured`; otherwise pass `endpoint`/`jwt`/`anonKey` to
1309
+ * `getActionableAdvisories({ ... })` et al.
1310
+ *
1311
+ * Pre-trim semantics carry from `readKeyValue` — paste-newline-trap
1312
+ * (L-060 / L-083 / L-108) closure extends to brain env vars.
1313
+ *
1314
+ * Filed by tt-intel-Cairn (s89, 2026-05-27) after the s89 actionable-
1315
+ * advisories ref template hit `malformed brain response` on prod because
1316
+ * the endpoint env var pointed at the kgauto-dashboard URL instead of the
1317
+ * Supabase URL, AND because IC's ref template used a third env name
1318
+ * (`KGAUTO_V2_BRAIN_ENDPOINT`) that was unset. Three distinct name shapes
1319
+ * across two consumers — the durable closure is one canonical contract.
1320
+ */
1321
+ interface BrainReadEnv {
1322
+ /** Supabase project URL (PostgREST base). Undefined when neither canonical nor fallback is set. */
1323
+ endpoint?: string;
1324
+ /** JWT carrying `app_id` claim, signed by brain JWT_SECRET. Undefined when neither canonical nor fallback is set. */
1325
+ jwt?: string;
1326
+ /** Supabase anon (publishable) key. Undefined when not set. */
1327
+ anonKey?: string;
1328
+ /**
1329
+ * Canonical names not satisfied by either canonical OR fallback. Subset
1330
+ * (in order) of:
1331
+ * ['KGAUTO_V2_BRAIN_SUPABASE_URL', 'KGAUTO_V2_BRAIN_JWT', 'KGAUTO_V2_BRAIN_ANON_KEY']
1332
+ * Consumer policy: render `not_configured` when length > 0.
1333
+ */
1334
+ missingEnv: string[];
1335
+ }
1336
+ /**
1337
+ * Resolve brain-read env vars. Defaults to `process.env`; pass `envSource`
1338
+ * for hermetic tests. Trims surrounding whitespace and treats
1339
+ * empty-after-trim as unset (same shape as `resolveProviderKey`).
1340
+ */
1341
+ declare function readBrainReadEnv(envSource?: Record<string, string | undefined>): BrainReadEnv;
1155
1342
 
1156
1343
  /**
1157
1344
  * getDefaultFallbackChain — the alpha.9 cascading ship.
@@ -1932,4 +2119,4 @@ declare function markPromoteReadyHandled(opts: MarkPromoteReadyHandledOptions):
1932
2119
  */
1933
2120
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
1934
2121
 
1935
- export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, deriveFamilyFromModelId, execute, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isExclusionFindingsBrainActive, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, profileToRow, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
2122
+ 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, BestPracticeAdvisory, type BrainConfig, type BrainQueryConfig, type BrainReadEnv, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetDefaultFallbackChainOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, Grounding, IntentArchetypeName, type LLMJudgeOptions, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type SupportedProvider, SystemModelMessage, TRANSLATOR_FLOOR, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isBrainQueryActiveFor, isExclusionFindingsBrainActive, isModelReachable, isProviderReachable, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, profileToRow, readBrainReadEnv, record, recordOutcome, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };