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.
@@ -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 缺席的宿主
@@ -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
  })