@kernloop/workflows 0.1.0 → 0.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernloop/workflows",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Kernloop Layer 3 — the canonical loop as data plus the execution engine (spec §6): one blessed graph, per-node checkpoint/resume, and the K-bounded vote-iterate cycle. All real work (model calls, gates, memory) arrives as injected node executors; checkpoint persistence arrives as an injected storage interface — this package imports contracts and zod only.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "zod": "^4.4.3",
20
- "@kernloop/contracts": "0.1.0"
20
+ "@kernloop/contracts": "0.1.2"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^25.9.3"
@@ -1,36 +0,0 @@
1
- /**
2
- * Shared scripted fixtures for the child-iteration + budget-mode tests
3
- * [CLM-0043, CLM-0077]. Kept apart so neither test file outgrows the 400-line
4
- * budget; not a runtime export (test-only, imported by `*.test.ts`).
5
- */
6
- import type { Brief, Finding, Outcome, TaskContract, Verdict } from '@kernloop/contracts';
7
- import type { NodeContext, NodeExecutor } from './engine.js';
8
- export declare const task: TaskContract;
9
- export declare const brief: (taskId: string) => Brief;
10
- export declare const verdict: (taskId: string, gate: string, result: Verdict["result"]) => Verdict;
11
- export declare const outcome: (taskId: string) => Outcome;
12
- export declare const names: (trace: readonly {
13
- node: string;
14
- childId?: string;
15
- }[]) => string[];
16
- /**
17
- * A scripted executor set. `qualityByChild` maps a child id to its sequence of
18
- * quality results (last entry repeats). Records each implement's NodeContext so
19
- * tests can assert the folded child findings + childIteration.
20
- */
21
- export declare function scripted(qualityByChild?: Record<string, Array<Verdict['result']>>): {
22
- executors: Record<string, NodeExecutor>;
23
- qualityCalls: Record<string, number>;
24
- implementCtx: {
25
- childId: string;
26
- iteration: number;
27
- findings: readonly Finding[];
28
- }[];
29
- };
30
- export declare function counted(executors: Record<string, NodeExecutor>): {
31
- executors: {
32
- [k: string]: (input: unknown, ctx: NodeContext) => Promise<unknown>;
33
- };
34
- calls: Record<string, number>;
35
- };
36
- //# sourceMappingURL=child-iterate-fixtures.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-iterate-fixtures.d.ts","sourceRoot":"","sources":["../src/child-iterate-fixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,eAAO,MAAM,IAAI,EAAE,YASlB,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,KAAG,KAKrC,CAAC;AAEH,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,QAAQ,OAAO,CAAC,QAAQ,CAAC,KAAG,OAUhF,CAAC;AAEH,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,KAAG,OAOvC,CAAC;AAEH,eAAO,MAAM,KAAK,GAAI,OAAO,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,aACO,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAM;;;;iBAE/C,MAAM;mBAAa,MAAM;kBAAY,SAAS,OAAO,EAAE;;EAiC7F;AAED,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;;6BAKjD,OAAO,OAAO,WAAW;;;EAOtC"}
@@ -1,86 +0,0 @@
1
- export const task = {
2
- id: 'task-1',
3
- goal: 'ship the feature',
4
- constraints: [],
5
- budget: { tokens: 1000, usd: 1, wallClockMin: 10 },
6
- evidence: [],
7
- definitionOfDone: [],
8
- authorityCeiling: 'suggest',
9
- overlay: 'repo',
10
- };
11
- export const brief = (taskId) => ({
12
- taskId,
13
- sections: [],
14
- budget: { allotted: 10, used: 0 },
15
- compilerVersion: 'scripted-1',
16
- });
17
- export const verdict = (taskId, gate, result) => ({
18
- taskId,
19
- gate,
20
- result,
21
- confidence: 1,
22
- findings: result === 'approve' || result === 'pass'
23
- ? []
24
- : [{ severity: 'error', message: `${gate} wants ${taskId} fixed` }],
25
- cost: { tokens: 0, usd: 0 },
26
- });
27
- export const outcome = (taskId) => ({
28
- taskId,
29
- status: 'success',
30
- signals: [],
31
- cost: { tokens: 0, usd: 0 },
32
- traceRef: `trace-${taskId}`,
33
- distillCandidates: [],
34
- });
35
- export const names = (trace) => trace.map((t) => (t.childId === undefined ? t.node : `${t.node}:${t.childId}`));
36
- /**
37
- * A scripted executor set. `qualityByChild` maps a child id to its sequence of
38
- * quality results (last entry repeats). Records each implement's NodeContext so
39
- * tests can assert the folded child findings + childIteration.
40
- */
41
- export function scripted(qualityByChild = {}) {
42
- const qualityCalls = {};
43
- const implementCtx = [];
44
- const executors = {
45
- frame: () => Promise.resolve(task),
46
- research: () => Promise.resolve(brief(task.id)),
47
- plan: () => Promise.resolve(brief(task.id)),
48
- vote: (_i, ctx) => Promise.resolve(verdict(ctx.taskId, 'vote', 'approve')),
49
- decompose: () => Promise.resolve([
50
- { ...task, id: `${task.id}.c1`, parent: task.id },
51
- { ...task, id: `${task.id}.c2`, parent: task.id },
52
- ]),
53
- implement: (input, ctx) => {
54
- const c = input;
55
- implementCtx.push({
56
- childId: c.id,
57
- iteration: ctx.childIteration ?? -1,
58
- findings: ctx.findings,
59
- });
60
- return Promise.resolve(outcome(c.id));
61
- },
62
- quality: (_i, ctx) => {
63
- const id = ctx.child?.id ?? ctx.taskId;
64
- const seq = qualityByChild[id] ?? ['pass'];
65
- const n = qualityCalls[id] ?? 0;
66
- qualityCalls[id] = n + 1;
67
- return Promise.resolve(verdict(id, 'quality', seq[Math.min(n, seq.length - 1)] ?? 'pass'));
68
- },
69
- review: (_i, ctx) => Promise.resolve(verdict(ctx.child?.id ?? ctx.taskId, 'review', 'approve')),
70
- integrate: () => Promise.resolve(outcome(task.id)),
71
- retrospect: (input) => Promise.resolve(input),
72
- };
73
- return { executors, qualityCalls, implementCtx };
74
- }
75
- export function counted(executors) {
76
- const calls = {};
77
- const wrapped = Object.fromEntries(Object.entries(executors).map(([key, fn]) => [
78
- key,
79
- (input, ctx) => {
80
- calls[key] = (calls[key] ?? 0) + 1;
81
- return fn(input, ctx);
82
- },
83
- ]));
84
- return { executors: wrapped, calls };
85
- }
86
- //# sourceMappingURL=child-iterate-fixtures.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-iterate-fixtures.js","sourceRoot":"","sources":["../src/child-iterate-fixtures.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,IAAI,GAAiB;IAChC,EAAE,EAAE,QAAQ;IACZ,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,EAAE;IACf,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;IAClD,QAAQ,EAAE,EAAE;IACZ,gBAAgB,EAAE,EAAE;IACpB,gBAAgB,EAAE,SAAS;IAC3B,OAAO,EAAE,MAAM;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAS,EAAE,CAAC,CAAC;IAC/C,MAAM;IACN,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACjC,eAAe,EAAE,YAAY;CAC9B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC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