@agenticprimitives/orchestration 0.0.0-alpha.3 → 0.0.0-alpha.31
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/README.md +7 -0
- package/dist/adapter-policy.d.ts +29 -0
- package/dist/adapter-policy.d.ts.map +1 -0
- package/dist/adapter-policy.js +33 -0
- package/dist/adapter-policy.js.map +1 -0
- package/dist/admission.d.ts +75 -10
- package/dist/admission.d.ts.map +1 -1
- package/dist/admission.js +203 -8
- package/dist/admission.js.map +1 -1
- package/dist/answer-quality.d.ts +129 -0
- package/dist/answer-quality.d.ts.map +1 -0
- package/dist/answer-quality.js +197 -0
- package/dist/answer-quality.js.map +1 -0
- package/dist/approval.d.ts +73 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +263 -0
- package/dist/approval.js.map +1 -0
- package/dist/artifacts.d.ts +9 -1
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +119 -2
- package/dist/artifacts.js.map +1 -1
- package/dist/authority.d.ts +321 -2
- package/dist/authority.d.ts.map +1 -1
- package/dist/authority.js +11 -1
- package/dist/authority.js.map +1 -1
- package/dist/conformance.d.ts +80 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +264 -0
- package/dist/conformance.js.map +1 -0
- package/dist/derivation.d.ts +40 -0
- package/dist/derivation.d.ts.map +1 -0
- package/dist/derivation.js +158 -0
- package/dist/derivation.js.map +1 -0
- package/dist/digest.d.ts +10 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +45 -0
- package/dist/digest.js.map +1 -0
- package/dist/evidence.d.ts +77 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +101 -0
- package/dist/evidence.js.map +1 -0
- package/dist/export-port.d.ts +13 -0
- package/dist/export-port.d.ts.map +1 -0
- package/dist/export-port.js +2 -0
- package/dist/export-port.js.map +1 -0
- package/dist/index.d.ts +35 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -6
- package/dist/index.js.map +1 -1
- package/dist/input.d.ts +52 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +15 -0
- package/dist/input.js.map +1 -1
- package/dist/intent.d.ts +37 -0
- package/dist/intent.d.ts.map +1 -0
- package/dist/intent.js +46 -0
- package/dist/intent.js.map +1 -0
- package/dist/judgment.d.ts +131 -0
- package/dist/judgment.d.ts.map +1 -0
- package/dist/judgment.js +249 -0
- package/dist/judgment.js.map +1 -0
- package/dist/loop.d.ts +79 -9
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +1070 -178
- package/dist/loop.js.map +1 -1
- package/dist/metrics.js +8 -8
- package/dist/metrics.js.map +1 -1
- package/dist/outcome.d.ts +223 -0
- package/dist/outcome.d.ts.map +1 -0
- package/dist/outcome.js +326 -0
- package/dist/outcome.js.map +1 -0
- package/dist/plan-digest.d.ts +16 -0
- package/dist/plan-digest.d.ts.map +1 -0
- package/dist/plan-digest.js +45 -0
- package/dist/plan-digest.js.map +1 -0
- package/dist/planner.d.ts +43 -0
- package/dist/planner.d.ts.map +1 -1
- package/dist/planner.js +132 -0
- package/dist/planner.js.map +1 -1
- package/dist/provenance.d.ts +37 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +127 -0
- package/dist/provenance.js.map +1 -0
- package/dist/reconcile.d.ts +48 -0
- package/dist/reconcile.d.ts.map +1 -0
- package/dist/reconcile.js +20 -0
- package/dist/reconcile.js.map +1 -0
- package/dist/record.d.ts +129 -22
- package/dist/record.d.ts.map +1 -1
- package/dist/record.js +53 -1
- package/dist/record.js.map +1 -1
- package/dist/regression.d.ts +130 -0
- package/dist/regression.d.ts.map +1 -0
- package/dist/regression.js +113 -0
- package/dist/regression.js.map +1 -0
- package/dist/rollup.d.ts +72 -0
- package/dist/rollup.d.ts.map +1 -0
- package/dist/rollup.js +117 -0
- package/dist/rollup.js.map +1 -0
- package/dist/selection.d.ts +334 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +481 -0
- package/dist/selection.js.map +1 -0
- package/dist/spans.d.ts +77 -2
- package/dist/spans.d.ts.map +1 -1
- package/dist/spans.js +98 -25
- package/dist/spans.js.map +1 -1
- package/dist/step-lifecycle.d.ts +303 -0
- package/dist/step-lifecycle.d.ts.map +1 -0
- package/dist/step-lifecycle.js +304 -0
- package/dist/step-lifecycle.js.map +1 -0
- package/dist/tool-invoker.d.ts +58 -3
- package/dist/tool-invoker.d.ts.map +1 -1
- package/dist/tool-invoker.js +26 -1
- package/dist/tool-invoker.js.map +1 -1
- package/dist/trace-facts.d.ts +93 -0
- package/dist/trace-facts.d.ts.map +1 -0
- package/dist/trace-facts.js +82 -0
- package/dist/trace-facts.js.map +1 -0
- package/dist/types.d.ts +223 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -1
- package/package.json +17 -8
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { StructuredCallLike } from './selection.js';
|
|
2
|
+
export declare const ANSWER_QUALITY_JUDGE: {
|
|
3
|
+
name: string;
|
|
4
|
+
kind: "model";
|
|
5
|
+
};
|
|
6
|
+
/** The rubric: each a statement the judge gives P(true) for. Stable ids — a changed rubric is a new judge name (J5). */
|
|
7
|
+
export declare const ANSWER_QUALITY_RUBRIC: ReadonlyArray<{
|
|
8
|
+
id: string;
|
|
9
|
+
statement: string;
|
|
10
|
+
}>;
|
|
11
|
+
export interface AnswerQualityV1 {
|
|
12
|
+
judge: typeof ANSWER_QUALITY_JUDGE;
|
|
13
|
+
/** P(true) per rubric question. */
|
|
14
|
+
scores: Record<string, number>;
|
|
15
|
+
/** Their mean — the quality number a comparison reads. */
|
|
16
|
+
score: number;
|
|
17
|
+
ms: number;
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
/** Judge one answer. The answer is truncated to `maxChars` (the judge reads a bounded state). */
|
|
21
|
+
export declare function judgeAnswerQuality(input: {
|
|
22
|
+
request: string;
|
|
23
|
+
skillCard: string;
|
|
24
|
+
answer: string;
|
|
25
|
+
maxChars?: number;
|
|
26
|
+
}, call: StructuredCallLike): Promise<AnswerQualityV1>;
|
|
27
|
+
export declare const ANSWER_PREFERENCE_JUDGE: {
|
|
28
|
+
name: string;
|
|
29
|
+
kind: "model";
|
|
30
|
+
};
|
|
31
|
+
export interface AnswerPreferenceV1 {
|
|
32
|
+
judge: typeof ANSWER_PREFERENCE_JUDGE;
|
|
33
|
+
preference: Record<string, number>;
|
|
34
|
+
permutations: {
|
|
35
|
+
asked: number;
|
|
36
|
+
answered: number;
|
|
37
|
+
};
|
|
38
|
+
ms: number;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function judgeAnswerPreference(input: {
|
|
42
|
+
request: string;
|
|
43
|
+
skillCard: string;
|
|
44
|
+
answers: Record<string, string>;
|
|
45
|
+
maxChars?: number;
|
|
46
|
+
}, call: StructuredCallLike): Promise<AnswerPreferenceV1>;
|
|
47
|
+
export declare const OUTCOME_CHECK_JUDGE: {
|
|
48
|
+
name: string;
|
|
49
|
+
kind: "model";
|
|
50
|
+
};
|
|
51
|
+
/** One scoring unit: a single class (`id` = its IRI), or an alternative group (`id` = `alternative:<group>`). */
|
|
52
|
+
export interface OutcomeUnitV1 {
|
|
53
|
+
id: string;
|
|
54
|
+
members: string[];
|
|
55
|
+
requested: number;
|
|
56
|
+
delivered: number;
|
|
57
|
+
counted: boolean;
|
|
58
|
+
required?: true;
|
|
59
|
+
}
|
|
60
|
+
export interface OutcomeCheckV1 {
|
|
61
|
+
judge: typeof OUTCOME_CHECK_JUDGE;
|
|
62
|
+
classes: Record<string, number>;
|
|
63
|
+
requested: Record<string, number>;
|
|
64
|
+
units?: OutcomeUnitV1[];
|
|
65
|
+
score: number;
|
|
66
|
+
ms: number;
|
|
67
|
+
error?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function judgeOutcomeDelivered(input: {
|
|
70
|
+
request: string;
|
|
71
|
+
answer: string;
|
|
72
|
+
expected: ReadonlyArray<{
|
|
73
|
+
iri: string;
|
|
74
|
+
label: string;
|
|
75
|
+
required?: boolean;
|
|
76
|
+
alternative?: string;
|
|
77
|
+
}>;
|
|
78
|
+
maxChars?: number;
|
|
79
|
+
}, call: StructuredCallLike): Promise<OutcomeCheckV1>;
|
|
80
|
+
export declare const OUTCOME_PER_CLASS_JUDGE: {
|
|
81
|
+
name: string;
|
|
82
|
+
kind: "model";
|
|
83
|
+
};
|
|
84
|
+
export type OutcomeVerdictV1 = 'delivered' | 'missing' | 'unknown';
|
|
85
|
+
export type OutcomeExpectationKindV1 = 'delivered' | 'named-missing' | 'asked-which';
|
|
86
|
+
/** What one class is expected to be in the answer, with the words the question is built from. */
|
|
87
|
+
export interface OutcomeExpectationV1 {
|
|
88
|
+
iri: string;
|
|
89
|
+
label: string;
|
|
90
|
+
required?: boolean;
|
|
91
|
+
alternative?: string;
|
|
92
|
+
/** The class's `rdfs:comment` — what a complete one IS, in the ontology's words. */
|
|
93
|
+
comment?: string;
|
|
94
|
+
/** The fields its shape requires (`sh:minCount 1`, by `sh:name`) — what a complete one HAS. */
|
|
95
|
+
requiredFields?: string[];
|
|
96
|
+
/** The shape's other fields — what a GOOD one also has (quality, never pass/fail). */
|
|
97
|
+
qualityFields?: string[];
|
|
98
|
+
/** delivered (default) · named-missing (W2 `missing`) · asked-which (W2 `behaviour: clarify`). */
|
|
99
|
+
kind?: OutcomeExpectationKindV1;
|
|
100
|
+
}
|
|
101
|
+
export interface OutcomeUnitVerdictV1 extends OutcomeUnitV1 {
|
|
102
|
+
verdict: OutcomeVerdictV1;
|
|
103
|
+
}
|
|
104
|
+
export interface OutcomePerClassV1 {
|
|
105
|
+
judge: typeof OUTCOME_PER_CLASS_JUDGE;
|
|
106
|
+
/** Per class: P(delivered) from its own call (0 when the verdict is unknown — read `verdicts` before this). */
|
|
107
|
+
classes: Record<string, number>;
|
|
108
|
+
requested: Record<string, number>;
|
|
109
|
+
verdicts: Record<string, OutcomeVerdictV1>;
|
|
110
|
+
units: OutcomeUnitVerdictV1[];
|
|
111
|
+
/** Mean P(delivered) over the counted units WITH a verdict; 0 when none has one (and `counted` says so). */
|
|
112
|
+
score: number;
|
|
113
|
+
/** How many counted units had a verdict (the denominator) and how many were cantTell (out of it, reported). */
|
|
114
|
+
counted: number;
|
|
115
|
+
cantTell: number;
|
|
116
|
+
/** Judge calls made (one per class + one for the request). */
|
|
117
|
+
calls: number;
|
|
118
|
+
ms: number;
|
|
119
|
+
error?: string;
|
|
120
|
+
}
|
|
121
|
+
/** The question for one class, from the ontology's own words. Pure, so the prompt is a function of the class. */
|
|
122
|
+
export declare function outcomeQuestionOf(c: OutcomeExpectationV1): string;
|
|
123
|
+
export declare function judgeOutcomePerClass(input: {
|
|
124
|
+
request: string;
|
|
125
|
+
answer: string;
|
|
126
|
+
expected: ReadonlyArray<OutcomeExpectationV1>;
|
|
127
|
+
maxChars?: number;
|
|
128
|
+
}, call: StructuredCallLike): Promise<OutcomePerClassV1>;
|
|
129
|
+
//# sourceMappingURL=answer-quality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-quality.d.ts","sourceRoot":"","sources":["../src/answer-quality.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAO,MAAM,oBAAoB;;;CAAiE,CAAC;AAEnG,wHAAwH;AACxH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAMlF,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,oBAAoB,CAAC;IACnC,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IAC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AC;CACjC;AACD,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IAAG,OAAO,EAAE,gBAAgB,CAAA;CAAE;AACzF,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,uBAAuB,CAAC;IACtC,+GAA+G;IAC/G,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,4GAA4G;IAC5G,KAAK,EAAE,MAAM,CAAC;IACd,+GAA+G;IAC/G,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAClC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,iHAAiH;AACjH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAYjE;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA6D7M"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// ANSWER QUALITY, JUDGED — spec 416 §4h. An instruction skill's answer is scored by typed yes-no questions (J9) over one
|
|
2
|
+
// frozen state — the request, the skill's ontology card, the answer — so a faster or cheaper way of answering can be
|
|
3
|
+
// traded against quality with evidence, not taste. Numbers only leave (J7): the per-question probabilities and their
|
|
4
|
+
// mean. Evidence, never authority (J1): nothing reads the score to permit or refuse anything.
|
|
5
|
+
import { judgeQuestions, judgeQuestionsAveraged, structuredCallDecisionModel } from './judgment.js';
|
|
6
|
+
export const ANSWER_QUALITY_JUDGE = { name: 'ap.answer-quality-judge.v1', kind: 'model' };
|
|
7
|
+
/** The rubric: each a statement the judge gives P(true) for. Stable ids — a changed rubric is a new judge name (J5). */
|
|
8
|
+
export const ANSWER_QUALITY_RUBRIC = [
|
|
9
|
+
{ id: 'answers', statement: 'The answer addresses what the request actually asks for, not a neighbouring task.' },
|
|
10
|
+
{ id: 'method', statement: 'The answer follows the skill\'s method and produces what the skill says it produces.' },
|
|
11
|
+
{ id: 'grounded', statement: 'The answer states no specific facts about the organization (names, figures, dates) that the request did not give, or marks each such fact as a placeholder to confirm.' },
|
|
12
|
+
{ id: 'asks', statement: 'Where the request lacks information the skill needs, the answer says what is needed instead of inventing it (true if nothing was missing).' },
|
|
13
|
+
{ id: 'usable', statement: 'A person could act on this answer as it stands, without rewriting it.' },
|
|
14
|
+
];
|
|
15
|
+
/** Judge one answer. The answer is truncated to `maxChars` (the judge reads a bounded state). */
|
|
16
|
+
export async function judgeAnswerQuality(input, call) {
|
|
17
|
+
const t0 = Date.now();
|
|
18
|
+
const max = input.maxChars ?? 8000;
|
|
19
|
+
const answer = input.answer.length > max ? `${input.answer.slice(0, max)}\n…(truncated)` : input.answer;
|
|
20
|
+
const questions = ANSWER_QUALITY_RUBRIC.map((q) => ({ id: q.id, kind: 'yes-no', statement: q.statement }));
|
|
21
|
+
const j = await judgeQuestions(`The skill: ${input.skillCard}\n\nThe request:\n${input.request}\n\nThe answer:\n${answer}`, questions, structuredCallDecisionModel(call, { name: ANSWER_QUALITY_JUDGE.name, stablePrefix: true }));
|
|
22
|
+
const scores = Object.fromEntries(Object.entries(j.answers).map(([id, a]) => [id, Number((a.distribution['true'] ?? 0).toFixed(4))]));
|
|
23
|
+
const vals = Object.values(scores);
|
|
24
|
+
return { judge: ANSWER_QUALITY_JUDGE, scores, score: vals.length ? Number((vals.reduce((a, b) => a + b, 0) / vals.length).toFixed(4)) : 0, ms: Date.now() - t0, ...(j.error !== undefined ? { error: j.error } : {}) };
|
|
25
|
+
}
|
|
26
|
+
// ── PAIRWISE PREFERENCE — a rubric scored in isolation saturates (0.97–1.00 for everything, 2026-09-27); two answers to
|
|
27
|
+
// the same request, judged side by side in BOTH orders under neutral labels and averaged (position bias cancelled), is
|
|
28
|
+
// the comparison that discriminates. Numbers only: P(first better), P(second better), P(no real difference).
|
|
29
|
+
export const ANSWER_PREFERENCE_JUDGE = { name: 'ap.answer-preference-judge.v1', kind: 'model' };
|
|
30
|
+
export async function judgeAnswerPreference(input, call) {
|
|
31
|
+
const t0 = Date.now();
|
|
32
|
+
const max = input.maxChars ?? 6000;
|
|
33
|
+
const cut = (a) => (a.length > max ? `${a.slice(0, max)}\n…(truncated)` : a);
|
|
34
|
+
const q = { id: 'better', kind: 'choice', question: 'Which answer better serves this request under this skill — more correct, more complete, better grounded, more usable?', options: Object.entries(input.answers).map(([id, a]) => ({ id, describe: cut(a).replace(/\s+/g, ' ') })), alsoOutcomes: [{ id: 'tie', describe: 'No real difference in quality.' }] };
|
|
35
|
+
const j = await judgeQuestionsAveraged(`The skill: ${input.skillCard}\n\nThe request:\n${input.request}`, [q], structuredCallDecisionModel(call, { name: ANSWER_PREFERENCE_JUDGE.name }), { permutations: 2 });
|
|
36
|
+
const a = j.answers['better'];
|
|
37
|
+
return { judge: ANSWER_PREFERENCE_JUDGE, preference: a ? { ...a.distribution } : {}, permutations: j.permutations, ms: Date.now() - t0, ...(j.error !== undefined ? { error: j.error } : {}) };
|
|
38
|
+
}
|
|
39
|
+
// ── THE OUTCOME CHECK — spec 418 / gap register A2. Not "was the right skill chosen" but "did the answer DELIVER what the
|
|
40
|
+
// request asked for". The ontology says what each skill PRODUCES; the request says WHICH of those it wants. So one call asks,
|
|
41
|
+
// per candidate class of the terminal skill, "does the request ask for a <class>?" and, per class, "does the answer deliver
|
|
42
|
+
// it — or, where the request lacks the facts it needs, its structure with the missing facts named?". Intermediate artifacts
|
|
43
|
+
// the plan was built on are always required. The score is delivery over the REQUESTED classes (those asked with P ≥ 0.5;
|
|
44
|
+
// the most-asked one when none is). v2 (2026-09-28): v1 required every product, and scored a correct letter of inquiry
|
|
45
|
+
// 0.24 because the drafter also produces proposals, and a structured pipeline with its gaps named ~0.
|
|
46
|
+
// v3 (2026-10-02) — ALTERNATIVE OUTPUTS ARE SCORED ONCE. A skill can produce EITHER one class OR another (the drafter: a
|
|
47
|
+
// Letter of Inquiry or a Grant Proposal, two entries to one application; its body picks one). v2 still asked about each
|
|
48
|
+
// and, when a request read as asking for both, averaged in the one the skill was never meant to write: on chain panels
|
|
49
|
+
// 1–4 (3 repeats, Claude Haiku judging) 51 of 68 grant runs delivered exactly one and lost about a third of the score.
|
|
50
|
+
// The ontology now says which produced classes are alternatives (`alternative`, a group name from the data graph's
|
|
51
|
+
// `skills:alternativeGroup`), and the score counts UNITS: an ungrouped class is its own unit, exactly as in v2; a group
|
|
52
|
+
// is one unit, requested = the most-asked member, delivered = the best-delivered member, required if any member is. The
|
|
53
|
+
// per-class `classes` / `requested` maps keep their shape; `units` says what was scored.
|
|
54
|
+
// Numbers only; evidence, never authority (J1).
|
|
55
|
+
export const OUTCOME_CHECK_JUDGE = { name: 'ap.outcome-check-judge.v3', kind: 'model' };
|
|
56
|
+
export async function judgeOutcomeDelivered(input, call) {
|
|
57
|
+
const t0 = Date.now();
|
|
58
|
+
const max = input.maxChars ?? 9000;
|
|
59
|
+
const answer = input.answer.length > max ? `${input.answer.slice(0, max)}\n…(truncated)` : input.answer;
|
|
60
|
+
const cands = input.expected.slice(0, 8);
|
|
61
|
+
if (!cands.length)
|
|
62
|
+
return { judge: OUTCOME_CHECK_JUDGE, classes: {}, requested: {}, score: 0, ms: 0, error: 'no expected classes' };
|
|
63
|
+
const qs = [
|
|
64
|
+
// Two plain questions per class, never one compound one: a judge reading "X, or else Y" anchored on X and scored a
|
|
65
|
+
// correct template-with-gaps 0.02 (validation, 2026-09-28). Delivered = the higher of the two.
|
|
66
|
+
...cands.map((c, i) => ({ id: `d${i + 1}`, kind: 'yes-no', statement: `The answer contains a complete ${c.label}.` })),
|
|
67
|
+
...cands.map((c, i) => ({ id: `s${i + 1}`, kind: 'yes-no', statement: `The answer lays out a ${c.label}'s full structure, filled in wherever the request gave the facts, and names the facts still needed to finish it.` })),
|
|
68
|
+
...cands.flatMap((c, i) => (c.required ? [] : [{ id: `r${i + 1}`, kind: 'yes-no', statement: `The request asks for a ${c.label}.` }])),
|
|
69
|
+
];
|
|
70
|
+
const j = await judgeQuestions(`The request:\n${input.request}\n\nThe answer:\n${answer}`, qs, structuredCallDecisionModel(call, { name: OUTCOME_CHECK_JUDGE.name, stablePrefix: true }));
|
|
71
|
+
const p = (id) => Number((j.answers[id]?.distribution['true'] ?? 0).toFixed(4));
|
|
72
|
+
const classes = Object.fromEntries(cands.map((c, i) => [c.iri, Math.max(p(`d${i + 1}`), p(`s${i + 1}`))]));
|
|
73
|
+
const requested = Object.fromEntries(cands.map((c, i) => [c.iri, c.required ? 1 : p(`r${i + 1}`)]));
|
|
74
|
+
// Fold each alternative group into ONE unit (v3); an ungrouped class is its own unit, so v2's arithmetic is unchanged.
|
|
75
|
+
const byId = new Map();
|
|
76
|
+
for (const c of cands) {
|
|
77
|
+
const id = c.alternative ? `alternative:${c.alternative}` : c.iri;
|
|
78
|
+
const u = byId.get(id) ?? (byId.set(id, { id, members: [], requested: 0, delivered: 0, counted: false }).get(id));
|
|
79
|
+
u.members.push(c.iri);
|
|
80
|
+
u.requested = Math.max(u.requested, requested[c.iri]);
|
|
81
|
+
u.delivered = Math.max(u.delivered, classes[c.iri]);
|
|
82
|
+
if (c.required)
|
|
83
|
+
u.required = true;
|
|
84
|
+
}
|
|
85
|
+
const units = [...byId.values()];
|
|
86
|
+
let counted = units.filter((u) => u.requested >= 0.5);
|
|
87
|
+
if (!counted.some((u) => !u.required)) {
|
|
88
|
+
const optional = units.filter((u) => !u.required).sort((a, b) => b.requested - a.requested);
|
|
89
|
+
if (optional[0])
|
|
90
|
+
counted = [...counted, optional[0]];
|
|
91
|
+
}
|
|
92
|
+
for (const u of counted)
|
|
93
|
+
u.counted = true;
|
|
94
|
+
const vals = counted.map((u) => u.delivered);
|
|
95
|
+
return { judge: OUTCOME_CHECK_JUDGE, classes, requested, units, score: vals.length ? Number((vals.reduce((a, b) => a + b, 0) / vals.length).toFixed(4)) : 0, ms: Date.now() - t0, ...(j.error !== undefined ? { error: j.error } : {}) };
|
|
96
|
+
}
|
|
97
|
+
// ── THE OUTCOME, ONE CLASS PER CALL — v4 (2026-10-14, "evals article gap" W4). v3 asked ONE call about every class at
|
|
98
|
+
// once (up to 8 classes, 2–3 questions each): one judge call grading several dimensions, which is the thing the article
|
|
99
|
+
// says not to do, and a judge that could not read the answer still had to put a number on every class. v4 asks the
|
|
100
|
+
// judge ONE QUESTION PER CLASS, each in its own call, with the class's own words — its `rdfs:comment` and the fields its
|
|
101
|
+
// SHACL shape requires (W3 hands these over) — and lets it say UNKNOWN. Unknown is earl:cantTell: counted, reported, and
|
|
102
|
+
// OUT of the denominator (a judge that cannot read an answer must not score it 0 or 1). The "which classes does the
|
|
103
|
+
// request ask for" question is about the REQUEST, not the answer, so it stays one call of its own, as before.
|
|
104
|
+
//
|
|
105
|
+
// What a class EXPECTS depends on the gold (W2): a class the plan PRODUCES must be delivered; a class the gold names
|
|
106
|
+
// MISSING must be NAMED as missing (asked for, never invented); a clarify case must ASK WHICH option. The units, the
|
|
107
|
+
// alternative groups and the arithmetic are v3's; only the questions and the cantTell verdict are new.
|
|
108
|
+
export const OUTCOME_PER_CLASS_JUDGE = { name: 'ap.outcome-per-class-judge.v4', kind: 'model' };
|
|
109
|
+
/** The question for one class, from the ontology's own words. Pure, so the prompt is a function of the class. */
|
|
110
|
+
export function outcomeQuestionOf(c) {
|
|
111
|
+
const what = c.comment ? ` ${c.comment.trim().replace(/\s+/g, ' ')}` : '';
|
|
112
|
+
const has = c.requiredFields?.length ? ` A complete one has: ${c.requiredFields.join(', ')}.` : '';
|
|
113
|
+
const good = c.qualityFields?.length ? ` A good one also has: ${c.qualityFields.join(', ')}.` : '';
|
|
114
|
+
switch (c.kind ?? 'delivered') {
|
|
115
|
+
case 'named-missing':
|
|
116
|
+
return `The right answer NAMES the ${c.label} as missing — says it needs it, asks for it, or leaves a marked placeholder — instead of inventing one.${what} Does the answer do that?`;
|
|
117
|
+
case 'asked-which':
|
|
118
|
+
return `The right answer ASKS the person which of the named options they mean, instead of choosing one for them. Does the answer ask which?`;
|
|
119
|
+
default:
|
|
120
|
+
return `Does the answer deliver a ${c.label}?${what}${has}${good} "Delivered" means the answer contains a complete ${c.label}, or lays out its full structure filled in wherever the request gave the facts and names the facts still needed.`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export async function judgeOutcomePerClass(input, call) {
|
|
124
|
+
const t0 = Date.now();
|
|
125
|
+
const max = input.maxChars ?? 9000;
|
|
126
|
+
const answer = input.answer.length > max ? `${input.answer.slice(0, max)}\n…(truncated)` : input.answer;
|
|
127
|
+
const cands = input.expected.slice(0, 8);
|
|
128
|
+
if (!cands.length)
|
|
129
|
+
return { judge: OUTCOME_PER_CLASS_JUDGE, classes: {}, requested: {}, verdicts: {}, units: [], score: 0, counted: 0, cantTell: 0, calls: 0, ms: 0, error: 'no expected classes' };
|
|
130
|
+
const port = structuredCallDecisionModel(call, { name: OUTCOME_PER_CLASS_JUDGE.name, stablePrefix: true });
|
|
131
|
+
const state = `The request:\n${input.request}\n\nThe answer:\n${answer}`;
|
|
132
|
+
const errors = [];
|
|
133
|
+
const classes = {};
|
|
134
|
+
const verdicts = {};
|
|
135
|
+
let calls = 0;
|
|
136
|
+
// ONE CLASS PER CALL. Sequential, so the wall time is the sum (the post-run phase subtracts it) and the provider's
|
|
137
|
+
// prompt cache sees one stable prefix; the answer is the same bytes in every call.
|
|
138
|
+
for (const c of cands) {
|
|
139
|
+
const q = { id: 'd', kind: 'choice', question: outcomeQuestionOf(c), options: [
|
|
140
|
+
{ id: 'delivered', describe: c.kind === 'named-missing' ? 'the answer names it as missing and asks for it' : c.kind === 'asked-which' ? 'the answer asks which option is meant' : `the answer delivers a ${c.label} (complete, or its full structure with the missing facts named)` },
|
|
141
|
+
{ id: 'missing', describe: c.kind === 'named-missing' ? 'the answer invents it or does not mention it' : c.kind === 'asked-which' ? 'the answer chooses an option or does neither' : `the answer does not deliver a ${c.label}` },
|
|
142
|
+
], notApplicable: 'unknown — the answer cannot be read well enough to tell (empty, cut off, not about this request, or unreadable)' };
|
|
143
|
+
calls++;
|
|
144
|
+
const j = await judgeQuestions(state, [q], port);
|
|
145
|
+
if (j.error !== undefined)
|
|
146
|
+
errors.push(`${c.label}: ${j.error}`);
|
|
147
|
+
const a = j.answers['d'];
|
|
148
|
+
const top = a?.top;
|
|
149
|
+
verdicts[c.iri] = top === 'delivered' || top === 'missing' ? top : 'unknown';
|
|
150
|
+
classes[c.iri] = verdicts[c.iri] === 'unknown' ? 0 : Number((a.distribution['delivered'] ?? 0).toFixed(4));
|
|
151
|
+
}
|
|
152
|
+
// THE REQUEST's question, once: which of the optional classes it asks for (a required one is asked for by construction).
|
|
153
|
+
const optional = cands.filter((c) => !c.required);
|
|
154
|
+
const requested = Object.fromEntries(cands.map((c) => [c.iri, c.required ? 1 : 0]));
|
|
155
|
+
if (optional.length) {
|
|
156
|
+
calls++;
|
|
157
|
+
const rq = await judgeQuestions(`The request:\n${input.request}`, optional.map((c, i) => ({ id: `r${i + 1}`, kind: 'yes-no', statement: `The request asks for a ${c.label}.` })), port);
|
|
158
|
+
if (rq.error !== undefined)
|
|
159
|
+
errors.push(`request: ${rq.error}`);
|
|
160
|
+
optional.forEach((c, i) => { requested[c.iri] = Number((rq.answers[`r${i + 1}`]?.distribution['true'] ?? 0).toFixed(4)); });
|
|
161
|
+
}
|
|
162
|
+
// v3's units: an alternative group is ONE unit (requested = most-asked member, delivered = best member, verdict = the
|
|
163
|
+
// best member's); an ungrouped class is its own unit.
|
|
164
|
+
const byId = new Map();
|
|
165
|
+
for (const c of cands) {
|
|
166
|
+
const id = c.alternative ? `alternative:${c.alternative}` : c.iri;
|
|
167
|
+
const u = byId.get(id) ?? (byId.set(id, { id, members: [], requested: 0, delivered: 0, counted: false, verdict: 'unknown' }).get(id));
|
|
168
|
+
u.members.push(c.iri);
|
|
169
|
+
u.requested = Math.max(u.requested, requested[c.iri]);
|
|
170
|
+
const v = verdicts[c.iri];
|
|
171
|
+
// A group's verdict: delivered if any member was; else missing if any member was read as missing; else unknown.
|
|
172
|
+
if (v === 'delivered' && (u.verdict !== 'delivered' || classes[c.iri] > u.delivered)) {
|
|
173
|
+
u.verdict = 'delivered';
|
|
174
|
+
u.delivered = Math.max(u.delivered, classes[c.iri]);
|
|
175
|
+
}
|
|
176
|
+
else if (v === 'missing' && u.verdict === 'unknown')
|
|
177
|
+
u.verdict = 'missing';
|
|
178
|
+
if (v !== 'unknown')
|
|
179
|
+
u.delivered = Math.max(u.delivered, classes[c.iri]);
|
|
180
|
+
if (c.required)
|
|
181
|
+
u.required = true;
|
|
182
|
+
}
|
|
183
|
+
const units = [...byId.values()];
|
|
184
|
+
let counted = units.filter((u) => u.requested >= 0.5);
|
|
185
|
+
if (!counted.some((u) => !u.required)) {
|
|
186
|
+
const opt = units.filter((u) => !u.required).sort((a, b) => b.requested - a.requested);
|
|
187
|
+
if (opt[0])
|
|
188
|
+
counted = [...counted, opt[0]];
|
|
189
|
+
}
|
|
190
|
+
for (const u of counted)
|
|
191
|
+
u.counted = true;
|
|
192
|
+
const known = counted.filter((u) => u.verdict !== 'unknown');
|
|
193
|
+
const cantTell = counted.length - known.length;
|
|
194
|
+
const vals = known.map((u) => u.delivered);
|
|
195
|
+
return { judge: OUTCOME_PER_CLASS_JUDGE, classes, requested, verdicts, units, score: vals.length ? Number((vals.reduce((a, b) => a + b, 0) / vals.length).toFixed(4)) : 0, counted: known.length, cantTell, calls, ms: Date.now() - t0, ...(errors.length ? { error: errors.join(' | ').slice(0, 300) } : {}) };
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=answer-quality.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer-quality.js","sourceRoot":"","sources":["../src/answer-quality.ts"],"names":[],"mappings":"AAAA,yHAAyH;AACzH,qHAAqH;AACrH,qHAAqH;AACrH,8FAA8F;AAC9F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,2BAA2B,EAA2B,MAAM,eAAe,CAAC;AAG7H,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,OAAgB,EAAE,CAAC;AAEnG,wHAAwH;AACxH,MAAM,CAAC,MAAM,qBAAqB,GAAqD;IACrF,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,mFAAmF,EAAE;IACjH,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,sFAAsF,EAAE;IACnH,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,wKAAwK,EAAE;IACvM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,4IAA4I,EAAE;IACvK,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,uEAAuE,EAAE;CACrG,CAAC;AAYF,iGAAiG;AACjG,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,KAAgF,EAAE,IAAwB;IACjJ,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACtB,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IACxG,MAAM,SAA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AAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AAClT,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ApprovalBindingV1, ApprovalVerifier, DecisionEvidence, Obligation, PrincipalFactsPort, ResolvedStep, VerifiedApprovalV1 } from './authority.js';
|
|
2
|
+
/** `0x` + SHA-256 over the canonical JSON of the binding — what an approver signs, and what a verifier recomputes. */
|
|
3
|
+
export declare function approvalDigest(binding: ApprovalBindingV1): Promise<`0x${string}`>;
|
|
4
|
+
/**
|
|
5
|
+
* THE binding an approval of this step is signed over — computed here for the loop and exported so a host computes the
|
|
6
|
+
* same one (to show it, to put its digest beside a mandate's in one signature). Spec 448 §0 (N-1 review R2-2):
|
|
7
|
+
* - Under a plan-bound, single-use mandate (the verifier's `countedUnder`; for a hand-off in the member form, the
|
|
8
|
+
* PARENT's — `evidence.member.countedUnder`) the approval names that mandate, and the run is named BY it
|
|
9
|
+
* (`runRef` = `mandate:<ref>`): never a presenter-supplied field. The member form binds the parent plan and the parent's
|
|
10
|
+
* step, so the one approval she gave at the parent is what the specialist judges — and it is useless under any other
|
|
11
|
+
* mandate, even one over the same plan.
|
|
12
|
+
* - Otherwise (a self-acting step; an act counted on chain or by a per-request challenge) it names the presented
|
|
13
|
+
* mandate's reference (`self` for a self-acting step) and the host's run reference (`anchor: 'run'`): a new run may use
|
|
14
|
+
* that reference only once (`OrchestrationPorts.runRefs`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function approvalBindingFor(input: {
|
|
17
|
+
step: ResolvedStep;
|
|
18
|
+
planDigest: string;
|
|
19
|
+
evidence?: DecisionEvidence | null;
|
|
20
|
+
obligationKind: string;
|
|
21
|
+
obligationIndex: number;
|
|
22
|
+
approver: string;
|
|
23
|
+
argsDigest?: string;
|
|
24
|
+
}): Promise<ApprovalBindingV1 | {
|
|
25
|
+
error: string;
|
|
26
|
+
}>;
|
|
27
|
+
/** The anchor of a binding: `mandate` — named by a plan-bound single-use mandate; `run` — by the host's run reference. */
|
|
28
|
+
export declare function bindingWithAnchor(input: Parameters<typeof approvalBindingFor>[0]): Promise<{
|
|
29
|
+
binding: ApprovalBindingV1;
|
|
30
|
+
anchor: 'mandate' | 'run';
|
|
31
|
+
} | {
|
|
32
|
+
error: string;
|
|
33
|
+
}>;
|
|
34
|
+
/** The approval digests a host can have the approver sign TOGETHER with a mandate (one signature — e.g. the digests an
|
|
35
|
+
* account approves in the same operation as the mandate): one per obligation she may discharge, bound exactly as the
|
|
36
|
+
* loop will bind it. `obligations` must be the step's obligations in the loop's order (verifier caveats, then policy). */
|
|
37
|
+
export declare function approvalDigestsToSign(input: {
|
|
38
|
+
step: ResolvedStep;
|
|
39
|
+
planDigest: string;
|
|
40
|
+
evidence?: DecisionEvidence | null;
|
|
41
|
+
approver: string;
|
|
42
|
+
obligations: ReadonlyArray<Pick<Obligation, 'kind'>>;
|
|
43
|
+
}): Promise<Array<{
|
|
44
|
+
purpose: string;
|
|
45
|
+
obligationIndex: number;
|
|
46
|
+
binding: ApprovalBindingV1;
|
|
47
|
+
digest: `0x${string}`;
|
|
48
|
+
}>>;
|
|
49
|
+
export type ApprovalJudgement = {
|
|
50
|
+
ok: true;
|
|
51
|
+
approved: VerifiedApprovalV1[];
|
|
52
|
+
} | {
|
|
53
|
+
ok: false;
|
|
54
|
+
reason: string;
|
|
55
|
+
};
|
|
56
|
+
/** Judge the records an approval port returned against every obligation. Pure apart from the verifier and facts calls. */
|
|
57
|
+
export declare function judgeApprovals(input: {
|
|
58
|
+
obligations: Obligation[];
|
|
59
|
+
records: unknown;
|
|
60
|
+
step: ResolvedStep;
|
|
61
|
+
planDigest: string;
|
|
62
|
+
evidence: DecisionEvidence;
|
|
63
|
+
verifier: ApprovalVerifier;
|
|
64
|
+
/** Spec 448 §0 (N-1) — sourced facts about the principal; see `OrchestrationPorts.principalFacts`. */
|
|
65
|
+
principalFacts?: PrincipalFactsPort;
|
|
66
|
+
/** Spec 448 §0 (review M-1) — a SELF-ACTING step (no chain): the principal whose authority it spends, judged as the root. */
|
|
67
|
+
selfPrincipal?: string;
|
|
68
|
+
/** Spec 448 §0 (R2-2) — the loop's word that this run's reference is FRESH (generated by the loop, begun in the
|
|
69
|
+
* run-reference ledger, or a checkpoint resume of one). An approval anchored on the run reference alone is refused
|
|
70
|
+
* otherwise. */
|
|
71
|
+
runRefFresh?: boolean;
|
|
72
|
+
}): Promise<ApprovalJudgement>;
|
|
73
|
+
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../src/approval.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,gBAAgB,EAAmB,gBAAgB,EAA4B,UAAU,EAAE,kBAAkB,EAAoB,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAQ7O,sHAAsH;AACtH,wBAAsB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAEvF;AAID;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAA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