@principles/core 1.275.2 → 1.276.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 (35) hide show
  1. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.d.ts +2 -0
  2. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.d.ts.map +1 -0
  3. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.js +377 -0
  4. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.js.map +1 -0
  5. package/dist/runtime-v2/internalization/__tests__/progressive-disclosure-spike.test.js +8 -8
  6. package/dist/runtime-v2/internalization/__tests__/progressive-disclosure-spike.test.js.map +1 -1
  7. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.d.ts +2 -0
  8. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.d.ts.map +1 -0
  9. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.js +628 -0
  10. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.js.map +1 -0
  11. package/dist/runtime-v2/internalization/artificer-runner.d.ts +23 -0
  12. package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  13. package/dist/runtime-v2/internalization/artificer-runner.js +104 -13
  14. package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  15. package/dist/runtime-v2/internalization/context-manifests.d.ts +90 -17
  16. package/dist/runtime-v2/internalization/context-manifests.d.ts.map +1 -1
  17. package/dist/runtime-v2/internalization/context-manifests.js +124 -27
  18. package/dist/runtime-v2/internalization/context-manifests.js.map +1 -1
  19. package/dist/runtime-v2/internalization/context-resolution.d.ts +189 -0
  20. package/dist/runtime-v2/internalization/context-resolution.d.ts.map +1 -0
  21. package/dist/runtime-v2/internalization/context-resolution.js +317 -0
  22. package/dist/runtime-v2/internalization/context-resolution.js.map +1 -0
  23. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +32 -0
  24. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  25. package/dist/runtime-v2/internalization/evaluator-runner.js +72 -7
  26. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  27. package/dist/runtime-v2/runner/base-peer-runner.d.ts +62 -17
  28. package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  29. package/dist/runtime-v2/runner/base-peer-runner.js +116 -10
  30. package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  31. package/dist/telemetry-event.d.ts +2 -2
  32. package/dist/telemetry-event.d.ts.map +1 -1
  33. package/dist/telemetry-event.js +47 -0
  34. package/dist/telemetry-event.js.map +1 -1
  35. package/package.json +1 -1
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Shared Information Plane — context resolution composition (design §6.4/§6.6).
3
+ *
4
+ * Pure logic only: no I/O, no fs, no DB, no network (Core vs Plugin boundary,
5
+ * AGENTS.md `antipattern-core-io`).
6
+ *
7
+ * This module is the seam that turns three independent fact-acquisition
8
+ * channels into ONE `available` map consumed by `resolveInjection`:
9
+ *
10
+ * 1. predecessor summary envelope → `summary-field-reader` (pure, Layer 1)
11
+ * 2. ancestry content → `CandidateLineage` nodes (Layer 2; the
12
+ * traversal/I/O is owned by the caller).
13
+ * Serves BOTH `<stage>.raw.*` and
14
+ * `<stage>.summary.*` for any ancestor.
15
+ * 3. related references → explicit caller-provided sources
16
+ * (e.g. the PR-A replay evidence), which
17
+ * are causal references — NOT ancestry
18
+ *
19
+ * Why three channels stay separate at acquisition but merge at composition
20
+ * (design §33 / INV-LINEAGE-SCOPE): `lineageArtifactIds` expresses *content
21
+ * ancestry*; a repair's `sourceEvaluatorTaskId` expresses *causal reference*.
22
+ * Collapsing them into one data structure would silently redefine what
23
+ * "lineage" means. They are unified at read time, never at write time.
24
+ *
25
+ * rc-1/rc-5: every source `contentJson` stays `unknown`; all reads use
26
+ * `Object.hasOwn` + typeof/Array.isArray guards — no `as` casts.
27
+ */
28
+ import { readSummaryField } from './summary-field-reader.js';
29
+ import { deriveArtifactSummary, SUMMARY_RUNNER_KINDS, } from './artifact-summary.js';
30
+ /**
31
+ * Split a manifest field path into namespace / layer / rest.
32
+ * Returns null for paths that do not follow the grammar (e.g. malformed,
33
+ * too short) so callers can skip them instead of throwing.
34
+ */
35
+ export function parseContextPath(fieldPath) {
36
+ const parts = fieldPath.split('.');
37
+ if (parts.length < 3)
38
+ return null;
39
+ const [namespace, layer] = parts;
40
+ const rest = parts.slice(2);
41
+ if (namespace === undefined || namespace === '')
42
+ return null;
43
+ if (layer !== 'raw' && layer !== 'summary' && layer !== 'predecessorSummary')
44
+ return null;
45
+ if (rest.length === 0 || rest.some((segment) => segment === ''))
46
+ return null;
47
+ return { namespace, layer, rest };
48
+ }
49
+ // ── Pure raw field reader (design §16–§18) ──────────────────────────────────
50
+ /**
51
+ * Keys that must never be traversed: reading them is how prototype pollution
52
+ * enters a context map. Rejected at every segment, not just the first.
53
+ */
54
+ const FORBIDDEN_SEGMENTS = new Set([
55
+ '__proto__',
56
+ 'constructor',
57
+ 'prototype',
58
+ ]);
59
+ function isRecord(value) {
60
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
61
+ }
62
+ /** A dotted segment addressing an array element, e.g. `0` in `candidates.0`. */
63
+ const ARRAY_INDEX = /^(0|[1-9][0-9]*)$/;
64
+ /**
65
+ * Read a dotted path out of an untrusted contentJson (rc-1/rc-5).
66
+ *
67
+ * Supports array element addressing via numeric segments
68
+ * (`candidates.0.betterDecision`) because several durable artifacts nest their
69
+ * semantic payload under an array (DreamerOutput.candidates). No I/O, no
70
+ * lineage traversal, no manifest knowledge — it only walks a path.
71
+ *
72
+ * Returns undefined for: non-object intermediates, missing own properties,
73
+ * out-of-range or non-numeric array access, and forbidden keys.
74
+ */
75
+ export function readRawField(rawPath, contentJson) {
76
+ let current = contentJson;
77
+ for (const segment of rawPath) {
78
+ if (FORBIDDEN_SEGMENTS.has(segment))
79
+ return undefined;
80
+ if (Array.isArray(current)) {
81
+ if (!ARRAY_INDEX.test(segment))
82
+ return undefined;
83
+ if (!Object.hasOwn(current, segment))
84
+ return undefined;
85
+ current = current[Number(segment)];
86
+ continue;
87
+ }
88
+ if (!isRecord(current))
89
+ return undefined;
90
+ if (!Object.hasOwn(current, segment))
91
+ return undefined;
92
+ current = current[segment];
93
+ }
94
+ return current;
95
+ }
96
+ // ── Channel 2: ancestry raw resolution (CandidateLineage) ───────────────────
97
+ /**
98
+ * A manifest NAMESPACE is a *semantic* stage; a lineage node's stage is the
99
+ * *producer taskKind* (two-hop F1). Explicit fixed mapping — never fuzzy:
100
+ *
101
+ * diagnostician → the manifest addresses the final diagnosis artifact
102
+ * (DiagnosticianOutputV1). Its canonical producer on the DEFAULT split
103
+ * pipeline is taskKind `diag_router` (SplitDiagnosticianRunner stage C);
104
+ * the legacy monolithic runner committed the identical output contract
105
+ * under taskKind `diagnostician`. Both must resolve the same namespace.
106
+ *
107
+ * Adding an alias here is a contract change — the resolver's nearest-match
108
+ * then accepts the listed producer kinds for that namespace.
109
+ */
110
+ export const SEMANTIC_STAGE_ALIASES = {
111
+ diagnostician: ['diagnostician', 'diag_router'],
112
+ };
113
+ /**
114
+ * Producer taskKind used for the read-time summary projection (below).
115
+ * `diagnostician` is NOT a SummaryRunnerKind, but its output is byte-for-byte
116
+ * the diag_router contract, so the derivation reuses the diag_router resolver.
117
+ */
118
+ const SUMMARY_DERIVATION_STAGE = {
119
+ diagnostician: 'diag_router',
120
+ };
121
+ /**
122
+ * Read `<stage>.summary.<key>` from an ancestry node, with a bounded
123
+ * read-time projection fallback.
124
+ *
125
+ * Why the fallback exists (review round): the writer-side envelope for diag
126
+ * outputs is SKIPPED (`output_summary_key_collision`, base-peer-runner) —
127
+ * DiagnosticianOutputV1 owns a top-level `summary` STRING that the Layer 0
128
+ * envelope must not overwrite. So `diagnostician.summary.rootSymptom` /
129
+ * `category` would be structurally absent forever. The fields are derivable
130
+ * from the unchanged durable output via the SAME derivation the writer would
131
+ * have used (`deriveArtifactSummary`, pure, no I/O), so the read side applies
132
+ * it as a bounded projection. Deterministic: same output → same fields. Only
133
+ * fires when the direct envelope read misses; still-absent → `absent` floor.
134
+ */
135
+ function readSummaryWithProjection(fieldPath, stage, contentJson) {
136
+ const direct = readSummaryField(fieldPath, contentJson);
137
+ if (direct !== undefined)
138
+ return direct;
139
+ if (!isRecord(contentJson))
140
+ return undefined;
141
+ const derivationStage = SUMMARY_DERIVATION_STAGE[stage]
142
+ ?? (SUMMARY_RUNNER_KINDS.includes(stage) ? stage : undefined);
143
+ if (derivationStage === undefined)
144
+ return undefined;
145
+ const derived = deriveArtifactSummary(derivationStage, contentJson);
146
+ if (!derived.ok)
147
+ return undefined;
148
+ const parsed = parseContextPath(fieldPath);
149
+ if (parsed === null)
150
+ return undefined;
151
+ const [key] = parsed.rest;
152
+ if (key === undefined || FORBIDDEN_SEGMENTS.has(key))
153
+ return undefined;
154
+ if (key === 'headline')
155
+ return derived.value.headline;
156
+ if (!Object.hasOwn(derived.value.fields, key))
157
+ return undefined;
158
+ return derived.value.fields[key];
159
+ }
160
+ /**
161
+ * Convert CandidateLineage nodes into raw stage sources.
162
+ *
163
+ * Order is preserved, which is what makes stage selection deterministic:
164
+ * `CandidateLineage.resolve` walks BFS from the start artifact, so the FIRST
165
+ * node matching a stage is the NEAREST ancestor (design §20). Later duplicates
166
+ * are ignored — never a positional/arbitrary pick.
167
+ *
168
+ * Nodes whose stage could not be determined (`taskKind === 'unknown'`) carry no
169
+ * stage authority and are dropped.
170
+ */
171
+ export function toRawStageSources(nodes) {
172
+ const sources = [];
173
+ for (const node of nodes) {
174
+ if (node.taskKind === 'unknown' || node.taskKind === '')
175
+ continue;
176
+ sources.push({ stage: node.taskKind, contentJson: node.contentJson });
177
+ }
178
+ return sources;
179
+ }
180
+ /**
181
+ * Split a manifest's tier2 into (ancestry raw paths, related raw paths).
182
+ *
183
+ * Related namespaces are excluded from the ancestry walk explicitly: a related
184
+ * reference is a causal pointer supplied by the caller, so it must never be
185
+ * mistaken for an ancestor stage — even if a taskKind happened to share the
186
+ * name. This is the executable form of INV-LINEAGE-SCOPE (design §33).
187
+ */
188
+ export function partitionTier2Paths(tier2Paths, relatedNamespaces) {
189
+ const related = new Set(relatedNamespaces);
190
+ const ancestry = [];
191
+ const relatedPaths = [];
192
+ for (const fieldPath of tier2Paths) {
193
+ const parsed = parseContextPath(fieldPath);
194
+ if (parsed !== null && parsed.layer === 'raw' && related.has(parsed.namespace)) {
195
+ relatedPaths.push(fieldPath);
196
+ continue;
197
+ }
198
+ ancestry.push(fieldPath);
199
+ }
200
+ return { ancestry, related: relatedPaths };
201
+ }
202
+ /**
203
+ * Resolve ancestor-declared paths against ancestry sources — BOTH layers:
204
+ *
205
+ * `<stage>.raw.<dotted.path>` — full contentJson walk (`readRawField`)
206
+ * `<stage>.summary.<key>` — the ancestor's own Layer 0 envelope
207
+ * (`readSummaryField`)
208
+ *
209
+ * Why the summary layer needs the ancestry channel too (PR B, evidence-backed):
210
+ * `readSummaryField` deliberately STRIPS the leading `<stage>.` namespace and
211
+ * reads only its single `predecessorContentJson`. That convention is correct
212
+ * for manifests whose stage namespace is the runner's direct predecessor
213
+ * (dreamer/scribe/artificer), but a manifest that names an ancestor further up
214
+ * the chain (the Evaluator's `scribe.*` / `dreamer.*` / `diagnostician.*`)
215
+ * would otherwise have those paths structurally unreachable — they would land
216
+ * in `absent` forever and force the information-floor fallback on every run.
217
+ * The lineage walk already holds every ancestor's contentJson, so the same
218
+ * traversal that serves `raw` also serves `summary`, with no extra store read.
219
+ *
220
+ * First (nearest) matching stage wins; unresolvable paths are omitted so the
221
+ * caller's information-floor logic records them in `absent`.
222
+ *
223
+ * `predecessorSummary` is intentionally NOT answered here: it is the
224
+ * direct-predecessor forwarding concept owned by Channel 1.
225
+ *
226
+ * Namespace → node matching honors `SEMANTIC_STAGE_ALIASES`: a manifest
227
+ * namespace is the SEMANTIC stage, a node's stage is the producer taskKind.
228
+ */
229
+ export function resolveAncestryPaths(fieldPaths, sources) {
230
+ const resolved = new Map();
231
+ for (const fieldPath of fieldPaths) {
232
+ const parsed = parseContextPath(fieldPath);
233
+ if (parsed === null)
234
+ continue;
235
+ if (parsed.layer === 'predecessorSummary')
236
+ continue;
237
+ const producerStages = [
238
+ parsed.namespace,
239
+ ...(SEMANTIC_STAGE_ALIASES[parsed.namespace] ?? []),
240
+ ];
241
+ const source = sources.find((candidate) => producerStages.includes(candidate.stage));
242
+ if (source === undefined)
243
+ continue;
244
+ const value = parsed.layer === 'raw'
245
+ ? readRawField(parsed.rest, source.contentJson)
246
+ : readSummaryWithProjection(fieldPath, source.stage, source.contentJson);
247
+ if (value !== undefined)
248
+ resolved.set(fieldPath, value);
249
+ }
250
+ return resolved;
251
+ }
252
+ /**
253
+ * Resolve `<ns>.summary.<key>` / `<ns>.raw.<key>` against related sources.
254
+ * Related refs expose flat keys only — a multi-segment rest path is not a
255
+ * related reference and is skipped (it belongs to the ancestry reader).
256
+ */
257
+ export function resolveRelatedPaths(fieldPaths, sources) {
258
+ const resolved = new Map();
259
+ for (const fieldPath of fieldPaths) {
260
+ const parsed = parseContextPath(fieldPath);
261
+ if (parsed === null)
262
+ continue;
263
+ if (parsed.rest.length !== 1)
264
+ continue;
265
+ if (parsed.layer === 'predecessorSummary')
266
+ continue;
267
+ const source = sources.find((candidate) => candidate.namespace === parsed.namespace);
268
+ if (source === undefined)
269
+ continue;
270
+ const table = parsed.layer === 'raw' ? source.raw : source.summary;
271
+ if (table === undefined)
272
+ continue;
273
+ const [key] = parsed.rest;
274
+ if (key === undefined || FORBIDDEN_SEGMENTS.has(key))
275
+ continue;
276
+ if (!Object.hasOwn(table, key))
277
+ continue;
278
+ const value = table[key];
279
+ if (value !== undefined)
280
+ resolved.set(fieldPath, value);
281
+ }
282
+ return resolved;
283
+ }
284
+ // ── Composition ─────────────────────────────────────────────────────────────
285
+ /**
286
+ * Merge the channel maps into one `available` map. FIRST WRITER WINS: the
287
+ * predecessor summary envelope is the highest-authority local source, then
288
+ * ancestry raw, then related. Channel namespaces are disjoint by construction
289
+ * (a path is either a summary path, an ancestry raw path, or a related path),
290
+ * so the rule only matters defensively — but it keeps the result deterministic.
291
+ */
292
+ export function mergeContextFields(base, extras) {
293
+ const merged = new Map(base);
294
+ for (const extra of extras) {
295
+ for (const [fieldPath, value] of extra) {
296
+ if (!merged.has(fieldPath))
297
+ merged.set(fieldPath, value);
298
+ }
299
+ }
300
+ return merged;
301
+ }
302
+ // ── Information floor: required-evidence gate (design §33–§37) ──────────────
303
+ /**
304
+ * Required paths that did NOT reach the prompt — either absent from the
305
+ * available map or dropped/truncated by the budget.
306
+ *
307
+ * This is the regression guard for "Stage2 enabled + raw fields silently
308
+ * absent": a required field that was truncated by `PromptBudgetManager` counts
309
+ * as unresolved just like an absent one, because the runner's semantic
310
+ * requirement was still not met.
311
+ */
312
+ export function findUnresolvedRequiredPaths(params) {
313
+ const absentPaths = new Set(params.absent);
314
+ const truncatedPaths = new Set(params.truncated.map((record) => record.fieldPath));
315
+ return params.required.filter((path) => absentPaths.has(path) || truncatedPaths.has(path));
316
+ }
317
+ //# sourceMappingURL=context-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-resolution.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AAoB/B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;IACjC,MAAM,IAAI,GAAG,KAAK,CAAC,K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AAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAkC,EAClC,MAA+C;IAE/C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAkB,IAAI,CAAC,CAAC;IAC9C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAI3C;IACC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAC3B,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,CAC5D,CAAC;AACJ,CAAC"}
@@ -33,6 +33,7 @@ import { type PreviousEvaluationContext, type HostToolCatalogFacts } from './eva
33
33
  import { type InternalizationChannel, type ArtifactRef } from './peer-runner-contracts.js';
34
34
  import { BasePeerRunner } from '../runner/base-peer-runner.js';
35
35
  import type { PeerRunnerOptions, PeerRunnerDeps, PeerRunnerResult, PeerRunnerValidationResult } from '../runner/peer-runner-types.js';
36
+ import type { EffectivePdConfig } from '../config/pd-config-types.js';
36
37
  import { type RefinerRuleHostGateDeps } from './refiner-rulehost-gate.js';
37
38
  /** Context built by EvaluatorRunner.buildContext() and consumed by invokeRuntime(). */
38
39
  interface EvaluatorContext {
@@ -87,6 +88,14 @@ export interface EvaluatorRunnerOptions extends PeerRunnerOptions {
87
88
  * 工具名差异不得成为 hard blocker。
88
89
  */
89
90
  readonly hostToolCatalog?: HostToolCatalogFacts;
91
+ /**
92
+ * PR B (ADR-0019 pattern, mirrors ArtificerRunner): effective config for
93
+ * feature flag resolution. Without it the evaluator's flag helpers
94
+ * (progressive_evaluator / context_manifest_budget) always saw undefined and
95
+ * silently stayed legacy — the two-stage path could never be enabled even
96
+ * when the config asked for it.
97
+ */
98
+ readonly effectiveConfig?: EffectivePdConfig;
90
99
  }
91
100
  export interface ResolvedEvaluatorRunnerOptions {
92
101
  readonly pollIntervalMs: number;
@@ -120,6 +129,16 @@ export interface SeedArtificerRepairParams {
120
129
  /** Input artifact refs inherited from the original artificer task. */
121
130
  readonly inheritedInputArtifactRefs: readonly ArtifactRef[];
122
131
  }
132
+ /**
133
+ * Outcome of resolving a Stage-2 prompt's required deep evidence (review
134
+ * round). Drives the fail-loud gate in the progressive path.
135
+ */
136
+ export type EvaluatorStage2Evidence = {
137
+ readonly state: 'not_stage2' | 'focused' | 'fallback_other';
138
+ } | {
139
+ readonly state: 'required_unavailable';
140
+ readonly unresolvedRequired: readonly string[];
141
+ };
123
142
  export interface EvaluatorRunnerDeps extends PeerRunnerDeps {
124
143
  readonly validator: EvaluatorValidator;
125
144
  /**
@@ -208,6 +227,19 @@ export declare class EvaluatorRunner extends BasePeerRunner<EvaluatorContext, Ev
208
227
  * 解析失败 → 结构化降级事件 + undefined (保持既有行为,可观测)。
209
228
  */
210
229
  private resolvePreviousEvaluation;
230
+ /**
231
+ * Stage 2 required-evidence outcome (review round / information floor):
232
+ * - `focused` — required tier2 (`diagnostician.raw.evidence`,
233
+ * `dreamer.raw.candidates`) resolved from the
234
+ * durable CandidateLineage.
235
+ * - `fallback_other` — non-required fallback (envelope sparsity, budget
236
+ * flag off): the full artificer artifact is used,
237
+ * which is the pre-PR-B legacy assembly.
238
+ * - `required_unavailable` — REQUIRED deep evidence is absent/truncated or
239
+ * the lineage is corrupt. No safe legacy fallback
240
+ * exists for a deep-evidence stage: the caller MUST
241
+ * refuse to send the Stage 2 prompt.
242
+ */
211
243
  private buildEvaluatorPrompt;
212
244
  /** Original single-stage invokeRuntime (flag-off path). */
213
245
  private invokeRuntimeSingleStage;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluator-runner.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/evaluator-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EACV,iBAAiB,EAEjB,kBAAkB,EAInB,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAkB,KAAK,eAAe,EAAqB,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAwE,KAAK,aAAa,EAAqE,MAAM,sBAAsB,CAAC;AAQnM,OAAO,EAAmD,KAAK,yBAAyB,EAAE,KAAK,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC3J,OAAO,EAAwB,KAAK,sBAAsB,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACjH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,gCAAgC,CAAC;AAKxC,OAAO,EAA+B,KAAK,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAWvG,uFAAuF;AACvF,UAAU,gBAAgB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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;IAoNxC;;;OAGG;IAEH,OAAO,CAAC,sBAAsB;IAyB9B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,MAAM,CAAC,8BAA8B;IA8B7C;;;;;;OAMG;IAEH,OAAO,CAAC,oBAAoB;IAO5B;;;;;;;;;;;;;;;OAeG;IAEH,OAAO,CAAC,4BAA4B;IAmFpC;;;;;;;;;OASG;IAEH,OAAO,CAAC,cAAc;IA0DtB;;;;;;;;;;OAUG;YAEW,oBAAoB;IAwLlC;;;;;;;;;;OAUG;YACW,8BAA8B;IAmE5C;;;OAGG;IAEH,OAAO,CAAC,wBAAwB;IAwBhC,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB;;;;;;;;;;;OAWG;YACW,oCAAoC;CA+BnD"}
@@ -200,6 +200,9 @@ export class EvaluatorRunner extends BasePeerRunner {
200
200
  expectedTaskKind: 'evaluator',
201
201
  defaultAgentId: 'evaluator',
202
202
  resultRefPrefix: 'evaluator',
203
+ // PR B: forward effectiveConfig so the flag helpers (progressive
204
+ // evaluator / manifest budget) can actually read the config (ADR-0019).
205
+ effectiveConfig: options.effectiveConfig,
203
206
  });
204
207
  this.validator = deps.validator;
205
208
  this.gateDeps = options.gateDeps ?? null;
@@ -309,7 +312,7 @@ export class EvaluatorRunner extends BasePeerRunner {
309
312
  // ── Two-stage progressive evaluation ──
310
313
  // Stage 1: summary-level evaluation (same prompt as single-stage, but
311
314
  // uses EVALUATOR_STAGE1_MANIFEST for focused context).
312
- const stage1Message = this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE1_MANIFEST);
315
+ const { message: stage1Message } = await this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE1_MANIFEST);
313
316
  const stage1Output = await this.runSingleEvaluation(taskId, stage1Message);
314
317
  // 9.4c (design §6.5.4): Stage 1 output contract violation check.
315
318
  // Detect malformed Stage 1 output shapes that Phase 0 testing identified:
@@ -345,7 +348,24 @@ export class EvaluatorRunner extends BasePeerRunner {
345
348
  // Stage 2 triggered: independent re-evaluation with tier2 context.
346
349
  // rc-7 / ERR-015 / ERR-018 / ERR-019: Stage 2 does NOT receive Stage 1
347
350
  // output, concerns, or the FlaggedDecision. It is a fully independent call.
348
- const stage2Message = this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE2_MANIFEST);
351
+ const { message: stage2Message, stage2Evidence } = await this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE2_MANIFEST);
352
+ if (stage2Evidence.state === 'required_unavailable') {
353
+ // Review round (information floor): Stage 2 is the deep-evidence stage;
354
+ // its REQUIRED evidence is unavailable, so there is NO safe fallback
355
+ // that still carries it — the full artificer artifact is the
356
+ // implementer's view, not the pain/dreamer deep evidence. Telemetry
357
+ // alone is not correctness: issuing an authoritative verdict from a
358
+ // Stage-2 prompt that lacks its declared evidence would silently
359
+ // proceed. Refuse the LLM round entirely (0 extra calls) and fail
360
+ // loud (input_invalid is permanent — no blind retry), mirroring the
361
+ // PR-A repair-evidence-unavailable contract.
362
+ this.emitEvent('stage2_required_evidence_unavailable', taskId, {
363
+ manifestId: EVALUATOR_STAGE2_MANIFEST.manifestId,
364
+ requiredPaths: stage2Evidence.unresolvedRequired,
365
+ nextAction: 'verify_durable_diagnosis_and_dreamer_ancestry_before_reevaluation',
366
+ });
367
+ throw new PDRuntimeError('input_invalid', `evaluator stage2: required tier2 evidence unavailable (${stage2Evidence.unresolvedRequired.join(', ')}) — refusing to issue a deep-evidence verdict without it.`);
368
+ }
349
369
  const stage2Output = await this.runSingleEvaluation(taskId, stage2Message);
350
370
  this.progressiveFinalOutput = stage2Output;
351
371
  this.progressiveRunActive = true;
@@ -494,7 +514,20 @@ export class EvaluatorRunner extends BasePeerRunner {
494
514
  ...(repairSummary !== undefined ? { repairSummary } : {}),
495
515
  };
496
516
  }
497
- buildEvaluatorPrompt(taskId, context, manifest) {
517
+ /**
518
+ * Stage 2 required-evidence outcome (review round / information floor):
519
+ * - `focused` — required tier2 (`diagnostician.raw.evidence`,
520
+ * `dreamer.raw.candidates`) resolved from the
521
+ * durable CandidateLineage.
522
+ * - `fallback_other` — non-required fallback (envelope sparsity, budget
523
+ * flag off): the full artificer artifact is used,
524
+ * which is the pre-PR-B legacy assembly.
525
+ * - `required_unavailable` — REQUIRED deep evidence is absent/truncated or
526
+ * the lineage is corrupt. No safe legacy fallback
527
+ * exists for a deep-evidence stage: the caller MUST
528
+ * refuse to send the Stage 2 prompt.
529
+ */
530
+ async buildEvaluatorPrompt(taskId, context, manifest) {
498
531
  let parsedArtificerArtifact = null;
499
532
  if (context.artificerArtifact) {
500
533
  try {
@@ -513,12 +546,44 @@ export class EvaluatorRunner extends BasePeerRunner {
513
546
  parsedScribeArtifact = context.scribeArtifact;
514
547
  }
515
548
  }
516
- // Resolve manifest-injected focused fields (Layer 1).
549
+ // Resolve manifest-injected focused fields (Layer 1 + PR B tier2).
517
550
  const artificerPred = toArtificerPredecessor(context);
551
+ const isStage2 = manifest.manifestId === EVALUATOR_STAGE2_MANIFEST.manifestId;
552
+ let resolutionOutcome = isStage2
553
+ ? { state: 'fallback_other' }
554
+ : { state: 'not_stage2' };
518
555
  if (artificerPred !== null) {
519
- const resolved = this.resolveContextInjection(taskId, manifest, artificerPred.contentJson);
556
+ // Stage 2 is by definition the deep-evidence stage, so its tier2 raw
557
+ // fields (`diagnostician.raw.evidence`, `dreamer.raw.candidates`) are
558
+ // REQUIRED. When they cannot be resolved from the durable CandidateLineage
559
+ // — or the budget cannot carry them — resolution falls back to the
560
+ // authoritative full artificer artifact rather than injecting a silently
561
+ // thinner context (design §34/§35: no silent required-field loss).
562
+ const requiredPaths = isStage2 ? [...EVALUATOR_STAGE2_MANIFEST.tier2] : [];
563
+ const resolved = await this.resolveContextInjectionAsync({
564
+ taskId,
565
+ manifest,
566
+ predecessorContentJson: artificerPred.contentJson,
567
+ startArtifactId: context.sourceArtificerArtifactId ?? undefined,
568
+ requiredPaths,
569
+ });
520
570
  if (resolved.mode === 'focused') {
521
571
  parsedArtificerArtifact = resolved.fields;
572
+ if (isStage2)
573
+ resolutionOutcome = { state: 'focused' };
574
+ }
575
+ else if (isStage2
576
+ && resolved.mode === 'fallback'
577
+ && (resolved.reason === 'required_evidence_unresolved' || resolved.reason === 'lineage_unavailable')) {
578
+ // Review round: telemetry alone is not correctness. A deep-evidence
579
+ // stage whose REQUIRED evidence is unavailable must NOT proceed —
580
+ // there is no safe legacy fallback that contains the missing evidence
581
+ // (the full artificer artifact is the implementer's view, not the
582
+ // pain/dreamer deep evidence). The caller aborts before any LLM call.
583
+ resolutionOutcome = {
584
+ state: 'required_unavailable',
585
+ unresolvedRequired: resolved.unresolvedRequired,
586
+ };
522
587
  }
523
588
  }
524
589
  const builder = new EvaluatorPromptBuilder();
@@ -531,11 +596,11 @@ export class EvaluatorRunner extends BasePeerRunner {
531
596
  previousEvaluation: context.previousEvaluation,
532
597
  hostToolCatalog: this.hostToolCatalog ?? undefined,
533
598
  });
534
- return message;
599
+ return { message, stage2Evidence: resolutionOutcome };
535
600
  }
536
601
  /** Original single-stage invokeRuntime (flag-off path). */
537
602
  async invokeRuntimeSingleStage(taskId, context) {
538
- const message = this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE1_MANIFEST);
603
+ const { message } = await this.buildEvaluatorPrompt(taskId, context, EVALUATOR_STAGE1_MANIFEST);
539
604
  return this.runtimeAdapter.startRun({
540
605
  agentSpec: { agentId: this.resolvedOptions.agentId, schemaVersion: 'v1' },
541
606
  taskRef: { taskId },