@principles/core 1.287.7 → 1.288.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 (96) hide show
  1. package/dist/principle-tree-ledger.d.ts +50 -0
  2. package/dist/principle-tree-ledger.d.ts.map +1 -1
  3. package/dist/principle-tree-ledger.js +133 -1
  4. package/dist/principle-tree-ledger.js.map +1 -1
  5. package/dist/runtime-v2/adapter/output-schema-registry.d.ts.map +1 -1
  6. package/dist/runtime-v2/adapter/output-schema-registry.js +4 -0
  7. package/dist/runtime-v2/adapter/output-schema-registry.js.map +1 -1
  8. package/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts +24 -0
  9. package/dist/runtime-v2/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  10. package/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js +36 -1
  11. package/dist/runtime-v2/adapter/principle-tree-ledger-adapter.js.map +1 -1
  12. package/dist/runtime-v2/candidate-intake-service.d.ts +102 -3
  13. package/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
  14. package/dist/runtime-v2/candidate-intake-service.js +280 -47
  15. package/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  16. package/dist/runtime-v2/candidate-intake.d.ts +44 -0
  17. package/dist/runtime-v2/candidate-intake.d.ts.map +1 -1
  18. package/dist/runtime-v2/candidate-intake.js +7 -0
  19. package/dist/runtime-v2/candidate-intake.js.map +1 -1
  20. package/dist/runtime-v2/config/index.d.ts +2 -2
  21. package/dist/runtime-v2/config/index.d.ts.map +1 -1
  22. package/dist/runtime-v2/config/index.js +1 -1
  23. package/dist/runtime-v2/config/index.js.map +1 -1
  24. package/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -1
  25. package/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  26. package/dist/runtime-v2/config/pd-config-defaults.js +11 -0
  27. package/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  28. package/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  29. package/dist/runtime-v2/config/pd-config-effective.js +19 -1
  30. package/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  31. package/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  32. package/dist/runtime-v2/config/pd-config-redaction.js +2 -0
  33. package/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  34. package/dist/runtime-v2/config/pd-config-types.d.ts +39 -0
  35. package/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  36. package/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  37. package/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  38. package/dist/runtime-v2/config/pd-config-validate.js +44 -0
  39. package/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  40. package/dist/runtime-v2/index.d.ts +12 -1
  41. package/dist/runtime-v2/index.d.ts.map +1 -1
  42. package/dist/runtime-v2/index.js +16 -1
  43. package/dist/runtime-v2/index.js.map +1 -1
  44. package/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  45. package/dist/runtime-v2/pain-signal-bridge.js +14 -1
  46. package/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  47. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts +8 -9
  48. package/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  49. package/dist/runtime-v2/pain-signal-runtime-factory.js +69 -35
  50. package/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  51. package/dist/runtime-v2/principle-reuse/reuse-domain.d.ts +89 -0
  52. package/dist/runtime-v2/principle-reuse/reuse-domain.d.ts.map +1 -0
  53. package/dist/runtime-v2/principle-reuse/reuse-domain.js +16 -0
  54. package/dist/runtime-v2/principle-reuse/reuse-domain.js.map +1 -0
  55. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts +40 -0
  56. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts.map +1 -0
  57. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js +97 -0
  58. package/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js.map +1 -0
  59. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts +111 -0
  60. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -0
  61. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js +230 -0
  62. package/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js.map +1 -0
  63. package/dist/runtime-v2/principle-reuse/reuse-proposal.d.ts +87 -0
  64. package/dist/runtime-v2/principle-reuse/reuse-proposal.d.ts.map +1 -0
  65. package/dist/runtime-v2/principle-reuse/reuse-proposal.js +99 -0
  66. package/dist/runtime-v2/principle-reuse/reuse-proposal.js.map +1 -0
  67. package/dist/runtime-v2/principle-reuse/reuse-retrieval.d.ts +36 -0
  68. package/dist/runtime-v2/principle-reuse/reuse-retrieval.d.ts.map +1 -0
  69. package/dist/runtime-v2/principle-reuse/reuse-retrieval.js +118 -0
  70. package/dist/runtime-v2/principle-reuse/reuse-retrieval.js.map +1 -0
  71. package/dist/runtime-v2/principle-reuse/reuse-shortlist.d.ts +40 -0
  72. package/dist/runtime-v2/principle-reuse/reuse-shortlist.d.ts.map +1 -0
  73. package/dist/runtime-v2/principle-reuse/reuse-shortlist.js +184 -0
  74. package/dist/runtime-v2/principle-reuse/reuse-shortlist.js.map +1 -0
  75. package/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.d.ts +7 -0
  76. package/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.d.ts.map +1 -1
  77. package/dist/runtime-v2/store/pain-diagnosis/pain-diagnosis-store.js.map +1 -1
  78. package/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.d.ts +1 -0
  79. package/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.d.ts.map +1 -1
  80. package/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.js +12 -0
  81. package/dist/runtime-v2/store/pain-diagnosis/sqlite-pain-diagnosis-store.js.map +1 -1
  82. package/dist/runtime-v2/store/runtime-state-manager.d.ts +5 -0
  83. package/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
  84. package/dist/runtime-v2/store/runtime-state-manager.js +8 -0
  85. package/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
  86. package/dist/runtime-v2/types/principle-schema.d.ts +65 -0
  87. package/dist/runtime-v2/types/principle-schema.d.ts.map +1 -1
  88. package/dist/runtime-v2/types/principle-schema.js +14 -0
  89. package/dist/runtime-v2/types/principle-schema.js.map +1 -1
  90. package/dist/runtime-v2/types/principle-tree-store.d.ts +12 -0
  91. package/dist/runtime-v2/types/principle-tree-store.d.ts.map +1 -1
  92. package/dist/telemetry-event.d.ts +2 -2
  93. package/dist/telemetry-event.d.ts.map +1 -1
  94. package/dist/telemetry-event.js +8 -0
  95. package/dist/telemetry-event.js.map +1 -1
  96. package/package.json +2 -2
@@ -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
@@ -33,8 +41,11 @@
33
41
  * - No promotion to active principle (M8+)
34
42
  * - No pain signal bridge
35
43
  */
36
- import type { LedgerAdapter, LedgerPrincipleEntry } from './candidate-intake.js';
44
+ import type { LedgerAdapter, LedgerPrincipleEntry, Recommendation } from './candidate-intake.js';
45
+ import { CandidateIntakeError } from './candidate-intake.js';
37
46
  import type { RuntimeStateManager } from './store/runtime-state-manager.js';
47
+ import type { ReuseDecision, ReuseProposal } from './principle-reuse/reuse-proposal.js';
48
+ import type { ReuseEvidenceEntry } from './types/principle-schema.js';
38
49
  /**
39
50
  * Why the Principle Ledger write boundary refused a candidate (Phase 1 / PR1).
40
51
  *
@@ -43,8 +54,26 @@ import type { RuntimeStateManager } from './store/runtime-state-manager.js';
43
54
  * candidate keeps flowing through its existing route / defer handling.
44
55
  * - `unknown_kind` — no usable kind at all (missing / non-string / not in the
45
56
  * known set). This is the case that previously FAILED OPEN into a principle.
57
+ * - `reuse_selected` (PRI-917 Slice 2) — the reuse gate produced a credible
58
+ * proposal and the injected decision function answered `reuse`, so no new
59
+ * Principle was written. Encoded as a refusal rather than a new result
60
+ * variant, which keeps the result-union shape stable for every consumer.
61
+ * PRI-917 PR3B Phase 2: the verdict is now ALSO materialised as durable
62
+ * evidence on the selected Principle (`reuseEvidence[]`) before this
63
+ * disposition is returned, and this reason doubles as the replay
64
+ * disposition when a candidate's resolution already exists (no new decision
65
+ * is asked, no Principle is created — INV-R07).
66
+ *
67
+ * ⚠ That is shape compatibility ONLY, not message compatibility. Known
68
+ * counter-example (verified, not fixed here): `pd candidate` presents ANY
69
+ * refusal as "this candidate kind does not target the Principle Ledger" and
70
+ * re-throws it as INPUT_INVALID — both wrong for a reuse decision, which
71
+ * DOES target the Ledger. No production caller injects `reuseDecision`
72
+ * yet, so this cannot surface today; but any consumer that renders
73
+ * refusal-specific operator messages MUST branch on
74
+ * `reason === 'reuse_selected'` BEFORE production reuse is enabled.
46
75
  */
47
- export type LedgerRefusalReason = 'non_principle_kind' | 'unknown_kind';
76
+ export type LedgerRefusalReason = 'non_principle_kind' | 'unknown_kind' | 'reuse_selected';
48
77
  /**
49
78
  * Explicit disposition returned by {@link CandidateIntakeService.intake}.
50
79
  *
@@ -57,18 +86,88 @@ export type CandidateIntakeResult = {
57
86
  /** `true` when THIS call wrote a new entry; `false` for the idempotent no-op. */
58
87
  readonly written: boolean;
59
88
  readonly entry: LedgerPrincipleEntry;
89
+ /**
90
+ * PRI-917 Slice 2 — what the reuse gate did, for observability.
91
+ * Optional so every existing producer of this variant stays valid.
92
+ */
93
+ readonly reuseCheck?: ReuseCheckOutcome;
60
94
  } | {
61
95
  readonly outcome: 'refused';
62
96
  readonly reason: LedgerRefusalReason;
63
97
  readonly candidateId: string;
64
- /** The raw persisted kind, or `null` when it was absent / not a string. */
98
+ /** The raw persisted kind, or `null` when it was absent / not a string / not loaded. */
65
99
  readonly rawRecommendationKind: string | null;
66
100
  readonly message: string;
101
+ /** PRI-917 Slice 2 — present only when `reason === 'reuse_selected'`. */
102
+ readonly reuseProposal?: ReuseProposal;
103
+ /** The Principle the decision function selected, when it chose reuse. */
104
+ readonly selectedPrincipleId?: string;
105
+ /**
106
+ * PRI-917 PR3B Phase 2 — present only when `reason === 'reuse_selected'`:
107
+ * the evidence entry just written (fresh decision), or the pre-existing
108
+ * resolution (replay). This is the durable record that the candidate was
109
+ * resolved into `selectedPrincipleId` instead of creating a Principle.
110
+ */
111
+ readonly reuseEvidence?: ReuseEvidenceEntry;
67
112
  };
113
+ /**
114
+ * PRI-917 Slice 2 — what the reuse gate did before a ledger write.
115
+ *
116
+ * - `not_configured` — no decision function was injected, so no gate ran. This
117
+ * is the current production shape; it is reported rather than assumed, so a
118
+ * caller can never mistake "gate absent" for "gate found nothing".
119
+ * - `no_candidates` — the gate ran and found nothing credible.
120
+ * - `create_decided` — the gate found candidates and the decision function
121
+ * answered `create`; the write proceeded exactly as before.
122
+ */
123
+ export type ReuseCheckOutcome = 'not_configured' | 'no_candidates' | 'create_decided';
68
124
  export interface CandidateIntakeServiceOptions {
69
125
  stateManager: RuntimeStateManager;
70
126
  ledgerAdapter: LedgerAdapter;
127
+ /**
128
+ * PRI-917 Slice 2 — optional reuse decision function.
129
+ *
130
+ * When omitted (the current production shape) the reuse gate does not run
131
+ * and intake behaves exactly as before; the result still reports
132
+ * `reuseCheck: 'not_configured'` so "no gate" is never mistaken for "no
133
+ * duplicate found".
134
+ *
135
+ * When provided, it receives the bounded proposal and MUST answer `reuse`
136
+ * or `create` — there is no automatic option and no default.
137
+ */
138
+ reuseDecision?: (proposal: ReuseProposal) => ReuseDecision;
139
+ /** Workspace state dir used for read-only reuse retrieval. */
140
+ reuseStateDir?: string;
71
141
  }
142
+ /**
143
+ * PRI-917 PR3A (surface audit C4): the candidate-semantics extraction shared
144
+ * by BOTH the intake flow (steps 4b/4c) and the `pd candidate review`
145
+ * surface — one implementation, so the retrieval input shown to the Owner can
146
+ * never drift from what intake actually consumes.
147
+ *
148
+ * Resolution order (identical to intake steps 4b→4c):
149
+ * 1. candidate.sourceRecommendationJson — validated directly, then via the
150
+ * diagnostician description→text normalization; malformed JSON warns and
151
+ * falls through (rc-9 observable degradation);
152
+ * 2. artifact.contentJson — the three historical shapes.
153
+ *
154
+ * Pure apart from the rc-9 warn; never throws — failures come back as
155
+ * `{ ok: false, error }` carrying the exact CandidateIntakeError intake
156
+ * itself would throw.
157
+ */
158
+ export type CandidateRecommendationExtraction = {
159
+ ok: true;
160
+ recommendation: Recommendation;
161
+ } | {
162
+ ok: false;
163
+ error: CandidateIntakeError;
164
+ };
165
+ export declare function extractIntakeRecommendation(candidate: {
166
+ candidateId: string;
167
+ sourceRecommendationJson?: string | null;
168
+ }, artifact: {
169
+ contentJson: string;
170
+ } | null): CandidateRecommendationExtraction;
72
171
  export declare class CandidateIntakeService {
73
172
  #private;
74
173
  constructor(opts: CandidateIntakeServiceOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-intake-service.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/candidate-intake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAkB,MAAM,uBAAuB,CAAC;AAEjG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAM5E;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,cAAc,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,iFAAiF;IACjF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;CACtC,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGN,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,mBAAmB,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAyDD,qBAAa,sBAAsB;;IAIjC,YAAY,IAAI,EAAE,6BAA6B,EAG9C;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA2JhE;CACF"}
1
+ {"version":3,"file":"candidate-intake-service.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/candidate-intake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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iB,GAAG,gBAAgB,GAAG,eAAe,GAAG,gBAAgB,CAAC;AAGtF,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,mBAAmB,CAAC;IAClC,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,aAAa,CAAC;IAC3D,8DAA8D;IAC9D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAyDD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,iCAAiC,GACzC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,cAAc,CAAA;CAAE,GAC5C;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAE/C,wBAAgB,2BAA2B,CACzC,SAAS,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC5E,QAAQ,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GACvC,iCAAiC,CAgEnC;AAED,qBAAa,sBAAsB;;IAMjC,YAAY,IAAI,EAAE,6BAA6B,EAK9C;IAED;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA0ShE;CAuDF"}
@@ -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,72 @@ 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
+ #reuseStateDir;
104
173
  constructor(opts) {
105
174
  this.#stateManager = opts.stateManager;
106
175
  this.#ledgerAdapter = opts.ledgerAdapter;
176
+ this.#reuseDecision = opts.reuseDecision;
177
+ this.#reuseStateDir = opts.reuseStateDir;
107
178
  }
108
179
  /**
109
180
  * Consume a pending candidate: load it and its artifact, build a
@@ -132,6 +203,34 @@ export class CandidateIntakeService {
132
203
  if (existing) {
133
204
  return { outcome: 'ledger_entry', written: false, entry: existing };
134
205
  }
206
+ // 2b. PRI-917 PR3B Phase 2 — durable reuse resolution replay (INV-R07).
207
+ //
208
+ // A candidate resolved by a recorded REUSE decision left its evidence on
209
+ // the target Principle and NO ledger principle of its own, so step 2
210
+ // cannot see it — without this check a replay would reach the gate again
211
+ // (re-asking the Owner) or, with the gate absent, fall through to CREATE
212
+ // and manufacture the very duplicate this feature exists to prevent.
213
+ //
214
+ // Unconditional (not gated on reuseDecision being injected): the
215
+ // resolution is durable persisted state, and honouring it is idempotency,
216
+ // not gate behaviour. Gate-unconfigured candidates WITHOUT a recorded
217
+ // resolution keep the exact pre-Phase-2 flow.
218
+ const resolved = this.#ledgerAdapter.findReuseResolutionForCandidate(candidateId);
219
+ if (resolved) {
220
+ return {
221
+ outcome: 'refused',
222
+ reason: 'reuse_selected',
223
+ candidateId,
224
+ // The candidate row is intentionally not loaded for a replay: the
225
+ // recorded evidence is itself the authoritative proof that this
226
+ // candidate was fully validated and resolved before.
227
+ rawRecommendationKind: null,
228
+ message: `Candidate ${candidateId} was already resolved into existing Principle ${resolved.principleId} by a ` +
229
+ 'recorded reuse decision; the decision was NOT asked again and no new Principle was created (INV-R07 replay).',
230
+ selectedPrincipleId: resolved.principleId,
231
+ reuseEvidence: resolved.evidence,
232
+ };
233
+ }
135
234
  // 3. Load candidate from DB
136
235
  const candidate = await this.#stateManager.getCandidate(candidateId);
137
236
  if (!candidate) {
@@ -171,57 +270,144 @@ export class CandidateIntakeService {
171
270
  if (!artifact) {
172
271
  throw new CandidateIntakeError(INTAKE_ERROR_CODES.ARTIFACT_NOT_FOUND, `Artifact ${candidate.artifactId} not found for candidate ${candidateId}`, { candidateId, artifactId: candidate.artifactId });
173
272
  }
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
- }
273
+ // 4b/4c. Extract the recommendation via the SHARED semantics extraction
274
+ // (PRI-917 PR3A C4) — the exact logic `pd candidate review` uses to show
275
+ // the Owner what this candidate claims, so proposal and intake can never
276
+ // disagree about the input. Failures carry the same CandidateIntakeError
277
+ // this method always threw.
278
+ const extracted = extractIntakeRecommendation(candidate, artifact);
279
+ if (!extracted.ok) {
280
+ throw extracted.error;
200
281
  }
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.`);
282
+ const recommendation = extracted.recommendation;
283
+ // 4d. PRI-917 Slice 2 — reuse gate.
284
+ //
285
+ // Sits between "we know what this candidate claims" (4c) and "we mint a new
286
+ // canonical identity for it" (5), which is the only place a duplicate can
287
+ // still be prevented without changing any downstream contract.
288
+ //
289
+ // Three shapes, and the default one is "no gate":
290
+ // not_configured — no decision function injected (today's production);
291
+ // the write proceeds EXACTLY as before.
292
+ // no_candidates — the gate ran and found nothing credible.
293
+ // reuse_selected — the Owner/AI Owner answered `reuse`; nothing is
294
+ // written. Encoded as a refusal disposition to keep
295
+ // the result-union shape stable. See the ⚠ note on
296
+ // LedgerRefusalReason: shape-compatible does NOT
297
+ // mean message-compatible — consumers with
298
+ // refusal-specific wording must branch on
299
+ // `reason === 'reuse_selected'` before reuse ships.
300
+ //
301
+ // A retrieval failure NEVER falls through to create (rc-9): it throws, so
302
+ // the candidate stays pending and visible instead of silently manufacturing
303
+ // the duplicate this gate exists to prevent.
304
+ //
305
+ // PRI-917 hardening: a HALF-configured gate is a configuration error, not
306
+ // a disabled one. Previously a decision function without a state dir
307
+ // skipped the gate silently while still reporting 'not_configured', so a
308
+ // one-option misconfiguration looked exactly like "the gate is off" and
309
+ // wrote duplicates without ever asking.
310
+ if (this.#reuseDecision && !this.#reuseStateDir) {
311
+ 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' });
205
312
  }
206
- // 4c. Fall back to artifact.contentJson if no valid sourceRecommendationJson
207
- if (!recommendation) {
313
+ let reuseCheck = 'not_configured';
314
+ if (this.#reuseDecision && this.#reuseStateDir) {
315
+ let proposal;
208
316
  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 });
317
+ proposal = buildReuseProposal(candidateId, buildReuseShortlist({
318
+ text: recommendation.text || candidate.description || '',
319
+ triggerPattern: recommendation.triggerPattern ?? '',
320
+ action: recommendation.action ?? '',
321
+ }, this.#reuseStateDir,
322
+ // Single truth: the persisted candidate's own kind. Step 3b has
323
+ // already proved eligibility fail-closed, so this is a restatement,
324
+ // never a second source a caller can override.
325
+ { recommendationKind: candidate.rawRecommendationKind }));
326
+ }
327
+ catch (reuseErr) {
328
+ 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 });
329
+ }
330
+ if (proposalNeedsDecision(proposal)) {
331
+ // PRI-917 hardening: the decision function is an UNTRUSTED boundary
332
+ // (an AI Owner parses model output), so its return value is validated
333
+ // at runtime. Previously anything that was not exactly 'reuse' fell
334
+ // through to 'create' — a malformed answer silently manufactured the
335
+ // very duplicate this gate exists to prevent (rc-1/rc-2/rc-3).
336
+ let decision;
337
+ try {
338
+ const raw = this.#reuseDecision(proposal);
339
+ const validated = validateReuseDecision(raw);
340
+ if (!validated.ok) {
341
+ 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 });
342
+ }
343
+ ({ decision } = validated);
344
+ }
345
+ catch (decisionErr) {
346
+ if (decisionErr instanceof CandidateIntakeError)
347
+ throw decisionErr;
348
+ // A throwing decision function (LLM timeout, parse crash) is a reuse
349
+ // check failure, not an internal error: it must fail closed with a
350
+ // candidate-scoped code rather than escaping as an arbitrary throw.
351
+ 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 });
218
352
  }
219
- recommendation = rec;
353
+ if (decision.decision === 'reuse') {
354
+ const known = new Set(proposal.candidates.map((c) => c.principleId));
355
+ if (!known.has(decision.selectedPrincipleId)) {
356
+ // INV-R08: a selection outside the proposal fails closed. It must
357
+ // NOT silently degrade into "create". This is a defect in the
358
+ // reuse decision contract, not a malformed intake input, so it
359
+ // carries REUSE_CHECK_FAILED rather than INPUT_INVALID — the
360
+ // latter would file a governance error under "bad input".
361
+ 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' });
362
+ }
363
+ // PRI-917 PR3B Phase 2 — materialise the verdict as durable evidence
364
+ // BEFORE reporting it. A reuse verdict that is not persisted would
365
+ // leave the resolution invisible: replay would re-ask the Owner, and
366
+ // the SPEC §11/§12 asymmetry (REUSE must be auditable, CREATE's
367
+ // artifact speaks for itself) would silently break. The write runs
368
+ // INSIDE the ledger's single-writer lock (appendReuseEvidence) and is
369
+ // fail-closed: an integrity/shape failure propagates and the
370
+ // candidate stays pending — it NEVER degrades into creating a
371
+ // Principle (INV-R03/INV-R08).
372
+ const painId = await this.#resolveReusePainId(candidateId, candidate);
373
+ let evidence;
374
+ try {
375
+ const appended = this.#ledgerAdapter.appendReuseEvidence(decision.selectedPrincipleId, {
376
+ painId,
377
+ candidateId,
378
+ decision: 'reuse',
379
+ actor: decision.actor,
380
+ reason: decision.reason,
381
+ decidedAt: decision.decidedAt,
382
+ });
383
+ // The writer either appended this candidate's entry or returned the
384
+ // already-recorded one (concurrent-intake dedupe) — the entry for
385
+ // THIS candidateId must be present; anything else is a broken
386
+ // adapter and fails loud instead of reporting a fabricated record.
387
+ const recorded = appended.reuseEvidence.find((e) => e.candidateId === candidateId);
388
+ if (!recorded) {
389
+ throw new Error(`appendReuseEvidence returned no evidence entry for candidate ${candidateId} (adapter contract violation)`);
390
+ }
391
+ evidence = recorded;
392
+ }
393
+ catch (evidenceErr) {
394
+ 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 });
395
+ }
396
+ return {
397
+ outcome: 'refused',
398
+ reason: 'reuse_selected',
399
+ candidateId,
400
+ rawRecommendationKind: typeof candidate.rawRecommendationKind === 'string' ? candidate.rawRecommendationKind : null,
401
+ 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.`,
402
+ reuseProposal: proposal,
403
+ selectedPrincipleId: decision.selectedPrincipleId,
404
+ reuseEvidence: evidence,
405
+ };
406
+ }
407
+ reuseCheck = 'create_decided';
220
408
  }
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 });
409
+ else {
410
+ reuseCheck = 'no_candidates';
225
411
  }
226
412
  }
227
413
  // 5. Build 11-field LedgerPrincipleEntry (E-06)
@@ -241,7 +427,7 @@ export class CandidateIntakeService {
241
427
  // 6. Write to ledger via adapter (E-01, D-09)
242
428
  try {
243
429
  const written = this.#ledgerAdapter.writeProbationEntry(entry);
244
- return { outcome: 'ledger_entry', written: true, entry: written };
430
+ return { outcome: 'ledger_entry', written: true, entry: written, reuseCheck };
245
431
  }
246
432
  catch (err) {
247
433
  if (err instanceof CandidateIntakeError) {
@@ -250,5 +436,52 @@ export class CandidateIntakeService {
250
436
  throw new CandidateIntakeError(INTAKE_ERROR_CODES.LEDGER_WRITE_FAILED, `Failed to write ledger entry for candidate ${candidateId}`, { candidateId, cause: err });
251
437
  }
252
438
  }
439
+ /**
440
+ * PRI-917 PR3B Phase 2 — resolve the Pain behind a candidate for its reuse
441
+ * evidence entry (SPEC v0.2.1 §12 requires a non-empty `painId`).
442
+ *
443
+ * `principle_candidates` carries NO pain column (audit F5); the durable
444
+ * bridge is `pain_diagnoses(task_id → pain_id)`, written by the diagnosis
445
+ * persistence path. Rows for one task are re-diagnoses / mixed attributions,
446
+ * so the LATEST row wins — ordered by (createdAt, id) for determinism.
447
+ *
448
+ * Fail-closed: a candidate with no resolvable Pain cannot produce a
449
+ * self-contained evidence entry, so the reuse decision is refused
450
+ * (`reuse_pain_unresolvable`) instead of writing a fabricated painId (rc-3).
451
+ * The candidate stays pending; no Principle is created.
452
+ */
453
+ async #resolveReusePainId(candidateId, candidate) {
454
+ const refuse = (detail) => {
455
+ throw new CandidateIntakeError(INTAKE_ERROR_CODES.REUSE_CHECK_FAILED, `Reuse decision for candidate ${candidateId} cannot be recorded: ${detail} ` +
456
+ 'The evidence entry requires the Pain that re-validated the Principle. ' +
457
+ 'nextAction: ensure the candidate\'s diagnostician task has a persisted pain diagnosis (pain_diagnoses), then retry intake.', { candidateId, reason: 'reuse_pain_unresolvable' });
458
+ };
459
+ if (typeof candidate.taskId !== 'string' || candidate.taskId === '') {
460
+ refuse('the candidate has no diagnostician task reference');
461
+ }
462
+ let diagnoses;
463
+ try {
464
+ diagnoses = await this.#stateManager.getDiagnosesByTaskId(candidate.taskId);
465
+ }
466
+ catch (err) {
467
+ 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 });
468
+ }
469
+ if (diagnoses.length === 0) {
470
+ refuse('no persisted pain diagnosis exists for its task');
471
+ }
472
+ const sorted = [...diagnoses].sort((a, b) => {
473
+ if (a.createdAt !== b.createdAt)
474
+ return a.createdAt < b.createdAt ? -1 : 1;
475
+ return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
476
+ });
477
+ const latest = sorted.at(-1);
478
+ const latestPainId = typeof latest?.painId === 'string' ? latest.painId : '';
479
+ if (latestPainId === '') {
480
+ // Empty history or a latest row without a usable pain id — either way
481
+ // no fabricated value is written (rc-3).
482
+ refuse('no usable pain id in the candidate\'s diagnosis history');
483
+ }
484
+ return latestPainId;
485
+ }
253
486
  }
254
487
  //# 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,CAAC;IAC1C,OAAO,EAAE,IAAI,EAAE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