@@ -20,10 +20,10 @@ import {
2020 createTrustedCopilotPrincipal ,
2121 createTrustedOrganizationCopilotPrincipal ,
2222} from '@/lib/mothership/auth/application-delegation'
23- import { MemoryAccessResult } from '@/lib/mothership/generated/memory-access'
23+ import { MemoryNotesAccessResult } from '@/lib/mothership/generated/memory-notes -access'
2424import {
25- MEMORY_ACCESS_AUDIENCE ,
26- resolveMemoryAccess ,
25+ MEMORY_NOTES_ACCESS_AUDIENCE ,
26+ resolveMemoryNotesAccess ,
2727} from '@/lib/mothership/memories/application/resolve-access'
2828import { executeSimControl } from '@/lib/mothership/transport/control'
2929import { splitForkProject } from '@/lib/projects/membership'
@@ -45,7 +45,7 @@ const workspaceChatId = generateId()
4545const organizationChatId = generateId ( )
4646
4747function principal ( organizationChat = false ) {
48- const options = { audience : MEMORY_ACCESS_AUDIENCE , ttlMs : 60_000 }
48+ const options = { audience : MEMORY_NOTES_ACCESS_AUDIENCE , ttlMs : 60_000 }
4949 return organizationChat
5050 ? createTrustedOrganizationCopilotPrincipal (
5151 { userId : actorId , organizationId, chatId : organizationChatId , delegationId : generateId ( ) } ,
@@ -156,7 +156,7 @@ it('denies every Project memory action on both transports when projects is disab
156156 chatId,
157157 ...( organizationChat ? { organizationId } : { workspaceId } ) ,
158158 } ,
159- operation : { kind : 'memory_access ' , input } ,
159+ operation : { kind : 'memory_notes_access ' , input } ,
160160 } )
161161 expect ( checkpoint . status ) . toBe ( 503 )
162162 expect ( JSON . parse ( checkpoint . body ) ) . toEqual ( {
@@ -170,19 +170,19 @@ it('keeps personal and workspace memories usable without Project context when pr
170170 featureFlagsMockFns . mockIsFeatureEnabled . mockResolvedValue ( false )
171171 for ( const organizationChat of [ false , true ] ) {
172172 for ( const action of [ 'read' , 'private_mutation' ] as const ) {
173- const personal = await resolveMemoryAccess . execute ( {
173+ const personal = await resolveMemoryNotesAccess . execute ( {
174174 principal : principal ( organizationChat ) ,
175175 input : { target : { scope : 'personal' } , action } ,
176176 } )
177177 expect ( personal . target ) . toEqual ( {
178178 scope : 'personal' ,
179179 permissions : { read : true , privateMutation : true , sharedMutation : false } ,
180180 } )
181- const result = await resolveMemoryAccess . execute ( {
181+ const result = await resolveMemoryNotesAccess . execute ( {
182182 principal : principal ( organizationChat ) ,
183183 input : { target : { scope : 'workspace' , workspaceId } , action } ,
184184 } )
185- expect ( MemoryAccessResult . parse ( result ) . target ) . toEqual ( {
185+ expect ( MemoryNotesAccessResult . parse ( result ) . target ) . toEqual ( {
186186 scope : 'workspace' ,
187187 id : workspaceId ,
188188 name : 'Environment' ,
@@ -191,7 +191,7 @@ it('keeps personal and workspace memories usable without Project context when pr
191191 } )
192192 }
193193 await expect (
194- resolveMemoryAccess . execute ( {
194+ resolveMemoryNotesAccess . execute ( {
195195 principal : principal ( organizationChat ) ,
196196 input : { target : { scope : 'workspace' , workspaceId } , action : 'shared_mutation' } ,
197197 } )
@@ -203,7 +203,7 @@ it('keeps personal and workspace memories usable without Project context when pr
203203 . where ( and ( eq ( permissions . userId , actorId ) , eq ( permissions . entityId , workspaceId ) ) )
204204 try {
205205 for ( const organizationChat of [ false , true ] ) {
206- const result = await resolveMemoryAccess . execute ( {
206+ const result = await resolveMemoryNotesAccess . execute ( {
207207 principal : principal ( organizationChat ) ,
208208 input : { target : { scope : 'workspace' , workspaceId } , action : 'shared_mutation' } ,
209209 } )
@@ -222,7 +222,7 @@ it('keeps personal and workspace memories usable without Project context when pr
222222
223223it ( 'lets a read-only end user mutate private notes through either chat and keeps Project shared writes denied' , async ( ) => {
224224 for ( const organizationChat of [ false , true ] ) {
225- const result = await resolveMemoryAccess . execute ( {
225+ const result = await resolveMemoryNotesAccess . execute ( {
226226 principal : principal ( organizationChat ) ,
227227 input : { target : { scope : 'workspace' , workspaceId } , action : 'private_mutation' } ,
228228 } )
@@ -234,7 +234,7 @@ it('lets a read-only end user mutate private notes through either chat and keeps
234234 currentProject : { id : projectId , permissions : { read : true , sharedMutation : false } } ,
235235 } )
236236 await expect (
237- resolveMemoryAccess . execute ( {
237+ resolveMemoryNotesAccess . execute ( {
238238 principal : principal ( organizationChat ) ,
239239 input : { target : { scope : 'project' , projectId } , action : 'shared_mutation' } ,
240240 } )
@@ -248,7 +248,7 @@ it('does not turn write in one environment into shared Project write', async ()
248248 . set ( { permissionType : 'write' } )
249249 . where ( and ( eq ( permissions . userId , actorId ) , eq ( permissions . entityId , workspaceId ) ) )
250250 try {
251- const result = await resolveMemoryAccess . execute ( {
251+ const result = await resolveMemoryNotesAccess . execute ( {
252252 principal : principal ( ) ,
253253 input : { target : { scope : 'workspace' , workspaceId } , action : 'shared_mutation' } ,
254254 } )
@@ -263,7 +263,7 @@ it('does not turn write in one environment into shared Project write', async ()
263263 entityId : siblingId ,
264264 permissionType : 'write' ,
265265 } )
266- const shared = await resolveMemoryAccess . execute ( {
266+ const shared = await resolveMemoryNotesAccess . execute ( {
267267 principal : principal ( true ) ,
268268 input : { target : { scope : 'project' , projectId } , action : 'shared_mutation' } ,
269269 } )
@@ -286,11 +286,11 @@ it('rejects wrong actor, audience, expired delegation and another workspace targ
286286 { ...principal ( ) , audience : 'sim:workspaces' } ,
287287 { ...principal ( ) , expiresAt : new Date ( 0 ) } ,
288288 ] )
289- await expect ( resolveMemoryAccess . execute ( { principal : altered , input } ) ) . rejects . toBeInstanceOf (
290- Error
291- )
289+ await expect (
290+ resolveMemoryNotesAccess . execute ( { principal : altered , input } )
291+ ) . rejects . toBeInstanceOf ( Error )
292292 await expect (
293- resolveMemoryAccess . execute ( {
293+ resolveMemoryNotesAccess . execute ( {
294294 principal : principal ( ) ,
295295 input : { ...input , target : { scope : 'workspace' , workspaceId : siblingId } } ,
296296 } )
@@ -303,12 +303,12 @@ it('denies a lost scoped grant while personal-only organization context remains
303303 . where ( and ( eq ( permissions . userId , actorId ) , eq ( permissions . entityId , workspaceId ) ) )
304304 try {
305305 await expect (
306- resolveMemoryAccess . execute ( {
306+ resolveMemoryNotesAccess . execute ( {
307307 principal : principal ( true ) ,
308308 input : { target : { scope : 'project' , projectId } , action : 'private_mutation' } ,
309309 } )
310310 ) . rejects . toMatchObject ( { code : 'not_found' } )
311- const result = await resolveMemoryAccess . execute ( {
311+ const result = await resolveMemoryNotesAccess . execute ( {
312312 principal : principal ( true ) ,
313313 input : { target : { scope : 'personal' } , action : 'private_mutation' } ,
314314 } )
@@ -353,7 +353,7 @@ it('applies the Files capability to shared Project writes without blocking priva
353353 organizationId,
354354 } )
355355 try {
356- const result = await resolveMemoryAccess . execute ( {
356+ const result = await resolveMemoryNotesAccess . execute ( {
357357 principal : principal ( true ) ,
358358 input : { target : { scope : 'project' , projectId } , action : 'private_mutation' } ,
359359 } )
@@ -363,7 +363,7 @@ it('applies the Files capability to shared Project writes without blocking priva
363363 sharedMutation : false ,
364364 } )
365365 await expect (
366- resolveMemoryAccess . execute ( {
366+ resolveMemoryNotesAccess . execute ( {
367367 principal : principal ( true ) ,
368368 input : { target : { scope : 'project' , projectId } , action : 'shared_mutation' } ,
369369 } )
@@ -393,13 +393,13 @@ it('rejects cross-organization authority and organization non-agent mode', async
393393 try {
394394 const otherPrincipal = { ...principal ( true ) , organizationId : otherId }
395395 await expect (
396- resolveMemoryAccess . execute ( {
396+ resolveMemoryNotesAccess . execute ( {
397397 principal : otherPrincipal ,
398398 input : { target : { scope : 'project' , projectId } , action : 'read' } ,
399399 } )
400400 ) . rejects . toMatchObject ( { code : 'not_found' } )
401401 await expect (
402- resolveMemoryAccess . execute ( {
402+ resolveMemoryNotesAccess . execute ( {
403403 principal : otherPrincipal ,
404404 input : { target : { scope : 'workspace' , workspaceId } , action : 'read' } ,
405405 } )
@@ -418,7 +418,7 @@ it('rejects cross-organization authority and organization non-agent mode', async
418418 . where ( eq ( copilotChats . id , organizationChatId ) )
419419 try {
420420 await expect (
421- resolveMemoryAccess . execute ( {
421+ resolveMemoryNotesAccess . execute ( {
422422 principal : principal ( true ) ,
423423 input : { target : { scope : 'project' , projectId } , action : 'read' } ,
424424 } )
@@ -457,7 +457,7 @@ it('serves the typed route using authenticated headers and rejects body identity
457457 )
458458 const response = await POST ( request ( input ) )
459459 expect ( response . status ) . toBe ( 200 )
460- expect ( MemoryAccessResult . parse ( await response . json ( ) ) ) . toMatchObject ( {
460+ expect ( MemoryNotesAccessResult . parse ( await response . json ( ) ) ) . toMatchObject ( {
461461 success : true ,
462462 version : 1 ,
463463 actor : { userId : actorId , chatId : workspaceChatId } ,
@@ -476,13 +476,13 @@ it('resolves detach to the new Project and rejects the former Project from the w
476476 return id
477477 } )
478478 try {
479- const result = await resolveMemoryAccess . execute ( {
479+ const result = await resolveMemoryNotesAccess . execute ( {
480480 principal : principal ( ) ,
481481 input : { target : { scope : 'workspace' , workspaceId } , action : 'read' } ,
482482 } )
483483 expect ( result . target ) . toMatchObject ( { currentProject : { id : detachedProject } } )
484484 await expect (
485- resolveMemoryAccess . execute ( {
485+ resolveMemoryNotesAccess . execute ( {
486486 principal : principal ( ) ,
487487 input : { target : { scope : 'project' , projectId } , action : 'read' } ,
488488 } )
@@ -515,12 +515,12 @@ it('uses identical current authority over checkpoint transport for workspace and
515515 expiresAt : Date . now ( ) + 60_000 ,
516516 scope,
517517 operation : {
518- kind : 'memory_access ' ,
518+ kind : 'memory_notes_access ' ,
519519 input : { target : { scope : 'workspace' , workspaceId } , action : 'private_mutation' } ,
520520 } ,
521521 } )
522522 expect ( result . status ) . toBe ( 200 )
523- expect ( MemoryAccessResult . parse ( JSON . parse ( result . body ) ) ) . toMatchObject ( {
523+ expect ( MemoryNotesAccessResult . parse ( JSON . parse ( result . body ) ) ) . toMatchObject ( {
524524 actor : { userId : actorId , chatId : scope . chatId } ,
525525 target : { id : workspaceId , currentProject : projectsEnabled ? { id : projectId } : null } ,
526526 } )
@@ -529,7 +529,7 @@ it('uses identical current authority over checkpoint transport for workspace and
529529 expiresAt : Date . now ( ) + 60_000 ,
530530 scope,
531531 operation : {
532- kind : 'memory_access ' ,
532+ kind : 'memory_notes_access ' ,
533533 input : { target : { scope : 'project' , projectId } , action : 'shared_mutation' } ,
534534 } ,
535535 } )
0 commit comments