create-principles-disciple 1.144.12 → 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 (97) 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/package.json +2 -2
  7. package/core/dist/runtime-v2/adapter/output-schema-registry.d.ts.map +1 -1
  8. package/core/dist/runtime-v2/adapter/output-schema-registry.js +4 -0
  9. package/core/dist/runtime-v2/adapter/output-schema-registry.js.map +1 -1
  10. package/core/dist/runtime-v2/bridge-result-shaper.d.ts +8 -0
  11. package/core/dist/runtime-v2/bridge-result-shaper.d.ts.map +1 -1
  12. package/core/dist/runtime-v2/bridge-result-shaper.js +61 -3
  13. package/core/dist/runtime-v2/bridge-result-shaper.js.map +1 -1
  14. package/core/dist/runtime-v2/candidate-intake-service.d.ts +52 -2
  15. package/core/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
  16. package/core/dist/runtime-v2/candidate-intake-service.js +201 -76
  17. package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
  18. package/core/dist/runtime-v2/config/index.d.ts +2 -2
  19. package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
  20. package/core/dist/runtime-v2/config/index.js +1 -1
  21. package/core/dist/runtime-v2/config/index.js.map +1 -1
  22. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +7 -1
  23. package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
  24. package/core/dist/runtime-v2/config/pd-config-defaults.js +11 -0
  25. package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
  26. package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
  27. package/core/dist/runtime-v2/config/pd-config-effective.js +24 -1
  28. package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
  29. package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
  30. package/core/dist/runtime-v2/config/pd-config-redaction.js +2 -0
  31. package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
  32. package/core/dist/runtime-v2/config/pd-config-types.d.ts +39 -0
  33. package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
  34. package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
  35. package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
  36. package/core/dist/runtime-v2/config/pd-config-validate.js +44 -0
  37. package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
  38. package/core/dist/runtime-v2/index.d.ts +8 -1
  39. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  40. package/core/dist/runtime-v2/index.js +14 -1
  41. package/core/dist/runtime-v2/index.js.map +1 -1
  42. package/core/dist/runtime-v2/pain-signal-bridge.d.ts.map +1 -1
  43. package/core/dist/runtime-v2/pain-signal-bridge.js +93 -1
  44. package/core/dist/runtime-v2/pain-signal-bridge.js.map +1 -1
  45. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +29 -14
  46. package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
  47. package/core/dist/runtime-v2/pain-signal-runtime-factory.js +215 -46
  48. package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
  49. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts +40 -0
  50. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.d.ts.map +1 -0
  51. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js +97 -0
  52. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-output.js.map +1 -0
  53. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts +111 -0
  54. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -0
  55. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js +232 -0
  56. package/core/dist/runtime-v2/principle-reuse/reuse-evaluation-runner.js.map +1 -0
  57. package/core/dist/telemetry-event.d.ts +2 -2
  58. package/core/dist/telemetry-event.d.ts.map +1 -1
  59. package/core/dist/telemetry-event.js +11 -0
  60. package/core/dist/telemetry-event.js.map +1 -1
  61. package/core/package.json +1 -1
  62. package/host-runtime/dist/index.d.ts +2 -0
  63. package/host-runtime/dist/index.js +1 -0
  64. package/host-runtime/dist/production-rulehost-gate.d.ts +1 -0
  65. package/host-runtime/dist/production-rulehost-gate.js +1 -1
  66. package/host-runtime/package.json +1 -1
  67. package/package.json +3 -3
  68. package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
  69. package/pd-cli/dist/commands/candidate.js +170 -20
  70. package/pd-cli/dist/commands/candidate.js.map +1 -1
  71. package/pd-cli/dist/commands/config-doctor.d.ts.map +1 -1
  72. package/pd-cli/dist/commands/config-doctor.js +14 -0
  73. package/pd-cli/dist/commands/config-doctor.js.map +1 -1
  74. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  75. package/pd-cli/dist/commands/diagnose.js +67 -11
  76. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  77. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  78. package/pd-cli/dist/commands/pain-retry.js +80 -11
  79. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  80. package/pd-cli/dist/services/config-doctor.d.ts +11 -0
  81. package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
  82. package/pd-cli/dist/services/config-doctor.js +6 -0
  83. package/pd-cli/dist/services/config-doctor.js.map +1 -1
  84. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts +14 -0
  85. package/pd-cli/dist/services/resolve-runtime-from-pd-config.d.ts.map +1 -1
  86. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js +20 -4
  87. package/pd-cli/dist/services/resolve-runtime-from-pd-config.js.map +1 -1
  88. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts +6 -0
  89. package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
  90. package/pd-cli/dist/services/runtime-adapter-resolver.js +11 -2
  91. package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
  92. package/pd-cli/package.json +1 -1
  93. package/plugin/dist/bundle.js +548 -544
  94. package/plugin/dist/openclaw.plugin.json +1 -1
  95. package/plugin/openclaw.plugin.json +1 -1
  96. package/plugin/package.json +4 -4
  97. package/release-manager/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "productVersion": "2.2.0",
4
- "sourceCommit": "332de78574839e4970145fc34617ed4b8abf743a"
4
+ "sourceCommit": "04bd7eceea7c50a1c5e1dd7408ab1c92d0bf8c3e"
5
5
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync, realpathSync } from 'node:fs';
2
+ import { readFileSync, realpathSync, statSync } from 'node:fs';
3
+ import os from 'node:os';
3
4
  import path from 'node:path';
4
5
  import process from 'node:process';
5
6
  import { pathToFileURL, fileURLToPath } from 'node:url';
@@ -195,11 +196,27 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
195
196
  const nextAction = error instanceof CodexDecoderError ? error.nextAction : 'Inspect the Codex 0.147 hook payload.';
196
197
  return { stdout: {}, exitCode: 0, stderr: [diagnostic(reason, nextAction)] };
197
198
  }
198
- // Codex 0.147 supplies the invocation cwd. It is the authoritative starting
199
- // point; a process-global environment variable can otherwise route one
200
- // Workspace's hook into another Workspace's business state.
199
+ // Initializing the user workspace explicitly opts Codex into shared
200
+ // governance. Otherwise preserve the existing per-project resolution.
201
201
  const requestedCwd = event.context.workspaceDir || cwd;
202
- const resolution = resolveNearestPdWorkspace(requestedCwd);
202
+ if (!path.isAbsolute(requestedCwd))
203
+ return { stdout: {}, exitCode: 0, stderr: [diagnostic('cwd_not_absolute', 'Provide the absolute Codex project directory.')] };
204
+ // Resolve like pd-locate.cjs does: a relative CODEX_HOME must yield the same
205
+ // absolute workspace for hooks and owner scripts, or resolveNearestPdWorkspace
206
+ // rejects it after the config check already accepted it.
207
+ const userWorkspace = path.join(path.resolve(_env.CODEX_HOME || path.join(os.homedir(), '.codex')), 'pd-workspace');
208
+ let userWorkspaceInitialized = false;
209
+ try {
210
+ userWorkspaceInitialized = statSync(path.join(userWorkspace, '.pd', 'config.yaml')).isFile();
211
+ if (!userWorkspaceInitialized)
212
+ return { stdout: {}, exitCode: 0, stderr: [diagnostic('user_workspace_config_invalid', 'Repair the user workspace .pd/config.yaml; project configuration was not used.')] };
213
+ }
214
+ catch (error) {
215
+ if (!(error instanceof Error && Object.hasOwn(error, 'code') && Reflect.get(error, 'code') === 'ENOENT')) {
216
+ return { stdout: {}, exitCode: 0, stderr: [diagnostic('user_workspace_config_unreadable', 'Restore access to the user workspace .pd/config.yaml; project configuration was not used.')] };
217
+ }
218
+ }
219
+ const resolution = resolveNearestPdWorkspace(userWorkspaceInitialized ? userWorkspace : requestedCwd);
203
220
  if (!resolution.ok)
204
221
  return { stdout: {}, exitCode: 0, stderr: [diagnostic(resolution.reason, resolution.nextAction)] };
205
222
  event = { ...event, context: { ...event.context, workspaceDir: resolution.workspaceDir } };
@@ -242,6 +259,7 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
242
259
  // the Codex adapter stays independent of the OpenClaw plugin). The line
243
260
  // writer appends synchronously — no flush/dispose needed for the subprocess.
244
261
  const result = await createProductionHostRuntime({
262
+ projectDir: requestedCwd,
245
263
  hostKind: 'codex',
246
264
  toolSemantics: CODEX_TOOL_SEMANTICS,
247
265
  events: codexEventEmitter(path.join(resolution.workspaceDir, '.state')),
@@ -13,6 +13,12 @@ export interface CodexWorkerCycleStepReport {
13
13
  readonly errorCategory?: string;
14
14
  /** PRI-638 P1-C: recovery action for capability-disabled pauses. */
15
15
  readonly nextAction?: string;
16
+ /**
17
+ * PRI-917 v0.3.3 review fix (P2-2): candidates parked by the Reuse Review
18
+ * Gate (suspected duplicates awaiting the Owner). Forwarded per-candidate
19
+ * so the report shows WHAT awaits the Owner, not just a degraded status.
20
+ */
21
+ readonly reuseReviewRequiredCandidateIds?: readonly string[];
16
22
  } | null;
17
23
  readonly downstream: InternalizationConsumerCycleOutcome | null;
18
24
  }
@@ -156,11 +156,18 @@ export async function runCodexWorkspaceWorkerCycle(options) {
156
156
  getEnvVar: (name) => process.env[name],
157
157
  });
158
158
  const executed = await bridge.executePendingDiagnosis({ taskId: candidate.taskId });
159
+ // PRI-917 v0.3.3 review fix (P2-2): forward the parked-candidate
160
+ // dispositions so the Owner sees the pending items instead of a bare
161
+ // degraded status with no subject.
162
+ const reuseReviewRequired = (executed.candidateOutcomes ?? [])
163
+ .filter((outcome) => outcome.reason === 'reuse_review_required')
164
+ .map((outcome) => outcome.candidateId);
159
165
  diagnostician = {
160
166
  taskId: candidate.taskId,
161
167
  status: executed.status,
162
168
  ...(executed.message !== undefined ? { message: executed.message.slice(0, 200) } : {}),
163
169
  ...(executed.errorCategory !== undefined ? { errorCategory: executed.errorCategory } : {}),
170
+ ...(reuseReviewRequired.length > 0 ? { reuseReviewRequiredCandidateIds: reuseReviewRequired } : {}),
164
171
  };
165
172
  // The bridge stays cached per workspace (bounded: one per workspace
166
173
  // per worker process, exactly like the OpenClaw plugin host) — no
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/codex-adapter",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -43,7 +43,7 @@
43
43
  "js-yaml": "^5.4.1",
44
44
  "lucide-react": "^1.28.0",
45
45
  "postcss": "^8.5.14",
46
- "postcss-cli": "^11.0.1",
46
+ "postcss-cli": "^12.0.0",
47
47
  "principles-disciple": "file:../plugin",
48
48
  "react": "^19.3.0",
49
49
  "react-dom": "^19.3.0",
@@ -61,7 +61,7 @@
61
61
  "@types/node": "^26.4.1",
62
62
  "@types/react": "^19.3.0",
63
63
  "@types/react-dom": "^19.3.0",
64
- "@types/semver": "^7.7.1",
64
+ "@types/semver": "^7.8.0",
65
65
  "esbuild": "^0.28.2",
66
66
  "tsx": "^4.23.12",
67
67
  "typescript": "^7.0.2",
@@ -1 +1 @@
1
- {"version":3,"file":"output-schema-registry.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/output-schema-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAajD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAY9D,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CAGvF"}
1
+ {"version":3,"file":"output-schema-registry.d.ts","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/output-schema-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAcjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAe9D,CAAC;AAEH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CAGvF"}
@@ -9,6 +9,7 @@ import { EvaluatorOutputV1Schema } from '../internalization/evaluator-output.js'
9
9
  import { RolloutReviewerOutputV1Schema } from '../internalization/rollout-reviewer-output.js';
10
10
  import { CorrectionObserverOutputV1Schema } from '../observer/correction-observer.js';
11
11
  import { SignalClassificationOutputV1Schema } from '../signal-collector/types.js';
12
+ import { ReuseEvaluationOutputV1Schema } from '../principle-reuse/reuse-evaluation-output.js';
12
13
  /**
13
14
  * Map of `outputSchemaRef` string → TypeBox schema. Keys match the
14
15
  * `outputSchemaRef` values passed by each runner's `invokeRuntime()`.
@@ -25,6 +26,9 @@ export const OUTPUT_SCHEMA_REGISTRY = new Map([
25
26
  ['rollout-reviewer-output-v1', RolloutReviewerOutputV1Schema],
26
27
  ['correction-observer-output-v1', CorrectionObserverOutputV1Schema],
27
28
  ['signal-classification-output-v1', SignalClassificationOutputV1Schema],
29
+ // PRI-917 v0.3.2: the Semantic Reuse Evaluation Capability's proposal contract
30
+ // (proposal-only — its outputs are never persisted; SPEC section 4.2/10).
31
+ ['reuse-evaluation-output-v1', ReuseEvaluationOutputV1Schema],
28
32
  ]);
29
33
  /**
30
34
  * Resolve the TypeBox schema for a given `outputSchemaRef`.
@@ -1 +1 @@
1
- {"version":3,"file":"output-schema-registry.js","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/output-schema-registry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAElF;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAiC,IAAI,GAAG,CAAkB;IAC3F,CAAC,yBAAyB,EAAE,2BAA2B,CAAC;IACxD,CAAC,0BAA0B,EAAE,2BAA2B,CAAC;IACzD,CAAC,0BAA0B,EAAE,2BAA2B,CAAC;IACzD,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;IAC5C,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;IACpD,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;IAC1C,CAAC,0BAA0B,EAAE,yBAAyB,CAAC;IACvD,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;IAChD,CAAC,4BAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,+BAA+B,EAAE,gCAAgC,CAAC;IACnE,CAAC,iCAAiC,EAAE,kCAAkC,CAAC;CACxE,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAA8B;IAChE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"output-schema-registry.js","sourceRoot":"","sources":["../../../src/runtime-v2/adapter/output-schema-registry.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAC9F,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,EAAE,kCAAkC,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+CAA+C,CAAC;AAE9F;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAiC,IAAI,GAAG,CAAkB;IAC3F,CAAC,yBAAyB,EAAE,2BAA2B,CAAC;IACxD,CAAC,0BAA0B,EAAE,2BAA2B,CAAC;IACzD,CAAC,0BAA0B,EAAE,2BAA2B,CAAC;IACzD,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;IAC5C,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;IACpD,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;IAC1C,CAAC,0BAA0B,EAAE,yBAAyB,CAAC;IACvD,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;IAChD,CAAC,4BAA4B,EAAE,6BAA6B,CAAC;IAC7D,CAAC,+BAA+B,EAAE,gCAAgC,CAAC;IACnE,CAAC,iCAAiC,EAAE,kCAAkC,CAAC;IACvE,+EAA+E;IAC/E,0EAA0E;IAC1E,CAAC,4BAA4B,EAAE,6BAA6B,CAAC;CAC9D,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAA8B;IAChE,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAC3B,OAAO,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC"}
@@ -40,6 +40,14 @@ interface ShapeBridgeResultBase {
40
40
  * reported as routed / not_internalizable rather than as a failed run.
41
41
  */
42
42
  ledgerEligibleCandidateCount: number;
43
+ /**
44
+ * PRI-917 v0.3.3 — candidateIds parked by the Reuse Review Gate (suspected
45
+ * duplicates awaiting the Owner). A parked ledger-eligible candidate has NO
46
+ * ledger entry BY DESIGN, so a batch whose ledger-eligible candidates are
47
+ * ALL parked is a degraded "waiting for the Owner" outcome, not the intake
48
+ * failure this branch used to report.
49
+ */
50
+ reuseReviewRequiredCandidateIds?: string[];
43
51
  /** PRI-539: candidates admitted+ledgered but not internalizable (MVP-disabled channel). */
44
52
  notInternalizable?: NotInternalizableCandidate[];
45
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-result-shaper.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/bridge-result-shaper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,2DAA2D;AAC3D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;OAUG;IACH,4BAA4B,EAAE,MAAM,CAAC;IACrC,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,0BAA0B,EAAE,CAAC;CAClD;AAED,2EAA2E;AAC3E,MAAM,WAAW,2BAA4B,SAAQ,qBAAqB;IACxE,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,wBAAwB,EAAE,CAAC;IAC7C,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,+EAA+E;AAC/E,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IAC3E,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,sBAAsB,GAC9B,2BAA2B,GAC3B,8BAA8B,CAAC;AAEnC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@ -37,12 +37,37 @@ export function shapeBridgeResult(input) {
37
37
  const notInternalizableNote = notInternalizable.length > 0
38
38
  ? `not_internalizable:${notInternalizable.map((n) => `${n.candidateId}=${n.reason}`).join(',')}`
39
39
  : '';
40
+ // PRI-917 v0.3.3 review fix (P2-2): parked candidates must stay visible in
41
+ // MIXED batches too. Previously only a fully-parked batch surfaced the
42
+ // review requirement; a batch with one ledgered and one parked candidate
43
+ // reported plain succeeded and hid the pending item from the Owner.
44
+ const parked = input.reuseReviewRequiredCandidateIds ?? [];
45
+ const parkedNote = parked.length > 0
46
+ ? `reuse_review_required:${parked.join(',')} — suspected duplicates parked for Owner review; nextAction: pd candidate review --candidate-id <id> --decide reuse|create`
47
+ : '';
40
48
  const admittedCount = admissionResults.filter((a) => a.admission.decision === 'admitted').length;
41
49
  const nonAdmittedCount = admissionResults.length - admittedCount;
42
50
  // Admitted LEDGER-ELIGIBLE candidates exist but intake produced no ledger
43
51
  // entries. Non-principle kinds are excluded here: the Principle Ledger write
44
52
  // boundary refuses them by design (Phase 1 / PR1), which is not a failure.
53
+ // PRI-917 v0.3.3: candidates parked by the Reuse Review Gate also have no
54
+ // ledger entry BY DESIGN — when EVERY ledger-eligible candidate is parked,
55
+ // the run is a degraded "awaiting the Owner" outcome (rc-9), not a failure.
45
56
  if (autoIntakeEnabled && input.ledgerEligibleCandidateCount > 0 && ledgerEntryIds.length === 0) {
57
+ if (parked.length > 0 && parked.length >= input.ledgerEligibleCandidateCount) {
58
+ return {
59
+ status: 'degraded',
60
+ painId,
61
+ taskId,
62
+ runId,
63
+ artifactId,
64
+ candidateIds,
65
+ ledgerEntryIds,
66
+ admissionResults,
67
+ notInternalizable: input.notInternalizable,
68
+ message: parkedNote,
69
+ };
70
+ }
46
71
  return {
47
72
  status: 'failed',
48
73
  painId,
@@ -83,11 +108,12 @@ export function shapeBridgeResult(input) {
83
108
  ledgerEntryIds,
84
109
  admissionResults,
85
110
  notInternalizable: input.notInternalizable,
86
- message: `partial_admission:${admittedCount}_admitted_${nonAdmittedCount}_gated${seedFailureNote ? `; ${seedFailureNote}` : ''}${notInternalizableNote ? `; ${notInternalizableNote}` : ''}`,
111
+ message: `partial_admission:${admittedCount}_admitted_${nonAdmittedCount}_gated${seedFailureNote ? `; ${seedFailureNote}` : ''}${notInternalizableNote ? `; ${notInternalizableNote}` : ''}${parkedNote ? `; ${parkedNote}` : ''}`,
87
112
  };
88
113
  }
89
- // Success (or degraded when seed failed or a candidate was not internalizable)
90
- const combinedNote = [notInternalizableNote, seedFailureNote].filter(Boolean).join('; ');
114
+ // Success (or degraded when seed failed, a candidate was not internalizable,
115
+ // or a candidate is parked awaiting the Owner — P2-2)
116
+ const combinedNote = [notInternalizableNote, seedFailureNote, parkedNote].filter(Boolean).join('; ');
91
117
  return {
92
118
  status: combinedNote ? 'degraded' : 'succeeded',
93
119
  painId,
@@ -104,7 +130,25 @@ export function shapeBridgeResult(input) {
104
130
  // Existing path: no admission results, simpler decision tree.
105
131
  // Phase 1 / PR1: same reasoning as the fresh path — only ledger-eligible
106
132
  // candidates can be legitimately "missing" a ledger entry.
133
+ // The caller passes candidates whose replay admission and read-only reuse
134
+ // review confirmed a current reuse recommendation. Pending alone proves
135
+ // neither admission nor reuse.
136
+ // A replay of a parked task used to flip from the fresh path's
137
+ // review_required outcome into a bare intake failure here.
138
+ const parked = input.reuseReviewRequiredCandidateIds ?? [];
107
139
  if (autoIntakeEnabled && input.ledgerEligibleCandidateCount > 0 && ledgerEntryIds.length === 0) {
140
+ if (parked.length > 0 && parked.length >= input.ledgerEligibleCandidateCount) {
141
+ return {
142
+ status: 'degraded',
143
+ painId,
144
+ taskId,
145
+ runId,
146
+ artifactId,
147
+ candidateIds,
148
+ ledgerEntryIds,
149
+ message: `reuse_review_required:${parked.join(',')} — suspected duplicates confirmed by read-only reuse review; nextAction: pd candidate review --candidate-id <id> --decide reuse|create`,
150
+ };
151
+ }
108
152
  return {
109
153
  status: 'failed',
110
154
  painId,
@@ -116,6 +160,20 @@ export function shapeBridgeResult(input) {
116
160
  message: 'Candidate intake did not produce a ledger entry — treating as failed',
117
161
  };
118
162
  }
163
+ // P2-2/F3: a replayed batch that ledgered SOME candidates while others are
164
+ // still pending keeps the same review_required visibility as the fresh path.
165
+ if (autoIntakeEnabled && parked.length > 0) {
166
+ return {
167
+ status: 'degraded',
168
+ painId,
169
+ taskId,
170
+ runId,
171
+ artifactId,
172
+ candidateIds,
173
+ ledgerEntryIds,
174
+ message: `Task already succeeded; reuse_review_required:${parked.join(',')} — pending candidates await Owner review; nextAction: pd candidate review --candidate-id <id> --decide reuse|create`,
175
+ };
176
+ }
119
177
  return {
120
178
  status: 'succeeded',
121
179
  painId,
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-result-shaper.js","sourceRoot":"","sources":["../../src/runtime-v2/bridge-result-shaper.ts"],"names":[],"mappings":"AAgEA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC;IAErG,2DAA2D;IAC3D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,MAAM;gBACN,MAAM;gBACN,KAAK;gBACL,YAAY;gBACZ,cAAc;gBACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;gBACxC,OAAO,EAAE,8DAA8D;aACxE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,uDAAuD;SACjE,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC3B,MA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AC;IACJ,CAAC;IAED,8DAA8D;IAC9D,yEAAyE;IACzE,2DAA2D;IAC3D,IAAI,iBAAiB,IAAI,KAAK,CAAC,4BAA4B,GAAG,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/F,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,UAAU;YACV,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,sEAAsE;SAChF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM;QACN,MAAM;QACN,KAAK;QACL,UAAU;QACV,YAAY;QACZ,cAAc;QACd,OAAO,EAAE,wBAAwB;KAClC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"bridge-result-shaper.js","sourceRoot":"","sources":["../../src/runtime-v2/bridge-result-shaper.ts"],"names":[],"mappings":"AAwEA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,KAAK,CAAC;IAErG,2DAA2D;IAC3D,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC3B,OAAO;gBACL,MAAM,EAAE,QAAQ;gBAChB,MAAM;gBACN,MAAM;gBACN,KAAK;gBACL,YAAY;gBACZ,cAAc;gBACd,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;gBACxC,OAAO,EAAE,8DAA8D;aACxE,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,uDAAuD;SACjE,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,CAAC,IAA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;gBAClB,MAAM;gBACN,MAAM;gBACN,KAAK;gBACL,UAAU;gBACV,YAAY;gBACZ,cAAc;gBACd,OAAO,EAAE,yBAAyB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,wIAAwI;aAC3L,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,MAAM;YACN,MAAM;YACN,KAAK;YACL,UAAU;YACV,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,sEAAsE;SAChF,CAAC;IACJ,CAAC;IAED,2EAA2E;IAC3E,6EAA6E;IAC7E,IAAI,iBAAiB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,MAAM;YACN,MAAM;YACN,KAAK;YACL,UAAU;YACV,YAAY;YACZ,cAAc;YACd,OAAO,EAAE,iDAAiD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,qHAAqH;SAChM,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,MAAM;QACN,MAAM;QACN,KAAK;QACL,UAAU;QACV,YAAY;QACZ,cAAc;QACd,OAAO,EAAE,wBAAwB;KAClC,CAAC;AACJ,CAAC"}
@@ -45,6 +45,8 @@ import type { LedgerAdapter, LedgerPrincipleEntry, Recommendation } from './cand
45
45
  import { CandidateIntakeError } from './candidate-intake.js';
46
46
  import type { RuntimeStateManager } from './store/runtime-state-manager.js';
47
47
  import type { ReuseDecision, ReuseProposal } from './principle-reuse/reuse-proposal.js';
48
+ import type { ReuseEvaluationOutputV1 } from './principle-reuse/reuse-evaluation-output.js';
49
+ import type { ReuseCandidateInput } from './principle-reuse/reuse-domain.js';
48
50
  import type { ReuseEvidenceEntry } from './types/principle-schema.js';
49
51
  /**
50
52
  * Why the Principle Ledger write boundary refused a candidate (Phase 1 / PR1).
@@ -72,8 +74,15 @@ import type { ReuseEvidenceEntry } from './types/principle-schema.js';
72
74
  * yet, so this cannot surface today; but any consumer that renders
73
75
  * refusal-specific operator messages MUST branch on
74
76
  * `reason === 'reuse_selected'` BEFORE production reuse is enabled.
77
+ * - `reuse_pending_owner` (PRI-917 v0.3.3, OD-PRI917-05) — the Reuse Review
78
+ * Gate ran the semantic evaluation on the AUTO path (no Owner decision
79
+ * function present) and the recommendation was `reuse` with a selection
80
+ * inside the proposal. No Principle is created, NO evidence is written, and
81
+ * the candidate stays PENDING for the Owner. Consumers MUST branch on this
82
+ * reason: unlike every other refusal, the candidate is intentionally kept
83
+ * pending — do not mark it consumed and do not seed internalization for it.
75
84
  */
76
- export type LedgerRefusalReason = 'non_principle_kind' | 'unknown_kind' | 'reuse_selected';
85
+ export type LedgerRefusalReason = 'non_principle_kind' | 'unknown_kind' | 'reuse_selected' | 'reuse_pending_owner';
77
86
  /**
78
87
  * Explicit disposition returned by {@link CandidateIntakeService.intake}.
79
88
  *
@@ -109,6 +118,26 @@ export type CandidateIntakeResult = {
109
118
  * resolved into `selectedPrincipleId` instead of creating a Principle.
110
119
  */
111
120
  readonly reuseEvidence?: ReuseEvidenceEntry;
121
+ /**
122
+ * PRI-917 v0.3.3 — present only when `reason === 'reuse_pending_owner'`:
123
+ * the semantic recommendation that triggered the park. NEVER persisted —
124
+ * the Owner re-evaluates via `pd candidate review` (T7: proposal output
125
+ * cannot mutate ledger/evidence; the park itself writes nothing).
126
+ */
127
+ readonly reuseRecommendation?: ReuseRecommendationOutcome;
128
+ };
129
+ /**
130
+ * PRI-917 v0.3.3 — outcome of the auto-path Reuse Review Gate's evaluation
131
+ * hook. `recommended` wraps the validated `reuse-evaluation-output-v1` payload
132
+ * (a RECOMMENDATION — never a decision); `unavailable` is the observable
133
+ * degradation that lets CREATE proceed (SPEC v0.3.3 Rule 4: evaluation failure
134
+ * must never block learning).
135
+ */
136
+ export type ReuseRecommendationOutcome = ({
137
+ status: 'recommended';
138
+ } & ReuseEvaluationOutputV1) | {
139
+ status: 'unavailable';
140
+ reason: string;
112
141
  };
113
142
  /**
114
143
  * PRI-917 Slice 2 — what the reuse gate did before a ledger write.
@@ -119,8 +148,12 @@ export type CandidateIntakeResult = {
119
148
  * - `no_candidates` — the gate ran and found nothing credible.
120
149
  * - `create_decided` — the gate found candidates and the decision function
121
150
  * answered `create`; the write proceeded exactly as before.
151
+ * - `recommended_create` (PRI-917 v0.3.3) — the auto-path recommendation hook
152
+ * ran and did NOT answer reuse (create / uncertain / unavailable / selection
153
+ * outside the proposal); the write proceeded per Rules 2-4. Never emitted
154
+ * when only an Owner decision function is configured.
122
155
  */
123
- export type ReuseCheckOutcome = 'not_configured' | 'no_candidates' | 'create_decided';
156
+ export type ReuseCheckOutcome = 'not_configured' | 'no_candidates' | 'create_decided' | 'recommended_create';
124
157
  export interface CandidateIntakeServiceOptions {
125
158
  stateManager: RuntimeStateManager;
126
159
  ledgerAdapter: LedgerAdapter;
@@ -132,12 +165,25 @@ export interface CandidateIntakeServiceOptions {
132
165
  * `reuseCheck: 'not_configured'` so "no gate" is never mistaken for "no
133
166
  * duplicate found".
134
167
  *
168
+ * Mutually exclusive with reuseRecommendation; supplying both fails at construction.
135
169
  * When provided, it receives the bounded proposal and MUST answer `reuse`
136
170
  * or `create` — there is no automatic option and no default.
137
171
  */
138
172
  reuseDecision?: (proposal: ReuseProposal) => ReuseDecision;
139
173
  /** Workspace state dir used for read-only reuse retrieval. */
140
174
  reuseStateDir?: string;
175
+ /**
176
+ * PRI-917 v0.3.3 (OD-PRI917-05) — optional auto-path Reuse Review Gate
177
+ * recommendation hook. When injected (WITHOUT `reuseDecision`), the gate
178
+ * runs the semantic evaluation for every candidate with a credible proposal
179
+ * and parks the candidate (`refused/reuse_pending_owner`) when the
180
+ * recommendation is `reuse` with a selection inside the proposal. Any other
181
+ * outcome (create / uncertain / unavailable / throw) degrades to CREATE —
182
+ * evaluation failure must never block learning (Rule 4). The hook is a
183
+ * RECOMMENDATION channel only: it can never write, and it is never injected
184
+ * together with an Owner decision function by production callers.
185
+ */
186
+ reuseRecommendation?: (claim: ReuseCandidateInput, proposal: ReuseProposal) => Promise<ReuseRecommendationOutcome>;
141
187
  }
142
188
  /**
143
189
  * PRI-917 PR3A (surface audit C4): the candidate-semantics extraction shared
@@ -189,5 +235,9 @@ export declare class CandidateIntakeService {
189
235
  * - LEDGER_WRITE_FAILED when ledger write fails
190
236
  */
191
237
  intake(candidateId: string): Promise<CandidateIntakeResult>;
238
+ /** Whether the automatic recommendation channel is configured for read-only review. */
239
+ get reuseReviewEnabled(): boolean;
240
+ /** Uses the same input validation and gate as intake, but never writes. */
241
+ reviewReuse(candidateId: string): Promise<CandidateIntakeResult | null>;
192
242
  }
193
243
  //# sourceMappingURL=candidate-intake-service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-intake-service.d.ts","sourceRoot":"","sources":["../../src/runtime-v2/candidate-intake-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAwD,MAAM,uBAAuB,CAAC;AACnH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAQ5E,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAE3F;;;;;;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,oBAAo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