@principles/core 1.285.0 → 1.286.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js +209 -0
  2. package/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js.map +1 -1
  3. package/dist/runtime-v2/__tests__/dreamer-source-pain-provenance.test.d.ts +2 -0
  4. package/dist/runtime-v2/__tests__/dreamer-source-pain-provenance.test.d.ts.map +1 -0
  5. package/dist/runtime-v2/__tests__/dreamer-source-pain-provenance.test.js +208 -0
  6. package/dist/runtime-v2/__tests__/dreamer-source-pain-provenance.test.js.map +1 -0
  7. package/dist/runtime-v2/__tests__/pitask-metadata.test.js +28 -1
  8. package/dist/runtime-v2/__tests__/pitask-metadata.test.js.map +1 -1
  9. package/dist/runtime-v2/internalization/__tests__/dreamer-prompt-builder.test.js +8 -0
  10. package/dist/runtime-v2/internalization/__tests__/dreamer-prompt-builder.test.js.map +1 -1
  11. package/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.js +2 -2
  12. package/dist/runtime-v2/internalization/__tests__/evaluator-pain-reason-echo.test.d.ts +2 -0
  13. package/dist/runtime-v2/internalization/__tests__/evaluator-pain-reason-echo.test.d.ts.map +1 -0
  14. package/dist/runtime-v2/internalization/__tests__/evaluator-pain-reason-echo.test.js +328 -0
  15. package/dist/runtime-v2/internalization/__tests__/evaluator-pain-reason-echo.test.js.map +1 -0
  16. package/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder.test.js +2 -2
  17. package/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.d.ts +2 -0
  18. package/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.d.ts.map +1 -0
  19. package/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.js +433 -0
  20. package/dist/runtime-v2/internalization/__tests__/evaluator-validator-refeed.test.js.map +1 -0
  21. package/dist/runtime-v2/internalization/__tests__/owner-decision-review.test.js +204 -3
  22. package/dist/runtime-v2/internalization/__tests__/owner-decision-review.test.js.map +1 -1
  23. package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  24. package/dist/runtime-v2/internalization/artificer-runner.js +20 -41
  25. package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  26. package/dist/runtime-v2/internalization/dreamer-prompt-builder.js +2 -2
  27. package/dist/runtime-v2/internalization/dreamer-runner.d.ts +19 -3
  28. package/dist/runtime-v2/internalization/dreamer-runner.d.ts.map +1 -1
  29. package/dist/runtime-v2/internalization/dreamer-runner.js +39 -10
  30. package/dist/runtime-v2/internalization/dreamer-runner.js.map +1 -1
  31. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +33 -1
  32. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  33. package/dist/runtime-v2/internalization/evaluator-prompt-builder.js +42 -2
  34. package/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  35. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +10 -1
  36. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  37. package/dist/runtime-v2/internalization/evaluator-runner.js +65 -1
  38. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  39. package/dist/runtime-v2/internalization/formation-context.d.ts +24 -4
  40. package/dist/runtime-v2/internalization/formation-context.d.ts.map +1 -1
  41. package/dist/runtime-v2/internalization/formation-context.js +5 -2
  42. package/dist/runtime-v2/internalization/formation-context.js.map +1 -1
  43. package/dist/runtime-v2/internalization/owner-decision-review.d.ts +33 -1
  44. package/dist/runtime-v2/internalization/owner-decision-review.d.ts.map +1 -1
  45. package/dist/runtime-v2/internalization/owner-decision-review.js +93 -1
  46. package/dist/runtime-v2/internalization/owner-decision-review.js.map +1 -1
  47. package/dist/runtime-v2/internalization/pitask-metadata.d.ts +15 -0
  48. package/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
  49. package/dist/runtime-v2/internalization/pitask-metadata.js +34 -0
  50. package/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
  51. package/dist/runtime-v2/owner-decision/__tests__/owner-decision-view.test.js +56 -0
  52. package/dist/runtime-v2/owner-decision/__tests__/owner-decision-view.test.js.map +1 -1
  53. package/dist/runtime-v2/owner-decision/owner-decision-view-contract.d.ts +169 -0
  54. package/dist/runtime-v2/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
  55. package/dist/runtime-v2/owner-decision/owner-decision-view-contract.js +4 -0
  56. package/dist/runtime-v2/owner-decision/owner-decision-view-contract.js.map +1 -1
  57. package/dist/runtime-v2/owner-decision/owner-decision-view.d.ts.map +1 -1
  58. package/dist/runtime-v2/owner-decision/owner-decision-view.js +26 -8
  59. package/dist/runtime-v2/owner-decision/owner-decision-view.js.map +1 -1
  60. package/dist/runtime-v2/pain-to-principle-service.d.ts +7 -0
  61. package/dist/runtime-v2/pain-to-principle-service.d.ts.map +1 -1
  62. package/dist/runtime-v2/pain-to-principle-service.js +1 -0
  63. package/dist/runtime-v2/pain-to-principle-service.js.map +1 -1
  64. package/dist/runtime-v2/runner/__tests__/base-peer-runner-agent-draft.test.js +34 -0
  65. package/dist/runtime-v2/runner/__tests__/base-peer-runner-agent-draft.test.js.map +1 -1
  66. package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  67. package/dist/runtime-v2/runner/base-peer-runner.js +4 -47
  68. package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  69. package/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js +29 -2
  70. package/dist/runtime-v2/store/task/__tests__/sqlite-task-store.failed-tasks.test.js.map +1 -1
  71. package/dist/runtime-v2/store/task/sqlite-task-store.d.ts.map +1 -1
  72. package/dist/runtime-v2/store/task/sqlite-task-store.js +6 -37
  73. package/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
  74. package/dist/telemetry-event.d.ts +2 -2
  75. package/dist/telemetry-event.d.ts.map +1 -1
  76. package/dist/telemetry-event.js +8 -0
  77. package/dist/telemetry-event.js.map +1 -1
  78. package/package.json +1 -1
@@ -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,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,qCAAqC,EACrC,qCAAqC,GACtC,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM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