@warmdrift/kgauto-compiler 2.0.0-alpha.72 → 2.0.0-alpha.74
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.
- package/dist/{chunk-AI4NNR5T.mjs → chunk-EB2YR7HL.mjs} +1 -1
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/format.d.mts +2 -2
- package/dist/glassbox-routes/format.d.ts +2 -2
- package/dist/glassbox-routes/index.d.mts +4 -4
- package/dist/glassbox-routes/index.d.ts +4 -4
- package/dist/glassbox-routes/react/index.d.mts +2 -2
- package/dist/glassbox-routes/react/index.d.ts +2 -2
- package/dist/index.d.mts +58 -10
- package/dist/index.d.ts +58 -10
- package/dist/index.js +88 -4
- package/dist/index.mjs +86 -4
- package/dist/{ir-BEQ28muo.d.ts → ir-B0v2f9NY.d.ts} +39 -0
- package/dist/{ir-CnnJST_N.d.mts → ir-CZukZvDn.d.mts} +39 -0
- package/dist/key-health.js +1 -1
- package/dist/key-health.mjs +1 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{types-DeGRCTlJ.d.mts → types-BOTLfJOp.d.mts} +1 -1
- package/dist/{types-DSeJJ6tt.d.ts → types-Ba68lIs1.d.ts} +1 -1
- package/dist/{types-BDFrJkma.d.mts → types-BgJ5iQB_.d.mts} +1 -1
- package/dist/{types-B--CYzMo.d.ts → types-D-PuKCWk.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
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-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-BgJ5iQB_.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-BgJ5iQB_.mjs';
|
|
3
|
+
import '../ir-CZukZvDn.mjs';
|
|
4
4
|
import '../dialect.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/glassbox/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
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-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-D-PuKCWk.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-D-PuKCWk.js';
|
|
3
|
+
import '../ir-B0v2f9NY.js';
|
|
4
4
|
import '../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-BgJ5iQB_.mjs';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-BOTLfJOp.mjs';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-BOTLfJOp.mjs';
|
|
4
|
+
import '../ir-CZukZvDn.mjs';
|
|
5
5
|
import '../dialect.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-D-PuKCWk.js';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-Ba68lIs1.js';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-Ba68lIs1.js';
|
|
4
|
+
import '../ir-B0v2f9NY.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-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-BOTLfJOp.mjs';
|
|
3
|
+
import '../../ir-CZukZvDn.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-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-Ba68lIs1.js';
|
|
3
|
+
import '../../ir-B0v2f9NY.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-
|
|
2
|
-
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-
|
|
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-CZukZvDn.mjs';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-CZukZvDn.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';
|
|
@@ -120,11 +120,6 @@ declare function execute(request: CompiledRequest, opts?: ExecuteOptions): Promi
|
|
|
120
120
|
* Hard cap at fallbackChain.length + 1 attempts. Terminal errors short-circuit.
|
|
121
121
|
*/
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
* Compile, execute, normalize, record. Returns a CallResult once a provider
|
|
125
|
-
* actually serves the request. Throws CallError if the fallback chain is
|
|
126
|
-
* exhausted without success.
|
|
127
|
-
*/
|
|
128
123
|
declare function call(ir: PromptIR, opts?: CallOptions): Promise<CallResult>;
|
|
129
124
|
/** Served-side result the AI-SDK consumer already holds from streamText. */
|
|
130
125
|
interface ProbeShadowServed {
|
|
@@ -440,6 +435,19 @@ interface BrainQueryConfig {
|
|
|
440
435
|
interface BrainConfig {
|
|
441
436
|
/** Brain HTTP endpoint base URL (e.g., https://kgauto-brain.vercel.app/api). */
|
|
442
437
|
endpoint: string;
|
|
438
|
+
/**
|
|
439
|
+
* alpha.73 — the consumer's app id, declared once so brain-driven levers can
|
|
440
|
+
* start their first read at configuration time instead of at the first
|
|
441
|
+
* compile.
|
|
442
|
+
*
|
|
443
|
+
* Optional and purely an optimisation: every IR already carries `appId`, and
|
|
444
|
+
* omitting this changes no verdict — it only means the measured-failure
|
|
445
|
+
* gate's warm-up starts when `call()` runs rather than when the module
|
|
446
|
+
* initialises. Declaring it lets a short-lived isolate spend its startup
|
|
447
|
+
* time on the fetch, so the bounded wait in `call()` usually costs nothing.
|
|
448
|
+
* Consumers running one app per process should set it.
|
|
449
|
+
*/
|
|
450
|
+
appId?: string;
|
|
443
451
|
/** Bearer token for auth. */
|
|
444
452
|
apiKey?: string;
|
|
445
453
|
/** Optional error hook for debugging. Defaults to console.warn. */
|
|
@@ -1009,7 +1017,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
|
|
|
1009
1017
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1010
1018
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1011
1019
|
*/
|
|
1012
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1020
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.74";
|
|
1013
1021
|
|
|
1014
1022
|
/**
|
|
1015
1023
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -2997,12 +3005,52 @@ interface GetMeasuredFailureOpts {
|
|
|
2997
3005
|
archetype: IntentArchetypeName | string;
|
|
2998
3006
|
model: string;
|
|
2999
3007
|
}
|
|
3008
|
+
/**
|
|
3009
|
+
* alpha.73 — start the warm-up WITHOUT needing a compile to trigger it.
|
|
3010
|
+
*
|
|
3011
|
+
* The SWR posture below ("cold start returns undefined and warms in the
|
|
3012
|
+
* background") is right for a long-lived process and wrong for a
|
|
3013
|
+
* short-lived isolate, where the first compile IS most compiles. Measured on
|
|
3014
|
+
* playbacksam: on a cold isolate the gate was absent, `claude-haiku-4-5` led,
|
|
3015
|
+
* cliffed, was same-model retried and fell over to gemini — two billed
|
|
3016
|
+
* inferences and ~27–34s, every time an isolate is new. PB has ~1 user, so
|
|
3017
|
+
* its isolates are cold most of the time, which inverts the usual severity
|
|
3018
|
+
* ordering: this hits the LOWEST-traffic consumers hardest, and they are the
|
|
3019
|
+
* ones least able to absorb it.
|
|
3020
|
+
*
|
|
3021
|
+
* Kicking the fetch off at `configureBrain()` moves the refresh into the time
|
|
3022
|
+
* the isolate spends on everything else it does before its first compile.
|
|
3023
|
+
* Fire-and-forget and non-blocking: on its own this narrows the window rather
|
|
3024
|
+
* than closing it, which is why `awaitMeasuredFailureReady()` exists too.
|
|
3025
|
+
*
|
|
3026
|
+
* Returns the in-flight promise (or undefined when not configured / already
|
|
3027
|
+
* fresh) so a caller can await it. NEVER throws.
|
|
3028
|
+
*/
|
|
3029
|
+
declare function prefetchMeasuredFailure(appId: string): Promise<void> | undefined;
|
|
3030
|
+
/**
|
|
3031
|
+
* alpha.73 — bounded await on the warm-up, for async callers only.
|
|
3032
|
+
*
|
|
3033
|
+
* `compile()` is synchronous and must stay so, so it cannot block on a fetch;
|
|
3034
|
+
* `call()` is async and is about to spend seconds on an inference, which makes
|
|
3035
|
+
* a few hundred milliseconds here a trivially good trade against the ~27–34s
|
|
3036
|
+
* and second billed inference a cold-blind gate costs.
|
|
3037
|
+
*
|
|
3038
|
+
* Deliberately bounded and deliberately silent on timeout: the gate is
|
|
3039
|
+
* protective, never required. If the brain is slow or down, the caller
|
|
3040
|
+
* proceeds un-gated exactly as it does today — this can delay a call by at
|
|
3041
|
+
* most `timeoutMs`, and can never fail one.
|
|
3042
|
+
*
|
|
3043
|
+
* NEVER throws.
|
|
3044
|
+
*/
|
|
3045
|
+
declare function awaitMeasuredFailureReady(appId: string, timeoutMs: number): Promise<void>;
|
|
3000
3046
|
/**
|
|
3001
3047
|
* Sync reader. Returns the verdict for `(appId, archetype, model)` or
|
|
3002
3048
|
* undefined (not configured / cold / below minSample / brain down).
|
|
3003
3049
|
*
|
|
3004
3050
|
* NEVER throws. Cold start returns undefined and warms in the background —
|
|
3005
|
-
* same posture as every other brain-driven lever in compile().
|
|
3051
|
+
* same posture as every other brain-driven lever in compile(). Async callers
|
|
3052
|
+
* that can afford a bounded wait should call `awaitMeasuredFailureReady()`
|
|
3053
|
+
* first; `call()` does.
|
|
3006
3054
|
*/
|
|
3007
3055
|
declare function getMeasuredFailureVerdict(opts: GetMeasuredFailureOpts): MeasuredFailureVerdict | undefined;
|
|
3008
3056
|
declare function _testResetMeasuredFailure(): void;
|
|
@@ -3054,4 +3102,4 @@ declare function _testWaitForMeasuredFailureRefresh(): Promise<void>;
|
|
|
3054
3102
|
*/
|
|
3055
3103
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3056
3104
|
|
|
3057
|
-
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, type SurfaceFailureRow, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer, wilsonLowerBound };
|
|
3105
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, type SurfaceFailureRow, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer, wilsonLowerBound };
|
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-
|
|
2
|
-
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-
|
|
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-B0v2f9NY.js';
|
|
2
|
+
export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, F as FallbackReason, r as GoldenCaptureOptions, H as HistoryCachePolicy, I as IntentDeclaration, M as Message, s as MutationApplied, t as NormalizedTokens, u as OutcomeKind, v as PerAxisMetricsByModel, w as PromptSection, x as SectionKind, y as ShadowProbeConfig, T as ToolCall, z as ToolDefinition, D as captureGoldenIr, J as parseGoldenCaptureRate, K as resolveGoldenCaptureRate, L as shouldCaptureGolden } from './ir-B0v2f9NY.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';
|
|
@@ -120,11 +120,6 @@ declare function execute(request: CompiledRequest, opts?: ExecuteOptions): Promi
|
|
|
120
120
|
* Hard cap at fallbackChain.length + 1 attempts. Terminal errors short-circuit.
|
|
121
121
|
*/
|
|
122
122
|
|
|
123
|
-
/**
|
|
124
|
-
* Compile, execute, normalize, record. Returns a CallResult once a provider
|
|
125
|
-
* actually serves the request. Throws CallError if the fallback chain is
|
|
126
|
-
* exhausted without success.
|
|
127
|
-
*/
|
|
128
123
|
declare function call(ir: PromptIR, opts?: CallOptions): Promise<CallResult>;
|
|
129
124
|
/** Served-side result the AI-SDK consumer already holds from streamText. */
|
|
130
125
|
interface ProbeShadowServed {
|
|
@@ -440,6 +435,19 @@ interface BrainQueryConfig {
|
|
|
440
435
|
interface BrainConfig {
|
|
441
436
|
/** Brain HTTP endpoint base URL (e.g., https://kgauto-brain.vercel.app/api). */
|
|
442
437
|
endpoint: string;
|
|
438
|
+
/**
|
|
439
|
+
* alpha.73 — the consumer's app id, declared once so brain-driven levers can
|
|
440
|
+
* start their first read at configuration time instead of at the first
|
|
441
|
+
* compile.
|
|
442
|
+
*
|
|
443
|
+
* Optional and purely an optimisation: every IR already carries `appId`, and
|
|
444
|
+
* omitting this changes no verdict — it only means the measured-failure
|
|
445
|
+
* gate's warm-up starts when `call()` runs rather than when the module
|
|
446
|
+
* initialises. Declaring it lets a short-lived isolate spend its startup
|
|
447
|
+
* time on the fetch, so the bounded wait in `call()` usually costs nothing.
|
|
448
|
+
* Consumers running one app per process should set it.
|
|
449
|
+
*/
|
|
450
|
+
appId?: string;
|
|
443
451
|
/** Bearer token for auth. */
|
|
444
452
|
apiKey?: string;
|
|
445
453
|
/** Optional error hook for debugging. Defaults to console.warn. */
|
|
@@ -1009,7 +1017,7 @@ declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunRe
|
|
|
1009
1017
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1010
1018
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1011
1019
|
*/
|
|
1012
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1020
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.74";
|
|
1013
1021
|
|
|
1014
1022
|
/**
|
|
1015
1023
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -2997,12 +3005,52 @@ interface GetMeasuredFailureOpts {
|
|
|
2997
3005
|
archetype: IntentArchetypeName | string;
|
|
2998
3006
|
model: string;
|
|
2999
3007
|
}
|
|
3008
|
+
/**
|
|
3009
|
+
* alpha.73 — start the warm-up WITHOUT needing a compile to trigger it.
|
|
3010
|
+
*
|
|
3011
|
+
* The SWR posture below ("cold start returns undefined and warms in the
|
|
3012
|
+
* background") is right for a long-lived process and wrong for a
|
|
3013
|
+
* short-lived isolate, where the first compile IS most compiles. Measured on
|
|
3014
|
+
* playbacksam: on a cold isolate the gate was absent, `claude-haiku-4-5` led,
|
|
3015
|
+
* cliffed, was same-model retried and fell over to gemini — two billed
|
|
3016
|
+
* inferences and ~27–34s, every time an isolate is new. PB has ~1 user, so
|
|
3017
|
+
* its isolates are cold most of the time, which inverts the usual severity
|
|
3018
|
+
* ordering: this hits the LOWEST-traffic consumers hardest, and they are the
|
|
3019
|
+
* ones least able to absorb it.
|
|
3020
|
+
*
|
|
3021
|
+
* Kicking the fetch off at `configureBrain()` moves the refresh into the time
|
|
3022
|
+
* the isolate spends on everything else it does before its first compile.
|
|
3023
|
+
* Fire-and-forget and non-blocking: on its own this narrows the window rather
|
|
3024
|
+
* than closing it, which is why `awaitMeasuredFailureReady()` exists too.
|
|
3025
|
+
*
|
|
3026
|
+
* Returns the in-flight promise (or undefined when not configured / already
|
|
3027
|
+
* fresh) so a caller can await it. NEVER throws.
|
|
3028
|
+
*/
|
|
3029
|
+
declare function prefetchMeasuredFailure(appId: string): Promise<void> | undefined;
|
|
3030
|
+
/**
|
|
3031
|
+
* alpha.73 — bounded await on the warm-up, for async callers only.
|
|
3032
|
+
*
|
|
3033
|
+
* `compile()` is synchronous and must stay so, so it cannot block on a fetch;
|
|
3034
|
+
* `call()` is async and is about to spend seconds on an inference, which makes
|
|
3035
|
+
* a few hundred milliseconds here a trivially good trade against the ~27–34s
|
|
3036
|
+
* and second billed inference a cold-blind gate costs.
|
|
3037
|
+
*
|
|
3038
|
+
* Deliberately bounded and deliberately silent on timeout: the gate is
|
|
3039
|
+
* protective, never required. If the brain is slow or down, the caller
|
|
3040
|
+
* proceeds un-gated exactly as it does today — this can delay a call by at
|
|
3041
|
+
* most `timeoutMs`, and can never fail one.
|
|
3042
|
+
*
|
|
3043
|
+
* NEVER throws.
|
|
3044
|
+
*/
|
|
3045
|
+
declare function awaitMeasuredFailureReady(appId: string, timeoutMs: number): Promise<void>;
|
|
3000
3046
|
/**
|
|
3001
3047
|
* Sync reader. Returns the verdict for `(appId, archetype, model)` or
|
|
3002
3048
|
* undefined (not configured / cold / below minSample / brain down).
|
|
3003
3049
|
*
|
|
3004
3050
|
* NEVER throws. Cold start returns undefined and warms in the background —
|
|
3005
|
-
* same posture as every other brain-driven lever in compile().
|
|
3051
|
+
* same posture as every other brain-driven lever in compile(). Async callers
|
|
3052
|
+
* that can afford a bounded wait should call `awaitMeasuredFailureReady()`
|
|
3053
|
+
* first; `call()` does.
|
|
3006
3054
|
*/
|
|
3007
3055
|
declare function getMeasuredFailureVerdict(opts: GetMeasuredFailureOpts): MeasuredFailureVerdict | undefined;
|
|
3008
3056
|
declare function _testResetMeasuredFailure(): void;
|
|
@@ -3054,4 +3102,4 @@ declare function _testWaitForMeasuredFailureRefresh(): Promise<void>;
|
|
|
3054
3102
|
*/
|
|
3055
3103
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3056
3104
|
|
|
3057
|
-
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, type SurfaceFailureRow, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer, wilsonLowerBound };
|
|
3105
|
+
export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryResolutionSource, type AdvisorySeverity, type AdvisoryStatus, type AdvisorySuggestedFix, ApiKeys, type AppOracle, type ApplySectionRewritesArgs, type ApplySectionRewritesResult, ArchetypeConvention, type ArchetypeFamilyFit, type ArchetypePerfMap, type ArchetypePerfNMap, type ArchetypePerfScoreResult, type AttachCacheControlResult, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type FallbackPosture, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenIrRecordInput, Grounding, IntentArchetypeName, JUDGE_RUBRICS, LIBRARY_VERSION, type LLMJudgeOptions, MEASURED_FAILURE_CFG, MEASURED_GROUNDING_MIN_N, type MarkAdvisoryResolvedOptions, type MarkExclusionFindingHandledOptions, type MarkPromoteReadyHandledOptions, type MeasuredFailureRuntime, type MeasuredFailureVerdict, type ModelBrainRow, type ModelCompatibility, ModelProfile, NormalizedResponse, type OracleContext, OracleScore, type OutcomePayload, OutcomeResult, OutputMode, PRODUCER_OWNED_RULE_CODES, PROVIDER_ENV_KEYS, PerAxisMetrics, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, SectionRewrite, type ShadowProbeRecordInput, type SupportedProvider, type SurfaceFailureRow, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, deriveFamilyFromModelId, deriveOwnership, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rubricFor, runAdvisor, runGoldenEval, setTokenizer, wilsonLowerBound };
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __export(index_exports, {
|
|
|
49
49
|
applyArchetypeConvention: () => applyArchetypeConvention,
|
|
50
50
|
applySectionRewrites: () => applySectionRewrites,
|
|
51
51
|
attachCacheControlToStreamTextInput: () => attachCacheControlToStreamTextInput,
|
|
52
|
+
awaitMeasuredFailureReady: () => awaitMeasuredFailureReady,
|
|
52
53
|
brainHealth: () => brainHealth,
|
|
53
54
|
bucketContext: () => bucketContext,
|
|
54
55
|
bucketHistory: () => bucketHistory,
|
|
@@ -118,6 +119,7 @@ __export(index_exports, {
|
|
|
118
119
|
parseGoldenCaptureRate: () => parseGoldenCaptureRate,
|
|
119
120
|
parseJudgeVerdict: () => parseJudgeVerdict,
|
|
120
121
|
peekBrainDeadLetter: () => peekBrainDeadLetter,
|
|
122
|
+
prefetchMeasuredFailure: () => prefetchMeasuredFailure,
|
|
121
123
|
probeShadow: () => probeShadow,
|
|
122
124
|
profileToRow: () => profileToRow,
|
|
123
125
|
profilesByProvider: () => profilesByProvider,
|
|
@@ -2981,20 +2983,27 @@ function passScoreTargets(ir, opts) {
|
|
|
2981
2983
|
});
|
|
2982
2984
|
}
|
|
2983
2985
|
if (qualityGatePenalty > 0) {
|
|
2986
|
+
const rankBefore = rank + qualityGatePenalty;
|
|
2984
2987
|
if (measuredGate) {
|
|
2985
2988
|
const pct = (x) => `${(x * 100).toFixed(0)}%`;
|
|
2986
2989
|
policyMutations.push({
|
|
2987
2990
|
id: `quality-gate-measured-${modelId}`,
|
|
2988
2991
|
source: "quality_gate",
|
|
2989
2992
|
passName: "score_targets",
|
|
2990
|
-
|
|
2993
|
+
rankDelta: -qualityGatePenalty,
|
|
2994
|
+
rankBefore,
|
|
2995
|
+
rankAfter: rank,
|
|
2996
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' by MEASURED evidence from this app's own outcomes \u2014 ${measuredGate.nFail} of ${measuredGate.n} attempts failed on the quality axis in the trailing window (${pct(measuredGate.rate)}; 95% lower bound ${pct(measuredGate.lowerBound)} > 50%). Rank ${rankBefore.toFixed(2)} \u2192 ${rank.toFixed(2)} (\u2212${qualityGatePenalty.toFixed(2)}). Down-ranked out of leadership; retained as graceful fallback only. The gate is derived, not stored \u2014 it lifts on its own once the failures age out of the window.`
|
|
2991
2997
|
});
|
|
2992
2998
|
} else {
|
|
2993
2999
|
policyMutations.push({
|
|
2994
3000
|
id: `quality-gate-structured-${modelId}`,
|
|
2995
3001
|
source: "quality_gate",
|
|
2996
3002
|
passName: "score_targets",
|
|
2997
|
-
|
|
3003
|
+
rankDelta: -qualityGatePenalty,
|
|
3004
|
+
rankBefore,
|
|
3005
|
+
rankAfter: rank,
|
|
3006
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' \u2014 declared structuredOutput + kgauto convention flags it schema-weak for this contract (structuredOutputHint:'avoid'). Rank ${rankBefore.toFixed(2)} \u2192 ${rank.toFixed(2)} (\u2212${qualityGatePenalty.toFixed(2)}). Down-ranked out of leadership; retained as graceful fallback only.`
|
|
2998
3007
|
});
|
|
2999
3008
|
}
|
|
3000
3009
|
}
|
|
@@ -4734,6 +4743,40 @@ function configureMeasuredFailureBrain(rt) {
|
|
|
4734
4743
|
function isMeasuredFailureBrainActive() {
|
|
4735
4744
|
return runtime6 !== void 0;
|
|
4736
4745
|
}
|
|
4746
|
+
function prefetchMeasuredFailure(appId) {
|
|
4747
|
+
const rt = runtime6;
|
|
4748
|
+
if (!rt || !appId) return void 0;
|
|
4749
|
+
let snap = snapshots5.get(appId);
|
|
4750
|
+
if (!snap) {
|
|
4751
|
+
snap = { data: [], expiresAt: 0, refreshing: false };
|
|
4752
|
+
snapshots5.set(appId, snap);
|
|
4753
|
+
}
|
|
4754
|
+
if (snap.expiresAt > Date.now()) return void 0;
|
|
4755
|
+
const inflight = pendingRefreshes5.get(appId);
|
|
4756
|
+
if (inflight) return inflight;
|
|
4757
|
+
if (snap.refreshing) return void 0;
|
|
4758
|
+
snap.refreshing = true;
|
|
4759
|
+
void asyncRefresh6(rt, appId);
|
|
4760
|
+
return pendingRefreshes5.get(appId);
|
|
4761
|
+
}
|
|
4762
|
+
async function awaitMeasuredFailureReady(appId, timeoutMs) {
|
|
4763
|
+
if (!runtime6 || !appId) return;
|
|
4764
|
+
const pending = prefetchMeasuredFailure(appId) ?? pendingRefreshes5.get(appId);
|
|
4765
|
+
if (!(timeoutMs > 0)) return;
|
|
4766
|
+
if (!pending) return;
|
|
4767
|
+
let timer;
|
|
4768
|
+
try {
|
|
4769
|
+
await Promise.race([
|
|
4770
|
+
pending,
|
|
4771
|
+
new Promise((resolve) => {
|
|
4772
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
4773
|
+
})
|
|
4774
|
+
]);
|
|
4775
|
+
} catch {
|
|
4776
|
+
} finally {
|
|
4777
|
+
if (timer) clearTimeout(timer);
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4737
4780
|
function getMeasuredFailureVerdict(opts) {
|
|
4738
4781
|
const rt = runtime6;
|
|
4739
4782
|
if (!rt) return void 0;
|
|
@@ -5239,6 +5282,12 @@ function configureBrain(config) {
|
|
|
5239
5282
|
fetchImpl: config.fetchImpl ?? fetch,
|
|
5240
5283
|
onError: config.onError
|
|
5241
5284
|
});
|
|
5285
|
+
if (config.appId) {
|
|
5286
|
+
try {
|
|
5287
|
+
void prefetchMeasuredFailure(config.appId);
|
|
5288
|
+
} catch {
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5242
5291
|
} else {
|
|
5243
5292
|
configureMeasuredFailureBrain(void 0);
|
|
5244
5293
|
}
|
|
@@ -6295,6 +6344,24 @@ function tryParseJson(s) {
|
|
|
6295
6344
|
return void 0;
|
|
6296
6345
|
}
|
|
6297
6346
|
}
|
|
6347
|
+
function isAuthSignatureBody(body, message) {
|
|
6348
|
+
if (body && typeof body === "object") {
|
|
6349
|
+
const err = body.error;
|
|
6350
|
+
if (err && typeof err === "object") {
|
|
6351
|
+
const e = err;
|
|
6352
|
+
if (Array.isArray(e.details)) {
|
|
6353
|
+
for (const d of e.details) {
|
|
6354
|
+
if (d && typeof d === "object" && d.reason === "API_KEY_INVALID") {
|
|
6355
|
+
return true;
|
|
6356
|
+
}
|
|
6357
|
+
}
|
|
6358
|
+
}
|
|
6359
|
+
if (e.code === "invalid_api_key") return true;
|
|
6360
|
+
}
|
|
6361
|
+
}
|
|
6362
|
+
const m = message.toLowerCase();
|
|
6363
|
+
return m.includes("api key not valid") || m.includes("invalid api key") || m.includes("invalid x-api-key") || m.includes("incorrect api key");
|
|
6364
|
+
}
|
|
6298
6365
|
function classifyHttpError(status, body) {
|
|
6299
6366
|
const message = extractErrorMessage(body) ?? `HTTP ${status}`;
|
|
6300
6367
|
if (status === 429)
|
|
@@ -6307,8 +6374,11 @@ function classifyHttpError(status, body) {
|
|
|
6307
6374
|
return { ok: false, status, errorType: "retryable", errorCode: "model_not_found", message, raw: body };
|
|
6308
6375
|
if (status === 401 || status === 403)
|
|
6309
6376
|
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
6310
|
-
if (status === 400)
|
|
6377
|
+
if (status === 400) {
|
|
6378
|
+
if (isAuthSignatureBody(body, message))
|
|
6379
|
+
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
6311
6380
|
return { ok: false, status, errorType: "terminal", errorCode: "invalid_request", message, raw: body };
|
|
6381
|
+
}
|
|
6312
6382
|
return { ok: false, status, errorType: "terminal", errorCode: "unknown", message, raw: body };
|
|
6313
6383
|
}
|
|
6314
6384
|
function extractErrorMessage(body) {
|
|
@@ -6573,6 +6643,9 @@ function classifyHttpError2(status, body) {
|
|
|
6573
6643
|
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
6574
6644
|
}
|
|
6575
6645
|
if (status === 400) {
|
|
6646
|
+
if (isAuthSignatureBody(body, message)) {
|
|
6647
|
+
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
6648
|
+
}
|
|
6576
6649
|
return { ok: false, status, errorType: "terminal", errorCode: "invalid_request", message, raw: body };
|
|
6577
6650
|
}
|
|
6578
6651
|
return { ok: false, status, errorType: "terminal", errorCode: "unknown", message, raw: body };
|
|
@@ -7258,6 +7331,14 @@ function emitFallbackWalked(traceId, appId, data) {
|
|
|
7258
7331
|
}
|
|
7259
7332
|
|
|
7260
7333
|
// src/call.ts
|
|
7334
|
+
function resolveGateWarmupMs(opts) {
|
|
7335
|
+
const declared = opts.gateWarmupMs;
|
|
7336
|
+
if (typeof declared === "number" && Number.isFinite(declared) && declared >= 0) {
|
|
7337
|
+
return declared;
|
|
7338
|
+
}
|
|
7339
|
+
return DEFAULT_GATE_WARMUP_MS;
|
|
7340
|
+
}
|
|
7341
|
+
var DEFAULT_GATE_WARMUP_MS = 400;
|
|
7261
7342
|
async function call(ir, opts = {}) {
|
|
7262
7343
|
const traceId = generateTraceId();
|
|
7263
7344
|
safeEmit(
|
|
@@ -7273,6 +7354,7 @@ async function call(ir, opts = {}) {
|
|
|
7273
7354
|
)
|
|
7274
7355
|
})
|
|
7275
7356
|
);
|
|
7357
|
+
await awaitMeasuredFailureReady(ir.appId, resolveGateWarmupMs(opts));
|
|
7276
7358
|
const initial = compileAndRegister(ir, opts);
|
|
7277
7359
|
safeEmit(
|
|
7278
7360
|
() => emitCompileDone(traceId, ir.appId, {
|
|
@@ -8741,7 +8823,7 @@ function createBrainForwardRoutes(config) {
|
|
|
8741
8823
|
}
|
|
8742
8824
|
|
|
8743
8825
|
// src/version.ts
|
|
8744
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
8826
|
+
var LIBRARY_VERSION = "2.0.0-alpha.74";
|
|
8745
8827
|
|
|
8746
8828
|
// src/key-health.ts
|
|
8747
8829
|
var JSON_HEADERS2 = { "Content-Type": "application/json" };
|
|
@@ -9396,6 +9478,7 @@ function compile2(ir, opts) {
|
|
|
9396
9478
|
applyArchetypeConvention,
|
|
9397
9479
|
applySectionRewrites,
|
|
9398
9480
|
attachCacheControlToStreamTextInput,
|
|
9481
|
+
awaitMeasuredFailureReady,
|
|
9399
9482
|
brainHealth,
|
|
9400
9483
|
bucketContext,
|
|
9401
9484
|
bucketHistory,
|
|
@@ -9465,6 +9548,7 @@ function compile2(ir, opts) {
|
|
|
9465
9548
|
parseGoldenCaptureRate,
|
|
9466
9549
|
parseJudgeVerdict,
|
|
9467
9550
|
peekBrainDeadLetter,
|
|
9551
|
+
prefetchMeasuredFailure,
|
|
9468
9552
|
probeShadow,
|
|
9469
9553
|
profileToRow,
|
|
9470
9554
|
profilesByProvider,
|
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
LIBRARY_VERSION,
|
|
18
18
|
createKeyHealthRoute
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EB2YR7HL.mjs";
|
|
20
20
|
import {
|
|
21
21
|
ABSOLUTE_FLOOR,
|
|
22
22
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
@@ -877,20 +877,27 @@ function passScoreTargets(ir, opts) {
|
|
|
877
877
|
});
|
|
878
878
|
}
|
|
879
879
|
if (qualityGatePenalty > 0) {
|
|
880
|
+
const rankBefore = rank + qualityGatePenalty;
|
|
880
881
|
if (measuredGate) {
|
|
881
882
|
const pct = (x) => `${(x * 100).toFixed(0)}%`;
|
|
882
883
|
policyMutations.push({
|
|
883
884
|
id: `quality-gate-measured-${modelId}`,
|
|
884
885
|
source: "quality_gate",
|
|
885
886
|
passName: "score_targets",
|
|
886
|
-
|
|
887
|
+
rankDelta: -qualityGatePenalty,
|
|
888
|
+
rankBefore,
|
|
889
|
+
rankAfter: rank,
|
|
890
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' by MEASURED evidence from this app's own outcomes \u2014 ${measuredGate.nFail} of ${measuredGate.n} attempts failed on the quality axis in the trailing window (${pct(measuredGate.rate)}; 95% lower bound ${pct(measuredGate.lowerBound)} > 50%). Rank ${rankBefore.toFixed(2)} \u2192 ${rank.toFixed(2)} (\u2212${qualityGatePenalty.toFixed(2)}). Down-ranked out of leadership; retained as graceful fallback only. The gate is derived, not stored \u2014 it lifts on its own once the failures age out of the window.`
|
|
887
891
|
});
|
|
888
892
|
} else {
|
|
889
893
|
policyMutations.push({
|
|
890
894
|
id: `quality-gate-structured-${modelId}`,
|
|
891
895
|
source: "quality_gate",
|
|
892
896
|
passName: "score_targets",
|
|
893
|
-
|
|
897
|
+
rankDelta: -qualityGatePenalty,
|
|
898
|
+
rankBefore,
|
|
899
|
+
rankAfter: rank,
|
|
900
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' \u2014 declared structuredOutput + kgauto convention flags it schema-weak for this contract (structuredOutputHint:'avoid'). Rank ${rankBefore.toFixed(2)} \u2192 ${rank.toFixed(2)} (\u2212${qualityGatePenalty.toFixed(2)}). Down-ranked out of leadership; retained as graceful fallback only.`
|
|
894
901
|
});
|
|
895
902
|
}
|
|
896
903
|
}
|
|
@@ -2630,6 +2637,40 @@ function configureMeasuredFailureBrain(rt) {
|
|
|
2630
2637
|
function isMeasuredFailureBrainActive() {
|
|
2631
2638
|
return runtime5 !== void 0;
|
|
2632
2639
|
}
|
|
2640
|
+
function prefetchMeasuredFailure(appId) {
|
|
2641
|
+
const rt = runtime5;
|
|
2642
|
+
if (!rt || !appId) return void 0;
|
|
2643
|
+
let snap = snapshots5.get(appId);
|
|
2644
|
+
if (!snap) {
|
|
2645
|
+
snap = { data: [], expiresAt: 0, refreshing: false };
|
|
2646
|
+
snapshots5.set(appId, snap);
|
|
2647
|
+
}
|
|
2648
|
+
if (snap.expiresAt > Date.now()) return void 0;
|
|
2649
|
+
const inflight = pendingRefreshes5.get(appId);
|
|
2650
|
+
if (inflight) return inflight;
|
|
2651
|
+
if (snap.refreshing) return void 0;
|
|
2652
|
+
snap.refreshing = true;
|
|
2653
|
+
void asyncRefresh5(rt, appId);
|
|
2654
|
+
return pendingRefreshes5.get(appId);
|
|
2655
|
+
}
|
|
2656
|
+
async function awaitMeasuredFailureReady(appId, timeoutMs) {
|
|
2657
|
+
if (!runtime5 || !appId) return;
|
|
2658
|
+
const pending = prefetchMeasuredFailure(appId) ?? pendingRefreshes5.get(appId);
|
|
2659
|
+
if (!(timeoutMs > 0)) return;
|
|
2660
|
+
if (!pending) return;
|
|
2661
|
+
let timer;
|
|
2662
|
+
try {
|
|
2663
|
+
await Promise.race([
|
|
2664
|
+
pending,
|
|
2665
|
+
new Promise((resolve) => {
|
|
2666
|
+
timer = setTimeout(resolve, timeoutMs);
|
|
2667
|
+
})
|
|
2668
|
+
]);
|
|
2669
|
+
} catch {
|
|
2670
|
+
} finally {
|
|
2671
|
+
if (timer) clearTimeout(timer);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2633
2674
|
function getMeasuredFailureVerdict(opts) {
|
|
2634
2675
|
const rt = runtime5;
|
|
2635
2676
|
if (!rt) return void 0;
|
|
@@ -3135,6 +3176,12 @@ function configureBrain(config) {
|
|
|
3135
3176
|
fetchImpl: config.fetchImpl ?? fetch,
|
|
3136
3177
|
onError: config.onError
|
|
3137
3178
|
});
|
|
3179
|
+
if (config.appId) {
|
|
3180
|
+
try {
|
|
3181
|
+
void prefetchMeasuredFailure(config.appId);
|
|
3182
|
+
} catch {
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3138
3185
|
} else {
|
|
3139
3186
|
configureMeasuredFailureBrain(void 0);
|
|
3140
3187
|
}
|
|
@@ -4106,6 +4153,24 @@ function tryParseJson(s) {
|
|
|
4106
4153
|
return void 0;
|
|
4107
4154
|
}
|
|
4108
4155
|
}
|
|
4156
|
+
function isAuthSignatureBody(body, message) {
|
|
4157
|
+
if (body && typeof body === "object") {
|
|
4158
|
+
const err = body.error;
|
|
4159
|
+
if (err && typeof err === "object") {
|
|
4160
|
+
const e = err;
|
|
4161
|
+
if (Array.isArray(e.details)) {
|
|
4162
|
+
for (const d of e.details) {
|
|
4163
|
+
if (d && typeof d === "object" && d.reason === "API_KEY_INVALID") {
|
|
4164
|
+
return true;
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
if (e.code === "invalid_api_key") return true;
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4171
|
+
const m = message.toLowerCase();
|
|
4172
|
+
return m.includes("api key not valid") || m.includes("invalid api key") || m.includes("invalid x-api-key") || m.includes("incorrect api key");
|
|
4173
|
+
}
|
|
4109
4174
|
function classifyHttpError(status, body) {
|
|
4110
4175
|
const message = extractErrorMessage(body) ?? `HTTP ${status}`;
|
|
4111
4176
|
if (status === 429)
|
|
@@ -4118,8 +4183,11 @@ function classifyHttpError(status, body) {
|
|
|
4118
4183
|
return { ok: false, status, errorType: "retryable", errorCode: "model_not_found", message, raw: body };
|
|
4119
4184
|
if (status === 401 || status === 403)
|
|
4120
4185
|
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
4121
|
-
if (status === 400)
|
|
4186
|
+
if (status === 400) {
|
|
4187
|
+
if (isAuthSignatureBody(body, message))
|
|
4188
|
+
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
4122
4189
|
return { ok: false, status, errorType: "terminal", errorCode: "invalid_request", message, raw: body };
|
|
4190
|
+
}
|
|
4123
4191
|
return { ok: false, status, errorType: "terminal", errorCode: "unknown", message, raw: body };
|
|
4124
4192
|
}
|
|
4125
4193
|
function extractErrorMessage(body) {
|
|
@@ -4384,6 +4452,9 @@ function classifyHttpError2(status, body) {
|
|
|
4384
4452
|
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
4385
4453
|
}
|
|
4386
4454
|
if (status === 400) {
|
|
4455
|
+
if (isAuthSignatureBody(body, message)) {
|
|
4456
|
+
return { ok: false, status, errorType: "terminal", errorCode: "auth", message, raw: body };
|
|
4457
|
+
}
|
|
4387
4458
|
return { ok: false, status, errorType: "terminal", errorCode: "invalid_request", message, raw: body };
|
|
4388
4459
|
}
|
|
4389
4460
|
return { ok: false, status, errorType: "terminal", errorCode: "unknown", message, raw: body };
|
|
@@ -4415,6 +4486,14 @@ function tryParseJson2(s) {
|
|
|
4415
4486
|
}
|
|
4416
4487
|
|
|
4417
4488
|
// src/call.ts
|
|
4489
|
+
function resolveGateWarmupMs(opts) {
|
|
4490
|
+
const declared = opts.gateWarmupMs;
|
|
4491
|
+
if (typeof declared === "number" && Number.isFinite(declared) && declared >= 0) {
|
|
4492
|
+
return declared;
|
|
4493
|
+
}
|
|
4494
|
+
return DEFAULT_GATE_WARMUP_MS;
|
|
4495
|
+
}
|
|
4496
|
+
var DEFAULT_GATE_WARMUP_MS = 400;
|
|
4418
4497
|
async function call(ir, opts = {}) {
|
|
4419
4498
|
const traceId = generateTraceId();
|
|
4420
4499
|
safeEmit(
|
|
@@ -4430,6 +4509,7 @@ async function call(ir, opts = {}) {
|
|
|
4430
4509
|
)
|
|
4431
4510
|
})
|
|
4432
4511
|
);
|
|
4512
|
+
await awaitMeasuredFailureReady(ir.appId, resolveGateWarmupMs(opts));
|
|
4433
4513
|
const initial = compileAndRegister(ir, opts);
|
|
4434
4514
|
safeEmit(
|
|
4435
4515
|
() => emitCompileDone(traceId, ir.appId, {
|
|
@@ -6187,6 +6267,7 @@ export {
|
|
|
6187
6267
|
applyArchetypeConvention,
|
|
6188
6268
|
applySectionRewrites,
|
|
6189
6269
|
attachCacheControlToStreamTextInput,
|
|
6270
|
+
awaitMeasuredFailureReady,
|
|
6190
6271
|
brainHealth,
|
|
6191
6272
|
bucketContext,
|
|
6192
6273
|
bucketHistory,
|
|
@@ -6256,6 +6337,7 @@ export {
|
|
|
6256
6337
|
parseGoldenCaptureRate,
|
|
6257
6338
|
parseJudgeVerdict,
|
|
6258
6339
|
peekBrainDeadLetter,
|
|
6340
|
+
prefetchMeasuredFailure,
|
|
6259
6341
|
probeShadow,
|
|
6260
6342
|
profileToRow,
|
|
6261
6343
|
profilesByProvider,
|
|
@@ -419,6 +419,28 @@ type MutationApplied = {
|
|
|
419
419
|
source: string;
|
|
420
420
|
passName: string;
|
|
421
421
|
description: string;
|
|
422
|
+
/**
|
|
423
|
+
* alpha.73 — the ranking delta this mutation applied, when it applied one.
|
|
424
|
+
* Negative de-ranks, positive boosts. Absent for mutations that do not touch
|
|
425
|
+
* rank (advisory/labelling mutations).
|
|
426
|
+
*
|
|
427
|
+
* Exists because a consumer could previously see *that* a gate fired and
|
|
428
|
+
* *why*, but not *how much* — which cannot distinguish "the gate did not see
|
|
429
|
+
* this model" from "the gate saw it and the penalty lost to a price
|
|
430
|
+
* advantage." PB spent two days and three wrong conclusions inside that gap
|
|
431
|
+
* (2026-07-25/26), and both wrong conclusions were inferences substituted
|
|
432
|
+
* for a quantity that was known at emit time and thrown away. Same class as
|
|
433
|
+
* the `rankedOn` request: a consumer cannot reason about ranking behaviour
|
|
434
|
+
* it cannot observe, so it will guess.
|
|
435
|
+
*/
|
|
436
|
+
rankDelta?: number;
|
|
437
|
+
/**
|
|
438
|
+
* alpha.73 — the model's rank before and after this mutation, when it
|
|
439
|
+
* changed one. Together with `rankDelta` this answers the question a
|
|
440
|
+
* penalty magnitude alone cannot: whether the gated model still WON.
|
|
441
|
+
*/
|
|
442
|
+
rankBefore?: number;
|
|
443
|
+
rankAfter?: number;
|
|
422
444
|
};
|
|
423
445
|
/**
|
|
424
446
|
* Target-specific wire request. Shape varies by provider — caller passes the
|
|
@@ -1051,6 +1073,23 @@ interface CallOptions {
|
|
|
1051
1073
|
* fire-and-forget. See {@link ShadowProbeConfig}.
|
|
1052
1074
|
*/
|
|
1053
1075
|
shadowProbe?: ShadowProbeConfig;
|
|
1076
|
+
/**
|
|
1077
|
+
* alpha.73 — how long `call()` may wait for the measured-failure gate's
|
|
1078
|
+
* first brain read before compiling, in ms. Default 400.
|
|
1079
|
+
*
|
|
1080
|
+
* Exists because `compile()` is synchronous and therefore reads only what
|
|
1081
|
+
* the SWR cache already holds: on a cold isolate that is nothing, so the
|
|
1082
|
+
* gate silently does not fire on the first compile — measured on
|
|
1083
|
+
* playbacksam as two billed inferences and ~27–34s of added latency, every
|
|
1084
|
+
* time an isolate is new. Low-traffic consumers are cold most of the time,
|
|
1085
|
+
* so this hits them hardest, inverting the usual severity ordering.
|
|
1086
|
+
*
|
|
1087
|
+
* The wait is bounded and never required: on timeout, brain-down, or no
|
|
1088
|
+
* brain configured, the call proceeds un-gated exactly as before. Set `0`
|
|
1089
|
+
* to disable the wait entirely (the background prefetch still runs, so
|
|
1090
|
+
* later calls in the same isolate are gated either way).
|
|
1091
|
+
*/
|
|
1092
|
+
gateWarmupMs?: number;
|
|
1054
1093
|
toolRelevanceThreshold?: number;
|
|
1055
1094
|
compressHistoryAfter?: number;
|
|
1056
1095
|
/** Override API keys (defaults: process.env). */
|
|
@@ -419,6 +419,28 @@ type MutationApplied = {
|
|
|
419
419
|
source: string;
|
|
420
420
|
passName: string;
|
|
421
421
|
description: string;
|
|
422
|
+
/**
|
|
423
|
+
* alpha.73 — the ranking delta this mutation applied, when it applied one.
|
|
424
|
+
* Negative de-ranks, positive boosts. Absent for mutations that do not touch
|
|
425
|
+
* rank (advisory/labelling mutations).
|
|
426
|
+
*
|
|
427
|
+
* Exists because a consumer could previously see *that* a gate fired and
|
|
428
|
+
* *why*, but not *how much* — which cannot distinguish "the gate did not see
|
|
429
|
+
* this model" from "the gate saw it and the penalty lost to a price
|
|
430
|
+
* advantage." PB spent two days and three wrong conclusions inside that gap
|
|
431
|
+
* (2026-07-25/26), and both wrong conclusions were inferences substituted
|
|
432
|
+
* for a quantity that was known at emit time and thrown away. Same class as
|
|
433
|
+
* the `rankedOn` request: a consumer cannot reason about ranking behaviour
|
|
434
|
+
* it cannot observe, so it will guess.
|
|
435
|
+
*/
|
|
436
|
+
rankDelta?: number;
|
|
437
|
+
/**
|
|
438
|
+
* alpha.73 — the model's rank before and after this mutation, when it
|
|
439
|
+
* changed one. Together with `rankDelta` this answers the question a
|
|
440
|
+
* penalty magnitude alone cannot: whether the gated model still WON.
|
|
441
|
+
*/
|
|
442
|
+
rankBefore?: number;
|
|
443
|
+
rankAfter?: number;
|
|
422
444
|
};
|
|
423
445
|
/**
|
|
424
446
|
* Target-specific wire request. Shape varies by provider — caller passes the
|
|
@@ -1051,6 +1073,23 @@ interface CallOptions {
|
|
|
1051
1073
|
* fire-and-forget. See {@link ShadowProbeConfig}.
|
|
1052
1074
|
*/
|
|
1053
1075
|
shadowProbe?: ShadowProbeConfig;
|
|
1076
|
+
/**
|
|
1077
|
+
* alpha.73 — how long `call()` may wait for the measured-failure gate's
|
|
1078
|
+
* first brain read before compiling, in ms. Default 400.
|
|
1079
|
+
*
|
|
1080
|
+
* Exists because `compile()` is synchronous and therefore reads only what
|
|
1081
|
+
* the SWR cache already holds: on a cold isolate that is nothing, so the
|
|
1082
|
+
* gate silently does not fire on the first compile — measured on
|
|
1083
|
+
* playbacksam as two billed inferences and ~27–34s of added latency, every
|
|
1084
|
+
* time an isolate is new. Low-traffic consumers are cold most of the time,
|
|
1085
|
+
* so this hits them hardest, inverting the usual severity ordering.
|
|
1086
|
+
*
|
|
1087
|
+
* The wait is bounded and never required: on timeout, brain-down, or no
|
|
1088
|
+
* brain configured, the call proceeds un-gated exactly as before. Set `0`
|
|
1089
|
+
* to disable the wait entirely (the background prefetch still runs, so
|
|
1090
|
+
* later calls in the same isolate are gated either way).
|
|
1091
|
+
*/
|
|
1092
|
+
gateWarmupMs?: number;
|
|
1054
1093
|
toolRelevanceThreshold?: number;
|
|
1055
1094
|
compressHistoryAfter?: number;
|
|
1056
1095
|
/** Override API keys (defaults: process.env). */
|
package/dist/key-health.js
CHANGED
|
@@ -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.
|
|
28
|
+
var LIBRARY_VERSION = "2.0.0-alpha.74";
|
|
29
29
|
|
|
30
30
|
// src/key-health.ts
|
|
31
31
|
var JSON_HEADERS = { "Content-Type": "application/json" };
|
package/dist/key-health.mjs
CHANGED
package/dist/profiles.d.mts
CHANGED
package/dist/profiles.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-
|
|
1
|
+
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-CZukZvDn.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Glass-Box observability types (alpha.17).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-
|
|
1
|
+
import { s as MutationApplied, B as BestPracticeAdvisory, F as FallbackReason, m as CallAttempt } from './ir-B0v2f9NY.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.
|
|
3
|
+
"version": "2.0.0-alpha.74",
|
|
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",
|