@mhingston5/lasso 0.1.0 → 0.2.0
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/.lean-ctx/graph.db +0 -0
- package/.lean-ctx/graph.db-shm +0 -0
- package/.lean-ctx/graph.db-wal +0 -0
- package/README.md +189 -46
- package/package.json +1 -1
- package/src/cir/lower.ts +2 -0
- package/src/cir/types.ts +6 -0
- package/src/compiler/compile.ts +272 -2
- package/src/failures/generator.ts +78 -2
- package/src/failures/types.ts +21 -0
- package/src/index.ts +1 -0
- package/src/metaharness/engine.ts +146 -3
- package/src/metaharness/trace-adapter.ts +34 -0
- package/src/metaharness/types.ts +41 -0
- package/src/replanner/runtime.ts +181 -0
- package/src/spec/schema.ts +46 -6
- package/src/spec/types.ts +39 -0
- package/test/compiler/per-node-harness.test.ts +955 -0
- package/test/failures/risk.test.ts +285 -0
- package/test/metaharness/synthesize-from-trace.test.ts +372 -0
- package/test/replanner/runtime.test.ts +134 -0
package/src/spec/schema.ts
CHANGED
|
@@ -35,7 +35,9 @@ export const harnessSpecSchema = {
|
|
|
35
35
|
label: { type: "string" },
|
|
36
36
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
37
37
|
retryPolicy: { $ref: "#/$defs/retryPolicy" },
|
|
38
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
38
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
39
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
40
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
{
|
|
@@ -54,7 +56,9 @@ export const harnessSpecSchema = {
|
|
|
54
56
|
label: { type: "string" },
|
|
55
57
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
56
58
|
retryPolicy: { $ref: "#/$defs/retryPolicy" },
|
|
57
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
59
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
60
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
61
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
58
62
|
}
|
|
59
63
|
},
|
|
60
64
|
{
|
|
@@ -70,7 +74,9 @@ export const harnessSpecSchema = {
|
|
|
70
74
|
timeout: { type: "number" },
|
|
71
75
|
label: { type: "string" },
|
|
72
76
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
73
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
77
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
78
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
79
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
74
80
|
}
|
|
75
81
|
},
|
|
76
82
|
{
|
|
@@ -85,7 +91,9 @@ export const harnessSpecSchema = {
|
|
|
85
91
|
elseNodeId: { type: "string", minLength: 1 },
|
|
86
92
|
label: { type: "string" },
|
|
87
93
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
88
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
94
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
95
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
96
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
89
97
|
}
|
|
90
98
|
},
|
|
91
99
|
{
|
|
@@ -99,7 +107,9 @@ export const harnessSpecSchema = {
|
|
|
99
107
|
strategy: { enum: ["all", "any", "majority"] },
|
|
100
108
|
label: { type: "string" },
|
|
101
109
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
102
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
110
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
111
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
112
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
103
113
|
}
|
|
104
114
|
},
|
|
105
115
|
{
|
|
@@ -114,7 +124,9 @@ export const harnessSpecSchema = {
|
|
|
114
124
|
label: { type: "string" },
|
|
115
125
|
executionPolicy: { $ref: "#/$defs/executionPolicy" },
|
|
116
126
|
retryPolicy: { $ref: "#/$defs/retryPolicy" },
|
|
117
|
-
verificationPolicy: { $ref: "#/$defs/verificationPolicy" }
|
|
127
|
+
verificationPolicy: { $ref: "#/$defs/verificationPolicy" },
|
|
128
|
+
guardrails: { $ref: "#/$defs/nodeGuardrails" },
|
|
129
|
+
verificationHooks: { $ref: "#/$defs/verificationHooks" }
|
|
118
130
|
}
|
|
119
131
|
}
|
|
120
132
|
]
|
|
@@ -249,6 +261,34 @@ export const harnessSpecSchema = {
|
|
|
249
261
|
items: { type: "string" }
|
|
250
262
|
}
|
|
251
263
|
}
|
|
264
|
+
},
|
|
265
|
+
nodeGuardrails: {
|
|
266
|
+
type: "object",
|
|
267
|
+
additionalProperties: false,
|
|
268
|
+
properties: {
|
|
269
|
+
timeoutSeconds: { type: "number", exclusiveMinimum: 0 },
|
|
270
|
+
maxRetries: { type: "number", minimum: 0 },
|
|
271
|
+
maxCostUsd: { type: "number", exclusiveMinimum: 0 },
|
|
272
|
+
constraints: {
|
|
273
|
+
type: "array",
|
|
274
|
+
items: { type: "string", minLength: 1 }
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
verificationHooks: {
|
|
279
|
+
type: "array",
|
|
280
|
+
items: {
|
|
281
|
+
type: "object",
|
|
282
|
+
required: ["name", "kind", "check", "onFail"],
|
|
283
|
+
additionalProperties: false,
|
|
284
|
+
properties: {
|
|
285
|
+
name: { type: "string", minLength: 1 },
|
|
286
|
+
kind: { enum: ["tool", "llm", "expression"] },
|
|
287
|
+
check: { type: "string", minLength: 1 },
|
|
288
|
+
onFail: { enum: ["block", "warn", "retry"] },
|
|
289
|
+
maxAttempts: { type: "number", minimum: 1 }
|
|
290
|
+
}
|
|
291
|
+
}
|
|
252
292
|
}
|
|
253
293
|
}
|
|
254
294
|
};
|
package/src/spec/types.ts
CHANGED
|
@@ -75,6 +75,45 @@ export interface BaseNode {
|
|
|
75
75
|
|
|
76
76
|
/** Verification policy for this node */
|
|
77
77
|
verificationPolicy?: VerificationPolicy;
|
|
78
|
+
|
|
79
|
+
/** Per-node guardrails — limits that apply only during this node's execution */
|
|
80
|
+
guardrails?: NodeGuardrails;
|
|
81
|
+
|
|
82
|
+
/** Per-node verification hooks — run after this specific node completes */
|
|
83
|
+
verificationHooks?: VerificationHook[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface NodeGuardrails {
|
|
87
|
+
/** Max execution time for this node in seconds */
|
|
88
|
+
timeoutSeconds?: number;
|
|
89
|
+
/** Max retries for this node (overrides global retryPolicy) */
|
|
90
|
+
maxRetries?: number;
|
|
91
|
+
/** Max cost in USD for this node (for LLM nodes) */
|
|
92
|
+
maxCostUsd?: number;
|
|
93
|
+
/** Custom guardrail expressions that must hold true */
|
|
94
|
+
constraints?: string[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Inline verification hook that runs after the declaring node completes.
|
|
99
|
+
* Unlike {@link VerificationRule}, which references a separate verifier node
|
|
100
|
+
* in the graph (node-based verification), a VerificationHook defines an
|
|
101
|
+
* inline check (string expression, LLM prompt, or tool call) that executes
|
|
102
|
+
* as part of the same node's lifecycle. Both serve similar purposes through
|
|
103
|
+
* different mechanisms: hooks are lightweight and co-located, while rules
|
|
104
|
+
* allow full graph-node verification logic with independent inputs/outputs.
|
|
105
|
+
*/
|
|
106
|
+
export interface VerificationHook {
|
|
107
|
+
/** Hook name for identification */
|
|
108
|
+
name: string;
|
|
109
|
+
/** Kind of verification */
|
|
110
|
+
kind: "tool" | "llm" | "expression";
|
|
111
|
+
/** The check to run (tool name, prompt, or expression) */
|
|
112
|
+
check: string;
|
|
113
|
+
/** What to do on failure */
|
|
114
|
+
onFail: "block" | "warn" | "retry";
|
|
115
|
+
/** Max verification attempts (optional) */
|
|
116
|
+
maxAttempts?: number;
|
|
78
117
|
}
|
|
79
118
|
|
|
80
119
|
/** Execute a tool command */
|