create-principles-disciple 1.150.6 → 1.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/codex-version.d.ts +14 -12
- package/codex-adapter/dist/ingestion/codex-version.js +19 -20
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/bind-guard.d.ts +6 -13
- package/console/dist/server/bind-guard.js +8 -17
- package/console/dist/server/index.d.ts +9 -3
- package/console/dist/server/index.js +55 -53
- package/console/dist/server/models/ActivationsConsoleModel.js +2 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +58 -19
- package/console/dist/server/routes/activations.js +2 -2
- package/console/dist/server/routes/diagnostician.js +1 -1
- package/console/dist/server/routes/evidence-outcomes.d.ts +3 -2
- package/console/dist/server/routes/evidence-outcomes.js +1 -1
- package/console/dist/server/routes/failed-tasks.js +85 -2
- package/console/dist/server/routes/governance.d.ts +9 -6
- package/console/dist/server/routes/governance.js +10 -6
- package/console/dist/server/routes/owner-decisions.d.ts +3 -3
- package/console/dist/server/routes/owner-decisions.js +1 -1
- package/console/dist/server/routes/owner-identity.d.ts +4 -5
- package/console/dist/server/routes/owner-identity.js +4 -4
- package/console/dist/server/routes/rule-candidate-bindings.js +1 -1
- package/console/dist/server/routes/update.js +24 -6
- package/console/dist/server/utils/request-guard.d.ts +35 -0
- package/console/dist/server/utils/request-guard.js +81 -0
- package/console/dist/server/utils/response.d.ts +0 -1
- package/console/dist/server/utils/response.js +0 -3
- package/console/dist/web/assets/app.css +95 -167
- package/console/dist/web/assets/app.js +32 -37
- package/core/dist/runtime/activation/activation-control-types.d.ts +3 -0
- package/core/dist/runtime/activation/activation-control-types.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.d.ts.map +1 -1
- package/core/dist/runtime/activation/ledger-identity.js +5 -0
- package/core/dist/runtime/activation/ledger-identity.js.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +6 -0
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js +105 -7
- package/core/dist/runtime/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js +3 -2
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js +26 -13
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +22 -8
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +10 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.d.ts +17 -2
- package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.js +26 -5
- package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime/governance-experience-contract.d.ts +12 -12
- package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience-contract.js +0 -2
- package/core/dist/runtime/governance-experience-contract.js.map +1 -1
- package/core/dist/runtime/governance-experience.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience.js +8 -16
- package/core/dist/runtime/governance-experience.js.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.d.ts.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js +2 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts +13 -0
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +28 -4
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +25 -3
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.d.ts +7 -0
- package/core/dist/runtime/recovery-sweep-service.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.js +1 -0
- package/core/dist/runtime/recovery-sweep-service.js.map +1 -1
- package/core/dist/runtime/signal-collector/types.d.ts +6 -0
- package/core/dist/runtime/signal-collector/types.d.ts.map +1 -1
- package/core/dist/runtime/signal-collector/types.js.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +59 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js +201 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -0
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +43 -2
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +96 -37
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +49 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +118 -78
- package/dist/installer.js.map +1 -1
- package/dist/installers/index.d.ts +31 -0
- package/dist/installers/index.d.ts.map +1 -1
- package/dist/installers/index.js +76 -3
- package/dist/installers/index.js.map +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/dist/update/data-compatibility.d.ts.map +1 -1
- package/dist/update/data-compatibility.js +3 -1
- package/dist/update/data-compatibility.js.map +1 -1
- package/dist/update/release-manager.d.ts +6 -1
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +56 -3
- package/dist/update/release-manager.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.js +1 -0
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +36 -8
- package/host-runtime/dist/adaptive-decision-protocol.js +79 -20
- package/host-runtime/dist/adaptive-selection.js +6 -1
- package/host-runtime/dist/cli-recovery-probe.d.ts +42 -1
- package/host-runtime/dist/cli-recovery-probe.js +16 -3
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +0 -29
- package/host-runtime/dist/conversation-ingestion/pipeline.js +39 -2
- package/host-runtime/dist/governance-signal-admission.js +12 -0
- package/host-runtime/dist/prompt-activation-deliverability.d.ts +2 -0
- package/host-runtime/dist/prompt-activation-deliverability.js +2 -0
- package/host-runtime/dist/prompt-injection-status.js +1 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/mcp-binding-contract.js +5 -0
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +117 -3
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts +0 -4
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +8 -63
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +4 -8
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +114 -63
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +0 -8
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +13 -15
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +3 -85
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +1 -1
- package/plugin/dist/bundle.js +469 -452
- package/plugin/dist/core/mcp-binding.d.ts +3 -1
- package/plugin/dist/core/signal-collector-host.d.ts +19 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/mcp/launcher.cjs +85 -0
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +118 -78
- package/release-manager/dist/installers/index.js +76 -3
- package/release-manager/dist/mvp-config.js +1 -1
- package/release-manager/dist/update/release-manager.js +56 -3
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +85 -0
- package/console/dist/server/config/AuthConfig.d.ts +0 -14
- package/console/dist/server/config/AuthConfig.js +0 -42
|
@@ -19,6 +19,7 @@ import { readBootstrapManifest, readInstallConfig, resolvePdHomePaths, } from '.
|
|
|
19
19
|
import { appendJournalTransition, readActiveRecord, TransactionJournalError, } from './transaction-journal.js';
|
|
20
20
|
import { downloadReleaseAsset, extractAndVerifyReleaseAsset, ApplyPayloadError } from './apply-payload.js';
|
|
21
21
|
import { compareProductVersions, parseProductVersion } from './product-identity.js';
|
|
22
|
+
import { installManifestHostsForPersist, parseInstallManifest } from '@principles/install-layout';
|
|
22
23
|
export class ReleaseManagerError extends Error {
|
|
23
24
|
reason;
|
|
24
25
|
nextAction;
|
|
@@ -147,6 +148,44 @@ function toReleaseManagerError(error) {
|
|
|
147
148
|
const message = error instanceof Error ? error.message : String(error);
|
|
148
149
|
return new ReleaseManagerError('apply_failed', `Release application failed: ${message}`, 'The runtime was left on the previous release (installer backup/restore). Retry the update; if it fails again, run the official installer to repair.');
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* PRI-1204: the deployment host an update must target.
|
|
153
|
+
*
|
|
154
|
+
* `~/.pd/install.json` is the installer-owned record of the hosts this
|
|
155
|
+
* installation serves. No caller of `apply()` supplies a host (the console
|
|
156
|
+
* request carries none), so this layer used to fall back to a literal
|
|
157
|
+
* `'openclaw'` — on a WorkBuddy-only (or Codex-only) installation the update
|
|
158
|
+
* was then deployed AS IF OpenClaw had been requested: the journal recorded a
|
|
159
|
+
* host the machine does not serve, the installer's manifest merge added
|
|
160
|
+
* `openclaw` to `hosts`, and OpenClaw-specific writes ran on a machine with no
|
|
161
|
+
* OpenClaw. The recorded host is the truth.
|
|
162
|
+
*
|
|
163
|
+
* One target is enough: the installer's own upgrade plan refreshes every OTHER
|
|
164
|
+
* installed host in the same run (`resolveHostRefreshTargets`).
|
|
165
|
+
*
|
|
166
|
+
* A legacy install.json without the manifest fields keeps the historical
|
|
167
|
+
* default — there is no record to contradict it.
|
|
168
|
+
*/
|
|
169
|
+
function resolveDeploymentHost(installConfigPath) {
|
|
170
|
+
let value;
|
|
171
|
+
try {
|
|
172
|
+
value = JSON.parse(fs.readFileSync(installConfigPath, 'utf8'));
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return 'openclaw';
|
|
176
|
+
}
|
|
177
|
+
const parsed = parseInstallManifest(value);
|
|
178
|
+
if (!parsed.manifest)
|
|
179
|
+
return 'openclaw';
|
|
180
|
+
const recorded = installManifestHostsForPersist(parsed.manifest);
|
|
181
|
+
if (recorded.includes('openclaw'))
|
|
182
|
+
return 'openclaw';
|
|
183
|
+
if (recorded.includes('workbuddy'))
|
|
184
|
+
return 'workbuddy';
|
|
185
|
+
if (recorded.includes('codex'))
|
|
186
|
+
return 'codex';
|
|
187
|
+
return 'openclaw';
|
|
188
|
+
}
|
|
150
189
|
/**
|
|
151
190
|
* Single authority for active.json: the transaction journal's strict reader
|
|
152
191
|
* (schemaVersion + full field set). This adapter only maps its corruption
|
|
@@ -250,6 +289,10 @@ export class ReleaseManager {
|
|
|
250
289
|
if (status.layout === 'legacy-overlay') {
|
|
251
290
|
throw new ReleaseManagerError('legacy_layout_not_supported', 'This installation uses the legacy overlay layout, which the transactional updater does not serve.', 'Run the official installer to repair this installation into the supported layout, then retry.');
|
|
252
291
|
}
|
|
292
|
+
// PRI-1204: the host this update deploys into comes from the installation
|
|
293
|
+
// record, not from a literal. Resolved once, before any side effect, so the
|
|
294
|
+
// journal, the installer call, and the manifest merge all state ONE target.
|
|
295
|
+
const deploymentHost = options.host ?? resolveDeploymentHost(this.paths.installConfigPath);
|
|
253
296
|
// Pre-transaction resolution phase: no side effects have happened, so any
|
|
254
297
|
// refusal here is a clean, unjournaled refusal — still mapped onto the
|
|
255
298
|
// typed ReleaseManagerError contract (rc-9), never a raw transport error.
|
|
@@ -268,7 +311,12 @@ export class ReleaseManager {
|
|
|
268
311
|
if (!decision.allowed) {
|
|
269
312
|
// PRI-848: the reason travels structured — the Console must map refusal
|
|
270
313
|
// states from a reason code, never by parsing the note string.
|
|
271
|
-
return {
|
|
314
|
+
return {
|
|
315
|
+
kind: 'no_update',
|
|
316
|
+
reason: decision.reason,
|
|
317
|
+
note: decision.message,
|
|
318
|
+
nextAction: decision.nextAction,
|
|
319
|
+
};
|
|
272
320
|
}
|
|
273
321
|
// PRI-853 (SPEC §10 wired, live-run fix): data compatibility preflight
|
|
274
322
|
// runs against the CURRENTLY ACTIVE version — the release whose data must
|
|
@@ -284,6 +332,7 @@ export class ReleaseManager {
|
|
|
284
332
|
kind: 'no_update',
|
|
285
333
|
reason: 'install_identity_unverifiable',
|
|
286
334
|
note: 'The installation has no readable active release record, so its data compatibility cannot be proven.',
|
|
335
|
+
nextAction: 'No runtime change was made. Run the official installer (npx create-principles-disciple) to repair the active release record, then retry the update.',
|
|
287
336
|
};
|
|
288
337
|
}
|
|
289
338
|
const windowVersion = parseProductVersion(releaseMetadata.compatibility.dataSchemaForwardReadableFrom, 'compatibility.dataSchemaForwardReadableFrom');
|
|
@@ -293,6 +342,10 @@ export class ReleaseManager {
|
|
|
293
342
|
kind: 'no_update',
|
|
294
343
|
reason: 'destructive_migration_requires_maintenance',
|
|
295
344
|
note: `Release ${releaseMetadata.productVersion} only guarantees data readable back to ${windowVersion.productVersion}, but the installed release is ${activeVersion.productVersion}. An ordinary update could strand code rollback.`,
|
|
345
|
+
// PRI-1153: state the facts and an executable step. There is no
|
|
346
|
+
// "official maintenance workflow" entry in this repository, so the
|
|
347
|
+
// refusal must not promise one.
|
|
348
|
+
nextAction: `No runtime change was made. Back up this workspace's ".pd" directory, then contact the maintainer to migrate data from ${activeVersion.productVersion} before installing ${releaseMetadata.productVersion}; this ordinary update path cannot cross the ${windowVersion.productVersion} schema boundary.`,
|
|
296
349
|
};
|
|
297
350
|
}
|
|
298
351
|
// PRI-850: honor a caller-generated transaction id (bootstrap executor
|
|
@@ -338,7 +391,7 @@ export class ReleaseManager {
|
|
|
338
391
|
// transaction BEFORE the first side effect. If even 'planned' cannot be
|
|
339
392
|
// written, refuse with zero side effects.
|
|
340
393
|
try {
|
|
341
|
-
appendApplyTransition(journal, 'planned', `host=${
|
|
394
|
+
appendApplyTransition(journal, 'planned', `host=${deploymentHost} mode=smart source=release-manager`);
|
|
342
395
|
}
|
|
343
396
|
catch (error) {
|
|
344
397
|
// PRI-897 (CR-1): the O_EXCL create is the ATOMIC seal. If two writers
|
|
@@ -377,7 +430,7 @@ export class ReleaseManager {
|
|
|
377
430
|
workspaceDir: options.workspaceDir,
|
|
378
431
|
channels: [],
|
|
379
432
|
overwriteConfig: false,
|
|
380
|
-
host:
|
|
433
|
+
host: deploymentHost,
|
|
381
434
|
stopGateway: true,
|
|
382
435
|
}, payloadDir, { quiet: true, nonInteractive: true }, journal);
|
|
383
436
|
if (!installResult.success) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/workbuddy-adapter",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -94,6 +94,76 @@ const logState = {
|
|
|
94
94
|
exhausted: false,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
// ── Experiment isolation (P0, 2026-11-13 real-host E2E) ────────────────────
|
|
98
|
+
// The experiment gateway inherits this launcher's environment. When
|
|
99
|
+
// PD_EXPERIMENT_ROOT is present every PD-owned path used here must stay inside
|
|
100
|
+
// it: the log directory (default would be the PRODUCTION `~/.pd/logs/mcp`) and
|
|
101
|
+
// the binding workspace (a stale/inherited binding must never point the
|
|
102
|
+
// experiment at the production workspace). Refuse BEFORE any MCP traffic.
|
|
103
|
+
const EXPERIMENT_ROOT = typeof process.env.PD_EXPERIMENT_ROOT === 'string'
|
|
104
|
+
? process.env.PD_EXPERIMENT_ROOT.trim()
|
|
105
|
+
: '';
|
|
106
|
+
|
|
107
|
+
function canonicalExisting(target) {
|
|
108
|
+
const resolved = path.resolve(target);
|
|
109
|
+
const missing = [];
|
|
110
|
+
let current = resolved;
|
|
111
|
+
for (;;) {
|
|
112
|
+
try {
|
|
113
|
+
const real = fs.realpathSync.native(current);
|
|
114
|
+
return missing.length === 0 ? real : path.join(real, ...missing.reverse());
|
|
115
|
+
} catch {
|
|
116
|
+
// Missing path (the log dir is created later): canonicalize the deepest
|
|
117
|
+
// existing ancestor so an 8.3-form ancestor cannot make two views of the
|
|
118
|
+
// same directory look different.
|
|
119
|
+
}
|
|
120
|
+
const parent = path.dirname(current);
|
|
121
|
+
if (parent === current) return resolved;
|
|
122
|
+
missing.push(path.basename(current));
|
|
123
|
+
current = parent;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function isInsideOrSame(parent, child) {
|
|
128
|
+
const relative = path.relative(path.resolve(parent), path.resolve(child));
|
|
129
|
+
return relative === '' || (!path.isAbsolute(relative) && relative !== '..' && !relative.startsWith('..' + path.sep));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function experimentRootRealPath() {
|
|
133
|
+
if (EXPERIMENT_ROOT === '') return null;
|
|
134
|
+
if (!path.isAbsolute(EXPERIMENT_ROOT)) {
|
|
135
|
+
fail('experiment_root_not_absolute', 'PD_EXPERIMENT_ROOT must be an absolute path; refusing to start the MCP server from an ambiguous root.');
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
return fs.realpathSync.native(EXPERIMENT_ROOT);
|
|
139
|
+
} catch {
|
|
140
|
+
fail('experiment_root_missing', 'PD_EXPERIMENT_ROOT does not resolve to an existing directory; refusing to start the MCP server.');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isLogDirAllowed(dir) {
|
|
145
|
+
if (EXPERIMENT_ROOT === '') return true;
|
|
146
|
+
const rootReal = experimentRootRealPath();
|
|
147
|
+
return rootReal !== null && isInsideOrSame(rootReal, canonicalExisting(dir));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (EXPERIMENT_ROOT !== '') {
|
|
151
|
+
const logOverride = typeof process.env.PD_MCP_LOG_DIR === 'string' ? process.env.PD_MCP_LOG_DIR.trim() : '';
|
|
152
|
+
if (logOverride === '') {
|
|
153
|
+
fail(
|
|
154
|
+
'experiment_mcp_log_dir_missing',
|
|
155
|
+
'PD_MCP_LOG_DIR must be set for an experiment instance; the default log directory is the production ~/.pd/logs/mcp.',
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
const rootReal = experimentRootRealPath();
|
|
159
|
+
if (rootReal !== null && !isInsideOrSame(rootReal, canonicalExisting(logOverride))) {
|
|
160
|
+
fail(
|
|
161
|
+
'experiment_mcp_log_dir_outside_root',
|
|
162
|
+
'PD_MCP_LOG_DIR resolves outside PD_EXPERIMENT_ROOT; refusing to write MCP logs into production state.',
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
97
167
|
function pad(value, width) {
|
|
98
168
|
return String(value).padStart(width || 2, '0');
|
|
99
169
|
}
|
|
@@ -176,6 +246,7 @@ function ensureLogFile() {
|
|
|
176
246
|
if (logState.currentPath !== null) return logState.currentPath;
|
|
177
247
|
try {
|
|
178
248
|
const dir = logDir();
|
|
249
|
+
if (!isLogDirAllowed(dir)) return null;
|
|
179
250
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
180
251
|
if (!fs.statSync(dir).isDirectory()) return null;
|
|
181
252
|
maintainLogDir(dir, Date.now(), null);
|
|
@@ -497,6 +568,20 @@ if (!workspaceStat.isDirectory()) {
|
|
|
497
568
|
}
|
|
498
569
|
logState.workspaceResolution = 'ok';
|
|
499
570
|
|
|
571
|
+
// P0 (2026-11-13): an experiment must never bind a workspace outside its own
|
|
572
|
+
// root. The binding is untrusted input written by another process generation;
|
|
573
|
+
// a stale one (or one produced from an inherited production pointer) keeps the
|
|
574
|
+
// production path while every environment variable says "experiment".
|
|
575
|
+
if (EXPERIMENT_ROOT !== '') {
|
|
576
|
+
const rootReal = experimentRootRealPath();
|
|
577
|
+
if (rootReal !== null && !isInsideOrSame(rootReal, canonicalExisting(binding.workspaceDir))) {
|
|
578
|
+
fail(
|
|
579
|
+
'experiment_binding_workspace_outside_root',
|
|
580
|
+
'mcp-binding.json binds a workspace outside PD_EXPERIMENT_ROOT. Restart the experiment gateway so the PD plugin rewrites the binding for the experiment workspace.',
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
500
585
|
// ── OpenClaw workspace-declaration gate (SPEC §3.5, final safety closure) ──
|
|
501
586
|
// The OpenClaw binding is HOST-WIDE while agents have per-agent workspaces, so
|
|
502
587
|
// a binding may only be trusted while it still matches the workspace the Owner
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from 'node:http';
|
|
2
|
-
export interface AuthConfigOptions {
|
|
3
|
-
cliToken?: string;
|
|
4
|
-
envToken?: string;
|
|
5
|
-
noAuth?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare class AuthConfig {
|
|
8
|
-
private readonly token;
|
|
9
|
-
private readonly enabled;
|
|
10
|
-
constructor(opts?: AuthConfigOptions);
|
|
11
|
-
isEnabled(): boolean;
|
|
12
|
-
getToken(): string | null;
|
|
13
|
-
isAuthenticated(req: IncomingMessage): boolean;
|
|
14
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as crypto from 'crypto';
|
|
2
|
-
export class AuthConfig {
|
|
3
|
-
token;
|
|
4
|
-
enabled;
|
|
5
|
-
constructor(opts = {}) {
|
|
6
|
-
const token = opts.cliToken ?? opts.envToken ?? null;
|
|
7
|
-
this.enabled = !opts.noAuth && token !== null && token.length > 0;
|
|
8
|
-
this.token = token;
|
|
9
|
-
}
|
|
10
|
-
isEnabled() {
|
|
11
|
-
return this.enabled;
|
|
12
|
-
}
|
|
13
|
-
getToken() {
|
|
14
|
-
return this.token;
|
|
15
|
-
}
|
|
16
|
-
isAuthenticated(req) {
|
|
17
|
-
if (!this.enabled) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
const authHeader = req.headers.authorization;
|
|
21
|
-
if (typeof authHeader !== 'string') {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
const match = /^Bearer\s+(.+)$/i.exec(authHeader);
|
|
25
|
-
if (!match) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
const [, provided] = match;
|
|
29
|
-
if (!provided) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
if (!this.token) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
const providedBuf = Buffer.from(provided, 'utf8');
|
|
36
|
-
const expectedBuf = Buffer.from(this.token, 'utf8');
|
|
37
|
-
if (providedBuf.length !== expectedBuf.length) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
return crypto.timingSafeEqual(providedBuf, expectedBuf);
|
|
41
|
-
}
|
|
42
|
-
}
|