@hmbown/kytchen-reasoning 0.1.1 → 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 +3 -2
- package/dist/autocode.test.d.ts +0 -2
- package/dist/autocode.test.d.ts.map +0 -1
- package/dist/autocode.test.js +0 -149
- package/dist/autocode.test.js.map +0 -1
- package/dist/coherence.test.d.ts +0 -2
- package/dist/coherence.test.d.ts.map +0 -1
- package/dist/coherence.test.js +0 -14
- package/dist/coherence.test.js.map +0 -1
- package/dist/recursive.test.d.ts +0 -2
- package/dist/recursive.test.d.ts.map +0 -1
- package/dist/recursive.test.js +0 -94
- package/dist/recursive.test.js.map +0 -1
- package/dist/router.golden.test.d.ts +0 -2
- package/dist/router.golden.test.d.ts.map +0 -1
- package/dist/router.golden.test.js +0 -84
- package/dist/router.golden.test.js.map +0 -1
- package/dist/router.test.d.ts +0 -2
- package/dist/router.test.d.ts.map +0 -1
- package/dist/router.test.js +0 -86
- package/dist/router.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hmbown/kytchen-reasoning",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Reasoning engines for Kytchen: auto-router, dialectical critique, recursive decomposition, autocode, and coherence control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
+
"!dist/**/*.test.*",
|
|
16
17
|
"LICENSE",
|
|
17
18
|
"README.md"
|
|
18
19
|
],
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@hmbown/kytchen-protocol": "0.1.
|
|
21
|
+
"@hmbown/kytchen-protocol": "0.1.2"
|
|
21
22
|
},
|
|
22
23
|
"keywords": [
|
|
23
24
|
"kytchen",
|
package/dist/autocode.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocode.test.d.ts","sourceRoot":"","sources":["../src/autocode.test.ts"],"names":[],"mappings":""}
|
package/dist/autocode.test.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { AutocodeEngine } from "./autocode.js";
|
|
4
|
-
test("autocode uses defensive fallback when coach response is not valid JSON", async () => {
|
|
5
|
-
const engine = new AutocodeEngine({
|
|
6
|
-
maxRounds: 1,
|
|
7
|
-
qualityThreshold: 0.8,
|
|
8
|
-
generate: async (systemPrompt) => {
|
|
9
|
-
if (systemPrompt.includes("COACH")) {
|
|
10
|
-
return "not-json";
|
|
11
|
-
}
|
|
12
|
-
return "function add(a, b) { return a + b; }";
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const result = await engine.run({
|
|
16
|
-
goal: "Implement addition helper.",
|
|
17
|
-
context: "",
|
|
18
|
-
maxTurns: 1,
|
|
19
|
-
});
|
|
20
|
-
assert.equal(result.accepted, false);
|
|
21
|
-
assert.equal(result.iterations.length, 1);
|
|
22
|
-
assert.equal(result.artifact.accepted, false);
|
|
23
|
-
assert.equal(result.artifact.rounds.length, 1);
|
|
24
|
-
assert.equal(result.artifact.rounds[0]?.review.accept, false);
|
|
25
|
-
assert.equal(result.artifact.rounds[0]?.review.confidence, 0);
|
|
26
|
-
});
|
|
27
|
-
test("autocode rejects malformed coach JSON fields instead of coercing accept/score", async () => {
|
|
28
|
-
const engine = new AutocodeEngine({
|
|
29
|
-
maxIterations: 1,
|
|
30
|
-
acceptanceThreshold: 0.8,
|
|
31
|
-
generate: async (systemPrompt) => {
|
|
32
|
-
if (systemPrompt.includes("COACH")) {
|
|
33
|
-
return JSON.stringify({
|
|
34
|
-
confidence: "NaN",
|
|
35
|
-
accept: "true",
|
|
36
|
-
issues: [],
|
|
37
|
-
refinementNotes: "bad schema",
|
|
38
|
-
rationale: "bad schema",
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return "export const value = 42;";
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
const result = await engine.run({
|
|
45
|
-
task: "Implement value export.",
|
|
46
|
-
maxIterations: 1,
|
|
47
|
-
});
|
|
48
|
-
assert.equal(result.accepted, false);
|
|
49
|
-
assert.equal(result.confidence, 0);
|
|
50
|
-
assert.equal(result.artifact.rounds[0]?.review.accept, false);
|
|
51
|
-
assert.equal(result.artifact.rounds[0]?.review.confidence, 0);
|
|
52
|
-
});
|
|
53
|
-
test("autocode accepts when modern config names meet acceptance threshold", async () => {
|
|
54
|
-
const engine = new AutocodeEngine({
|
|
55
|
-
maxIterations: 2,
|
|
56
|
-
acceptanceThreshold: 0.8,
|
|
57
|
-
generate: async (systemPrompt) => {
|
|
58
|
-
if (systemPrompt.includes("COACH")) {
|
|
59
|
-
return JSON.stringify({
|
|
60
|
-
confidence: 0.92,
|
|
61
|
-
accept: true,
|
|
62
|
-
issues: [],
|
|
63
|
-
refinementNotes: "Looks good.",
|
|
64
|
-
rationale: "Correct, safe, and complete.",
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return "export function multiply(a: number, b: number) { return a * b; }";
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
const result = await engine.run({
|
|
71
|
-
task: "Implement a multiply helper.",
|
|
72
|
-
context: "TypeScript only.",
|
|
73
|
-
existingCode: "export const version = '1.0.0';",
|
|
74
|
-
constraints: ["Keep API stable", "No external dependencies"],
|
|
75
|
-
maxIterations: 2,
|
|
76
|
-
});
|
|
77
|
-
assert.equal(result.mode, "autocode");
|
|
78
|
-
assert.equal(result.accepted, true);
|
|
79
|
-
assert.equal(result.proposal.includes("multiply"), true);
|
|
80
|
-
assert.equal(result.confidence >= 0.8, true);
|
|
81
|
-
assert.equal(result.artifact.accepted, true);
|
|
82
|
-
});
|
|
83
|
-
test("autocode preserves legacy input aliases and artifact compatibility", async () => {
|
|
84
|
-
const engine = new AutocodeEngine({
|
|
85
|
-
maxRounds: 1,
|
|
86
|
-
qualityThreshold: 0.8,
|
|
87
|
-
generate: async (systemPrompt) => {
|
|
88
|
-
if (systemPrompt.includes("COACH")) {
|
|
89
|
-
return JSON.stringify({
|
|
90
|
-
confidence: 0.95,
|
|
91
|
-
accept: true,
|
|
92
|
-
issues: [],
|
|
93
|
-
refinementNotes: "ship it",
|
|
94
|
-
rationale: "Complete implementation.",
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return "export function legacyPath() { return true; }";
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
const result = await engine.run({
|
|
101
|
-
goal: "Implement legacy path helper.",
|
|
102
|
-
context: "",
|
|
103
|
-
maxTurns: 1,
|
|
104
|
-
});
|
|
105
|
-
assert.equal(result.accepted, true);
|
|
106
|
-
assert.equal(result.artifact.draft.includes("legacyPath"), true);
|
|
107
|
-
assert.equal(result.iterations.length, 1);
|
|
108
|
-
});
|
|
109
|
-
test("autocode exposes pause/resume helpers via snapshots", async () => {
|
|
110
|
-
let coachRound = 0;
|
|
111
|
-
const engine = new AutocodeEngine({
|
|
112
|
-
maxIterations: 2,
|
|
113
|
-
acceptanceThreshold: 0.9,
|
|
114
|
-
generate: async (systemPrompt) => {
|
|
115
|
-
if (systemPrompt.includes("COACH")) {
|
|
116
|
-
coachRound += 1;
|
|
117
|
-
if (coachRound === 1) {
|
|
118
|
-
return JSON.stringify({
|
|
119
|
-
confidence: 0.6,
|
|
120
|
-
accept: false,
|
|
121
|
-
issues: ["Add tests"],
|
|
122
|
-
refinementNotes: "Improve validation coverage.",
|
|
123
|
-
rationale: "Coverage is insufficient for edge cases.",
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
return JSON.stringify({
|
|
127
|
-
confidence: 0.95,
|
|
128
|
-
accept: true,
|
|
129
|
-
issues: [],
|
|
130
|
-
refinementNotes: "Ready.",
|
|
131
|
-
rationale: "All criteria met.",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
return coachRound === 0
|
|
135
|
-
? "export function draftOne() { return 1; }"
|
|
136
|
-
: "export function draftTwo() { return 2; }";
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
const snapshot = engine.createSnapshot({
|
|
140
|
-
task: "Iterate until accepted.",
|
|
141
|
-
maxIterations: 2,
|
|
142
|
-
});
|
|
143
|
-
const paused = engine.pause(snapshot);
|
|
144
|
-
const resumed = await engine.resume(paused);
|
|
145
|
-
assert.equal(resumed.accepted, true);
|
|
146
|
-
assert.equal(resumed.iterations.length, 2);
|
|
147
|
-
assert.equal(resumed.snapshot.state, "done");
|
|
148
|
-
});
|
|
149
|
-
//# sourceMappingURL=autocode.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocode.test.js","sourceRoot":"","sources":["../src/autocode.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,IAAI,CAAC,wEAAwE,EAAE,KAAK,IAAI,EAAE;IACxF,MAAM,MAAM,GAAG,IAAI,cAAc,CAAC;QAChC,SAAS,EAAE,CAAC;QACZ,gBAAgB,EAAE,GAAG;QACrB,QAAQ,EAAE,KAAK,EAAE,YAAoB,EAAE,EAAE;YACvC,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnC,OAAO,UAAU,CAAC;YACpB,CAAC;YACD,OAAO,sCAAsC,CAAC;QAChD,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC;QAC9B,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,CAAC;KACZ,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QA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AE5C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
package/dist/coherence.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coherence.test.d.ts","sourceRoot":"","sources":["../src/coherence.test.ts"],"names":[],"mappings":""}
|
package/dist/coherence.test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { getModelProfile, MODEL_PROFILES } from "./coherence.js";
|
|
4
|
-
test("MODEL_PROFILES includes gpt-5.3-codex and related codex entries", () => {
|
|
5
|
-
assert.ok(MODEL_PROFILES["gpt-5.3-codex"]);
|
|
6
|
-
assert.ok(MODEL_PROFILES["gpt-5.3-codex-spark"]);
|
|
7
|
-
assert.ok(MODEL_PROFILES["gpt-5.2-codex"]);
|
|
8
|
-
});
|
|
9
|
-
test("getModelProfile falls back to default profile for unknown models", () => {
|
|
10
|
-
const fallback = getModelProfile("unknown-model-name");
|
|
11
|
-
assert.equal(fallback.name, "default");
|
|
12
|
-
assert.equal(fallback.maxContextTokens, MODEL_PROFILES.default.maxContextTokens);
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=coherence.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"coherence.test.js","sourceRoot":"","sources":["../src/coherence.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEjE,IAAI,CAAC,iEAAiE,EAAE,GAAG,EAAE;IAC3E,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,kEAAkE,EAAE,GAAG,EAAE;IAC5E,MAAM,QAAQ,GAAG,eAAe,CAAC,oBAAoB,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACnF,CAAC,CAAC,CAAC"}
|
package/dist/recursive.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recursive.test.d.ts","sourceRoot":"","sources":["../src/recursive.test.ts"],"names":[],"mappings":""}
|
package/dist/recursive.test.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import test from "node:test";
|
|
3
|
-
import { RecursiveOrchestrator, _resetIdCounter, } from "./recursive.js";
|
|
4
|
-
test("recursive orchestrator emits deterministic task ids and lifecycle events", async () => {
|
|
5
|
-
_resetIdCounter();
|
|
6
|
-
const lifecycle = [];
|
|
7
|
-
const orchestrator = new RecursiveOrchestrator({
|
|
8
|
-
maxDepth: 3,
|
|
9
|
-
maxIterations: 8,
|
|
10
|
-
maxBreadth: 2,
|
|
11
|
-
});
|
|
12
|
-
const trace = await orchestrator.run("root", async (task) => {
|
|
13
|
-
if (task.depth === 0) {
|
|
14
|
-
return {
|
|
15
|
-
summary: "root summary",
|
|
16
|
-
evidence: [],
|
|
17
|
-
subQueries: ["child A", "child B"],
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
summary: `leaf ${task.prompt}`,
|
|
22
|
-
evidence: [],
|
|
23
|
-
};
|
|
24
|
-
}, {
|
|
25
|
-
onLifecycleEvent: (event) => {
|
|
26
|
-
lifecycle.push(event);
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
const taskIds = [...trace.taskMap.keys()];
|
|
30
|
-
assert.deepEqual(taskIds, ["rq-0001", "rq-0002", "rq-0003"]);
|
|
31
|
-
assert.equal(trace.rootOutcome.childOutcomes.length, 2);
|
|
32
|
-
assert.equal(lifecycle.some((event) => event.type === "task.spawned"), true);
|
|
33
|
-
assert.equal(lifecycle.some((event) => event.type === "task.merged"), true);
|
|
34
|
-
});
|
|
35
|
-
test("recursive orchestrator enforces wall-clock budget across children", async () => {
|
|
36
|
-
_resetIdCounter();
|
|
37
|
-
let nowMs = 0;
|
|
38
|
-
const orchestrator = new RecursiveOrchestrator({
|
|
39
|
-
maxDepth: 3,
|
|
40
|
-
maxIterations: 8,
|
|
41
|
-
maxBreadth: 3,
|
|
42
|
-
});
|
|
43
|
-
const trace = await orchestrator.run("root", async (task) => {
|
|
44
|
-
if (task.depth === 0) {
|
|
45
|
-
nowMs += 250;
|
|
46
|
-
return {
|
|
47
|
-
summary: "root summary",
|
|
48
|
-
evidence: [],
|
|
49
|
-
subQueries: ["child"],
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
summary: "child summary",
|
|
54
|
-
evidence: [],
|
|
55
|
-
};
|
|
56
|
-
}, {
|
|
57
|
-
maxWallTimeMs: 100,
|
|
58
|
-
now: () => nowMs,
|
|
59
|
-
});
|
|
60
|
-
assert.equal(trace.rootOutcome.finalized, false);
|
|
61
|
-
assert.equal(trace.rootOutcome.finalizationStatus, "time_budget_exceeded");
|
|
62
|
-
});
|
|
63
|
-
test("recursive orchestrator surfaces interruption as explicit finalization state", async () => {
|
|
64
|
-
_resetIdCounter();
|
|
65
|
-
const controller = new AbortController();
|
|
66
|
-
const lifecycle = [];
|
|
67
|
-
const orchestrator = new RecursiveOrchestrator({
|
|
68
|
-
maxDepth: 3,
|
|
69
|
-
maxIterations: 8,
|
|
70
|
-
maxBreadth: 3,
|
|
71
|
-
});
|
|
72
|
-
const trace = await orchestrator.run("root", async (task) => {
|
|
73
|
-
if (task.depth === 0) {
|
|
74
|
-
controller.abort();
|
|
75
|
-
return {
|
|
76
|
-
summary: "root summary",
|
|
77
|
-
evidence: [],
|
|
78
|
-
subQueries: ["child"],
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
summary: "child summary",
|
|
83
|
-
evidence: [],
|
|
84
|
-
};
|
|
85
|
-
}, {
|
|
86
|
-
signal: controller.signal,
|
|
87
|
-
onLifecycleEvent: (event) => {
|
|
88
|
-
lifecycle.push(event);
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
assert.equal(trace.rootOutcome.finalizationStatus, "interrupted");
|
|
92
|
-
assert.equal(lifecycle.some((event) => event.type === "task.interrupted"), true);
|
|
93
|
-
});
|
|
94
|
-
//# sourceMappingURL=recursive.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recursive.test.js","sourceRoot":"","sources":["../src/recursive.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,qBAAqB,EACrB,eAAe,GAEhB,MAAM,gBAAgB,CAAC;AAExB,IAAI,CAAC,0EAA0E,EAAE,KAAK,IAAI,EAAE;IAC1F,eAAe,EAAE,CAAC;IAClB,MAAM,SAAS,GAA8B,EAAE,CAAC;IAChD,MAAM,YAAY,GAAG,IAAI,qBAAqB,CAAC;QAC7C,QAAQ,EAAE,CAAC;QACX,aAAa,EAAE,CAAC;QAChB,UAAU,EAAE,CAAC;KACd,CAAC,CA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ACrB,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO;gBACL,OAAO,EAAE,cAAc;gBACvB,QAAQ,EAAE,EAAE;gBACZ,UAAU,EAAE,CAAC,OAAO,CAAC;aACtB,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE,EAAE;SACb,CAAC;IACJ,CAAC,EACD;QACE,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;KACF,CACF,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAClE,MAAM,CAAC,KAAK,CACV,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC,EAC5D,IAAI,CACL,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.golden.test.d.ts","sourceRoot":"","sources":["../src/router.golden.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { access, readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import test from "node:test";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { ReasoningRouter } from "./router.js";
|
|
6
|
-
const UPDATE_ENV_VAR = "UPDATE_ROUTER_GOLDEN";
|
|
7
|
-
const UPDATE_REQUESTED = process.env[UPDATE_ENV_VAR] === "1";
|
|
8
|
-
const FIXTURE_CANDIDATES = [
|
|
9
|
-
new URL("./router.golden.fixtures.json", import.meta.url),
|
|
10
|
-
new URL("../src/router.golden.fixtures.json", import.meta.url),
|
|
11
|
-
];
|
|
12
|
-
async function resolveFixturePath() {
|
|
13
|
-
for (const candidate of FIXTURE_CANDIDATES) {
|
|
14
|
-
const candidatePath = fileURLToPath(candidate);
|
|
15
|
-
try {
|
|
16
|
-
await access(candidatePath);
|
|
17
|
-
return candidatePath;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
// Continue searching.
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
throw new Error(`Unable to find router golden fixtures. Checked: ${FIXTURE_CANDIDATES.map((candidate) => fileURLToPath(candidate)).join(", ")}`);
|
|
24
|
-
}
|
|
25
|
-
async function loadFixtures() {
|
|
26
|
-
const path = await resolveFixturePath();
|
|
27
|
-
const raw = await readFile(path, "utf8");
|
|
28
|
-
return {
|
|
29
|
-
path,
|
|
30
|
-
fixtures: JSON.parse(raw),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
function normalizeDecision(decision) {
|
|
34
|
-
return {
|
|
35
|
-
selectedMode: decision.selectedMode,
|
|
36
|
-
pipeline: [...decision.pipeline],
|
|
37
|
-
confidence: decision.confidence,
|
|
38
|
-
scores: { ...decision.scores },
|
|
39
|
-
signals: decision.signals.map((signal) => ({
|
|
40
|
-
name: signal.name,
|
|
41
|
-
kind: signal.kind,
|
|
42
|
-
matched: signal.matched,
|
|
43
|
-
...(signal.detail ? { detail: signal.detail } : {}),
|
|
44
|
-
score: signal.score,
|
|
45
|
-
weight: signal.weight,
|
|
46
|
-
weightedScore: signal.weightedScore,
|
|
47
|
-
evidence: [...signal.evidence],
|
|
48
|
-
})),
|
|
49
|
-
rationale: decision.rationale,
|
|
50
|
-
escalationAllowed: decision.escalationAllowed,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
test("router acceptance matrix routes prompts to expected mode and pipeline", async () => {
|
|
54
|
-
const { fixtures } = await loadFixtures();
|
|
55
|
-
const router = new ReasoningRouter();
|
|
56
|
-
for (const fixture of fixtures.cases) {
|
|
57
|
-
const decision = router.route(fixture.input);
|
|
58
|
-
assert.equal(decision.selectedMode, fixture.acceptance.selectedMode, `Case "${fixture.id}" selectedMode mismatch`);
|
|
59
|
-
assert.deepEqual(decision.pipeline, fixture.acceptance.pipeline, `Case "${fixture.id}" pipeline mismatch`);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
test("router golden fixtures remain deterministic", async () => {
|
|
63
|
-
const { path, fixtures } = await loadFixtures();
|
|
64
|
-
const router = new ReasoningRouter();
|
|
65
|
-
const refreshedCases = fixtures.cases.map((fixture) => ({
|
|
66
|
-
...fixture,
|
|
67
|
-
golden: normalizeDecision(router.route(fixture.input)),
|
|
68
|
-
}));
|
|
69
|
-
if (UPDATE_REQUESTED) {
|
|
70
|
-
const updated = {
|
|
71
|
-
...fixtures,
|
|
72
|
-
cases: refreshedCases,
|
|
73
|
-
};
|
|
74
|
-
await writeFile(path, `${JSON.stringify(updated, null, 2)}\n`, "utf8");
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const missingGolden = fixtures.cases.filter((fixture) => fixture.golden == null);
|
|
78
|
-
assert.equal(missingGolden.length, 0, `Missing golden snapshots for: ${missingGolden.map((fixture) => fixture.id).join(", ")}. Run ${fixtures.updateWorkflow.command}`);
|
|
79
|
-
for (const fixture of fixtures.cases) {
|
|
80
|
-
const actual = normalizeDecision(router.route(fixture.input));
|
|
81
|
-
assert.deepEqual(actual, fixture.golden, `Golden mismatch for "${fixture.id}". Refresh with ${fixtures.updateWorkflow.command}`);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
//# sourceMappingURL=router.golden.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.golden.test.js","sourceRoot":"","sources":["../src/router.golden.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aA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AAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9D,MAAM,CAAC,SAAS,CACd,MAAM,EACN,OAAO,CAAC,MAAM,EACd,wBAAwB,OAAO,CAAC,EAAE,mBAAmB,QAAQ,CAAC,cAAc,CAAC,OAAO,EAAE,CACvF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/router.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.test.d.ts","sourceRoot":"","sources":["../src/router.test.ts"],"names":[],"mappings":""}
|
package/dist/router.test.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { ReasoningRouter } from "./router.js";
|
|
4
|
-
test("router scoring is deterministic for identical input (excluding timestamp)", () => {
|
|
5
|
-
const router = new ReasoningRouter();
|
|
6
|
-
const input = {
|
|
7
|
-
prompt: "Implement a TypeScript function for request signing, include tests, and fix failing auth regression.",
|
|
8
|
-
context: "Current build is red and stack trace points to auth middleware.",
|
|
9
|
-
allowAutocode: true,
|
|
10
|
-
};
|
|
11
|
-
const first = router.route(input);
|
|
12
|
-
const second = router.route(input);
|
|
13
|
-
assert.equal(typeof first.timestamp, "string");
|
|
14
|
-
assert.equal(typeof second.timestamp, "string");
|
|
15
|
-
assert.equal(first.selectedMode, second.selectedMode);
|
|
16
|
-
assert.deepStrictEqual(first.pipeline, second.pipeline);
|
|
17
|
-
assert.equal(first.confidence, second.confidence);
|
|
18
|
-
assert.deepStrictEqual(first.scores, second.scores);
|
|
19
|
-
assert.deepStrictEqual(first.signals, second.signals);
|
|
20
|
-
assert.equal(first.rationale, second.rationale);
|
|
21
|
-
});
|
|
22
|
-
test("router maps acceptance prompts to expected selected mode", () => {
|
|
23
|
-
const router = new ReasoningRouter();
|
|
24
|
-
const defaultDecision = router.route({
|
|
25
|
-
prompt: "explain what a closure is",
|
|
26
|
-
});
|
|
27
|
-
const autocodeDecision = router.route({
|
|
28
|
-
prompt: "implement a Redis cache layer with TTL support and write tests",
|
|
29
|
-
});
|
|
30
|
-
const dialecticalDecision = router.route({
|
|
31
|
-
prompt: "should we use PostgreSQL or MongoDB? Consider consistency and scalability",
|
|
32
|
-
});
|
|
33
|
-
const recursiveDecision = router.route({
|
|
34
|
-
prompt: "Build a complete auth system: 1) OAuth 2) Session mgmt 3) RBAC 4) Audit logging",
|
|
35
|
-
});
|
|
36
|
-
assert.equal(defaultDecision.selectedMode, "default");
|
|
37
|
-
assert.equal(autocodeDecision.selectedMode, "autocode");
|
|
38
|
-
assert.equal(dialecticalDecision.selectedMode, "dialectical");
|
|
39
|
-
assert.equal(recursiveDecision.selectedMode, "recursive");
|
|
40
|
-
});
|
|
41
|
-
test("router can compose dialectical+recursive pipeline for mixed prompts", () => {
|
|
42
|
-
const router = new ReasoningRouter();
|
|
43
|
-
const decision = router.route({
|
|
44
|
-
prompt: "Compare migration tradeoffs, then break rollout into phased subtasks with sequencing and risks.",
|
|
45
|
-
allowAutocode: false,
|
|
46
|
-
});
|
|
47
|
-
assert.equal(decision.pipeline.includes("dialectical"), true);
|
|
48
|
-
assert.equal(decision.pipeline.includes("recursive"), true);
|
|
49
|
-
});
|
|
50
|
-
test("router config supports SHA-1764 names and legacy aliases", () => {
|
|
51
|
-
const modernConfigRouter = new ReasoningRouter({
|
|
52
|
-
enableAutocode: false,
|
|
53
|
-
confidenceThreshold: 0.2,
|
|
54
|
-
signalWeights: { implementation_intent: 3.0 },
|
|
55
|
-
});
|
|
56
|
-
const legacyConfigRouter = new ReasoningRouter({
|
|
57
|
-
allowAutocodeByDefault: false,
|
|
58
|
-
composeThreshold: 0.2,
|
|
59
|
-
});
|
|
60
|
-
const modernDecision = modernConfigRouter.route({
|
|
61
|
-
prompt: "Implement and patch this bug with tests.",
|
|
62
|
-
});
|
|
63
|
-
const legacyDecision = legacyConfigRouter.route({
|
|
64
|
-
prompt: "Implement and patch this bug with tests.",
|
|
65
|
-
});
|
|
66
|
-
assert.equal(modernDecision.selectedMode === "autocode", false);
|
|
67
|
-
assert.equal(legacyDecision.selectedMode === "autocode", false);
|
|
68
|
-
});
|
|
69
|
-
test("router falls back to default when confidence is below threshold", () => {
|
|
70
|
-
const router = new ReasoningRouter({ confidenceThreshold: 0.99 });
|
|
71
|
-
const decision = router.route({
|
|
72
|
-
prompt: "Compare pros and cons of two deployment options.",
|
|
73
|
-
});
|
|
74
|
-
assert.equal(decision.selectedMode, "default");
|
|
75
|
-
assert.deepStrictEqual(decision.pipeline, ["default"]);
|
|
76
|
-
});
|
|
77
|
-
test("router can explicitly disable recursive stage eligibility", () => {
|
|
78
|
-
const router = new ReasoningRouter();
|
|
79
|
-
const decision = router.route({
|
|
80
|
-
prompt: "Break this system into milestones and phased subtasks with rollout sequence.",
|
|
81
|
-
allowRecursive: false,
|
|
82
|
-
});
|
|
83
|
-
assert.equal(decision.pipeline.includes("recursive"), false);
|
|
84
|
-
assert.equal(decision.selectedMode === "recursive", false);
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=router.test.js.map
|
package/dist/router.test.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.test.js","sourceRoot":"","sources":["../src/router.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,IAAI,CAAC,2EAA2E,EAAE,GAAG,EAAE;IACrF,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,MAAM,KAAK,GAAG;QACZ,MAAM,EACJ,sGAAsG;QACxG,OAAO,EAAE,iEAAiE;QAC1E,aAAa,EAAE,IAAI;KACpB,CAAC;IAEF,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,M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