@agenticprimitives/evaluation 0.0.0-alpha.1 → 0.0.0-alpha.11

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.
Files changed (90) hide show
  1. package/README.md +2 -0
  2. package/dist/act.d.ts +97 -0
  3. package/dist/act.d.ts.map +1 -0
  4. package/dist/act.js +115 -0
  5. package/dist/act.js.map +1 -0
  6. package/dist/agent-record.d.ts +86 -0
  7. package/dist/agent-record.d.ts.map +1 -0
  8. package/dist/agent-record.js +108 -0
  9. package/dist/agent-record.js.map +1 -0
  10. package/dist/assessment.d.ts +158 -0
  11. package/dist/assessment.d.ts.map +1 -0
  12. package/dist/assessment.js +167 -0
  13. package/dist/assessment.js.map +1 -0
  14. package/dist/canonical.d.ts +2 -0
  15. package/dist/canonical.d.ts.map +1 -0
  16. package/dist/canonical.js +4 -0
  17. package/dist/canonical.js.map +1 -0
  18. package/dist/capture.d.ts +90 -0
  19. package/dist/capture.d.ts.map +1 -0
  20. package/dist/capture.js +195 -0
  21. package/dist/capture.js.map +1 -0
  22. package/dist/compare-runner.d.ts +211 -0
  23. package/dist/compare-runner.d.ts.map +1 -0
  24. package/dist/compare-runner.js +379 -0
  25. package/dist/compare-runner.js.map +1 -0
  26. package/dist/conformal.d.ts +113 -0
  27. package/dist/conformal.d.ts.map +1 -0
  28. package/dist/conformal.js +113 -0
  29. package/dist/conformal.js.map +1 -0
  30. package/dist/consensus.d.ts +53 -0
  31. package/dist/consensus.d.ts.map +1 -0
  32. package/dist/consensus.js +64 -0
  33. package/dist/consensus.js.map +1 -0
  34. package/dist/eval-file.d.ts +104 -0
  35. package/dist/eval-file.d.ts.map +1 -0
  36. package/dist/eval-file.js +92 -0
  37. package/dist/eval-file.js.map +1 -0
  38. package/dist/experiment.d.ts +301 -0
  39. package/dist/experiment.d.ts.map +1 -0
  40. package/dist/experiment.js +237 -0
  41. package/dist/experiment.js.map +1 -0
  42. package/dist/index.d.ts +38 -0
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +38 -0
  45. package/dist/index.js.map +1 -1
  46. package/dist/ledger.d.ts +128 -0
  47. package/dist/ledger.d.ts.map +1 -0
  48. package/dist/ledger.js +146 -0
  49. package/dist/ledger.js.map +1 -0
  50. package/dist/live-gates.d.ts +3 -0
  51. package/dist/live-gates.d.ts.map +1 -1
  52. package/dist/live-gates.js +3 -1
  53. package/dist/live-gates.js.map +1 -1
  54. package/dist/measure.d.ts +63 -0
  55. package/dist/measure.d.ts.map +1 -0
  56. package/dist/measure.js +95 -0
  57. package/dist/measure.js.map +1 -0
  58. package/dist/replay.d.ts +58 -0
  59. package/dist/replay.d.ts.map +1 -0
  60. package/dist/replay.js +65 -0
  61. package/dist/replay.js.map +1 -0
  62. package/dist/report.d.ts +249 -0
  63. package/dist/report.d.ts.map +1 -0
  64. package/dist/report.js +363 -0
  65. package/dist/report.js.map +1 -0
  66. package/dist/rollup.d.ts +91 -0
  67. package/dist/rollup.d.ts.map +1 -0
  68. package/dist/rollup.js +80 -0
  69. package/dist/rollup.js.map +1 -0
  70. package/dist/selection-gates.d.ts +283 -0
  71. package/dist/selection-gates.d.ts.map +1 -0
  72. package/dist/selection-gates.js +331 -0
  73. package/dist/selection-gates.js.map +1 -0
  74. package/dist/selection-score.d.ts +285 -0
  75. package/dist/selection-score.d.ts.map +1 -0
  76. package/dist/selection-score.js +392 -0
  77. package/dist/selection-score.js.map +1 -0
  78. package/dist/selection.d.ts +83 -0
  79. package/dist/selection.d.ts.map +1 -0
  80. package/dist/selection.js +86 -0
  81. package/dist/selection.js.map +1 -0
  82. package/dist/signals.d.ts +37 -0
  83. package/dist/signals.d.ts.map +1 -0
  84. package/dist/signals.js +44 -0
  85. package/dist/signals.js.map +1 -0
  86. package/dist/stats.d.ts +62 -0
  87. package/dist/stats.d.ts.map +1 -0
  88. package/dist/stats.js +279 -0
  89. package/dist/stats.js.map +1 -0
  90. package/package.json +17 -2
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @agenticprimitives/evaluation
2
2
 
3
+ > Part of **[Agentic Primitives](https://agenticprimitives.dev)** — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. [Developer kit](https://github.com/agentictrustlabs/agentic-primitives) · [All packages](https://agenticprimitives.dev/developers)
4
+
3
5
  Truthfulness evaluation for agent answers. A truth case asks a **live** agent a question, reads the
4
6
  **ground truth** from somewhere the agent does not control, and judges the reply's **claims** — the prose
5
7
  and the evidence it cites — with deterministic checks. Failures print the sentence that was wrong.
package/dist/act.d.ts ADDED
@@ -0,0 +1,97 @@
1
+ /** The gold for one case. Parties and the delegator are NAMES in the set (the estate's fixture), resolved to addresses
2
+ * before a run by the caller — a gold file stays readable and the estate stays the source of who is who. */
3
+ export interface ActGoldCaseV1 {
4
+ /** What the reply must be: the act parked for authority, a question back, an answer (a read), or a refusal. */
5
+ reply: 'authority_required' | 'prompt' | 'answer' | 'done' | 'refused';
6
+ /** The capability the act exercises (authority_required / prompt), or the read that answers (answer). */
7
+ capability?: string;
8
+ /** Argument → the agent it must resolve to (a name here; an address after `resolveActGold`). */
9
+ parties?: Record<string, string>;
10
+ /** Whose authority the act needs — the mandate's delegator (a name; an address after resolution). */
11
+ delegator?: string;
12
+ /** Requirement limits that must hold exactly (e.g. `{ maxAmount: '3000000' }` — base units). */
13
+ limits?: Record<string, string>;
14
+ /** For `prompt`: fields the question must ask for (any order; others may be asked too); `usdc|amount` = either name. */
15
+ promptFields?: string[];
16
+ /** The run's provenance must hold the act's step (realizing the capability, governed by a skill contract). */
17
+ /** `true`: the act's step is Suspended or Completed; `'dry-run'`: a self-acting write held by a comparison run (Skipped). */
18
+ receipt?: boolean | 'dry-run';
19
+ /** Capabilities the run must NOT reach (a near-neighbour act the words could be mistaken for). */
20
+ forbidden?: string[];
21
+ /** Spec 420 — the domain principles (`appr:` ids, tbox/principles.ttl) this case tests; its verdict counts toward each. */
22
+ principles?: string[];
23
+ /** Spec 420 W4 — a UX ACTION: the plan a Home button supplies (its words ride as the message). The run is judged the same way;
24
+ * a read must also return its rows to the screen (`results` for each supplied tool). */
25
+ supplied?: {
26
+ steps: Array<{
27
+ toolId: string;
28
+ args: Record<string, unknown>;
29
+ }>;
30
+ };
31
+ /** Spec 420 §10 — keys the capability's result must NOT carry (a supplied read that must withhold its rows: `['members']`).
32
+ * Judged on the result's KEYS only; no row is read. */
33
+ withholds?: string[];
34
+ /** Spec 421 W3 — what the act's arguments must CARRY (`argName` → text, `a|b` alternatives; `*` = any argument): the fact
35
+ * that came from what was read ("Linden" in a remembered address). A plan that acts on the sentence's own words passes
36
+ * every other check and fails this one — the hollow success the continuation laboratory exists to catch. */
37
+ argsInclude?: Record<string, string>;
38
+ /** Spec 421 W2 — the arguments the reply must NAME as having come from someone else's words (the card's warning). */
39
+ flags?: string[];
40
+ }
41
+ export interface ActGoldV1 {
42
+ type: 'ap.act-gold.v1';
43
+ replaySetDigest?: string;
44
+ note?: string;
45
+ estate?: string;
46
+ cases: Record<string, ActGoldCaseV1>;
47
+ }
48
+ /** What a reply said about the act — taken from the reply by the caller; addresses lowercased. */
49
+ export interface ActCaptureV1 {
50
+ kind: string;
51
+ capability?: string;
52
+ delegator?: string;
53
+ limits?: Record<string, string | number>;
54
+ parties?: Record<string, string>;
55
+ promptFields?: string[];
56
+ /** The tools the plan named, in order (to check `forbidden`). */
57
+ planned?: string[];
58
+ /** Spec 421 W2 — the act's arguments the reply said came only from someone else's words. */
59
+ fromOthers?: string[];
60
+ /** The plan's steps with their arguments (for `argsInclude`). */
61
+ plannedArgs?: Array<{
62
+ toolId: string;
63
+ args: Record<string, unknown>;
64
+ }>;
65
+ /** Tools whose rows came back to the surface (`results[]` on a supplied plan's reply). */
66
+ results?: string[];
67
+ /** The KEYS of each supplied tool's result (never the values) — for `withholds`. */
68
+ resultKeys?: Record<string, string[]>;
69
+ /** Of those keys, the ones whose value is an empty list or object. */
70
+ resultEmpty?: Record<string, string[]>;
71
+ }
72
+ /** One step of the run as its provenance records it. */
73
+ export interface ActStepV1 {
74
+ capability: string | null;
75
+ state: string | null;
76
+ skill: string | null;
77
+ }
78
+ /** The judgement: every check by name, and right only when all hold. Booleans only — no addresses leave. */
79
+ export interface ActVerdictV1 {
80
+ right: boolean;
81
+ checks: Record<string, boolean>; /** Spec 420 — the principles this case tests. */
82
+ principles?: string[];
83
+ }
84
+ /** The steps a run's provenance graph records (JSON-LD graph as `/harness/provenance` returns it). */
85
+ export declare function actStepsOf(graph: unknown): ActStepV1[];
86
+ export declare function judgeAct(gold: ActGoldCaseV1, got: ActCaptureV1, steps: readonly ActStepV1[]): ActVerdictV1;
87
+ /** The reply of `/harness/ask`, read for the act — the one place the reply's shape is interpreted. */
88
+ export declare function actCaptureOf(reply: unknown): ActCaptureV1;
89
+ /** Names in the gold → addresses, by the estate's own resolver (the caller's). A name that resolves nowhere is an error:
90
+ * a case whose gold names nobody cannot be judged. */
91
+ export declare function resolveActGold(gold: ActGoldV1, resolveName: (name: string) => Promise<string | null>): Promise<ActGoldV1>;
92
+ /** Spec 420 — right / total per principle over act verdicts (each case's verdict counts toward every principle it cites). */
93
+ export declare function principleCoverageOf(verdicts: ReadonlyArray<ActVerdictV1 | undefined>): Record<string, {
94
+ right: number;
95
+ total: number;
96
+ }>;
97
+ //# sourceMappingURL=act.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../src/act.ts"],"names":[],"mappings":"AASA;6GAC6G;AAC7G,MAAM,WAAW,aAAa;IAC5B,+GAA+G;IAC/G,KAAK,EAAE,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IACvE,yGAAyG;IACzG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gGAAgG;IAChG,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,qGAAqG;IACrG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG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AAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAc/H;AAED,6HAA6H;AAC7H,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAIvI"}
package/dist/act.js ADDED
@@ -0,0 +1,115 @@
1
+ // THE ACT LABORATORY — spec 418 §12. The CIL Commons sets ask "did we pick the right writer, and was the writing good?";
2
+ // a Home act asks something else: did the harness reach THE act the person asked for — the right capability, the parties
3
+ // her words named resolved to the right agents, the amount she said, whose authority it needs — and did it leave the
4
+ // receipt? A payment that parks for the wrong account is a wrong outcome even when the pick was right.
5
+ //
6
+ // Nothing here signs or moves anything. An act under test ends where the person would sign (`authority_required`) or
7
+ // where she would be asked (`prompt`); the gold says which, and what would have been signed. Every check is
8
+ // deterministic over the reply and the run's own provenance — no model judges an act.
9
+ const lc = (s) => (s ?? '').toLowerCase();
10
+ /** The steps a run's provenance graph records (JSON-LD graph as `/harness/provenance` returns it). */
11
+ export function actStepsOf(graph) {
12
+ const nodes = (graph?.graph ?? []);
13
+ const byId = new Map(nodes.map((n) => [String(n['id']), n]));
14
+ const run = nodes.find((n) => Array.isArray(n['hasStep']) || typeof n['hasStep'] === 'string');
15
+ const ids = run ? [].concat(run['hasStep']).map(String) : [];
16
+ return ids.map((id) => byId.get(id)).filter((n) => !!n).map((n) => ({
17
+ capability: typeof n['realizesCapability'] === 'string' ? String(n['realizesCapability']).replace(/^urn:ap:capability:/, '') : null,
18
+ state: typeof n['completionState'] === 'string' ? String(n['completionState']) : null,
19
+ skill: typeof n['governedBySkill'] === 'string' ? String(n['governedBySkill']) : null,
20
+ }));
21
+ }
22
+ export function judgeAct(gold, got, steps) {
23
+ // A write HELD by a comparison's dry run is reported as not saved — `done` or `answer` both say the run reached it.
24
+ const checks = { reply: gold.receipt === 'dry-run' ? got.kind === 'done' || got.kind === 'answer' : got.kind === gold.reply };
25
+ if (gold.capability)
26
+ checks['capability'] = gold.reply === 'answer' || gold.reply === 'done' || gold.reply === 'refused' ? (got.planned ?? []).includes(gold.capability) : got.capability === gold.capability;
27
+ for (const [arg, want] of Object.entries(gold.parties ?? {}))
28
+ checks[`party:${arg}`] = lc(got.parties?.[arg]) === lc(want);
29
+ if (gold.delegator)
30
+ checks['delegator'] = lc(got.delegator) === lc(gold.delegator);
31
+ for (const [k, v] of Object.entries(gold.limits ?? {}))
32
+ checks[`limit:${k}`] = String(got.limits?.[k] ?? '') === v;
33
+ // `a|b` — the argument under any of its declared names (the harness may ask for `usdc` as `amount`).
34
+ for (const f of gold.promptFields ?? [])
35
+ checks[`asks:${f}`] = f.split('|').some((x) => (got.promptFields ?? []).includes(x));
36
+ if (gold.receipt && gold.capability)
37
+ checks['receipt'] = steps.some((s) => s.capability === gold.capability && !!s.skill && (gold.receipt === 'dry-run' ? s.state === 'Skipped' : s.state === 'Suspended' || s.state === 'Completed'));
38
+ if (gold.supplied && gold.reply === 'answer')
39
+ for (const st of gold.supplied.steps)
40
+ checks[`rows:${st.toolId}`] = (got.results ?? []).includes(st.toolId);
41
+ // Withheld = the key is absent, or present and EMPTY (a refused roster answers `members: []`): nothing was disclosed either way.
42
+ if (gold.withholds?.length && gold.capability)
43
+ for (const k of gold.withholds)
44
+ checks[`withholds:${k}`] = !(got.resultKeys?.[gold.capability] ?? []).includes(k) || (got.resultEmpty?.[gold.capability] ?? []).includes(k);
45
+ for (const f of gold.forbidden ?? [])
46
+ checks[`not:${f}`] = !(got.planned ?? []).includes(f) && got.capability !== f;
47
+ for (const a of gold.flags ?? [])
48
+ checks[`flags:${a}`] = (got.fromOthers ?? []).includes(a);
49
+ for (const [arg, want] of Object.entries(gold.argsInclude ?? {})) {
50
+ const steps = (got.plannedArgs ?? []).filter((p) => p.toolId === gold.capability);
51
+ const values = steps.flatMap((p) => (arg === '*' ? Object.values(p.args) : [p.args[arg]])).map((v) => lc(typeof v === 'string' ? v : JSON.stringify(v ?? '')));
52
+ checks[`carries:${arg}`] = want.split('|').some((w) => values.some((v) => v.includes(lc(w))));
53
+ }
54
+ return { right: Object.values(checks).every(Boolean), checks, ...(gold.principles?.length ? { principles: [...gold.principles] } : {}) };
55
+ }
56
+ /** The reply of `/harness/ask`, read for the act — the one place the reply's shape is interpreted. */
57
+ export function actCaptureOf(reply) {
58
+ const r = (reply ?? {});
59
+ const parties = Object.fromEntries((r.parties ?? []).flatMap((p) => (p.arg && p.agent ? [[p.arg, p.agent.toLowerCase()]] : [])));
60
+ // A question back names no capability on the reply; the step it asks about does (`s<N>` → the plan's step N).
61
+ const planned = (r.plannerTrace?.plan ?? []).map((p) => String(p.toolId ?? ''));
62
+ const asked = r.prompt?.stepRef?.match(/^s(\d+)$/)?.[1];
63
+ const capability = r.capability ?? (r.kind === 'prompt' && asked !== undefined ? planned[Number(asked)] : undefined);
64
+ return {
65
+ kind: String(r.kind ?? 'none'),
66
+ ...(capability ? { capability } : {}),
67
+ ...(r.delegator ? { delegator: r.delegator.toLowerCase() } : {}),
68
+ ...(r.requirement?.limits ? { limits: r.requirement.limits } : {}),
69
+ ...(Object.keys(parties).length ? { parties } : {}),
70
+ ...(r.prompt?.fields?.length ? { promptFields: r.prompt.fields.map((f) => (typeof f === 'string' ? f : String(f.name ?? ''))) } : {}),
71
+ ...(r.plannerTrace?.plan?.length ? { planned: r.plannerTrace.plan.map((p) => String(p.toolId ?? '')) } : {}),
72
+ ...(Array.isArray(r.fromOthers) ? { fromOthers: (r.fromOthers).map((x) => String(x.arg ?? '')) } : {}),
73
+ ...(r.plannerTrace?.plan?.length ? { plannedArgs: r.plannerTrace.plan.map((p) => ({ toolId: String(p.toolId ?? ''), args: (p.args ?? {}) })) } : {}),
74
+ ...(Array.isArray(r.results) ? { results: (r.results).map((x) => String(x.toolId ?? '')) } : {}),
75
+ ...(Array.isArray(r.results) ? { resultEmpty: Object.fromEntries((r.results).map((x) => [String(x.toolId ?? ''), x.result && typeof x.result === 'object' ? Object.entries(x.result).filter(([, v]) => (Array.isArray(v) && v.length === 0) || (v && typeof v === 'object' && !Array.isArray(v) && Object.keys(v).length === 0)).map(([k]) => k) : []])) } : {}),
76
+ ...(Array.isArray(r.results) ? { resultKeys: Object.fromEntries((r.results).map((x) => [String(x.toolId ?? ''), x.result && typeof x.result === 'object' ? Object.keys(x.result) : []])) } : {}),
77
+ };
78
+ }
79
+ /** Names in the gold → addresses, by the estate's own resolver (the caller's). A name that resolves nowhere is an error:
80
+ * a case whose gold names nobody cannot be judged. */
81
+ export async function resolveActGold(gold, resolveName) {
82
+ const memo = new Map();
83
+ const addr = async (v) => {
84
+ if (/^0x[0-9a-fA-F]{40}$/.test(v))
85
+ return v.toLowerCase();
86
+ if (!memo.has(v)) {
87
+ const a = await resolveName(v);
88
+ if (!a)
89
+ throw new Error(`act gold names "${v}", which resolves to no agent on this estate`);
90
+ memo.set(v, a.toLowerCase());
91
+ }
92
+ return memo.get(v);
93
+ };
94
+ const cases = {};
95
+ for (const [id, c] of Object.entries(gold.cases)) {
96
+ const parties = {};
97
+ for (const [k, v] of Object.entries(c.parties ?? {}))
98
+ parties[k] = await addr(v);
99
+ cases[id] = { ...c, ...(c.parties ? { parties } : {}), ...(c.delegator ? { delegator: await addr(c.delegator) } : {}) };
100
+ }
101
+ return { ...gold, cases };
102
+ }
103
+ /** Spec 420 — right / total per principle over act verdicts (each case's verdict counts toward every principle it cites). */
104
+ export function principleCoverageOf(verdicts) {
105
+ const out = {};
106
+ for (const v of verdicts)
107
+ for (const p of v?.principles ?? []) {
108
+ const e = (out[p] ??= { right: 0, total: 0 });
109
+ e.total++;
110
+ if (v.right)
111
+ e.right++;
112
+ }
113
+ return out;
114
+ }
115
+ //# sourceMappingURL=act.js.map
@@ -0,0 +1 @@
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E,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAAC,CAAC,CAAC,KAAK,EAAE,CAAC;YAAC,IAAI,CAAE,CAAC,KAAK;gBAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAAC,CAAC;IACrJ,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,86 @@
1
+ import type { RunEnding, RunEndingFactsV1 } from './rollup.js';
2
+ import type { AssessmentOutcomeV1, SignedAssessmentV1 } from './assessment.js';
3
+ /** How complete a run's record is, as `evidenceStatusOf` reports it. Projected BY THE CALLER: this package
4
+ * is a leaf and does not import `orchestration`, so the run record never reaches it. */
5
+ export type EvidenceCoverageV1 = 'complete' | 'incomplete' | 'unknown';
6
+ /** One run, as this join needs to see it. Everything beyond the ending is optional, and every absence is a
7
+ * distinct bucket below rather than a default — `unreported` is not `complete`. */
8
+ export interface AgentRunFactsV1 extends RunEndingFactsV1 {
9
+ /** The digest of the record AS IT STANDS NOW. Absent ⇒ no assessment of this run can be called current,
10
+ * because there is nothing to compare its subject digest against; those count as `undetermined`. */
11
+ recordDigest?: string;
12
+ evidence?: {
13
+ coverage: EvidenceCoverageV1;
14
+ effectUncertain?: boolean;
15
+ };
16
+ /** The work this run was attached to. Attaching is an act with an author; nothing is inferred (§3). */
17
+ work?: {
18
+ endeavorId: string;
19
+ commitmentId?: string;
20
+ planStepId?: string;
21
+ };
22
+ /** The run this one continued, when it was started from a continuation package (stage 5). */
23
+ continues?: string;
24
+ }
25
+ export interface AgentAssessmentSummaryV1 {
26
+ /** Runs with at least one STANDING assessment that examined the run's current digest. */
27
+ runsAssessed: number;
28
+ /** Runs with none. Not a failing grade: criteria are usually simply not stated yet. */
29
+ runsUnassessed: number;
30
+ /** Standing assessments examining the current document. */
31
+ current: number;
32
+ /** Standing assessments whose subject digest is NOT the run's current digest — a judgment of another
33
+ * version of the same run. Shown as that, never folded into `current`. */
34
+ stale: number;
35
+ /** Assessments naming a run not in the facts given. Counted rather than dropped. */
36
+ orphaned: number;
37
+ /** The run has no digest to compare against, so currency cannot be decided either way. */
38
+ undetermined: number;
39
+ /** Assessments a later one supersedes. They stay readable; a correction is a new assessment (§5). */
40
+ superseded: number;
41
+ /** Distinct evaluator Smart Agents, sorted. A LIST of who has judged — never a weighting of them. */
42
+ evaluators: string[];
43
+ /** Distinct criteria judged against, as `outcomeId@revision`. Says what was being judged, not how well. */
44
+ criteria: string[];
45
+ /** EARL outcomes across current assessments' results. `cantTell` is a real verdict and is never rounded. */
46
+ outcomes: Record<AssessmentOutcomeV1, number>;
47
+ }
48
+ export interface AgentRecordV1 {
49
+ agent: string;
50
+ /** Stage 2 — every ending with a count, including the zeros. */
51
+ endings: Record<RunEnding, number>;
52
+ total: number;
53
+ firstEndedAt?: string;
54
+ lastEndedAt?: string;
55
+ /** Stage 3 — four buckets, and `unreported` is its own. A run whose coverage nobody computed is not a
56
+ * complete one, and the only way to say so is to keep it apart. */
57
+ evidence: {
58
+ complete: number;
59
+ incomplete: number;
60
+ unknown: number;
61
+ unreported: number;
62
+ effectUncertain: number;
63
+ };
64
+ /** Stage 4. */
65
+ assessment: AgentAssessmentSummaryV1;
66
+ /** Stages 2 and 5 — the work the runs belong to, and the runs that continued another. */
67
+ work: {
68
+ runsWithWork: number;
69
+ endeavors: string[];
70
+ continuations: number;
71
+ };
72
+ }
73
+ /**
74
+ * Join one agent's runs with the assessments made of them.
75
+ *
76
+ * `runs` are that agent's; `assessments` are every signed assessment held for it, in any order and across any
77
+ * number of runs. Pure and order-independent: the same inputs in any order give the same record.
78
+ *
79
+ * Supersession is resolved first (`standingAssessments`), so a corrected judgment does not double-count —
80
+ * and the superseded ones are still COUNTED, because "two people judged this once each" and "one person
81
+ * judged it twice" are different facts about an agent.
82
+ */
83
+ export declare function agentRecordOf(agent: string, runs: readonly AgentRunFactsV1[], assessments?: readonly SignedAssessmentV1[]): AgentRecordV1;
84
+ /** The record in a person's words, for a surface that wants one line. Counts in pairs, never a ratio. */
85
+ export declare function agentRecordWords(r: AgentRecordV1): string[];
86
+ //# sourceMappingURL=agent-record.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-record.d.ts","sourceRoot":"","sources":["../src/agent-record.ts"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG/E;yFACyF;AACzF,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAC;AAEvE;oFACoF;AACpF,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD;yGACqG;IACrG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE;QAAE,QAAQ,EAAE,kBAAkB,CAAC;QAAC,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACvE,uGAAuG;IACvG,IAAI,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1E,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,yFAAyF;IACzF,YAAY,EAAE,MAAM,CAAC;IACrB,uFAAuF;IACvF,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB;+EAC2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,0FAA0F;IAC1F,YAAY,EAAE,MAAM,CAAC;IACrB,qGAAqG;IACrG,UAAU,EAAE,MAAM,CAAC;IACnB,qGAAqG;IACrG,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,2GAA2G;IAC3G,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,4GAA4G;IAC5G,QAAQ,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;wEACoE;IACpE,QAAQ,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IACjH,eAAe;IACf,UAAU,EAAE,wBAAwB,CAAC;IACrC,yFAAyF;IACzF,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,EAAE,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5E;AASD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,WAAW,GAAE,SAAS,kBAAkB,EAAO,GAC9C,aAAa,CA6Df;AAED,yGAAyG;AACzG,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,EAAE,CAsB3D"}
@@ -0,0 +1,108 @@
1
+ import { agentHistoryOf } from './rollup.js';
2
+ import { standingAssessments } from './assessment.js';
3
+ const OUTCOMES = ['passed', 'failed', 'cantTell', 'inapplicable', 'untested'];
4
+ const emptyOutcomes = () => Object.fromEntries(OUTCOMES.map((o) => [o, 0]));
5
+ const sorted = (s) => [...new Set(s)].sort();
6
+ /**
7
+ * Join one agent's runs with the assessments made of them.
8
+ *
9
+ * `runs` are that agent's; `assessments` are every signed assessment held for it, in any order and across any
10
+ * number of runs. Pure and order-independent: the same inputs in any order give the same record.
11
+ *
12
+ * Supersession is resolved first (`standingAssessments`), so a corrected judgment does not double-count —
13
+ * and the superseded ones are still COUNTED, because "two people judged this once each" and "one person
14
+ * judged it twice" are different facts about an agent.
15
+ */
16
+ export function agentRecordOf(agent, runs, assessments = []) {
17
+ const mine = runs.filter((r) => r.agent === agent);
18
+ const history = agentHistoryOf(mine)[0] ?? {
19
+ agent,
20
+ endings: { completed: 0, failed: 0, denied: 0, suspended: 0, 'authority-required': 0, canceled: 0, unknown: 0 },
21
+ total: 0,
22
+ };
23
+ const evidence = { complete: 0, incomplete: 0, unknown: 0, unreported: 0, effectUncertain: 0 };
24
+ for (const r of mine) {
25
+ if (!r.evidence)
26
+ evidence.unreported += 1;
27
+ else {
28
+ evidence[r.evidence.coverage] += 1;
29
+ if (r.evidence.effectUncertain)
30
+ evidence.effectUncertain += 1;
31
+ }
32
+ }
33
+ const digestOf = new Map(mine.map((r) => [r.runRef, r.recordDigest]));
34
+ const { standing, superseded } = standingAssessments(assessments);
35
+ const a = {
36
+ runsAssessed: 0, runsUnassessed: 0, current: 0, stale: 0, orphaned: 0, undetermined: 0,
37
+ superseded: superseded.length, evaluators: [], criteria: [], outcomes: emptyOutcomes(),
38
+ };
39
+ const evaluators = [];
40
+ const criteria = [];
41
+ const assessedRuns = new Set();
42
+ for (const s of standing) {
43
+ const { subject, criteria: c, evaluator, results } = s.assessment;
44
+ evaluators.push(String(evaluator.sa).toLowerCase());
45
+ criteria.push(`${c.outcomeId}@${c.revision}`);
46
+ if (!digestOf.has(subject.runRef)) {
47
+ a.orphaned += 1;
48
+ continue;
49
+ }
50
+ const current = digestOf.get(subject.runRef);
51
+ if (!current) {
52
+ a.undetermined += 1;
53
+ continue;
54
+ }
55
+ if (current !== subject.recordDigest) {
56
+ a.stale += 1;
57
+ continue;
58
+ }
59
+ a.current += 1;
60
+ assessedRuns.add(subject.runRef);
61
+ // Outcomes are counted only for assessments of the CURRENT document. A verdict on another version is
62
+ // reported as stale and nothing else: adding its outcomes here would be the misattribution in miniature.
63
+ for (const r of results)
64
+ a.outcomes[r.outcome] += 1;
65
+ }
66
+ a.evaluators = sorted(evaluators);
67
+ a.criteria = sorted(criteria);
68
+ a.runsAssessed = assessedRuns.size;
69
+ a.runsUnassessed = mine.length - assessedRuns.size;
70
+ return {
71
+ agent,
72
+ endings: history.endings,
73
+ total: history.total,
74
+ ...(history.firstEndedAt ? { firstEndedAt: history.firstEndedAt } : {}),
75
+ ...(history.lastEndedAt ? { lastEndedAt: history.lastEndedAt } : {}),
76
+ evidence,
77
+ assessment: a,
78
+ work: {
79
+ runsWithWork: mine.filter((r) => !!r.work?.endeavorId).length,
80
+ endeavors: sorted(mine.map((r) => r.work?.endeavorId).filter((x) => !!x)),
81
+ continuations: mine.filter((r) => !!r.continues).length,
82
+ },
83
+ };
84
+ }
85
+ /** The record in a person's words, for a surface that wants one line. Counts in pairs, never a ratio. */
86
+ export function agentRecordWords(r) {
87
+ const lines = [
88
+ `${r.total} run(s) recorded${r.lastEndedAt ? `, the last on ${r.lastEndedAt.slice(0, 10)}` : ''}: ` +
89
+ OUTCOME_ORDER.filter((k) => r.endings[k] > 0).map((k) => `${r.endings[k]} ${k}`).join(', '),
90
+ `Evidence: ${r.evidence.complete} complete, ${r.evidence.incomplete} incomplete, ${r.evidence.unknown} stopped before the plan finished` +
91
+ (r.evidence.unreported ? `, ${r.evidence.unreported} not read` : '') +
92
+ (r.evidence.effectUncertain ? `; ${r.evidence.effectUncertain} with an external effect still being reconciled` : ''),
93
+ ];
94
+ lines.push(r.assessment.current === 0
95
+ ? `Nobody has judged these runs. That is not a failing grade: an assessment needs criteria stated before the run it judges, and none has been.`
96
+ : `${r.assessment.runsAssessed} of ${r.total} run(s) have a standing judgment, by ${r.assessment.evaluators.length} evaluator(s) against ${r.assessment.criteria.length} stated criteri${r.assessment.criteria.length === 1 ? 'on' : 'a'}.`);
97
+ if (r.assessment.stale)
98
+ lines.push(`${r.assessment.stale} assessment(s) examined a different version of their run and are not counted as current — the record changed after they were made.`);
99
+ if (r.assessment.orphaned)
100
+ lines.push(`${r.assessment.orphaned} assessment(s) name a run not in this record.`);
101
+ lines.push(r.work.runsWithWork
102
+ ? `${r.work.runsWithWork} run(s) are attached to ${r.work.endeavors.length} endeavour(s)${r.work.continuations ? `; ${r.work.continuations} continued an earlier run` : ''}.`
103
+ : 'No run here names work. Nothing is inferred: a run joins an endeavour when somebody attaches it.');
104
+ lines.push('Counts, never a score. A rate over these buckets would fall whenever this agent correctly refused something.');
105
+ return lines;
106
+ }
107
+ const OUTCOME_ORDER = ['completed', 'failed', 'denied', 'authority-required', 'suspended', 'canceled', 'unknown'];
108
+ //# sourceMappingURL=agent-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-record.js","sourceRoot":"","sources":["../src/agent-record.ts"],"names":[],"mappings":"AA4CA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA2DtD,MAAM,QAAQ,GAAmC,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;AAE9G,MAAM,aAAa,GAAG,GAAwC,EAAE,CAC9D,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAwC,CAAC;AAEzF,MAAM,MAAM,GAAG,CAAC,CAAmB,EAAY,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAa,EACb,IAAgC,EAChC,cAA6C,EAAE;IAE/C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,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C,QAAQ,CAAC,MAAM,kBAAkB,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAC9O,CAAC;IACF,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,oIAAoI,CAAC,CAAC;IAC9L,IAAI,CAAC,CAAC,UAAU,CAAC,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,+CAA+C,CAAC,CAAC;IAC/G,KAAK,CAAC,IAAI,CACR,CAAC,CAAC,IAAI,CAAC,YAAY;QACjB,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,2BAA2B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,2BAA2B,CAAC,CAAC,CAAC,EAAE,GAAG;QAC7K,CAAC,CAAC,kGAAkG,CACvG,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,8GAA8G,CAAC,CAAC;IAC3H,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,aAAa,GAAyB,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC"}
@@ -0,0 +1,158 @@
1
+ import type { JudgeKindV1 } from './selection.js';
2
+ /** EARL's outcome vocabulary. `cantTell` is a real verdict — it is never rounded to a pass or a fail (J8). */
3
+ export type AssessmentOutcomeV1 = 'passed' | 'failed' | 'cantTell' | 'inapplicable' | 'untested';
4
+ export interface AssessmentSubjectV1 {
5
+ runRef: string;
6
+ /** The digest of the record as judged. A later reader comparing this to the record they fetched learns
7
+ * whether the assessment is even about the same document. */
8
+ recordDigest: string;
9
+ /** ISO — when the subject came into being. Compared against `criteria.statedAt` for J2. */
10
+ at: string;
11
+ artifactDigests?: readonly string[];
12
+ }
13
+ export interface AssessmentCriteriaV1 {
14
+ outcomeId: string;
15
+ /** The `OutcomeSpecificationV1` revision judged against (revisions are new entities, never edits). */
16
+ revision: number;
17
+ digest: string;
18
+ /** ISO — when this revision was stated. MUST pre-date `subject.at` (J2). */
19
+ statedAt: string;
20
+ }
21
+ export interface AssessmentEvaluatorV1 {
22
+ /** The evaluator's Smart Agent address. For a mechanical or model evaluator this is a Service Agent. */
23
+ sa: string;
24
+ kind: JudgeKindV1;
25
+ /** Digest of the implementation (mechanical) — so J5 reproducibility can be claimed or honestly refused. */
26
+ implementation?: string;
27
+ modelRef?: string;
28
+ promptDigest?: string;
29
+ }
30
+ export interface AssessmentResultV1 {
31
+ criterionId: string;
32
+ outcome: AssessmentOutcomeV1;
33
+ /** What the verdict rests on. An empty list is allowed only for `untested` / `inapplicable`. */
34
+ evidenceRefs: readonly string[];
35
+ /** An optional number for criteria that are scored rather than passed. Aggregation uses it; nothing else does. */
36
+ score?: number;
37
+ }
38
+ export interface AssessmentV1 {
39
+ schema: 'apeval/AssessmentV1';
40
+ subject: AssessmentSubjectV1;
41
+ criteria: AssessmentCriteriaV1;
42
+ evaluator: AssessmentEvaluatorV1;
43
+ results: readonly AssessmentResultV1[];
44
+ /** ISO — when the judgment was made. */
45
+ at: string;
46
+ /** The digest of the assessment this one replaces. The replaced one remains readable. */
47
+ supersedes?: string;
48
+ }
49
+ export interface SignedAssessmentV1 {
50
+ assessment: AssessmentV1;
51
+ /** sha256 over the assessment's canonical JSON — what was signed. */
52
+ digest: `sha256:${string}`;
53
+ /** The signature, in whatever form the binding produced (ERC-1271, or the `0x51` session-wrapped form). */
54
+ signature: string;
55
+ }
56
+ /** The assessment's identity: sha256 over its canonical JSON. Two assessments with the same content have the
57
+ * same digest whatever order their keys were written in. */
58
+ export declare const assessmentDigest: (a: AssessmentV1) => Promise<`sha256:${string}`>;
59
+ /**
60
+ * THE DIGEST AN ASSESSMENT CITES FOR THE CRITERIA IT JUDGED AGAINST.
61
+ *
62
+ * It lives here, beside the thing that validates an assessment, so the judge and every later reader hash the
63
+ * same bytes. Computing it at the call site is the obvious shortcut and the one that quietly breaks J2: two
64
+ * callers canonicalising a criteria revision slightly differently produce two digests for one revision, and
65
+ * an assessment then cites a criteria document nobody else can find.
66
+ *
67
+ * Only the fields that DEFINE the revision go in. A revision is a new entity rather than an edit (the
68
+ * `OutcomeSpecificationV1` rule), so its identity is its id, its number and its criteria — not when it was
69
+ * read, who read it, or which endeavour's log it came out of.
70
+ */
71
+ export interface OutcomeCriteriaDigestInput {
72
+ outcomeId: string;
73
+ revision: number;
74
+ criteria: ReadonlyArray<{
75
+ criterionId: string;
76
+ kind: string;
77
+ statement: string;
78
+ }>;
79
+ }
80
+ export declare const outcomeCriteriaDigest: (o: OutcomeCriteriaDigestInput) => Promise<`sha256:${string}`>;
81
+ export interface AssessmentValidationV1 {
82
+ ok: boolean;
83
+ /** Every problem found, not just the first: a caller fixing one at a time learns the next only by retrying. */
84
+ problems: string[];
85
+ }
86
+ /**
87
+ * The structural rules, checked without any cryptography — so they can be run before signing, in a test, or
88
+ * over an assessment that arrived from somewhere else.
89
+ */
90
+ export declare function validateAssessment(a: AssessmentV1): AssessmentValidationV1;
91
+ /** Signs the assessment's digest. Whatever key it uses, the binding must be the evaluator's own delegate. */
92
+ export type AssessmentSigner = (digest: `sha256:${string}`) => Promise<string>;
93
+ /**
94
+ * Who actually signed, as the binding can determine it.
95
+ *
96
+ * `delegator` is what makes the session form checkable: for a `0x51` session-wrapped signature the binding
97
+ * recovers the session key AND the wire it signed under, and the wire's delegator is the evaluator the
98
+ * assessment claims. For a human assessment (ERC-1271 by the person's own account) `signer` is the answer and
99
+ * `delegator` is absent.
100
+ */
101
+ export interface AssessmentSignatureFacts {
102
+ ok: boolean;
103
+ signer?: string;
104
+ delegator?: string;
105
+ /** The selector the wire was pinned to, when there was one. Expected to be `assessment.issue`. */
106
+ selector?: string;
107
+ reason?: string;
108
+ }
109
+ export type AssessmentVerifier = (input: {
110
+ digest: `sha256:${string}`;
111
+ signature: string;
112
+ }) => Promise<AssessmentSignatureFacts>;
113
+ /** The selector an assessment-issuing wire is pinned to. A wire that may do anything is not this wire. */
114
+ export declare const ASSESSMENT_SELECTOR = "assessment.issue";
115
+ export declare function signAssessment(a: AssessmentV1, sign: AssessmentSigner): Promise<SignedAssessmentV1>;
116
+ export interface AssessmentVerdictV1 {
117
+ ok: boolean;
118
+ problems: string[];
119
+ signer?: string;
120
+ }
121
+ /**
122
+ * Verify a signed assessment: the digest recomputes, the structure holds, and the signer is the evaluator's
123
+ * own delegate.
124
+ *
125
+ * Every failure is reported rather than thrown, because an assessment that does not verify is a FACT about
126
+ * the evidence someone is holding, and a thrown error tends to be caught and turned into silence.
127
+ */
128
+ export declare function verifyAssessment(signed: SignedAssessmentV1, verify: AssessmentVerifier): Promise<AssessmentVerdictV1>;
129
+ /** The vault record key for a run's assessments. Mirrors `runMeasuresRecordKey`. */
130
+ export declare const runAssessmentRecordKey: (runRef: string) => string;
131
+ export type AssessmentReadV1 = {
132
+ found: true;
133
+ assessments: SignedAssessmentV1[];
134
+ } | {
135
+ found: false;
136
+ } | {
137
+ refused: string;
138
+ };
139
+ export interface AssessmentStorePort {
140
+ readonly binding: string;
141
+ /** APPEND, never replace: a correction is a new assessment that supersedes an earlier one, and the earlier
142
+ * one stays readable (§5). A store that overwrote would quietly make the chain unverifiable. */
143
+ append(agent: string, runRef: string, signed: SignedAssessmentV1): Promise<{
144
+ ok: true;
145
+ } | {
146
+ refused: string;
147
+ }>;
148
+ get(agent: string, runRef: string): Promise<AssessmentReadV1>;
149
+ }
150
+ /** The assessments that currently STAND: those nothing else supersedes. Pure, so a caller can resolve the
151
+ * chain without the store. An assessment naming a `supersedes` digest nobody holds is kept and reported —
152
+ * dropping it would hide a correction whose predecessor is merely missing. */
153
+ export declare function standingAssessments(signed: readonly SignedAssessmentV1[]): {
154
+ standing: SignedAssessmentV1[];
155
+ superseded: SignedAssessmentV1[];
156
+ danglingSupersedes: string[];
157
+ };
158
+ //# sourceMappingURL=assessment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assessment.d.ts","sourceRoot":"","sources":["../src/assessment.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,8GAA8G;AAC9G,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAEjG,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf;kEAC8D;IAC9D,YAAY,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,EAAE,EAAE,MAAM,CAAC;IACX,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,wGAAwG;IACxG,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,4GAA4G;IAC5G,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,mBAAmB,CAAC;IAC7B,gGAAgG;IAChG,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,kHAAkH;IAClH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAA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