@sanqianx/project-knowledge 5.0.30 → 5.0.32

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 (135) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +26 -0
  3. package/README.md +5 -2
  4. package/_site/_test/appearance-settings-test.js +148 -0
  5. package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
  6. package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
  7. package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
  8. package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
  9. package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
  10. package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
  11. package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
  12. package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
  13. package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
  14. package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
  15. package/_site/_test/helpers/parallel-engine-advanced-engine-child.js +1 -1
  16. package/_site/_test/helpers/parallel-engine-advanced-fault-writer.js +3 -3
  17. package/_site/_test/helpers/parallel-engine-advanced-harness.js +1 -1
  18. package/_site/_test/helpers/parallel-engine-advanced-standin-analyzer.js +1 -1
  19. package/_site/_test/helpers/parallel-engine-final-harness.js +2 -2
  20. package/_site/_test/helpers/parallel-engine-final-standin-analyzer.js +1 -1
  21. package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
  22. package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
  23. package/_site/_test/helpers/parallel-memory-analyzer.js +1 -1
  24. package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
  25. package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
  26. package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
  27. package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
  28. package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
  29. package/_site/_test/helpers/parallel-nav-shell.js +1 -1
  30. package/_site/_test/helpers/parallel-qa-engine-endpoint-guard.js +1 -1
  31. package/_site/_test/helpers/parallel-retrieval-followup-r2-shell.js +1 -1
  32. package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
  33. package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
  34. package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
  35. package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
  36. package/_site/_test/helpers/qa-r45-harness.js +94 -0
  37. package/_site/_test/helpers/qa-r48-env.js +64 -0
  38. package/_site/_test/helpers/qa-r51-env.cjs +77 -0
  39. package/_site/_test/helpers/qa-r91-harness.cjs +4 -1
  40. package/_site/_test/package-boundary-test.js +5 -0
  41. package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
  42. package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
  43. package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
  44. package/_site/_test/parallel-engine-advanced-eng011-ui-probe.js +1 -1
  45. package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
  46. package/_site/_test/parallel-knowledge-engine-test.js +3 -3
  47. package/_site/_test/parallel-knowledge-retrieval-test.js +2 -2
  48. package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
  49. package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
  50. package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
  51. package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
  52. package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
  53. package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
  54. package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
  55. package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
  56. package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
  57. package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
  58. package/_site/_test/parallel-memory-injection-probe.js +411 -0
  59. package/_site/_test/parallel-nav-isolation-test.js +1 -1
  60. package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +1 -1
  61. package/_site/_test/parallel-retrieval-followup-citation-test.js +2 -2
  62. package/_site/_test/parallel-retrieval-followup-corpus-test.js +1 -1
  63. package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
  64. package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
  65. package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
  66. package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
  67. package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
  68. package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
  69. package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
  70. package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
  71. package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
  72. package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
  73. package/_site/_test/t07d-git-rel-coverage-test.js +226 -0
  74. package/_site/_test/t07e-qta-coverage-test.js +195 -0
  75. package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
  76. package/_site/lib/module-bridge.js +2 -11
  77. package/_site/lib/server-app.js +11 -2
  78. package/_site/lib/settings-store.js +43 -1
  79. package/_site/scripts/install-module-candidates.js +1 -1
  80. package/_site/scripts/pack-module-candidates.js +2 -1
  81. package/_site/scripts/verify-module-runtime.js +17 -32
  82. package/_site/scripts/verify-product-runtime.js +7 -3
  83. package/docs/README.zh-CN.md +3 -1
  84. package/module-runtime-manifest.json +56 -6
  85. package/package.json +2 -4
  86. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  87. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  88. package/plugins/project-knowledge/.mcp.json +1 -1
  89. package/ui/index.html +18 -1
  90. package/ui/product.css +6 -2
  91. package/ui/product.js +86 -1
  92. package/_modules/knowledge-engine/README.md +0 -133
  93. package/_modules/knowledge-engine/package.json +0 -38
  94. package/_modules/knowledge-engine/src/analysis-contract.js +0 -35
  95. package/_modules/knowledge-engine/src/analysis-failures.js +0 -39
  96. package/_modules/knowledge-engine/src/analysis-output.js +0 -52
  97. package/_modules/knowledge-engine/src/analysis-worker.js +0 -58
  98. package/_modules/knowledge-engine/src/bin.js +0 -52
  99. package/_modules/knowledge-engine/src/bridge-client.js +0 -24
  100. package/_modules/knowledge-engine/src/context.js +0 -140
  101. package/_modules/knowledge-engine/src/coordinator.js +0 -376
  102. package/_modules/knowledge-engine/src/diagnostics.js +0 -37
  103. package/_modules/knowledge-engine/src/headless-analyzer.js +0 -66
  104. package/_modules/knowledge-engine/src/index-request.js +0 -49
  105. package/_modules/knowledge-engine/src/knowledge-targets.js +0 -46
  106. package/_modules/knowledge-engine/src/memories.js +0 -281
  107. package/_modules/knowledge-engine/src/memory-eligibility.js +0 -74
  108. package/_modules/knowledge-engine/src/retrieval-policy.json +0 -14
  109. package/_modules/knowledge-engine/src/retrieval-ranking.js +0 -153
  110. package/_modules/knowledge-engine/src/retrieval.js +0 -367
  111. package/_modules/knowledge-engine/src/runtime/README.md +0 -7
  112. package/_modules/knowledge-engine/src/runtime/atomic-file.js +0 -204
  113. package/_modules/knowledge-engine/src/runtime/automation-config.js +0 -140
  114. package/_modules/knowledge-engine/src/runtime/commit-conversation-binder.js +0 -250
  115. package/_modules/knowledge-engine/src/runtime/commit-processing-ledger.js +0 -26
  116. package/_modules/knowledge-engine/src/runtime/commit-prompt.js +0 -205
  117. package/_modules/knowledge-engine/src/runtime/commit-reconciler.js +0 -432
  118. package/_modules/knowledge-engine/src/runtime/content-hash.js +0 -4
  119. package/_modules/knowledge-engine/src/runtime/contracts.js +0 -282
  120. package/_modules/knowledge-engine/src/runtime/conversation-exclusions.js +0 -204
  121. package/_modules/knowledge-engine/src/runtime/conversation-store.js +0 -389
  122. package/_modules/knowledge-engine/src/runtime/evidence-bundle.js +0 -228
  123. package/_modules/knowledge-engine/src/runtime/git-runner.js +0 -62
  124. package/_modules/knowledge-engine/src/runtime/knowledge-promotion.js +0 -559
  125. package/_modules/knowledge-engine/src/runtime/knowledge-retrieval-service.js +0 -408
  126. package/_modules/knowledge-engine/src/runtime/layout.js +0 -46
  127. package/_modules/knowledge-engine/src/runtime/markdown-knowledge-indexer.js +0 -276
  128. package/_modules/knowledge-engine/src/runtime/scanner.js +0 -298
  129. package/_modules/knowledge-engine/src/server.js +0 -166
  130. package/_modules/knowledge-engine/src/store.js +0 -267
  131. package/_modules/knowledge-engine/ui/app.css +0 -172
  132. package/_modules/knowledge-engine/ui/app.js +0 -318
  133. package/_modules/knowledge-engine/ui/index.html +0 -95
  134. package/_site/scripts/vendor-modules.js +0 -49
  135. package/vendor-manifest.json +0 -55
@@ -0,0 +1,313 @@
1
+ 'use strict';
2
+ // WB-005 — 草稿与附件隔离(真实浏览器 / 真实 0.13.6 隔离宿主)。
3
+ //
4
+ // 本入口用真实 Chrome 打开模块自带的 agent-terminal UI(安装包内
5
+ // apps/agent-terminal),在隔离宿主上跑真实的草稿生命周期:
6
+ //
7
+ // * 两个项目 A / B,各自不同的草稿,通过产品自己的侧栏点击切换;
8
+ // * 同一项目内两个会话,各自不同的草稿,通过产品自己的会话行点击切换;
9
+ // * 真实浏览器刷新后草稿仍在(产品自己的浏览器存储);
10
+ // * 附件走产品自己的文件输入框,验证附件字节从不进入浏览器存储,
11
+ // 并且不跨项目 / 跨会话泄漏;
12
+ // * 只重启本用例自己的隔离宿主(同一端口、同一数据目录、同一浏览器
13
+ // profile),验证草稿与项目清单仍然成立。
14
+ //
15
+ // 全程只点产品自己的控件、只读产品自己的存储;不调用 store API 代替 UI
16
+ // 行为,不发送任何模型请求。
17
+ //
18
+ // 退出码:0 = 全部证明;3 = 诚实 BLOCKED;1 = 脚本错误。
19
+ const path = require('node:path');
20
+ const crypto = require('node:crypto');
21
+ const fixture = require('./helpers/parallel-workbench-fixture');
22
+ const harness = require('./helpers/parallel-workbench-runtime-harness');
23
+
24
+ const PROFILE_ID = String(process.env.PK_WB_MODEL_PROFILE || 'minimax');
25
+ const REQUESTED_MODEL = String(process.env.PK_WB_MODEL_ID || 'MiniMax-M3.1-Flash');
26
+
27
+ const results = [];
28
+ function record(caseId, status, detail) {
29
+ results.push({ caseId, status, detail });
30
+ console.log(`CASE ${caseId} ${status} ${JSON.stringify(detail)}`);
31
+ }
32
+ function assertTrue(condition, message) {
33
+ if (!condition) throw new Error(message);
34
+ }
35
+
36
+ (async () => {
37
+ const realProfilesBefore = fixture.digestDirectory(fixture.realWorkbenchProfileDir());
38
+ const host = await harness.startHost({ prefix: 'parallel-wb005' });
39
+ const identity = harness.moduleIdentity(host.moduleRoot);
40
+ let browser = null;
41
+ let outcome = null;
42
+
43
+ try {
44
+ const opened = await harness.openBrowser(host.base, host.layout);
45
+ browser = opened.browser;
46
+
47
+ const health = await harness.getJson(`${host.base}${harness.API_BASE}/health`);
48
+ const projectA = await harness.ensureProject(browser, path.join(host.layout.root, 'wb005-project-a'), { name: 'wb005-project-a' });
49
+ const projectB = await harness.ensureProject(browser, path.join(host.layout.root, 'wb005-project-b'), { name: 'wb005-project-b' });
50
+ record('WB-005.a-real-browser-and-host', health.ok && health.body && health.body.status === 'ok' ? 'PASS' : 'BLOCKED', {
51
+ browser: 'real Chrome via CDP (headless), isolated user-data-dir below the isolated layout',
52
+ chrome: opened.chrome,
53
+ module: identity,
54
+ host: { mode: 'standalone', dataDir: host.layout.dataDir, workspace: host.layout.workspace, port: host.port },
55
+ projects: [
56
+ { id: projectA.projectId, name: projectA.name, createdThroughTheProductForm: projectA.created === true },
57
+ { id: projectB.projectId, name: projectB.name, createdThroughTheProductForm: projectB.created === true },
58
+ ],
59
+ health: health.body,
60
+ });
61
+ assertTrue(health.ok && health.body && health.body.status === 'ok', 'the isolated host is not healthy');
62
+ assertTrue(projectA.projectId && projectB.projectId && projectA.projectId !== projectB.projectId, 'the two projects were not created through the product form');
63
+
64
+ // The profile is only selected so the product can create sessions; no
65
+ // message is ever sent, so no model request is made in this case.
66
+ const profiles = await harness.getJson(`${host.base}${harness.API_BASE}/profiles`);
67
+ const listed = Array.isArray(profiles.body && profiles.body.profiles) ? profiles.body.profiles : [];
68
+ const profile = listed.find(item => item.id === PROFILE_ID) || null;
69
+ assertTrue(profile, `the ${PROFILE_ID} profile is not visible through the read-only facade`);
70
+ await harness.selectModel(browser, profile.name, REQUESTED_MODEL);
71
+ const afterModel = await harness.readState(browser);
72
+
73
+ // --- project level drafts -------------------------------------------
74
+ const draftA = `WB005-PROJECT-A-${crypto.randomBytes(4).toString('hex')}`;
75
+ const draftB = `WB005-PROJECT-B-${crypto.randomBytes(4).toString('hex')}`;
76
+ await harness.selectProject(browser, projectA.projectId);
77
+ await harness.typeText(browser, draftA);
78
+ const typedInA = await harness.readState(browser);
79
+ assertTrue(typedInA.inputValue === draftA, 'project A did not keep the typed draft');
80
+ await harness.selectProject(browser, projectB.projectId);
81
+ const switchedToB = await harness.readState(browser);
82
+ await harness.typeText(browser, draftB);
83
+ await harness.selectProject(browser, projectA.projectId);
84
+ const backInA = await harness.readState(browser);
85
+ const projectIsolation = switchedToB.inputValue === ''
86
+ && backInA.inputValue === draftA
87
+ && !backInA.inputValue.includes(draftB);
88
+ record('WB-005.b-project-drafts-are-isolated', projectIsolation ? 'PASS' : 'BLOCKED', {
89
+ switch: 'the product\'s own sidebar project head (a real click on .proj-item)',
90
+ projectA: { id: projectA.projectId, draft: draftA, composerAfterSwitchBack: backInA.inputValue },
91
+ projectB: { id: projectB.projectId, draft: draftB, composerAfterSwitchIn: switchedToB.inputValue },
92
+ projectBDraftVisibleInProjectA: backInA.inputValue.includes(draftB),
93
+ composerShowedTheOtherProjectDraft: switchedToB.inputValue !== '',
94
+ });
95
+ assertTrue(projectIsolation, 'the project drafts were not isolated');
96
+
97
+ // --- session level drafts -------------------------------------------
98
+ const draftS1 = `WB005-SESSION-ONE-${crypto.randomBytes(4).toString('hex')}`;
99
+ const draftS2 = `WB005-SESSION-TWO-${crypto.randomBytes(4).toString('hex')}`;
100
+ await harness.clickNewSession(browser);
101
+ const firstSession = await harness.waitForState(browser, state => state.product && state.product.activeSessionId, 'the first session of project A', 30000);
102
+ const sessionS1 = firstSession.product.activeSessionId;
103
+ await harness.typeText(browser, draftS1);
104
+ await harness.clickNewSession(browser);
105
+ const secondSession = await harness.waitForState(browser, state => state.product && state.product.activeSessionId && state.product.activeSessionId !== sessionS1, 'the second session of project A', 30000);
106
+ const sessionS2 = secondSession.product.activeSessionId;
107
+ const inS2 = await harness.readState(browser);
108
+ await harness.typeText(browser, draftS2);
109
+ await harness.openSessionRow(browser, projectA.projectId, sessionS1);
110
+ const inS1 = await harness.readState(browser);
111
+ await harness.openSessionRow(browser, projectA.projectId, sessionS2);
112
+ const inS2Again = await harness.readState(browser);
113
+ const sessionIsolation = inS2.inputValue === ''
114
+ && inS1.inputValue === draftS1 && !inS1.inputValue.includes(draftS2)
115
+ && inS2Again.inputValue === draftS2 && !inS2Again.inputValue.includes(draftS1);
116
+ record('WB-005.c-session-drafts-are-isolated', sessionIsolation ? 'PASS' : 'BLOCKED', {
117
+ switch: 'the product\'s own sidebar session row (a real click on .session)',
118
+ projectId: projectA.projectId,
119
+ sessionOne: { sessionId: sessionS1, draft: draftS1, composer: inS1.inputValue },
120
+ sessionTwo: { sessionId: sessionS2, draft: draftS2, composerBeforeTyping: inS2.inputValue, composerAfterTyping: inS2Again.inputValue },
121
+ sessionOneDraftLeakedIntoSessionTwo: inS2.inputValue !== '',
122
+ sessionTwoDraftLeakedIntoSessionOne: inS1.inputValue.includes(draftS2),
123
+ });
124
+ assertTrue(sessionIsolation, 'the session drafts were not isolated');
125
+
126
+ // --- attachment lifecycle -------------------------------------------
127
+ const attachmentName = 'wb005-note.txt';
128
+ const attachmentToken = `WB005-ATTACHMENT-${crypto.randomBytes(4).toString('hex')}`;
129
+ const attachmentContent = `${attachmentToken}\nWB-005 attachment lifecycle\n`;
130
+ const attachmentBase64 = Buffer.from(attachmentContent, 'utf8').toString('base64');
131
+ await harness.openSessionRow(browser, projectA.projectId, sessionS1);
132
+ await harness.attachFile(browser, attachmentName, attachmentContent);
133
+ const withAttachment = await harness.readState(browser);
134
+ const storageWithAttachment = await harness.readDraftStorage(browser);
135
+ const bytesInStorage = storageWithAttachment.raw.includes(attachmentToken) || storageWithAttachment.raw.includes(attachmentBase64);
136
+ await harness.selectProject(browser, projectB.projectId);
137
+ const attachmentInB = await harness.readState(browser);
138
+ await harness.openSessionRow(browser, projectA.projectId, sessionS1);
139
+ const attachmentBackInA = await harness.readState(browser);
140
+ const attachmentOk = withAttachment.attachments.length === 1
141
+ && withAttachment.attachments[0].includes(attachmentName)
142
+ && withAttachment.product.attachmentCount === 1
143
+ && !bytesInStorage
144
+ && attachmentInB.attachments.length === 0
145
+ && attachmentInB.product.attachmentCount === 0
146
+ && attachmentBackInA.attachments.length === 1;
147
+ record('WB-005.d-attachment-lifecycle-and-isolation', attachmentOk ? 'PASS' : 'BLOCKED', {
148
+ attach: 'the product\'s own <input type="file"> change handler (a real File into the real input)',
149
+ file: attachmentName,
150
+ trayInSessionOne: withAttachment.attachments,
151
+ productAttachmentCountInSessionOne: withAttachment.product.attachmentCount,
152
+ trayInProjectB: attachmentInB.attachments,
153
+ productAttachmentCountInProjectB: attachmentInB.product.attachmentCount,
154
+ trayAfterReturningToSessionOne: attachmentBackInA.attachments,
155
+ attachmentBytesInBrowserStorage: bytesInStorage,
156
+ storageKey: storageWithAttachment.key,
157
+ storageEntryCount: storageWithAttachment.entryCount,
158
+ storageKeys: storageWithAttachment.keys,
159
+ contract: 'apps/agent-terminal/app.js writeDraft(): only the text goes to the browser storage, the attachment bytes stay in the page memory',
160
+ });
161
+ assertTrue(attachmentOk, 'the attachment lifecycle or its isolation is wrong');
162
+
163
+ // --- a real browser refresh -----------------------------------------
164
+ const storageBeforeRefresh = await harness.readDraftStorage(browser);
165
+ await harness.reloadPage(browser);
166
+ const reloaded = await harness.readState(browser);
167
+ await harness.openSessionRow(browser, projectA.projectId, sessionS1);
168
+ const afterRefreshS1 = await harness.readState(browser);
169
+ await harness.selectProject(browser, projectB.projectId);
170
+ const afterRefreshB = await harness.readState(browser);
171
+ const storageAfterRefresh = await harness.readDraftStorage(browser);
172
+ const refreshOk = afterRefreshS1.inputValue === draftS1
173
+ && afterRefreshB.inputValue === draftB
174
+ && afterRefreshS1.attachments.length === 0
175
+ && !storageAfterRefresh.raw.includes(attachmentToken)
176
+ && !storageAfterRefresh.raw.includes(attachmentBase64);
177
+ record('WB-005.e-drafts-survive-a-real-browser-refresh', refreshOk ? 'PASS' : 'BLOCKED', {
178
+ refresh: 'a real Page.reload of the real page in the real browser',
179
+ composerInSessionOneAfterRefresh: afterRefreshS1.inputValue,
180
+ composerInProjectBAfterRefresh: afterRefreshB.inputValue,
181
+ attachmentAfterRefresh: afterRefreshS1.attachments,
182
+ attachmentSurvivedTheRefresh: afterRefreshS1.attachments.length > 0,
183
+ storageEntryCountBefore: storageBeforeRefresh.entryCount,
184
+ storageEntryCountAfter: storageAfterRefresh.entryCount,
185
+ storageKeys: storageAfterRefresh.keys,
186
+ attachmentBytesInBrowserStorage: storageAfterRefresh.raw.includes(attachmentToken) || storageAfterRefresh.raw.includes(attachmentBase64),
187
+ pageBusyAfterReload: reloaded.busy,
188
+ });
189
+ assertTrue(refreshOk, 'the drafts did not survive the refresh, or the attachment bytes entered the storage');
190
+
191
+ // --- restart of this case\'s own host --------------------------------
192
+ const oldPid = host.child.child.pid;
193
+ const oldPort = host.port;
194
+ await harness.stopHost(host);
195
+ const exitInfo = await host.child.exited;
196
+ const oldHostGone = !harness.listProcesses().some(entry => entry.pid === oldPid);
197
+ const oldHostExited = Boolean(exitInfo) && oldHostGone;
198
+ const restarted = await harness.startHost({ layout: host.layout, port: oldPort });
199
+ const healthAfterRestart = await harness.getJson(`${restarted.base}${harness.API_BASE}/health`);
200
+ await harness.reloadPage(browser);
201
+ const afterRestart = await harness.readState(browser);
202
+ const projectsAfterRestart = await harness.readState(browser);
203
+ await harness.selectProject(browser, projectA.projectId);
204
+ const restartProjectA = await harness.readState(browser);
205
+ await harness.openSessionRow(browser, projectA.projectId, sessionS1);
206
+ const restartDraftS1 = await harness.readState(browser);
207
+ await harness.selectProject(browser, projectB.projectId);
208
+ const restartDraftB = await harness.readState(browser);
209
+ const restartOk = healthAfterRestart.ok && healthAfterRestart.body && healthAfterRestart.body.status === 'ok'
210
+ && oldHostExited
211
+ && restartDraftS1.inputValue === draftS1
212
+ && restartDraftB.inputValue === draftB
213
+ && projectsAfterRestart.product.projects.length === 2;
214
+ record('WB-005.f-own-host-restart-keeps-projects-and-drafts', restartOk ? 'PASS' : 'BLOCKED', {
215
+ restart: 'only this case\'s own isolated host child was stopped and restarted',
216
+ oldHostPid: oldPid,
217
+ oldHostExited: oldHostExited,
218
+ oldHostProcessStillListed: !oldHostGone,
219
+ newHostPid: restarted.child.child.pid,
220
+ portKept: oldPort,
221
+ healthAfterRestart: healthAfterRestart.body,
222
+ projectsAfterRestart: projectsAfterRestart.product.projects.map(project => ({ id: project.id, name: project.name })),
223
+ composerInProjectAAfterRestart: restartProjectA.inputValue,
224
+ projectAProjectLevelEntryNote: 'the project level entry of project A is the migration tombstone the product writes when the draft moved into the first session of that project (writeDraft(projectId, null, { text: \'\' }))',
225
+ composerInSessionOneAfterRestart: restartDraftS1.inputValue,
226
+ composerInProjectBAfterRestart: restartDraftB.inputValue,
227
+ browserProfile: opened.profileDir,
228
+ });
229
+ assertTrue(restartOk, 'the own-host restart did not preserve the projects and drafts');
230
+
231
+ // --- no model request was made in this case --------------------------
232
+ const events = await harness.recordedEvents(browser);
233
+ const modelEvents = events.filter(event => event.type === 'claude/result' || event.type === 'claude/init');
234
+ const noModelCall = modelEvents.length === 0;
235
+ record('WB-005.g-no-model-request-was-made', noModelCall ? 'PASS' : 'BLOCKED', {
236
+ recordedStreamEvents: events.map(event => event.type),
237
+ modelStreamEvents: modelEvents.map(event => event.type),
238
+ paidTurns: 0,
239
+ });
240
+ assertTrue(noModelCall, 'the draft case triggered a model request');
241
+
242
+ outcome = {
243
+ projectA: { id: projectA.projectId, name: projectA.name, draft: draftA },
244
+ projectB: { id: projectB.projectId, name: projectB.name, draft: draftB },
245
+ sessionOne: { id: sessionS1, draft: draftS1 },
246
+ sessionTwo: { id: sessionS2, draft: draftS2 },
247
+ attachment: { name: attachmentName, bytesInStorage: bytesInStorage, survivedRefresh: afterRefreshS1.attachments.length > 0 },
248
+ hostRestart: { pid: oldPid, port: oldPort, ok: restartOk },
249
+ paidTurns: 0,
250
+ };
251
+ } catch (error) {
252
+ record('WB-005.runtime', 'BLOCKED', { error: String(error && error.message ? error.message : error) });
253
+ } finally {
254
+ if (browser) { try { await browser.close(); } catch { /* the browser is disposable */ } }
255
+ if (host.child) { await harness.stopHost(host); }
256
+ }
257
+
258
+ const digestComparison = fixture.compareDigests(realProfilesBefore, fixture.digestDirectory(fixture.realWorkbenchProfileDir()));
259
+ record('WB-005.h-real-profiles-byte-identical', digestComparison.byteIdentical ? 'PASS' : 'FAIL', {
260
+ profileDir: fixture.realWorkbenchProfileDir(),
261
+ comparison: 'byte-level SHA256, computed in memory; digests never printed, logged or persisted',
262
+ fileCount: digestComparison.count,
263
+ changedFiles: digestComparison.changedFiles,
264
+ addedFiles: digestComparison.addedFiles,
265
+ removedFiles: digestComparison.removedFiles,
266
+ });
267
+
268
+ const essential = [
269
+ 'WB-005.a-real-browser-and-host',
270
+ 'WB-005.b-project-drafts-are-isolated',
271
+ 'WB-005.c-session-drafts-are-isolated',
272
+ 'WB-005.d-attachment-lifecycle-and-isolation',
273
+ 'WB-005.e-drafts-survive-a-real-browser-refresh',
274
+ 'WB-005.f-own-host-restart-keeps-projects-and-drafts',
275
+ 'WB-005.g-no-model-request-was-made',
276
+ 'WB-005.h-real-profiles-byte-identical',
277
+ ];
278
+ const proven = essential.every(id => (results.find(entry => entry.caseId === id) || {}).status === 'PASS');
279
+
280
+ const summary = {
281
+ lane: 'test-workbench-runtime',
282
+ file: 'parallel-workbench-runtime-wb005-drafts.js',
283
+ case: 'WB-005',
284
+ title: '草稿与附件隔离(真实浏览器 + 真实 UI 操作)',
285
+ module: identity,
286
+ host: { mode: 'standalone', engineUrlConfigured: false, dataDir: host.layout.dataDir, workspace: host.layout.workspace },
287
+ profile: { id: PROFILE_ID, source: 'original-subscription-store read-only, credential in memory only', credentialWrittenAnywhere: false },
288
+ uiActions: [
289
+ 'the product\'s own sidebar project head (.proj-item) to switch project',
290
+ 'the product\'s own sidebar session row (.session) to open a session',
291
+ 'the product\'s own "新会话" button to create a session',
292
+ 'the product\'s own <input type="file"> change handler to attach a file',
293
+ 'a real Page.reload of the real page',
294
+ ],
295
+ storeApiUsedAsUiSubstitute: false,
296
+ turn: outcome,
297
+ cases: results,
298
+ verdict: proven ? 'PASS (drafts and attachments are isolated across projects, sessions, refresh and an own-host restart)' : 'BLOCKED',
299
+ paidTurnsSent: 0,
300
+ quotaEndpointQueried: false,
301
+ networkUsed: false,
302
+ };
303
+
304
+ const evidenceTarget = process.env.PARALLEL_WORKBENCH_RUNTIME_EVIDENCE;
305
+ harness.writeEvidence(evidenceTarget, summary);
306
+ if (!proven) console.log(`SCENE KEPT ${host.layout.root}`);
307
+ else fixture.removeTree(host.layout.root);
308
+ console.log(`parallel-workbench-runtime-wb005-drafts verdict=${summary.verdict}`);
309
+ process.exitCode = proven ? 0 : 3;
310
+ })().catch(error => {
311
+ console.error(error);
312
+ process.exitCode = 1;
313
+ });
@@ -0,0 +1,321 @@
1
+ 'use strict';
2
+ // WB-008 — 中止隔离(真实浏览器 / 真实 0.13.6 隔离宿主 / 真实 MiniMax)。
3
+ //
4
+ // 本入口用真实 Chrome 打开模块自带的 agent-terminal UI(安装包内
5
+ // apps/agent-terminal),在隔离宿主上跑两个同时进行的真实会话 A / B:
6
+ //
7
+ // * A 与 B 都是真实模型请求,两个会话同时在跑;
8
+ // * 只通过产品自己的 UI 停止 B:切到 B,点发送按钮(忙碌时该按钮就是
9
+ // 产品自己的“停止”控件),不做任何绕过 UI 的中止调用;
10
+ // * 判定只看产品自身的事实:B 的流以 claude/aborted 结束且没有
11
+ // claaude/result、B 的 CLI 进程真的退出、A 的 CLI 进程还在、A 的流
12
+ // 在中止之后继续并且最后以 claude/result 正常完成。
13
+ //
14
+ // 进程普查只读,且只取本用例自己的宿主子进程子树;5757/5760 与任何
15
+ // 未知进程都不触碰。
16
+ //
17
+ // 退出码:0 = 全部证明;3 = 诚实 BLOCKED;1 = 脚本错误。
18
+ const path = require('node:path');
19
+ const crypto = require('node:crypto');
20
+ const fixture = require('./helpers/parallel-workbench-fixture');
21
+ const harness = require('./helpers/parallel-workbench-runtime-harness');
22
+
23
+ const PROFILE_ID = String(process.env.PK_WB_MODEL_PROFILE || 'minimax');
24
+ const REQUESTED_MODEL = String(process.env.PK_WB_MODEL_ID || 'MiniMax-M3.1-Flash');
25
+ const TURN_TIMEOUT_MS = Number(process.env.PK_WB_TURN_TIMEOUT_MS || 420000);
26
+
27
+ const results = [];
28
+ function record(caseId, status, detail) {
29
+ results.push({ caseId, status, detail });
30
+ console.log(`CASE ${caseId} ${status} ${JSON.stringify(detail)}`);
31
+ }
32
+ function assertTrue(condition, message) {
33
+ if (!condition) throw new Error(message);
34
+ }
35
+
36
+ // The runtime processes of THIS host child only.
37
+ function runtimeProcesses(hostPid) {
38
+ return harness.runtimeProcesses(hostPid);
39
+ }
40
+
41
+ async function waitForRuntimeProcesses(hostPid, minimum, timeoutMs) {
42
+ const deadline = Date.now() + timeoutMs;
43
+ let last = [];
44
+ while (Date.now() < deadline) {
45
+ last = runtimeProcesses(hostPid);
46
+ if (last.length >= minimum) return last;
47
+ await harness.wait(250);
48
+ }
49
+ return last;
50
+ }
51
+
52
+ (async () => {
53
+ const realProfilesBefore = fixture.digestDirectory(fixture.realWorkbenchProfileDir());
54
+ const host = await harness.startHost({ prefix: 'parallel-wb008' });
55
+ const identity = harness.moduleIdentity(host.moduleRoot);
56
+ const hostPid = host.child.child.pid;
57
+ let browser = null;
58
+ let outcome = null;
59
+
60
+ const tokenA = `WBRT-ABORT-A-${crypto.randomBytes(5).toString('hex')}`;
61
+ const tokenB = `WBRT-ABORT-B-${crypto.randomBytes(5).toString('hex')}`;
62
+ // A long answer keeps session A running while B is aborted.
63
+ const questionA = `这是 WB-008 中止隔离的真实抽测(第 1 问,会话 A)。请输出 400 行,每行形如 "行 0001 编号 xxxxx",最后一行原样包含标记 ${tokenA}。`;
64
+ const questionB = `这是 WB-008 中止隔离的真实抽测(第 2 问,会话 B)。请输出 200 行,每行形如 "行 0001 编号 xxxxx",最后一行原样包含标记 ${tokenB}。`;
65
+
66
+ const eventsA = [];
67
+ const eventsB = [];
68
+ let abortAt = null;
69
+
70
+ try {
71
+ const opened = await harness.openBrowser(host.base, host.layout);
72
+ browser = opened.browser;
73
+
74
+ const health = await harness.getJson(`${host.base}${harness.API_BASE}/health`);
75
+ const project = await harness.ensureProject(browser, path.join(host.layout.root, 'wb008-project'), { name: 'wb008-project' });
76
+ record('WB-008.a-real-browser-and-host', health.ok && health.body && health.body.status === 'ok' ? 'PASS' : 'BLOCKED', {
77
+ browser: 'real Chrome via CDP (headless), isolated user-data-dir below the isolated layout',
78
+ chrome: opened.chrome,
79
+ module: identity,
80
+ host: { mode: 'standalone', dataDir: host.layout.dataDir, workspace: host.layout.workspace, port: host.port, hostPid },
81
+ project: { id: project.projectId, name: project.name, createdThroughTheProductForm: project.created === true },
82
+ health: health.body,
83
+ });
84
+ assertTrue(health.ok && health.body && health.body.status === 'ok', 'the isolated host is not healthy');
85
+
86
+ const profiles = await harness.getJson(`${host.base}${harness.API_BASE}/profiles`);
87
+ const listed = Array.isArray(profiles.body && profiles.body.profiles) ? profiles.body.profiles : [];
88
+ const profile = listed.find(item => item.id === PROFILE_ID) || null;
89
+ assertTrue(profile, `the ${PROFILE_ID} profile is not visible through the read-only facade`);
90
+ await harness.selectModel(browser, profile.name, REQUESTED_MODEL);
91
+ const afterModel = await harness.readState(browser);
92
+ record('WB-008.b-model-selected-through-the-real-ui', afterModel.product.currentProfileId === PROFILE_ID && afterModel.product.currentModel === REQUESTED_MODEL ? 'PASS' : 'BLOCKED', {
93
+ profileId: PROFILE_ID,
94
+ profileName: profile.name,
95
+ requestedModel: REQUESTED_MODEL,
96
+ uiProfileId: afterModel.product.currentProfileId,
97
+ uiModel: afterModel.product.currentModel,
98
+ credentialConfigured: profile.credentialConfigured === true,
99
+ credentialWrittenAnywhere: false,
100
+ });
101
+ assertTrue(afterModel.product.currentProfileId === PROFILE_ID, 'the profile was not selected through the UI');
102
+
103
+ // --- session A ------------------------------------------------------
104
+ await harness.clickNewSession(browser);
105
+ const firstSession = await harness.waitForState(browser, state => state.product && state.product.activeSessionId, 'session A', 30000);
106
+ const sessionA = firstSession.product.activeSessionId;
107
+ const streamA = harness.consumeSessionEvents(
108
+ harness.sessionEventsUrl(host.base, sessionA),
109
+ event => eventsA.push(event),
110
+ event => event.type === 'claude/result' || event.type === 'claude/error',
111
+ TURN_TIMEOUT_MS,
112
+ );
113
+ await harness.typeText(browser, questionA);
114
+ await harness.clickSend(browser);
115
+ const aBusy = await harness.waitForState(browser, state => state.busy === true, 'session A to start', 90000);
116
+ const procsA = await waitForRuntimeProcesses(hostPid, 1, 90000);
117
+ record('WB-008.c-session-a-is-running', aBusy.busy === true && procsA.length >= 1 ? 'PASS' : 'BLOCKED', {
118
+ sessionId: sessionA,
119
+ uiSendTitleWhileBusy: aBusy.sendTitle,
120
+ uiSessionState: aBusy.product.sessionState,
121
+ runtimeProcessesOfThisHost: procsA,
122
+ tokenA,
123
+ });
124
+ assertTrue(procsA.length >= 1, 'session A has no runtime process');
125
+
126
+ // --- session B, started while A is still running --------------------
127
+ await harness.clickNewSession(browser);
128
+ const secondSession = await harness.waitForState(browser, state => state.product && state.product.activeSessionId && state.product.activeSessionId !== sessionA, 'session B', 30000);
129
+ const sessionB = secondSession.product.activeSessionId;
130
+ const streamB = harness.consumeSessionEvents(
131
+ harness.sessionEventsUrl(host.base, sessionB),
132
+ event => eventsB.push(event),
133
+ event => event.type === 'claude/result' || event.type === 'claude/aborted' || event.type === 'claude/error',
134
+ TURN_TIMEOUT_MS,
135
+ );
136
+ await harness.typeText(browser, questionB);
137
+ await harness.clickSend(browser);
138
+ const bBusy = await harness.waitForState(browser, state => state.busy === true, 'session B to start', 90000);
139
+ const procsB = await waitForRuntimeProcesses(hostPid, procsA.length + 1, 90000);
140
+ // The processes that were already running for A when B started are A's;
141
+ // the ones that appeared with B are B's. A short-lived helper of A may
142
+ // have exited on its own in between, so the mapping is the intersection
143
+ // and the difference, not the raw first census.
144
+ const aPids = procsA.filter(entry => procsB.some(other => other.pid === entry.pid)).map(entry => entry.pid);
145
+ const bPids = procsB.filter(entry => !procsA.some(other => other.pid === entry.pid)).map(entry => entry.pid);
146
+ const aStillRunning = aPids.length >= 1 && bPids.length >= 1;
147
+ record('WB-008.d-two-sessions-run-at-the-same-time', bBusy.busy === true && aStillRunning ? 'PASS' : 'BLOCKED', {
148
+ sessionA: { id: sessionA, runtimeProcesses: procsA.map(entry => ({ pid: entry.pid, name: entry.name, commandLine: entry.commandLine })) },
149
+ sessionB: { id: sessionB, runtimeProcesses: procsB.map(entry => ({ pid: entry.pid, name: entry.name, commandLine: entry.commandLine })) },
150
+ sessionAProcessPids: aPids,
151
+ sessionBProcessPids: bPids,
152
+ runtimeProcessesAddedForSessionB: bPids,
153
+ sessionAProcessStillAlive: aStillRunning,
154
+ uiSendTitleWhileBusy: bBusy.sendTitle,
155
+ });
156
+ assertTrue(aStillRunning, 'session A stopped running while session B started');
157
+
158
+ // --- abort B through the product's own stop control -----------------
159
+ await harness.openSessionRow(browser, project.projectId, sessionB);
160
+ const bBusyInUi = await harness.waitForState(browser, state => state.busy === true && state.product.activeSessionId === sessionB, 'session B to be busy in the UI', 30000);
161
+ const beforeAbort = runtimeProcesses(hostPid);
162
+ abortAt = Date.now();
163
+ await harness.clickSend(browser);
164
+ const bIdle = await harness.waitForState(browser, state => state.busy === false && state.product.activeSessionId === sessionB, 'session B to become idle after the stop', 60000);
165
+ await harness.wait(3000);
166
+ const afterAbort = runtimeProcesses(hostPid);
167
+ const afterPids = new Set(afterAbort.map(entry => entry.pid));
168
+ const exitedPids = beforeAbort.map(entry => entry.pid).filter(pid => !afterPids.has(pid));
169
+ const survivedA = aPids.filter(pid => afterPids.has(pid));
170
+ const bStillAlive = bPids.filter(pid => afterPids.has(pid));
171
+ const bAborted = eventsB.some(event => event.type === 'claude/aborted');
172
+ const bResulted = eventsB.some(event => event.type === 'claude/result');
173
+ const stopNoteInUi = bIdle.streamText.includes('已停止');
174
+ const abortOk = bAborted && !bResulted && exitedPids.length >= 1
175
+ && survivedA.length === aPids.length && survivedA.length >= 1
176
+ && bStillAlive.length === 0
177
+ && bIdle.busy === false;
178
+ record('WB-008.e-only-b-was-aborted', abortOk ? 'PASS' : 'BLOCKED', {
179
+ abortControl: 'the product\'s own send button, which the product itself turns into “停止” while the turn runs (btn-send.title === "停止")',
180
+ sendTitleWhileBusy: bBusyInUi.sendTitle,
181
+ sessionB: {
182
+ sessionId: sessionB,
183
+ abortedEvent: bAborted,
184
+ resultEvent: bResulted,
185
+ eventTypes: eventsB.map(event => event.type),
186
+ uiSendTitleAfterAbort: bIdle.sendTitle,
187
+ uiSessionStateAfterAbort: bIdle.product.sessionState,
188
+ stopNoteRenderedInTheTranscript: stopNoteInUi,
189
+ },
190
+ processCensus: {
191
+ scope: 'the descendants of this case\'s own host child only',
192
+ beforeAbort: beforeAbort.map(entry => ({ pid: entry.pid, name: entry.name, commandLine: entry.commandLine })),
193
+ afterAbort: afterAbort.map(entry => ({ pid: entry.pid, name: entry.name, commandLine: entry.commandLine })),
194
+ exitedPids,
195
+ sessionAPidsBeforeTheAbort: aPids,
196
+ sessionAPidsStillAlive: survivedA,
197
+ sessionBPidsBeforeTheAbort: bPids,
198
+ sessionBPidsStillAlive: bStillAlive,
199
+ },
200
+ });
201
+ assertTrue(abortOk, 'the abort did not isolate B');
202
+
203
+ // --- A keeps running and finishes on its own ------------------------
204
+ // The UI is put back onto A while A is still running, so the answer of A
205
+ // is observed in the product's own live rendering. The completion gate is
206
+ // the session's own result event, not the marker inside the answer.
207
+ await harness.openSessionRow(browser, project.projectId, sessionA);
208
+ await harness.waitUntil(() => eventsA.some(event => event.type === 'claude/result'), 'the result event of session A', TURN_TIMEOUT_MS, 500);
209
+ const aAnswerInUi = await harness.waitForState(
210
+ browser,
211
+ state => state.product && state.product.activeSessionId === sessionA && state.busy === false
212
+ && state.assistantMessages.some(text => text.includes(tokenA)),
213
+ 'the finished answer of session A in the UI',
214
+ 30000,
215
+ 200,
216
+ );
217
+ const aEventsAfterAbort = eventsA.filter(event => Date.parse(event.at) >= abortAt - 500);
218
+ const aResult = eventsA.find(event => event.type === 'claude/result') || null;
219
+ const aAnswer = aResult ? String(aResult.result || '') : '';
220
+ const aFinishedAfterAbort = aResult ? Date.parse(aResult.at) >= abortAt : false;
221
+ const aOk = aEventsAfterAbort.length > 0 && Boolean(aResult) && aFinishedAfterAbort
222
+ && aAnswer.includes(tokenA);
223
+ record('WB-008.f-session-a-kept-running-and-completed', aOk ? 'PASS' : 'BLOCKED', {
224
+ sessionA: {
225
+ sessionId: sessionA,
226
+ eventCount: eventsA.length,
227
+ eventsAfterTheAbortOfB: aEventsAfterAbort.length,
228
+ eventTypesAfterTheAbortOfB: [...new Set(aEventsAfterAbort.map(event => event.type))],
229
+ resultAt: aResult ? aResult.at : null,
230
+ finishedAfterTheAbortOfB: aFinishedAfterAbort,
231
+ tokenEchoedInTheAnswer: aAnswer.includes(tokenA),
232
+ answerPreview: aAnswer.slice(0, 120),
233
+ tokenEchoedInTheUi: aAnswerInUi.assistantMessages.some(text => text.includes(tokenA)),
234
+ uiSendTitleAfterTheAnswer: aAnswerInUi.sendTitle,
235
+ uiSessionStateAfterTheAnswer: aAnswerInUi.product.sessionState,
236
+ },
237
+ paidTurns: 2,
238
+ });
239
+ assertTrue(aOk, 'session A did not keep running after B was aborted');
240
+
241
+ // --- the UI shows both facts ----------------------------------------
242
+ // The reopened session renders its own history, so the transcript is
243
+ // waited for instead of being read in the middle of the replay.
244
+ await harness.openSessionRow(browser, project.projectId, sessionB);
245
+ const bView = await harness.waitForState(browser, state => state.streamText.includes('已停止'), 'the stopped note of session B in the reopened transcript', 30000, 200);
246
+ const bTranscriptStopped = bView.streamText.includes('已停止');
247
+ const bHasNoAnswer = !bView.assistantMessages.some(text => text.includes(tokenB));
248
+ await harness.openSessionRow(browser, project.projectId, sessionA);
249
+ const aView = await harness.waitForState(browser, state => state.assistantMessages.some(text => text.includes(tokenA)), 'the answer of session A in the reopened transcript', 30000, 200);
250
+ const aHasAnswer = aView.assistantMessages.some(text => text.includes(tokenA));
251
+ const uiOk = bTranscriptStopped && bHasNoAnswer && aHasAnswer;
252
+ record('WB-008.g-the-ui-shows-the-abort-of-b-and-the-answer-of-a', uiOk ? 'PASS' : 'BLOCKED', {
253
+ sessionB: { stoppedNoteInTheTranscript: bTranscriptStopped, answerWithTheTokenPresent: bView.assistantMessages.some(text => text.includes(tokenB)), assistantMessageCount: bView.assistantMessages.length },
254
+ sessionA: { answerWithTheTokenPresent: aHasAnswer, assistantMessageCount: aView.assistantMessages.length },
255
+ reopenedFrom: 'the product\'s own session history (the newest page of the session\'s own history file)',
256
+ });
257
+ assertTrue(uiOk, 'the UI does not show the abort of B and the answer of A');
258
+
259
+ outcome = {
260
+ sessionA: { id: sessionA, tokenA, answered: aAnswer.includes(tokenA), events: eventsA.length, eventsAfterTheAbortOfB: aEventsAfterAbort.length },
261
+ sessionB: { id: sessionB, tokenB, aborted: bAborted, result: bResulted, events: eventsB.length },
262
+ processCensus: { beforeAbort: beforeAbort.map(entry => entry.pid), afterAbort: afterAbort.map(entry => entry.pid), exitedPids },
263
+ paidTurns: 2,
264
+ };
265
+ } catch (error) {
266
+ record('WB-008.runtime', 'BLOCKED', { error: String(error && error.message ? error.message : error) });
267
+ } finally {
268
+ if (browser) { try { await browser.close(); } catch { /* the browser is disposable */ } }
269
+ if (host.child) { await harness.stopHost(host); }
270
+ }
271
+
272
+ const digestComparison = fixture.compareDigests(realProfilesBefore, fixture.digestDirectory(fixture.realWorkbenchProfileDir()));
273
+ record('WB-008.h-real-profiles-byte-identical', digestComparison.byteIdentical ? 'PASS' : 'FAIL', {
274
+ profileDir: fixture.realWorkbenchProfileDir(),
275
+ comparison: 'byte-level SHA256, computed in memory; digests never printed, logged or persisted',
276
+ fileCount: digestComparison.count,
277
+ changedFiles: digestComparison.changedFiles,
278
+ addedFiles: digestComparison.addedFiles,
279
+ removedFiles: digestComparison.removedFiles,
280
+ });
281
+
282
+ const essential = [
283
+ 'WB-008.a-real-browser-and-host',
284
+ 'WB-008.b-model-selected-through-the-real-ui',
285
+ 'WB-008.c-session-a-is-running',
286
+ 'WB-008.d-two-sessions-run-at-the-same-time',
287
+ 'WB-008.e-only-b-was-aborted',
288
+ 'WB-008.f-session-a-kept-running-and-completed',
289
+ 'WB-008.g-the-ui-shows-the-abort-of-b-and-the-answer-of-a',
290
+ 'WB-008.h-real-profiles-byte-identical',
291
+ ];
292
+ const proven = essential.every(id => (results.find(entry => entry.caseId === id) || {}).status === 'PASS');
293
+
294
+ const summary = {
295
+ lane: 'test-workbench-runtime',
296
+ file: 'parallel-workbench-runtime-wb008-abort.js',
297
+ case: 'WB-008',
298
+ title: '中止隔离(真实浏览器 + 真实模型 + 真实进程退出证明)',
299
+ module: identity,
300
+ host: { mode: 'standalone', engineUrlConfigured: false, dataDir: host.layout.dataDir, workspace: host.layout.workspace, hostPid },
301
+ profile: { id: PROFILE_ID, source: 'original-subscription-store read-only, credential in memory only', credentialWrittenAnywhere: false },
302
+ abortControl: 'the product\'s own send button in its own busy state (停止) — no out-of-band abort call',
303
+ processCensusScope: 'the descendants of this case\'s own host child only; 5757/5760 and every unknown process are never enumerated, signalled or stopped',
304
+ turn: outcome,
305
+ cases: results,
306
+ verdict: proven ? 'PASS (only B was aborted and terminated, A kept running and completed)' : 'BLOCKED',
307
+ paidTurnsSent: outcome ? outcome.paidTurns : 0,
308
+ quotaEndpointQueried: false,
309
+ networkUsed: true,
310
+ };
311
+
312
+ const evidenceTarget = process.env.PARALLEL_WORKBENCH_RUNTIME_EVIDENCE;
313
+ harness.writeEvidence(evidenceTarget, summary);
314
+ if (!proven) console.log(`SCENE KEPT ${host.layout.root}`);
315
+ else fixture.removeTree(host.layout.root);
316
+ console.log(`parallel-workbench-runtime-wb008-abort verdict=${summary.verdict}`);
317
+ process.exitCode = proven ? 0 : 3;
318
+ })().catch(error => {
319
+ console.error(error);
320
+ process.exitCode = 1;
321
+ });