@warmdrift/kgauto-compiler 2.0.0-alpha.77 → 2.0.0-alpha.78

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.
@@ -442,6 +442,26 @@ type MutationApplied = {
442
442
  rankBefore?: number;
443
443
  rankAfter?: number;
444
444
  };
445
+ /**
446
+ * alpha.78 — shape-proof accessor for a mutation entry (PB filing
447
+ * 2026-07-25 addendum #2). TWO public surfaces share the name
448
+ * `mutationsApplied` with DIFFERENT element types: `CompileResult` /
449
+ * `CallResult` carry `MutationApplied[]` (objects), while
450
+ * `compileForAISDKv6` carries `string[]` (ids) — each internally
451
+ * consistent, but a consumer coding to one surface's d.ts while reading the
452
+ * other's runtime gets a silent false negative (`typeof m === 'string'`
453
+ * compiles clean, runs clean, and is wrong on every row). Neither element
454
+ * type can change without breaking a live consumer, so the fix is an
455
+ * accessor that is correct on both.
456
+ */
457
+ declare function mutationId(m: string | MutationApplied): string;
458
+ /**
459
+ * alpha.78 — does any mutation in the list match `idOrPrefix` (exact id, or
460
+ * prefix when it ends with `*`)? Works on both `mutationsApplied` element
461
+ * shapes. `hasMutation(result.mutationsApplied, 'quality-gate-measured-*')`
462
+ * is the gate-detection idiom PB hand-rolled in their deep-smoke.
463
+ */
464
+ declare function hasMutation(list: ReadonlyArray<string | MutationApplied> | undefined, idOrPrefix: string): boolean;
445
465
  /**
446
466
  * Target-specific wire request. Shape varies by provider — caller passes the
447
467
  * right field to the right SDK.
@@ -1090,6 +1110,36 @@ interface CallOptions {
1090
1110
  * later calls in the same isolate are gated either way).
1091
1111
  */
1092
1112
  gateWarmupMs?: number;
1113
+ /**
1114
+ * alpha.78 — per-ATTEMPT time bound on the provider leg, in ms
1115
+ * (IC `per-call-timeout-on-call-options` + the portfolio-wide
1116
+ * unbounded-LLM-call scan). Without it the only ceiling is the serverless
1117
+ * route's `maxDuration`, and one hung socket eats the entire route budget
1118
+ * before the fallback chain — the product's whole promise — can walk.
1119
+ *
1120
+ * Semantics per attempt shape:
1121
+ * - non-streaming: total bound via `AbortSignal.timeout()`; firing
1122
+ * classifies retryable `timeout` (L-061) so the chain WALKS.
1123
+ * - streaming: per-chunk STALL bound (max silence between bytes,
1124
+ * covering time-to-first-byte) — a total bound would cut legitimate
1125
+ * long streams. Also classifies `timeout` on fire.
1126
+ *
1127
+ * Each wire attempt (including the same-model retry) gets a fresh budget.
1128
+ * Default: none — today's unbounded behavior, additive and opt-in; a
1129
+ * consumer-side bounds scan (tt-intel s114 shape) can then require it
1130
+ * mechanically. A hang recorded before this existed reads as model
1131
+ * latency in brain telemetry — transport stalls were indistinguishable
1132
+ * from slow models.
1133
+ */
1134
+ attemptTimeoutMs?: number;
1135
+ /**
1136
+ * alpha.78 — caller-owned cancellation (route-level deadline propagation).
1137
+ * Composed per-attempt with `attemptTimeoutMs` via `AbortSignal.any`.
1138
+ * Aborting classifies terminal `aborted` and stops the WHOLE chain walk —
1139
+ * the caller cancelled, so walking would spend money on an answer nobody
1140
+ * is waiting for. Distinct from a timeout, which walks.
1141
+ */
1142
+ abortSignal?: AbortSignal;
1093
1143
  toolRelevanceThreshold?: number;
1094
1144
  compressHistoryAfter?: number;
1095
1145
  /** Override API keys (defaults: process.env). */
@@ -1654,4 +1704,4 @@ interface PerAxisMetrics {
1654
1704
  /** Per-axis metrics keyed by model — used for chain-comparison views. */
1655
1705
  type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
1656
1706
 
1657
- export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, captureGoldenIr as D, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, parseGoldenCaptureRate as J, resolveGoldenCaptureRate as K, shouldCaptureGolden as L, 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 GoldenCaptureOptions as r, type MutationApplied as s, type NormalizedTokens as t, type OutcomeKind as u, type PerAxisMetricsByModel as v, type PromptSection as w, type SectionKind as x, type ShadowProbeConfig as y, type ToolDefinition as z };
1707
+ export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, captureGoldenIr as D, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, hasMutation as J, mutationId as K, parseGoldenCaptureRate as L, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, resolveGoldenCaptureRate as Q, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, shouldCaptureGolden as U, 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 GoldenCaptureOptions as r, type MutationApplied as s, type NormalizedTokens as t, type OutcomeKind as u, type PerAxisMetricsByModel as v, type PromptSection as w, type SectionKind as x, type ShadowProbeConfig as y, type ToolDefinition as z };
@@ -442,6 +442,26 @@ type MutationApplied = {
442
442
  rankBefore?: number;
443
443
  rankAfter?: number;
444
444
  };
445
+ /**
446
+ * alpha.78 — shape-proof accessor for a mutation entry (PB filing
447
+ * 2026-07-25 addendum #2). TWO public surfaces share the name
448
+ * `mutationsApplied` with DIFFERENT element types: `CompileResult` /
449
+ * `CallResult` carry `MutationApplied[]` (objects), while
450
+ * `compileForAISDKv6` carries `string[]` (ids) — each internally
451
+ * consistent, but a consumer coding to one surface's d.ts while reading the
452
+ * other's runtime gets a silent false negative (`typeof m === 'string'`
453
+ * compiles clean, runs clean, and is wrong on every row). Neither element
454
+ * type can change without breaking a live consumer, so the fix is an
455
+ * accessor that is correct on both.
456
+ */
457
+ declare function mutationId(m: string | MutationApplied): string;
458
+ /**
459
+ * alpha.78 — does any mutation in the list match `idOrPrefix` (exact id, or
460
+ * prefix when it ends with `*`)? Works on both `mutationsApplied` element
461
+ * shapes. `hasMutation(result.mutationsApplied, 'quality-gate-measured-*')`
462
+ * is the gate-detection idiom PB hand-rolled in their deep-smoke.
463
+ */
464
+ declare function hasMutation(list: ReadonlyArray<string | MutationApplied> | undefined, idOrPrefix: string): boolean;
445
465
  /**
446
466
  * Target-specific wire request. Shape varies by provider — caller passes the
447
467
  * right field to the right SDK.
@@ -1090,6 +1110,36 @@ interface CallOptions {
1090
1110
  * later calls in the same isolate are gated either way).
1091
1111
  */
1092
1112
  gateWarmupMs?: number;
1113
+ /**
1114
+ * alpha.78 — per-ATTEMPT time bound on the provider leg, in ms
1115
+ * (IC `per-call-timeout-on-call-options` + the portfolio-wide
1116
+ * unbounded-LLM-call scan). Without it the only ceiling is the serverless
1117
+ * route's `maxDuration`, and one hung socket eats the entire route budget
1118
+ * before the fallback chain — the product's whole promise — can walk.
1119
+ *
1120
+ * Semantics per attempt shape:
1121
+ * - non-streaming: total bound via `AbortSignal.timeout()`; firing
1122
+ * classifies retryable `timeout` (L-061) so the chain WALKS.
1123
+ * - streaming: per-chunk STALL bound (max silence between bytes,
1124
+ * covering time-to-first-byte) — a total bound would cut legitimate
1125
+ * long streams. Also classifies `timeout` on fire.
1126
+ *
1127
+ * Each wire attempt (including the same-model retry) gets a fresh budget.
1128
+ * Default: none — today's unbounded behavior, additive and opt-in; a
1129
+ * consumer-side bounds scan (tt-intel s114 shape) can then require it
1130
+ * mechanically. A hang recorded before this existed reads as model
1131
+ * latency in brain telemetry — transport stalls were indistinguishable
1132
+ * from slow models.
1133
+ */
1134
+ attemptTimeoutMs?: number;
1135
+ /**
1136
+ * alpha.78 — caller-owned cancellation (route-level deadline propagation).
1137
+ * Composed per-attempt with `attemptTimeoutMs` via `AbortSignal.any`.
1138
+ * Aborting classifies terminal `aborted` and stops the WHOLE chain walk —
1139
+ * the caller cancelled, so walking would spend money on an answer nobody
1140
+ * is waiting for. Distinct from a timeout, which walks.
1141
+ */
1142
+ abortSignal?: AbortSignal;
1093
1143
  toolRelevanceThreshold?: number;
1094
1144
  compressHistoryAfter?: number;
1095
1145
  /** Override API keys (defaults: process.env). */
@@ -1654,4 +1704,4 @@ interface PerAxisMetrics {
1654
1704
  /** Per-axis metrics keyed by model — used for chain-comparison views. */
1655
1705
  type PerAxisMetricsByModel = Record<string, PerAxisMetrics>;
1656
1706
 
1657
- export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, captureGoldenIr as D, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, parseGoldenCaptureRate as J, resolveGoldenCaptureRate as K, shouldCaptureGolden as L, 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 GoldenCaptureOptions as r, type MutationApplied as s, type NormalizedTokens as t, type OutcomeKind as u, type PerAxisMetricsByModel as v, type PromptSection as w, type SectionKind as x, type ShadowProbeConfig as y, type ToolDefinition as z };
1707
+ export { type ApiKeys as A, type BestPracticeAdvisory as B, type CompilePolicy as C, captureGoldenIr as D, type EffortLevel as E, type FallbackReason as F, type Grounding as G, type HistoryCachePolicy as H, type IntentDeclaration as I, hasMutation as J, mutationId as K, parseGoldenCaptureRate as L, type Message as M, type NormalizedResponse as N, type OutcomeResult as O, type ProviderOverrides as P, resolveGoldenCaptureRate as Q, type RecordInput as R, type SystemModelMessage as S, type ToolCall as T, shouldCaptureGolden as U, 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 GoldenCaptureOptions as r, type MutationApplied as s, type NormalizedTokens as t, type OutcomeKind as u, type PerAxisMetricsByModel as v, type PromptSection as w, type SectionKind as x, type ShadowProbeConfig as y, type ToolDefinition as z };
@@ -25,7 +25,7 @@ __export(key_health_exports, {
25
25
  module.exports = __toCommonJS(key_health_exports);
26
26
 
27
27
  // src/version.ts
28
- var LIBRARY_VERSION = "2.0.0-alpha.77";
28
+ var LIBRARY_VERSION = "2.0.0-alpha.78";
29
29
 
30
30
  // src/key-health.ts
31
31
  var JSON_HEADERS = { "Content-Type": "application/json" };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createKeyHealthRoute
3
- } from "./chunk-GB7VJQ6C.mjs";
3
+ } from "./chunk-QVD2QWST.mjs";
4
4
  export {
5
5
  createKeyHealthRoute
6
6
  };
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-CRV1_taF.mjs';
1
+ import { k as Provider } from './ir-BFwWhj2s.mjs';
2
2
  import { IntentArchetypeName } from './dialect.mjs';
3
3
 
4
4
  /**
@@ -22,7 +22,17 @@ interface CliffRule {
22
22
  /** Threshold — meaning depends on metric. */
23
23
  threshold: number;
24
24
  /** What action to take when triggered. */
25
- action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools';
25
+ action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools'
26
+ /**
27
+ * alpha.78 — apply the band-dominating QUALITY_GATE_PENALTY (same lever
28
+ * as the alpha.49 schema-weak gate) when the IR declares
29
+ * structuredOutput and the metric crosses threshold. For models whose
30
+ * declared structured-output support is MEASURED not to hold above an
31
+ * input size on an archetype — evidence-shaped, unlike the archetype-
32
+ * wide `structuredOutputHint: 'avoid'`. Only meaningful with
33
+ * `metric: 'input_tokens'` (+ usually `whenIntent`).
34
+ */
35
+ | 'quality_gate_structured';
26
36
  /**
27
37
  * Optional: only fire this cliff when the IR's intent.archetype matches.
28
38
  * Used for archetype-specific failure modes (e.g. Gemini Flash returns
@@ -1,4 +1,4 @@
1
- import { k as Provider } from './ir-C02EIElQ.js';
1
+ import { k as Provider } from './ir-DZKS1tI7.js';
2
2
  import { IntentArchetypeName } from './dialect.js';
3
3
 
4
4
  /**
@@ -22,7 +22,17 @@ interface CliffRule {
22
22
  /** Threshold — meaning depends on metric. */
23
23
  threshold: number;
24
24
  /** What action to take when triggered. */
25
- action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools';
25
+ action: 'downgrade_quality_warning' | 'drop_to_top_relevant' | 'force_thinking_budget_zero' | 'force_terse_output' | 'escalate_target' | 'strip_tools'
26
+ /**
27
+ * alpha.78 — apply the band-dominating QUALITY_GATE_PENALTY (same lever
28
+ * as the alpha.49 schema-weak gate) when the IR declares
29
+ * structuredOutput and the metric crosses threshold. For models whose
30
+ * declared structured-output support is MEASURED not to hold above an
31
+ * input size on an archetype — evidence-shaped, unlike the archetype-
32
+ * wide `structuredOutputHint: 'avoid'`. Only meaningful with
33
+ * `metric: 'input_tokens'` (+ usually `whenIntent`).
34
+ */
35
+ | 'quality_gate_structured';
26
36
  /**
27
37
  * Optional: only fire this cliff when the IR's intent.archetype matches.
28
38
  * Used for archetype-specific failure modes (e.g. Gemini Flash returns
package/dist/profiles.js CHANGED
@@ -395,6 +395,22 @@ var PROFILES_RAW = [
395
395
  threshold: 16,
396
396
  action: "drop_to_top_relevant",
397
397
  reason: "Haiku reliability degrades above ~16 tools"
398
+ },
399
+ {
400
+ // alpha.78 — the declared `structuredOutput: 'grammar'` does NOT
401
+ // hold on long-input summarize. MEASURED (brain, playbacksam):
402
+ // 21 disambiguated `structured_output_parse_failed` fallover rows
403
+ // 2026-07-22..27, tokens_in 12,280–31,450; PB's gate counted 20/20
404
+ // in-window failures. Clean traffic p50 sits at ~9K tokens_in, so
405
+ // 12K gates the failing band without touching the working one.
406
+ // Short-input summarize carries no failure evidence and stays
407
+ // ungated — this is why it's a cliff, not an archetype-wide
408
+ // `structuredOutputHint: 'avoid'`.
409
+ metric: "input_tokens",
410
+ threshold: 12e3,
411
+ action: "quality_gate_structured",
412
+ whenIntent: "summarize",
413
+ reason: "Structured-output parse failures at 100% in-window on long-input summarize (measured on playbacksam, 2026-07-25..27; haiku only led when input size made price dominate, then failed every time)."
398
414
  }
399
415
  ],
400
416
  costInputPer1m: 1,
package/dist/profiles.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  latencyTierOf,
9
9
  profilesByProvider,
10
10
  tryGetProfile
11
- } from "./chunk-N36LE3MK.mjs";
11
+ } from "./chunk-VVRDFE6T.mjs";
12
12
  export {
13
13
  ALIASES,
14
14
  LATENCY_TIER_MS,
@@ -1,4 +1,4 @@
1
- import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-C02EIElQ.js';
1
+ import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-DZKS1tI7.js';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-C02EIElQ.js';
1
+ import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-DZKS1tI7.js';
2
2
 
3
3
  /**
4
4
  * Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
@@ -1,4 +1,4 @@
1
- import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-CRV1_taF.mjs';
1
+ import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-BFwWhj2s.mjs';
2
2
 
3
3
  /**
4
4
  * Glass-Box observability types (alpha.17).
@@ -1,4 +1,4 @@
1
- import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-CRV1_taF.mjs';
1
+ import { i as Adapter, F as FallbackReason, x as SectionKind } from './ir-BFwWhj2s.mjs';
2
2
 
3
3
  /**
4
4
  * Wire contract for the Glass-Box Chrome extension's brain-poll endpoint.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmdrift/kgauto-compiler",
3
- "version": "2.0.0-alpha.77",
3
+ "version": "2.0.0-alpha.78",
4
4
  "description": "Prompt compiler with executable provider knowledge for multi-model AI apps: normalized multi-provider transport with fallback chains, compile-time cliff guards, a curated model registry, and a telemetry flight recorder. Swap models without rewriting prompts.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",