create-principles-disciple 1.143.4 → 1.143.5

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 (38) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/tool-semantics.d.ts +6 -3
  3. package/codex-adapter/dist/tool-semantics.js +6 -3
  4. package/codex-adapter/package.json +1 -1
  5. package/core/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.js +2 -2
  6. package/core/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder.test.js +2 -2
  7. package/core/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.d.ts +2 -0
  8. package/core/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.d.ts.map +1 -0
  9. package/core/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.js +433 -0
  10. package/core/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.js.map +1 -0
  11. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +33 -1
  12. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  13. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js +42 -2
  14. package/core/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  15. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts +10 -1
  16. package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  17. package/core/dist/runtime-v2/internalization/evaluator-runner.js +25 -1
  18. package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  19. package/core/dist/telemetry-event.d.ts +2 -2
  20. package/core/dist/telemetry-event.d.ts.map +1 -1
  21. package/core/dist/telemetry-event.js +4 -0
  22. package/core/dist/telemetry-event.js.map +1 -1
  23. package/core/package.json +1 -1
  24. package/dist/utils/env.d.ts.map +1 -1
  25. package/dist/utils/env.js +11 -2
  26. package/dist/utils/env.js.map +1 -1
  27. package/package.json +1 -1
  28. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
  29. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js +17 -4
  30. package/pd-cli/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
  31. package/pd-cli/package.json +1 -1
  32. package/plugin/dist/bundle.js +300 -300
  33. package/plugin/dist/governance-audit.js +29 -29
  34. package/plugin/dist/rulehost-evidence.js +53 -53
  35. package/release-manager/dist/utils/env.d.ts.map +1 -1
  36. package/release-manager/dist/utils/env.js +11 -2
  37. package/release-manager/dist/utils/env.js.map +1 -1
  38. package/release-manager/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "productVersion": "2.1.0",
4
- "sourceCommit": "a75c89f7bb529be3f96adb75df458c5492bd16fd"
4
+ "sourceCommit": "2d4605a339688f0fedfe94d486b106a0d02e354e"
5
5
  }
@@ -8,9 +8,12 @@
8
8
  * never fire on a real Codex event.
9
9
  *
10
10
  * EVIDENCE BOUND: this declaration contains only names with in-repo
11
- * evidence — the installer's hook matcher `Bash|apply_patch`
12
- * (create-principles-disciple/src/installers/codex-host-installer.ts:203,
13
- * locked by codex-plugin-bundle.test.ts). Extending it with the remaining
11
+ * evidence — the shipped hook matcher `Bash|apply_patch`
12
+ * (plugins/principles-disciple/hooks/hooks.json:5, locked by
13
+ * packages/codex-adapter/tests/codex-plugin-bundle.test.ts:183 and used as
14
+ * the installed-hook fixture in
15
+ * packages/create-principles-disciple/tests/codex-host-installer.test.ts
16
+ * lines 122/162/170). Extending it with the remaining
14
17
  * Codex tool surface is tracked as PRI-657 — a wrong guess would be worse
15
18
  * than a gap (the reliability check rejects undeclared names, forcing
16
19
  * correct names).
@@ -8,9 +8,12 @@
8
8
  * never fire on a real Codex event.
9
9
  *
10
10
  * EVIDENCE BOUND: this declaration contains only names with in-repo
11
- * evidence — the installer's hook matcher `Bash|apply_patch`
12
- * (create-principles-disciple/src/installers/codex-host-installer.ts:203,
13
- * locked by codex-plugin-bundle.test.ts). Extending it with the remaining
11
+ * evidence — the shipped hook matcher `Bash|apply_patch`
12
+ * (plugins/principles-disciple/hooks/hooks.json:5, locked by
13
+ * packages/codex-adapter/tests/codex-plugin-bundle.test.ts:183 and used as
14
+ * the installed-hook fixture in
15
+ * packages/create-principles-disciple/tests/codex-host-installer.test.ts
16
+ * lines 122/162/170). Extending it with the remaining
14
17
  * Codex tool surface is tracked as PRI-657 — a wrong guess would be worse
15
18
  * than a gap (the reliability check rejects undeclared names, forcing
16
19
  * correct names).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -191,8 +191,8 @@ describe('PRI-843 — evaluator prompt contract (conditional formation injection
191
191
  artificerArtifact: { taskId: ART_ID },
192
192
  scribeArtifact: scribeContent(true),
193
193
  };
194
- it('prompt contract version is v5', () => {
195
- expect(EVALUATOR_PROMPT_CONTRACT_VERSION).toBe('evaluator-output-v1.prompt.v5');
194
+ it('prompt contract version is v6', () => {
195
+ expect(EVALUATOR_PROMPT_CONTRACT_VERSION).toBe('evaluator-output-v1.prompt.v6');
196
196
  });
197
197
  it('without formationContext the payload keeps the pre-PRI-843 shape (byte-identical) and the system prompt is unchanged', () => {
198
198
  const a = builder.buildPrompt(baseInput);
@@ -54,8 +54,8 @@ describe('EvaluatorPromptBuilder', () => {
54
54
  const { promptInput } = builder.buildPrompt(input);
55
55
  expect(promptInput.promptContractVersion).toBe(EVALUATOR_PROMPT_CONTRACT_VERSION);
56
56
  });
57
- it('promptContractVersion value is evaluator-output-v1.prompt.v5 (PRI-843 formation-context anchor)', () => {
58
- expect(EVALUATOR_PROMPT_CONTRACT_VERSION).toBe('evaluator-output-v1.prompt.v5');
57
+ it('promptContractVersion value is evaluator-output-v1.prompt.v6 (PRI-644 validator re-feed anchor)', () => {
58
+ expect(EVALUATOR_PROMPT_CONTRACT_VERSION).toBe('evaluator-output-v1.prompt.v6');
59
59
  });
60
60
  it('score instruction says number not string/percentage', () => {
61
61
  expect(EVALUATOR_PROTOCOL_INSTRUCTION).toContain('NOT a string, NOT a percentage');
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=evaluator-validator-refeed.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator-validator-refeed.test.d.ts","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,433 @@
1
+ /**
2
+ * PRI-644 — evaluator consumes the existing validator-error re-feed.
3
+ *
4
+ * PRI-700 factor B already persists the verbatim validator rejections of each
5
+ * failed attempt into task.diagnosticJson (`lastValidatorErrors`) and the
6
+ * artificer is the only consumer. The evaluator's BUSINESS-layer rejections
7
+ * (e.g. the repair round missing `requirementLedger`) therefore still burned
8
+ * all retries with a byte-identical zero-information prompt → task death.
9
+ *
10
+ * Three layers here mirror the established artificer contract:
11
+ * 1. Prompt contract (builder unit): conditional re-feed block; a run
12
+ * without priorValidatorErrors keeps the payload/system prompt
13
+ * byte-identical to the pre-PRI-644 shape.
14
+ * 2. buildContext wiring (probe subclass, real stores): freshness gate
15
+ * `sourceAttemptCount === leasedAttempt - 1`; stale/no-lease records are
16
+ * suppressed with an observable event (rc-9), never silently re-fed.
17
+ * The re-feed NEVER participates in contextHash (same posture as
18
+ * artificer — replay/cache identity covers evidence, not feedback).
19
+ * 3. Golden replay (production path — RuntimeStateManager + real
20
+ * EvaluatorRunner + DefaultEvaluatorValidator, only the LLM is
21
+ * scripted): attempt 1 rejected → attempt 2 prompt carries the verbatim
22
+ * rejection reasons; attempt 1 prompt has none.
23
+ */
24
+ import { describe, it, expect, afterEach } from 'vitest';
25
+ import * as fs from 'node:fs';
26
+ import * as path from 'node:path';
27
+ import * as os from 'node:os';
28
+ import { RuntimeStateManager } from '../../store/runtime-state-manager.js';
29
+ import { EvaluatorRunner } from '../evaluator-runner.js';
30
+ import { DefaultEvaluatorValidator } from '../evaluator-output.js';
31
+ import { EvaluatorPromptBuilder, EVALUATOR_PROTOCOL_INSTRUCTION, EVALUATOR_FORMATION_EVIDENCE_ADDENDUM, EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM, } from '../evaluator-prompt-builder.js';
32
+ import { StoreEventEmitter } from '../../store/event-emitter.js';
33
+ import { SqliteConnection } from '../../store/sqlite-connection.js';
34
+ import { SqlitePIArtifactStore } from '../../store/artifact/sqlite-pi-artifact-store.js';
35
+ import { createPITaskDiagnosticJson } from '../pitask-metadata.js';
36
+ import { createProductionGateDeps } from '../../activation/production-gate-deps.js';
37
+ // ── Shared fixtures ──────────────────────────────────────────────────────────
38
+ const SCRIBE_ID = 'scribe-644';
39
+ const ART_ID = 'artificer-644';
40
+ const EVAL_ID = 'evaluator-644';
41
+ const SCRIBE_ART = 'pi-art-scribe-644';
42
+ const REJECTION_TEXT = 'evaluation.requirementLedger is required in a repair round (previous evaluation context was provided)';
43
+ function record(sourceAttemptCount, errors = [REJECTION_TEXT]) {
44
+ return {
45
+ recordedAt: '2026-09-20T00:00:00.000Z',
46
+ errorCategory: 'output_invalid',
47
+ errors,
48
+ sourceAttemptCount,
49
+ };
50
+ }
51
+ function unitRecord() {
52
+ return record(1, [REJECTION_TEXT, "evaluation.decision must be one of 'approved' | 'needs_revision' | 'rejected'"]);
53
+ }
54
+ /** Minimal in-budget FormationContext (same shape as evaluator-formation-context.test.ts). */
55
+ function unitFormationContext() {
56
+ return {
57
+ version: 'formation-context.v1',
58
+ dreamerProposals: [
59
+ {
60
+ candidateIndex: 1, priorityRank: 1,
61
+ badDecision: 'kept two sources of truth', betterDecision: 'keep one authoritative contract',
62
+ rationale: 'duplicate contracts drift', confidence: 0.9, riskLevel: 'low', strategicPerspective: null,
63
+ },
64
+ ],
65
+ dreamerContextRefs: [],
66
+ sourceDiagnosis: {
67
+ artifactId: 'diag-art-644', taskId: 'diag-644', stage: 'diag_router',
68
+ rootCause: 'retry prompts carried no validator feedback', summary: 'deterministic death loop',
69
+ violatedPrinciples: [],
70
+ evidence: [{ sourceRef: 'trajectory://session-644/turn-4', note: 'retried identically' }],
71
+ recommendations: [], confidence: 0.8, omittedFields: [],
72
+ },
73
+ provenance: {
74
+ sourceDreamerArtifactId: 'dreamer-art-644', sourceDreamerTaskId: 'dreamer-644',
75
+ sourceDiagnosisArtifactId: 'diag-art-644', sourceDiagnosisTaskId: 'diag-644',
76
+ sourcePainId: 'pain-644', lineageArtifactIds: ['diag-art-644'],
77
+ },
78
+ truncationNotes: [],
79
+ };
80
+ }
81
+ function flagsOffConfig() {
82
+ return {
83
+ config: {
84
+ version: 1,
85
+ features: {},
86
+ runtimeProfiles: {},
87
+ internalAgents: {},
88
+ ui: { diagnostics: { mode: 'simple' } },
89
+ },
90
+ source: 'user_config',
91
+ warnings: [],
92
+ resolvedContextInjection: { thinkingOs: false, projectFocus: 'off' },
93
+ };
94
+ }
95
+ function meta(o = {}) {
96
+ return createPITaskDiagnosticJson({
97
+ dependencyTaskIds: [], channel: 'prompt', timeoutMs: 300_000,
98
+ inputArtifactRefs: [], outputArtifactRefs: [], ...o,
99
+ });
100
+ }
101
+ /** diagnosticJson envelope with a top-level lastValidatorErrors record. */
102
+ function metaWithValidatorErrors(diagnostic) {
103
+ const envelope = JSON.parse(meta({ dependencyTaskIds: [ART_ID] }));
104
+ envelope.lastValidatorErrors = diagnostic;
105
+ return JSON.stringify(envelope);
106
+ }
107
+ function scribeContent() {
108
+ return {
109
+ principleId: 'refeed-644',
110
+ principleDraft: {
111
+ title: 'Feedback must reach the retry',
112
+ statement: 'A rejected output shape must be re-fed verbatim into the next attempt.',
113
+ rationale: 'Same-prompt retries are a deterministic death loop.',
114
+ applicability: ['evaluator repair rounds'],
115
+ antiPatterns: ['zero-information retry'],
116
+ confidence: 0.8,
117
+ },
118
+ };
119
+ }
120
+ function artificerOutput() {
121
+ return {
122
+ taskId: ART_ID,
123
+ sourceScribeArtifactId: SCRIBE_ART,
124
+ implementationSummary: 'refeed gate',
125
+ sourceTrace: { scribeArtifactId: SCRIBE_ART },
126
+ risks: [],
127
+ goldenTraceCases: [
128
+ { caseId: 'neg-1', kind: 'negative', toolName: 'write_file', params: { path: '/app/config.json' }, expectedDecision: 'block' },
129
+ { caseId: 'pos-1', kind: 'positive', toolName: 'write_file', params: { path: '/app/src/a.ts' }, expectedDecision: 'allow' },
130
+ ],
131
+ affectedTools: ['write_file'],
132
+ generatedAt: '2026-09-20T00:00:00.000Z',
133
+ };
134
+ }
135
+ function evaluatorOutput() {
136
+ return {
137
+ taskId: EVAL_ID,
138
+ sourceArtificerArtifactId: `pi-art-${ART_ID}-seed`,
139
+ evaluation: {
140
+ decision: 'approved',
141
+ summary: 'pri-644 golden replay',
142
+ score: 0.9,
143
+ strengths: [],
144
+ concerns: [],
145
+ requiredChanges: [],
146
+ },
147
+ sourceTrace: { artificerArtifactId: `pi-art-${ART_ID}-seed`, scribeArtifactId: SCRIBE_ART },
148
+ risks: [],
149
+ generatedAt: '2026-09-20T00:00:00.000Z',
150
+ };
151
+ }
152
+ /** Output rejected by DefaultEvaluatorValidator (decision not in enum). */
153
+ function rejectedEvaluatorOutput() {
154
+ const out = evaluatorOutput();
155
+ const evaluation = { ...out.evaluation };
156
+ delete evaluation.summary;
157
+ evaluation.decision = 'maybe';
158
+ return { ...out, evaluation };
159
+ }
160
+ let world;
161
+ async function makeWorld(evaluatorDiagnosticJson) {
162
+ const workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pd-pri644-'));
163
+ const stateManager = new RuntimeStateManager({ workspaceDir });
164
+ await stateManager.initialize();
165
+ const emitter = new StoreEventEmitter();
166
+ const emitted = [];
167
+ emitter.onTelemetry((event) => {
168
+ emitted.push({ eventType: event.eventType, payload: event.payload });
169
+ });
170
+ const store = new SqlitePIArtifactStore(new SqliteConnection(workspaceDir));
171
+ const now = '2026-09-20T00:00:00.000Z';
172
+ const mkTask = async (spec) => {
173
+ await stateManager.createTask({
174
+ taskId: spec.id, taskKind: spec.kind, status: 'pending', attemptCount: 0, maxAttempts: 3,
175
+ diagnosticJson: meta({ dependencyTaskIds: spec.deps }),
176
+ });
177
+ await stateManager.acquireLease({ taskId: spec.id, owner: 'pri644-test', runtimeKind: 'test-double' });
178
+ await stateManager.markTaskSucceeded(spec.id);
179
+ };
180
+ const upsert = (spec) => store.upsertArtifact({
181
+ artifactId: spec.artifactId, artifactKind: 'principle', sourceTaskId: spec.sourceTaskId,
182
+ lineageArtifactIds: [...spec.lineage],
183
+ validationStatus: 'pending', contentJson: JSON.stringify(spec.content), createdAt: now, updatedAt: now,
184
+ });
185
+ await mkTask({ id: SCRIBE_ID, kind: 'scribe', deps: [] });
186
+ await upsert({ artifactId: SCRIBE_ART, sourceTaskId: SCRIBE_ID, content: scribeContent(), lineage: [] });
187
+ await mkTask({ id: ART_ID, kind: 'artificer', deps: [SCRIBE_ID] });
188
+ await upsert({ artifactId: `pi-art-${ART_ID}-seed`, sourceTaskId: ART_ID, content: artificerOutput(), lineage: [SCRIBE_ART] });
189
+ await stateManager.createTask({
190
+ taskId: EVAL_ID, taskKind: 'evaluator', status: 'pending', attemptCount: 0, maxAttempts: 3,
191
+ diagnosticJson: evaluatorDiagnosticJson ?? meta({ dependencyTaskIds: [ART_ID] }),
192
+ });
193
+ return { workspaceDir, stateManager, emitter, emitted, store };
194
+ }
195
+ function closeWorld() {
196
+ if (!world)
197
+ return;
198
+ void world.stateManager.close();
199
+ try {
200
+ fs.rmSync(world.workspaceDir, { recursive: true, force: true });
201
+ }
202
+ catch { /* temp */ }
203
+ world = undefined;
204
+ }
205
+ afterEach(() => {
206
+ closeWorld();
207
+ });
208
+ /** Scripted LLM returning one payload per invocation (queue order). */
209
+ function queuedAdapter(payloads, prompts) {
210
+ let next = 0;
211
+ return {
212
+ startRun: async (req) => {
213
+ prompts.push({
214
+ message: String(req.inputPayload),
215
+ systemPrompt: typeof req.systemPrompt === 'string' ? req.systemPrompt : '',
216
+ });
217
+ return { runId: `pri644-run-${next}`, runtimeKind: 'test-double', startedAt: new Date().toISOString() };
218
+ },
219
+ pollRun: async () => ({ status: 'succeeded', runId: 'pri644-run' }),
220
+ fetchOutput: async () => ({ runId: 'pri644-run', payload: payloads[Math.min(next++, payloads.length - 1)] }),
221
+ cancelRun: async () => undefined,
222
+ };
223
+ }
224
+ function makeRunner(w, payloads, prompts) {
225
+ return new EvaluatorRunner({
226
+ stateManager: w.stateManager,
227
+ runtimeAdapter: queuedAdapter(payloads, prompts),
228
+ eventEmitter: w.emitter,
229
+ artifactStore: w.store,
230
+ validator: new DefaultEvaluatorValidator(),
231
+ isRepairLoopEnabled: () => false,
232
+ seedArtificerRepairTask: async () => 'unused',
233
+ }, {
234
+ owner: 'pri644-test', runtimeKind: 'test-double', pollIntervalMs: 5, timeoutMs: 5000,
235
+ gateDeps: createProductionGateDeps(), effectiveConfig: flagsOffConfig(),
236
+ });
237
+ }
238
+ /** Exposes the protected leased-attempt so buildContext freshness can be probed directly. */
239
+ class ProbeEvaluatorRunner extends EvaluatorRunner {
240
+ setLeasedAttempt(attempt) {
241
+ this.currentLeasedAttempt = attempt;
242
+ }
243
+ }
244
+ function makeProbe(w) {
245
+ return new ProbeEvaluatorRunner({
246
+ stateManager: w.stateManager,
247
+ runtimeAdapter: queuedAdapter([], []),
248
+ eventEmitter: w.emitter,
249
+ artifactStore: w.store,
250
+ validator: new DefaultEvaluatorValidator(),
251
+ }, {
252
+ owner: 'pri644-test', runtimeKind: 'test-double', pollIntervalMs: 5, timeoutMs: 5000,
253
+ gateDeps: createProductionGateDeps(), effectiveConfig: flagsOffConfig(),
254
+ });
255
+ }
256
+ function suppressedEvents(w) {
257
+ return w.emitted.filter((e) => e.eventType === 'evaluator_prior_validator_errors_suppressed');
258
+ }
259
+ // ── Layer 1: prompt contract (builder unit) ──────────────────────────────────
260
+ describe('PRI-644 — evaluator prompt contract (conditional validator re-feed)', () => {
261
+ const builder = new EvaluatorPromptBuilder();
262
+ const baseInput = {
263
+ taskId: EVAL_ID,
264
+ contextHash: 'ctx-644',
265
+ sourceArtificerArtifactId: 'pi-art-artificer-644-seed',
266
+ artificerArtifact: { taskId: ART_ID },
267
+ scribeArtifact: scribeContent(),
268
+ };
269
+ it('without priorValidatorErrors the payload has no key and the system prompt is byte-identical (first attempt untouched)', () => {
270
+ const a = builder.buildPrompt(baseInput);
271
+ const parsed = JSON.parse(a.message);
272
+ expect(Object.hasOwn(parsed, 'priorValidatorErrors')).toBe(false);
273
+ expect(a.systemPrompt).toBe(EVALUATOR_PROTOCOL_INSTRUCTION);
274
+ expect(a.systemPrompt).not.toContain('PRIOR OUTPUT-CONTRACT REJECTIONS');
275
+ });
276
+ it('with priorValidatorErrors the payload carries the record verbatim and the system prompt gains the re-feed block', () => {
277
+ const { message, systemPrompt, promptInput } = builder.buildPrompt({
278
+ ...baseInput,
279
+ priorValidatorErrors: unitRecord(),
280
+ });
281
+ const parsed = JSON.parse(message);
282
+ expect(parsed.priorValidatorErrors).toEqual(unitRecord());
283
+ expect(message).toContain(REJECTION_TEXT);
284
+ expect(promptInput.priorValidatorErrors?.errors).toHaveLength(2);
285
+ expect(systemPrompt).toBe(EVALUATOR_PROTOCOL_INSTRUCTION + EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM);
286
+ expect(systemPrompt).toContain('PRIOR OUTPUT-CONTRACT REJECTIONS');
287
+ });
288
+ it('the re-feed coexists with the formation addendum in stable order (protocol + formation + validator)', () => {
289
+ const { systemPrompt } = builder.buildPrompt({
290
+ ...baseInput,
291
+ formationContext: undefined,
292
+ priorValidatorErrors: unitRecord(),
293
+ });
294
+ expect(systemPrompt).toBe(EVALUATOR_PROTOCOL_INSTRUCTION + EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM);
295
+ const withFormation = builder.buildPrompt(baseInput);
296
+ expect(withFormation.systemPrompt).toBe(EVALUATOR_PROTOCOL_INSTRUCTION);
297
+ });
298
+ it('the addendum pins the evaluator-specific duties: verbatim reasons, ledger echo obligation, no re-judging of the plan', () => {
299
+ expect(EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM).toContain('PRIOR OUTPUT-CONTRACT REJECTIONS');
300
+ expect(EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM).toContain('priorValidatorErrors.errors');
301
+ expect(EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM).toContain('requirementLedger');
302
+ expect(EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM).toContain('NOT re-judge');
303
+ });
304
+ });
305
+ // ── Layer 2: buildContext freshness wiring ──────────────────────────────────
306
+ describe('PRI-644 — evaluator buildContext consumes lastValidatorErrors with freshness gating', () => {
307
+ it('fresh record (sourceAttemptCount === leasedAttempt - 1) is carried onto the context, no suppression event', async () => {
308
+ world = await makeWorld(metaWithValidatorErrors(record(2)));
309
+ const runner = makeProbe(world);
310
+ runner.setLeasedAttempt(3);
311
+ const context = await runner.buildContext(EVAL_ID);
312
+ expect(context.priorValidatorErrors?.sourceAttemptCount).toBe(2);
313
+ expect(context.priorValidatorErrors?.errors).toEqual([REJECTION_TEXT]);
314
+ expect(suppressedEvents(world)).toHaveLength(0);
315
+ });
316
+ it('stale record is NOT re-fed and emits an observable suppression event with reason stale_source_attempt', async () => {
317
+ world = await makeWorld(metaWithValidatorErrors(record(1)));
318
+ const runner = makeProbe(world);
319
+ runner.setLeasedAttempt(5);
320
+ const context = await runner.buildContext(EVAL_ID);
321
+ expect(context.priorValidatorErrors).toBeUndefined();
322
+ const suppressed = suppressedEvents(world);
323
+ expect(suppressed).toHaveLength(1);
324
+ expect(suppressed[0]?.payload).toMatchObject({
325
+ sourceAttemptCount: 1,
326
+ currentAttempt: 5,
327
+ reason: 'stale_source_attempt',
328
+ errorCount: 1,
329
+ });
330
+ });
331
+ it('record present without lease context is suppressed with reason no_lease_context (restart-safe)', async () => {
332
+ world = await makeWorld(metaWithValidatorErrors(record(1)));
333
+ const runner = makeProbe(world);
334
+ const context = await runner.buildContext(EVAL_ID);
335
+ expect(context.priorValidatorErrors).toBeUndefined();
336
+ const suppressed = suppressedEvents(world);
337
+ expect(suppressed).toHaveLength(1);
338
+ expect(suppressed[0]?.payload).toMatchObject({ reason: 'no_lease_context' });
339
+ });
340
+ it('no record → no field, no event (first attempt untouched)', async () => {
341
+ world = await makeWorld();
342
+ const runner = makeProbe(world);
343
+ runner.setLeasedAttempt(1);
344
+ const context = await runner.buildContext(EVAL_ID);
345
+ expect(context.priorValidatorErrors).toBeUndefined();
346
+ expect(suppressedEvents(world)).toHaveLength(0);
347
+ });
348
+ it('the re-feed never participates in contextHash (same posture as artificer: identity covers evidence, not feedback)', async () => {
349
+ const plainWorld = await makeWorld();
350
+ const fedWorld = await makeWorld(metaWithValidatorErrors(record(2)));
351
+ try {
352
+ const plain = makeProbe(plainWorld);
353
+ plain.setLeasedAttempt(1);
354
+ const contextWithout = await plain.buildContext(EVAL_ID);
355
+ const fed = makeProbe(fedWorld);
356
+ fed.setLeasedAttempt(3);
357
+ const contextWith = await fed.buildContext(EVAL_ID);
358
+ expect(contextWith.priorValidatorErrors).toBeDefined();
359
+ expect(contextWith.contextHash).toBe(contextWithout.contextHash);
360
+ }
361
+ finally {
362
+ void plainWorld.stateManager.close();
363
+ void fedWorld.stateManager.close();
364
+ try {
365
+ fs.rmSync(plainWorld.workspaceDir, { recursive: true, force: true });
366
+ }
367
+ catch { /* temp */ }
368
+ try {
369
+ fs.rmSync(fedWorld.workspaceDir, { recursive: true, force: true });
370
+ }
371
+ catch { /* temp */ }
372
+ }
373
+ });
374
+ });
375
+ // ── Layer 3: golden replay — rejection feeds the next attempt ───────────────
376
+ describe('PRI-644 — golden replay: validator rejection re-feeds attempt N+1 (production path)', () => {
377
+ it('attempt 2 prompt carries the verbatim attempt-1 rejection reasons; attempt 1 prompt carries none', async () => {
378
+ world = await makeWorld();
379
+ const prompts = [];
380
+ const runner = makeRunner(world, [rejectedEvaluatorOutput(), evaluatorOutput()], prompts);
381
+ const first = await runner.run(EVAL_ID);
382
+ expect(first.status).toBe('retried');
383
+ // The task itself waits in retry_wait for attempt 2.
384
+ expect((await world.stateManager.getTask(EVAL_ID))?.status).toBe('retry_wait');
385
+ // Producer side: the rejection was persisted with the attempt-1 source tag.
386
+ const afterFirst = await world.stateManager.getTask(EVAL_ID);
387
+ const persisted = JSON.parse(afterFirst?.diagnosticJson ?? '{}');
388
+ expect(persisted.lastValidatorErrors).toBeDefined();
389
+ expect(persisted.lastValidatorErrors?.sourceAttemptCount).toBe(1);
390
+ expect(persisted.lastValidatorErrors?.errors.length).toBeGreaterThan(0);
391
+ // Retry backoff must not gate the second lease in this test.
392
+ await world.stateManager.updateTask(EVAL_ID, { leaseExpiresAt: '2000-01-01T00:00:00.000Z' });
393
+ const second = await runner.run(EVAL_ID);
394
+ expect(second.status).toBe('succeeded');
395
+ expect(prompts).toHaveLength(2);
396
+ const p1 = JSON.parse(prompts[0]?.message ?? '{}');
397
+ const p2 = JSON.parse(prompts[1]?.message ?? '{}');
398
+ // attempt 1: zero-information prompt (no feedback yet)
399
+ expect(Object.hasOwn(p1, 'priorValidatorErrors')).toBe(false);
400
+ expect(prompts[0]?.systemPrompt).not.toContain('PRIOR OUTPUT-CONTRACT REJECTIONS');
401
+ // attempt 2: the SAME rejection reasons that killed attempt 1, verbatim.
402
+ const fed = p2.priorValidatorErrors;
403
+ expect(fed).toBeDefined();
404
+ expect(fed.sourceAttemptCount).toBe(1);
405
+ expect(fed.errors).toEqual(persisted.lastValidatorErrors?.errors);
406
+ for (const errorText of fed.errors) {
407
+ expect(prompts[1]?.message).toContain(errorText);
408
+ }
409
+ expect(prompts[1]?.systemPrompt).toContain('PRIOR OUTPUT-CONTRACT REJECTIONS');
410
+ // feedback is ephemeral prompt context, NOT cache identity:
411
+ expect(p2.contextHash).toBe(p1.contextHash);
412
+ expect(p2.promptContractVersion).toBe('evaluator-output-v1.prompt.v6');
413
+ });
414
+ });
415
+ // both addenda coexist: real ordering exercised with a formation context
416
+ describe('PRI-644/PRI-843 addendum coexistence', () => {
417
+ it('renders protocol → formation → validator in order when both are present', () => {
418
+ const builder = new EvaluatorPromptBuilder();
419
+ const { systemPrompt } = builder.buildPrompt({
420
+ taskId: EVAL_ID,
421
+ contextHash: 'ctx-644',
422
+ sourceArtificerArtifactId: 'pi-art-artificer-644-seed',
423
+ artificerArtifact: { taskId: ART_ID },
424
+ scribeArtifact: scribeContent(),
425
+ formationContext: unitFormationContext(),
426
+ priorValidatorErrors: unitRecord(),
427
+ });
428
+ expect(systemPrompt).toBe(EVALUATOR_PROTOCOL_INSTRUCTION + EVALUATOR_FORMATION_EVIDENCE_ADDENDUM + EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM);
429
+ // the validator block must sit AFTER the formation block, not replace it
430
+ expect(systemPrompt.indexOf(EVALUATOR_FORMATION_EVIDENCE_ADDENDUM)).toBeLessThan(systemPrompt.indexOf(EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM));
431
+ });
432
+ });
433
+ //# sourceMappingURL=evaluator-validator-refeed.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator-validator-refeed.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OA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,CAAC,sCAAsC,EAAE,GAAG,EAAE;IACpD,EAAE,CAAC,yEAAyE,EAAE,GAAG,EAAE;QACjF,MAAM,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC7C,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;YAC3C,MAAM,EAAE,OAAO;YACf,WAAW,EAAE,SAAS;YACtB,yBAAyB,EAAE,2BAA2B;YACtD,iBAAiB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;YACrC,cAAc,EAAE,aAAa,EAAE;YAC/B,gBAAgB,EAAE,oBAAoB,EAAE;YACxC,oBAAoB,EAAE,UAAU,EAAE;SACnC,CAAC,CAAC;QACH,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CACvB,8BAA8B,GAAG,qCAAqC,GAAG,qCAAqC,CAC/G,CAAC;QACF,yEAAyE;QACzE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC,CAAC,YAAY,CAC9E,YAAY,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAC5D,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import type { IntentContractV1 } from './intent-contract.js';
2
2
  import type { FormationContext } from './formation-context.js';
3
+ import type { LastValidatorErrors } from './pitask-metadata.js';
3
4
  import type { OutputLanguage } from '../language-directive.js';
4
5
  export interface EvaluatorPromptBuilderInput {
5
6
  taskId: string;
@@ -51,6 +52,15 @@ export interface EvaluatorPromptBuilderInput {
51
52
  * shape byte-for-byte and the system prompt stays unchanged.
52
53
  */
53
54
  formationContext?: FormationContext;
55
+ /**
56
+ * PRI-644 (PRI-700 factor B wiring): verbatim validator rejection reasons
57
+ * from the immediately-preceding attempt, freshness-gated by the runner.
58
+ * Presence = the previous output was rejected by the business validator
59
+ * (e.g. a repair round missing requirementLedger) — attempt N+1 must not be
60
+ * a zero-information retry of the same prompt. Undefined on first attempt /
61
+ * when suppressed (payload and system prompt stay byte-identical).
62
+ */
63
+ priorValidatorErrors?: LastValidatorErrors;
54
64
  }
55
65
  export interface PriorRequirement {
56
66
  readonly id: string;
@@ -102,6 +112,8 @@ export interface EvaluatorPromptInput {
102
112
  intentContract?: IntentContractV1;
103
113
  /** Present only when the formation evidence resolved (PRI-843). */
104
114
  formationContext?: FormationContext;
115
+ /** Present only when the prior attempt was rejected by the validator (PRI-644). */
116
+ priorValidatorErrors?: LastValidatorErrors;
105
117
  promptContractVersion: string;
106
118
  }
107
119
  export interface EvaluatorPromptBuildResult {
@@ -139,6 +151,19 @@ export declare const PRINCIPLE_PAIN_MISMATCH_MARKER = "[principle_pain_mismatch]
139
151
  * requiredChanges (the repair pipeline can only regenerate the Rule).
140
152
  */
141
153
  export declare const EVALUATOR_FORMATION_EVIDENCE_ADDENDUM = "\n\nFORMATION EVIDENCE (when `input.formationContext` is present):\nYour input additionally carries `formationContext` \u2014 the ORIGINAL FORMATION EVIDENCE that started this formation chain. It is OBSERVATION DATA, not authority: it does not authorize you to modify, reject, or rewrite the Principle, and it never overrides the intentContract.\n- formationContext.sourceDiagnosis: the diagnostician output that started this formation (rootCause, summary, violatedPrinciples, evidence, recommendations) \u2014 the closest available carrier of the source pain's content.\n- formationContext.dreamerProposals: ALL alternative candidates the Dreamer proposed, not only the selected one. `priorityRank` is a derived reading aid over the Dreamer's own signals, not an authority.\n- formationContext.provenance: lineage ids linking this formation back to the source pain and diagnosis (sourcePainId when present).\n\nHOW TO USE IT:\n1. Judge faithfulness at TWO levels: (a) does the Rule faithfully implement the Principle \u2014 your existing intentConsistency / scopePrecision / traceCoverage duties; and (b) does the Principle actually address the pain described by sourceDiagnosis (rootCause and evidence)? Level (b) asks whether the principle answers the REAL root cause, or only a minor facet of it, or a mis-attributed one.\n2. When you conclude the Principle does NOT address the source pain, record it in evaluation.concerns as a concern whose text BEGINS with the exact token [principle_pain_mismatch], followed by the concrete evidence citation (a diagnosis evidence sourceRef, a rootCause excerpt, or a provenance id). The pipeline routes that finding to the Owner for a governance decision.\n3. NEVER express a Principle-level revision demand in evaluation.requiredChanges \u2014 requiredChanges may only demand changes to the RULE itself. The repair pipeline can only regenerate the rule; it can never satisfy a Principle-level demand.\n4. A [principle_pain_mismatch] finding is NOT a rule defect: by itself it must not flip codeReview dimensions, must not lower the score below what the rule itself merits, and must not appear in requiredChanges. If the rule is sound, judge the rule as sound and let the marked concern carry the principle-level question.\n5. The diagnosis is EVIDENCE, not truth: it is itself an upstream product of this chain and may mis-attribute. When sourceDiagnosis is absent or you find it untrustworthy, say so in risks, weaken your pain-faithfulness conclusion accordingly, and NEVER base a rejection or a [principle_pain_mismatch] finding on the ABSENCE of formation evidence alone.\n6. Do not re-litigate which dreamer proposal should have been selected (the Philosopher critique already decided that \u2014 do not revive a proposal the critique rejected); use the proposals only as evidence of what alternatives existed.";
154
+ /**
155
+ * PRI-644 (PRI-700 factor B wiring): system-channel addendum appended ONLY
156
+ * when `priorValidatorErrors` is present — the same conditional-placement
157
+ * discipline as the PRI-843 formation addendum, so a first attempt stays
158
+ * byte-identical to the pre-PRI-644 prompt. Its content is the evaluator
159
+ * variant of the artificer's "PRIOR OUTPUT-CONTRACT REJECTIONS" block —
160
+ * deliberately NOT a placement mirror: the artificer bakes that block
161
+ * unconditionally into its protocol string, this one is conditional. Phrased
162
+ * for the evaluator's failure mode (BUSINESS validator rejections such as a
163
+ * repair round missing `requirementLedger` — output captured but rejected,
164
+ * then retried with the identical prompt until max_attempts_exceeded).
165
+ */
166
+ export declare const EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM = "\n\nPRIOR OUTPUT-CONTRACT REJECTIONS (when `priorValidatorErrors` is present):\n- Your previous attempt was REJECTED BY THE OUTPUT VALIDATOR before its evaluation was ever recorded \u2014 the pipeline never advanced. The `priorValidatorErrors.errors` list contains the exact, verbatim rejection reasons.\n- The highest-priority fix is to make your JSON satisfy EVERY listed rejection reason. Re-read each error, map it to the OUTPUT FORMAT and CONSTRAINTS blocks above, and correct the exact fields it names.\n- These errors describe YOUR output's shape and completeness, NOT the implementation plan you are evaluating. Fix the contract violation and do NOT re-judge or change the substance (decision, score, findings) of your previous evaluation unless a listed rejection reason explicitly forces it.\n- When a rejection names a missing field \u2014 e.g. `evaluation.requirementLedger` or `evaluation.priorRequirementStatuses` in a repair round \u2014 that field is REQUIRED by the CONVERGENCE CONTRACT: echo EVERY input requirement with its exact id and statement-as-given, plus the status you assigned. Omitting, renumbering, or restating ids is the most common rejection cause.\n- After addressing every listed error, re-check the full OUTPUT FORMAT and CONSTRAINTS blocks once more before emitting.\n";
142
167
  /**
143
168
  * PRI-843 (SPEC v1.1): bumped v4 → v5. The prompt input gains the optional
144
169
  * `formationContext` block (dreamer proposals + source diagnosis + provenance)
@@ -149,8 +174,15 @@ export declare const EVALUATOR_FORMATION_EVIDENCE_ADDENDUM = "\n\nFORMATION EVID
149
174
  * run without formation evidence emits exactly the v4 wire shape plus the new
150
175
  * version string. Existing v4 evaluations stay immutable — the version bump
151
176
  * changes replay/cache identity for future runs only.
177
+ *
178
+ * PRI-644: bumped v5 → v6. The prompt input gains the optional
179
+ * `priorValidatorErrors` block (verbatim validator rejection reasons from the
180
+ * immediately-preceding attempt, PRI-700 factor B) and the system prompt
181
+ * conditionally carries `EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM`. Additive:
182
+ * same discipline as v5 — a run without validator feedback emits exactly the
183
+ * v5 wire shape plus the new version string.
152
184
  */
153
- export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.v5";
185
+ export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.v6";
154
186
  export declare class EvaluatorPromptBuilder {
155
187
  buildPrompt(input: EvaluatorPromptBuilderInput): EvaluatorPromptBuildResult;
156
188
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],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,eAAO,MAAM,qCAAqC,gzFAcwL,CAAC;AAE3O;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,kCAAkC,CAAC;AAEjF,qBAAa,sBAAsB;IAEjC,WAAW,CAAC,KAAK,EAAE,2BAA2B,GAAG,0BAA0B,CAgC1E;CACF"}
1
+ {"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C;;;;OAIG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,mBAAmB,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACx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