@zelari/core 1.28.0 → 1.29.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.
@@ -6,4 +6,5 @@
6
6
  */
7
7
  export * from './graph.js';
8
8
  export * from './conflict.js';
9
+ export * from './verdict.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kraken/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kraken/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -6,4 +6,5 @@
6
6
  */
7
7
  export * from './graph.js';
8
8
  export * from './conflict.js';
9
+ export * from './verdict.js';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kraken/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/kraken/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Kraken graph engine — verify verdict parsing (pure).
3
+ *
4
+ * A `verify` node's job is to judge a writer's work, but a tentacle that runs
5
+ * to completion is a *successful run* regardless of what it concluded: the
6
+ * executor marked the node `done` and never read the text. A verify that said
7
+ * "this is wrong" was indistinguishable from one that said "this is correct",
8
+ * so the graph converged over known-bad work and the only iteration the engine
9
+ * could do was on execution failure, never on quality.
10
+ *
11
+ * This module turns that free text into a decision. The verify prompt asks for
12
+ * a `VERDICT: PASS` / `VERDICT: FAIL` trailer; the executor parses it and, on
13
+ * FAIL, spawns a bounded rework round.
14
+ *
15
+ * No CLI dependencies (see CORREZIONE-1 in the engine plan).
16
+ *
17
+ * @since v1.28.x — verify quality gate
18
+ */
19
+ /**
20
+ * What a verify node concluded.
21
+ *
22
+ * `unknown` means no trailer was found. It is deliberately distinct from
23
+ * `pass` so the caller can *report* the omission (a model that quietly stops
24
+ * emitting the trailer would otherwise disable the whole gate invisibly) while
25
+ * still treating it as non-blocking.
26
+ */
27
+ export type VerifyVerdict = 'pass' | 'fail' | 'unknown';
28
+ export interface ParsedVerdict {
29
+ verdict: VerifyVerdict;
30
+ /**
31
+ * The verify's own reasoning — everything except the trailer line, trimmed
32
+ * and capped. Fed back into the rework node so it knows what to fix.
33
+ */
34
+ findings: string;
35
+ }
36
+ /**
37
+ * Cap on retained findings text. Mirrors `MAX_UPSTREAM_CHARS_PER_DEP` in the
38
+ * CLI executor, since findings travel the same route (into a sub-agent prompt).
39
+ */
40
+ export declare const MAX_FINDINGS_CHARS = 2800;
41
+ /**
42
+ * Extract a verify node's verdict from its conclusion text.
43
+ *
44
+ * The **last** trailer wins. Models routinely restate the instruction before
45
+ * answering ("...end with VERDICT: PASS or VERDICT: FAIL") and a first-match
46
+ * scan would read that echo as the answer — inverting the gate on exactly the
47
+ * verbose runs where the judgement matters most.
48
+ */
49
+ export declare function parseVerifyVerdict(text: string | undefined | null): ParsedVerdict;
50
+ /**
51
+ * A verify verdict the run could not resolve, carried in the execution summary
52
+ * and rendered in the digest.
53
+ *
54
+ * Lives here (pure) rather than in the CLI executor so the executor and the
55
+ * status/digest renderer can share it without importing each other.
56
+ */
57
+ export interface UnresolvedFinding {
58
+ /** The writer node whose work was judged. */
59
+ nodeId: string;
60
+ label: string;
61
+ /** 'fail' → rework budget exhausted; 'unknown' → no parseable verdict. */
62
+ reason: 'fail' | 'unknown';
63
+ findings: string;
64
+ }
65
+ //# sourceMappingURL=verdict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../src/kraken/verdict.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAUvC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,aAAa,CAsBjF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,0EAA0E;IAC1E,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Kraken graph engine — verify verdict parsing (pure).
3
+ *
4
+ * A `verify` node's job is to judge a writer's work, but a tentacle that runs
5
+ * to completion is a *successful run* regardless of what it concluded: the
6
+ * executor marked the node `done` and never read the text. A verify that said
7
+ * "this is wrong" was indistinguishable from one that said "this is correct",
8
+ * so the graph converged over known-bad work and the only iteration the engine
9
+ * could do was on execution failure, never on quality.
10
+ *
11
+ * This module turns that free text into a decision. The verify prompt asks for
12
+ * a `VERDICT: PASS` / `VERDICT: FAIL` trailer; the executor parses it and, on
13
+ * FAIL, spawns a bounded rework round.
14
+ *
15
+ * No CLI dependencies (see CORREZIONE-1 in the engine plan).
16
+ *
17
+ * @since v1.28.x — verify quality gate
18
+ */
19
+ /**
20
+ * Cap on retained findings text. Mirrors `MAX_UPSTREAM_CHARS_PER_DEP` in the
21
+ * CLI executor, since findings travel the same route (into a sub-agent prompt).
22
+ */
23
+ export const MAX_FINDINGS_CHARS = 2800;
24
+ /**
25
+ * Matches a verdict trailer at the start of a line: `VERDICT: PASS`.
26
+ * Tolerates leading whitespace, markdown emphasis/bullets the model may wrap
27
+ * it in (`**VERDICT: FAIL**`, `- VERDICT: PASS`), and any trailing text on the
28
+ * line (a model that appends "— 3 gaps found" should still be understood).
29
+ */
30
+ const VERDICT_LINE = /^[\s>*_-]*VERDICT[\s*_]*:[\s*_]*(PASS|FAIL)\b/gim;
31
+ /**
32
+ * Extract a verify node's verdict from its conclusion text.
33
+ *
34
+ * The **last** trailer wins. Models routinely restate the instruction before
35
+ * answering ("...end with VERDICT: PASS or VERDICT: FAIL") and a first-match
36
+ * scan would read that echo as the answer — inverting the gate on exactly the
37
+ * verbose runs where the judgement matters most.
38
+ */
39
+ export function parseVerifyVerdict(text) {
40
+ const source = typeof text === 'string' ? text : '';
41
+ if (source.trim() === '')
42
+ return { verdict: 'unknown', findings: '' };
43
+ VERDICT_LINE.lastIndex = 0;
44
+ let match;
45
+ let last = null;
46
+ while ((match = VERDICT_LINE.exec(source)) !== null) {
47
+ last = match;
48
+ // A zero-length match would spin forever; the pattern cannot produce one
49
+ // (it requires the literal "VERDICT"), but guard anyway.
50
+ if (match.index === VERDICT_LINE.lastIndex)
51
+ VERDICT_LINE.lastIndex += 1;
52
+ }
53
+ if (!last) {
54
+ return { verdict: 'unknown', findings: capFindings(source) };
55
+ }
56
+ const verdict = last[1].toUpperCase() === 'FAIL' ? 'fail' : 'pass';
57
+ // Everything before the trailer is the reasoning that produced it.
58
+ const findings = capFindings(source.slice(0, last.index));
59
+ return { verdict, findings };
60
+ }
61
+ /** Trim and cap findings text, marking the cut so a reader knows it happened. */
62
+ function capFindings(raw) {
63
+ const trimmed = raw.trim();
64
+ if (trimmed.length <= MAX_FINDINGS_CHARS)
65
+ return trimmed;
66
+ return `${trimmed.slice(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AAC;IAClF,mEAAmE;IACnE,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC;AAkBD,iFAAiF;AACjF,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,CAAC,MAAM,IAAI,kBAAkB;QAAE,OAAO,OAAO,CAAC;IACzD,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,kBAAkB,CAAC,iBAAiB,CAAC;AAClE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zelari/core",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "description": "Zelari Code core library — provider-neutral agent loop (AgentHarness), multi-agent council orchestration, and built-in skills. Used by the zelari-code CLI; consumable by other agent frontends.",
5
5
  "author": "Anathema Studio <https://anathema-studio.com/>",
6
6
  "license": "MIT",