@agenticprimitives/evaluation 0.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/ap-live-gates.mjs +31 -0
- package/dist/checks.d.ts +28 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +59 -0
- package/dist/checks.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/live-gates.d.ts +69 -0
- package/dist/live-gates.d.ts.map +1 -0
- package/dist/live-gates.js +79 -0
- package/dist/live-gates.js.map +1 -0
- package/dist/truth.d.ts +56 -0
- package/dist/truth.d.ts.map +1 -0
- package/dist/truth.js +72 -0
- package/dist/truth.js.map +1 -0
- package/package.json +36 -0
- package/spec.md +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Trust Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @agenticprimitives/evaluation
|
|
2
|
+
|
|
3
|
+
Truthfulness evaluation for agent answers. A truth case asks a **live** agent a question, reads the
|
|
4
|
+
**ground truth** from somewhere the agent does not control, and judges the reply's **claims** — the prose
|
|
5
|
+
and the evidence it cites — with deterministic checks. Failures print the sentence that was wrong.
|
|
6
|
+
|
|
7
|
+
Born from a week of live incidents in which every authority gate held and the answers lied ("the
|
|
8
|
+
directory does not list any organizations" — it held 37). The rule this package enforces: **no incident's
|
|
9
|
+
fix is done until the sentence that was wrong is a permanent fixture** (spec 358 §4).
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { runTruthSet, falseEmptiness, evidenceFromTool, answered } from '@agenticprimitives/evaluation';
|
|
13
|
+
|
|
14
|
+
const report = await runTruthSet([{
|
|
15
|
+
id: 'false-empty-organizations',
|
|
16
|
+
incident: '2026-09-05: "does not list any organizations" — of 37',
|
|
17
|
+
question: 'what organizations are out there',
|
|
18
|
+
probes: { orgCount: () => countFromTheStoreDirectly() }, // never through the agent under test
|
|
19
|
+
run: () => askTheLiveAgent('what organizations are out there'),
|
|
20
|
+
checks: [answered(), falseEmptiness('orgCount', /does not list any organi[sz]ations/i), evidenceFromTool('kb.question')],
|
|
21
|
+
}]);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The judge is deterministic — no model grades a model here. When a claim is too soft to check by pattern,
|
|
25
|
+
the honest fix is a narrower claim in the product, not a looser judge.
|
|
26
|
+
|
|
27
|
+
License: MIT.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ap-live-gates — run a live-gates ledger (spec 392 / 399 §3.3) and write the nightly's report.
|
|
3
|
+
//
|
|
4
|
+
// ap-live-gates --ledger scripts/live-gates.json (every gate, in ledger order)
|
|
5
|
+
// ap-live-gates --ledger … --only a,b (a subset by id)
|
|
6
|
+
// ap-live-gates --ledger … --home https://… --report out.json (another Home; where the report lands)
|
|
7
|
+
// LIVE_GATES_PACE_MS=0 ap-live-gates … (no spacing between paced gates)
|
|
8
|
+
//
|
|
9
|
+
// Exit 1 when a REQUIRED gate failed (a skipped gate is waiting, not failing).
|
|
10
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { resolve } from 'node:path';
|
|
12
|
+
import { runLiveGates, formatLiveGatesTable, failedRequiredGates } from '../dist/index.js';
|
|
13
|
+
|
|
14
|
+
const argv = process.argv.slice(2);
|
|
15
|
+
const opt = (name) => { const eq = argv.find((a) => a.startsWith(`--${name}=`)); if (eq) return eq.slice(name.length + 3); const i = argv.indexOf(`--${name}`); return i >= 0 ? argv[i + 1] : undefined; };
|
|
16
|
+
const ledgerPath = opt('ledger');
|
|
17
|
+
if (!ledgerPath) { console.error('usage: ap-live-gates --ledger <ledger.json> [--only a,b] [--home <url>] [--report <out.json>] [--cwd <dir>]'); process.exit(2); }
|
|
18
|
+
const cwd = resolve(opt('cwd') ?? process.cwd());
|
|
19
|
+
const ledger = JSON.parse(readFileSync(resolve(cwd, ledgerPath), 'utf8'));
|
|
20
|
+
const only = opt('only')?.split(',').map((s) => s.trim()).filter(Boolean);
|
|
21
|
+
const reportPath = resolve(cwd, opt('report') ?? 'live-gates-report.json');
|
|
22
|
+
let report;
|
|
23
|
+
try {
|
|
24
|
+
report = await runLiveGates(ledger, { cwd, homeUrl: opt('home') ?? process.env.HOME_URL, only, paceMs: Number(process.env.LIVE_GATES_PACE_MS ?? 20_000), log: (l) => process.stdout.write(l.endsWith(' ') ? l : `${l}\n`) });
|
|
25
|
+
} catch (e) { console.error(e instanceof Error ? e.message : String(e)); process.exit(2); }
|
|
26
|
+
console.log(formatLiveGatesTable(report));
|
|
27
|
+
writeFileSync(reportPath, JSON.stringify(report, null, 2));
|
|
28
|
+
console.log(` · ${reportPath}`);
|
|
29
|
+
const failed = failedRequiredGates(report);
|
|
30
|
+
if (failed.length) { console.error(`\n✗ ${failed.length} required gate(s) failed: ${failed.map((r) => r.id).join(', ')}`); process.exit(1); }
|
|
31
|
+
console.log('\n✓ every required live gate holds.');
|
package/dist/checks.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TruthCheck } from './truth.js';
|
|
2
|
+
/** The reply is an answer at all — not a refusal, an error shape, or an authority card. */
|
|
3
|
+
export declare const answered: () => TruthCheck;
|
|
4
|
+
/** The reply's kind is exactly this — for cases whose correct behaviour is a prompt or a requirement. */
|
|
5
|
+
export declare const replyKindIs: (kind: string) => TruthCheck;
|
|
6
|
+
/** The prose never matches — used for the sentences that were live incidents, verbatim. */
|
|
7
|
+
export declare const neverClaims: (pattern: RegExp, why: string) => TruthCheck;
|
|
8
|
+
/** When the prose matches `claim`, it must also match `requires` — attribution and disclaimers. */
|
|
9
|
+
export declare const claimsRequire: (claim: RegExp, requires: RegExp, why: string) => TruthCheck;
|
|
10
|
+
/**
|
|
11
|
+
* THE FALSE-EMPTY CHECK — the incident that started the set. When the ground truth says the world is
|
|
12
|
+
* non-empty, the prose may not say it is empty. The 2026-09-05 form: "The directory does not list any
|
|
13
|
+
* organizations", said of a directory holding 37, because a NAME search matched nothing and a composer
|
|
14
|
+
* turned the empty match into a statement about the world.
|
|
15
|
+
*/
|
|
16
|
+
export declare const falseEmptiness: (truthKey: string, emptyClaim: RegExp) => TruthCheck;
|
|
17
|
+
/** Every empty observation says what it DID — an empty count with no reason is how a true empty result
|
|
18
|
+
* becomes a false sentence (spec 358 W3's rule, asserted from W2 so W3 has a red test to turn green). */
|
|
19
|
+
export declare const emptinessCarriesReason: () => TruthCheck;
|
|
20
|
+
/** The question was answered by the RIGHT tool — a kind/count question that ran the name search instead
|
|
21
|
+
* of the graph is the routing that produced the false-empty incident. */
|
|
22
|
+
export declare const evidenceFromTool: (toolId: string) => TruthCheck;
|
|
23
|
+
/** The evidence's count agrees with the ground truth (within slack for a moving estate). */
|
|
24
|
+
export declare const evidenceCountAgrees: (toolId: string, truthKey: string, slack?: number) => TruthCheck;
|
|
25
|
+
/** Nothing placeholder-shaped leaked into what a person would sign or read — the "<UNKNOWN>" incident:
|
|
26
|
+
* a planner placeholder passed every emptiness check and landed in a mandate's maxAmount. */
|
|
27
|
+
export declare const noPlaceholderLeaks: () => TruthCheck;
|
|
28
|
+
//# sourceMappingURL=checks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAA2B,UAAU,EAAE,MAAM,YAAY,CAAC;AAEtE,2FAA2F;AAC3F,eAAO,MAAM,QAAQ,QAAO,UAC2C,CAAC;AAExE,yGAAyG;AACzG,eAAO,MAAM,WAAW,SAAU,MAAM,KAAG,UAC2B,CAAC;AAEvE,2FAA2F;AAC3F,eAAO,MAAM,WAAW,YAAa,MAAM,OAAO,MAAM,KAAG,UACgC,CAAC;AAE5F,mGAAmG;AACnG,eAAO,MAAM,aAAa,UAAW,MAAM,YAAY,MAAM,OAAO,MAAM,KAAG,UAGnE,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,cAAc,aAAc,MAAM,cAAc,MAAM,KAAG,UAMrE,CAAC;AAEF;0GAC0G;AAC1G,eAAO,MAAM,sBAAsB,QAAO,UAOzC,CAAC;AAEF;0EAC0E;AAC1E,eAAO,MAAM,gBAAgB,WAAY,MAAM,KAAG,UAG+E,CAAC;AAElI,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB,WAAY,MAAM,YAAY,MAAM,qBAAc,UAQjF,CAAC;AAEF;8FAC8F;AAC9F,eAAO,MAAM,kBAAkB,QAAO,UAIrC,CAAC"}
|
package/dist/checks.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** The reply is an answer at all — not a refusal, an error shape, or an authority card. */
|
|
2
|
+
export const answered = () => (o) => o.kind === 'answer' ? null : `expected an answer, got kind=${o.kind}`;
|
|
3
|
+
/** The reply's kind is exactly this — for cases whose correct behaviour is a prompt or a requirement. */
|
|
4
|
+
export const replyKindIs = (kind) => (o) => o.kind === kind ? null : `expected kind=${kind}, got kind=${o.kind}`;
|
|
5
|
+
/** The prose never matches — used for the sentences that were live incidents, verbatim. */
|
|
6
|
+
export const neverClaims = (pattern, why) => (o) => pattern.test(o.text) ? `the prose claims “${o.text.match(pattern)?.[0]}” — ${why}` : null;
|
|
7
|
+
/** When the prose matches `claim`, it must also match `requires` — attribution and disclaimers. */
|
|
8
|
+
export const claimsRequire = (claim, requires, why) => (o) => claim.test(o.text) && !requires.test(o.text)
|
|
9
|
+
? `the prose makes a claim (“${o.text.match(claim)?.[0]}”) without what it requires — ${why}`
|
|
10
|
+
: null;
|
|
11
|
+
/**
|
|
12
|
+
* THE FALSE-EMPTY CHECK — the incident that started the set. When the ground truth says the world is
|
|
13
|
+
* non-empty, the prose may not say it is empty. The 2026-09-05 form: "The directory does not list any
|
|
14
|
+
* organizations", said of a directory holding 37, because a NAME search matched nothing and a composer
|
|
15
|
+
* turned the empty match into a statement about the world.
|
|
16
|
+
*/
|
|
17
|
+
export const falseEmptiness = (truthKey, emptyClaim) => (o, t) => {
|
|
18
|
+
const n = Number(t[truthKey] ?? 0);
|
|
19
|
+
if (n <= 0)
|
|
20
|
+
return null; // the world really is empty; an emptiness claim would be TRUE
|
|
21
|
+
return emptyClaim.test(o.text)
|
|
22
|
+
? `ground truth ${truthKey}=${n} but the prose claims emptiness (“${o.text.match(emptyClaim)?.[0]}”)`
|
|
23
|
+
: null;
|
|
24
|
+
};
|
|
25
|
+
/** Every empty observation says what it DID — an empty count with no reason is how a true empty result
|
|
26
|
+
* becomes a false sentence (spec 358 W3's rule, asserted from W2 so W3 has a red test to turn green). */
|
|
27
|
+
export const emptinessCarriesReason = () => (o) => {
|
|
28
|
+
for (const e of o.evidence) {
|
|
29
|
+
if (e.count === 0 && !e.reason && !e.searched) {
|
|
30
|
+
return `evidence from ${e.toolId} reports count=0 with no reason and no searched terms — an unexplained empty is the raw material of a false-empty claim`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
/** The question was answered by the RIGHT tool — a kind/count question that ran the name search instead
|
|
36
|
+
* of the graph is the routing that produced the false-empty incident. */
|
|
37
|
+
export const evidenceFromTool = (toolId) => (o) => o.evidence.some((e) => e.toolId === toolId)
|
|
38
|
+
? null
|
|
39
|
+
: `no evidence from ${toolId} — the answer was produced by ${o.evidence.map((e) => e.toolId).join(', ') || 'no tool at all'}`;
|
|
40
|
+
/** The evidence's count agrees with the ground truth (within slack for a moving estate). */
|
|
41
|
+
export const evidenceCountAgrees = (toolId, truthKey, slack = 0) => (o, t) => {
|
|
42
|
+
const e = o.evidence.find((x) => x.toolId === toolId && x.count !== undefined);
|
|
43
|
+
if (!e)
|
|
44
|
+
return `no counted evidence from ${toolId}`;
|
|
45
|
+
const want = Number(t[truthKey] ?? NaN);
|
|
46
|
+
if (!Number.isFinite(want))
|
|
47
|
+
return `ground truth ${truthKey} is not a number: ${String(t[truthKey])}`;
|
|
48
|
+
return Math.abs((e.count ?? 0) - want) <= slack
|
|
49
|
+
? null
|
|
50
|
+
: `evidence count ${e.count} disagrees with ground truth ${truthKey}=${want} (slack ${slack})`;
|
|
51
|
+
};
|
|
52
|
+
/** Nothing placeholder-shaped leaked into what a person would sign or read — the "<UNKNOWN>" incident:
|
|
53
|
+
* a planner placeholder passed every emptiness check and landed in a mandate's maxAmount. */
|
|
54
|
+
export const noPlaceholderLeaks = () => (o) => {
|
|
55
|
+
const hay = JSON.stringify({ text: o.text, limits: o.requirementLimits ?? {} });
|
|
56
|
+
const hit = hay.match(/<[A-Z_]+>|UNKNOWN|PLACEHOLDER|TBD\b/);
|
|
57
|
+
return hit ? `a placeholder leaked into the reply: “${hit[0]}”` : null;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAOA,2FAA2F;AAC3F,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAe,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC9C,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,IAAI,EAAE,CAAC;AAExE,yGAAyG;AACzG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7D,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,IAAI,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;AAEvE,2FAA2F;AAC3F,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAE,GAAW,EAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAE5F,mGAAmG;AACnG,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,QAAgB,EAAE,GAAW,EAAc,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/F,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAA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CAAC,MAAM,kBAAkB,GAAG,GAAe,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IACxD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,iBAAiB,IAAI,EAAE,EAAE,CAAC,CAAC;IAChF,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAC7D,OAAO,GAAG,CAAC,CAAC,CAAC,yCAAyC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME: "@agenticprimitives/evaluation";
|
|
2
|
+
export declare const PACKAGE_STATUS: "w2-ask-truth";
|
|
3
|
+
export declare const SPEC_REF: "specs/358-semantic-context-plane.md";
|
|
4
|
+
export type { AskEvidenceLike, AskOutcome, GroundTruth, TruthCheck, TruthCaseV1, TruthCaseResult, TruthReport, } from './truth.js';
|
|
5
|
+
export { runTruthSet, formatTruthReport } from './truth.js';
|
|
6
|
+
export { answered, neverClaims, claimsRequire, falseEmptiness, emptinessCarriesReason, evidenceFromTool, evidenceCountAgrees, replyKindIs, noPlaceholderLeaks, } from './checks.js';
|
|
7
|
+
export { runLiveGates, formatLiveGatesTable, failedRequiredGates } from './live-gates.js';
|
|
8
|
+
export type { LiveGateV1, LiveGatesLedgerV1, LiveGateStatus, LiveGateResultV1, LiveGatesReportV1, RunLiveGatesOptions, } from './live-gates.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,EAAG,+BAAwC,CAAC;AACrE,eAAO,MAAM,cAAc,EAAG,cAAuB,CAAC;AACtD,eAAO,MAAM,QAAQ,EAAG,qCAA8C,CAAC;AAEvE,YAAY,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,eAAe,EACf,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC1F,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @agenticprimitives/evaluation — public API (spec 358 W2, spec 351 "AP Operations").
|
|
2
|
+
//
|
|
3
|
+
// THE FAILURE SET IS THE TEST SET. This package exists because a week of live incidents shared one
|
|
4
|
+
// shape: every authority gate held, and the ANSWER lied — "the directory does not list any
|
|
5
|
+
// organizations" (it held 37), Alice's records summarised as Nathan's, "0 members" for a body of four.
|
|
6
|
+
// Each was found by a person noticing. This is the harness that notices instead.
|
|
7
|
+
//
|
|
8
|
+
// A truth case is not a unit test. It runs against a LIVE surface, states where the ground truth can be
|
|
9
|
+
// independently read, and judges the reply's CLAIMS against that truth — the prose and the evidence
|
|
10
|
+
// both, because an answer whose prose contradicts its own evidence is the exact defect on record.
|
|
11
|
+
export const PACKAGE_NAME = '@agenticprimitives/evaluation';
|
|
12
|
+
export const PACKAGE_STATUS = 'w2-ask-truth';
|
|
13
|
+
export const SPEC_REF = 'specs/358-semantic-context-plane.md';
|
|
14
|
+
export { runTruthSet, formatTruthReport } from './truth.js';
|
|
15
|
+
export { answered, neverClaims, claimsRequire, falseEmptiness, emptinessCarriesReason, evidenceFromTool, evidenceCountAgrees, replyKindIs, noPlaceholderLeaks, } from './checks.js';
|
|
16
|
+
// Spec 399 §2.3 / §3.3 — the live-gates runner with the gates as DATA (lifted from scripts/live-gates.mts).
|
|
17
|
+
export { runLiveGates, formatLiveGatesTable, failedRequiredGates } from './live-gates.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,EAAE;AACF,mGAAmG;AACnG,2FAA2F;AAC3F,uGAAuG;AACvG,iFAAiF;AACjF,EAAE;AACF,wGAAwG;AACxG,oGAAoG;AACpG,kGAAkG;AAClG,MAAM,CAAC,MAAM,YAAY,GAAG,+BAAwC,CAAC;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,cAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,QAAQ,GAAG,qCAA8C,CAAC;AAWvE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,WAAW,EACX,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,4GAA4G;AAC5G,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface LiveGateV1 {
|
|
2
|
+
id: string;
|
|
3
|
+
/** The script, relative to `cwd`; run as `npx tsx <script>`. */
|
|
4
|
+
script: string;
|
|
5
|
+
spec: string;
|
|
6
|
+
proves: string;
|
|
7
|
+
twin: string;
|
|
8
|
+
/** A required gate that fails fails the run; the rest report. */
|
|
9
|
+
required: boolean;
|
|
10
|
+
/** Paced gates make metered model calls and are spaced by `paceMs`. */
|
|
11
|
+
paced?: boolean;
|
|
12
|
+
timeoutSec?: number;
|
|
13
|
+
env?: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
export interface LiveGatesLedgerV1 {
|
|
16
|
+
home: string;
|
|
17
|
+
gates: LiveGateV1[];
|
|
18
|
+
}
|
|
19
|
+
export type LiveGateStatus = 'passed' | 'failed' | 'timed out' | 'skipped';
|
|
20
|
+
export interface LiveGateResultV1 {
|
|
21
|
+
id: string;
|
|
22
|
+
spec: string;
|
|
23
|
+
ok: boolean;
|
|
24
|
+
required: boolean;
|
|
25
|
+
ms: number;
|
|
26
|
+
status: LiveGateStatus;
|
|
27
|
+
/** The last lines the script printed — what a person reads when it is red. */
|
|
28
|
+
tail: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface LiveGatesReportV1 {
|
|
31
|
+
at: string;
|
|
32
|
+
home: string;
|
|
33
|
+
/** Gates that passed. */
|
|
34
|
+
passed: number;
|
|
35
|
+
/** Gates that did not pass — INCLUDING skipped ones, as the nightly has always counted them. */
|
|
36
|
+
failed: number;
|
|
37
|
+
results: LiveGateResultV1[];
|
|
38
|
+
ledger: Array<Pick<LiveGateV1, 'id' | 'spec' | 'proves' | 'twin' | 'required'>>;
|
|
39
|
+
}
|
|
40
|
+
export interface RunLiveGatesOptions {
|
|
41
|
+
/** The repository root the scripts are relative to. */
|
|
42
|
+
cwd: string;
|
|
43
|
+
/** Overrides the ledger's `home` (`HOME_URL` to every gate). */
|
|
44
|
+
homeUrl?: string;
|
|
45
|
+
/** A subset of gate ids; the ledger's order is kept. */
|
|
46
|
+
only?: string[];
|
|
47
|
+
/** Spacing before each paced gate (default 20 s; 0 disables). */
|
|
48
|
+
paceMs?: number;
|
|
49
|
+
/** Extra environment for every gate (the process environment is inherited regardless). */
|
|
50
|
+
env?: Record<string, string>;
|
|
51
|
+
/** Progress lines, as the old script printed them. Silent by default. */
|
|
52
|
+
log?: (line: string) => void;
|
|
53
|
+
/** Injected for tests: how a gate is run. Default spawns `npx tsx <script>`. */
|
|
54
|
+
spawn?: (gate: LiveGateV1, env: Record<string, string>, timeoutMs: number) => {
|
|
55
|
+
status: number | null;
|
|
56
|
+
signal: string | null;
|
|
57
|
+
stdout: string;
|
|
58
|
+
stderr: string;
|
|
59
|
+
timedOut: boolean;
|
|
60
|
+
};
|
|
61
|
+
sleep?: (ms: number) => Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/** Run the ledger's gates in order and build the report. Never throws for a gate's behaviour. */
|
|
64
|
+
export declare function runLiveGates(ledger: LiveGatesLedgerV1, opts: RunLiveGatesOptions): Promise<LiveGatesReportV1>;
|
|
65
|
+
/** The markdown table + summary the nightly prints — byte-for-byte what `scripts/live-gates.mts` printed. */
|
|
66
|
+
export declare function formatLiveGatesTable(report: LiveGatesReportV1): string;
|
|
67
|
+
/** The gates whose failure fails the run: required, not passed, not merely waiting on a prerequisite. */
|
|
68
|
+
export declare function failedRequiredGates(report: LiveGatesReportV1): LiveGateResultV1[];
|
|
69
|
+
//# sourceMappingURL=live-gates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-gates.d.ts","sourceRoot":"","sources":["../src/live-gates.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,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AAE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAClL,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAYD,iGAAiG;AACjG,wBAAsB,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsCnH;AAED,6GAA6G;AAC7G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAUtE;AAED,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB,EAAE,CAEjF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// THE LIVE-GATES RUNNER, AS A PACKAGE — spec 392 (the ledger of live verify scripts, each with its authority
|
|
2
|
+
// twin) lifted out of `scripts/live-gates.mts` per spec 399 §2.3 / §3.3, so each product repo runs ITS gates
|
|
3
|
+
// nightly against ITS deployment with the same runner and the same report. The gates are DATA: a ledger names
|
|
4
|
+
// each script, what it proves, the twin it carries, whether it gates, and how it is paced; the runner knows
|
|
5
|
+
// nothing of any deployment. The judge is the script's own exit code — this never re-reads a reply.
|
|
6
|
+
//
|
|
7
|
+
// The report shape is the nightly's artifact and the trend's input: it must not drift from what
|
|
8
|
+
// `scripts/live-gates-trend.mts` reads (`at`, `home`, `passed`, `failed`, `results[]`, `ledger[]`).
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
10
|
+
const SKIP_LINE = /^⊘ skipped:/;
|
|
11
|
+
function defaultSpawn(cwd) {
|
|
12
|
+
return (gate, env, timeoutMs) => {
|
|
13
|
+
const run = spawnSync('npx', ['tsx', gate.script], { cwd, env, encoding: 'utf8', timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 });
|
|
14
|
+
const timedOut = run.error?.name === 'Error' && /ETIMEDOUT|TIMEOUT/i.test(String(run.error?.message ?? run.signal ?? ''));
|
|
15
|
+
return { status: run.status, signal: run.signal, stdout: run.stdout ?? '', stderr: run.stderr ?? '', timedOut };
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Run the ledger's gates in order and build the report. Never throws for a gate's behaviour. */
|
|
19
|
+
export async function runLiveGates(ledger, opts) {
|
|
20
|
+
const wanted = opts.only && opts.only.length ? new Set(opts.only) : null;
|
|
21
|
+
const gates = ledger.gates.filter((g) => !wanted || wanted.has(g.id));
|
|
22
|
+
if (!gates.length)
|
|
23
|
+
throw new Error(`no gates match ${opts.only?.join(',') ?? '(none)'}`);
|
|
24
|
+
const paceMs = opts.paceMs ?? 20_000;
|
|
25
|
+
const home = opts.homeUrl ?? ledger.home;
|
|
26
|
+
const log = opts.log ?? (() => undefined);
|
|
27
|
+
const spawn = opts.spawn ?? defaultSpawn(opts.cwd);
|
|
28
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
29
|
+
const baseEnv = {};
|
|
30
|
+
for (const [k, v] of Object.entries(process.env))
|
|
31
|
+
if (typeof v === 'string')
|
|
32
|
+
baseEnv[k] = v;
|
|
33
|
+
const results = [];
|
|
34
|
+
log(`live gates · ${gates.length} of ${ledger.gates.length} · ${home}\n`);
|
|
35
|
+
for (const [i, g] of gates.entries()) {
|
|
36
|
+
if (i > 0 && g.paced && paceMs > 0)
|
|
37
|
+
await sleep(paceMs);
|
|
38
|
+
const t0 = Date.now();
|
|
39
|
+
log(`▶ ${g.id.padEnd(26)} ${g.spec.padEnd(20)} `);
|
|
40
|
+
const run = spawn(g, { ...baseEnv, HOME_URL: home, ...(opts.env ?? {}), ...(g.env ?? {}) }, (g.timeoutSec ?? 300) * 1000);
|
|
41
|
+
const ms = Date.now() - t0;
|
|
42
|
+
const out = `${run.stdout}\n${run.stderr}`.split('\n').map((l) => l.replace(/\s+$/, '')).filter((l) => l && !/^npm warn/.test(l));
|
|
43
|
+
// A gate that cannot run because a PREREQUISITE the estate does not yet hold says so with `⊘ skipped:` and
|
|
44
|
+
// exits 0 — SKIPPED is its own status, never a pass: the table shows it waiting, the trend does not count it green.
|
|
45
|
+
const skipped = run.status === 0 && out.some((l) => SKIP_LINE.test(l));
|
|
46
|
+
const status = run.timedOut || run.signal === 'SIGTERM' ? 'timed out' : skipped ? 'skipped' : run.status === 0 ? 'passed' : 'failed';
|
|
47
|
+
const tail = out.slice(-8);
|
|
48
|
+
results.push({ id: g.id, spec: g.spec, ok: status === 'passed', required: g.required, ms, status, tail });
|
|
49
|
+
log(`${status === 'passed' ? '✓' : status === 'skipped' ? '⊘' : '✗'} ${status} in ${(ms / 1000).toFixed(1)}s`);
|
|
50
|
+
if (status !== 'passed')
|
|
51
|
+
for (const l of tail)
|
|
52
|
+
log(` │ ${l.slice(0, 200)}`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
at: new Date().toISOString(),
|
|
56
|
+
home,
|
|
57
|
+
passed: results.filter((r) => r.ok).length,
|
|
58
|
+
failed: results.filter((r) => !r.ok).length,
|
|
59
|
+
results,
|
|
60
|
+
ledger: gates.map((g) => ({ id: g.id, spec: g.spec, proves: g.proves, twin: g.twin, required: g.required })),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** The markdown table + summary the nightly prints — byte-for-byte what `scripts/live-gates.mts` printed. */
|
|
64
|
+
export function formatLiveGatesTable(report) {
|
|
65
|
+
const lines = ['', '── live gates ──', '| gate | spec | result | time |', '| --- | --- | --- | --- |'];
|
|
66
|
+
for (const r of report.results) {
|
|
67
|
+
const result = r.ok ? '✓ passed' : r.status === 'skipped' ? `⊘ skipped — ${r.tail.find((l) => SKIP_LINE.test(l))?.replace(/^⊘ skipped:\s*/, '') ?? 'a prerequisite is missing'}` : `✗ ${r.status}${r.required ? '' : ' (advisory)'}`;
|
|
68
|
+
lines.push(`| ${r.id} | ${r.spec} | ${result} | ${(r.ms / 1000).toFixed(1)}s |`);
|
|
69
|
+
}
|
|
70
|
+
const skipped = report.results.filter((r) => r.status === 'skipped');
|
|
71
|
+
const failedOptional = report.results.filter((r) => !r.ok && !r.required && r.status !== 'skipped');
|
|
72
|
+
lines.push('', `${report.passed} passed, ${report.failed - skipped.length} failed${failedOptional.length ? ` (${failedOptional.length} advisory)` : ''}${skipped.length ? `, ${skipped.length} skipped (waiting on a prerequisite)` : ''}`);
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
/** The gates whose failure fails the run: required, not passed, not merely waiting on a prerequisite. */
|
|
76
|
+
export function failedRequiredGates(report) {
|
|
77
|
+
return report.results.filter((r) => !r.ok && r.required && r.status !== 'skipped');
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=live-gates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-gates.js","sourceRoot":"","sources":["../src/live-gates.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAC7G,6GAA6G;AAC7G,8GAA8G;AAC9G,4GAA4G;AAC5G,oGAAoG;AACpG,EAAE;AACF,gGAAgG;AAChG,oGAAoG;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAgE/C,MAAM,SAAS,GAAG,aAAa,CAAC;AAEhC,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,CAAC,IAAgB,EAAE,GAA2B,EAAE,SAAiB,EAAE,EAAE;QAC1E,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG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CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,MAAM,sCAAsC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5O,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,mBAAmB,CAAC,MAAyB;IAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AACrF,CAAC"}
|
package/dist/truth.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** The slice of an Ask reply's evidence this harness reads — matches demo-a2a's `AskEvidence`. */
|
|
2
|
+
export interface AskEvidenceLike {
|
|
3
|
+
toolId: string;
|
|
4
|
+
interpretation?: string;
|
|
5
|
+
query?: string;
|
|
6
|
+
count?: number;
|
|
7
|
+
searched?: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
}
|
|
10
|
+
/** What one ask produced, normalised for judging. `raw` is kept for the report, never for checks. */
|
|
11
|
+
export interface AskOutcome {
|
|
12
|
+
kind: string;
|
|
13
|
+
text: string;
|
|
14
|
+
evidence: AskEvidenceLike[];
|
|
15
|
+
/** For authority replies: the requirement's limits, so a case can judge WHAT would have been signed. */
|
|
16
|
+
requirementLimits?: Record<string, unknown>;
|
|
17
|
+
/** For prompts: the fields asked for. */
|
|
18
|
+
promptFields?: string[];
|
|
19
|
+
raw?: unknown;
|
|
20
|
+
}
|
|
21
|
+
export type GroundTruth = Record<string, unknown>;
|
|
22
|
+
/** One deterministic judgement. `null` = holds; a sentence = the failure, stated for a person. */
|
|
23
|
+
export type TruthCheck = (outcome: AskOutcome, truth: GroundTruth) => string | null;
|
|
24
|
+
export interface TruthCaseV1 {
|
|
25
|
+
id: string;
|
|
26
|
+
/** The live incident this memorialises — date + the false sentence, verbatim where possible. */
|
|
27
|
+
incident: string;
|
|
28
|
+
question: string;
|
|
29
|
+
/** Independent reads of the world. Keyed; results land in `truth` for every check. */
|
|
30
|
+
probes: Record<string, () => Promise<unknown>>;
|
|
31
|
+
/** Perform the ask. Wired by the caller (session, surface, addressee live there). */
|
|
32
|
+
run: () => Promise<AskOutcome>;
|
|
33
|
+
checks: TruthCheck[];
|
|
34
|
+
}
|
|
35
|
+
export interface TruthCaseResult {
|
|
36
|
+
id: string;
|
|
37
|
+
incident: string;
|
|
38
|
+
question: string;
|
|
39
|
+
passed: boolean;
|
|
40
|
+
/** Failures, each a sentence. Probe/run errors land here too — an unrunnable case is a FAILING case,
|
|
41
|
+
* because "the eval could not run" reported as green is this package's own version of the lie. */
|
|
42
|
+
failures: string[];
|
|
43
|
+
truth: GroundTruth;
|
|
44
|
+
outcome?: AskOutcome;
|
|
45
|
+
ms: number;
|
|
46
|
+
}
|
|
47
|
+
export interface TruthReport {
|
|
48
|
+
results: TruthCaseResult[];
|
|
49
|
+
passed: number;
|
|
50
|
+
failed: number;
|
|
51
|
+
}
|
|
52
|
+
/** Run the set, serially — the cases hit one live estate, and parallel asks contend for its budgets. */
|
|
53
|
+
export declare function runTruthSet(cases: TruthCaseV1[]): Promise<TruthReport>;
|
|
54
|
+
/** The report, for a terminal. Failures print the prose that was judged — the artefact a person needs. */
|
|
55
|
+
export declare function formatTruthReport(report: TruthReport): string;
|
|
56
|
+
//# sourceMappingURL=truth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truth.d.ts","sourceRoot":"","sources":["../src/truth.ts"],"names":[],"mappings":"AAiBA,kGAAkG;AAClG,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CA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;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wGAAwG;AACxG,wBAAsB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CA8B5E;AAED,0GAA0G;AAC1G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAkB7D"}
|
package/dist/truth.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// THE TRUTH-CASE CONTRACT — spec 358 W2.
|
|
2
|
+
//
|
|
3
|
+
// Three parts, deliberately separated:
|
|
4
|
+
//
|
|
5
|
+
// THE ASK `run()` performs the question against the live surface and returns what came back,
|
|
6
|
+
// normalised. The package never signs in, never fetches — the script wires that.
|
|
7
|
+
// THE TRUTH `probes` read the ground truth from a place the agent under test does not control:
|
|
8
|
+
// the KB endpoint directly, the vault through a steward's own wire, the chain. A case
|
|
9
|
+
// whose truth comes from the same answer it judges proves agreement, not truthfulness.
|
|
10
|
+
// THE JUDGE `checks` are DETERMINISTIC functions over (outcome, truth). No model judges a model
|
|
11
|
+
// here: a flaky judge turns a truth set into a mood, and every failure must print
|
|
12
|
+
// something a person can act on. When a claim is genuinely too soft to check by
|
|
13
|
+
// pattern, the honest move is a narrower claim in the product, not a looser judge.
|
|
14
|
+
//
|
|
15
|
+
// A case is pinned to the INCIDENT it memorialises. That is the point of the set: no live failure is
|
|
16
|
+
// "fixed" until the sentence that was wrong is a permanent fixture here (spec 358 §4).
|
|
17
|
+
/** Run the set, serially — the cases hit one live estate, and parallel asks contend for its budgets. */
|
|
18
|
+
export async function runTruthSet(cases) {
|
|
19
|
+
const results = [];
|
|
20
|
+
for (const c of cases) {
|
|
21
|
+
const started = Date.now();
|
|
22
|
+
const failures = [];
|
|
23
|
+
const truth = {};
|
|
24
|
+
let outcome;
|
|
25
|
+
try {
|
|
26
|
+
for (const [key, probe] of Object.entries(c.probes)) {
|
|
27
|
+
truth[key] = await probe();
|
|
28
|
+
}
|
|
29
|
+
outcome = await c.run();
|
|
30
|
+
for (const check of c.checks) {
|
|
31
|
+
const verdict = check(outcome, truth);
|
|
32
|
+
if (verdict)
|
|
33
|
+
failures.push(verdict);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
failures.push(`case did not run: ${e instanceof Error ? e.message : String(e)}`);
|
|
38
|
+
}
|
|
39
|
+
results.push({
|
|
40
|
+
id: c.id, incident: c.incident, question: c.question,
|
|
41
|
+
passed: failures.length === 0, failures, truth,
|
|
42
|
+
...(outcome ? { outcome } : {}), ms: Date.now() - started,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
results,
|
|
47
|
+
passed: results.filter((r) => r.passed).length,
|
|
48
|
+
failed: results.filter((r) => !r.passed).length,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** The report, for a terminal. Failures print the prose that was judged — the artefact a person needs. */
|
|
52
|
+
export function formatTruthReport(report) {
|
|
53
|
+
const lines = [];
|
|
54
|
+
for (const r of report.results) {
|
|
55
|
+
lines.push(`${r.passed ? '✓' : '✗'} ${r.id} (${(r.ms / 1000).toFixed(1)}s) “${r.question}”`);
|
|
56
|
+
if (!r.passed) {
|
|
57
|
+
lines.push(` incident: ${r.incident}`);
|
|
58
|
+
for (const f of r.failures)
|
|
59
|
+
lines.push(` FAIL: ${f}`);
|
|
60
|
+
if (r.outcome) {
|
|
61
|
+
lines.push(` said: ${r.outcome.text.split('\n')[0]?.slice(0, 160) ?? ''}`);
|
|
62
|
+
for (const e of r.outcome.evidence) {
|
|
63
|
+
lines.push(` evidence: ${e.toolId}${e.count !== undefined ? ` count=${e.count}` : ''}${e.reason ? ` reason=${e.reason.slice(0, 80)}` : ''}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
lines.push(` truth: ${JSON.stringify(r.truth).slice(0, 200)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
lines.push('', `${report.passed}/${report.results.length} truth cases hold${report.failed ? ` — ${report.failed} FAILING` : ''}`);
|
|
70
|
+
return lines.join('\n');
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=truth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truth.js","sourceRoot":"","sources":["../src/truth.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,oGAAoG;AACpG,gGAAgG;AAChG,oGAAoG;AACpG,qGAAqG;AACrG,sGAAsG;AACtG,qGAAqG;AACrG,iGAAiG;AACjG,+FAA+F;AAC/F,kGAAkG;AAClG,EAAE;AACF,qGAAqG;AACrG,uFAAuF;AA4DvF,wGAAwG;AACxG,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,KAAoB;IACpD,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAgB,EAAE,CAAC;QAC9B,IAAI,OAA+B,CAAC;QACpC,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpD,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,KAAK,EAAE,CAAC;YAC7B,CAAC;YACD,OAAO,GAAG,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC;YACxB,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;gBACtC,I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,MAAM,CAAC,OAAO,CAAC,MAAM,oBAAoB,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,MAAM,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClI,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/evaluation",
|
|
3
|
+
"version": "0.0.0-alpha.1",
|
|
4
|
+
"description": "Truthfulness evaluation for agent answers (spec 358 W2): cases seeded from live incidents, ground-truth probes, and deterministic checks over the prose AND the evidence.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"dist",
|
|
15
|
+
"spec.md",
|
|
16
|
+
"README.md",
|
|
17
|
+
"bin"
|
|
18
|
+
],
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"vitest": "^4.1.8"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bin": {
|
|
27
|
+
"ap-live-gates": "./bin/ap-live-gates.mjs"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.build.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"test:unit": "vitest run test/unit --passWithNoTests",
|
|
34
|
+
"clean": "rm -rf dist"
|
|
35
|
+
}
|
|
36
|
+
}
|
package/spec.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @agenticprimitives/evaluation — package spec
|
|
2
|
+
|
|
3
|
+
Spec of record: [specs/358-semantic-context-plane.md](../../specs/358-semantic-context-plane.md) (W2),
|
|
4
|
+
within [specs/351-agentic-primitives-substrate-program.md](../../specs/351-agentic-primitives-substrate-program.md)
|
|
5
|
+
("AP Operations": `evaluation` is the planned second operations package beside `audit`).
|
|
6
|
+
|
|
7
|
+
Owns the truth-case contract (`TruthCaseV1`), the deterministic runner (`runTruthSet` — probes first,
|
|
8
|
+
then the ask, then every check; an unrunnable case fails), the named checks, and the report. Does not own
|
|
9
|
+
case data, transport, or any model call. The live ASK set lives in `scripts/ask-truth.mts`
|
|
10
|
+
(`pnpm check:ask-truth`), seeded from the 2026-09 incidents and grown by the spec 358 §4 rule.
|