dsh-memu-memory 1.3.11 → 1.3.13
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/CHANGELOG.md +28 -0
- package/README.md +3 -3
- package/README.zh.md +1 -1
- package/docs/contributing.md +14 -2
- package/docs/memory-semantics.md +4 -2
- package/docs/troubleshooting.md +52 -1
- package/lib/auto-link/candidates.js +10 -5
- package/lib/auto-link/terminology.js +34 -18
- package/lib/binding-diagnostics.js +1 -1
- package/lib/client.js +431 -69
- package/lib/diagnostics.js +514 -0
- package/lib/environment-check.js +325 -0
- package/lib/graph.js +94 -21
- package/lib/index.js +70 -2
- package/lib/local-embedding-manager.js +39 -5
- package/lib/memory.js +81 -0
- package/lib/paths.js +153 -10
- package/lib/private.js +14 -2
- package/lib/rpc.js +66 -2
- package/lib/tools.js +4 -20
- package/lib/vector-profile.js +302 -8
- package/lib/webui/graph-view.bundle.js +1 -1
- package/lib/webui/graph-view.js +1 -2
- package/lib/webui/standalone.js +2 -2
- package/package.json +1 -1
- package/tests/auto-link-candidates.test.mjs +71 -0
- package/tests/client-render.test.mjs +226 -3
- package/tests/diagnostics.test.mjs +257 -0
- package/tests/environment-check.test.mjs +159 -0
- package/tests/global-lifecycle.test.mjs +130 -0
- package/tests/graph-view.test.mjs +31 -3
- package/tests/graph.test.mjs +110 -0
- package/tests/tools.test.mjs +95 -0
- package/tests/webui-auth.test.mjs +73 -0
- package/tests/webui.test.mjs +2 -1
|
@@ -520,6 +520,7 @@ const MATRIX_SHA = 'a'.repeat(64)
|
|
|
520
520
|
const matrixRows = [
|
|
521
521
|
{ endpoint: 'getMemory', operation: 'read', payload: (lib) => ({ libraryId: lib.id, id: 'mem-matrix-scratch' }) },
|
|
522
522
|
{ endpoint: 'browseWall', operation: 'read', payload: (lib) => ({ libraryId: lib.id }) },
|
|
523
|
+
{ endpoint: 'getGraph', operation: 'read', payload: (lib) => ({ libraryId: lib.id, offset: 0, domain: 'coding' }) },
|
|
523
524
|
{ endpoint: 'getStats', operation: 'read', payload: (lib) => ({ libraryId: lib.id }) },
|
|
524
525
|
// 工单 F:实体合并的读写面。合并矩阵只验证路由授权:不存在的实体在 200
|
|
525
526
|
// 业务信封里报 unknown entity,403 必须在 dispatch 之前发生。
|
|
@@ -783,6 +784,78 @@ test('global review queue: embedded sessions may read, writes need a live bindin
|
|
|
783
784
|
}
|
|
784
785
|
})
|
|
785
786
|
|
|
787
|
+
// 全局生命周期(1.3.12):scope:'global' 的 archiveMemory/updateMemory/deleteMemory
|
|
788
|
+
// 与全局复核队列同一管理面凭据模型——embedded 要活绑定、standalone 走 libraryId=null
|
|
789
|
+
// 的 review.manage;scope 与 libraryId 同时出现是作用域冲突,先于 dispatch 拒绝。
|
|
790
|
+
test('global lifecycle: scope global follows the global management credential model', async () => {
|
|
791
|
+
const seedGlobalActive = () => {
|
|
792
|
+
state.updateGlobalIndex((index) => {
|
|
793
|
+
index.entries['mem-global-lifecycle'] = {
|
|
794
|
+
title: 'global lifecycle', content: 'global lifecycle body', status: 'active', layer: 'long_term',
|
|
795
|
+
domain: 'general', visibility: 'shared', disclosure: 'can_tell', source: 'inferred',
|
|
796
|
+
createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(),
|
|
797
|
+
}
|
|
798
|
+
})
|
|
799
|
+
state.flushState()
|
|
800
|
+
}
|
|
801
|
+
const post = (prefix, endpoint, payload) => send(prefix.route, prefix.base + '/' + endpoint, { method: 'POST', body: envelope(endpoint, payload) })
|
|
802
|
+
for (const prefix of prefixes) {
|
|
803
|
+
seedGlobalActive()
|
|
804
|
+
auth.callbackMode = 'present'
|
|
805
|
+
auth.libraryDecision = true
|
|
806
|
+
auth.libraryCalls = 0
|
|
807
|
+
const embedded = await post(prefix, 'archiveMemory', { scope: 'global', sessionId, id: 'mem-global-lifecycle' })
|
|
808
|
+
assert.equal(embedded.res.status, 200, `${prefix.name}: a live binding may archive global memory without the host callback`)
|
|
809
|
+
assert.equal(JSON.parse(embedded.res.text).result.ok, true)
|
|
810
|
+
assert.equal(state.loadGlobalIndex().entries['mem-global-lifecycle'].status, 'archived')
|
|
811
|
+
assert.equal(auth.libraryCalls, 0)
|
|
812
|
+
|
|
813
|
+
seedGlobalActive()
|
|
814
|
+
const ghost = await post(prefix, 'archiveMemory', { scope: 'global', sessionId: 'ghost-session', id: 'mem-global-lifecycle' })
|
|
815
|
+
assert.equal(ghost.res.status, 403, `${prefix.name}: a dangling session is never a credential`)
|
|
816
|
+
assert.equal(state.loadGlobalIndex().entries['mem-global-lifecycle'].status, 'active', 'a denied write must not touch the store')
|
|
817
|
+
|
|
818
|
+
const conflict = await post(prefix, 'archiveMemory', { scope: 'global', libraryId: 'lib-whatever', id: 'mem-global-lifecycle' })
|
|
819
|
+
assert.equal(conflict.res.status, 403, `${prefix.name}: scope global alongside a libraryId is a scope conflict`)
|
|
820
|
+
|
|
821
|
+
const rows = [
|
|
822
|
+
['archiveMemory', { scope: 'global', id: 'mem-global-lifecycle' }],
|
|
823
|
+
['updateMemory', { scope: 'global', id: 'mem-global-lifecycle', patch: { status: 'active' } }],
|
|
824
|
+
['deleteMemory', { scope: 'global', id: 'mem-global-lifecycle', confirmed: true }],
|
|
825
|
+
]
|
|
826
|
+
for (const [endpoint, payload] of rows) {
|
|
827
|
+
seedGlobalActive()
|
|
828
|
+
if (endpoint !== 'archiveMemory') {
|
|
829
|
+
state.updateGlobalIndex((index) => { index.entries['mem-global-lifecycle'].status = 'archived' })
|
|
830
|
+
}
|
|
831
|
+
auth.callbackMode = 'present'
|
|
832
|
+
auth.libraryDecision = true
|
|
833
|
+
auth.libraryCalls = 0
|
|
834
|
+
auth.libraryRequests.length = 0
|
|
835
|
+
const granted = await post(prefix, endpoint, payload)
|
|
836
|
+
assert.equal(granted.res.status, 200, `${prefix.name} ${endpoint}: review.manage true must grant`)
|
|
837
|
+
assert.equal(JSON.parse(granted.res.text).result.ok, true)
|
|
838
|
+
assert.equal(auth.libraryCalls, 1)
|
|
839
|
+
assert.equal(auth.libraryRequests.at(-1).libraryId, null, 'global lifecycle authorizes with libraryId null')
|
|
840
|
+
assert.equal(auth.libraryRequests.at(-1).operation, 'review.manage')
|
|
841
|
+
|
|
842
|
+
seedGlobalActive()
|
|
843
|
+
auth.libraryDecision = false
|
|
844
|
+
auth.libraryCalls = 0
|
|
845
|
+
assert.equal((await post(prefix, endpoint, payload)).res.status, 403, `${prefix.name} ${endpoint}: review.manage false must deny`)
|
|
846
|
+
assert.equal(auth.libraryCalls, 1)
|
|
847
|
+
|
|
848
|
+
auth.callbackMode = 'throw'
|
|
849
|
+
auth.libraryDecision = true
|
|
850
|
+
assert.equal((await post(prefix, endpoint, payload)).res.status, 403, `${prefix.name} ${endpoint}: a thrown callback must deny`)
|
|
851
|
+
|
|
852
|
+
auth.callbackMode = 'absent'
|
|
853
|
+
assert.equal((await post(prefix, endpoint, payload)).res.status, 200, `${prefix.name} ${endpoint}: absent callback falls back to the HTTP boundary`)
|
|
854
|
+
auth.callbackMode = 'present'
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
})
|
|
858
|
+
|
|
786
859
|
|
|
787
860
|
// ---- 2026-11-01 现场(Unexpected token "forbidden" / Invalid RPC response: 403)----
|
|
788
861
|
// 无 libraryId 的 browseWall("全部记忆库"视图)曾被硬拒 403:capability 缺席的宿主
|
package/tests/webui.test.mjs
CHANGED
|
@@ -135,7 +135,8 @@ test('the wall drawer reads exactly one memory', async () => {
|
|
|
135
135
|
assert.match(source, /function WallCover/, 'cards use the first usable attachment as a cover')
|
|
136
136
|
assert.match(source, /className: 'dshm-wall-cover'/)
|
|
137
137
|
assert.match(source, /detail\.file\?\.status === 'archived'/, 'delete is offered only for archived memories')
|
|
138
|
-
assert.match(source, /call\('deleteMemory', \{ libraryId: current\.item\.libraryId
|
|
138
|
+
assert.match(source, /call\('deleteMemory', \{\s*\.\.\.\(current\.item\.libraryId \? \{ libraryId: current\.item\.libraryId \} : \{ scope: 'global' \}\)/, 'the drawer delete names its target: private libraryId or explicit global scope')
|
|
139
|
+
assert.match(source, /id: current\.item\.id, confirmed: true/, 'the drawer delete always carries explicit confirmation')
|
|
139
140
|
assert.match(source, /t\('confirmDelete'\)/, 'deleting takes a second click')
|
|
140
141
|
assert.match(source, /current\.file\.status !== 'archived'/, 'the delete handler refuses live memories')
|
|
141
142
|
})
|