@sanqianx/project-knowledge 5.2.0 → 5.3.0

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 (33) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +4 -0
  3. package/README.md +6 -0
  4. package/_site/_test/automatic-context-test.js +6 -0
  5. package/_site/_test/context-session-index-test.js +19 -9
  6. package/_site/_test/helpers/parallel-memory-shell.js +15 -7
  7. package/_site/_test/helpers/parallel-qa-engine-endpoint-isolate.js +3 -1
  8. package/_site/_test/memory-groups-ui-test.js +27 -3
  9. package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +2 -2
  10. package/_site/_test/parallel-engine-final-eng012-test.js +4 -4
  11. package/_site/_test/parallel-memory-candidate-test.js +7 -5
  12. package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +1 -1
  13. package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +2 -2
  14. package/_site/_test/parallel-memory-home-review-test.js +1 -1
  15. package/_site/_test/parallel-memory-manual-test.js +14 -25
  16. package/_site/_test/parallel-memory-scope-test.js +66 -264
  17. package/_site/_test/parallel-memory-source-test.js +5 -7
  18. package/_site/_test/parallel-memory-sync-test.js +8 -8
  19. package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +4 -2
  20. package/_site/_test/project-team-ui-test.js +54 -46
  21. package/_site/_test/shared-scope-root-binding-test.js +7 -6
  22. package/_site/_test/t07f-mem-008-coverage-test.js +0 -1
  23. package/_site/lib/engine-connection.js +2 -2
  24. package/_site/lib/engine-knowledge-client.js +1 -1
  25. package/_site/scripts/verify-retrieval-gold.js +10 -13
  26. package/module-runtime-manifest.json +26 -25
  27. package/package.json +3 -3
  28. package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
  29. package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
  30. package/plugins/project-knowledge/.mcp.json +1 -1
  31. package/plugins/project-knowledge/scripts/context-hook.cjs +3 -3
  32. package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +5 -6
  33. package/ui/product.js +147 -65
@@ -9,7 +9,7 @@
9
9
  "plugins": [
10
10
  {
11
11
  "name": "project-knowledge",
12
- "version": "5.2.0",
12
+ "version": "5.3.0",
13
13
  "source": "./plugins/project-knowledge",
14
14
  "description": "Search durable project decisions and implementation history through MCP."
15
15
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.1] - 2026-11-22
4
+
5
+ - 工作流模块升级至 `0.2.1`。AI 团队页按新交互设计重构:任务工作台(列表搜索、团队计划的依赖工作项与真实成员、最新意见在前代码审查、验收依据含工具版本/命令摘要/退出码/快照与收据时效)、团队设置(真实配置编辑带版本冲突保护)与只读接入诊断;全部数据来自服务端,无示例内容。程序收据新增脱敏命令摘要;能力声明如实标记审查编排可用。
6
+
3
7
  ## [5.2.0] - 2026-11-21
4
8
 
5
9
  - 工作流模块升级至 `0.2.0`。任务创建在事务内绑定受信 Git 根(同名仓与目录不符直接拒绝,未绑定任务在检查启动前失败);CLI 修复二次监听崩溃。
package/README.md CHANGED
@@ -192,6 +192,12 @@ local legacy read contract. Use `--scope domain` or `--scope brain` to broaden
192
192
  CLI searches; MCP accepts the equivalent `scope`. Shared-file reads accept
193
193
  `--space <spaceId>` (MCP: `space` or `spaceId`).
194
194
 
195
+ ## Long-term memory
196
+
197
+ A confirmed memory is stored once in the engine state and can belong to several combinations. A combination applies to the projects you bind to it. Unassigned memories stay in the library. Review candidates with their original evidence before assigning them to a combination.
198
+
199
+ Upgrading to 5.3 migrates old confirmed scopes into combinations for their existing projects. Existing combinations, memory IDs, bodies and candidate evidence are kept. The engine backs up its state before migration. Readable group Markdown is generated under the brain's shared knowledge directory at `memories/groups/<group-id>.md`. Export a project's effective memories as `MEMORY.md` from its detail page.
200
+
195
201
  ## Storage
196
202
 
197
203
  Version 5 is a fresh start, not a data upgrade. Stop the previous process,
@@ -44,6 +44,12 @@ async function main() {
44
44
  assert.equal(indexed.receipt.injectionKind, 'index'); assert.equal(indexed.receipt.sessionIndexedCount, 7);
45
45
  await writeOutput(indexed, { write: (text, callback) => callback() });
46
46
  assert.ok(fs.readFileSync(path.join(logDir, fs.readdirSync(logDir)[0]), 'utf8').includes('"injectionKind":"index"'), 'the receipt log carries the injection kind');
47
+ const evidence = await run(payload, { env, fetchImpl: engineResponse({ status: 'ready', injectionKind: 'evidence', prompt: '<knowledge_context>source excerpt 37</knowledge_context>', facts: [{ text: 'source excerpt 37' }], memories: [], references: [{}] }) });
48
+ assert.match(evidence.hookSpecificOutput.additionalContext, /source excerpt 37/);
49
+ assert.equal(evidence.receipt.injectionKind, 'evidence'); assert.equal(evidence.receipt.evidenceCount, 1);
50
+ await writeOutput(evidence, { write: (text, callback) => callback() });
51
+ const evidenceLog = fs.readFileSync(path.join(logDir, fs.readdirSync(logDir)[0]), 'utf8');
52
+ assert.match(evidenceLog, /"evidenceCount":1/); assert.doesNotMatch(evidenceLog, /source excerpt 37/);
47
53
  const oversized = await run(payload, { env, fetchImpl: engineResponse({ status: 'ready', prompt: 'x'.repeat(8001), facts: [], memories: [], references: [] }) });
48
54
  assert.match(oversized.systemMessage, /CONTEXT_INVALID_RESPONSE/);
49
55
  calls.length = 0;
@@ -159,8 +159,8 @@ async function main() {
159
159
  fs.writeFileSync(path.join(knowledgeC, 'modules', 'rpc.md'), '# RpcTransportSDK lane 轮转规则\n\n恢复导出配置的九步流程与并发调度。KB-INDEX-SECRET-D\n');
160
160
  fs.writeFileSync(path.join(knowledgeC, 'changes', 'extrapolation.md'), '# 外推算法九步流程\n\n外推算法按九步执行并记录证据。KB-INDEX-SECRET-E\n');
161
161
 
162
- // 1. The first turn injects the index once: statement block, no body text.
163
- const first = await context('开始设计记忆系统的注入机制', 'sess-main');
162
+ // 问候只需首轮索引。 / A greeting needs only the opening index.
163
+ const first = await context('你好', 'sess-main');
164
164
  assert.equal(first.status, 'ready'); assert.equal(first.injectionKind, 'index');
165
165
  assert.equal(first.rankingVersion, 'project-knowledge/ranking-v3');
166
166
  assert.ok(first.facts.some(item => item.entryId === 'modules/context.md' && item.role === '本项目事实'), 'the index lists the memory-system module');
@@ -170,7 +170,7 @@ async function main() {
170
170
  assert.ok(first.prompt.length <= 3000, `index stays compact, got ${first.prompt.length}`);
171
171
  assert.ok(first.sessionIndexedCount >= 2, 'the session registry counts its titles');
172
172
  for (const secret of ['KB-INDEX-SECRET-A', 'KB-INDEX-SECRET-B', 'KB-INDEX-SECRET-C', 'KB-INDEX-SECRET-D', 'KB-INDEX-SECRET-E']) {
173
- assert.ok(!first.prompt.includes(secret), 'no knowledge body ever enters the injection layer');
173
+ assert.ok(!first.prompt.includes(secret), 'a greeting does not recall excerpts');
174
174
  }
175
175
 
176
176
  // 2. A later turn without changes or strong matches is fully silent. With
@@ -189,20 +189,30 @@ async function main() {
189
189
  const decoyTurn = await context(decoyQuery, 'sess-main');
190
190
  assert.equal(decoyTurn.prompt, '', 'a boundary-bigram collision never becomes a breadcrumb');
191
191
 
192
- // 4. A real word match earns a one-line breadcrumb, then cools down.
192
+ // 强命中只显示一次,兼容已发布的标题提示。 / A strong hit is sent once, including on released title-only engines.
193
193
  const strongQuery = '记忆注入机制是怎么设计的';
194
194
  const crumb = await context(strongQuery, 'sess-main');
195
- assert.equal(crumb.injectionKind, 'breadcrumb');
196
- assert.ok(crumb.facts.some(item => item.entryId === 'modules/context.md'), 'the breadcrumb points at the matching entry');
195
+ assert.ok(['evidence', 'breadcrumb'].includes(crumb.injectionKind));
196
+ assert.ok(crumb.facts.some(item => item.entryId === 'modules/context.md'), 'the response points at the matching entry');
197
197
  assert.ok(!crumb.facts.some(item => String(item.entryId).includes('rpc') || String(item.entryId).includes('extrapolation')), 'the decoys never appear');
198
- assert.ok(crumb.prompt.includes('modules/context.md')); assert.ok(!crumb.prompt.includes('KB-INDEX-SECRET-B'));
198
+ assert.ok(crumb.prompt.includes('modules/context.md'));
199
+ const hasEvidence = crumb.injectionKind === 'evidence';
200
+ assert.equal(crumb.prompt.includes('KB-INDEX-SECRET-B'), hasEvidence);
201
+ if (hasEvidence) {
202
+ const firstTask = await context(strongQuery, 'sess-first-task');
203
+ assert.equal(firstTask.injectionKind, 'index');
204
+ assert.ok(firstTask.facts.some(item => item.entryId === 'modules/context.md' && item.text?.includes('KB-INDEX-SECRET-B')));
205
+ }
199
206
  assert.ok(!crumb.prompt.includes('当前生效的已确认记忆只来自'), 'deltas never repeat the statement block');
200
207
  assert.equal((await context(strongQuery, 'sess-main')).prompt, '', 'the same entry is on cooldown');
201
208
 
202
209
  // 5. A memory added mid-session is re-sent in full exactly once.
203
210
  const brainScope = (await engineApi('GET', '/api/snapshot?summary=1&limit=1')).body.sharedScopes.find(scope => scope.kind === 'brain');
204
211
  assert.ok(brainScope, 'the brain scope exists');
205
- const created = await engineApi('POST', '/api/memories', { text: '本仓库必须保持中文提交信息', scopeType: 'project', scopeId: projectA, brainId: brainScope.brainId });
212
+ const group = (await engineApi('POST', '/api/memory-groups', { name: '提交约定' })).body.group;
213
+ assert.ok(group);
214
+ assert.equal((await engineApi('POST', `/api/memory-groups/${group.id}/project-bindings`, { addProjectIds: [projectA] })).status, 200);
215
+ const created = await engineApi('POST', '/api/memories', { text: '本仓库必须保持中文提交信息', groupId: group.id, brainId: brainScope.brainId });
206
216
  assert.equal(created.status, 200, JSON.stringify(created.body));
207
217
  const memoryId = created.body.memory.id;
208
218
  const memoryTurn = await context('继续做别的', 'sess-main');
@@ -227,7 +237,7 @@ async function main() {
227
237
  const result = await context(query, 'sess-30');
228
238
  cumulative += (result.prompt || '').length;
229
239
  assert.ok((result.prompt || '').length <= 8000, 'the hard contract never breaks');
230
- assert.ok(!(result.prompt || '').includes('KB-INDEX-SECRET-'), 'no turn ever leaks a body');
240
+ assert.doesNotMatch(result.prompt || '', /KB-INDEX-SECRET-[DE]/, 'unrelated entries stay outside the prompt');
231
241
  }
232
242
  assert.ok(cumulative <= 10240, `30 turns inject at most 10KB in total, got ${cumulative}`);
233
243
 
@@ -35,7 +35,7 @@ const { applyDriverIsolation } = require('./parallel-qa-engine-endpoint-isolate'
35
35
  const { guardedCreateEngineServer, createEngineVectorStandin } = require('./parallel-qa-engine-endpoint-guard');
36
36
 
37
37
  const ROOT = path.resolve(__dirname, '../../..');
38
- const LIVE_PORTS = new Set([5757, 5790, 8787, 8790]);
38
+ const LIVE_PORTS = new Set([5757, 5760, 5790, 5810, 8787, 8790]);
39
39
 
40
40
  function git(cwd, args) {
41
41
  const result = spawnSync('git', ['-C', cwd, ...args], { encoding: 'utf8', windowsHide: true, env: { ...process.env, GIT_TERMINAL_PROMPT: '0' } });
@@ -361,6 +361,15 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
361
361
  return snapshot.body.memories || [];
362
362
  };
363
363
 
364
+ const addGroup = async (name, projectIds) => {
365
+ const created = await engineApi('POST', '/api/memory-groups', { name });
366
+ assert.equal(created.status, 200, JSON.stringify(created.body));
367
+ const { group } = created.body;
368
+ const binding = await engineApi('POST', `/api/memory-groups/${group.id}/project-bindings`, { addProjectIds: projectIds });
369
+ assert.equal(binding.status, 200, JSON.stringify(binding.body));
370
+ return group;
371
+ };
372
+
364
373
  /** The memories the engine would inject into a task for one project. */
365
374
  const injectedMemories = async projectId => {
366
375
  const context = await engineApi('POST', '/api/context', { projectId, query: '长期记忆', task: 'memory-lane' });
@@ -373,17 +382,16 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
373
382
  * quotes the real human event, the quote contains the memory text, and it
374
383
  * declares why the text is a durable, cross-project owner preference.
375
384
  */
376
- const memoryCandidate = ({ text, event, scopeType = 'global' }) => ({
385
+ const memoryCandidate = ({ text, event }) => ({
377
386
  text,
378
387
  quote: text,
379
- scopeType,
380
388
  sourceEventId: event.eventId,
381
389
  sourceHash: event.contentHash,
382
390
  eligibility: {
383
391
  durable: true,
384
392
  crossProject: true,
385
393
  reason: '人工明确表达的长期偏好',
386
- scopeReason: scopeType === 'global' ? '适用于所有领域与项目' : '适用于指定领域',
394
+ scopeReason: '跨项目可复用的约定',
387
395
  },
388
396
  });
389
397
 
@@ -392,7 +400,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
392
400
  * conversation event bound to it, the stand-in analyzer's manifest and the
393
401
  * engine's own promotion and capture.
394
402
  */
395
- const produceCandidate = async ({ repo, projectId, text, scopeType = 'global', inputOrigin = 'human', file = 'src/candidate.js' }) => {
403
+ const produceCandidate = async ({ repo, projectId, text, inputOrigin = 'human', file = 'src/candidate.js' }) => {
396
404
  const head = commitFile(repo, file, `// ${text}\n`, 'candidate commit');
397
405
  const event = await ingestUserEvent({
398
406
  projectId,
@@ -401,7 +409,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
401
409
  inputOrigin,
402
410
  });
403
411
  plan.document = `# 冻结证据\n\n${text}\n`;
404
- plan.memoryCandidates = [memoryCandidate({ text, event, scopeType })];
412
+ plan.memoryCandidates = [memoryCandidate({ text, event })];
405
413
  const run = await triggerRun(projectId, head);
406
414
  return { run, event, commitSha: head, capture: run.memoryCapture };
407
415
  };
@@ -473,7 +481,7 @@ async function startHarness({ tag, evidenceDir, viewport = { width: 1600, height
473
481
  nativeClick, pressKey, pressTab, pressEnter, typeText,
474
482
  importProject, addDomain, ingestUserEvent, triggerRun,
475
483
  brainScopePath, domainScopePath, productMemories, injectedMemories,
476
- memoryCandidate, produceCandidate,
484
+ addGroup, memoryCandidate, produceCandidate,
477
485
  cleanup,
478
486
  };
479
487
  }
@@ -45,7 +45,7 @@ const os = require('node:os');
45
45
  const path = require('node:path');
46
46
 
47
47
  const REPO_ROOT = path.resolve(__dirname, '..', '..', '..');
48
- const PROTECTED_PORTS = new Set([5757, 5760, 5789, 5790, 8787, 8790]);
48
+ const PROTECTED_PORTS = new Set([5757, 5760, 5789, 5790, 5810, 8787, 8790]);
49
49
 
50
50
  // Captured at module load, before any isolation rebuilds the environment.
51
51
  const LIVE_HOME = process.env.USERPROFILE || process.env.HOME || os.homedir();
@@ -194,6 +194,8 @@ function applyDriverIsolation({ prefix = 'pk-qa-engine-endpoint', captureChrome
194
194
 
195
195
  const parsed = path.parse(layout.home);
196
196
  const envMap = {
197
+ // Chromium 使用 locale 编码下载文件名。 / Chromium uses the locale for download filenames.
198
+ ...(process.platform === 'linux' ? { LANG: 'C.UTF-8' } : {}),
197
199
  HOME: layout.home,
198
200
  USERPROFILE: layout.home,
199
201
  HOMEDRIVE: parsed.root,
@@ -51,7 +51,7 @@ async function main() {
51
51
  await harness.browser.send('Input.insertText', { text: '开发时保护日常服务' });
52
52
  await harness.nativeClick('#memoryForm textarea[name=text]');
53
53
  await harness.browser.send('Input.insertText', { text: MULTILINE_BODY });
54
- // 默认 scopeType=group;选择加入「通用约定」
54
+ assert.equal(await harness.run("Boolean(document.querySelector('#memoryForm [name=scopeType], #memoryForm [name=scopeTarget]'))"), false);
55
55
  await harness.run("(() => { const sel = document.getElementById('memoryForm').elements.groupId; sel.value = [...sel.options].find(o => o.text.includes('通用约定'))?.value || ''; return sel.value !== ''; })()");
56
56
  await harness.nativeClick('#appDialogActions button.primary');
57
57
  await harness.waitFor(() => harness.run("document.getElementById('appDialog').open === false"), 'the memory editor closes');
@@ -124,7 +124,7 @@ async function main() {
124
124
  await harness.waitFor(() => harness.run("[...document.querySelectorAll('.memory-folders button')].some(b => b.textContent.includes('通用约定')) && [...document.querySelectorAll('.memory-item')].some(el => el.textContent.includes('开发时保护日常服务'))"), 'the group and its memory survive a reload');
125
125
 
126
126
  // ---------- 7. 候选审核:确认并加入组合 ----------
127
- await harness.produceCandidate({ repo: repoA, projectId: projectIdA, text: '界面变更先给可点击的预览,确认流程后再实施。', scopeType: 'global' });
127
+ await harness.produceCandidate({ repo: repoA, projectId: projectIdA, text: '界面变更先给可点击的预览,确认流程后再实施。' });
128
128
  await harness.nativeClick('nav [data-view="home"]');
129
129
  await harness.waitFor(() => harness.run("document.getElementById('homeContent').textContent.includes('待确认记忆') && document.getElementById('homeCount') !== null"), 'the home overview renders');
130
130
  await harness.waitFor(() => harness.run("document.body.textContent.includes('界面变更先给可点击的预览')"), 'the candidate preview shows on home');
@@ -134,7 +134,31 @@ async function main() {
134
134
  await harness.nativeClick('#appDialogActions button.primary');
135
135
  await harness.waitFor(() => harness.run("document.getElementById('appDialog').open === false"), 'the review dialog closes');
136
136
  const confirmed = (await harness.engineApi('GET', `/api/memories?status=confirmed&groupId=${group.id}&limit=10`)).body;
137
- assert.ok(confirmed.memories.some(m => m.text.includes('可点击的预览')), 'the confirmed candidate joined the group');
137
+ assert.ok(confirmed.memories.some(m => m.text.includes('可点击的预览') && m.scopeType === 'group'), 'the confirmed candidate activates through its group');
138
+
139
+ await harness.produceCandidate({ repo: repoB, projectId: projectIdB, text: '验收包必须包含独立的操作清单。' });
140
+ await harness.nativeClick('nav [data-view="memory"]');
141
+ await harness.nativeClick('[data-memory-tab="candidate"]');
142
+ await harness.selectOption('#candidateProjectFilter', projectIdB);
143
+ await harness.waitFor(() => harness.run("document.getElementById('memoryContent').textContent.includes('独立的操作清单')"), 'the candidate filter selects by source project before it is assigned to a group');
144
+ await harness.selectOption('#candidateProjectFilter', projectIdA);
145
+ await harness.waitFor(() => harness.run("!document.getElementById('memoryContent').textContent.includes('独立的操作清单')"), 'another project does not show this candidate');
146
+
147
+ const downloadDir = path.join(harness.fixture, 'downloads');
148
+ fs.mkdirSync(downloadDir);
149
+ await harness.browser.send('Page.setDownloadBehavior', { behavior: 'allow', downloadPath: downloadDir });
150
+ await harness.nativeClick('nav [data-view="projects"]');
151
+ await harness.nativeClick(`[data-action="project-detail"][data-id="${projectIdA}"]`);
152
+ await harness.waitFor(() => harness.run("Boolean(document.querySelector('[data-action=export-memories]:not([disabled])'))"), 'the effective memory page enables its export control');
153
+ await harness.nativeClick('[data-action="export-memories"]:not([disabled])');
154
+ const download = await harness.waitFor(
155
+ () => fs.readdirSync(downloadDir).find(name => name.endsWith('-MEMORY.md')),
156
+ 'the browser downloads the complete project Markdown',
157
+ );
158
+ const exported = fs.readFileSync(path.join(downloadDir, download), 'utf8');
159
+ assert.match(exported, /^# 项目甲 · 生效记忆/);
160
+ assert.ok(exported.includes(MULTILINE_BODY), 'the download keeps the multiline memory intact');
161
+ assert.doesNotMatch(exported, /独立的操作清单/, 'pending candidates are absent from the export');
138
162
 
139
163
  // ---------- 8. 首页组合入口 ----------
140
164
  await harness.nativeClick('nav [data-view="home"]');
@@ -168,8 +168,8 @@ async function main() {
168
168
 
169
169
  // 1. Two real candidates through the real pipeline: A will be ignored,
170
170
  // B stays candidate and is the healthy-page contrast.
171
- const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, scopeType: 'global', file: 'src/r4-candidate-a.js' });
172
- const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, scopeType: 'global', file: 'src/r4-candidate-b.js' });
171
+ const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, file: 'src/r4-candidate-a.js' });
172
+ const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, file: 'src/r4-candidate-b.js' });
173
173
  assert.equal(producedA.capture.accepted, 1, `run A admitted one candidate: ${JSON.stringify(producedA.capture)}`);
174
174
  assert.equal(producedB.capture.accepted, 1, `run B admitted one candidate: ${JSON.stringify(producedB.capture)}`);
175
175
  const memories = await harness.productMemories();
@@ -164,18 +164,18 @@ async function scenarioOriginExclusion(lane, evidence, commands) {
164
164
 
165
165
  // ---- C01: the open item is blocked explicitly, the implementation is intact ----
166
166
  const injected = await callJson(engineUrl, '/api/memories', {
167
- text: '注入来源证据的记忆', scopeType: 'global', evidence: { projectId: PROJECT_ID, commitSha: sha },
167
+ text: '注入来源证据的记忆', evidence: { projectId: PROJECT_ID, commitSha: sha },
168
168
  });
169
169
  assert.equal(injected.status, 400, `evidence injection must be refused (status ${injected.status})`);
170
170
  assert.equal(injected.body?.error, 'INVALID_ARGUMENT', `unexpected error code ${injected.body?.error}`);
171
- assert.match(String(injected.body?.message || ''), /不能指定来源证据/, 'the refusal states the C01 rule explicitly');
171
+ assert.match(String(injected.body?.message || ''), /只支持填写标题、记忆内容、所属智脑和组合/, 'the refusal states the C01 rule explicitly');
172
172
 
173
173
  // A manual memory (explicit user confirmation) still stores no evidence.
174
174
  const brainScope = await callJson(engineUrl, '/api/scopes', {
175
175
  scopes: [{ id: 'brain-default', kind: 'brain', brainId: 'brain-default', name: '默认智脑', knowledgePath: brainPath }],
176
176
  }, { headers: { authorization: 'Bearer eng012-lane-token' } });
177
177
  assert.equal(brainScope.status, 200, `brain scope binding failed: ${JSON.stringify(brainScope.body)}`);
178
- const manual = await callJson(engineUrl, '/api/memories', { text: MANUAL_TEXT, scopeType: 'global' });
178
+ const manual = await callJson(engineUrl, '/api/memories', { text: MANUAL_TEXT });
179
179
  assert.equal(manual.status, 200, `manual memory creation failed: ${JSON.stringify(manual.body)}`);
180
180
  assert.equal(manual.body?.memory?.sourceType, 'manual');
181
181
  assert.equal(manual.body?.memory?.evidence, null, 'a manual record stores no evidence');
@@ -334,7 +334,7 @@ async function main() {
334
334
  'expected1 维护/委派不能自动成为人类长期偏好': 'PASS',
335
335
  'expected2 C01未定项不得自动删除实现': 'PASS',
336
336
  originExclusion: 'the frozen commit conversation snapshot carries both origins; the engine rejected the delegated candidate with SOURCE_NOT_HUMAN and kept the human one as a plain candidate - nothing was confirmed automatically',
337
- c01Block: 'POST /api/memories with an injected source-evidence field is refused with INVALID_ARGUMENT ("不能指定来源证据"); a manual memory is stored with evidence null and sourceType manual, so the MEM-008 implementation was not deleted',
337
+ c01Block: 'POST /api/memories with an injected source-evidence field is refused with INVALID_ARGUMENT (only editable memory fields are accepted); a manual memory is stored with evidence null and sourceType manual, so the MEM-008 implementation was not deleted',
338
338
  noImplementationDeletion: 'a manifest that tries to delete an implementation file is refused by the promotion path (PATH_OUTSIDE_ROOT); the run fails, no knowledge operation is applied and the implementation files stay byte-identical',
339
339
  analyzerStandin: 'deterministic stand-in that deliberately emits both the human and the delegated candidate - NO real model output covered',
340
340
  vectorService: 'real vector-hub server, deterministic test embeddings - paid embedding API NOT covered',
@@ -107,6 +107,7 @@ async function main() {
107
107
  try {
108
108
  const repo = makeRepo(harness.fixture, 'memcand-repo', { 'README.md': '# 候选甲\n' });
109
109
  const { projectId } = await harness.importProject(repo, '候选甲');
110
+ const group = await harness.addGroup('候选甲约定', [projectId]);
110
111
  await harness.requestRegistryRefresh();
111
112
  // The new home page no longer lists projects; the registry projection is
112
113
  // surfaced by the topbar project selector instead.
@@ -117,7 +118,7 @@ async function main() {
117
118
  );
118
119
 
119
120
  // ---------------------------------------------------------------- MEM-003
120
- const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT, scopeType: 'global' });
121
+ const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
121
122
  assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
122
123
  assert.deepEqual(produced.capture.rejected, [], 'the real gate rejected nothing for a human source');
123
124
 
@@ -125,8 +126,8 @@ async function main() {
125
126
  assert.ok(stored, 'the candidate really exists in the engine');
126
127
  assert.equal(stored.status, 'candidate', 'the automatic memory is saved as a candidate');
127
128
  assert.notEqual(stored.sourceType, 'manual', 'an automatic candidate is not a manual memory');
128
- assert.equal(stored.scopeType, 'global', 'a global candidate keeps the global scope');
129
- assert.equal(stored.scopeId, stored.brainId, 'a global candidate targets the brain itself');
129
+ assert.equal(stored.scopeType, 'group');
130
+ assert.deepEqual(stored.groups, [], 'the candidate has no assignment');
130
131
  assert.equal(stored.evidence.projectId, projectId, 'the frozen source names the source project');
131
132
  assert.equal(stored.evidence.commitSha, produced.commitSha, 'the frozen source names the real commit');
132
133
  assert.ok(stored.evidence.entryId, 'the frozen source names the promoted entry');
@@ -223,6 +224,7 @@ async function main() {
223
224
  'the review dialog is open again',
224
225
  10000,
225
226
  );
227
+ await harness.selectOption('#reviewForm select[name=groupId]', group.id);
226
228
  await harness.nativeClick('#appDialogActions button.primary');
227
229
  await harness.waitFor(
228
230
  () => harness.run("document.getElementById('appDialog').open === false"),
@@ -231,7 +233,7 @@ async function main() {
231
233
  );
232
234
  const patch = harness.network.find(entry => entry.method === 'PATCH' && entry.url.includes(`/api/engine/memories/${stored.id}`)).pop();
233
235
  assert.ok(patch, 'the shell really patched the candidate');
234
- assert.deepEqual(patch.body, { status: 'confirmed' }, 'the confirmation only changes the status');
236
+ assert.deepEqual(patch.body, { status: 'confirmed', groupId: group.id }, 'the confirmation assigns the chosen combination');
235
237
  assert.equal(patch.status, 200, `the confirmation answers 200: ${JSON.stringify(patch.body)}`);
236
238
  const patchBody = await harness.network.body(patch);
237
239
  assert.ok(patchBody && patchBody.memory, `the confirmation answers with the memory: ${JSON.stringify(patchBody)}`);
@@ -268,7 +270,7 @@ async function main() {
268
270
  });
269
271
 
270
272
  // ---------------------------------------------------------------- MEM-005
271
- const second = await harness.produceCandidate({ repo, projectId, text: IGNORED_TEXT, scopeType: 'global', file: 'src/ignored.js' });
273
+ const second = await harness.produceCandidate({ repo, projectId, text: IGNORED_TEXT, file: 'src/ignored.js' });
272
274
  assert.equal(second.capture.accepted, 1, `the second real run admitted one candidate: ${JSON.stringify(second.capture)}`);
273
275
  const toIgnore = (await harness.productMemories()).find(memory => memory.text === IGNORED_TEXT);
274
276
  assert.ok(toIgnore, 'the second candidate really exists in the engine');
@@ -138,7 +138,7 @@ async function main() {
138
138
  );
139
139
 
140
140
  // 1. A real candidate through the real pipeline.
141
- const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT, scopeType: 'global' });
141
+ const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
142
142
  assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
143
143
  const candidate = (await harness.productMemories()).find(memory => memory.text === CANDIDATE_TEXT);
144
144
  assert.ok(candidate, 'the candidate really exists in the engine');
@@ -161,8 +161,8 @@ async function main() {
161
161
 
162
162
  // 1. Two real candidates through the real pipeline: A will be ignored,
163
163
  // B stays candidate and is the healthy-page contrast.
164
- const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, scopeType: 'global', file: 'src/r4-candidate-a.js' });
165
- const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, scopeType: 'global', file: 'src/r4-candidate-b.js' });
164
+ const producedA = await harness.produceCandidate({ repo, projectId, text: TEXT_A, file: 'src/r4-candidate-a.js' });
165
+ const producedB = await harness.produceCandidate({ repo, projectId, text: TEXT_B, file: 'src/r4-candidate-b.js' });
166
166
  assert.equal(producedA.capture.accepted, 1, `run A admitted one candidate: ${JSON.stringify(producedA.capture)}`);
167
167
  assert.equal(producedB.capture.accepted, 1, `run B admitted one candidate: ${JSON.stringify(producedB.capture)}`);
168
168
  const memories = await harness.productMemories();
@@ -73,7 +73,7 @@ async function main() {
73
73
  );
74
74
 
75
75
  // A real candidate through the real pipeline (commit + event + run + gate).
76
- const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT, scopeType: 'global' });
76
+ const produced = await harness.produceCandidate({ repo, projectId, text: CANDIDATE_TEXT });
77
77
  assert.equal(produced.capture.accepted, 1, `the real run admitted one candidate: ${JSON.stringify(produced.capture)}`);
78
78
  const stored = (await harness.productMemories()).find(m => m.text === CANDIDATE_TEXT);
79
79
  assert.ok(stored, 'the candidate really exists in the engine');
@@ -43,9 +43,7 @@
43
43
  // N 随引擎版本由 2000 变为 8000(MEMORY_TEXT_LIMIT),断言语义不变。
44
44
  // * 旧 UI 的默认作用域=当前项目;新表单默认=组合记忆。MEM-001 的「项目
45
45
  // 作用域存储」语义保持:在表单里显式选择 适用范围=项目 +
46
- // 适用目标=当前项目(#memoryForm select[name="scopeType"] 与
47
- // [data-role="scope-target"] select[name="scopeTarget"]),存储的
48
- // scopeType/scopeId 另用 engineApi GET /api/memories 复核。
46
+ // 选择已应用到当前项目的组合,存储结果透过引擎 API 复核。
49
47
  // * 「导入项目已列出」等待:旧首页项目面板(homeContent 含项目名)已删除,
50
48
  // 等价为顶栏 #projectSelect 选项里出现项目名(同一 registry projection)。
51
49
  // * 其余引擎断言(POST 200、confirmed/manual/evidence null、磁盘记忆文件
@@ -90,6 +88,7 @@ async function main() {
90
88
  const { projectId } = await harness.importProject(repo, '记忆甲');
91
89
 
92
90
  // The shell has to know the project before it can bind a project scope.
91
+ const group = await harness.addGroup('记忆甲约定', [projectId]);
93
92
  await harness.requestRegistryRefresh();
94
93
  // The new home page no longer lists projects; the registry projection is
95
94
  // surfaced by the topbar project selector instead.
@@ -164,11 +163,11 @@ async function main() {
164
163
  assert.equal(postsAfter, postsBefore, 'the shell must not send a request for a blank body');
165
164
 
166
165
  // The backend refuses the same blank body on its own.
167
- const backendBlank = await harness.productApi('POST', '/api/engine/memories', { text: ' ', scopeType: 'global', scopeId: 'brain-default', brainId: 'brain-default' });
166
+ const backendBlank = await harness.productApi('POST', '/api/engine/memories', { text: ' ', brainId: 'brain-default' });
168
167
  assert.equal(backendBlank.status, 400, `the engine refuses a blank body: ${JSON.stringify(backendBlank.body)}`);
169
168
  assert.equal(backendBlank.body.error, 'INVALID_ARGUMENT', 'the engine reports an invalid argument');
170
169
  assert.match(String(backendBlank.body.message), /记忆内容必须为 1–8000 个字符。/, 'the engine names the length rule (MEMORY_TEXT_LIMIT is 8000 in the current engine)');
171
- const backendBlankEngine = await harness.engineApi('POST', '/api/memories', { text: ' ', scopeType: 'global', scopeId: 'brain-default', brainId: 'brain-default' });
170
+ const backendBlankEngine = await harness.engineApi('POST', '/api/memories', { text: ' ', brainId: 'brain-default' });
172
171
  assert.equal(backendBlankEngine.status, 400, `the engine behind the proxy refuses it too: ${JSON.stringify(backendBlankEngine.body)}`);
173
172
 
174
173
  const afterBlank = await harness.productMemories();
@@ -195,18 +194,8 @@ async function main() {
195
194
  const body = await harness.run("document.getElementById('memoryForm').elements.text.value");
196
195
  assert.equal(body, MEMORY_TEXT, 'the real body reached the textarea');
197
196
 
198
- // The old UI defaulted a manual add to the active project's scope; the new
199
- // form defaults to a group memory, so the project-scope semantics are
200
- // chosen explicitly through the real selects.
201
- await harness.selectOption('#memoryForm select[name="scopeType"]', 'project');
202
- await harness.waitFor(
203
- () => harness.run("document.querySelector('#memoryForm [data-role=\"scope-target\"]').hidden === false"),
204
- 'the project scope target select is shown',
205
- 10000,
206
- );
207
- const targetOptions = await harness.run("Array.from(document.querySelector('#memoryForm [data-role=\"scope-target\"] select[name=\"scopeTarget\"]').options).map(o => o.value)");
208
- assert.ok(targetOptions.includes(projectId), `the project scope offers ${projectId}: ${JSON.stringify(targetOptions)}`);
209
- await harness.selectOption('#memoryForm [data-role="scope-target"] select[name="scopeTarget"]', projectId);
197
+ assert.equal(await harness.run("document.querySelector('#memoryForm select[name=scopeType]')"), null);
198
+ await harness.selectOption('#memoryForm select[name="groupId"]', group.id);
210
199
 
211
200
  const postsBeforeSave = harness.network.find(entry => entry.method === 'POST' && entry.url.includes('/api/engine/memories')).length;
212
201
  await harness.nativeClick('#appDialogActions button.primary');
@@ -227,15 +216,15 @@ async function main() {
227
216
  assert.equal(created.evidence, null, 'a manual memory invents no evidence');
228
217
  assert.equal(created.text, MEMORY_TEXT, 'the saved text is the text that was typed');
229
218
  assert.equal(created.title, MEMORY_TITLE, 'the saved title is the title that was typed');
230
- assert.equal(created.scopeType, 'project', 'the chosen scope of the manual memory is the project');
231
- assert.equal(created.scopeId, projectId, 'the scope target is the active project');
219
+ assert.equal(created.scopeType, 'group');
220
+ assert.deepEqual(created.groups.map(item => item.id), [group.id]);
232
221
  assert.ok(created.id, 'the memory has an id');
233
222
 
234
223
  // The engine's own record confirms the stored scope pair.
235
224
  const engineRecord = (await harness.engineApi('GET', '/api/memories')).body.memories.find(memory => memory.id === created.id);
236
225
  assert.ok(engineRecord, 'the engine really stored the memory');
237
- assert.equal(engineRecord.scopeType, 'project', 'the engine stores the project scope type');
238
- assert.equal(engineRecord.scopeId, projectId, 'the engine stores the active project as the scope target');
226
+ assert.equal(engineRecord.scopeType, 'group');
227
+ assert.deepEqual(engineRecord.groups.map(item => item.id), [group.id]);
239
228
  assert.equal(engineRecord.status, 'confirmed', 'the engine stores the memory as confirmed');
240
229
 
241
230
  // The memory is listed in the real UI (the 记忆库 tab lists confirmed
@@ -249,7 +238,7 @@ async function main() {
249
238
 
250
239
  // The memory file really holds the memory.
251
240
  const brainScope = harness.brainScopePath();
252
- const memoryFile = path.join(brainScope, 'memories', 'projects', `${projectId}.md`);
241
+ const memoryFile = path.join(brainScope, 'memories', 'groups', `${group.id}.md`);
253
242
  assert.ok(fs.existsSync(memoryFile), `the memory file exists: ${memoryFile}`);
254
243
  const fileText = fs.readFileSync(memoryFile, 'utf8');
255
244
  assert.ok(fileText.includes(created.id), 'the memory file names the memory');
@@ -274,8 +263,8 @@ async function main() {
274
263
  assert.ok(kept, 'the memory survives the reload');
275
264
  assert.equal(kept.status, 'confirmed', 'the memory is still confirmed after the reload');
276
265
  assert.equal(kept.text, MEMORY_TEXT, 'the memory text survives the reload');
277
- assert.equal(kept.scopeType, 'project', 'the scope survives the reload');
278
- assert.equal(kept.scopeId, projectId, 'the scope target survives the reload');
266
+ assert.equal(kept.scopeType, 'group');
267
+ assert.deepEqual(kept.groups.map(item => item.id), [group.id]);
279
268
  assert.equal(kept.syncStatus, 'ready', 'the memory file is in sync');
280
269
 
281
270
  evidence.push({
@@ -294,7 +283,7 @@ async function main() {
294
283
  fs.writeFileSync(path.join(harness.evidence, 'mem001-manual.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
295
284
  }
296
285
 
297
- console.log(`parallel-memory-manual-test PASS (MEM-001 confirmed with an explicit project scope + survives a real reload; MEM-002 refused by native required and by the shell without a request, and by the engine with 400)`);
286
+ console.log(`parallel-memory-manual-test PASS (MEM-001 confirmed with a project-bound combination + survives a real reload; MEM-002 refused by native required and by the shell without a request, and by the engine with 400)`);
298
287
  } finally {
299
288
  await harness.cleanup();
300
289
  }