dsh-memu-memory 1.3.15 → 1.4.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/AGENTS.md +5 -2
- package/CHANGELOG.md +49 -1
- package/README.md +4 -1
- package/README.zh.md +4 -1
- package/docs/client-conventions.md +1 -0
- package/docs/host-adaptation.md +52 -36
- package/docs/host-versions.md +120 -0
- package/docs/memory-semantics.md +4 -2
- package/docs/pending-work.md +51 -0
- package/docs/troubleshooting.md +41 -2
- package/lib/auto-link/candidates.js +4 -1
- package/lib/auto-link/decide.js +1 -1
- package/lib/auto-link/normalize.js +2 -2
- package/lib/auto-link/terminology.js +31 -1
- package/lib/binding-diagnostics.js +2 -2
- package/lib/client.js +53 -6
- package/lib/consolidation-snapshot.js +7 -1
- package/lib/consolidation-worker.js +11 -3
- package/lib/curator.js +17 -5
- package/lib/cycle.js +75 -4
- package/lib/diagnostics.js +10 -0
- package/lib/entity-repair.js +285 -0
- package/lib/environment-check.js +72 -3
- package/lib/global-graph.js +11 -2
- package/lib/graph.js +32 -8
- package/lib/host-surface.js +30 -0
- package/lib/index.js +120 -3
- package/lib/inject.js +142 -8
- package/lib/memory.js +72 -0
- package/lib/private-links.js +12 -0
- package/lib/private.js +49 -13
- package/lib/prompts/private-consolidation.coding.md +3 -1
- package/lib/prompts/private-consolidation.md +2 -0
- package/lib/prompts/private-consolidation.mixed.md +2 -0
- package/lib/prompts/private-consolidation.rp.md +2 -0
- package/lib/prompts/system-guide.coding.md +8 -2
- package/lib/prompts/system-guide.md +6 -0
- package/lib/prompts/system-guide.mixed.md +11 -0
- package/lib/prompts/system-guide.rp.md +6 -0
- package/lib/rpc.js +48 -10
- package/lib/state.js +5 -1
- package/lib/turn-log.js +34 -11
- package/lib/worker-pool.js +11 -7
- package/package.json +16 -1
- package/scripts/chain-matrix.mjs +4 -0
- package/scripts/check-doc-drift.mjs +194 -0
- package/scripts/entity-dedupe.mjs +110 -0
- package/tests/auto-link-candidates.test.mjs +22 -9
- package/tests/auto-link-decide.test.mjs +59 -59
- package/tests/auto-link-migration.test.mjs +4 -4
- package/tests/client-render.test.mjs +112 -1
- package/tests/consolidation-fork.test.mjs +20 -1
- package/tests/curator-probe.test.mjs +19 -1
- package/tests/cycle.test.mjs +2 -2
- package/tests/diagnostics.test.mjs +21 -0
- package/tests/doc-drift.test.mjs +122 -2
- package/tests/entity-merge.test.mjs +17 -0
- package/tests/environment-check.test.mjs +28 -0
- package/tests/global-graph.test.mjs +16 -0
- package/tests/global-lifecycle.test.mjs +24 -4
- package/tests/graph-cascade.test.mjs +111 -0
- package/tests/hybrid-recall.test.mjs +1 -1
- package/tests/inject-guide.test.mjs +108 -1
- package/tests/managed-memory.test.mjs +7 -7
- package/tests/private-links.test.mjs +12 -0
- package/tests/prompts.test.mjs +30 -0
- package/tests/recall-corpus-eligibility.test.mjs +3 -3
- package/tests/salience-domain.test.mjs +34 -0
- package/tests/settings-plumbing.test.mjs +2 -0
- package/tests/stale-maintenance.test.mjs +131 -0
- package/tests/tools.test.mjs +1 -1
- package/tests/turn-log.test.mjs +13 -0
- package/tests/webui-auth.test.mjs +58 -0
|
@@ -47,31 +47,31 @@ function index(entries) {
|
|
|
47
47
|
test('mentions are boundary-aware and punctuation-insensitive: CJK substrings, identifiers, NFKC folding', () => {
|
|
48
48
|
assert.equal(normalize.mentionCount('yuike 和 yuikeee', 'yuike'), 1, 'Latin must not match a longer identifier')
|
|
49
49
|
assert.equal(normalize.mentionCount('YUIKE!来了', 'yuike'), 1, 'full-width and punctuation fold away')
|
|
50
|
-
assert.equal(normalize.mentionCount('
|
|
50
|
+
assert.equal(normalize.mentionCount('洛云澜来了,洛云澜走了', '洛云澜'), 2)
|
|
51
51
|
// §8.1: NFKC + 去标点/空白 applies to the name as well as the text.
|
|
52
|
-
assert.equal(normalize.mentionCount('
|
|
53
|
-
assert.equal(normalize.mentionCount('小
|
|
54
|
-
assert.equal(normalize.mentionCount('
|
|
52
|
+
assert.equal(normalize.mentionCount('小·檀来了', '小檀'), 1)
|
|
53
|
+
assert.equal(normalize.mentionCount('小 檀来了', '小檀'), 1)
|
|
54
|
+
assert.equal(normalize.mentionCount('小檀来了', '小 檀'), 1)
|
|
55
55
|
// §2: code identifiers keep their punctuation and their word boundaries.
|
|
56
56
|
assert.equal(normalize.mentionCount('Yuike_01 上线', 'Yuike_01'), 1)
|
|
57
57
|
assert.equal(normalize.mentionCount('yuike.dev is down', 'yuike.dev'), 1)
|
|
58
|
-
assert.equal(normalize.mentionCount('
|
|
58
|
+
assert.equal(normalize.mentionCount('洛云澜-alex 来了', '洛云澜-alex'), 1)
|
|
59
59
|
assert.equal(normalize.firstMention('猫娘yuike', 'yuike'), 2)
|
|
60
|
-
assert.equal(normalize.firstMention('
|
|
60
|
+
assert.equal(normalize.firstMention('「小·檀」来了', '小檀'), 1, 'offset is the raw text position, not the compact index')
|
|
61
61
|
assert.equal(normalize.isMentionSurface('小'), false, 'one CJK character is not a surface')
|
|
62
|
-
assert.equal(normalize.isMentionSurface('
|
|
62
|
+
assert.equal(normalize.isMentionSurface('小檀'), true)
|
|
63
63
|
assert.equal(normalize.isMentionSurface('a'), false, 'one Latin character is not a surface')
|
|
64
64
|
})
|
|
65
65
|
|
|
66
66
|
test('punctuated and identifier surfaces produce mention edges with raw offsets', () => {
|
|
67
67
|
const lib = library('punct')
|
|
68
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
68
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
69
69
|
const yuike = graph.createEntity({ libraryId: lib, name: 'yuike_01', kind: 'person', status: 'confirmed' })
|
|
70
|
-
const mixed = graph.createEntity({ libraryId: lib, name: '
|
|
70
|
+
const mixed = graph.createEntity({ libraryId: lib, name: '洛云澜-alex', kind: 'person', status: 'confirmed' })
|
|
71
71
|
const snapshot = index({
|
|
72
|
-
'mem-a': entry('
|
|
72
|
+
'mem-a': entry('「小·檀」来了', '她带着伞。'),
|
|
73
73
|
'mem-b': entry('yuike_01 上线', 'yuike_01 迟到了。'),
|
|
74
|
-
'mem-c': entry('
|
|
74
|
+
'mem-c': entry('洛云澜-alex 到访', '洛云澜-alex 和 洛云澜 yuike 都来了。'),
|
|
75
75
|
})
|
|
76
76
|
const edges = decide.decideAutoLinks({ index: snapshot, entities: [you, yuike, mixed] })
|
|
77
77
|
const mention = edges.filter(edge => edge.rule === 'entity-mention')
|
|
@@ -79,8 +79,8 @@ test('punctuated and identifier surfaces produce mention edges with raw offsets'
|
|
|
79
79
|
for (const edge of edges) assert.ok(policy.EVIDENCE_RULES.includes(edge.rule), 'only the declared rule vocabulary: ' + edge.rule)
|
|
80
80
|
const byEntity = new Map(mention.map(edge => [edge.to, edge]))
|
|
81
81
|
const youEdge = byEntity.get(you.id)
|
|
82
|
-
assert.equal(youEdge.evidence.surface, '
|
|
83
|
-
assert.equal(youEdge.evidence.offset, 1, 'raw offset inside
|
|
82
|
+
assert.equal(youEdge.evidence.surface, '小檀')
|
|
83
|
+
assert.equal(youEdge.evidence.offset, 1, 'raw offset inside 「小·檀」')
|
|
84
84
|
assert.ok(byEntity.has(yuike.id), 'identifier with underscore is found')
|
|
85
85
|
assert.ok(byEntity.has(mixed.id), 'mixed CJK-Latin name is found')
|
|
86
86
|
})
|
|
@@ -89,17 +89,17 @@ test('punctuated and identifier surfaces produce mention edges with raw offsets'
|
|
|
89
89
|
|
|
90
90
|
test('only confirmed entities produce mention edges; provisional, archived and secret rows do not', () => {
|
|
91
91
|
const lib = library('mention')
|
|
92
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
93
|
-
graph.createEntity({ libraryId: lib, name: '
|
|
92
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', aliases: ['檀子'], status: 'confirmed', confirmedBy: 'user' })
|
|
93
|
+
graph.createEntity({ libraryId: lib, name: '沈砚舟', kind: 'person' })
|
|
94
94
|
graph.createEntity({ libraryId: lib, name: '阿兰', kind: 'person', status: 'archived' })
|
|
95
95
|
const snapshot = index({
|
|
96
|
-
'mem-a': entry('
|
|
97
|
-
'mem-b': entry('
|
|
96
|
+
'mem-a': entry('小檀今天来了', '她带了一篮水果。'),
|
|
97
|
+
'mem-b': entry('沈砚舟的日记', '沈砚舟写下了今天的安排。'),
|
|
98
98
|
'mem-c': entry('阿兰回信', '阿兰说下周再联系。'),
|
|
99
|
-
'mem-d': entry('
|
|
100
|
-
'mem-e': entry('
|
|
99
|
+
'mem-d': entry('小檀与秘密', '关于小檀的一件不能外传的事。', { visibility: 'secret' }),
|
|
100
|
+
'mem-e': entry('小檀旧事', '小檀很久以前来过。', { status: 'archived' }),
|
|
101
101
|
})
|
|
102
|
-
const edges = decide.decideAutoLinks({ index: snapshot, entities: [you, { id: 'ent-provisional', name: '
|
|
102
|
+
const edges = decide.decideAutoLinks({ index: snapshot, entities: [you, { id: 'ent-provisional', name: '沈砚舟', kind: 'person', status: 'provisional' }, { id: 'ent-archived', name: '阿兰', kind: 'person', status: 'archived' }] })
|
|
103
103
|
const mention = edges.filter(edge => edge.rule === 'entity-mention')
|
|
104
104
|
assert.equal(mention.length, 1, 'one eligible memory mentions the confirmed entity')
|
|
105
105
|
assert.equal(mention[0].from, 'mem-a')
|
|
@@ -107,7 +107,7 @@ test('only confirmed entities produce mention edges; provisional, archived and s
|
|
|
107
107
|
assert.equal(mention[0].kind, 'person')
|
|
108
108
|
assert.equal(mention[0].confidence, 1)
|
|
109
109
|
assert.equal(mention[0].schemaVersion, 2)
|
|
110
|
-
assert.ok(mention[0].evidence.surface === '
|
|
110
|
+
assert.ok(mention[0].evidence.surface === '小檀' || mention[0].evidence.surface === '檀子')
|
|
111
111
|
assert.equal(mention[0].evidence.entityId, you.id)
|
|
112
112
|
assert.equal(mention[0].evidence.field, 'title')
|
|
113
113
|
assert.equal(mention[0].evidence.offset, 0)
|
|
@@ -115,8 +115,8 @@ test('only confirmed entities produce mention edges; provisional, archived and s
|
|
|
115
115
|
|
|
116
116
|
test('suppression removes a decided edge and decide stays pure', () => {
|
|
117
117
|
const lib = library('suppress')
|
|
118
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
119
|
-
const snapshot = index({ 'mem-a': entry('
|
|
118
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
119
|
+
const snapshot = index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') })
|
|
120
120
|
const first = decide.decideAutoLinks({ index: snapshot, entities: [you] })
|
|
121
121
|
const second = decide.decideAutoLinks({ index: snapshot, entities: [you] })
|
|
122
122
|
assert.deepEqual(second, first, 'same input -> same output')
|
|
@@ -152,10 +152,10 @@ test('field evidence builds conflict, supersede and fact-key edges without cliqu
|
|
|
152
152
|
|
|
153
153
|
test('apply writes evidence and never overwrites a manual edge', () => {
|
|
154
154
|
const lib = library('apply')
|
|
155
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
155
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
156
156
|
state.savePrivateIndex(lib, index({
|
|
157
|
-
'mem-a': entry('
|
|
158
|
-
'mem-b': entry('
|
|
157
|
+
'mem-a': entry('小檀来了', '小檀进门坐下。'),
|
|
158
|
+
'mem-b': entry('小檀与阿檀', '小檀提起阿檀。', {
|
|
159
159
|
links: [{ to: you.id, kind: 'person', note: '用户手动确认过这条关系。', confidence: 0.9 }],
|
|
160
160
|
}),
|
|
161
161
|
}))
|
|
@@ -181,11 +181,11 @@ test('apply writes evidence and never overwrites a manual edge', () => {
|
|
|
181
181
|
|
|
182
182
|
test('confirming an entity flips its status and backfills mention edges immediately', () => {
|
|
183
183
|
const lib = library('confirm')
|
|
184
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
184
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
185
185
|
assert.equal(you.status, 'provisional', 'creation alone does not confirm')
|
|
186
186
|
state.savePrivateIndex(lib, index({
|
|
187
|
-
'mem-a': entry('
|
|
188
|
-
'mem-b': entry('
|
|
187
|
+
'mem-a': entry('小檀来了', '小檀进门坐下。'),
|
|
188
|
+
'mem-b': entry('小檀的伞', '小檀把伞落在门口。'),
|
|
189
189
|
}))
|
|
190
190
|
const confirmed = graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
191
191
|
assert.deepEqual(confirmed.confirmed, [you.id])
|
|
@@ -203,29 +203,29 @@ test('confirming an entity flips its status and backfills mention edges immediat
|
|
|
203
203
|
|
|
204
204
|
test('renaming a confirmed entity retires stale mention edges and attaches the new surface', () => {
|
|
205
205
|
const lib = library('rename')
|
|
206
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
206
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
207
207
|
state.savePrivateIndex(lib, index({
|
|
208
|
-
'mem-a': entry('
|
|
209
|
-
'mem-b': entry('
|
|
208
|
+
'mem-a': entry('小檀来了', '小檀进门坐下。'),
|
|
209
|
+
'mem-b': entry('檀子来了', '檀子带着伞。'),
|
|
210
210
|
}))
|
|
211
211
|
graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
212
212
|
assert.ok((state.loadPrivateIndex(lib).entries['mem-a'].links || []).some(link => link.to === you.id))
|
|
213
|
-
graph.renameEntity({ libraryId: lib, entityId: you.id, name: '
|
|
213
|
+
graph.renameEntity({ libraryId: lib, entityId: you.id, name: '檀子', aliases: [] })
|
|
214
214
|
const rows = state.loadPrivateIndex(lib)
|
|
215
215
|
assert.equal((rows.entries['mem-a'].links || []).some(link => link.to === you.id), false, 'old name no longer matches')
|
|
216
|
-
assert.ok((rows.entries['mem-b'].links || []).some(link => link.to === you.id && link.evidence?.surface === '
|
|
216
|
+
assert.ok((rows.entries['mem-b'].links || []).some(link => link.to === you.id && link.evidence?.surface === '檀子'))
|
|
217
217
|
})
|
|
218
218
|
|
|
219
219
|
test('merging a confirmed source into a provisional target confirms it and remaps evidence', () => {
|
|
220
220
|
const lib = library('merge')
|
|
221
|
-
const source = graph.createEntity({ libraryId: lib, name: '
|
|
222
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
221
|
+
const source = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
222
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
223
223
|
graph.confirmEntities({ libraryId: lib, entityIds: [source.id], by: 'user' })
|
|
224
|
-
const target = graph.createEntity({ libraryId: lib, name: '
|
|
224
|
+
const target = graph.createEntity({ libraryId: lib, name: '檀子', kind: 'person' })
|
|
225
225
|
graph.mergeEntities({ libraryId: lib, targetId: target.id, sourceIds: [source.id] })
|
|
226
226
|
const store = graph.graphExport(lib)
|
|
227
227
|
assert.equal(store.entities[target.id].status, 'confirmed', 'a confirmed source confirms the surviving row')
|
|
228
|
-
assert.deepEqual(store.entities[target.id].aliases, ['
|
|
228
|
+
assert.deepEqual(store.entities[target.id].aliases, ['小檀'])
|
|
229
229
|
const link = (state.loadPrivateIndex(lib).entries['mem-a'].links || []).find(item => item.to === target.id)
|
|
230
230
|
assert.ok(link, 'the mention edge points at the merged row')
|
|
231
231
|
assert.equal(link.evidence.entityId, target.id)
|
|
@@ -233,8 +233,8 @@ test('merging a confirmed source into a provisional target confirms it and remap
|
|
|
233
233
|
|
|
234
234
|
test('deleting an entity records suppression for the auto edges it collects', () => {
|
|
235
235
|
const lib = library('delete')
|
|
236
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
237
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
236
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
237
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
238
238
|
graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
239
239
|
graph.deleteEntity({ libraryId: lib, entityId: you.id, force: true })
|
|
240
240
|
const store = suppression.readSuppression(lib)
|
|
@@ -244,8 +244,8 @@ test('deleting an entity records suppression for the auto edges it collects', ()
|
|
|
244
244
|
|
|
245
245
|
test('removing an auto edge by hand suppresses it against the next recompute', () => {
|
|
246
246
|
const lib = library('unlink')
|
|
247
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
248
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
247
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
248
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
249
249
|
graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
250
250
|
const removed = graph.unlinkEntry({ libraryId: lib, fromId: 'mem-a', toId: you.id, kind: 'person' })
|
|
251
251
|
assert.equal(removed.removed, 1)
|
|
@@ -258,9 +258,9 @@ test('removing an auto edge by hand suppresses it against the next recompute', (
|
|
|
258
258
|
|
|
259
259
|
test('deleting a legacy auto edge also blocks the later entity-mention edge (P6)', () => {
|
|
260
260
|
const lib = library('legacy-suppress')
|
|
261
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
261
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
262
262
|
state.savePrivateIndex(lib, index({
|
|
263
|
-
'mem-a': entry('
|
|
263
|
+
'mem-a': entry('小檀来了', '小檀进门坐下。', {
|
|
264
264
|
links: [{ to: you.id, kind: 'person', note: '旧算法自动建立的实体枢纽。', confidence: 0.65, source: 'auto' }],
|
|
265
265
|
}),
|
|
266
266
|
}))
|
|
@@ -297,8 +297,8 @@ test('purgeAutoLinks removes only auto edges, keeps a manual edge byte-for-byte
|
|
|
297
297
|
|
|
298
298
|
test('off mode closes explicit mention maintenance too, and apply rejects unknown rules', () => {
|
|
299
299
|
const lib = library('off-mode')
|
|
300
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
301
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
300
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
301
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
302
302
|
state.updateSettings({ autoLinkMode: 'off' })
|
|
303
303
|
try {
|
|
304
304
|
const result = graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
@@ -306,7 +306,7 @@ test('off mode closes explicit mention maintenance too, and apply rejects unknow
|
|
|
306
306
|
assert.equal(result.entities, 0, 'off writes no edge')
|
|
307
307
|
assert.equal((state.loadPrivateIndex(lib).entries['mem-a'].links || []).length, 0)
|
|
308
308
|
// A hand-supplied edge outside the evidence vocabulary is refused by the writer.
|
|
309
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
309
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
310
310
|
const applied = apply.applyAutoEdges({
|
|
311
311
|
libraryId: lib,
|
|
312
312
|
entities: [you],
|
|
@@ -321,8 +321,8 @@ test('off mode closes explicit mention maintenance too, and apply rejects unknow
|
|
|
321
321
|
|
|
322
322
|
test('clearLinkSuppression removes markers and the deterministic rebuild restores the edge', async () => {
|
|
323
323
|
const lib = library('clear-suppress')
|
|
324
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
325
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
324
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
325
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
326
326
|
state.updateSettings({ autoLinkMode: 'deterministic' })
|
|
327
327
|
try {
|
|
328
328
|
graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
@@ -340,8 +340,8 @@ test('clearLinkSuppression removes markers and the deterministic rebuild restore
|
|
|
340
340
|
|
|
341
341
|
test('switching to deterministic backfills entities confirmed while off', async () => {
|
|
342
342
|
const lib = library('mode-switch')
|
|
343
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
344
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
343
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person' })
|
|
344
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
345
345
|
state.updateSettings({ autoLinkMode: 'off' })
|
|
346
346
|
try {
|
|
347
347
|
const off = graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
@@ -357,8 +357,8 @@ test('switching to deterministic backfills entities confirmed while off', async
|
|
|
357
357
|
|
|
358
358
|
test('re-confirming an already-confirmed entity backfills missing mentions', () => {
|
|
359
359
|
const lib = library('reconfirm')
|
|
360
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
361
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
360
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
361
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
362
362
|
const result = graph.confirmEntities({ libraryId: lib, entityIds: [you.id], by: 'user' })
|
|
363
363
|
assert.deepEqual(result.confirmed, [], 'it was already confirmed')
|
|
364
364
|
assert.equal(result.entities, 1, 'the refresh still runs and attaches the edge')
|
|
@@ -369,8 +369,8 @@ test('three automatic passes in suggest mode add no edges', async () => {
|
|
|
369
369
|
state.updateSettings({ autoLinkMode: 'suggest' })
|
|
370
370
|
try {
|
|
371
371
|
const lib = library('suggest-three')
|
|
372
|
-
graph.createEntity({ libraryId: lib, name: '
|
|
373
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
372
|
+
graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
373
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
374
374
|
for (let pass = 0; pass < 3; pass += 1) {
|
|
375
375
|
const result = await privateLinks.refreshPrivateAutoLinks({ libraryId: lib, ids: ['mem-a'] })
|
|
376
376
|
assert.equal(result.skipped, 'suggest')
|
|
@@ -398,7 +398,7 @@ test('confirming eight entities backfills all mentions in one batch (8 x 9 = 72)
|
|
|
398
398
|
|
|
399
399
|
test('a broken entity store makes the automatic refresh fail open (warn, no throw)', async () => {
|
|
400
400
|
const lib = library('broken-entities')
|
|
401
|
-
state.savePrivateIndex(lib, index({ 'mem-a': entry('
|
|
401
|
+
state.savePrivateIndex(lib, index({ 'mem-a': entry('小檀来了', '小檀进门坐下。') }))
|
|
402
402
|
const file = path.join(home, 'index', `${lib}.entities.json`)
|
|
403
403
|
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
404
404
|
fs.writeFileSync(file, '{not json', 'utf8')
|
|
@@ -496,11 +496,11 @@ test('review accept refreshes the supersede edge immediately and stays silent in
|
|
|
496
496
|
|
|
497
497
|
test('recallRelations ignores entity-mention edges even at confidence 1.0 but keeps field evidence', () => {
|
|
498
498
|
const lib = library('recall')
|
|
499
|
-
const you = graph.createEntity({ libraryId: lib, name: '
|
|
499
|
+
const you = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
500
500
|
state.savePrivateIndex(lib, index({
|
|
501
|
-
'mem-a': entry('
|
|
501
|
+
'mem-a': entry('小檀来了', '小檀进门坐下。', {
|
|
502
502
|
links: [
|
|
503
|
-
{ to: you.id, kind: 'person', note: '
|
|
503
|
+
{ to: you.id, kind: 'person', note: '提及已确认实体「小檀」(标题)。', confidence: 1, source: 'auto', evidence: { rule: 'entity-mention', entityId: you.id, surface: '小檀', field: 'title', offset: 0 } },
|
|
504
504
|
{ to: 'mem-b', kind: 'conflict', note: '字段证据:conflicts_with 指向这条记忆。', confidence: 1, source: 'auto', evidence: { rule: 'conflict', field: 'conflicts_with' } },
|
|
505
505
|
],
|
|
506
506
|
}),
|
|
@@ -76,14 +76,14 @@ test('dry run reports legacy edges and writes no entity status or edge', async (
|
|
|
76
76
|
test('apply backs up, removes legacy auto edges, grades rows and rebuilds confirmed mentions', async () => {
|
|
77
77
|
const binding = state.ensureSession('migration-apply', { cwd: path.join(home, 'ws-apply'), agentPreset: 'rp' })
|
|
78
78
|
const lib = binding.libraryId
|
|
79
|
-
const confirmed = graph.createEntity({ libraryId: lib, name: '
|
|
80
|
-
const provisional = graph.createEntity({ libraryId: lib, name: '
|
|
79
|
+
const confirmed = graph.createEntity({ libraryId: lib, name: '小檀', kind: 'person', status: 'confirmed' })
|
|
80
|
+
const provisional = graph.createEntity({ libraryId: lib, name: '沈砚舟', kind: 'person' })
|
|
81
81
|
state.savePrivateIndex(lib, { version: 1, entries: {
|
|
82
|
-
'mem-a': entry('
|
|
82
|
+
'mem-a': entry('小檀来了,沈砚舟也在', '小檀进门,沈砚舟在窗边。', [
|
|
83
83
|
{ to: 'mem-b', kind: 'relation', note: '旧的词面自动关联,没有任何证据字段。', confidence: 0.66, source: 'auto' },
|
|
84
84
|
{ to: 'mem-b', kind: 'event', note: '用户手动建立的一条边,不能被迁移删掉。', confidence: 0.8 },
|
|
85
85
|
]),
|
|
86
|
-
'mem-b': entry('另一条记录', '
|
|
86
|
+
'mem-b': entry('另一条记录', '只有小檀出现。'),
|
|
87
87
|
} })
|
|
88
88
|
const report = await runRebuildAutoLinks({ apply: true, json: true, log: () => {} })
|
|
89
89
|
assert.ok(report.backup, 'apply takes a backup first')
|
|
@@ -327,8 +327,44 @@ test('graph studio pages all libraries and filters custom domains without mergin
|
|
|
327
327
|
} finally { view.close() }
|
|
328
328
|
})
|
|
329
329
|
|
|
330
|
-
test('graph
|
|
330
|
+
test('the whole-workspace graph sends its domain filter to the global endpoint', async () => {
|
|
331
|
+
const calls = []
|
|
331
332
|
const call = async (endpoint, payload) => {
|
|
333
|
+
calls.push({ endpoint, payload })
|
|
334
|
+
if (endpoint !== 'getGraph') return { items: [] }
|
|
335
|
+
const wanted = 'project:travel'
|
|
336
|
+
const hit = !payload.domain || payload.domain === wanted
|
|
337
|
+
return {
|
|
338
|
+
scope: 'global',
|
|
339
|
+
nodes: hit ? [{ id: 'mem-g-1', title: 'global memory', kind: 'global', domain: 'project:travel' }] : [],
|
|
340
|
+
edges: [],
|
|
341
|
+
domains: ['general', 'project:travel'],
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// 没有私有库时面板落在全局图:这条路径走的是 getGlobalGraph,不是逐库合并。
|
|
345
|
+
const view = await graphStudioHarness(call, [])
|
|
346
|
+
try {
|
|
347
|
+
let tree = await view.render(true)
|
|
348
|
+
view.pick(tree, node => node.type === 'input' && node.props['aria-label'] === 'gsDomain')[0]
|
|
349
|
+
.props.onChange({ target: { value: 'project:travel' } })
|
|
350
|
+
tree = await view.render(true)
|
|
351
|
+
const asked = calls.filter(row => row.endpoint === 'getGraph')
|
|
352
|
+
const last = asked[asked.length - 1]
|
|
353
|
+
assert.equal(last.payload.scope, 'global', 'the panel stayed on the global graph')
|
|
354
|
+
assert.equal(last.payload.domain, 'project:travel', 'the global branch forwards the domain filter')
|
|
355
|
+
const datalist = view.pick(tree, node => node.type === 'datalist' && node.props?.id === 'dshm-graph-domains')[0]
|
|
356
|
+
const options = []
|
|
357
|
+
const visit = (value) => {
|
|
358
|
+
if (Array.isArray(value)) { value.forEach(visit); return }
|
|
359
|
+
if (value && value.type === 'option') options.push(String(value.props?.value ?? ''))
|
|
360
|
+
}
|
|
361
|
+
if (datalist) visit([].concat(datalist.props?.children ?? []))
|
|
362
|
+
assert.deepEqual(options, ['rp', 'coding', 'general', 'mixed', 'project:travel'].sort(),
|
|
363
|
+
'the datalist keeps every domain the server reported, not only the filtered one')
|
|
364
|
+
} finally { view.close() }
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
test('graph studio surfaces failed libraries and retains successful results', async () => { const call = async (endpoint, payload) => {
|
|
332
368
|
if (endpoint !== 'getGraph') return { items: [] }
|
|
333
369
|
if (payload.libraryId === 'lib-denied') throw new Error('forbidden')
|
|
334
370
|
return { nodes: [{ id: 'mem-ok', title: 'visible', kind: 'memory' }], edges: [], nextOffset: null }
|
|
@@ -1614,3 +1650,78 @@ test('the memory wall global block bulk-archives and the drawer deletes global e
|
|
|
1614
1650
|
delete RPC_ANSWERS.deleteMemory
|
|
1615
1651
|
}
|
|
1616
1652
|
})
|
|
1653
|
+
|
|
1654
|
+
test('the memory wall filters by domain and names every card domain', async () => {
|
|
1655
|
+
const rpcCalls = []
|
|
1656
|
+
const ctx = fakeCtx({ rpcCalls })
|
|
1657
|
+
const originalGetState = RPC_ANSWERS.getState
|
|
1658
|
+
const originalSettingsState = RPC_ANSWERS.getSettingsState
|
|
1659
|
+
const loaded = {
|
|
1660
|
+
...EMPTY_STATE,
|
|
1661
|
+
libraries: [{ id: 'lib-1', name: 'demo', scopeKey: '/proj/demo', privateCount: 2 }],
|
|
1662
|
+
}
|
|
1663
|
+
RPC_ANSWERS.getState = loaded
|
|
1664
|
+
RPC_ANSWERS.getSettingsState = loaded
|
|
1665
|
+
RPC_ANSWERS.browseWall = {
|
|
1666
|
+
total: 2,
|
|
1667
|
+
domains: ['coding', 'rp'],
|
|
1668
|
+
items: [
|
|
1669
|
+
{ id: 'mem-rp', libraryId: 'lib-1', libraryName: 'demo', title: '约定的日子', preview: 'p', layer: 'long_term', status: 'active', source: 'user_said', decay: 0.5, tags: [], domain: 'rp' },
|
|
1670
|
+
{ id: 'mem-code', libraryId: 'lib-1', libraryName: 'demo', title: '部署窗口', preview: 'p', layer: 'long_term', status: 'active', source: 'inferred', decay: 0.4, tags: [], domain: 'coding' },
|
|
1671
|
+
],
|
|
1672
|
+
}
|
|
1673
|
+
const settle = async () => {
|
|
1674
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
1675
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
1676
|
+
}
|
|
1677
|
+
// harness 的 hook 游标是全局的:同一棵树只能展开一次,二次 walk 会把子组件的
|
|
1678
|
+
// useState 重新初始化。所以每轮 render 只走一遍,把要的东西一次收齐。
|
|
1679
|
+
const collect = (tree) => {
|
|
1680
|
+
const found = { select: null, domainTags: [], cards: 0 }
|
|
1681
|
+
walkNodes(tree, (node) => {
|
|
1682
|
+
if (node.type === 'select' && node.props?.['aria-label'] === 'wallFilterDomain' && !found.select) found.select = node
|
|
1683
|
+
if (node.type === 'span' && node.props?.title === 'wallDomainHint') found.domainTags.push(String(node.props?.children ?? ''))
|
|
1684
|
+
if (node.type === 'button' && String(node.props?.className || '').includes('dshm-wall-item')) found.cards += 1
|
|
1685
|
+
})
|
|
1686
|
+
const values = []
|
|
1687
|
+
const visit = (value) => {
|
|
1688
|
+
if (Array.isArray(value)) { value.forEach(visit); return }
|
|
1689
|
+
if (value && value.type === 'option') values.push(String(value.props?.value ?? ''))
|
|
1690
|
+
}
|
|
1691
|
+
if (found.select) visit([].concat(found.select.props?.children ?? []))
|
|
1692
|
+
found.values = values
|
|
1693
|
+
return found
|
|
1694
|
+
}
|
|
1695
|
+
try {
|
|
1696
|
+
globalThis.__dshMemuExports.apply(ctx)
|
|
1697
|
+
const settings = registrations.filter((r) => r.slot === 'settings.section').pop()
|
|
1698
|
+
const props = { ctx, t: (key) => key }
|
|
1699
|
+
const first = await renderPage(settings.component, props, undefined, { remount: true })
|
|
1700
|
+
collectPageHook()
|
|
1701
|
+
for (const effect of first.effects) effect.fn()
|
|
1702
|
+
await settle()
|
|
1703
|
+
let view = collect((await renderPage(settings.component, props, 9)).tree)
|
|
1704
|
+
for (const effect of effects) effect.fn()
|
|
1705
|
+
await settle()
|
|
1706
|
+
view = collect((await renderPage(settings.component, props, 9)).tree)
|
|
1707
|
+
|
|
1708
|
+
assert.ok(view.select, 'the wall renders a domain filter')
|
|
1709
|
+
assert.equal(view.cards, 2, 'both wall cards rendered')
|
|
1710
|
+
assert.deepEqual(view.values, ['', 'coding', 'rp'], 'the filter offers every domain the server reported')
|
|
1711
|
+
assert.deepEqual(view.domainTags.sort(), ['dmCoding', 'dmRp'], 'each card names the domain it came from')
|
|
1712
|
+
|
|
1713
|
+
view.select.props.onChange({ target: { value: 'rp' } })
|
|
1714
|
+
view = collect((await renderPage(settings.component, props, 9)).tree)
|
|
1715
|
+
for (const effect of effects) effect.fn()
|
|
1716
|
+
await settle()
|
|
1717
|
+
const asked = rpcCalls.filter((call) => call.endpoint === 'browseWall')
|
|
1718
|
+
assert.equal(asked[asked.length - 1].payload.domain, 'rp', 'picking a domain asks the server instead of trimming the page in the browser')
|
|
1719
|
+
view = collect((await renderPage(settings.component, props, 9)).tree)
|
|
1720
|
+
assert.deepEqual(view.domainTags, [], 'once filtered, cards stop repeating the same domain')
|
|
1721
|
+
assert.equal(view.select.props.value, 'rp', 'the filter keeps what the reader picked')
|
|
1722
|
+
} finally {
|
|
1723
|
+
RPC_ANSWERS.getState = originalGetState
|
|
1724
|
+
RPC_ANSWERS.getSettingsState = originalSettingsState
|
|
1725
|
+
delete RPC_ANSWERS.browseWall
|
|
1726
|
+
}
|
|
1727
|
+
})
|
|
@@ -17,7 +17,7 @@ const forkModel = await import('../lib/fork-model.js')
|
|
|
17
17
|
const { dataDir, setWarnSink } = await import('../lib/paths.js')
|
|
18
18
|
const { retireWorker } = await import('../lib/worker-pool.js')
|
|
19
19
|
const { CORE_WRITE_TOOLS, WORKER_TOOL_ALLOW } = await import('../lib/consolidation-worker.js')
|
|
20
|
-
const { requestPrivateConsolidation, isConsolidating, consolidationWaitBudget, CONSOLIDATION_WAIT_POLICY, CONSOLIDATION_WINDOW_EVENTS, isEffortRefused, markEffortRefused, effortRefusalOf, compactSeedEvents, selectConsolidationWindow, selectTailTurnWindow, mustCoverCandidates, mergeMustCover, candidateCovered } = await import('../lib/private.js')
|
|
20
|
+
const { requestPrivateConsolidation, isConsolidating, consolidationWaitBudget, CONSOLIDATION_WAIT_POLICY, CONSOLIDATION_WINDOW_EVENTS, isEffortRefused, markEffortRefused, effortRefusalOf, compactSeedEvents, selectConsolidationWindow, selectTailTurnWindow, mustCoverCandidates, mergeMustCover, candidateCovered, seedLimitsFor } = await import('../lib/private.js')
|
|
21
21
|
// 这些用例验证“路由继承”,不是推理强度;默认 medium 由 config 测试单独覆盖。
|
|
22
22
|
state.updateSettings({ consolidationReasoningEffort: 'inherit' })
|
|
23
23
|
|
|
@@ -1518,3 +1518,22 @@ test('missing buildForkSeed only disables fork; worker really completes without
|
|
|
1518
1518
|
child.release()
|
|
1519
1519
|
await child.done
|
|
1520
1520
|
})
|
|
1521
|
+
|
|
1522
|
+
test('coding seeds keep more tool output and arguments than the default caps', () => {
|
|
1523
|
+
const events = [
|
|
1524
|
+
{ seq: 0, type: 'user/message', data: { source: { kind: 'user' }, content: [{ type: 'text', text: '改代码' }] } },
|
|
1525
|
+
{ seq: 1, type: 'tool/call', data: { callId: 'c1', name: 'edit', arguments: '{"patch":"' + 'A'.repeat(1500) + '"}' } },
|
|
1526
|
+
{ seq: 2, type: 'tool/result', data: { message: { callId: 'c1', content: [{ type: 'text', text: 'R'.repeat(3000) }] } } },
|
|
1527
|
+
{ seq: 3, type: 'assistant/message', data: { message: { content: [{ type: 'text', text: '完成' }] } } },
|
|
1528
|
+
]
|
|
1529
|
+
const sizes = (seed) => ({
|
|
1530
|
+
args: String(seed.find((event) => event.type === 'tool/call').data.arguments).length,
|
|
1531
|
+
result: String(seed.find((event) => event.type === 'tool/result').data.message.content[0].text).length,
|
|
1532
|
+
})
|
|
1533
|
+
const plain = sizes(compactSeedEvents(events))
|
|
1534
|
+
const coding = sizes(compactSeedEvents(events, null, seedLimitsFor('coding')))
|
|
1535
|
+
assert.ok(plain.args <= 510, 'the default argument cap is unchanged')
|
|
1536
|
+
assert.ok(coding.args > 1000, 'coding keeps a longer tool-call argument body')
|
|
1537
|
+
assert.ok(plain.result <= 1110, 'the default result cap is unchanged')
|
|
1538
|
+
assert.ok(coding.result > 2100 && coding.result < 2300, 'coding keeps 2200 chars of the tool result')
|
|
1539
|
+
})
|
|
@@ -64,7 +64,7 @@ crypto.randomBytes = (size) => {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const {
|
|
67
|
-
startGlobalCuration, commitCuratorOutput, getCurationJob, condenseEvents,
|
|
67
|
+
startGlobalCuration, commitCuratorOutput, getCurationJob, condenseEvents, condenseLimitsFor,
|
|
68
68
|
} = await import('../lib/curator.js')
|
|
69
69
|
const { loadGlobalIndex, saveGlobalIndex } = await import('../lib/state.js')
|
|
70
70
|
const { dataDir } = await import('../lib/paths.js')
|
|
@@ -470,3 +470,21 @@ test('condense keeps private prose; redaction only covers credential-shaped stri
|
|
|
470
470
|
assert.match(text, /Bearer \[REDACTED_KEY\]/)
|
|
471
471
|
assert.doesNotMatch(text, /abcdefghijklmnopqrstuvwxyz/)
|
|
472
472
|
})
|
|
473
|
+
|
|
474
|
+
test('condenseLimitsFor widens coding tool caps; the default stays 400/300', () => {
|
|
475
|
+
const events = [
|
|
476
|
+
{ type: 'tool/call', data: { name: 'edit', arguments: '{"patch":"' + 'A'.repeat(1200) + '"}' } },
|
|
477
|
+
{ type: 'tool/result', data: { message: { content: [{ type: 'text', text: 'R'.repeat(3000) }] } } },
|
|
478
|
+
]
|
|
479
|
+
const plain = condenseEvents(events, 200000)
|
|
480
|
+
const coding = condenseEvents(events, 200000, condenseLimitsFor('coding'))
|
|
481
|
+
const plainCall = (plain.match(/Tool call: edit (.*)/) || [])[1] || ''
|
|
482
|
+
const codingCall = (coding.match(/Tool call: edit (.*)/) || [])[1] || ''
|
|
483
|
+
const plainResult = (plain.match(/Tool result: (.*)/) || [])[1] || ''
|
|
484
|
+
const codingResult = (coding.match(/Tool result: (.*)/) || [])[1] || ''
|
|
485
|
+
assert.ok(plainCall.length <= 310, 'the default argument cap is unchanged')
|
|
486
|
+
assert.ok(codingCall.length > 700, 'coding keeps more of the call arguments')
|
|
487
|
+
assert.ok(plainResult.length <= 410, 'the default result cap is unchanged')
|
|
488
|
+
assert.ok(codingResult.length > 1400 && codingResult.length < 1500, 'coding keeps 1400 chars of the result')
|
|
489
|
+
assert.equal(condenseLimitsFor('rp').toolResultChars, 400)
|
|
490
|
+
})
|
package/tests/cycle.test.mjs
CHANGED
|
@@ -521,7 +521,7 @@ test('a session arriving at an archived library revives it through the fast path
|
|
|
521
521
|
})
|
|
522
522
|
|
|
523
523
|
test('a legacy archive with no recorded source is not revived just because an old binding exists', () => {
|
|
524
|
-
// 本机实测:rp(14
|
|
524
|
+
// 本机实测:rp(14 个绑定)、另一个工作区库(4 个)都是「归档 + 还有旧绑定」,但 lastUsed 三周前。
|
|
525
525
|
// 旧数据分不清是用户归档还是老扫描误归档,所以只复活「还热」的;冷的不动。
|
|
526
526
|
const lib = state.createLibrary({ name: 'legacy-cold', cwd: path.join(home, 'legacy-cold') })
|
|
527
527
|
const st = state.loadState()
|
|
@@ -553,7 +553,7 @@ test('a warm legacy archive (no source recorded, used minutes ago) is revived',
|
|
|
553
553
|
})
|
|
554
554
|
|
|
555
555
|
test('a cold legacy archive with an old binding can still be deleted', () => {
|
|
556
|
-
// 本机 rp /
|
|
556
|
+
// 本机 rp / 另一个工作区库 形态:很久以前归档、仍留着旧绑定、lastUsed 三周前。
|
|
557
557
|
// 它不是扫描误归档(那类会被自愈),也不该因为“有旧绑定”变成永远删不掉。
|
|
558
558
|
const lib = state.createLibrary({ name: 'legacy-deletable', cwd: path.join(home, 'legacy-deletable') })
|
|
559
559
|
const st = state.loadState()
|
|
@@ -255,3 +255,24 @@ test('rows on disk survive a restart, so the page is not empty after a reload',
|
|
|
255
255
|
assert.equal(parsed.total >= 1, true, 'a fresh process must read the persisted rows')
|
|
256
256
|
assert.equal(parsed.code, 'PERSISTED_ROW')
|
|
257
257
|
})
|
|
258
|
+
|
|
259
|
+
// docs/host-versions.md §13.6:台账指纹的运行时对应物。它不判断、不比版本号,
|
|
260
|
+
// 只是把已经发生过的结构探测结果聚合成一行——所以断言盯着"记下了什么"。
|
|
261
|
+
test('host surface records probe verdicts and refuses unregistered keys', async () => {
|
|
262
|
+
const surface = await import('../lib/host-surface.js')
|
|
263
|
+
const before = surface.hostSurface()
|
|
264
|
+
assert.deepEqual(Object.keys(before).sort(), [...surface.HOST_SURFACES].sort())
|
|
265
|
+
|
|
266
|
+
surface.noteHostSurface('rpcGuard', 'admit')
|
|
267
|
+
assert.equal(surface.hostSurface().rpcGuard, 'admit')
|
|
268
|
+
surface.noteHostSurface('rpcGuard', '')
|
|
269
|
+
assert.equal(surface.hostSurface().rpcGuard, 'admit', 'an empty verdict never erases a known one')
|
|
270
|
+
surface.noteHostSurface('semver', '0.2.3-alpha.1')
|
|
271
|
+
assert.equal('semver' in surface.hostSurface(), false, 'a stale call site cannot invent a ledger key')
|
|
272
|
+
|
|
273
|
+
const line = surface.hostSurfaceLine()
|
|
274
|
+
assert.match(line, /rpcGuard=admit/)
|
|
275
|
+
assert.equal(line.split(' ').length, surface.HOST_SURFACES.length)
|
|
276
|
+
for (const part of line.split(' ')) assert.match(part, /^[a-zA-Z]+=\S+$/, 'every surface prints key=value: ' + line)
|
|
277
|
+
surface.noteHostSurface('rpcGuard', before.rpcGuard)
|
|
278
|
+
})
|