@principles/core 1.287.8 → 1.288.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/runtime-v2/adapter/output-schema-registry.d.ts.map +1 -1
  2. package/dist/runtime-v2/adapter/output-schema-registry.js +4 -0
  3. package/dist/runtime-v2/adapter/output-schema-registry.js.map +1 -1
  4. package/dist/runtime-v2/config/index.d.ts +2 -2
  5. package/dist/runtime-v2/config/index.d.ts.map +1 -1
  6. package/dist/runtime-v2/config/index.js +1 -1
  7. package/dist/runtime-v2/config/index.js.map +1 -1
  8. package/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -1
  9. package/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  10. package/dist/runtime-v2/config/pd-config-defaults.js +11 -0
  11. package/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  12. package/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  13. package/dist/runtime-v2/config/pd-config-effective.js +19 -1
  14. package/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  15. package/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  16. package/dist/runtime-v2/config/pd-config-redaction.js +2 -0
  17. package/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  18. package/dist/runtime-v2/config/pd-config-types.d.ts +39 -0
  19. package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  20. package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  21. package/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  22. package/dist/runtime-v2/config/pd-config-validate.js +44 -0
  23. package/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  24. package/dist/runtime-v2/index.d.ts +6 -1
  25. package/dist/runtime-v2/index.d.ts.map +1 -1
  26. package/dist/runtime-v2/index.js +9 -1
  27. package/dist/runtime-v2/index.js.map +1 -1
  28. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts +8 -9
  29. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  30. package/dist/runtime-v2/pain-signal-runtime-factory.js +69 -35
  31. package/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  32. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts +40 -0
  33. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts.map +1 -0
  34. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js +97 -0
  35. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js.map +1 -0
  36. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts +111 -0
  37. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -0
  38. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js +230 -0
  39. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js.map +1 -0
  40. package/dist/telemetry-event.d.ts +2 -2
  41. package/dist/telemetry-event.d.ts.map +1 -1
  42. package/dist/telemetry-event.js +6 -0
  43. package/dist/telemetry-event.js.map +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,40 @@
1
+ /** Registry key for OUTPUT_SCHEMA_REGISTRY (adapter-side validation). */
2
+ export declare const REUSE_EVALUATION_OUTPUT_SCHEMA_REF = "reuse-evaluation-output-v1";
3
+ export declare const ReuseEvaluationRecommendationSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"reuse">, import("@sinclair/typebox").TLiteral<"create">, import("@sinclair/typebox").TLiteral<"uncertain">]>;
4
+ export interface ReuseEvaluationOutputV1 {
5
+ /** A RECOMMENDATION for the Owner — never a decision. */
6
+ recommendation: 'reuse' | 'create' | 'uncertain';
7
+ /** REQUIRED when recommendation=reuse; FORBIDDEN when uncertain. */
8
+ selectedPrincipleId?: string;
9
+ rationale: string;
10
+ confidence: number;
11
+ }
12
+ export declare const ReuseEvaluationOutputV1Schema: import("@sinclair/typebox").TObject<{
13
+ recommendation: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"reuse">, import("@sinclair/typebox").TLiteral<"create">, import("@sinclair/typebox").TLiteral<"uncertain">]>;
14
+ selectedPrincipleId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
15
+ rationale: import("@sinclair/typebox").TString;
16
+ confidence: import("@sinclair/typebox").TNumber;
17
+ }>;
18
+ export type ReuseEvaluationValidation = {
19
+ ok: true;
20
+ output: ReuseEvaluationOutputV1;
21
+ } | {
22
+ ok: false;
23
+ reason: string;
24
+ };
25
+ /**
26
+ * Runtime validation for the evaluation output (rc-1/rc-2/rc-3).
27
+ *
28
+ * Pure function, never throws. Returns the FIRST failure reason:
29
+ * - non-object input → `evaluation_is_not_an_object`
30
+ * - any key outside the closed field set → `unknown_field:<key>` (T7a)
31
+ * - schema violation (bad recommendation value, empty rationale,
32
+ * confidence out of [0,1], empty/non-string selectedPrincipleId) →
33
+ * `schema_validation_failed:<details>`
34
+ * - `recommendation=reuse` without `selectedPrincipleId` →
35
+ * `reuse_without_principle_id`
36
+ * - `recommendation=uncertain` WITH `selectedPrincipleId` →
37
+ * `uncertain_with_principle_id`
38
+ */
39
+ export declare function validateReuseEvaluationOutput(raw: unknown): ReuseEvaluationValidation;
40
+ //# sourceMappingURL=reuse-evaluation-output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuse-evaluation-output.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/principle-reuse/reuse-evaluation-output.ts"],"names":[],"mappings":"AA2BA,yEAAyE;AACzE,eAAO,MAAM,kCAAkC,+BAA+B,CAAC;AAE/E,eAAO,MAAM,mCAAmC,wLAI9C,CAAC;AAEH,MAAM,WAAW,uBAAuB;IACtC,yDAAyD;IACzD,cAAc,EAAE,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;IACjD,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,6BAA6B;;;;;EAKxC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GACjC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,uBAAuB,CAAA;CAAE,GAC7C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAalC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,yBAAyB,CAqCrF"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Reuse Evaluation Output — the Semantic Reuse Evaluation Capability's
3
+ * proposal contract (PRI-917 SPEC v0.3.2 §4.2).
4
+ *
5
+ * This is a PROPOSAL-ONLY contract: it is what the LLM-backed evaluation
6
+ * returns to the Owner's review surface, never what it can do. The word
7
+ * "decision" deliberately does NOT appear here — in the reuse chain,
8
+ * "decision" belongs exclusively to the Owner; this layer can only
9
+ * recommend (SPEC v0.3.2 §3 naming boundary).
10
+ *
11
+ * Pure contract + runtime validator, zero I/O. The runtime validator is the
12
+ * trust boundary for an UNTRUSTED LLM output (rc-1/rc-2/rc-3):
13
+ * - closed field set: ANY key outside the schema is rejected, so a model
14
+ * output can never smuggle persistence-ish fields (`reuseEvidence`,
15
+ * `write`, `persist`, ...) — T7a of SPEC v0.3.2 §11;
16
+ * - cross-field rules: `recommendation=reuse` REQUIRES
17
+ * `selectedPrincipleId`; `recommendation=uncertain` FORBIDS it.
18
+ *
19
+ * Deliberate deviation from SPEC v0.3.2 §4.2 ("合法 UUID 形状"): the
20
+ * validator does NOT assert a UUID shape on `selectedPrincipleId`, because
21
+ * bootstrap core principles carry `T-xx` ids in the live ledger — a UUID
22
+ * assertion would wrongly reject them as reuse targets. Existence of the id
23
+ * is enforced one layer up, against the actual shortlist (INV-R08).
24
+ */
25
+ import { Type } from '@sinclair/typebox';
26
+ import { Value } from '@sinclair/typebox/value';
27
+ /** Registry key for OUTPUT_SCHEMA_REGISTRY (adapter-side validation). */
28
+ export const REUSE_EVALUATION_OUTPUT_SCHEMA_REF = 'reuse-evaluation-output-v1';
29
+ export const ReuseEvaluationRecommendationSchema = Type.Union([
30
+ Type.Literal('reuse'),
31
+ Type.Literal('create'),
32
+ Type.Literal('uncertain'),
33
+ ]);
34
+ export const ReuseEvaluationOutputV1Schema = Type.Object({
35
+ recommendation: ReuseEvaluationRecommendationSchema,
36
+ selectedPrincipleId: Type.Optional(Type.String({ minLength: 1 })),
37
+ rationale: Type.String({ minLength: 1 }),
38
+ confidence: Type.Number({ minimum: 0, maximum: 1 }),
39
+ });
40
+ function isRecord(value) {
41
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
42
+ }
43
+ const ALLOWED_KEYS = new Set([
44
+ 'recommendation',
45
+ 'selectedPrincipleId',
46
+ 'rationale',
47
+ 'confidence',
48
+ ]);
49
+ /**
50
+ * Runtime validation for the evaluation output (rc-1/rc-2/rc-3).
51
+ *
52
+ * Pure function, never throws. Returns the FIRST failure reason:
53
+ * - non-object input → `evaluation_is_not_an_object`
54
+ * - any key outside the closed field set → `unknown_field:<key>` (T7a)
55
+ * - schema violation (bad recommendation value, empty rationale,
56
+ * confidence out of [0,1], empty/non-string selectedPrincipleId) →
57
+ * `schema_validation_failed:<details>`
58
+ * - `recommendation=reuse` without `selectedPrincipleId` →
59
+ * `reuse_without_principle_id`
60
+ * - `recommendation=uncertain` WITH `selectedPrincipleId` →
61
+ * `uncertain_with_principle_id`
62
+ */
63
+ export function validateReuseEvaluationOutput(raw) {
64
+ if (!isRecord(raw)) {
65
+ return { ok: false, reason: 'evaluation_is_not_an_object' };
66
+ }
67
+ for (const key of Object.keys(raw)) {
68
+ if (!ALLOWED_KEYS.has(key)) {
69
+ return { ok: false, reason: `unknown_field:${key}` };
70
+ }
71
+ }
72
+ if (!Value.Check(ReuseEvaluationOutputV1Schema, raw)) {
73
+ const details = [...Value.Errors(ReuseEvaluationOutputV1Schema, raw)]
74
+ .slice(0, 5)
75
+ .map((e) => `${e.path || '/'}: ${e.message}`)
76
+ .join('; ');
77
+ return { ok: false, reason: `schema_validation_failed:${details}` };
78
+ }
79
+ const { recommendation, rationale, confidence } = raw;
80
+ const selected = raw.selectedPrincipleId;
81
+ if (recommendation === 'reuse' && (typeof selected !== 'string' || selected.trim() === '')) {
82
+ return { ok: false, reason: 'reuse_without_principle_id' };
83
+ }
84
+ if (recommendation === 'uncertain' && typeof selected === 'string' && selected.trim() !== '') {
85
+ return { ok: false, reason: 'uncertain_with_principle_id' };
86
+ }
87
+ return {
88
+ ok: true,
89
+ output: {
90
+ recommendation,
91
+ rationale,
92
+ confidence,
93
+ ...(typeof selected === 'string' && selected.trim() !== '' ? { selectedPrincipleId: selected } : {}),
94
+ },
95
+ };
96
+ }
97
+ //# sourceMappingURL=reuse-evaluation-output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuse-evaluation-output.js","sourceRoot":"","sources":["../../../src/runtime-v2/principle-reuse/reuse-evaluation-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,CAAC,MAAM,kCAAkC,GAAG,4BAA4B,CAAC;AAE/E,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC5D,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACrB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACtB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;CAC1B,CAAC,CAAC;AAWH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC,MAAM,CAAC;IACvD,cAAc,EAAE,mCAAmC;IACnD,mBAAmB,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,SA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CAAC,CAAC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;aAC5C,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,4BAA4B,OAAO,EAAE,EAAE,CAAC;IACtE,CAAC;IACD,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,GAIjD,CAAC;IACF,MAAM,QAAQ,GAAG,GAAG,CAAC,mBAAmB,CAAC;IACzC,IAAI,cAAc,KAAK,OAAO,IAAI,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;QAC3F,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC;IAC7D,CAAC;IACD,IAAI,cAAc,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7F,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,6BAA6B,EAAE,CAAC;IAC9D,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,MAAM,EAAE;YACN,cAAc;YACd,SAAS;YACT,UAAU;YACV,GAAG,CAAC,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrG;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * ReuseEvaluationRunner — the Semantic Reuse Evaluation Capability's execution
3
+ * path (PRI-917 SPEC v0.3.2 §7, Phase 3C-3).
4
+ *
5
+ * A PROPOSAL-ONLY runner. It compares a candidate against a bounded shortlist
6
+ * of existing Principles and returns a RECOMMENDATION. It has no path to any
7
+ * ledger writer: this module imports no ledger mutation API, and nothing here
8
+ * can create, modify, or record a Principle. The Owner decides (SPEC §5).
9
+ *
10
+ * Design constraints honoured here (SPEC §7):
11
+ * - ALL LLM execution goes through the injected PDRuntimeAdapter. This
12
+ * module creates no client, no inference abstraction, and no provider
13
+ * seam of its own; the repair loop drives the SAME adapter.
14
+ * - Structured output repair reuses `structured-output-repair` (the
15
+ * runtime-agnostic loop) with an adapter-backed `llmCaller`.
16
+ * - The output contract is the Phase 3C-1 schema, and the Phase 3C-1
17
+ * validator is the trust boundary (closed field set + cross-field rules).
18
+ *
19
+ * Failure is always fail-closed and observable: a timed-out run, unparsable
20
+ * output, or a payload that still violates the contract after repair throws a
21
+ * {@link ReuseEvaluationError}. It NEVER degrades into "no candidates, so
22
+ * create" — that is the caller's (review surface's) decision, not this
23
+ * runner's silent default (SPEC §9).
24
+ */
25
+ import type { PDRuntimeAdapter } from '../runtime-protocol.js';
26
+ import { type ReuseEvaluationOutputV1 } from './reuse-evaluation-output.js';
27
+ /** The candidate's semantic claim — the same claim intake resolves (4b/4c). */
28
+ export interface ReuseEvaluationCandidateInput {
29
+ text: string;
30
+ triggerPattern: string;
31
+ action: string;
32
+ }
33
+ /** One existing Principle from the deterministic shortlist. */
34
+ export interface ReuseEvaluationShortlistEntry {
35
+ principleId: string;
36
+ text: string;
37
+ triggerPattern: string;
38
+ action: string;
39
+ }
40
+ export interface ReuseEvaluationInput {
41
+ candidate: ReuseEvaluationCandidateInput;
42
+ /** Bounded Top-K from reuse-shortlist (caller guarantees ≤ 3). */
43
+ candidates: ReuseEvaluationShortlistEntry[];
44
+ }
45
+ export type ReuseEvaluationFailureReason = 'timeout' | 'run_failed' | 'output_unavailable' | 'output_invalid' | 'repair_failed';
46
+ /**
47
+ * Fail-closed error from the evaluation runner. Carries a structured reason
48
+ * and next action so the review surface can degrade OBSERVABLY (SPEC §9)
49
+ * instead of pretending the shortlist was semantically judged.
50
+ */
51
+ export declare class ReuseEvaluationError extends Error {
52
+ readonly reason: ReuseEvaluationFailureReason;
53
+ readonly nextAction: string;
54
+ readonly detail?: string;
55
+ readonly repairAttempts: number;
56
+ constructor(args: {
57
+ reason: ReuseEvaluationFailureReason;
58
+ message: string;
59
+ nextAction: string;
60
+ detail?: string;
61
+ repairAttempts?: number;
62
+ });
63
+ }
64
+ export interface ReuseEvaluationRunnerDeps {
65
+ /** The one and only LLM execution path (never constructed here). */
66
+ readonly runtimeAdapter: PDRuntimeAdapter;
67
+ }
68
+ export interface ReuseEvaluationRunnerOptions {
69
+ /** Per-run budget. Bounded polling never exceeds it. Default 30s. */
70
+ readonly timeoutMs?: number;
71
+ /** Bounded repair attempts after a contract violation. Default 1. */
72
+ readonly maxRepairAttempts?: number;
73
+ /** agentSpec label for telemetry/lineage. Not an agent registration. */
74
+ readonly agentId?: string;
75
+ /** Poll interval while waiting for the run. Default 200ms. */
76
+ readonly pollIntervalMs?: number;
77
+ }
78
+ export declare class ReuseEvaluationRunner {
79
+ private readonly runtimeAdapter;
80
+ private readonly timeoutMs;
81
+ private readonly maxRepairAttempts;
82
+ private readonly agentId;
83
+ private readonly pollIntervalMs;
84
+ constructor(deps: ReuseEvaluationRunnerDeps, options?: ReuseEvaluationRunnerOptions);
85
+ /**
86
+ * Role declaration delivered on the system channel (base-layer prompt,
87
+ * following CorrectionObserver's PRI-633 pattern). The "you recommend, the
88
+ * Owner decides" boundary is stated here so the model never narrates itself
89
+ * as a decision authority (SPEC §5).
90
+ */
91
+ static readonly SYSTEM_PROMPT: string;
92
+ /** Build the evaluation prompt (deterministic, bounded). */
93
+ static buildPrompt(input: ReuseEvaluationInput): string;
94
+ /**
95
+ * Run one semantic evaluation and return the validated RECOMMENDATION.
96
+ *
97
+ * @throws ReuseEvaluationError — timeout / run failure / unparsable output /
98
+ * contract violation surviving repair. Never a silent fallback.
99
+ */
100
+ recommend(input: ReuseEvaluationInput): Promise<ReuseEvaluationOutputV1>;
101
+ /** Bounded repair using the SAME adapter (no second LLM path). */
102
+ private repairAndValidate;
103
+ /**
104
+ * One adapter round-trip: start → bounded poll → fetch. This is the ONLY
105
+ * place the runner touches the runtime, for both the initial call and each
106
+ * repair attempt.
107
+ */
108
+ private invoke;
109
+ }
110
+ export declare function isValidReuseEvaluationOutput(value: unknown): boolean;
111
+ //# sourceMappingURL=reuse-evaluation-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuse-evaluation-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/principle-reuse/reuse-evaluation-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAStC,+EAA+E;AAC/E,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,+DAA+D;AAC/D,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,6BAA6B,CAAC;IACzC,kEAAkE;IAClE,UAAU,EAAE,6BAA6B,EAAE,CAAC;CAC7C;AAID,MAAM,MAAM,4BAA4B,GACpC,SAAS,GACT,YAAY,GACZ,oBAAoB,GACpB,gBAAgB,GAChB,eAAe,CAAC;AAEpB;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAgB,MAAM,EAAE,4BAA4B,CAAC;IACrD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,cAAc,EAAE,MAAM,C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,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE"}
@@ -0,0 +1,230 @@
1
+ import { ReuseEvaluationOutputV1Schema, validateReuseEvaluationOutput, } from './reuse-evaluation-output.js';
2
+ import { attemptStructuredOutputRepair, } from '../adapter/structured-output-repair.js';
3
+ import { Value } from '@sinclair/typebox/value';
4
+ /**
5
+ * Fail-closed error from the evaluation runner. Carries a structured reason
6
+ * and next action so the review surface can degrade OBSERVABLY (SPEC §9)
7
+ * instead of pretending the shortlist was semantically judged.
8
+ */
9
+ export class ReuseEvaluationError extends Error {
10
+ reason;
11
+ nextAction;
12
+ detail;
13
+ repairAttempts;
14
+ constructor(args) {
15
+ super(args.message);
16
+ this.name = 'ReuseEvaluationError';
17
+ this.reason = args.reason;
18
+ this.nextAction = args.nextAction;
19
+ this.detail = args.detail;
20
+ this.repairAttempts = args.repairAttempts ?? 0;
21
+ }
22
+ }
23
+ const DEFAULT_TIMEOUT_MS = 30_000;
24
+ const DEFAULT_POLL_INTERVAL_MS = 200;
25
+ const MAX_POLLED_FIELD_CHARS = 2000;
26
+ /** Bounded poll backoff (module-level: no runner state involved). */
27
+ function sleep(ms) {
28
+ return new Promise((resolve) => {
29
+ setTimeout(resolve, ms);
30
+ });
31
+ }
32
+ export class ReuseEvaluationRunner {
33
+ runtimeAdapter;
34
+ timeoutMs;
35
+ maxRepairAttempts;
36
+ agentId;
37
+ pollIntervalMs;
38
+ constructor(deps, options = {}) {
39
+ this.runtimeAdapter = deps.runtimeAdapter;
40
+ this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
41
+ this.maxRepairAttempts = options.maxRepairAttempts ?? 1;
42
+ this.agentId = options.agentId ?? 'reuse-evaluation';
43
+ this.pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
44
+ }
45
+ /**
46
+ * Role declaration delivered on the system channel (base-layer prompt,
47
+ * following CorrectionObserver's PRI-633 pattern). The "you recommend, the
48
+ * Owner decides" boundary is stated here so the model never narrates itself
49
+ * as a decision authority (SPEC §5).
50
+ */
51
+ static SYSTEM_PROMPT = [
52
+ 'You are a semantic reuse evaluator for a principles-disciple knowledge base.',
53
+ 'You compare a NEW candidate claim against EXISTING principles and RECOMMEND whether an existing principle already covers the same experience.',
54
+ 'You are a recommender, NOT a decision maker: the Owner decides. Never claim a decision was made, never instruct that a principle be written, and never emit fields outside the requested JSON shape.',
55
+ ].join(' ');
56
+ /** Build the evaluation prompt (deterministic, bounded). */
57
+ static buildPrompt(input) {
58
+ const clip = (s) => (s.length > MAX_POLLED_FIELD_CHARS ? `${s.slice(0, MAX_POLLED_FIELD_CHARS)}…` : s);
59
+ const candidateBlock = [
60
+ ` text: ${clip(input.candidate.text)}`,
61
+ ` trigger: ${clip(input.candidate.triggerPattern)}`,
62
+ ` action: ${clip(input.candidate.action)}`,
63
+ ].join('\n');
64
+ const existingBlock = input.candidates.length === 0
65
+ ? ' (none)'
66
+ : input.candidates
67
+ .map((c, i) => [
68
+ ` [${i + 1}] principleId: ${c.principleId}`,
69
+ ` text: ${clip(c.text)}`,
70
+ ` trigger: ${clip(c.triggerPattern)}`,
71
+ ` action: ${clip(c.action)}`,
72
+ ].join('\n'))
73
+ .join('\n');
74
+ return [
75
+ '## TASK',
76
+ 'Decide whether ONE existing principle already expresses the same experience as the candidate claim.',
77
+ '',
78
+ '## Candidate claim',
79
+ candidateBlock,
80
+ '',
81
+ `## Existing principles (${input.candidates.length})`,
82
+ existingBlock,
83
+ '',
84
+ '## Rules',
85
+ '- Judge SEMANTIC coverage, not word overlap: shared vocabulary alone is NOT the same experience.',
86
+ '- recommendation=reuse: an existing principle already covers this claim. Set selectedPrincipleId to that principle\'s id (required).',
87
+ '- recommendation=create: no existing principle covers this claim; a new one is warranted.',
88
+ '- recommendation=uncertain: the evidence is genuinely ambiguous. Do NOT set selectedPrincipleId.',
89
+ '- rationale: one or two sentences naming WHY the coverage holds or fails.',
90
+ '- confidence: 0..1 in your recommendation.',
91
+ '- Emit ONLY these fields: recommendation, selectedPrincipleId (only for reuse), rationale, confidence.',
92
+ '',
93
+ 'Return strict JSON (no markdown):',
94
+ '{"recommendation": "reuse" | "create" | "uncertain", "selectedPrincipleId": string, "rationale": string, "confidence": number}',
95
+ ].join('\n');
96
+ }
97
+ /**
98
+ * Run one semantic evaluation and return the validated RECOMMENDATION.
99
+ *
100
+ * @throws ReuseEvaluationError — timeout / run failure / unparsable output /
101
+ * contract violation surviving repair. Never a silent fallback.
102
+ */
103
+ async recommend(input) {
104
+ const payload = await this.invoke(ReuseEvaluationRunner.buildPrompt(input), 'evaluate');
105
+ const validated = validateReuseEvaluationOutput(payload);
106
+ if (validated.ok) {
107
+ return validated.output;
108
+ }
109
+ // Contract violation (unknown field, bad cross-field pairing, bad types):
110
+ // the schema itself is permissive about extra keys, so this is where the
111
+ // closed field set bites. One bounded repair round, then fail closed.
112
+ return this.repairAndValidate(payload, validated.reason);
113
+ }
114
+ /** Bounded repair using the SAME adapter (no second LLM path). */
115
+ async repairAndValidate(invalidOutput, reason) {
116
+ if (this.maxRepairAttempts <= 0) {
117
+ throw new ReuseEvaluationError({
118
+ reason: 'repair_failed',
119
+ message: `Reuse evaluation output violated its contract (${reason}) and repair is disabled`,
120
+ nextAction: 'Review the evaluation output contract; repair attempts are configured to 0',
121
+ detail: reason,
122
+ });
123
+ }
124
+ const schemaErrors = [{ path: '/', message: reason, value: invalidOutput }];
125
+ const repair = await attemptStructuredOutputRepair(invalidOutput, schemaErrors, {
126
+ // The repair LLM is the SAME adapter — this callback only marshals
127
+ // prompt in and raw JSON text out.
128
+ llmCaller: async (prompt) => {
129
+ const repaired = await this.invoke(prompt, 'repair');
130
+ return JSON.stringify(repaired);
131
+ },
132
+ schemaCheck: (value) => validateReuseEvaluationOutput(value).ok,
133
+ }, {
134
+ maxRepairAttempts: this.maxRepairAttempts,
135
+ schemaRef: 'reuse-evaluation-output-v1',
136
+ schemaJson: JSON.stringify(ReuseEvaluationOutputV1Schema),
137
+ requiredKeys: ['recommendation', 'rationale', 'confidence'],
138
+ });
139
+ if (repair.repaired && repair.output) {
140
+ // The repair loop's schemaCheck is our validator, but re-validate the
141
+ // returned value explicitly: a caller-visible contract must never rely
142
+ // on a callback's internal check alone.
143
+ const revalidated = validateReuseEvaluationOutput(repair.output);
144
+ if (revalidated.ok) {
145
+ return revalidated.output;
146
+ }
147
+ }
148
+ throw new ReuseEvaluationError({
149
+ reason: 'repair_failed',
150
+ message: `Reuse evaluation output violated its contract (${reason}) and could not be repaired`,
151
+ nextAction: 'Re-run the review; if it persists, inspect the evaluation prompt/runtime output format',
152
+ detail: `${reason}; ${repair.repairSummary}`,
153
+ repairAttempts: repair.attemptsUsed,
154
+ });
155
+ }
156
+ /**
157
+ * One adapter round-trip: start → bounded poll → fetch. This is the ONLY
158
+ * place the runner touches the runtime, for both the initial call and each
159
+ * repair attempt.
160
+ */
161
+ async invoke(prompt, phase) {
162
+ const runHandle = await this.runtimeAdapter.startRun({
163
+ agentSpec: { agentId: this.agentId, schemaVersion: 'v1' },
164
+ taskRef: { taskId: `reuse_eval_${phase}_${Date.now()}` },
165
+ inputPayload: prompt,
166
+ contextItems: [],
167
+ outputSchemaRef: 'reuse-evaluation-output-v1',
168
+ timeoutMs: this.timeoutMs,
169
+ systemPrompt: ReuseEvaluationRunner.SYSTEM_PROMPT,
170
+ });
171
+ const deadline = Date.now() + this.timeoutMs;
172
+ let terminal = false;
173
+ while (Date.now() < deadline) {
174
+ const status = await this.runtimeAdapter.pollRun(runHandle.runId);
175
+ if (status.status === 'succeeded') {
176
+ terminal = true;
177
+ break;
178
+ }
179
+ if (status.status === 'failed' || status.status === 'timed_out' || status.status === 'cancelled') {
180
+ throw new ReuseEvaluationError({
181
+ reason: status.status === 'timed_out' ? 'timeout' : 'run_failed',
182
+ message: `Reuse evaluation ${phase} run finished as '${status.status}'`,
183
+ nextAction: 'Check the configured reuseEvaluation runtime profile and LLM channel health',
184
+ detail: status.reason,
185
+ });
186
+ }
187
+ await sleep(this.pollIntervalMs);
188
+ }
189
+ if (!terminal) {
190
+ try {
191
+ await this.runtimeAdapter.cancelRun(runHandle.runId);
192
+ }
193
+ catch { /* best effort: the run is already past its budget */ }
194
+ throw new ReuseEvaluationError({
195
+ reason: 'timeout',
196
+ message: `Reuse evaluation ${phase} run exceeded ${this.timeoutMs}ms`,
197
+ nextAction: 'Raise reuseEvaluation.timeoutMs or check the configured runtime profile',
198
+ });
199
+ }
200
+ let output;
201
+ try {
202
+ output = await this.runtimeAdapter.fetchOutput(runHandle.runId);
203
+ }
204
+ catch (err) {
205
+ // The adapter validates against outputSchemaRef and can also perform its
206
+ // own internal repair (pi-ai does). If it still fails, the raw text is
207
+ // unavailable for a runner-level repair — surface it fail-closed.
208
+ throw new ReuseEvaluationError({
209
+ reason: 'output_invalid',
210
+ message: `Reuse evaluation ${phase} output could not be parsed or validated by the runtime`,
211
+ nextAction: 'Inspect the runtime output format; the adapter rejected it against reuse-evaluation-output-v1',
212
+ detail: err instanceof Error ? err.message : String(err),
213
+ });
214
+ }
215
+ if (!output || output.payload === undefined || output.payload === null) {
216
+ throw new ReuseEvaluationError({
217
+ reason: 'output_unavailable',
218
+ message: `Reuse evaluation ${phase} run produced no output payload`,
219
+ nextAction: 'Re-run the review; the runtime returned an empty payload',
220
+ });
221
+ }
222
+ return output.payload;
223
+ }
224
+ }
225
+ // Re-exported for callers that want a plain boolean pre-check without
226
+ // constructing a runner (e.g. a surface deciding whether to show a warning).
227
+ export function isValidReuseEvaluationOutput(value) {
228
+ return Value.Check(ReuseEvaluationOutputV1Schema, value);
229
+ }
230
+ //# sourceMappingURL=reuse-evaluation-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reuse-evaluation-runner.js","sourceRoot":"","sources":["../../../src/runtime-v2/principle-reuse/reuse-evaluation-runner.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,GAE9B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,6BAA6B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