@warmdrift/kgauto-compiler 2.0.0-alpha.83 → 2.0.0-alpha.86

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/index.d.mts CHANGED
@@ -1,7 +1,7 @@
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 FallbackReason, 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-D4S9R816.mjs';
2
- export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, 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 hasMutation, K as mutationId, L as parseGoldenCaptureRate, Q as resolveGoldenCaptureRate, U as shouldCaptureGolden } from './ir-D4S9R816.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 FallbackReason, 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-5TJLAYKR.mjs';
2
+ export { m as CallAttempt, n as CallError, o as ChainModelEntry, p as ChainWithGrounding, q as Constraints, E as EffortLevel, 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 hasMutation, K as mutationId, L as parseGoldenCaptureRate, Q as resolveGoldenCaptureRate, U as shouldCaptureGolden } from './ir-5TJLAYKR.mjs';
3
3
  import { ModelProfile, ArchetypeConvention } from './profiles.mjs';
4
- export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, tryGetProfile } from './profiles.mjs';
4
+ export { ALIASES, CacheStrategy, CliffRule, LATENCY_TIER_MS, LatencyTier, LoweringSpec, RecoveryRule, StructuredOutputCapability, SystemPromptMode, allProfiles, getProfile, latencyTierOf, profilesByProvider, resolveModelAlias, tryGetProfile } from './profiles.mjs';
5
5
  export { BrainForwardConfig, BrainForwardRoutes, createBrainForwardRoutes } from './brain-proxy.mjs';
6
6
  export { KEY_FINGERPRINT_DOMAIN, KEY_FINGERPRINT_LENGTH, KeyHealthConfig, KeyHealthProvider, KeyHealthResponseBody, KeyHealthResult, KeyHealthRoute, createKeyHealthRoute, keyFingerprint } from './key-health.mjs';
7
7
  import { IntentArchetypeName, OutputMode } from './dialect.mjs';
@@ -655,6 +655,12 @@ interface OutcomePayload {
655
655
  latency_ms: number;
656
656
  success: boolean;
657
657
  empty_response: boolean;
658
+ /**
659
+ * alpha.86 (migration 056) — synthetic-writer self-mark. Key OMITTED for
660
+ * organic traffic (and against pre-056 brains). NULL in the table means
661
+ * organic; liveness rules compute over `source IS NULL` rows.
662
+ */
663
+ source?: string;
658
664
  error_type?: string;
659
665
  tools_called?: string[];
660
666
  oracle_score?: number;
@@ -1226,7 +1232,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
1226
1232
  * guard in `tests/version.test.ts` fails the suite (and therefore
1227
1233
  * `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
1228
1234
  */
1229
- declare const LIBRARY_VERSION = "2.0.0-alpha.83";
1235
+ declare const LIBRARY_VERSION = "2.0.0-alpha.86";
1230
1236
 
1231
1237
  /**
1232
1238
  * Oracle contract — how an app tells the brain whether a response was good.
@@ -1645,6 +1651,218 @@ declare function deriveOwnership(code: string, selfDeclared?: 'consumer-actionab
1645
1651
  */
1646
1652
  declare function runAdvisor(ir: PromptIR, result: AdvisorContext, profile: ModelProfile, policy?: CompilePolicy, phase2?: RunAdvisorPhase2Context): BestPracticeAdvisory[];
1647
1653
 
1654
+ /**
1655
+ * promote-ready-brain — alpha.41 substrate.
1656
+ *
1657
+ * Per-tenant SWR cache for the `promote_ready_findings` table populated by
1658
+ * the autonomous `promotion-probe-watcher` (Mode 2). Mirrors
1659
+ * `exclusion-findings-brain.ts` shape byte-for-byte where applicable; this
1660
+ * is the read-side substrate for the compile-time `promote-ready` advisor
1661
+ * rule.
1662
+ *
1663
+ * Architecture (mirror of exclusion-findings-brain):
1664
+ *
1665
+ * - **Sync API surface.** `getPromoteReadyFindings({ appId, archetype,
1666
+ * family })` returns `PromoteReadyFindingRow[]` immediately. First call
1667
+ * returns the bundled fallback (empty array); async refresh fires in
1668
+ * background; subsequent calls within TTL return brain data.
1669
+ *
1670
+ * - **Per-appId snapshot.** Each appId gets its own cache entry. One fetch
1671
+ * per appId per TTL window. Tests reset between cases via
1672
+ * `_testResetPromoteReadyFindings()`.
1673
+ *
1674
+ * - **Tolerant.** Brain down / endpoint misconfigured / unexpected shape →
1675
+ * silent bundled fallback (empty array). Never throws. Warns once per
1676
+ * process per error to avoid log spam.
1677
+ *
1678
+ * - **Opt-in.** Activation gated on `configurePromoteReadyBrain()` having
1679
+ * been called with a runtime. The public `configureBrain()` in brain.ts
1680
+ * wires this up automatically when
1681
+ * `BrainConfig.brainQuery.findingsPromoteReady !== false`.
1682
+ *
1683
+ * Plus: `markPromoteReadyHandled` — direct PostgREST PATCH against the
1684
+ * brain (no kgauto proxy). Mirrors `markExclusionFindingHandled` shape
1685
+ * byte-for-byte. Idempotent on `resolved_at=is.null` filter.
1686
+ *
1687
+ * Default endpoint:
1688
+ * `https://kgauto-dashboard.vercel.app/api/kgauto-v2/findings/promote-ready`
1689
+ * The route accepts `?app_id=X` and returns a JSON array of findings
1690
+ * for that app filtered to `resolved_at IS NULL`.
1691
+ */
1692
+
1693
+ /**
1694
+ * Shape of one row from the `promote_ready_findings` cache table. Mirrors
1695
+ * the snake_case JSONB returned by the brain endpoint, mapped to camelCase
1696
+ * at the boundary (rowToFinding) so the in-memory shape stays consistent
1697
+ * with the rest of the library.
1698
+ */
1699
+ interface PromoteReadyFindingRow {
1700
+ /** Intent archetype the finding applies to. */
1701
+ archetype: string;
1702
+ /** Model family (e.g. 'claude-opus', 'gemini-flash'). */
1703
+ family: string;
1704
+ /** The candidate model that the probe validated. */
1705
+ candidateModel: string;
1706
+ /** The current production model the candidate was compared against. */
1707
+ currentModel: string;
1708
+ /** Sample size of the probe run (typically 10). */
1709
+ sampleN: number;
1710
+ /** Fraction of probes where the judge verdict was 'candidate-better' or
1711
+ * 'tied'. 0.000 to 1.000. */
1712
+ judgePassRate: number;
1713
+ /** Mean judge score across the probe sample. 1.00 to 5.00. */
1714
+ judgeAvgScore: number;
1715
+ /** Signed cost delta as a fraction (negative = candidate is cheaper).
1716
+ * Null when pricing data was incomplete at probe time. */
1717
+ costDeltaPct: number | null;
1718
+ /** ISO timestamp of detection (when the probe wrote the row). */
1719
+ detectedAt: string;
1720
+ }
1721
+ /**
1722
+ * Resolution sources supported by alpha.41 `markPromoteReadyHandled`. The
1723
+ * three values map to the three CHECK-constrained resolution values on
1724
+ * `promote_ready_findings.resolution`:
1725
+ *
1726
+ * - `'promoted'` — consumer migrated to the candidate model. Strong
1727
+ * positive signal; the probe was right.
1728
+ * - `'declined'` — consumer evaluated and chose not to promote.
1729
+ * Strong negative signal; revisit only on new
1730
+ * family entries or material score swings.
1731
+ * - `'still-evaluating'` — consumer acknowledges the finding but defers
1732
+ * the decision. Acknowledges-without-deciding;
1733
+ * finding silences this cycle but next probe may
1734
+ * re-surface.
1735
+ */
1736
+ type PromoteReadyResolution = 'promoted' | 'declined' | 'still-evaluating';
1737
+ interface MarkPromoteReadyHandledOptions {
1738
+ /** App id the finding belongs to. Required (RLS scopes writes by this). */
1739
+ appId: string;
1740
+ /** Archetype the finding applies to (e.g. 'hunt', 'classify'). */
1741
+ archetype: IntentArchetypeName | string;
1742
+ /** Model family the finding applies to (e.g. 'claude-opus'). */
1743
+ family: string;
1744
+ /** Resolution semantics — see `PromoteReadyResolution`. */
1745
+ resolution: PromoteReadyResolution;
1746
+ /** Optional free-form note explaining the decision. */
1747
+ resolutionNote?: string;
1748
+ /** Brain Supabase URL base (e.g. `https://<project>.supabase.co`). */
1749
+ brainEndpoint: string;
1750
+ /** Consumer-scoped JWT carrying the `app_id` claim. */
1751
+ brainJwt: string;
1752
+ /** Supabase anon key for the `apikey` header. */
1753
+ brainAnonKey: string;
1754
+ /** Injected fetch for tests. Defaults to global fetch. */
1755
+ fetch?: typeof fetch;
1756
+ }
1757
+ /**
1758
+ * Mark a probe-validated promote-ready finding as handled. Returns an
1759
+ * `ok/reason` envelope matching `markExclusionFindingHandled`.
1760
+ *
1761
+ * Idempotent: if no row matches the (app_id, archetype, family) tuple
1762
+ * (already resolved, never existed, watcher not yet UPSERTed), PostgREST
1763
+ * returns 200/204 with zero affected rows and we return `{ ok: true }`.
1764
+ *
1765
+ * Reasons surfaced on failure:
1766
+ * - `app_id_required` / `archetype_required` / `family_required`
1767
+ * - `resolution_invalid` — not one of the three documented values
1768
+ * - `brain_auth_misconfig` — 401/403
1769
+ * - `brain_unavailable` — 5xx
1770
+ * - `network_error:<message>` — fetch threw
1771
+ * - `patch_failed:<status>` — anything else non-2xx
1772
+ */
1773
+ declare function markPromoteReadyHandled(opts: MarkPromoteReadyHandledOptions): Promise<{
1774
+ ok: true;
1775
+ } | {
1776
+ ok: false;
1777
+ reason: string;
1778
+ }>;
1779
+
1780
+ /**
1781
+ * blocked-model-drift — advisor rule for the two ways a consumer's
1782
+ * `CompilePolicy.blockedModels` can stop meaning what the consumer meant,
1783
+ * without anything anywhere reporting a problem.
1784
+ *
1785
+ * ── The incidents this is grounded in (tt-intel s113 + s119) ─────────────
1786
+ *
1787
+ * (Correction, s83: an earlier draft cited "claude-sonnet-5 served 30% of
1788
+ * tt-intel's ask traffic" as the motivating incident. That number was a
1789
+ * FOSSIL — tt-intel's own L-188 traced all 11 calls to a 29-second burst
1790
+ * from their own prior spend-gate experiment, fixed minutes later, and
1791
+ * their block was in fact working. Do not resurrect it.)
1792
+ *
1793
+ * The real, verified incidents:
1794
+ *
1795
+ * 1. alpha.72 retargeted the curated `claude-sonnet` family primary from
1796
+ * `claude-sonnet-4-6` (now `legacy`) to `claude-sonnet-5` (now
1797
+ * `current`), and tt-intel's literal-id gate STOPPED MATCHING the
1798
+ * family's routed traffic — their s113 response was to build
1799
+ * consumer-side family→concrete-id resolution (`parseBlockedModels`)
1800
+ * before ids reach kgauto. Every consumer without that local machinery
1801
+ * is exposed to the same silent retarget: `blockedModels` is matched by
1802
+ * exact id, so a block written against yesterday's primary says nothing
1803
+ * about today's.
1804
+ *
1805
+ * 2. tt-intel s119 (2026-07-29 filing): a blocked model SERVED when an
1806
+ * unblocked ALIAS of it sat in the candidate set (`deepseek-chat` ≡
1807
+ * `deepseek-v4-flash`). That one was a kgauto correctness bug, fixed in
1808
+ * alpha.85 by canonical matching (`policy-match.ts`) — but it proved
1809
+ * the class: a block-list meaning drifts whenever the roster's id
1810
+ * surface moves under it, and no layer errors.
1811
+ *
1812
+ * ── What this rule is NOT ────────────────────────────────────────────────
1813
+ *
1814
+ * It does not change matching semantics. Exact-ID matching is arguably the
1815
+ * correct contract: family-glob matching would silently widen every
1816
+ * existing consumer's block-list, which is a breaking semantic change and
1817
+ * not kgauto's to make unilaterally. The gap here is silence, not
1818
+ * semantics — so the fix is a signal, not a behavior change. Selection is
1819
+ * untouched; a consumer who blocked one exact id still gets exactly that
1820
+ * id blocked and nothing else.
1821
+ *
1822
+ * ── The two branches ─────────────────────────────────────────────────────
1823
+ *
1824
+ * (a) `blocked-model-not-in-roster` — a `blockedModels` entry resolves to
1825
+ * no model in the current roster (after alias resolution). The block is
1826
+ * inert: it can never match anything. Causes are a typo, a model
1827
+ * retired out of the roster, or a stale env var carried forward. There
1828
+ * is no reading under which an entry matching nothing is what the
1829
+ * consumer wanted, so this is unambiguous.
1830
+ *
1831
+ * (b) `blocked-model-family-sibling-served` — the model selected for THIS
1832
+ * call is in the same family as a blocked entry but is a different
1833
+ * exact id. This is the tt-intel shape. Unlike (a) it IS ambiguous:
1834
+ * "block `claude-sonnet-4-6` specifically, `claude-sonnet-5` is fine"
1835
+ * is a legitimate and common intent. So the message states both
1836
+ * readings and says how to act on either. It escalates its wording —
1837
+ * not its level — when the blocked sibling is `legacy`/`deprecated` and
1838
+ * the served sibling is `current`, because that combination is the
1839
+ * signature of a roster lifecycle move rather than a deliberate
1840
+ * per-generation block.
1841
+ *
1842
+ * Both fire at `warn`, and both fire regardless of `policy.posture`.
1843
+ * `posture: 'locked'` means "do not recommend models to me" — these are not
1844
+ * recommendations, they are reports that the consumer's own declared
1845
+ * constraint is not doing what its author expects. Same reasoning as the
1846
+ * alpha.28 `archetype-perf-floor-breach` cliff advisor, which is also
1847
+ * posture-independent because it reports a structural fact rather than a
1848
+ * preference.
1849
+ *
1850
+ * Companion watcher: `v2/scripts/blocked-model-drift-watch.mjs` rolls the
1851
+ * same two branches up across a consumer's recent traffic from the brain,
1852
+ * so the signal survives a consumer who never reads `result.advisories[]`.
1853
+ *
1854
+ * L-073 family ("no errors = healthy"): as with DeepSeek's `deepseek-chat`
1855
+ * compat alias and the alpha.47/.43 field-drop chain, nothing errored,
1856
+ * nothing 404'd, latency did not move — and the cached intent was wrong for
1857
+ * an unknown duration. The detection loop has to be built deliberately
1858
+ * because the failure emits no natural signal.
1859
+ */
1860
+
1861
+ /** Stable rule code — branch (a). Written to `compile_outcome_advisories.code`. */
1862
+ declare const BLOCKED_MODEL_NOT_IN_ROSTER_CODE = "blocked-model-not-in-roster";
1863
+ /** Stable rule code — branch (b). Written to `compile_outcome_advisories.code`. */
1864
+ declare const BLOCKED_MODEL_FAMILY_SIBLING_SERVED_CODE = "blocked-model-family-sibling-served";
1865
+
1648
1866
  /**
1649
1867
  * Translator primitive — alpha.31.
1650
1868
  *
@@ -3241,132 +3459,6 @@ declare function deriveFamilyFromModelId(modelId: string): string | null;
3241
3459
  */
3242
3460
  declare function getRecommendedPrimary(opts: GetRecommendedPrimaryOptions): string;
3243
3461
 
3244
- /**
3245
- * promote-ready-brain — alpha.41 substrate.
3246
- *
3247
- * Per-tenant SWR cache for the `promote_ready_findings` table populated by
3248
- * the autonomous `promotion-probe-watcher` (Mode 2). Mirrors
3249
- * `exclusion-findings-brain.ts` shape byte-for-byte where applicable; this
3250
- * is the read-side substrate for the compile-time `promote-ready` advisor
3251
- * rule.
3252
- *
3253
- * Architecture (mirror of exclusion-findings-brain):
3254
- *
3255
- * - **Sync API surface.** `getPromoteReadyFindings({ appId, archetype,
3256
- * family })` returns `PromoteReadyFindingRow[]` immediately. First call
3257
- * returns the bundled fallback (empty array); async refresh fires in
3258
- * background; subsequent calls within TTL return brain data.
3259
- *
3260
- * - **Per-appId snapshot.** Each appId gets its own cache entry. One fetch
3261
- * per appId per TTL window. Tests reset between cases via
3262
- * `_testResetPromoteReadyFindings()`.
3263
- *
3264
- * - **Tolerant.** Brain down / endpoint misconfigured / unexpected shape →
3265
- * silent bundled fallback (empty array). Never throws. Warns once per
3266
- * process per error to avoid log spam.
3267
- *
3268
- * - **Opt-in.** Activation gated on `configurePromoteReadyBrain()` having
3269
- * been called with a runtime. The public `configureBrain()` in brain.ts
3270
- * wires this up automatically when
3271
- * `BrainConfig.brainQuery.findingsPromoteReady !== false`.
3272
- *
3273
- * Plus: `markPromoteReadyHandled` — direct PostgREST PATCH against the
3274
- * brain (no kgauto proxy). Mirrors `markExclusionFindingHandled` shape
3275
- * byte-for-byte. Idempotent on `resolved_at=is.null` filter.
3276
- *
3277
- * Default endpoint:
3278
- * `https://kgauto-dashboard.vercel.app/api/kgauto-v2/findings/promote-ready`
3279
- * The route accepts `?app_id=X` and returns a JSON array of findings
3280
- * for that app filtered to `resolved_at IS NULL`.
3281
- */
3282
-
3283
- /**
3284
- * Shape of one row from the `promote_ready_findings` cache table. Mirrors
3285
- * the snake_case JSONB returned by the brain endpoint, mapped to camelCase
3286
- * at the boundary (rowToFinding) so the in-memory shape stays consistent
3287
- * with the rest of the library.
3288
- */
3289
- interface PromoteReadyFindingRow {
3290
- /** Intent archetype the finding applies to. */
3291
- archetype: string;
3292
- /** Model family (e.g. 'claude-opus', 'gemini-flash'). */
3293
- family: string;
3294
- /** The candidate model that the probe validated. */
3295
- candidateModel: string;
3296
- /** The current production model the candidate was compared against. */
3297
- currentModel: string;
3298
- /** Sample size of the probe run (typically 10). */
3299
- sampleN: number;
3300
- /** Fraction of probes where the judge verdict was 'candidate-better' or
3301
- * 'tied'. 0.000 to 1.000. */
3302
- judgePassRate: number;
3303
- /** Mean judge score across the probe sample. 1.00 to 5.00. */
3304
- judgeAvgScore: number;
3305
- /** Signed cost delta as a fraction (negative = candidate is cheaper).
3306
- * Null when pricing data was incomplete at probe time. */
3307
- costDeltaPct: number | null;
3308
- /** ISO timestamp of detection (when the probe wrote the row). */
3309
- detectedAt: string;
3310
- }
3311
- /**
3312
- * Resolution sources supported by alpha.41 `markPromoteReadyHandled`. The
3313
- * three values map to the three CHECK-constrained resolution values on
3314
- * `promote_ready_findings.resolution`:
3315
- *
3316
- * - `'promoted'` — consumer migrated to the candidate model. Strong
3317
- * positive signal; the probe was right.
3318
- * - `'declined'` — consumer evaluated and chose not to promote.
3319
- * Strong negative signal; revisit only on new
3320
- * family entries or material score swings.
3321
- * - `'still-evaluating'` — consumer acknowledges the finding but defers
3322
- * the decision. Acknowledges-without-deciding;
3323
- * finding silences this cycle but next probe may
3324
- * re-surface.
3325
- */
3326
- type PromoteReadyResolution = 'promoted' | 'declined' | 'still-evaluating';
3327
- interface MarkPromoteReadyHandledOptions {
3328
- /** App id the finding belongs to. Required (RLS scopes writes by this). */
3329
- appId: string;
3330
- /** Archetype the finding applies to (e.g. 'hunt', 'classify'). */
3331
- archetype: IntentArchetypeName | string;
3332
- /** Model family the finding applies to (e.g. 'claude-opus'). */
3333
- family: string;
3334
- /** Resolution semantics — see `PromoteReadyResolution`. */
3335
- resolution: PromoteReadyResolution;
3336
- /** Optional free-form note explaining the decision. */
3337
- resolutionNote?: string;
3338
- /** Brain Supabase URL base (e.g. `https://<project>.supabase.co`). */
3339
- brainEndpoint: string;
3340
- /** Consumer-scoped JWT carrying the `app_id` claim. */
3341
- brainJwt: string;
3342
- /** Supabase anon key for the `apikey` header. */
3343
- brainAnonKey: string;
3344
- /** Injected fetch for tests. Defaults to global fetch. */
3345
- fetch?: typeof fetch;
3346
- }
3347
- /**
3348
- * Mark a probe-validated promote-ready finding as handled. Returns an
3349
- * `ok/reason` envelope matching `markExclusionFindingHandled`.
3350
- *
3351
- * Idempotent: if no row matches the (app_id, archetype, family) tuple
3352
- * (already resolved, never existed, watcher not yet UPSERTed), PostgREST
3353
- * returns 200/204 with zero affected rows and we return `{ ok: true }`.
3354
- *
3355
- * Reasons surfaced on failure:
3356
- * - `app_id_required` / `archetype_required` / `family_required`
3357
- * - `resolution_invalid` — not one of the three documented values
3358
- * - `brain_auth_misconfig` — 401/403
3359
- * - `brain_unavailable` — 5xx
3360
- * - `network_error:<message>` — fetch threw
3361
- * - `patch_failed:<status>` — anything else non-2xx
3362
- */
3363
- declare function markPromoteReadyHandled(opts: MarkPromoteReadyHandledOptions): Promise<{
3364
- ok: true;
3365
- } | {
3366
- ok: false;
3367
- reason: string;
3368
- }>;
3369
-
3370
3462
  /**
3371
3463
  * promotions-brain — alpha.64 Stage-2 substrate.
3372
3464
  *
@@ -3544,6 +3636,37 @@ declare function getRecentRollback(opts: {
3544
3636
  windowDays?: number;
3545
3637
  nowMs?: number;
3546
3638
  }): PromotionRow | undefined;
3639
+ /**
3640
+ * alpha.86 — cold-start prefetch, the promotions twin of alpha.73's
3641
+ * `prefetchMeasuredFailure`.
3642
+ *
3643
+ * alpha.73 fixed cold-isolate blindness for the measured-failure gate and
3644
+ * did not cover this sibling subsystem: `compile()` is synchronous, so on a
3645
+ * cold isolate `getApplicablePromotion` reads an empty snapshot and an
3646
+ * ACTIVE promotion silently does not apply — hitting low-traffic consumers
3647
+ * (whose isolates are cold most of the time) hardest, directly under
3648
+ * trust-artifact #3. Found s81 via the smoke's own cold-cache bug; grep
3649
+ * confirmed zero prefetch call sites existed.
3650
+ *
3651
+ * Also the fix for the s81 smoke incident's root shape: this starts the SWR
3652
+ * refresh directly, so it cannot be defeated by `getApplicablePromotion`'s
3653
+ * argument validation early-returns.
3654
+ *
3655
+ * Returns the in-flight promise (or undefined when not configured / already
3656
+ * fresh) so a caller can await it. NEVER throws.
3657
+ */
3658
+ declare function prefetchPromotions(appId: string): Promise<void> | undefined;
3659
+ /**
3660
+ * alpha.86 — bounded await on the promotions warm-up, for async callers
3661
+ * only (`call()`); `compile()` stays synchronous. Same contract as
3662
+ * `awaitMeasuredFailureReady`: bounded, silent on timeout, protective
3663
+ * never required — a slow or down brain delays a call by at most
3664
+ * `timeoutMs` and can never fail one. A zero budget still kicks the
3665
+ * prefetch (the opt-out is "do not make me wait", not "do not warm up").
3666
+ *
3667
+ * NEVER throws.
3668
+ */
3669
+ declare function awaitPromotionsReady(appId: string, timeoutMs: number): Promise<void>;
3547
3670
  /** Reset module state. Tests must call between cases. */
3548
3671
  declare function _testResetPromotions(): void;
3549
3672
  /** Wait for any in-flight refresh to settle. */
@@ -3929,4 +4052,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
3929
4052
  */
3930
4053
  declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
3931
4054
 
3932
- export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ALT_BLIND_TOKEN_BUDGET_BREACH, ALT_STRATEGY_IDS, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryEvidenceWindow, 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, BRAIN_READ_ENV_NAMES, BURST_SPAN_MS, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, COST_RANKING_REFERENCE_SHAPE, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_BLIND_HEADER, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, 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 PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_INDEPENDENT, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altBlindGatesBlockFor, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, burstCaveat, call, chainProviderSpread, classifyEvidenceWindow, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, estimateModelCostUsd, execute, findBetterFit, flushBrainDeadLetter, formatEvidenceSpan, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAltStrategy, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rowToAdvisory, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltBlindDisciplineContract, withAltDisciplineContract, withDisciplineContract };
4055
+ export { ABSOLUTE_FLOOR, type AISDKConvertedMessage, ALT_BLIND_TOKEN_BUDGET_BREACH, ALT_STRATEGY_IDS, ARCHETYPE_FAMILY_FITS, ARCHETYPE_FLOOR_DEFAULT, type ActionableAdvisory, Adapter, type AdvisoryEvidenceWindow, 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, BLOCKED_MODEL_FAMILY_SIBLING_SERVED_CODE, BLOCKED_MODEL_NOT_IN_ROSTER_CODE, BRAIN_READ_ENV_NAMES, BURST_SPAN_MS, BestPracticeAdvisory, type BrainConfig, type BrainDeadLetterEntry, type BrainHealthSnapshot, type BrainQueryConfig, type BrainReadEnv, COACH_CFG, COST_RANKING_REFERENCE_SHAPE, CallOptions, CallResult, ChainEntry, type CompatibilityIntent, type CompileForAISDKv6Result, type CompileOptions, CompilePolicy, CompileResult, CompiledRequest, type CreateDelegateOpts, DECOMPOSITION_TEMPLATES, DECOMPOSITION_TEMPLATES_VERSION, DEFAULT_FINDINGS_ENDPOINT, DEFAULT_MEASURED_FAILURE_ENDPOINT, DEFAULT_PROMOTIONS_ENDPOINT, DELEGATE_TOOL_DEFINITION, DISCIPLINE_GATES_V1_ALT_BLIND_HEADER, DISCIPLINE_GATES_V1_ALT_HEADER, type DecompositionPlan, type DecompositionStep, type DecompositionTemplate, type DelegateHandle, type DelegateRefusalReason, type DelegateResult, type DelegateToolArgs, type ExclusionFindingRow, type ExclusionResolutionSource, type ExecuteErr, type ExecuteOk, type ExecuteOptions, type ExecuteResult, type ExecutorCandidate, type FallbackPosture, FallbackReason, FamilyResolutionError, type GetActionableAdvisoriesOptions, type GetApplicablePromotionOpts, type GetDefaultFallbackChainOpts, type GetMeasuredFailureOpts, type GetPerAxisMetricsOpts, type GetRecommendedPrimaryOptions, type GoldenEvalAxis, type GoldenEvalCase, type GoldenEvalOptions, type GoldenEvalRunResult, type GoldenEvalStrategyId, 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 PlannedStep, type PricingRow, type ProbeShadowOptions, type ProbeShadowServed, type ProfileToRowOptions, type PromoteReadyFindingRow, type PromoteReadyResolution, type PromotionRow, type PromotionsRuntime, PromptIR, Provider, ProviderOverrides, type ProviderReachability, ROLLBACK_SUPPRESSION_WINDOW_DAYS, RULE_DISCIPLINE_GATES_V1, RULE_DISCIPLINE_GATES_V1_STRUCTURED, RULE_SEQUENTIAL_TOOL_CLIFF, type ReachabilityOpts, RecordInput, RecordOutcomeInput, type RunAdvisorPhase2Context, STRATEGY_AUTHORSHIP_INDEPENDENT, STRATEGY_AUTHORSHIP_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altBlindGatesBlockFor, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, awaitPromotionsReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, burstCaveat, call, chainProviderSpread, classifyEvidenceWindow, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, estimateModelCostUsd, execute, findBetterFit, flushBrainDeadLetter, formatEvidenceSpan, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, isAltStrategy, isAutoPromoteEnabledFromEnv, isBrainQueryActiveFor, isBrainSync, isDelegateEnabledFromEnv, isExclusionFindingsBrainActive, isMeasuredFailureBrainActive, isMeasuredFailureGateEnabledFromEnv, isModelReachable, isPromotionsBrainActive, isProviderReachable, judgeMeasuredFailure, loadAliasesFromBrain, loadArchetypePerfFromBrain, loadArchetypePerfNFromBrain, loadChainsFromBrain, loadModelsFromBrain, loadPricingFromBrain, mapMeasuredFailureRows, markAdvisoryResolved, markExclusionFindingHandled, markPromoteReadyHandled, parseJudgeVerdict, peekBrainDeadLetter, planDecomposition, prefetchMeasuredFailure, prefetchPromotions, probeShadow, profileToRow, readBrainReadEnv, record, recordGoldenIr, recordOutcome, recordShadowProbe, renderIrForJudge, resetTokenizer, resolveConventionsForProfile, resolvePricingAt, resolveProviderKey, rowToAdvisory, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltBlindDisciplineContract, withAltDisciplineContract, withDisciplineContract };