@principles/core 1.275.2 → 1.277.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 (47) hide show
  1. package/dist/runtime-v2/index.d.ts +2 -2
  2. package/dist/runtime-v2/index.d.ts.map +1 -1
  3. package/dist/runtime-v2/index.js +1 -1
  4. package/dist/runtime-v2/index.js.map +1 -1
  5. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.d.ts +2 -0
  6. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.d.ts.map +1 -0
  7. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.js +377 -0
  8. package/dist/runtime-v2/internalization/__tests__/context-resolution.test.js.map +1 -0
  9. package/dist/runtime-v2/internalization/__tests__/progressive-disclosure-spike.test.js +8 -8
  10. package/dist/runtime-v2/internalization/__tests__/progressive-disclosure-spike.test.js.map +1 -1
  11. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.d.ts +2 -0
  12. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.d.ts.map +1 -0
  13. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.js +628 -0
  14. package/dist/runtime-v2/internalization/__tests__/shared-information-plane-runner.test.js.map +1 -0
  15. package/dist/runtime-v2/internalization/artificer-runner.d.ts +23 -0
  16. package/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
  17. package/dist/runtime-v2/internalization/artificer-runner.js +104 -13
  18. package/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
  19. package/dist/runtime-v2/internalization/context-manifests.d.ts +90 -17
  20. package/dist/runtime-v2/internalization/context-manifests.d.ts.map +1 -1
  21. package/dist/runtime-v2/internalization/context-manifests.js +124 -27
  22. package/dist/runtime-v2/internalization/context-manifests.js.map +1 -1
  23. package/dist/runtime-v2/internalization/context-resolution.d.ts +189 -0
  24. package/dist/runtime-v2/internalization/context-resolution.d.ts.map +1 -0
  25. package/dist/runtime-v2/internalization/context-resolution.js +317 -0
  26. package/dist/runtime-v2/internalization/context-resolution.js.map +1 -0
  27. package/dist/runtime-v2/internalization/evaluator-runner.d.ts +32 -0
  28. package/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
  29. package/dist/runtime-v2/internalization/evaluator-runner.js +72 -7
  30. package/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
  31. package/dist/runtime-v2/runner/base-peer-runner.d.ts +62 -17
  32. package/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
  33. package/dist/runtime-v2/runner/base-peer-runner.js +116 -10
  34. package/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
  35. package/dist/runtime-v2/types/event-types.d.ts +27 -3
  36. package/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  37. package/dist/runtime-v2/types/event-types.js +6 -0
  38. package/dist/runtime-v2/types/event-types.js.map +1 -1
  39. package/dist/runtime-v2/types/index.d.ts +2 -2
  40. package/dist/runtime-v2/types/index.d.ts.map +1 -1
  41. package/dist/runtime-v2/types/index.js +1 -1
  42. package/dist/runtime-v2/types/index.js.map +1 -1
  43. package/dist/telemetry-event.d.ts +2 -2
  44. package/dist/telemetry-event.d.ts.map +1 -1
  45. package/dist/telemetry-event.js +47 -0
  46. package/dist/telemetry-event.js.map +1 -1
  47. package/package.json +1 -1
@@ -1,17 +1,28 @@
1
1
  /**
2
- * Layer 1 — the 4 built-in ContextManifests (design §6.6).
2
+ * Layer 1 — the built-in ContextManifests (design §6.6).
3
3
  *
4
4
  * Pure logic only (Core vs Plugin boundary). These are the single source of
5
- * truth for which manifest each peer runner uses; the manifest count is
6
- * exactly 4 (dreamer / scribe / artificer / evaluator, with evaluator carrying
7
- * a Stage 1 + Stage 2 variant). The three diagnostic stages own NO manifest
8
- * (design §4.7.1, requirement 2.14, guarded by the scope-regression test from
9
- * PR 1 task 3.21).
5
+ * truth for which manifest each peer runner uses.
6
+ *
7
+ * INV-MANIFEST-SCOPE: the frozen invariant is **4 manifest-owning runner
8
+ * KINDS** dreamer / scribe / artificer / evaluator, with evaluator carrying
9
+ * a Stage 1 + Stage 2 variant. It is NOT a literal manifest-instance count: a
10
+ * runner kind may own more than one manifest VARIANT when its context needs
11
+ * genuinely differ (e.g. `artificer.repair`, which additionally needs replay /
12
+ * repair evidence a normal artificer must never see). The three diagnostic
13
+ * stages own NO manifest (design §4.7.1, requirement 2.14, guarded by the
14
+ * scope-regression test from PR 1 task 3.21).
10
15
  *
11
16
  * Field-path naming convention (design §6.6):
12
17
  * `<stage>.summary.<key>` — read from an ArtifactSummary
13
18
  * `<stage>.predecessorSummary.*` — read from a forwarded predecessor summary
14
19
  * `<stage>.raw.<path>` — read from tier2 full contentJson (Layer 2)
20
+ * or from a related-reference namespace
21
+ *
22
+ * `<stage>.raw.<path>` paths must be TRUTHFUL: `readRawField` resolves them
23
+ * verbatim against the durable contentJson. Numeric segments address array
24
+ * elements — e.g. `dreamer.raw.candidates.0.betterDecision`, because
25
+ * DreamerOutput nests its 5 dimensions under `candidates[0]`.
15
26
  *
16
27
  * budgetTokens semantics (design §6.2.1 / §6.3): the budget covers ONLY these
17
28
  * manifest-declared injection fields. It does NOT include core grounding text
@@ -91,8 +102,13 @@ export const SCRIBE_MANIFEST = {
91
102
  /**
92
103
  * Artificer manifest. Under the one-level-redundancy rule, dreamer 5 dims are
93
104
  * NOT in scribe.predecessorSummary (that holds philosopher); so artificer's
94
- * dreamer context continues to flow through PRI-508's `resolveDreamerContext`
95
- * (F2) as tier2 raw fields.
105
+ * dreamer context resolves as tier2 raw fields through CandidateLineage (PR B).
106
+ *
107
+ * The tier2 paths address `candidates[0]` explicitly because that is where the
108
+ * durable DreamerOutput keeps the selected candidate's 5 dimensions — the same
109
+ * element `resolveDreamerContext` (PRI-508, F2) reads on the flag-off path.
110
+ * When `context_manifest_budget` is OFF, `resolveDreamerContext` stays the
111
+ * injection channel and this manifest is not consulted (design §23).
96
112
  */
97
113
  export const ARTIFICER_MANIFEST = {
98
114
  manifestId: 'artificer.v1',
@@ -100,24 +116,85 @@ export const ARTIFICER_MANIFEST = {
100
116
  runnerKind: 'artificer',
101
117
  tier0: ['scribe.summary.headline', 'scribe.predecessorSummary.headline'],
102
118
  tier1: ['scribe.summary.principleText', 'scribe.summary.scope', 'scribe.summary.exceptions'],
103
- tier2: ['dreamer.raw.betterDecision', 'dreamer.raw.rationale', 'dreamer.raw.riskLevel'],
119
+ tier2: [
120
+ 'dreamer.raw.candidates.0.betterDecision',
121
+ 'dreamer.raw.candidates.0.rationale',
122
+ 'dreamer.raw.candidates.0.riskLevel',
123
+ ],
104
124
  budgetTokens: 2000,
105
125
  priority: [
106
126
  'scribe.summary.principleText',
107
- 'dreamer.raw.betterDecision',
127
+ 'dreamer.raw.candidates.0.betterDecision',
108
128
  'scribe.summary.scope',
109
- 'dreamer.raw.rationale',
110
- 'dreamer.raw.riskLevel',
129
+ 'dreamer.raw.candidates.0.rationale',
130
+ 'dreamer.raw.candidates.0.riskLevel',
111
131
  'scribe.summary.exceptions',
112
132
  'scribe.summary.headline',
113
133
  'scribe.predecessorSummary.headline',
114
134
  ],
115
135
  };
136
+ /**
137
+ * Artificer REPAIR manifest variant (design §35).
138
+ *
139
+ * A repair round is a different context job than a first-write: it additionally
140
+ * needs the concrete deterministic replay evidence and the evaluator's required
141
+ * changes. Those fields do NOT belong on the normal ARTIFICER_MANIFEST — a
142
+ * first-write artificer has no replay to read and would only be polluted by
143
+ * repair-only namespaces.
144
+ *
145
+ * `replay.*` is a RELATED reference, not ancestry: the source Evaluator
146
+ * artifact is referenced by `RepairPayload.sourceEvaluatorTaskId`, never pushed
147
+ * into `lineageArtifactIds` (design §33 / INV-LINEAGE-SCOPE). The values come
148
+ * from the PR-A `RepairReplayContext`, so the ≤16 bound
149
+ * (MAX_REPLAY_FAILURES_IN_REPAIR) is inherited rather than re-expanded
150
+ * (design §43).
151
+ *
152
+ * Flag-off behaviour is unchanged: when `context_manifest_budget` is false this
153
+ * manifest is never consulted and PR A's `repairFeedback` string remains the
154
+ * replay-evidence channel (PRI-634 invariant §26).
155
+ */
156
+ export const ARTIFICER_REPAIR_MANIFEST = {
157
+ manifestId: 'artificer.repair.v1',
158
+ schemaVersion: CONTEXT_MANIFEST_SCHEMA_VERSION,
159
+ runnerKind: 'artificer',
160
+ tier0: ['scribe.summary.principleText', 'replay.summary.passed', 'replay.summary.failedCaseCount'],
161
+ tier1: ['repair.summary.requiredChanges', 'repair.summary.concerns', 'replay.summary.failureTypes'],
162
+ tier2: ['replay.raw.traceFailures', 'replay.raw.systemFailures', 'replay.raw.globalViolations'],
163
+ budgetTokens: 2400,
164
+ priority: [
165
+ 'scribe.summary.principleText',
166
+ 'replay.raw.traceFailures',
167
+ 'repair.summary.requiredChanges',
168
+ 'replay.raw.systemFailures',
169
+ 'replay.raw.globalViolations',
170
+ 'repair.summary.concerns',
171
+ 'replay.summary.passed',
172
+ 'replay.summary.failedCaseCount',
173
+ 'replay.summary.failureTypes',
174
+ ],
175
+ };
116
176
  /**
117
177
  * Evaluator Stage 1 manifest — summary-level only (no tier2 raw fields).
118
- * Stage 1's `dreamer.summary.*` / `pain.summary.*` are read at the summary
119
- * level via CandidateLineage (Layer 2); if a summary is absent the path enters
120
- * `absent` and surfaces as a `summary_absent` degradation, never a silent empty.
178
+ *
179
+ * NAMESPACE CORRECTION (PR B, fresh-code verification): this manifest names
180
+ * stages that are NOT the Evaluator's direct predecessor (its predecessor is
181
+ * the Artificer; `scribe.*` / `dreamer.*` / `diagnostician.*` sit further up
182
+ * the chain). Layer 1's `readSummaryField` strips the leading `<stage>.`
183
+ * segment and reads only the single loaded predecessor, so those ancestor
184
+ * namespaces are resolved by the PR-B ancestry channel (`resolveAncestryPaths`,
185
+ * which matches a lineage node by producer taskKind) — not by Channel 1.
186
+ *
187
+ * `pain.*` becomes `diagnostician.*` and is resolved through
188
+ * `SEMANTIC_STAGE_ALIASES` (diagnostician → {diagnostician, diag_router}):
189
+ * `pain` is a LOGICAL Layer-1 namespace, never a lineage node; the durable
190
+ * DiagnosticianOutputV1 is owned by the split pipeline's `diag_router`
191
+ * sub-task on the DEFAULT chain (legacy monolith committed it under
192
+ * `diagnostician`). Summary fields on this stage are served by the bounded
193
+ * read-time projection when the writer had to skip the Layer-0 envelope
194
+ * (the output itself owns a top-level `summary` string).
195
+ *
196
+ * If an ancestor summary is absent the path enters `absent` and surfaces as a
197
+ * `summary_absent` degradation, never a silent empty.
121
198
  */
122
199
  export const EVALUATOR_STAGE1_MANIFEST = {
123
200
  manifestId: 'evaluator.stage1.v1',
@@ -134,21 +211,21 @@ export const EVALUATOR_STAGE1_MANIFEST = {
134
211
  'dreamer.summary.betterDecision',
135
212
  'dreamer.summary.rationale',
136
213
  'dreamer.summary.riskLevel',
137
- 'pain.summary.rootSymptom',
138
- 'pain.summary.category',
214
+ 'diagnostician.summary.rootSymptom',
215
+ 'diagnostician.summary.category',
139
216
  ],
140
217
  tier2: [],
141
218
  budgetTokens: 3000,
142
219
  priority: [
143
220
  'scribe.summary.principleText',
144
221
  'dreamer.summary.betterDecision',
145
- 'pain.summary.rootSymptom',
222
+ 'diagnostician.summary.rootSymptom',
146
223
  'artificer.summary.apiSurface',
147
224
  'dreamer.summary.riskLevel',
148
225
  'dreamer.summary.rationale',
149
226
  'scribe.summary.scope',
150
227
  'artificer.summary.risks',
151
- 'pain.summary.category',
228
+ 'diagnostician.summary.category',
152
229
  'artificer.summary.changedFiles',
153
230
  'dreamer.summary.badDecision',
154
231
  'artificer.summary.headline',
@@ -159,19 +236,36 @@ export const EVALUATOR_STAGE1_MANIFEST = {
159
236
  * Evaluator Stage 2 manifest — Stage 1 plus tier2 raw fields for the
160
237
  * independent re-evaluation (design §6.5). budgetTokens is larger to
161
238
  * accommodate the raw fields.
239
+ *
240
+ * SPEC ASSUMPTION STALE (PR B Phase 0, fresh-code verification): the SPEC's
241
+ * example path `pain.raw.evidence` assumed a `pain` stage node on the lineage.
242
+ * `pain` is only a LOGICAL summary namespace — never a lineage node. The
243
+ * ancestry namespace is `diagnostician` (mapped via SEMANTIC_STAGE_ALIASES to
244
+ * the real producer taskKinds):
245
+ *
246
+ * - DEFAULT split chain: the durable DiagnosticianOutputV1 is committed by
247
+ * the `diag_router` sub-task (SplitDiagnosticianRunner stage C) — the node
248
+ * the dreamer lineage actually depends on (candidate.taskId);
249
+ * - legacy monolith: the same contract was committed under taskKind
250
+ * `diagnostician`.
251
+ *
252
+ * So `diagnostician.raw.evidence` reads `DiagnosticianOutputV1.evidence`, and
253
+ * `dreamer.raw.candidates` addresses `DreamerOutput.candidates` directly — the
254
+ * whole array, exactly what the deep-evidence stage reviews.
162
255
  */
163
256
  export const EVALUATOR_STAGE2_MANIFEST = {
164
257
  ...EVALUATOR_STAGE1_MANIFEST,
165
258
  manifestId: 'evaluator.stage2.v1',
166
- tier2: ['pain.raw.evidence', 'dreamer.raw.candidates'],
259
+ tier2: ['diagnostician.raw.evidence', 'dreamer.raw.candidates'],
167
260
  budgetTokens: 4500,
168
- priority: [...EVALUATOR_STAGE1_MANIFEST.priority, 'pain.raw.evidence', 'dreamer.raw.candidates'],
261
+ priority: [...EVALUATOR_STAGE1_MANIFEST.priority, 'dreamer.raw.candidates', 'diagnostician.raw.evidence'],
169
262
  };
170
263
  /**
171
- * The built-in manifest registry. **Always exactly 4** manifests (dreamer /
172
- * scribe / artificer / evaluator-with-two-variants). The three diagnostic
173
- * stages own NO manifest (design §4.7.1, requirement 2.14). The scope-
174
- * regression test (PR 1 task 3.21) guards this count.
264
+ * The built-in manifest registry (INV-MANIFEST-SCOPE): 4 manifest-owning
265
+ * runner KINDS across 6 manifest INSTANCES dreamer, scribe, artificer,
266
+ * artificer.repair, evaluator.stage1, evaluator.stage2. No diagnostic stage
267
+ * owns a manifest (design §4.7.1, requirement 2.14). The scope-regression test
268
+ * guards the runner-kind set, not the instance count.
175
269
  *
176
270
  * Exposed for: well-formedness enumeration (CP-12), the CLI's manifest
177
271
  * resolution, and the architecture-regression assertion that no diag kind is a
@@ -181,12 +275,15 @@ export const BUILTIN_MANIFESTS = [
181
275
  DREAMER_MANIFEST,
182
276
  SCRIBE_MANIFEST,
183
277
  ARTIFICER_MANIFEST,
278
+ ARTIFICER_REPAIR_MANIFEST,
184
279
  EVALUATOR_STAGE1_MANIFEST,
185
280
  EVALUATOR_STAGE2_MANIFEST,
186
281
  ];
187
282
  /**
188
- * The distinct runnerKinds that own a manifest. Always a subset of
189
- * {dreamer, scribe, artificer, evaluator} — never includes a diagnostic kind.
283
+ * The distinct runnerKinds that own a manifest. Always exactly 4 and always a
284
+ * subset of {dreamer, scribe, artificer, evaluator} — never includes a
285
+ * diagnostic kind. Adding a runner-kind VARIANT (not a new kind) leaves this
286
+ * unchanged, which is the intended reading of INV-MANIFEST-SCOPE.
190
287
  */
191
288
  export const MANIFEST_RUNNER_KINDS = Array.from(new Set(BUILTIN_MANIFESTS.map((m) => m.runnerKind)));
192
289
  //# sourceMappingURL=context-manifests.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-manifests.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAoB;IAC/C,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,+BAA+B;IAC9C,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,CAAC,uBAAuB,EAAE,4BAA4B,CAAC;IAC9D,KAAK,EAAE;QACL,uBAAuB;QACvB,uBAAuB;QACvB,0BAA0B;QAC1B,6BAA6B;QAC7B,sCAAsC;KACvC;IACD,KAAK,EAAE,EAAE;IACT,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE;QACR,6BAA6B;QAC7B,0BAA0B;QAC1B,uBAAuB;QACvB,uBAAuB;QACvB,sCAAsC;QACtC,uBAAuB;QACvB,4BAA4B;KAC7B;CACF,CAAC;A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BAA4B,EAAE,uCAAuC,CAAC;IAC9E,KAAK,EAAE;QACL,8BAA8B;QAC9B,sBAAsB;QACtB,gCAAgC;QAChC,8BAA8B;QAC9B,yBAAyB;QACzB,6BAA6B;QAC7B,gCAAgC;QAChC,2BAA2B;QAC3B,2BAA2B;QAC3B,0BAA0B;QAC1B,uBAAuB;KACxB;IACD,KAAK,EAAE,EAAE;IACT,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE;QACR,8BAA8B;QAC9B,gCAAgC;QAChC,0BAA0B;QAC1B,8BAA8B;QAC9B,2BAA2B;QAC3B,2BAA2B;QAC3B,sBAAsB;QACtB,yBAAyB;QACzB,uBAAuB;QACvB,gCAAgC;QAChC,6BAA6B;QAC7B,4BAA4B;QAC5B,uCAAuC;KACxC;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,GAAG,yBAAyB;IAC5B,UAAU,EAAE,qBAAqB;IACjC,KAAK,EAAE,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;IACtD,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,CAAC,GAAG,yBAAyB,CAAC,QAAQ,EAAE,mBAAmB,EAAE,wBAAwB,CAAC;CACjG,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IAC3D,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,yBAAyB;IACzB,yBAAyB;CAC1B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB,KAAK,CAAC,IAAI,CAChE,IAAI,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CACpD,CAAC"}
1
+ {"version":3,"file":"context-manifests.js","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-manifests.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;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yB;QACzB,6BAA6B;QAC7B,gCAAgC;QAChC,2BAA2B;QAC3B,2BAA2B;QAC3B,mCAAmC;QACnC,gCAAgC;KACjC;IACD,KAAK,EAAE,EAAE;IACT,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE;QACR,8BAA8B;QAC9B,gCAAgC;QAChC,mCAAmC;QACnC,8BAA8B;QAC9B,2BAA2B;QAC3B,2BAA2B;QAC3B,sBAAsB;QACtB,yBAAyB;QACzB,gCAAgC;QAChC,gCAAgC;QAChC,6BAA6B;QAC7B,4BAA4B;QAC5B,uCAAuC;KACxC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoB;IACxD,GAAG,yBAAyB;IAC5B,UAAU,EAAE,qBAAqB;IACjC,KAAK,EAAE,CAAC,4BAA4B,EAAE,wBAAwB,CAAC;IAC/D,YAAY,EAAE,IAAI;IAClB,QAAQ,EAAE,CAAC,GAAG,yBAAyB,CAAC,QAAQ,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;CAC1G,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA+B;IAC3D,gBAAgB;IAChB,eAAe;IACf,kBAAkB;IAClB,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;CAC1B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB,KAAK,CAAC,IAAI,CAChE,IAAI,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CACpD,CAAC"}
@@ -0,0 +1,189 @@
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 type { TruncationRecord } from './prompt-budget-manager.js';
29
+ /**
30
+ * Context field path grammar (design §6.6, extended for tier2 + related refs):
31
+ * `<ns>.summary.<key>` — ArtifactSummary / related summary table
32
+ * `<ns>.predecessorSummary.<key>` — forwarded predecessor summary
33
+ * `<ns>.raw.<dotted.path>` — full contentJson (ancestry) or a related
34
+ * raw table (related refs)
35
+ */
36
+ export type ContextPathLayer = 'raw' | 'summary' | 'predecessorSummary';
37
+ export interface ParsedContextPath {
38
+ readonly namespace: string;
39
+ readonly layer: ContextPathLayer;
40
+ /** Path segments after the layer marker. Empty is never valid. */
41
+ readonly rest: readonly string[];
42
+ }
43
+ /**
44
+ * Split a manifest field path into namespace / layer / rest.
45
+ * Returns null for paths that do not follow the grammar (e.g. malformed,
46
+ * too short) so callers can skip them instead of throwing.
47
+ */
48
+ export declare function parseContextPath(fieldPath: string): ParsedContextPath | null;
49
+ /**
50
+ * Read a dotted path out of an untrusted contentJson (rc-1/rc-5).
51
+ *
52
+ * Supports array element addressing via numeric segments
53
+ * (`candidates.0.betterDecision`) because several durable artifacts nest their
54
+ * semantic payload under an array (DreamerOutput.candidates). No I/O, no
55
+ * lineage traversal, no manifest knowledge — it only walks a path.
56
+ *
57
+ * Returns undefined for: non-object intermediates, missing own properties,
58
+ * out-of-range or non-numeric array access, and forbidden keys.
59
+ */
60
+ export declare function readRawField(rawPath: readonly string[], contentJson: unknown): unknown | undefined;
61
+ /**
62
+ * A manifest NAMESPACE is a *semantic* stage; a lineage node's stage is the
63
+ * *producer taskKind* (two-hop F1). Explicit fixed mapping — never fuzzy:
64
+ *
65
+ * diagnostician → the manifest addresses the final diagnosis artifact
66
+ * (DiagnosticianOutputV1). Its canonical producer on the DEFAULT split
67
+ * pipeline is taskKind `diag_router` (SplitDiagnosticianRunner stage C);
68
+ * the legacy monolithic runner committed the identical output contract
69
+ * under taskKind `diagnostician`. Both must resolve the same namespace.
70
+ *
71
+ * Adding an alias here is a contract change — the resolver's nearest-match
72
+ * then accepts the listed producer kinds for that namespace.
73
+ */
74
+ export declare const SEMANTIC_STAGE_ALIASES: Readonly<Record<string, readonly string[]>>;
75
+ /**
76
+ * One durable ancestry node exposed to the raw reader. Built by the caller
77
+ * from `CandidateLineage` nodes — this module never performs the traversal.
78
+ *
79
+ * `stage` is the two-hop `sourceTaskId → task.taskKind` value (design §6.4,
80
+ * F1), never `artifactKind`: every internalization artifact is `principle`,
81
+ * so `artifactKind` carries no stage authority.
82
+ */
83
+ export interface RawStageSource {
84
+ readonly stage: string;
85
+ /** rc-1: stays `unknown`; narrowed only by `readRawField`. */
86
+ readonly contentJson: unknown;
87
+ }
88
+ /**
89
+ * Convert CandidateLineage nodes into raw stage sources.
90
+ *
91
+ * Order is preserved, which is what makes stage selection deterministic:
92
+ * `CandidateLineage.resolve` walks BFS from the start artifact, so the FIRST
93
+ * node matching a stage is the NEAREST ancestor (design §20). Later duplicates
94
+ * are ignored — never a positional/arbitrary pick.
95
+ *
96
+ * Nodes whose stage could not be determined (`taskKind === 'unknown'`) carry no
97
+ * stage authority and are dropped.
98
+ */
99
+ export declare function toRawStageSources(nodes: readonly {
100
+ readonly taskKind: string;
101
+ readonly contentJson: unknown;
102
+ }[]): readonly RawStageSource[];
103
+ /**
104
+ * Split a manifest's tier2 into (ancestry raw paths, related raw paths).
105
+ *
106
+ * Related namespaces are excluded from the ancestry walk explicitly: a related
107
+ * reference is a causal pointer supplied by the caller, so it must never be
108
+ * mistaken for an ancestor stage — even if a taskKind happened to share the
109
+ * name. This is the executable form of INV-LINEAGE-SCOPE (design §33).
110
+ */
111
+ export declare function partitionTier2Paths(tier2Paths: readonly string[], relatedNamespaces: readonly string[]): {
112
+ readonly ancestry: readonly string[];
113
+ readonly related: readonly string[];
114
+ };
115
+ /**
116
+ * Resolve ancestor-declared paths against ancestry sources — BOTH layers:
117
+ *
118
+ * `<stage>.raw.<dotted.path>` — full contentJson walk (`readRawField`)
119
+ * `<stage>.summary.<key>` — the ancestor's own Layer 0 envelope
120
+ * (`readSummaryField`)
121
+ *
122
+ * Why the summary layer needs the ancestry channel too (PR B, evidence-backed):
123
+ * `readSummaryField` deliberately STRIPS the leading `<stage>.` namespace and
124
+ * reads only its single `predecessorContentJson`. That convention is correct
125
+ * for manifests whose stage namespace is the runner's direct predecessor
126
+ * (dreamer/scribe/artificer), but a manifest that names an ancestor further up
127
+ * the chain (the Evaluator's `scribe.*` / `dreamer.*` / `diagnostician.*`)
128
+ * would otherwise have those paths structurally unreachable — they would land
129
+ * in `absent` forever and force the information-floor fallback on every run.
130
+ * The lineage walk already holds every ancestor's contentJson, so the same
131
+ * traversal that serves `raw` also serves `summary`, with no extra store read.
132
+ *
133
+ * First (nearest) matching stage wins; unresolvable paths are omitted so the
134
+ * caller's information-floor logic records them in `absent`.
135
+ *
136
+ * `predecessorSummary` is intentionally NOT answered here: it is the
137
+ * direct-predecessor forwarding concept owned by Channel 1.
138
+ *
139
+ * Namespace → node matching honors `SEMANTIC_STAGE_ALIASES`: a manifest
140
+ * namespace is the SEMANTIC stage, a node's stage is the producer taskKind.
141
+ */
142
+ export declare function resolveAncestryPaths(fieldPaths: readonly string[], sources: readonly RawStageSource[]): ReadonlyMap<string, unknown>;
143
+ /**
144
+ * A related — NOT ancestral — fact source, exposed under its own namespace.
145
+ *
146
+ * Deliberately narrow: a flat namespace with two flat lookup tables. It is not
147
+ * a relation graph and cannot express arbitrary edges. Each source is supplied
148
+ * explicitly by the caller, so nothing is discovered or inferred at read time.
149
+ *
150
+ * Values are already-bounded objects: this seam never re-expands a durable
151
+ * artifact. For replay evidence the caller passes the PR-A
152
+ * `RepairReplayContext`, whose ≤16 bound (MAX_REPLAY_FAILURES_IN_REPAIR) is
153
+ * therefore preserved through the information plane (design §43).
154
+ */
155
+ export interface RelatedContextSource {
156
+ /** Manifest namespace this source answers, e.g. `replay`. */
157
+ readonly namespace: string;
158
+ readonly summary?: Readonly<Record<string, unknown>>;
159
+ readonly raw?: Readonly<Record<string, unknown>>;
160
+ }
161
+ /**
162
+ * Resolve `<ns>.summary.<key>` / `<ns>.raw.<key>` against related sources.
163
+ * Related refs expose flat keys only — a multi-segment rest path is not a
164
+ * related reference and is skipped (it belongs to the ancestry reader).
165
+ */
166
+ export declare function resolveRelatedPaths(fieldPaths: readonly string[], sources: readonly RelatedContextSource[]): ReadonlyMap<string, unknown>;
167
+ /**
168
+ * Merge the channel maps into one `available` map. FIRST WRITER WINS: the
169
+ * predecessor summary envelope is the highest-authority local source, then
170
+ * ancestry raw, then related. Channel namespaces are disjoint by construction
171
+ * (a path is either a summary path, an ancestry raw path, or a related path),
172
+ * so the rule only matters defensively — but it keeps the result deterministic.
173
+ */
174
+ export declare function mergeContextFields(base: ReadonlyMap<string, unknown>, extras: readonly ReadonlyMap<string, unknown>[]): ReadonlyMap<string, unknown>;
175
+ /**
176
+ * Required paths that did NOT reach the prompt — either absent from the
177
+ * available map or dropped/truncated by the budget.
178
+ *
179
+ * This is the regression guard for "Stage2 enabled + raw fields silently
180
+ * absent": a required field that was truncated by `PromptBudgetManager` counts
181
+ * as unresolved just like an absent one, because the runner's semantic
182
+ * requirement was still not met.
183
+ */
184
+ export declare function findUnresolvedRequiredPaths(params: {
185
+ readonly required: readonly string[];
186
+ readonly absent: readonly string[];
187
+ readonly truncated: readonly TruncationRecord[];
188
+ }): readonly string[];
189
+ //# sourceMappingURL=context-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-resolution.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/internalization/context-resolution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAUnE;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,SAAS,GAAG,oBAAoB,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,kEAAkE;IAClE,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAS5E;AAqBD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,WAAW,EAAE,OAAO,GACnB,OAAO,GAAG,SAAS,CAiBrB;AAID;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAE9E,CAAC;AAiDF;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AAC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