@crewhaus/spec-patch 0.2.1 → 0.2.3
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.ts +8 -0
- package/dist/index.js +32 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -63,6 +63,14 @@ export type ApplySpecPatchResult = {
|
|
|
63
63
|
/** The re-parsed Spec after the patch. */
|
|
64
64
|
readonly spec: Spec;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* Whether the YAML source TEXTUALLY carries a key at `path`. Patch producers
|
|
68
|
+
* need this to pick `add` vs `replace` correctly: Zod-defaulted fields (e.g.
|
|
69
|
+
* `model_pool.policy`) are always present on the PARSED spec, but `replace`
|
|
70
|
+
* throws when the key is absent from the document and `add` throws when it is
|
|
71
|
+
* present — only the CST knows which applies. Unparseable YAML → false.
|
|
72
|
+
*/
|
|
73
|
+
export declare function specHasPath(yamlText: string, path: ReadonlyArray<string>): boolean;
|
|
66
74
|
/**
|
|
67
75
|
* Apply a structured patch to a YAML spec source. Uses the `yaml`
|
|
68
76
|
* package's CST so comments and key order survive the round-trip; the
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,21 @@ const specPatchSchema = z.object({
|
|
|
52
52
|
value: z.unknown().optional(),
|
|
53
53
|
rationale: z.string().optional(),
|
|
54
54
|
});
|
|
55
|
+
/**
|
|
56
|
+
* Whether the YAML source TEXTUALLY carries a key at `path`. Patch producers
|
|
57
|
+
* need this to pick `add` vs `replace` correctly: Zod-defaulted fields (e.g.
|
|
58
|
+
* `model_pool.policy`) are always present on the PARSED spec, but `replace`
|
|
59
|
+
* throws when the key is absent from the document and `add` throws when it is
|
|
60
|
+
* present — only the CST knows which applies. Unparseable YAML → false.
|
|
61
|
+
*/
|
|
62
|
+
export function specHasPath(yamlText, path) {
|
|
63
|
+
try {
|
|
64
|
+
return parseDocument(yamlText).hasIn([...path]);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
55
70
|
/**
|
|
56
71
|
* Apply a structured patch to a YAML spec source. Uses the `yaml`
|
|
57
72
|
* package's CST so comments and key order survive the round-trip; the
|
|
@@ -171,6 +186,15 @@ export const OPTIMIZABLE_PATHS = Object.freeze({
|
|
|
171
186
|
// by patching their parent block.
|
|
172
187
|
Object.freeze(["chains"]),
|
|
173
188
|
Object.freeze(["transaction_policy"]),
|
|
189
|
+
// Adaptive model routing — the pool's POLICY knobs are tunable (advise
|
|
190
|
+
// mines the reward scoreboard into these; optimize --from-advice gates
|
|
191
|
+
// them), but deliberately NOT ["agent","model_pool"] wholesale and NOT
|
|
192
|
+
// ["agent","model_pool","candidates"]: the candidate ROSTER is
|
|
193
|
+
// human-owned, mirroring the standing ["agent","model"] exclusion —
|
|
194
|
+
// learning tunes selection within the declared set, never the set.
|
|
195
|
+
Object.freeze(["agent", "model_pool", "policy"]),
|
|
196
|
+
Object.freeze(["agent", "model_pool", "routing"]),
|
|
197
|
+
Object.freeze(["agent", "model_pool", "learning"]),
|
|
174
198
|
]),
|
|
175
199
|
workflow: Object.freeze([
|
|
176
200
|
Object.freeze(["steps"]),
|
|
@@ -183,6 +207,10 @@ export const OPTIMIZABLE_PATHS = Object.freeze({
|
|
|
183
207
|
Object.freeze(["failure_taxonomy"]),
|
|
184
208
|
Object.freeze(["chains"]),
|
|
185
209
|
Object.freeze(["transaction_policy"]),
|
|
210
|
+
// Adaptive model routing — pool policy knobs only (see the cli entry).
|
|
211
|
+
Object.freeze(["agent", "model_pool", "policy"]),
|
|
212
|
+
Object.freeze(["agent", "model_pool", "routing"]),
|
|
213
|
+
Object.freeze(["agent", "model_pool", "learning"]),
|
|
186
214
|
]),
|
|
187
215
|
graph: Object.freeze([
|
|
188
216
|
Object.freeze(["nodes"]),
|
|
@@ -193,6 +221,10 @@ export const OPTIMIZABLE_PATHS = Object.freeze({
|
|
|
193
221
|
managed: Object.freeze([
|
|
194
222
|
Object.freeze(["agent", "instructions"]),
|
|
195
223
|
Object.freeze(["failure_taxonomy"]),
|
|
224
|
+
// Adaptive model routing — pool policy knobs only (see the cli entry).
|
|
225
|
+
Object.freeze(["agent", "model_pool", "policy"]),
|
|
226
|
+
Object.freeze(["agent", "model_pool", "routing"]),
|
|
227
|
+
Object.freeze(["agent", "model_pool", "learning"]),
|
|
196
228
|
]),
|
|
197
229
|
pipeline: Object.freeze([
|
|
198
230
|
Object.freeze(["agent", "instructions"]),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewhaus/spec-patch",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pillar-2 patch infrastructure — apply a SpecPatch to a YAML source preserving comments and key order via the yaml CST. Drives the active eval optimizer's spec-level mutation loop.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"test": "bun test src"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@crewhaus/errors": "0.2.
|
|
19
|
-
"@crewhaus/spec": "0.2.
|
|
18
|
+
"@crewhaus/errors": "0.2.3",
|
|
19
|
+
"@crewhaus/spec": "0.2.3",
|
|
20
20
|
"yaml": "^2.6.0",
|
|
21
21
|
"zod": "^3.23.8"
|
|
22
22
|
},
|