create-principles-disciple 1.148.8 → 1.148.10

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 (180) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/codex-adapter/package.json +1 -1
  3. package/console/dist/server/config/WorkspaceConfigStore.js +4 -3
  4. package/console/dist/server/console-ports.d.ts +13 -0
  5. package/console/dist/server/console-ports.js +15 -0
  6. package/console/dist/server/index.js +51 -5
  7. package/console/dist/server/routes/update-transaction.js +4 -4
  8. package/console/dist/server/routes/update.js +37 -21
  9. package/console/dist/server/utils/gateway.js +23 -6
  10. package/console/dist/server/utils/installed-layout.js +5 -3
  11. package/console/dist/server/utils/pd-backups.d.ts +6 -4
  12. package/console/dist/server/utils/pd-backups.js +8 -9
  13. package/console/dist/server/utils/pd-home.d.ts +34 -0
  14. package/console/dist/server/utils/pd-home.js +47 -0
  15. package/console/dist/web/assets/app.js +1 -1
  16. package/console/package.json +1 -1
  17. package/core/dist/index.d.ts +2 -2
  18. package/core/dist/index.d.ts.map +1 -1
  19. package/core/dist/index.js +2 -2
  20. package/core/dist/index.js.map +1 -1
  21. package/core/dist/runtime/adapter/output-schema-registry.d.ts +4 -3
  22. package/core/dist/runtime/adapter/output-schema-registry.d.ts.map +1 -1
  23. package/core/dist/runtime/adapter/output-schema-registry.js +9 -5
  24. package/core/dist/runtime/adapter/output-schema-registry.js.map +1 -1
  25. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +1 -1
  26. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
  27. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +10 -3
  28. package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
  29. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +31 -0
  30. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
  31. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +55 -0
  32. package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
  33. package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
  34. package/core/dist/runtime/adapter/schema-prompt-adapter.js +48 -9
  35. package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
  36. package/core/dist/runtime/adapter/split-pipeline-fixtures.d.ts +2 -2
  37. package/core/dist/runtime/adapter/split-pipeline-fixtures.d.ts.map +1 -1
  38. package/core/dist/runtime/adapter/split-pipeline-fixtures.js +11 -0
  39. package/core/dist/runtime/adapter/split-pipeline-fixtures.js.map +1 -1
  40. package/core/dist/runtime/adapter/test-double-runtime-adapter.d.ts +3 -3
  41. package/core/dist/runtime/adapter/test-double-runtime-adapter.d.ts.map +1 -1
  42. package/core/dist/runtime/adapter/test-double-runtime-adapter.js +9 -3
  43. package/core/dist/runtime/adapter/test-double-runtime-adapter.js.map +1 -1
  44. package/core/dist/runtime/admission-gate.d.ts +2 -2
  45. package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
  46. package/core/dist/runtime/candidate-intake-service.js +176 -13
  47. package/core/dist/runtime/candidate-intake-service.js.map +1 -1
  48. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +42 -7
  49. package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
  50. package/core/dist/runtime/diagnostician/router-prompt-builder.js +53 -10
  51. package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
  52. package/core/dist/runtime/diagnostician-association-shadow.d.ts +111 -4
  53. package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
  54. package/core/dist/runtime/diagnostician-association-shadow.js +206 -3
  55. package/core/dist/runtime/diagnostician-association-shadow.js.map +1 -1
  56. package/core/dist/runtime/diagnostician-output.d.ts +67 -84
  57. package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
  58. package/core/dist/runtime/diagnostician-output.js +90 -41
  59. package/core/dist/runtime/diagnostician-output.js.map +1 -1
  60. package/core/dist/runtime/index.d.ts +3 -3
  61. package/core/dist/runtime/index.d.ts.map +1 -1
  62. package/core/dist/runtime/index.js +3 -3
  63. package/core/dist/runtime/index.js.map +1 -1
  64. package/core/dist/runtime/internalization/artifact-summary.js +1 -1
  65. package/core/dist/runtime/internalization/diag-router-runner.d.ts +49 -12
  66. package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
  67. package/core/dist/runtime/internalization/diag-router-runner.js +135 -30
  68. package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
  69. package/core/dist/runtime/internalization/formation-context.d.ts +2 -2
  70. package/core/dist/runtime/internalization/formation-context.js +2 -2
  71. package/core/dist/runtime/internalization/internalization-route.d.ts +15 -2
  72. package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
  73. package/core/dist/runtime/internalization/internalization-route.js +5 -2
  74. package/core/dist/runtime/internalization/internalization-route.js.map +1 -1
  75. package/core/dist/runtime/internalization/router-context-evidence.d.ts +148 -6
  76. package/core/dist/runtime/internalization/router-context-evidence.d.ts.map +1 -1
  77. package/core/dist/runtime/internalization/router-context-evidence.js +156 -11
  78. package/core/dist/runtime/internalization/router-context-evidence.js.map +1 -1
  79. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +64 -0
  80. package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -0
  81. package/core/dist/runtime/internalization/router-context-reconstruction.js +124 -0
  82. package/core/dist/runtime/internalization/router-context-reconstruction.js.map +1 -0
  83. package/core/dist/runtime/pain-signal-bridge.d.ts +3 -3
  84. package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
  85. package/core/dist/runtime/pain-signal-bridge.js +35 -9
  86. package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
  87. package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
  88. package/core/dist/runtime/pain-signal-runtime-factory.js +32 -4
  89. package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
  90. package/core/dist/runtime/principle-tree/rule-candidate-binding.d.ts.map +1 -1
  91. package/core/dist/runtime/principle-tree/rule-candidate-binding.js +9 -5
  92. package/core/dist/runtime/principle-tree/rule-candidate-binding.js.map +1 -1
  93. package/core/dist/runtime/runner/base-peer-runner.d.ts +18 -4
  94. package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
  95. package/core/dist/runtime/runner/base-peer-runner.js +32 -9
  96. package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
  97. package/core/dist/runtime/runner/context-hash.d.ts +9 -0
  98. package/core/dist/runtime/runner/context-hash.d.ts.map +1 -0
  99. package/core/dist/runtime/runner/context-hash.js +18 -0
  100. package/core/dist/runtime/runner/context-hash.js.map +1 -0
  101. package/core/dist/runtime/runner/default-validator.d.ts +3 -3
  102. package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
  103. package/core/dist/runtime/runner/default-validator.js +149 -85
  104. package/core/dist/runtime/runner/default-validator.js.map +1 -1
  105. package/core/dist/runtime/runner/diagnostician-validator.d.ts +11 -9
  106. package/core/dist/runtime/runner/diagnostician-validator.d.ts.map +1 -1
  107. package/core/dist/runtime/runner/peer-runner-types.d.ts +14 -2
  108. package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
  109. package/core/dist/runtime/runner/runner-result.d.ts +2 -2
  110. package/core/dist/runtime/runtime-protocol.d.ts +8 -0
  111. package/core/dist/runtime/runtime-protocol.d.ts.map +1 -1
  112. package/core/dist/runtime/runtime-protocol.js +8 -0
  113. package/core/dist/runtime/runtime-protocol.js.map +1 -1
  114. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts +4 -4
  115. package/core/dist/runtime/store/commit/diagnostician-committer.d.ts.map +1 -1
  116. package/core/dist/runtime/store/commit/diagnostician-committer.js +27 -8
  117. package/core/dist/runtime/store/commit/diagnostician-committer.js.map +1 -1
  118. package/core/dist/runtime/store/pain-diagnosis/pain-diagnosis-store.d.ts +2 -2
  119. package/core/dist/runtime/store/pain-diagnosis/pain-diagnosis-store.js +1 -1
  120. package/core/dist/runtime/store/run/memory-run-store.d.ts +1 -1
  121. package/core/dist/runtime/store/run/memory-run-store.d.ts.map +1 -1
  122. package/core/dist/runtime/store/run/memory-run-store.js.map +1 -1
  123. package/core/dist/runtime/store/run/run-store.d.ts +1 -1
  124. package/core/dist/runtime/store/run/run-store.d.ts.map +1 -1
  125. package/core/dist/runtime/store/run/sqlite-run-store.d.ts +1 -1
  126. package/core/dist/runtime/store/run/sqlite-run-store.d.ts.map +1 -1
  127. package/core/dist/runtime/store/run/sqlite-run-store.js +4 -0
  128. package/core/dist/runtime/store/run/sqlite-run-store.js.map +1 -1
  129. package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -1
  130. package/core/dist/runtime/store/runtime-state-manager.js +1 -1
  131. package/core/dist/runtime/synthetic-baseline.d.ts +2 -2
  132. package/core/dist/runtime/synthetic-baseline.d.ts.map +1 -1
  133. package/core/dist/runtime/synthetic-baseline.js +2 -0
  134. package/core/dist/runtime/synthetic-baseline.js.map +1 -1
  135. package/core/dist/runtime/types/evidence-chain-contract.d.ts +1 -1
  136. package/core/dist/runtime/types/evidence-chain-contract.js +2 -2
  137. package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
  138. package/core/dist/runtime/types/rule-candidate-binding.d.ts +10 -2
  139. package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
  140. package/core/dist/telemetry-event.d.ts +2 -2
  141. package/core/dist/telemetry-event.d.ts.map +1 -1
  142. package/core/dist/telemetry-event.js +19 -0
  143. package/core/dist/telemetry-event.js.map +1 -1
  144. package/core/package.json +1 -1
  145. package/dist/update/bootstrap-executor.d.ts.map +1 -1
  146. package/dist/update/bootstrap-executor.js +33 -19
  147. package/dist/update/bootstrap-executor.js.map +1 -1
  148. package/host-runtime/dist/workspace-telemetry-emitter.js +13 -0
  149. package/host-runtime/package.json +1 -1
  150. package/install-layout/dist/index.d.ts +7 -0
  151. package/install-layout/dist/index.js +7 -0
  152. package/install-layout/dist/pd-home.d.ts +55 -0
  153. package/install-layout/dist/pd-home.js +226 -0
  154. package/install-layout/package.json +1 -1
  155. package/package.json +4 -4
  156. package/pd-cli/dist/commands/candidate.js.map +1 -1
  157. package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
  158. package/pd-cli/dist/commands/diagnose.js +14 -5
  159. package/pd-cli/dist/commands/diagnose.js.map +1 -1
  160. package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
  161. package/pd-cli/dist/commands/pain-retry.js +18 -7
  162. package/pd-cli/dist/commands/pain-retry.js.map +1 -1
  163. package/pd-cli/dist/services/demo-story-a-runner.js +2 -2
  164. package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
  165. package/pd-cli/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
  166. package/pd-cli/dist/services/pain-flood-simulation-runner.js +4 -1
  167. package/pd-cli/dist/services/pain-flood-simulation-runner.js.map +1 -1
  168. package/pd-cli/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
  169. package/pd-cli/dist/services/synthetic-baseline-runner.js +5 -1
  170. package/pd-cli/dist/services/synthetic-baseline-runner.js.map +1 -1
  171. package/pd-cli/package.json +1 -1
  172. package/pd-mcp-server/dist/version.d.ts +1 -1
  173. package/pd-mcp-server/dist/version.js +1 -1
  174. package/pd-mcp-server/package.json +1 -1
  175. package/plugin/dist/bundle.js +472 -448
  176. package/plugin/openclaw.plugin.json +1 -1
  177. package/plugin/package.json +1 -1
  178. package/release-manager/dist/update/bootstrap-executor.js +33 -19
  179. package/release-manager/package.json +1 -1
  180. package/workbuddy-adapter/package.json +1 -1
@@ -16,11 +16,10 @@
16
16
  * never writes installation files directly.
17
17
  */
18
18
  import * as fs from 'node:fs';
19
- import * as path from 'node:path';
20
- import * as os from 'node:os';
21
19
  import { readFileSync, writeFileSync } from 'node:fs';
22
20
  import { parseBootstrapRequest, serializeBootstrapResponse, handleBootstrapRequest, } from './bootstrap-protocol.js';
23
21
  import { createReleaseManagerAuthority } from './release-manager-authority.js';
22
+ import { resolvePdHome } from '@principles/install-layout';
24
23
  export async function runBootstrapExecutor(options) {
25
24
  let response;
26
25
  let resultFile = null;
@@ -34,28 +33,43 @@ export async function runBootstrapExecutor(options) {
34
33
  response = { ok: true, result: { pong: true } };
35
34
  }
36
35
  else {
37
- const authority = createReleaseManagerAuthority({
38
- pdHome: path.join(os.homedir(), '.pd'),
39
- // The executor resolves the metadata source exactly like the Console:
40
- // process env first, then the durable install.json tier. No guessing.
41
- metadataBaseUrl: process.env.PD_RELEASE_METADATA_URL,
42
- });
43
- // Only apply passes the authority readiness gate — read ops (inspect /
44
- // check) must answer on ANY installation so the repair flow can see the
45
- // actual state; check carries its own policy gating.
46
- if (request.op === 'apply' && !authority.kinds['apply-full'].ready) {
47
- const readiness = authority.kinds['apply-full'];
36
+ // PRI-872: the executor runs detached from the Console that spawned it,
37
+ // so it must resolve the SAME home through the same authority. Without
38
+ // this an experiment Console's update transaction would target the
39
+ // production install — the exact dual-open failure this ticket removes.
40
+ const pdHome = resolvePdHome();
41
+ if (!pdHome.ok) {
48
42
  response = {
49
43
  ok: false,
50
- reason: readiness.reasons[0] ?? 'install_state_corrupt',
51
- message: 'The installation is not ready for a signed release update.',
52
- nextAction: 'Run the official installer (npx create-principles-disciple) to repair the installation, then retry.',
44
+ reason: pdHome.reason,
45
+ message: pdHome.message,
46
+ nextAction: pdHome.nextAction,
53
47
  };
54
48
  }
55
49
  else {
56
- // handleBootstrapRequest never throws: manager failures come back as
57
- // structured protocol refusals.
58
- response = await handleBootstrapRequest(request, authority.manager);
50
+ const authority = createReleaseManagerAuthority({
51
+ pdHome: pdHome.pdHome,
52
+ // The executor resolves the metadata source exactly like the Console:
53
+ // process env first, then the durable install.json tier. No guessing.
54
+ metadataBaseUrl: process.env.PD_RELEASE_METADATA_URL,
55
+ });
56
+ // Only apply passes the authority readiness gate — read ops (inspect /
57
+ // check) must answer on ANY installation so the repair flow can see the
58
+ // actual state; check carries its own policy gating.
59
+ if (request.op === 'apply' && !authority.kinds['apply-full'].ready) {
60
+ const readiness = authority.kinds['apply-full'];
61
+ response = {
62
+ ok: false,
63
+ reason: readiness.reasons[0] ?? 'install_state_corrupt',
64
+ message: 'The installation is not ready for a signed release update.',
65
+ nextAction: 'Run the official installer (npx create-principles-disciple) to repair the installation, then retry.',
66
+ };
67
+ }
68
+ else {
69
+ // handleBootstrapRequest never throws: manager failures come back as
70
+ // structured protocol refusals.
71
+ response = await handleBootstrapRequest(request, authority.manager);
72
+ }
59
73
  }
60
74
  }
61
75
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap-executor.js","sourceRoot":"","sources":["../../src/update/bootstrap-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAc/E,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAiC;IAC1E,IAAI,QAA2B,CAAC;IAChC,IAAI,UAAU,GAAkB,IAAI,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC1D,wEAAwE;QACxE,yEAAyE;QACzE,0EAA0E;QAC1E,qEAAqE;QACrE,IAAI,OAAO,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;YAC1B,QAAQ,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;QAClD,CAAC;aAAM,C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AK,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACrH,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC"}
@@ -39,6 +39,10 @@ import { StoreEventEmitter } from '@principles/core/runtime';
39
39
  * Rule 4 降级放行 CREATE 时 Owner 必须能事后取证「复用保护为何没拦」。
40
40
  * 注意 reuse_evaluation_recommended 刻意不入列:recommended 已由
41
41
  * candidateOutcomes / reuseEvidence 持久承载,落盘会形成第二决策日志)
42
+ * - diag_router_trusted_context_unavailable / replay_review_source_invalid
43
+ * (PRI-1146 P1-01:低频 skip/degradation 取证 — 前者记录 ledger 不可证明
44
+ * 时 canonical association 为何保持 unresolved,后者是 replay review skip
45
+ * 的唯一持久记录;见 Set 内注释)
42
46
  *
43
47
  * 落点 `<workspaceDir>/.pd/telemetry/critical-events.jsonl`(JSONL,一行一
44
48
  * 事件,含完整 TelemetryEvent)。同步 append:事件量小(allowlist 限流),
@@ -59,6 +63,15 @@ const CRITICAL_EVENT_ALLOWLIST = new Set([
59
63
  'artificer_blocked_on_owner_evidence',
60
64
  'reuse_gate_triggered',
61
65
  'reuse_evaluation_unavailable',
66
+ // PRI-1146 (P1-01 / rc-9): typed-unavailable diagnosis runs and replay-review
67
+ // skips must be reconstructable after the fact. Both are low-frequency skip/
68
+ // degradation evidence: the router event records WHY canonical associations
69
+ // stayed unresolved when the ledger was unprovable (the receipt is the
70
+ // primary proof; this line survives even if the artifact write later fails),
71
+ // and the replay event records WHY a pending candidate was not reuse-reviewed
72
+ // (its only durable record — the candidate row itself carries no skip reason).
73
+ 'diag_router_trusted_context_unavailable',
74
+ 'replay_review_source_invalid',
62
75
  ]);
63
76
  export class WorkspaceTelemetryEmitter extends StoreEventEmitter {
64
77
  upstream;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "3.1.2",
3
+ "version": "3.2.1",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -189,3 +189,10 @@ export declare function resolveInstallLayout(options: ResolveInstallLayoutOption
189
189
  export declare function getConsoleServerEntry(paths: InstallLayoutPaths, mode: InstallLayoutMode): string;
190
190
  export declare function getConsoleWebIndex(paths: InstallLayoutPaths, mode: InstallLayoutMode): string;
191
191
  export declare function getPdCliEntry(paths: InstallLayoutPaths, mode: InstallLayoutMode): string;
192
+ /**
193
+ * PD home resolution (PRI-872): production keeps the historical `os.homedir()`
194
+ * derivation; `PD_EXPERIMENT_ROOT` opts into a fail-closed isolated root. This
195
+ * is the ONE authority for "which PD home does this process own" — components
196
+ * must not re-derive it locally.
197
+ */
198
+ export { PD_EXPERIMENT_ROOT_ENV, PD_OPENCLAW_HOME_ENV, PD_HOME_MODES, PD_HOME_FAILURE_REASONS, resolvePdHome, isPathWithinRoot, type PdHomeMode, type PdHomePaths, type PdHomeFailure, type PdHomeFailureReason, type PdHomeSuccess, type PdHomeResolution, type ResolvePdHomeOptions, } from './pd-home.js';
@@ -278,3 +278,10 @@ export function getPdCliEntry(paths, mode) {
278
278
  const root = mode === 'canonical' ? paths.pdCliDir : path.join(paths.openClawExtensionDir, 'pd-cli');
279
279
  return path.join(root, 'dist', 'index.js');
280
280
  }
281
+ /**
282
+ * PD home resolution (PRI-872): production keeps the historical `os.homedir()`
283
+ * derivation; `PD_EXPERIMENT_ROOT` opts into a fail-closed isolated root. This
284
+ * is the ONE authority for "which PD home does this process own" — components
285
+ * must not re-derive it locally.
286
+ */
287
+ export { PD_EXPERIMENT_ROOT_ENV, PD_OPENCLAW_HOME_ENV, PD_HOME_MODES, PD_HOME_FAILURE_REASONS, resolvePdHome, isPathWithinRoot, } from './pd-home.js';
@@ -0,0 +1,55 @@
1
+ /** Opt-in isolation switch. Absolute path to the experiment's own root. */
2
+ export declare const PD_EXPERIMENT_ROOT_ENV = "PD_EXPERIMENT_ROOT";
3
+ /** OpenClaw's own home override (pre-existing; honoured in production mode). */
4
+ export declare const PD_OPENCLAW_HOME_ENV = "OPENCLAW_HOME";
5
+ export declare const PD_HOME_MODES: readonly ['production', 'experiment'];
6
+ export type PdHomeMode = (typeof PD_HOME_MODES)[number];
7
+ export interface PdHomePaths {
8
+ readonly mode: PdHomeMode;
9
+ /**
10
+ * The effective home all layout paths derive from. Production: the real user
11
+ * home. Experiment: the resolved experiment root (a stand-in home, so
12
+ * `getInstallLayoutPaths(homeDir)` keeps working unchanged).
13
+ */
14
+ readonly homeDir: string;
15
+ /** `<homeDir>/.pd` — active record, transactions, bootstrap executor. */
16
+ readonly pdHome: string;
17
+ /** `<homeDir>/.openclaw` (or `OPENCLAW_HOME`). */
18
+ readonly openclawHome: string;
19
+ /** `<homeDir>/.pd-console` — the console's workspace registry. */
20
+ readonly consoleConfigDir: string;
21
+ /** `<homeDir>/.codex` — suggested Codex home for the experiment launcher. */
22
+ readonly codexHome: string;
23
+ /** Present only in experiment mode: the canonical (realpath'd) root. */
24
+ readonly experimentRoot?: string;
25
+ }
26
+ export declare const PD_HOME_FAILURE_REASONS: readonly ['experiment_root_empty', 'experiment_root_not_absolute', 'experiment_root_missing', 'experiment_root_not_directory', 'experiment_root_unresolvable', 'experiment_root_overlaps_production', 'experiment_path_escapes_root', 'openclaw_home_outside_experiment'];
27
+ export type PdHomeFailureReason = (typeof PD_HOME_FAILURE_REASONS)[number];
28
+ export interface PdHomeFailure {
29
+ readonly ok: false;
30
+ readonly reason: PdHomeFailureReason;
31
+ readonly message: string;
32
+ readonly nextAction: string;
33
+ readonly details: Readonly<Record<string, string>>;
34
+ }
35
+ export interface PdHomeSuccess extends PdHomePaths {
36
+ readonly ok: true;
37
+ }
38
+ export type PdHomeResolution = PdHomeSuccess | PdHomeFailure;
39
+ export interface ResolvePdHomeOptions {
40
+ /** Environment to read. Defaults to `process.env`; injected by tests. */
41
+ readonly env?: Readonly<Record<string, string | undefined>>;
42
+ /** Real user home. Defaults to `os.homedir()`; injected by tests. */
43
+ readonly homeDir?: string;
44
+ }
45
+ /**
46
+ * True when `candidate` is inside `root` (or equal to it). Uses
47
+ * `path.relative`, which on win32 compares case-insensitively — the reason not
48
+ * to hand-roll a `startsWith` prefix check.
49
+ */
50
+ export declare function isPathWithinRoot(root: string, candidate: string): boolean;
51
+ /**
52
+ * Resolve the PD home for this process. Callers must treat `ok: false` as a
53
+ * startup refusal — there is no degraded mode.
54
+ */
55
+ export declare function resolvePdHome(options?: ResolvePdHomeOptions): PdHomeResolution;
@@ -0,0 +1,226 @@
1
+ /**
2
+ * PD home resolution — the ONE place that answers "which user-level PD home
3
+ * does THIS process belong to?".
4
+ *
5
+ * Why this exists (PRI-872 / SPEC `install-mjs-dev-prod-isolation-review` §6):
6
+ * before this module every PD component re-derived the home on its own with
7
+ * `os.homedir()` (pd-console had ten such sites plus the bootstrap executor),
8
+ * so a second, experimental instance silently shared the production install:
9
+ * the update page read `~/.pd`, the "apply" action spawned the production
10
+ * bootstrap executor, and the console registry (`~/.pd-console/workspaces.json`)
11
+ * was read and written by both instances.
12
+ *
13
+ * Why an explicit root instead of `HOME`: on Windows `os.homedir()` reads
14
+ * USERPROFILE while the installer's `getHomeDir()` prefers `HOME`
15
+ * (`create-principles-disciple/src/mvp-config.ts`). Pointing `HOME` elsewhere
16
+ * therefore made the installer and the console disagree about the same
17
+ * installation instead of isolating it. The isolation switch is its own
18
+ * variable and the whole derivation hangs off it.
19
+ *
20
+ * FAIL-CLOSED: when `PD_EXPERIMENT_ROOT` is present but unusable (relative,
21
+ * missing, not a directory, unresolvable, or overlapping the real production
22
+ * dirs) this returns a refusal. It never falls back to the real user home —
23
+ * a silent fallback is exactly the failure mode this module exists to remove.
24
+ */
25
+ import * as fs from 'node:fs';
26
+ import * as os from 'node:os';
27
+ import * as path from 'node:path';
28
+ /** Opt-in isolation switch. Absolute path to the experiment's own root. */
29
+ export const PD_EXPERIMENT_ROOT_ENV = 'PD_EXPERIMENT_ROOT';
30
+ /** OpenClaw's own home override (pre-existing; honoured in production mode). */
31
+ export const PD_OPENCLAW_HOME_ENV = 'OPENCLAW_HOME';
32
+ export const PD_HOME_MODES = ['production', 'experiment'];
33
+ export const PD_HOME_FAILURE_REASONS = [
34
+ 'experiment_root_empty',
35
+ 'experiment_root_not_absolute',
36
+ 'experiment_root_missing',
37
+ 'experiment_root_not_directory',
38
+ 'experiment_root_unresolvable',
39
+ 'experiment_root_overlaps_production',
40
+ 'experiment_path_escapes_root',
41
+ 'openclaw_home_outside_experiment',
42
+ ];
43
+ function failure(input) {
44
+ return { ok: false, ...input };
45
+ }
46
+ /**
47
+ * True when `candidate` is inside `root` (or equal to it). Uses
48
+ * `path.relative`, which on win32 compares case-insensitively — the reason not
49
+ * to hand-roll a `startsWith` prefix check.
50
+ */
51
+ export function isPathWithinRoot(root, candidate) {
52
+ const relative = path.relative(path.resolve(root), path.resolve(candidate));
53
+ if (relative === '')
54
+ return true;
55
+ if (path.isAbsolute(relative))
56
+ return false;
57
+ return relative !== '..' && !relative.startsWith(`..${path.sep}`);
58
+ }
59
+ /**
60
+ * Realpath the deepest EXISTING ancestor of `target`, then re-append the
61
+ * missing tail. Unlike `realpathSync(target)` this also answers for paths that
62
+ * do not exist yet (PD creates its own directories), while still resolving any
63
+ * link that already sits on the path.
64
+ */
65
+ function canonicalizeDeepestExisting(target) {
66
+ const missing = [];
67
+ let current = path.resolve(target);
68
+ for (;;) {
69
+ try {
70
+ const real = fs.realpathSync.native(current);
71
+ return missing.length === 0 ? real : path.join(real, ...missing.reverse());
72
+ }
73
+ catch {
74
+ // Missing or broken link — walk up one level and retry.
75
+ }
76
+ const parent = path.dirname(current);
77
+ if (parent === current)
78
+ return null;
79
+ missing.push(path.basename(current));
80
+ current = parent;
81
+ }
82
+ }
83
+ function productionPaths(realHome, env) {
84
+ const openclawOverride = env[PD_OPENCLAW_HOME_ENV]?.trim();
85
+ // Preserved production behaviour: OPENCLAW_HOME wins when set, no realpath
86
+ // rewrite (existing installs rely on the literal resolved path).
87
+ const openclawHome = openclawOverride !== undefined && openclawOverride.length > 0
88
+ ? path.resolve(openclawOverride)
89
+ : path.join(realHome, '.openclaw');
90
+ return {
91
+ ok: true,
92
+ mode: 'production',
93
+ homeDir: realHome,
94
+ pdHome: path.join(realHome, '.pd'),
95
+ openclawHome,
96
+ consoleConfigDir: path.join(realHome, '.pd-console'),
97
+ codexHome: path.join(realHome, '.codex'),
98
+ };
99
+ }
100
+ /**
101
+ * Resolve the PD home for this process. Callers must treat `ok: false` as a
102
+ * startup refusal — there is no degraded mode.
103
+ */
104
+ export function resolvePdHome(options = {}) {
105
+ const env = options.env ?? process.env;
106
+ const realHome = path.resolve(options.homeDir ?? os.homedir());
107
+ const rawRoot = env[PD_EXPERIMENT_ROOT_ENV];
108
+ if (rawRoot === undefined) {
109
+ return productionPaths(realHome, env);
110
+ }
111
+ const declared = rawRoot.trim();
112
+ if (declared.length === 0) {
113
+ return failure({
114
+ reason: 'experiment_root_empty',
115
+ message: `${PD_EXPERIMENT_ROOT_ENV} is set to an empty value.`,
116
+ nextAction: `Set ${PD_EXPERIMENT_ROOT_ENV} to an absolute path outside the production install, or unset it to run the production instance.`,
117
+ details: { [PD_EXPERIMENT_ROOT_ENV]: rawRoot },
118
+ });
119
+ }
120
+ if (!path.isAbsolute(declared)) {
121
+ return failure({
122
+ reason: 'experiment_root_not_absolute',
123
+ message: `${PD_EXPERIMENT_ROOT_ENV} must be an absolute path (got "${declared}").`,
124
+ nextAction: 'Use an absolute path such as D:/pd-labs/pri-872; a relative root would resolve against the current directory and drift.',
125
+ details: { [PD_EXPERIMENT_ROOT_ENV]: rawRoot },
126
+ });
127
+ }
128
+ let stats;
129
+ try {
130
+ stats = fs.statSync(declared);
131
+ }
132
+ catch {
133
+ return failure({
134
+ reason: 'experiment_root_missing',
135
+ message: `Experiment root does not exist: ${declared}`,
136
+ nextAction: 'Create the directory first (an empty directory is enough); PD will populate its own state under it.',
137
+ details: { experimentRoot: declared },
138
+ });
139
+ }
140
+ if (!stats.isDirectory()) {
141
+ return failure({
142
+ reason: 'experiment_root_not_directory',
143
+ message: `Experiment root is not a directory: ${declared}`,
144
+ nextAction: 'Point the root at a directory, not a file or a device.',
145
+ details: { experimentRoot: declared },
146
+ });
147
+ }
148
+ // Canonicalise once: every path below is derived from the REAL root, so a
149
+ // junction/symlink/case difference cannot make later checks disagree with
150
+ // where files actually land.
151
+ let rootReal;
152
+ try {
153
+ rootReal = fs.realpathSync.native(declared);
154
+ }
155
+ catch {
156
+ return failure({
157
+ reason: 'experiment_root_unresolvable',
158
+ message: `Experiment root cannot be resolved to a real path: ${declared}`,
159
+ nextAction: 'Check the path for a broken junction/symlink and retry.',
160
+ details: { experimentRoot: declared },
161
+ });
162
+ }
163
+ // The experiment must be DISJOINT from the production control plane in both
164
+ // directions: the root must not live inside ~/.pd, ~/.pd-console or
165
+ // ~/.openclaw, and it must not be an ancestor of them (e.g. C:/Users/me).
166
+ const productionDirs = [
167
+ ['.pd', path.join(realHome, '.pd')],
168
+ ['.pd-console', path.join(realHome, '.pd-console')],
169
+ ['.openclaw', path.join(realHome, '.openclaw')],
170
+ ];
171
+ for (const [label, productionDir] of productionDirs) {
172
+ const productionReal = canonicalizeDeepestExisting(productionDir) ?? path.resolve(productionDir);
173
+ if (isPathWithinRoot(rootReal, productionReal) || isPathWithinRoot(productionReal, rootReal)) {
174
+ return failure({
175
+ reason: 'experiment_root_overlaps_production',
176
+ message: `Experiment root overlaps the production ${label} directory (${productionReal}).`,
177
+ nextAction: 'Choose a root that contains neither the production state nor sits inside it — for example D:/pd-labs/<task>.',
178
+ details: { experimentRoot: rootReal, productionDir: productionReal },
179
+ });
180
+ }
181
+ }
182
+ const experimentPaths = [
183
+ ['pdHome', path.join(rootReal, '.pd')],
184
+ ['openclawHome', path.join(rootReal, '.openclaw')],
185
+ ['consoleConfigDir', path.join(rootReal, '.pd-console')],
186
+ ['codexHome', path.join(rootReal, '.codex')],
187
+ ];
188
+ for (const [label, candidate] of experimentPaths) {
189
+ // A pre-existing link at (or above) a derived path is the escape route:
190
+ // `<root>/.pd` junctioned to the production `~/.pd` would pass a naive
191
+ // prefix check on the declared path while writing production state.
192
+ const candidateReal = canonicalizeDeepestExisting(candidate);
193
+ if (candidateReal === null || !isPathWithinRoot(rootReal, candidateReal)) {
194
+ return failure({
195
+ reason: 'experiment_path_escapes_root',
196
+ message: `${label} resolves outside the experiment root: ${candidate} -> ${candidateReal ?? 'unresolvable'}`,
197
+ nextAction: 'Remove the junction/symlink at that path (or point it inside the root) and retry.',
198
+ details: { experimentRoot: rootReal, path: candidate, resolved: candidateReal ?? '' },
199
+ });
200
+ }
201
+ }
202
+ const openclawOverride = env[PD_OPENCLAW_HOME_ENV]?.trim();
203
+ let openclawHome = path.join(rootReal, '.openclaw');
204
+ if (openclawOverride !== undefined && openclawOverride.length > 0) {
205
+ const overrideReal = canonicalizeDeepestExisting(openclawOverride) ?? path.resolve(openclawOverride);
206
+ if (!path.isAbsolute(openclawOverride) || !isPathWithinRoot(rootReal, overrideReal)) {
207
+ return failure({
208
+ reason: 'openclaw_home_outside_experiment',
209
+ message: `${PD_OPENCLAW_HOME_ENV} points outside the experiment root: ${openclawOverride} -> ${overrideReal}`,
210
+ nextAction: `Unset ${PD_OPENCLAW_HOME_ENV} (the experiment derives its own openclaw home) or point it inside ${rootReal}.`,
211
+ details: { experimentRoot: rootReal, [PD_OPENCLAW_HOME_ENV]: openclawOverride },
212
+ });
213
+ }
214
+ openclawHome = path.resolve(openclawOverride);
215
+ }
216
+ return {
217
+ ok: true,
218
+ mode: 'experiment',
219
+ homeDir: rootReal,
220
+ pdHome: path.join(rootReal, '.pd'),
221
+ openclawHome,
222
+ consoleConfigDir: path.join(rootReal, '.pd-console'),
223
+ codexHome: path.join(rootReal, '.codex'),
224
+ experimentRoot: rootReal,
225
+ };
226
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/install-layout",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.148.8",
3
+ "version": "1.148.10",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -63,7 +63,7 @@
63
63
  "dependencies": {
64
64
  "@earendil-works/pi-agent-core": "1.2.0",
65
65
  "@earendil-works/pi-ai": "1.4.0",
66
- "@principles/install-layout": "^0.5.0",
66
+ "@principles/install-layout": "^0.6.0",
67
67
  "@sinclair/typebox": "^0.34.52",
68
68
  "@tufjs/models": "3.0.1",
69
69
  "@inquirer/prompts": "^8.7.2",
@@ -99,7 +99,7 @@
99
99
  "directory": "packages/create-principles-disciple"
100
100
  },
101
101
  "pd": {
102
- "bundledPluginVersion": "3.1.4"
102
+ "bundledPluginVersion": "3.1.5"
103
103
  },
104
- "gitHead": "716789d80d4308eac4f3d224ea68a6961331b047"
104
+ "gitHead": "80e8f5e27a6b7b395f73d2334477eb34317c3cc0"
105
105
  }