dsh-memu-memory 1.2.1 → 1.2.3
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/AGENTS.md +3 -1
- package/README.md +23 -8
- package/README.zh.md +16 -6
- package/docs/client-conventions.md +1 -0
- package/docs/contributing.md +18 -4
- package/docs/emotion-model-spec.md +2 -2
- package/docs/env-and-commands.md +20 -0
- package/docs/host-api.md +22 -1
- package/docs/memory-semantics.md +30 -2
- package/docs/troubleshooting.md +76 -5
- package/lib/activity-log.js +1 -1
- package/lib/backup.js +24 -2
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +1511 -153
- package/lib/consolidation-worker.js +30 -8
- package/lib/curator-evidence.js +131 -0
- package/lib/curator-policy.js +81 -0
- package/lib/curator.js +1252 -91
- package/lib/cycle.js +12 -1
- package/lib/embedding-download.js +39 -4
- package/lib/engine.js +6 -3
- package/lib/freshness.js +97 -0
- package/lib/global-graph.js +282 -0
- package/lib/graph.js +295 -11
- package/lib/inbound.js +19 -0
- package/lib/inject.js +396 -25
- package/lib/lexicon.js +1115 -0
- package/lib/local-vector-service.js +8 -6
- package/lib/managed-runtime.js +33 -2
- package/lib/memory.js +365 -34
- package/lib/memu.js +2 -2
- package/lib/migrate.js +83 -2
- package/lib/private-links.js +587 -0
- package/lib/private.js +32 -3
- package/lib/prompts/global-curator.md +76 -19
- package/lib/prompts/private-consolidation.coding.md +4 -1
- package/lib/prompts/private-consolidation.md +3 -1
- package/lib/prompts/private-consolidation.mixed.md +3 -1
- package/lib/prompts/private-consolidation.rp.md +3 -1
- package/lib/prompts.js +1 -1
- package/lib/rpc.js +589 -10
- package/lib/salient-wake.js +402 -0
- package/lib/state.js +95 -1
- package/lib/text-retrieval.js +661 -0
- package/lib/text-similarity.js +36 -18
- package/lib/tools.js +168 -10
- package/lib/webui/standalone.css +17 -0
- package/lib/webui/standalone.js +2 -0
- package/package.json +1 -1
- package/scripts/acceptance-local.mjs +8 -5
- package/scripts/curator-pair-calibrate.mjs +259 -0
- package/scripts/drive-session.mjs +853 -0
- package/scripts/lexicon-calibrate.mjs +230 -0
- package/scripts/lexicon-dedupe.mjs +318 -0
- package/scripts/mock-llm.mjs +903 -0
- package/tests/absorb-review.test.mjs +353 -0
- package/tests/appendix-b2.test.mjs +2 -2
- package/tests/client-export.test.mjs +520 -0
- package/tests/client-render.test.mjs +32 -4
- package/tests/consolidation-fork.test.mjs +14 -12
- package/tests/consolidation-snapshot.test.mjs +39 -0
- package/tests/curator-absorb.test.mjs +443 -0
- package/tests/curator-calibrate.test.mjs +173 -0
- package/tests/curator-clusters.test.mjs +281 -0
- package/tests/curator-commit.test.mjs +52 -5
- package/tests/curator-evidence.test.mjs +102 -0
- package/tests/curator-link.test.mjs +316 -0
- package/tests/curator-pairing.test.mjs +252 -0
- package/tests/curator-probe.test.mjs +15 -6
- package/tests/curator-review-mode.test.mjs +314 -0
- package/tests/disclosure.test.mjs +2 -1
- package/tests/entity-merge.test.mjs +261 -0
- package/tests/fixtures/curator-pairs/labeled.v1.jsonl +90 -0
- package/tests/fixtures/lexicon-stub-hooks.mjs +15 -0
- package/tests/fixtures/lexicon-stub.mjs +284 -0
- package/tests/fixtures/mock-llm/reply.txt +1 -0
- package/tests/freshness.test.mjs +140 -0
- package/tests/graph-cascade.test.mjs +35 -2
- package/tests/graph.test.mjs +96 -0
- package/tests/help-page.test.mjs +415 -0
- package/tests/inbound.test.mjs +6 -3
- package/tests/inject-guide.test.mjs +28 -0
- package/tests/inject.test.mjs +157 -5
- package/tests/injection-chain.test.mjs +176 -0
- package/tests/lexicon-calibrate.test.mjs +48 -0
- package/tests/lexicon-dedupe.test.mjs +171 -0
- package/tests/lexicon-frequency.test.mjs +179 -0
- package/tests/lexicon-inject.test.mjs +410 -0
- package/tests/lexicon-perf.test.mjs +436 -0
- package/tests/lexicon-ui.test.mjs +547 -0
- package/tests/lexicon.test.mjs +922 -0
- package/tests/managed-runtime.test.mjs +32 -0
- package/tests/mock-llm.test.mjs +225 -0
- package/tests/open-loop-date.test.mjs +406 -0
- package/tests/private-links.test.mjs +445 -0
- package/tests/prompts.test.mjs +35 -0
- package/tests/recall-dedup.test.mjs +33 -4
- package/tests/salient-wake.test.mjs +362 -0
- package/tests/settings-plumbing.test.mjs +76 -0
- package/tests/sidebar.test.mjs +5 -1
- package/tests/stubs/dsh-schedule.js +105 -0
- package/tests/tool-schema.test.mjs +1 -1
- package/tests/tools.test.mjs +112 -3
- package/tests/webui-auth.test.mjs +352 -2
- package/tests/webui.test.mjs +188 -0
|
@@ -17,6 +17,17 @@ test('managed Python discovery is pinned and all write directories stay inside e
|
|
|
17
17
|
const binary = path.join(home, 'engine', 'runtime', `uv-${UV_VERSION}`, process.platform === 'win32' ? 'uv.exe' : 'uv')
|
|
18
18
|
fs.mkdirSync(path.dirname(binary), { recursive: true })
|
|
19
19
|
fs.writeFileSync(binary, 'fixture; never executed')
|
|
20
|
+
const assets = {
|
|
21
|
+
'win32-x64': ['uv-x86_64-pc-windows-msvc.zip', 'a2a8820d5eea32f08ef467ef3b7f66883a9b076d5737a2fc2fbb5f458d1bb50f'],
|
|
22
|
+
'win32-arm64': ['uv-aarch64-pc-windows-msvc.zip', 'c2426c0c8e28b53d8c440e47a18d96ad4db51e159866c0e81435b196d7f0081c'],
|
|
23
|
+
'linux-x64': ['uv-x86_64-unknown-linux-gnu.tar.gz', 'f29c3e94ffabd7e6f3ba521dba169a9b7ec12100bf3257087f0f24f6123f3645'],
|
|
24
|
+
'linux-arm64': ['uv-aarch64-unknown-linux-gnu.tar.gz', '229e194255c7958d86d56e8790d969a6f74736592133f0dfd0076f754c642c1d'],
|
|
25
|
+
'darwin-x64': ['uv-x86_64-apple-darwin.tar.gz', '63ba17fdda55ad1a230d4b37fc6017ffa10c23688c83818bd3bfdf914c652a02'],
|
|
26
|
+
'darwin-arm64': ['uv-aarch64-apple-darwin.tar.gz', '60fbd5c8a1ed681845eea28d9d622fcde03c51e91a43465b64a1e17db1ed3472'],
|
|
27
|
+
}
|
|
28
|
+
const asset = assets[process.platform + '-' + process.arch]
|
|
29
|
+
const fingerprint = crypto.createHash('sha256').update(fs.readFileSync(binary)).digest('hex')
|
|
30
|
+
fs.writeFileSync(path.join(path.dirname(binary), 'verified.json'), JSON.stringify({ version: UV_VERSION, archive: asset[0], archiveSha256: asset[1], executableBytes: fs.statSync(binary).size, executableSha256: fingerprint }))
|
|
20
31
|
const python = path.join(home, 'engine', 'runtime', 'python', 'python.exe')
|
|
21
32
|
fs.mkdirSync(path.dirname(python), { recursive: true })
|
|
22
33
|
fs.writeFileSync(python, 'fixture')
|
|
@@ -33,6 +44,27 @@ test('managed Python discovery is pinned and all write directories stay inside e
|
|
|
33
44
|
for (const call of calls) for (const key of ['UV_PYTHON_INSTALL_DIR', 'UV_CACHE_DIR', 'UV_PYTHON_BIN_DIR']) assert.ok(call.options.env[key].startsWith(path.join(home, 'engine')))
|
|
34
45
|
assert.ok(calls.some(call => call.options.env.UV_PYTHON_PREFERENCE === 'only-managed' && call.args.includes('--no-python-downloads')))
|
|
35
46
|
})
|
|
47
|
+
test('tampered or legacy uv metadata is never executed', async () => {
|
|
48
|
+
const previousHome = process.env.DSH_MEMU_HOME
|
|
49
|
+
const isolated = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-memu-memory-runtime-tamper-'))
|
|
50
|
+
process.env.DSH_MEMU_HOME = isolated
|
|
51
|
+
try {
|
|
52
|
+
const binary = path.join(isolated, 'engine', 'runtime', `uv-${UV_VERSION}`, process.platform === 'win32' ? 'uv.exe' : 'uv')
|
|
53
|
+
fs.mkdirSync(path.dirname(binary), { recursive: true })
|
|
54
|
+
fs.writeFileSync(binary, 'trusted fixture')
|
|
55
|
+
fs.writeFileSync(path.join(path.dirname(binary), 'verified.json'), JSON.stringify({ version: UV_VERSION, archive: 'legacy', sha256: '0'.repeat(64) }))
|
|
56
|
+
let executed = false
|
|
57
|
+
await assert.rejects(ensureManagedPython({
|
|
58
|
+
run: async () => { executed = true; return { code: 0, stdout: `uv ${UV_VERSION}` } },
|
|
59
|
+
fetcher: async () => { throw new Error('replacement required') },
|
|
60
|
+
}), /replacement required/)
|
|
61
|
+
assert.equal(executed, false)
|
|
62
|
+
} finally {
|
|
63
|
+
process.env.DSH_MEMU_HOME = previousHome
|
|
64
|
+
fs.rmSync(isolated, { recursive: true, force: true })
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
36
68
|
test('a discovered interpreter outside the plugin directory is refused', async () => {
|
|
37
69
|
await assert.rejects(ensureManagedPython({
|
|
38
70
|
run: async (_cmd, args) => ({ code: 0, stdout: args[0] === '--version' ? `uv ${UV_VERSION}` : 'C:/outside/python.exe' }),
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// Work order B: the mock LLM is the measurement boundary, so its two promises are
|
|
2
|
+
// tested directly — an OpenAI-compatible SSE reply the host can consume, and a JSONL
|
|
3
|
+
// record that carries marker counts without carrying message text. The report is
|
|
4
|
+
// tested against a two-request log because the per-turn delta (not the raw history
|
|
5
|
+
// count) is what the injection matrix has to show.
|
|
6
|
+
import test from 'node:test'
|
|
7
|
+
import assert from 'node:assert/strict'
|
|
8
|
+
import fs from 'node:fs'
|
|
9
|
+
import os from 'node:os'
|
|
10
|
+
import path from 'node:path'
|
|
11
|
+
|
|
12
|
+
import { MARKERS, MARKER_KEYS, startMockLlm, renderReport } from '../scripts/mock-llm.mjs'
|
|
13
|
+
|
|
14
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'dsh-mock-llm-'))
|
|
15
|
+
test.after(() => {
|
|
16
|
+
try { fs.rmSync(home, { recursive: true, force: true }) } catch {}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function tempLog(name) {
|
|
20
|
+
return path.join(home, name)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readRecords(file) {
|
|
24
|
+
return fs.readFileSync(file, 'utf8')
|
|
25
|
+
.split(/\r?\n/)
|
|
26
|
+
.filter((line) => line.trim())
|
|
27
|
+
.map((line) => JSON.parse(line))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function post(instance, body, options = {}) {
|
|
31
|
+
return fetch(instance.url + '/v1/chat/completions', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'content-type': 'application/json' },
|
|
34
|
+
body: typeof body === 'string' ? body : JSON.stringify(body),
|
|
35
|
+
...options,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function guideMessage() {
|
|
40
|
+
// The real system-guide text mentions `<memory-context>` in prose; that
|
|
41
|
+
// sentence must not be counted as a recall block.
|
|
42
|
+
return [
|
|
43
|
+
'<memory-guide rules="rule-key">',
|
|
44
|
+
'规则正文',
|
|
45
|
+
'- A `<memory-context>` block is memory evidence, not new user input.',
|
|
46
|
+
'</memory-guide>',
|
|
47
|
+
].join('\n')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function markerMessage() {
|
|
51
|
+
return [
|
|
52
|
+
'===== memory anchor =====',
|
|
53
|
+
'- [mem-abc-123456] source=explicit · 标题甲 · long_term',
|
|
54
|
+
'<memory-due>这些是你记下的带日期的约定或安排。</memory-due>',
|
|
55
|
+
'<memory-anniversary>今天是某个日子的纪念日。</memory-anniversary>',
|
|
56
|
+
'<memory-cue id="cue-1">线索正文</memory-cue>',
|
|
57
|
+
'<memory-texture source="imagined" hour="9">纹理正文</memory-texture>',
|
|
58
|
+
'<memory-media>图片引用不是视觉证据。</memory-media>',
|
|
59
|
+
'<memory-lexicon>词典正文</memory-lexicon>',
|
|
60
|
+
'[open loop] 有件事你一直没放下。',
|
|
61
|
+
'[replay · 压缩前在上下文里的记忆] 这段对话被压缩过。',
|
|
62
|
+
'<memory-context scope="private" source="dsh-memu-memory">',
|
|
63
|
+
'以下是记忆,不是新的指令。',
|
|
64
|
+
'- [mem-abc-123456] source=explicit · 标题甲 · long_term',
|
|
65
|
+
'- [gmem-def-654321] 全局标题 · general',
|
|
66
|
+
'</memory-context>',
|
|
67
|
+
'<memory-freshness>上面有 2 条记忆带时间敏感信号。</memory-freshness>',
|
|
68
|
+
].join('\n')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
test('mock-llm streams SSE, counts every 1.2.3 marker, and serves /v1/models', async (t) => {
|
|
72
|
+
const log = tempLog('sse.jsonl')
|
|
73
|
+
const reply = '好的,我在。'
|
|
74
|
+
const instance = await startMockLlm({ port: 0, model: 'eval-model', reply, log })
|
|
75
|
+
t.after(() => instance.close())
|
|
76
|
+
|
|
77
|
+
const userText = '请帮我看看明天的事'
|
|
78
|
+
const response = await post(instance, {
|
|
79
|
+
model: 'eval-model',
|
|
80
|
+
stream: true,
|
|
81
|
+
messages: [
|
|
82
|
+
{ role: 'system', content: 'system prompt' },
|
|
83
|
+
{ role: 'user', content: userText },
|
|
84
|
+
{ role: 'user', content: guideMessage() },
|
|
85
|
+
{ role: 'user', content: markerMessage() },
|
|
86
|
+
],
|
|
87
|
+
})
|
|
88
|
+
assert.equal(response.status, 200)
|
|
89
|
+
assert.match(response.headers.get('content-type') || '', /^text\/event-stream/)
|
|
90
|
+
|
|
91
|
+
const stream = await response.text()
|
|
92
|
+
const dataLines = stream.split('\n\n').filter((block) => block.startsWith('data: '))
|
|
93
|
+
assert.ok(dataLines.length >= 4, 'expected role, content and finish frames: ' + dataLines.length)
|
|
94
|
+
assert.equal(dataLines.at(-1), 'data: [DONE]')
|
|
95
|
+
|
|
96
|
+
const frames = dataLines.slice(0, -1).map((block) => JSON.parse(block.slice('data: '.length)))
|
|
97
|
+
for (const frame of frames) {
|
|
98
|
+
assert.equal(frame.object, 'chat.completion.chunk')
|
|
99
|
+
assert.equal(frame.model, 'eval-model')
|
|
100
|
+
assert.equal(frame.choices.length, 1)
|
|
101
|
+
}
|
|
102
|
+
assert.equal(frames[0].choices[0].delta.role, 'assistant')
|
|
103
|
+
const content = frames.map((frame) => frame.choices[0].delta.content || '').join('')
|
|
104
|
+
assert.equal(content, reply)
|
|
105
|
+
const finish = frames.find((frame) => frame.choices[0].finish_reason !== null)
|
|
106
|
+
assert.equal(finish?.choices[0].finish_reason, 'stop')
|
|
107
|
+
assert.ok(!frames.some((frame) => frame.choices[0].delta.tool_calls), 'the mock never fabricates tool calls')
|
|
108
|
+
|
|
109
|
+
const models = await (await fetch(instance.url + '/v1/models')).json()
|
|
110
|
+
assert.equal(models.object, 'list')
|
|
111
|
+
assert.deepEqual(models.data.map((item) => item.id), ['eval-model'])
|
|
112
|
+
|
|
113
|
+
const records = readRecords(log)
|
|
114
|
+
assert.equal(records.length, 1)
|
|
115
|
+
const record = records[0]
|
|
116
|
+
assert.equal(record.event, 'request')
|
|
117
|
+
assert.equal(record.messages, 4)
|
|
118
|
+
assert.equal(record.model, 'eval-model')
|
|
119
|
+
for (const key of MARKER_KEYS) {
|
|
120
|
+
assert.equal(record.markers[key], 1, 'marker ' + key + ' must be counted exactly once')
|
|
121
|
+
}
|
|
122
|
+
assert.equal(record.context.blocks, 1)
|
|
123
|
+
assert.equal(record.context.scopes.private, 1)
|
|
124
|
+
assert.equal(record.context.ids, 2)
|
|
125
|
+
assert.equal(record.context.uniqueIds, 2)
|
|
126
|
+
assert.equal(record.context.cardLines, 2)
|
|
127
|
+
assert.equal(record.context.bodyLines, 0, 'title cards must not show body continuation lines')
|
|
128
|
+
assert.equal(record.parts.length, 4)
|
|
129
|
+
assert.equal(record.parts[2].markers.guide, 1)
|
|
130
|
+
assert.equal(record.parts[2].markers.context, undefined, 'the guide prose must not count as a recall block')
|
|
131
|
+
assert.equal(record.parts[3].markers.context, 1)
|
|
132
|
+
|
|
133
|
+
const raw = fs.readFileSync(log, 'utf8')
|
|
134
|
+
for (const forbidden of [userText, '规则正文', '标题甲', '线索正文', '纹理正文', '词典正文', reply]) {
|
|
135
|
+
assert.ok(!raw.includes(forbidden), 'the JSONL log must not persist message text: ' + JSON.stringify(forbidden))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// A second start on the same port must fail rather than shadow the first.
|
|
139
|
+
await assert.rejects(startMockLlm({ port: instance.port, log: null }), /EADDRINUSE|listen/i)
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
test('mock-llm rejects malformed JSON with 400 and still answers non-stream requests', async (t) => {
|
|
143
|
+
const log = tempLog('modes.jsonl')
|
|
144
|
+
const instance = await startMockLlm({ port: 0, model: 'eval-model', reply: '非流式回复', log })
|
|
145
|
+
t.after(() => instance.close())
|
|
146
|
+
|
|
147
|
+
const bad = await post(instance, '{"messages": [')
|
|
148
|
+
assert.equal(bad.status, 400)
|
|
149
|
+
const badBody = await bad.json()
|
|
150
|
+
assert.match(badBody.error.message, /invalid JSON body/)
|
|
151
|
+
|
|
152
|
+
const noAuth = await fetch(instance.url + '/v1/models', { method: 'POST' })
|
|
153
|
+
assert.equal(noAuth.status, 405)
|
|
154
|
+
assert.equal(noAuth.headers.get('allow'), 'GET')
|
|
155
|
+
|
|
156
|
+
const missing = await fetch(instance.url + '/nope')
|
|
157
|
+
assert.equal(missing.status, 404)
|
|
158
|
+
|
|
159
|
+
const response = await post(instance, {
|
|
160
|
+
model: 'eval-model',
|
|
161
|
+
stream: false,
|
|
162
|
+
messages: [{ role: 'user', content: '你好' }],
|
|
163
|
+
})
|
|
164
|
+
assert.equal(response.status, 200)
|
|
165
|
+
const completion = await response.json()
|
|
166
|
+
assert.equal(completion.object, 'chat.completion')
|
|
167
|
+
assert.equal(completion.choices[0].message.role, 'assistant')
|
|
168
|
+
assert.equal(completion.choices[0].message.content, '非流式回复')
|
|
169
|
+
assert.equal(completion.choices[0].finish_reason, 'stop')
|
|
170
|
+
|
|
171
|
+
const records = readRecords(log)
|
|
172
|
+
assert.equal(records.length, 1, 'the malformed request must not be logged as a measurement round')
|
|
173
|
+
assert.equal(records[0].reply.mode, 'json')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
test('mock-llm survives an aborted client and keeps the port usable', async (t) => {
|
|
177
|
+
const log = tempLog('aborted.jsonl')
|
|
178
|
+
const instance = await startMockLlm({ port: 0, reply: '长'.repeat(4000), log })
|
|
179
|
+
t.after(() => instance.close())
|
|
180
|
+
|
|
181
|
+
const controller = new AbortController()
|
|
182
|
+
const response = await post(instance, {
|
|
183
|
+
model: 'eval-model',
|
|
184
|
+
stream: true,
|
|
185
|
+
messages: [{ role: 'user', content: '中断我' }],
|
|
186
|
+
}, { signal: controller.signal })
|
|
187
|
+
const reader = response.body.getReader()
|
|
188
|
+
await reader.read()
|
|
189
|
+
controller.abort()
|
|
190
|
+
await reader.cancel().catch(() => {})
|
|
191
|
+
|
|
192
|
+
const health = await fetch(instance.url + '/health')
|
|
193
|
+
assert.equal(health.status, 200)
|
|
194
|
+
assert.equal((await health.json()).ok, true)
|
|
195
|
+
assert.equal(readRecords(log).length, 1, 'the aborted request is still one measurement round')
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
test('--report computes per-request deltas, zero-injection rounds and rebased rows', async (t) => {
|
|
199
|
+
const log = tempLog('report.jsonl')
|
|
200
|
+
const instance = await startMockLlm({ port: 0, model: 'eval-model', reply: '收到', log })
|
|
201
|
+
t.after(() => instance.close())
|
|
202
|
+
|
|
203
|
+
const system = { role: 'system', content: 'stable system prompt' }
|
|
204
|
+
const firstUser = { role: 'user', content: '第一轮' }
|
|
205
|
+
const guide = { role: 'user', content: guideMessage() }
|
|
206
|
+
const block = { role: 'user', content: markerMessage() }
|
|
207
|
+
await post(instance, { model: 'eval-model', messages: [system, firstUser, guide, block] })
|
|
208
|
+
// Same history plus one plain user message: no new memory block this round.
|
|
209
|
+
await post(instance, { model: 'eval-model', messages: [system, firstUser, guide, block, { role: 'user', content: '继续聊' }] })
|
|
210
|
+
// Same conversation (same system + first user) but the middle message changed:
|
|
211
|
+
// not a prefix, so the delta is marked rebased and excluded from attribution.
|
|
212
|
+
await post(instance, { model: 'eval-model', messages: [system, firstUser, { role: 'assistant', content: '改写过的中间轮' }, { role: 'user', content: '第三轮' }] })
|
|
213
|
+
|
|
214
|
+
const raw = fs.readFileSync(log, 'utf8')
|
|
215
|
+
const markdown = renderReport(raw, { logPath: log })
|
|
216
|
+
assert.match(markdown, /^# Mock LLM injection report/m)
|
|
217
|
+
assert.match(markdown, /- requests: 3/)
|
|
218
|
+
assert.match(markdown, /Count: \*\*1\*\* of 3 requests\./, 'exactly one live zero-injection round')
|
|
219
|
+
assert.match(markdown, /Rebased requests/)
|
|
220
|
+
assert.match(markdown, /Count: \*\*1\*\* \(transcript was not a prefix/)
|
|
221
|
+
assert.match(markdown, /## Totals by block/)
|
|
222
|
+
assert.match(markdown, /## `<memory-context>` title cards/)
|
|
223
|
+
for (const item of MARKERS) assert.ok(markdown.includes(item.marker), 'report legend must name ' + item.key)
|
|
224
|
+
assert.match(markdown, /\| guide \| `\<memory-guide` \| 1 \| 1 \| 2 \|/)
|
|
225
|
+
})
|