@principles/core 1.237.0 → 1.239.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.
- package/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js +839 -0
- package/dist/runtime-v2/__tests__/artificer-runner-vslice.test.js.map +1 -1
- package/dist/runtime-v2/__tests__/evaluator-repair-loop.test.d.ts +2 -0
- package/dist/runtime-v2/__tests__/evaluator-repair-loop.test.d.ts.map +1 -0
- package/dist/runtime-v2/__tests__/evaluator-repair-loop.test.js +562 -0
- package/dist/runtime-v2/__tests__/evaluator-repair-loop.test.js.map +1 -0
- package/dist/runtime-v2/__tests__/pitask-metadata.test.js +150 -0
- package/dist/runtime-v2/__tests__/pitask-metadata.test.js.map +1 -1
- package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +32 -0
- package/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/dist/runtime-v2/feature-flags/feature-flag-contract.js +7 -0
- package/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js +133 -0
- package/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.js.map +1 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts +42 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.js +20 -0
- package/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
- package/dist/runtime-v2/internalization/artificer-runner.d.ts +22 -0
- package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-runner.js +188 -2
- package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts +85 -0
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.js +223 -0
- package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts +3 -0
- package/dist/runtime-v2/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/peer-runner-contracts.js.map +1 -1
- package/dist/runtime-v2/internalization/pitask-metadata.d.ts +34 -0
- package/dist/runtime-v2/internalization/pitask-metadata.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/pitask-metadata.js +64 -0
- package/dist/runtime-v2/internalization/pitask-metadata.js.map +1 -1
- package/package.json +1 -1
|
@@ -151,6 +151,139 @@ describe('PRI-484 Artificer prompt context modes', () => {
|
|
|
151
151
|
expect(ARTIFICER_PROTOCOL_INSTRUCTION).toContain('RETRY');
|
|
152
152
|
});
|
|
153
153
|
});
|
|
154
|
+
describe('PRI-508: Artificer dreamer context passthrough', () => {
|
|
155
|
+
// Vertical slice 1: dreamerContext 5维字段透传到 prompt message
|
|
156
|
+
it('includes dreamerContext.badDecision/betterDecision/rationale in prompt message when provided', () => {
|
|
157
|
+
const builder = new ArtificerPromptBuilder();
|
|
158
|
+
const { message, promptInput } = builder.buildPrompt({
|
|
159
|
+
contextMode: 'v1',
|
|
160
|
+
taskId: 'task-pri-508',
|
|
161
|
+
contextHash: 'ctx-pri-508',
|
|
162
|
+
sourceScribeArtifactId: 'scribe-pri-508',
|
|
163
|
+
scribeArtifact: {},
|
|
164
|
+
dreamerContext: {
|
|
165
|
+
badDecision: 'agent called write_file without checking parent path',
|
|
166
|
+
betterDecision: 'agent should resolve and validate parent path before write',
|
|
167
|
+
rationale: 'unchecked parent path leads to path traversal risk',
|
|
168
|
+
riskLevel: 'medium',
|
|
169
|
+
strategicPerspective: 'proactive validation over reactive cleanup',
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
const parsed = JSON.parse(message);
|
|
173
|
+
expect(parsed.dreamerContext).toBeDefined();
|
|
174
|
+
expect(parsed.dreamerContext.badDecision).toBe('agent called write_file without checking parent path');
|
|
175
|
+
expect(parsed.dreamerContext.betterDecision).toBe('agent should resolve and validate parent path before write');
|
|
176
|
+
expect(parsed.dreamerContext.rationale).toBe('unchecked parent path leads to path traversal risk');
|
|
177
|
+
expect(parsed.dreamerContext.riskLevel).toBe('medium');
|
|
178
|
+
expect(parsed.dreamerContext.strategicPerspective).toBe('proactive validation over reactive cleanup');
|
|
179
|
+
expect(promptInput.dreamerContext).toBeDefined();
|
|
180
|
+
});
|
|
181
|
+
// Vertical slice 2: RuleHost capability boundary hint in protocol instruction
|
|
182
|
+
it('instruction includes RuleHost capability boundary (stateless/single-call)', () => {
|
|
183
|
+
// PRI-508: artificer must know RuleHost evaluate() is a stateless single-call
|
|
184
|
+
// gate to avoid implementing unenforceable procedural rules (e.g. path whitelists
|
|
185
|
+
// for "audit before modify" principles). PoC-validated text.
|
|
186
|
+
expect(ARTIFICER_PROTOCOL_INSTRUCTION).toMatch(/stateless|single-call/i);
|
|
187
|
+
});
|
|
188
|
+
// Vertical slice 3: backward compatibility — dreamerContext absent → not in prompt
|
|
189
|
+
it('does not include dreamerContext in prompt when not provided (backward compatible)', () => {
|
|
190
|
+
const builder = new ArtificerPromptBuilder();
|
|
191
|
+
const { message, promptInput } = builder.buildPrompt({
|
|
192
|
+
contextMode: 'v1',
|
|
193
|
+
taskId: 'task-pri-508-no-dreamer',
|
|
194
|
+
contextHash: 'ctx-pri-508',
|
|
195
|
+
sourceScribeArtifactId: 'scribe-pri-508',
|
|
196
|
+
scribeArtifact: {},
|
|
197
|
+
});
|
|
198
|
+
const parsed = JSON.parse(message);
|
|
199
|
+
expect(parsed.dreamerContext).toBeUndefined();
|
|
200
|
+
expect(promptInput.dreamerContext).toBeUndefined();
|
|
201
|
+
});
|
|
202
|
+
// Vertical slice 3b: v2 mode also passes dreamerContext through
|
|
203
|
+
it('v2 mode includes dreamerContext in prompt when provided', () => {
|
|
204
|
+
const builder = new ArtificerPromptBuilder();
|
|
205
|
+
const { message } = builder.buildPrompt({
|
|
206
|
+
contextMode: 'v2',
|
|
207
|
+
taskId: 'task-pri-508-v2',
|
|
208
|
+
contextHash: 'ctx-pri-508-v2',
|
|
209
|
+
sourceScribeArtifactId: 'scribe-pri-508',
|
|
210
|
+
scribeArtifact: {},
|
|
211
|
+
behaviorExamplePack: validBehaviorExamplePack,
|
|
212
|
+
dreamerContext: {
|
|
213
|
+
badDecision: 'v2 bad decision text',
|
|
214
|
+
betterDecision: 'v2 better decision text',
|
|
215
|
+
rationale: 'v2 rationale text',
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
const parsed = JSON.parse(message);
|
|
219
|
+
expect(parsed.dreamerContext).toBeDefined();
|
|
220
|
+
expect(parsed.dreamerContext.badDecision).toBe('v2 bad decision text');
|
|
221
|
+
expect(parsed.dreamerContext.betterDecision).toBe('v2 better decision text');
|
|
222
|
+
expect(parsed.dreamerContext.rationale).toBe('v2 rationale text');
|
|
223
|
+
// Optional fields not provided → should be undefined (not serialized as null)
|
|
224
|
+
expect(parsed.dreamerContext.riskLevel).toBeUndefined();
|
|
225
|
+
expect(parsed.dreamerContext.strategicPerspective).toBeUndefined();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('PRI-509: Artificer repair feedback passthrough', () => {
|
|
229
|
+
const builder = new ArtificerPromptBuilder();
|
|
230
|
+
// Slice 1: repairFeedback serialized into prompt message when present
|
|
231
|
+
it('includes repairFeedback in prompt message when provided (with requiredChanges text)', () => {
|
|
232
|
+
const { message, promptInput } = builder.buildPrompt({
|
|
233
|
+
contextMode: 'v1',
|
|
234
|
+
taskId: 'task-pri-509',
|
|
235
|
+
contextHash: 'ctx-pri-509',
|
|
236
|
+
sourceScribeArtifactId: 'scribe-pri-509',
|
|
237
|
+
scribeArtifact: {},
|
|
238
|
+
repairFeedback: 'Previous attempt scored 0.65 (needs_revision). Evaluator concerns:\n1. code quality\nRequired changes:\n1. add input validation\nFix ALL the above.',
|
|
239
|
+
});
|
|
240
|
+
const parsed = JSON.parse(message);
|
|
241
|
+
expect(parsed.repairFeedback).toBeDefined();
|
|
242
|
+
expect(parsed.repairFeedback).toContain('add input validation');
|
|
243
|
+
expect(parsed.repairFeedback).toContain('needs_revision');
|
|
244
|
+
expect(promptInput.repairFeedback).toBeDefined();
|
|
245
|
+
});
|
|
246
|
+
// Slice 2: backward compatibility — repairFeedback absent → not in prompt
|
|
247
|
+
it('does not include repairFeedback in prompt when not provided (backward compatible)', () => {
|
|
248
|
+
const { message, promptInput } = builder.buildPrompt({
|
|
249
|
+
contextMode: 'v1',
|
|
250
|
+
taskId: 'task-pri-509-no-repair',
|
|
251
|
+
contextHash: 'ctx-pri-509',
|
|
252
|
+
sourceScribeArtifactId: 'scribe-pri-509',
|
|
253
|
+
scribeArtifact: {},
|
|
254
|
+
});
|
|
255
|
+
const parsed = JSON.parse(message);
|
|
256
|
+
expect(parsed.repairFeedback).toBeUndefined();
|
|
257
|
+
expect(promptInput.repairFeedback).toBeUndefined();
|
|
258
|
+
});
|
|
259
|
+
// Slice 3: empty/whitespace repairFeedback treated as absent (backward compatible)
|
|
260
|
+
it('does not include repairFeedback when empty or whitespace-only', () => {
|
|
261
|
+
const { message: msgEmpty } = builder.buildPrompt({
|
|
262
|
+
contextMode: 'v1',
|
|
263
|
+
taskId: 'task-pri-509-empty',
|
|
264
|
+
contextHash: 'ctx-pri-509',
|
|
265
|
+
sourceScribeArtifactId: 'scribe-pri-509',
|
|
266
|
+
scribeArtifact: {},
|
|
267
|
+
repairFeedback: '',
|
|
268
|
+
});
|
|
269
|
+
expect(JSON.parse(msgEmpty).repairFeedback).toBeUndefined();
|
|
270
|
+
const { message: msgWs } = builder.buildPrompt({
|
|
271
|
+
contextMode: 'v1',
|
|
272
|
+
taskId: 'task-pri-509-ws',
|
|
273
|
+
contextHash: 'ctx-pri-509',
|
|
274
|
+
sourceScribeArtifactId: 'scribe-pri-509',
|
|
275
|
+
scribeArtifact: {},
|
|
276
|
+
repairFeedback: ' \n\t ',
|
|
277
|
+
});
|
|
278
|
+
expect(JSON.parse(msgWs).repairFeedback).toBeUndefined();
|
|
279
|
+
});
|
|
280
|
+
// Slice 4: protocol instruction advertises repair feedback semantics
|
|
281
|
+
it('instruction includes REPAIR FEEDBACK section hinting at prior attempt', () => {
|
|
282
|
+
// PRI-509: artificer must know this is a RETRY round when repairFeedback is present,
|
|
283
|
+
// so it addresses each requiredChange instead of regenerating blind.
|
|
284
|
+
expect(ARTIFICER_PROTOCOL_INSTRUCTION).toMatch(/REPAIR FEEDBACK|prior attempt/i);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
154
287
|
describe('BUG-3 (PRI-442): artificer prompt propose_correction consistency', () => {
|
|
155
288
|
const builder = new ArtificerPromptBuilder();
|
|
156
289
|
it('shared CONSTRAINTS must not mention propose_correction as an expected negative case', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artificer-prompt-builder.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AAGxC,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,MAAM,wBAAwB,GAAwB;IACpD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;QAChC,gBAAgB,EAAE,OAAO;KAC1B;IACD,mBAAmB,EAAE,oCAAoC;IACzD,uBAAuB,EAAE;QACvB;YACE,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,UAAU;YAChB,QAAQ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,CAAC,yCAAyC,CAAC,CAAC;IACzG,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;YACjC,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,SAAS;YACjB,WAAW,EAAE,UAAU;YACvB,sBAAsB,EAAE,aAAa;YACrC,cAAc,EAAE,EAAE;YAClB,mBAAmB,EAAE,wBAAwB;SAC9C,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACvF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACpF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"artificer-prompt-builder.test.js","sourceRoot":"","sources":["../../../../src/runtime-v2/internalization/__tests__/artificer-prompt-builder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AAGxC,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,2EAA2E;AAC3E,MAAM,wBAAwB,GAAwB;IACpD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,YAAY;QACtB,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;QAChC,gBAAgB,EAAE,OAAO;KAC1B;IACD,mBAAmB,EAAE,oCAAoC;IACzD,uBAAuB,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er candidate 5-dim context (PRI-508).
|
|
4
|
+
*
|
|
5
|
+
* Carries the dreamer-stage candidate fields that scribe compresses into a
|
|
6
|
+
* single principleDraft.statement. Forwarding them to the artificer prompt
|
|
7
|
+
* prevents intent inconsistency (PoC: deepseek-v4-flash 0.7 needs_revision
|
|
8
|
+
* → 0.85 approved when combined with repair loop).
|
|
9
|
+
*
|
|
10
|
+
* All fields are runtime-validated by ArtificerRunner.buildContext via
|
|
11
|
+
* typeof / Object.hasOwn / Array.isArray guards before being placed here
|
|
12
|
+
* (rc-1, rc-2). dreamerContext is optional — undefined when the scribe
|
|
13
|
+
* artifact lacks `sourceTrace.dreamerArtifactId` or the dreamer artifact
|
|
14
|
+
* cannot be resolved (backward compatible with pre-PRI-508 flows).
|
|
15
|
+
*/
|
|
16
|
+
export interface ArtificerDreamerContext {
|
|
17
|
+
readonly badDecision: string;
|
|
18
|
+
readonly betterDecision: string;
|
|
19
|
+
readonly rationale: string;
|
|
20
|
+
readonly riskLevel?: string;
|
|
21
|
+
readonly strategicPerspective?: string;
|
|
22
|
+
}
|
|
2
23
|
export interface ArtificerPromptBuilderInput {
|
|
3
24
|
contextMode: 'v1' | 'v2';
|
|
4
25
|
behaviorExamplePack?: BehaviorExamplePack;
|
|
@@ -12,6 +33,22 @@ export interface ArtificerPromptBuilderInput {
|
|
|
12
33
|
* the prompt is the initial generation prompt (backward compatible).
|
|
13
34
|
*/
|
|
14
35
|
adversarialFeedback?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Dreamer candidate 5-dim context (PRI-508). Optional — when present,
|
|
38
|
+
* serialized into the prompt so the artificer can align its implementation
|
|
39
|
+
* with the dreamer's original intent. Undefined for backward compatibility.
|
|
40
|
+
*/
|
|
41
|
+
dreamerContext?: ArtificerDreamerContext;
|
|
42
|
+
/**
|
|
43
|
+
* Evaluator repair feedback (PRI-509). Present only on Round-2+ artificer
|
|
44
|
+
* tasks seeded by evaluator needs_revision. Carries the evaluator's
|
|
45
|
+
* requiredChanges/concerns/previousScore as a single pre-formatted string
|
|
46
|
+
* (built by ArtificerRunner.buildContext from PITaskMetadata.repairPayload).
|
|
47
|
+
* Distinct from adversarialFeedback (PRI-428): adversarialFeedback is
|
|
48
|
+
* adversarial-replay failure text; repairFeedback is evaluator semantic feedback.
|
|
49
|
+
* Undefined on Round-1 artificer tasks (backward compatible).
|
|
50
|
+
*/
|
|
51
|
+
repairFeedback?: string;
|
|
15
52
|
}
|
|
16
53
|
export interface ArtificerPromptInput {
|
|
17
54
|
contextMode: 'v1' | 'v2';
|
|
@@ -24,12 +61,16 @@ export interface ArtificerPromptInput {
|
|
|
24
61
|
promptContractVersion: string;
|
|
25
62
|
/** Present only when this is a retry with prior adversarial failures. */
|
|
26
63
|
adversarialFeedback?: string;
|
|
64
|
+
/** Present only when dreamer candidate context is available (PRI-508). */
|
|
65
|
+
dreamerContext?: ArtificerDreamerContext;
|
|
66
|
+
/** Present only on Round-2+ artificer repair tasks (PRI-509). */
|
|
67
|
+
repairFeedback?: string;
|
|
27
68
|
}
|
|
28
69
|
export interface ArtificerPromptBuildResult {
|
|
29
70
|
readonly message: string;
|
|
30
71
|
readonly promptInput: ArtificerPromptInput;
|
|
31
72
|
}
|
|
32
|
-
export declare const ARTIFICER_PROTOCOL_INSTRUCTION = "You are an Artificer agent in a principle internalization pipeline. Your role is to transform the Scribe's formal principle draft into executable RuleHost code with a concise implementation summary, tests, and rollout notes.\n\nPROTOCOL:\n1. Review the scribeArtifact to understand the formal principle draft\n2. Transform the principle draft into executable RuleHost code and a brief implementation summary\n3. Preserve the lineage trace from scribe, philosopher, and dreamer artifacts\n4. Identify risks associated with implementing this principle\n5. The implementation summary should clearly describe what the code does and why\n\nOUTPUT FORMAT (pure JSON, no markdown):\n{\n \"taskId\": \"<from input>\",\n \"sourceScribeArtifactId\": \"<copy exactly from input.sourceScribeArtifactId>\",\n \"implementationSummary\": \"<concise summary of what the code does and the implementation approach>\",\n \"sourceTrace\": {\n \"scribeArtifactId\": \"<copy exactly from input.sourceScribeArtifactId>\",\n \"philosopherArtifactId\": \"<from scribe artifact if available, or omit>\",\n \"dreamerArtifactId\": \"<from scribe artifact if available, or omit>\"\n },\n \"risks\": [\"<risk 1>\", \"<risk 2>\"],\n \"implementationCode\": \"function evaluate(input, helpers) { ... }\",\n \"goldenTraceCases\": [\n {\"caseId\":\"negative-1\",\"kind\":\"negative\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/system/file\"},\"expectedDecision\":\"block\"},\n {\"caseId\":\"positive-1\",\"kind\":\"positive\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/workspace/file\"},\"expectedDecision\":\"allow\"}\n ],\n \"affectedTools\": [\"write_file\"],\n \"generatedAt\": \"<ISO-8601 timestamp>\"\n}\n\nCONSTRAINTS:\n- Output ONLY valid JSON (no markdown, no explanatory text, no code fences)\n- implementationSummary MUST be a non-empty string describing what the code does and the implementation approach\n- sourceScribeArtifactId MUST be copied exactly from input.sourceScribeArtifactId (non-empty string)\n- sourceTrace.scribeArtifactId MUST be copied exactly from input.sourceScribeArtifactId\n- sourceTrace.philosopherArtifactId is optional \u2014 include only if available from scribe artifact\n- sourceTrace.dreamerArtifactId is optional \u2014 include only if available from scribe artifact\n- risks MUST be an array of strings (can be empty if no risks identified)\n- generatedAt MUST be the current ISO-8601 timestamp (use the actual current time, NOT a placeholder)\n- implementationCode MUST define exactly function evaluate(input, helpers) and return { decision, matched, reason }\n- EVERY return statement inside evaluate() MUST include ALL three fields: decision, matched, reason\n- Do NOT return partial objects \u2014 missing fields will fail sandbox validation and block activation\n- GOOD: return { decision: 'allow', matched: false, reason: 'path is within workspace, no risk' }\n- GOOD: return { decision: 'block', matched: true, reason: 'write to system path outside workspace' }\n- BAD: return { matched: false } \u2014 missing decision and reason, will be rejected\n- BAD: return { decision: 'allow', matched: true } \u2014 missing reason, will be rejected\n- input.action contains toolName, normalizedPath, and paramsSummary\n- implementationCode MUST be deterministic and self-contained: no imports, require, eval, Function, I/O, network, timers, Date.now, or randomness\n- goldenTraceCases MUST contain 2-10 cases with at least one positive allow case and one negative block case\n- goldenTraceCases expectedDecision MUST be only \"allow\" or \"block\" \u2014 do NOT emit \"propose_correction\", \"requireApproval\", or \"auto_correct\" (seed-user MVP only supports allow/block; all other action types are rejected by the schema validator)\n- affectedTools MUST contain the non-empty tool names the rule can match\n\nPRIOR ADVERSARIAL FAILURES (when `adversarialFeedback` is present):\n- This is a RETRY. A prior version of your generated code was reviewed and failed adversarial sandbox replay.\n- The `adversarialFeedback` field lists the specific cases that failed, each with the attack type, the expected vs actual decision, and a rationale.\n- You MUST address each listed failure specifically \u2014 do not regenerate blind. Adjust the matcher/logic so the failed cases produce the expected decision while preserving the cases that previously passed.\n";
|
|
73
|
+
export declare const ARTIFICER_PROTOCOL_INSTRUCTION = "You are an Artificer agent in a principle internalization pipeline. Your role is to transform the Scribe's formal principle draft into executable RuleHost code with a concise implementation summary, tests, and rollout notes.\n\nPROTOCOL:\n1. Review the scribeArtifact to understand the formal principle draft\n2. Transform the principle draft into executable RuleHost code and a brief implementation summary\n3. Preserve the lineage trace from scribe, philosopher, and dreamer artifacts\n4. Identify risks associated with implementing this principle\n5. The implementation summary should clearly describe what the code does and why\n\nOUTPUT FORMAT (pure JSON, no markdown):\n{\n \"taskId\": \"<from input>\",\n \"sourceScribeArtifactId\": \"<copy exactly from input.sourceScribeArtifactId>\",\n \"implementationSummary\": \"<concise summary of what the code does and the implementation approach>\",\n \"sourceTrace\": {\n \"scribeArtifactId\": \"<copy exactly from input.sourceScribeArtifactId>\",\n \"philosopherArtifactId\": \"<from scribe artifact if available, or omit>\",\n \"dreamerArtifactId\": \"<from scribe artifact if available, or omit>\"\n },\n \"risks\": [\"<risk 1>\", \"<risk 2>\"],\n \"implementationCode\": \"function evaluate(input, helpers) { ... }\",\n \"goldenTraceCases\": [\n {\"caseId\":\"negative-1\",\"kind\":\"negative\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/system/file\"},\"expectedDecision\":\"block\"},\n {\"caseId\":\"positive-1\",\"kind\":\"positive\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/workspace/file\"},\"expectedDecision\":\"allow\"}\n ],\n \"affectedTools\": [\"write_file\"],\n \"generatedAt\": \"<ISO-8601 timestamp>\"\n}\n\nCONSTRAINTS:\n- Output ONLY valid JSON (no markdown, no explanatory text, no code fences)\n- implementationSummary MUST be a non-empty string describing what the code does and the implementation approach\n- sourceScribeArtifactId MUST be copied exactly from input.sourceScribeArtifactId (non-empty string)\n- sourceTrace.scribeArtifactId MUST be copied exactly from input.sourceScribeArtifactId\n- sourceTrace.philosopherArtifactId is optional \u2014 include only if available from scribe artifact\n- sourceTrace.dreamerArtifactId is optional \u2014 include only if available from scribe artifact\n- risks MUST be an array of strings (can be empty if no risks identified)\n- generatedAt MUST be the current ISO-8601 timestamp (use the actual current time, NOT a placeholder)\n- implementationCode MUST define exactly function evaluate(input, helpers) and return { decision, matched, reason }\n- EVERY return statement inside evaluate() MUST include ALL three fields: decision, matched, reason\n- Do NOT return partial objects \u2014 missing fields will fail sandbox validation and block activation\n- GOOD: return { decision: 'allow', matched: false, reason: 'path is within workspace, no risk' }\n- GOOD: return { decision: 'block', matched: true, reason: 'write to system path outside workspace' }\n- BAD: return { matched: false } \u2014 missing decision and reason, will be rejected\n- BAD: return { decision: 'allow', matched: true } \u2014 missing reason, will be rejected\n- input.action contains toolName, normalizedPath, and paramsSummary\n- implementationCode MUST be deterministic and self-contained: no imports, require, eval, Function, I/O, network, timers, Date.now, or randomness\n- goldenTraceCases MUST contain 2-10 cases with at least one positive allow case and one negative block case\n- goldenTraceCases expectedDecision MUST be only \"allow\" or \"block\" \u2014 do NOT emit \"propose_correction\", \"requireApproval\", or \"auto_correct\" (seed-user MVP only supports allow/block; all other action types are rejected by the schema validator)\n- affectedTools MUST contain the non-empty tool names the rule can match\n\nPRIOR ADVERSARIAL FAILURES (when `adversarialFeedback` is present):\n- This is a RETRY. A prior version of your generated code was reviewed and failed adversarial sandbox replay.\n- The `adversarialFeedback` field lists the specific cases that failed, each with the attack type, the expected vs actual decision, and a rationale.\n- You MUST address each listed failure specifically \u2014 do not regenerate blind. Adjust the matcher/logic so the failed cases produce the expected decision while preserving the cases that previously passed.\n\nRULEHOST CAPABILITY BOUNDARY (PRI-508):\n- RuleHost evaluate(input) is a STATELESS single-call gate. It CANNOT track multi-step workflows (e.g., audit\u2192verify\u2192incremental) across invocations.\n- Translate the principle into a STATEFUL-CHECKABLE constraint that evaluate() CAN enforce per tool call: check whether the current tool call carries evidence of prior analysis (context markers, params encoding prior reads, explicit preconditions in the params).\n- Do NOT implement a path whitelist or a \"first call must be X\" ordering rule if the principle is about procedural discipline \u2014 the runtime cannot observe ordering across calls.\n- If the principle cannot be enforced per-call, encode the closest per-call proxy and document the gap in implementationSummary.\n\nREPAIR FEEDBACK (PRI-509, when `repairFeedback` is present):\n- This is a REPAIR RETRY. A prior attempt of your generated code was reviewed by the evaluator and returned needs_revision.\n- The `repairFeedback` field lists the evaluator's concerns and required changes from the prior attempt.\n- You MUST address each required change specifically \u2014 do not regenerate blind. Adjust the matcher/logic so the concerns are resolved while preserving the principle intent.\n- If a required change contradicts the principle intent (from scribeArtifact/dreamerContext), prefer the principle intent and document the conflict in implementationSummary.\n";
|
|
33
74
|
export declare const ARTIFICER_PROMPT_CONTRACT_VERSION = "artificer-output-v2.prompt.v2";
|
|
34
75
|
export declare class ArtificerPromptBuilder {
|
|
35
76
|
buildPrompt(input: ArtificerPromptBuilderInput): ArtificerPromptBuildResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artificer-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-prompt-builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"artificer-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-prompt-builder.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,uBAAuB,CAAC;IACzC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,0EAA0E;IAC1E,cAAc,CAAC,EAAE,uBAAuB,CAAC;IACzC,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;CAC5C;AAED,eAAO,MAAM,8BAA8B,stLAmE1C,CAAC;AAoBF,eAAO,MAAM,iCAAiC,kCAAkC,CAAC;AAEjF,qBAAa,sBAAsB;IAEjC,WAAW,CAAC,KAAK,EAAE,2BAA2B,GAAG,0BAA0B;CAyC5E"}
|
|
@@ -55,6 +55,18 @@ PRIOR ADVERSARIAL FAILURES (when \`adversarialFeedback\` is present):
|
|
|
55
55
|
- This is a RETRY. A prior version of your generated code was reviewed and failed adversarial sandbox replay.
|
|
56
56
|
- The \`adversarialFeedback\` field lists the specific cases that failed, each with the attack type, the expected vs actual decision, and a rationale.
|
|
57
57
|
- You MUST address each listed failure specifically — do not regenerate blind. Adjust the matcher/logic so the failed cases produce the expected decision while preserving the cases that previously passed.
|
|
58
|
+
|
|
59
|
+
RULEHOST CAPABILITY BOUNDARY (PRI-508):
|
|
60
|
+
- RuleHost evaluate(input) is a STATELESS single-call gate. It CANNOT track multi-step workflows (e.g., audit→verify→incremental) across invocations.
|
|
61
|
+
- Translate the principle into a STATEFUL-CHECKABLE constraint that evaluate() CAN enforce per tool call: check whether the current tool call carries evidence of prior analysis (context markers, params encoding prior reads, explicit preconditions in the params).
|
|
62
|
+
- Do NOT implement a path whitelist or a "first call must be X" ordering rule if the principle is about procedural discipline — the runtime cannot observe ordering across calls.
|
|
63
|
+
- If the principle cannot be enforced per-call, encode the closest per-call proxy and document the gap in implementationSummary.
|
|
64
|
+
|
|
65
|
+
REPAIR FEEDBACK (PRI-509, when \`repairFeedback\` is present):
|
|
66
|
+
- This is a REPAIR RETRY. A prior attempt of your generated code was reviewed by the evaluator and returned needs_revision.
|
|
67
|
+
- The \`repairFeedback\` field lists the evaluator's concerns and required changes from the prior attempt.
|
|
68
|
+
- You MUST address each required change specifically — do not regenerate blind. Adjust the matcher/logic so the concerns are resolved while preserving the principle intent.
|
|
69
|
+
- If a required change contradicts the principle intent (from scribeArtifact/dreamerContext), prefer the principle intent and document the conflict in implementationSummary.
|
|
58
70
|
`;
|
|
59
71
|
const V1_CONTEXT_INSTRUCTION = `
|
|
60
72
|
CONTEXT MODE: v1
|
|
@@ -103,6 +115,14 @@ export class ArtificerPromptBuilder {
|
|
|
103
115
|
...(typeof input.adversarialFeedback === 'string' && input.adversarialFeedback.trim() !== ''
|
|
104
116
|
? { adversarialFeedback: input.adversarialFeedback }
|
|
105
117
|
: {}),
|
|
118
|
+
// PRI-508: only include dreamerContext when present, so pre-PRI-508
|
|
119
|
+
// prompts stay backward-compatible (test asserts absence when undefined).
|
|
120
|
+
...(input.dreamerContext !== undefined ? { dreamerContext: input.dreamerContext } : {}),
|
|
121
|
+
// PRI-509: only include repairFeedback when present + non-empty, so
|
|
122
|
+
// Round-1 prompts stay backward-compatible (test asserts absence).
|
|
123
|
+
...(typeof input.repairFeedback === 'string' && input.repairFeedback.trim() !== ''
|
|
124
|
+
? { repairFeedback: input.repairFeedback }
|
|
125
|
+
: {}),
|
|
106
126
|
};
|
|
107
127
|
const message = serializePromptInput(promptInput);
|
|
108
128
|
return { message, promptInput };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artificer-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"artificer-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AA8EzE,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmE7C,CAAC;AAEF,MAAM,sBAAsB,GAAG;;;;;CAK9B,CAAC;AAEF,MAAM,sBAAsB,GAAG;;;;;;;;;CAS9B,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC;AAEjF,MAAM,OAAO,sBAAsB;IACjC,qEAAqE;IACrE,WAAW,CAAC,KAAkC;QAC5C,IAAI,KAAK,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,UAAU,GAAG,2BAA2B,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC1E,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;gBACtB,MAAM,IAAI,KAAK,CAAC,iEAAiE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACnH,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,oBAAoB,GAAG,8BAA8B;cACvD,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC;QACnF,MAAM,WAAW,GAAyB;YACxC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,E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} from './behavior-example-pack.js';
|
|
38
38
|
import type { TaskRecord } from '../task-status.js';
|
|
39
39
|
import { type PDErrorCategory } from '../error-categories.js';
|
|
40
|
+
import { type ArtificerDreamerContext } from './artificer-prompt-builder.js';
|
|
40
41
|
import { BasePeerRunner } from '../runner/base-peer-runner.js';
|
|
41
42
|
import type { PeerRunnerOptions, PeerRunnerDeps, PeerRunnerResult, PeerRunnerValidationResult } from '../runner/peer-runner-types.js';
|
|
42
43
|
/** Context built by ArtificerRunner.buildContext() and consumed by invokeRuntime(). */
|
|
@@ -51,6 +52,27 @@ interface ArtificerContext {
|
|
|
51
52
|
* LLM can make targeted corrections.
|
|
52
53
|
*/
|
|
53
54
|
readonly adversarialFeedback: string | null;
|
|
55
|
+
/**
|
|
56
|
+
* Dreamer candidate 5-dim context (PRI-508). Undefined when:
|
|
57
|
+
* - scribe artifact lacks sourceTrace.dreamerArtifactId (pre-PRI-508 flows)
|
|
58
|
+
* - dreamer artifact cannot be resolved (best-effort, non-blocking)
|
|
59
|
+
* - dreamer artifact contentJson fails runtime validation
|
|
60
|
+
* Lineage: scribe.sourceTrace.dreamerArtifactId → dreamer artifact → candidates[0] (rc-6).
|
|
61
|
+
*/
|
|
62
|
+
readonly dreamerContext?: ArtificerDreamerContext;
|
|
63
|
+
/**
|
|
64
|
+
* Evaluator repair feedback (PRI-509). Non-null only on artificer repair
|
|
65
|
+
* tasks seeded by evaluator needs_revision. Constructed by buildContext from
|
|
66
|
+
* the task's PITaskMetadata.repairPayload (already validated by
|
|
67
|
+
* isValidRepairPayload in pitask-metadata.ts). Forwarded to the prompt
|
|
68
|
+
* builder so the LLM addresses each requiredChange instead of regenerating
|
|
69
|
+
* blind. Null on Round-1 artificer tasks (backward compatible).
|
|
70
|
+
*
|
|
71
|
+
* Loop state freshness (rc-7, EP-05): repairPayload.repairIteration is
|
|
72
|
+
* written at task creation time, never inferred at read. Each repair round
|
|
73
|
+
* reads the current evaluator's feedback — never a cached value.
|
|
74
|
+
*/
|
|
75
|
+
readonly repairFeedback: string | null;
|
|
54
76
|
}
|
|
55
77
|
export type ArtificerRunnerResultStatus = 'succeeded' | 'failed' | 'retried';
|
|
56
78
|
export interface ArtificerRunnerResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artificer-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAkB,KAAK,eAAe,EAAqB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"artificer-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/artificer-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAkB,KAAK,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EAA0B,KAAK,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGrG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB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AC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAwC5E,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAiC/G,WAAW,CACf,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,mBAAmB,EAC3B,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;IAsGjD;;;;;;;OAOG;cACgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI;cAK9F,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI;CAO3F;AAED,OAAO,EAAE,gCAAgC,EAAE,CAAC"}
|
|
@@ -22,6 +22,162 @@ export function resolveArtificerRunnerOptions(options) {
|
|
|
22
22
|
function isRecord(value) {
|
|
23
23
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
24
|
}
|
|
25
|
+
// ── PRI-508: Dreamer context extraction ─────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the dreamer candidate 5-dim context from the dreamer artifact
|
|
28
|
+
* referenced by `scribe.sourceTrace.dreamerArtifactId`.
|
|
29
|
+
*
|
|
30
|
+
* Trust boundary (rc-1, rc-2): scribe contentJson and dreamer contentJson are
|
|
31
|
+
* untrusted. All field access uses Object.hasOwn (rc-5) and typeof / Array.isArray
|
|
32
|
+
* guards (rc-4) — no `as` casts that bypass validation.
|
|
33
|
+
*
|
|
34
|
+
* Lineage consistency (rc-6): dreamerContext comes from the exact artifact
|
|
35
|
+
* referenced by the scribe's sourceTrace.dreamerArtifactId — never inferred.
|
|
36
|
+
*
|
|
37
|
+
* Fail-loud / no silent fallback (rc-3, rc-9): when dreamerArtifactId is present
|
|
38
|
+
* but the dreamer artifact cannot be resolved or fails validation, emits a
|
|
39
|
+
* `dreamer_artifact_missing` / `dreamer_context_invalid` event so the gap is
|
|
40
|
+
* observable. Returns undefined (best-effort, non-blocking) so the artificer
|
|
41
|
+
* can still proceed with the scribe principle alone.
|
|
42
|
+
*/
|
|
43
|
+
async function resolveDreamerContext(params) {
|
|
44
|
+
const { scribeContentJson, taskId, emitEvent } = params;
|
|
45
|
+
// Parse scribe contentJson as unknown — never trust the shape (rc-1).
|
|
46
|
+
let scribeParsed;
|
|
47
|
+
try {
|
|
48
|
+
scribeParsed = JSON.parse(scribeContentJson);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Scribe contentJson malformed — cannot resolve dreamer lineage.
|
|
52
|
+
emitEvent('dreamer_context_skipped', taskId, { reason: 'scribe_contentJson_unparseable' });
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (!isRecord(scribeParsed))
|
|
56
|
+
return undefined;
|
|
57
|
+
// rc-5: use Object.hasOwn, not `in`.
|
|
58
|
+
if (!Object.hasOwn(scribeParsed, 'sourceTrace') || !isRecord(scribeParsed.sourceTrace)) {
|
|
59
|
+
// scribe has no sourceTrace.dreamerArtifactId — pre-PRI-508 flow, backward compatible.
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const { sourceTrace } = scribeParsed;
|
|
63
|
+
if (!Object.hasOwn(sourceTrace, 'dreamerArtifactId') || sourceTrace.dreamerArtifactId === undefined) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const { dreamerArtifactId } = sourceTrace;
|
|
67
|
+
if (typeof dreamerArtifactId !== 'string' || dreamerArtifactId.trim() === '') {
|
|
68
|
+
emitEvent('dreamer_context_skipped', taskId, { reason: 'dreamerArtifactId_not_string', dreamerArtifactId });
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
// Fetch the dreamer artifact via the canonical source (rc-6 lineage).
|
|
72
|
+
const dreamerArtifact = await params.artifactStore.getArtifactById(dreamerArtifactId);
|
|
73
|
+
if (!dreamerArtifact) {
|
|
74
|
+
// rc-9: observable event — do NOT silently swallow.
|
|
75
|
+
emitEvent('dreamer_artifact_missing', taskId, { dreamerArtifactId });
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
let dreamerParsed;
|
|
79
|
+
try {
|
|
80
|
+
dreamerParsed = JSON.parse(dreamerArtifact.contentJson);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'contentJson_unparseable' });
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
if (!isRecord(dreamerParsed)) {
|
|
87
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'content_not_record' });
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
// rc-4: validate candidates is a non-empty array, then element[0] shape.
|
|
91
|
+
// rc-2: avoid `as` cast — let `Array.isArray` type-guard narrow the local var.
|
|
92
|
+
if (!Object.hasOwn(dreamerParsed, 'candidates')) {
|
|
93
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'candidates_not_array' });
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const candidatesField = dreamerParsed.candidates;
|
|
97
|
+
if (!Array.isArray(candidatesField)) {
|
|
98
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'candidates_not_array' });
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
if (candidatesField.length === 0) {
|
|
102
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'candidates_empty' });
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const [firstCandidate] = candidatesField;
|
|
106
|
+
if (!isRecord(firstCandidate)) {
|
|
107
|
+
emitEvent('dreamer_context_invalid', taskId, { dreamerArtifactId, reason: 'candidate0_not_record' });
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
// Validate the 5-dim fields. badDecision/betterDecision/rationale are required strings.
|
|
111
|
+
// riskLevel/strategicPerspective are optional but must be string when present.
|
|
112
|
+
const requiredString = (key) => {
|
|
113
|
+
if (!Object.hasOwn(firstCandidate, key))
|
|
114
|
+
return undefined;
|
|
115
|
+
const value = firstCandidate[key];
|
|
116
|
+
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
117
|
+
};
|
|
118
|
+
const badDecision = requiredString('badDecision');
|
|
119
|
+
const betterDecision = requiredString('betterDecision');
|
|
120
|
+
const rationale = requiredString('rationale');
|
|
121
|
+
if (badDecision === undefined || betterDecision === undefined || rationale === undefined) {
|
|
122
|
+
emitEvent('dreamer_context_invalid', taskId, {
|
|
123
|
+
dreamerArtifactId,
|
|
124
|
+
reason: 'missing_required_5dim_fields',
|
|
125
|
+
hasBadDecision: badDecision !== undefined,
|
|
126
|
+
hasBetterDecision: betterDecision !== undefined,
|
|
127
|
+
hasRationale: rationale !== undefined,
|
|
128
|
+
});
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const riskLevel = requiredString('riskLevel');
|
|
132
|
+
const strategicPerspective = requiredString('strategicPerspective');
|
|
133
|
+
const dreamerContext = {
|
|
134
|
+
badDecision,
|
|
135
|
+
betterDecision,
|
|
136
|
+
rationale,
|
|
137
|
+
...(riskLevel !== undefined ? { riskLevel } : {}),
|
|
138
|
+
...(strategicPerspective !== undefined ? { strategicPerspective } : {}),
|
|
139
|
+
};
|
|
140
|
+
return dreamerContext;
|
|
141
|
+
}
|
|
142
|
+
// ── PRI-509: Evaluator repair feedback formatting ───────────────────────────
|
|
143
|
+
/**
|
|
144
|
+
* Format a validated RepairPayload into a repairFeedback string for the
|
|
145
|
+
* artificer prompt. The format is PoC-validated (Campaign 1 R2):
|
|
146
|
+
*
|
|
147
|
+
* Previous attempt scored <previousScore> (needs_revision).
|
|
148
|
+
* Evaluator concerns:
|
|
149
|
+
* 1. <concern1>
|
|
150
|
+
* 2. <concern2>
|
|
151
|
+
* Required changes:
|
|
152
|
+
* 1. <change1>
|
|
153
|
+
* 2. <change2>
|
|
154
|
+
* Fix ALL the above.
|
|
155
|
+
*
|
|
156
|
+
* Trust boundary (rc-1, rc-2): the RepairPayload was already validated by
|
|
157
|
+
* isValidRepairPayload in pitask-metadata.ts (called inside hydratePITaskRecord).
|
|
158
|
+
* By the time we receive it here, requiredChanges is a non-empty readonly
|
|
159
|
+
* string array and concerns is a readonly string array (possibly empty).
|
|
160
|
+
* No further `as` casts or shape checks are needed — we treat the validated
|
|
161
|
+
* payload as typed text input for the prompt.
|
|
162
|
+
*
|
|
163
|
+
* Loop state freshness (rc-7, EP-05): the caller passes the CURRENT task's
|
|
164
|
+
* repairPayload — never a cached or stale value. repairIteration tells the
|
|
165
|
+
* artificer which round it's in (1 = first repair, 2 = second repair).
|
|
166
|
+
*/
|
|
167
|
+
function formatRepairFeedback(payload) {
|
|
168
|
+
const concernsLines = payload.concerns.length > 0
|
|
169
|
+
? payload.concerns.map((c, i) => `${i + 1}. ${c}`).join('\n')
|
|
170
|
+
: '(none)';
|
|
171
|
+
const changesLines = payload.requiredChanges.map((c, i) => `${i + 1}. ${c}`).join('\n');
|
|
172
|
+
return [
|
|
173
|
+
`Previous attempt scored ${payload.previousScore} (needs_revision).`,
|
|
174
|
+
`Evaluator concerns:`,
|
|
175
|
+
concernsLines,
|
|
176
|
+
`Required changes:`,
|
|
177
|
+
changesLines,
|
|
178
|
+
`Fix ALL the above.`,
|
|
179
|
+
].join('\n');
|
|
180
|
+
}
|
|
25
181
|
function deepJsonEqual(left, right) {
|
|
26
182
|
if (Object.is(left, right))
|
|
27
183
|
return true;
|
|
@@ -121,9 +277,20 @@ export class ArtificerRunner extends BasePeerRunner {
|
|
|
121
277
|
&& piTask.adversarialFeedback.trim() !== ''
|
|
122
278
|
? piTask.adversarialFeedback
|
|
123
279
|
: null;
|
|
280
|
+
// PRI-509: carry evaluator repair feedback into the prompt when this is
|
|
281
|
+
// an artificer repair task seeded by evaluator needs_revision. The
|
|
282
|
+
// repairPayload was already validated by isValidRepairPayload in
|
|
283
|
+
// pitask-metadata.ts (called inside hydratePITaskRecord); we treat the
|
|
284
|
+
// hydrated value as typed text input and format it for the prompt.
|
|
285
|
+
// rc-7 (loop state freshness): repairPayload comes from the CURRENT task's
|
|
286
|
+
// diagnosticJson — never a cached or inferred value. repairIteration tells
|
|
287
|
+
// the artificer which round it's in.
|
|
288
|
+
const repairFeedback = piTask?.repairPayload
|
|
289
|
+
? formatRepairFeedback(piTask.repairPayload)
|
|
290
|
+
: null;
|
|
124
291
|
if (deps.length === 0) {
|
|
125
292
|
this.emitEvent('no_dependencies', taskId, {});
|
|
126
|
-
return { contextHash: 'empty', scribeArtifact: null, sourceScribeArtifactId: null, adversarialFeedback };
|
|
293
|
+
return { contextHash: 'empty', scribeArtifact: null, sourceScribeArtifactId: null, adversarialFeedback, repairFeedback };
|
|
127
294
|
}
|
|
128
295
|
for (const depId of deps) {
|
|
129
296
|
const depTask = await this.stateManager.getTask(depId);
|
|
@@ -148,16 +315,28 @@ export class ArtificerRunner extends BasePeerRunner {
|
|
|
148
315
|
depTaskId: depId,
|
|
149
316
|
artifactId: firstArtifact.artifactId,
|
|
150
317
|
});
|
|
318
|
+
// PRI-508: resolve dreamer candidate 5-dim context from the dreamer
|
|
319
|
+
// artifact referenced by scribe.sourceTrace.dreamerArtifactId.
|
|
320
|
+
// Best-effort: undefined when absent or invalid (backward compatible).
|
|
321
|
+
// rc-9: emits observable events on resolution failure — no silent fallback.
|
|
322
|
+
const dreamerContext = await resolveDreamerContext({
|
|
323
|
+
scribeContentJson: firstArtifact.contentJson,
|
|
324
|
+
artifactStore: this.artifactStore,
|
|
325
|
+
taskId,
|
|
326
|
+
emitEvent: (eventName, tId, payload) => this.emitEvent(eventName, tId, payload),
|
|
327
|
+
});
|
|
151
328
|
return {
|
|
152
329
|
contextHash: BasePeerRunner.hashContextRefs([artifactRef]),
|
|
153
330
|
scribeArtifact: firstArtifact.contentJson,
|
|
154
331
|
sourceScribeArtifactId: firstArtifact.artifactId,
|
|
155
332
|
adversarialFeedback,
|
|
333
|
+
repairFeedback,
|
|
334
|
+
...(dreamerContext !== undefined ? { dreamerContext } : {}),
|
|
156
335
|
};
|
|
157
336
|
}
|
|
158
337
|
}
|
|
159
338
|
this.emitEvent('no_scribe_artifact', taskId, {});
|
|
160
|
-
return { contextHash: 'empty', scribeArtifact: null, sourceScribeArtifactId: null, adversarialFeedback };
|
|
339
|
+
return { contextHash: 'empty', scribeArtifact: null, sourceScribeArtifactId: null, adversarialFeedback, repairFeedback };
|
|
161
340
|
}
|
|
162
341
|
async invokeRuntime(taskId, context) {
|
|
163
342
|
if (!context.scribeArtifact || !context.sourceScribeArtifactId) {
|
|
@@ -179,6 +358,13 @@ export class ArtificerRunner extends BasePeerRunner {
|
|
|
179
358
|
scribeArtifact: scribeArtifactInput,
|
|
180
359
|
sourceScribeArtifactId: context.sourceScribeArtifactId,
|
|
181
360
|
adversarialFeedback: context.adversarialFeedback ?? undefined,
|
|
361
|
+
// PRI-508: forward dreamer 5-dim context to artificer prompt so artificer
|
|
362
|
+
// can produce implementations aligned with dreamer's badDecision/betterDecision intent.
|
|
363
|
+
dreamerContext: context.dreamerContext,
|
|
364
|
+
// PRI-509: forward evaluator repair feedback so artificer addresses each
|
|
365
|
+
// requiredChange instead of regenerating blind. Undefined when absent
|
|
366
|
+
// (prompt builder treats undefined as backward-compatible no-op).
|
|
367
|
+
repairFeedback: context.repairFeedback ?? undefined,
|
|
182
368
|
});
|
|
183
369
|
return this.runtimeAdapter.startRun({
|
|
184
370
|
agentSpec: { agentId: this.resolvedOptions.agentId, schemaVersion: 'v1' },
|