create-principles-disciple 1.153.2 → 1.153.4
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/worker/workspace-worker.js +5 -1
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.js +8 -1
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +9 -1
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +19 -1
- package/console/dist/server/models/IntentPageModel.d.ts +37 -1
- package/console/dist/server/models/IntentPageModel.js +53 -1
- package/console/dist/server/routes/update-history.d.ts +32 -0
- package/console/dist/server/routes/update-history.js +215 -1
- package/console/dist/web/assets/app.css +106 -0
- package/console/dist/web/assets/app.js +118 -32
- package/console/dist/web/assets/intent-reflection.webp +3 -0
- package/core/dist/runtime/config/index.d.ts +1 -1
- package/core/dist/runtime/config/index.d.ts.map +1 -1
- package/core/dist/runtime/config/index.js +1 -1
- package/core/dist/runtime/config/index.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 +4 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/index.d.ts +3 -3
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +2 -2
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/intent/intent-browser.d.ts +2 -2
- package/core/dist/runtime/intent/intent-browser.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-browser.js +5 -1
- package/core/dist/runtime/intent/intent-browser.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +58 -11
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +11 -2
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +24 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +59 -5
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +7 -0
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +62 -14
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +44 -8
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/prompts.d.ts +6 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +17 -7
- package/dist/prompts.js.map +1 -1
- package/dist/utils/env.d.ts +19 -2
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js +55 -14
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/host-workspace-ownership.d.ts +25 -0
- package/dist/utils/host-workspace-ownership.d.ts.map +1 -0
- package/dist/utils/host-workspace-ownership.js +69 -0
- package/dist/utils/host-workspace-ownership.js.map +1 -0
- package/host-runtime/dist/diagnostician-auto-run.js +6 -0
- package/host-runtime/dist/governance-signal-admission.js +7 -0
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +4 -0
- package/host-runtime/dist/intent-doc-reader.d.ts +70 -0
- package/host-runtime/dist/intent-doc-reader.js +292 -0
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +24 -1
- package/install-layout/dist/index.js +58 -1
- package/install-layout/dist/mcp-binding-contract.d.ts +27 -0
- package/install-layout/dist/mcp-binding-contract.js +62 -0
- package/install-layout/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +7 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-mcp.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-mcp.js +20 -2
- package/pd-cli/dist/commands/health-mcp.js.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.d.ts +11 -0
- package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.js +24 -2
- package/pd-cli/dist/commands/mcp-probe.js.map +1 -1
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +6 -0
- 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 +8 -1
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +473 -473
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/mcp/launcher.cjs +132 -5
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +59 -5
- package/release-manager/dist/installers/codex-host-installer.js +62 -14
- package/release-manager/dist/installers/workbuddy-host-installer.js +44 -8
- package/release-manager/dist/utils/env.js +55 -14
- package/release-manager/dist/utils/host-workspace-ownership.js +69 -0
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/worker/workspace-worker.js +5 -1
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/mcp/launcher.cjs +132 -5
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1229 / SPEC-PD-INTENT-UNIFICATION-001 §9.3 — neutral host IntentDocReader.
|
|
3
|
+
*
|
|
4
|
+
* A host-neutral adapter implementing Core's `IntentDocReader` port for the
|
|
5
|
+
* production entry points that live outside the OpenClaw plugin: PD CLI
|
|
6
|
+
* (pain record / diagnose / pain retry) and host-runtime governance admission.
|
|
7
|
+
*
|
|
8
|
+
* Why a separate thin adapter instead of sharing the plugin's
|
|
9
|
+
* `safeReadIntentDoc()` (SPEC §9.3 rule 4): the plugin package is a
|
|
10
|
+
* host-specific delivery unit (ClawHub tarball) and must never become a
|
|
11
|
+
* dependency of pd-cli or host-runtime — that would invert the dependency
|
|
12
|
+
* direction. All BUSINESS logic stays in Core and is shared by every entry
|
|
13
|
+
* point (no second copy):
|
|
14
|
+
* - flag predicate: `isIntentAnchoringEnabled(effectiveConfig)`
|
|
15
|
+
* - content hash: `computeIntentContentHash(raw)`
|
|
16
|
+
* - path naming: `getIntentFilename(lang)`
|
|
17
|
+
* This module only performs the file read and maps it onto the Core port
|
|
18
|
+
* result — the same responsibility split as the plugin-side adapter.
|
|
19
|
+
*
|
|
20
|
+
* Contract (SPEC §12 / §13.1, mirroring the plugin reader):
|
|
21
|
+
* - Flag check FIRST from the entry-provided effectiveConfig. Flag off →
|
|
22
|
+
* `flag_disabled` WITHOUT any filesystem or cache access.
|
|
23
|
+
* - 32KB cap enforced on the actually-read bytes (single open descriptor:
|
|
24
|
+
* no stat-then-read TOCTOU; the fixed buffer also bounds a file that
|
|
25
|
+
* grows while being read).
|
|
26
|
+
* - `not_found` / `oversized` / `read_error` degrade with structured
|
|
27
|
+
* reason + nextAction. NEVER throws.
|
|
28
|
+
* - TTL + mtime cache keyed `${workspaceDir}:${lang}` — the same mechanism
|
|
29
|
+
* as the plugin reader (SPEC §12.1: 60s TTL, mtime verified).
|
|
30
|
+
*/
|
|
31
|
+
import * as fs from 'node:fs';
|
|
32
|
+
import * as path from 'node:path';
|
|
33
|
+
import { INTENT_MAX_BYTES, computeIntentContentHash, getIntentFilename, isIntentAnchoringEnabled, } from '@principles/core/runtime';
|
|
34
|
+
/** True when a filesystem call failed because the path does not exist. */
|
|
35
|
+
function isEnoent(err) {
|
|
36
|
+
if (!(err instanceof Error))
|
|
37
|
+
return false;
|
|
38
|
+
const descriptor = Object.getOwnPropertyDescriptor(err, 'code');
|
|
39
|
+
return descriptor?.value === 'ENOENT';
|
|
40
|
+
}
|
|
41
|
+
const INTENT_DIR = '.principles';
|
|
42
|
+
const INTENT_CACHE_TTL_MS = 60_000; // 1 minute (SPEC §12.1, same as plugin reader)
|
|
43
|
+
/**
|
|
44
|
+
* PR #2684 P1: how many times a single readIntentDoc() call may re-open the
|
|
45
|
+
* file when the stability check fails (writer rewriting the file while we
|
|
46
|
+
* read). Bounded, not a sleep-and-hope loop: after the budget is exhausted
|
|
47
|
+
* the read degrades to the structured read_error result (rc-9) rather than
|
|
48
|
+
* caching possibly-torn content.
|
|
49
|
+
*/
|
|
50
|
+
const INTENT_STABILITY_RETRIES = 2;
|
|
51
|
+
const _intentDocCache = new Map();
|
|
52
|
+
function identityOf(bigStat) {
|
|
53
|
+
return {
|
|
54
|
+
dev: bigStat.dev,
|
|
55
|
+
ino: bigStat.ino,
|
|
56
|
+
size: bigStat.size,
|
|
57
|
+
// Full ns precision (CodeRabbit PR #2684 r2): truncating to milliseconds
|
|
58
|
+
// would miss an in-place same-millisecond rewrite whose size is unchanged.
|
|
59
|
+
mtimeNs: bigStat.mtimeNs,
|
|
60
|
+
ctimeNs: bigStat.ctimeNs,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function sameIdentity(a, b) {
|
|
64
|
+
return a.dev === b.dev && a.ino === b.ino && a.size === b.size
|
|
65
|
+
&& a.mtimeNs === b.mtimeNs && a.ctimeNs === b.ctimeNs;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Reset the intent doc cache for test isolation (same semantics as the
|
|
69
|
+
* plugin reader's resetIntentDocCacheForTest).
|
|
70
|
+
*/
|
|
71
|
+
export function resetHostIntentDocCacheForTest(workspaceDir, lang) {
|
|
72
|
+
if (workspaceDir === undefined) {
|
|
73
|
+
_intentDocCache.clear();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (lang !== undefined) {
|
|
77
|
+
_intentDocCache.delete(`${workspaceDir}:${lang}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const prefix = `${workspaceDir}:`;
|
|
81
|
+
for (const key of _intentDocCache.keys()) {
|
|
82
|
+
if (key.startsWith(prefix))
|
|
83
|
+
_intentDocCache.delete(key);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ── Language resolution ───────────────────────────────────────────────────────
|
|
87
|
+
/**
|
|
88
|
+
* Detect which language's INTENT file exists on disk (zh-CN first, then en,
|
|
89
|
+
* default zh-CN) — the same resolution the OpenClaw plugin adapter applies.
|
|
90
|
+
*
|
|
91
|
+
* Filesystem-touching by design: callers MUST only invoke it when the
|
|
92
|
+
* intent_engineering flag is already known to be on, so flag-off keeps the
|
|
93
|
+
* zero-file-access contract.
|
|
94
|
+
*/
|
|
95
|
+
export function resolveHostIntentLang(workspaceDir) {
|
|
96
|
+
const zhPath = path.join(workspaceDir, INTENT_DIR, getIntentFilename('zh-CN'));
|
|
97
|
+
if (fs.existsSync(zhPath))
|
|
98
|
+
return 'zh-CN';
|
|
99
|
+
const enPath = path.join(workspaceDir, INTENT_DIR, getIntentFilename('en'));
|
|
100
|
+
if (fs.existsSync(enPath))
|
|
101
|
+
return 'en';
|
|
102
|
+
return 'zh-CN';
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create an IntentDocReader bound to a specific workspace.
|
|
106
|
+
*
|
|
107
|
+
* The returned reader is a closure over (workspaceDir, effectiveConfig, lang)
|
|
108
|
+
* — each `readIntentDoc()` call re-evaluates the Core flag predicate against
|
|
109
|
+
* the captured config, then reads through the TTL+mtime cache.
|
|
110
|
+
*/
|
|
111
|
+
export function createHostIntentDocReader(options) {
|
|
112
|
+
const { workspaceDir, effectiveConfig, logger } = options;
|
|
113
|
+
const { lang: boundLang } = options;
|
|
114
|
+
return {
|
|
115
|
+
readIntentDoc() {
|
|
116
|
+
// SPEC §12 / §13.1 — flag check FIRST, from the entry-provided config.
|
|
117
|
+
// Flag off → no filesystem access, no cache access.
|
|
118
|
+
if (!isIntentAnchoringEnabled(effectiveConfig)) {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
found: false,
|
|
122
|
+
flagEnabled: false,
|
|
123
|
+
reason: 'flag_disabled',
|
|
124
|
+
nextAction: 'Enable the intent_engineering feature flag in .pd/config.yaml to read the INTENT document.',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Language is resolved lazily (AFTER the flag gate) so a flag-off read
|
|
128
|
+
// performs zero filesystem probes.
|
|
129
|
+
const lang = boundLang ?? resolveHostIntentLang(workspaceDir);
|
|
130
|
+
const cacheKey = `${workspaceDir}:${lang}`;
|
|
131
|
+
const filePath = path.resolve(workspaceDir, INTENT_DIR, getIntentFilename(lang));
|
|
132
|
+
const now = Date.now();
|
|
133
|
+
const cached = _intentDocCache.get(cacheKey);
|
|
134
|
+
if (cached && (now - cached.loadedAt) < INTENT_CACHE_TTL_MS) {
|
|
135
|
+
try {
|
|
136
|
+
// PR #2684 P1: cache-hit validation checks FILE IDENTITY, not just
|
|
137
|
+
// mtime — a same-length rewrite or an atomic replace that kept the
|
|
138
|
+
// size would otherwise pass an mtime-only check on filesystems with
|
|
139
|
+
// coarse timestamps. dev+ino+size+mtimeMs(+ctimeMs) must all match.
|
|
140
|
+
const stat = fs.statSync(filePath, { bigint: true });
|
|
141
|
+
if (sameIdentity(identityOf(stat), cached.identity)) {
|
|
142
|
+
return { ok: true, found: true, flagEnabled: true, doc: cached.reference };
|
|
143
|
+
}
|
|
144
|
+
// Identity mismatch → fall through to the fresh-read path.
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// File deleted since caching — fall through to the fresh-read path
|
|
148
|
+
// (which will report not_found). Never serve a doc for a gone file.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// PR #2684 P1: bounded re-read loop. A writer that rewrites/atomically
|
|
152
|
+
// replaces the file WHILE we read it can invalidate every consistency
|
|
153
|
+
// check of that attempt; we retry a bounded number of times and, if the
|
|
154
|
+
// file never stabilizes, degrade to the structured read_error result
|
|
155
|
+
// instead of caching torn content (rc-3 / rc-9).
|
|
156
|
+
for (let attempt = 0; attempt <= INTENT_STABILITY_RETRIES; attempt += 1) {
|
|
157
|
+
try {
|
|
158
|
+
// Open once and let ENOENT be the not-found signal — a path-based
|
|
159
|
+
// existsSync before the open is a check/use race.
|
|
160
|
+
let fd;
|
|
161
|
+
try {
|
|
162
|
+
fd = fs.openSync(filePath, 'r');
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
if (!isEnoent(err))
|
|
166
|
+
throw err;
|
|
167
|
+
_intentDocCache.delete(cacheKey);
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
found: false,
|
|
171
|
+
flagEnabled: true,
|
|
172
|
+
reason: 'not_found',
|
|
173
|
+
nextAction: `Create .principles/${getIntentFilename(lang)} using "pd intent init".`,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const openStat = fs.fstatSync(fd, { bigint: true });
|
|
178
|
+
if (openStat.size > BigInt(INTENT_MAX_BYTES)) {
|
|
179
|
+
_intentDocCache.delete(cacheKey);
|
|
180
|
+
return {
|
|
181
|
+
ok: false,
|
|
182
|
+
found: true,
|
|
183
|
+
flagEnabled: true,
|
|
184
|
+
reason: 'oversized',
|
|
185
|
+
nextAction: `${getIntentFilename(lang)} exceeds ${INTENT_MAX_BYTES} bytes (${openStat.size} bytes). Reduce content.`,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// Read at most INTENT_MAX_BYTES + 1 bytes on the SAME descriptor:
|
|
189
|
+
// the fixed buffer prevents concurrent growth from turning the size
|
|
190
|
+
// check into an unbounded allocation.
|
|
191
|
+
const buffer = Buffer.allocUnsafe(INTENT_MAX_BYTES + 1);
|
|
192
|
+
const bytesRead = fs.readSync(fd, buffer, 0, buffer.byteLength, 0);
|
|
193
|
+
const finalStat = fs.fstatSync(fd, { bigint: true });
|
|
194
|
+
if (bytesRead > INTENT_MAX_BYTES || finalStat.size > BigInt(INTENT_MAX_BYTES)) {
|
|
195
|
+
_intentDocCache.delete(cacheKey);
|
|
196
|
+
return {
|
|
197
|
+
ok: false,
|
|
198
|
+
found: true,
|
|
199
|
+
flagEnabled: true,
|
|
200
|
+
reason: 'oversized',
|
|
201
|
+
nextAction: `${getIntentFilename(lang)} exceeds ${INTENT_MAX_BYTES} bytes (${Math.max(Number(openStat.size), Number(finalStat.size), bytesRead)} bytes observed). Reduce content.`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
const raw = buffer.toString('utf8', 0, bytesRead);
|
|
205
|
+
// PR #2684 P1 (Owner directive): the bytes may be TORN even when
|
|
206
|
+
// the size matches — a writer that rewrites the file in place to
|
|
207
|
+
// NEW content of the SAME length, or atomically replaces the path
|
|
208
|
+
// mid-read, leaves `raw` describing a file that no longer exists.
|
|
209
|
+
// Stability requires ALL of:
|
|
210
|
+
// a) full metadata equality (dev/ino/size/mtime/ctime) between
|
|
211
|
+
// the pre-read and post-read fstat of the SAME descriptor —
|
|
212
|
+
// a same-length rewrite bumps mtime, an atomic replace makes
|
|
213
|
+
// the fd point at an unlinked inode whose link count dropped;
|
|
214
|
+
// b) the PATH still resolves to the SAME dev/ino the fd holds —
|
|
215
|
+
// an atomic replace leaves the fd on the old inode while the
|
|
216
|
+
// path now names the new one;
|
|
217
|
+
// c) bytesRead equals the file size (complete, not torn read).
|
|
218
|
+
// Any failure → serve the bytes read but do NOT cache, and retry
|
|
219
|
+
// within the bounded budget; exhausted → structured read_error.
|
|
220
|
+
const postPathStat = fs.statSync(filePath, { bigint: true });
|
|
221
|
+
const stable = sameIdentity(identityOf(openStat), identityOf(finalStat))
|
|
222
|
+
&& finalStat.dev === postPathStat.dev
|
|
223
|
+
&& finalStat.ino === postPathStat.ino
|
|
224
|
+
&& BigInt(bytesRead) === finalStat.size;
|
|
225
|
+
const reference = {
|
|
226
|
+
raw,
|
|
227
|
+
contentHash: computeIntentContentHash(raw),
|
|
228
|
+
path: filePath,
|
|
229
|
+
};
|
|
230
|
+
if (!stable) {
|
|
231
|
+
if (attempt < INTENT_STABILITY_RETRIES) {
|
|
232
|
+
continue; // bounded re-read — try again from a fresh open
|
|
233
|
+
}
|
|
234
|
+
// Budget exhausted: never cache torn content, and do not present
|
|
235
|
+
// possibly-mixed bytes as a successful read (rc-3).
|
|
236
|
+
_intentDocCache.delete(cacheKey);
|
|
237
|
+
logger?.warn?.(`[host-runtime:intent] read unstable after ${attempt + 1} attempts: workspace=${workspaceDir}, lang=${lang}`);
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
found: true,
|
|
241
|
+
flagEnabled: true,
|
|
242
|
+
reason: 'read_error',
|
|
243
|
+
nextAction: `${getIntentFilename(lang)} kept changing while being read (concurrent writer). Retry; if this recurs, stop the writer process first.`,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
_intentDocCache.set(cacheKey, {
|
|
247
|
+
reference,
|
|
248
|
+
identity: identityOf(finalStat),
|
|
249
|
+
loadedAt: now,
|
|
250
|
+
});
|
|
251
|
+
return { ok: true, found: true, flagEnabled: true, doc: reference };
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
fs.closeSync(fd);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
// PR #2684 P1: a stability retry that hits a transient fs error
|
|
259
|
+
// (e.g. the path vanished mid-retry because of an atomic replace)
|
|
260
|
+
// is retried within the same budget; ENOENT on the FIRST open is
|
|
261
|
+
// handled above, so reaching here mid-loop means the file was
|
|
262
|
+
// removed while we were re-reading — treat as unstable and retry;
|
|
263
|
+
// if the budget is exhausted, degrade below exactly like any other
|
|
264
|
+
// real read failure (never throw — ERR-002).
|
|
265
|
+
if (attempt < INTENT_STABILITY_RETRIES && isEnoent(err)) {
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
_intentDocCache.delete(cacheKey);
|
|
269
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
270
|
+
logger?.warn?.(`[host-runtime:intent] read failed: workspace=${workspaceDir}, lang=${lang}, error=${message}`);
|
|
271
|
+
return {
|
|
272
|
+
ok: false,
|
|
273
|
+
found: false,
|
|
274
|
+
flagEnabled: true,
|
|
275
|
+
reason: 'read_error',
|
|
276
|
+
nextAction: `Check filesystem permissions for .principles/${getIntentFilename(lang)}.`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Unreachable: every loop iteration either returns or continues, and the
|
|
281
|
+
// stability-exhausted branch returns inside the loop. Kept so the
|
|
282
|
+
// compiler sees a terminating return for IntentDocReadResult.
|
|
283
|
+
return {
|
|
284
|
+
ok: false,
|
|
285
|
+
found: true,
|
|
286
|
+
flagEnabled: true,
|
|
287
|
+
reason: 'read_error',
|
|
288
|
+
nextAction: `${getIntentFilename(lang)} kept changing while being read (concurrent writer). Retry.`,
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
@@ -196,10 +196,33 @@ export declare function getPdCliEntry(paths: InstallLayoutPaths, mode: InstallLa
|
|
|
196
196
|
* must not re-derive it locally.
|
|
197
197
|
*/
|
|
198
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';
|
|
199
|
+
/**
|
|
200
|
+
* Codex host-persistent binding location. The versioned payload directory is
|
|
201
|
+
* REPLACED by a host cache refresh, taking any binding written inside it with
|
|
202
|
+
* it (PRI-1248). PLUGIN_DATA survives; this resolves the same
|
|
203
|
+
* `principles-disciple-<marketplace>` data root the installer uses.
|
|
204
|
+
*/
|
|
205
|
+
export declare function resolveCodexPluginDataRoot(codexHome: string, marketplace: string): string | undefined;
|
|
206
|
+
/** Marketplace segment of `<codexHome>/plugins/cache/<marketplace>/principles-disciple/<version>`. */
|
|
207
|
+
export declare function getCodexMarketplaceFromPayload(pluginRoot: string): string;
|
|
208
|
+
export interface CodexMcpBindingLocations {
|
|
209
|
+
readonly persistent: string | null;
|
|
210
|
+
readonly legacy: string;
|
|
211
|
+
}
|
|
212
|
+
export declare function getCodexMcpBindingLocations(codexHome: string, pluginRoot: string): CodexMcpBindingLocations;
|
|
213
|
+
/**
|
|
214
|
+
* Pick the binding authority exactly as launcher.cjs does: the host-persistent
|
|
215
|
+
* copy when present, otherwise the legacy payload-local copy. `undefined` means
|
|
216
|
+
* neither exists.
|
|
217
|
+
*/
|
|
218
|
+
export declare function selectCodexMcpBindingPath(codexHome: string, pluginRoot: string): {
|
|
219
|
+
readonly path: string;
|
|
220
|
+
readonly persistent: boolean;
|
|
221
|
+
} | undefined;
|
|
199
222
|
/**
|
|
200
223
|
* MCP binding contract (schema `pd.mcp-binding.v1`). This is the single
|
|
201
224
|
* declaration of a valid binding; the launcher's payload copies are verified
|
|
202
225
|
* against it by the parity test, and the installer / `pd health` import it
|
|
203
226
|
* directly so neither can drift into a more permissive check.
|
|
204
227
|
*/
|
|
205
|
-
export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, type McpBindingHost, type McpBindingRecord, type McpBindingVerdict, type McpBindingShapeCode, type McpBindingFixture, type McpBindingFixtureId, type McpBindingFixtureContext, } from './mcp-binding-contract.js';
|
|
228
|
+
export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, getHostDefaultWorkspaceDirs, findForeignWorkspaceHost, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, type McpBindingHost, type McpHostWorkspaceOptions, type McpBindingRecord, type McpBindingVerdict, type McpBindingShapeCode, type McpBindingFixture, type McpBindingFixtureId, type McpBindingFixtureContext, } from './mcp-binding-contract.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
1
2
|
import * as path from 'node:path';
|
|
2
3
|
export const INSTALL_LAYOUT_VERSION = 1;
|
|
3
4
|
export const INSTALL_LAYOUT_MODES = ['canonical', 'legacy'];
|
|
@@ -295,10 +296,66 @@ export function getPdCliEntry(paths, mode) {
|
|
|
295
296
|
* must not re-derive it locally.
|
|
296
297
|
*/
|
|
297
298
|
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';
|
|
299
|
+
/**
|
|
300
|
+
* Codex host-persistent binding location. The versioned payload directory is
|
|
301
|
+
* REPLACED by a host cache refresh, taking any binding written inside it with
|
|
302
|
+
* it (PRI-1248). PLUGIN_DATA survives; this resolves the same
|
|
303
|
+
* `principles-disciple-<marketplace>` data root the installer uses.
|
|
304
|
+
*/
|
|
305
|
+
export function resolveCodexPluginDataRoot(codexHome, marketplace) {
|
|
306
|
+
const dataRoot = path.join(codexHome, 'plugins', 'data');
|
|
307
|
+
try {
|
|
308
|
+
// The installer treats a single existing data directory as authoritative;
|
|
309
|
+
// the launcher/health reader must resolve the SAME directory.
|
|
310
|
+
const matches = fs.readdirSync(dataRoot).filter((name) => name.startsWith('principles-disciple-'));
|
|
311
|
+
if (matches.length === 1)
|
|
312
|
+
return path.join(dataRoot, matches[0]);
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// The data root is created by the first setup; fall through to the
|
|
316
|
+
// canonical name derived from the payload's marketplace.
|
|
317
|
+
}
|
|
318
|
+
return /^[A-Za-z0-9._-]+$/.test(marketplace)
|
|
319
|
+
? path.join(dataRoot, `principles-disciple-${marketplace}`)
|
|
320
|
+
: undefined;
|
|
321
|
+
}
|
|
322
|
+
/** Marketplace segment of `<codexHome>/plugins/cache/<marketplace>/principles-disciple/<version>`. */
|
|
323
|
+
export function getCodexMarketplaceFromPayload(pluginRoot) {
|
|
324
|
+
return path.basename(path.dirname(path.dirname(pluginRoot)));
|
|
325
|
+
}
|
|
326
|
+
export function getCodexMcpBindingLocations(codexHome, pluginRoot) {
|
|
327
|
+
const pluginData = resolveCodexPluginDataRoot(codexHome, getCodexMarketplaceFromPayload(pluginRoot));
|
|
328
|
+
return {
|
|
329
|
+
persistent: pluginData === undefined ? null : path.join(pluginData, 'mcp-binding.json'),
|
|
330
|
+
legacy: path.join(pluginRoot, 'mcp-binding.json'),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function isBindingFile(file) {
|
|
334
|
+
try {
|
|
335
|
+
return fs.statSync(file).isFile();
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Pick the binding authority exactly as launcher.cjs does: the host-persistent
|
|
343
|
+
* copy when present, otherwise the legacy payload-local copy. `undefined` means
|
|
344
|
+
* neither exists.
|
|
345
|
+
*/
|
|
346
|
+
export function selectCodexMcpBindingPath(codexHome, pluginRoot) {
|
|
347
|
+
const locations = getCodexMcpBindingLocations(codexHome, pluginRoot);
|
|
348
|
+
if (locations.persistent !== null && isBindingFile(locations.persistent)) {
|
|
349
|
+
return { path: locations.persistent, persistent: true };
|
|
350
|
+
}
|
|
351
|
+
if (isBindingFile(locations.legacy))
|
|
352
|
+
return { path: locations.legacy, persistent: false };
|
|
353
|
+
return undefined;
|
|
354
|
+
}
|
|
298
355
|
/**
|
|
299
356
|
* MCP binding contract (schema `pd.mcp-binding.v1`). This is the single
|
|
300
357
|
* declaration of a valid binding; the launcher's payload copies are verified
|
|
301
358
|
* against it by the parity test, and the installer / `pd health` import it
|
|
302
359
|
* directly so neither can drift into a more permissive check.
|
|
303
360
|
*/
|
|
304
|
-
export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, } from './mcp-binding-contract.js';
|
|
361
|
+
export { MCP_BINDING_SCHEMA_VERSION, MCP_BINDING_HOSTS, MCP_BINDING_SERVER_ENTRY_SEGMENTS, MCP_BINDING_SHAPE_CODES, MCP_BINDING_LAUNCHER_ONLY_REASONS, MCP_BINDING_FIXTURES, getCanonicalMcpServerEntry, getHostDefaultWorkspaceDirs, findForeignWorkspaceHost, isSameMcpBindingPath, validateMcpBinding, buildMcpBindingFixture, isMcpBindingHost, isSupportedBindingSchemaVersion, isSemverVersion, } from './mcp-binding-contract.js';
|
|
@@ -40,6 +40,33 @@ export declare function isSemverVersion(value: unknown): value is string;
|
|
|
40
40
|
* value) instead of read here so the win32 branch is exercised on Linux CI.
|
|
41
41
|
*/
|
|
42
42
|
export declare function isSameMcpBindingPath(left: string, right: string, platform: string): boolean;
|
|
43
|
+
export interface McpHostWorkspaceOptions {
|
|
44
|
+
/** The OS home directory (`os.homedir()` in production). */
|
|
45
|
+
readonly homeDir: string;
|
|
46
|
+
/** Codex home override (`CODEX_HOME`); defaults to `<homeDir>/.codex`. */
|
|
47
|
+
readonly codexHome?: string;
|
|
48
|
+
/** Node's `process.platform` value, injected so the win32 rule is testable. */
|
|
49
|
+
readonly platform: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The directories each PD host OWNS as its default governance workspace.
|
|
53
|
+
*
|
|
54
|
+
* PRI-1247: the installer used to run the OpenClaw-oriented workspace detector
|
|
55
|
+
* for every host, so a Codex install could bind `~/clawd` or
|
|
56
|
+
* `~/.openclaw/workspace` and write Codex pain evidence into OpenClaw's
|
|
57
|
+
* database. A binding that points at another host's owned workspace is a
|
|
58
|
+
* cross-host misbinding, not a valid custom workspace.
|
|
59
|
+
*/
|
|
60
|
+
export declare function getHostDefaultWorkspaceDirs(host: McpBindingHost, options: McpHostWorkspaceOptions): readonly string[];
|
|
61
|
+
/**
|
|
62
|
+
* Return the OTHER host whose owned workspace tree contains `workspaceDir`,
|
|
63
|
+
* or null when the path is not another host's default workspace.
|
|
64
|
+
*
|
|
65
|
+
* Kept filesystem-free on purpose: callers decide whether to refuse at write
|
|
66
|
+
* time (pd-setup), at launch (launcher.cjs mirrors this rule), at install
|
|
67
|
+
* health time (Codex installer) or in `pd health`.
|
|
68
|
+
*/
|
|
69
|
+
export declare function findForeignWorkspaceHost(host: McpBindingHost, workspaceDir: string, options: McpHostWorkspaceOptions): McpBindingHost | null;
|
|
43
70
|
/**
|
|
44
71
|
* Validate the binding SHAPE (and the canonical-entry rule) exactly as the
|
|
45
72
|
* launcher does. Filesystem facts — file present/readable, runtime dir and
|
|
@@ -58,6 +58,67 @@ export function isSameMcpBindingPath(left, right, platform) {
|
|
|
58
58
|
const b = path.resolve(right);
|
|
59
59
|
return platform === 'win32' ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The directories each PD host OWNS as its default governance workspace.
|
|
63
|
+
*
|
|
64
|
+
* PRI-1247: the installer used to run the OpenClaw-oriented workspace detector
|
|
65
|
+
* for every host, so a Codex install could bind `~/clawd` or
|
|
66
|
+
* `~/.openclaw/workspace` and write Codex pain evidence into OpenClaw's
|
|
67
|
+
* database. A binding that points at another host's owned workspace is a
|
|
68
|
+
* cross-host misbinding, not a valid custom workspace.
|
|
69
|
+
*/
|
|
70
|
+
export function getHostDefaultWorkspaceDirs(host, options) {
|
|
71
|
+
const home = path.resolve(options.homeDir);
|
|
72
|
+
const codexHome = options.codexHome !== undefined
|
|
73
|
+
? path.resolve(options.codexHome)
|
|
74
|
+
: path.join(home, '.codex');
|
|
75
|
+
switch (host) {
|
|
76
|
+
case 'openclaw':
|
|
77
|
+
return [path.join(home, 'clawd'), path.join(home, '.openclaw', 'workspace')];
|
|
78
|
+
case 'codex':
|
|
79
|
+
return [path.join(codexHome, 'pd-workspace')];
|
|
80
|
+
case 'workbuddy':
|
|
81
|
+
return [path.join(home, '.workbuddy', 'pd-workspace')];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function isSameOrInside(parent, child, platform) {
|
|
85
|
+
// Normalize BOTH sides with the injected platform rule: on Linux CI the real
|
|
86
|
+
// `path` is posix, so lowercasing here is what makes the win32 branch testable.
|
|
87
|
+
const normalize = (value) => {
|
|
88
|
+
const resolved = path.resolve(value);
|
|
89
|
+
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
90
|
+
};
|
|
91
|
+
const base = normalize(parent);
|
|
92
|
+
const target = normalize(child);
|
|
93
|
+
if (base === target)
|
|
94
|
+
return true;
|
|
95
|
+
const relative = path.relative(base, target);
|
|
96
|
+
return relative !== ''
|
|
97
|
+
&& !path.isAbsolute(relative)
|
|
98
|
+
&& relative !== '..'
|
|
99
|
+
&& !relative.startsWith('..' + path.sep);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Return the OTHER host whose owned workspace tree contains `workspaceDir`,
|
|
103
|
+
* or null when the path is not another host's default workspace.
|
|
104
|
+
*
|
|
105
|
+
* Kept filesystem-free on purpose: callers decide whether to refuse at write
|
|
106
|
+
* time (pd-setup), at launch (launcher.cjs mirrors this rule), at install
|
|
107
|
+
* health time (Codex installer) or in `pd health`.
|
|
108
|
+
*/
|
|
109
|
+
export function findForeignWorkspaceHost(host, workspaceDir, options) {
|
|
110
|
+
if (workspaceDir.trim().length === 0)
|
|
111
|
+
return null;
|
|
112
|
+
for (const other of MCP_BINDING_HOSTS) {
|
|
113
|
+
if (other === host)
|
|
114
|
+
continue;
|
|
115
|
+
for (const owned of getHostDefaultWorkspaceDirs(other, options)) {
|
|
116
|
+
if (isSameOrInside(owned, workspaceDir, options.platform))
|
|
117
|
+
return other;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
61
122
|
function reject(code, reason, nextAction) {
|
|
62
123
|
return { ok: false, code, reason, nextAction };
|
|
63
124
|
}
|
|
@@ -152,6 +213,7 @@ export const MCP_BINDING_LAUNCHER_ONLY_REASONS = [
|
|
|
152
213
|
{ code: 'runtime_pin_mismatch', why: 'The installed runtime must match the payload pin.' },
|
|
153
214
|
{ code: 'binding_workspace_missing', why: 'The bound workspace must exist on this machine.' },
|
|
154
215
|
{ code: 'binding_workspace_not_directory', why: 'The bound workspace must be a directory.' },
|
|
216
|
+
{ code: 'binding_workspace_foreign_host', why: 'A host must not bind another PD host\'s owned default workspace (PRI-1247 cross-host misbinding).' },
|
|
155
217
|
{ code: 'binding_workspace_not_declared', why: 'OpenClaw requires an explicit workspace declaration matching the binding.' },
|
|
156
218
|
{ code: 'workspace_declaration_missing', why: 'OpenClaw declaration sources produced no workspace (dynamic reason from the declaration resolver).' },
|
|
157
219
|
{ code: 'workspace_declaration_invalid', why: 'OpenClaw declaration sources produced a value that is not a usable absolute workspace directory (dynamic reason from the declaration resolver).' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-principles-disciple",
|
|
3
|
-
"version": "1.153.
|
|
3
|
+
"version": "1.153.4",
|
|
4
4
|
"description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@earendil-works/pi-agent-core": "1.2.0",
|
|
66
66
|
"@earendil-works/pi-ai": "1.4.0",
|
|
67
|
-
"@principles/install-layout": "^0.8.
|
|
67
|
+
"@principles/install-layout": "^0.8.3",
|
|
68
68
|
"@sinclair/typebox": "^0.34.52",
|
|
69
69
|
"@tufjs/models": "3.0.1",
|
|
70
70
|
"@inquirer/prompts": "^8.7.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"pd": {
|
|
103
103
|
"bundledPluginVersion": "2.2.13"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "adbcfd33f4765fffee9de71055826edb8ed128a6"
|
|
106
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/commands/diagnose.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/commands/diagnose.ts"],"names":[],"mappings":"AAuEA,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;IACjF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,uBAAuB,CAiDtG;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmErF;AAkCD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAy0B/E"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* pd diagnose run --task-id <taskId> --workspace <path>
|
|
7
7
|
*/
|
|
8
8
|
import { RuntimeStateManager, SqliteHistoryQuery, SqliteContextAssembler, SqliteDiagnosticianCommitter, SqliteTrajectoryLocator, SqliteSourceTraceLocator, SplitDiagnosticianRunner, DiagRootCauseRunner, DiagDistillerRunner, DiagRouterRunner, DefaultDiagRootCauseValidator, DefaultDiagDistillerValidator, TestDoubleRuntimeAdapter, PDRuntimeError, isRuntimeConfigError, CandidateIntakeService, run as diagnoseRun, status as diagnoseStatus, PrincipleTreeLedgerAdapter, buildDreamerSeedFromCandidate, findExistingDreamerTask, CANDIDATE_KIND_TO_ROUTE, ROUTE_CHANNEL_MAP, MVP_ENABLED_CHANNELS, persistPainDiagnosis, createBridgeTelemetryEventEmitter, createReuseRecommendationHook, computeFeatureFlagsFromConfig, isFeatureEnabled, evaluateDreamerSeedSuppression, pendingOwnerDecision, } from '@principles/core/runtime';
|
|
9
|
+
import { createHostIntentDocReader } from '@principles/host-runtime';
|
|
9
10
|
import { resolveWorkspaceDir } from '../resolve-workspace.js';
|
|
10
11
|
import { createWorkspaceTelemetryEmitter } from '../services/workspace-telemetry.js';
|
|
11
12
|
import { readOutputLanguageFromWorkspace } from '../config-reader.js';
|
|
@@ -439,7 +440,12 @@ export async function handleDiagnoseRun(opts) {
|
|
|
439
440
|
// One adapter instance serves both the router exposure and the intake path
|
|
440
441
|
// below (same ledger authority).
|
|
441
442
|
const ledgerAdapter = new PrincipleTreeLedgerAdapter({ stateDir: path.join(workspaceDir, '.state') });
|
|
442
|
-
const rootCauseRunner = new DiagRootCauseRunner(
|
|
443
|
+
const rootCauseRunner = new DiagRootCauseRunner(
|
|
444
|
+
// PRI-1231 / SPEC §9.2: Stage A reads INTENT.md through the neutral
|
|
445
|
+
// host reader (same Core semantics as every entry point). A task with
|
|
446
|
+
// a persisted snapshot keeps using it — the runner never re-reads
|
|
447
|
+
// INTENT.md for an already-captured task (SPEC §6.6).
|
|
448
|
+
{ stateManager, runtimeAdapter, eventEmitter, artifactStore: stateManager.piArtifactStore, validator: new DefaultDiagRootCauseValidator(), contextAssembler, intentDocReader: createHostIntentDocReader({ workspaceDir, effectiveConfig }) }, { owner: 'pd-cli-diagnose', runtimeKind: resolvedKind, outputLanguage, timeoutMs: perStageTimeoutMs, effectiveConfig });
|
|
443
449
|
const distillerRunner = new DiagDistillerRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore: stateManager.piArtifactStore, validator: new DefaultDiagDistillerValidator() }, { owner: 'pd-cli-diagnose', runtimeKind: resolvedKind, outputLanguage, timeoutMs: perStageTimeoutMs, effectiveConfig });
|
|
444
450
|
const routerRunner = new DiagRouterRunner({ stateManager, runtimeAdapter, eventEmitter, artifactStore: stateManager.piArtifactStore, committer, trustedPrincipleSource: ledgerAdapter }, { owner: 'pd-cli-diagnose', runtimeKind: resolvedKind, outputLanguage, timeoutMs: perStageTimeoutMs, effectiveConfig });
|
|
445
451
|
const runner = new SplitDiagnosticianRunner({
|