@zelari/core 2.0.0-alpha.4 → 2.0.0-alpha.6
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/session/agentAdapter.d.ts +31 -0
- package/dist/session/agentAdapter.d.ts.map +1 -0
- package/dist/session/agentAdapter.js +38 -0
- package/dist/session/agentAdapter.js.map +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -0
- package/dist/session/index.js.map +1 -1
- package/dist/verification/completionPolicy.d.ts +12 -1
- package/dist/verification/completionPolicy.d.ts.map +1 -1
- package/dist/verification/completionPolicy.js +23 -0
- package/dist/verification/completionPolicy.js.map +1 -1
- package/dist/verification/index.d.ts +1 -0
- package/dist/verification/index.d.ts.map +1 -1
- package/dist/verification/index.js +1 -0
- package/dist/verification/index.js.map +1 -1
- package/dist/verification/sessionEvidence.d.ts +52 -0
- package/dist/verification/sessionEvidence.d.ts.map +1 -0
- package/dist/verification/sessionEvidence.js +98 -0
- package/dist/verification/sessionEvidence.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/agentAdapter.ts — the single adapter from the session projection
|
|
3
|
+
* to the AgentHarness message list (Exit-1 E1.1).
|
|
4
|
+
*
|
|
5
|
+
* `deriveMessages()` is the only model-history path (ADR-0016/0021); this
|
|
6
|
+
* adapter is the only way those `DerivedMessage`s become the `AgentMessage[]`
|
|
7
|
+
* fed to the harness. Hosts (CLI headless, TUI, Desktop) must not build model
|
|
8
|
+
* history any other way — model-visible ⟺ logged.
|
|
9
|
+
*
|
|
10
|
+
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
+
* - `seq` (provenance) has no AgentMessage equivalent — audits read it from
|
|
12
|
+
* the spine, not from the harness input.
|
|
13
|
+
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
|
+
* output text is already in `content`, the semantics stay in the log.
|
|
15
|
+
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
16
|
+
* assistant messages (see deriveMessages); providers that need structured
|
|
17
|
+
* `tool_calls` blocks rebuild them from `pairToolCalls()` — this adapter
|
|
18
|
+
* deliberately does NOT parse the JSON back into `AgentMessage.toolCalls`:
|
|
19
|
+
* one derived message → one agent message, nothing invented.
|
|
20
|
+
* - `images` / `reasoningContent` are runtime-only concepts; they never come
|
|
21
|
+
* from the spine.
|
|
22
|
+
*/
|
|
23
|
+
import type { AgentMessage } from '../core/AgentHarness.js';
|
|
24
|
+
import type { DerivedMessage } from './modelSurface.js';
|
|
25
|
+
/**
|
|
26
|
+
* Map session-derived messages onto the AgentHarness input format.
|
|
27
|
+
* Deterministic and side-effect free: the input is never mutated and the
|
|
28
|
+
* output shares no object references with it (roles/content are copied).
|
|
29
|
+
*/
|
|
30
|
+
export declare function derivedToAgentMessages(messages: readonly DerivedMessage[]): AgentMessage[];
|
|
31
|
+
//# sourceMappingURL=agentAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAdapter.d.ts","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,YAAY,EAAE,CAQhB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/agentAdapter.ts — the single adapter from the session projection
|
|
3
|
+
* to the AgentHarness message list (Exit-1 E1.1).
|
|
4
|
+
*
|
|
5
|
+
* `deriveMessages()` is the only model-history path (ADR-0016/0021); this
|
|
6
|
+
* adapter is the only way those `DerivedMessage`s become the `AgentMessage[]`
|
|
7
|
+
* fed to the harness. Hosts (CLI headless, TUI, Desktop) must not build model
|
|
8
|
+
* history any other way — model-visible ⟺ logged.
|
|
9
|
+
*
|
|
10
|
+
* Field mapping (lossy by design, log keeps the full truth):
|
|
11
|
+
* - `seq` (provenance) has no AgentMessage equivalent — audits read it from
|
|
12
|
+
* the spine, not from the harness input.
|
|
13
|
+
* - `toolName` / `isError` on tool results have no AgentMessage slot; the
|
|
14
|
+
* output text is already in `content`, the semantics stay in the log.
|
|
15
|
+
* - tool calls derived with `includeToolCalls: true` are JSON-encoded
|
|
16
|
+
* assistant messages (see deriveMessages); providers that need structured
|
|
17
|
+
* `tool_calls` blocks rebuild them from `pairToolCalls()` — this adapter
|
|
18
|
+
* deliberately does NOT parse the JSON back into `AgentMessage.toolCalls`:
|
|
19
|
+
* one derived message → one agent message, nothing invented.
|
|
20
|
+
* - `images` / `reasoningContent` are runtime-only concepts; they never come
|
|
21
|
+
* from the spine.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Map session-derived messages onto the AgentHarness input format.
|
|
25
|
+
* Deterministic and side-effect free: the input is never mutated and the
|
|
26
|
+
* output shares no object references with it (roles/content are copied).
|
|
27
|
+
*/
|
|
28
|
+
export function derivedToAgentMessages(messages) {
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const m of messages) {
|
|
31
|
+
const agent = { role: m.role, content: m.content };
|
|
32
|
+
if (m.toolCallId !== undefined)
|
|
33
|
+
agent.toolCallId = m.toolCallId;
|
|
34
|
+
out.push(agent);
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=agentAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAdapter.js","sourceRoot":"","sources":["../../src/session/agentAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAmC;IAEnC,MAAM,GAAG,GAAmB,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,KAAK,GAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACjE,IAAI,CAAC,CAAC,UAAU,KAAK,SAAS;YAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;QAChE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/session/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
package/dist/session/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/session/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
|
|
@@ -6,14 +6,25 @@
|
|
|
6
6
|
* (including "pass without evidence") → BLOCKED. A clean "done" without
|
|
7
7
|
* sufficient evidence is blockable by construction: unknown ≠ pass.
|
|
8
8
|
*/
|
|
9
|
-
import type { Criterion, VerificationResult } from './types.js';
|
|
9
|
+
import type { Criterion, EvidenceRefTier, VerificationResult } from './types.js';
|
|
10
10
|
export type CompletionVerdict = 'PASS' | 'REPAIR_REQUIRED' | 'BLOCKED';
|
|
11
11
|
export interface CompletionPolicy {
|
|
12
12
|
mode: 'strict';
|
|
13
13
|
/** Criterion ids gating completion; '*' = every criterion with required:true. */
|
|
14
14
|
required: '*' | string[];
|
|
15
|
+
/**
|
|
16
|
+
* Evidence tiers that may satisfy a criterion (E2.2). Undefined = every tier
|
|
17
|
+
* is admissible (legacy behaviour). The strict BUILD gate admits only
|
|
18
|
+
* deterministic tiers: an advisory LLM score alone is never proof of done
|
|
19
|
+
* (PRINCIPLES P1 — trust tool/terminal output, not narration).
|
|
20
|
+
*/
|
|
21
|
+
admissibleTiers?: readonly EvidenceRefTier[];
|
|
15
22
|
}
|
|
16
23
|
export declare const STRICT_ALL_POLICY: CompletionPolicy;
|
|
24
|
+
/** Tiers produced by deterministic observation: tools, commands, fs, humans. */
|
|
25
|
+
export declare const DETERMINISTIC_EVIDENCE_TIERS: readonly EvidenceRefTier[];
|
|
26
|
+
/** Strict BUILD/mission completion: every required criterion, deterministic evidence only. */
|
|
27
|
+
export declare const STRICT_BUILD_POLICY: CompletionPolicy;
|
|
17
28
|
export interface UnsatisfiedCriterion {
|
|
18
29
|
id: string;
|
|
19
30
|
status: 'fail' | 'unknown' | 'missing';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completionPolicy.d.ts","sourceRoot":"","sources":["../../src/verification/completionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"completionPolicy.d.ts","sourceRoot":"","sources":["../../src/verification/completionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEjF,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,iFAAiF;IACjF,QAAQ,EAAE,GAAG,GAAG,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,iBAAiB,EAAE,gBAAoD,CAAC;AAErF,gFAAgF;AAChF,eAAO,MAAM,4BAA4B,EAAE,SAAS,eAAe,EAKlE,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,EAAE,gBAIjC,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,+DAA+D;IAC/D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AAQD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,SAAS,EAAE,EAC9B,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,MAAM,GAAE,gBAAoC,GAC3C,oBAAoB,CAiEtB;AAED,+EAA+E;AAC/E,eAAO,MAAM,eAAe,2BAAqB,CAAC"}
|
|
@@ -7,6 +7,19 @@
|
|
|
7
7
|
* sufficient evidence is blockable by construction: unknown ≠ pass.
|
|
8
8
|
*/
|
|
9
9
|
export const STRICT_ALL_POLICY = { mode: 'strict', required: '*' };
|
|
10
|
+
/** Tiers produced by deterministic observation: tools, commands, fs, humans. */
|
|
11
|
+
export const DETERMINISTIC_EVIDENCE_TIERS = [
|
|
12
|
+
'tool-output',
|
|
13
|
+
'command-output',
|
|
14
|
+
'fs-observation',
|
|
15
|
+
'human',
|
|
16
|
+
];
|
|
17
|
+
/** Strict BUILD/mission completion: every required criterion, deterministic evidence only. */
|
|
18
|
+
export const STRICT_BUILD_POLICY = {
|
|
19
|
+
mode: 'strict',
|
|
20
|
+
required: '*',
|
|
21
|
+
admissibleTiers: DETERMINISTIC_EVIDENCE_TIERS,
|
|
22
|
+
};
|
|
10
23
|
function lastResultById(results) {
|
|
11
24
|
const map = new Map();
|
|
12
25
|
for (const r of results)
|
|
@@ -44,6 +57,16 @@ export function evaluateCompletion(criteria, results, policy = STRICT_ALL_POLICY
|
|
|
44
57
|
});
|
|
45
58
|
continue;
|
|
46
59
|
}
|
|
60
|
+
const admissible = policy.admissibleTiers;
|
|
61
|
+
if (admissible && !result.evidence.some((e) => admissible.includes(e.tier))) {
|
|
62
|
+
const tiers = [...new Set(result.evidence.map((e) => e.tier))].join(', ');
|
|
63
|
+
unsatisfied.push({
|
|
64
|
+
id,
|
|
65
|
+
status: 'unknown',
|
|
66
|
+
reason: `pass with inadmissible evidence tiers only (${tiers}) — not acceptable for completion`,
|
|
67
|
+
});
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
47
70
|
satisfied.push(id);
|
|
48
71
|
}
|
|
49
72
|
const verdict = unsatisfied.length === 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completionPolicy.js","sourceRoot":"","sources":["../../src/verification/completionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"completionPolicy.js","sourceRoot":"","sources":["../../src/verification/completionPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,MAAM,CAAC,MAAM,iBAAiB,GAAqB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAErF,gFAAgF;AAChF,MAAM,CAAC,MAAM,4BAA4B,GAA+B;IACtE,aAAa;IACb,gBAAgB;IAChB,gBAAgB;IAChB,OAAO;CACR,CAAC;AAEF,8FAA8F;AAC9F,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACnD,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,GAAG;IACb,eAAe,EAAE,4BAA4B;CAC9C,CAAC;AAiBF,SAAS,cAAc,CAAC,OAAsC;IAC5D,MAAM,GAAG,GAAG,IAAI,GAAG,EAA8B,CAAC;IAClD,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACnD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,QAA8B,EAC9B,OAAsC,EACtC,SAA2B,iBAAiB;IAE5C,MAAM,WAAW,GACf,MAAM,CAAC,QAAQ,KAAK,GAAG;QACrB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QA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AAS;QACT,WAAW;QACX,gBAAgB,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC;QAC1C,OAAO,EACL,OAAO,KAAK,MAAM;YAChB,CAAC,CAAC,aAAa,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,uCAAuC;YACpF,CAAC,CAAC,eAAe,OAAO,MAAM,WAAW;iBACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;iBACjC,IAAI,CAAC,IAAI,CAAC,EAAE;KACtB,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/verification/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* verification/sessionEvidence.ts — read the strict completion verdict back
|
|
3
|
+
* from the session spine (ADR-0023 × ADR-0021; Exit-2/E2.1).
|
|
4
|
+
*
|
|
5
|
+
* A `verification.run` event carries the machine-readable record emitted by
|
|
6
|
+
* the strict build gate (`strictGateEventPayload`). This module reconstructs
|
|
7
|
+
* a CompletionEvaluation from the session log alone — no in-process registry
|
|
8
|
+
* — so hosts, mission retries and audits can confirm why a turn finished.
|
|
9
|
+
*
|
|
10
|
+
* Discipline (P1): unknown ≠ pass. A missing or malformed record yields
|
|
11
|
+
* null; a non-strict record is readable as a snapshot but NEVER converts to
|
|
12
|
+
* a completion evaluation. Callers must treat null as "no verification
|
|
13
|
+
* evidence", never as a pass.
|
|
14
|
+
*/
|
|
15
|
+
import type { CompletionEvaluation, CompletionVerdict } from './completionPolicy.js';
|
|
16
|
+
/** Structural event view — decoupled from session internals (no cycles). */
|
|
17
|
+
export interface VerificationEventLike {
|
|
18
|
+
kind: string;
|
|
19
|
+
seq: number;
|
|
20
|
+
ts: number;
|
|
21
|
+
data?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/** Defensive view of one verification record from the log. */
|
|
24
|
+
export interface SessionVerificationRunSnapshot {
|
|
25
|
+
seq: number;
|
|
26
|
+
ts: number;
|
|
27
|
+
engine: string | null;
|
|
28
|
+
strict: boolean;
|
|
29
|
+
verdict: CompletionVerdict | 'unknown';
|
|
30
|
+
satisfied: string[];
|
|
31
|
+
unsatisfied: {
|
|
32
|
+
id: string;
|
|
33
|
+
status: string;
|
|
34
|
+
reason: string;
|
|
35
|
+
}[];
|
|
36
|
+
evidenceComplete: boolean;
|
|
37
|
+
summary: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse one `verification.run` event payload defensively.
|
|
41
|
+
* Returns null when the payload carries no recognizable record.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseVerificationRunPayload(ev: VerificationEventLike): SessionVerificationRunSnapshot | null;
|
|
44
|
+
/** Last recognizable `verification.run` in the log (latest wins). */
|
|
45
|
+
export declare function lastVerificationRun(events: readonly VerificationEventLike[]): SessionVerificationRunSnapshot | null;
|
|
46
|
+
/**
|
|
47
|
+
* Convert a snapshot into a CompletionEvaluation. Null when the record is
|
|
48
|
+
* not strict (informational only): a non-strict legacy record must never
|
|
49
|
+
* satisfy the evidence contract.
|
|
50
|
+
*/
|
|
51
|
+
export declare function snapshotToCompletionEvaluation(snap: SessionVerificationRunSnapshot): CompletionEvaluation | null;
|
|
52
|
+
//# sourceMappingURL=sessionEvidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionEvidence.d.ts","sourceRoot":"","sources":["../../src/verification/sessionEvidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAElB,MAAM,uBAAuB,CAAC;AAE/B,4EAA4E;AAC5E,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,8DAA8D;AAC9D,MAAM,WAAW,8BAA8B;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9D,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB;AA8BD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,qBAAqB,GACxB,8BAA8B,GAAG,IAAI,CA8BvC;AAED,qEAAqE;AACrE,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,qBAAqB,EAAE,GACvC,8BAA8B,GAAG,IAAI,CAQvC;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,8BAA8B,GACnC,oBAAoB,GAAG,IAAI,CAkB7B"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const VERDICTS = new Set(['PASS', 'REPAIR_REQUIRED', 'BLOCKED']);
|
|
2
|
+
function asString(v) {
|
|
3
|
+
return typeof v === 'string' ? v : null;
|
|
4
|
+
}
|
|
5
|
+
function asStringArray(v) {
|
|
6
|
+
if (!Array.isArray(v))
|
|
7
|
+
return [];
|
|
8
|
+
return v.filter((x) => typeof x === 'string');
|
|
9
|
+
}
|
|
10
|
+
function asUnsatisfied(v) {
|
|
11
|
+
if (!Array.isArray(v))
|
|
12
|
+
return [];
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const item of v) {
|
|
15
|
+
if (!item || typeof item !== 'object')
|
|
16
|
+
continue;
|
|
17
|
+
const rec = item;
|
|
18
|
+
const id = asString(rec.id);
|
|
19
|
+
if (id === null)
|
|
20
|
+
continue;
|
|
21
|
+
out.push({
|
|
22
|
+
id,
|
|
23
|
+
status: asString(rec.status) ?? 'unknown',
|
|
24
|
+
reason: asString(rec.reason) ?? '',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parse one `verification.run` event payload defensively.
|
|
31
|
+
* Returns null when the payload carries no recognizable record.
|
|
32
|
+
*/
|
|
33
|
+
export function parseVerificationRunPayload(ev) {
|
|
34
|
+
const data = ev.data;
|
|
35
|
+
if (!data || typeof data !== 'object')
|
|
36
|
+
return null;
|
|
37
|
+
const rec = data;
|
|
38
|
+
const verdictRaw = asString(rec.verdict);
|
|
39
|
+
const verdict = verdictRaw !== null && VERDICTS.has(verdictRaw)
|
|
40
|
+
? verdictRaw
|
|
41
|
+
: 'unknown';
|
|
42
|
+
const evidence = rec.evidence && typeof rec.evidence === 'object'
|
|
43
|
+
? rec.evidence
|
|
44
|
+
: null;
|
|
45
|
+
const satisfied = asStringArray(evidence?.satisfied);
|
|
46
|
+
const unsatisfied = asUnsatisfied(evidence?.unsatisfied);
|
|
47
|
+
const completeRaw = evidence?.complete;
|
|
48
|
+
return {
|
|
49
|
+
seq: ev.seq,
|
|
50
|
+
ts: ev.ts,
|
|
51
|
+
engine: asString(rec.engine),
|
|
52
|
+
strict: rec.strict === true,
|
|
53
|
+
verdict,
|
|
54
|
+
satisfied,
|
|
55
|
+
unsatisfied,
|
|
56
|
+
evidenceComplete: typeof completeRaw === 'boolean'
|
|
57
|
+
? completeRaw
|
|
58
|
+
: verdict === 'PASS' && satisfied.length > 0 && unsatisfied.length === 0,
|
|
59
|
+
summary: asString(rec.summary) ?? '',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/** Last recognizable `verification.run` in the log (latest wins). */
|
|
63
|
+
export function lastVerificationRun(events) {
|
|
64
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
65
|
+
const ev = events[i];
|
|
66
|
+
if (ev.kind !== 'verification.run')
|
|
67
|
+
continue;
|
|
68
|
+
const snap = parseVerificationRunPayload(ev);
|
|
69
|
+
if (snap)
|
|
70
|
+
return snap;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Convert a snapshot into a CompletionEvaluation. Null when the record is
|
|
76
|
+
* not strict (informational only): a non-strict legacy record must never
|
|
77
|
+
* satisfy the evidence contract.
|
|
78
|
+
*/
|
|
79
|
+
export function snapshotToCompletionEvaluation(snap) {
|
|
80
|
+
if (!snap.strict)
|
|
81
|
+
return null;
|
|
82
|
+
const unsatisfied = snap.unsatisfied.map((u) => ({
|
|
83
|
+
id: u.id,
|
|
84
|
+
status: u.status === 'fail' || u.status === 'missing' ? u.status : 'unknown',
|
|
85
|
+
reason: u.reason,
|
|
86
|
+
}));
|
|
87
|
+
const verdict = snap.verdict === 'PASS' || snap.verdict === 'REPAIR_REQUIRED' || snap.verdict === 'BLOCKED'
|
|
88
|
+
? snap.verdict
|
|
89
|
+
: 'BLOCKED';
|
|
90
|
+
return {
|
|
91
|
+
verdict,
|
|
92
|
+
satisfied: [...snap.satisfied],
|
|
93
|
+
unsatisfied,
|
|
94
|
+
evidenceComplete: snap.evidenceComplete && unsatisfied.length === 0 && verdict === 'PASS',
|
|
95
|
+
summary: snap.summary,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=sessionEvidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionEvidence.js","sourceRoot":"","sources":["../../src/verification/sessionEvidence.ts"],"names":[],"mappings":"AAyCA,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAS,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC;AAEzE,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,IAAI,CAA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;IACxB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,IAAoC;IAEpC,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,WAAW,GAA2B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACvE,EAAE,EAAE,CAAC,CAAC,EAAE;QACR,MAAM,EAAE,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QAC5E,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC,CAAC,CAAC;IACJ,MAAM,OAAO,GACX,IAAI,CAAC,OAAO,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,KAAK,iBAAiB,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QACzF,CAAC,CAAC,IAAI,CAAC,OAAO;QACd,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO;QACL,OAAO;QACP,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;QAC9B,WAAW;QACX,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,MAAM;QACzF,OAAO,EAAE,IAAI,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zelari/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.6",
|
|
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": "Apache-2.0",
|