create-principles-disciple 1.148.11 → 1.150.1
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.
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/pd-hook.d.ts +22 -1
- package/codex-adapter/dist/pd-hook.js +81 -7
- package/codex-adapter/dist/worker/workspace-worker.d.ts +15 -0
- package/codex-adapter/dist/worker/workspace-worker.js +7 -36
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.js +21 -0
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +3 -17
- package/console/dist/server/models/ActivationsConsoleModel.js +5 -44
- package/console/dist/server/routes/compatibility-scan.d.ts +18 -0
- package/console/dist/server/routes/compatibility-scan.js +33 -0
- package/console/dist/server/routes/diagnostician.d.ts +50 -0
- package/console/dist/server/routes/diagnostician.js +388 -0
- package/console/dist/shared/compatibility-scan-contract.d.ts +26 -0
- package/console/dist/shared/compatibility-scan-contract.js +1 -0
- package/console/dist/web/assets/app.js +31 -31
- package/core/dist/host/host-installer.d.ts +7 -0
- package/core/dist/host/host-installer.d.ts.map +1 -1
- package/core/dist/host/host-installer.js.map +1 -1
- package/core/dist/runtime/activation/index.d.ts +3 -3
- package/core/dist/runtime/activation/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/index.js +1 -1
- package/core/dist/runtime/activation/index.js.map +1 -1
- package/core/dist/runtime/activation/promotion-readiness-evaluator.d.ts +25 -1
- package/core/dist/runtime/activation/promotion-readiness-evaluator.d.ts.map +1 -1
- package/core/dist/runtime/activation/promotion-readiness-evaluator.js +58 -1
- package/core/dist/runtime/activation/promotion-readiness-evaluator.js.map +1 -1
- package/core/dist/runtime/activation/promotion-readiness-reader.d.ts.map +1 -1
- package/core/dist/runtime/activation/promotion-readiness-reader.js +4 -2
- package/core/dist/runtime/activation/promotion-readiness-reader.js.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts +28 -0
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js +2 -0
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime/activation-compatibility-read-model.d.ts +20 -5
- package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
- package/core/dist/runtime/activation-compatibility-read-model.js +15 -3
- package/core/dist/runtime/activation-compatibility-read-model.js.map +1 -1
- package/core/dist/runtime/admission-gate.d.ts +8 -1
- package/core/dist/runtime/admission-gate.d.ts.map +1 -1
- package/core/dist/runtime/admission-gate.js +2 -1
- package/core/dist/runtime/admission-gate.js.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.js +20 -2
- package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +18 -0
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/context-payload.d.ts +48 -3
- package/core/dist/runtime/context-payload.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.js +38 -0
- package/core/dist/runtime/context-payload.js.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +8 -2
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +28 -2
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician-candidate.d.ts +24 -0
- package/core/dist/runtime/diagnostician-candidate.d.ts.map +1 -0
- package/core/dist/runtime/diagnostician-candidate.js +55 -0
- package/core/dist/runtime/diagnostician-candidate.js.map +1 -0
- package/core/dist/runtime/evidence-guards.d.ts +10 -4
- package/core/dist/runtime/evidence-guards.d.ts.map +1 -1
- package/core/dist/runtime/evidence-guards.js +12 -5
- package/core/dist/runtime/evidence-guards.js.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.d.ts +4 -4
- package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.js +1 -0
- package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.js +14 -0
- package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +16 -0
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/index.d.ts +5 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +6 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +1 -0
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +2 -0
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/rule-host-contracts.d.ts +10 -0
- package/core/dist/runtime/internalization/rule-host-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-host-evaluator.js +10 -10
- package/core/dist/runtime/internalization/rule-host-evaluator.js.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts +7 -6
- package/core/dist/runtime/internalization/rule-host-input-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-host-input-builder.js +6 -2
- package/core/dist/runtime/internalization/rule-host-input-builder.js.map +1 -1
- package/core/dist/runtime/internalization/rule-host-result-normalizer.d.ts +33 -0
- package/core/dist/runtime/internalization/rule-host-result-normalizer.d.ts.map +1 -0
- package/core/dist/runtime/internalization/rule-host-result-normalizer.js +61 -0
- package/core/dist/runtime/internalization/rule-host-result-normalizer.js.map +1 -0
- package/core/dist/runtime/internalization/rule-host-validator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-host-validator.js +17 -0
- package/core/dist/runtime/internalization/rule-host-validator.js.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.d.ts +27 -2
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +45 -3
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts +4 -2
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js +23 -3
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-severity.d.ts +14 -0
- package/core/dist/runtime/pain-severity.d.ts.map +1 -0
- package/core/dist/runtime/pain-severity.js +14 -0
- package/core/dist/runtime/pain-severity.js.map +1 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts +17 -3
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +6 -0
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-observability.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-observability.js +3 -2
- package/core/dist/runtime/pain-signal-observability.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.d.ts +164 -0
- package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -0
- package/core/dist/runtime/pain-submit-capability.js +442 -0
- package/core/dist/runtime/pain-submit-capability.js.map +1 -0
- package/core/dist/runtime/pain-to-principle-service.d.ts +4 -0
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +2 -0
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime/stalled-diagnostician-task-read-model.d.ts +56 -10
- package/core/dist/runtime/stalled-diagnostician-task-read-model.d.ts.map +1 -1
- package/core/dist/runtime/stalled-diagnostician-task-read-model.js +80 -4
- package/core/dist/runtime/stalled-diagnostician-task-read-model.js.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +11 -0
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/run/memory-run-store.d.ts +10 -0
- package/core/dist/runtime/store/run/memory-run-store.d.ts.map +1 -1
- package/core/dist/runtime/store/run/memory-run-store.js +21 -0
- package/core/dist/runtime/store/run/memory-run-store.js.map +1 -1
- package/core/dist/runtime/store/run/run-store.d.ts +12 -0
- package/core/dist/runtime/store/run/run-store.d.ts.map +1 -1
- package/core/dist/runtime/store/run/sqlite-run-store.d.ts +1 -0
- package/core/dist/runtime/store/run/sqlite-run-store.d.ts.map +1 -1
- package/core/dist/runtime/store/run/sqlite-run-store.js +14 -0
- package/core/dist/runtime/store/run/sqlite-run-store.js.map +1 -1
- package/core/dist/runtime/task-status.d.ts +9 -0
- package/core/dist/runtime/task-status.d.ts.map +1 -1
- package/core/dist/runtime/task-status.js +7 -1
- package/core/dist/runtime/task-status.js.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.d.ts +18 -0
- package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.js +37 -7
- package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
- package/core/package.json +5 -1
- package/dist/install-summary.d.ts +7 -0
- package/dist/install-summary.d.ts.map +1 -1
- package/dist/install-summary.js +4 -0
- package/dist/install-summary.js.map +1 -1
- package/dist/installer.d.ts +92 -8
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +215 -10
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +88 -1
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +350 -11
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/index.d.ts +23 -0
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +38 -1
- package/dist/installers/index.js.map +1 -1
- package/dist/installers/legacy-workbuddy-skill.d.ts +59 -0
- package/dist/installers/legacy-workbuddy-skill.d.ts.map +1 -0
- package/dist/installers/legacy-workbuddy-skill.js +168 -0
- package/dist/installers/legacy-workbuddy-skill.js.map +1 -0
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +7 -0
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/host-runtime/dist/adaptive-priority-provider.d.ts +94 -0
- package/host-runtime/dist/adaptive-priority-provider.js +162 -0
- package/host-runtime/dist/adaptive-selection.d.ts +164 -0
- package/host-runtime/dist/adaptive-selection.js +506 -0
- package/host-runtime/dist/diagnostician-auto-run.d.ts +28 -0
- package/host-runtime/dist/diagnostician-auto-run.js +100 -0
- package/host-runtime/dist/host-tool-semantic-resolver.d.ts +42 -1
- package/host-runtime/dist/host-tool-semantic-resolver.js +80 -14
- package/host-runtime/dist/index.d.ts +4 -0
- package/host-runtime/dist/index.js +6 -0
- package/host-runtime/dist/production-rulehost-gate.js +17 -17
- package/host-runtime/dist/rulecode-event-collection.d.ts +31 -0
- package/host-runtime/dist/rulecode-event-collection.js +62 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +1 -1
- package/install-layout/dist/index.js +1 -1
- package/install-layout/dist/pd-home.d.ts +9 -2
- package/install-layout/dist/pd-home.js +77 -14
- package/install-layout/package.json +1 -1
- package/package.json +4 -4
- package/pd-cli/dist/commands/diagnose.d.ts +30 -0
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +75 -0
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +5 -4
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +2 -1
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts +6 -17
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +42 -48
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-compatibility-scan.d.ts +5 -2
- package/pd-cli/dist/commands/runtime-compatibility-scan.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-compatibility-scan.js +22 -2
- package/pd-cli/dist/commands/runtime-compatibility-scan.js.map +1 -1
- package/pd-cli/dist/index.js +1 -0
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/config-doctor.d.ts +9 -0
- package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
- package/pd-cli/dist/services/config-doctor.js +15 -0
- package/pd-cli/dist/services/config-doctor.js.map +1 -1
- package/pd-cli/dist/services/delivery-surfaces.js +1 -1
- package/pd-cli/dist/services/delivery-surfaces.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/budget.d.ts +1 -1
- package/pd-mcp-server/dist/budget.js +2 -2
- package/pd-mcp-server/dist/envelope.d.ts +15 -0
- package/pd-mcp-server/dist/envelope.js +49 -1
- package/pd-mcp-server/dist/index.d.ts +2 -0
- package/pd-mcp-server/dist/index.js +6 -0
- package/pd-mcp-server/dist/server.d.ts +83 -14
- package/pd-mcp-server/dist/server.js +251 -4
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/dist/workspace.d.ts +4 -2
- package/pd-mcp-server/dist/workspace.js +5 -2
- package/pd-mcp-server/package.json +1 -1
- package/plugin/dist/bundle.js +443 -431
- package/plugin/dist/core/evolution-reducer.d.ts +2 -2
- package/plugin/dist/hooks/hook-tool-semantics.d.ts +25 -0
- package/plugin/dist/hooks/pain-ingress-adapter.d.ts +1 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +215 -10
- package/release-manager/dist/installers/codex-host-installer.js +350 -11
- package/release-manager/dist/installers/index.js +38 -1
- package/release-manager/dist/installers/legacy-workbuddy-skill.js +168 -0
- package/release-manager/dist/installers/workbuddy-host-installer.js +7 -0
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/pd-hook.js +20 -4
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/skills/pd-pain-signal/SKILL.md +123 -20
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* on the Console)
|
|
16
16
|
* - auto-consumer / codex worker (host-threaded registries, already
|
|
17
17
|
* host-exact; the resolver exists for host-neutral entries)
|
|
18
|
+
* - B3: `resolveHostToolSemanticsForHook` — the realtime hook entry point
|
|
19
|
+
* (OpenClaw gate, Codex / WorkBuddy pd-hook) resolves the SAME durable
|
|
20
|
+
* declarations replay reads, instead of only its compiled-in list.
|
|
18
21
|
*
|
|
19
22
|
* Multi-host semantics (R2 P1-2): declarations are PER-HOST files under
|
|
20
23
|
* `.pd/host-tool-semantics/<hostKind>.json` (last-writer-wins on a shared
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
*
|
|
26
29
|
* Pure logic + declared-file I/O only. Merging is order-independent.
|
|
27
30
|
*/
|
|
28
|
-
import { type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
31
|
+
import { type ToolSemanticMappingV1, type ToolSemanticRegistry } from '@principles/core/runtime';
|
|
29
32
|
import { saveHostToolDeclaration, type HostToolDeclaration } from './host-tool-declaration.js';
|
|
30
33
|
export type HostToolSemanticResolution = {
|
|
31
34
|
readonly ok: true;
|
|
@@ -43,5 +46,43 @@ export type HostToolSemanticResolution = {
|
|
|
43
46
|
* against baseline names is a forged proof; ERR-114).
|
|
44
47
|
*/
|
|
45
48
|
export declare function resolveWorkspaceHostToolSemantics(workspaceDir: string): HostToolSemanticResolution;
|
|
49
|
+
/** Where the hook-facing registry got its host layer from. */
|
|
50
|
+
export type HookToolSemanticsSource = 'workspace-declaration' | 'host-static';
|
|
51
|
+
export type HookToolSemanticsResolution = {
|
|
52
|
+
readonly ok: true;
|
|
53
|
+
readonly registry: ToolSemanticRegistry;
|
|
54
|
+
readonly source: HookToolSemanticsSource;
|
|
55
|
+
} | {
|
|
56
|
+
readonly ok: false;
|
|
57
|
+
readonly reason: string;
|
|
58
|
+
readonly nextAction: string;
|
|
59
|
+
};
|
|
60
|
+
export interface HookToolSemanticsOptions {
|
|
61
|
+
readonly workspaceDir: string;
|
|
62
|
+
/** The calling host's identity label (also the declaration filename). */
|
|
63
|
+
readonly hostKind: string;
|
|
64
|
+
/** The host's compiled-in declaration — the fallback data source. */
|
|
65
|
+
readonly staticMappings: readonly ToolSemanticMappingV1[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* B3 — the ONE entry point the realtime hook uses to resolve tool semantics.
|
|
69
|
+
*
|
|
70
|
+
* Precedence (plan §4.2): workspace declaration → host static declaration →
|
|
71
|
+
* core baseline. Replay/evidence/Console already read the declarations via
|
|
72
|
+
* `resolveWorkspaceHostToolSemantics`; before B3 the hook read the compiled-in
|
|
73
|
+
* static list only, so a workspace declaration could disagree with production
|
|
74
|
+
* on the same event.
|
|
75
|
+
*
|
|
76
|
+
* - no declaration persisted → the host static registry (`source:
|
|
77
|
+
* 'host-static'`): the pre-B3 behavior, and the normal state before a host
|
|
78
|
+
* has started once in this workspace.
|
|
79
|
+
* - declaration persisted → its names win (they are what replay resolves),
|
|
80
|
+
* and static names the declaration does not carry are still filled in so a
|
|
81
|
+
* stale file cannot amputate the host's current surface.
|
|
82
|
+
* - malformed / conflicting declaration → typed refusal, never a silent
|
|
83
|
+
* static fallback and never an empty registry. Consumers must surface the
|
|
84
|
+
* reason (rc-9) and may fall back to their static registry for availability.
|
|
85
|
+
*/
|
|
86
|
+
export declare function resolveHostToolSemanticsForHook(options: HookToolSemanticsOptions): HookToolSemanticsResolution;
|
|
46
87
|
export { saveHostToolDeclaration };
|
|
47
88
|
export type { HostToolDeclaration };
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
* on the Console)
|
|
16
16
|
* - auto-consumer / codex worker (host-threaded registries, already
|
|
17
17
|
* host-exact; the resolver exists for host-neutral entries)
|
|
18
|
+
* - B3: `resolveHostToolSemanticsForHook` — the realtime hook entry point
|
|
19
|
+
* (OpenClaw gate, Codex / WorkBuddy pd-hook) resolves the SAME durable
|
|
20
|
+
* declarations replay reads, instead of only its compiled-in list.
|
|
18
21
|
*
|
|
19
22
|
* Multi-host semantics (R2 P1-2): declarations are PER-HOST files under
|
|
20
23
|
* `.pd/host-tool-semantics/<hostKind>.json` (last-writer-wins on a shared
|
|
@@ -28,22 +31,16 @@
|
|
|
28
31
|
import { buildToolSemanticRegistry, } from '@principles/core/runtime';
|
|
29
32
|
import { loadHostToolDeclarations, saveHostToolDeclaration, } from './host-tool-declaration.js';
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
34
|
+
* Union every declared host's mappings, order-independently.
|
|
35
|
+
*
|
|
36
|
+
* Same raw name from two hosts must agree on kind; a conflict means a host
|
|
37
|
+
* declared a name it does not own — fail loud rather than pick a winner by
|
|
38
|
+
* startup order (P4 one-source-of-truth).
|
|
35
39
|
*/
|
|
36
|
-
|
|
37
|
-
const loaded = loadHostToolDeclarations(workspaceDir);
|
|
38
|
-
if (!loaded.ok) {
|
|
39
|
-
return { ok: false, reason: loaded.reason, nextAction: loaded.nextAction };
|
|
40
|
-
}
|
|
40
|
+
function mergeDeclarations(declarations) {
|
|
41
41
|
const mappings = [];
|
|
42
|
-
for (const declaration of
|
|
42
|
+
for (const declaration of declarations) {
|
|
43
43
|
for (const mapping of declaration.mappings) {
|
|
44
|
-
// Same raw name from two hosts must agree on kind; a conflict means a
|
|
45
|
-
// host declared a name it does not own — fail loud rather than pick a
|
|
46
|
-
// winner by startup order (P4 one-source-of-truth).
|
|
47
44
|
const existing = mappings.find((m) => m.rawToolName === mapping.rawToolName);
|
|
48
45
|
if (existing && existing.canonicalKind !== mapping.canonicalKind) {
|
|
49
46
|
return {
|
|
@@ -56,7 +53,23 @@ export function resolveWorkspaceHostToolSemantics(workspaceDir) {
|
|
|
56
53
|
mappings.push(mapping);
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
|
-
|
|
56
|
+
return { ok: true, mappings };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the merged workspace registry from durable host provenance.
|
|
60
|
+
* Fails loud when no declaration is persisted or any persisted declaration
|
|
61
|
+
* is malformed — never falls back to the core baseline (an existence check
|
|
62
|
+
* against baseline names is a forged proof; ERR-114).
|
|
63
|
+
*/
|
|
64
|
+
export function resolveWorkspaceHostToolSemantics(workspaceDir) {
|
|
65
|
+
const loaded = loadHostToolDeclarations(workspaceDir);
|
|
66
|
+
if (!loaded.ok) {
|
|
67
|
+
return { ok: false, reason: loaded.reason, nextAction: loaded.nextAction };
|
|
68
|
+
}
|
|
69
|
+
const merged = mergeDeclarations(loaded.declarations);
|
|
70
|
+
if (!merged.ok)
|
|
71
|
+
return merged;
|
|
72
|
+
const built = buildToolSemanticRegistry(merged.mappings);
|
|
60
73
|
if (!built.ok) {
|
|
61
74
|
return {
|
|
62
75
|
ok: false,
|
|
@@ -70,4 +83,57 @@ export function resolveWorkspaceHostToolSemantics(workspaceDir) {
|
|
|
70
83
|
hostKinds: loaded.declarations.map((d) => d.hostKind).sort(),
|
|
71
84
|
};
|
|
72
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* B3 — the ONE entry point the realtime hook uses to resolve tool semantics.
|
|
88
|
+
*
|
|
89
|
+
* Precedence (plan §4.2): workspace declaration → host static declaration →
|
|
90
|
+
* core baseline. Replay/evidence/Console already read the declarations via
|
|
91
|
+
* `resolveWorkspaceHostToolSemantics`; before B3 the hook read the compiled-in
|
|
92
|
+
* static list only, so a workspace declaration could disagree with production
|
|
93
|
+
* on the same event.
|
|
94
|
+
*
|
|
95
|
+
* - no declaration persisted → the host static registry (`source:
|
|
96
|
+
* 'host-static'`): the pre-B3 behavior, and the normal state before a host
|
|
97
|
+
* has started once in this workspace.
|
|
98
|
+
* - declaration persisted → its names win (they are what replay resolves),
|
|
99
|
+
* and static names the declaration does not carry are still filled in so a
|
|
100
|
+
* stale file cannot amputate the host's current surface.
|
|
101
|
+
* - malformed / conflicting declaration → typed refusal, never a silent
|
|
102
|
+
* static fallback and never an empty registry. Consumers must surface the
|
|
103
|
+
* reason (rc-9) and may fall back to their static registry for availability.
|
|
104
|
+
*/
|
|
105
|
+
export function resolveHostToolSemanticsForHook(options) {
|
|
106
|
+
const builtStatic = buildToolSemanticRegistry(options.staticMappings);
|
|
107
|
+
if (!builtStatic.ok) {
|
|
108
|
+
return {
|
|
109
|
+
ok: false,
|
|
110
|
+
reason: `host_tool_semantics_static_invalid (${options.hostKind})`,
|
|
111
|
+
nextAction: `fix the '${options.hostKind}' compiled-in tool declaration: ${builtStatic.errors.slice(0, 3).join('; ')}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const loaded = loadHostToolDeclarations(options.workspaceDir);
|
|
115
|
+
if (!loaded.ok) {
|
|
116
|
+
if (loaded.reason === 'host_tool_declaration_missing') {
|
|
117
|
+
return { ok: true, registry: builtStatic.registry, source: 'host-static' };
|
|
118
|
+
}
|
|
119
|
+
return { ok: false, reason: loaded.reason, nextAction: loaded.nextAction };
|
|
120
|
+
}
|
|
121
|
+
const merged = mergeDeclarations(loaded.declarations);
|
|
122
|
+
if (!merged.ok)
|
|
123
|
+
return merged;
|
|
124
|
+
const mappings = [...merged.mappings];
|
|
125
|
+
for (const mapping of options.staticMappings) {
|
|
126
|
+
if (!mappings.some((m) => m.rawToolName === mapping.rawToolName))
|
|
127
|
+
mappings.push(mapping);
|
|
128
|
+
}
|
|
129
|
+
const built = buildToolSemanticRegistry(mappings);
|
|
130
|
+
if (!built.ok) {
|
|
131
|
+
return {
|
|
132
|
+
ok: false,
|
|
133
|
+
reason: `host_tool_semantics_static_invalid (${options.hostKind})`,
|
|
134
|
+
nextAction: `merged tool mappings invalid: ${built.errors.slice(0, 3).join('; ')}`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return { ok: true, registry: built.registry, source: 'workspace-declaration' };
|
|
138
|
+
}
|
|
73
139
|
export { saveHostToolDeclaration };
|
|
@@ -11,6 +11,7 @@ export * from './prompt-activation-deliverability.js';
|
|
|
11
11
|
export * from './prompt-injection-status.js';
|
|
12
12
|
export * from './prompt-injection-event-evidence.js';
|
|
13
13
|
export * from './prompt-injection-budget-observation.js';
|
|
14
|
+
export * from './rulecode-event-collection.js';
|
|
14
15
|
export * from './pd-config.js';
|
|
15
16
|
export * from './production-rulehost-gate.js';
|
|
16
17
|
export * from './rule-implementation-runtime.js';
|
|
@@ -18,10 +19,13 @@ export * from './production-pain-evidence.js';
|
|
|
18
19
|
export * from './governance-observation-store.js';
|
|
19
20
|
export * from './governance-signal-admission.js';
|
|
20
21
|
export * from './signal-classifier.js';
|
|
22
|
+
export * from './adaptive-selection.js';
|
|
23
|
+
export * from './adaptive-priority-provider.js';
|
|
21
24
|
export * from './signal-stage2-cycle.js';
|
|
22
25
|
export * from './host-liveness-contract.js';
|
|
23
26
|
export * from './internalization-consumer-governance.js';
|
|
24
27
|
export * from './internalization-consumer-cycle.js';
|
|
28
|
+
export * from './diagnostician-auto-run.js';
|
|
25
29
|
export * from './host-tool-declaration.js';
|
|
26
30
|
export * from './host-tool-semantic-resolver.js';
|
|
27
31
|
export * from './evaluator-runtime-context.js';
|
|
@@ -21,6 +21,9 @@ export * from './prompt-injection-event-evidence.js';
|
|
|
21
21
|
// events — console surfaces forecast under the budget the last real
|
|
22
22
|
// injection used (SPEC §6.1), labelled with source + observation time.
|
|
23
23
|
export * from './prompt-injection-budget-observation.js';
|
|
24
|
+
// RuleCode shadow telemetry scan: ONE filesystem reader for CLI promotion
|
|
25
|
+
// review and the Console Owner review (5B deduplication).
|
|
26
|
+
export * from './rulecode-event-collection.js';
|
|
24
27
|
export * from './pd-config.js';
|
|
25
28
|
export * from './production-rulehost-gate.js';
|
|
26
29
|
export * from './rule-implementation-runtime.js';
|
|
@@ -28,12 +31,15 @@ export * from './production-pain-evidence.js';
|
|
|
28
31
|
export * from './governance-observation-store.js';
|
|
29
32
|
export * from './governance-signal-admission.js';
|
|
30
33
|
export * from './signal-classifier.js';
|
|
34
|
+
export * from './adaptive-selection.js';
|
|
35
|
+
export * from './adaptive-priority-provider.js';
|
|
31
36
|
export * from './signal-stage2-cycle.js';
|
|
32
37
|
export * from './host-liveness-contract.js';
|
|
33
38
|
// PRI-624 Slice C: shared internalization consumer execution (OpenClaw
|
|
34
39
|
// auto-consumer + Companion workspace worker call the same cycle).
|
|
35
40
|
export * from './internalization-consumer-governance.js';
|
|
36
41
|
export * from './internalization-consumer-cycle.js';
|
|
42
|
+
export * from './diagnostician-auto-run.js';
|
|
37
43
|
// PRI-634-F R2: durable host-authored tool declaration — hosts persist, host-
|
|
38
44
|
// neutral consumers (pd-cli/pd-console) resolve through the ONE resolver.
|
|
39
45
|
export * from './host-tool-declaration.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { buildRuleHostAction, buildToolSemanticRegistry, deriveToolHintsFromCanonicalKind, estimateLineChanges, mergeDecisions, SqliteConnection, UNAVAILABLE_RULE_CONTEXT, validateRuleContextV2,
|
|
3
|
+
import { buildRuleHostAction, buildToolSemanticRegistry, deriveToolHintsFromCanonicalKind, estimateLineChanges, mergeDecisions, normalizeRuleHostResult, SqliteConnection, UNAVAILABLE_RULE_CONTEXT, validateRuleContextV2, verifyPiArtifactRowDigest, RECOVERY_CONTROL_SURFACES, } from '@principles/core/runtime';
|
|
4
4
|
import { isSensitiveSystemPath } from '@principles/core/runtime/internalization/rule-host-input-builder';
|
|
5
5
|
import { classifyBashRisk } from '@principles/core/runtime/internalization/bash-risk';
|
|
6
6
|
import { scanRetiredContractSymbols } from './legacy-rule-contract-symbols.js';
|
|
@@ -76,9 +76,6 @@ function isRuleMeta(value) {
|
|
|
76
76
|
function isRuleContext(value) {
|
|
77
77
|
return validateRuleContextV2(value).valid;
|
|
78
78
|
}
|
|
79
|
-
function isRuleResult(value) {
|
|
80
|
-
return validateRuleHostResult(value).valid;
|
|
81
|
-
}
|
|
82
79
|
const baselineToolSemanticsResult = buildToolSemanticRegistry();
|
|
83
80
|
// Static baseline input — always builds; throwing here is a programming error.
|
|
84
81
|
if (!baselineToolSemanticsResult.ok) {
|
|
@@ -588,14 +585,14 @@ export function createProductionRuleHostGate(options = {}) {
|
|
|
588
585
|
addWarning(warnings, `implementation_unhealthy: ${batchResult && !batchResult.ok ? batchResult.error ?? 'unknown child error' : 'rule_batch_result_missing'}`, 'fix the shadow RuleCode and reactivate the rule; live enforcement is unaffected');
|
|
589
586
|
continue;
|
|
590
587
|
}
|
|
591
|
-
const
|
|
592
|
-
if (
|
|
593
|
-
addWarning(warnings, `invalid RuleHostResult: ${
|
|
588
|
+
const normalized = normalizeRuleHostResult(batchResult.result);
|
|
589
|
+
if (normalized.degraded !== undefined) {
|
|
590
|
+
addWarning(warnings, `invalid RuleHostResult: ${normalized.degraded.notes ?? 'unknown invalid result'}`, 'fix the shadow RuleCode result and reactivate the rule; live enforcement is unaffected');
|
|
594
591
|
continue;
|
|
595
592
|
}
|
|
596
|
-
const shadowResult =
|
|
597
|
-
? { ...
|
|
598
|
-
:
|
|
593
|
+
const shadowResult = normalized.matched
|
|
594
|
+
? { ...normalized, ruleId: candidate.ruleId, principleId: candidate.principleId }
|
|
595
|
+
: normalized;
|
|
599
596
|
shadowEvaluations.push({
|
|
600
597
|
toolName: input.toolName,
|
|
601
598
|
filePath: action.normalizedPath,
|
|
@@ -623,14 +620,17 @@ export function createProductionRuleHostGate(options = {}) {
|
|
|
623
620
|
addWarning(warnings, `implementation_unhealthy: ${batchResult.error ?? 'unknown child error'}`, 'fix the RuleCode and reactivate the rule');
|
|
624
621
|
continue;
|
|
625
622
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
623
|
+
// B1: one reading of unusable output. Previously this branch warned and
|
|
624
|
+
// `continue`d, so the rule silently stopped participating and another
|
|
625
|
+
// rule's allow could win the merge. Normalization keeps it in the merge
|
|
626
|
+
// as a contract-level fail-closed requireApproval marked `degraded`.
|
|
627
|
+
const normalized = normalizeRuleHostResult(batchResult.result);
|
|
628
|
+
if (normalized.degraded !== undefined) {
|
|
629
|
+
addWarning(warnings, `invalid RuleHostResult: ${normalized.degraded.notes ?? 'unknown invalid result'}`, 'fix the RuleCode result and reactivate the rule; invalid output is normalized to requireApproval (fail-closed in the contract, not enforced as a block by this gate)');
|
|
630
630
|
}
|
|
631
|
-
const validatedResult =
|
|
632
|
-
? { ...
|
|
633
|
-
:
|
|
631
|
+
const validatedResult = normalized.matched
|
|
632
|
+
? { ...normalized, ruleId: candidate.ruleId, principleId: candidate.principleId }
|
|
633
|
+
: normalized;
|
|
634
634
|
implementations.push({ ...candidate, evaluate: () => validatedResult });
|
|
635
635
|
liveEvaluatedResults.push(validatedResult);
|
|
636
636
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface CollectedRuleCodeEventEntries {
|
|
2
|
+
entries: unknown[];
|
|
3
|
+
/** Number of candidate directories that actually exist on disk. */
|
|
4
|
+
sourceDirsFound: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* PRI-577: RuleCode event telemetry candidate directories, in priority order.
|
|
8
|
+
*
|
|
9
|
+
* Runtime convention is `.pd/logs`, but the v1 EventLog writer
|
|
10
|
+
* (openclaw-plugin `src/core/event-log.ts`) still emits `events_*.jsonl` under
|
|
11
|
+
* `.state/logs`. No production code ever created `.pd/logs`, so scanning only
|
|
12
|
+
* that path made every shadow metric report "unavailable" while 2500+ real
|
|
13
|
+
* evaluations sat unread in `.state/logs`. Readers scan both candidates until
|
|
14
|
+
* the writer migrates (ERR-031: every reader derives from the host-runtime
|
|
15
|
+
* constant `RUNTIME_EVENT_LOG_CANDIDATE_DIRS`, so they cannot drift).
|
|
16
|
+
*/
|
|
17
|
+
export declare const RULECODE_EVENT_LOG_CANDIDATE_DIRS: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Collect rulehost telemetry entries from all candidate log directories.
|
|
20
|
+
* Malformed lines are excluded individually. A directory counts as a source
|
|
21
|
+
* only after it can be enumerated, so an unreadable path cannot be mistaken
|
|
22
|
+
* for a healthy channel with zero events (ERR-002).
|
|
23
|
+
*
|
|
24
|
+
* Exact lines copied between candidate directories are deduplicated by
|
|
25
|
+
* priority. Different events in same-named daily files are retained.
|
|
26
|
+
*
|
|
27
|
+
* ONE implementation: this is the host-side filesystem reader the CLI
|
|
28
|
+
* (`runtime activation promote`) and the Console Owner review both consume, so
|
|
29
|
+
* a fix to the scan cannot land in one consumer and silently lag in the other.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectRuleCodeEventEntries(workspaceDir: string): CollectedRuleCodeEventEntries;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { RUNTIME_EVENT_LOG_CANDIDATE_DIRS } from './prompt-injection-budget-observation.js';
|
|
4
|
+
/**
|
|
5
|
+
* PRI-577: RuleCode event telemetry candidate directories, in priority order.
|
|
6
|
+
*
|
|
7
|
+
* Runtime convention is `.pd/logs`, but the v1 EventLog writer
|
|
8
|
+
* (openclaw-plugin `src/core/event-log.ts`) still emits `events_*.jsonl` under
|
|
9
|
+
* `.state/logs`. No production code ever created `.pd/logs`, so scanning only
|
|
10
|
+
* that path made every shadow metric report "unavailable" while 2500+ real
|
|
11
|
+
* evaluations sat unread in `.state/logs`. Readers scan both candidates until
|
|
12
|
+
* the writer migrates (ERR-031: every reader derives from the host-runtime
|
|
13
|
+
* constant `RUNTIME_EVENT_LOG_CANDIDATE_DIRS`, so they cannot drift).
|
|
14
|
+
*/
|
|
15
|
+
export const RULECODE_EVENT_LOG_CANDIDATE_DIRS = RUNTIME_EVENT_LOG_CANDIDATE_DIRS;
|
|
16
|
+
/**
|
|
17
|
+
* Collect rulehost telemetry entries from all candidate log directories.
|
|
18
|
+
* Malformed lines are excluded individually. A directory counts as a source
|
|
19
|
+
* only after it can be enumerated, so an unreadable path cannot be mistaken
|
|
20
|
+
* for a healthy channel with zero events (ERR-002).
|
|
21
|
+
*
|
|
22
|
+
* Exact lines copied between candidate directories are deduplicated by
|
|
23
|
+
* priority. Different events in same-named daily files are retained.
|
|
24
|
+
*
|
|
25
|
+
* ONE implementation: this is the host-side filesystem reader the CLI
|
|
26
|
+
* (`runtime activation promote`) and the Console Owner review both consume, so
|
|
27
|
+
* a fix to the scan cannot land in one consumer and silently lag in the other.
|
|
28
|
+
*/
|
|
29
|
+
export function collectRuleCodeEventEntries(workspaceDir) {
|
|
30
|
+
const entries = [];
|
|
31
|
+
let sourceDirsFound = 0;
|
|
32
|
+
const higherPriorityLines = new Set();
|
|
33
|
+
for (const candidate of RULECODE_EVENT_LOG_CANDIDATE_DIRS) {
|
|
34
|
+
const logsDir = path.join(workspaceDir, ...candidate.split('/'));
|
|
35
|
+
if (!fs.existsSync(logsDir))
|
|
36
|
+
continue;
|
|
37
|
+
try {
|
|
38
|
+
const files = fs.readdirSync(logsDir)
|
|
39
|
+
.filter(name => /^events_.*\.jsonl$/.test(name))
|
|
40
|
+
.sort()
|
|
41
|
+
.slice(-7);
|
|
42
|
+
sourceDirsFound += 1;
|
|
43
|
+
const currentSourceLines = [];
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const lines = fs.readFileSync(path.join(logsDir, file), 'utf8').split('\n').filter(Boolean);
|
|
46
|
+
for (const line of lines) {
|
|
47
|
+
currentSourceLines.push(line);
|
|
48
|
+
if (higherPriorityLines.has(line))
|
|
49
|
+
continue;
|
|
50
|
+
try {
|
|
51
|
+
entries.push(JSON.parse(line));
|
|
52
|
+
}
|
|
53
|
+
catch { /* exclude malformed telemetry */ }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
for (const line of currentSourceLines)
|
|
57
|
+
higherPriorityLines.add(line);
|
|
58
|
+
}
|
|
59
|
+
catch { /* unreadable directory contributes no entries */ }
|
|
60
|
+
}
|
|
61
|
+
return { entries, sourceDirsFound };
|
|
62
|
+
}
|
|
@@ -195,4 +195,4 @@ export declare function getPdCliEntry(paths: InstallLayoutPaths, mode: InstallLa
|
|
|
195
195
|
* is the ONE authority for "which PD home does this process own" — components
|
|
196
196
|
* must not re-derive it locally.
|
|
197
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';
|
|
198
|
+
export { PD_EXPERIMENT_ROOT_ENV, PD_OPENCLAW_HOME_ENV, PD_OPENCLAW_STATE_DIR_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';
|
|
@@ -284,4 +284,4 @@ export function getPdCliEntry(paths, mode) {
|
|
|
284
284
|
* is the ONE authority for "which PD home does this process own" — components
|
|
285
285
|
* must not re-derive it locally.
|
|
286
286
|
*/
|
|
287
|
-
export { PD_EXPERIMENT_ROOT_ENV, PD_OPENCLAW_HOME_ENV, PD_HOME_MODES, PD_HOME_FAILURE_REASONS, resolvePdHome, isPathWithinRoot, } from './pd-home.js';
|
|
287
|
+
export { PD_EXPERIMENT_ROOT_ENV, PD_OPENCLAW_HOME_ENV, PD_OPENCLAW_STATE_DIR_ENV, PD_HOME_MODES, PD_HOME_FAILURE_REASONS, resolvePdHome, isPathWithinRoot, } from './pd-home.js';
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
export declare const PD_EXPERIMENT_ROOT_ENV = "PD_EXPERIMENT_ROOT";
|
|
3
3
|
/** OpenClaw's own home override (pre-existing; honoured in production mode). */
|
|
4
4
|
export declare const PD_OPENCLAW_HOME_ENV = "OPENCLAW_HOME";
|
|
5
|
+
/**
|
|
6
|
+
* OpenClaw's explicit state-dir override. Authoritative over `OPENCLAW_HOME`
|
|
7
|
+
* (OpenClaw resolves its state dir from this first), so PD's `openclawHome`
|
|
8
|
+
* must follow it — otherwise PD writes extensions/backups to one place while
|
|
9
|
+
* the host reads another.
|
|
10
|
+
*/
|
|
11
|
+
export declare const PD_OPENCLAW_STATE_DIR_ENV = "OPENCLAW_STATE_DIR";
|
|
5
12
|
export declare const PD_HOME_MODES: readonly ['production', 'experiment'];
|
|
6
13
|
export type PdHomeMode = (typeof PD_HOME_MODES)[number];
|
|
7
14
|
export interface PdHomePaths {
|
|
@@ -14,7 +21,7 @@ export interface PdHomePaths {
|
|
|
14
21
|
readonly homeDir: string;
|
|
15
22
|
/** `<homeDir>/.pd` — active record, transactions, bootstrap executor. */
|
|
16
23
|
readonly pdHome: string;
|
|
17
|
-
/** `<homeDir>/.openclaw` (or `OPENCLAW_HOME`). */
|
|
24
|
+
/** `<homeDir>/.openclaw` (or `OPENCLAW_STATE_DIR` > `OPENCLAW_HOME`). */
|
|
18
25
|
readonly openclawHome: string;
|
|
19
26
|
/** `<homeDir>/.pd-console` — the console's workspace registry. */
|
|
20
27
|
readonly consoleConfigDir: string;
|
|
@@ -23,7 +30,7 @@ export interface PdHomePaths {
|
|
|
23
30
|
/** Present only in experiment mode: the canonical (realpath'd) root. */
|
|
24
31
|
readonly experimentRoot?: string;
|
|
25
32
|
}
|
|
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'];
|
|
33
|
+
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', 'openclaw_state_dir_not_absolute', 'openclaw_state_dir_outside_experiment'];
|
|
27
34
|
export type PdHomeFailureReason = (typeof PD_HOME_FAILURE_REASONS)[number];
|
|
28
35
|
export interface PdHomeFailure {
|
|
29
36
|
readonly ok: false;
|
|
@@ -29,6 +29,13 @@ import * as path from 'node:path';
|
|
|
29
29
|
export const PD_EXPERIMENT_ROOT_ENV = 'PD_EXPERIMENT_ROOT';
|
|
30
30
|
/** OpenClaw's own home override (pre-existing; honoured in production mode). */
|
|
31
31
|
export const PD_OPENCLAW_HOME_ENV = 'OPENCLAW_HOME';
|
|
32
|
+
/**
|
|
33
|
+
* OpenClaw's explicit state-dir override. Authoritative over `OPENCLAW_HOME`
|
|
34
|
+
* (OpenClaw resolves its state dir from this first), so PD's `openclawHome`
|
|
35
|
+
* must follow it — otherwise PD writes extensions/backups to one place while
|
|
36
|
+
* the host reads another.
|
|
37
|
+
*/
|
|
38
|
+
export const PD_OPENCLAW_STATE_DIR_ENV = 'OPENCLAW_STATE_DIR';
|
|
32
39
|
export const PD_HOME_MODES = ['production', 'experiment'];
|
|
33
40
|
export const PD_HOME_FAILURE_REASONS = [
|
|
34
41
|
'experiment_root_empty',
|
|
@@ -39,6 +46,8 @@ export const PD_HOME_FAILURE_REASONS = [
|
|
|
39
46
|
'experiment_root_overlaps_production',
|
|
40
47
|
'experiment_path_escapes_root',
|
|
41
48
|
'openclaw_home_outside_experiment',
|
|
49
|
+
'openclaw_state_dir_not_absolute',
|
|
50
|
+
'openclaw_state_dir_outside_experiment',
|
|
42
51
|
];
|
|
43
52
|
function failure(input) {
|
|
44
53
|
return { ok: false, ...input };
|
|
@@ -80,13 +89,40 @@ function canonicalizeDeepestExisting(target) {
|
|
|
80
89
|
current = parent;
|
|
81
90
|
}
|
|
82
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Production PD home. `OPENCLAW_STATE_DIR` (absolute) wins over
|
|
94
|
+
* `OPENCLAW_HOME` — kept in its legacy meaning here, i.e. the `.openclaw`
|
|
95
|
+
* directory itself — which wins over `<realHome>/.openclaw`. A non-absolute
|
|
96
|
+
* `OPENCLAW_STATE_DIR` is refused instead of being resolved against the cwd.
|
|
97
|
+
*/
|
|
83
98
|
function productionPaths(realHome, env) {
|
|
99
|
+
// PRI-1165: OPENCLAW_STATE_DIR is OpenClaw's authoritative state dir, so PD's
|
|
100
|
+
// `openclawHome` follows it when set. OPENCLAW_HOME stays as the legacy
|
|
101
|
+
// fallback: OpenClaw itself treats it as a HOME substitute, but existing PD
|
|
102
|
+
// installs pass the `.openclaw` directory, and reinterpreting it would move
|
|
103
|
+
// their backups/extensions. Precedence:
|
|
104
|
+
// OPENCLAW_STATE_DIR > OPENCLAW_HOME > <realHome>/.openclaw
|
|
105
|
+
const stateDirOverride = env[PD_OPENCLAW_STATE_DIR_ENV]?.trim();
|
|
106
|
+
if (stateDirOverride !== undefined && stateDirOverride.length > 0 && !path.isAbsolute(stateDirOverride)) {
|
|
107
|
+
return failure({
|
|
108
|
+
reason: 'openclaw_state_dir_not_absolute',
|
|
109
|
+
message: `${PD_OPENCLAW_STATE_DIR_ENV} must be an absolute path (got "${stateDirOverride}").`,
|
|
110
|
+
nextAction: `Use an absolute path, or unset ${PD_OPENCLAW_STATE_DIR_ENV} to derive <home>/.openclaw.`,
|
|
111
|
+
details: { [PD_OPENCLAW_STATE_DIR_ENV]: stateDirOverride },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
84
114
|
const openclawOverride = env[PD_OPENCLAW_HOME_ENV]?.trim();
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
// No realpath rewrite (existing installs rely on the literal resolved path).
|
|
116
|
+
let openclawHome;
|
|
117
|
+
if (stateDirOverride !== undefined && stateDirOverride.length > 0) {
|
|
118
|
+
openclawHome = path.resolve(stateDirOverride);
|
|
119
|
+
}
|
|
120
|
+
else if (openclawOverride !== undefined && openclawOverride.length > 0) {
|
|
121
|
+
openclawHome = path.resolve(openclawOverride);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
openclawHome = path.join(realHome, '.openclaw');
|
|
125
|
+
}
|
|
90
126
|
return {
|
|
91
127
|
ok: true,
|
|
92
128
|
mode: 'production',
|
|
@@ -199,19 +235,46 @@ export function resolvePdHome(options = {}) {
|
|
|
199
235
|
});
|
|
200
236
|
}
|
|
201
237
|
}
|
|
202
|
-
|
|
238
|
+
// PRI-1165: the launcher passes OPENCLAW_STATE_DIR = the derived
|
|
239
|
+
// `<root>/.openclaw`, so PD and OpenClaw agree on one state dir. It is
|
|
240
|
+
// authoritative over OPENCLAW_HOME (mirroring OpenClaw) and must stay inside
|
|
241
|
+
// the root; OPENCLAW_HOME is only consulted when no state dir is given.
|
|
203
242
|
let openclawHome = path.join(rootReal, '.openclaw');
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (!path.isAbsolute(
|
|
243
|
+
const stateDirOverride = env[PD_OPENCLAW_STATE_DIR_ENV]?.trim();
|
|
244
|
+
if (stateDirOverride !== undefined && stateDirOverride.length > 0) {
|
|
245
|
+
if (!path.isAbsolute(stateDirOverride)) {
|
|
207
246
|
return failure({
|
|
208
|
-
reason: '
|
|
209
|
-
message: `${
|
|
210
|
-
nextAction: `
|
|
211
|
-
details: { experimentRoot: rootReal, [
|
|
247
|
+
reason: 'openclaw_state_dir_not_absolute',
|
|
248
|
+
message: `${PD_OPENCLAW_STATE_DIR_ENV} must be an absolute path (got "${stateDirOverride}").`,
|
|
249
|
+
nextAction: `Use an absolute path inside ${rootReal}, or unset ${PD_OPENCLAW_STATE_DIR_ENV}.`,
|
|
250
|
+
details: { experimentRoot: rootReal, [PD_OPENCLAW_STATE_DIR_ENV]: stateDirOverride },
|
|
212
251
|
});
|
|
213
252
|
}
|
|
214
|
-
|
|
253
|
+
const stateReal = canonicalizeDeepestExisting(stateDirOverride) ?? path.resolve(stateDirOverride);
|
|
254
|
+
if (!isPathWithinRoot(rootReal, stateReal)) {
|
|
255
|
+
return failure({
|
|
256
|
+
reason: 'openclaw_state_dir_outside_experiment',
|
|
257
|
+
message: `${PD_OPENCLAW_STATE_DIR_ENV} points outside the experiment root: ${stateDirOverride} -> ${stateReal}`,
|
|
258
|
+
nextAction: `Unset ${PD_OPENCLAW_STATE_DIR_ENV} (the experiment derives its own openclaw state) or point it inside ${rootReal}.`,
|
|
259
|
+
details: { experimentRoot: rootReal, [PD_OPENCLAW_STATE_DIR_ENV]: stateDirOverride },
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
openclawHome = path.resolve(stateDirOverride);
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
const openclawOverride = env[PD_OPENCLAW_HOME_ENV]?.trim();
|
|
266
|
+
if (openclawOverride !== undefined && openclawOverride.length > 0) {
|
|
267
|
+
const overrideReal = canonicalizeDeepestExisting(openclawOverride) ?? path.resolve(openclawOverride);
|
|
268
|
+
if (!path.isAbsolute(openclawOverride) || !isPathWithinRoot(rootReal, overrideReal)) {
|
|
269
|
+
return failure({
|
|
270
|
+
reason: 'openclaw_home_outside_experiment',
|
|
271
|
+
message: `${PD_OPENCLAW_HOME_ENV} points outside the experiment root: ${openclawOverride} -> ${overrideReal}`,
|
|
272
|
+
nextAction: `Unset ${PD_OPENCLAW_HOME_ENV} (the experiment derives its own openclaw home) or point it inside ${rootReal}.`,
|
|
273
|
+
details: { experimentRoot: rootReal, [PD_OPENCLAW_HOME_ENV]: openclawOverride },
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
openclawHome = path.resolve(openclawOverride);
|
|
277
|
+
}
|
|
215
278
|
}
|
|
216
279
|
return {
|
|
217
280
|
ok: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.150.1",
|
|
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.
|
|
66
|
+
"@principles/install-layout": "^0.7.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
|
|
102
|
+
"bundledPluginVersion": "3.2.1"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "8851a3be8c3bcacb732609143bfe3d2ac4ba4ea5"
|
|
105
105
|
}
|