@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.
Files changed (65) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +21 -0
  3. package/_site/_test/appearance-settings-test.js +148 -0
  4. package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
  5. package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
  6. package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
  7. package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
  8. package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
  9. package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
  10. package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
  11. package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
  12. package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
  13. package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
  14. package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
  15. package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
  16. package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
  17. package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
  18. package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
  19. package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
  20. package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
  21. package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
  22. package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
  23. package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
  24. package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
  25. package/_site/_test/helpers/qa-r45-harness.js +94 -0
  26. package/_site/_test/helpers/qa-r48-env.js +64 -0
  27. package/_site/_test/helpers/qa-r51-env.cjs +77 -0
  28. package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
  29. package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
  30. package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
  31. package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
  32. package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
  33. package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
  34. package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
  35. package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
  36. package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
  37. package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
  38. package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
  39. package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
  40. package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
  41. package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
  42. package/_site/_test/parallel-memory-injection-probe.js +411 -0
  43. package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
  44. package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
  45. package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
  46. package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
  47. package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
  48. package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
  49. package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
  50. package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
  51. package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
  52. package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
  53. package/_site/_test/t07d-git-rel-coverage-test.js +224 -0
  54. package/_site/_test/t07e-qta-coverage-test.js +195 -0
  55. package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
  56. package/_site/lib/server-app.js +11 -2
  57. package/_site/lib/settings-store.js +43 -1
  58. package/module-runtime-manifest.json +16 -16
  59. package/package.json +2 -2
  60. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  61. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  62. package/plugins/project-knowledge/.mcp.json +1 -1
  63. package/ui/index.html +18 -1
  64. package/ui/product.css +6 -2
  65. package/ui/product.js +86 -1
@@ -0,0 +1,320 @@
1
+ 'use strict';
2
+ // _site/_test/parallel-capture-safety-r5-mem005-health-test.js
3
+ //
4
+ // R5 copy of _site/_test/parallel-memory-capture-r4-mem005-health-test.js
5
+ // (byte-identical logic; the only change is the shell require below, swapped
6
+ // to the R5 memory shell whose in-proc engine is constructed with an explicit
7
+ // lane-local vectorUrl — R4's shell left it unset and the engine's built-in
8
+ // default contacted the real 127.0.0.1:8787 hub; see evidence/vectorhub-incident).
9
+ //
10
+ // MEM-005 R4 — the UI half that R3 never proved on a healthy page.
11
+ //
12
+ // The Leader review of the R3 run found the vacuous pass: the after-reload
13
+ // screenshot showed the memory view's offline fallback ("知识引擎暂时不可用。
14
+ // 未读取到的记忆不会显示为已确认。"), so "no candidate card / no candidate
15
+ // text" was trivially true on an unavailable page. R3's waits accepted any
16
+ // non-empty #memoryContent — including that banner — before the page's own
17
+ // boot snapshot had answered.
18
+ //
19
+ // This case keeps the accepted R3 layers (product API ignored, engine API
20
+ // ignored, engine state file ignored, frozen source byte-identical, never
21
+ // injected) and re-proves the UI half with three gates that cannot pass on an
22
+ // unhealthy or empty projection:
23
+ // * a CONTRAST memory B is produced through the same real pipeline and must
24
+ // stay visible in the candidate box — before the ignore, right after it,
25
+ // and again after a real page reload. A box that empties, errors or falls
26
+ // back offline can never satisfy "B visible".
27
+ // * the offline banner text must be absent from the memory view AND from the
28
+ // home view at every gate.
29
+ // * the page's own /api/engine/snapshot requests after the reload must have
30
+ // answered 200 (network capture of the real browser).
31
+ // Only then: the ignored A has no card, no text, no ignore button, is not
32
+ // counted by the candidate badge and is not presented as confirmed.
33
+ //
34
+ // HONEST SCOPE: the analysis step is the frozen P-MEMORY-01 stand-in analyzer
35
+ // (helpers/parallel-memory-analyzer.js); this case is evidence about the
36
+ // engine's admission, the ignore action, the persistence of that state, the
37
+ // frozen source and the real UI's healthy-page projection — never about the
38
+ // model's judgement. The health gates are read-only observations of the real
39
+ // page; the driver never sets any availability flag.
40
+
41
+ const fs = require('node:fs');
42
+ const path = require('node:path');
43
+ const assert = require('node:assert/strict');
44
+
45
+ const { startHarness, makeRepo } = require('./helpers/parallel-capture-safety-r5-memory-shell');
46
+ const r3 = require('./helpers/parallel-memory-capture-r3-shell');
47
+
48
+ const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_TEST_EVIDENCE_DIR) : null;
49
+ const BANNER = '知识引擎暂时不可用';
50
+ const TEXT_A = 'R4 健康页忽略持久性(忽略项):对外错误信息使用中文表述,并优先复用已有模块。';
51
+ const TEXT_B = 'R4 对照记忆(保持候选):发布前必须运行隔离回归,不允许跳过。';
52
+ const REPO_NAME = 'mem005r4-repo';
53
+
54
+ async function openMemoryView(harness) {
55
+ await harness.nativeClick('nav [data-view="memory"]');
56
+ await harness.waitFor(
57
+ () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
58
+ 'the memory view is open',
59
+ 10000,
60
+ );
61
+ }
62
+
63
+ async function openCandidateBox(harness) {
64
+ await openMemoryView(harness);
65
+ await harness.nativeClick('[data-memory-tab="candidate"]');
66
+ }
67
+
68
+ /** A memory card's text is rendered by the real page (implies engine data). */
69
+ const cardTextVisible = (harness, text) => harness.run(
70
+ `document.getElementById('memoryContent').textContent.includes(${JSON.stringify(text)})`,
71
+ );
72
+
73
+ const bannerInMemoryView = harness => harness.run(
74
+ `document.getElementById('memoryContent').textContent.includes(${JSON.stringify(BANNER)})`,
75
+ );
76
+
77
+ const bannerInHome = harness => harness.run(
78
+ `document.getElementById('homeContent').textContent.includes(${JSON.stringify(BANNER)})`,
79
+ );
80
+
81
+ /**
82
+ * The healthy-page gate: the contrast candidate B must be visible AND the
83
+ * offline banner absent. Waiting for B's real text is the essential part —
84
+ * only a page that actually read engine data can render it.
85
+ */
86
+ async function waitHealthyCandidateBox(harness, label) {
87
+ const startedAt = Date.now();
88
+ await harness.waitFor(
89
+ () => cardTextVisible(harness, TEXT_B),
90
+ `${label}: the contrast candidate is visible in the candidate box (a page that fell back offline cannot render it)`,
91
+ 20000,
92
+ );
93
+ await harness.waitFor(
94
+ () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(BANNER)})`),
95
+ `${label}: the offline banner is absent from the memory view`,
96
+ 10000,
97
+ );
98
+ return { waitedMs: Date.now() - startedAt };
99
+ }
100
+
101
+ async function main() {
102
+ const harness = await startHarness({ tag: 'mem005r4', evidenceDir: EVIDENCE || undefined });
103
+ const evidence = [];
104
+ try {
105
+ const repo = makeRepo(harness.fixture, REPO_NAME, { 'README.md': '# R4 健康页忽略持久性夹具\n' });
106
+ const { projectId, knowledgePath } = await harness.importProject(repo, 'R4健康页忽略持久性');
107
+ await harness.requestRegistryRefresh();
108
+ await harness.waitFor(
109
+ () => harness.run("document.getElementById('homeContent').textContent.includes('R4健康页忽略持久性')"),
110
+ 'the imported project is listed',
111
+ 20000,
112
+ );
113
+
114
+ // 1. Two real candidates through the real pipeline: A will be ignored,
115
+ // B stays candidate and is the healthy-page contrast.
116
+ const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, scopeType: 'global', file: 'src/r4-candidate-a.js' });
117
+ const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, scopeType: 'global', file: 'src/r4-candidate-b.js' });
118
+ assert.equal(producedA.capture.accepted, 1, `run A admitted one candidate: ${JSON.stringify(producedA.capture)}`);
119
+ assert.equal(producedB.capture.accepted, 1, `run B admitted one candidate: ${JSON.stringify(producedB.capture)}`);
120
+ const memories = await harness.productMemories();
121
+ const candidateA = memories.find(memory => memory.text === TEXT_A);
122
+ const candidateB = memories.find(memory => memory.text === TEXT_B);
123
+ assert.ok(candidateA, 'candidate A really exists in the engine');
124
+ assert.ok(candidateB, 'candidate B really exists in the engine');
125
+ assert.equal(candidateA.status, 'candidate', 'A starts as a candidate');
126
+ assert.equal(candidateB.status, 'candidate', 'B starts as a candidate');
127
+ assert.equal(candidateA.evidence.commitSha, producedA.commitSha, 'A\'s frozen source names its real commit');
128
+ assert.equal(candidateB.evidence.commitSha, producedB.commitSha, 'B\'s frozen source names its real commit');
129
+
130
+ // 2. The frozen sources, fingerprinted before anything is clicked.
131
+ const fingerprint = (candidate, produced) => {
132
+ const events = harness.engine.coordinator.conversations.readEvents(projectId);
133
+ return {
134
+ source: r3.sourceFingerprint({
135
+ knowledgePath,
136
+ entryId: candidate.evidence.entryId,
137
+ repoPath: repo.path,
138
+ commitSha: produced.commitSha,
139
+ eventId: candidate.sourceEventId,
140
+ events,
141
+ }),
142
+ memory: r3.memoryFrozenFields(candidate),
143
+ };
144
+ };
145
+ const beforeA = fingerprint(candidateA, producedA);
146
+ assert.equal(beforeA.source.git.commitExists, true, 'A\'s frozen commit really exists');
147
+ assert.ok(beforeA.source.event, 'A\'s frozen conversation event really exists');
148
+
149
+ // 3. Healthy candidate box BEFORE the ignore: both cards visible, no banner.
150
+ await harness.reload();
151
+ await openCandidateBox(harness);
152
+ const gateBefore = await waitHealthyCandidateBox(harness, 'before ignore');
153
+ assert.equal(await cardTextVisible(harness, TEXT_A), true, 'A is listed alongside B before the ignore');
154
+ const cardsBefore = await harness.run("document.querySelectorAll('#memoryContent [data-memory-card]').length");
155
+ assert.ok(Number(cardsBefore) >= 2, `the healthy candidate box really shows both cards: ${cardsBefore}`);
156
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r4-healthy-before-ignore.png'));
157
+
158
+ // 4. Ignore A through the real UI. The strong half: A must leave while B
159
+ // STAYS — an emptied, errored or offline box can never pass this.
160
+ await harness.nativeClick(`[data-memory-action="ignore"][data-memory-id="${candidateA.id}"]`);
161
+ await harness.waitFor(
162
+ () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(TEXT_A)})`),
163
+ 'the ignored candidate A leaves the candidate box',
164
+ 15000,
165
+ );
166
+ assert.equal(await cardTextVisible(harness, TEXT_B), true, 'the contrast candidate B is STILL visible right after the ignore (the box did not empty or fall back offline)');
167
+ const ignorePatch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${candidateA.id}`)).pop();
168
+ assert.ok(ignorePatch, 'the shell really ignored A');
169
+ assert.equal(ignorePatch.status, 200, `the ignore answers 200: ${JSON.stringify(ignorePatch.body)}`);
170
+ assert.deepEqual(ignorePatch.body, { status: 'ignored' }, 'the ignore only changes the status');
171
+
172
+ // 5. RELOAD. Re-open the view the way a user does. First gate: the page
173
+ // must really have read engine data again — B visible, banner absent,
174
+ // and the page's own snapshot requests answered 200.
175
+ await harness.reload();
176
+ await harness.waitFor(() => harness.run("document.readyState === 'complete'"), 'the reloaded page is complete', 20000);
177
+ await harness.nativeClick('nav [data-view="home"]');
178
+ await harness.waitFor(
179
+ () => harness.run("document.getElementById('view-home').classList.contains('active')"),
180
+ 'the home view is open after the reload',
181
+ 10000,
182
+ );
183
+ await harness.waitFor(
184
+ () => harness.run(`document.getElementById('homeContent').textContent.includes(${JSON.stringify(TEXT_B)})`),
185
+ 'the home view\'s 待确认记忆 panel lists the contrast candidate B after the reload',
186
+ 20000,
187
+ );
188
+ assert.equal(await bannerInHome(harness), false, 'the home view shows real updates, not the engine-offline fallback, after the reload');
189
+
190
+ await openCandidateBox(harness);
191
+ const gateAfter = await waitHealthyCandidateBox(harness, 'after reload');
192
+ const afterReload = {
193
+ candidateACardPresent: await harness.run(`Boolean(document.querySelector('[data-memory-card=${JSON.stringify(candidateA.id)}]'))`),
194
+ textAInMemoryView: await cardTextVisible(harness, TEXT_A),
195
+ candidateCountBadge: await harness.run("document.getElementById('candidateCount').textContent"),
196
+ ignoreButtonPresent: await harness.run(`Boolean(document.querySelector('[data-memory-action="ignore"][data-memory-id=${JSON.stringify(candidateA.id)}]'))`),
197
+ confirmButtonPresent: await harness.run(`Boolean(document.querySelector('[data-memory-action="confirm"][data-memory-id=${JSON.stringify(candidateA.id)}]'))`),
198
+ contrastCardPresent: await harness.run(`Boolean(document.querySelector('[data-memory-card=${JSON.stringify(candidateB.id)}]'))`),
199
+ };
200
+ assert.equal(afterReload.candidateACardPresent, false, 'the ignored A has no card after the reload');
201
+ assert.equal(afterReload.textAInMemoryView, false, 'A\'s text is not in the memory view after the reload');
202
+ assert.equal(String(afterReload.candidateCountBadge).trim(), '1', `the candidate counter counts only the contrast candidate B after the reload: ${JSON.stringify(afterReload.candidateCountBadge)}`);
203
+ assert.equal(afterReload.ignoreButtonPresent, false, 'A offers no ignore button after the reload');
204
+ assert.equal(afterReload.confirmButtonPresent, false, 'A offers no confirm button after the reload');
205
+ assert.equal(afterReload.contrastCardPresent, true, 'B\'s card is right there — the absence of A is a real filtered-out record, not an offline fallback');
206
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r4-after-reload-healthy-candidates.png'));
207
+
208
+ // 6. The confirmed tab: rendered from real data (B is not confirmed, so
209
+ // the real empty-state text shows), banner absent, A not confirmed.
210
+ await harness.nativeClick('[data-memory-tab="confirmed"]');
211
+ await harness.waitFor(
212
+ () => harness.run(`(!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(BANNER)}) && (document.getElementById('memoryContent').textContent.includes('还没有已确认的长期记忆') || document.querySelectorAll('[data-memory-card]').length > 0))`),
213
+ 'the confirmed tab is rendered from real data (not the offline banner)',
214
+ 15000,
215
+ );
216
+ const confirmedTab = {
217
+ cardAPresent: await harness.run(`Boolean(document.querySelector('[data-memory-card=${JSON.stringify(candidateA.id)}]'))`),
218
+ textAPresent: await cardTextVisible(harness, TEXT_A),
219
+ bannerPresent: await bannerInMemoryView(harness),
220
+ };
221
+ assert.equal(confirmedTab.cardAPresent, false, 'A is not shown as a confirmed memory');
222
+ assert.equal(confirmedTab.textAPresent, false, 'A\'s text is not shown in the confirmed tab');
223
+ assert.equal(confirmedTab.bannerPresent, false, 'the confirmed tab is not the offline fallback');
224
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r4-after-reload-confirmed.png'));
225
+
226
+ // 7. The page's own snapshot requests after the reload answered 200.
227
+ const pageSnapshotRequests = harness.network
228
+ .find(entry => entry.method === 'GET' && entry.url.includes('/api/engine/snapshot'))
229
+ .map(entry => ({ url: entry.url.replace(harness.base, ''), status: entry.status }));
230
+ assert.ok(
231
+ pageSnapshotRequests.some(entry => entry.status === 200),
232
+ `the real page loaded its engine snapshot successfully after the reload: ${JSON.stringify(pageSnapshotRequests.slice(-5))}`,
233
+ );
234
+
235
+ // 8. The engine state after the reload — kept from R3: through the
236
+ // product, through the engine itself and from the persisted file.
237
+ const productView = (await harness.productMemories()).find(memory => memory.id === candidateA.id);
238
+ assert.ok(productView, 'A is still served by the product after the reload');
239
+ assert.equal(productView.status, 'ignored', 'the product still reports A as ignored after the reload');
240
+ const productB = (await harness.productMemories()).find(memory => memory.id === candidateB.id);
241
+ assert.equal(productB.status, 'candidate', 'the contrast B is still a candidate after the reload');
242
+
243
+ const engineList = await harness.engineApi('GET', '/api/memories');
244
+ assert.equal(engineList.status, 200, `the engine memory list must be readable: ${JSON.stringify(engineList.body)}`);
245
+ const engineA = (engineList.body.memories || []).find(memory => memory.id === candidateA.id);
246
+ const engineB = (engineList.body.memories || []).find(memory => memory.id === candidateB.id);
247
+ assert.ok(engineA, 'the engine still knows A after the reload');
248
+ assert.equal(engineA.status, 'ignored', 'the engine still reports A as ignored after the reload');
249
+ assert.equal(engineB.status, 'candidate', 'the engine still reports B as a candidate after the reload');
250
+
251
+ const onDisk = r3.engineStateOnDisk(harness.engine);
252
+ assert.equal(onDisk.exists, true, 'the engine really persisted a state file');
253
+ const diskA = onDisk.memories.find(memory => memory.id === candidateA.id);
254
+ const diskB = onDisk.memories.find(memory => memory.id === candidateB.id);
255
+ assert.ok(diskA, 'A is really persisted in the engine state file');
256
+ assert.equal(diskA.status, 'ignored', 'the persisted record on disk carries A\'s ignored status');
257
+ assert.equal(diskB.status, 'candidate', 'the persisted record on disk keeps B a candidate');
258
+
259
+ // 9. A's frozen source is untouched by the ignore.
260
+ const afterA = fingerprint(productView, producedA);
261
+ const comparison = r3.compareFrozen(beforeA, afterA);
262
+ assert.equal(comparison.identical, true, `A's frozen source must not change: ${JSON.stringify(comparison.diffs)}`);
263
+ assert.equal(comparison.entrySha256Same, true, 'A\'s promoted entry file is byte-identical after the ignore');
264
+ assert.equal(comparison.gitTreeSame, true, 'A\'s frozen commit tree is unchanged after the ignore');
265
+ assert.equal(comparison.eventHashSame, true, 'A\'s frozen event hash is unchanged after the ignore');
266
+ assert.equal(comparison.memoryFrozenFieldsSame, true, 'A\'s frozen record fields are unchanged after the ignore');
267
+
268
+ // 10. Still not injected after the reload.
269
+ const injected = await harness.injectedMemories(projectId);
270
+ assert.ok(
271
+ !injected.some(entry => entry.memoryId === candidateA.id),
272
+ `an ignored memory is still never injected: ${JSON.stringify(injected)}`,
273
+ );
274
+
275
+ assert.equal(harness.browser.exceptions.length, 0, `no uncaught product JavaScript exceptions: ${JSON.stringify(harness.browser.exceptions)}`);
276
+
277
+ evidence.push({
278
+ case: 'MEM-005-persistence-healthy-page',
279
+ run: {
280
+ projectId,
281
+ commitA: producedA.commitSha,
282
+ commitB: producedB.commitSha,
283
+ knowledgePath,
284
+ },
285
+ candidates: {
286
+ ignored: { id: candidateA.id, text: TEXT_A, statusBefore: 'candidate', statusAfter: productView.status },
287
+ contrast: { id: candidateB.id, text: TEXT_B, statusBefore: 'candidate', statusAfter: productB.status },
288
+ },
289
+ healthyPageGates: {
290
+ banner: BANNER,
291
+ beforeIgnore: { ...gateBefore, bothCardsVisible: true },
292
+ afterIgnoreClick: { contrastStillVisible: true },
293
+ afterReload: { ...gateAfter, contrastVisible: true, homeListsContrast: true, bannerInMemoryView: false, bannerInHome: false },
294
+ pageSnapshotRequests: pageSnapshotRequests.slice(-6),
295
+ },
296
+ uiAfterReload: { ...afterReload, confirmedTab, pageReloaded: true, viewReopenedAfterReload: true },
297
+ ignoreRequest: { method: 'PATCH', url: ignorePatch.url.replace(harness.base, ''), status: ignorePatch.status, request: ignorePatch.body },
298
+ engineStateAfterReload: {
299
+ productEndpoint: { A: productView.status, B: productB.status },
300
+ engineEndpoint: { A: engineA.status, B: engineB.status },
301
+ engineStateFile: { file: onDisk.file, exists: onDisk.exists, sha256: onDisk.sha256, A: diskA.status, B: diskB.status },
302
+ },
303
+ frozenSourceIgnored: { before: beforeA.source, after: afterA.source, comparison },
304
+ injectedAfterReload: injected.map(entry => entry.memoryId),
305
+ provenance: r3.provenance(),
306
+ scopeLabel: 'honest: the analysis step is the frozen P-MEMORY-01 stand-in analyzer, not a model; health gates only read the real page (banner absence + contrast visibility + page snapshot 200s), the driver never sets an availability flag',
307
+ });
308
+
309
+ if (harness.evidence) {
310
+ fs.mkdirSync(harness.evidence, { recursive: true });
311
+ fs.writeFileSync(path.join(harness.evidence, 'mem005-r4-healthy-persistence.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
312
+ }
313
+
314
+ console.log('parallel-memory-capture-r4-mem005-health-test PASS (on a provably healthy page — contrast candidate visible, offline banner absent, page snapshot 200s — the ignored candidate stays ignored across a real reload and never returns as candidate or confirmed, while the engine, its persisted state and the frozen source are unchanged)');
315
+ } finally {
316
+ await harness.cleanup();
317
+ }
318
+ }
319
+
320
+ main().catch(error => { console.error(error.stack || error.message); process.exitCode = 1; });
@@ -0,0 +1,304 @@
1
+ 'use strict';
2
+
3
+ // P-ENGINE-RECONCILE-R4 - ENG-007 gap probe (the open item R3 left behind).
4
+ //
5
+ // R3 proved honestly that the startup reconciliation contract is JOURNAL
6
+ // RECOVERY: a commit whose hook failed and therefore never reached the
7
+ // journal is not "found back" by the engine, because the engine has no
8
+ // Git-history traversal at all (CommitScanner.scan/scanProject/applyScanResult
9
+ // are exported but never called from src/).
10
+ //
11
+ // R3 also proved the OTHER case: a commit whose boundary event WAS captured
12
+ // but was delivered after the analysed head had already moved past it was
13
+ // silently DISCARDED - the event was consumed (cursor advanced), the boundary
14
+ // was projected, and no run, no ledger entry and no analysis were created.
15
+ // Durable evidence disappeared with no diagnostic and no way to recover it.
16
+ // That is the case this probe drives to a decision.
17
+ //
18
+ // Everything here is real:
19
+ // * a REAL fixture git repository with REAL commits
20
+ // * a REAL post-commit hook that runs the REAL pinned
21
+ // ai-coding-event-bridge commit-boundary CLI as a separate OS process
22
+ // * the "broken hook" mode points the hook at a non-existent CLI, so the
23
+ // hook FAILS for real and the commit never reaches the journal - no
24
+ // API-created task is used to stand in for a hook failure
25
+ // * the REAL bridge console (isolated --home journal), the REAL vector-hub
26
+ // (deterministic test embeddings - the paid embedding API is NOT
27
+ // exercised), the REAL knowledge-engine under test
28
+ //
29
+ // The analysed analyzer is a deterministic stand-in: it writes real staged
30
+ // Markdown bytes and a real staging manifest through the engine's real
31
+ // promotion path. NO real model output is exercised.
32
+ //
33
+ // TARGET IDENTITY
34
+ // default run : the VENDORED bytes (_modules/knowledge-engine) - the pinned
35
+ // bytes in which the late-delivery drop is live -> RED
36
+ // candidate : PK_TEST_ENGINE_ROOT=<module source checkout> -> GREEN
37
+ //
38
+ // This file is deliberately NOT named *-test.js: the canonical runner collects
39
+ // only *-test.js, and the fix lives in the module SOURCE repo (not vendored),
40
+ // so a default-red canonical entry would misrepresent the pinned package. The
41
+ // same file runs RED against the pinned bytes and GREEN against the candidate
42
+ // bytes.
43
+
44
+ const assert = require('node:assert/strict');
45
+ const fs = require('node:fs');
46
+ const path = require('node:path');
47
+ const {
48
+ makeLaneDir, buildFixtureRepo, installPostCommitHook, startBridge, startVector,
49
+ startEngine, captureBoundary, boundaryEvents, waitUntil, git, gitRun, readJsonl,
50
+ saveEvidence, hashFile, resolveEngineRoot, RUNTIME_IDENTITY, REPO_ROOT,
51
+ VENDORED_ENGINE_ROOT, VENDORED_ENGINE_VERSION,
52
+ } = require('./helpers/parallel-engine-reconcile-r4-harness.js');
53
+ const { createStandinAnalyzer } = require('./helpers/parallel-engine-reconcile-r4-standin-analyzer.js');
54
+
55
+ const ARTIFACTS = process.env.PK_TEST_EVIDENCE_ROOT
56
+ ? path.join(process.env.PK_TEST_EVIDENCE_ROOT, 'eng007r4')
57
+ : path.resolve(__dirname, '../../qa-autopilot/artifacts/parallel-20261023/engine-reconcile-r4/reruns/eng007r4');
58
+ const PROJECT_ID = 'project-eng007r4';
59
+
60
+ function targetLabel(engineIdentity) {
61
+ return engineIdentity.candidate ? 'candidate' : 'pinned';
62
+ }
63
+
64
+ function readDiagnostics(dataDir) {
65
+ const records = [];
66
+ const root = path.join(dataDir, 'logs');
67
+ const walk = dir => {
68
+ if (!fs.existsSync(dir)) return;
69
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
70
+ const absolute = path.join(dir, entry.name);
71
+ if (entry.isDirectory()) walk(absolute);
72
+ else if (entry.name.endsWith('.jsonl')) records.push(...readJsonl(absolute));
73
+ }
74
+ };
75
+ walk(root);
76
+ return records;
77
+ }
78
+
79
+ async function main() {
80
+ const engineIdentity = resolveEngineRoot();
81
+ const lane = makeLaneDir('eng007r4');
82
+ const commands = [];
83
+ const evidence = {
84
+ caseId: 'ENG-007 (R4): a captured commit boundary delivered after the analysed head moved past it',
85
+ laneDir: lane,
86
+ target: {
87
+ engineRoot: engineIdentity.root,
88
+ engineVersion: engineIdentity.version,
89
+ engineOrigin: engineIdentity.origin,
90
+ candidateBytes: engineIdentity.candidate,
91
+ vendoredEngineRoot: VENDORED_ENGINE_ROOT,
92
+ vendoredEngineVersion: VENDORED_ENGINE_VERSION,
93
+ bridge: RUNTIME_IDENTITY.bridge,
94
+ vector: RUNTIME_IDENTITY.vector,
95
+ coordinatorSha256: {
96
+ underTest: hashFile(path.join(engineIdentity.root, 'src', 'coordinator.js')),
97
+ vendored: hashFile(path.join(VENDORED_ENGINE_ROOT, 'src', 'coordinator.js')),
98
+ },
99
+ },
100
+ contract: {
101
+ source: 'README.md 触发面 (the journal is the reconciliation source) + README.md:119 (hook-captured events are retained in the journal and only become tasks after the service consumes them) + src/coordinator.js consumeJournal + src/runtime/commit-reconciler.js:173 (a failed SHA is never retried, scanned or inferred from history)',
102
+ scope: 'startup reconciliation = JOURNAL RECOVERY. A commit that never reached the journal is OUTSIDE the contract (uncovered boundary, stated - not papered over). A commit whose event WAS captured but was delivered after the analysed head moved past it is INSIDE the contract and must not be dropped.',
103
+ },
104
+ phases: {},
105
+ commands,
106
+ };
107
+
108
+ const fixture = buildFixtureRepo(lane, 'eng007r4', []);
109
+ const knowledgePath = path.join(lane, 'knowledge-eng007r4');
110
+ const storePath = path.join(knowledgePath, 'dev-conversations');
111
+ fs.mkdirSync(storePath, { recursive: true });
112
+ const home = path.join(lane, 'bridge-home');
113
+ const dataDir = path.join(lane, 'engine-data');
114
+ const vectorRoot = path.join(lane, 'vector-root');
115
+ const eventsFile = path.join(lane, 'analyzer-events.jsonl');
116
+
117
+ const bridge = startBridge(home);
118
+ let engine = null;
119
+ let vector = null;
120
+ const analyzer = createStandinAnalyzer({ eventsFile, engineRoot: engineIdentity.root });
121
+ const invocationsFor = sha => readJsonl(eventsFile).filter(entry => entry.kind === 'start' && entry.commitSha === sha).length;
122
+
123
+ try {
124
+ const bridgeUrl = await bridge.listen();
125
+ vector = await startVector(vectorRoot);
126
+ const registered = await bridge.projectRegistry.addProject({ home, path: fixture.repoPath, store: storePath });
127
+ const { repoIdentity } = await bridge.resolveRepoContext(fixture.repoPath);
128
+
129
+ // Register the project (consumer off), then stop the engine: the offline
130
+ // window begins. Nothing can consume a journal event while the engine is
131
+ // down.
132
+ engine = await startEngine({ dataDir, bridgeUrl, vectorUrl: vector.url, analyzer, consume: false, engineRoot: engineIdentity.root });
133
+ await engine.listen();
134
+ engine.runtime.store.addProject({
135
+ projectId: PROJECT_ID, repoPath: fixture.repoPath, knowledgePath,
136
+ trackingStartCommit: fixture.baseline, repoIdentity, journalId: registered.id, conversationBaselineCursor: 0,
137
+ });
138
+ await engine.close();
139
+ engine = null;
140
+ commands.push('engine lifecycle 0: project registered (consumer off), engine stopped - offline window begins');
141
+
142
+ // ----- commit A: BROKEN hook (the real hook failure) -----
143
+ installPostCommitHook(fixture.repoPath, { home, mode: 'broken' });
144
+ fs.writeFileSync(path.join(fixture.repoPath, 'offline-a.txt'), `offline feature A\n${'a'.repeat(64)}\n`);
145
+ git(fixture.repoPath, ['add', '.']);
146
+ const commitA = gitRun(fixture.repoPath, ['commit', '-qm', 'offline feature A']);
147
+ assert.equal(commitA.code, 0, `Git must not be blocked by the failing hook (exit ${commitA.code})`);
148
+ const shaA = git(fixture.repoPath, ['rev-parse', 'HEAD']);
149
+ assert.match(commitA.stderr, /commit-boundary\.missing\.js/, 'the hook really failed');
150
+
151
+ // ----- commit C: BROKEN hook too, and it is NEVER captured later -----
152
+ installPostCommitHook(fixture.repoPath, { home, mode: 'broken' });
153
+ fs.writeFileSync(path.join(fixture.repoPath, 'offline-c.txt'), `offline feature C\n${'c'.repeat(64)}\n`);
154
+ git(fixture.repoPath, ['add', '.']);
155
+ const commitC = gitRun(fixture.repoPath, ['commit', '-qm', 'offline feature C']);
156
+ assert.equal(commitC.code, 0);
157
+ const shaC = git(fixture.repoPath, ['rev-parse', 'HEAD']);
158
+
159
+ // ----- commit B: WORKING hook (the real capture path) -----
160
+ installPostCommitHook(fixture.repoPath, { home, mode: 'ok' });
161
+ fs.writeFileSync(path.join(fixture.repoPath, 'offline-b.txt'), `offline feature B\n${'b'.repeat(64)}\n`);
162
+ git(fixture.repoPath, ['add', '.']);
163
+ const commitB = gitRun(fixture.repoPath, ['commit', '-qm', 'offline feature B']);
164
+ assert.equal(commitB.code, 0);
165
+ const shaB = git(fixture.repoPath, ['rev-parse', 'HEAD']);
166
+
167
+ const boundariesOffline = boundaryEvents(home, storePath);
168
+ assert.equal(boundariesOffline.filter(e => e.commitSha === shaB).length, 1, 'B wrote exactly one boundary event while the engine was down');
169
+ assert.equal(boundariesOffline.filter(e => e.commitSha === shaA).length, 0, 'A wrote no boundary event (hook failure)');
170
+ assert.equal(boundariesOffline.filter(e => e.commitSha === shaC).length, 0, 'C wrote no boundary event (hook failure)');
171
+
172
+ // A and C really are ancestors of B in the real Git history (the
173
+ // "the analysed head moved past them" precondition).
174
+ const aIsAncestorOfB = gitRun(fixture.repoPath, ['merge-base', '--is-ancestor', shaA, shaB]);
175
+ const cIsAncestorOfB = gitRun(fixture.repoPath, ['merge-base', '--is-ancestor', shaC, shaB]);
176
+ assert.equal(aIsAncestorOfB.code, 0, 'A must be an ancestor of B');
177
+ assert.equal(cIsAncestorOfB.code, 0, 'C must be an ancestor of B');
178
+
179
+ evidence.phases.offlineWindow = {
180
+ baseline: fixture.baseline,
181
+ commitA: { sha: shaA, subject: 'offline feature A', hook: 'broken (missing CLI)', gitExit: commitA.code, hookStderr: (commitA.stderr.split('\n').find(line => line.includes('commit-boundary.missing.js')) || commitA.stderr.split('\n')[0]), boundaryEvents: 0 },
182
+ commitC: { sha: shaC, subject: 'offline feature C', hook: 'broken (missing CLI)', gitExit: commitC.code, boundaryEvents: 0 },
183
+ commitB: { sha: shaB, subject: 'offline feature B', hook: 'working (real bridge CLI)', gitExit: commitB.code, boundaryEvents: 1 },
184
+ aIsAncestorOfB: aIsAncestorOfB.code === 0,
185
+ cIsAncestorOfB: cIsAncestorOfB.code === 0,
186
+ };
187
+ commands.push(`offline window: A (broken hook, 0 events), C (broken hook, 0 events), B (working hook, 1 event); A and C are ancestors of B`);
188
+
189
+ // ----- restart: startup drain compensates B (journal recovery works) -----
190
+ engine = await startEngine({ dataDir, bridgeUrl, vectorUrl: vector.url, analyzer, consume: true, engineRoot: engineIdentity.root });
191
+ await engine.listen();
192
+ const runB = await waitUntil(async () => {
193
+ const run = engine.runtime.store.listRuns(PROJECT_ID).find(r => r.commitSha === shaB);
194
+ return run && run.state === 'succeeded' ? run : null;
195
+ }, 60000, 'startup drain compensates B');
196
+ await new Promise(resolve => setTimeout(resolve, 1500));
197
+
198
+ const ledgerPath = sha => path.join(dataDir, 'runtime', 'processed-commits', PROJECT_ID, `${sha}.json`);
199
+ const runsAfterStart = engine.runtime.store.listRuns(PROJECT_ID);
200
+ const lastAnalyzedAfterStart = engine.runtime.store.getProject(PROJECT_ID)?.runtime?.lastAnalyzedCommit || null;
201
+ evidence.phases.startupJournalRecovery = {
202
+ runForB: { runId: runB.runId, trigger: runB.trigger, state: runB.state },
203
+ analyzerInvocations: { forA: invocationsFor(shaA), forB: invocationsFor(shaB), forC: invocationsFor(shaC) },
204
+ runsForA: runsAfterStart.filter(r => r.commitSha === shaA).length,
205
+ runsForC: runsAfterStart.filter(r => r.commitSha === shaC).length,
206
+ totalRuns: runsAfterStart.length,
207
+ ledgerAExists: fs.existsSync(ledgerPath(shaA)),
208
+ ledgerCExists: fs.existsSync(ledgerPath(shaC)),
209
+ lastAnalyzedCommit: lastAnalyzedAfterStart,
210
+ verdict: 'the startup drain compensates B (the captured event). A and C never reached the journal, so no recovery path exists for them - that is the documented journal-recovery boundary, not a defect.',
211
+ };
212
+ assert.equal(runB.trigger, 'git-hook');
213
+ assert.equal(invocationsFor(shaB), 1, 'B compensated exactly once');
214
+ assert.equal(runsAfterStart.filter(r => r.commitSha === shaA).length, 0, 'A has no run: nothing for the engine to consume');
215
+ assert.equal(runsAfterStart.filter(r => r.commitSha === shaC).length, 0, 'C has no run: nothing for the engine to consume');
216
+ assert.equal(fs.existsSync(ledgerPath(shaA)), false, 'A is not in the processing ledger');
217
+ assert.equal(lastAnalyzedAfterStart, shaB, 'B\'s success moved lastAnalyzedCommit to shaB');
218
+ commands.push(`restart -> drain compensated B (${shaB.slice(0, 8)}); A (${shaA.slice(0, 8)}) and C (${shaC.slice(0, 8)}) have no run/ledger/analysis - never captured`);
219
+
220
+ // ----- the defect: A's boundary is captured NOW, after the head moved past it -----
221
+ const cursorBefore = engine.runtime.store.state.journalCursors[registered.id] || 0;
222
+ const captureA = captureBoundary({ home, repoPath: fixture.repoPath, sha: shaA });
223
+ assert.equal(captureA.code, 0, `capturing A's boundary through the real CLI failed: ${captureA.stderr}`);
224
+ assert.equal(captureA.payload?.ok, true, `the real boundary CLI did not report ok: ${captureA.stdout}`);
225
+ await waitUntil(async () => (engine.runtime.store.state.journalCursors[registered.id] || 0) > cursorBefore, 30000, 'A\'s late boundary event is consumed');
226
+ await engine.runtime.coordinator.drain();
227
+ await new Promise(resolve => setTimeout(resolve, 1500));
228
+
229
+ const runsAfterLateCapture = engine.runtime.store.listRuns(PROJECT_ID);
230
+ const runA = runsAfterLateCapture.find(r => r.commitSha === shaA) || null;
231
+ const lastAnalyzedAfterLateCapture = engine.runtime.store.getProject(PROJECT_ID)?.runtime?.lastAnalyzedCommit || null;
232
+ const diagnostics = readDiagnostics(dataDir);
233
+ const compensationDiagnostic = diagnostics.find(d => d.event === 'reconcile.missed_commit_compensated') || null;
234
+ const knowledgeFileA = path.join(knowledgePath, 'changes', `${shaA.slice(0, 12)}.md`);
235
+ const knowledgeFileB = path.join(knowledgePath, 'changes', `${shaB.slice(0, 12)}.md`);
236
+
237
+ evidence.phases.lateDelivery = {
238
+ capture: { code: captureA.code, ok: captureA.payload?.ok, commitSha: shaA, cli: 'pinned ai-coding-event-bridge commit-boundary CLI (the same code path the post-commit hook runs)' },
239
+ journalCursorBefore: cursorBefore,
240
+ journalCursorAfter: engine.runtime.store.state.journalCursors[registered.id] || 0,
241
+ runsForA: runsAfterLateCapture.filter(r => r.commitSha === shaA).length,
242
+ runForA: runA ? { runId: runA.runId, trigger: runA.trigger, state: runA.state, error: runA.error || null } : null,
243
+ analyzerInvocations: { forA: invocationsFor(shaA), forB: invocationsFor(shaB), forC: invocationsFor(shaC) },
244
+ ledgerAExists: fs.existsSync(ledgerPath(shaA)),
245
+ knowledgeFileForA: fs.existsSync(knowledgeFileA),
246
+ knowledgeFileForB: fs.existsSync(knowledgeFileB),
247
+ lastAnalyzedCommit: lastAnalyzedAfterLateCapture,
248
+ runOrder: runsAfterLateCapture.map(r => ({ commitSha: r.commitSha, state: r.state })),
249
+ analysisOrder: readJsonl(eventsFile).filter(entry => entry.kind === 'start').map(entry => entry.commitSha),
250
+ compensationDiagnostic: compensationDiagnostic
251
+ ? { event: compensationDiagnostic.event, level: compensationDiagnostic.level, commitSha: compensationDiagnostic.commitSha, message: compensationDiagnostic.message }
252
+ : null,
253
+ runsForC: runsAfterLateCapture.filter(r => r.commitSha === shaC).length,
254
+ };
255
+ commands.push(`A's boundary captured through the real CLI after B was analysed -> cursor ${cursorBefore}->${evidence.phases.lateDelivery.journalCursorAfter}; runs for A: ${evidence.phases.lateDelivery.runsForA}`);
256
+
257
+ // ----- the boundaries that must survive -----
258
+ assert.equal(invocationsFor(shaB), 1, 'the already completed SHA is not analysed a second time');
259
+ assert.equal(runsAfterLateCapture.filter(r => r.commitSha === shaB).length, 1, 'the already completed SHA has exactly one run');
260
+ assert.equal(invocationsFor(shaC), 0, 'C (never captured) is still not analysed - the journal-recovery boundary is unchanged');
261
+ assert.equal(runsAfterLateCapture.filter(r => r.commitSha === shaC).length, 0, 'C (never captured) still has no run');
262
+
263
+ saveEvidence(ARTIFACTS, `eng007r4-evidence-${targetLabel(engineIdentity)}.json`, evidence);
264
+
265
+ // ----- the decision: a captured commit must not be dropped -----
266
+ assert.equal(
267
+ evidence.phases.lateDelivery.runsForA, 1,
268
+ `A's boundary WAS captured (real CLI, ok) and consumed (cursor advanced), but the engine produced no run for it: the captured evidence was dropped. runs=${JSON.stringify(evidence.phases.lateDelivery.runOrder)}`,
269
+ );
270
+ assert.equal(runA.state, 'succeeded', `A's compensated run must succeed: ${JSON.stringify(runA.error)}`);
271
+ assert.equal(invocationsFor(shaA), 1, 'A is analysed exactly once (no duplicate paid call)');
272
+ assert.equal(fs.existsSync(ledgerPath(shaA)), true, 'A is recorded in the processing ledger');
273
+ assert.equal(fs.existsSync(knowledgeFileA), true, 'A reaches the knowledge tree');
274
+ assert.ok(compensationDiagnostic, 'the compensation is recorded as a diagnostic');
275
+ assert.equal(compensationDiagnostic.commitSha, shaA);
276
+
277
+ evidence.verdict = {
278
+ 'never captured (hook failure)': `UNCOVERED BY CONTRACT - A and C never reached the journal (0 boundary events on disk); the engine has no Git-history traversal (CommitScanner.scan/scanProject/applyScanResult are exported but never called from src/). Startup reconciliation is journal recovery only (README 触发面, README:119, src/coordinator.js consumeJournal, src/runtime/commit-reconciler.js:173).`,
279
+ 'captured but delivered after the analysed head moved past it': `COMPENSATED - A's real boundary event is captured and consumed and A is analysed exactly once, promoted to the knowledge tree and recorded in the processing ledger; a 'reconcile.missed_commit_compensated' diagnostic records the compensation.`,
280
+ 'completed SHA not re-run': 'PASS (B analysed exactly once, one run)',
281
+ 'never-captured SHA not analysed': 'PASS (C is still not analysed - the contract boundary is unchanged)',
282
+ 'analyser invocations': 'no duplicate paid call: exactly one invocation per analysed SHA',
283
+ analyzerStandin: 'deterministic stand-in - NO real model output covered; vector-hub real with deterministic test embeddings - the paid embedding API is NOT covered',
284
+ consequence: `lastAnalyzedCommit moved ${shaB.slice(0, 8)} -> ${String(lastAnalyzedAfterLateCapture).slice(0, 8)} (the compensated commit is older than the analysed head, so the single pointer regresses) and the chronological analysis order becomes ${evidence.phases.lateDelivery.analysisOrder.map(sha => sha.slice(0, 8)).join(' -> ')} (B first, then the compensated A), which deviates from README:95 ("同项目按提交顺序执行"). The run list itself is returned ordered by SHA, so the order above is read from the analyzer's append-only invocation log. Recorded as a consequence of the minimal fix, not as a test assertion.`,
285
+ };
286
+ saveEvidence(ARTIFACTS, `eng007r4-evidence-${targetLabel(engineIdentity)}.json`, evidence);
287
+
288
+ await engine.close();
289
+ await vector.close();
290
+ await bridge.close();
291
+ console.log(`ENG-007 R4 probe PASS (engine: ${engineIdentity.origin} ${engineIdentity.version})`);
292
+ process.exit(0);
293
+ } catch (error) {
294
+ evidence.verdict = { failed: String((error && error.stack) || error) };
295
+ try { await engine?.close(); } catch {}
296
+ try { await vector?.close(); } catch {}
297
+ try { await bridge.close(); } catch {}
298
+ saveEvidence(ARTIFACTS, `eng007r4-evidence-${targetLabel(engineIdentity)}.json`, evidence);
299
+ console.error(`ENG-007 R4 probe FAIL: ${error.message}`);
300
+ process.exit(1);
301
+ }
302
+ }
303
+
304
+ main();