refactor(web): drop the permission RPC pair and turn-anchoring machinery
The session.permissions/setPermission unary pair, the PermissionOption wire DTO, the client Session wrappers, and the fixture/fake mirrors all leave the wire: the read side moves to the 'permissions' session projection and the write side moves to the /permission command in follow-up commits, so the web protocol gains no permission methods at all. The pendingSwitches + prompt-submit flush + hasOpenTurn move also goes. Knob events no longer need turn enclosure: the persistence scanner keeps standalone events after the last turn/end as part of the preserved prefix (remove-synthetic-log-only-turns), none of the three knob invariants demand an open turn, and the setters append bare events. An idle switch commits immediately; hasOpenTurn stays a user-approval private fold (its audit pair is the one contract that still requires enclosure). The old PermissionSelect chip and its mount-time fetch die with the RPCs (the resident composer broke the mount-once assumption); the projection-fed replacement lands with the Access seat swap.
This commit is contained in:
@@ -816,27 +816,3 @@ describe('reference stability (the memo contract)', () => {
|
||||
expect(resolved.pending).toBe(after.pending)
|
||||
})
|
||||
})
|
||||
|
||||
describe('permissions / setPermission', () => {
|
||||
it('passes the select read and switch through with the session id', async () => {
|
||||
const { api, session } = makeSession()
|
||||
api.onPermissions = () => Promise.resolve(ok({ options: [{ value: 'workspace-write', name: 'workspace-write' }], currentValue: 'workspace-write' }))
|
||||
const read = await session.permissions()
|
||||
expect(read.ok).toBe(true)
|
||||
if (read.ok) expect(read.value.currentValue).toBe('workspace-write')
|
||||
expect(api.callsOf('session.permissions')).toMatchObject([{ sessionId: SID }])
|
||||
|
||||
const switched = await session.setPermission('danger-full-access')
|
||||
expect(switched.ok).toBe(true)
|
||||
if (switched.ok) expect(switched.value.currentValue).toBe('danger-full-access')
|
||||
expect(api.callsOf('session.setPermission')).toMatchObject([{ sessionId: SID, value: 'danger-full-access' }])
|
||||
})
|
||||
|
||||
it('folds transport failures into the error branch', async () => {
|
||||
const { api, session } = makeSession()
|
||||
api.onPermissions = () => Promise.reject(new Error('down'))
|
||||
api.onSetPermission = () => Promise.reject(new Error('down'))
|
||||
expect((await session.permissions()).ok).toBe(false)
|
||||
expect((await session.setPermission('x')).ok).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user