@warmdrift/kgauto-compiler 2.0.0-alpha.48 → 2.0.0-alpha.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +46 -3
- package/dist/index.mjs +46 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1844,6 +1844,10 @@ interface ModelBrainRow {
|
|
|
1844
1844
|
active?: boolean;
|
|
1845
1845
|
/** alpha.41 — model-family tag (migration 024 column). */
|
|
1846
1846
|
family?: string | null;
|
|
1847
|
+
/** alpha.49 — explicit latency bucket (migration 028 column). */
|
|
1848
|
+
latency_tier?: string | null;
|
|
1849
|
+
/** alpha.49 — per-archetype prompt-shape conventions (migration 028 column). */
|
|
1850
|
+
archetype_conventions?: ArchetypeConvention[] | null;
|
|
1847
1851
|
}
|
|
1848
1852
|
interface ProfileToRowOptions {
|
|
1849
1853
|
/** e.g. `'2.0.0-alpha.12'` — leave undefined to omit from row. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1844,6 +1844,10 @@ interface ModelBrainRow {
|
|
|
1844
1844
|
active?: boolean;
|
|
1845
1845
|
/** alpha.41 — model-family tag (migration 024 column). */
|
|
1846
1846
|
family?: string | null;
|
|
1847
|
+
/** alpha.49 — explicit latency bucket (migration 028 column). */
|
|
1848
|
+
latency_tier?: string | null;
|
|
1849
|
+
/** alpha.49 — per-archetype prompt-shape conventions (migration 028 column). */
|
|
1850
|
+
archetype_conventions?: ArchetypeConvention[] | null;
|
|
1847
1851
|
}
|
|
1848
1852
|
interface ProfileToRowOptions {
|
|
1849
1853
|
/** e.g. `'2.0.0-alpha.12'` — leave undefined to omit from row. */
|
package/dist/index.js
CHANGED
|
@@ -1587,6 +1587,9 @@ function rowToProfile(row) {
|
|
|
1587
1587
|
if (row.lowering !== void 0 && row.lowering !== null && (typeof row.lowering !== "object" || Array.isArray(row.lowering))) {
|
|
1588
1588
|
return null;
|
|
1589
1589
|
}
|
|
1590
|
+
if (row.archetype_conventions !== void 0 && row.archetype_conventions !== null && !Array.isArray(row.archetype_conventions)) {
|
|
1591
|
+
return null;
|
|
1592
|
+
}
|
|
1590
1593
|
return {
|
|
1591
1594
|
id: row.model_id,
|
|
1592
1595
|
provider: row.provider,
|
|
@@ -1613,12 +1616,21 @@ function rowToProfile(row) {
|
|
|
1613
1616
|
// resolution time (see family-resolution.ts, G1).
|
|
1614
1617
|
family: row.family ?? void 0,
|
|
1615
1618
|
versionAdded: row.version_added ?? void 0,
|
|
1616
|
-
active: row.active ?? void 0
|
|
1619
|
+
active: row.active ?? void 0,
|
|
1620
|
+
// alpha.49 — executable-knowledge fields (migration 028). Invalid
|
|
1621
|
+
// latency_tier → undefined (latencyTierOf derives from tags; not
|
|
1622
|
+
// safety-critical). archetype_conventions already array-validated above.
|
|
1623
|
+
latencyTier: normalizeLatencyTier(row.latency_tier),
|
|
1624
|
+
archetypeConventions: row.archetype_conventions ?? void 0
|
|
1617
1625
|
};
|
|
1618
1626
|
} catch {
|
|
1619
1627
|
return null;
|
|
1620
1628
|
}
|
|
1621
1629
|
}
|
|
1630
|
+
var VALID_LATENCY_TIERS = /* @__PURE__ */ new Set(["fast", "medium", "slow"]);
|
|
1631
|
+
function normalizeLatencyTier(v) {
|
|
1632
|
+
return typeof v === "string" && VALID_LATENCY_TIERS.has(v) ? v : void 0;
|
|
1633
|
+
}
|
|
1622
1634
|
function profileToRow(profile, opts = {}) {
|
|
1623
1635
|
const row = {
|
|
1624
1636
|
model_id: profile.id,
|
|
@@ -1644,7 +1656,12 @@ function profileToRow(profile, opts = {}) {
|
|
|
1644
1656
|
// alpha.41 — round-trip family + version_added when present on profile.
|
|
1645
1657
|
// version_added is operator-controlled via opts; profile-side value is
|
|
1646
1658
|
// used only when opts didn't override.
|
|
1647
|
-
family: profile.family ?? null
|
|
1659
|
+
family: profile.family ?? null,
|
|
1660
|
+
// alpha.49 — round-trip the executable-knowledge fields (migration 028)
|
|
1661
|
+
// so a reseed from bundled profiles makes the latency lever + schema
|
|
1662
|
+
// conventions live warm. Closes the silently-dropped-field gap.
|
|
1663
|
+
latency_tier: profile.latencyTier ?? null,
|
|
1664
|
+
archetype_conventions: profile.archetypeConventions ?? null
|
|
1648
1665
|
};
|
|
1649
1666
|
if (opts.verifiedAgainstDocs !== void 0) {
|
|
1650
1667
|
row.verified_against_docs = opts.verifiedAgainstDocs;
|
|
@@ -2389,6 +2406,17 @@ function passApplyCliffs(ir, profile, estimatedInputTokens) {
|
|
|
2389
2406
|
}
|
|
2390
2407
|
var LATENCY_OVERAGE_WEIGHT = 0.6;
|
|
2391
2408
|
var LATENCY_PENALTY_CAP = 1;
|
|
2409
|
+
var QUALITY_GATE_PENALTY = 4;
|
|
2410
|
+
function effectiveConventions(profile) {
|
|
2411
|
+
const own = profile.archetypeConventions ?? [];
|
|
2412
|
+
if (own.length > 0) return own;
|
|
2413
|
+
const family = profile.family ?? deriveFamilyFromModelId(profile.id);
|
|
2414
|
+
if (!family) return [];
|
|
2415
|
+
const repId = familyRepId(family);
|
|
2416
|
+
if (!repId || repId === profile.id) return [];
|
|
2417
|
+
const rep = tryGetProfile(repId);
|
|
2418
|
+
return rep?.archetypeConventions ?? [];
|
|
2419
|
+
}
|
|
2392
2420
|
function passScoreTargets(ir, opts) {
|
|
2393
2421
|
const constraints = ir.constraints ?? {};
|
|
2394
2422
|
const policy = opts.policy ?? {};
|
|
@@ -2453,7 +2481,14 @@ function passScoreTargets(ir, opts) {
|
|
|
2453
2481
|
latencyPenalty = Math.min(LATENCY_OVERAGE_WEIGHT * overage, LATENCY_PENALTY_CAP);
|
|
2454
2482
|
}
|
|
2455
2483
|
}
|
|
2456
|
-
|
|
2484
|
+
let qualityGatePenalty = 0;
|
|
2485
|
+
if (constraints.structuredOutput) {
|
|
2486
|
+
const schemaWeak = effectiveConventions(profile).some(
|
|
2487
|
+
(c) => c.archetype === ir.intent.archetype && c.structuredOutputHint === "avoid"
|
|
2488
|
+
);
|
|
2489
|
+
if (schemaWeak) qualityGatePenalty = QUALITY_GATE_PENALTY;
|
|
2490
|
+
}
|
|
2491
|
+
const rank = qualityScore + callerOrderBoost - costPenalty - reasons.length * 10 + preferredBoost - latencyPenalty - qualityGatePenalty;
|
|
2457
2492
|
scores.push({
|
|
2458
2493
|
modelId,
|
|
2459
2494
|
estimatedCostUsd,
|
|
@@ -2495,6 +2530,14 @@ function passScoreTargets(ir, opts) {
|
|
|
2495
2530
|
description: `Model ${modelId} rank down ${latencyPenalty.toFixed(2)} \u2014 latency tier '${tier}' (~${LATENCY_TIER_MS[tier]}ms) exceeds constraints.maxLatencyMs (${maxLatencyMs}ms)`
|
|
2496
2531
|
});
|
|
2497
2532
|
}
|
|
2533
|
+
if (qualityGatePenalty > 0) {
|
|
2534
|
+
policyMutations.push({
|
|
2535
|
+
id: `quality-gate-structured-${modelId}`,
|
|
2536
|
+
source: "quality_gate",
|
|
2537
|
+
passName: "score_targets",
|
|
2538
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' \u2014 declared structuredOutput + kgauto convention flags it schema-weak for this contract (structuredOutputHint:'avoid'). Down-ranked out of leadership; retained as graceful fallback only.`
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2498
2541
|
}
|
|
2499
2542
|
return { value: scores, mutations: policyMutations };
|
|
2500
2543
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -76,6 +76,9 @@ function rowToProfile(row) {
|
|
|
76
76
|
if (row.lowering !== void 0 && row.lowering !== null && (typeof row.lowering !== "object" || Array.isArray(row.lowering))) {
|
|
77
77
|
return null;
|
|
78
78
|
}
|
|
79
|
+
if (row.archetype_conventions !== void 0 && row.archetype_conventions !== null && !Array.isArray(row.archetype_conventions)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
79
82
|
return {
|
|
80
83
|
id: row.model_id,
|
|
81
84
|
provider: row.provider,
|
|
@@ -102,12 +105,21 @@ function rowToProfile(row) {
|
|
|
102
105
|
// resolution time (see family-resolution.ts, G1).
|
|
103
106
|
family: row.family ?? void 0,
|
|
104
107
|
versionAdded: row.version_added ?? void 0,
|
|
105
|
-
active: row.active ?? void 0
|
|
108
|
+
active: row.active ?? void 0,
|
|
109
|
+
// alpha.49 — executable-knowledge fields (migration 028). Invalid
|
|
110
|
+
// latency_tier → undefined (latencyTierOf derives from tags; not
|
|
111
|
+
// safety-critical). archetype_conventions already array-validated above.
|
|
112
|
+
latencyTier: normalizeLatencyTier(row.latency_tier),
|
|
113
|
+
archetypeConventions: row.archetype_conventions ?? void 0
|
|
106
114
|
};
|
|
107
115
|
} catch {
|
|
108
116
|
return null;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
119
|
+
var VALID_LATENCY_TIERS = /* @__PURE__ */ new Set(["fast", "medium", "slow"]);
|
|
120
|
+
function normalizeLatencyTier(v) {
|
|
121
|
+
return typeof v === "string" && VALID_LATENCY_TIERS.has(v) ? v : void 0;
|
|
122
|
+
}
|
|
111
123
|
function profileToRow(profile, opts = {}) {
|
|
112
124
|
const row = {
|
|
113
125
|
model_id: profile.id,
|
|
@@ -133,7 +145,12 @@ function profileToRow(profile, opts = {}) {
|
|
|
133
145
|
// alpha.41 — round-trip family + version_added when present on profile.
|
|
134
146
|
// version_added is operator-controlled via opts; profile-side value is
|
|
135
147
|
// used only when opts didn't override.
|
|
136
|
-
family: profile.family ?? null
|
|
148
|
+
family: profile.family ?? null,
|
|
149
|
+
// alpha.49 — round-trip the executable-knowledge fields (migration 028)
|
|
150
|
+
// so a reseed from bundled profiles makes the latency lever + schema
|
|
151
|
+
// conventions live warm. Closes the silently-dropped-field gap.
|
|
152
|
+
latency_tier: profile.latencyTier ?? null,
|
|
153
|
+
archetype_conventions: profile.archetypeConventions ?? null
|
|
137
154
|
};
|
|
138
155
|
if (opts.verifiedAgainstDocs !== void 0) {
|
|
139
156
|
row.verified_against_docs = opts.verifiedAgainstDocs;
|
|
@@ -714,6 +731,17 @@ function passApplyCliffs(ir, profile, estimatedInputTokens) {
|
|
|
714
731
|
}
|
|
715
732
|
var LATENCY_OVERAGE_WEIGHT = 0.6;
|
|
716
733
|
var LATENCY_PENALTY_CAP = 1;
|
|
734
|
+
var QUALITY_GATE_PENALTY = 4;
|
|
735
|
+
function effectiveConventions(profile) {
|
|
736
|
+
const own = profile.archetypeConventions ?? [];
|
|
737
|
+
if (own.length > 0) return own;
|
|
738
|
+
const family = profile.family ?? deriveFamilyFromModelId(profile.id);
|
|
739
|
+
if (!family) return [];
|
|
740
|
+
const repId = familyRepId(family);
|
|
741
|
+
if (!repId || repId === profile.id) return [];
|
|
742
|
+
const rep = tryGetProfile(repId);
|
|
743
|
+
return rep?.archetypeConventions ?? [];
|
|
744
|
+
}
|
|
717
745
|
function passScoreTargets(ir, opts) {
|
|
718
746
|
const constraints = ir.constraints ?? {};
|
|
719
747
|
const policy = opts.policy ?? {};
|
|
@@ -778,7 +806,14 @@ function passScoreTargets(ir, opts) {
|
|
|
778
806
|
latencyPenalty = Math.min(LATENCY_OVERAGE_WEIGHT * overage, LATENCY_PENALTY_CAP);
|
|
779
807
|
}
|
|
780
808
|
}
|
|
781
|
-
|
|
809
|
+
let qualityGatePenalty = 0;
|
|
810
|
+
if (constraints.structuredOutput) {
|
|
811
|
+
const schemaWeak = effectiveConventions(profile).some(
|
|
812
|
+
(c) => c.archetype === ir.intent.archetype && c.structuredOutputHint === "avoid"
|
|
813
|
+
);
|
|
814
|
+
if (schemaWeak) qualityGatePenalty = QUALITY_GATE_PENALTY;
|
|
815
|
+
}
|
|
816
|
+
const rank = qualityScore + callerOrderBoost - costPenalty - reasons.length * 10 + preferredBoost - latencyPenalty - qualityGatePenalty;
|
|
782
817
|
scores.push({
|
|
783
818
|
modelId,
|
|
784
819
|
estimatedCostUsd,
|
|
@@ -820,6 +855,14 @@ function passScoreTargets(ir, opts) {
|
|
|
820
855
|
description: `Model ${modelId} rank down ${latencyPenalty.toFixed(2)} \u2014 latency tier '${tier}' (~${LATENCY_TIER_MS[tier]}ms) exceeds constraints.maxLatencyMs (${maxLatencyMs}ms)`
|
|
821
856
|
});
|
|
822
857
|
}
|
|
858
|
+
if (qualityGatePenalty > 0) {
|
|
859
|
+
policyMutations.push({
|
|
860
|
+
id: `quality-gate-structured-${modelId}`,
|
|
861
|
+
source: "quality_gate",
|
|
862
|
+
passName: "score_targets",
|
|
863
|
+
description: `Model ${modelId} gated below the quality floor for archetype '${ir.intent.archetype}' \u2014 declared structuredOutput + kgauto convention flags it schema-weak for this contract (structuredOutputHint:'avoid'). Down-ranked out of leadership; retained as graceful fallback only.`
|
|
864
|
+
});
|
|
865
|
+
}
|
|
823
866
|
}
|
|
824
867
|
return { value: scores, mutations: policyMutations };
|
|
825
868
|
}
|
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.49",
|
|
4
4
|
"description": "Prompt compiler + central learning brain for multi-model AI apps. Swap models without rewriting prompts.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|