@warmdrift/kgauto-compiler 2.0.0-alpha.82 → 2.0.0-alpha.83
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-L246YOV7.mjs → chunk-QEFIAAE7.mjs} +1 -1
- package/dist/index.d.mts +181 -12
- package/dist/index.d.ts +181 -12
- package/dist/index.js +144 -11
- package/dist/index.mjs +132 -11
- package/dist/key-health.js +1 -1
- package/dist/key-health.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -965,7 +965,11 @@ type GoldenEvalAxis = 'model' | 'strategy';
|
|
|
965
965
|
* measurable against its exact frozen bytes. The `-alt` wording is
|
|
966
966
|
* EVAL-ONLY: it exists to attribute a v1 loss to wording vs mechanism
|
|
967
967
|
* (§6) and never ships in a production compile. */
|
|
968
|
-
type GoldenEvalStrategyId = 'discipline-gates-v1' | 'discipline-gates-v1-alt';
|
|
968
|
+
type GoldenEvalStrategyId = 'discipline-gates-v1' | 'discipline-gates-v1-alt' | 'discipline-gates-v1-alt-blind';
|
|
969
|
+
/** Both re-wordings of v1. Dispatch keys on this, never on a string prefix,
|
|
970
|
+
* so adding a fourth arm is one edit rather than a grep. */
|
|
971
|
+
declare const ALT_STRATEGY_IDS: readonly GoldenEvalStrategyId[];
|
|
972
|
+
declare function isAltStrategy(id: GoldenEvalStrategyId | undefined): boolean;
|
|
969
973
|
interface GoldenEvalOptions {
|
|
970
974
|
appId: string;
|
|
971
975
|
archetype: string;
|
|
@@ -1085,6 +1089,45 @@ declare function altGatesBlockFor(args: {
|
|
|
1085
1089
|
outputMode: 'text' | 'json' | 'tool_call';
|
|
1086
1090
|
hasTools: boolean;
|
|
1087
1091
|
}): string;
|
|
1092
|
+
declare const ALT_BLIND_TOKEN_BUDGET_BREACH: {
|
|
1093
|
+
readonly ceilingTokens: 264;
|
|
1094
|
+
readonly measuredTokensTextWithTools: 285;
|
|
1095
|
+
readonly note: string;
|
|
1096
|
+
};
|
|
1097
|
+
declare const DISCIPLINE_GATES_V1_ALT_BLIND_HEADER = "Before stating any conclusion, run this check:";
|
|
1098
|
+
/**
|
|
1099
|
+
* The variant matrix — and this is the ONE place this seat's judgment enters
|
|
1100
|
+
* the blind arm, so it is stated rather than buried.
|
|
1101
|
+
*
|
|
1102
|
+
* cc's instruction: adapt MECHANICALLY where the injection format demands it,
|
|
1103
|
+
* note the diff, never edit semantics. Choosing which gates to drop per
|
|
1104
|
+
* surface is a selection, not an edit — the bytes of every retained gate are
|
|
1105
|
+
* untouched — but the selection is still mine, so:
|
|
1106
|
+
*
|
|
1107
|
+
* NO TOOLS drops `toolPredict`. Forced, not chosen: the string opens
|
|
1108
|
+
* "When using tools" and is literally inapplicable without them.
|
|
1109
|
+
* Mirrors v1 dropping its compressed-item bullet.
|
|
1110
|
+
* STRUCTURED drops `markAssumed` ONLY. It is the sole gate whose entire
|
|
1111
|
+
* function is text in the final answer ('mark anything unchecked
|
|
1112
|
+
* as "assumed"'), which a JSON/tool_call schema has no field for
|
|
1113
|
+
* and which would corrupt the parse.
|
|
1114
|
+
*
|
|
1115
|
+
* The judgment call worth flagging: v1 drops TWO bullets on structured
|
|
1116
|
+
* surfaces, and a stricter reading would also drop `falsify` ("state in one
|
|
1117
|
+
* line") and `deviation` ("say so explicitly"), since both demand output
|
|
1118
|
+
* text. I kept them. Their output demand is incidental (and conditional, for
|
|
1119
|
+
* `deviation`) while their primary effect is on reasoning before the answer
|
|
1120
|
+
* exists — whereas v1's dropped pair (`label`, `gap`) are purely
|
|
1121
|
+
* output-shaping. Dropping three of five would leave a two-gate arm that no
|
|
1122
|
+
* longer tests the same mechanism, and an arm crippled by my formatting
|
|
1123
|
+
* choice would read as a wording loss that was actually a scoping loss.
|
|
1124
|
+
* If the structured surface shows anomalous results, this is the first
|
|
1125
|
+
* thing to re-examine.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function altBlindGatesBlockFor(args: {
|
|
1128
|
+
outputMode: 'text' | 'json' | 'tool_call';
|
|
1129
|
+
hasTools: boolean;
|
|
1130
|
+
}): string;
|
|
1088
1131
|
/**
|
|
1089
1132
|
* The alt arm injects its block DIRECTLY as an untagged section — it must
|
|
1090
1133
|
* not carry `kind: 'discipline_contract'`, or the translator would prepend
|
|
@@ -1094,6 +1137,14 @@ declare function altGatesBlockFor(args: {
|
|
|
1094
1137
|
* no-ops — the attribution is about WORDING, and everything else is held.
|
|
1095
1138
|
*/
|
|
1096
1139
|
declare function withAltDisciplineContract(ir: PromptIR): PromptIR;
|
|
1140
|
+
/**
|
|
1141
|
+
* Same injection contract as `withAltDisciplineContract` — untagged section,
|
|
1142
|
+
* so the translator never prepends the v1 bytes on top and the arm measures
|
|
1143
|
+
* exactly one wording. Same variant inputs, so the blind arm no-ops nowhere
|
|
1144
|
+
* v1 fires and fires nowhere v1 no-ops; the comparison is about WORDING and
|
|
1145
|
+
* everything else is held.
|
|
1146
|
+
*/
|
|
1147
|
+
declare function withAltBlindDisciplineContract(ir: PromptIR): PromptIR;
|
|
1097
1148
|
declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunResult>;
|
|
1098
1149
|
/**
|
|
1099
1150
|
* Aggregate outcome of one strategy run, in gates-on terms. 'loses' is the
|
|
@@ -1107,25 +1158,54 @@ declare function classifyStrategyOutcome(r: GoldenEvalRunResult): StrategyOutcom
|
|
|
1107
1158
|
* recorded as a mechanism failure would let Factor B permanently disable a
|
|
1108
1159
|
* real capability on evidence about one author's prose.
|
|
1109
1160
|
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1161
|
+
* THREE arms since 2026-07-29. Both re-wordings run on a v1 loss, and a win
|
|
1162
|
+
* by EITHER is enough to acquit the mechanism — the question "does some
|
|
1163
|
+
* wording of this work?" is answered by one existence proof, so there is no
|
|
1164
|
+
* reason to require agreement between the alts.
|
|
1165
|
+
*
|
|
1166
|
+
* v1 vs off | alt / alt-blind vs off | attribution
|
|
1167
|
+
* ----------+------------------------+------------------------------------
|
|
1168
|
+
* wins | (not run) | mechanism-works — ship
|
|
1169
|
+
* ties | (not run) | no-lift — inconclusive at n, re-eval
|
|
1170
|
+
* loses | either wins | wording-failure — do NOT disable
|
|
1171
|
+
* loses | BOTH lose | mechanism-failure — Factor B may disable
|
|
1172
|
+
* loses | neither wins, not both lose | wording-inconclusive — no disable
|
|
1173
|
+
*
|
|
1174
|
+
* The `mechanism-failure` cell is the one that changed character. It used to
|
|
1175
|
+
* rest on two wordings by one author, so a shared blind spot (the principles
|
|
1176
|
+
* being the wrong principles) was invisible and the verdict was hedged. The
|
|
1177
|
+
* blind arm was authored by a context-free subagent with no knowledge of this
|
|
1178
|
+
* repo, the experiment, or who was asking — so a both-lose verdict now spans
|
|
1179
|
+
* independent authorship and is strong on its own terms. That is exactly the
|
|
1180
|
+
* gap `STRATEGY_AUTHORSHIP_LIMITATION` was written to confess, which is why
|
|
1181
|
+
* the limitation text is now conditional on whether the blind arm ran.
|
|
1117
1182
|
*/
|
|
1118
1183
|
type StrategyAttribution = 'mechanism-works' | 'no-lift' | 'wording-failure' | 'mechanism-failure' | 'wording-inconclusive' | 'inconclusive';
|
|
1119
1184
|
interface StrategyAttributionResult {
|
|
1120
1185
|
attribution: StrategyAttribution;
|
|
1121
1186
|
primary: GoldenEvalRunResult;
|
|
1122
|
-
/** Present ONLY when the primary lost (the loss-triggered
|
|
1187
|
+
/** Present ONLY when the primary lost (the loss-triggered arms). */
|
|
1123
1188
|
alt?: GoldenEvalRunResult;
|
|
1189
|
+
/** The independently-authored arm. Present ONLY when the primary lost. */
|
|
1190
|
+
altBlind?: GoldenEvalRunResult;
|
|
1124
1191
|
/** The authorship limitation, restated on every result so no downstream
|
|
1125
|
-
* reader can cite an attribution without it.
|
|
1192
|
+
* reader can cite an attribution without it. Which string this carries
|
|
1193
|
+
* depends on whether the blind arm actually ran — see below. */
|
|
1126
1194
|
limitation: string;
|
|
1127
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Carried when the blind arm did NOT run — i.e. v1 won or tied, so no
|
|
1198
|
+
* re-wording was measured at all and any claim about wording is unevidenced.
|
|
1199
|
+
*/
|
|
1128
1200
|
declare const STRATEGY_AUTHORSHIP_LIMITATION: string;
|
|
1201
|
+
/**
|
|
1202
|
+
* Carried when both re-wording arms ran. The shared-author caveat is GONE by
|
|
1203
|
+
* construction, and saying so is the point: the previous version of this
|
|
1204
|
+
* string confessed a gap that has since been closed, and a stale confession
|
|
1205
|
+
* is its own kind of false statement — a reader would discount a verdict
|
|
1206
|
+
* that no longer deserves discounting.
|
|
1207
|
+
*/
|
|
1208
|
+
declare const STRATEGY_AUTHORSHIP_INDEPENDENT: string;
|
|
1129
1209
|
/**
|
|
1130
1210
|
* Run the strategy eval with loss-triggered wording attribution: v1 first;
|
|
1131
1211
|
* the alt arm replays ONLY on a v1 loss (mirrors the engine's retry
|
|
@@ -1146,7 +1226,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
|
|
|
1146
1226
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1147
1227
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1148
1228
|
*/
|
|
1149
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1229
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.83";
|
|
1150
1230
|
|
|
1151
1231
|
/**
|
|
1152
1232
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -1795,6 +1875,77 @@ interface AdvisorySuggestedFix {
|
|
|
1795
1875
|
* view's snake_case columns to camelCase. See `feedback_typed_boundary_transformers.md`
|
|
1796
1876
|
* (L-118) for the rationale.
|
|
1797
1877
|
*/
|
|
1878
|
+
/**
|
|
1879
|
+
* The window of evidence a finding was computed from — migration 054.
|
|
1880
|
+
*
|
|
1881
|
+
* READ THE DISTINCTION BEFORE USING THIS. It is NOT `openedAt` /
|
|
1882
|
+
* `lastObservedAt` / `observationCount`, which describe the ADVISORY (how
|
|
1883
|
+
* long it has been firing, how many times the watcher ran and still saw the
|
|
1884
|
+
* condition). This describes what the generator LOOKED AT.
|
|
1885
|
+
*
|
|
1886
|
+
* A daily cron that keeps firing on a single 29-second burst reports
|
|
1887
|
+
* `observationCount: 11` spanning 11 days — the most standing-looking of
|
|
1888
|
+
* standing conditions — while its evidence is one event from 11 days ago.
|
|
1889
|
+
* Separating the two is the entire point.
|
|
1890
|
+
*
|
|
1891
|
+
* `null` when the generator did not state its window. Honest unknown; it
|
|
1892
|
+
* must never be read as "not a burst". Compile-time library rules carry
|
|
1893
|
+
* null legitimately — they fire on ONE call, so their evidence is the call
|
|
1894
|
+
* in hand and there is no window to state.
|
|
1895
|
+
*/
|
|
1896
|
+
interface AdvisoryEvidenceWindow {
|
|
1897
|
+
firstAt: string;
|
|
1898
|
+
lastAt: string;
|
|
1899
|
+
n: number;
|
|
1900
|
+
/** `lastAt - firstAt`, precomputed so no caller re-derives it wrong. */
|
|
1901
|
+
spanMs: number;
|
|
1902
|
+
/**
|
|
1903
|
+
* `true` when the evidence is clustered tightly enough to be ONE EVENT
|
|
1904
|
+
* rather than a standing rate. See `classifyEvidenceWindow`.
|
|
1905
|
+
*/
|
|
1906
|
+
isBurst: boolean;
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Burst-vs-rate, computed rather than judged.
|
|
1910
|
+
*
|
|
1911
|
+
* Origin: tt-intel s118. A cost query showed `claude-sonnet-5` at 30% of
|
|
1912
|
+
* their `ask` traffic and 80% of ask spend. Every number true, every
|
|
1913
|
+
* mechanism check correct, and every correct check made them more certain
|
|
1914
|
+
* the spend gate had regressed. All eleven calls sat in a 29-second window —
|
|
1915
|
+
* their own prior experiment, fixed six minutes after the last one. Their
|
|
1916
|
+
* formulation: **a cluster is an event, not a rate.**
|
|
1917
|
+
*
|
|
1918
|
+
* The rule, deliberately crude because a subtle one would need tuning per
|
|
1919
|
+
* rule and would then be wrong per rule: evidence is a burst when it spans
|
|
1920
|
+
* less than `BURST_SPAN_MS` (5 minutes). Multiple observations inside five
|
|
1921
|
+
* minutes are one incident — a deploy, a retry storm, a test run, a
|
|
1922
|
+
* benchmark — not a pattern of behavior over time.
|
|
1923
|
+
*
|
|
1924
|
+
* Two deliberate non-features:
|
|
1925
|
+
*
|
|
1926
|
+
* - **n is not in the test.** Two rows 4 minutes apart are as much a single
|
|
1927
|
+
* event as eleven are. Requiring a minimum n would let the smallest, least
|
|
1928
|
+
* evidenced findings skip the check.
|
|
1929
|
+
* - **It does not try to detect fossils.** A burst is not necessarily stale;
|
|
1930
|
+
* it is merely not a rate. Only the consumer's own deploy log can turn
|
|
1931
|
+
* "one event" into "an event we already fixed", and this library cannot
|
|
1932
|
+
* see that. Claiming otherwise would be the same over-reach the rule
|
|
1933
|
+
* exists to correct.
|
|
1934
|
+
*/
|
|
1935
|
+
declare const BURST_SPAN_MS: number;
|
|
1936
|
+
declare function classifyEvidenceWindow(row: {
|
|
1937
|
+
evidence_first_at?: string | null;
|
|
1938
|
+
evidence_last_at?: string | null;
|
|
1939
|
+
evidence_n?: number | null;
|
|
1940
|
+
}): AdvisoryEvidenceWindow | null;
|
|
1941
|
+
/** Human-readable span for advisory text. Terse by design — it sits inline. */
|
|
1942
|
+
declare function formatEvidenceSpan(spanMs: number): string;
|
|
1943
|
+
/**
|
|
1944
|
+
* The sentence that travels with a burst-shaped finding. Written to be
|
|
1945
|
+
* usable verbatim in advisory text, and to say what the library CAN claim
|
|
1946
|
+
* (one event) rather than what it cannot (that the event is stale).
|
|
1947
|
+
*/
|
|
1948
|
+
declare function burstCaveat(w: AdvisoryEvidenceWindow): string;
|
|
1798
1949
|
interface ActionableAdvisory {
|
|
1799
1950
|
id: string;
|
|
1800
1951
|
rule: string;
|
|
@@ -1802,6 +1953,18 @@ interface ActionableAdvisory {
|
|
|
1802
1953
|
openedAt: string;
|
|
1803
1954
|
lastObservedAt: string;
|
|
1804
1955
|
observationCount: number;
|
|
1956
|
+
/**
|
|
1957
|
+
* Migration 054. `null` when the generator did not state a window — an
|
|
1958
|
+
* honest unknown, NOT an assertion that the evidence is well-spread.
|
|
1959
|
+
*/
|
|
1960
|
+
evidenceWindow: AdvisoryEvidenceWindow | null;
|
|
1961
|
+
/**
|
|
1962
|
+
* The severity the rule ASKED for, present only when this advisory's
|
|
1963
|
+
* effective `severity` was downgraded because its evidence is burst-shaped.
|
|
1964
|
+
* Kept so a consumer can see the downgrade happened rather than silently
|
|
1965
|
+
* receiving a quieter advisory than the generator wrote.
|
|
1966
|
+
*/
|
|
1967
|
+
severityBeforeBurstDowngrade?: AdvisorySeverity;
|
|
1805
1968
|
appliesTo: {
|
|
1806
1969
|
archetype?: IntentArchetypeName;
|
|
1807
1970
|
model?: string;
|
|
@@ -1853,6 +2016,12 @@ interface MarkAdvisoryResolvedOptions {
|
|
|
1853
2016
|
brainAnonKey?: string;
|
|
1854
2017
|
fetch?: typeof fetch;
|
|
1855
2018
|
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Map a single `actionable_advisories_v` row (snake_case, Postgres
|
|
2021
|
+
* native) to the public `ActionableAdvisory` shape (camelCase). Single
|
|
2022
|
+
* canonical mapping site for this boundary (L-118).
|
|
2023
|
+
*/
|
|
2024
|
+
declare function rowToAdvisory(row: Record<string, unknown>): ActionableAdvisory;
|
|
1856
2025
|
/**
|
|
1857
2026
|
* Query the open advisory set for an app. Pulls from
|
|
1858
2027
|
* `actionable_advisories_v` (per-(app_id, code) rollup with stable ids
|
|
@@ -3760,4 +3929,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
|
|
|
3760
3929
|
*/
|
|
3761
3930
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3762
3931
|
|
|
3763
|
-
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, BRAIN_READ_ENV_NAMES, 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_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_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, chainProviderSpread, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, estimateModelCostUsd, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, 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, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -965,7 +965,11 @@ type GoldenEvalAxis = 'model' | 'strategy';
|
|
|
965
965
|
* measurable against its exact frozen bytes. The `-alt` wording is
|
|
966
966
|
* EVAL-ONLY: it exists to attribute a v1 loss to wording vs mechanism
|
|
967
967
|
* (§6) and never ships in a production compile. */
|
|
968
|
-
type GoldenEvalStrategyId = 'discipline-gates-v1' | 'discipline-gates-v1-alt';
|
|
968
|
+
type GoldenEvalStrategyId = 'discipline-gates-v1' | 'discipline-gates-v1-alt' | 'discipline-gates-v1-alt-blind';
|
|
969
|
+
/** Both re-wordings of v1. Dispatch keys on this, never on a string prefix,
|
|
970
|
+
* so adding a fourth arm is one edit rather than a grep. */
|
|
971
|
+
declare const ALT_STRATEGY_IDS: readonly GoldenEvalStrategyId[];
|
|
972
|
+
declare function isAltStrategy(id: GoldenEvalStrategyId | undefined): boolean;
|
|
969
973
|
interface GoldenEvalOptions {
|
|
970
974
|
appId: string;
|
|
971
975
|
archetype: string;
|
|
@@ -1085,6 +1089,45 @@ declare function altGatesBlockFor(args: {
|
|
|
1085
1089
|
outputMode: 'text' | 'json' | 'tool_call';
|
|
1086
1090
|
hasTools: boolean;
|
|
1087
1091
|
}): string;
|
|
1092
|
+
declare const ALT_BLIND_TOKEN_BUDGET_BREACH: {
|
|
1093
|
+
readonly ceilingTokens: 264;
|
|
1094
|
+
readonly measuredTokensTextWithTools: 285;
|
|
1095
|
+
readonly note: string;
|
|
1096
|
+
};
|
|
1097
|
+
declare const DISCIPLINE_GATES_V1_ALT_BLIND_HEADER = "Before stating any conclusion, run this check:";
|
|
1098
|
+
/**
|
|
1099
|
+
* The variant matrix — and this is the ONE place this seat's judgment enters
|
|
1100
|
+
* the blind arm, so it is stated rather than buried.
|
|
1101
|
+
*
|
|
1102
|
+
* cc's instruction: adapt MECHANICALLY where the injection format demands it,
|
|
1103
|
+
* note the diff, never edit semantics. Choosing which gates to drop per
|
|
1104
|
+
* surface is a selection, not an edit — the bytes of every retained gate are
|
|
1105
|
+
* untouched — but the selection is still mine, so:
|
|
1106
|
+
*
|
|
1107
|
+
* NO TOOLS drops `toolPredict`. Forced, not chosen: the string opens
|
|
1108
|
+
* "When using tools" and is literally inapplicable without them.
|
|
1109
|
+
* Mirrors v1 dropping its compressed-item bullet.
|
|
1110
|
+
* STRUCTURED drops `markAssumed` ONLY. It is the sole gate whose entire
|
|
1111
|
+
* function is text in the final answer ('mark anything unchecked
|
|
1112
|
+
* as "assumed"'), which a JSON/tool_call schema has no field for
|
|
1113
|
+
* and which would corrupt the parse.
|
|
1114
|
+
*
|
|
1115
|
+
* The judgment call worth flagging: v1 drops TWO bullets on structured
|
|
1116
|
+
* surfaces, and a stricter reading would also drop `falsify` ("state in one
|
|
1117
|
+
* line") and `deviation` ("say so explicitly"), since both demand output
|
|
1118
|
+
* text. I kept them. Their output demand is incidental (and conditional, for
|
|
1119
|
+
* `deviation`) while their primary effect is on reasoning before the answer
|
|
1120
|
+
* exists — whereas v1's dropped pair (`label`, `gap`) are purely
|
|
1121
|
+
* output-shaping. Dropping three of five would leave a two-gate arm that no
|
|
1122
|
+
* longer tests the same mechanism, and an arm crippled by my formatting
|
|
1123
|
+
* choice would read as a wording loss that was actually a scoping loss.
|
|
1124
|
+
* If the structured surface shows anomalous results, this is the first
|
|
1125
|
+
* thing to re-examine.
|
|
1126
|
+
*/
|
|
1127
|
+
declare function altBlindGatesBlockFor(args: {
|
|
1128
|
+
outputMode: 'text' | 'json' | 'tool_call';
|
|
1129
|
+
hasTools: boolean;
|
|
1130
|
+
}): string;
|
|
1088
1131
|
/**
|
|
1089
1132
|
* The alt arm injects its block DIRECTLY as an untagged section — it must
|
|
1090
1133
|
* not carry `kind: 'discipline_contract'`, or the translator would prepend
|
|
@@ -1094,6 +1137,14 @@ declare function altGatesBlockFor(args: {
|
|
|
1094
1137
|
* no-ops — the attribution is about WORDING, and everything else is held.
|
|
1095
1138
|
*/
|
|
1096
1139
|
declare function withAltDisciplineContract(ir: PromptIR): PromptIR;
|
|
1140
|
+
/**
|
|
1141
|
+
* Same injection contract as `withAltDisciplineContract` — untagged section,
|
|
1142
|
+
* so the translator never prepends the v1 bytes on top and the arm measures
|
|
1143
|
+
* exactly one wording. Same variant inputs, so the blind arm no-ops nowhere
|
|
1144
|
+
* v1 fires and fires nowhere v1 no-ops; the comparison is about WORDING and
|
|
1145
|
+
* everything else is held.
|
|
1146
|
+
*/
|
|
1147
|
+
declare function withAltBlindDisciplineContract(ir: PromptIR): PromptIR;
|
|
1097
1148
|
declare function runGoldenEval(opts: GoldenEvalOptions): Promise<GoldenEvalRunResult>;
|
|
1098
1149
|
/**
|
|
1099
1150
|
* Aggregate outcome of one strategy run, in gates-on terms. 'loses' is the
|
|
@@ -1107,25 +1158,54 @@ declare function classifyStrategyOutcome(r: GoldenEvalRunResult): StrategyOutcom
|
|
|
1107
1158
|
* recorded as a mechanism failure would let Factor B permanently disable a
|
|
1108
1159
|
* real capability on evidence about one author's prose.
|
|
1109
1160
|
*
|
|
1110
|
-
*
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
1161
|
+
* THREE arms since 2026-07-29. Both re-wordings run on a v1 loss, and a win
|
|
1162
|
+
* by EITHER is enough to acquit the mechanism — the question "does some
|
|
1163
|
+
* wording of this work?" is answered by one existence proof, so there is no
|
|
1164
|
+
* reason to require agreement between the alts.
|
|
1165
|
+
*
|
|
1166
|
+
* v1 vs off | alt / alt-blind vs off | attribution
|
|
1167
|
+
* ----------+------------------------+------------------------------------
|
|
1168
|
+
* wins | (not run) | mechanism-works — ship
|
|
1169
|
+
* ties | (not run) | no-lift — inconclusive at n, re-eval
|
|
1170
|
+
* loses | either wins | wording-failure — do NOT disable
|
|
1171
|
+
* loses | BOTH lose | mechanism-failure — Factor B may disable
|
|
1172
|
+
* loses | neither wins, not both lose | wording-inconclusive — no disable
|
|
1173
|
+
*
|
|
1174
|
+
* The `mechanism-failure` cell is the one that changed character. It used to
|
|
1175
|
+
* rest on two wordings by one author, so a shared blind spot (the principles
|
|
1176
|
+
* being the wrong principles) was invisible and the verdict was hedged. The
|
|
1177
|
+
* blind arm was authored by a context-free subagent with no knowledge of this
|
|
1178
|
+
* repo, the experiment, or who was asking — so a both-lose verdict now spans
|
|
1179
|
+
* independent authorship and is strong on its own terms. That is exactly the
|
|
1180
|
+
* gap `STRATEGY_AUTHORSHIP_LIMITATION` was written to confess, which is why
|
|
1181
|
+
* the limitation text is now conditional on whether the blind arm ran.
|
|
1117
1182
|
*/
|
|
1118
1183
|
type StrategyAttribution = 'mechanism-works' | 'no-lift' | 'wording-failure' | 'mechanism-failure' | 'wording-inconclusive' | 'inconclusive';
|
|
1119
1184
|
interface StrategyAttributionResult {
|
|
1120
1185
|
attribution: StrategyAttribution;
|
|
1121
1186
|
primary: GoldenEvalRunResult;
|
|
1122
|
-
/** Present ONLY when the primary lost (the loss-triggered
|
|
1187
|
+
/** Present ONLY when the primary lost (the loss-triggered arms). */
|
|
1123
1188
|
alt?: GoldenEvalRunResult;
|
|
1189
|
+
/** The independently-authored arm. Present ONLY when the primary lost. */
|
|
1190
|
+
altBlind?: GoldenEvalRunResult;
|
|
1124
1191
|
/** The authorship limitation, restated on every result so no downstream
|
|
1125
|
-
* reader can cite an attribution without it.
|
|
1192
|
+
* reader can cite an attribution without it. Which string this carries
|
|
1193
|
+
* depends on whether the blind arm actually ran — see below. */
|
|
1126
1194
|
limitation: string;
|
|
1127
1195
|
}
|
|
1196
|
+
/**
|
|
1197
|
+
* Carried when the blind arm did NOT run — i.e. v1 won or tied, so no
|
|
1198
|
+
* re-wording was measured at all and any claim about wording is unevidenced.
|
|
1199
|
+
*/
|
|
1128
1200
|
declare const STRATEGY_AUTHORSHIP_LIMITATION: string;
|
|
1201
|
+
/**
|
|
1202
|
+
* Carried when both re-wording arms ran. The shared-author caveat is GONE by
|
|
1203
|
+
* construction, and saying so is the point: the previous version of this
|
|
1204
|
+
* string confessed a gap that has since been closed, and a stale confession
|
|
1205
|
+
* is its own kind of false statement — a reader would discount a verdict
|
|
1206
|
+
* that no longer deserves discounting.
|
|
1207
|
+
*/
|
|
1208
|
+
declare const STRATEGY_AUTHORSHIP_INDEPENDENT: string;
|
|
1129
1209
|
/**
|
|
1130
1210
|
* Run the strategy eval with loss-triggered wording attribution: v1 first;
|
|
1131
1211
|
* the alt arm replays ONLY on a v1 loss (mirrors the engine's retry
|
|
@@ -1146,7 +1226,7 @@ declare function runStrategyEvalWithAttribution(opts: Omit<GoldenEvalOptions, 'a
|
|
|
1146
1226
|
* guard in `tests/version.test.ts` fails the suite (and therefore
|
|
1147
1227
|
* `prepublishOnly`) when they diverge — a stale constant cannot reach npm.
|
|
1148
1228
|
*/
|
|
1149
|
-
declare const LIBRARY_VERSION = "2.0.0-alpha.
|
|
1229
|
+
declare const LIBRARY_VERSION = "2.0.0-alpha.83";
|
|
1150
1230
|
|
|
1151
1231
|
/**
|
|
1152
1232
|
* Oracle contract — how an app tells the brain whether a response was good.
|
|
@@ -1795,6 +1875,77 @@ interface AdvisorySuggestedFix {
|
|
|
1795
1875
|
* view's snake_case columns to camelCase. See `feedback_typed_boundary_transformers.md`
|
|
1796
1876
|
* (L-118) for the rationale.
|
|
1797
1877
|
*/
|
|
1878
|
+
/**
|
|
1879
|
+
* The window of evidence a finding was computed from — migration 054.
|
|
1880
|
+
*
|
|
1881
|
+
* READ THE DISTINCTION BEFORE USING THIS. It is NOT `openedAt` /
|
|
1882
|
+
* `lastObservedAt` / `observationCount`, which describe the ADVISORY (how
|
|
1883
|
+
* long it has been firing, how many times the watcher ran and still saw the
|
|
1884
|
+
* condition). This describes what the generator LOOKED AT.
|
|
1885
|
+
*
|
|
1886
|
+
* A daily cron that keeps firing on a single 29-second burst reports
|
|
1887
|
+
* `observationCount: 11` spanning 11 days — the most standing-looking of
|
|
1888
|
+
* standing conditions — while its evidence is one event from 11 days ago.
|
|
1889
|
+
* Separating the two is the entire point.
|
|
1890
|
+
*
|
|
1891
|
+
* `null` when the generator did not state its window. Honest unknown; it
|
|
1892
|
+
* must never be read as "not a burst". Compile-time library rules carry
|
|
1893
|
+
* null legitimately — they fire on ONE call, so their evidence is the call
|
|
1894
|
+
* in hand and there is no window to state.
|
|
1895
|
+
*/
|
|
1896
|
+
interface AdvisoryEvidenceWindow {
|
|
1897
|
+
firstAt: string;
|
|
1898
|
+
lastAt: string;
|
|
1899
|
+
n: number;
|
|
1900
|
+
/** `lastAt - firstAt`, precomputed so no caller re-derives it wrong. */
|
|
1901
|
+
spanMs: number;
|
|
1902
|
+
/**
|
|
1903
|
+
* `true` when the evidence is clustered tightly enough to be ONE EVENT
|
|
1904
|
+
* rather than a standing rate. See `classifyEvidenceWindow`.
|
|
1905
|
+
*/
|
|
1906
|
+
isBurst: boolean;
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Burst-vs-rate, computed rather than judged.
|
|
1910
|
+
*
|
|
1911
|
+
* Origin: tt-intel s118. A cost query showed `claude-sonnet-5` at 30% of
|
|
1912
|
+
* their `ask` traffic and 80% of ask spend. Every number true, every
|
|
1913
|
+
* mechanism check correct, and every correct check made them more certain
|
|
1914
|
+
* the spend gate had regressed. All eleven calls sat in a 29-second window —
|
|
1915
|
+
* their own prior experiment, fixed six minutes after the last one. Their
|
|
1916
|
+
* formulation: **a cluster is an event, not a rate.**
|
|
1917
|
+
*
|
|
1918
|
+
* The rule, deliberately crude because a subtle one would need tuning per
|
|
1919
|
+
* rule and would then be wrong per rule: evidence is a burst when it spans
|
|
1920
|
+
* less than `BURST_SPAN_MS` (5 minutes). Multiple observations inside five
|
|
1921
|
+
* minutes are one incident — a deploy, a retry storm, a test run, a
|
|
1922
|
+
* benchmark — not a pattern of behavior over time.
|
|
1923
|
+
*
|
|
1924
|
+
* Two deliberate non-features:
|
|
1925
|
+
*
|
|
1926
|
+
* - **n is not in the test.** Two rows 4 minutes apart are as much a single
|
|
1927
|
+
* event as eleven are. Requiring a minimum n would let the smallest, least
|
|
1928
|
+
* evidenced findings skip the check.
|
|
1929
|
+
* - **It does not try to detect fossils.** A burst is not necessarily stale;
|
|
1930
|
+
* it is merely not a rate. Only the consumer's own deploy log can turn
|
|
1931
|
+
* "one event" into "an event we already fixed", and this library cannot
|
|
1932
|
+
* see that. Claiming otherwise would be the same over-reach the rule
|
|
1933
|
+
* exists to correct.
|
|
1934
|
+
*/
|
|
1935
|
+
declare const BURST_SPAN_MS: number;
|
|
1936
|
+
declare function classifyEvidenceWindow(row: {
|
|
1937
|
+
evidence_first_at?: string | null;
|
|
1938
|
+
evidence_last_at?: string | null;
|
|
1939
|
+
evidence_n?: number | null;
|
|
1940
|
+
}): AdvisoryEvidenceWindow | null;
|
|
1941
|
+
/** Human-readable span for advisory text. Terse by design — it sits inline. */
|
|
1942
|
+
declare function formatEvidenceSpan(spanMs: number): string;
|
|
1943
|
+
/**
|
|
1944
|
+
* The sentence that travels with a burst-shaped finding. Written to be
|
|
1945
|
+
* usable verbatim in advisory text, and to say what the library CAN claim
|
|
1946
|
+
* (one event) rather than what it cannot (that the event is stale).
|
|
1947
|
+
*/
|
|
1948
|
+
declare function burstCaveat(w: AdvisoryEvidenceWindow): string;
|
|
1798
1949
|
interface ActionableAdvisory {
|
|
1799
1950
|
id: string;
|
|
1800
1951
|
rule: string;
|
|
@@ -1802,6 +1953,18 @@ interface ActionableAdvisory {
|
|
|
1802
1953
|
openedAt: string;
|
|
1803
1954
|
lastObservedAt: string;
|
|
1804
1955
|
observationCount: number;
|
|
1956
|
+
/**
|
|
1957
|
+
* Migration 054. `null` when the generator did not state a window — an
|
|
1958
|
+
* honest unknown, NOT an assertion that the evidence is well-spread.
|
|
1959
|
+
*/
|
|
1960
|
+
evidenceWindow: AdvisoryEvidenceWindow | null;
|
|
1961
|
+
/**
|
|
1962
|
+
* The severity the rule ASKED for, present only when this advisory's
|
|
1963
|
+
* effective `severity` was downgraded because its evidence is burst-shaped.
|
|
1964
|
+
* Kept so a consumer can see the downgrade happened rather than silently
|
|
1965
|
+
* receiving a quieter advisory than the generator wrote.
|
|
1966
|
+
*/
|
|
1967
|
+
severityBeforeBurstDowngrade?: AdvisorySeverity;
|
|
1805
1968
|
appliesTo: {
|
|
1806
1969
|
archetype?: IntentArchetypeName;
|
|
1807
1970
|
model?: string;
|
|
@@ -1853,6 +2016,12 @@ interface MarkAdvisoryResolvedOptions {
|
|
|
1853
2016
|
brainAnonKey?: string;
|
|
1854
2017
|
fetch?: typeof fetch;
|
|
1855
2018
|
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Map a single `actionable_advisories_v` row (snake_case, Postgres
|
|
2021
|
+
* native) to the public `ActionableAdvisory` shape (camelCase). Single
|
|
2022
|
+
* canonical mapping site for this boundary (L-118).
|
|
2023
|
+
*/
|
|
2024
|
+
declare function rowToAdvisory(row: Record<string, unknown>): ActionableAdvisory;
|
|
1856
2025
|
/**
|
|
1857
2026
|
* Query the open advisory set for an app. Pulls from
|
|
1858
2027
|
* `actionable_advisories_v` (per-(app_id, code) rollup with stable ids
|
|
@@ -3760,4 +3929,4 @@ declare function planDecomposition(args: PlanDecompositionArgs): DecompositionPl
|
|
|
3760
3929
|
*/
|
|
3761
3930
|
declare function compile(ir: PromptIR, opts?: CompileOptions): CompileResult;
|
|
3762
3931
|
|
|
3763
|
-
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, BRAIN_READ_ENV_NAMES, 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_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_LIMITATION, SectionRewrite, type ShadowProbeRecordInput, type StrategyAttribution, type StrategyAttributionResult, type StrategyOutcome, type SupportedProvider, type SurfaceFailureRow, type SurfaceStats, SystemModelMessage, TRANSLATOR_FLOOR, _testResetMeasuredFailure, _testResetPromotions, _testWaitForMeasuredFailureRefresh, _testWaitForPromotionsRefresh, altGatesBlockFor, applyArchetypeConvention, applySectionRewrites, attachCacheControlToStreamTextInput, awaitMeasuredFailureReady, brainHealth, buildGoldenIrRow, buildLLMJudge, buildPairwiseJudgePrompt, buildShadowProbeRow, call, chainProviderSpread, classifyStrategyOutcome, clearBrain, combineOrderSwappedVerdicts, compile, compileForAISDKv6, configureBrain, configureMeasuredFailureBrain, configurePromotionsBrain, countTokens, createDelegate, deriveFamilyFromModelId, deriveOwnership, estimateChainCostUsd, estimateModelCostUsd, execute, findBetterFit, flushBrainDeadLetter, getActionableAdvisories, getAllStarterChains, getAllStarterChainsWithGrounding, getApplicablePromotion, getArchetypePerfScore, getDefaultFallbackChain, getDefaultFallbackChainWithGrounding, getMeasuredFailureVerdict, getModelCompatibility, getPerAxisMetrics, getReachabilityDiagnostic, getRecentRollback, getRecommendedPrimary, getSequentialStarterChain, getSequentialStarterChainWithGrounding, getStaleExclusionFindings, getStarterChain, getStarterChainWithGrounding, 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, rubricFor, runAdvisor, runGoldenEval, runStrategyEvalWithAttribution, setTokenizer, wilsonLowerBound, withAltDisciplineContract, withDisciplineContract };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -23,9 +23,12 @@ __export(index_exports, {
|
|
|
23
23
|
ABSOLUTE_FLOOR: () => ABSOLUTE_FLOOR,
|
|
24
24
|
ALIASES: () => ALIASES,
|
|
25
25
|
ALL_ARCHETYPES: () => ALL_ARCHETYPES,
|
|
26
|
+
ALT_BLIND_TOKEN_BUDGET_BREACH: () => ALT_BLIND_TOKEN_BUDGET_BREACH,
|
|
27
|
+
ALT_STRATEGY_IDS: () => ALT_STRATEGY_IDS,
|
|
26
28
|
ARCHETYPE_FAMILY_FITS: () => ARCHETYPE_FAMILY_FITS,
|
|
27
29
|
ARCHETYPE_FLOOR_DEFAULT: () => ARCHETYPE_FLOOR_DEFAULT,
|
|
28
30
|
BRAIN_READ_ENV_NAMES: () => BRAIN_READ_ENV_NAMES,
|
|
31
|
+
BURST_SPAN_MS: () => BURST_SPAN_MS,
|
|
29
32
|
COACH_CFG: () => COACH_CFG,
|
|
30
33
|
COST_RANKING_REFERENCE_SHAPE: () => COST_RANKING_REFERENCE_SHAPE,
|
|
31
34
|
CallError: () => CallError,
|
|
@@ -36,6 +39,7 @@ __export(index_exports, {
|
|
|
36
39
|
DEFAULT_PROMOTIONS_ENDPOINT: () => DEFAULT_PROMOTIONS_ENDPOINT,
|
|
37
40
|
DELEGATE_TOOL_DEFINITION: () => DELEGATE_TOOL_DEFINITION,
|
|
38
41
|
DIALECT_VERSION: () => DIALECT_VERSION,
|
|
42
|
+
DISCIPLINE_GATES_V1_ALT_BLIND_HEADER: () => DISCIPLINE_GATES_V1_ALT_BLIND_HEADER,
|
|
39
43
|
DISCIPLINE_GATES_V1_ALT_HEADER: () => DISCIPLINE_GATES_V1_ALT_HEADER,
|
|
40
44
|
FamilyResolutionError: () => FamilyResolutionError,
|
|
41
45
|
INTENT_ARCHETYPES: () => INTENT_ARCHETYPES,
|
|
@@ -52,6 +56,7 @@ __export(index_exports, {
|
|
|
52
56
|
RULE_DISCIPLINE_GATES_V1: () => RULE_DISCIPLINE_GATES_V1,
|
|
53
57
|
RULE_DISCIPLINE_GATES_V1_STRUCTURED: () => RULE_DISCIPLINE_GATES_V1_STRUCTURED,
|
|
54
58
|
RULE_SEQUENTIAL_TOOL_CLIFF: () => RULE_SEQUENTIAL_TOOL_CLIFF,
|
|
59
|
+
STRATEGY_AUTHORSHIP_INDEPENDENT: () => STRATEGY_AUTHORSHIP_INDEPENDENT,
|
|
55
60
|
STRATEGY_AUTHORSHIP_LIMITATION: () => STRATEGY_AUTHORSHIP_LIMITATION,
|
|
56
61
|
TRANSLATOR_FLOOR: () => TRANSLATOR_FLOOR,
|
|
57
62
|
_testResetMeasuredFailure: () => _testResetMeasuredFailure,
|
|
@@ -59,6 +64,7 @@ __export(index_exports, {
|
|
|
59
64
|
_testWaitForMeasuredFailureRefresh: () => _testWaitForMeasuredFailureRefresh,
|
|
60
65
|
_testWaitForPromotionsRefresh: () => _testWaitForPromotionsRefresh,
|
|
61
66
|
allProfiles: () => allProfiles,
|
|
67
|
+
altBlindGatesBlockFor: () => altBlindGatesBlockFor,
|
|
62
68
|
altGatesBlockFor: () => altGatesBlockFor,
|
|
63
69
|
applyArchetypeConvention: () => applyArchetypeConvention,
|
|
64
70
|
applySectionRewrites: () => applySectionRewrites,
|
|
@@ -72,9 +78,11 @@ __export(index_exports, {
|
|
|
72
78
|
buildLLMJudge: () => buildLLMJudge,
|
|
73
79
|
buildPairwiseJudgePrompt: () => buildPairwiseJudgePrompt,
|
|
74
80
|
buildShadowProbeRow: () => buildShadowProbeRow,
|
|
81
|
+
burstCaveat: () => burstCaveat,
|
|
75
82
|
call: () => call,
|
|
76
83
|
captureGoldenIr: () => captureGoldenIr,
|
|
77
84
|
chainProviderSpread: () => chainProviderSpread,
|
|
85
|
+
classifyEvidenceWindow: () => classifyEvidenceWindow,
|
|
78
86
|
classifyStrategyOutcome: () => classifyStrategyOutcome,
|
|
79
87
|
clearBrain: () => clearBrain,
|
|
80
88
|
combineOrderSwappedVerdicts: () => combineOrderSwappedVerdicts,
|
|
@@ -94,6 +102,7 @@ __export(index_exports, {
|
|
|
94
102
|
execute: () => execute,
|
|
95
103
|
findBetterFit: () => findBetterFit,
|
|
96
104
|
flushBrainDeadLetter: () => flushBrainDeadLetter,
|
|
105
|
+
formatEvidenceSpan: () => formatEvidenceSpan,
|
|
97
106
|
getActionableAdvisories: () => getActionableAdvisories,
|
|
98
107
|
getAllStarterChains: () => getAllStarterChains,
|
|
99
108
|
getAllStarterChainsWithGrounding: () => getAllStarterChainsWithGrounding,
|
|
@@ -115,6 +124,7 @@ __export(index_exports, {
|
|
|
115
124
|
getStarterChainWithGrounding: () => getStarterChainWithGrounding,
|
|
116
125
|
hasMutation: () => hasMutation,
|
|
117
126
|
hashShape: () => hashShape,
|
|
127
|
+
isAltStrategy: () => isAltStrategy,
|
|
118
128
|
isArchetype: () => isArchetype,
|
|
119
129
|
isAutoPromoteEnabledFromEnv: () => isAutoPromoteEnabledFromEnv,
|
|
120
130
|
isBrainQueryActiveFor: () => isBrainQueryActiveFor,
|
|
@@ -160,6 +170,7 @@ __export(index_exports, {
|
|
|
160
170
|
resolveGoldenCaptureRate: () => resolveGoldenCaptureRate,
|
|
161
171
|
resolvePricingAt: () => resolvePricingAt,
|
|
162
172
|
resolveProviderKey: () => resolveProviderKey,
|
|
173
|
+
rowToAdvisory: () => rowToAdvisory,
|
|
163
174
|
rubricFor: () => rubricFor,
|
|
164
175
|
runAdvisor: () => runAdvisor,
|
|
165
176
|
runGoldenEval: () => runGoldenEval,
|
|
@@ -168,6 +179,7 @@ __export(index_exports, {
|
|
|
168
179
|
shouldCaptureGolden: () => shouldCaptureGolden,
|
|
169
180
|
tryGetProfile: () => tryGetProfile,
|
|
170
181
|
wilsonLowerBound: () => wilsonLowerBound,
|
|
182
|
+
withAltBlindDisciplineContract: () => withAltBlindDisciplineContract,
|
|
171
183
|
withAltDisciplineContract: () => withAltDisciplineContract,
|
|
172
184
|
withDisciplineContract: () => withDisciplineContract
|
|
173
185
|
});
|
|
@@ -5853,7 +5865,7 @@ function validateFinalFit(ir, profile, tokens) {
|
|
|
5853
5865
|
}
|
|
5854
5866
|
|
|
5855
5867
|
// src/version.ts
|
|
5856
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
5868
|
+
var LIBRARY_VERSION = "2.0.0-alpha.83";
|
|
5857
5869
|
|
|
5858
5870
|
// src/pricing-brain.ts
|
|
5859
5871
|
function isPricingRow(x) {
|
|
@@ -8636,6 +8648,13 @@ function combineOrderSwappedVerdicts(run1, run2) {
|
|
|
8636
8648
|
if (run1 === run2) return run1;
|
|
8637
8649
|
return "tied";
|
|
8638
8650
|
}
|
|
8651
|
+
var ALT_STRATEGY_IDS = [
|
|
8652
|
+
"discipline-gates-v1-alt",
|
|
8653
|
+
"discipline-gates-v1-alt-blind"
|
|
8654
|
+
];
|
|
8655
|
+
function isAltStrategy(id) {
|
|
8656
|
+
return id !== void 0 && ALT_STRATEGY_IDS.includes(id);
|
|
8657
|
+
}
|
|
8639
8658
|
function replayRetryDelayMs(errorCode) {
|
|
8640
8659
|
return errorCode === "rate_limit" ? 65e3 : 2e3;
|
|
8641
8660
|
}
|
|
@@ -8689,7 +8708,34 @@ function altGatesBlockFor(args) {
|
|
|
8689
8708
|
...shapeAltering
|
|
8690
8709
|
]);
|
|
8691
8710
|
}
|
|
8711
|
+
var ALT_BLIND_TOKEN_BUDGET_BREACH = {
|
|
8712
|
+
ceilingTokens: 264,
|
|
8713
|
+
measuredTokensTextWithTools: 285,
|
|
8714
|
+
note: "Blind arm exceeds the stated 264-token ceiling on text+tools (285) and costs ~2.4x the v1-alt arm. Not corrected: compressing it would require editing prose the arm depends on NOT having been edited by this seat. Read a blind-arm LOSS as confounded by token tax; a WIN is unaffected."
|
|
8715
|
+
};
|
|
8716
|
+
var DISCIPLINE_GATES_V1_ALT_BLIND_HEADER = "Before stating any conclusion, run this check:";
|
|
8717
|
+
var ALT_BLIND_BULLETS = {
|
|
8718
|
+
falsify: "- Before committing to an approach, state in one line what evidence would prove it wrong and how you would notice it. If nothing could falsify the approach, you hold a preference, not a plan \u2014 rework it until something could.",
|
|
8719
|
+
deviation: "- When you choose not to follow an applicable instruction, say so explicitly: name the instruction, why you are deviating, and what you are doing instead. Silent deviation is forbidden \u2014 an override is only legitimate when it is visible.",
|
|
8720
|
+
toolPredict: "- When using tools: before each call, state the result you expect. On mismatch, treat the gap as evidence your model of the system is wrong \u2014 revise the model before acting again; never silently retry.",
|
|
8721
|
+
verifyDelegated: "- Verify every delegated or sub-agent result before composing it into an answer: spot-check it against the source or an independent probe. An unverified sub-result is a claim you are repeating, not a fact you know.",
|
|
8722
|
+
markAssumed: '- In the final answer, keep verified claims and assumptions visibly distinct: mark anything unchecked as "assumed" or "unverified". Never let an assumption borrow the confidence of the verified claims beside it.'
|
|
8723
|
+
};
|
|
8724
|
+
function altBlindGatesBlockFor(args) {
|
|
8725
|
+
const parts = [
|
|
8726
|
+
"falsify",
|
|
8727
|
+
"deviation",
|
|
8728
|
+
...args.hasTools ? ["toolPredict"] : [],
|
|
8729
|
+
"verifyDelegated",
|
|
8730
|
+
...args.outputMode === "text" ? ["markAssumed"] : []
|
|
8731
|
+
];
|
|
8732
|
+
return [
|
|
8733
|
+
DISCIPLINE_GATES_V1_ALT_BLIND_HEADER,
|
|
8734
|
+
...parts.map((p) => ALT_BLIND_BULLETS[p])
|
|
8735
|
+
].join("\n");
|
|
8736
|
+
}
|
|
8692
8737
|
var STRATEGY_ALT_SECTION_ID = "__kgauto_strategy_eval_gates_alt__";
|
|
8738
|
+
var STRATEGY_ALT_BLIND_SECTION_ID = "__kgauto_strategy_eval_gates_alt_blind__";
|
|
8693
8739
|
function withAltDisciplineContract(ir) {
|
|
8694
8740
|
const outputMode = resolveOutputMode({
|
|
8695
8741
|
declared: ir.constraints?.outputMode,
|
|
@@ -8708,6 +8754,28 @@ function withAltDisciplineContract(ir) {
|
|
|
8708
8754
|
]
|
|
8709
8755
|
};
|
|
8710
8756
|
}
|
|
8757
|
+
function withAltBlindDisciplineContract(ir) {
|
|
8758
|
+
const outputMode = resolveOutputMode({
|
|
8759
|
+
declared: ir.constraints?.outputMode,
|
|
8760
|
+
structuredOutput: ir.constraints?.structuredOutput,
|
|
8761
|
+
toolCount: ir.tools?.length ?? 0
|
|
8762
|
+
});
|
|
8763
|
+
const hasTools = (ir.tools?.length ?? 0) > 0;
|
|
8764
|
+
return {
|
|
8765
|
+
...ir,
|
|
8766
|
+
sections: [
|
|
8767
|
+
...ir.sections ?? [],
|
|
8768
|
+
{
|
|
8769
|
+
id: STRATEGY_ALT_BLIND_SECTION_ID,
|
|
8770
|
+
text: altBlindGatesBlockFor({ outputMode, hasTools })
|
|
8771
|
+
}
|
|
8772
|
+
]
|
|
8773
|
+
};
|
|
8774
|
+
}
|
|
8775
|
+
var ALT_SECTION_ID_BY_STRATEGY = {
|
|
8776
|
+
"discipline-gates-v1-alt": STRATEGY_ALT_SECTION_ID,
|
|
8777
|
+
"discipline-gates-v1-alt-blind": STRATEGY_ALT_BLIND_SECTION_ID
|
|
8778
|
+
};
|
|
8711
8779
|
async function runGoldenEval(opts) {
|
|
8712
8780
|
const fetchFn = opts.fetchImpl ?? fetch;
|
|
8713
8781
|
const progress = opts.onProgress ?? (() => {
|
|
@@ -8775,7 +8843,9 @@ async function runGoldenEval(opts) {
|
|
|
8775
8843
|
}
|
|
8776
8844
|
const armBIr = (ir) => {
|
|
8777
8845
|
if (axis !== "strategy") return ir;
|
|
8778
|
-
|
|
8846
|
+
if (strategyId === "discipline-gates-v1-alt") return withAltDisciplineContract(ir);
|
|
8847
|
+
if (strategyId === "discipline-gates-v1-alt-blind") return withAltBlindDisciplineContract(ir);
|
|
8848
|
+
return withDisciplineContract(ir);
|
|
8779
8849
|
};
|
|
8780
8850
|
const replay = async (ir, model, captureGates = false) => {
|
|
8781
8851
|
let gates;
|
|
@@ -8787,13 +8857,14 @@ async function runGoldenEval(opts) {
|
|
|
8787
8857
|
};
|
|
8788
8858
|
const compiled = compile(evalIr);
|
|
8789
8859
|
if (captureGates) {
|
|
8790
|
-
if (strategyId
|
|
8860
|
+
if (isAltStrategy(strategyId)) {
|
|
8861
|
+
const altSectionId = ALT_SECTION_ID_BY_STRATEGY[strategyId];
|
|
8791
8862
|
const altSection = (evalIr.sections ?? []).find(
|
|
8792
|
-
(s) => s.id ===
|
|
8863
|
+
(s) => s.id === altSectionId
|
|
8793
8864
|
);
|
|
8794
8865
|
gates = {
|
|
8795
8866
|
fired: altSection !== void 0 && altSection.text.length > 0,
|
|
8796
|
-
rule:
|
|
8867
|
+
rule: strategyId,
|
|
8797
8868
|
gateTokens: altSection ? countTokens(`${altSection.text}
|
|
8798
8869
|
|
|
8799
8870
|
`) : 0
|
|
@@ -9224,7 +9295,8 @@ function classifyStrategyOutcome(r) {
|
|
|
9224
9295
|
if (r.losses > r.wins) return "loses";
|
|
9225
9296
|
return "ties";
|
|
9226
9297
|
}
|
|
9227
|
-
var STRATEGY_AUTHORSHIP_LIMITATION = "
|
|
9298
|
+
var STRATEGY_AUTHORSHIP_LIMITATION = "Only the v1 wording was measured on this run; no re-wording arm was triggered, so this result says nothing about whether the wording or the mechanism produced it.";
|
|
9299
|
+
var STRATEGY_AUTHORSHIP_INDEPENDENT = "Three arms: v1 and one re-wording by this seat, plus an independently authored arm (context-free subagent, no repo access, no knowledge of the experiment). A both-lose verdict therefore spans independent authorship and is not explained by one author's blind spot. Residual limitation: all three arms encode a similar set of underlying principles, so a wrong CHOICE of principles remains harder to see than a wrong wording of them.";
|
|
9228
9300
|
async function runStrategyEvalWithAttribution(opts) {
|
|
9229
9301
|
const primary = await runGoldenEval({
|
|
9230
9302
|
...opts,
|
|
@@ -9241,9 +9313,20 @@ async function runStrategyEvalWithAttribution(opts) {
|
|
|
9241
9313
|
axis: "strategy",
|
|
9242
9314
|
strategy: "discipline-gates-v1-alt"
|
|
9243
9315
|
});
|
|
9244
|
-
const
|
|
9245
|
-
|
|
9246
|
-
|
|
9316
|
+
const altBlind = await runGoldenEval({
|
|
9317
|
+
...opts,
|
|
9318
|
+
axis: "strategy",
|
|
9319
|
+
strategy: "discipline-gates-v1-alt-blind"
|
|
9320
|
+
});
|
|
9321
|
+
const outcomes = [classifyStrategyOutcome(alt), classifyStrategyOutcome(altBlind)];
|
|
9322
|
+
const attribution = outcomes.includes("wins") ? "wording-failure" : outcomes.every((o) => o === "loses") ? "mechanism-failure" : "wording-inconclusive";
|
|
9323
|
+
return {
|
|
9324
|
+
attribution,
|
|
9325
|
+
primary,
|
|
9326
|
+
alt,
|
|
9327
|
+
altBlind,
|
|
9328
|
+
limitation: STRATEGY_AUTHORSHIP_INDEPENDENT
|
|
9329
|
+
};
|
|
9247
9330
|
}
|
|
9248
9331
|
|
|
9249
9332
|
// src/brain-proxy.ts
|
|
@@ -9875,6 +9958,30 @@ function createDelegate(opts) {
|
|
|
9875
9958
|
}
|
|
9876
9959
|
|
|
9877
9960
|
// src/advisories-api.ts
|
|
9961
|
+
var BURST_SPAN_MS = 5 * 60 * 1e3;
|
|
9962
|
+
function classifyEvidenceWindow(row) {
|
|
9963
|
+
const { evidence_first_at: first, evidence_last_at: last, evidence_n: n } = row;
|
|
9964
|
+
if (typeof first !== "string" || typeof last !== "string") return null;
|
|
9965
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n <= 0) return null;
|
|
9966
|
+
const t0 = Date.parse(first);
|
|
9967
|
+
const t1 = Date.parse(last);
|
|
9968
|
+
if (Number.isNaN(t0) || Number.isNaN(t1)) return null;
|
|
9969
|
+
const spanMs = Math.max(0, t1 - t0);
|
|
9970
|
+
return { firstAt: first, lastAt: last, n, spanMs, isBurst: spanMs < BURST_SPAN_MS };
|
|
9971
|
+
}
|
|
9972
|
+
function formatEvidenceSpan(spanMs) {
|
|
9973
|
+
if (spanMs < 1e3) return `${spanMs}ms`;
|
|
9974
|
+
const s = Math.round(spanMs / 1e3);
|
|
9975
|
+
if (s < 90) return `${s}s`;
|
|
9976
|
+
const m = Math.round(s / 60);
|
|
9977
|
+
if (m < 90) return `${m}m`;
|
|
9978
|
+
const h = Math.round(m / 60);
|
|
9979
|
+
if (h < 48) return `${h}h`;
|
|
9980
|
+
return `${Math.round(h / 24)}d`;
|
|
9981
|
+
}
|
|
9982
|
+
function burstCaveat(w) {
|
|
9983
|
+
return `Evidence is ${w.n} observation${w.n === 1 ? "" : "s"} spanning ${formatEvidenceSpan(w.spanMs)} (${w.firstAt} \u2192 ${w.lastAt}) \u2014 that is a single burst, not a standing rate. Check it against your own deploy log before acting: a cluster this tight is usually one incident, and may already be fixed.`;
|
|
9984
|
+
}
|
|
9878
9985
|
var SEVERITY_SET = /* @__PURE__ */ new Set(["info", "warn", "critical"]);
|
|
9879
9986
|
var STATUS_SET = /* @__PURE__ */ new Set(["open", "snoozed", "resolved"]);
|
|
9880
9987
|
var RESOLUTION_SOURCE_SET = /* @__PURE__ */ new Set([
|
|
@@ -9914,10 +10021,18 @@ function rowToAdvisory(row) {
|
|
|
9914
10021
|
if (docsLink) suggestedFix.docsLink = docsLink;
|
|
9915
10022
|
if (suggestion) suggestedFix.before = suggestion;
|
|
9916
10023
|
}
|
|
10024
|
+
const evidenceWindow = classifyEvidenceWindow(
|
|
10025
|
+
row
|
|
10026
|
+
);
|
|
10027
|
+
const declaredSeverity = asSeverity(row.severity);
|
|
10028
|
+
const downgraded = evidenceWindow?.isBurst === true && declaredSeverity === "critical";
|
|
10029
|
+
const effectiveSeverity = downgraded ? "warn" : declaredSeverity;
|
|
9917
10030
|
const out = {
|
|
9918
10031
|
id: typeof row.id === "string" ? row.id : "",
|
|
9919
10032
|
rule: typeof row.rule === "string" ? row.rule : "",
|
|
9920
|
-
severity:
|
|
10033
|
+
severity: effectiveSeverity,
|
|
10034
|
+
evidenceWindow,
|
|
10035
|
+
...downgraded ? { severityBeforeBurstDowngrade: declaredSeverity } : {},
|
|
9921
10036
|
openedAt: typeof row.opened_at === "string" ? row.opened_at : "",
|
|
9922
10037
|
lastObservedAt: typeof row.last_observed_at === "string" ? row.last_observed_at : "",
|
|
9923
10038
|
observationCount: typeof row.observation_count === "number" ? row.observation_count : 0,
|
|
@@ -9925,7 +10040,13 @@ function rowToAdvisory(row) {
|
|
|
9925
10040
|
...archetype ? { archetype } : {},
|
|
9926
10041
|
...model ? { model } : {}
|
|
9927
10042
|
},
|
|
9928
|
-
|
|
10043
|
+
// The caveat goes INLINE in the message, not only in `evidenceWindow`.
|
|
10044
|
+
// A structured field a consumer must think to read is the same defect
|
|
10045
|
+
// one layer along: the substrate knowing and not telling. The whole
|
|
10046
|
+
// point is that the check costs a glance rather than a query.
|
|
10047
|
+
message: (typeof row.message === "string" ? row.message : "") + (evidenceWindow?.isBurst ? `
|
|
10048
|
+
|
|
10049
|
+
${burstCaveat(evidenceWindow)}` : ""),
|
|
9929
10050
|
suggestedFix,
|
|
9930
10051
|
autoApplicable: false,
|
|
9931
10052
|
// reserved — alpha.30+
|
|
@@ -10463,9 +10584,12 @@ function compile2(ir, opts) {
|
|
|
10463
10584
|
ABSOLUTE_FLOOR,
|
|
10464
10585
|
ALIASES,
|
|
10465
10586
|
ALL_ARCHETYPES,
|
|
10587
|
+
ALT_BLIND_TOKEN_BUDGET_BREACH,
|
|
10588
|
+
ALT_STRATEGY_IDS,
|
|
10466
10589
|
ARCHETYPE_FAMILY_FITS,
|
|
10467
10590
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
10468
10591
|
BRAIN_READ_ENV_NAMES,
|
|
10592
|
+
BURST_SPAN_MS,
|
|
10469
10593
|
COACH_CFG,
|
|
10470
10594
|
COST_RANKING_REFERENCE_SHAPE,
|
|
10471
10595
|
CallError,
|
|
@@ -10476,6 +10600,7 @@ function compile2(ir, opts) {
|
|
|
10476
10600
|
DEFAULT_PROMOTIONS_ENDPOINT,
|
|
10477
10601
|
DELEGATE_TOOL_DEFINITION,
|
|
10478
10602
|
DIALECT_VERSION,
|
|
10603
|
+
DISCIPLINE_GATES_V1_ALT_BLIND_HEADER,
|
|
10479
10604
|
DISCIPLINE_GATES_V1_ALT_HEADER,
|
|
10480
10605
|
FamilyResolutionError,
|
|
10481
10606
|
INTENT_ARCHETYPES,
|
|
@@ -10492,6 +10617,7 @@ function compile2(ir, opts) {
|
|
|
10492
10617
|
RULE_DISCIPLINE_GATES_V1,
|
|
10493
10618
|
RULE_DISCIPLINE_GATES_V1_STRUCTURED,
|
|
10494
10619
|
RULE_SEQUENTIAL_TOOL_CLIFF,
|
|
10620
|
+
STRATEGY_AUTHORSHIP_INDEPENDENT,
|
|
10495
10621
|
STRATEGY_AUTHORSHIP_LIMITATION,
|
|
10496
10622
|
TRANSLATOR_FLOOR,
|
|
10497
10623
|
_testResetMeasuredFailure,
|
|
@@ -10499,6 +10625,7 @@ function compile2(ir, opts) {
|
|
|
10499
10625
|
_testWaitForMeasuredFailureRefresh,
|
|
10500
10626
|
_testWaitForPromotionsRefresh,
|
|
10501
10627
|
allProfiles,
|
|
10628
|
+
altBlindGatesBlockFor,
|
|
10502
10629
|
altGatesBlockFor,
|
|
10503
10630
|
applyArchetypeConvention,
|
|
10504
10631
|
applySectionRewrites,
|
|
@@ -10512,9 +10639,11 @@ function compile2(ir, opts) {
|
|
|
10512
10639
|
buildLLMJudge,
|
|
10513
10640
|
buildPairwiseJudgePrompt,
|
|
10514
10641
|
buildShadowProbeRow,
|
|
10642
|
+
burstCaveat,
|
|
10515
10643
|
call,
|
|
10516
10644
|
captureGoldenIr,
|
|
10517
10645
|
chainProviderSpread,
|
|
10646
|
+
classifyEvidenceWindow,
|
|
10518
10647
|
classifyStrategyOutcome,
|
|
10519
10648
|
clearBrain,
|
|
10520
10649
|
combineOrderSwappedVerdicts,
|
|
@@ -10534,6 +10663,7 @@ function compile2(ir, opts) {
|
|
|
10534
10663
|
execute,
|
|
10535
10664
|
findBetterFit,
|
|
10536
10665
|
flushBrainDeadLetter,
|
|
10666
|
+
formatEvidenceSpan,
|
|
10537
10667
|
getActionableAdvisories,
|
|
10538
10668
|
getAllStarterChains,
|
|
10539
10669
|
getAllStarterChainsWithGrounding,
|
|
@@ -10555,6 +10685,7 @@ function compile2(ir, opts) {
|
|
|
10555
10685
|
getStarterChainWithGrounding,
|
|
10556
10686
|
hasMutation,
|
|
10557
10687
|
hashShape,
|
|
10688
|
+
isAltStrategy,
|
|
10558
10689
|
isArchetype,
|
|
10559
10690
|
isAutoPromoteEnabledFromEnv,
|
|
10560
10691
|
isBrainQueryActiveFor,
|
|
@@ -10600,6 +10731,7 @@ function compile2(ir, opts) {
|
|
|
10600
10731
|
resolveGoldenCaptureRate,
|
|
10601
10732
|
resolvePricingAt,
|
|
10602
10733
|
resolveProviderKey,
|
|
10734
|
+
rowToAdvisory,
|
|
10603
10735
|
rubricFor,
|
|
10604
10736
|
runAdvisor,
|
|
10605
10737
|
runGoldenEval,
|
|
@@ -10608,6 +10740,7 @@ function compile2(ir, opts) {
|
|
|
10608
10740
|
shouldCaptureGolden,
|
|
10609
10741
|
tryGetProfile,
|
|
10610
10742
|
wilsonLowerBound,
|
|
10743
|
+
withAltBlindDisciplineContract,
|
|
10611
10744
|
withAltDisciplineContract,
|
|
10612
10745
|
withDisciplineContract
|
|
10613
10746
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
LIBRARY_VERSION,
|
|
20
20
|
createKeyHealthRoute,
|
|
21
21
|
keyFingerprint
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QEFIAAE7.mjs";
|
|
23
23
|
import {
|
|
24
24
|
ABSOLUTE_FLOOR,
|
|
25
25
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
@@ -5652,6 +5652,13 @@ function combineOrderSwappedVerdicts(run1, run2) {
|
|
|
5652
5652
|
if (run1 === run2) return run1;
|
|
5653
5653
|
return "tied";
|
|
5654
5654
|
}
|
|
5655
|
+
var ALT_STRATEGY_IDS = [
|
|
5656
|
+
"discipline-gates-v1-alt",
|
|
5657
|
+
"discipline-gates-v1-alt-blind"
|
|
5658
|
+
];
|
|
5659
|
+
function isAltStrategy(id) {
|
|
5660
|
+
return id !== void 0 && ALT_STRATEGY_IDS.includes(id);
|
|
5661
|
+
}
|
|
5655
5662
|
function replayRetryDelayMs(errorCode) {
|
|
5656
5663
|
return errorCode === "rate_limit" ? 65e3 : 2e3;
|
|
5657
5664
|
}
|
|
@@ -5705,7 +5712,34 @@ function altGatesBlockFor(args) {
|
|
|
5705
5712
|
...shapeAltering
|
|
5706
5713
|
]);
|
|
5707
5714
|
}
|
|
5715
|
+
var ALT_BLIND_TOKEN_BUDGET_BREACH = {
|
|
5716
|
+
ceilingTokens: 264,
|
|
5717
|
+
measuredTokensTextWithTools: 285,
|
|
5718
|
+
note: "Blind arm exceeds the stated 264-token ceiling on text+tools (285) and costs ~2.4x the v1-alt arm. Not corrected: compressing it would require editing prose the arm depends on NOT having been edited by this seat. Read a blind-arm LOSS as confounded by token tax; a WIN is unaffected."
|
|
5719
|
+
};
|
|
5720
|
+
var DISCIPLINE_GATES_V1_ALT_BLIND_HEADER = "Before stating any conclusion, run this check:";
|
|
5721
|
+
var ALT_BLIND_BULLETS = {
|
|
5722
|
+
falsify: "- Before committing to an approach, state in one line what evidence would prove it wrong and how you would notice it. If nothing could falsify the approach, you hold a preference, not a plan \u2014 rework it until something could.",
|
|
5723
|
+
deviation: "- When you choose not to follow an applicable instruction, say so explicitly: name the instruction, why you are deviating, and what you are doing instead. Silent deviation is forbidden \u2014 an override is only legitimate when it is visible.",
|
|
5724
|
+
toolPredict: "- When using tools: before each call, state the result you expect. On mismatch, treat the gap as evidence your model of the system is wrong \u2014 revise the model before acting again; never silently retry.",
|
|
5725
|
+
verifyDelegated: "- Verify every delegated or sub-agent result before composing it into an answer: spot-check it against the source or an independent probe. An unverified sub-result is a claim you are repeating, not a fact you know.",
|
|
5726
|
+
markAssumed: '- In the final answer, keep verified claims and assumptions visibly distinct: mark anything unchecked as "assumed" or "unverified". Never let an assumption borrow the confidence of the verified claims beside it.'
|
|
5727
|
+
};
|
|
5728
|
+
function altBlindGatesBlockFor(args) {
|
|
5729
|
+
const parts = [
|
|
5730
|
+
"falsify",
|
|
5731
|
+
"deviation",
|
|
5732
|
+
...args.hasTools ? ["toolPredict"] : [],
|
|
5733
|
+
"verifyDelegated",
|
|
5734
|
+
...args.outputMode === "text" ? ["markAssumed"] : []
|
|
5735
|
+
];
|
|
5736
|
+
return [
|
|
5737
|
+
DISCIPLINE_GATES_V1_ALT_BLIND_HEADER,
|
|
5738
|
+
...parts.map((p) => ALT_BLIND_BULLETS[p])
|
|
5739
|
+
].join("\n");
|
|
5740
|
+
}
|
|
5708
5741
|
var STRATEGY_ALT_SECTION_ID = "__kgauto_strategy_eval_gates_alt__";
|
|
5742
|
+
var STRATEGY_ALT_BLIND_SECTION_ID = "__kgauto_strategy_eval_gates_alt_blind__";
|
|
5709
5743
|
function withAltDisciplineContract(ir) {
|
|
5710
5744
|
const outputMode = resolveOutputMode({
|
|
5711
5745
|
declared: ir.constraints?.outputMode,
|
|
@@ -5724,6 +5758,28 @@ function withAltDisciplineContract(ir) {
|
|
|
5724
5758
|
]
|
|
5725
5759
|
};
|
|
5726
5760
|
}
|
|
5761
|
+
function withAltBlindDisciplineContract(ir) {
|
|
5762
|
+
const outputMode = resolveOutputMode({
|
|
5763
|
+
declared: ir.constraints?.outputMode,
|
|
5764
|
+
structuredOutput: ir.constraints?.structuredOutput,
|
|
5765
|
+
toolCount: ir.tools?.length ?? 0
|
|
5766
|
+
});
|
|
5767
|
+
const hasTools = (ir.tools?.length ?? 0) > 0;
|
|
5768
|
+
return {
|
|
5769
|
+
...ir,
|
|
5770
|
+
sections: [
|
|
5771
|
+
...ir.sections ?? [],
|
|
5772
|
+
{
|
|
5773
|
+
id: STRATEGY_ALT_BLIND_SECTION_ID,
|
|
5774
|
+
text: altBlindGatesBlockFor({ outputMode, hasTools })
|
|
5775
|
+
}
|
|
5776
|
+
]
|
|
5777
|
+
};
|
|
5778
|
+
}
|
|
5779
|
+
var ALT_SECTION_ID_BY_STRATEGY = {
|
|
5780
|
+
"discipline-gates-v1-alt": STRATEGY_ALT_SECTION_ID,
|
|
5781
|
+
"discipline-gates-v1-alt-blind": STRATEGY_ALT_BLIND_SECTION_ID
|
|
5782
|
+
};
|
|
5727
5783
|
async function runGoldenEval(opts) {
|
|
5728
5784
|
const fetchFn = opts.fetchImpl ?? fetch;
|
|
5729
5785
|
const progress = opts.onProgress ?? (() => {
|
|
@@ -5791,7 +5847,9 @@ async function runGoldenEval(opts) {
|
|
|
5791
5847
|
}
|
|
5792
5848
|
const armBIr = (ir) => {
|
|
5793
5849
|
if (axis !== "strategy") return ir;
|
|
5794
|
-
|
|
5850
|
+
if (strategyId === "discipline-gates-v1-alt") return withAltDisciplineContract(ir);
|
|
5851
|
+
if (strategyId === "discipline-gates-v1-alt-blind") return withAltBlindDisciplineContract(ir);
|
|
5852
|
+
return withDisciplineContract(ir);
|
|
5795
5853
|
};
|
|
5796
5854
|
const replay = async (ir, model, captureGates = false) => {
|
|
5797
5855
|
let gates;
|
|
@@ -5803,13 +5861,14 @@ async function runGoldenEval(opts) {
|
|
|
5803
5861
|
};
|
|
5804
5862
|
const compiled = compile(evalIr);
|
|
5805
5863
|
if (captureGates) {
|
|
5806
|
-
if (strategyId
|
|
5864
|
+
if (isAltStrategy(strategyId)) {
|
|
5865
|
+
const altSectionId = ALT_SECTION_ID_BY_STRATEGY[strategyId];
|
|
5807
5866
|
const altSection = (evalIr.sections ?? []).find(
|
|
5808
|
-
(s) => s.id ===
|
|
5867
|
+
(s) => s.id === altSectionId
|
|
5809
5868
|
);
|
|
5810
5869
|
gates = {
|
|
5811
5870
|
fired: altSection !== void 0 && altSection.text.length > 0,
|
|
5812
|
-
rule:
|
|
5871
|
+
rule: strategyId,
|
|
5813
5872
|
gateTokens: altSection ? countTokens(`${altSection.text}
|
|
5814
5873
|
|
|
5815
5874
|
`) : 0
|
|
@@ -6240,7 +6299,8 @@ function classifyStrategyOutcome(r) {
|
|
|
6240
6299
|
if (r.losses > r.wins) return "loses";
|
|
6241
6300
|
return "ties";
|
|
6242
6301
|
}
|
|
6243
|
-
var STRATEGY_AUTHORSHIP_LIMITATION = "
|
|
6302
|
+
var STRATEGY_AUTHORSHIP_LIMITATION = "Only the v1 wording was measured on this run; no re-wording arm was triggered, so this result says nothing about whether the wording or the mechanism produced it.";
|
|
6303
|
+
var STRATEGY_AUTHORSHIP_INDEPENDENT = "Three arms: v1 and one re-wording by this seat, plus an independently authored arm (context-free subagent, no repo access, no knowledge of the experiment). A both-lose verdict therefore spans independent authorship and is not explained by one author's blind spot. Residual limitation: all three arms encode a similar set of underlying principles, so a wrong CHOICE of principles remains harder to see than a wrong wording of them.";
|
|
6244
6304
|
async function runStrategyEvalWithAttribution(opts) {
|
|
6245
6305
|
const primary = await runGoldenEval({
|
|
6246
6306
|
...opts,
|
|
@@ -6257,9 +6317,20 @@ async function runStrategyEvalWithAttribution(opts) {
|
|
|
6257
6317
|
axis: "strategy",
|
|
6258
6318
|
strategy: "discipline-gates-v1-alt"
|
|
6259
6319
|
});
|
|
6260
|
-
const
|
|
6261
|
-
|
|
6262
|
-
|
|
6320
|
+
const altBlind = await runGoldenEval({
|
|
6321
|
+
...opts,
|
|
6322
|
+
axis: "strategy",
|
|
6323
|
+
strategy: "discipline-gates-v1-alt-blind"
|
|
6324
|
+
});
|
|
6325
|
+
const outcomes = [classifyStrategyOutcome(alt), classifyStrategyOutcome(altBlind)];
|
|
6326
|
+
const attribution = outcomes.includes("wins") ? "wording-failure" : outcomes.every((o) => o === "loses") ? "mechanism-failure" : "wording-inconclusive";
|
|
6327
|
+
return {
|
|
6328
|
+
attribution,
|
|
6329
|
+
primary,
|
|
6330
|
+
alt,
|
|
6331
|
+
altBlind,
|
|
6332
|
+
limitation: STRATEGY_AUTHORSHIP_INDEPENDENT
|
|
6333
|
+
};
|
|
6263
6334
|
}
|
|
6264
6335
|
|
|
6265
6336
|
// src/oracle.ts
|
|
@@ -6516,6 +6587,30 @@ function createDelegate(opts) {
|
|
|
6516
6587
|
}
|
|
6517
6588
|
|
|
6518
6589
|
// src/advisories-api.ts
|
|
6590
|
+
var BURST_SPAN_MS = 5 * 60 * 1e3;
|
|
6591
|
+
function classifyEvidenceWindow(row) {
|
|
6592
|
+
const { evidence_first_at: first, evidence_last_at: last, evidence_n: n } = row;
|
|
6593
|
+
if (typeof first !== "string" || typeof last !== "string") return null;
|
|
6594
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n <= 0) return null;
|
|
6595
|
+
const t0 = Date.parse(first);
|
|
6596
|
+
const t1 = Date.parse(last);
|
|
6597
|
+
if (Number.isNaN(t0) || Number.isNaN(t1)) return null;
|
|
6598
|
+
const spanMs = Math.max(0, t1 - t0);
|
|
6599
|
+
return { firstAt: first, lastAt: last, n, spanMs, isBurst: spanMs < BURST_SPAN_MS };
|
|
6600
|
+
}
|
|
6601
|
+
function formatEvidenceSpan(spanMs) {
|
|
6602
|
+
if (spanMs < 1e3) return `${spanMs}ms`;
|
|
6603
|
+
const s = Math.round(spanMs / 1e3);
|
|
6604
|
+
if (s < 90) return `${s}s`;
|
|
6605
|
+
const m = Math.round(s / 60);
|
|
6606
|
+
if (m < 90) return `${m}m`;
|
|
6607
|
+
const h = Math.round(m / 60);
|
|
6608
|
+
if (h < 48) return `${h}h`;
|
|
6609
|
+
return `${Math.round(h / 24)}d`;
|
|
6610
|
+
}
|
|
6611
|
+
function burstCaveat(w) {
|
|
6612
|
+
return `Evidence is ${w.n} observation${w.n === 1 ? "" : "s"} spanning ${formatEvidenceSpan(w.spanMs)} (${w.firstAt} \u2192 ${w.lastAt}) \u2014 that is a single burst, not a standing rate. Check it against your own deploy log before acting: a cluster this tight is usually one incident, and may already be fixed.`;
|
|
6613
|
+
}
|
|
6519
6614
|
var SEVERITY_SET = /* @__PURE__ */ new Set(["info", "warn", "critical"]);
|
|
6520
6615
|
var STATUS_SET = /* @__PURE__ */ new Set(["open", "snoozed", "resolved"]);
|
|
6521
6616
|
var RESOLUTION_SOURCE_SET = /* @__PURE__ */ new Set([
|
|
@@ -6555,10 +6650,18 @@ function rowToAdvisory(row) {
|
|
|
6555
6650
|
if (docsLink) suggestedFix.docsLink = docsLink;
|
|
6556
6651
|
if (suggestion) suggestedFix.before = suggestion;
|
|
6557
6652
|
}
|
|
6653
|
+
const evidenceWindow = classifyEvidenceWindow(
|
|
6654
|
+
row
|
|
6655
|
+
);
|
|
6656
|
+
const declaredSeverity = asSeverity(row.severity);
|
|
6657
|
+
const downgraded = evidenceWindow?.isBurst === true && declaredSeverity === "critical";
|
|
6658
|
+
const effectiveSeverity = downgraded ? "warn" : declaredSeverity;
|
|
6558
6659
|
const out = {
|
|
6559
6660
|
id: typeof row.id === "string" ? row.id : "",
|
|
6560
6661
|
rule: typeof row.rule === "string" ? row.rule : "",
|
|
6561
|
-
severity:
|
|
6662
|
+
severity: effectiveSeverity,
|
|
6663
|
+
evidenceWindow,
|
|
6664
|
+
...downgraded ? { severityBeforeBurstDowngrade: declaredSeverity } : {},
|
|
6562
6665
|
openedAt: typeof row.opened_at === "string" ? row.opened_at : "",
|
|
6563
6666
|
lastObservedAt: typeof row.last_observed_at === "string" ? row.last_observed_at : "",
|
|
6564
6667
|
observationCount: typeof row.observation_count === "number" ? row.observation_count : 0,
|
|
@@ -6566,7 +6669,13 @@ function rowToAdvisory(row) {
|
|
|
6566
6669
|
...archetype ? { archetype } : {},
|
|
6567
6670
|
...model ? { model } : {}
|
|
6568
6671
|
},
|
|
6569
|
-
|
|
6672
|
+
// The caveat goes INLINE in the message, not only in `evidenceWindow`.
|
|
6673
|
+
// A structured field a consumer must think to read is the same defect
|
|
6674
|
+
// one layer along: the substrate knowing and not telling. The whole
|
|
6675
|
+
// point is that the check costs a glance rather than a query.
|
|
6676
|
+
message: (typeof row.message === "string" ? row.message : "") + (evidenceWindow?.isBurst ? `
|
|
6677
|
+
|
|
6678
|
+
${burstCaveat(evidenceWindow)}` : ""),
|
|
6570
6679
|
suggestedFix,
|
|
6571
6680
|
autoApplicable: false,
|
|
6572
6681
|
// reserved — alpha.30+
|
|
@@ -7103,9 +7212,12 @@ export {
|
|
|
7103
7212
|
ABSOLUTE_FLOOR,
|
|
7104
7213
|
ALIASES,
|
|
7105
7214
|
ALL_ARCHETYPES,
|
|
7215
|
+
ALT_BLIND_TOKEN_BUDGET_BREACH,
|
|
7216
|
+
ALT_STRATEGY_IDS,
|
|
7106
7217
|
ARCHETYPE_FAMILY_FITS,
|
|
7107
7218
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
7108
7219
|
BRAIN_READ_ENV_NAMES,
|
|
7220
|
+
BURST_SPAN_MS,
|
|
7109
7221
|
COACH_CFG,
|
|
7110
7222
|
COST_RANKING_REFERENCE_SHAPE,
|
|
7111
7223
|
CallError,
|
|
@@ -7116,6 +7228,7 @@ export {
|
|
|
7116
7228
|
DEFAULT_PROMOTIONS_ENDPOINT,
|
|
7117
7229
|
DELEGATE_TOOL_DEFINITION,
|
|
7118
7230
|
DIALECT_VERSION,
|
|
7231
|
+
DISCIPLINE_GATES_V1_ALT_BLIND_HEADER,
|
|
7119
7232
|
DISCIPLINE_GATES_V1_ALT_HEADER,
|
|
7120
7233
|
FamilyResolutionError,
|
|
7121
7234
|
INTENT_ARCHETYPES,
|
|
@@ -7132,6 +7245,7 @@ export {
|
|
|
7132
7245
|
RULE_DISCIPLINE_GATES_V1,
|
|
7133
7246
|
RULE_DISCIPLINE_GATES_V1_STRUCTURED,
|
|
7134
7247
|
RULE_SEQUENTIAL_TOOL_CLIFF,
|
|
7248
|
+
STRATEGY_AUTHORSHIP_INDEPENDENT,
|
|
7135
7249
|
STRATEGY_AUTHORSHIP_LIMITATION,
|
|
7136
7250
|
TRANSLATOR_FLOOR,
|
|
7137
7251
|
_testResetMeasuredFailure,
|
|
@@ -7139,6 +7253,7 @@ export {
|
|
|
7139
7253
|
_testWaitForMeasuredFailureRefresh,
|
|
7140
7254
|
_testWaitForPromotionsRefresh,
|
|
7141
7255
|
allProfiles,
|
|
7256
|
+
altBlindGatesBlockFor,
|
|
7142
7257
|
altGatesBlockFor,
|
|
7143
7258
|
applyArchetypeConvention,
|
|
7144
7259
|
applySectionRewrites,
|
|
@@ -7152,9 +7267,11 @@ export {
|
|
|
7152
7267
|
buildLLMJudge,
|
|
7153
7268
|
buildPairwiseJudgePrompt,
|
|
7154
7269
|
buildShadowProbeRow,
|
|
7270
|
+
burstCaveat,
|
|
7155
7271
|
call,
|
|
7156
7272
|
captureGoldenIr,
|
|
7157
7273
|
chainProviderSpread,
|
|
7274
|
+
classifyEvidenceWindow,
|
|
7158
7275
|
classifyStrategyOutcome,
|
|
7159
7276
|
clearBrain,
|
|
7160
7277
|
combineOrderSwappedVerdicts,
|
|
@@ -7174,6 +7291,7 @@ export {
|
|
|
7174
7291
|
execute,
|
|
7175
7292
|
findBetterFit,
|
|
7176
7293
|
flushBrainDeadLetter,
|
|
7294
|
+
formatEvidenceSpan,
|
|
7177
7295
|
getActionableAdvisories,
|
|
7178
7296
|
getAllStarterChains,
|
|
7179
7297
|
getAllStarterChainsWithGrounding,
|
|
@@ -7195,6 +7313,7 @@ export {
|
|
|
7195
7313
|
getStarterChainWithGrounding,
|
|
7196
7314
|
hasMutation,
|
|
7197
7315
|
hashShape,
|
|
7316
|
+
isAltStrategy,
|
|
7198
7317
|
isArchetype,
|
|
7199
7318
|
isAutoPromoteEnabledFromEnv,
|
|
7200
7319
|
isBrainQueryActiveFor,
|
|
@@ -7240,6 +7359,7 @@ export {
|
|
|
7240
7359
|
resolveGoldenCaptureRate,
|
|
7241
7360
|
resolvePricingAt,
|
|
7242
7361
|
resolveProviderKey,
|
|
7362
|
+
rowToAdvisory,
|
|
7243
7363
|
rubricFor,
|
|
7244
7364
|
runAdvisor,
|
|
7245
7365
|
runGoldenEval,
|
|
@@ -7248,6 +7368,7 @@ export {
|
|
|
7248
7368
|
shouldCaptureGolden,
|
|
7249
7369
|
tryGetProfile,
|
|
7250
7370
|
wilsonLowerBound,
|
|
7371
|
+
withAltBlindDisciplineContract,
|
|
7251
7372
|
withAltDisciplineContract,
|
|
7252
7373
|
withDisciplineContract
|
|
7253
7374
|
};
|
package/dist/key-health.js
CHANGED
|
@@ -28,7 +28,7 @@ __export(key_health_exports, {
|
|
|
28
28
|
module.exports = __toCommonJS(key_health_exports);
|
|
29
29
|
|
|
30
30
|
// src/version.ts
|
|
31
|
-
var LIBRARY_VERSION = "2.0.0-alpha.
|
|
31
|
+
var LIBRARY_VERSION = "2.0.0-alpha.83";
|
|
32
32
|
|
|
33
33
|
// src/key-health.ts
|
|
34
34
|
var JSON_HEADERS = { "Content-Type": "application/json" };
|
package/dist/key-health.mjs
CHANGED
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.83",
|
|
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",
|