@warmdrift/kgauto-compiler 2.0.0-alpha.55 → 2.0.0-alpha.57

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.
@@ -59,6 +59,19 @@
59
59
  * segment of each library POST (`outcomes`, `probe_outcomes`, …) is what
60
60
  * `handle()` receives as `segment`.
61
61
  *
62
+ * ## Prefer-header relay (alpha.56)
63
+ *
64
+ * `record()` sends `Prefer: return=representation` on its `/outcomes` POST and
65
+ * parses the inserted row id from the PROXY's response to fire the secondary
66
+ * `compile_outcome_advisories` POST. alpha.54/.55 hardcoded
67
+ * `Prefer: return=minimal` toward the brain and returned `{ok:true}` — so the
68
+ * id-parse found nothing and the advisory secondary silently never fired for
69
+ * factory-mounted consumers (PB + GE convergent finding, 2026-07-06). The
70
+ * factory now honors a caller `Prefer: return=representation` header: it is
71
+ * forwarded to the brain and the brain's response body (the inserted row(s))
72
+ * is relayed verbatim on success. Callers that don't send the header keep the
73
+ * `return=minimal` + `{ok:true}` behavior.
74
+ *
62
75
  * ## Quality-segment handle resolution (alpha.55)
63
76
  *
64
77
  * `recordOutcome()` sends `outcome_id` as `CompileResult.handle` (a string),
@@ -59,6 +59,19 @@
59
59
  * segment of each library POST (`outcomes`, `probe_outcomes`, …) is what
60
60
  * `handle()` receives as `segment`.
61
61
  *
62
+ * ## Prefer-header relay (alpha.56)
63
+ *
64
+ * `record()` sends `Prefer: return=representation` on its `/outcomes` POST and
65
+ * parses the inserted row id from the PROXY's response to fire the secondary
66
+ * `compile_outcome_advisories` POST. alpha.54/.55 hardcoded
67
+ * `Prefer: return=minimal` toward the brain and returned `{ok:true}` — so the
68
+ * id-parse found nothing and the advisory secondary silently never fired for
69
+ * factory-mounted consumers (PB + GE convergent finding, 2026-07-06). The
70
+ * factory now honors a caller `Prefer: return=representation` header: it is
71
+ * forwarded to the brain and the brain's response body (the inserted row(s))
72
+ * is relayed verbatim on success. Callers that don't send the header keep the
73
+ * `return=minimal` + `{ok:true}` behavior.
74
+ *
62
75
  * ## Quality-segment handle resolution (alpha.55)
63
76
  *
64
77
  * `recordOutcome()` sends `outcome_id` as `CompileResult.handle` (a string),
@@ -136,6 +136,9 @@ function createBrainForwardRoutes(config) {
136
136
  if (outcome instanceof Response) return outcome;
137
137
  row = outcome;
138
138
  }
139
+ const wantsRepresentation = /return=representation/i.test(
140
+ req.headers.get("Prefer") ?? ""
141
+ );
139
142
  let brainRes;
140
143
  try {
141
144
  brainRes = await fetchFn(`${brainUrl}/rest/v1/${table}`, {
@@ -144,7 +147,7 @@ function createBrainForwardRoutes(config) {
144
147
  apikey: serviceKey,
145
148
  Authorization: `Bearer ${serviceKey}`,
146
149
  "Content-Type": "application/json",
147
- Prefer: "return=minimal"
150
+ Prefer: wantsRepresentation ? "return=representation" : "return=minimal"
148
151
  },
149
152
  body: JSON.stringify(row)
150
153
  });
@@ -156,6 +159,12 @@ function createBrainForwardRoutes(config) {
156
159
  });
157
160
  }
158
161
  if (brainRes.ok) {
162
+ if (wantsRepresentation) {
163
+ const text2 = await brainRes.text().catch(() => "");
164
+ if (text2.length > 0) {
165
+ return new Response(text2, { status: 201, headers: JSON_HEADERS });
166
+ }
167
+ }
159
168
  return jsonResponse(201, { ok: true });
160
169
  }
161
170
  const text = await brainRes.text().catch(() => "<no body>");
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createBrainForwardRoutes
3
- } from "./chunk-WVICNOLA.mjs";
3
+ } from "./chunk-IUWFML6Z.mjs";
4
4
  export {
5
5
  createBrainForwardRoutes
6
6
  };
@@ -112,6 +112,9 @@ function createBrainForwardRoutes(config) {
112
112
  if (outcome instanceof Response) return outcome;
113
113
  row = outcome;
114
114
  }
115
+ const wantsRepresentation = /return=representation/i.test(
116
+ req.headers.get("Prefer") ?? ""
117
+ );
115
118
  let brainRes;
116
119
  try {
117
120
  brainRes = await fetchFn(`${brainUrl}/rest/v1/${table}`, {
@@ -120,7 +123,7 @@ function createBrainForwardRoutes(config) {
120
123
  apikey: serviceKey,
121
124
  Authorization: `Bearer ${serviceKey}`,
122
125
  "Content-Type": "application/json",
123
- Prefer: "return=minimal"
126
+ Prefer: wantsRepresentation ? "return=representation" : "return=minimal"
124
127
  },
125
128
  body: JSON.stringify(row)
126
129
  });
@@ -132,6 +135,12 @@ function createBrainForwardRoutes(config) {
132
135
  });
133
136
  }
134
137
  if (brainRes.ok) {
138
+ if (wantsRepresentation) {
139
+ const text2 = await brainRes.text().catch(() => "");
140
+ if (text2.length > 0) {
141
+ return new Response(text2, { status: 201, headers: JSON_HEADERS });
142
+ }
143
+ }
135
144
  return jsonResponse(201, { ok: true });
136
145
  }
137
146
  const text = await brainRes.text().catch(() => "<no body>");
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-C_dkNMA_.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-C_dkNMA_.mjs';
3
- import '../ir-CAlLBu5d.mjs';
1
+ import { G as GlassboxEvent } from '../types-CRy90cjp.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-CRy90cjp.mjs';
3
+ import '../ir-BC4uDL98.mjs';
4
4
  import '../dialect.mjs';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { G as GlassboxEvent } from '../types-hEDGehpz.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-hEDGehpz.js';
3
- import '../ir-BiXAMyji.js';
1
+ import { G as GlassboxEvent } from '../types-CsB2YASc.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-CsB2YASc.js';
3
+ import '../ir-B2h0GAEL.js';
4
4
  import '../dialect.js';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-Dj5FLhBV.mjs';
2
- import '../ir-CAlLBu5d.mjs';
1
+ import { T as TraceHealth } from '../types-B-pzBJKf.mjs';
2
+ import '../ir-BC4uDL98.mjs';
3
3
  import '../dialect.mjs';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { T as TraceHealth } from '../types-DsA8JFOp.js';
2
- import '../ir-BiXAMyji.js';
1
+ import { T as TraceHealth } from '../types-CKuu7Clz.js';
2
+ import '../ir-B2h0GAEL.js';
3
3
  import '../dialect.js';
4
4
 
5
5
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-C_dkNMA_.mjs';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-Dj5FLhBV.mjs';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-Dj5FLhBV.mjs';
4
- import '../ir-CAlLBu5d.mjs';
1
+ import { G as GlassboxEvent } from '../types-CRy90cjp.mjs';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-B-pzBJKf.mjs';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-B-pzBJKf.mjs';
4
+ import '../ir-BC4uDL98.mjs';
5
5
  import '../dialect.mjs';
6
6
 
7
7
  /**
@@ -1,7 +1,7 @@
1
- import { G as GlassboxEvent } from '../types-hEDGehpz.js';
2
- import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-DsA8JFOp.js';
3
- export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-DsA8JFOp.js';
4
- import '../ir-BiXAMyji.js';
1
+ import { G as GlassboxEvent } from '../types-CsB2YASc.js';
2
+ import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-CKuu7Clz.js';
3
+ export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-CKuu7Clz.js';
4
+ import '../ir-B2h0GAEL.js';
5
5
  import '../dialect.js';
6
6
 
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { a as TraceDetail } from '../../types-Dj5FLhBV.mjs';
3
- import '../../ir-CAlLBu5d.mjs';
2
+ import { a as TraceDetail } from '../../types-B-pzBJKf.mjs';
3
+ import '../../ir-BC4uDL98.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-DsA8JFOp.js';
3
- import '../../ir-BiXAMyji.js';
2
+ import { a as TraceDetail } from '../../types-CKuu7Clz.js';
3
+ import '../../ir-B2h0GAEL.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, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-CAlLBu5d.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, x as ShadowProbeConfig, T as ToolCall, y as ToolDefinition } from './ir-CAlLBu5d.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, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-BC4uDL98.mjs';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, 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, x as ShadowProbeConfig, T as ToolCall, y as ToolDefinition } from './ir-BC4uDL98.mjs';
3
3
  import { ModelProfile, ArchetypeConvention } from './profiles.mjs';
4
4
  export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, tryGetProfile } from './profiles.mjs';
5
5
  export { BrainForwardConfig, BrainForwardRoutes, createBrainForwardRoutes } from './brain-proxy.mjs';
@@ -463,6 +463,7 @@ interface OutcomePayload {
463
463
  cost_usd_actual?: number;
464
464
  ttft_ms?: number;
465
465
  history_cacheable_tokens?: number;
466
+ effort?: string;
466
467
  history_tokens_at_compile?: number;
467
468
  /**
468
469
  * Mirrors `ir.constraints.toolOrchestration` from compile time. NULL when
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, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-BiXAMyji.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, x as ShadowProbeConfig, T as ToolCall, y as ToolDefinition } from './ir-BiXAMyji.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, B as BestPracticeAdvisory, f as SectionRewrite, R as RecordInput, g as RecordOutcomeInput, O as OutcomeResult, h as OracleScore, i as Adapter, j as PerAxisMetrics, k as Provider, l as ChainEntry, G as Grounding } from './ir-B2h0GAEL.js';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, 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, x as ShadowProbeConfig, T as ToolCall, y as ToolDefinition } from './ir-B2h0GAEL.js';
3
3
  import { ModelProfile, ArchetypeConvention } from './profiles.js';
4
4
  export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, tryGetProfile } from './profiles.js';
5
5
  export { BrainForwardConfig, BrainForwardRoutes, createBrainForwardRoutes } from './brain-proxy.js';
@@ -463,6 +463,7 @@ interface OutcomePayload {
463
463
  cost_usd_actual?: number;
464
464
  ttft_ms?: number;
465
465
  history_cacheable_tokens?: number;
466
+ effort?: string;
466
467
  history_tokens_at_compile?: number;
467
468
  /**
468
469
  * Mirrors `ir.constraints.toolOrchestration` from compile time. NULL when
package/dist/index.js CHANGED
@@ -4509,7 +4509,9 @@ function registerCompile(appId, archetype, ir, result) {
4509
4509
  // alpha.29: translator activity — persisted on the brain row so
4510
4510
  // cross-app aggregates can answer "Sonnet narration rule fired N times,
4511
4511
  // outcome quality lifted to M."
4512
- sectionRewritesApplied: result.sectionRewritesApplied
4512
+ sectionRewritesApplied: result.sectionRewritesApplied,
4513
+ // alpha.57: cache the declared effort tier for record()'s auto-enrich.
4514
+ effortFromCompile: ir.constraints?.effort
4513
4515
  });
4514
4516
  }
4515
4517
  function estimateSystemPromptChars(sections) {
@@ -4664,6 +4666,10 @@ function buildPayload(input, reg) {
4664
4666
  cost_usd_actual: costUsdActual,
4665
4667
  ttft_ms: input.ttftMs,
4666
4668
  history_cacheable_tokens: reg?.historyCacheableTokens,
4669
+ // alpha.57 (data-first): input wins over compile-declared; undefined
4670
+ // end-to-end -> key absent from the JSON body entirely (safe against
4671
+ // brains that haven't applied migration 033 yet).
4672
+ effort: input.effort ?? reg?.effortFromCompile,
4667
4673
  history_tokens_at_compile: reg?.historyTokensTotal,
4668
4674
  // alpha.20 E3: mirror consumer's declared tool-orchestration mode so
4669
4675
  // the brain can measure per-mode model perf separately (DeepSeek in
@@ -6881,6 +6887,9 @@ function createBrainForwardRoutes(config) {
6881
6887
  if (outcome instanceof Response) return outcome;
6882
6888
  row = outcome;
6883
6889
  }
6890
+ const wantsRepresentation = /return=representation/i.test(
6891
+ req.headers.get("Prefer") ?? ""
6892
+ );
6884
6893
  let brainRes;
6885
6894
  try {
6886
6895
  brainRes = await fetchFn(`${brainUrl}/rest/v1/${table}`, {
@@ -6889,7 +6898,7 @@ function createBrainForwardRoutes(config) {
6889
6898
  apikey: serviceKey,
6890
6899
  Authorization: `Bearer ${serviceKey}`,
6891
6900
  "Content-Type": "application/json",
6892
- Prefer: "return=minimal"
6901
+ Prefer: wantsRepresentation ? "return=representation" : "return=minimal"
6893
6902
  },
6894
6903
  body: JSON.stringify(row)
6895
6904
  });
@@ -6901,6 +6910,12 @@ function createBrainForwardRoutes(config) {
6901
6910
  });
6902
6911
  }
6903
6912
  if (brainRes.ok) {
6913
+ if (wantsRepresentation) {
6914
+ const text2 = await brainRes.text().catch(() => "");
6915
+ if (text2.length > 0) {
6916
+ return new Response(text2, { status: 201, headers: JSON_HEADERS });
6917
+ }
6918
+ }
6904
6919
  return jsonResponse(201, { ok: true });
6905
6920
  }
6906
6921
  const text = await brainRes.text().catch(() => "<no body>");
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createBrainForwardRoutes
3
- } from "./chunk-WVICNOLA.mjs";
3
+ } from "./chunk-IUWFML6Z.mjs";
4
4
  import {
5
5
  ALL_ARCHETYPES,
6
6
  DIALECT_VERSION,
@@ -2665,7 +2665,9 @@ function registerCompile(appId, archetype, ir, result) {
2665
2665
  // alpha.29: translator activity — persisted on the brain row so
2666
2666
  // cross-app aggregates can answer "Sonnet narration rule fired N times,
2667
2667
  // outcome quality lifted to M."
2668
- sectionRewritesApplied: result.sectionRewritesApplied
2668
+ sectionRewritesApplied: result.sectionRewritesApplied,
2669
+ // alpha.57: cache the declared effort tier for record()'s auto-enrich.
2670
+ effortFromCompile: ir.constraints?.effort
2669
2671
  });
2670
2672
  }
2671
2673
  function estimateSystemPromptChars(sections) {
@@ -2820,6 +2822,10 @@ function buildPayload(input, reg) {
2820
2822
  cost_usd_actual: costUsdActual,
2821
2823
  ttft_ms: input.ttftMs,
2822
2824
  history_cacheable_tokens: reg?.historyCacheableTokens,
2825
+ // alpha.57 (data-first): input wins over compile-declared; undefined
2826
+ // end-to-end -> key absent from the JSON body entirely (safe against
2827
+ // brains that haven't applied migration 033 yet).
2828
+ effort: input.effort ?? reg?.effortFromCompile,
2823
2829
  history_tokens_at_compile: reg?.historyTokensTotal,
2824
2830
  // alpha.20 E3: mirror consumer's declared tool-orchestration mode so
2825
2831
  // the brain can measure per-mode model perf separately (DeepSeek in
@@ -111,11 +111,34 @@ interface IntentDeclaration {
111
111
  /** Canonical dialect-v1 archetype. Required for cross-app learning. */
112
112
  archetype: IntentArchetypeName;
113
113
  }
114
+ /**
115
+ * alpha.57 — dialect-level reasoning-effort tier (data-first).
116
+ *
117
+ * Vocabulary is a portfolio-level tier ladder (low → max), NOT any provider's
118
+ * wire value — mapping to `reasoning_effort` (OpenAI) / thinking budgets
119
+ * (Anthropic) / `thinkingConfig` (Gemini) stays consumer-side until
120
+ * routing-on-effort ships. Declaring it records the tier on the brain row
121
+ * (`compile_outcomes.effort`, migration 033) so effort×archetype quality
122
+ * evidence accumulates BEFORE any routing logic exists — same data-first
123
+ * sequencing as `tool_orchestration` (alpha.20).
124
+ */
125
+ type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
114
126
  interface Constraints {
115
127
  /** Hard latency ceiling — compiler will down-rank slow models. Advisory. */
116
128
  maxLatencyMs?: number;
117
129
  /** Hard cost ceiling per call (USD). Advisory. */
118
130
  maxCostUsd?: number;
131
+ /**
132
+ * alpha.57 (data-first): the reasoning-effort tier the consumer ran (or
133
+ * intends to run) this call at. RECORDED, NOT APPLIED — the compiler does
134
+ * not emit provider thinking/effort params from this field and does not
135
+ * route on it yet; it flows to `compile_outcomes.effort` via record()'s
136
+ * registry auto-enrich (same pattern as `mutationsApplied`/advisories).
137
+ * Declare it truthfully: this is consumer-reported ground truth, like
138
+ * `tokensIn`/`latencyMs`. Does NOT enter the shape key (no learning-key
139
+ * fragmentation).
140
+ */
141
+ effort?: EffortLevel;
119
142
  /** Caller wants structured (JSON) output. */
120
143
  structuredOutput?: boolean;
121
144
  /** Hint: caller expects a short response (used to disable thinking on Gemini). */
@@ -1145,6 +1168,15 @@ interface RecordInput {
1145
1168
  * surfaces it. Distinct from `latencyMs` (end-to-end wall clock).
1146
1169
  */
1147
1170
  ttftMs?: number;
1171
+ /**
1172
+ * alpha.57 (data-first) — the reasoning-effort tier this call actually ran
1173
+ * at. Overrides the compile-declared `constraints.effort` when both are
1174
+ * present (input wins — same precedence as `mutationsApplied`/`advisories`).
1175
+ * When omitted, record() auto-enriches from the registry-cached compile
1176
+ * declaration. Undefined end-to-end → the `effort` key is absent from the
1177
+ * outcome payload entirely (safe against pre-migration-033 brains).
1178
+ */
1179
+ effort?: EffortLevel;
1148
1180
  /**
1149
1181
  * alpha.20 — advisories fired at compile() time. Persisted to the brain's
1150
1182
  * `compile_outcome_advisories` sibling table via a second POST that fires
@@ -1343,4 +1375,4 @@ interface PerAxisMetrics {
1343
1375
  /** Per-axis metrics keyed by model — used for chain-comparison views. */
1344
1376
  type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
1345
1377
 
1346
- export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainModelEntry as o, type ChainWithGrounding as p, type Constraints as q, type MutationApplied as r, type NormalizedTokens as s, type OutcomeKind as t, type PerAxisMetricsByModel as u, type PromptSection as v, type SectionKind as w, type ShadowProbeConfig as x, type ToolDefinition as y };
1378
+ export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainModelEntry as o, type ChainWithGrounding as p, type Constraints as q, type MutationApplied as r, type NormalizedTokens as s, type OutcomeKind as t, type PerAxisMetricsByModel as u, type PromptSection as v, type SectionKind as w, type ShadowProbeConfig as x, type ToolDefinition as y };
@@ -111,11 +111,34 @@ interface IntentDeclaration {
111
111
  /** Canonical dialect-v1 archetype. Required for cross-app learning. */
112
112
  archetype: IntentArchetypeName;
113
113
  }
114
+ /**
115
+ * alpha.57 — dialect-level reasoning-effort tier (data-first).
116
+ *
117
+ * Vocabulary is a portfolio-level tier ladder (low → max), NOT any provider's
118
+ * wire value — mapping to `reasoning_effort` (OpenAI) / thinking budgets
119
+ * (Anthropic) / `thinkingConfig` (Gemini) stays consumer-side until
120
+ * routing-on-effort ships. Declaring it records the tier on the brain row
121
+ * (`compile_outcomes.effort`, migration 033) so effort×archetype quality
122
+ * evidence accumulates BEFORE any routing logic exists — same data-first
123
+ * sequencing as `tool_orchestration` (alpha.20).
124
+ */
125
+ type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
114
126
  interface Constraints {
115
127
  /** Hard latency ceiling — compiler will down-rank slow models. Advisory. */
116
128
  maxLatencyMs?: number;
117
129
  /** Hard cost ceiling per call (USD). Advisory. */
118
130
  maxCostUsd?: number;
131
+ /**
132
+ * alpha.57 (data-first): the reasoning-effort tier the consumer ran (or
133
+ * intends to run) this call at. RECORDED, NOT APPLIED — the compiler does
134
+ * not emit provider thinking/effort params from this field and does not
135
+ * route on it yet; it flows to `compile_outcomes.effort` via record()'s
136
+ * registry auto-enrich (same pattern as `mutationsApplied`/advisories).
137
+ * Declare it truthfully: this is consumer-reported ground truth, like
138
+ * `tokensIn`/`latencyMs`. Does NOT enter the shape key (no learning-key
139
+ * fragmentation).
140
+ */
141
+ effort?: EffortLevel;
119
142
  /** Caller wants structured (JSON) output. */
120
143
  structuredOutput?: boolean;
121
144
  /** Hint: caller expects a short response (used to disable thinking on Gemini). */
@@ -1145,6 +1168,15 @@ interface RecordInput {
1145
1168
  * surfaces it. Distinct from `latencyMs` (end-to-end wall clock).
1146
1169
  */
1147
1170
  ttftMs?: number;
1171
+ /**
1172
+ * alpha.57 (data-first) — the reasoning-effort tier this call actually ran
1173
+ * at. Overrides the compile-declared `constraints.effort` when both are
1174
+ * present (input wins — same precedence as `mutationsApplied`/`advisories`).
1175
+ * When omitted, record() auto-enriches from the registry-cached compile
1176
+ * declaration. Undefined end-to-end → the `effort` key is absent from the
1177
+ * outcome payload entirely (safe against pre-migration-033 brains).
1178
+ */
1179
+ effort?: EffortLevel;
1148
1180
  /**
1149
1181
  * alpha.20 — advisories fired at compile() time. Persisted to the brain's
1150
1182
  * `compile_outcome_advisories` sibling table via a second POST that fires
@@ -1343,4 +1375,4 @@ interface PerAxisMetrics {
1343
1375
  /** Per-axis metrics keyed by model — used for chain-comparison views. */
1344
1376
  type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
1345
1377
 
1346
- export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainModelEntry as o, type ChainWithGrounding as p, type Constraints as q, type MutationApplied as r, type NormalizedTokens as s, type OutcomeKind as t, type PerAxisMetricsByModel as u, type PromptSection as v, type SectionKind as w, type ShadowProbeConfig as x, type ToolDefinition as y };
1378
+ export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, type CompiledRequest as a, type PromptIR as b, type CallOptions as c, type CallResult as d, type CompileResult as e, type SectionRewrite as f, type RecordOutcomeInput as g, type OracleScore as h, type Adapter as i, type PerAxisMetrics as j, type Provider as k, type ChainEntry as l, type CallAttempt as m, CallError as n, type ChainModelEntry as o, type ChainWithGrounding as p, type Constraints as q, type MutationApplied as r, type NormalizedTokens as s, type OutcomeKind as t, type PerAxisMetricsByModel as u, type PromptSection as v, type SectionKind as w, type ShadowProbeConfig as x, type ToolDefinition as y };
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-CAlLBu5d.mjs';
1
+ import { k as Provider } from './ir-BC4uDL98.mjs';
2
2
  import { IntentArchetypeName } from './dialect.mjs';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-BiXAMyji.js';
1
+ import { k as Provider } from './ir-B2h0GAEL.js';
2
2
  import { IntentArchetypeName } from './dialect.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { i as Adapter, w as SectionKind } from './ir-CAlLBu5d.mjs';
1
+ import { i as Adapter, w as SectionKind } from './ir-BC4uDL98.mjs';
2
2
 
3
3
  /**
4
4
  * Internal config + hook types for createGlassboxRoutes().
@@ -1,4 +1,4 @@
1
- import { i as Adapter, w as SectionKind } from './ir-BiXAMyji.js';
1
+ import { i as Adapter, w as SectionKind } from './ir-B2h0GAEL.js';
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-CAlLBu5d.mjs';
1
+ import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BC4uDL98.mjs';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BiXAMyji.js';
1
+ import { r as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-B2h0GAEL.js';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.55",
3
+ "version": "2.0.0-alpha.57",
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",