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

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.
@@ -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,
@@ -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-eKKDeADI.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-eKKDeADI.mjs';
3
+ import '../ir-BG70lg9b.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-Cs_hsBGm.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-Cs_hsBGm.js';
3
+ import '../ir-BmumS1Du.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-DIl0tCDX.mjs';
2
+ import '../ir-BG70lg9b.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-kFsIDC_5.js';
2
+ import '../ir-BmumS1Du.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-eKKDeADI.mjs';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-DIl0tCDX.mjs';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-DIl0tCDX.mjs';
4
+ import '../ir-BG70lg9b.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-Cs_hsBGm.js';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-kFsIDC_5.js';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-kFsIDC_5.js';
4
+ import '../ir-BmumS1Du.js';
5
5
  import '../dialect.js';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ARCHETYPE_FLOOR_DEFAULT,
3
3
  getDefaultFallbackChain
4
- } from "../chunk-XJZRDGHF.mjs";
4
+ } from "../chunk-KCNQUMHN.mjs";
5
5
  import {
6
6
  tryGetProfile
7
7
  } from "../chunk-JQGRWJZO.mjs";
@@ -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-DIl0tCDX.mjs';
3
+ import '../../ir-BG70lg9b.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-kFsIDC_5.js';
3
+ import '../../ir-BmumS1Du.js';
4
4
  import '../../dialect.js';
5
5
 
6
6
  /**
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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';
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-BG70lg9b.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-BG70lg9b.mjs';
3
3
  import { ModelProfile } 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';
@@ -467,6 +467,31 @@ interface RunAdvisorPhase2Context {
467
467
  */
468
468
  sectionRewritesApplied?: SectionRewrite[];
469
469
  }
470
+ /**
471
+ * alpha.42 — rule codes whose advisories are positioned for kgauto (not
472
+ * the consumer) to act on. Used by `compile()` to default the `ownership`
473
+ * stamp on each advisory when the rule didn't self-declare. Consumer-side
474
+ * rules don't need to be listed — they default to `'consumer-actionable'`
475
+ * via fall-through.
476
+ *
477
+ * - `model-stale-evidence`: kgauto's profile data is out of date; the
478
+ * consumer can't fix that, kgauto needs to update profiles or refresh
479
+ * archetypePerf scores.
480
+ * - `promote-ready`: kgauto's promotion-probe-watcher detected a
481
+ * candidate model worth promoting; consumer-side adoption is downstream
482
+ * of kgauto adding it to the chain / family taxonomy.
483
+ *
484
+ * Frozen so consumers and tests can't mutate the global ownership map.
485
+ */
486
+ declare const PRODUCER_OWNED_RULE_CODES: ReadonlySet<string>;
487
+ /**
488
+ * alpha.42 — pure function used by `compile()` to decide ownership for an
489
+ * advisory. Rule-self-declared wins; falls back to the static map; defaults
490
+ * `consumer-actionable`. Exported so consumer-side code (or a Glass-Box
491
+ * renderer) can derive the same classification from a rule code alone
492
+ * without needing the advisory object.
493
+ */
494
+ declare function deriveOwnership(code: string, selfDeclared?: 'consumer-actionable' | 'producer-owned'): 'consumer-actionable' | 'producer-owned';
470
495
  /**
471
496
  * Run all phased rules and return collected advisories. Order is fixed so
472
497
  * output is stable across runs. The `policy` argument is alpha.9 — the
@@ -1152,6 +1177,71 @@ interface ProviderReachability {
1152
1177
  * Does NOT log the key value itself — only the env var name that supplied it.
1153
1178
  */
1154
1179
  declare function getReachabilityDiagnostic(opts?: ReachabilityOpts): Record<SupportedProvider, ProviderReachability>;
1180
+ /**
1181
+ * Brain-read env contract — canonical names + accepted fallbacks for the
1182
+ * env vars kgauto's brain-read APIs need.
1183
+ *
1184
+ * Affected APIs: `getActionableAdvisories`, `markAdvisoryResolved`,
1185
+ * `markExclusionFindingHandled`, `markPromoteReadyHandled`,
1186
+ * `getStaleExclusionFindings`, and future brain-read surfaces. Each accepts
1187
+ * `brainEndpoint`/`brainJwt`/`brainAnonKey` as call-site arguments; this
1188
+ * helper centralizes resolution from the consumer's environment.
1189
+ *
1190
+ * Resolution order (first-truthy-trimmed wins):
1191
+ * endpoint = KGAUTO_V2_BRAIN_SUPABASE_URL ?? KGAUTO_V2_BRAIN_URL
1192
+ * jwt = KGAUTO_V2_BRAIN_JWT ?? GLASSBOX_BRAIN_JWT
1193
+ * anonKey = KGAUTO_V2_BRAIN_ANON_KEY (no fallback)
1194
+ *
1195
+ * Why fallbacks exist:
1196
+ *
1197
+ * 1. Pre-alpha.42, some consumers set `KGAUTO_V2_BRAIN_URL` pointing at
1198
+ * the kgauto-dashboard URL (write target). The canonical
1199
+ * `KGAUTO_V2_BRAIN_SUPABASE_URL` is the Supabase project URL (read
1200
+ * target — PostgREST against `/rest/v1/`). Until consumers split the
1201
+ * two names, the fallback grabs whichever URL is set. When BOTH are
1202
+ * set, canonical wins (the consumer has explicitly split).
1203
+ *
1204
+ * 2. The s33 Glass-Box ship provisioned `GLASSBOX_BRAIN_JWT` across all
1205
+ * consumers with the same `app_id` claim shape, signed by the same
1206
+ * JWT_SECRET. Reusing it for brain-read avoids re-minting + re-pasting
1207
+ * a second JWT per consumer per surface.
1208
+ *
1209
+ * `missingEnv` lists the CANONICAL names that aren't satisfied by either
1210
+ * canonical OR fallback. Consumer policy: if `missingEnv.length > 0`,
1211
+ * render `not_configured`; otherwise pass `endpoint`/`jwt`/`anonKey` to
1212
+ * `getActionableAdvisories({ ... })` et al.
1213
+ *
1214
+ * Pre-trim semantics carry from `readKeyValue` — paste-newline-trap
1215
+ * (L-060 / L-083 / L-108) closure extends to brain env vars.
1216
+ *
1217
+ * Filed by tt-intel-Cairn (s89, 2026-05-27) after the s89 actionable-
1218
+ * advisories ref template hit `malformed brain response` on prod because
1219
+ * the endpoint env var pointed at the kgauto-dashboard URL instead of the
1220
+ * Supabase URL, AND because IC's ref template used a third env name
1221
+ * (`KGAUTO_V2_BRAIN_ENDPOINT`) that was unset. Three distinct name shapes
1222
+ * across two consumers — the durable closure is one canonical contract.
1223
+ */
1224
+ interface BrainReadEnv {
1225
+ /** Supabase project URL (PostgREST base). Undefined when neither canonical nor fallback is set. */
1226
+ endpoint?: string;
1227
+ /** JWT carrying `app_id` claim, signed by brain JWT_SECRET. Undefined when neither canonical nor fallback is set. */
1228
+ jwt?: string;
1229
+ /** Supabase anon (publishable) key. Undefined when not set. */
1230
+ anonKey?: string;
1231
+ /**
1232
+ * Canonical names not satisfied by either canonical OR fallback. Subset
1233
+ * (in order) of:
1234
+ * ['KGAUTO_V2_BRAIN_SUPABASE_URL', 'KGAUTO_V2_BRAIN_JWT', 'KGAUTO_V2_BRAIN_ANON_KEY']
1235
+ * Consumer policy: render `not_configured` when length > 0.
1236
+ */
1237
+ missingEnv: string[];
1238
+ }
1239
+ /**
1240
+ * Resolve brain-read env vars. Defaults to `process.env`; pass `envSource`
1241
+ * for hermetic tests. Trims surrounding whitespace and treats
1242
+ * empty-after-trim as unset (same shape as `resolveProviderKey`).
1243
+ */
1244
+ declare function readBrainReadEnv(envSource?: Record<string, string | undefined>): BrainReadEnv;
1155
1245
 
1156
1246
  /**
1157
1247
  * getDefaultFallbackChain — the alpha.9 cascading ship.
@@ -1932,4 +2022,4 @@ declare function markPromoteReadyHandled(opts: MarkPromoteReadyHandledOptions):
1932
2022
  */
1933
2023
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
1934
2024
 
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 };
2025
+ 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, 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, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, 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, readBrainReadEnv, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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-DYpvUSEw.js';
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-DYpvUSEw.js';
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-BmumS1Du.js';
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-BmumS1Du.js';
3
3
  import { ModelProfile } from './profiles.js';
4
4
  export { ALIASES, CacheStrategy, CliffRule, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, profilesByProvider, tryGetProfile } from './profiles.js';
5
5
  import { IntentArchetypeName } from './dialect.js';
@@ -467,6 +467,31 @@ interface RunAdvisorPhase2Context {
467
467
  */
468
468
  sectionRewritesApplied?: SectionRewrite[];
469
469
  }
470
+ /**
471
+ * alpha.42 — rule codes whose advisories are positioned for kgauto (not
472
+ * the consumer) to act on. Used by `compile()` to default the `ownership`
473
+ * stamp on each advisory when the rule didn't self-declare. Consumer-side
474
+ * rules don't need to be listed — they default to `'consumer-actionable'`
475
+ * via fall-through.
476
+ *
477
+ * - `model-stale-evidence`: kgauto's profile data is out of date; the
478
+ * consumer can't fix that, kgauto needs to update profiles or refresh
479
+ * archetypePerf scores.
480
+ * - `promote-ready`: kgauto's promotion-probe-watcher detected a
481
+ * candidate model worth promoting; consumer-side adoption is downstream
482
+ * of kgauto adding it to the chain / family taxonomy.
483
+ *
484
+ * Frozen so consumers and tests can't mutate the global ownership map.
485
+ */
486
+ declare const PRODUCER_OWNED_RULE_CODES: ReadonlySet<string>;
487
+ /**
488
+ * alpha.42 — pure function used by `compile()` to decide ownership for an
489
+ * advisory. Rule-self-declared wins; falls back to the static map; defaults
490
+ * `consumer-actionable`. Exported so consumer-side code (or a Glass-Box
491
+ * renderer) can derive the same classification from a rule code alone
492
+ * without needing the advisory object.
493
+ */
494
+ declare function deriveOwnership(code: string, selfDeclared?: 'consumer-actionable' | 'producer-owned'): 'consumer-actionable' | 'producer-owned';
470
495
  /**
471
496
  * Run all phased rules and return collected advisories. Order is fixed so
472
497
  * output is stable across runs. The `policy` argument is alpha.9 — the
@@ -1152,6 +1177,71 @@ interface ProviderReachability {
1152
1177
  * Does NOT log the key value itself — only the env var name that supplied it.
1153
1178
  */
1154
1179
  declare function getReachabilityDiagnostic(opts?: ReachabilityOpts): Record<SupportedProvider, ProviderReachability>;
1180
+ /**
1181
+ * Brain-read env contract — canonical names + accepted fallbacks for the
1182
+ * env vars kgauto's brain-read APIs need.
1183
+ *
1184
+ * Affected APIs: `getActionableAdvisories`, `markAdvisoryResolved`,
1185
+ * `markExclusionFindingHandled`, `markPromoteReadyHandled`,
1186
+ * `getStaleExclusionFindings`, and future brain-read surfaces. Each accepts
1187
+ * `brainEndpoint`/`brainJwt`/`brainAnonKey` as call-site arguments; this
1188
+ * helper centralizes resolution from the consumer's environment.
1189
+ *
1190
+ * Resolution order (first-truthy-trimmed wins):
1191
+ * endpoint = KGAUTO_V2_BRAIN_SUPABASE_URL ?? KGAUTO_V2_BRAIN_URL
1192
+ * jwt = KGAUTO_V2_BRAIN_JWT ?? GLASSBOX_BRAIN_JWT
1193
+ * anonKey = KGAUTO_V2_BRAIN_ANON_KEY (no fallback)
1194
+ *
1195
+ * Why fallbacks exist:
1196
+ *
1197
+ * 1. Pre-alpha.42, some consumers set `KGAUTO_V2_BRAIN_URL` pointing at
1198
+ * the kgauto-dashboard URL (write target). The canonical
1199
+ * `KGAUTO_V2_BRAIN_SUPABASE_URL` is the Supabase project URL (read
1200
+ * target — PostgREST against `/rest/v1/`). Until consumers split the
1201
+ * two names, the fallback grabs whichever URL is set. When BOTH are
1202
+ * set, canonical wins (the consumer has explicitly split).
1203
+ *
1204
+ * 2. The s33 Glass-Box ship provisioned `GLASSBOX_BRAIN_JWT` across all
1205
+ * consumers with the same `app_id` claim shape, signed by the same
1206
+ * JWT_SECRET. Reusing it for brain-read avoids re-minting + re-pasting
1207
+ * a second JWT per consumer per surface.
1208
+ *
1209
+ * `missingEnv` lists the CANONICAL names that aren't satisfied by either
1210
+ * canonical OR fallback. Consumer policy: if `missingEnv.length > 0`,
1211
+ * render `not_configured`; otherwise pass `endpoint`/`jwt`/`anonKey` to
1212
+ * `getActionableAdvisories({ ... })` et al.
1213
+ *
1214
+ * Pre-trim semantics carry from `readKeyValue` — paste-newline-trap
1215
+ * (L-060 / L-083 / L-108) closure extends to brain env vars.
1216
+ *
1217
+ * Filed by tt-intel-Cairn (s89, 2026-05-27) after the s89 actionable-
1218
+ * advisories ref template hit `malformed brain response` on prod because
1219
+ * the endpoint env var pointed at the kgauto-dashboard URL instead of the
1220
+ * Supabase URL, AND because IC's ref template used a third env name
1221
+ * (`KGAUTO_V2_BRAIN_ENDPOINT`) that was unset. Three distinct name shapes
1222
+ * across two consumers — the durable closure is one canonical contract.
1223
+ */
1224
+ interface BrainReadEnv {
1225
+ /** Supabase project URL (PostgREST base). Undefined when neither canonical nor fallback is set. */
1226
+ endpoint?: string;
1227
+ /** JWT carrying `app_id` claim, signed by brain JWT_SECRET. Undefined when neither canonical nor fallback is set. */
1228
+ jwt?: string;
1229
+ /** Supabase anon (publishable) key. Undefined when not set. */
1230
+ anonKey?: string;
1231
+ /**
1232
+ * Canonical names not satisfied by either canonical OR fallback. Subset
1233
+ * (in order) of:
1234
+ * ['KGAUTO_V2_BRAIN_SUPABASE_URL', 'KGAUTO_V2_BRAIN_JWT', 'KGAUTO_V2_BRAIN_ANON_KEY']
1235
+ * Consumer policy: render `not_configured` when length > 0.
1236
+ */
1237
+ missingEnv: string[];
1238
+ }
1239
+ /**
1240
+ * Resolve brain-read env vars. Defaults to `process.env`; pass `envSource`
1241
+ * for hermetic tests. Trims surrounding whitespace and treats
1242
+ * empty-after-trim as unset (same shape as `resolveProviderKey`).
1243
+ */
1244
+ declare function readBrainReadEnv(envSource?: Record<string, string | undefined>): BrainReadEnv;
1155
1245
 
1156
1246
  /**
1157
1247
  * getDefaultFallbackChain — the alpha.9 cascading ship.
@@ -1932,4 +2022,4 @@ declare function markPromoteReadyHandled(opts: MarkPromoteReadyHandledOptions):
1932
2022
  */
1933
2023
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
1934
2024
 
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 };
2025
+ 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, 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, applySectionRewrites, attachCacheControlToStreamTextInput, buildLLMJudge, call, clearBrain, compile, configureBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, 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, readBrainReadEnv, record, recordOutcome, resetTokenizer, resolvePricingAt, resolveProviderKey, runAdvisor, setTokenizer };
package/dist/index.js CHANGED
@@ -30,6 +30,7 @@ __export(index_exports, {
30
30
  FamilyResolutionError: () => FamilyResolutionError,
31
31
  INTENT_ARCHETYPES: () => INTENT_ARCHETYPES,
32
32
  MEASURED_GROUNDING_MIN_N: () => MEASURED_GROUNDING_MIN_N,
33
+ PRODUCER_OWNED_RULE_CODES: () => PRODUCER_OWNED_RULE_CODES,
33
34
  PROVIDER_ENV_KEYS: () => PROVIDER_ENV_KEYS,
34
35
  RULE_SEQUENTIAL_TOOL_CLIFF: () => RULE_SEQUENTIAL_TOOL_CLIFF,
35
36
  TRANSLATOR_FLOOR: () => TRANSLATOR_FLOOR,
@@ -46,6 +47,7 @@ __export(index_exports, {
46
47
  configureBrain: () => configureBrain,
47
48
  countTokens: () => countTokens,
48
49
  deriveFamilyFromModelId: () => deriveFamilyFromModelId,
50
+ deriveOwnership: () => deriveOwnership,
49
51
  execute: () => execute,
50
52
  getActionableAdvisories: () => getActionableAdvisories,
51
53
  getAllStarterChains: () => getAllStarterChains,
@@ -81,6 +83,7 @@ __export(index_exports, {
81
83
  markPromoteReadyHandled: () => markPromoteReadyHandled,
82
84
  profileToRow: () => profileToRow,
83
85
  profilesByProvider: () => profilesByProvider,
86
+ readBrainReadEnv: () => readBrainReadEnv,
84
87
  record: () => record,
85
88
  recordOutcome: () => recordOutcome,
86
89
  resetTokenizer: () => resetTokenizer,
@@ -2919,6 +2922,13 @@ function advisorRuleConsumerOnStaleModel(ir) {
2919
2922
  var QUALITY_FLOOR_FOR_RECOMMENDATION = 6;
2920
2923
  var TIER_DOWN_COST_RATIO = 0.5;
2921
2924
  var COST_MISMATCHED_CHOSEN_SCORE_CEILING = 7;
2925
+ var PRODUCER_OWNED_RULE_CODES = Object.freeze(
2926
+ /* @__PURE__ */ new Set(["model-stale-evidence", "promote-ready"])
2927
+ );
2928
+ function deriveOwnership(code, selfDeclared) {
2929
+ if (selfDeclared) return selfDeclared;
2930
+ return PRODUCER_OWNED_RULE_CODES.has(code) ? "producer-owned" : "consumer-actionable";
2931
+ }
2922
2932
  function runAdvisor(ir, result, profile, policy, phase2) {
2923
2933
  const out = [];
2924
2934
  out.push(...detectCachingOff(ir, profile));
@@ -3625,7 +3635,7 @@ function compile(ir, opts = {}) {
3625
3635
  return void 0;
3626
3636
  }
3627
3637
  } : tryGetProfile;
3628
- const advisories = runAdvisor(
3638
+ const rawAdvisories = runAdvisor(
3629
3639
  ir,
3630
3640
  {
3631
3641
  target: profile.id,
@@ -3646,6 +3656,11 @@ function compile(ir, opts = {}) {
3646
3656
  sectionRewritesApplied
3647
3657
  }
3648
3658
  );
3659
+ const advisories = rawAdvisories.map((a) => ({
3660
+ ...a,
3661
+ kgautoRequestId: handle,
3662
+ ownership: deriveOwnership(a.code, a.ownership)
3663
+ }));
3649
3664
  return {
3650
3665
  handle,
3651
3666
  target: profile.id,
@@ -4211,6 +4226,16 @@ function getReachabilityDiagnostic(opts = {}) {
4211
4226
  }
4212
4227
  return out;
4213
4228
  }
4229
+ function readBrainReadEnv(envSource = defaultEnv()) {
4230
+ const endpoint = readKeyValue(envSource.KGAUTO_V2_BRAIN_SUPABASE_URL) ?? readKeyValue(envSource.KGAUTO_V2_BRAIN_URL);
4231
+ const jwt = readKeyValue(envSource.KGAUTO_V2_BRAIN_JWT) ?? readKeyValue(envSource.GLASSBOX_BRAIN_JWT);
4232
+ const anonKey = readKeyValue(envSource.KGAUTO_V2_BRAIN_ANON_KEY);
4233
+ const missingEnv = [];
4234
+ if (!endpoint) missingEnv.push("KGAUTO_V2_BRAIN_SUPABASE_URL");
4235
+ if (!jwt) missingEnv.push("KGAUTO_V2_BRAIN_JWT");
4236
+ if (!anonKey) missingEnv.push("KGAUTO_V2_BRAIN_ANON_KEY");
4237
+ return { endpoint, jwt, anonKey, missingEnv };
4238
+ }
4214
4239
 
4215
4240
  // src/streaming.ts
4216
4241
  var ANTHROPIC_URL = "https://api.anthropic.com/v1/messages";
@@ -6200,6 +6225,7 @@ function compile2(ir, opts) {
6200
6225
  FamilyResolutionError,
6201
6226
  INTENT_ARCHETYPES,
6202
6227
  MEASURED_GROUNDING_MIN_N,
6228
+ PRODUCER_OWNED_RULE_CODES,
6203
6229
  PROVIDER_ENV_KEYS,
6204
6230
  RULE_SEQUENTIAL_TOOL_CLIFF,
6205
6231
  TRANSLATOR_FLOOR,
@@ -6216,6 +6242,7 @@ function compile2(ir, opts) {
6216
6242
  configureBrain,
6217
6243
  countTokens,
6218
6244
  deriveFamilyFromModelId,
6245
+ deriveOwnership,
6219
6246
  execute,
6220
6247
  getActionableAdvisories,
6221
6248
  getAllStarterChains,
@@ -6251,6 +6278,7 @@ function compile2(ir, opts) {
6251
6278
  markPromoteReadyHandled,
6252
6279
  profileToRow,
6253
6280
  profilesByProvider,
6281
+ readBrainReadEnv,
6254
6282
  record,
6255
6283
  recordOutcome,
6256
6284
  resetTokenizer,
package/dist/index.mjs CHANGED
@@ -31,8 +31,9 @@ import {
31
31
  isModelReachable,
32
32
  isProviderReachable,
33
33
  loadChainsFromBrain,
34
+ readBrainReadEnv,
34
35
  resolveProviderKey
35
- } from "./chunk-XJZRDGHF.mjs";
36
+ } from "./chunk-KCNQUMHN.mjs";
36
37
  import {
37
38
  ALIASES,
38
39
  _setProfileBrainHook,
@@ -1336,6 +1337,13 @@ function advisorRuleConsumerOnStaleModel(ir) {
1336
1337
  var QUALITY_FLOOR_FOR_RECOMMENDATION = 6;
1337
1338
  var TIER_DOWN_COST_RATIO = 0.5;
1338
1339
  var COST_MISMATCHED_CHOSEN_SCORE_CEILING = 7;
1340
+ var PRODUCER_OWNED_RULE_CODES = Object.freeze(
1341
+ /* @__PURE__ */ new Set(["model-stale-evidence", "promote-ready"])
1342
+ );
1343
+ function deriveOwnership(code, selfDeclared) {
1344
+ if (selfDeclared) return selfDeclared;
1345
+ return PRODUCER_OWNED_RULE_CODES.has(code) ? "producer-owned" : "consumer-actionable";
1346
+ }
1339
1347
  function runAdvisor(ir, result, profile, policy, phase2) {
1340
1348
  const out = [];
1341
1349
  out.push(...detectCachingOff(ir, profile));
@@ -2042,7 +2050,7 @@ function compile(ir, opts = {}) {
2042
2050
  return void 0;
2043
2051
  }
2044
2052
  } : tryGetProfile;
2045
- const advisories = runAdvisor(
2053
+ const rawAdvisories = runAdvisor(
2046
2054
  ir,
2047
2055
  {
2048
2056
  target: profile.id,
@@ -2063,6 +2071,11 @@ function compile(ir, opts = {}) {
2063
2071
  sectionRewritesApplied
2064
2072
  }
2065
2073
  );
2074
+ const advisories = rawAdvisories.map((a) => ({
2075
+ ...a,
2076
+ kgautoRequestId: handle,
2077
+ ownership: deriveOwnership(a.code, a.ownership)
2078
+ }));
2066
2079
  return {
2067
2080
  handle,
2068
2081
  target: profile.id,
@@ -3911,6 +3924,7 @@ export {
3911
3924
  FamilyResolutionError,
3912
3925
  INTENT_ARCHETYPES,
3913
3926
  MEASURED_GROUNDING_MIN_N,
3927
+ PRODUCER_OWNED_RULE_CODES,
3914
3928
  PROVIDER_ENV_KEYS,
3915
3929
  RULE_SEQUENTIAL_TOOL_CLIFF,
3916
3930
  TRANSLATOR_FLOOR,
@@ -3927,6 +3941,7 @@ export {
3927
3941
  configureBrain,
3928
3942
  countTokens,
3929
3943
  deriveFamilyFromModelId,
3944
+ deriveOwnership,
3930
3945
  execute,
3931
3946
  getActionableAdvisories,
3932
3947
  getAllStarterChains,
@@ -3962,6 +3977,7 @@ export {
3962
3977
  markPromoteReadyHandled,
3963
3978
  profileToRow,
3964
3979
  profilesByProvider,
3980
+ readBrainReadEnv,
3965
3981
  record,
3966
3982
  recordOutcome,
3967
3983
  resetTokenizer,
@@ -471,6 +471,38 @@ interface BestPracticeAdvisory {
471
471
  * MUST type to the same union. Phase 2 integration verifies.
472
472
  */
473
473
  suggestedAdaptation?: Adapter;
474
+ /**
475
+ * alpha.42 — the kgauto request handle that produced this advisory. Stamped
476
+ * by `compile()` after `runAdvisor()` returns, sourced from
477
+ * `CompileResult.handle`. Lets a consumer's admin UI pivot from advisory
478
+ * row → original trace (Glass-Box card, brain `compile_outcomes` lookup).
479
+ *
480
+ * Absent when the advisory was constructed outside the full `compile()`
481
+ * pipeline (e.g., a direct `runAdvisor()` call in tests). Always present
482
+ * on advisories returned from `compile().advisories`.
483
+ */
484
+ kgautoRequestId?: string;
485
+ /**
486
+ * alpha.42 — who is positioned to act on this advisory.
487
+ *
488
+ * - `'consumer-actionable'` (Class A): the consumer can fix this by
489
+ * changing their wire-up — add `cacheable: true` markers, swap their
490
+ * model literal, declare a section, etc. The admin UI should surface
491
+ * a one-click apply or a "fix it" CTA.
492
+ * - `'producer-owned'` (Class B): kgauto needs to ship a code or data
493
+ * change — update a profile, promote a model in the chain, fix a
494
+ * wire contract. The admin UI should surface this as informational
495
+ * ("kgauto is on it") and not present a consumer-side action.
496
+ *
497
+ * Stamped by `compile()` after `runAdvisor()` returns. Rules can self-
498
+ * declare via the matching field on their return; otherwise the stamp
499
+ * consults the static `PRODUCER_OWNED_RULE_CODES` set in `advisor.ts`,
500
+ * defaulting to `'consumer-actionable'` when the code isn't listed.
501
+ *
502
+ * Closes the s47 dogfood gap where the tt-intel admin UI conflated the
503
+ * two classes — consumers couldn't tell whether they should act or wait.
504
+ */
505
+ ownership?: 'consumer-actionable' | 'producer-owned';
474
506
  }
475
507
  /**
476
508
  * alpha.28 — adapter shape attached to advisories and returned by
@@ -471,6 +471,38 @@ interface BestPracticeAdvisory {
471
471
  * MUST type to the same union. Phase 2 integration verifies.
472
472
  */
473
473
  suggestedAdaptation?: Adapter;
474
+ /**
475
+ * alpha.42 — the kgauto request handle that produced this advisory. Stamped
476
+ * by `compile()` after `runAdvisor()` returns, sourced from
477
+ * `CompileResult.handle`. Lets a consumer's admin UI pivot from advisory
478
+ * row → original trace (Glass-Box card, brain `compile_outcomes` lookup).
479
+ *
480
+ * Absent when the advisory was constructed outside the full `compile()`
481
+ * pipeline (e.g., a direct `runAdvisor()` call in tests). Always present
482
+ * on advisories returned from `compile().advisories`.
483
+ */
484
+ kgautoRequestId?: string;
485
+ /**
486
+ * alpha.42 — who is positioned to act on this advisory.
487
+ *
488
+ * - `'consumer-actionable'` (Class A): the consumer can fix this by
489
+ * changing their wire-up — add `cacheable: true` markers, swap their
490
+ * model literal, declare a section, etc. The admin UI should surface
491
+ * a one-click apply or a "fix it" CTA.
492
+ * - `'producer-owned'` (Class B): kgauto needs to ship a code or data
493
+ * change — update a profile, promote a model in the chain, fix a
494
+ * wire contract. The admin UI should surface this as informational
495
+ * ("kgauto is on it") and not present a consumer-side action.
496
+ *
497
+ * Stamped by `compile()` after `runAdvisor()` returns. Rules can self-
498
+ * declare via the matching field on their return; otherwise the stamp
499
+ * consults the static `PRODUCER_OWNED_RULE_CODES` set in `advisor.ts`,
500
+ * defaulting to `'consumer-actionable'` when the code isn't listed.
501
+ *
502
+ * Closes the s47 dogfood gap where the tt-intel admin UI conflated the
503
+ * two classes — consumers couldn't tell whether they should act or wait.
504
+ */
505
+ ownership?: 'consumer-actionable' | 'producer-owned';
474
506
  }
475
507
  /**
476
508
  * alpha.28 — adapter shape attached to advisories and returned by
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-D_kgJcaV.mjs';
1
+ import { k as Provider } from './ir-BG70lg9b.mjs';
2
2
  import { IntentArchetypeName } from './dialect.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-DYpvUSEw.js';
1
+ import { k as Provider } from './ir-BmumS1Du.js';
2
2
  import { IntentArchetypeName } from './dialect.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-DYpvUSEw.js';
1
+ import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BmumS1Du.js';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { i as Adapter, w as SectionKind } from './ir-D_kgJcaV.mjs';
1
+ import { i as Adapter, w as SectionKind } from './ir-BG70lg9b.mjs';
2
2
 
3
3
  /**
4
4
  * Internal config + hook types for createGlassboxRoutes().
@@ -1,4 +1,4 @@
1
- import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-D_kgJcaV.mjs';
1
+ import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BG70lg9b.mjs';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { i as Adapter, w as SectionKind } from './ir-DYpvUSEw.js';
1
+ import { i as Adapter, w as SectionKind } from './ir-BmumS1Du.js';
2
2
 
3
3
  /**
4
4
  * Internal config + hook types for createGlassboxRoutes().
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.41",
3
+ "version": "2.0.0-alpha.42",
4
4
  "description": "Prompt compiler + central learning brain for multi-model AI apps. Swap models without rewriting prompts.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",