@sanqianx/project-knowledge 5.2.1 → 5.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +6 -0
- package/README.md +6 -0
- package/_site/_test/ai-team-ui-integration-test.js +219 -0
- package/_site/_test/automatic-context-test.js +6 -0
- package/_site/_test/context-session-index-test.js +19 -9
- package/_site/_test/helpers/ai-team-ui-fixture.js +235 -0
- package/_site/_test/helpers/parallel-memory-shell.js +15 -7
- package/_site/_test/helpers/parallel-qa-engine-endpoint-isolate.js +3 -1
- package/_site/_test/helpers/single-repo-maintenance-fixture.js +94 -0
- package/_site/_test/helpers/single-repo-maintenance-tool.js +56 -0
- package/_site/_test/memory-groups-ui-test.js +27 -3
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +2 -2
- package/_site/_test/parallel-engine-final-eng012-test.js +4 -4
- package/_site/_test/parallel-memory-candidate-test.js +7 -5
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +1 -1
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +2 -2
- package/_site/_test/parallel-memory-home-review-test.js +1 -1
- package/_site/_test/parallel-memory-manual-test.js +14 -25
- package/_site/_test/parallel-memory-scope-test.js +66 -264
- package/_site/_test/parallel-memory-source-test.js +5 -7
- package/_site/_test/parallel-memory-sync-test.js +18 -9
- package/_site/_test/parallel-qa-engine-endpoint-guard-test.js +4 -2
- package/_site/_test/project-team-ui-test.js +11 -15
- package/_site/_test/shared-scope-root-binding-test.js +7 -6
- package/_site/_test/single-repo-maintenance-e2e-test.js +200 -0
- package/_site/_test/t07f-mem-008-coverage-test.js +0 -1
- package/_site/_test/workbench-context-receipts-test.js +9 -4
- package/_site/lib/engine-connection.js +2 -2
- package/_site/lib/engine-knowledge-client.js +1 -1
- package/_site/scripts/verify-retrieval-gold.js +10 -13
- package/module-runtime-manifest.json +31 -26
- package/package.json +3 -3
- package/plugins/project-knowledge/.claude-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.codex-plugin/plugin.json +1 -1
- package/plugins/project-knowledge/.mcp.json +1 -1
- package/plugins/project-knowledge/scripts/context-hook.cjs +3 -3
- package/plugins/project-knowledge/skills/project-knowledge/SKILL.md +5 -6
- package/ui/product.css +20 -0
- package/ui/product.js +161 -67
|
@@ -1,293 +1,95 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
// _site/_test/parallel-memory-scope-test.js
|
|
3
|
-
//
|
|
4
|
-
// MEM-004 确认目标(适用范围).
|
|
5
|
-
//
|
|
6
|
-
// Real isolated product instance, real browser, real HTTP and real disk. Three
|
|
7
|
-
// real projects are imported into one real brain: two of them belong to a real
|
|
8
|
-
// domain, the third belongs to none. Three real memories are added through the
|
|
9
|
-
// real UI: one global, one bound to the domain, one bound to a single project.
|
|
10
|
-
//
|
|
11
|
-
// MEM-004 expected:
|
|
12
|
-
// * scopeId与scopeType匹配。 -> the stored memory carries the scope id that
|
|
13
|
-
// belongs to its scope type, the UI only offers
|
|
14
|
-
// targets of that type, and the engine refuses
|
|
15
|
-
// a scope id that does not belong to the
|
|
16
|
-
// declared scope type;
|
|
17
|
-
// * 只影响指定范围。 -> a global memory reaches every project, a
|
|
18
|
-
// domain memory only reaches the projects of
|
|
19
|
-
// that domain, a project memory only reaches
|
|
20
|
-
// that project.
|
|
21
|
-
//
|
|
22
|
-
// 迁移说明(五页简化 UI,见 patches/ui-test-mapping-spec.md):
|
|
23
|
-
// * 添加记忆:#addMemory/#memoryDialog → #memoryContent
|
|
24
|
-
// [data-action="new-memory"] → #appDialog 内 #memoryForm。新契约要求标题
|
|
25
|
-
// (input[name="title"],本测试以记忆正文为标题)与正文
|
|
26
|
-
// (textarea[name="text"]),均用 CDP Input.insertText(真实粘贴路径)
|
|
27
|
-
// 录入;提交 = #appDialogActions button.primary。
|
|
28
|
-
// * 适用范围:#memoryScope → #memoryForm select[name="scopeType"](新表单
|
|
29
|
-
// 默认 group,global/domain/project 需显式选择,选择后 change 触发
|
|
30
|
-
// fillTargets);适用目标:#memoryTarget →
|
|
31
|
-
// #memoryForm [data-role="scope-target"] select[name="scopeTarget"]
|
|
32
|
-
// (仅 domain/project 显示;「UI 只提供该类型的目标」断言保持为读取
|
|
33
|
-
// 该 select 的 options)。
|
|
34
|
-
// * scope 存储语义断言保持:POST 响应 scopeType/scopeId + 新增 engineApi
|
|
35
|
-
// GET /api/memories 复核引擎存储的 scopeType/scopeId。
|
|
36
|
-
// * 引擎侧断言全部不变:错配 scope 的 400 INVALID_ARGUMENT
|
|
37
|
-
// (所选记忆目标不存在或不属于当前智脑。)、注入矩阵
|
|
38
|
-
// (/api/context)、磁盘文件布局(brain 共享目录下 memories/
|
|
39
|
-
// confirmed.md、domains/<domainId>.md、projects/<projectId>.md,领域目录
|
|
40
|
-
// 自身无记忆文件)。
|
|
41
|
-
// * 「导入项目已列出」等待:旧首页项目面板已删除 → 顶栏 #projectSelect。
|
|
42
|
-
// * 作用域标签断言:旧 confirmed tab 的 [data-memory-card] → library tab
|
|
43
|
-
// ([data-memory-tab="library"])的 .memory-item(卡片第三行仍标注
|
|
44
|
-
// 全局记忆/领域记忆/项目记忆 与目标名称)。
|
|
45
2
|
|
|
3
|
+
// MEM-004。组合选择、生效矩阵和磁盘投影。 / Verify combination selection, visibility and Markdown projection.
|
|
46
4
|
const fs = require('node:fs');
|
|
47
5
|
const path = require('node:path');
|
|
48
6
|
const assert = require('node:assert/strict');
|
|
49
|
-
|
|
50
7
|
const { startHarness, makeRepo } = require('./helpers/parallel-memory-shell');
|
|
51
8
|
|
|
52
|
-
|
|
53
|
-
const GLOBAL_TEXT = '全局约定:所有对外错误信息使用中文表述。';
|
|
54
|
-
const DOMAIN_TEXT = '平台领域约定:发布流程必须先跑完整回归。';
|
|
55
|
-
const PROJECT_TEXT = '项目约定:数据库迁移脚本一律放在 db/migrations。';
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Open the memory view with retries against the known reload commit-gap race
|
|
59
|
-
* (driver robustness only: the assertion stays "the view is really active").
|
|
60
|
-
*/
|
|
61
|
-
async function openMemoryView(harness) {
|
|
62
|
-
let lastError = null;
|
|
63
|
-
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
64
|
-
await harness.nativeClick('nav [data-view="memory"]');
|
|
65
|
-
try {
|
|
66
|
-
await harness.waitFor(
|
|
67
|
-
() => harness.run("document.getElementById('view-memory').classList.contains('active')"),
|
|
68
|
-
'the memory view is open',
|
|
69
|
-
5000,
|
|
70
|
-
);
|
|
71
|
-
return;
|
|
72
|
-
} catch (error) { lastError = error; }
|
|
73
|
-
}
|
|
74
|
-
throw lastError;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Add one memory through the real UI (new-memory dialog: title + body +
|
|
79
|
-
* explicit scope) and return what the engine answered, cross-checked against
|
|
80
|
-
* the engine's own stored record.
|
|
81
|
-
*/
|
|
82
|
-
async function addMemoryViaUi(harness, { text, scopeType, scopeId }) {
|
|
9
|
+
async function addMemoryViaUi(harness, text, groupId) {
|
|
83
10
|
await harness.nativeClick('#memoryContent [data-action="new-memory"]');
|
|
84
|
-
await harness.waitFor(
|
|
85
|
-
|
|
86
|
-
'the add dialog with the memory form is open',
|
|
87
|
-
10000,
|
|
88
|
-
);
|
|
89
|
-
// The new contract requires a title; the memory text doubles as its title.
|
|
11
|
+
await harness.waitFor(() => harness.run("Boolean(document.getElementById('memoryForm') && document.getElementById('appDialog').open)"), 'the editor opens');
|
|
12
|
+
assert.equal(await harness.run("Boolean(document.querySelector('#memoryForm [name=scopeType], #memoryForm [name=scopeTarget]'))"), false);
|
|
90
13
|
await harness.nativeClick('#memoryForm input[name="title"]');
|
|
91
14
|
await harness.browser.send('Input.insertText', { text });
|
|
92
15
|
await harness.nativeClick('#memoryForm textarea[name="text"]');
|
|
93
16
|
await harness.browser.send('Input.insertText', { text });
|
|
94
|
-
await harness.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
() => harness.run("document.querySelector('#memoryForm [data-role=\"scope-target\"]').hidden === false"),
|
|
98
|
-
`the ${scopeType} scope target select is shown`,
|
|
99
|
-
10000,
|
|
100
|
-
);
|
|
101
|
-
const options = await harness.run("Array.from(document.querySelector('#memoryForm [data-role=\"scope-target\"] select[name=\"scopeTarget\"]').options).map(o => o.value)");
|
|
102
|
-
assert.ok(options.includes(scopeId), `the ${scopeType} scope offers ${scopeId}: ${JSON.stringify(options)}`);
|
|
103
|
-
await harness.selectOption('#memoryForm [data-role="scope-target"] select[name="scopeTarget"]', scopeId);
|
|
104
|
-
}
|
|
105
|
-
const postsBefore = harness.network.find(entry => entry.method === 'POST' && entry.url.includes('/api/engine/memories')).length;
|
|
17
|
+
const choices = await harness.run("[...document.querySelector('#memoryForm select[name=groupId]').options].map(o => o.value)");
|
|
18
|
+
assert.ok(choices.includes(groupId), 'group selector options: ' + JSON.stringify(choices));
|
|
19
|
+
await harness.selectOption('#memoryForm select[name="groupId"]', groupId);
|
|
106
20
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
107
|
-
await harness.waitFor(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
);
|
|
112
|
-
const
|
|
113
|
-
assert.
|
|
114
|
-
assert.
|
|
115
|
-
|
|
116
|
-
if (scopeId) assert.equal(post.body.scopeId, scopeId, 'the chosen scope target really travelled with the request');
|
|
117
|
-
const body = await harness.network.body(post);
|
|
118
|
-
assert.ok(body && body.memory, `the real POST answers with the memory: ${JSON.stringify(body)}`);
|
|
119
|
-
assert.equal(body.memory.text, text, 'the saved text is the text that was typed');
|
|
120
|
-
assert.equal(body.memory.scopeType, scopeType, 'the saved scope type is the chosen one');
|
|
121
|
-
assert.equal(body.memory.scopeId, scopeId || body.memory.brainId, 'the saved scope id belongs to the scope type');
|
|
122
|
-
assert.equal(body.memory.status, 'confirmed', 'the memory is saved as confirmed');
|
|
123
|
-
// The engine's own stored record confirms the scope pair.
|
|
124
|
-
const engineRecord = (await harness.engineApi('GET', '/api/memories')).body.memories.find(memory => memory.id === body.memory.id);
|
|
125
|
-
assert.ok(engineRecord, 'the engine really stored the memory');
|
|
126
|
-
assert.equal(engineRecord.scopeType, scopeType, `the engine stores the ${scopeType} scope type`);
|
|
127
|
-
assert.equal(engineRecord.scopeId, scopeId || engineRecord.brainId, `the engine stores the ${scopeType} scope id`);
|
|
128
|
-
assert.equal(engineRecord.status, 'confirmed', 'the engine stores the memory as confirmed');
|
|
129
|
-
return { memory: body.memory, engineRecord, request: post.body, url: post.url.replace(harness.base, '') };
|
|
21
|
+
await harness.waitFor(() => harness.run("!document.getElementById('appDialog').open"), 'the memory saves');
|
|
22
|
+
|
|
23
|
+
const post = harness.network.find(entry => entry.method === 'POST' && entry.url.includes('/api/engine/memories')).at(-1);
|
|
24
|
+
assert.equal(post.status, 200);
|
|
25
|
+
assert.deepEqual(post.body, { title: text, text, brainId: 'brain-default', groupId });
|
|
26
|
+
const { memory } = await harness.network.body(post);
|
|
27
|
+
assert.equal(memory.status, 'confirmed');
|
|
28
|
+
assert.deepEqual(memory.groups.map(item => item.id), [groupId]);
|
|
29
|
+
return memory;
|
|
130
30
|
}
|
|
131
31
|
|
|
132
32
|
async function main() {
|
|
133
|
-
const
|
|
134
|
-
const
|
|
33
|
+
const evidenceDir = process.env.PK_TEST_EVIDENCE_DIR && path.resolve(process.env.PK_TEST_EVIDENCE_DIR);
|
|
34
|
+
const harness = await startHarness({ tag: 'memscope', evidenceDir: evidenceDir || undefined });
|
|
135
35
|
try {
|
|
136
36
|
const domain = await harness.addDomain('平台领域');
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
37
|
+
const projects = [];
|
|
38
|
+
for (const label of ['甲', '乙', '丙']) {
|
|
39
|
+
const repo = makeRepo(harness.fixture, 'memscope-' + projects.length);
|
|
40
|
+
const { projectId } = await harness.importProject(repo, '范围' + label, label === '丙' ? {} : { domainId: domain.id });
|
|
41
|
+
projects.push(projectId);
|
|
42
|
+
}
|
|
43
|
+
const groups = [
|
|
44
|
+
await harness.addGroup('错误文案', projects),
|
|
45
|
+
await harness.addGroup('发布回归', [projects[0], projects[2]]),
|
|
46
|
+
await harness.addGroup('数据库迁移', [projects[1]]),
|
|
47
|
+
];
|
|
146
48
|
await harness.requestRegistryRefresh();
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
await harness.waitFor(
|
|
150
|
-
() => harness.run("document.getElementById('projectSelect').textContent.includes('范围丙')"),
|
|
151
|
-
'the imported projects are listed',
|
|
152
|
-
20000,
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
// The engine really knows the domain binding of every project.
|
|
156
|
-
const engineProjects = (await harness.engineApi('GET', '/api/projects')).body.projects;
|
|
157
|
-
assert.equal(engineProjects.find(p => p.projectId === a.projectId).domainId, domain.id, 'the engine knows the domain of 甲');
|
|
158
|
-
assert.equal(engineProjects.find(p => p.projectId === b.projectId).domainId, domain.id, 'the engine knows the domain of 乙');
|
|
159
|
-
assert.equal(engineProjects.find(p => p.projectId === c.projectId).domainId || null, null, 'the engine knows 丙 has no domain');
|
|
160
|
-
|
|
161
|
-
// The UI works on project 甲, the one inside the domain.
|
|
162
|
-
await harness.selectOption('#projectSelect', a.projectId);
|
|
163
|
-
await harness.waitFor(
|
|
164
|
-
() => harness.run("document.getElementById('projectSelect').value === " + JSON.stringify(a.projectId)),
|
|
165
|
-
'the active project is 甲',
|
|
166
|
-
10000,
|
|
167
|
-
);
|
|
168
|
-
await openMemoryView(harness);
|
|
169
|
-
await harness.waitFor(
|
|
170
|
-
() => harness.run("document.querySelector('#memoryContent [data-action=\"new-memory\"]') !== null"),
|
|
171
|
-
'the engine is reachable and the add action is live',
|
|
172
|
-
20000,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// ---------------------------------------------------------------- MEM-004
|
|
176
|
-
const globalMemory = await addMemoryViaUi(harness, { text: GLOBAL_TEXT, scopeType: 'global' });
|
|
177
|
-
const domainMemory = await addMemoryViaUi(harness, { text: DOMAIN_TEXT, scopeType: 'domain', scopeId: domain.id });
|
|
178
|
-
const projectMemory = await addMemoryViaUi(harness, { text: PROJECT_TEXT, scopeType: 'project', scopeId: a.projectId });
|
|
179
|
-
|
|
180
|
-
assert.equal(globalMemory.memory.scopeId, globalMemory.memory.brainId, 'a global memory targets the brain itself');
|
|
181
|
-
assert.equal(domainMemory.memory.scopeId, domain.id, 'a domain memory targets the domain');
|
|
182
|
-
assert.equal(projectMemory.memory.scopeId, a.projectId, 'a project memory targets the project');
|
|
183
|
-
assert.equal(globalMemory.engineRecord.scopeId, globalMemory.engineRecord.brainId, 'the engine stores the global scope against the brain');
|
|
184
|
-
assert.equal(domainMemory.engineRecord.scopeId, domain.id, 'the engine stores the domain scope');
|
|
185
|
-
assert.equal(projectMemory.engineRecord.scopeId, a.projectId, 'the engine stores the project scope');
|
|
49
|
+
await harness.nativeClick('nav [data-view="memory"]');
|
|
50
|
+
await harness.waitFor(() => harness.run("Boolean(document.querySelector('#memoryContent [data-action=new-memory]'))"), 'the memory library is ready');
|
|
186
51
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
{ scopeType: 'project', scopeId: domain.id, why: 'a domain id is not a project' },
|
|
192
|
-
{ scopeType: 'global', scopeId: a.projectId, why: 'a global memory always targets the brain' },
|
|
52
|
+
const memories = [
|
|
53
|
+
await addMemoryViaUi(harness, '所有对外错误信息使用中文。', groups[0].id),
|
|
54
|
+
await addMemoryViaUi(harness, '发布前必须运行完整回归。', groups[1].id),
|
|
55
|
+
await addMemoryViaUi(harness, '数据库迁移脚本放在指定目录。', groups[2].id),
|
|
193
56
|
];
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
assert.equal(
|
|
198
|
-
assert.
|
|
57
|
+
const rejected = [];
|
|
58
|
+
for (const [scopeType, scopeId] of [['global', 'brain-default'], ['domain', domain.id], ['project', projects[0]]]) {
|
|
59
|
+
const response = await harness.productApi('POST', '/api/engine/memories', { text: '旧作用域写入', scopeType, scopeId });
|
|
60
|
+
assert.equal(response.status, 400);
|
|
61
|
+
assert.equal(response.body.error, 'INVALID_ARGUMENT');
|
|
62
|
+
rejected.push(scopeType);
|
|
199
63
|
}
|
|
200
|
-
const noMismatch = await harness.productMemories();
|
|
201
|
-
assert.ok(!noMismatch.some(memory => memory.text.startsWith('范围不匹配的记忆')), 'no mismatched memory was stored');
|
|
202
64
|
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
assert.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
65
|
+
const expected = [[memories[0].id, memories[1].id], [memories[0].id, memories[2].id], [memories[0].id, memories[1].id]];
|
|
66
|
+
const injected = [];
|
|
67
|
+
for (const [index, id] of projects.entries()) {
|
|
68
|
+
const memoryIds = (await harness.injectedMemories(id)).map(memory => memory.memoryId).sort();
|
|
69
|
+
assert.deepEqual(memoryIds, [...expected[index]].sort());
|
|
70
|
+
injected.push(memoryIds);
|
|
71
|
+
}
|
|
72
|
+
const root = path.join(harness.brainScopePath(), 'memories');
|
|
73
|
+
for (const relative of ['confirmed.md', 'domains', 'projects']) assert.equal(fs.existsSync(path.join(root, relative)), false);
|
|
74
|
+
for (const [index, group] of groups.entries()) {
|
|
75
|
+
const content = fs.readFileSync(path.join(root, 'groups', group.id + '.md'), 'utf8');
|
|
76
|
+
assert.ok(content.includes(memories[index].id));
|
|
77
|
+
assert.ok(memories.every((item, offset) => offset === index || !content.includes(item.id)));
|
|
78
|
+
}
|
|
217
79
|
|
|
218
|
-
// The real UI names the scope of every memory (the library tab lists the
|
|
219
|
-
// confirmed memories; each .memory-item card names the scope and target).
|
|
220
80
|
await harness.reload();
|
|
221
|
-
await
|
|
222
|
-
await harness.waitFor(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
await harness.waitFor(
|
|
229
|
-
() => harness.run(`document.getElementById('memoryContent').textContent.includes(${JSON.stringify(GLOBAL_TEXT)})`),
|
|
230
|
-
'the confirmed memories are listed',
|
|
231
|
-
15000,
|
|
232
|
-
);
|
|
233
|
-
const scopeLabels = await harness.run("Array.from(document.querySelectorAll('#memoryContent .memory-item')).map(el => el.textContent)");
|
|
234
|
-
const globalCard = scopeLabels.find(text => text.includes(GLOBAL_TEXT));
|
|
235
|
-
const domainCard = scopeLabels.find(text => text.includes(DOMAIN_TEXT));
|
|
236
|
-
const projectCard = scopeLabels.find(text => text.includes(PROJECT_TEXT));
|
|
237
|
-
assert.ok(globalCard && domainCard && projectCard, `all three memories have cards: ${JSON.stringify(scopeLabels)}`);
|
|
238
|
-
assert.match(globalCard, /全局/, 'the UI names the global scope');
|
|
239
|
-
assert.match(domainCard, /领域/, 'the UI names the domain scope');
|
|
240
|
-
assert.match(domainCard, new RegExp(domain.name), 'the UI names the domain');
|
|
241
|
-
assert.match(projectCard, /项目/, 'the UI names the project scope');
|
|
242
|
-
assert.match(projectCard, new RegExp('范围甲'), 'the UI names the project');
|
|
243
|
-
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem004-scopes.png'));
|
|
244
|
-
|
|
245
|
-
// The memory files really live in the scope they claim. The engine
|
|
246
|
-
// materializes every scope's memory file in the brain's shared directory:
|
|
247
|
-
// the domain scope directory itself holds no memory file.
|
|
248
|
-
const brainScope = harness.brainScopePath();
|
|
249
|
-
const domainScope = harness.domainScopePath(domain.id);
|
|
250
|
-
assert.ok(fs.existsSync(path.join(brainScope, 'memories', 'confirmed.md')), 'the global memory file exists');
|
|
251
|
-
assert.ok(fs.existsSync(path.join(brainScope, 'memories', 'domains', `${domain.id}.md`)), 'the domain memory file exists');
|
|
252
|
-
assert.ok(fs.existsSync(path.join(brainScope, 'memories', 'projects', `${a.projectId}.md`)), 'the project memory file exists');
|
|
253
|
-
assert.ok(!fs.existsSync(path.join(domainScope, 'memories')), 'the domain scope directory holds no memory file of its own');
|
|
254
|
-
const globalFile = fs.readFileSync(path.join(brainScope, 'memories', 'confirmed.md'), 'utf8');
|
|
255
|
-
assert.ok(globalFile.includes(globalMemory.memory.id), 'the global file holds the global memory');
|
|
256
|
-
assert.ok(!globalFile.includes(domainMemory.memory.id), 'the global file does not hold the domain memory');
|
|
257
|
-
const domainFile = fs.readFileSync(path.join(brainScope, 'memories', 'domains', `${domain.id}.md`), 'utf8');
|
|
258
|
-
assert.ok(domainFile.includes(domainMemory.memory.id), 'the domain file holds the domain memory');
|
|
259
|
-
const projectFile = fs.readFileSync(path.join(brainScope, 'memories', 'projects', `${a.projectId}.md`), 'utf8');
|
|
260
|
-
assert.ok(projectFile.includes(projectMemory.memory.id), 'the project file holds the project memory');
|
|
261
|
-
assert.ok(!projectFile.includes(globalMemory.memory.id), 'the project file does not hold the global memory');
|
|
262
|
-
|
|
263
|
-
evidence.push({
|
|
264
|
-
case: 'MEM-004',
|
|
265
|
-
domain: { id: domain.id, name: domain.name },
|
|
266
|
-
projects: { a: a.projectId, b: b.projectId, c: c.projectId },
|
|
267
|
-
memories: {
|
|
268
|
-
global: { id: globalMemory.memory.id, scopeType: globalMemory.memory.scopeType, scopeId: globalMemory.memory.scopeId },
|
|
269
|
-
domain: { id: domainMemory.memory.id, scopeType: domainMemory.memory.scopeType, scopeId: domainMemory.memory.scopeId },
|
|
270
|
-
project: { id: projectMemory.memory.id, scopeType: projectMemory.memory.scopeType, scopeId: projectMemory.memory.scopeId },
|
|
271
|
-
},
|
|
272
|
-
mismatchedScopes: mismatches.map(mismatch => mismatch.scopeType),
|
|
273
|
-
injected: { a: ids(injectedA), b: ids(injectedB), c: ids(injectedC) },
|
|
274
|
-
files: {
|
|
275
|
-
brainScope,
|
|
276
|
-
domainScope,
|
|
277
|
-
global: path.join(brainScope, 'memories', 'confirmed.md'),
|
|
278
|
-
domain: path.join(brainScope, 'memories', 'domains', `${domain.id}.md`),
|
|
279
|
-
project: path.join(brainScope, 'memories', 'projects', `${a.projectId}.md`),
|
|
280
|
-
},
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
assert.equal(harness.browser.exceptions.length, 0, `no uncaught product JavaScript exceptions: ${JSON.stringify(harness.browser.exceptions)}`);
|
|
284
|
-
|
|
285
|
-
if (harness.evidence) {
|
|
286
|
-
fs.mkdirSync(harness.evidence, { recursive: true });
|
|
287
|
-
fs.writeFileSync(path.join(harness.evidence, 'mem004-scope.json'), `${JSON.stringify(evidence, null, 2)}\n`, 'utf8');
|
|
81
|
+
await harness.nativeClick('nav [data-view="memory"]');
|
|
82
|
+
await harness.waitFor(() => harness.run("document.querySelectorAll('#memoryContent .memory-item').length === 3"), 'the saved records reload');
|
|
83
|
+
const cards = await harness.run("[...document.querySelectorAll('#memoryContent .memory-item')].map(el => el.textContent)");
|
|
84
|
+
for (const [index, memory] of memories.entries()) {
|
|
85
|
+
const card = cards.find(text => text.includes(memory.title));
|
|
86
|
+
assert.ok(card?.includes(groups[index].name));
|
|
87
|
+
assert.doesNotMatch(card, /全局记忆|领域记忆|项目记忆/);
|
|
288
88
|
}
|
|
289
|
-
|
|
290
|
-
|
|
89
|
+
assert.deepEqual(harness.browser.exceptions, []);
|
|
90
|
+
await harness.browser.screenshot(path.join(harness.evidence, 'mem004-combinations.png'));
|
|
91
|
+
fs.writeFileSync(path.join(harness.evidence, 'mem004-scope.json'), JSON.stringify([{ case: 'MEM-004', projects, groups, injected, rejected }], null, 2));
|
|
92
|
+
console.log('parallel-memory-scope-test PASS (MEM-004 combination boundaries)');
|
|
291
93
|
} finally {
|
|
292
94
|
await harness.cleanup();
|
|
293
95
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// 问题,断言仍是「视图真正激活」)。
|
|
12
12
|
// * 候选箱 tab:[data-memory-tab="candidate"] 选择器不变;tab 栏由
|
|
13
13
|
// #memoryContent 动态渲染且仅引擎可达时出现,先等 tab 渲染再点击。
|
|
14
|
-
// *
|
|
14
|
+
// * 候选箱空态文案为「这个范围内没有待确认的记忆。」。
|
|
15
15
|
// * 首页边界文案:「没有待确认记忆。」→「没有待确认的记忆。」(新 UI
|
|
16
16
|
// 措辞微调),语义(智脑不会自动把项目行为当作偏好)不变。
|
|
17
17
|
// * 冻结来源:本例四个候选全部被引擎来源门拒绝,没有可审核对象,UI 侧
|
|
@@ -89,7 +89,7 @@ async function main() {
|
|
|
89
89
|
document: `# 冻结证据\n\n${DELEGATED_TEXT}\n`,
|
|
90
90
|
inputOrigin: 'agent-delegation',
|
|
91
91
|
eventContent: `委派任务:${DELEGATED_TEXT}`,
|
|
92
|
-
candidate: event => harness.memoryCandidate({ text: DELEGATED_TEXT, event
|
|
92
|
+
candidate: event => harness.memoryCandidate({ text: DELEGATED_TEXT, event }),
|
|
93
93
|
});
|
|
94
94
|
assert.equal(delegated.capture.accepted, 0, 'a delegated task order is not admitted');
|
|
95
95
|
assert.deepEqual(delegated.capture.rejected.map(entry => entry.code), ['SOURCE_NOT_HUMAN'], 'the gate names the non-human source');
|
|
@@ -101,7 +101,7 @@ async function main() {
|
|
|
101
101
|
document: `# 冻结证据\n\n${UNKNOWN_TEXT}\n`,
|
|
102
102
|
inputOrigin: 'unknown',
|
|
103
103
|
eventContent: `无法确认来源的输入:${UNKNOWN_TEXT}`,
|
|
104
|
-
candidate: event => harness.memoryCandidate({ text: UNKNOWN_TEXT, event
|
|
104
|
+
candidate: event => harness.memoryCandidate({ text: UNKNOWN_TEXT, event }),
|
|
105
105
|
});
|
|
106
106
|
assert.equal(unknown.capture.accepted, 0, 'an unverifiable source is not admitted');
|
|
107
107
|
assert.deepEqual(unknown.capture.rejected.map(entry => entry.code), ['SOURCE_NOT_HUMAN'], 'the gate names the non-human source');
|
|
@@ -115,7 +115,6 @@ async function main() {
|
|
|
115
115
|
candidate: () => ({
|
|
116
116
|
text: UNSOURCED_TEXT,
|
|
117
117
|
quote: UNSOURCED_TEXT,
|
|
118
|
-
scopeType: 'global',
|
|
119
118
|
eligibility: { durable: true, crossProject: true, reason: '人工明确表达的长期偏好', scopeReason: '适用于所有领域与项目' },
|
|
120
119
|
}),
|
|
121
120
|
});
|
|
@@ -131,7 +130,6 @@ async function main() {
|
|
|
131
130
|
candidate: () => ({
|
|
132
131
|
text: MISSING_EVENT_TEXT,
|
|
133
132
|
quote: MISSING_EVENT_TEXT,
|
|
134
|
-
scopeType: 'global',
|
|
135
133
|
sourceEventId: 'event-does-not-exist',
|
|
136
134
|
sourceHash: 'sha256:0000000000000000000000000000000000000000000000000000000000000000',
|
|
137
135
|
eligibility: { durable: true, crossProject: true, reason: '人工明确表达的长期偏好', scopeReason: '适用于所有领域与项目' },
|
|
@@ -193,7 +191,7 @@ async function main() {
|
|
|
193
191
|
await harness.nativeClick('#memoryContent [data-memory-tab="candidate"]');
|
|
194
192
|
try {
|
|
195
193
|
await harness.waitFor(
|
|
196
|
-
() => harness.run("document.getElementById('memoryContent').textContent.includes('
|
|
194
|
+
() => harness.run("document.getElementById('memoryContent').textContent.includes('这个范围内没有待确认的记忆。')"),
|
|
197
195
|
'the candidate box is really empty once the engine answered again',
|
|
198
196
|
20000,
|
|
199
197
|
);
|
|
@@ -202,7 +200,7 @@ async function main() {
|
|
|
202
200
|
throw error;
|
|
203
201
|
}
|
|
204
202
|
const candidateBox = await harness.run("document.getElementById('memoryContent').textContent");
|
|
205
|
-
assert.match(candidateBox,
|
|
203
|
+
assert.match(candidateBox, /这个范围内没有待确认的记忆。/, `the candidate box is really empty: ${candidateBox}`);
|
|
206
204
|
assert.ok(!candidateBox.includes(DELEGATED_TEXT), 'the delegated order is not listed');
|
|
207
205
|
assert.ok(!candidateBox.includes(UNSOURCED_TEXT), 'the unsourced preference is not listed');
|
|
208
206
|
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem008-candidate-empty.png'));
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
// * 添加表单:#memoryDialog/#memoryText/#memoryScope/#confirmMemory →
|
|
30
30
|
// #appDialog 内 #memoryForm:标题 input[name="title"](新契约必填)与
|
|
31
31
|
// 正文 textarea[name="text"] 都用 CDP Input.insertText(真实粘贴路径),
|
|
32
|
-
//
|
|
32
|
+
// 加入组合 select[name="groupId"],提交 =
|
|
33
33
|
// #appDialogActions button.primary(type=submit 关联 #memoryForm)。
|
|
34
34
|
// * 记忆卡片:[data-memory-card=<id>] → .memory-item(以
|
|
35
35
|
// [data-action="memory-detail"][data-id=<id>] 定位)。旧卡片的
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
// 「未同步内容不注入」语义仍由引擎注入门(/api/context)断言证明。
|
|
41
41
|
// * 恢复后的「已确认」卡片文案在新 UI 不存在;等价断言 = 恢复的记忆重新
|
|
42
42
|
// 出现在「记忆库」tab([data-memory-tab="library"],旧 confirmed tab,
|
|
43
|
-
// 仅列出 status=confirmed
|
|
43
|
+
// 仅列出 status=confirmed 的记忆)、卡片带组合名称且无
|
|
44
44
|
// pending 徽标。
|
|
45
45
|
// * 导入项目已列出的等待:旧首页项目面板(homeContent 含项目名)已删除,
|
|
46
46
|
// 等价为顶栏 #projectSelect 选项里出现项目名(同一 registry projection)。
|
|
47
47
|
// * 引擎/数据断言(POST 200、created.status=confirmed、syncStatus=pending、
|
|
48
|
-
// syncError、注入门、
|
|
48
|
+
// syncError、注入门、the group Markdown 物化与恢复)保持不变;本测试使用真实
|
|
49
49
|
// 引擎(dataSchemaVersion 由引擎自身报告,当前为 4),无需同步任何桩。
|
|
50
50
|
|
|
51
51
|
const fs = require('node:fs');
|
|
@@ -94,6 +94,7 @@ async function main() {
|
|
|
94
94
|
try {
|
|
95
95
|
const repo = makeRepo(harness.fixture, 'memsync-repo', { 'README.md': '# 同步甲\n' });
|
|
96
96
|
const { projectId } = await harness.importProject(repo, '同步甲');
|
|
97
|
+
const group = await harness.addGroup('同步组合', [projectId]);
|
|
97
98
|
await harness.requestRegistryRefresh();
|
|
98
99
|
// The new home page no longer lists projects (领域/项目面板已删除);the
|
|
99
100
|
// registry projection is surfaced by the topbar project selector instead.
|
|
@@ -113,15 +114,23 @@ async function main() {
|
|
|
113
114
|
// Break the real write path: the confirmed memory file path becomes a
|
|
114
115
|
// directory, so the engine cannot write the memory file.
|
|
115
116
|
const brainScope = harness.brainScopePath();
|
|
116
|
-
const memoryFile = path.join(brainScope, 'memories', '
|
|
117
|
-
fs.rmSync(memoryFile, { recursive: true, force: true });
|
|
117
|
+
const memoryFile = path.join(brainScope, 'memories', 'groups', group.id + '.md');
|
|
118
118
|
fs.mkdirSync(memoryFile, { recursive: true });
|
|
119
119
|
assert.ok(fs.lstatSync(memoryFile).isDirectory(), 'the confirmed memory file path really is occupied by a directory');
|
|
120
120
|
|
|
121
|
-
// Add the memory through the real UI
|
|
121
|
+
// Add the memory through the real UI with the project-bound combination: the new-memory
|
|
122
122
|
// dialog (#appDialog > #memoryForm) with title + multiline body, scope
|
|
123
123
|
// global, submitted by the primary (type=submit) action button.
|
|
124
|
-
|
|
124
|
+
// Initial live refreshes can redraw the toolbar between the coordinate
|
|
125
|
+
// probe and the CDP click. Find, hit-test and activate the same node.
|
|
126
|
+
await harness.waitFor(() => harness.run(`(() => {
|
|
127
|
+
const button = document.querySelector('#memoryContent [data-action="new-memory"]');
|
|
128
|
+
if (!button || button.disabled || !button.getClientRects().length) return false;
|
|
129
|
+
const rect = button.getBoundingClientRect();
|
|
130
|
+
if (!button.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2))) return false;
|
|
131
|
+
button.click();
|
|
132
|
+
return true;
|
|
133
|
+
})()`), 'the add memory control is actionable', 10000);
|
|
125
134
|
await harness.waitFor(
|
|
126
135
|
() => harness.run("document.getElementById('appDialog').open === true && document.getElementById('memoryForm') !== null"),
|
|
127
136
|
'the add dialog with the memory form is open',
|
|
@@ -131,7 +140,7 @@ async function main() {
|
|
|
131
140
|
await harness.browser.send('Input.insertText', { text: MEMORY_TITLE });
|
|
132
141
|
await harness.nativeClick('#memoryForm textarea[name="text"]');
|
|
133
142
|
await harness.browser.send('Input.insertText', { text: MEMORY_TEXT });
|
|
134
|
-
await harness.selectOption('#memoryForm select[name="
|
|
143
|
+
await harness.selectOption('#memoryForm select[name="groupId"]', group.id);
|
|
135
144
|
const postsBefore = harness.network.find(entry => entry.method === 'POST' && entry.url.includes('/api/engine/memories')).length;
|
|
136
145
|
await harness.nativeClick('#appDialogActions button.primary');
|
|
137
146
|
await harness.waitFor(
|
|
@@ -239,7 +248,7 @@ async function main() {
|
|
|
239
248
|
const recoveredCard = await memoryCardText(harness, created.id);
|
|
240
249
|
assert.ok(recoveredCard, 'the recovered memory has a card');
|
|
241
250
|
assert.ok(!recoveredCard.includes('写入待恢复'), `the card no longer shows the pending write: ${recoveredCard}`);
|
|
242
|
-
assert.match(recoveredCard,
|
|
251
|
+
assert.match(recoveredCard, /同步组合/, 'the recovered card shows its combination');
|
|
243
252
|
if (harness.evidence) await harness.browser.screenshot(path.join(harness.evidence, 'mem006-recovered.png'));
|
|
244
253
|
|
|
245
254
|
evidence.push({
|
|
@@ -92,7 +92,8 @@ const {
|
|
|
92
92
|
assert.equal(negScope.index.error.details.upstreamCode, EGRESS_BLOCK_CODE);
|
|
93
93
|
|
|
94
94
|
// S1/S2 chain: manual memory confirm → materialize → onMaterialized → import.
|
|
95
|
-
const
|
|
95
|
+
const negGroup = await negativeEngine.coordinator.memoryGroups.create({ name: '负向测试组合', brainId: 'brain-r5' });
|
|
96
|
+
const negMemory = await negativeEngine.coordinator.memories.create({ text: '负向回归:确认流必须在 LIVE 8787 之前被拦截', brainId: 'brain-r5', groupId: negGroup.id });
|
|
96
97
|
assert.equal(negMemory.status, 'confirmed');
|
|
97
98
|
await waitFor(() => guard.blocked.filter(entry => entry.href === 'http://127.0.0.1:8787/api/import').length >= 2, 'confirm chain attempting LIVE import while blocked');
|
|
98
99
|
// index() chain: run maintenance index → /api/sync at LIVE 8787.
|
|
@@ -143,7 +144,8 @@ const {
|
|
|
143
144
|
// content then takes the GET /api/projects health path and skips import.
|
|
144
145
|
const importsAfterConfigure = importCount();
|
|
145
146
|
const healthGets = () => standin.records.filter(record => record.method === 'GET' && record.path === '/api/projects').length;
|
|
146
|
-
const
|
|
147
|
+
const posGroup = await positiveEngine.coordinator.memoryGroups.create({ name: '正向测试组合', brainId: 'brain-pos' });
|
|
148
|
+
const posMemory = await positiveEngine.coordinator.memories.create({ text: '正向证明:确认流导入必须落到自有替身', brainId: 'brain-pos', groupId: posGroup.id });
|
|
147
149
|
assert.equal(posMemory.status, 'confirmed');
|
|
148
150
|
await waitFor(() => importCount() >= importsAfterConfigure + 1, 'confirm chain importing at the OWN stand-in');
|
|
149
151
|
assert.equal(importCount(), importsAfterConfigure + 1, 'materialized memory must trigger exactly one real import at the stand-in');
|
|
@@ -23,32 +23,28 @@ async function createTeamViaSettings(harness, projectId, group) {
|
|
|
23
23
|
node.click();
|
|
24
24
|
return true;
|
|
25
25
|
}, selector), `control clickable: ${selector}`);
|
|
26
|
-
const change = (selector, value, eventType) => inFrame((doc, target, next, type) => {
|
|
27
|
-
const node = doc.querySelector(target);
|
|
28
|
-
node.value = next;
|
|
29
|
-
node.dispatchEvent(new Event(type, { bubbles: true }));
|
|
30
|
-
}, selector, value, eventType);
|
|
31
|
-
|
|
32
26
|
await harness.nativeClick('nav [data-view="projects"]');
|
|
33
27
|
const createTeam = `[data-project-team="${projectId}"] [data-go="team"]`;
|
|
34
28
|
// Atomic wait-and-click: the project list re-renders after async loads, so
|
|
35
29
|
// a separate waitFor+click races a redraw that swaps the node out.
|
|
36
30
|
await harness.waitFor(() => harness.run(`(selector => { const node = document.querySelector(selector); if (!node || node.disabled || !node.getClientRects().length) return false; node.click(); return true; })(${JSON.stringify(createTeam)})`), 'create-team entry clickable');
|
|
37
31
|
// P4a workbench: the workbench opens on the tasks view; the empty-team
|
|
38
|
-
//
|
|
32
|
+
// creation form lives on the settings view. Wait for the app's startup probe to
|
|
39
33
|
// settle FIRST — clicking inside a frame that is about to be reloaded lands
|
|
40
34
|
// in the dying document and the fresh one boots back to the tasks view.
|
|
41
35
|
await harness.waitFor(() => inFrame(doc => doc && doc.querySelector('#serviceText') && !doc.querySelector('#serviceText').textContent.includes('正在连接')), 'workbench settled');
|
|
42
36
|
await click('#navSettings');
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
await harness.waitFor(() => inFrame((doc, name) => {
|
|
38
|
+
const form = doc?.querySelector('#teamForm');
|
|
39
|
+
const submit = form?.querySelector('button[type="submit"]');
|
|
40
|
+
if (!submit || submit.disabled || !submit.getClientRects().length) return false;
|
|
41
|
+
form.elements.name.value = name;
|
|
42
|
+
submit.click();
|
|
43
|
+
return true;
|
|
44
|
+
}, teamName), 'submit the first-team form');
|
|
51
45
|
await harness.waitFor(() => inFrame(doc => Boolean(doc?.querySelector('#addMember'))), 'member management after team creation');
|
|
46
|
+
const team = await harness.productApi('GET', workflowApi + '/team');
|
|
47
|
+
assert.equal(team.body.team.name, teamName, 'the form creates the named team');
|
|
52
48
|
|
|
53
49
|
// Default roster: the module seeds developer + reviewer.
|
|
54
50
|
let members = (await harness.productApi('GET', workflowApi + '/members')).body.members;
|
|
@@ -38,11 +38,12 @@ const { guardedCreateEngineServer, createEngineVectorStandin, createEngineBridge
|
|
|
38
38
|
const brain = scopes.find(scope => scope.kind === 'brain');
|
|
39
39
|
const domain = scopes.find(scope => scope.kind === 'domain');
|
|
40
40
|
engine.store.addProject({ projectId: 'project-test', repoPath: path.join(root, 'code'), knowledgePath: path.join(root, 'project-knowledge'), domainId: domain.id });
|
|
41
|
-
engine.
|
|
42
|
-
engine.
|
|
43
|
-
await engine.coordinator.memories.
|
|
41
|
+
const group = await engine.coordinator.memoryGroups.create({ name: '共享目录绑定测试', brainId: brain.id });
|
|
42
|
+
await engine.coordinator.memoryGroups.setProjectBindings(group.id, { addProjectIds: ['project-test'] });
|
|
43
|
+
const memory = await engine.coordinator.memories.create({ text: '保持目录绑定稳定', brainId: brain.id, groupId: group.id });
|
|
44
|
+
const entryId = engine.coordinator.memories.entryFor(memory, engine.store.getProject('project-test'));
|
|
44
45
|
fs.writeFileSync(path.join(domain.knowledgePath, 'README.md'), '# 领域经验\n\n领域知识不能随根目录设置隐式移动。\n');
|
|
45
|
-
const memoryFile = engine.coordinator.memories.file(brain);
|
|
46
|
+
const memoryFile = engine.coordinator.memories.file(brain, entryId);
|
|
46
47
|
const before = fs.readFileSync(memoryFile);
|
|
47
48
|
await settings.updatePatch({ knowledge: { rootPath: newRoot } });
|
|
48
49
|
assert.equal((await bridge.syncEngineConfiguration()).scopes, true, 'changing index root must not invalidate shared memory wiring');
|
|
@@ -59,8 +60,8 @@ const { guardedCreateEngineServer, createEngineVectorStandin, createEngineBridge
|
|
|
59
60
|
bridge.engineUrl = await start();
|
|
60
61
|
assert.equal((await bridge.syncEngineConfiguration()).scopes, true);
|
|
61
62
|
assert.deepEqual(fs.readFileSync(memoryFile), before);
|
|
62
|
-
const
|
|
63
|
-
assert.ok(
|
|
63
|
+
const found = await engine.coordinator.retrieval.get({ projectId: 'project-test', spaceId: 'brain:brain-default', entryId });
|
|
64
|
+
assert.ok(found.chunks.some(chunk => chunk.chunk_text.includes('保持目录绑定稳定')));
|
|
64
65
|
const shared = await engine.coordinator.retrieval.get({ projectId: 'project-test', spaceId: 'domain:domain-tools', entryId: 'README.md' });
|
|
65
66
|
assert.ok(shared.chunks.some(chunk => chunk.chunk_text.includes('不能随根目录设置隐式移动')));
|
|
66
67
|
await engine.close(); engine = null;
|