@principles/core 1.295.3 → 1.296.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.
- package/dist/runtime-v2/activation/prompt-budget-policy.d.ts +14 -2
- package/dist/runtime-v2/activation/prompt-budget-policy.d.ts.map +1 -1
- package/dist/runtime-v2/activation/prompt-budget-policy.js +24 -2
- package/dist/runtime-v2/activation/prompt-budget-policy.js.map +1 -1
- package/dist/runtime-v2/adapter/artificer-l2-adapter.d.ts.map +1 -1
- package/dist/runtime-v2/adapter/artificer-l2-adapter.js +18 -0
- package/dist/runtime-v2/adapter/artificer-l2-adapter.js.map +1 -1
- package/dist/runtime-v2/config/index.d.ts +3 -3
- package/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/dist/runtime-v2/config/index.js +3 -1
- package/dist/runtime-v2/config/index.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-effective.d.ts +8 -1
- package/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-effective.js +10 -0
- package/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-redaction.js +2 -0
- package/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.d.ts +39 -0
- package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-types.js +7 -0
- package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
- package/dist/runtime-v2/config/pd-config-validate.js +67 -1
- package/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
- package/dist/runtime-v2/index.d.ts +2 -2
- package/dist/runtime-v2/index.d.ts.map +1 -1
- package/dist/runtime-v2/index.js +3 -1
- package/dist/runtime-v2/index.js.map +1 -1
- package/dist/runtime-v2/internalization/artificer-intent-preflight.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-intent-preflight.js +10 -0
- package/dist/runtime-v2/internalization/artificer-intent-preflight.js.map +1 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.js +3 -1
- package/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
- package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/artificer-runner.js +8 -1
- package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-output.d.ts +2 -0
- package/dist/runtime-v2/internalization/evaluator-output.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-output.js +3 -0
- package/dist/runtime-v2/internalization/evaluator-output.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +2 -2
- package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-prompt-builder.js +90 -38
- package/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/dist/runtime-v2/internalization/evaluator-runner.js +115 -39
- package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/dist/runtime-v2/internalization/rulecode-verification-obligations.d.ts +66 -0
- package/dist/runtime-v2/internalization/rulecode-verification-obligations.d.ts.map +1 -0
- package/dist/runtime-v2/internalization/rulecode-verification-obligations.js +150 -0
- package/dist/runtime-v2/internalization/rulecode-verification-obligations.js.map +1 -0
- package/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts +10 -0
- package/dist/runtime-v2/tools/artificer-l2-tool-contract.d.ts.map +1 -1
- package/dist/runtime-v2/tools/artificer-l2-tool-contract.js +55 -5
- package/dist/runtime-v2/tools/artificer-l2-tool-contract.js.map +1 -1
- package/dist/runtime-v2/types/event-types.d.ts +3 -3
- package/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/dist/runtime-v2/types/event-types.js +1 -0
- package/dist/runtime-v2/types/event-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -222,8 +222,8 @@ export declare const EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM = "\n\nPRIOR OUTPUT-C
|
|
|
222
222
|
* Additive: a run without implementationCode review sees only the new clause
|
|
223
223
|
* and version string.
|
|
224
224
|
*/
|
|
225
|
-
export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.
|
|
226
|
-
export declare const EVALUATOR_DESIGN_GATE_ADDENDUM = "\n\nDESIGN GATE FACT (when present in an artificer goldenTraceCase ruleContext.facts):\nThe runtime input path is `input.context.facts.designGate`. It is a host-supplied DesignGateFact v1 with resolution `approved`, `not_approved`, `not_required`, or `unknown`, plus sourceRef/revision, task/spec/scope binding refs, and revoked state. Read the actual case value and binding; never infer approval from params, command text, history, or a missing field. `unknown` is neither approval nor explicit rejection.\n\nEVALUATOR DISPLAY NOTE: when a case carries evaluatorDisplayNote, its exact repeated history is abbreviated in this prompt only. Treat it as the same history named by the note; the stored artifact and deterministic replay retain the full original.";
|
|
225
|
+
export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.v12";
|
|
226
|
+
export declare const EVALUATOR_DESIGN_GATE_ADDENDUM = "\n\nDESIGN GATE FACT (when present in an artificer goldenTraceCase ruleContext.facts):\nPROMPT VIEW QUALIFICATION: historicalEvidenceOnlyCases contains immutable historical evidence moved out of goldenTraceCases/ownerGoldenTraceCases. evaluatorHistoricalQualifications gives the system-derived qualification and missingFacts for each Owner caseId. These cases are not executable golden expectations and must not create requiredChanges to relabel them, add invented facts, or make the rule reproduce their labels. Evaluate actual code against the declared contract and executable cases; report historical gaps separately. Invalid input remains a validation stop.\nHistorical cases missing the declared decisive fact are historical_evidence_only: preserve their labels as evidence, never require their block/allow labels as direct replay expectations or invent historical approvals. Independent system_counterfactual cases verify the declared runtime contract; their success does not mean historical replay success.\nThe runtime input path is `input.context.facts.designGate`. It is a host-supplied DesignGateFact v1 with resolution `approved`, `not_approved`, `not_required`, or `unknown`, plus sourceRef/revision, task/spec/scope binding refs, and revoked state. Read the actual case value and binding; never infer approval from params, command text, history, or a missing field. `unknown` is neither approval nor explicit rejection.\n\nEVALUATOR DISPLAY NOTE: when a case carries evaluatorDisplayNote, its exact repeated history is abbreviated in this prompt only. Treat it as the same history named by the note; the stored artifact and deterministic replay retain the full original.";
|
|
227
227
|
export declare class EvaluatorPromptBuilder {
|
|
228
228
|
buildPrompt(input: EvaluatorPromptBuilderInput): EvaluatorPromptBuildResult;
|
|
229
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AAGA,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;AAM/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;I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5KAoBwL,CAAC;AAE3O;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qCAAqC,8xCAQjD,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH;;;;;;;;;;;GAWG;AAgDH,eAAO,MAAM,iCAAiC,mCAAmC,CAAC;AAElF,eAAO,MAAM,8BAA8B,ypDAM6M,CAAC;AAEzP,qBAAa,sBAAsB;IAEjC,WAAW,CAAC,KAAK,EAAE,2BAA2B,GAAG,0BAA0B,CAsD1E;CACF"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { extractExecutionConditions } from './intent-contract.js';
|
|
2
|
+
import { buildIntentExecutionConditionsBlock } from './artificer-prompt-builder.js';
|
|
1
3
|
import { serializePromptInput } from './prompt-serializer.js';
|
|
2
4
|
import { buildLanguageDirective } from '../language-directive.js';
|
|
5
|
+
import { buildGoldenTraceFromArtificer, validateGoldenTraceCase } from '../golden-trace.js';
|
|
6
|
+
import { validateRuleContextV2 } from './rule-context-v2.js';
|
|
7
|
+
import { deriveRuleCodeVerification } from './rulecode-verification-obligations.js';
|
|
3
8
|
function normalizeStatement(s) {
|
|
4
9
|
return s.replace(/\s+/gu, ' ').trim().toLowerCase();
|
|
5
10
|
}
|
|
@@ -48,41 +53,44 @@ export function projectRepeatedGoldenHistoriesForEvaluator(artifact) {
|
|
|
48
53
|
const firstCaseByHistory = new Map();
|
|
49
54
|
let changed = false;
|
|
50
55
|
const projected = { ...artifact };
|
|
56
|
+
const projectCase = (entry, index) => {
|
|
57
|
+
if (!isRecord(entry) || !isRecord(entry.ruleContext) || !isRecord(entry.ruleContext.history))
|
|
58
|
+
return entry;
|
|
59
|
+
const { history } = entry.ruleContext;
|
|
60
|
+
let historyKey;
|
|
61
|
+
try {
|
|
62
|
+
historyKey = JSON.stringify(history);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return entry;
|
|
66
|
+
}
|
|
67
|
+
if (historyKey === undefined)
|
|
68
|
+
return entry;
|
|
69
|
+
const caseId = typeof entry.caseId === 'string' && entry.caseId.trim() !== ''
|
|
70
|
+
? entry.caseId
|
|
71
|
+
: `case-${index + 1}`;
|
|
72
|
+
const firstCaseId = firstCaseByHistory.get(historyKey);
|
|
73
|
+
if (firstCaseId === undefined) {
|
|
74
|
+
firstCaseByHistory.set(historyKey, caseId);
|
|
75
|
+
return entry;
|
|
76
|
+
}
|
|
77
|
+
changed = true;
|
|
78
|
+
return {
|
|
79
|
+
...entry,
|
|
80
|
+
ruleContext: {
|
|
81
|
+
...entry.ruleContext,
|
|
82
|
+
history: { ...history, calls: [], truncated: true },
|
|
83
|
+
},
|
|
84
|
+
evaluatorDisplayNote: `This case's exact history is repeated in case ${firstCaseId}; it is omitted from this evaluator prompt only. The stored artifact and deterministic replay retain the complete original history.`,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
51
87
|
for (const field of ['goldenTraceCases', 'ownerGoldenTraceCases']) {
|
|
52
88
|
const entries = artifact[field];
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const { history } = entry.ruleContext;
|
|
59
|
-
let historyKey;
|
|
60
|
-
try {
|
|
61
|
-
historyKey = JSON.stringify(history);
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return entry;
|
|
65
|
-
}
|
|
66
|
-
if (historyKey === undefined)
|
|
67
|
-
return entry;
|
|
68
|
-
const caseId = typeof entry.caseId === 'string' && entry.caseId.trim() !== ''
|
|
69
|
-
? entry.caseId
|
|
70
|
-
: `case-${index + 1}`;
|
|
71
|
-
const firstCaseId = firstCaseByHistory.get(historyKey);
|
|
72
|
-
if (firstCaseId === undefined) {
|
|
73
|
-
firstCaseByHistory.set(historyKey, caseId);
|
|
74
|
-
return entry;
|
|
75
|
-
}
|
|
76
|
-
changed = true;
|
|
77
|
-
return {
|
|
78
|
-
...entry,
|
|
79
|
-
ruleContext: {
|
|
80
|
-
...entry.ruleContext,
|
|
81
|
-
history: { ...history, calls: [], truncated: true },
|
|
82
|
-
},
|
|
83
|
-
evaluatorDisplayNote: `This case's exact history is repeated in case ${firstCaseId}; it is omitted from this evaluator prompt only. The stored artifact and deterministic replay retain the complete original history.`,
|
|
84
|
-
};
|
|
85
|
-
});
|
|
89
|
+
if (Array.isArray(entries))
|
|
90
|
+
projected[field] = entries.map(projectCase);
|
|
91
|
+
}
|
|
92
|
+
if (Array.isArray(artifact.historicalEvidenceOnlyCases)) {
|
|
93
|
+
projected.historicalEvidenceOnlyCases = artifact.historicalEvidenceOnlyCases.map((entry, index) => isRecord(entry) ? { ...entry, originalCase: projectCase(entry.originalCase, index) } : entry);
|
|
86
94
|
}
|
|
87
95
|
return changed ? projected : artifact;
|
|
88
96
|
}
|
|
@@ -95,6 +103,46 @@ function artifactHasDesignGate(artifact) {
|
|
|
95
103
|
return Object.hasOwn(entry.ruleContext.facts, 'designGate');
|
|
96
104
|
});
|
|
97
105
|
}
|
|
106
|
+
/** Display only: qualification comes from the system-owned Owner stamp, never model facts. */
|
|
107
|
+
function projectHistoricalEvidenceForEvaluator(input) {
|
|
108
|
+
const artifact = input.artificerArtifact;
|
|
109
|
+
if (!isRecord(artifact))
|
|
110
|
+
return artifact;
|
|
111
|
+
const conditions = extractExecutionConditions(input.scribeArtifact);
|
|
112
|
+
if (conditions.corrupted || !conditions.conditions?.requiredFacts.some((fact) => fact.required))
|
|
113
|
+
return artifact;
|
|
114
|
+
const ownerCases = artifact.ownerGoldenTraceCases;
|
|
115
|
+
if (!Array.isArray(ownerCases) || !ownerCases.every((entry) => validateGoldenTraceCase(entry).valid && isRecord(entry)
|
|
116
|
+
&& (!Object.hasOwn(entry, 'ruleContext') || validateRuleContextV2(entry.ruleContext).valid)))
|
|
117
|
+
return artifact;
|
|
118
|
+
const ownerBuild = buildGoldenTraceFromArtificer({ cases: ownerCases });
|
|
119
|
+
if (!ownerBuild.ok)
|
|
120
|
+
return artifact;
|
|
121
|
+
const verification = deriveRuleCodeVerification(input.scribeArtifact, ownerBuild.trace.cases, input.hostToolKinds ?? []);
|
|
122
|
+
if (!verification.historical.some((entry) => entry.qualification === 'historical_evidence_only'))
|
|
123
|
+
return artifact;
|
|
124
|
+
const qualificationById = new Map(verification.historical.map((entry) => [entry.caseId, entry]));
|
|
125
|
+
const historicalEvidenceOnlyCases = [];
|
|
126
|
+
const projected = { ...artifact };
|
|
127
|
+
for (const field of ['goldenTraceCases', 'ownerGoldenTraceCases']) {
|
|
128
|
+
const entries = artifact[field];
|
|
129
|
+
if (!Array.isArray(entries))
|
|
130
|
+
continue;
|
|
131
|
+
projected[field] = entries.filter((entry) => {
|
|
132
|
+
const qualification = isRecord(entry) && typeof entry.caseId === 'string'
|
|
133
|
+
? qualificationById.get(entry.caseId) : undefined;
|
|
134
|
+
if (qualification?.qualification !== 'historical_evidence_only')
|
|
135
|
+
return true;
|
|
136
|
+
historicalEvidenceOnlyCases.push({ sourceField: field, originalCase: entry, ...qualification,
|
|
137
|
+
provenanceNote: field === 'ownerGoldenTraceCases' ? 'Authoritative system-owned Owner historical evidence.' : 'Model-authored mirror; not authority for Owner labels or facts. Qualification is inherited by caseId from the Owner stamp.',
|
|
138
|
+
qualificationBasis: 'System-derived from the real Scribe executionConditions and system-owned ownerGoldenTraceCases stamp. The original label and missing facts are immutable historical evidence, not executable expectations. Do not change labels or invent historical facts to make replay pass.' });
|
|
139
|
+
return false;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return { ...projected, historicalEvidenceOnlyCases,
|
|
143
|
+
evaluatorHistoricalQualifications: verification.historical,
|
|
144
|
+
evaluatorHistoricalQualificationNote: 'Prompt-only projection. historical_evidence_only cases were moved out of executable golden lists; invalid_input remains a validation stop, never a pass. Historical gaps remain unresolved even when independent system_counterfactual checks pass. Stored artifacts, Owner evidence, hashes and sandbox inputs are unchanged.' };
|
|
145
|
+
}
|
|
98
146
|
export const EVALUATOR_PROTOCOL_INSTRUCTION = `You are an Evaluator agent in a principle internalization pipeline. Your role is to critically review the Artificer's implementation plan and produce a structured evaluation with a decision, score, and actionable feedback.
|
|
99
147
|
|
|
100
148
|
COMPRESSION FIDELITY COVERAGE CRITERIA (design §6.5.2 — Stage 1 and Stage 2 use the SAME criteria):
|
|
@@ -313,11 +361,12 @@ PRIOR OUTPUT-CONTRACT REJECTIONS (when \`priorValidatorErrors\` is present):
|
|
|
313
361
|
// defeating one is situation (c) → mismatchFindings → Owner.
|
|
314
362
|
// Additive: mismatchFindings is optional on the wire; a run without formation
|
|
315
363
|
// evidence sees only the new CONSTRAINTS clause and the version string.
|
|
316
|
-
export const EVALUATOR_PROMPT_CONTRACT_VERSION = 'evaluator-output-v1.prompt.
|
|
364
|
+
export const EVALUATOR_PROMPT_CONTRACT_VERSION = 'evaluator-output-v1.prompt.v12';
|
|
317
365
|
export const EVALUATOR_DESIGN_GATE_ADDENDUM = `
|
|
318
366
|
|
|
319
367
|
DESIGN GATE FACT (when present in an artificer goldenTraceCase ruleContext.facts):
|
|
320
|
-
|
|
368
|
+
PROMPT VIEW QUALIFICATION: historicalEvidenceOnlyCases contains immutable historical evidence moved out of goldenTraceCases/ownerGoldenTraceCases. evaluatorHistoricalQualifications gives the system-derived qualification and missingFacts for each Owner caseId. These cases are not executable golden expectations and must not create requiredChanges to relabel them, add invented facts, or make the rule reproduce their labels. Evaluate actual code against the declared contract and executable cases; report historical gaps separately. Invalid input remains a validation stop.
|
|
369
|
+
Historical cases missing the declared decisive fact are historical_evidence_only: preserve their labels as evidence, never require their block/allow labels as direct replay expectations or invent historical approvals. Independent system_counterfactual cases verify the declared runtime contract; their success does not mean historical replay success.\nThe runtime input path is \`input.context.facts.designGate\`. It is a host-supplied DesignGateFact v1 with resolution \`approved\`, \`not_approved\`, \`not_required\`, or \`unknown\`, plus sourceRef/revision, task/spec/scope binding refs, and revoked state. Read the actual case value and binding; never infer approval from params, command text, history, or a missing field. \`unknown\` is neither approval nor explicit rejection.
|
|
321
370
|
|
|
322
371
|
EVALUATOR DISPLAY NOTE: when a case carries evaluatorDisplayNote, its exact repeated history is abbreviated in this prompt only. Treat it as the same history named by the note; the stored artifact and deterministic replay retain the full original.`;
|
|
323
372
|
export class EvaluatorPromptBuilder {
|
|
@@ -330,7 +379,7 @@ export class EvaluatorPromptBuilder {
|
|
|
330
379
|
taskId: input.taskId,
|
|
331
380
|
contextHash: input.contextHash,
|
|
332
381
|
sourceArtificerArtifactId: input.sourceArtificerArtifactId,
|
|
333
|
-
artificerArtifact: projectRepeatedGoldenHistoriesForEvaluator(input
|
|
382
|
+
artificerArtifact: projectRepeatedGoldenHistoriesForEvaluator(projectHistoricalEvidenceForEvaluator(input)),
|
|
334
383
|
scribeArtifact: input.scribeArtifact,
|
|
335
384
|
previousEvaluation: input.previousEvaluation,
|
|
336
385
|
hostToolCatalog: input.hostToolCatalog,
|
|
@@ -363,13 +412,16 @@ export class EvaluatorPromptBuilder {
|
|
|
363
412
|
const validatorFeedbackAddendum = input.priorValidatorErrors !== undefined
|
|
364
413
|
? EVALUATOR_VALIDATOR_FEEDBACK_ADDENDUM
|
|
365
414
|
: '';
|
|
366
|
-
const designGateAddendum = artifactHasDesignGate(input.artificerArtifact)
|
|
415
|
+
const designGateAddendum = (extractExecutionConditions(input.scribeArtifact).conditions?.requiredFacts.some((fact) => fact.required && fact.factKind === 'design_approval') || artifactHasDesignGate(input.artificerArtifact))
|
|
367
416
|
? EVALUATOR_DESIGN_GATE_ADDENDUM
|
|
368
417
|
: '';
|
|
418
|
+
const declaredConditions = extractExecutionConditions(input.scribeArtifact).conditions;
|
|
419
|
+
const declaredContract = declaredConditions?.requiredFacts.some((fact) => fact.required && fact.factKind === 'design_approval')
|
|
420
|
+
? buildIntentExecutionConditionsBlock(declaredConditions) : '';
|
|
369
421
|
return {
|
|
370
422
|
message,
|
|
371
423
|
promptInput,
|
|
372
|
-
systemPrompt: EVALUATOR_PROTOCOL_INSTRUCTION + formationAddendum + validatorFeedbackAddendum + designGateAddendum + languageDirective,
|
|
424
|
+
systemPrompt: EVALUATOR_PROTOCOL_INSTRUCTION + formationAddendum + validatorFeedbackAddendum + designGateAddendum + declaredContract + languageDirective,
|
|
373
425
|
};
|
|
374
426
|
}
|
|
375
427
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluator-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAK9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAwB,MAAM,oBAAoB,CAAC;AAClH,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAsGpF,SAAS,kBAAkB,CAAC,CAAS;IACnC,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,cAAwF,EACxF,eAAkC;IAElC,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5C,EAAE,EAAE,OAAO,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;;;;;;;;;;;;;;OAkBG;YAEW,oBAAoB;IA+BlC;;;;;;;;OAQG;YAEW,0BAA0B;IA6UxC;;;OAGG;IAEH,OAAO,CAAC,sBAAsB;IA2B9B;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,4BAA4B;IA0BpC;;;;;;OAMG;IAEH,OAAO,CAAC,oBAAoB;IAO5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,qBAAqB;IA0D7B;;;;;;;;;;;;;OAaG;IAEH,OAAO,CAAC,4BAA4B;IAkEpC;;;;;;;;;OASG;IAEH,OAAO,CAAC,cAAc;IAsEtB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAmCvC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAiE3B;;;;;;;;;;OAUG;YAEW,oBAAoB;IA6WlC;;;;;;;;;;OAUG;YACW,8BAA8B;IAmE5C;;;OAGG;IAEH,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB;;;;;;;;;;;OAWG;YACW,oCAAoC;CA+BnD"}
|
|
@@ -21,6 +21,7 @@ import { buildGoldenTraceFromArtificer } from '../golden-trace.js';
|
|
|
21
21
|
// PRI-485 Phase 6: auto-generate 5 v2 adversarial cases (unavailable/truncation/
|
|
22
22
|
// alias/path/combination) to defend against false-positive blocks.
|
|
23
23
|
import { generateV2ContextAdversarialCases } from './v2-adversarial-cases.js';
|
|
24
|
+
import { deriveRuleCodeVerification } from './rulecode-verification-obligations.js';
|
|
24
25
|
import { canonicalizeToolKind } from './rule-context-v2.js';
|
|
25
26
|
/** PRI-741: length of the shared case-insensitive prefix of two tool names. */
|
|
26
27
|
function commonPrefixLength(a, b) {
|
|
@@ -381,6 +382,21 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
381
382
|
throw new PDRuntimeError('input_invalid', 'Artificer dependency artifact not found');
|
|
382
383
|
}
|
|
383
384
|
async invokeRuntime(taskId, context) {
|
|
385
|
+
if (context.scribeArtifact !== null) {
|
|
386
|
+
let scribe;
|
|
387
|
+
try {
|
|
388
|
+
scribe = JSON.parse(context.scribeArtifact);
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
throw new PDRuntimeError('input_invalid', 'scribe_artifact_unparseable');
|
|
392
|
+
}
|
|
393
|
+
const material = deriveRuleCodeVerification(scribe, [], this.hostSemanticContext?.tools ?? []);
|
|
394
|
+
if (material.unavailable.length > 0) {
|
|
395
|
+
this.emitEvent('adversarial_replay_skipped', taskId, { reason: 'required_fact_verification_unavailable', required: material.required,
|
|
396
|
+
executed: 0, passed: 0, failed: 0, unavailable: material.unavailable, nextAction: 'restore_supported_valid_fact_contract_before_model_request' });
|
|
397
|
+
throw new PDRuntimeError('input_invalid', `required_fact_verification_unavailable:${material.unavailable.join(',')}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
384
400
|
// Single-stage evaluation is the only path — the two-stage
|
|
385
401
|
// progressive_evaluator branch was retired with PRI-819 R-06.
|
|
386
402
|
const { message, systemPrompt } = await this.buildEvaluatorPrompt(taskId, context);
|
|
@@ -2086,13 +2102,17 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2086
2102
|
// PRI-705 / PRI-703 Phase 2: 混合场景 (非纯 out-of-scope) 下,归因与
|
|
2087
2103
|
// out-of-scope case 清单随载荷流动 — 修复 LLM 明确知道哪些失败属于
|
|
2088
2104
|
// 通道设计限制(不得尝试满足),哪些是真实 Rule 缺陷(必须修复)。
|
|
2105
|
+
const systemReplayChanges = ctx.diagnosticReplayEvidence?.passed === false
|
|
2106
|
+
&& output.evaluation.requiredChanges.length === 0 && isEvaluatorOutputV2(output)
|
|
2107
|
+
? [`[system deterministic replay] Repair the RuleCode against the executed failure evidence without inventing Owner facts: ${(output.adversarialResult?.failedCases ?? []).slice(0, 8).map((failure) => `${failure.caseId}: expected=${failure.expectedDecision}, actual=${failure.actualDecision ?? 'no decision'}, error=${failure.errorType ?? 'unknown'}; ${(failure.message ?? failure.rationale).slice(0, 160)}`).join(' | ') || 'deterministic replay failed; inspect the referenced evaluator artifact for the execution failure and restore the supported contract.'}`]
|
|
2108
|
+
: [];
|
|
2089
2109
|
const repairPayload = {
|
|
2090
2110
|
requiredChanges: completionIntent?.transitionOverrideReason === 'owner_golden_trace_provenance_missing'
|
|
2091
2111
|
? [
|
|
2092
2112
|
...output.evaluation.requiredChanges,
|
|
2093
2113
|
'Regenerate this RuleCode from the current validated Owner BehaviorExamplePack so the persisted artifact carries the system-owned ownerGoldenTraceCases; preserve the approved principle semantics.',
|
|
2094
2114
|
]
|
|
2095
|
-
: [...output.evaluation.requiredChanges],
|
|
2115
|
+
: [...output.evaluation.requiredChanges, ...systemReplayChanges],
|
|
2096
2116
|
concerns: [...output.evaluation.concerns],
|
|
2097
2117
|
previousScore: output.evaluation.score,
|
|
2098
2118
|
repairIteration: priorRepairIteration + 1,
|
|
@@ -2353,6 +2373,30 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2353
2373
|
// examples as its independent Owner acceptance baseline.
|
|
2354
2374
|
positiveCases = this.extractPositiveCases(goldenTraceCases);
|
|
2355
2375
|
}
|
|
2376
|
+
let scribe = null;
|
|
2377
|
+
try {
|
|
2378
|
+
scribe = context.scribeArtifact === null ? null : JSON.parse(context.scribeArtifact);
|
|
2379
|
+
}
|
|
2380
|
+
catch { /* the declaration extraction below fails closed on malformed content */ }
|
|
2381
|
+
const verification = deriveRuleCodeVerification(scribe, [...positiveCases, ...ownerNegativeCases], this.hostSemanticContext?.tools ?? []);
|
|
2382
|
+
if (context.scribeArtifact !== null && scribe === null)
|
|
2383
|
+
verification.unavailable.push('scribe_artifact_unparseable');
|
|
2384
|
+
if (verification.unavailable.length > 0) {
|
|
2385
|
+
this.emitEvent('adversarial_replay_skipped', taskId, { runId, reason: 'required_fact_verification_unavailable',
|
|
2386
|
+
required: verification.required, unavailable: verification.unavailable, historical: verification.historical,
|
|
2387
|
+
nextAction: 'restore_valid_declared_fact_contract_and_supported_host_projection_before_replay' });
|
|
2388
|
+
return { updatedOutput: null, skipReason: `required_fact_verification_unavailable:${verification.unavailable.join(',')}` };
|
|
2389
|
+
}
|
|
2390
|
+
positiveCases = verification.replayCases.filter((entry) => entry.kind === 'positive');
|
|
2391
|
+
ownerNegativeCases = verification.replayCases.filter((entry) => entry.kind === 'negative');
|
|
2392
|
+
// Explicit system contract positives can establish replay eligibility;
|
|
2393
|
+
// historical evidence-only labels are preserved but never counted as pass.
|
|
2394
|
+
if (positiveCases.length === 0 && verification.counterfactuals.length > 0) {
|
|
2395
|
+
positiveCases = verification.counterfactuals.filter((entry) => entry.expectedDecision === 'allow').map((entry) => ({
|
|
2396
|
+
caseId: entry.caseId, kind: 'positive', toolName: entry.toolName, params: entry.params,
|
|
2397
|
+
expectedDecision: 'allow', ruleContext: entry.ruleContext,
|
|
2398
|
+
}));
|
|
2399
|
+
}
|
|
2356
2400
|
if (positiveCases.length === 0) {
|
|
2357
2401
|
this.emitEvent('adversarial_replay_skipped', taskId, {
|
|
2358
2402
|
runId,
|
|
@@ -2368,7 +2412,7 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2368
2412
|
// PRI-634 R1: V1-shaped outputs carry no adversarialCases — the merged
|
|
2369
2413
|
// set below then relies entirely on the auto-generated v2 cases.
|
|
2370
2414
|
const llmCases = isEvaluatorOutputV2(output) ? (output.adversarialCases ?? []) : [];
|
|
2371
|
-
const v2Cases = this.generateV2CasesFromArtificer(affectedTools, positiveCases, taskId, runId);
|
|
2415
|
+
const v2Cases = verification.required.length > 0 ? [] : this.generateV2CasesFromArtificer(affectedTools, positiveCases, taskId, runId);
|
|
2372
2416
|
if (!Array.isArray(v2Cases)) {
|
|
2373
2417
|
this.emitEvent('v2_adversarial_cases_skipped', taskId, { runId, ...v2Cases });
|
|
2374
2418
|
this.emitEvent('adversarial_replay_skipped', taskId, { runId, ...v2Cases });
|
|
@@ -2376,7 +2420,7 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2376
2420
|
}
|
|
2377
2421
|
// PRI-741: host-name parity case — the rule must reach the same decision
|
|
2378
2422
|
// under the REAL host tool name as under the author's vocabulary.
|
|
2379
|
-
const hostAliasCase = this.generateHostAliasCase(requiresContextVersion === 2 ? ownerGoldenTraceCases : goldenTraceCases, taskId, runId);
|
|
2423
|
+
const hostAliasCase = this.generateHostAliasCase(verification.required.length > 0 ? verification.replayCases : requiresContextVersion === 2 ? ownerGoldenTraceCases : goldenTraceCases, taskId, runId);
|
|
2380
2424
|
const ownerNegativeAdversarial = ownerNegativeCases.map((ownerCase) => ({
|
|
2381
2425
|
caseId: `owner:${ownerCase.caseId}`,
|
|
2382
2426
|
attackType: 'boundary',
|
|
@@ -2386,39 +2430,12 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2386
2430
|
rationale: 'System-restored Owner-labelled negative behavior example; expected decision comes from the validated BehaviorExamplePack.',
|
|
2387
2431
|
...(ownerCase.ruleContext !== undefined ? { ruleContext: ownerCase.ruleContext } : {}),
|
|
2388
2432
|
}));
|
|
2389
|
-
// A trusted design fact scopes the invocation already. Changing its command
|
|
2390
|
-
// spelling must not bypass the same denied scope (counterfactual, not history).
|
|
2391
|
-
const designScopeCases = [];
|
|
2392
|
-
if (context.scribeArtifact !== null) {
|
|
2393
|
-
let scribe;
|
|
2394
|
-
try {
|
|
2395
|
-
scribe = JSON.parse(context.scribeArtifact);
|
|
2396
|
-
}
|
|
2397
|
-
catch {
|
|
2398
|
-
scribe = null;
|
|
2399
|
-
}
|
|
2400
|
-
const conditions = extractExecutionConditions(scribe);
|
|
2401
|
-
if (!conditions.corrupted && conditions.conditions?.requiredFacts.some((fact) => fact.required && fact.factKind === 'design_approval')) {
|
|
2402
|
-
for (const ownerCase of ownerNegativeCases) {
|
|
2403
|
-
const fact = ownerCase.ruleContext?.facts.designGate;
|
|
2404
|
-
const semantic = this.hostSemanticContext?.tools.find((tool) => tool.rawToolName === ownerCase.toolName);
|
|
2405
|
-
if (semantic?.canonicalKind !== 'execute' || fact?.resolution !== 'not_approved' || !fact.requiresApproval)
|
|
2406
|
-
continue;
|
|
2407
|
-
designScopeCases.push({
|
|
2408
|
-
caseId: `design-scope:${ownerCase.caseId}`, attackType: 'omission', toolName: ownerCase.toolName,
|
|
2409
|
-
params: { command: 'node -e "process.stdout.write(123)"' }, expectedDecision: 'block',
|
|
2410
|
-
rationale: 'System-derived counterfactual: the same trusted denied invocation scope cannot depend on command spelling; not a claim about historical behavior.',
|
|
2411
|
-
ruleContext: ownerCase.ruleContext,
|
|
2412
|
-
});
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
2433
|
const mergedAdversarialCases = [
|
|
2417
2434
|
...ownerNegativeAdversarial,
|
|
2418
|
-
...
|
|
2435
|
+
...verification.counterfactuals.filter((entry) => !positiveCases.some((positive) => positive.caseId === entry.caseId)),
|
|
2419
2436
|
...v2Cases,
|
|
2420
2437
|
...(hostAliasCase !== null ? [hostAliasCase] : []),
|
|
2421
|
-
...llmCases,
|
|
2438
|
+
...llmCases.filter((entry) => verification.required.length === 0 || entry.ruleContext?.facts.designGate !== undefined),
|
|
2422
2439
|
];
|
|
2423
2440
|
// (4) No adversarial cases (neither v2-generated nor LLM-supplied) →
|
|
2424
2441
|
// nothing to replay. codeReview may still be present (passive review only).
|
|
@@ -2552,11 +2569,33 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2552
2569
|
const accepted = gateResult.decision === 'accepted_shadow';
|
|
2553
2570
|
const failedCases = accepted
|
|
2554
2571
|
? []
|
|
2555
|
-
: this.mapFailedCases(gateResult, mergedAdversarialCases);
|
|
2572
|
+
: this.mapFailedCases(gateResult, mergedAdversarialCases, mergedTrace.cases);
|
|
2573
|
+
const failedIds = new Set(gateResult.sandboxResult.failedCases.map((entry) => entry.caseId));
|
|
2574
|
+
const runtimeUnavailable = gateResult.sandboxResult.forbiddenPatternViolations.length > 0
|
|
2575
|
+
|| (!gateResult.sandboxResult.success && gateResult.sandboxResult.failedCases.length === 0)
|
|
2576
|
+
|| gateResult.sandboxResult.failedCases.some((entry) => RESERVED_SYSTEM_CASE_ID.test(entry.caseId));
|
|
2577
|
+
const historyExecuted = runtimeUnavailable ? 0 : verification.replayCases.length;
|
|
2578
|
+
const historyFailed = verification.replayCases.filter((entry) => failedIds.has(entry.caseId) || failedIds.has(`owner:${entry.caseId}`)).length;
|
|
2579
|
+
const contractExecuted = runtimeUnavailable ? 0 : verification.counterfactuals.length;
|
|
2580
|
+
const contractFailed = verification.counterfactuals.filter((entry) => failedIds.has(entry.caseId)).length;
|
|
2556
2581
|
const adversarialResult = {
|
|
2557
2582
|
passed: accepted,
|
|
2558
2583
|
failedCases,
|
|
2559
2584
|
...(gateResult.failure ? { failure: { layer: gateResult.failure.layer, reasonCode: gateResult.failure.reasonCode } } : {}),
|
|
2585
|
+
verificationCoverage: {
|
|
2586
|
+
required: verification.required,
|
|
2587
|
+
executed: runtimeUnavailable ? 0 : mergedTrace.cases.length,
|
|
2588
|
+
passed: runtimeUnavailable ? 0 : mergedTrace.cases.length - gateResult.sandboxResult.failedCases.length,
|
|
2589
|
+
failed: runtimeUnavailable ? 0 : gateResult.sandboxResult.failedCases.length,
|
|
2590
|
+
unavailable: runtimeUnavailable ? [...verification.unavailable, 'sandbox_execution_unavailable'] : verification.unavailable,
|
|
2591
|
+
historicalCoverage: { executed: historyExecuted, passed: Math.max(0, historyExecuted - historyFailed), failed: historyFailed,
|
|
2592
|
+
unavailable: verification.historical.length - historyExecuted },
|
|
2593
|
+
contractCoverage: { required: verification.counterfactuals.length, executed: contractExecuted,
|
|
2594
|
+
passed: Math.max(0, contractExecuted - contractFailed), failed: contractFailed,
|
|
2595
|
+
unavailable: verification.counterfactuals.length - contractExecuted },
|
|
2596
|
+
historical: verification.historical,
|
|
2597
|
+
counterfactuals: verification.counterfactuals.map((entry) => ({ caseId: entry.caseId, source: 'system_counterfactual', contract: 'DesignGateFact/v1' })),
|
|
2598
|
+
},
|
|
2560
2599
|
};
|
|
2561
2600
|
return {
|
|
2562
2601
|
updatedOutput: { ...output, adversarialResult },
|
|
@@ -2801,8 +2840,14 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2801
2840
|
* (Runtime Contract Rule 9: graceful degradation includes a reason).
|
|
2802
2841
|
*/
|
|
2803
2842
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this
|
|
2804
|
-
mapFailedCases(gateResult, adversarialCases) {
|
|
2843
|
+
mapFailedCases(gateResult, adversarialCases, executedCases = []) {
|
|
2805
2844
|
const advById = new Map(adversarialCases.map((c) => [c.caseId, c]));
|
|
2845
|
+
for (const entry of executedCases) {
|
|
2846
|
+
if (!advById.has(entry.caseId))
|
|
2847
|
+
advById.set(entry.caseId, { caseId: entry.caseId, attackType: 'boundary',
|
|
2848
|
+
toolName: entry.toolName, params: entry.params, expectedDecision: entry.expectedDecision,
|
|
2849
|
+
rationale: 'System-executed replay case; this input is execution evidence, not a reconstructed historical fact.', ruleContext: entry.ruleContext });
|
|
2850
|
+
}
|
|
2806
2851
|
// PRI-634 PR-A (SPEC §14): the sandbox failedCase is the authority for
|
|
2807
2852
|
// expected/actual/errorType — it sees merged positive-case failures the
|
|
2808
2853
|
// adversarial-case list cannot. actualDecision is copied ONLY when the
|
|
@@ -2871,7 +2916,11 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
2871
2916
|
const contextState = adv.ruleContext
|
|
2872
2917
|
? `history ${history?.status ?? 'unknown'}${history?.truncated ? ' (truncated)' : ''}`
|
|
2873
2918
|
: 'none';
|
|
2874
|
-
const
|
|
2919
|
+
const gate = facts?.designGate;
|
|
2920
|
+
const designContext = gate !== undefined
|
|
2921
|
+
? `designGate=${gate.resolution}, requiresApproval=${gate.requiresApproval}, binding=${gate.taskRef === gate.decisionTaskRef && gate.specDigest === gate.decisionSpecDigest && gate.scopeRef === gate.decisionScopeRef ? 'matched' : 'mismatched'}, revoked=${gate.revoked}; `
|
|
2922
|
+
: adv.caseId.startsWith('system-contract:design_approval:') ? 'designGate=missing; ' : '';
|
|
2923
|
+
const identityAndContext = `tool=${adv.toolName} | context: ${designContext}${contextState}, priorReadOfTarget=${facts?.priorReadOfTarget ?? 'unknown'}, readCount=${facts?.readCount ?? 'unknown'}`;
|
|
2875
2924
|
let paramsDigest;
|
|
2876
2925
|
try {
|
|
2877
2926
|
paramsDigest = EvaluatorRunner.digestParams(adv.params);
|
|
@@ -3178,6 +3227,7 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
3178
3227
|
&& hostContext.tools.every((tool) => typeof tool.rawToolName === 'string' && tool.rawToolName.trim() !== ''
|
|
3179
3228
|
&& typeof tool.canonicalKind === 'string' && tool.canonicalKind.trim() !== '');
|
|
3180
3229
|
let requiredFactKinds;
|
|
3230
|
+
let executableTrace = traceBuild.trace;
|
|
3181
3231
|
if (typeof bearerPrincipleContentJson === 'string') {
|
|
3182
3232
|
let scribeArtifact;
|
|
3183
3233
|
try {
|
|
@@ -3201,9 +3251,34 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
3201
3251
|
return null;
|
|
3202
3252
|
}
|
|
3203
3253
|
if (executionConditions.conditions !== null) {
|
|
3204
|
-
|
|
3205
|
-
if (
|
|
3206
|
-
|
|
3254
|
+
requiredFactKinds = [...new Set(executionConditions.conditions.requiredFacts.filter((fact) => fact.required).map((fact) => fact.factKind))];
|
|
3255
|
+
if (requiredFactKinds.some((kind) => kind !== 'design_approval')) {
|
|
3256
|
+
this.emitEvent('rule_assembly_failed', taskId, { runId, reason: 'required_fact_contract_unsupported', requiredFactKinds,
|
|
3257
|
+
nextAction: 'provide_a_supported_runtime_fact_contract_before_assembly' });
|
|
3258
|
+
return null;
|
|
3259
|
+
}
|
|
3260
|
+
if (requiredFactKinds.length > 0) {
|
|
3261
|
+
const ownerBuild = Array.isArray(artificerParsed.ownerGoldenTraceCases)
|
|
3262
|
+
? buildGoldenTraceFromArtificer({ cases: artificerParsed.ownerGoldenTraceCases })
|
|
3263
|
+
: null;
|
|
3264
|
+
if (ownerBuild === null || !ownerBuild.ok) {
|
|
3265
|
+
this.emitEvent('rule_assembly_failed', taskId, { runId, reason: 'owner_verification_cases_unavailable',
|
|
3266
|
+
nextAction: 'restore_the_system_owned_owner_cases_before_assembly' });
|
|
3267
|
+
return null;
|
|
3268
|
+
}
|
|
3269
|
+
const material = deriveRuleCodeVerification(scribeArtifact, ownerBuild.trace.cases, hostContext?.tools ?? []);
|
|
3270
|
+
if (material.unavailable.length > 0) {
|
|
3271
|
+
this.emitEvent('rule_assembly_failed', taskId, { runId, reason: 'required_fact_verification_unavailable', unavailable: material.unavailable,
|
|
3272
|
+
nextAction: 'restore_valid_supported_fact_material_before_assembly' });
|
|
3273
|
+
return null;
|
|
3274
|
+
}
|
|
3275
|
+
// The activation consumer replays this trace. Evidence-only Owner
|
|
3276
|
+
// labels remain verbatim alongside it, never synthetic history.
|
|
3277
|
+
executableTrace = { ...traceBuild.trace, cases: [...material.replayCases, ...material.counterfactuals.map((entry) => ({
|
|
3278
|
+
caseId: entry.caseId, kind: entry.expectedDecision === 'allow' ? 'positive' : 'negative', toolName: entry.toolName,
|
|
3279
|
+
params: entry.params, expectedDecision: entry.expectedDecision, ruleContext: entry.ruleContext,
|
|
3280
|
+
}))] };
|
|
3281
|
+
}
|
|
3207
3282
|
}
|
|
3208
3283
|
}
|
|
3209
3284
|
if (requiresContextVersion === 2 && !hasHostInputContract) {
|
|
@@ -3215,8 +3290,9 @@ export class EvaluatorRunner extends BasePeerRunner {
|
|
|
3215
3290
|
}
|
|
3216
3291
|
const ruleContent = {
|
|
3217
3292
|
implementationCode,
|
|
3218
|
-
goldenTrace:
|
|
3293
|
+
goldenTrace: executableTrace,
|
|
3219
3294
|
goldenTraceCases,
|
|
3295
|
+
...(artificerParsed.ownerGoldenTraceCases !== undefined ? { ownerGoldenTraceCases: artificerParsed.ownerGoldenTraceCases } : {}),
|
|
3220
3296
|
affectedTools: validatedAffectedTools,
|
|
3221
3297
|
// adversarialResult.passed === true is the precondition for this method;
|
|
3222
3298
|
// the gate decision is therefore accepted_shadow.
|