@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +21 -0
- package/_site/_test/appearance-settings-test.js +148 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-cap-shell.js +606 -0
- package/_site/_test/helpers/parallel-capture-safety-r5-memory-shell.js +464 -0
- package/_site/_test/helpers/parallel-dock-acceptance-env.js +301 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-env.js +378 -0
- package/_site/_test/helpers/parallel-dock-acceptance-r2-ui.js +314 -0
- package/_site/_test/helpers/parallel-dock-acceptance-ui.js +195 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-credential-preload.js +113 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-env.js +307 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-fixture.js +373 -0
- package/_site/_test/helpers/parallel-dock-isolation-r3-ui.js +314 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-harness.js +340 -0
- package/_site/_test/helpers/parallel-engine-reconcile-r4-standin-analyzer.js +82 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-cap-shell.js +605 -0
- package/_site/_test/helpers/parallel-memory-capture-r3-shell.js +176 -0
- package/_site/_test/helpers/parallel-memory-capture-r4-cap-shell.js +577 -0
- package/_site/_test/helpers/parallel-memory-injection-shell.js +723 -0
- package/_site/_test/helpers/parallel-memory-injection-wb-host.js +81 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-fixture.js +295 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-harness.js +573 -0
- package/_site/_test/helpers/parallel-workbench-drafts-r5-host.js +69 -0
- package/_site/_test/helpers/parallel-workbench-runtime-harness.js +587 -0
- package/_site/_test/helpers/qa-r45-harness.js +94 -0
- package/_site/_test/helpers/qa-r48-env.js +64 -0
- package/_site/_test/helpers/qa-r51-env.cjs +77 -0
- package/_site/_test/parallel-capture-safety-r5-cap006-probe.js +524 -0
- package/_site/_test/parallel-capture-safety-r5-cap008e-probe.js +577 -0
- package/_site/_test/parallel-capture-safety-r5-mem005-health-test.js +320 -0
- package/_site/_test/parallel-engine-reconcile-r4-eng007-probe.js +304 -0
- package/_site/_test/parallel-logging-acceptance-log003-probe.js +78 -0
- package/_site/_test/parallel-logging-acceptance-log004-probe.js +85 -0
- package/_site/_test/parallel-memory-capture-r3-cap001-probe.js +238 -0
- package/_site/_test/parallel-memory-capture-r3-cap006-probe.js +371 -0
- package/_site/_test/parallel-memory-capture-r3-cap008-probe.js +439 -0
- package/_site/_test/parallel-memory-capture-r3-mem005-persistence-test.js +271 -0
- package/_site/_test/parallel-memory-capture-r4-cap006-probe.js +519 -0
- package/_site/_test/parallel-memory-capture-r4-cap008e-probe.js +569 -0
- package/_site/_test/parallel-memory-capture-r4-mem005-health-test.js +314 -0
- package/_site/_test/parallel-memory-injection-origin-probe.js +412 -0
- package/_site/_test/parallel-memory-injection-probe.js +411 -0
- package/_site/_test/parallel-workbench-drafts-r4-probe.js +477 -0
- package/_site/_test/parallel-workbench-drafts-r5-chrome-env-bisect.js +89 -0
- package/_site/_test/parallel-workbench-drafts-r5-probe.js +593 -0
- package/_site/_test/parallel-workbench-runtime-minimax-probe.js +321 -0
- package/_site/_test/parallel-workbench-runtime-wb004-ordering.js +307 -0
- package/_site/_test/parallel-workbench-runtime-wb005-drafts.js +313 -0
- package/_site/_test/parallel-workbench-runtime-wb008-abort.js +321 -0
- package/_site/_test/qa-r45-offline-backfill-test.js +279 -0
- package/_site/_test/qa-r48-sys003-blank-secret-test.js +258 -0
- package/_site/_test/t07c-cln-001-002-007-coverage-test.js +135 -0
- package/_site/_test/t07d-git-rel-coverage-test.js +224 -0
- package/_site/_test/t07e-qta-coverage-test.js +195 -0
- package/_site/_test/t07f-mem-008-coverage-test.js +101 -0
- package/_site/lib/server-app.js +11 -2
- package/_site/lib/settings-store.js +43 -1
- package/module-runtime-manifest.json +6 -6
- package/package.json +1 -1
- 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/ui/index.html +18 -1
- package/ui/product.css +6 -2
- package/ui/product.js +86 -1
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
// _site/_test/parallel-memory-injection-origin-probe.js
|
|
3
|
+
//
|
|
4
|
+
// MEM-008 C01 — who is the author of a captured Workbench event, and can a
|
|
5
|
+
// real delegation ever be admitted as a human turn?
|
|
6
|
+
//
|
|
7
|
+
// The chain under test, every component real:
|
|
8
|
+
//
|
|
9
|
+
// real Workbench module 0.13.6 (real capture, real eventKey, real
|
|
10
|
+
// ConversationCapture -> real event-bridge console)
|
|
11
|
+
// -> real event-bridge console journal (real normalisation)
|
|
12
|
+
// -> real knowledge engine (real journal consumption, real
|
|
13
|
+
// ConversationStore, real MemoryService.capture admission gate)
|
|
14
|
+
//
|
|
15
|
+
// Three real turns, each through the module's own HTTP contract:
|
|
16
|
+
//
|
|
17
|
+
// A the real CLIENT shape session created with inputOrigin 'human'
|
|
18
|
+
// (packages/client: opts.inputOrigin || 'human')
|
|
19
|
+
// B the real DISPATCHER shape
|
|
20
|
+
// child session created WITHOUT an origin, then
|
|
21
|
+
// the input carries the dispatcher's own option
|
|
22
|
+
// object { inputOrigin: 'agent-delegation' }
|
|
23
|
+
// (workbench-service dispatcher -> send())
|
|
24
|
+
// C the CALLER-ASSERTED shape
|
|
25
|
+
// child session created WITHOUT an origin, then
|
|
26
|
+
// the input carries { inputOrigin: 'human' }
|
|
27
|
+
// — the public input endpoint forwards the body
|
|
28
|
+
// options straight into send()
|
|
29
|
+
//
|
|
30
|
+
// Everything the probe writes is synthetic: the fixture repository, the
|
|
31
|
+
// synthetic markers in the prompts, the isolated engine data directory. No
|
|
32
|
+
// real user identity is impersonated: leg C proves that NO identity is
|
|
33
|
+
// verified at all, which is exactly the open C01 question.
|
|
34
|
+
const fs = require('node:fs');
|
|
35
|
+
const path = require('node:path');
|
|
36
|
+
const crypto = require('node:crypto');
|
|
37
|
+
const shell = require('./helpers/parallel-memory-injection-shell');
|
|
38
|
+
|
|
39
|
+
const PROFILE_ID = String(process.env.PK_WB_MODEL_PROFILE || 'minimax');
|
|
40
|
+
const REQUESTED_MODEL = String(process.env.PK_WB_MODEL_ID || 'MiniMax-M3.1-Flash');
|
|
41
|
+
const EFFORT = String(process.env.PK_WB_MODEL_EFFORT || 'max');
|
|
42
|
+
const TURN_TIMEOUT_MS = Number(process.env.PK_WB_TURN_TIMEOUT_MS || 420000);
|
|
43
|
+
|
|
44
|
+
const BINDER_ENTRY = path.join(shell.REPO_ROOT, '_modules', 'knowledge-engine', 'src', 'runtime', 'commit-conversation-binder.js');
|
|
45
|
+
|
|
46
|
+
const results = [];
|
|
47
|
+
function record(caseId, status, detail) {
|
|
48
|
+
results.push({ caseId, status, detail });
|
|
49
|
+
console.log(`CASE ${caseId} ${status} ${JSON.stringify(detail)}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function markerFor(leg) {
|
|
53
|
+
return `SYNTHETIC-C01-${leg}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function promptFor(leg) {
|
|
57
|
+
return `【合成测试事件 ${markerFor(leg)}】这是一条用于归属审查的合成测试输入,请只回复:收到。`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function main() {
|
|
61
|
+
const moduleRoot = shell.resolveWorkbenchModuleRoot();
|
|
62
|
+
if (!moduleRoot) throw new Error('no claude-ai-workbench module copy was found to host');
|
|
63
|
+
const identity = shell.packageIdentity(moduleRoot);
|
|
64
|
+
|
|
65
|
+
const layout = shell.createIsolationLayout('parallel-memory-injection-origin');
|
|
66
|
+
const engineToken = crypto.randomBytes(24).toString('hex');
|
|
67
|
+
const bridgeToken = crypto.randomBytes(24).toString('hex');
|
|
68
|
+
const brainId = `brain-${crypto.randomBytes(6).toString('hex')}`;
|
|
69
|
+
const projectId = `c01-${crypto.randomBytes(4).toString('hex')}`;
|
|
70
|
+
|
|
71
|
+
const console_ = await shell.startBridgeConsole({ home: layout.bridgeHome, runtimeToken: bridgeToken });
|
|
72
|
+
const vector = await shell.startVectorHubStandIn();
|
|
73
|
+
const engine = await shell.startRealEngine({
|
|
74
|
+
dataDir: layout.engineDataDir,
|
|
75
|
+
runtimeToken: engineToken,
|
|
76
|
+
debug: true,
|
|
77
|
+
consume: true,
|
|
78
|
+
bridgeUrl: console_.url,
|
|
79
|
+
vectorUrl: vector.url,
|
|
80
|
+
});
|
|
81
|
+
const proxy = await shell.startRecordingProxy({ target: engine.url, label: 'knowledge-engine' });
|
|
82
|
+
|
|
83
|
+
const repo = shell.makeGitRepo(layout.repos, 'c01-origin');
|
|
84
|
+
const repoIdentity = await shell.resolveRepoIdentity(repo.path);
|
|
85
|
+
if (!repoIdentity || !repoIdentity.repoIdentity) throw new Error('the fixture repository has no bridge repo identity');
|
|
86
|
+
|
|
87
|
+
// The console must know the project, otherwise the real capture is refused
|
|
88
|
+
// with PROJECT_NOT_REGISTERED.
|
|
89
|
+
const registered = await console_.api('POST', '/api/projects', { path: repo.path });
|
|
90
|
+
if (registered.status !== 201) throw new Error(`the console project registration failed: HTTP ${registered.status} ${JSON.stringify(registered.body)}`);
|
|
91
|
+
const consoleProject = registered.body.project;
|
|
92
|
+
const journalId = consoleProject.id;
|
|
93
|
+
|
|
94
|
+
const scopes = await engine.api('POST', '/api/scopes', {
|
|
95
|
+
scopes: [{ id: `scope-${crypto.randomBytes(4).toString('hex')}`, kind: 'brain', brainId, name: 'C01 brain', knowledgePath: layout.brainKnowledgeDir }],
|
|
96
|
+
});
|
|
97
|
+
if (scopes.status !== 200) throw new Error(`the brain scope was not bound: HTTP ${scopes.status} ${JSON.stringify(scopes.body)}`);
|
|
98
|
+
|
|
99
|
+
const project = await engine.api('POST', '/api/projects', {
|
|
100
|
+
projectId,
|
|
101
|
+
name: 'c01-origin',
|
|
102
|
+
repoPath: repo.path,
|
|
103
|
+
knowledgePath: layout.projectKnowledgeDir,
|
|
104
|
+
brainId,
|
|
105
|
+
journalId,
|
|
106
|
+
repoIdentity: repoIdentity.repoIdentity,
|
|
107
|
+
});
|
|
108
|
+
if (project.status !== 200) throw new Error(`the engine project was not registered: HTTP ${project.status} ${JSON.stringify(project.body)}`);
|
|
109
|
+
|
|
110
|
+
const port = await shell.freePort();
|
|
111
|
+
const base = `http://127.0.0.1:${port}`;
|
|
112
|
+
const child = shell.spawnNode([path.join(__dirname, 'helpers', 'parallel-memory-injection-wb-host.js')], shell.hostEnv(layout, {
|
|
113
|
+
PK_WB_MODULE_ROOT: moduleRoot,
|
|
114
|
+
PK_WB_HOST_PORT: String(port),
|
|
115
|
+
PK_WB_HOST_DATA_DIR: layout.dataDir,
|
|
116
|
+
PK_WB_HOST_WORKSPACES: JSON.stringify({ 'wb-origin': repo.path }),
|
|
117
|
+
PK_WB_ENGINE_URL: proxy.url,
|
|
118
|
+
PK_WB_PROFILE_SOURCE: 'real-readonly',
|
|
119
|
+
PK_WB_BRIDGE_URL: console_.url,
|
|
120
|
+
PK_WB_BRIDGE_TOKEN: bridgeToken,
|
|
121
|
+
}));
|
|
122
|
+
|
|
123
|
+
const legs = {};
|
|
124
|
+
try {
|
|
125
|
+
await shell.waitForHttp(`${base}/api/claude-workbench/v1/health`, 30000);
|
|
126
|
+
|
|
127
|
+
// ---- the three real turns -----------------------------------------
|
|
128
|
+
legs.human = await shell.runWorkbenchTurn({
|
|
129
|
+
base, profileId: PROFILE_ID, model: REQUESTED_MODEL, effort: EFFORT,
|
|
130
|
+
workspaceRef: 'wb-origin', contextId: 'c01-origin',
|
|
131
|
+
question: promptFor('HUMAN'),
|
|
132
|
+
sessionInputOrigin: 'human',
|
|
133
|
+
timeoutMs: TURN_TIMEOUT_MS,
|
|
134
|
+
});
|
|
135
|
+
// The dispatcher shape: the child session carries no origin of its own and
|
|
136
|
+
// the input carries the dispatcher's own option object.
|
|
137
|
+
legs.delegated = await shell.runWorkbenchTurn({
|
|
138
|
+
base, profileId: PROFILE_ID, model: REQUESTED_MODEL, effort: EFFORT,
|
|
139
|
+
workspaceRef: 'wb-origin', contextId: 'c01-origin',
|
|
140
|
+
question: promptFor('DELEGATED'),
|
|
141
|
+
sessionInputOrigin: undefined,
|
|
142
|
+
inputOptions: { inputOrigin: 'agent-delegation', permissionMode: 'default', effort: EFFORT },
|
|
143
|
+
timeoutMs: TURN_TIMEOUT_MS,
|
|
144
|
+
});
|
|
145
|
+
// The caller-asserted shape: the public input endpoint forwards the body
|
|
146
|
+
// options straight into send(), so a caller can name the origin.
|
|
147
|
+
legs.callerAsserted = await shell.runWorkbenchTurn({
|
|
148
|
+
base, profileId: PROFILE_ID, model: REQUESTED_MODEL, effort: EFFORT,
|
|
149
|
+
workspaceRef: 'wb-origin', contextId: 'c01-origin',
|
|
150
|
+
question: promptFor('CALLERASSERTED'),
|
|
151
|
+
sessionInputOrigin: undefined,
|
|
152
|
+
inputOptions: { inputOrigin: 'human' },
|
|
153
|
+
timeoutMs: TURN_TIMEOUT_MS,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
record('MEM-008.C01.s1-three-real-turns', Object.values(legs).every(leg => leg && leg.sessionId) ? 'PASS' : 'BLOCKED', {
|
|
157
|
+
module: { name: identity.name, version: identity.version, root: moduleRoot },
|
|
158
|
+
profile: { id: PROFILE_ID, source: 'original-subscription-store read-only, credential in memory only', credentialWrittenAnywhere: false },
|
|
159
|
+
turns: Object.fromEntries(Object.entries(legs).map(([key, leg]) => [key, {
|
|
160
|
+
workbenchSessionId: leg.sessionId,
|
|
161
|
+
claudeSessionId: leg.claudeSessionId,
|
|
162
|
+
sdkReportedModel: leg.sdkReportedModel,
|
|
163
|
+
isError: leg.isError,
|
|
164
|
+
errorEvent: leg.error,
|
|
165
|
+
answerPreview: String(leg.answer || '').slice(0, 200),
|
|
166
|
+
}])),
|
|
167
|
+
note: 'the origin label of a turn is decided before the model runs; the model answer is not part of this case',
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// ---- the real console journal --------------------------------------
|
|
171
|
+
const journalEvents = await shell.eventually(async () => {
|
|
172
|
+
const response = await console_.api('GET', `/api/journal/events?journalId=${encodeURIComponent(journalId)}&fromSequence=1&limit=200`);
|
|
173
|
+
const events = (response.body && response.body.events) || [];
|
|
174
|
+
const prompts = events.filter(event => event.eventType === 'user_prompt');
|
|
175
|
+
return prompts.length >= 3 ? { events, prompts } : null;
|
|
176
|
+
}, 60000, 500);
|
|
177
|
+
|
|
178
|
+
const bySession = {};
|
|
179
|
+
for (const event of (journalEvents ? journalEvents.prompts : [])) bySession[event.sessionId] = event;
|
|
180
|
+
|
|
181
|
+
const describe = event => event ? {
|
|
182
|
+
eventId: event.eventId,
|
|
183
|
+
sequence: event.sequence,
|
|
184
|
+
sessionId: event.sessionId,
|
|
185
|
+
turnId: event.turnId,
|
|
186
|
+
eventKey: event.eventKey,
|
|
187
|
+
originInEventKey: /:origin=(human|agent-delegation|unknown)$/.exec(String(event.eventKey || '')) ?.[1] || null,
|
|
188
|
+
meta: event.meta || null,
|
|
189
|
+
identityConfidence: event.identityConfidence,
|
|
190
|
+
captureStatus: event.captureStatus,
|
|
191
|
+
repoIdentity: event.repoIdentity ? { workspaceId: event.repoIdentity.workspaceId, workspaceRoot: event.repoIdentity.workspaceRoot } : null,
|
|
192
|
+
authorFieldsPresent: Object.keys(event).filter(key => /author|owner|actor|person/i.test(key)),
|
|
193
|
+
contentHead: String(event.content || '').slice(0, 120),
|
|
194
|
+
} : null;
|
|
195
|
+
|
|
196
|
+
const humanEvent = bySession[legs.human.sessionId] || null;
|
|
197
|
+
const delegatedEvent = bySession[legs.delegated.sessionId] || null;
|
|
198
|
+
const assertedEvent = bySession[legs.callerAsserted.sessionId] || null;
|
|
199
|
+
|
|
200
|
+
record('MEM-008.C01.s2-console-journal-origin', humanEvent && delegatedEvent && assertedEvent ? 'PASS' : 'BLOCKED', {
|
|
201
|
+
journalId,
|
|
202
|
+
consoleProject: { id: consoleProject.id, path: consoleProject.path },
|
|
203
|
+
humanLeg: describe(humanEvent),
|
|
204
|
+
delegatedLeg: describe(delegatedEvent),
|
|
205
|
+
callerAssertedLeg: describe(assertedEvent),
|
|
206
|
+
detail: 'the real console normalised three real captures; the origin survives only inside the eventKey text and meta.origin is always the workbench module',
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const delegatedLabelledHuman = delegatedEvent && /:origin=human$/.test(String(delegatedEvent.eventKey || ''));
|
|
210
|
+
record('MEM-008.C01.s3-delegation-never-labelled-human', delegatedEvent && !delegatedLabelledHuman ? 'PASS' : 'BLOCKED', {
|
|
211
|
+
delegatedEventKey: delegatedEvent && delegatedEvent.eventKey,
|
|
212
|
+
delegatedOriginInEventKey: delegatedEvent ? (/:origin=(human|agent-delegation|unknown)$/.exec(String(delegatedEvent.eventKey || '')) || [])[1] : null,
|
|
213
|
+
labelledAsHuman: Boolean(delegatedLabelledHuman),
|
|
214
|
+
detail: 'the module stamped the dispatcher origin on the delegated turn; the console kept it',
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// ---- the real engine consumption ------------------------------------
|
|
218
|
+
const consumed = await shell.eventually(() => {
|
|
219
|
+
const events = engine.engine.coordinator.conversations.readEvents(projectId);
|
|
220
|
+
const prompts = events.filter(event => event.eventType === 'user_prompt');
|
|
221
|
+
return prompts.length >= 3 ? prompts : null;
|
|
222
|
+
}, 60000, 500);
|
|
223
|
+
|
|
224
|
+
const consumedBySession = {};
|
|
225
|
+
for (const event of (consumed || [])) consumedBySession[event.sessionId] = event;
|
|
226
|
+
const consumedHuman = consumedBySession[legs.human.sessionId] || null;
|
|
227
|
+
const consumedDelegated = consumedBySession[legs.delegated.sessionId] || null;
|
|
228
|
+
const consumedAsserted = consumedBySession[legs.callerAsserted.sessionId] || null;
|
|
229
|
+
|
|
230
|
+
record('MEM-008.C01.s4-engine-recovered-origin', consumedHuman && consumedDelegated && consumedAsserted ? 'PASS' : 'BLOCKED', {
|
|
231
|
+
projectId,
|
|
232
|
+
journalId,
|
|
233
|
+
engineEventCount: consumed ? consumed.length : 0,
|
|
234
|
+
humanLeg: consumedHuman ? { eventId: consumedHuman.eventId, inputOrigin: consumedHuman.inputOrigin, contentHash: consumedHuman.contentHash, sessionId: consumedHuman.sessionId } : null,
|
|
235
|
+
delegatedLeg: consumedDelegated ? { eventId: consumedDelegated.eventId, inputOrigin: consumedDelegated.inputOrigin, contentHash: consumedDelegated.contentHash, sessionId: consumedDelegated.sessionId } : null,
|
|
236
|
+
callerAssertedLeg: consumedAsserted ? { eventId: consumedAsserted.eventId, inputOrigin: consumedAsserted.inputOrigin, contentHash: consumedAsserted.contentHash, sessionId: consumedAsserted.sessionId } : null,
|
|
237
|
+
detail: 'the real engine consumed the real journal and recovered inputOrigin from the eventKey of each real event',
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
if (!consumedHuman || !consumedDelegated || !consumedAsserted) {
|
|
241
|
+
throw new Error('the engine did not consume the three real captured events');
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ---- the frozen snapshot of the engine ------------------------------
|
|
245
|
+
const { CommitConversationBinder } = require(BINDER_ENTRY);
|
|
246
|
+
const coordinator = engine.engine.coordinator;
|
|
247
|
+
const binder = new CommitConversationBinder({
|
|
248
|
+
layout: coordinator.layout,
|
|
249
|
+
projectStore: coordinator.projectStore,
|
|
250
|
+
conversationStore: coordinator.conversations,
|
|
251
|
+
});
|
|
252
|
+
const allEvents = coordinator.conversations.readEvents(projectId);
|
|
253
|
+
const commitSha = repo.headCommit;
|
|
254
|
+
const snapshot = coordinator.conversations.writeSnapshot(projectId, {
|
|
255
|
+
commitSha,
|
|
256
|
+
repoIdentity: repoIdentity.repoIdentity,
|
|
257
|
+
parentSha: null,
|
|
258
|
+
status: 'available',
|
|
259
|
+
turns: binder.buildExplicitTurns(allEvents),
|
|
260
|
+
});
|
|
261
|
+
record('MEM-008.C01.s5-engine-frozen-snapshot', snapshot && snapshot.snapshotHash ? 'PASS' : 'BLOCKED', {
|
|
262
|
+
commitSha,
|
|
263
|
+
snapshotHash: snapshot && snapshot.snapshotHash,
|
|
264
|
+
status: snapshot && snapshot.status,
|
|
265
|
+
turnCount: snapshot && snapshot.turns.length,
|
|
266
|
+
userEvents: snapshot ? snapshot.turns.reduce((total, turn) => total + turn.userEvents.length, 0) : 0,
|
|
267
|
+
frozenBy: 'the engine\'s own ConversationStore.writeSnapshot over the engine\'s own stored events, with the frozen binder projection buildExplicitTurns',
|
|
268
|
+
originsInSnapshot: snapshot ? snapshot.turns.flatMap(turn => turn.userEvents.map(event => ({ eventId: event.eventId, inputOrigin: event.inputOrigin }))) : [],
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// ---- the real long-term-memory candidate gate -----------------------
|
|
272
|
+
const memories = coordinator.memories;
|
|
273
|
+
const knowledgeDir = layout.projectKnowledgeDir;
|
|
274
|
+
const candidatesDir = path.join(knowledgeDir, 'memories', 'candidates');
|
|
275
|
+
fs.mkdirSync(candidatesDir, { recursive: true });
|
|
276
|
+
|
|
277
|
+
function buildCandidate(event, leg) {
|
|
278
|
+
const marker = markerFor(leg);
|
|
279
|
+
const entryId = `memories/candidates/c01-${leg.toLowerCase()}.md`;
|
|
280
|
+
fs.writeFileSync(path.join(knowledgeDir, ...entryId.split('/')), `# ${marker}\n\n合成测试条目 ${marker}。\n`, 'utf8');
|
|
281
|
+
return {
|
|
282
|
+
entryId,
|
|
283
|
+
text: marker,
|
|
284
|
+
quote: marker,
|
|
285
|
+
scopeType: 'global',
|
|
286
|
+
scopeId: brainId,
|
|
287
|
+
sourceEventId: event.eventId,
|
|
288
|
+
sourceHash: event.contentHash,
|
|
289
|
+
eligibility: { durable: true, crossProject: true, reason: 'synthetic C01 attribution probe', scopeReason: 'synthetic C01 attribution probe' },
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function runFor(candidate) {
|
|
294
|
+
return {
|
|
295
|
+
projectId,
|
|
296
|
+
commitSha,
|
|
297
|
+
promotedAt: new Date().toISOString(),
|
|
298
|
+
staging: {
|
|
299
|
+
operations: [{ path: candidate.entryId, operation: 'write', evidenceReferences: [`conversation:${snapshot.snapshotHash}`] }],
|
|
300
|
+
memoryCandidates: [candidate],
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
const humanCandidate = buildCandidate(consumedHuman, 'HUMAN');
|
|
306
|
+
const delegatedCandidate = buildCandidate(consumedDelegated, 'DELEGATED');
|
|
307
|
+
const assertedCandidate = buildCandidate(consumedAsserted, 'CALLERASSERTED');
|
|
308
|
+
|
|
309
|
+
const humanGate = memories.capture(runFor(humanCandidate));
|
|
310
|
+
const delegatedGate = memories.capture(runFor(delegatedCandidate));
|
|
311
|
+
const assertedGate = memories.capture(runFor(assertedCandidate));
|
|
312
|
+
|
|
313
|
+
record('MEM-008.C01.s6-gate-admits-human-labelled-event', humanGate.accepted === 1 ? 'PASS' : 'BLOCKED', {
|
|
314
|
+
gate: 'the real MemoryService.capture admission path of the frozen engine source',
|
|
315
|
+
inputOrigin: consumedHuman.inputOrigin,
|
|
316
|
+
accepted: humanGate.accepted,
|
|
317
|
+
rejected: humanGate.rejected,
|
|
318
|
+
detail: 'the gate is origin sensitive: a human-labelled real event passes every provenance check',
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
const delegatedRejected = (delegatedGate.rejected || []).some(entry => entry.code === 'SOURCE_NOT_HUMAN');
|
|
322
|
+
record('MEM-008.C01.s7-gate-rejects-delegated-event', delegatedRejected && delegatedGate.accepted === 0 ? 'PASS' : 'BLOCKED', {
|
|
323
|
+
gate: 'the real MemoryService.capture admission path of the frozen engine source',
|
|
324
|
+
inputOrigin: consumedDelegated.inputOrigin,
|
|
325
|
+
accepted: delegatedGate.accepted,
|
|
326
|
+
rejected: delegatedGate.rejected,
|
|
327
|
+
rejectionCode: (delegatedGate.rejected || [])[0] ? delegatedGate.rejected[0].code : null,
|
|
328
|
+
detail: 'a real delegation is refused by the long-term-memory candidate gate; it can never be admitted as a human turn',
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const assertedAccepted = assertedGate.accepted === 1;
|
|
332
|
+
record('MEM-008.C01.s8-c01-identity-not-provable', assertedAccepted ? 'BLOCKED' : 'PASS', {
|
|
333
|
+
gate: 'the real MemoryService.capture admission path of the frozen engine source',
|
|
334
|
+
inputOrigin: consumedAsserted.inputOrigin,
|
|
335
|
+
accepted: assertedGate.accepted,
|
|
336
|
+
rejected: assertedGate.rejected,
|
|
337
|
+
detail: 'the human label is asserted by the caller, not derived from an identity: a session that was never declared human was captured as human because the public input endpoint carried options.inputOrigin, and the gate admits it',
|
|
338
|
+
c01Verdict: 'BLOCKED — the chain carries no verified human identity, so "human == the owner" cannot be proven',
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
const authorFields = new Set();
|
|
342
|
+
for (const event of (journalEvents ? journalEvents.prompts : [])) {
|
|
343
|
+
for (const key of Object.keys(event)) if (/author|actor|owner|person/i.test(key)) authorFields.add(key);
|
|
344
|
+
}
|
|
345
|
+
record('MEM-008.C01.s9-no-author-identity-in-event', authorFields.size === 0 ? 'PASS' : 'BLOCKED', {
|
|
346
|
+
authorLikeFields: [...authorFields],
|
|
347
|
+
eventKeys: (journalEvents ? journalEvents.prompts : []).map(event => event.eventKey),
|
|
348
|
+
identityConfidenceMeaning: 'the console sets identityConfidence=exact for the REPOSITORY identity, not for a person',
|
|
349
|
+
detail: 'the normalised event carries the repository identity and the module origin, never an author identity',
|
|
350
|
+
});
|
|
351
|
+
} finally {
|
|
352
|
+
child.child.kill();
|
|
353
|
+
await child.exited;
|
|
354
|
+
await proxy.close();
|
|
355
|
+
await engine.close();
|
|
356
|
+
await vector.close();
|
|
357
|
+
await console_.close();
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const essentials = [
|
|
361
|
+
'MEM-008.C01.s1-three-real-turns',
|
|
362
|
+
'MEM-008.C01.s2-console-journal-origin',
|
|
363
|
+
'MEM-008.C01.s3-delegation-never-labelled-human',
|
|
364
|
+
'MEM-008.C01.s4-engine-recovered-origin',
|
|
365
|
+
'MEM-008.C01.s5-engine-frozen-snapshot',
|
|
366
|
+
'MEM-008.C01.s6-gate-admits-human-labelled-event',
|
|
367
|
+
'MEM-008.C01.s7-gate-rejects-delegated-event',
|
|
368
|
+
];
|
|
369
|
+
const essentialsPass = essentials.every(id => (results.find(entry => entry.caseId === id) || {}).status === 'PASS');
|
|
370
|
+
const c01Verdict = 'BLOCKED';
|
|
371
|
+
|
|
372
|
+
const cleanup = await shell.removeTreeAsync(layout.root);
|
|
373
|
+
if (!cleanup.removed) console.error(`CLEANUP-LEFTOVER ${cleanup.path} (${cleanup.error && cleanup.error.code})`);
|
|
374
|
+
|
|
375
|
+
const summary = {
|
|
376
|
+
lane: 'test-memory-injection',
|
|
377
|
+
file: 'parallel-memory-injection-origin-probe.js',
|
|
378
|
+
case: 'MEM-008-C01',
|
|
379
|
+
title: '真实 Workbench 事件归属与长期记忆 candidate 门禁',
|
|
380
|
+
c01Verdict,
|
|
381
|
+
c01VerdictReason: '真实委派被门禁以 SOURCE_NOT_HUMAN 拒绝;但 human 标签完全由调用方断言,链路中不存在可核验的人的身份,因此"human 就是本人"无法证明,C01 仍为 BLOCKED',
|
|
382
|
+
syntheticSource: true,
|
|
383
|
+
syntheticNote: '全部事件来自隔离夹具仓库与合成标记文本,不冒充任何真实用户身份',
|
|
384
|
+
cases: results,
|
|
385
|
+
ownership: {
|
|
386
|
+
laneOwned: [
|
|
387
|
+
'_site/_test/parallel-memory-injection-origin-probe.js',
|
|
388
|
+
'_site/_test/helpers/parallel-memory-injection-shell.js',
|
|
389
|
+
'_site/_test/helpers/parallel-memory-injection-wb-host.js',
|
|
390
|
+
],
|
|
391
|
+
snapshotProvenance: shell.snapshotProvenance(),
|
|
392
|
+
note: 'the three pieces copied into this lane helper are read-only snapshots of other lanes\' files; the sources are never edited or imported',
|
|
393
|
+
},
|
|
394
|
+
verdict: essentialsPass ? 'PASS (delegation is refused by the real gate) / C01 BLOCKED' : 'BLOCKED',
|
|
395
|
+
cleanup,
|
|
396
|
+
paidTurnsSent: 3,
|
|
397
|
+
networkUsed: true,
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
const target = process.env.PARALLEL_MEMORY_INJECTION_ORIGIN_EVIDENCE;
|
|
401
|
+
if (target) {
|
|
402
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
403
|
+
fs.writeFileSync(target, JSON.stringify(summary, null, 2), 'utf8');
|
|
404
|
+
}
|
|
405
|
+
console.log(`parallel-memory-injection-origin-probe verdict=${summary.verdict}`);
|
|
406
|
+
process.exitCode = essentialsPass ? 0 : 3;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
main().catch(error => {
|
|
410
|
+
console.error(error);
|
|
411
|
+
process.exitCode = 1;
|
|
412
|
+
});
|