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

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.js CHANGED
@@ -61,7 +61,9 @@ __export(index_exports, {
61
61
  STRATEGY_AUTHORSHIP_INDEPENDENT: () => STRATEGY_AUTHORSHIP_INDEPENDENT,
62
62
  STRATEGY_AUTHORSHIP_LIMITATION: () => STRATEGY_AUTHORSHIP_LIMITATION,
63
63
  TRANSLATOR_FLOOR: () => TRANSLATOR_FLOOR,
64
+ _testClearConsumerProfiles: () => _testClearConsumerProfiles,
64
65
  _testResetMeasuredFailure: () => _testResetMeasuredFailure,
66
+ _testResetOutcomeSourceWarning: () => _testResetOutcomeSourceWarning,
65
67
  _testResetPromotions: () => _testResetPromotions,
66
68
  _testWaitForMeasuredFailureRefresh: () => _testWaitForMeasuredFailureRefresh,
67
69
  _testWaitForPromotionsRefresh: () => _testWaitForPromotionsRefresh,
@@ -73,6 +75,7 @@ __export(index_exports, {
73
75
  attachCacheControlToStreamTextInput: () => attachCacheControlToStreamTextInput,
74
76
  awaitMeasuredFailureReady: () => awaitMeasuredFailureReady,
75
77
  awaitPromotionsReady: () => awaitPromotionsReady,
78
+ bestEffortProfile: () => bestEffortProfile,
76
79
  brainHealth: () => brainHealth,
77
80
  bucketContext: () => bucketContext,
78
81
  bucketHistory: () => bucketHistory,
@@ -127,6 +130,7 @@ __export(index_exports, {
127
130
  getStarterChainWithGrounding: () => getStarterChainWithGrounding,
128
131
  hasMutation: () => hasMutation,
129
132
  hashShape: () => hashShape,
133
+ inferProviderFromId: () => inferProviderFromId,
130
134
  isAltStrategy: () => isAltStrategy,
131
135
  isArchetype: () => isArchetype,
132
136
  isAutoPromoteEnabledFromEnv: () => isAutoPromoteEnabledFromEnv,
@@ -168,11 +172,13 @@ __export(index_exports, {
168
172
  recordGoldenIr: () => recordGoldenIr,
169
173
  recordOutcome: () => recordOutcome,
170
174
  recordShadowProbe: () => recordShadowProbe,
175
+ registerProfiles: () => registerProfiles,
171
176
  renderIrForJudge: () => renderIrForJudge,
172
177
  resetTokenizer: () => resetTokenizer,
173
178
  resolveConventionsForProfile: () => resolveConventionsForProfile,
174
179
  resolveGoldenCaptureRate: () => resolveGoldenCaptureRate,
175
180
  resolveModelAlias: () => resolveModelAlias,
181
+ resolveOutcomeSource: () => resolveOutcomeSource,
176
182
  resolvePricingAt: () => resolvePricingAt,
177
183
  resolveProviderKey: () => resolveProviderKey,
178
184
  rowToAdvisory: () => rowToAdvisory,
@@ -199,6 +205,9 @@ var FRESH_SNAPSHOT = {
199
205
  };
200
206
  var snapshot = { ...FRESH_SNAPSHOT };
201
207
  var runtime;
208
+ function configFreshness() {
209
+ return runtime && snapshot.data ? "brain" : "bundled";
210
+ }
202
211
  function configureBrainQuery(rt) {
203
212
  runtime = rt;
204
213
  snapshot = { ...FRESH_SNAPSHOT };
@@ -574,7 +583,7 @@ var PROFILES_RAW = [
574
583
  },
575
584
  {
576
585
  id: "claude-opus-4-7",
577
- verifiedAgainstDocs: "2026-05-08",
586
+ verifiedAgainstDocs: "2026-08-24",
578
587
  provider: "anthropic",
579
588
  status: "legacy",
580
589
  // s76 2026-07-25: docs list as LEGACY (Opus 5 is current). Bundle said current while the brain already said legacy — the two disagreed.
@@ -624,7 +633,7 @@ var PROFILES_RAW = [
624
633
  },
625
634
  {
626
635
  id: "claude-opus-4-6",
627
- verifiedAgainstDocs: "2026-05-08",
636
+ verifiedAgainstDocs: "2026-08-24",
628
637
  provider: "anthropic",
629
638
  status: "legacy",
630
639
  maxContextTokens: 1e6,
@@ -669,7 +678,7 @@ var PROFILES_RAW = [
669
678
  },
670
679
  {
671
680
  id: "claude-sonnet-4-6",
672
- verifiedAgainstDocs: "2026-05-08",
681
+ verifiedAgainstDocs: "2026-08-24",
673
682
  provider: "anthropic",
674
683
  status: "legacy",
675
684
  // s76 2026-07-25: docs list as LEGACY (Sonnet 5 is current).
@@ -710,7 +719,7 @@ var PROFILES_RAW = [
710
719
  },
711
720
  {
712
721
  id: "claude-haiku-4-5",
713
- verifiedAgainstDocs: "2026-05-08",
722
+ verifiedAgainstDocs: "2026-08-24",
714
723
  provider: "anthropic",
715
724
  status: "current",
716
725
  maxContextTokens: 2e5,
@@ -773,7 +782,7 @@ var PROFILES_RAW = [
773
782
  // ── Google ──
774
783
  {
775
784
  id: "gemini-2.5-flash",
776
- verifiedAgainstDocs: "2026-05-08",
785
+ verifiedAgainstDocs: "2026-08-24",
777
786
  provider: "google",
778
787
  status: "current",
779
788
  maxContextTokens: 1048576,
@@ -879,7 +888,7 @@ var PROFILES_RAW = [
879
888
  // thresholds. The brain will validate/relax these as evidence accumulates
880
889
  // per (archetype, model) tuple. Currently ZERO brain rows for this model.
881
890
  id: "gemini-2.5-flash-lite",
882
- verifiedAgainstDocs: "2026-05-13",
891
+ verifiedAgainstDocs: "2026-08-24",
883
892
  provider: "google",
884
893
  status: "current",
885
894
  maxContextTokens: 1048576,
@@ -1036,7 +1045,7 @@ var PROFILES_RAW = [
1036
1045
  },
1037
1046
  {
1038
1047
  id: "gemini-3.1-pro-preview",
1039
- verifiedAgainstDocs: "2026-05-08",
1048
+ verifiedAgainstDocs: "2026-08-24",
1040
1049
  provider: "google",
1041
1050
  status: "preview",
1042
1051
  maxContextTokens: 1048576,
@@ -1096,7 +1105,7 @@ var PROFILES_RAW = [
1096
1105
  // deepseek-reasoner registered as aliases (see ALIASES below).
1097
1106
  {
1098
1107
  id: "deepseek-v4-flash",
1099
- verifiedAgainstDocs: "2026-05-08",
1108
+ verifiedAgainstDocs: "2026-08-24",
1100
1109
  provider: "deepseek",
1101
1110
  status: "current",
1102
1111
  maxContextTokens: 1e6,
@@ -1114,8 +1123,8 @@ var PROFILES_RAW = [
1114
1123
  reason: "Sequential tool calls only \u2014 L-040"
1115
1124
  }
1116
1125
  ],
1117
- costInputPer1m: 0.14,
1118
- costOutputPer1m: 0.28,
1126
+ costInputPer1m: 0.44,
1127
+ costOutputPer1m: 1.32,
1119
1128
  lowering: {
1120
1129
  system: { mode: "inline" },
1121
1130
  cache: { strategy: "unsupported" },
@@ -1134,7 +1143,7 @@ var PROFILES_RAW = [
1134
1143
  // baseQuality (it carries 'reasoning') with no latency counterweight,
1135
1144
  // leapfrogged gemini-2.5-flash as PB's summarize leader once reachable.
1136
1145
  latencyTier: "slow",
1137
- notes: "Cheap workhorse. 1M context, 384k max output. Cache-hit input $0.0028/M (1/50\xD7 of miss). Aliased as `deepseek-chat` (non-thinking) and `deepseek-reasoner` (thinking) \u2014 see ALIASES.",
1146
+ notes: "Cheap workhorse. 1M context, 384k max output. Cache-hit input $0.0028/M (1/50\xD7 of miss). Aliased as `deepseek-chat` (non-thinking) and `deepseek-reasoner` (thinking) \u2014 see ALIASES. PEAK/OFF-PEAK since 2026-08-16 (page fetched 2026-08-24): peak = weekdays 01:00-04:00 + 06:00-10:00 UTC, off-peak = all other hours at HALF peak. Encoded prices ARE the peak rate (conservative: never understate cost); off-peak traffic costs half what the estimate says. alpha.87 shipped the DEAD pre-transition prices ($0.14/$0.28 flash, $0.435/$0.87 pro) with a fresh verification stamp \u2014 corrected here (alpha.88). A single price field cannot represent a two-rate schedule; catalog-sync extractions oscillate between the rates day-to-day (peak read 08-21, off-peak read 08-22) \u2014 time-of-day pricing remains unmodeled, roadmap.",
1138
1147
  // Master plan §6.2 anchor. Brain-validated tier 1 cross-provider for
1139
1148
  // classify (169 rows, 0% empty). Tier 0 for summarize-with-no-tools.
1140
1149
  // Falls off on hunt (sequential tools — L-040) and reasoning depth.
@@ -1169,7 +1178,7 @@ var PROFILES_RAW = [
1169
1178
  },
1170
1179
  {
1171
1180
  id: "deepseek-v4-pro",
1172
- verifiedAgainstDocs: "2026-06-22",
1181
+ verifiedAgainstDocs: "2026-08-24",
1173
1182
  provider: "deepseek",
1174
1183
  status: "current",
1175
1184
  maxContextTokens: 1e6,
@@ -1193,8 +1202,8 @@ var PROFILES_RAW = [
1193
1202
  // cache-hit in; no promo caveat). The old $1.74/$3.48 "regular post-promo"
1194
1203
  // was a projected revert that never happened (L-073/L-081) — it 4×-overstated
1195
1204
  // cost and suppressed V4-Pro in cost-aware ranking.
1196
- costInputPer1m: 0.435,
1197
- costOutputPer1m: 0.87,
1205
+ costInputPer1m: 1.32,
1206
+ costOutputPer1m: 3.96,
1198
1207
  lowering: {
1199
1208
  system: { mode: "inline" },
1200
1209
  cache: { strategy: "unsupported" },
@@ -1210,7 +1219,7 @@ var PROFILES_RAW = [
1210
1219
  // of the served set. Tag derivation would say 'medium'; the measurement says
1211
1220
  // otherwise.
1212
1221
  latencyTier: "slow",
1213
- notes: "Pro tier. 1M context, 384k max output. $0.435/$0.87 per 1M (cache-hit in $0.003625) \u2014 verified live 2026-06-22; the launch promo became the standing price (no revert). Default mode = thinking.",
1222
+ notes: "Pro tier. 1M context, 384k max output. $0.435/$0.87 per 1M (cache-hit in $0.003625) \u2014 verified live 2026-06-22; the launch promo became the standing price (no revert). Default mode = thinking. PEAK/OFF-PEAK since 2026-08-16 (page fetched 2026-08-24): peak = weekdays 01:00-04:00 + 06:00-10:00 UTC, off-peak = all other hours at HALF peak. Encoded prices ARE the peak rate (conservative: never understate cost); off-peak traffic costs half what the estimate says. alpha.87 shipped the DEAD pre-transition prices ($0.14/$0.28 flash, $0.435/$0.87 pro) with a fresh verification stamp \u2014 corrected here (alpha.88). A single price field cannot represent a two-rate schedule; catalog-sync extractions oscillate between the rates day-to-day (peak read 08-21, off-peak read 08-22) \u2014 time-of-day pricing remains unmodeled, roadmap.",
1214
1223
  // Master plan §3.3: tier 3 cross-provider for plan chain. Reasoning
1215
1224
  // bumped one notch over V4-Flash; same parallel-tool ceiling.
1216
1225
  archetypePerf: {
@@ -1818,13 +1827,111 @@ var PROFILES_RAW = [
1818
1827
  // +1 vs 2.5-flash — but still below Sonnet/Opus reasoning floor
1819
1828
  }
1820
1829
  },
1830
+ // ─────────────────────────────────────────────────────────────────────────
1831
+ // gemini-3.6-flash — hand-onboarded s86 (2026-08-14), step-zero against
1832
+ // Google docs (models/gemini-3.6-flash page + pricing via catalog-sync's
1833
+ // two-agreeing-extraction the same day). Docs list it as Stable and call
1834
+ // it "previous-generation Flash" (3.5-flash is now "legacy" in Google's
1835
+ // wording) — but kgauto status is 'preview' per the standing entry rule:
1836
+ // a new model enters on capability data verified only at the docs level,
1837
+ // preview is unreachable by starter chains, and promotion to routing
1838
+ // happens through brain evidence, not through Google's marketing tier.
1839
+ // This also means NO family-primary retarget rides this release.
1840
+ // ─────────────────────────────────────────────────────────────────────────
1841
+ {
1842
+ id: "gemini-3.6-flash",
1843
+ verifiedAgainstDocs: "2026-08-24",
1844
+ versionAdded: "2.0.0-alpha.87",
1845
+ provider: "google",
1846
+ status: "preview",
1847
+ maxContextTokens: 1048576,
1848
+ maxOutputTokens: 65536,
1849
+ maxTools: 128,
1850
+ parallelToolCalls: true,
1851
+ structuredOutput: "native",
1852
+ systemPromptMode: "separate",
1853
+ streaming: true,
1854
+ cliffs: [
1855
+ {
1856
+ metric: "input_tokens",
1857
+ threshold: 8e3,
1858
+ action: "downgrade_quality_warning",
1859
+ reason: "Inherited Flash-family guard (2.5\u21923.5 lineage); no 3.6 brain evidence yet"
1860
+ },
1861
+ {
1862
+ metric: "tool_count",
1863
+ threshold: 20,
1864
+ action: "drop_to_top_relevant",
1865
+ reason: "Inherited from Flash family: tool reliability drops above ~20 (despite 128 hard limit). Validate per (archetype, model) after n\u226520."
1866
+ },
1867
+ {
1868
+ metric: "thinking_with_short_output",
1869
+ threshold: 1,
1870
+ action: "force_thinking_budget_zero",
1871
+ reason: "Thinking supported per Google docs; same drain risk as 2.5/3.5-flash \u2014 thinking tokens consume maxOutputTokens"
1872
+ },
1873
+ {
1874
+ metric: "tool_count",
1875
+ threshold: 1,
1876
+ whenIntent: "summarize",
1877
+ action: "strip_tools",
1878
+ reason: "Inherited from 2.5-flash s11 cliff: summarize+tools \u2192 empty response. Preemptive family guard until brain evidence on 3.6-flash specifically."
1879
+ }
1880
+ ],
1881
+ costInputPer1m: 0.75,
1882
+ // promo through 2026-12-31; $1.50 from 2027-01-01 (TIME_BOUNDED_PRICING_ROWS carries the transition)
1883
+ costOutputPer1m: 3.75,
1884
+ // promo through 2026-12-31; $7.50 from 2027-01-01
1885
+ lowering: {
1886
+ ...GOOGLE_LOWERING_BASE,
1887
+ cache: { ...GOOGLE_LOWERING_BASE.cache, discount: 0.1 },
1888
+ thinking: { field: "generationConfig.thinkingConfig.thinkingBudget", default: "auto" }
1889
+ },
1890
+ recovery: [
1891
+ {
1892
+ signal: "empty_response_after_tool",
1893
+ action: "retry_with_params",
1894
+ retryParams: { "generationConfig.thinkingConfig.thinkingBudget": 0 },
1895
+ maxRetries: 1,
1896
+ reason: "Inherited Flash-family pattern: empty after tool result \u2014 retry with thinking off"
1897
+ },
1898
+ {
1899
+ signal: "empty_response",
1900
+ action: "retry_with_params",
1901
+ retryParams: { "generationConfig.thinkingConfig.thinkingBudget": 0 },
1902
+ maxRetries: 1,
1903
+ reason: "Empty response \u2014 try with thinking off"
1904
+ },
1905
+ {
1906
+ signal: "malformed_function_call",
1907
+ action: "escalate",
1908
+ reason: "MALFORMED_FUNCTION_CALL maps to stop \u2014 escalate to next target"
1909
+ }
1910
+ ],
1911
+ strengths: ["agentic_loops", "coding", "1m_context", "parallel_tools", "thinking_mode"],
1912
+ weaknesses: ["no_brain_evidence_yet"],
1913
+ notes: "Hand-onboarded s86 (2026-08-24; the session ran under a 10-day-slow machine clock, hence 08-14 stamps in kin artifacts), step-zero verified: 1,048,576 ctx / 65,536 out (Google model page). PRICING (page 2026-08-24): $0.75/$3.75 promo through 2026-12-31, $1.50/$7.50 from 2027-01-01 \u2014 the alpha.87 profile carried the post-promo rate as if current; corrected alpha.88. Docs status Stable; enters kgauto as preview per standing rule (availability != lifecycle, promotion via brain evidence). Function calling + structured outputs + thinking per docs; parallel tools assumed per Flash family (docs silent). First flagged by the release watcher s73 (2026-07-24); ~31 days in the onboarding queue.",
1914
+ archetypePerf: {
1915
+ hunt: 9,
1916
+ // Flash-family parallel-tool tier (L-040); inherited from 3.5-flash
1917
+ classify: 7,
1918
+ summarize: 7,
1919
+ transform: 7,
1920
+ ask: 8,
1921
+ generate: 8,
1922
+ plan: 7,
1923
+ extract: 7,
1924
+ critique: 5
1925
+ }
1926
+ },
1821
1927
  {
1822
1928
  // Auto-onboarded 2026-07-01 from `claude-sonnet-4-6`; VERIFIED 2026-07-02
1823
1929
  // against the claude-api reference (cc-portfolio ratification pass). The
1824
- // clone got context right (1M) and pricing right at sticker ($3/$15
1825
- // NOTE an introductory $2/$10 per MTok runs through 2026-08-31; sticker
1826
- // encoded here per the time-bounded-pricing convention, intro belongs in
1827
- // brain kgauto_pricing if worth capturing). The clone got max output WRONG:
1930
+ // clone got context right (1M). PRICING RE-BASED 2026-08-14 (s86): the
1931
+ // introductory $2/$10 was made PERMANENT Anthropic's pricing page now
1932
+ // states the scheduled Sept-1 increase to $3/$15 "will not occur", so
1933
+ // $2/$10 IS the sticker. (The $3/$15 encoded 07-02 was correct under the
1934
+ // time-bounded-pricing convention at the time; the bound was cancelled.) The clone got max output WRONG:
1828
1935
  // Sonnet 5 is 128k, not 4-6's 64k — corrected. New tokenizer (~30% more
1829
1936
  // tokens for the same text vs 4-6): byte-budget consumers should re-baseline.
1830
1937
  // API quirks (claude-api ref): (a) NON-DEFAULT temperature/top_p/top_k
@@ -1837,7 +1944,7 @@ var PROFILES_RAW = [
1837
1944
  // 'preview' per the Fable precedent — no brain evidence yet; promotion to
1838
1945
  // 'current' is an explicit call. (L-049/L-081.)
1839
1946
  id: "claude-sonnet-5",
1840
- verifiedAgainstDocs: "2026-07-02",
1947
+ verifiedAgainstDocs: "2026-08-24",
1841
1948
  provider: "anthropic",
1842
1949
  status: "current",
1843
1950
  // s76 2026-07-25: GA per docs; was preview.
@@ -1849,8 +1956,9 @@ var PROFILES_RAW = [
1849
1956
  systemPromptMode: "inline",
1850
1957
  streaming: true,
1851
1958
  cliffs: [],
1852
- costInputPer1m: 3,
1853
- costOutputPer1m: 15,
1959
+ costInputPer1m: 2,
1960
+ // 2026-08-24: intro price made PERMANENT (docs: "the previously scheduled increase to $3/$15 on September 1, 2026 will not occur")
1961
+ costOutputPer1m: 10,
1854
1962
  lowering: ANTHROPIC_LOWERING_BASE,
1855
1963
  recovery: [
1856
1964
  { signal: "rate_limit", action: "escalate", reason: "429 \u2014 escalate" },
@@ -2041,6 +2149,55 @@ function _setProfileBrainHook(hook) {
2041
2149
  function canonicalId(id) {
2042
2150
  return brainHook.resolveAlias?.(id) ?? ALIASES[id] ?? id;
2043
2151
  }
2152
+ var CONSUMER_INDEX = /* @__PURE__ */ new Map();
2153
+ function registerProfiles(profiles) {
2154
+ for (const p of profiles) CONSUMER_INDEX.set(p.id, p);
2155
+ }
2156
+ function _testClearConsumerProfiles() {
2157
+ CONSUMER_INDEX.clear();
2158
+ }
2159
+ function inferProviderFromId(id) {
2160
+ const lower2 = id.toLowerCase();
2161
+ if (lower2.startsWith("claude")) return "anthropic";
2162
+ if (lower2.startsWith("gemini") || lower2.startsWith("palm")) return "google";
2163
+ if (lower2.startsWith("gpt") || /^o[0-9]/.test(lower2) || lower2.startsWith("chatgpt")) return "openai";
2164
+ if (lower2.startsWith("deepseek")) return "deepseek";
2165
+ if (lower2.startsWith("glm")) return "zai";
2166
+ if (lower2.startsWith("kimi") || lower2.startsWith("moonshot")) return "moonshot";
2167
+ return void 0;
2168
+ }
2169
+ function bestEffortProfile(id) {
2170
+ const canonical = canonicalId(id);
2171
+ const existing = tryGetProfile(canonical);
2172
+ if (existing) return existing;
2173
+ const provider = inferProviderFromId(canonical);
2174
+ if (!provider) return void 0;
2175
+ const donor = PROFILES_RAW.find((p) => p.provider === provider && p.status === "current") ?? PROFILES_RAW.find((p) => p.provider === provider);
2176
+ if (!donor) return void 0;
2177
+ const synth = {
2178
+ id: canonical,
2179
+ provider,
2180
+ bestEffort: true,
2181
+ status: "preview",
2182
+ maxContextTokens: 128e3,
2183
+ maxOutputTokens: 4096,
2184
+ maxTools: donor.maxTools,
2185
+ parallelToolCalls: false,
2186
+ structuredOutput: "none",
2187
+ systemPromptMode: donor.systemPromptMode,
2188
+ streaming: donor.streaming,
2189
+ cliffs: [],
2190
+ costInputPer1m: 0,
2191
+ costOutputPer1m: 0,
2192
+ lowering: donor.lowering,
2193
+ recovery: [],
2194
+ strengths: [],
2195
+ weaknesses: ["best-effort synthesized profile \u2014 no verified capability data"],
2196
+ notes: `Synthesized by onUnprofiledModel:'best-effort' (provider ${provider} inferred from id; wire mechanics borrowed from ${donor.id}). No cliffs, no measured knowledge, cost UNKNOWN (recorded as 0). Replace via registerProfiles() for real guards.`
2197
+ };
2198
+ CONSUMER_INDEX.set(canonical, synth);
2199
+ return synth;
2200
+ }
2044
2201
  function resolveModelAlias(id) {
2045
2202
  return canonicalId(id);
2046
2203
  }
@@ -2049,18 +2206,22 @@ var PROFILE_INDEX = new Map(
2049
2206
  );
2050
2207
  function getProfile(id) {
2051
2208
  const canonical = canonicalId(id);
2209
+ const fromConsumer = CONSUMER_INDEX.get(canonical);
2210
+ if (fromConsumer) return fromConsumer;
2052
2211
  const fromBrain = brainHook.getProfile?.(canonical);
2053
2212
  if (fromBrain) return fromBrain;
2054
2213
  const p = PROFILE_INDEX.get(canonical);
2055
2214
  if (!p) {
2056
2215
  const known = [...PROFILE_INDEX.keys(), ...Object.keys(ALIASES)].join(", ");
2057
- throw new Error(`Unknown model id: "${id}". Known: ${known}`);
2216
+ throw new Error(
2217
+ `Unknown model id: "${id}". Known: ${known}. For a model kgauto has not onboarded: registerProfiles([...]) supplies a full profile, or policy.onUnprofiledModel:'best-effort' compiles with guards skipped (alpha.87).`
2218
+ );
2058
2219
  }
2059
2220
  return p;
2060
2221
  }
2061
2222
  function tryGetProfile(id) {
2062
2223
  const canonical = canonicalId(id);
2063
- return brainHook.getProfile?.(canonical) ?? PROFILE_INDEX.get(canonical);
2224
+ return CONSUMER_INDEX.get(canonical) ?? brainHook.getProfile?.(canonical) ?? PROFILE_INDEX.get(canonical);
2064
2225
  }
2065
2226
  function allProfiles() {
2066
2227
  return PROFILES_RAW;
@@ -2339,6 +2500,9 @@ function mapRowsToFindings(rows) {
2339
2500
  return out;
2340
2501
  }
2341
2502
  var snapshots = /* @__PURE__ */ new Map();
2503
+ function exclusionFindingsFreshness(appId) {
2504
+ return snapshots.get(appId)?.loaded ? "warm" : "cold";
2505
+ }
2342
2506
  var runtime2;
2343
2507
  var warnedOnce = false;
2344
2508
  var DEFAULT_FINDINGS_ENDPOINT = "https://kgauto-dashboard.vercel.app/api/kgauto-v2/findings/exclusions";
@@ -2399,6 +2563,7 @@ async function doRefresh2(rt, appId) {
2399
2563
  if (runtime2 !== rt) return;
2400
2564
  const rows = Array.isArray(body) ? mapRowsToFindings(body) : [];
2401
2565
  snap.data = rows;
2566
+ snap.loaded = true;
2402
2567
  snap.expiresAt = Date.now() + rt.ttlMs;
2403
2568
  snap.refreshing = false;
2404
2569
  } catch (err) {
@@ -4356,6 +4521,9 @@ function judgeMeasuredFailure(row, cfg = MEASURED_FAILURE_CFG) {
4356
4521
  };
4357
4522
  }
4358
4523
  var snapshots2 = /* @__PURE__ */ new Map();
4524
+ function measuredFailureFreshness(appId) {
4525
+ return snapshots2.get(appId)?.loaded ? "warm" : "cold";
4526
+ }
4359
4527
  var runtime3;
4360
4528
  var warnedOnce2 = false;
4361
4529
  var DEFAULT_MEASURED_FAILURE_ENDPOINT = "https://kgauto-dashboard.vercel.app/api/kgauto-v2/measured-failure";
@@ -4453,6 +4621,7 @@ async function doRefresh3(rt, appId) {
4453
4621
  const body = await res.json();
4454
4622
  if (runtime3 !== rt) return;
4455
4623
  snap.data = Array.isArray(body) ? mapRows(body) : [];
4624
+ snap.loaded = true;
4456
4625
  snap.expiresAt = Date.now() + rt.ttlMs;
4457
4626
  snap.refreshing = false;
4458
4627
  } catch (err) {
@@ -4524,6 +4693,9 @@ function mapRowsToPromotions(rows) {
4524
4693
  return out;
4525
4694
  }
4526
4695
  var snapshots3 = /* @__PURE__ */ new Map();
4696
+ function promotionsFreshness(appId) {
4697
+ return snapshots3.get(appId)?.loaded ? "warm" : "cold";
4698
+ }
4527
4699
  var runtime4;
4528
4700
  var warnedOnce3 = false;
4529
4701
  var DEFAULT_PROMOTIONS_ENDPOINT = "https://kgauto-dashboard.vercel.app/api/kgauto-v2/promotions";
@@ -4608,6 +4780,7 @@ async function doRefresh4(rt, appId) {
4608
4780
  if (runtime4 !== rt) return;
4609
4781
  const rows = Array.isArray(body) ? mapRowsToPromotions(body) : [];
4610
4782
  snap.data = rows;
4783
+ snap.loaded = true;
4611
4784
  snap.expiresAt = Date.now() + rt.ttlMs;
4612
4785
  snap.refreshing = false;
4613
4786
  } catch (err) {
@@ -4708,6 +4881,9 @@ function mapRowsToFindings2(rows) {
4708
4881
  return out;
4709
4882
  }
4710
4883
  var snapshots4 = /* @__PURE__ */ new Map();
4884
+ function promoteReadyFreshness(appId) {
4885
+ return snapshots4.get(appId)?.loaded ? "warm" : "cold";
4886
+ }
4711
4887
  var runtime5;
4712
4888
  var warnedOnce4 = false;
4713
4889
  function isPromoteReadyBrainActive() {
@@ -4766,6 +4942,7 @@ async function doRefresh5(rt, appId) {
4766
4942
  if (runtime5 !== rt) return;
4767
4943
  const rows = Array.isArray(body) ? mapRowsToFindings2(body) : [];
4768
4944
  snap.data = rows;
4945
+ snap.loaded = true;
4769
4946
  snap.expiresAt = Date.now() + rt.ttlMs;
4770
4947
  snap.refreshing = false;
4771
4948
  } catch (err) {
@@ -5715,7 +5892,16 @@ function makeHandle() {
5715
5892
  return `c${Date.now().toString(36)}-${counter.toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
5716
5893
  }
5717
5894
  function compile(ir, opts = {}) {
5718
- const resolver = opts.profileResolver ?? getProfile;
5895
+ const baseResolver = opts.profileResolver ?? getProfile;
5896
+ const resolver = opts.policy?.onUnprofiledModel === "best-effort" ? (id) => {
5897
+ try {
5898
+ return baseResolver(id);
5899
+ } catch (err) {
5900
+ const synth = bestEffortProfile(id);
5901
+ if (!synth) throw err;
5902
+ return synth;
5903
+ }
5904
+ } : baseResolver;
5719
5905
  validateIR(ir);
5720
5906
  ir = resolveModelEntries(ir);
5721
5907
  const sliced = passSlice(ir);
@@ -5775,11 +5961,26 @@ function compile(ir, opts = {}) {
5775
5961
  accumulatedMutations.push(...scores.mutations);
5776
5962
  const target = pickTarget(workingIR, scores.value);
5777
5963
  if (!target) {
5964
+ const unknownIds = scores.value.filter((s) => s.rejectReasons?.includes("unknown_model_id")).map((s) => s.modelId);
5965
+ const uninferable = unknownIds.filter((id) => !inferProviderFromId(id));
5966
+ const unknownHint = unknownIds.length > 0 ? ` Unprofiled model id(s): ${unknownIds.join(", ")}. registerProfiles([...]) supplies a full profile; policy.onUnprofiledModel:'best-effort' compiles with guards skipped.` + (uninferable.length > 0 ? ` Note: provider is not inferable from ${uninferable.join(", ")}, so best-effort cannot lower it \u2014 registerProfiles is the only path for those.` : "") : "";
5778
5967
  throw new Error(
5779
- `compile(): no allowed model fits the request. Scores: ${JSON.stringify(scores.value, null, 2)}`
5968
+ `compile(): no allowed model fits the request.${unknownHint} Scores: ${JSON.stringify(scores.value, null, 2)}`
5780
5969
  );
5781
5970
  }
5782
5971
  const profile = resolver(target.modelId);
5972
+ const bestEffortWarnings = [];
5973
+ if (profile.bestEffort) {
5974
+ bestEffortWarnings.push(
5975
+ `best-effort profile in use for "${profile.id}" (provider ${profile.provider} inferred from the id; wire mechanics borrowed). SKIPPED for this model: cliff guards, recovery rules, measured archetype knowledge, structured-output capability (treated as 'none'), parallel tools (treated as sequential). Cost is UNKNOWN and recorded as $0 \u2014 cost gates and cost attribution are meaningless for this model. registerProfiles() restores real guards.`
5976
+ );
5977
+ accumulatedMutations.push({
5978
+ id: `best_effort_profile_${profile.id}`,
5979
+ source: "best_effort",
5980
+ passName: "resolve-profile",
5981
+ description: `Unprofiled model "${profile.id}" compiled under onUnprofiledModel:'best-effort' \u2014 guards skipped, cost unknown. See diagnostics.cliffWarnings for the full list.`
5982
+ });
5983
+ }
5783
5984
  const fallbackChain = scores.value.filter((s) => s.modelId !== target.modelId && s.fits).sort((a, b) => b.rank - a.rank).map((s) => s.modelId);
5784
5985
  const cliffs = passApplyCliffs(workingIR, profile, inputTokens);
5785
5986
  workingIR = cliffs.value.ir;
@@ -5865,6 +6066,23 @@ function compile(ir, opts = {}) {
5865
6066
  const historyCacheMarkIndex = computeHistoryCacheMarkIndex(workingIR);
5866
6067
  const systemMessages = buildSystemMessages(workingIR, profile.provider);
5867
6068
  const systemCacheMarkIndex = lastCacheableSystemIndex(systemMessages);
6069
+ const keptSectionIds = new Set(workingIR.sections.map((s) => s.id));
6070
+ const cachePrefixActive = lowered.diagnostics.cacheableTokens > 0;
6071
+ const cacheReadFraction = profile.lowering.cache.discount ?? 0.25;
6072
+ const sectionAttribution = ir.sections.map((s) => {
6073
+ const tokens = countTokens(s.text);
6074
+ const kept = keptSectionIds.has(s.id);
6075
+ const estCostUsdFirstCall = kept ? tokens / 1e6 * profile.costInputPer1m : 0;
6076
+ const inActiveCachePrefix = kept && s.cacheable === true && cachePrefixActive;
6077
+ return {
6078
+ id: s.id,
6079
+ tokens,
6080
+ kept,
6081
+ cacheable: s.cacheable === true,
6082
+ estCostUsdFirstCall,
6083
+ estCostUsdWarm: inActiveCachePrefix ? estCostUsdFirstCall * cacheReadFraction : estCostUsdFirstCall
6084
+ };
6085
+ });
5868
6086
  const diagnostics = {
5869
6087
  sectionsKept: workingIR.sections.length,
5870
6088
  sectionsDropped: ir.sections.length - workingIR.sections.length,
@@ -5888,11 +6106,25 @@ function compile(ir, opts = {}) {
5888
6106
  // text the consumer can route on without changing behavior).
5889
6107
  cliffWarnings: [
5890
6108
  ...cliffs.value.loweringHints.qualityWarning ?? [],
5891
- ...conventions.value.cliffWarnings
6109
+ ...conventions.value.cliffWarnings,
6110
+ // alpha.87 — best-effort profile in use (loud on EVERY compile).
6111
+ ...bestEffortWarnings
5892
6112
  ],
5893
6113
  // alpha.68 / Release A — measured discipline gate-token tax (§5.D). 0 when
5894
6114
  // the gate didn't fire.
5895
- disciplineGateTokens
6115
+ disciplineGateTokens,
6116
+ // alpha.87 — per-source freshness stamped at the moment the compile's
6117
+ // reads have all happened, from state each source already tracks (the
6118
+ // "one-line stamp at the point where the source is already known and
6119
+ // discarded" this filing reduced to once alpha.73/.86 warmed the caches).
6120
+ freshness: {
6121
+ config: configFreshness(),
6122
+ measuredFailure: measuredFailureFreshness(ir.appId),
6123
+ promotions: promotionsFreshness(ir.appId),
6124
+ exclusions: exclusionFindingsFreshness(ir.appId),
6125
+ promoteReady: promoteReadyFreshness(ir.appId)
6126
+ },
6127
+ sections: sectionAttribution
5896
6128
  };
5897
6129
  if (ir.intent.archetype === "hunt" && ir.constraints?.toolOrchestration === "sequential") {
5898
6130
  accumulatedMutations.push({
@@ -6057,7 +6289,7 @@ function validateFinalFit(ir, profile, tokens) {
6057
6289
  }
6058
6290
 
6059
6291
  // src/version.ts
6060
- var LIBRARY_VERSION = "2.0.0-alpha.86";
6292
+ var LIBRARY_VERSION = "2.0.0-alpha.88";
6061
6293
 
6062
6294
  // src/pricing-brain.ts
6063
6295
  function isPricingRow(x) {
@@ -6431,6 +6663,26 @@ function maybeWarnDiscardedCompile(reg, handle) {
6431
6663
  `[kgauto] compile-then-discard: compileForAISDKv6() output for handle ${handle} (archetype=${reg.archetype}, model=${reg.model}) was recorded but neither .system, .model, nor .raw was read before record(). The brain row's mutations_applied / estimated_tokens_in / system_prompt_chars describe a compile that did NOT shape the served call. Pass compiled.system + compiled.model into your generateText/streamText (or use call()). Silence via configureBrain({ warnOnDiscardedCompile: false }).`
6432
6664
  );
6433
6665
  }
6666
+ var OUTCOME_SOURCES = ["canary", "smoke", "eval", "probe", "synthetic"];
6667
+ var warnedInvalidEnvSource = false;
6668
+ function resolveOutcomeSource(explicit) {
6669
+ if (explicit) return explicit;
6670
+ const raw = typeof process !== "undefined" ? process.env?.KGAUTO_SOURCE : void 0;
6671
+ if (!raw) return void 0;
6672
+ const trimmed = raw.trim();
6673
+ if (!trimmed) return void 0;
6674
+ if (OUTCOME_SOURCES.includes(trimmed)) return trimmed;
6675
+ if (!warnedInvalidEnvSource) {
6676
+ warnedInvalidEnvSource = true;
6677
+ console.warn(
6678
+ `[kgauto] KGAUTO_SOURCE="${trimmed}" is not one of ${OUTCOME_SOURCES.join("|")} \u2014 recording as 'synthetic' so the row survives the brain's CHECK constraint and stays out of organic-liveness stats.`
6679
+ );
6680
+ }
6681
+ return "synthetic";
6682
+ }
6683
+ function _testResetOutcomeSourceWarning() {
6684
+ warnedInvalidEnvSource = false;
6685
+ }
6434
6686
  async function record(input) {
6435
6687
  const reg = compileRegistry.get(input.handle);
6436
6688
  if (reg) {
@@ -6545,7 +6797,9 @@ function buildPayload(input, reg) {
6545
6797
  latency_ms: input.latencyMs,
6546
6798
  success: input.success,
6547
6799
  empty_response: input.emptyResponse ?? input.tokensOut === 0,
6548
- source: input.source,
6800
+ // alpha.87 — explicit source wins; KGAUTO_SOURCE env fills the gap (the
6801
+ // zero-code synthetic self-mark for harness/smoke processes).
6802
+ source: resolveOutcomeSource(input.source),
6549
6803
  error_type: input.errorType,
6550
6804
  tools_called: input.toolsCalled,
6551
6805
  oracle_score: input.oracleScore?.score,
@@ -10837,7 +11091,9 @@ function compile2(ir, opts) {
10837
11091
  STRATEGY_AUTHORSHIP_INDEPENDENT,
10838
11092
  STRATEGY_AUTHORSHIP_LIMITATION,
10839
11093
  TRANSLATOR_FLOOR,
11094
+ _testClearConsumerProfiles,
10840
11095
  _testResetMeasuredFailure,
11096
+ _testResetOutcomeSourceWarning,
10841
11097
  _testResetPromotions,
10842
11098
  _testWaitForMeasuredFailureRefresh,
10843
11099
  _testWaitForPromotionsRefresh,
@@ -10849,6 +11105,7 @@ function compile2(ir, opts) {
10849
11105
  attachCacheControlToStreamTextInput,
10850
11106
  awaitMeasuredFailureReady,
10851
11107
  awaitPromotionsReady,
11108
+ bestEffortProfile,
10852
11109
  brainHealth,
10853
11110
  bucketContext,
10854
11111
  bucketHistory,
@@ -10903,6 +11160,7 @@ function compile2(ir, opts) {
10903
11160
  getStarterChainWithGrounding,
10904
11161
  hasMutation,
10905
11162
  hashShape,
11163
+ inferProviderFromId,
10906
11164
  isAltStrategy,
10907
11165
  isArchetype,
10908
11166
  isAutoPromoteEnabledFromEnv,
@@ -10944,11 +11202,13 @@ function compile2(ir, opts) {
10944
11202
  recordGoldenIr,
10945
11203
  recordOutcome,
10946
11204
  recordShadowProbe,
11205
+ registerProfiles,
10947
11206
  renderIrForJudge,
10948
11207
  resetTokenizer,
10949
11208
  resolveConventionsForProfile,
10950
11209
  resolveGoldenCaptureRate,
10951
11210
  resolveModelAlias,
11211
+ resolveOutcomeSource,
10952
11212
  resolvePricingAt,
10953
11213
  resolveProviderKey,
10954
11214
  rowToAdvisory,