@sanqianx/project-knowledge 5.0.30 → 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 +6 -6
  59. package/package.json +1 -1
  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,271 @@
1
+ 'use strict';
2
+ // _site/_test/parallel-memory-capture-r3-mem005-persistence-test.js
3
+ //
4
+ // MEM-005 忽略候选 — the persistence half that the frozen P-MEMORY-01 run
5
+ // never proved.
6
+ //
7
+ // What the frozen run (helpers/parallel-memory-shell.js +
8
+ // parallel-memory-candidate-test.js) already proved: the real UI really
9
+ // ignores a real candidate, the engine answers {status:'ignored'}, the record
10
+ // keeps its frozen source and an ignored memory is never injected.
11
+ //
12
+ // What was still missing: that the ignored state SURVIVES. The old run read
13
+ // the stored record through the API right after the click, i.e. from the
14
+ // same live process that had just answered the PATCH. Nothing proved that a
15
+ // later page load still shows the candidate as ignored and still finds the
16
+ // untouched frozen source.
17
+ //
18
+ // This case therefore:
19
+ // 1. produces a real candidate (real commit, real frozen event, the real
20
+ // engine admission, the lane stand-in analyzer for the model step only);
21
+ // 2. fingerprints the frozen source (promoted entry file bytes + Git tree
22
+ // + frozen event hash) BEFORE the ignore;
23
+ // 3. ignores it through the real UI with a real pointer click;
24
+ // 4. RELOADS the page in the real browser and RE-OPENS the memory view;
25
+ // 5. proves the UI no longer offers it as a candidate and never shows it
26
+ // as confirmed;
27
+ // 6. proves the engine still reports status 'ignored' — through the
28
+ // product's own endpoint, through the engine's own endpoint AND from
29
+ // the engine's persisted state file on disk;
30
+ // 7. proves the frozen source is byte-identical to the fingerprint taken
31
+ // before the ignore, and that the memory is still not injected.
32
+ //
33
+ // HONEST SCOPE LABEL: the analysis step is the frozen P-MEMORY-01 stand-in
34
+ // analyzer. This case is evidence about the engine's admission, the ignore
35
+ // action, the persistence of that state and the frozen source — never about
36
+ // the model's judgement.
37
+
38
+ const fs = require('node:fs');
39
+ const path = require('node:path');
40
+ const assert = require('node:assert/strict');
41
+
42
+ const { startHarness, makeRepo } = require('./helpers/parallel-memory-shell');
43
+ const r3 = require('./helpers/parallel-memory-capture-r3-shell');
44
+
45
+ const EVIDENCE = process.env.PK_TEST_EVIDENCE_DIR ? path.resolve(process.env.PK_TEST_EVIDENCE_DIR) : null;
46
+ const CANDIDATE_TEXT = 'R3 忽略持久性:对外错误信息使用中文表述,并优先复用已有模块。';
47
+ const REPO_NAME = 'mem005r3-repo';
48
+
49
+ async function openMemoryView(harness) {
50
+ await harness.nativeClick('nav [data-view="memory"]');
51
+ await harness.waitFor(
52
+ () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
53
+ 'the memory view is open',
54
+ 10000,
55
+ );
56
+ }
57
+
58
+ async function openCandidateBox(harness) {
59
+ await openMemoryView(harness);
60
+ await harness.nativeClick('[data-memory-tab="candidate"]');
61
+ await harness.waitFor(
62
+ () => harness.run("document.getElementById('memoryContent').textContent.length > 0"),
63
+ 'the candidate box is rendered',
64
+ 15000,
65
+ );
66
+ }
67
+
68
+ async function cardPresent(harness, memoryId) {
69
+ return harness.run(`Boolean(document.querySelector('[data-memory-card=${JSON.stringify(memoryId)}]'))`);
70
+ }
71
+
72
+ async function main() {
73
+ const harness = await startHarness({ tag: 'mem005r3', evidenceDir: EVIDENCE || undefined });
74
+ const evidence = [];
75
+ try {
76
+ const repo = makeRepo(harness.fixture, REPO_NAME, { 'README.md': '# R3 忽略持久性夹具\n' });
77
+ const { projectId, knowledgePath } = await harness.importProject(repo, 'R3忽略持久性');
78
+ await harness.requestRegistryRefresh();
79
+ await harness.waitFor(
80
+ () => harness.run("document.getElementById('homeContent').textContent.includes('R3忽略持久性')"),
81
+ 'the imported project is listed',
82
+ 20000,
83
+ );
84
+
85
+ // 1. A real candidate through the real pipeline.
86
+ const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT, scopeType: 'global' });
87
+ assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
88
+ const candidate = (await harness.productMemories()).find(memory => memory.text === CANDIDATE_TEXT);
89
+ assert.ok(candidate, 'the candidate really exists in the engine');
90
+ assert.equal(candidate.status, 'candidate', 'the automatic memory starts as a candidate');
91
+ assert.equal(candidate.evidence.commitSha, produced.commitSha, 'the frozen source names the real commit');
92
+
93
+ // 2. The frozen source, fingerprinted before anything is clicked.
94
+ const before = (() => {
95
+ const events = harness.engine.coordinator.conversations.readEvents(projectId);
96
+ return {
97
+ source: r3.sourceFingerprint({
98
+ knowledgePath,
99
+ entryId: candidate.evidence.entryId,
100
+ repoPath: repo.path,
101
+ commitSha: produced.commitSha,
102
+ eventId: candidate.sourceEventId,
103
+ events,
104
+ }),
105
+ memory: r3.memoryFrozenFields(candidate),
106
+ };
107
+ })();
108
+ assert.ok(before.source.entry.exists, 'the promoted entry file really exists on disk');
109
+ assert.ok(before.source.entry.sha256, 'the promoted entry file really has a hash');
110
+ assert.equal(before.source.git.commitExists, true, 'the frozen commit really exists in the Git fixture');
111
+ assert.ok(before.source.git.tree, 'the frozen commit really has a tree');
112
+ assert.ok(before.source.event, 'the frozen conversation event really exists');
113
+ assert.equal(before.source.event.contentHash, candidate.sourceHash, 'the frozen event hash matches the memory');
114
+
115
+ // 3. The real UI ignores the real candidate.
116
+ await harness.reload();
117
+ await openCandidateBox(harness);
118
+ await harness.waitFor(
119
+ () => harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
120
+ 'the candidate is listed in the candidate box',
121
+ 15000,
122
+ );
123
+ assert.equal(await cardPresent(harness, candidate.id), true, 'the candidate really has a card');
124
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r3-before-ignore.png'));
125
+
126
+ await harness.nativeClick(`[data-memory-action="ignore"][data-memory-id="${candidate.id}"]`);
127
+ await harness.waitFor(
128
+ () => harness.run(`!document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
129
+ 'the ignored candidate leaves the candidate box',
130
+ 15000,
131
+ );
132
+ const ignorePatch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${candidate.id}`)).pop();
133
+ assert.ok(ignorePatch, 'the shell really ignored the candidate');
134
+ assert.equal(ignorePatch.status, 200, `the ignore answers 200: ${JSON.stringify(ignorePatch.body)}`);
135
+ assert.deepEqual(ignorePatch.body, { status: 'ignored' }, 'the ignore only changes the status');
136
+ const ignoreBody = await harness.network.body(ignorePatch);
137
+ assert.equal(ignoreBody.memory.status, 'ignored', 'the ignored memory is ignored');
138
+
139
+ // 4. RELOAD the page in the real browser, then RE-OPEN the memory view.
140
+ await harness.reload();
141
+ await harness.waitFor(
142
+ () => harness.run("document.readyState === 'complete'"),
143
+ 'the reloaded page is complete',
144
+ 20000,
145
+ );
146
+ // Re-open the view the way a user does: leave the memory view and come
147
+ // back, so the check is not a stale render of the old view.
148
+ await harness.nativeClick('nav [data-view="home"]');
149
+ await harness.waitFor(
150
+ () => harness.run("document.getElementById('view-home').classList.contains('active')"),
151
+ 'the home view is open after the reload',
152
+ 10000,
153
+ );
154
+ await harness.nativeClick('nav [data-view="memory"]');
155
+ await harness.waitFor(
156
+ () => harness.run("document.getElementById('view-memory').classList.contains('active')"),
157
+ 'the memory view is re-opened after the reload',
158
+ 10000,
159
+ );
160
+ await harness.nativeClick('[data-memory-tab="candidate"]');
161
+ await harness.waitFor(
162
+ () => harness.run("document.getElementById('memoryContent').textContent.length > 0"),
163
+ 'the candidate box is rendered after the reload',
164
+ 15000,
165
+ );
166
+
167
+ // 5. The UI after the reload: the ignored candidate does not come back,
168
+ // and it is not presented as a confirmed memory either.
169
+ const afterReload = {
170
+ candidateCardPresent: await cardPresent(harness, candidate.id),
171
+ textInMemoryView: await harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
172
+ candidateCountBadge: await harness.run("document.getElementById('candidateCount').textContent"),
173
+ ignoreButtonPresent: await harness.run(`Boolean(document.querySelector('[data-memory-action="ignore"][data-memory-id=${JSON.stringify(candidate.id)}]'))`),
174
+ };
175
+ assert.equal(afterReload.candidateCardPresent, false, 'the ignored candidate has no card after the reload');
176
+ assert.equal(afterReload.textInMemoryView, false, 'the ignored candidate is not in the memory view after the reload');
177
+ assert.equal(String(afterReload.candidateCountBadge).trim(), '', 'the candidate counter is empty after the reload');
178
+ assert.equal(afterReload.ignoreButtonPresent, false, 'the ignored candidate offers no ignore button after the reload');
179
+
180
+ await harness.nativeClick('[data-memory-tab="confirmed"]');
181
+ await harness.waitFor(
182
+ () => harness.run("document.getElementById('memoryContent').textContent.length > 0 || document.querySelectorAll('[data-memory-card]').length === 0"),
183
+ 'the confirmed tab is rendered after the reload',
184
+ 15000,
185
+ );
186
+ const confirmedTab = {
187
+ cardPresent: await cardPresent(harness, candidate.id),
188
+ textPresent: await harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(CANDIDATE_TEXT)})`),
189
+ };
190
+ assert.equal(confirmedTab.cardPresent, false, 'the ignored candidate is not shown as a confirmed memory');
191
+ assert.equal(confirmedTab.textPresent, false, 'the ignored text is not shown in the confirmed tab');
192
+ if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem005-r3-after-reload.png'));
193
+
194
+ // 6. The engine state after the reload: through the product, through the
195
+ // engine itself and from the engine's own persisted state file.
196
+ const productView = (await harness.productMemories()).find(memory => memory.id === candidate.id);
197
+ assert.ok(productView, 'the ignored memory is still served by the product after the reload');
198
+ assert.equal(productView.status, 'ignored', 'the product still reports the ignored status after the reload');
199
+
200
+ const engineList = await harness.engineApi('GET', '/api/memories');
201
+ assert.equal(engineList.status, 200, `the engine memory list must be readable: ${JSON.stringify(engineList.body)}`);
202
+ const engineView = (engineList.body.memories || []).find(memory => memory.id === candidate.id);
203
+ assert.ok(engineView, 'the engine still knows the ignored memory after the reload');
204
+ assert.equal(engineView.status, 'ignored', 'the engine still reports the ignored status after the reload');
205
+
206
+ const onDisk = r3.engineStateOnDisk(harness.engine);
207
+ assert.equal(onDisk.exists, true, 'the engine really persisted a state file');
208
+ const diskView = onDisk.memories.find(memory => memory.id === candidate.id);
209
+ assert.ok(diskView, 'the ignored memory is really persisted in the engine state file');
210
+ assert.equal(diskView.status, 'ignored', 'the persisted record on disk carries the ignored status');
211
+
212
+ // 7. The frozen source is untouched by the ignore.
213
+ const after = (() => {
214
+ const events = harness.engine.coordinator.conversations.readEvents(projectId);
215
+ return {
216
+ source: r3.sourceFingerprint({
217
+ knowledgePath,
218
+ entryId: productView.evidence.entryId,
219
+ repoPath: repo.path,
220
+ commitSha: productView.evidence.commitSha,
221
+ eventId: productView.sourceEventId,
222
+ events,
223
+ }),
224
+ memory: r3.memoryFrozenFields(productView),
225
+ };
226
+ })();
227
+ const comparison = r3.compareFrozen(before, after);
228
+ assert.equal(comparison.identical, true, `the frozen source must not change: ${JSON.stringify(comparison.diffs)}`);
229
+ assert.equal(comparison.entrySha256Same, true, 'the promoted entry file is byte-identical after the ignore');
230
+ assert.equal(comparison.gitTreeSame, true, 'the frozen commit tree is unchanged after the ignore');
231
+ assert.equal(comparison.eventHashSame, true, 'the frozen event hash is unchanged after the ignore');
232
+ assert.equal(comparison.memoryFrozenFieldsSame, true, 'the frozen fields of the record are unchanged after the ignore');
233
+
234
+ // 8. Still not injected after the reload.
235
+ const injected = await harness.injectedMemories(projectId);
236
+ assert.ok(
237
+ !injected.some(entry => entry.memoryId === candidate.id),
238
+ `an ignored memory is still never injected: ${JSON.stringify(injected)}`,
239
+ );
240
+
241
+ assert.equal(harness.browser.exceptions.length, 0, `no uncaught product JavaScript exceptions: ${JSON.stringify(harness.browser.exceptions)}`);
242
+
243
+ evidence.push({
244
+ case: 'MEM-005-persistence',
245
+ run: { projectId, commitSha: produced.commitSha, memoryCapture: produced.capture, knowledgePath },
246
+ candidate: { id: candidate.id, statusBefore: 'candidate', statusAfter: productView.status },
247
+ ignoreRequest: { method: ignorePatch.method, url: ignorePatch.url.replace(harness.base, ''), status: ignorePatch.status, request: ignorePatch.body, response: ignoreBody },
248
+ uiAfterReload: { ...afterReload, confirmedTab, pageReloaded: true, viewReopenedAfterReload: true },
249
+ engineStateAfterReload: {
250
+ productEndpoint: { status: productView.status, id: productView.id },
251
+ engineEndpoint: { status: engineView.status, id: engineView.id },
252
+ engineStateFile: { file: onDisk.file, exists: onDisk.exists, sha256: onDisk.sha256, status: diskView.status },
253
+ },
254
+ frozenSource: { before: before.source, after: after.source, comparison },
255
+ injectedAfterReload: injected.map(entry => entry.memoryId),
256
+ provenance: r3.provenance(),
257
+ scopeLabel: 'honest: the analysis step is the frozen P-MEMORY-01 stand-in analyzer, not a model',
258
+ });
259
+
260
+ if (harness.evidence) {
261
+ fs.mkdirSync(harness.evidence, { recursive: true });
262
+ fs.writeFileSync(path.join(harness.evidence, 'mem005-r3-persistence.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
263
+ }
264
+
265
+ console.log('parallel-memory-capture-r3-mem005-persistence-test PASS (the ignored candidate survives a real page reload: the UI no longer offers it, the engine and its persisted state still report ignored, and the frozen source is byte-identical)');
266
+ } finally {
267
+ await harness.cleanup();
268
+ }
269
+ }
270
+
271
+ main().catch(error => { console.error(error.stack || error.message); process.exitCode = 1; });