@principles/core 1.284.21 → 1.285.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.d.ts +2 -0
  2. package/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.d.ts.map +1 -0
  3. package/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.js +531 -0
  4. package/dist/runtime-v2/internalization/__tests__/evaluator-formation-context.test.js.map +1 -0
  5. package/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder.test.js +2 -2
  6. package/dist/runtime-v2/internalization/__tests__/evaluator-prompt-builder.test.js.map +1 -1
  7. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts +48 -1
  8. package/dist/runtime-v2/internalization/evaluator-prompt-builder.d.ts.map +1 -1
  9. package/dist/runtime-v2/internalization/evaluator-prompt-builder.js +60 -2
  10. package/dist/runtime-v2/internalization/evaluator-prompt-builder.js.map +1 -1
  11. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +15 -0
  12. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  13. package/dist/runtime-v2/internalization/evaluator-runner.js +161 -4
  14. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  15. package/dist/runtime-v2/internalization/owner-review.d.ts +10 -0
  16. package/dist/runtime-v2/internalization/owner-review.d.ts.map +1 -1
  17. package/dist/runtime-v2/internalization/owner-review.js +12 -0
  18. package/dist/runtime-v2/internalization/owner-review.js.map +1 -1
  19. package/dist/telemetry-event.d.ts +2 -2
  20. package/dist/telemetry-event.d.ts.map +1 -1
  21. package/dist/telemetry-event.js +22 -0
  22. package/dist/telemetry-event.js.map +1 -1
  23. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import type { IntentContractV1 } from './intent-contract.js';
2
+ import type { FormationContext } from './formation-context.js';
2
3
  import type { OutputLanguage } from '../language-directive.js';
3
4
  export interface EvaluatorPromptBuilderInput {
4
5
  taskId: string;
@@ -41,6 +42,15 @@ export interface EvaluatorPromptBuilderInput {
41
42
  * artifacts (backward compatible).
42
43
  */
43
44
  intentContract?: IntentContractV1;
45
+ /**
46
+ * PRI-843 (DC-4a): bounded formation-evidence projection resolved by the
47
+ * evaluator runner from the scribe artifact's authoritative dreamer lineage.
48
+ * OBSERVATION DATA — evidence about where this formation came from, never
49
+ * authority over the Principle. Undefined when the formation cannot be
50
+ * resolved (legacy / degraded): the payload then keeps its pre-PRI-843
51
+ * shape byte-for-byte and the system prompt stays unchanged.
52
+ */
53
+ formationContext?: FormationContext;
44
54
  }
45
55
  export interface PriorRequirement {
46
56
  readonly id: string;
@@ -90,6 +100,8 @@ export interface EvaluatorPromptInput {
90
100
  hostToolCatalog?: HostToolCatalogFacts;
91
101
  /** Present only when the scribe artifact carries a validated intent contract (PRI-703 Phase 1). */
92
102
  intentContract?: IntentContractV1;
103
+ /** Present only when the formation evidence resolved (PRI-843). */
104
+ formationContext?: FormationContext;
93
105
  promptContractVersion: string;
94
106
  }
95
107
  export interface EvaluatorPromptBuildResult {
@@ -103,7 +115,42 @@ export interface EvaluatorPromptBuildResult {
103
115
  readonly systemPrompt: string;
104
116
  }
105
117
  export declare 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.\n\nCOMPRESSION FIDELITY COVERAGE CRITERIA (design \u00A76.5.2 \u2014 Stage 1 and Stage 2 use the SAME criteria):\nWhen evaluating whether the dreamer's decision dimensions are covered in the scribe's principle text, apply these rules:\n1. Coverage = a semantically equivalent expression exists. Rewording (using different phrasing to express the same verifiable content) is allowed; the text does NOT need to contain the exact field name or verbatim string. HOWEVER, abstraction is NOT rewording \u2014 rules 1 and 2 MUST be read together.\n2. betterDecision coverage MUST satisfy BOTH existence AND specificity: verifiable, concrete actions must be retained. Replacing concrete, verifiable actions (e.g. \"audit file tree\", \"grep all imports\", \"check export dependency graph\") with unverifiable abstractions (e.g. \"understand architecture\", \"grasp the overall structure\", \"thoroughly assess\") does NOT count as covered \u2014 even if the abstraction points to the same intent. The sole criterion: can an Owner or a piece of rule code determine whether the described action has been performed? If not, specificity is lost.\n3. riskLevel: expressed as a risk-level word (high/medium/low or Chinese equivalents) OR an equivalent risk description (e.g. \"cross-package changes will cause compilation failure if a caller is missed\") \u2014 both count as covered.\n4. badDecision: appearing in antiPatterns counts as covered. NOT appearing is NOT a defect.\n5. strategicPerspective: does NOT participate in fidelity judgement. Do NOT draw conclusions about it, and never include it in missingDimensions.\n6. When a dimension is NOT covered, you MUST name the required dimension (betterDecision / rationale / riskLevel only). Do NOT give only a qualitative description.\n7. If a dimension's value was not injected (not in the available fields), do NOT judge it \u2014 it is outside scope.\n\nThese criteria apply identically to Stage 1 and Stage 2.\n\nCONVERGENCE CONTRACT (PRI-630 \u2014 applies whenever input.previousEvaluation is present):\n1. input.previousEvaluation.requirements lists the PRIOR round's review contract with stable ids (req-1..req-N). You MUST first verify each prior requirement against the CURRENT artifact state (not your memory of it), then emit BOTH evaluation.priorRequirementStatuses ({ id, status } with status \"resolved\" | \"still_open\" | \"regressed\") AND evaluation.requirementLedger ({ id, statement, status } \u2014 an ECHO of every input requirement with its id, its statement AS GIVEN IN THE INPUT, and the status you assigned; never renumber or restate the ids).\n2. requiredChanges in THIS round MUST be built from requirements you marked still_open or regressed, plus \u2014 only if genuinely necessary \u2014 newly discovered blockers. A newly discovered blocker MUST include: the concrete evidence found in the current artifact, the blocking reason, and why it was not detectable in the previous round. If you cannot state that evidence, the item MUST go to concerns instead of requiredChanges.\n3. Do NOT re-introduce a requirement that the artifact already satisfies. Before listing any required change, check the current artifact content (goldenTraceCases, implementationCode, summaries) for an item that already covers it. Demanding something that is already present is a review defect.\n4. If every prior requirement is resolved, no new evidenced blocker exists, and no Part A dimension fails, you MUST set decision to \"approved\" \u2014 do not invent new open-ended polish requirements.\n\nTOOL CATALOG AUTHORITY (PRI-630 \u2014 applies whenever input.hostToolCatalog is present):\nTool legality is judged ONLY against input.hostToolCatalog (readOnlyTools / writeTools). If a tool name appears in the catalog, it is a legitimate host tool \u2014 you MUST NOT flag it as a blocker for being a \"non-standard name\", regardless of your prior knowledge. The catalog is NOT exhaustive: a tool name absent from the catalog is not evidence of illegality either \u2014 tool-name spelling is never a blocker; only the tool BEHAVIOR described in the rule may be. When input.hostToolCatalog is ABSENT, you have NO authoritative tool knowledge: tool-name observations may appear in concerns at most, and MUST NOT become requiredChanges or affect the decision.\n\nPROTOCOL:\n1. Review the artificerArtifact to understand the proposed implementation plan\n2. Evaluate the plan against quality criteria: completeness, feasibility, test coverage, risk mitigation\n3. Produce a decision: approved (plan is sound), needs_revision (plan has issues but is salvageable), or rejected (plan is fundamentally flawed)\n4. Provide a score from 0.0 to 1.0 reflecting overall quality\n5. List specific strengths, concerns, and required changes\n6. Preserve the lineage trace from artificer, scribe, philosopher, and dreamer artifacts\n7. Identify risks associated with this evaluation\n\nCODE REVIEW (Part A \u2014 Passive Review): When the artificerArtifact contains an \"implementationCode\" field (V2 output), you MUST additionally review the generated code across three dimensions and emit a \"codeReview\" object:\n- intentConsistency: { aligned: boolean, explanation: string } \u2014 Does the code logic match the constraint intent described in the scribe principle text? Read the principle text (scribeArtifact.principleDraft or painReasonSummary), then read the code, then judge whether the code precisely implements the described constraint. When intentContract is present, judge primarily against it: the rule is intent-aligned iff it serves ownerIntent/targetBehavior and does not implement forbiddenBehavior.\n\nOWNER INTENT CONTRACT (when `intentContract` is present \u2014 PRI-703):\n- The intentContract is the distilled Owner intent for this principle \u2014 treat it as the DEFINITION of correctness, ahead of your own reading of the principle prose.\n- intentConsistency must cite the specific contract field(s) the rule satisfies or violates.\n- SCOPING RULE: an adversarial case or required change that demands behavior NOT derivable from ownerIntent/targetBehavior/forbiddenBehavior is OUTSIDE this principle's contract. Record it as a concern with the phrase \"test-scope\" and DO NOT count it as a rule defect in requiredChanges \u2014 it indicates the test case introduces a new behavioral requirement, which belongs to a future principle revision or contract extension, not to rewriting this rule.\n- scopePrecision: { verdict: \"precise\" | \"too_broad\" | \"too_narrow\", explanation: string } \u2014 Are the match conditions over-broad (false positive risk, e.g. using includes() substring matching) or over-narrow (false negative risk, e.g. hardcoded paths)?\n- traceCoverage: { sufficient: boolean, gaps: string[], explanation: string } \u2014 Do the goldenTraceCases cover the key scenarios described in the principle (both positive and negative)?\n\nIf ANY of the three dimensions fails (aligned=false, OR verdict!=precise, OR sufficient=false), set evaluation.decision to \"needs_revision\" and describe the gap in concerns/requiredChanges.\n\nADVERSARIAL CASES (Part B \u2014 only when Part A passes): If and only if all three passive-review dimensions pass (aligned=true AND verdict=precise AND sufficient=true), ALSO generate 3-5 \"adversarialCases\" \u2014 test inputs designed to expose gaps between the principle text and the code's actual behavior. Each case: { caseId, attackType: \"boundary\"|\"omission\"|\"inversion\", toolName, params, expectedDecision: \"allow\"|\"block\"|\"propose_correction\", rationale }. If Part A does NOT fully pass, do NOT generate adversarialCases (short-circuit: skip adversarial generation on passive-review failure to save tokens).\n\nCRITICAL: Your ENTIRE response must be ONLY the JSON object below. Do NOT include any text before or after the JSON. Do NOT wrap the JSON in markdown code fences. Do NOT add explanatory prose. Output the raw JSON object and nothing else.\n\nCOMPLETE EXAMPLE OUTPUT FOR A V2 ARTIFICER INPUT (follow this exact structure):\n{\"taskId\":\"task-123\",\"sourceArtificerArtifactId\":\"pi-art-artificer-001\",\"evaluation\":{\"decision\":\"approved\",\"summary\":\"The rule matches the principle and survives adversarial review.\",\"score\":0.85,\"strengths\":[\"Exact path-segment check\"],\"concerns\":[],\"requiredChanges\":[]},\"sourceTrace\":{\"artificerArtifactId\":\"pi-art-artificer-001\"},\"risks\":[],\"codeReview\":{\"intentConsistency\":{\"aligned\":true,\"explanation\":\"The rule enforces the stated confirmation boundary.\"},\"scopePrecision\":{\"verdict\":\"precise\",\"explanation\":\"It avoids substring and sibling-prefix matches.\"},\"traceCoverage\":{\"sufficient\":true,\"gaps\":[],\"explanation\":\"Positive, negative, and boundary cases are covered.\"}},\"adversarialCases\":[{\"caseId\":\"adversarial-1\",\"attackType\":\"boundary\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/system-backup/file\"},\"expectedDecision\":\"allow\",\"rationale\":\"A sibling prefix must not be blocked.\"},{\"caseId\":\"adversarial-2\",\"attackType\":\"omission\",\"toolName\":\"write_file\",\"params\":{\"path\":\"/system/file\"},\"expectedDecision\":\"block\",\"rationale\":\"The protected path must be blocked.\"},{\"caseId\":\"adversarial-3\",\"attackType\":\"inversion\",\"toolName\":\"read_file\",\"params\":{\"path\":\"/system/file\"},\"expectedDecision\":\"allow\",\"rationale\":\"A non-writing tool must remain allowed.\"}],\"generatedAt\":\"<current ISO-8601 timestamp>\"}\n\nCONSTRAINTS:\n- Output ONLY valid JSON \u2014 no markdown, no explanatory text, no code fences, no prose before or after\n- evaluation.decision MUST be one of: approved, needs_revision, rejected\n- evaluation.summary MUST be a non-empty string\n- evaluation.score MUST be a number between 0.0 and 1.0 (NOT a string, NOT a percentage)\n- evaluation.strengths MUST be an array of strings (can be empty)\n- evaluation.concerns MUST be an array of strings (can be empty)\n- evaluation.requiredChanges MUST be an array of strings; when decision is \"needs_revision\" it MUST contain at least one item (a revision demand without an actionable change is an invalid verdict)\n- evaluation.priorRequirementStatuses is REQUIRED when input.previousEvaluation is present: an array of { id, status } covering EVERY prior requirement id, where status is one of resolved, still_open, regressed; omit the field entirely on the first round (no prior evaluation)\n- evaluation.requirementLedger is REQUIRED under the same condition: an array of { id, statement, status } echoing EVERY input requirement (same ids and statements as given; status one of resolved, still_open, regressed); omit entirely on the first round\n- sourceArtificerArtifactId MUST be copied exactly from input.sourceArtificerArtifactId (non-empty string)\n- sourceTrace.artificerArtifactId MUST be copied exactly from input.sourceArtificerArtifactId\n- sourceTrace.scribeArtifactId is optional \u2014 include only if available from artificer artifact\n- sourceTrace.philosopherArtifactId is optional \u2014 include only if available from artificer artifact\n- sourceTrace.dreamerArtifactId is optional \u2014 include only if available from artificer 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- codeReview (when present) MUST contain intentConsistency, scopePrecision, and traceCoverage\n- adversarialCases (when present) MUST be an array of 3-5 objects; omit entirely when passive review fails\n";
106
- export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.v4";
118
+ /**
119
+ * PRI-843: the machine-readable concern-type token for a Principle↔Pain
120
+ * mismatch finding. The v5 prompt contract requires every such concern to
121
+ * BEGIN with this token (concerns are plain strings — the prefix is the only
122
+ * schema-free encoding); the evaluator runner scans the validated concerns
123
+ * for it and routes the completion to Owner review. Single source of truth:
124
+ * the addendum text below interpolates this constant.
125
+ */
126
+ export declare const PRINCIPLE_PAIN_MISMATCH_MARKER = "[principle_pain_mismatch]";
127
+ /**
128
+ * PRI-843: system-channel addendum appended ONLY when `formationContext` is
129
+ * present (the scribe FORMATION_EVIDENCE_ADDENDUM placement discipline). A
130
+ * run without formation evidence keeps the exact pre-PRI-843 system prompt.
131
+ *
132
+ * Contract posture (SPEC v1.1):
133
+ * - the formation evidence is OBSERVATION DATA — it never authorizes
134
+ * modifying the Principle and never overrides the intentContract;
135
+ * - the diagnosis is evidence, not truth (it is itself an upstream product
136
+ * of this chain) — absence/distrust degrades the conclusion, never
137
+ * rejects on its own;
138
+ * - a mismatch finding goes to a marked concern for the OWNER, never into
139
+ * requiredChanges (the repair pipeline can only regenerate the Rule).
140
+ */
141
+ export declare const EVALUATOR_FORMATION_EVIDENCE_ADDENDUM = "\n\nFORMATION EVIDENCE (when `input.formationContext` is present):\nYour input additionally carries `formationContext` \u2014 the ORIGINAL FORMATION EVIDENCE that started this formation chain. It is OBSERVATION DATA, not authority: it does not authorize you to modify, reject, or rewrite the Principle, and it never overrides the intentContract.\n- formationContext.sourceDiagnosis: the diagnostician output that started this formation (rootCause, summary, violatedPrinciples, evidence, recommendations) \u2014 the closest available carrier of the source pain's content.\n- formationContext.dreamerProposals: ALL alternative candidates the Dreamer proposed, not only the selected one. `priorityRank` is a derived reading aid over the Dreamer's own signals, not an authority.\n- formationContext.provenance: lineage ids linking this formation back to the source pain and diagnosis (sourcePainId when present).\n\nHOW TO USE IT:\n1. Judge faithfulness at TWO levels: (a) does the Rule faithfully implement the Principle \u2014 your existing intentConsistency / scopePrecision / traceCoverage duties; and (b) does the Principle actually address the pain described by sourceDiagnosis (rootCause and evidence)? Level (b) asks whether the principle answers the REAL root cause, or only a minor facet of it, or a mis-attributed one.\n2. When you conclude the Principle does NOT address the source pain, record it in evaluation.concerns as a concern whose text BEGINS with the exact token [principle_pain_mismatch], followed by the concrete evidence citation (a diagnosis evidence sourceRef, a rootCause excerpt, or a provenance id). The pipeline routes that finding to the Owner for a governance decision.\n3. NEVER express a Principle-level revision demand in evaluation.requiredChanges \u2014 requiredChanges may only demand changes to the RULE itself. The repair pipeline can only regenerate the rule; it can never satisfy a Principle-level demand.\n4. A [principle_pain_mismatch] finding is NOT a rule defect: by itself it must not flip codeReview dimensions, must not lower the score below what the rule itself merits, and must not appear in requiredChanges. If the rule is sound, judge the rule as sound and let the marked concern carry the principle-level question.\n5. The diagnosis is EVIDENCE, not truth: it is itself an upstream product of this chain and may mis-attribute. When sourceDiagnosis is absent or you find it untrustworthy, say so in risks, weaken your pain-faithfulness conclusion accordingly, and NEVER base a rejection or a [principle_pain_mismatch] finding on the ABSENCE of formation evidence alone.\n6. Do not re-litigate which dreamer proposal should have been selected (the Philosopher critique already decided that \u2014 do not revive a proposal the critique rejected); use the proposals only as evidence of what alternatives existed.";
142
+ /**
143
+ * PRI-843 (SPEC v1.1): bumped v4 → v5. The prompt input gains the optional
144
+ * `formationContext` block (dreamer proposals + source diagnosis + provenance)
145
+ * and the system prompt conditionally carries the formation-evidence addendum
146
+ * (`EVALUATOR_FORMATION_EVIDENCE_ADDENDUM`, including the
147
+ * principle-pain-mismatch concern contract). Additive: the OUTPUT FORMAT, the
148
+ * CONSTRAINTS, the validator and `EvaluatorOutputV1/V2` are unchanged, and a
149
+ * run without formation evidence emits exactly the v4 wire shape plus the new
150
+ * version string. Existing v4 evaluations stay immutable — the version bump
151
+ * changes replay/cache identity for future runs only.
152
+ */
153
+ export declare const EVALUATOR_PROMPT_CONTRACT_VERSION = "evaluator-output-v1.prompt.v5";
107
154
  export declare class EvaluatorPromptBuilder {
108
155
  buildPrompt(input: EvaluatorPromptBuilderInput): EvaluatorPromptBuildResult;
109
156
  }
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C;;;;OAIG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,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,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,8BAA8B,mlXAsE1C,CAAC;AAEF,eAAO,MAAM,iCAAiC,kCAAkC,CAAC;AAEjF,qBAAa,sBAAsB;IAEjC,WAAW,CAAC,KAAK,EAAE,2BAA2B,GAAG,0BAA0B,CAuB1E;CACF"}
1
+ {"version":3,"file":"evaluator-prompt-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,yBAAyB,EAAE,MAAM,CAAC;IAClC,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C;;;;OAIG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,QAA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C,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,8BAA8B,mlXAsE1C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,qCAAqC,gzFAcwL,CAAC;AAE3O;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iCAAiC,kCAAkC,CAAC;AAEjF,qBAAa,sBAAsB;IAEjC,WAAW,CAAC,KAAK,EAAE,2BAA2B,GAAG,0BAA0B,CAgC1E;CACF"}
@@ -105,7 +105,56 @@ CONSTRAINTS:
105
105
  - codeReview (when present) MUST contain intentConsistency, scopePrecision, and traceCoverage
106
106
  - adversarialCases (when present) MUST be an array of 3-5 objects; omit entirely when passive review fails
107
107
  `;
108
- export const EVALUATOR_PROMPT_CONTRACT_VERSION = 'evaluator-output-v1.prompt.v4';
108
+ /**
109
+ * PRI-843: the machine-readable concern-type token for a Principle↔Pain
110
+ * mismatch finding. The v5 prompt contract requires every such concern to
111
+ * BEGIN with this token (concerns are plain strings — the prefix is the only
112
+ * schema-free encoding); the evaluator runner scans the validated concerns
113
+ * for it and routes the completion to Owner review. Single source of truth:
114
+ * the addendum text below interpolates this constant.
115
+ */
116
+ export const PRINCIPLE_PAIN_MISMATCH_MARKER = '[principle_pain_mismatch]';
117
+ /**
118
+ * PRI-843: system-channel addendum appended ONLY when `formationContext` is
119
+ * present (the scribe FORMATION_EVIDENCE_ADDENDUM placement discipline). A
120
+ * run without formation evidence keeps the exact pre-PRI-843 system prompt.
121
+ *
122
+ * Contract posture (SPEC v1.1):
123
+ * - the formation evidence is OBSERVATION DATA — it never authorizes
124
+ * modifying the Principle and never overrides the intentContract;
125
+ * - the diagnosis is evidence, not truth (it is itself an upstream product
126
+ * of this chain) — absence/distrust degrades the conclusion, never
127
+ * rejects on its own;
128
+ * - a mismatch finding goes to a marked concern for the OWNER, never into
129
+ * requiredChanges (the repair pipeline can only regenerate the Rule).
130
+ */
131
+ export const EVALUATOR_FORMATION_EVIDENCE_ADDENDUM = `
132
+
133
+ FORMATION EVIDENCE (when \`input.formationContext\` is present):
134
+ Your input additionally carries \`formationContext\` — the ORIGINAL FORMATION EVIDENCE that started this formation chain. It is OBSERVATION DATA, not authority: it does not authorize you to modify, reject, or rewrite the Principle, and it never overrides the intentContract.
135
+ - formationContext.sourceDiagnosis: the diagnostician output that started this formation (rootCause, summary, violatedPrinciples, evidence, recommendations) — the closest available carrier of the source pain's content.
136
+ - formationContext.dreamerProposals: ALL alternative candidates the Dreamer proposed, not only the selected one. \`priorityRank\` is a derived reading aid over the Dreamer's own signals, not an authority.
137
+ - formationContext.provenance: lineage ids linking this formation back to the source pain and diagnosis (sourcePainId when present).
138
+
139
+ HOW TO USE IT:
140
+ 1. Judge faithfulness at TWO levels: (a) does the Rule faithfully implement the Principle — your existing intentConsistency / scopePrecision / traceCoverage duties; and (b) does the Principle actually address the pain described by sourceDiagnosis (rootCause and evidence)? Level (b) asks whether the principle answers the REAL root cause, or only a minor facet of it, or a mis-attributed one.
141
+ 2. When you conclude the Principle does NOT address the source pain, record it in evaluation.concerns as a concern whose text BEGINS with the exact token ${PRINCIPLE_PAIN_MISMATCH_MARKER}, followed by the concrete evidence citation (a diagnosis evidence sourceRef, a rootCause excerpt, or a provenance id). The pipeline routes that finding to the Owner for a governance decision.
142
+ 3. NEVER express a Principle-level revision demand in evaluation.requiredChanges — requiredChanges may only demand changes to the RULE itself. The repair pipeline can only regenerate the rule; it can never satisfy a Principle-level demand.
143
+ 4. A ${PRINCIPLE_PAIN_MISMATCH_MARKER} finding is NOT a rule defect: by itself it must not flip codeReview dimensions, must not lower the score below what the rule itself merits, and must not appear in requiredChanges. If the rule is sound, judge the rule as sound and let the marked concern carry the principle-level question.
144
+ 5. The diagnosis is EVIDENCE, not truth: it is itself an upstream product of this chain and may mis-attribute. When sourceDiagnosis is absent or you find it untrustworthy, say so in risks, weaken your pain-faithfulness conclusion accordingly, and NEVER base a rejection or a ${PRINCIPLE_PAIN_MISMATCH_MARKER} finding on the ABSENCE of formation evidence alone.
145
+ 6. Do not re-litigate which dreamer proposal should have been selected (the Philosopher critique already decided that — do not revive a proposal the critique rejected); use the proposals only as evidence of what alternatives existed.`;
146
+ /**
147
+ * PRI-843 (SPEC v1.1): bumped v4 → v5. The prompt input gains the optional
148
+ * `formationContext` block (dreamer proposals + source diagnosis + provenance)
149
+ * and the system prompt conditionally carries the formation-evidence addendum
150
+ * (`EVALUATOR_FORMATION_EVIDENCE_ADDENDUM`, including the
151
+ * principle-pain-mismatch concern contract). Additive: the OUTPUT FORMAT, the
152
+ * CONSTRAINTS, the validator and `EvaluatorOutputV1/V2` are unchanged, and a
153
+ * run without formation evidence emits exactly the v4 wire shape plus the new
154
+ * version string. Existing v4 evaluations stay immutable — the version bump
155
+ * changes replay/cache identity for future runs only.
156
+ */
157
+ export const EVALUATOR_PROMPT_CONTRACT_VERSION = 'evaluator-output-v1.prompt.v5';
109
158
  export class EvaluatorPromptBuilder {
110
159
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
111
160
  buildPrompt(input) {
@@ -123,12 +172,21 @@ export class EvaluatorPromptBuilder {
123
172
  // PRI-703 Phase 1: only include intentContract when present (pre-contract
124
173
  // scribe artifacts), so prompts stay backward-compatible.
125
174
  ...(input.intentContract !== undefined ? { intentContract: input.intentContract } : {}),
175
+ // PRI-843: only include formationContext when it actually resolved, so
176
+ // a run without formation evidence keeps the exact pre-PRI-843 payload.
177
+ ...(input.formationContext !== undefined ? { formationContext: input.formationContext } : {}),
126
178
  promptContractVersion: EVALUATOR_PROMPT_CONTRACT_VERSION,
127
179
  };
128
180
  const message = serializePromptInput(promptInput);
129
181
  // PRI-633: the instruction (with PRI-714's language directive) is the
130
182
  // base-layer systemPrompt — it left the payload.
131
- return { message, promptInput, systemPrompt: EVALUATOR_PROTOCOL_INSTRUCTION + languageDirective };
183
+ // PRI-843: the formation-evidence addendum rides the same system channel
184
+ // and is appended ONLY when formationContext is present (the scribe
185
+ // addendum placement discipline — no-formation runs stay byte-identical).
186
+ const formationAddendum = input.formationContext !== undefined
187
+ ? EVALUATOR_FORMATION_EVIDENCE_ADDENDUM
188
+ : '';
189
+ return { message, promptInput, systemPrompt: EVALUATOR_PROTOCOL_INSTRUCTION + formationAddendum + languageDirective };
132
190
  }
133
191
  }
134
192
  //# sourceMappingURL=evaluator-prompt-builder.js.map
@@ -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;AAG9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AA6ElE,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,CAAC,GAAG,CAAC,EAAE;YAClB,SAAS;YACT,MAAM,EAAE,KAAc;SACvB,CAAC,CAAC,CAAC;IACN,CAAC;IACD,MAAM,OAAO,GAAG,cAAc;SAC3B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G,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC;AAChC,CAAC;AA+BD,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsE7C,CAAC;AAEF,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC;AAEjF,MAAM,OAAO,sBAAsB;IACjC,qEAAqE;IACrE,WAAW,CAAC,KAAkC;QAC5C,mEAAmE;QACnE,mEAAmE;QACnE,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,KAAK,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACjF,MAAM,WAAW,GAAyB;YACxC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,yBAAyB,EAAE,KAAK,CAAC,yBAAyB;YAC1D,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,0EAA0E;YAC1E,0DAA0D;YAC1D,GAAG,CAAC,KAAK,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvF,qBAAqB,EAAE,iCAAiC;SACzD,CAAC;QAEF,MAAM,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAElD,sEAAsE;QACtE,iDAAiD;QACjD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,8BAA8B,GAAG,iBAAiB,EAAE,CAAC;IACpG,CAAC;CACF"}
1
+ {"version":3,"file":"evaluator-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-prompt-builder.ts"],"names":[],"mappings":"AAAA,O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C,cAAc,EAAE,QAAQ,CAAC,CAAC;QACjF,MAAM,WAAW,GAAyB;YACxC,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,yBAAyB,EAAE,KAAK,CAAC,yBAAyB;YAC1D,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;YACpC,kBAAkB,EAAE,KAAK,CAAC,kBAAkB;YAC5C,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,0EAA0E;YAC1E,0DAA0D;YAC1D,GAAG,CAAC,KAAK,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvF,uEAAuE;YACvE,wEAAwE;YACxE,GAAG,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,qBAAqB,EAAE,iCAAiC;SACzD,CAAC;QAEF,MAAM,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;QAElD,sEAAsE;QACtE,iDAAiD;QACjD,yEAAyE;QACzE,oEAAoE;QACpE,0EAA0E;QAC1E,MAAM,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,KAAK,SAAS;YAC5D,CAAC,CAAC,qCAAqC;YACvC,CAAC,CAAC,EAAE,CAAC;QACP,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,8BAA8B,GAAG,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;IACxH,CAAC;CACF"}
@@ -30,6 +30,7 @@ import type { TaskRecord } from '../task-status.js';
30
30
  import { type PDErrorCategory } from '../error-categories.js';
31
31
  import { type RepairPayload } from './pitask-metadata.js';
32
32
  import { type PreviousEvaluationContext, type HostToolCatalogFacts } from './evaluator-prompt-builder.js';
33
+ import type { FormationContext } from './formation-context.js';
33
34
  import type { ArtificerHostSemanticContext } from './artificer-prompt-builder.js';
34
35
  import { type InternalizationChannel, type PipelineTopologyMode, type ArtifactRef } from './peer-runner-contracts.js';
35
36
  import { BasePeerRunner } from '../runner/base-peer-runner.js';
@@ -58,6 +59,14 @@ interface EvaluatorContext {
58
59
  readonly dependencyRepairPayload?: RepairPayload;
59
60
  /** PRI-630: 由 dependencyRepairPayload 解析的上轮评估上下文 (首轮 undefined) */
60
61
  readonly previousEvaluation?: PreviousEvaluationContext;
62
+ /**
63
+ * PRI-843 (DC-4a): bounded formation-evidence projection (dreamer proposals +
64
+ * source diagnosis + provenance) resolved from the scribe artifact's
65
+ * authoritative `sourceTrace.dreamerArtifactId`. Undefined when the lineage id
66
+ * is absent or the formation cannot be resolved — the prompt then keeps its
67
+ * pre-PRI-843 shape exactly (legacy / degraded compatibility).
68
+ */
69
+ readonly formationContext?: FormationContext;
61
70
  }
62
71
  export type EvaluatorRunnerResultStatus = 'succeeded' | 'failed' | 'retried';
63
72
  export interface EvaluatorRunnerResult {
@@ -206,6 +215,12 @@ export declare class EvaluatorRunner extends BasePeerRunner<EvaluatorContext, Ev
206
215
  get permanentErrorCategories(): ReadonlySet<PDErrorCategory>;
207
216
  buildContext(taskId: string): Promise<EvaluatorContext>;
208
217
  invokeRuntime(taskId: string, context: EvaluatorContext): Promise<RunHandle>;
218
+ /**
219
+ * PRI-843: narrow task view for formation-context resolution (the scribe
220
+ * adapter, verbatim): phase identity lives on the task row, never on the
221
+ * artifact, so the diagnostic predecessor can only be found via task lookup.
222
+ */
223
+ private lookupFormationTask;
209
224
  /**
210
225
  * PRI-630 收敛契约 (SPEC §18.1): 解析上轮评估上下文 — 从 dependency
211
226
  * artificer 的 repairPayload.sourceEvaluatorTaskId 找到上轮 evaluator,
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization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BAAgB,GAAG,IAAI,CAoBhH;IAED,UAAmB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAKvF;IAED;;;OAGG;IACH,UAAmB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CASpH;IAID;;;;;;;;;;;;;;;;;;OAkBG;YAEW,oBAAoB;IA+BlC;;;;;;;;OAQG;YAEW,0BAA0B;IAkPxC;;;OAGG;IAEH,OAAO,CAAC,sBAAsB;IAyB9B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM,CAAC,8BAA8B;IA8B7C;;;;;;OAMG;IAEH,OAAO,CAAC,oBAAoB;IAO5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,CAAC,qBAAqB;IA0D7B;;;;;;;;;;;;;;;OAeG;IAEH,OAAO,CAAC,4BAA4B;IAmFpC;;;;;;;;;OASG;IAEH,OAAO,CAAC,cAAc;IA0DtB;;;;;;;;;;OAUG;YAEW,oBAAoB;IAkNlC;;;;;;;;;;OAUG;YACW,8BAA8B;IAmE5C;;;OAGG;IAEH,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB;;;;;;;;;;;OAWG;YACW,oCAAoC;CA+BnD"}
@@ -5,7 +5,8 @@ import { assessArtificerCodeBearing } from './artificer-code-bearing.js';
5
5
  import { PDRuntimeError, isPDErrorCategory } from '../error-categories.js';
6
6
  import { hydratePITaskRecord, createPITaskDiagnosticJson, mergePITaskMetadata, artificerRepairTaskId } from './pitask-metadata.js';
7
7
  import { HUMAN_REVIEW_REASON, planOwnerVerdictOverrideResume, markOwnerResolutionApplied, computeArtifactContentHash, } from './owner-review.js';
8
- import { EvaluatorPromptBuilder, deriveRequirementLedger } from './evaluator-prompt-builder.js';
8
+ import { EvaluatorPromptBuilder, deriveRequirementLedger, PRINCIPLE_PAIN_MISMATCH_MARKER } from './evaluator-prompt-builder.js';
9
+ import { resolveFormationContext } from './formation-context.js';
9
10
  import { reconcileLineageEcho } from './peer-runner-contracts.js';
10
11
  import { BasePeerRunner } from '../runner/base-peer-runner.js';
11
12
  import { extractIntentContract } from './intent-contract.js';
@@ -30,6 +31,55 @@ function commonPrefixLength(a, b) {
30
31
  function isRecordValue(value) {
31
32
  return value !== null && typeof value === 'object' && !Array.isArray(value);
32
33
  }
34
+ /**
35
+ * PRI-843: read the AUTHORITATIVE dreamer artifact id from the scribe principle
36
+ * artifact's `sourceTrace.dreamerArtifactId`.
37
+ *
38
+ * The scribe runner injects that id from its own resolver-verified context
39
+ * (scribe-runner lineage echo), so it is the only dreamer lineage this layer may
40
+ * trust; the artificer's echo of the same field is model-authored and never
41
+ * authoritative (SPEC "Lineage Source"). The scribe artifact here is untrusted
42
+ * contentJson — guarded reads only, no `as` cast (rc-1 / rc-2 / rc-5). Returns
43
+ * undefined when absent or malformed; the resolver then emits the observable
44
+ * skip event (rc-9).
45
+ */
46
+ function readDreamerArtifactIdFromScribeArtifact(contentJson) {
47
+ if (contentJson === null)
48
+ return undefined;
49
+ let parsed;
50
+ try {
51
+ parsed = JSON.parse(contentJson);
52
+ }
53
+ catch {
54
+ return undefined;
55
+ }
56
+ if (!isRecordValue(parsed) || !Object.hasOwn(parsed, 'sourceTrace'))
57
+ return undefined;
58
+ const sourceTrace = Reflect.get(parsed, 'sourceTrace');
59
+ if (!isRecordValue(sourceTrace) || !Object.hasOwn(sourceTrace, 'dreamerArtifactId'))
60
+ return undefined;
61
+ const value = Reflect.get(sourceTrace, 'dreamerArtifactId');
62
+ if (typeof value !== 'string' || value.trim() === '')
63
+ return undefined;
64
+ return value;
65
+ }
66
+ /**
67
+ * PRI-843: does the validated evaluation flag a Principle↔Pain mismatch?
68
+ *
69
+ * The v5 prompt contract requires every such concern to BEGIN with the exported
70
+ * marker token — the marker prefix is the only machine-readable channel plain
71
+ * string concerns have (no schema change). The runner scans the already
72
+ * validated `concerns` array; honoring is additionally gated on formation
73
+ * context having actually been injected (see deriveGovernanceEffect): without
74
+ * formation evidence the model has no pain evidence to cite, so a marker there
75
+ * is hallucination, not signal.
76
+ */
77
+ function hasPrinciplePainMismatchConcern(output) {
78
+ const concerns = output.evaluation?.concerns;
79
+ if (!Array.isArray(concerns))
80
+ return false;
81
+ return concerns.some((concern) => concern.startsWith(PRINCIPLE_PAIN_MISMATCH_MARKER));
82
+ }
33
83
  /**
34
84
  * PRI-634: resolve a golden-trace case's target path across the host tool
35
85
  * schemas actually observed on real chains.
@@ -249,9 +299,35 @@ export class EvaluatorRunner extends BasePeerRunner {
249
299
  });
250
300
  }
251
301
  }
252
- const contextRefs = scribeContent && scribeRef
253
- ? [artifactRef, scribeRef]
254
- : [artifactRef];
302
+ // PRI-843 (DC-4a): resolve the formation evidence the scribe artifact's
303
+ // authoritative dreamer lineage points at. Until now the evaluator held
304
+ // the Rule and the Principle but never the pain/diagnosis they came
305
+ // from — its verdict was structurally limited to "is the rule faithful
306
+ // to the principle text" and could not ask "is the principle faithful
307
+ // to the pain". Mirrors the scribe wiring (PRI-838): best-effort,
308
+ // never blocking, degradation observable via resolver events (rc-9).
309
+ const sourceDreamerArtifactId = readDreamerArtifactIdFromScribeArtifact(scribeContent);
310
+ const formationContext = await resolveFormationContext({
311
+ sourceDreamerArtifactId,
312
+ artifactStore: this.artifactStore,
313
+ lookupTask: (id) => this.lookupFormationTask(id),
314
+ emitEvent: (eventName, eventTaskId, payload) => this.emitEvent(eventName, eventTaskId, payload),
315
+ taskId,
316
+ });
317
+ // The context hash must cover the evidence the prompt actually carries
318
+ // (the scribe contextRefs rule): otherwise replay/cache could serve a
319
+ // prompt that predates the formation evidence.
320
+ const contextRefs = [
321
+ ...(scribeContent && scribeRef ? [artifactRef, scribeRef] : [artifactRef]),
322
+ ...(formationContext !== undefined
323
+ ? [
324
+ formationContext.provenance.sourceDreamerArtifactId,
325
+ ...(formationContext.provenance.sourceDiagnosisArtifactId !== null
326
+ ? [formationContext.provenance.sourceDiagnosisArtifactId]
327
+ : []),
328
+ ]
329
+ : []),
330
+ ];
255
331
  // PRI-630: 修复轮 (repairPayload 存在) 时解析上轮评估上下文
256
332
  let previousEvaluation;
257
333
  if (dependencyRepairPayload) {
@@ -265,6 +341,7 @@ export class EvaluatorRunner extends BasePeerRunner {
265
341
  sourceScribeArtifactId: scribeRef,
266
342
  ...(dependencyRepairPayload !== undefined ? { dependencyRepairPayload } : {}),
267
343
  ...(previousEvaluation !== undefined ? { previousEvaluation } : {}),
344
+ ...(formationContext !== undefined ? { formationContext } : {}),
268
345
  };
269
346
  }
270
347
  }
@@ -285,6 +362,21 @@ export class EvaluatorRunner extends BasePeerRunner {
285
362
  systemPrompt,
286
363
  });
287
364
  }
365
+ /**
366
+ * PRI-843: narrow task view for formation-context resolution (the scribe
367
+ * adapter, verbatim): phase identity lives on the task row, never on the
368
+ * artifact, so the diagnostic predecessor can only be found via task lookup.
369
+ */
370
+ async lookupFormationTask(taskId) {
371
+ const task = await this.stateManager.getTask(taskId);
372
+ if (!task)
373
+ return null;
374
+ return {
375
+ taskKind: task.taskKind,
376
+ status: task.status,
377
+ dependencyTaskIds: hydratePITaskRecord(task)?.dependencyTaskIds ?? [],
378
+ };
379
+ }
288
380
  /**
289
381
  * PRI-630 收敛契约 (SPEC §18.1): 解析上轮评估上下文 — 从 dependency
290
382
  * artificer 的 repairPayload.sourceEvaluatorTaskId 找到上轮 evaluator,
@@ -434,6 +526,9 @@ export class EvaluatorRunner extends BasePeerRunner {
434
526
  // injected as its own block). Absent on pre-contract artifacts →
435
527
  // undefined → prompt unchanged (backward compatible).
436
528
  intentContract: extractIntentContract(parsedScribeArtifact) ?? undefined,
529
+ // PRI-843: bounded formation evidence (undefined keeps the prompt payload
530
+ // byte-identical to its pre-PRI-843 shape).
531
+ formationContext: context.formationContext,
437
532
  });
438
533
  return { message, systemPrompt };
439
534
  }
@@ -770,6 +865,7 @@ export class EvaluatorRunner extends BasePeerRunner {
770
865
  output: finalOutput,
771
866
  sourceArtificerArtifactId: sourceArtificerArtifactIdForGovernance,
772
867
  diagnosticReplayEvidence,
868
+ formationContextPresent: context.formationContext !== undefined,
773
869
  });
774
870
  // ── P0 (verdict drift): verdict + completion intent 原子落库 ──
775
871
  // 必须先于一切治理 side effect (validate bearer / seed repair / rule
@@ -806,6 +902,8 @@ export class EvaluatorRunner extends BasePeerRunner {
806
902
  taskId, runId, finalOutput, task, artifactId, contextHash, sourceArtificerArtifactId, ruleAssemblyInput,
807
903
  // 执行时权威事实:仅本次 succeedTask 真正运行了诊断重放才存在
808
904
  diagnosticReplayEvidence,
905
+ // PRI-843: mismatch 处置在效果层先于一切 decision 分支执行
906
+ ...(governanceEffect !== undefined ? { governanceEffect } : {}),
809
907
  ...(approvedReplayFailed ? { transitionDecisionOverride: 'needs_revision' } : {}),
810
908
  });
811
909
  if (effectResult.kind === 'human_review') {
@@ -855,6 +953,47 @@ export class EvaluatorRunner extends BasePeerRunner {
855
953
  */
856
954
  async applyEvaluatorDecisionEffects(args) {
857
955
  const { taskId, runId, finalOutput, task, artifactId, contextHash, sourceArtificerArtifactId, diagnosticReplayEvidence } = args;
956
+ // ── PRI-843: Principle↔Pain mismatch preempts all decision effects ──
957
+ // Both exits below are wrong for a Principle-level finding: `approved`
958
+ // would validate the bearer and assemble a rule for a chain whose
959
+ // principle misses the source pain, and `needs_revision` would seed a
960
+ // rule repair that can never satisfy a principle-level demand (the SPEC's
961
+ // death loop). The Owner is the only meaningful exit — the PRI-703
962
+ // evaluator_test_out_of_scope precedent applied BEFORE the decision
963
+ // branches. Owner verdict override (decisionOverride path) never passes a
964
+ // governanceEffect, so an Owner accept/reject after review still works.
965
+ if (args.governanceEffect?.selectedEffect === 'needs_human_review'
966
+ && args.governanceEffect.effectReasonCode === HUMAN_REVIEW_REASON.principlePainMismatch) {
967
+ const resultRef = `${this.config.resultRefPrefix}://${runId}`;
968
+ // Fail loud (rc-9): NHR is this completion's materialize operation —
969
+ // same contract as the repair-loop NHR paths below.
970
+ await this.markNeedsHumanReviewOrThrow(taskId, {
971
+ runId,
972
+ reasonCode: HUMAN_REVIEW_REASON.principlePainMismatch,
973
+ sourceArtifactId: artifactId,
974
+ });
975
+ this.emitEvent('task_needs_human_review', taskId, {
976
+ attemptCount: task.attemptCount,
977
+ resultRef,
978
+ evaluationDecision: finalOutput.evaluation.decision,
979
+ evaluationScore: finalOutput.evaluation.score,
980
+ ruleArtifactId: null,
981
+ reason: HUMAN_REVIEW_REASON.principlePainMismatch,
982
+ });
983
+ return {
984
+ kind: 'human_review',
985
+ result: {
986
+ status: 'succeeded',
987
+ taskId,
988
+ runId,
989
+ artifactId,
990
+ resultRef,
991
+ contextHash,
992
+ output: finalOutput,
993
+ attemptCount: task.attemptCount,
994
+ },
995
+ };
996
+ }
858
997
  // PRI-758: transitionDecisionOverride routes approved+replay-failed into
859
998
  // the needs_revision repair branch (see the caller). Owner override
860
999
  // (decisionOverride) still takes precedence over both.
@@ -1591,6 +1730,24 @@ export class EvaluatorRunner extends BasePeerRunner {
1591
1730
  }
1592
1731
  }
1593
1732
  async deriveGovernanceEffect(evaluatorTaskId, ctx) {
1733
+ // ── PRI-843: Principle↔Pain mismatch → Owner review ──
1734
+ // A mismatch finding is a PRINCIPLE-level question. The only machine exit
1735
+ // below is the artificer repair loop, which can only regenerate the RULE —
1736
+ // seeding it on a principle-level demand is the structural death loop the
1737
+ // SPEC forbids (same shape as PRI-703's evaluator_test_out_of_scope), and
1738
+ // `requiredChanges` may not carry it either. Route to Owner review
1739
+ // instead, mirroring that precedent. Honored only when formation evidence
1740
+ // was actually injected: without it the model has no pain evidence to
1741
+ // cite, so a marker would be hallucination, not signal.
1742
+ if (ctx.formationContextPresent && hasPrinciplePainMismatchConcern(ctx.output)) {
1743
+ this.emitEvent('governance_effect_principle_pain_mismatch_selected', evaluatorTaskId, {
1744
+ nextAction: 'owner_decision_required_principle_pain_mismatch',
1745
+ });
1746
+ return {
1747
+ selectedEffect: 'needs_human_review',
1748
+ effectReasonCode: HUMAN_REVIEW_REASON.principlePainMismatch,
1749
+ };
1750
+ }
1594
1751
  if (ctx.output.evaluation?.decision !== 'needs_revision')
1595
1752
  return undefined;
1596
1753
  if (!this.isRepairLoopEnabled())