@sanqianx/project-knowledge 5.0.29 → 5.0.31
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/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +21 -0
- package/_site/_test/appearance-settings-test.js +148 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
- package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
- package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
- package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
- package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
- package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
- package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
- package/_site/_test/helpers/qa-r45-harness.js +94 -0
- package/_site/_test/helpers/qa-r48-env.js +64 -0
- package/_site/_test/helpers/qa-r51-env.cjs +77 -0
- package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
- package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
- package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
- package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
- package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
- package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
- package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
- package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
- package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
- package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
- package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
- package/_site/_test/parallel-memory-injection-probe.js +411 -0
- package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
- package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
- package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
- package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
- package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
- package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
- package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
- package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
- package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
- package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
- package/_site/_test/t07d-git-rel-coverage-test.js +224 -0
- package/_site/_test/t07e-qta-coverage-test.js +195 -0
- package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
- package/_site/lib/server-app.js +11 -2
- package/_site/lib/settings-store.js +43 -1
- package/module-runtime-manifest.json +16 -16
- package/package.json +2 -2
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/ui/index.html +18 -1
- package/ui/product.css +6 -2
- package/ui/product.js +86 -1
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// _site/_test/parallel-memory-capture-r4-cap006-probe.js
|
|
3
|
+
//
|
|
4
|
+
// CAP-006 R4 — Codex CODEX_HOME isolation retest (R4 contract item 3).
|
|
5
|
+
//
|
|
6
|
+
// R3 declared the Codex notify sub-item BLOCKED because the codex CLI "resolves
|
|
7
|
+
// the developer's real profile directory regardless of HOME/USERPROFILE". That
|
|
8
|
+
// experiment never set CODEX_HOME — and the product's own codexHookProbe
|
|
9
|
+
// (_site/lib/integration-installer.js) explicitly passes
|
|
10
|
+
// CODEX_HOME: this.env.CODEX_HOME || dirname(codexConfigFile), so the claimed
|
|
11
|
+
// un-isolatability was never the environment the product actually gives the
|
|
12
|
+
// CLI. This case settles it with real evidence, both directions:
|
|
13
|
+
//
|
|
14
|
+
// 1. FIRST a read-only CLI gate, before any UI step: with EXPLICIT
|
|
15
|
+
// CODEX_HOME plus independent APPDATA/LOCALAPPDATA/USERPROFILE/HOME on an
|
|
16
|
+
// external temp home, `codex plugin list --json` and
|
|
17
|
+
// `codex plugin marketplace list` must answer with every config/plugin
|
|
18
|
+
// path inside the isolated root and zero writes to the real home.
|
|
19
|
+
// One bounded attempt per command — if the CLI cannot answer, the gate
|
|
20
|
+
// fails with that single meaningful error, no blind retries.
|
|
21
|
+
// 2. THEN the real UI, three consecutive real 接入 clicks for the codex row:
|
|
22
|
+
// the first install writes the notify wrapper; the product's own settled
|
|
23
|
+
// status scan then proves clean-chain idempotence over it (its
|
|
24
|
+
// statusCaptureCodex computes planNotify and only reports installed when
|
|
25
|
+
// changed === false); a doubled owned chain wrapping a compatible DevTask
|
|
26
|
+
// Radar third-party entry is repaired by the second click (collapse to
|
|
27
|
+
// one anchor, third party preserved); a plain doubled anchor without any
|
|
28
|
+
// third party is repaired by the third click (repeatable collapse,
|
|
29
|
+
// nothing resurrected). One backup per real change, every write inside
|
|
30
|
+
// the isolated CODEX_HOME.
|
|
31
|
+
//
|
|
32
|
+
// Both corruptions are direct edits of the ISOLATED config.toml — declared
|
|
33
|
+
// artificial damage (an older stacking install's shape), never product
|
|
34
|
+
// output. No Codex session is ever started: the probe exercises the
|
|
35
|
+
// plugin/config surface only, so no model and no quota is consumed. If the
|
|
36
|
+
// product ignores the explicit isolation the probe FAILS with the escaping
|
|
37
|
+
// paths as the source-defect evidence; there is no must-be-BLOCKED assertion —
|
|
38
|
+
// real evidence decides.
|
|
39
|
+
|
|
40
|
+
const fs = require('node:fs');
|
|
41
|
+
const os = require('node:os');
|
|
42
|
+
const path = require('node:path');
|
|
43
|
+
const crypto = require('node:crypto');
|
|
44
|
+
const assert = require('node:assert/strict');
|
|
45
|
+
const { execFileSync, spawnSync } = require('node:child_process');
|
|
46
|
+
|
|
47
|
+
const r3cap = require('./helpers/parallel-memory-capture-r3-cap-shell');
|
|
48
|
+
const { startCapHarness, ROOT, realHomeDir } = require('./helpers/parallel-capture-safety-r5-cap-shell');
|
|
49
|
+
|
|
50
|
+
const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_TEST_EVIDENCE_DIR) : null;
|
|
51
|
+
const CLIENT = 'codex';
|
|
52
|
+
const MARKER = 'CAP006R4-ISOLATION-PROBE';
|
|
53
|
+
// P-CAPTURE-SAFETY-R5 copy: identical to the frozen R4 probe except that every
|
|
54
|
+
// read-only real-home digest and the live-state marker check resolve the real
|
|
55
|
+
// home explicitly (realHomeDir(), supplied by the R5 wrapper BEFORE isolation)
|
|
56
|
+
// instead of os.homedir(), which under the isolated environment would read the
|
|
57
|
+
// isolated home — a fake-HOME proof. No expected, fixture or assertion changed.
|
|
58
|
+
const RADAR = ['node', 'C:/DevTask Radar/connectors/codex/notify-hook.js'];
|
|
59
|
+
const FANOUT = path.join(ROOT, '_site', 'scripts', 'codex-notify-fanout.cjs');
|
|
60
|
+
// The live Codex desktop rewrites its electron state at arbitrary moments; the
|
|
61
|
+
// R4 cap008e probe proved these writes external. They stay carved out here and
|
|
62
|
+
// must stay marker-free.
|
|
63
|
+
const LIVE_CODEX_STATE = /^\.codex\/\.codex-global-state\.json(\.bak)?$/;
|
|
64
|
+
|
|
65
|
+
function gitHead() {
|
|
66
|
+
try {
|
|
67
|
+
return execFileSync('git', ['-C', ROOT, 'rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim();
|
|
68
|
+
} catch { return null; }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const encode = args => Buffer.from(JSON.stringify(args)).toString('base64');
|
|
72
|
+
const decode = value => {
|
|
73
|
+
try { return JSON.parse(Buffer.from(value, 'base64').toString('utf8')); } catch { return null; }
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** The root-level notify line of a codex config.toml, product-format. */
|
|
77
|
+
function readNotifyLine(configFile) {
|
|
78
|
+
const source = fs.existsSync(configFile) ? fs.readFileSync(configFile, 'utf8') : '';
|
|
79
|
+
const lines = source.split(/\r?\n/);
|
|
80
|
+
const table = lines.findIndex(line => /^\s*\[/.test(line));
|
|
81
|
+
const index = lines.findIndex((line, i) => /^\s*notify\s*=/.test(line) && (table < 0 || i < table));
|
|
82
|
+
if (index < 0) return { source, lines, eol: source.includes('\r\n') ? '\r\n' : '\n', index, args: null };
|
|
83
|
+
let args = null;
|
|
84
|
+
try { args = JSON.parse(lines[index].replace(/^\s*notify\s*=\s*/, '')); } catch { args = null; }
|
|
85
|
+
return { source, lines, eol: source.includes('\r\n') ? '\r\n' : '\n', index, args: Array.isArray(args) ? args : null };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const isOwnedFanout = args => Array.isArray(args)
|
|
89
|
+
&& /(?:^|[\\/])node(?:\.exe)?$/i.test(args[0] || '')
|
|
90
|
+
&& args[1] === FANOUT;
|
|
91
|
+
|
|
92
|
+
/** Walk the notify chain: owned fanouts collapse until a terminal command. */
|
|
93
|
+
function chainOf(args) {
|
|
94
|
+
const commands = [];
|
|
95
|
+
let fanoutCount = 0;
|
|
96
|
+
let bridge = null;
|
|
97
|
+
let current = args;
|
|
98
|
+
while (Array.isArray(current) && current.length) {
|
|
99
|
+
if (isOwnedFanout(current)) {
|
|
100
|
+
fanoutCount += 1;
|
|
101
|
+
const bridgeIndex = current.indexOf('--bridge-base64');
|
|
102
|
+
bridge = bridgeIndex >= 0 ? decode(current[bridgeIndex + 1]) : null;
|
|
103
|
+
commands.push({ kind: 'owned-fanout', bridge });
|
|
104
|
+
const nextIndex = current.indexOf('--next-base64');
|
|
105
|
+
current = nextIndex >= 0 ? decode(current[nextIndex + 1]) : null;
|
|
106
|
+
} else {
|
|
107
|
+
commands.push({ kind: 'terminal', command: current });
|
|
108
|
+
current = null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { commands, fanoutCount, bridge, terminal: commands.length && commands[commands.length - 1].kind === 'terminal' ? commands[commands.length - 1].command : null };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The read-only CLI gate. Exactly the environment the product's own server
|
|
116
|
+
* process (hence its codex children) will have. One bounded attempt per
|
|
117
|
+
* command; the classification is honest in all three directions.
|
|
118
|
+
*/
|
|
119
|
+
function codexReadGate({ homeDir, codexHome, appData, localAppData }) {
|
|
120
|
+
const env = { ...process.env };
|
|
121
|
+
for (const name of Object.keys(env)) if (name.startsWith('CODEX_')) delete env[name];
|
|
122
|
+
Object.assign(env, {
|
|
123
|
+
HOME: homeDir,
|
|
124
|
+
USERPROFILE: homeDir,
|
|
125
|
+
APPDATA: appData,
|
|
126
|
+
LOCALAPPDATA: localAppData,
|
|
127
|
+
CODEX_HOME: codexHome,
|
|
128
|
+
});
|
|
129
|
+
const inside = value => /^[A-Za-z]:[\\/]/.test(String(value)) && path.resolve(String(value)).toLowerCase().startsWith(path.resolve(homeDir).toLowerCase());
|
|
130
|
+
const collectPaths = value => {
|
|
131
|
+
const found = [];
|
|
132
|
+
const walk = item => {
|
|
133
|
+
if (!item) return;
|
|
134
|
+
if (typeof item === 'string') { if (/^[A-Za-z]:[\\/]/.test(item)) found.push(item); return; }
|
|
135
|
+
if (Array.isArray(item)) { item.forEach(walk); return; }
|
|
136
|
+
if (typeof item === 'object') Object.values(item).forEach(walk);
|
|
137
|
+
};
|
|
138
|
+
walk(value);
|
|
139
|
+
return [...new Set(found)];
|
|
140
|
+
};
|
|
141
|
+
const configBefore = r3cap.digestRealClientConfigs(realHomeDir());
|
|
142
|
+
const treesBefore = r3cap.digestRealClientTrees(realHomeDir());
|
|
143
|
+
const trials = [];
|
|
144
|
+
for (const [label, args] of [['plugin list', ['plugin', 'list', '--json']], ['marketplace list', ['plugin', 'marketplace', 'list']]]) {
|
|
145
|
+
const started = Date.now();
|
|
146
|
+
const result = spawnSync('codex', args, { encoding: 'utf8', windowsHide: true, timeout: 90000, env, cwd: os.tmpdir() });
|
|
147
|
+
let parsed = null;
|
|
148
|
+
try { parsed = JSON.parse(result.stdout); } catch { parsed = null; }
|
|
149
|
+
const paths = parsed ? collectPaths(parsed) : [];
|
|
150
|
+
const outside = paths.filter(p => !inside(p));
|
|
151
|
+
trials.push({
|
|
152
|
+
label,
|
|
153
|
+
command: `codex ${args.join(' ')}`,
|
|
154
|
+
exitCode: result.status,
|
|
155
|
+
durationMs: Date.now() - started,
|
|
156
|
+
answered: Boolean(result.stdout && result.stdout.trim()),
|
|
157
|
+
stderrHead: result.stderr ? String(result.stderr).slice(0, 200) : null,
|
|
158
|
+
absolutePathCount: paths.length,
|
|
159
|
+
pathsOutsideIsolatedHome: outside.slice(0, 5),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
const configComparison = r3cap.compareConfigSurface(configBefore, r3cap.digestRealClientConfigs(realHomeDir()));
|
|
163
|
+
const treeComparison = r3cap.compareRealTrees(treesBefore, r3cap.digestRealClientTrees(realHomeDir()));
|
|
164
|
+
const realHomeUntouched = configComparison.byteIdentical && treeComparison.leaks.length === 0 && treeComparison.configChanges.length === 0;
|
|
165
|
+
const answered = trials.every(trial => trial.answered);
|
|
166
|
+
const escaped = trials.some(trial => trial.pathsOutsideIsolatedHome.length > 0);
|
|
167
|
+
const classification = !answered
|
|
168
|
+
? 'blocked: the CLI does not answer under the isolated home'
|
|
169
|
+
: escaped
|
|
170
|
+
? 'blocked: the CLI resolves paths outside the isolated home'
|
|
171
|
+
: realHomeUntouched
|
|
172
|
+
? 'isolated'
|
|
173
|
+
: 'blocked: the read-only gate itself wrote the real home';
|
|
174
|
+
return {
|
|
175
|
+
environment: 'explicit CODEX_HOME + independent APPDATA/LOCALAPPDATA/USERPROFILE/HOME on the external temp home — exactly what the product server passes its codex children',
|
|
176
|
+
isolatedHome: homeDir,
|
|
177
|
+
codexHome,
|
|
178
|
+
trials,
|
|
179
|
+
realHomeAfterGate: { configByteIdentical: configComparison.byteIdentical, leaks: treeComparison.leaks, configChanges: treeComparison.configChanges },
|
|
180
|
+
classification,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** Replace the isolated config's notify line with an artificial chain. */
|
|
185
|
+
function writeCorruptNotify(configFile, args) {
|
|
186
|
+
const record = readNotifyLine(configFile);
|
|
187
|
+
if (record.index < 0) throw new Error(`the notify line must exist before corruption: ${record.source.slice(0, 300)}`);
|
|
188
|
+
record.lines[record.index] = `notify = ${JSON.stringify(args)}`;
|
|
189
|
+
fs.writeFileSync(configFile, record.lines.join(record.eol), 'utf8');
|
|
190
|
+
return chainOf(readNotifyLine(configFile).args);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const backupsIn = codexHome => fs.readdirSync(codexHome).filter(name => /^config\.toml\.project-knowledge-notify-.*\.bak$/.test(name));
|
|
194
|
+
|
|
195
|
+
/** One real 接入 click: wait for its request, its completion and the row. */
|
|
196
|
+
async function connectClick(harness, expectConnectedRow) {
|
|
197
|
+
const before = harness.installCallCount();
|
|
198
|
+
await harness.nativeClick(`[data-agent-switch="install"][data-agent-client="${CLIENT}"]`);
|
|
199
|
+
await harness.waitFor(() => harness.installCallCount() === before + 1, 'the 接入 click really sends a new install request', 30000);
|
|
200
|
+
await harness.waitFor(async () => {
|
|
201
|
+
const call = await harness.lastInstallCall();
|
|
202
|
+
return Boolean(call && call.response && call.response.complete === true);
|
|
203
|
+
}, 'the install request completes', 180000);
|
|
204
|
+
const call = await harness.lastInstallCall();
|
|
205
|
+
if (expectConnectedRow) {
|
|
206
|
+
await harness.waitFor(
|
|
207
|
+
() => harness.run(`(() => { const row = [...document.querySelectorAll('#agentCaptureList .agent-capture-row')].find(item => item.querySelector('[data-agent-switch]') && item.querySelector('[data-agent-switch]').dataset.agentClient === ${JSON.stringify(CLIENT)}); return Boolean(row) && row.querySelector('.status').textContent === '已接入'; })()`),
|
|
208
|
+
'the row shows codex as connected again',
|
|
209
|
+
90000,
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
return call;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function main() {
|
|
216
|
+
// The probe-owned external temp home: the server's whole homeDir (hence the
|
|
217
|
+
// integration homeDir and CODEX_HOME) moves here for this case, so the
|
|
218
|
+
// codex config file the product edits and the CODEX_HOME the CLI children
|
|
219
|
+
// use are one and the same isolated root.
|
|
220
|
+
const tempRoot = r3cap.resolveTempRoot();
|
|
221
|
+
fs.mkdirSync(tempRoot, { recursive: true });
|
|
222
|
+
const isolatedHome = fs.mkdtempSync(path.join(tempRoot, 'pk-cap-r4-cap006r-home-'));
|
|
223
|
+
const codexHome = path.join(isolatedHome, '.codex');
|
|
224
|
+
// The CLI refuses to answer when CODEX_HOME does not exist; the isolated
|
|
225
|
+
// home is this lane's own directory to prepare.
|
|
226
|
+
fs.mkdirSync(codexHome, { recursive: true });
|
|
227
|
+
const configFile = path.join(codexHome, 'config.toml');
|
|
228
|
+
|
|
229
|
+
const harness = await startCapHarness({
|
|
230
|
+
tag: 'cap006r4',
|
|
231
|
+
evidenceDir: EVIDENCE || undefined,
|
|
232
|
+
serverEnv: {
|
|
233
|
+
HOME: isolatedHome,
|
|
234
|
+
USERPROFILE: isolatedHome,
|
|
235
|
+
APPDATA: path.join(isolatedHome, 'AppData', 'Roaming'),
|
|
236
|
+
LOCALAPPDATA: path.join(isolatedHome, 'AppData', 'Local'),
|
|
237
|
+
CODEX_HOME: codexHome,
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
const evidence = [];
|
|
241
|
+
try {
|
|
242
|
+
const bridgeCommand = ['node', path.join(harness.bridgeHome, 'bin', 'bridge-hook.cjs')];
|
|
243
|
+
|
|
244
|
+
// ------------------------------------------------------------------
|
|
245
|
+
// 0. The read-only CLI gate, BEFORE any UI step (contract order).
|
|
246
|
+
// ------------------------------------------------------------------
|
|
247
|
+
const gate = codexReadGate({
|
|
248
|
+
homeDir: isolatedHome,
|
|
249
|
+
codexHome,
|
|
250
|
+
appData: path.join(isolatedHome, 'AppData', 'Roaming'),
|
|
251
|
+
localAppData: path.join(isolatedHome, 'AppData', 'Local'),
|
|
252
|
+
});
|
|
253
|
+
if (gate.classification !== 'isolated') {
|
|
254
|
+
// The product passes exactly this environment; an escape here is a
|
|
255
|
+
// source defect to report, not a boundary to hide behind.
|
|
256
|
+
throw new Error(`the read-only CLI gate must isolate under explicit CODEX_HOME (source defect if not): ${JSON.stringify(gate)}`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// ------------------------------------------------------------------
|
|
260
|
+
// 1. The first real 接入: install (notify wrapper + plugin/marketplace).
|
|
261
|
+
// ------------------------------------------------------------------
|
|
262
|
+
await harness.openSystemDrawer();
|
|
263
|
+
const rowBefore = await harness.agentRow(CLIENT);
|
|
264
|
+
assert.equal(rowBefore.badge, '未接入', `the isolated codex row must start disconnected: ${JSON.stringify(rowBefore)}`);
|
|
265
|
+
const firstCall = await connectClick(harness, true);
|
|
266
|
+
assert.equal(firstCall.status, 200, `the first install request answers 200: ${JSON.stringify(firstCall)}`);
|
|
267
|
+
assert.equal(firstCall.response.complete, true, `the first install must complete (isolation must not break the product): ${JSON.stringify(firstCall.response)}`);
|
|
268
|
+
const firstOperationId = firstCall.response.operationId;
|
|
269
|
+
assert.ok(firstOperationId, 'the first install must report an operation id');
|
|
270
|
+
const firstCapture = (firstCall.response.clients || []).find(entry => entry.client === CLIENT)?.developmentCapture;
|
|
271
|
+
assert.ok(firstCapture, `the install answer must carry the capture result: ${JSON.stringify(firstCall.response.clients)}`);
|
|
272
|
+
assert.equal(firstCapture.changed, true, `the first install really wrote the notify wrapper: ${JSON.stringify(firstCapture)}`);
|
|
273
|
+
assert.ok(firstCapture.backupFile && firstCapture.backupFile.startsWith(codexHome), `the backup must live inside the isolated home: ${JSON.stringify(firstCapture)}`);
|
|
274
|
+
assert.equal(fs.existsSync(firstCapture.backupFile), true, 'the reported backup file must exist on disk');
|
|
275
|
+
|
|
276
|
+
// The wrapper itself, in the product's own format, under the isolated home.
|
|
277
|
+
const afterFirst = readNotifyLine(configFile);
|
|
278
|
+
assert.notEqual(afterFirst.index, -1, `the isolated config.toml must carry the notify line: ${afterFirst.source.slice(0, 300)}`);
|
|
279
|
+
const chainFirst = chainOf(afterFirst.args);
|
|
280
|
+
assert.equal(chainFirst.fanoutCount, 1, `exactly one owned fanout anchors the chain: ${JSON.stringify(chainFirst)}`);
|
|
281
|
+
assert.equal(afterFirst.args.length, 4, `the fresh anchor is a plain fanout with no stacking: ${JSON.stringify(afterFirst.args)}`);
|
|
282
|
+
assert.deepEqual(chainFirst.bridge, bridgeCommand, `the fanout must target the lane Bridge entry: ${JSON.stringify(chainFirst)}`);
|
|
283
|
+
assert.equal(fs.existsSync(FANOUT), true, 'the owned fanout script must exist');
|
|
284
|
+
assert.equal(fs.existsSync(bridgeCommand[1]), true, 'the Bridge hook entry must exist');
|
|
285
|
+
|
|
286
|
+
// The plugin/marketplace half also landed inside the isolated CODEX_HOME.
|
|
287
|
+
const configText = fs.readFileSync(configFile, 'utf8');
|
|
288
|
+
assert.match(configText, /\[marketplaces\.project-knowledge\]/, `the marketplace registration must be in the isolated config.toml: ${configText.slice(0, 300)}`);
|
|
289
|
+
assert.match(configText, /\[plugins\."project-knowledge@project-knowledge"\]/, `the plugin registration must be in the isolated config.toml: ${configText.slice(0, 300)}`);
|
|
290
|
+
const pluginCacheRoot = path.join(codexHome, 'plugins', 'cache', 'project-knowledge', 'project-knowledge');
|
|
291
|
+
assert.equal(fs.existsSync(pluginCacheRoot), true, `the plugin cache must live under the isolated CODEX_HOME: ${pluginCacheRoot}`);
|
|
292
|
+
const notifyShaAfterFirst = crypto.createHash('sha256').update(afterFirst.lines[afterFirst.index]).digest('hex');
|
|
293
|
+
const backupsAfterFirst = backupsIn(codexHome);
|
|
294
|
+
assert.deepEqual(backupsAfterFirst.length, 1, `one backup per real change, the first install made exactly one: ${JSON.stringify(backupsAfterFirst)}`);
|
|
295
|
+
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'cap006r4-after-first-install.png'));
|
|
296
|
+
|
|
297
|
+
// ------------------------------------------------------------------
|
|
298
|
+
// 2. Clean-chain idempotence, proven by the product's own settled scan:
|
|
299
|
+
// statusCaptureCodex reports installed only when planNotify says the
|
|
300
|
+
// clean chain needs NO rewrite (changed === false).
|
|
301
|
+
// ------------------------------------------------------------------
|
|
302
|
+
const statusClean = await harness.settledStatus();
|
|
303
|
+
const clientClean = harness.statusClient(statusClean, CLIENT);
|
|
304
|
+
assert.equal(clientClean.developmentCapture.state, 'installed', `the product's own scan must accept the clean chain without rewrite: ${JSON.stringify(clientClean.developmentCapture)}`);
|
|
305
|
+
assert.equal(clientClean.developmentCapture.installed, true, `installed means planNotify.changed === false on the clean chain: ${JSON.stringify(clientClean.developmentCapture)}`);
|
|
306
|
+
const notifyShaClean = crypto.createHash('sha256').update(readNotifyLine(configFile).lines[readNotifyLine(configFile).index]).digest('hex');
|
|
307
|
+
assert.equal(notifyShaClean, notifyShaAfterFirst, 'the scan itself must not have rewritten the notify line');
|
|
308
|
+
assert.deepEqual(backupsIn(codexHome).length, 1, `a no-op status scan must not add backups: ${JSON.stringify(backupsIn(codexHome))}`);
|
|
309
|
+
const backupsAfterCleanScan = backupsIn(codexHome);
|
|
310
|
+
|
|
311
|
+
// ------------------------------------------------------------------
|
|
312
|
+
// 3. Corruption 1: a doubled owned chain (an older stacking install's
|
|
313
|
+
// shape) wrapping a compatible DevTask Radar third-party entry.
|
|
314
|
+
// Artificial damage declared up front — a direct edit of the ISOLATED
|
|
315
|
+
// config, never product output.
|
|
316
|
+
// ------------------------------------------------------------------
|
|
317
|
+
const inner = ['node', FANOUT, '--next-base64', encode(RADAR), '--bridge-base64', encode(bridgeCommand)];
|
|
318
|
+
const doubledWithRadar = ['node', FANOUT, '--next-base64', encode(inner), '--bridge-base64', encode(bridgeCommand)];
|
|
319
|
+
const chainCorrupt1 = writeCorruptNotify(configFile, doubledWithRadar);
|
|
320
|
+
assert.equal(chainCorrupt1.fanoutCount, 2, `the corruption really doubled the owned anchor: ${JSON.stringify(chainCorrupt1)}`);
|
|
321
|
+
assert.deepEqual(chainCorrupt1.terminal, RADAR, `the corruption really embedded the third-party radar entry: ${JSON.stringify(chainCorrupt1)}`);
|
|
322
|
+
|
|
323
|
+
// The product's own scan must see the damage before any repair is asked for.
|
|
324
|
+
await harness.reopenSystemDrawer();
|
|
325
|
+
await harness.waitFor(
|
|
326
|
+
() => harness.run(`(() => { const row = [...document.querySelectorAll('#agentCaptureList .agent-capture-row')].find(item => item.querySelector('[data-agent-switch]') && item.querySelector('[data-agent-switch]').dataset.agentClient === ${JSON.stringify(CLIENT)}); return Boolean(row) && row.querySelector('.status').textContent === '未接入'; })()`),
|
|
327
|
+
'the row re-renders as not connected after the fresh scan',
|
|
328
|
+
60000,
|
|
329
|
+
);
|
|
330
|
+
const statusCorrupt1 = await harness.settledStatus();
|
|
331
|
+
const clientCorrupt1 = harness.statusClient(statusCorrupt1, CLIENT);
|
|
332
|
+
assert.equal(clientCorrupt1.developmentCapture.state, 'not-installed', `the product must report the doubled chain as not installed (its repair vocabulary for codex): ${JSON.stringify(clientCorrupt1.developmentCapture)}`);
|
|
333
|
+
assert.equal(clientCorrupt1.developmentCapture.installed, false, `the doubled chain must not count as installed: ${JSON.stringify(clientCorrupt1.developmentCapture)}`);
|
|
334
|
+
assert.equal(clientCorrupt1.summary, 'disconnected', `the product must not report the client as connected: ${JSON.stringify(clientCorrupt1.summary)}`);
|
|
335
|
+
const rowCorrupt1 = await harness.agentRow(CLIENT);
|
|
336
|
+
assert.equal(rowCorrupt1.badge, '未接入', `the row must read as not connected while the chain is doubled: ${JSON.stringify(rowCorrupt1)}`);
|
|
337
|
+
assert.equal(rowCorrupt1.switch.action, 'install', `the switch must offer 接入 (the repair) again: ${JSON.stringify(rowCorrupt1.switch)}`);
|
|
338
|
+
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'cap006r4-needs-repair.png'));
|
|
339
|
+
|
|
340
|
+
// ------------------------------------------------------------------
|
|
341
|
+
// 4. The second real 接入: the repair. Collapse to one anchor, keep the
|
|
342
|
+
// third party, one more backup — all inside the isolated home.
|
|
343
|
+
// ------------------------------------------------------------------
|
|
344
|
+
const secondCall = await connectClick(harness, true);
|
|
345
|
+
assert.equal(secondCall.status, 200, `the repair request answers 200: ${JSON.stringify(secondCall)}`);
|
|
346
|
+
assert.equal(secondCall.response.complete, true, `the repair must complete: ${JSON.stringify(secondCall.response)}`);
|
|
347
|
+
const secondOperationId = secondCall.response.operationId;
|
|
348
|
+
assert.ok(secondOperationId, 'the repair must report its own operation id');
|
|
349
|
+
assert.notEqual(secondOperationId, firstOperationId, 'each action must be separately traceable');
|
|
350
|
+
const repairCapture = (secondCall.response.clients || []).find(entry => entry.client === CLIENT)?.developmentCapture;
|
|
351
|
+
assert.equal(repairCapture.changed, true, `the repair really rewrote the doubled chain: ${JSON.stringify(repairCapture)}`);
|
|
352
|
+
assert.ok(repairCapture.backupFile && repairCapture.backupFile.startsWith(codexHome), `the repair backup must live inside the isolated home: ${JSON.stringify(repairCapture)}`);
|
|
353
|
+
const chainAfterRepair1 = chainOf(readNotifyLine(configFile).args);
|
|
354
|
+
assert.equal(chainAfterRepair1.fanoutCount, 1, `the repair must collapse the doubled anchor back to one: ${JSON.stringify(chainAfterRepair1)}`);
|
|
355
|
+
assert.deepEqual(chainAfterRepair1.terminal, RADAR, `the compatible third-party radar entry must be preserved: ${JSON.stringify(chainAfterRepair1)}`);
|
|
356
|
+
assert.deepEqual(chainAfterRepair1.bridge, bridgeCommand, `the surviving anchor must still target the lane Bridge entry: ${JSON.stringify(chainAfterRepair1)}`);
|
|
357
|
+
const backupsAfterRepair1 = backupsIn(codexHome);
|
|
358
|
+
assert.deepEqual(backupsAfterRepair1.length, 2, `exactly one backup per real change (install + repair): ${JSON.stringify(backupsAfterRepair1)}`);
|
|
359
|
+
|
|
360
|
+
// ------------------------------------------------------------------
|
|
361
|
+
// 5. Corruption 2: a plain doubled anchor with NOTHING after it. The
|
|
362
|
+
// third repair cycle proves the collapse is repeatable, does not
|
|
363
|
+
// compound, and does not resurrect what was already gone.
|
|
364
|
+
// ------------------------------------------------------------------
|
|
365
|
+
const bareInner = ['node', FANOUT, '--bridge-base64', encode(bridgeCommand)];
|
|
366
|
+
const doubledBare = ['node', FANOUT, '--next-base64', encode(bareInner), '--bridge-base64', encode(bridgeCommand)];
|
|
367
|
+
const chainCorrupt2 = writeCorruptNotify(configFile, doubledBare);
|
|
368
|
+
assert.equal(chainCorrupt2.fanoutCount, 2, `the second corruption really doubled the anchor again: ${JSON.stringify(chainCorrupt2)}`);
|
|
369
|
+
assert.equal(chainCorrupt2.terminal, null, `the second corruption carries no third party: ${JSON.stringify(chainCorrupt2)}`);
|
|
370
|
+
|
|
371
|
+
await harness.reopenSystemDrawer();
|
|
372
|
+
await harness.waitFor(
|
|
373
|
+
() => harness.run(`(() => { const row = [...document.querySelectorAll('#agentCaptureList .agent-capture-row')].find(item => item.querySelector('[data-agent-switch]') && item.querySelector('[data-agent-switch]').dataset.agentClient === ${JSON.stringify(CLIENT)}); return Boolean(row) && row.querySelector('.status').textContent === '未接入'; })()`),
|
|
374
|
+
'the row re-renders as not connected before the second repair',
|
|
375
|
+
60000,
|
|
376
|
+
);
|
|
377
|
+
const thirdCall = await connectClick(harness, true);
|
|
378
|
+
assert.equal(thirdCall.response.complete, true, `the second repair must complete: ${JSON.stringify(thirdCall.response)}`);
|
|
379
|
+
const thirdOperationId = thirdCall.response.operationId;
|
|
380
|
+
assert.notEqual(thirdOperationId, secondOperationId, 'the third action is again separately traceable');
|
|
381
|
+
const repair2Capture = (thirdCall.response.clients || []).find(entry => entry.client === CLIENT)?.developmentCapture;
|
|
382
|
+
assert.equal(repair2Capture.changed, true, `the second repair really rewrote the chain: ${JSON.stringify(repair2Capture)}`);
|
|
383
|
+
const chainAfterRepair2 = chainOf(readNotifyLine(configFile).args);
|
|
384
|
+
assert.equal(chainAfterRepair2.fanoutCount, 1, `the second repair collapses to exactly one anchor: ${JSON.stringify(chainAfterRepair2)}`);
|
|
385
|
+
assert.equal(chainAfterRepair2.terminal, null, `nothing may be resurrected after the bare collapse: ${JSON.stringify(chainAfterRepair2)}`);
|
|
386
|
+
assert.equal(readNotifyLine(configFile).args.length, 4, `the collapsed chain is a plain fanout: ${JSON.stringify(readNotifyLine(configFile).args)}`);
|
|
387
|
+
assert.deepEqual(chainAfterRepair2.bridge, bridgeCommand, `the bridge target survives the second repair: ${JSON.stringify(chainAfterRepair2)}`);
|
|
388
|
+
const backupsAfterRepair2 = backupsIn(codexHome);
|
|
389
|
+
assert.deepEqual(backupsAfterRepair2.length, 3, `one backup per real change across install + two repairs: ${JSON.stringify(backupsAfterRepair2)}`);
|
|
390
|
+
|
|
391
|
+
// The settled scan accepts the final chain without rewrite, again.
|
|
392
|
+
const statusFinal = await harness.settledStatus();
|
|
393
|
+
assert.equal(harness.statusClient(statusFinal, CLIENT).developmentCapture.installed, true, `the final chain must satisfy the product's own no-rewrite check: ${JSON.stringify(harness.statusClient(statusFinal, CLIENT).developmentCapture)}`);
|
|
394
|
+
|
|
395
|
+
// ------------------------------------------------------------------
|
|
396
|
+
// 6. operationId traceability in the product's own diagnostics UI.
|
|
397
|
+
// ------------------------------------------------------------------
|
|
398
|
+
const traceability = [];
|
|
399
|
+
for (const [label, operationId] of [['first', firstOperationId], ['repair-radar', secondOperationId], ['repair-bare', thirdOperationId]]) {
|
|
400
|
+
const dialog = await harness.logsSearch(operationId);
|
|
401
|
+
assert.ok(dialog.entries.length > 0, `the operation id of the ${label} action must be findable in the diagnostics dialog`);
|
|
402
|
+
const hits = dialog.entries.filter(entry => `${entry.summary} ${entry.detail}`.includes(operationId));
|
|
403
|
+
assert.ok(hits.length > 0, `the ${label} operation id must appear in the returned diagnostics records themselves: ${JSON.stringify(dialog.entries.slice(0, 3))}`);
|
|
404
|
+
traceability.push({ action: label, operationId, returnedEntries: dialog.entries.length, operationIdHits: hits.length });
|
|
405
|
+
}
|
|
406
|
+
// The diagnostics dialog is open on the last repair's records — a visibly
|
|
407
|
+
// distinct page state from the first-install shot, and itself evidence.
|
|
408
|
+
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'cap006r4-after-repair.png'));
|
|
409
|
+
const commandLog = await harness.productApi('GET', '/api/logs?q=integration.command&pageSize=100');
|
|
410
|
+
assert.equal(commandLog.status, 200, `the diagnostics log must be readable: ${JSON.stringify(commandLog.body)}`);
|
|
411
|
+
const commands = (commandLog.body.entries || [])
|
|
412
|
+
.filter(entry => String(entry.event || '') === 'integration.command_completed')
|
|
413
|
+
.map(entry => ({ event: entry.event, client: entry.context?.client ?? null, status: entry.context?.status ?? null, argsHash: entry.context?.argsHash ?? null }));
|
|
414
|
+
assert.ok(commands.length > 0, 'the product must record the native codex commands it really ran');
|
|
415
|
+
assert.equal(commands.every(entry => entry.status === 0), true, `every native command must have exited 0: ${JSON.stringify(commands)}`);
|
|
416
|
+
|
|
417
|
+
// ------------------------------------------------------------------
|
|
418
|
+
// 7. Nothing leaked into the developer's real home (live-state carve-out).
|
|
419
|
+
// ------------------------------------------------------------------
|
|
420
|
+
const configComparison = r3cap.compareConfigSurface(harness.realHomeBefore, r3cap.digestRealClientConfigs(realHomeDir()));
|
|
421
|
+
assert.equal(configComparison.byteIdentical, true, `the real client configuration must be untouched: ${JSON.stringify({ changedFiles: configComparison.changedFiles, changedDirs: configComparison.changedDirs })}`);
|
|
422
|
+
const treeComparison = r3cap.compareRealTrees(harness.realTreesBefore, r3cap.digestRealClientTrees(realHomeDir()));
|
|
423
|
+
const liveWrites = treeComparison.changed.filter(item => LIVE_CODEX_STATE.test(`${item.dir}/${item.file}`));
|
|
424
|
+
assert.deepEqual(treeComparison.leaks.filter(item => !LIVE_CODEX_STATE.test(`${item.dir}/${item.file}`)), [], `nothing outside the runtime set and the proven live Codex state may change in the real home: ${JSON.stringify(treeComparison.leaks)}`);
|
|
425
|
+
assert.deepEqual(treeComparison.configChanges, [], `no real configuration file may change: ${JSON.stringify(treeComparison.configChanges)}`);
|
|
426
|
+
// Everything else that changed must be classified runtime by the frozen
|
|
427
|
+
// R3 partition (the developer's own live Claude/Codex sessions writing
|
|
428
|
+
// their own runtime files concurrently) — anything else IS a leak and
|
|
429
|
+
// already failed the leaks assertion above.
|
|
430
|
+
const concurrentRuntimeWrites = treeComparison.changed.filter(item => !LIVE_CODEX_STATE.test(`${item.dir}/${item.file}`));
|
|
431
|
+
assert.deepEqual(concurrentRuntimeWrites.filter(item => !r3cap.RUNTIME_PATH.test(`${item.dir}/${item.file}`)), [], `every non-carve-out change must be a runtime-path write of the live clients, not ours: ${JSON.stringify(concurrentRuntimeWrites)}`);
|
|
432
|
+
for (const relative of ['.codex/.codex-global-state.json', '.codex/.codex-global-state.json.bak']) {
|
|
433
|
+
const real = path.join(realHomeDir(), relative);
|
|
434
|
+
if (fs.existsSync(real)) {
|
|
435
|
+
assert.equal(fs.readFileSync(real, 'utf8').includes(MARKER), false, `the live Codex state must stay marker-free (external writes only): ${relative}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
evidence.push({
|
|
440
|
+
case: 'CAP-006 (R4 retest)',
|
|
441
|
+
fixture: { tag: 'cap006r4', fixtureDir: harness.fixture, isolatedHome, codexHome, port: Number(harness.base.split(':').pop()) },
|
|
442
|
+
source: { repoRoot: ROOT, gitHead: gitHead() },
|
|
443
|
+
r3ClaimRetested: 'R3 declared the codex notify sub-item BLOCKED ("the native codex CLI resolves the developer\'s real profile directory regardless of HOME/USERPROFILE") — that experiment never set CODEX_HOME, while the product\'s own codexHookProbe passes it explicitly',
|
|
444
|
+
gate,
|
|
445
|
+
firstInstall: {
|
|
446
|
+
control: `[data-agent-switch="install"][data-agent-client="${CLIENT}"]`,
|
|
447
|
+
realClick: true,
|
|
448
|
+
httpStatus: firstCall.status,
|
|
449
|
+
operationId: firstOperationId,
|
|
450
|
+
complete: firstCall.response.complete,
|
|
451
|
+
developmentCapture: firstCapture,
|
|
452
|
+
notifyChain: chainFirst,
|
|
453
|
+
backups: backupsAfterFirst,
|
|
454
|
+
},
|
|
455
|
+
cleanChainIdempotence: {
|
|
456
|
+
method: 'the product\'s own settled status scan — statusCaptureCodex reports installed only when planNotify computes changed === false over the existing chain',
|
|
457
|
+
developmentCapture: clientClean.developmentCapture,
|
|
458
|
+
notifyLineSha256Stable: notifyShaClean === notifyShaAfterFirst,
|
|
459
|
+
backups: backupsAfterCleanScan,
|
|
460
|
+
},
|
|
461
|
+
corruption1: {
|
|
462
|
+
method: 'direct edit of the ISOLATED config.toml notify line into a doubled owned fanout chain wrapping a compatible DevTask Radar third-party entry (declared artificial damage: an older stacking install\'s shape, never product output)',
|
|
463
|
+
chainAfterCorruption: chainCorrupt1,
|
|
464
|
+
productStatus: { developmentCapture: clientCorrupt1.developmentCapture, summary: clientCorrupt1.summary },
|
|
465
|
+
ui: { badge: rowCorrupt1.badge, switch: rowCorrupt1.switch },
|
|
466
|
+
},
|
|
467
|
+
repair1: {
|
|
468
|
+
control: `[data-agent-switch="install"][data-agent-client="${CLIENT}"]`,
|
|
469
|
+
realClick: true,
|
|
470
|
+
httpStatus: secondCall.status,
|
|
471
|
+
operationId: secondOperationId,
|
|
472
|
+
complete: secondCall.response.complete,
|
|
473
|
+
developmentCapture: repairCapture,
|
|
474
|
+
notifyChainAfterRepair: chainAfterRepair1,
|
|
475
|
+
backups: backupsAfterRepair1,
|
|
476
|
+
},
|
|
477
|
+
corruption2: {
|
|
478
|
+
method: 'direct edit of the ISOLATED config.toml notify line into a plain doubled owned anchor with no third party (declared artificial damage)',
|
|
479
|
+
chainAfterCorruption: chainCorrupt2,
|
|
480
|
+
},
|
|
481
|
+
repair2: {
|
|
482
|
+
control: `[data-agent-switch="install"][data-agent-client="${CLIENT}"]`,
|
|
483
|
+
realClick: true,
|
|
484
|
+
httpStatus: thirdCall.status,
|
|
485
|
+
operationId: thirdOperationId,
|
|
486
|
+
complete: thirdCall.response.complete,
|
|
487
|
+
developmentCapture: repair2Capture,
|
|
488
|
+
notifyChainAfterRepair: chainAfterRepair2,
|
|
489
|
+
finalScanInstalled: harness.statusClient(statusFinal, CLIENT).developmentCapture.installed,
|
|
490
|
+
backups: backupsAfterRepair2,
|
|
491
|
+
},
|
|
492
|
+
operationIdTraceability: traceability,
|
|
493
|
+
nativeCommands: commands,
|
|
494
|
+
realHomeIsolation: {
|
|
495
|
+
configuration: { byteIdentical: configComparison.byteIdentical, changedFiles: configComparison.changedFiles, changedDirs: configComparison.changedDirs },
|
|
496
|
+
tree: { leaks: treeComparison.leaks, configChanges: treeComparison.configChanges, runtimeChangeCount: treeComparison.runtimeChanges },
|
|
497
|
+
concurrentLiveWrites: { writes: liveWrites.map(item => `${item.dir}/${item.file} (${item.state})`), proof: 'the live Codex desktop\'s own electron state, marker-free, carved out exactly as the R4 cap008e probe proved external' },
|
|
498
|
+
concurrentRuntimeWrites: { count: concurrentRuntimeWrites.length, sample: concurrentRuntimeWrites.slice(0, 8).map(item => `${item.dir}/${item.file}`), proof: 'the developer\'s own live Claude/Codex sessions writing their runtime files mid-run; every one matches the frozen R3 RUNTIME_PATH partition, none is ours' },
|
|
499
|
+
scopeLabels: ['.claude', '.codex', '.config/opencode'],
|
|
500
|
+
},
|
|
501
|
+
scopeLabel: 'honest: read-only CLI gate first, then three real 接入 clicks (install, repair preserving a compatible third party, repair of a bare doubled anchor); clean-chain idempotence by the product\'s own no-rewrite scan; every write stays inside the explicit external CODEX_HOME; no Codex session, no model, no quota',
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
if (harness.evidence) {
|
|
505
|
+
fs.mkdirSync(harness.evidence, { recursive: true });
|
|
506
|
+
fs.writeFileSync(path.join(harness.evidence, 'cap006r4-codex-notify-isolation.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
console.log('parallel-memory-capture-r4-cap006-probe PASS (explicit CODEX_HOME isolates the codex CLI: the read-only gate kept every path inside the external temp home with the real home untouched; three real 接入 clicks installed, repaired a doubled chain preserving the third-party entry, and repaired a bare doubled anchor — collapsing to one anchor each time, one backup per real change — and the product\'s own scan accepted the clean chain without rewrite; the real ~/.codex was never touched)');
|
|
510
|
+
} finally {
|
|
511
|
+
await harness.cleanup();
|
|
512
|
+
// Never let scratch removal mask the real result: a codex child may hold
|
|
513
|
+
// the config file a moment past its kill; retry briefly, then report.
|
|
514
|
+
let removed = false;
|
|
515
|
+
for (let attempt = 0; attempt < 12 && !removed; attempt += 1) {
|
|
516
|
+
try { fs.rmSync(isolatedHome, { recursive: true, force: true }); removed = true; }
|
|
517
|
+
catch { await new Promise(resolve => setTimeout(resolve, 500)); }
|
|
518
|
+
}
|
|
519
|
+
if (!removed) console.error(`scratch isolated home removal left behind: ${isolatedHome}`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
process.on('unhandledRejection', error => { console.error(error); process.exitCode = 1; });
|
|
524
|
+
main().catch(error => { console.error(error); process.exitCode = 1; });
|