create-principles-disciple 1.144.11 → 1.144.13

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 (157) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/dist/pd-hook.js +23 -5
  3. package/codex-adapter/dist/worker/workspace-worker.d.ts +6 -0
  4. package/codex-adapter/dist/worker/workspace-worker.js +7 -0
  5. package/codex-adapter/package.json +1 -1
  6. package/console/dist/server/models/ApprovalsConsoleModel.d.ts +1 -1
  7. package/console/dist/server/models/ApprovalsConsoleModel.js +4 -4
  8. package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +5 -5
  9. package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +18 -18
  10. package/console/dist/shared/prompt-injection-contract.d.ts +5 -5
  11. package/console/dist/ui/pages/focus/FocusPage.js +1 -1
  12. package/console/dist/ui/pages/focus/focus-validation.js +1 -1
  13. package/console/dist/ui/utils/approval-warning-localization.js +1 -1
  14. package/console/dist/ui/utils/validators.d.ts +1 -1
  15. package/console/dist/ui/utils/validators.js +2 -2
  16. package/console/package.json +3 -3
  17. package/core/dist/principle-tree-ledger.d.ts +50 -0
  18. package/core/dist/principle-tree-ledger.d.ts.map +1 -1
  19. package/core/dist/principle-tree-ledger.js +133 -1
  20. package/core/dist/principle-tree-ledger.js.map +1 -1
  21. package/core/dist/runtime-v2/adapter/output-schema-registry.d.ts.map +1 -1
  22. package/core/dist/runtime-v2/adapter/output-schema-registry.js +4 -0
  23. package/core/dist/runtime-v2/adapter/output-schema-registry.js.map +1 -1
  24. package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts +24 -0
  25. package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  26. package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js +36 -1
  27. package/core/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js.map +1 -1
  28. package/core/dist/runtime-v2/bridge-result-shaper.d.ts +8 -0
  29. package/core/dist/runtime-v2/bridge-result-shaper.d.ts.map +1 -1
  30. package/core/dist/runtime-v2/bridge-result-shaper.js +61 -3
  31. package/core/dist/runtime-v2/bridge-result-shaper.js.map +1 -1
  32. package/core/dist/runtime-v2/candidate-intake-service.d.ts +152 -3
  33. package/core/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
  34. package/core/dist/runtime-v2/candidate-intake-service.js +405 -47
  35. package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  36. package/core/dist/runtime-v2/candidate-intake.d.ts +44 -0
  37. package/core/dist/runtime-v2/candidate-intake.d.ts.map +1 -1
  38. package/core/dist/runtime-v2/candidate-intake.js +7 -0
  39. package/core/dist/runtime-v2/candidate-intake.js.map +1 -1
  40. package/core/dist/runtime-v2/config/index.d.ts +2 -2
  41. package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
  42. package/core/dist/runtime-v2/config/index.js +1 -1
  43. package/core/dist/runtime-v2/config/index.js.map +1 -1
  44. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -1
  45. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  46. package/core/dist/runtime-v2/config/pd-config-defaults.js +11 -0
  47. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  48. package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  49. package/core/dist/runtime-v2/config/pd-config-effective.js +24 -1
  50. package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  51. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  52. package/core/dist/runtime-v2/config/pd-config-redaction.js +2 -0
  53. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  54. package/core/dist/runtime-v2/config/pd-config-types.d.ts +39 -0
  55. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  56. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  57. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  58. package/core/dist/runtime-v2/config/pd-config-validate.js +44 -0
  59. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  60. package/core/dist/runtime-v2/index.d.ts +14 -1
  61. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  62. package/core/dist/runtime-v2/index.js +21 -1
  63. package/core/dist/runtime-v2/index.js.map +1 -1
  64. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  65. package/core/dist/runtime-v2/pain-signal-bridge.js +107 -2
  66. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  67. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +29 -14
  68. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  69. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +215 -46
  70. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  71. package/core/dist/runtime-v2/principle-reuse/reuse-domain.d.ts +89 -0
  72. package/core/dist/runtime-v2/principle-reuse/reuse-domain.d.ts.map +1 -0
  73. package/core/dist/runtime-v2/principle-reuse/reuse-domain.js +16 -0
  74. package/core/dist/runtime-v2/principle-reuse/reuse-domain.js.map +1 -0
  75. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts +40 -0
  76. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts.map +1 -0
  77. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js +97 -0
  78. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js.map +1 -0
  79. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts +111 -0
  80. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -0
  81. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js +232 -0
  82. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js.map +1 -0
  83. package/core/dist/runtime-v2/principle-reuse/reuse-proposal.d.ts +87 -0
  84. package/core/dist/runtime-v2/principle-reuse/reuse-proposal.d.ts.map +1 -0
  85. package/core/dist/runtime-v2/principle-reuse/reuse-proposal.js +99 -0
  86. package/core/dist/runtime-v2/principle-reuse/reuse-proposal.js.map +1 -0
  87. package/core/dist/runtime-v2/principle-reuse/reuse-retrieval.d.ts +36 -0
  88. package/core/dist/runtime-v2/principle-reuse/reuse-retrieval.d.ts.map +1 -0
  89. package/core/dist/runtime-v2/principle-reuse/reuse-retrieval.js +118 -0
  90. package/core/dist/runtime-v2/principle-reuse/reuse-retrieval.js.map +1 -0
  91. package/core/dist/runtime-v2/principle-reuse/reuse-shortlist.d.ts +40 -0
  92. package/core/dist/runtime-v2/principle-reuse/reuse-shortlist.d.ts.map +1 -0
  93. package/core/dist/runtime-v2/principle-reuse/reuse-shortlist.js +184 -0
  94. package/core/dist/runtime-v2/principle-reuse/reuse-shortlist.js.map +1 -0
  95. package/core/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.d.ts +7 -0
  96. package/core/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.d.ts.map +1 -1
  97. package/core/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.js.map +1 -1
  98. package/core/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.d.ts +1 -0
  99. package/core/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.d.ts.map +1 -1
  100. package/core/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.js +12 -0
  101. package/core/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.js.map +1 -1
  102. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts +5 -0
  103. package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  104. package/core/dist/runtime-v2/store/runtime-state-manager.js +8 -0
  105. package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  106. package/core/dist/runtime-v2/types/principle-schema.d.ts +65 -0
  107. package/core/dist/runtime-v2/types/principle-schema.d.ts.map +1 -1
  108. package/core/dist/runtime-v2/types/principle-schema.js +14 -0
  109. package/core/dist/runtime-v2/types/principle-schema.js.map +1 -1
  110. package/core/dist/runtime-v2/types/principle-tree-store.d.ts +12 -0
  111. package/core/dist/runtime-v2/types/principle-tree-store.d.ts.map +1 -1
  112. package/core/dist/telemetry-event.d.ts +2 -2
  113. package/core/dist/telemetry-event.d.ts.map +1 -1
  114. package/core/dist/telemetry-event.js +13 -0
  115. package/core/dist/telemetry-event.js.map +1 -1
  116. package/core/package.json +2 -2
  117. package/host-runtime/dist/index.d.ts +2 -0
  118. package/host-runtime/dist/index.js +1 -0
  119. package/host-runtime/dist/production-rulehost-gate.d.ts +1 -0
  120. package/host-runtime/dist/production-rulehost-gate.js +1 -1
  121. package/host-runtime/dist/prompt-injection-projection.d.ts +5 -5
  122. package/host-runtime/dist/prompt-injection-projection.js +4 -4
  123. package/host-runtime/package.json +1 -1
  124. package/package.json +3 -3
  125. package/pd-cli/dist/commands/candidate.d.ts +27 -0
  126. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  127. package/pd-cli/dist/commands/candidate.js +508 -14
  128. package/pd-cli/dist/commands/candidate.js.map +1 -1
  129. package/pd-cli/dist/commands/config-doctor.d.ts.map +1 -1
  130. package/pd-cli/dist/commands/config-doctor.js +14 -0
  131. package/pd-cli/dist/commands/config-doctor.js.map +1 -1
  132. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  133. package/pd-cli/dist/commands/diagnose.js +84 -14
  134. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  135. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  136. package/pd-cli/dist/commands/pain-retry.js +97 -14
  137. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  138. package/pd-cli/dist/index.js +16 -2
  139. package/pd-cli/dist/index.js.map +1 -1
  140. package/pd-cli/dist/services/config-doctor.d.ts +11 -0
  141. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  142. package/pd-cli/dist/services/config-doctor.js +6 -0
  143. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  144. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts +14 -0
  145. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts.map +1 -1
  146. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js +20 -4
  147. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js.map +1 -1
  148. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +6 -0
  149. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  150. package/pd-cli/dist/services/runtime-adapter-resolver.js +11 -2
  151. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  152. package/pd-cli/package.json +1 -1
  153. package/plugin/dist/bundle.js +550 -546
  154. package/plugin/dist/openclaw.plugin.json +1 -1
  155. package/plugin/openclaw.plugin.json +1 -1
  156. package/plugin/package.json +5 -5
  157. package/release-manager/package.json +3 -3
@@ -4,12 +4,20 @@
4
4
  * Workflow:
5
5
  * 1. Validate input
6
6
  * 2. Check idempotency (existsForCandidate) — O(1) lookup
7
+ * 2b. Check durable reuse resolution replay (PRI-917 PR3B Phase 2) —
8
+ * a candidate already resolved into an existing Principle returns that
9
+ * resolution; no decision is re-asked, no Principle is created
7
10
  * 3. Load candidate from DB (RuntimeStateManager)
8
11
  * 3b. ★ Principle Ledger write boundary (Phase 1 / PR1) — see below
9
12
  * 4. Load artifact from DB and parse recommendation
10
13
  * 5. Build 11-field LedgerPrincipleEntry
11
14
  * 6. Write via adapter.writeProbationEntry()
12
15
  *
16
+ * 4d (PRI-917 Slice 2 + PR3B Phase 2) — the reuse gate sits between 4c and 5:
17
+ * a credible proposal + a `reuse` verdict is materialised as durable evidence
18
+ * on the selected Principle (appendReuseEvidence) and reported as a
19
+ * `reuse_selected` refusal; a `create` verdict proceeds exactly as before.
20
+ *
13
21
  * ── Principle Ledger write boundary (Phase 1 / PR1) ─────────────────────────
14
22
  * This service is the single shared chokepoint through which EVERY
15
23
  * candidate-origin write to the Principle Ledger flows (pd-cli `candidate
@@ -36,6 +44,9 @@
36
44
  import { randomUUID } from 'crypto';
37
45
  import { CandidateIntakeError, INTAKE_ERROR_CODES, isRecord, validateRecommendation } from './candidate-intake.js';
38
46
  import { isPrincipleLedgerEligibleKind, validateRecommendationKind, } from './store/candidate/recommendation-kind-resolver.js';
47
+ import { buildReuseProposal, proposalNeedsDecision } from './principle-reuse/reuse-proposal.js';
48
+ import { buildReuseShortlist } from './principle-reuse/reuse-retrieval.js';
49
+ import { validateReuseDecision } from './principle-reuse/reuse-proposal.js';
39
50
  /**
40
51
  * Normalize a DiagnosticianRecommendation-shaped object to the Recommendation
41
52
  * contract by mapping `description` → `text`. The diagnostician-committer stores
@@ -98,12 +109,97 @@ function extractRecommendationFromContentJson(parsed) {
98
109
  return validateRecommendation(norm);
99
110
  return null;
100
111
  }
112
+ export function extractIntakeRecommendation(candidate, artifact) {
113
+ const { candidateId } = candidate;
114
+ // 4b: the canonical source first.
115
+ const sourceRecJson = candidate.sourceRecommendationJson;
116
+ if (sourceRecJson && sourceRecJson.trim() !== '') {
117
+ try {
118
+ const parsed = JSON.parse(sourceRecJson);
119
+ const fromCandidate = validateRecommendation(parsed);
120
+ if (fromCandidate)
121
+ return { ok: true, recommendation: fromCandidate };
122
+ // diagnostician-committer stores a DiagnosticianRecommendation, whose
123
+ // body field is `description` (not `text`). Normalize that shape to the
124
+ // Recommendation contract. rc-4: validate the normalized value too.
125
+ const normalized = normalizeDiagnosticianRecommendation(parsed);
126
+ const fromNorm = normalized ? validateRecommendation(normalized) : null;
127
+ if (fromNorm)
128
+ return { ok: true, recommendation: fromNorm };
129
+ }
130
+ catch (err) {
131
+ // sourceRecommendationJson is non-empty but malformed — warn and fall through
132
+ const detail = err instanceof Error ? err.message : String(err);
133
+ console.warn(`[CandidateIntakeService] sourceRecommendationJson parse failed for candidate ${candidateId}: ${detail}. Falling back to artifact.contentJson.`);
134
+ }
135
+ }
136
+ // 4c: fall back to artifact.contentJson.
137
+ if (!artifact) {
138
+ return {
139
+ ok: false,
140
+ error: new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Cannot extract recommendation for candidate ${candidateId}: no artifact content available`, { candidateId }),
141
+ };
142
+ }
143
+ try {
144
+ const parsed = JSON.parse(artifact.contentJson);
145
+ // Three historical shapes can land in contentJson:
146
+ // 1. { recommendation: {...} } — manual E2E wrapper
147
+ // 2. DiagnosticianOutputV1 — { summary, rootCause, recommendations: [...] }
148
+ // 3. bare Recommendation-like object
149
+ // rc-1/rc-2: parsed is untrusted — validate, never cast. rc-5: Object.hasOwn.
150
+ const rec = extractRecommendationFromContentJson(parsed);
151
+ if (!rec) {
152
+ return {
153
+ ok: false,
154
+ error: new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Failed to parse artifact content for candidate ${candidateId}: contentJson is not a valid recommendation object`, { candidateId }),
155
+ };
156
+ }
157
+ return { ok: true, recommendation: rec };
158
+ }
159
+ catch (err) {
160
+ if (err instanceof CandidateIntakeError)
161
+ return { ok: false, error: err };
162
+ return {
163
+ ok: false,
164
+ error: new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Failed to parse artifact content for candidate ${candidateId}: ${err instanceof Error ? err.message : String(err)}`, { candidateId, cause: err }),
165
+ };
166
+ }
167
+ }
101
168
  export class CandidateIntakeService {
102
169
  #stateManager;
103
170
  #ledgerAdapter;
171
+ #reuseDecision;
172
+ #reuseRecommendation;
173
+ #reuseStateDir;
104
174
  constructor(opts) {
175
+ if (opts.reuseDecision && opts.reuseRecommendation) {
176
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, 'reuseDecision and reuseRecommendation are mutually exclusive. nextAction: supply reuseRecommendation for automatic intake or reuseDecision for Owner decisions, never both.', { reason: 'reuse_gate_misconfigured' });
177
+ }
105
178
  this.#stateManager = opts.stateManager;
106
179
  this.#ledgerAdapter = opts.ledgerAdapter;
180
+ this.#reuseDecision = opts.reuseDecision;
181
+ this.#reuseRecommendation = opts.reuseRecommendation;
182
+ this.#reuseStateDir = opts.reuseStateDir;
183
+ }
184
+ /**
185
+ * PRI-917 v0.3.3 — run the auto-path recommendation hook. A throwing hook
186
+ * (buggy builder, adapter crash) is an `unavailable` recommendation, NOT an
187
+ * intake failure: Rule 4 forbids evaluation failures from blocking learning.
188
+ */
189
+ async #runReuseRecommendation(claim, proposal) {
190
+ const hook = this.#reuseRecommendation;
191
+ if (!hook) {
192
+ return { status: 'unavailable', reason: 'reuse recommendation hook is not configured' };
193
+ }
194
+ try {
195
+ return await hook(claim, proposal);
196
+ }
197
+ catch (err) {
198
+ return {
199
+ status: 'unavailable',
200
+ reason: err instanceof Error ? err.message : String(err),
201
+ };
202
+ }
107
203
  }
108
204
  /**
109
205
  * Consume a pending candidate: load it and its artifact, build a
@@ -123,6 +219,19 @@ export class CandidateIntakeService {
123
219
  * - LEDGER_WRITE_FAILED when ledger write fails
124
220
  */
125
221
  async intake(candidateId) {
222
+ return this.#intake(candidateId, false);
223
+ }
224
+ /** Whether the automatic recommendation channel is configured for read-only review. */
225
+ get reuseReviewEnabled() {
226
+ return this.#reuseRecommendation !== undefined && !this.#reuseDecision;
227
+ }
228
+ /** Uses the same input validation and gate as intake, but never writes. */
229
+ async reviewReuse(candidateId) {
230
+ if (!this.reuseReviewEnabled)
231
+ return null;
232
+ return this.#intake(candidateId, true);
233
+ }
234
+ async #intake(candidateId, reviewOnly) {
126
235
  // 1. Input validation (E-01)
127
236
  if (!candidateId || typeof candidateId !== 'string' || candidateId.trim() === '') {
128
237
  throw new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, 'candidateId must be a non-empty string', { candidateId });
@@ -132,6 +241,34 @@ export class CandidateIntakeService {
132
241
  if (existing) {
133
242
  return { outcome: 'ledger_entry', written: false, entry: existing };
134
243
  }
244
+ // 2b. PRI-917 PR3B Phase 2 — durable reuse resolution replay (INV-R07).
245
+ //
246
+ // A candidate resolved by a recorded REUSE decision left its evidence on
247
+ // the target Principle and NO ledger principle of its own, so step 2
248
+ // cannot see it — without this check a replay would reach the gate again
249
+ // (re-asking the Owner) or, with the gate absent, fall through to CREATE
250
+ // and manufacture the very duplicate this feature exists to prevent.
251
+ //
252
+ // Unconditional (not gated on reuseDecision being injected): the
253
+ // resolution is durable persisted state, and honouring it is idempotency,
254
+ // not gate behaviour. Gate-unconfigured candidates WITHOUT a recorded
255
+ // resolution keep the exact pre-Phase-2 flow.
256
+ const resolved = this.#ledgerAdapter.findReuseResolutionForCandidate(candidateId);
257
+ if (resolved) {
258
+ return {
259
+ outcome: 'refused',
260
+ reason: 'reuse_selected',
261
+ candidateId,
262
+ // The candidate row is intentionally not loaded for a replay: the
263
+ // recorded evidence is itself the authoritative proof that this
264
+ // candidate was fully validated and resolved before.
265
+ rawRecommendationKind: null,
266
+ message: `Candidate ${candidateId} was already resolved into existing Principle ${resolved.principleId} by a ` +
267
+ 'recorded reuse decision; the decision was NOT asked again and no new Principle was created (INV-R07 replay).',
268
+ selectedPrincipleId: resolved.principleId,
269
+ reuseEvidence: resolved.evidence,
270
+ };
271
+ }
135
272
  // 3. Load candidate from DB
136
273
  const candidate = await this.#stateManager.getCandidate(candidateId);
137
274
  if (!candidate) {
@@ -171,59 +308,193 @@ export class CandidateIntakeService {
171
308
  if (!artifact) {
172
309
  throw new CandidateIntakeError(INTAKE_ERROR_CODES.ARTIFACT_NOT_FOUND, `Artifact ${candidate.artifactId} not found for candidate ${candidateId}`, { candidateId, artifactId: candidate.artifactId });
173
310
  }
174
- // 4b. Parse recommendation from candidate.sourceRecommendationJson FIRST (canonical source)
175
- // Fall back to artifact.contentJson for backwards-compatibility with legacy/manual inserts.
176
- let recommendation;
177
- const sourceRecJson = candidate.sourceRecommendationJson;
178
- try {
179
- if (sourceRecJson && sourceRecJson.trim() !== '') {
180
- // rc-1/rc-2 (ERR-001/ERR-005): candidate JSON is untrusted — validate shape,
181
- // never cast directly. validateRecommendation returns null on bad shape;
182
- // a null result falls through to the contentJson branch below.
183
- const parsed = JSON.parse(sourceRecJson);
184
- const fromCandidate = validateRecommendation(parsed);
185
- if (fromCandidate) {
186
- recommendation = fromCandidate;
187
- }
188
- else {
189
- // diagnostician-committer stores a DiagnosticianRecommendation, whose
190
- // body field is `description` (not `text`). Normalize that shape to the
191
- // Recommendation contract so the canonical source path is preferred over
192
- // the contentJson fallback. rc-4: validate the normalized value too.
193
- const normalized = normalizeDiagnosticianRecommendation(parsed);
194
- const fromNorm = normalized ? validateRecommendation(normalized) : null;
195
- if (fromNorm) {
196
- recommendation = fromNorm;
197
- }
198
- }
199
- }
311
+ // 4b/4c. Extract the recommendation via the SHARED semantics extraction
312
+ // (PRI-917 PR3A C4) — the exact logic `pd candidate review` uses to show
313
+ // the Owner what this candidate claims, so proposal and intake can never
314
+ // disagree about the input. Failures carry the same CandidateIntakeError
315
+ // this method always threw.
316
+ const extracted = extractIntakeRecommendation(candidate, artifact);
317
+ if (!extracted.ok) {
318
+ throw extracted.error;
200
319
  }
201
- catch (err) {
202
- // sourceRecommendationJson is non-empty but malformed — warn and fall through
203
- const detail = err instanceof Error ? err.message : String(err);
204
- console.warn(`[CandidateIntakeService] sourceRecommendationJson parse failed for candidate ${candidateId}: ${detail}. Falling back to artifact.contentJson.`);
320
+ const recommendation = extracted.recommendation;
321
+ // 4d. PRI-917 Slice 2 — reuse gate.
322
+ //
323
+ // Sits between "we know what this candidate claims" (4c) and "we mint a new
324
+ // canonical identity for it" (5), which is the only place a duplicate can
325
+ // still be prevented without changing any downstream contract.
326
+ //
327
+ // Three shapes, and the default one is "no gate":
328
+ // not_configured — no decision function injected (today's production);
329
+ // the write proceeds EXACTLY as before.
330
+ // no_candidates — the gate ran and found nothing credible.
331
+ // reuse_selected — the Owner/AI Owner answered `reuse`; nothing is
332
+ // written. Encoded as a refusal disposition to keep
333
+ // the result-union shape stable. See the ⚠ note on
334
+ // LedgerRefusalReason: shape-compatible does NOT
335
+ // mean message-compatible — consumers with
336
+ // refusal-specific wording must branch on
337
+ // `reason === 'reuse_selected'` before reuse ships.
338
+ //
339
+ // A retrieval failure NEVER falls through to create (rc-9): it throws, so
340
+ // the candidate stays pending and visible instead of silently manufacturing
341
+ // the duplicate this gate exists to prevent.
342
+ //
343
+ // PRI-917 hardening: a HALF-configured gate is a configuration error, not
344
+ // a disabled one. Previously a decision function without a state dir
345
+ // skipped the gate silently while still reporting 'not_configured', so a
346
+ // one-option misconfiguration looked exactly like "the gate is off" and
347
+ // wrote duplicates without ever asking.
348
+ if (this.#reuseDecision && !this.#reuseStateDir) {
349
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse gate is misconfigured: reuseDecision was provided without reuseStateDir; no Principle was created for candidate ${candidateId}. nextAction: pass reuseStateDir, or remove reuseDecision to disable the gate.`, { candidateId, reason: 'reuse_gate_misconfigured' });
350
+ }
351
+ if (this.#reuseRecommendation && !this.#reuseStateDir) {
352
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse gate is misconfigured: reuseRecommendation was provided without reuseStateDir; no Principle was created for candidate ${candidateId}. nextAction: pass reuseStateDir, or remove reuseRecommendation to disable the gate.`, { candidateId, reason: 'reuse_gate_misconfigured' });
205
353
  }
206
- // 4c. Fall back to artifact.contentJson if no valid sourceRecommendationJson
207
- if (!recommendation) {
354
+ let reuseCheck = 'not_configured';
355
+ if ((this.#reuseDecision || this.#reuseRecommendation) && this.#reuseStateDir) {
356
+ const reuseClaim = {
357
+ text: recommendation.text || candidate.description || '',
358
+ triggerPattern: recommendation.triggerPattern ?? '',
359
+ action: recommendation.action ?? '',
360
+ };
361
+ let proposal;
208
362
  try {
209
- const parsed = JSON.parse(artifact.contentJson);
210
- // Three historical shapes can land in contentJson:
211
- // 1. { recommendation: {...} } — manual E2E wrapper
212
- // 2. DiagnosticianOutputV1 — { summary, rootCause, recommendations: [...] }
213
- // 3. bare Recommendation-like object
214
- // rc-1/rc-2: parsed is untrusted — validate, never cast. rc-5: Object.hasOwn.
215
- const rec = extractRecommendationFromContentJson(parsed);
216
- if (!rec) {
217
- throw new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Failed to parse artifact content for candidate ${candidateId}: contentJson is not a valid recommendation object`, { candidateId });
363
+ proposal = buildReuseProposal(candidateId, buildReuseShortlist(reuseClaim, this.#reuseStateDir,
364
+ // Single truth: the persisted candidate's own kind. Step 3b has
365
+ // already proved eligibility fail-closed, so this is a restatement,
366
+ // never a second source a caller can override.
367
+ { recommendationKind: candidate.rawRecommendationKind }));
368
+ }
369
+ catch (reuseErr) {
370
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse check could not be completed for candidate ${candidateId}; no Principle was created. Cause: ${reuseErr instanceof Error ? reuseErr.message : String(reuseErr)}`, { candidateId, cause: reuseErr });
371
+ }
372
+ if (proposalNeedsDecision(proposal)) {
373
+ // PRI-917 v0.3.3 (OD-PRI917-05) — AUTO-path Reuse Review Gate.
374
+ //
375
+ // Runs only when a recommendation hook is injected WITHOUT an Owner
376
+ // decision function (the production auto shape: bridge / diagnose /
377
+ // pain-retry). The hook is a RECOMMENDATION channel: `reuse` parks the
378
+ // candidate for the Owner (refused/reuse_pending_owner — no Principle,
379
+ // no evidence, candidate stays pending); every other outcome
380
+ // (create / uncertain / unavailable / selection outside the proposal)
381
+ // proceeds to CREATE exactly as the unconfigured gate would (Rules
382
+ // 2-4: uncertain keeps creating in phase 1; evaluation failure must
383
+ // never block learning; a hallucinated id is treated as unavailable).
384
+ if (this.#reuseRecommendation && !this.#reuseDecision) {
385
+ const recommendationOutcome = await this.#runReuseRecommendation(reuseClaim, proposal);
386
+ if (recommendationOutcome.status === 'recommended') {
387
+ const { recommendation: verdict, selectedPrincipleId, confidence } = recommendationOutcome;
388
+ if (verdict === 'reuse' &&
389
+ selectedPrincipleId !== undefined &&
390
+ proposal.candidates.some((entry) => entry.principleId === selectedPrincipleId)) {
391
+ return {
392
+ outcome: 'refused',
393
+ reason: 'reuse_pending_owner',
394
+ candidateId,
395
+ rawRecommendationKind: typeof candidate.rawRecommendationKind === 'string' ? candidate.rawRecommendationKind : null,
396
+ message: `Candidate ${candidateId} is a suspected duplicate of existing Principle ${selectedPrincipleId} ` +
397
+ `(semantic reuse recommendation, confidence ${confidence}). No Principle was created and no evidence ` +
398
+ 'was written; the candidate stays PENDING for the Owner. ' +
399
+ `nextAction: pd candidate review --candidate-id ${candidateId} --decide reuse|create --reason "..."`,
400
+ reuseProposal: proposal,
401
+ reuseRecommendation: recommendationOutcome,
402
+ };
403
+ }
404
+ }
405
+ // create / uncertain / unavailable / hallucinated id → Rules 2/3/4:
406
+ // CREATE proceeds (uncertain keeps creating in phase 1; evaluation
407
+ // failure must never block learning).
408
+ reuseCheck = 'recommended_create';
409
+ }
410
+ else if (this.#reuseDecision) {
411
+ // PRI-917 hardening: the decision function is an UNTRUSTED boundary
412
+ // (an AI Owner parses model output), so its return value is validated
413
+ // at runtime. Previously anything that was not exactly 'reuse' fell
414
+ // through to 'create' — a malformed answer silently manufactured the
415
+ // very duplicate this gate exists to prevent (rc-1/rc-2/rc-3).
416
+ let decision;
417
+ try {
418
+ const raw = this.#reuseDecision(proposal);
419
+ const validated = validateReuseDecision(raw);
420
+ if (!validated.ok) {
421
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} is not a valid reuse|create decision (${validated.reason}); no Principle was created.`, { candidateId, reason: validated.reason });
422
+ }
423
+ ({ decision } = validated);
424
+ }
425
+ catch (decisionErr) {
426
+ if (decisionErr instanceof CandidateIntakeError)
427
+ throw decisionErr;
428
+ // A throwing decision function (LLM timeout, parse crash) is a reuse
429
+ // check failure, not an internal error: it must fail closed with a
430
+ // candidate-scoped code rather than escaping as an arbitrary throw.
431
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} failed (${decisionErr instanceof Error ? decisionErr.message : String(decisionErr)}); no Principle was created.`, { candidateId, cause: decisionErr });
432
+ }
433
+ if (decision.decision === 'reuse') {
434
+ const known = new Set(proposal.candidates.map((c) => c.principleId));
435
+ if (!known.has(decision.selectedPrincipleId)) {
436
+ // INV-R08: a selection outside the proposal fails closed. It must
437
+ // NOT silently degrade into "create". This is a defect in the
438
+ // reuse decision contract, not a malformed intake input, so it
439
+ // carries REUSE_CHECK_FAILED rather than INPUT_INVALID — the
440
+ // latter would file a governance error under "bad input".
441
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision selected principle '${decision.selectedPrincipleId}' which is not in the proposal for candidate ${candidateId}; no Principle was created.`, { candidateId, selectedPrincipleId: decision.selectedPrincipleId, reason: 'selected_principle_not_in_proposal' });
442
+ }
443
+ // PRI-917 PR3B Phase 2 — materialise the verdict as durable evidence
444
+ // BEFORE reporting it. A reuse verdict that is not persisted would
445
+ // leave the resolution invisible: replay would re-ask the Owner, and
446
+ // the SPEC §11/§12 asymmetry (REUSE must be auditable, CREATE's
447
+ // artifact speaks for itself) would silently break. The write runs
448
+ // INSIDE the ledger's single-writer lock (appendReuseEvidence) and is
449
+ // fail-closed: an integrity/shape failure propagates and the
450
+ // candidate stays pending — it NEVER degrades into creating a
451
+ // Principle (INV-R03/INV-R08).
452
+ const painId = await this.#resolveReusePainId(candidateId, candidate);
453
+ let evidence;
454
+ try {
455
+ const appended = this.#ledgerAdapter.appendReuseEvidence(decision.selectedPrincipleId, {
456
+ painId,
457
+ candidateId,
458
+ decision: 'reuse',
459
+ actor: decision.actor,
460
+ reason: decision.reason,
461
+ decidedAt: decision.decidedAt,
462
+ });
463
+ // The writer either appended this candidate's entry or returned the
464
+ // already-recorded one (concurrent-intake dedupe) — the entry for
465
+ // THIS candidateId must be present; anything else is a broken
466
+ // adapter and fails loud instead of reporting a fabricated record.
467
+ const recorded = appended.reuseEvidence.find((e) => e.candidateId === candidateId);
468
+ if (!recorded) {
469
+ throw new Error(`appendReuseEvidence returned no evidence entry for candidate ${candidateId} (adapter contract violation)`);
470
+ }
471
+ evidence = recorded;
472
+ }
473
+ catch (evidenceErr) {
474
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} could not be recorded on principle '${decision.selectedPrincipleId}'; no Principle was created and the decision is not durable. Cause: ${evidenceErr instanceof Error ? evidenceErr.message : String(evidenceErr)}`, { candidateId, selectedPrincipleId: decision.selectedPrincipleId, cause: evidenceErr });
475
+ }
476
+ return {
477
+ outcome: 'refused',
478
+ reason: 'reuse_selected',
479
+ candidateId,
480
+ rawRecommendationKind: typeof candidate.rawRecommendationKind === 'string' ? candidate.rawRecommendationKind : null,
481
+ message: `Candidate ${candidateId} was resolved to existing Principle ${decision.selectedPrincipleId}; the reuse decision was recorded on that Principle's reuseEvidence and no new Principle was created. This candidate DOES target the Principle Ledger — review the reuse proposal, and do not re-run intake to force a new Principle.`,
482
+ reuseProposal: proposal,
483
+ selectedPrincipleId: decision.selectedPrincipleId,
484
+ reuseEvidence: evidence,
485
+ };
486
+ }
487
+ reuseCheck = 'create_decided';
218
488
  }
219
- recommendation = rec;
220
489
  }
221
- catch (err) {
222
- if (err instanceof CandidateIntakeError)
223
- throw err;
224
- throw new CandidateIntakeError(INTAKE_ERROR_CODES.INPUT_INVALID, `Failed to parse artifact content for candidate ${candidateId}: ${err instanceof Error ? err.message : String(err)}`, { candidateId, cause: err });
490
+ else {
491
+ reuseCheck = 'no_candidates';
225
492
  }
226
493
  }
494
+ // Replay review is read-only: create/uncertain/unavailable never resumes a
495
+ // ledger write, and the Owner verdict path is excluded by reviewReuse.
496
+ if (reviewOnly)
497
+ return null;
227
498
  // 5. Build 11-field LedgerPrincipleEntry (E-06)
228
499
  const entry = {
229
500
  id: randomUUID(),
@@ -241,7 +512,7 @@ export class CandidateIntakeService {
241
512
  // 6. Write to ledger via adapter (E-01, D-09)
242
513
  try {
243
514
  const written = this.#ledgerAdapter.writeProbationEntry(entry);
244
- return { outcome: 'ledger_entry', written: true, entry: written };
515
+ return { outcome: 'ledger_entry', written: true, entry: written, reuseCheck };
245
516
  }
246
517
  catch (err) {
247
518
  if (err instanceof CandidateIntakeError) {
@@ -250,5 +521,92 @@ export class CandidateIntakeService {
250
521
  throw new CandidateIntakeError(INTAKE_ERROR_CODES.LEDGER_WRITE_FAILED, `Failed to write ledger entry for candidate ${candidateId}`, { candidateId, cause: err });
251
522
  }
252
523
  }
524
+ /**
525
+ * PRI-917 PR3B Phase 2 — resolve the Pain behind a candidate for its reuse
526
+ * evidence entry (SPEC v0.2.1 §12 requires a non-empty `painId`).
527
+ *
528
+ * `principle_candidates` carries NO pain column (audit F5); the durable
529
+ * bridge is `pain_diagnoses(task_id → pain_id)`, written by the diagnosis
530
+ * persistence path. Rows for one task are re-diagnoses / mixed attributions,
531
+ * so the LATEST row wins — ordered by (createdAt, id) for determinism.
532
+ *
533
+ * Fail-closed: a candidate with no resolvable Pain cannot produce a
534
+ * self-contained evidence entry, so the reuse decision is refused
535
+ * (`reuse_pain_unresolvable`) instead of writing a fabricated painId (rc-3).
536
+ * The candidate stays pending; no Principle is created.
537
+ */
538
+ async #resolveReusePainId(candidateId, candidate) {
539
+ const refuse = (detail) => {
540
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} cannot be recorded: ${detail} ` +
541
+ 'The evidence entry requires the Pain that re-validated the Principle. ' +
542
+ 'nextAction: ensure the candidate\'s diagnostician task has a persisted pain diagnosis (pain_diagnoses), then retry intake.', { candidateId, reason: 'reuse_pain_unresolvable' });
543
+ };
544
+ if (typeof candidate.taskId !== 'string' || candidate.taskId === '') {
545
+ refuse('the candidate has no diagnostician task reference');
546
+ }
547
+ let diagnoses;
548
+ try {
549
+ diagnoses = await this.#stateManager.getDiagnosesByTaskId(candidate.taskId);
550
+ }
551
+ catch (err) {
552
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} cannot be recorded: the pain diagnosis lookup failed. Cause: ${err instanceof Error ? err.message : String(err)}`, { candidateId, reason: 'reuse_pain_unresolvable', cause: err });
553
+ }
554
+ if (diagnoses.length === 0) {
555
+ // PRI-917 v0.3.3 replay fix (R6 reality replay finding): production
556
+ // candidates are minted on the diag_router SUB-task, while pain_diagnoses
557
+ // rows are persisted under the TOP diagnostician task — a lookup by the
558
+ // candidate's own taskId can therefore NEVER resolve, making every fresh
559
+ // reuse decision fail closed. Walk the canonical router → diagnostician
560
+ // chain (same discipline as the seeding-side resolver: verify the task
561
+ // kind, read diagnosisId from the router run's validated outputPayload)
562
+ // and retry the lookup against the top task. rc-6: the walk only follows
563
+ // real task/run records, never parses ids out of task-id strings.
564
+ const topTaskId = await this.#resolveTopDiagnosticianTaskId(candidate);
565
+ if (topTaskId !== null) {
566
+ try {
567
+ diagnoses = await this.#stateManager.getDiagnosesByTaskId(topTaskId);
568
+ }
569
+ catch (err) {
570
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} cannot be recorded: the pain diagnosis lookup for the top diagnostician task failed. Cause: ${err instanceof Error ? err.message : String(err)}`, { candidateId, reason: 'reuse_pain_unresolvable', cause: err });
571
+ }
572
+ }
573
+ }
574
+ if (diagnoses.length === 0) {
575
+ refuse('no persisted pain diagnosis exists for its task');
576
+ }
577
+ const sorted = [...diagnoses].sort((a, b) => {
578
+ if (a.createdAt !== b.createdAt)
579
+ return a.createdAt < b.createdAt ? -1 : 1;
580
+ return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
581
+ });
582
+ const latest = sorted.at(-1);
583
+ const latestPainId = typeof latest?.painId === 'string' ? latest.painId : '';
584
+ if (latestPainId === '') {
585
+ // Empty history or a latest row without a usable pain id — either way
586
+ // no fabricated value is written (rc-3).
587
+ refuse('no usable pain id in the candidate\'s diagnosis history');
588
+ }
589
+ return latestPainId;
590
+ }
591
+ /**
592
+ * PRI-917 v0.3.3 replay fix — resolve the TOP diagnostician task behind a
593
+ * diag_router sub-task. The sub-task's canonical parent link is its
594
+ * `inputRef` (verified against a real diagnostician task record — rc-6: the
595
+ * walk only follows persisted task records, never parses ids out of
596
+ * task-id strings). Returns `null` for any non-router task or broken link
597
+ * (the caller keeps the direct-lookup behavior).
598
+ */
599
+ async #resolveTopDiagnosticianTaskId(candidate) {
600
+ const task = await this.#stateManager.getTask(candidate.taskId);
601
+ if (!task || task.taskKind !== 'diag_router')
602
+ return null;
603
+ const parentTaskId = typeof task.inputRef === 'string' ? task.inputRef.trim() : '';
604
+ if (parentTaskId === '')
605
+ return null;
606
+ const topTask = await this.#stateManager.getTask(parentTaskId);
607
+ if (!topTask || topTask.taskKind !== 'diagnostician')
608
+ return null;
609
+ return topTask.taskId;
610
+ }
253
611
  }
254
612
  //# sourceMappingURL=candidate-intake-service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-intake-service.js","sourceRoot":"","sources":["../../src/runtime-v2/candidate-intake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEnH,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,mDAAmD,CAAC;AA0C3D;;;;;;;;;GASG;AACH,SAAS,oCAAoC,CAAC,GAAY;IACxD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,CAAC;IAC7B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,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H,KAAK,CAAC,8BAA8B,CAClC,SAA6B;QAE7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,aAAa;YAAE,OAAO,IAAI,CAAC;QAC1D,MAAM,YAAY,GAAG,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,IAAI,YAAY,KAAK,EAAE;YAAE,OAAO,IAAI,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,eAAe;YAAE,OAAO,IAAI,CAAC;QAClE,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;CACF"}
@@ -62,6 +62,7 @@
62
62
  * reviewCycle: undefined
63
63
  */
64
64
  import { type Static } from '@sinclair/typebox';
65
+ import type { ReuseEvidenceEntry } from './types/principle-schema.js';
65
66
  export declare const CandidateIntakeInputSchema: import("@sinclair/typebox").TObject<{
66
67
  candidateId: import("@sinclair/typebox").TString;
67
68
  workspaceDir: import("@sinclair/typebox").TString;
@@ -192,6 +193,13 @@ export declare const INTAKE_ERROR_CODES: {
192
193
  readonly ARTIFACT_NOT_FOUND: 'artifact_not_found';
193
194
  readonly LEDGER_WRITE_FAILED: 'ledger_write_failed';
194
195
  readonly INPUT_INVALID: 'input_invalid';
196
+ /**
197
+ * PRI-917 Slice 2 — the reuse gate ran and could not complete (ledger
198
+ * unreadable, shortlist construction failed). Thrown rather than falling
199
+ * through to create: a failed reuse check must not silently manufacture the
200
+ * very duplicate the gate exists to prevent (rc-9).
201
+ */
202
+ readonly REUSE_CHECK_FAILED: 'reuse_check_failed';
195
203
  };
196
204
  /**
197
205
  * Candidate intake error with structured code and optional context.
@@ -253,5 +261,41 @@ export interface LedgerAdapter {
253
261
  * @returns The existing LedgerPrincipleEntry if found, null otherwise.
254
262
  */
255
263
  existsForCandidate(candidateId: string): LedgerPrincipleEntry | null;
264
+ /**
265
+ * PRI-917 PR3B Phase 2 — look up the durable reuse resolution for a
266
+ * candidate, if one was ever recorded: the evidence entry whose
267
+ * `candidateId` matches, plus the Principle it resolved into.
268
+ *
269
+ * This is the REUSE-side counterpart of {@link existsForCandidate} and is
270
+ * deliberately a SEPARATE method: existsForCandidate keeps its
271
+ * derivedFromPainIds-based create-path idempotency semantics untouched
272
+ * (SPEC v0.2.1 §12 — that field is never repurposed for reuse).
273
+ *
274
+ * @param candidateId — The candidate to look up.
275
+ * @returns The recorded resolution (principle id + evidence entry), or null
276
+ * when this candidate has never been resolved by a reuse decision.
277
+ */
278
+ findReuseResolutionForCandidate(candidateId: string): {
279
+ principleId: string;
280
+ evidence: ReuseEvidenceEntry;
281
+ } | null;
282
+ /**
283
+ * PRI-917 PR3B Phase 2 — persist one reuse resolution: append the evidence
284
+ * entry to the Principle's `reuseEvidence[]` inside the single-writer
285
+ * ledger lock. Implementations delegate to the core appendReuseEvidence
286
+ * writer (fail-closed on corruption, idempotent per candidateId,
287
+ * append-only).
288
+ *
289
+ * @param principleId — The reused Principle (canonical ledger UUID).
290
+ * @param entry — The evidence entry (painId/candidateId/decision/actor/
291
+ * reason/decidedAt[/decisionId]).
292
+ * @throws on integrity/shape failures — the caller must NOT fall back to
293
+ * creating a Principle (INV-R03/INV-R08).
294
+ */
295
+ appendReuseEvidence(principleId: string, entry: ReuseEvidenceEntry): {
296
+ principleId: string;
297
+ reuseEvidence: ReuseEvidenceEntry[];
298
+ appended: boolean;
299
+ };
256
300
  }
257
301
  //# sourceMappingURL=candidate-intake.d.ts.map