Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(desktop): rp-002-residual end the drop when the ancestor resolve reports a session failure
M471456752b7f
diff --git a/desktop-app/ui/src/gfs/__tests__/dragAdjudication.test.tsx b/desktop-app/ui/src/gfs/__tests__/dragAdjudication.test.tsxindex b1e3bf63c..9438f8ba9 100644--- a/desktop-app/ui/src/gfs/__tests__/dragAdjudication.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/dragAdjudication.test.tsx@@ -317,13 +317,19 @@ describe('useGfsDragAdjudication — probe 401 revokes the session', () => {const handleAuthorityFailure = vi.fn(() => true)const { result } = renderAdjudication(handleAuthorityFailure)- await result.current.adjudicateDrop(+ const decision = await result.current.adjudicateDrop(dragSource({ kind: 'directory', knownAncestorIds: [] }),// An unproven chain (no root sentinel) forces the ancestor resolve.{ ...dropTarget(), ancestorIds: ['root-1'] })expect(handleAuthorityFailure).toHaveBeenCalledWith(message)+ // A session failure is TERMINAL for the gesture: the ancestry read died+ // with the session, so the adjudication must not continue into the later+ // probes and answer "allowed" over a dead session (RP-002).+ expect(decision).toEqual({ allowed: false, reason: 'session-lost' })+ // The failed resolve is the LAST read: nothing after it ran.+ expect(resolve).toHaveBeenCalledTimes(1)})it('leaves a policy verdict local: a 403 probe never reaches the classifier', async () => {diff --git a/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx b/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsxindex 8f4068388..7e6743206 100644--- a/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/dragOwnership.test.tsx@@ -531,3 +531,64 @@ for (const surface of ['sidebar', 'files'] as const) {})})}++// RP-002: a session failure while resolving the drop target's ancestry ends+// the gesture. The Files page is the surface where that read happens: its+// rows carry no loaded ancestry (the current view is a root listing), so a+// folder drop must resolve the target's ancestors before it can admit the+// move — and a session that died during that read must never end in an+// ALLOWED verdict.+describe('files surface drop admission (RP-002)', () => {+ it('never dispatches the move when the ancestor resolve reports a session failure', async () => {+ const message = 'Error invoking remote method: Error: 401 Unauthorized httpStatus=401'+ const bits = await affordancesResult(heldAffordances(['read', 'write', 'delete']))+ const affordances = vi.fn(async () => bits)+ const resolve = vi.fn(async () => {+ throw new Error(message)+ })+ Object.defineProperty(window, 'clerum', {+ configurable: true,+ value: {+ gfs: {+ listChildren: vi.fn(async () => listChildrenPage([])),+ affordances,+ resolve,+ },+ },+ })+ const { items } = await listAccessiblePage([+ accessibleResource('source', 'Source', 'directory', { parentResourceId: 'grand' }),+ accessibleResource('target', 'Target', 'directory', { parentResourceId: 'grand' }),+ ])+ const moveResource = vi.fn(async () => ({}))+ const ctrl = { ...baseController(), accessibleResources: items, items, moveResource }+ mocks.controller.mockReturnValue(ctrl)+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } })+ const toast = vi.fn()++ render(+ <QueryClientProvider client={queryClient}>+ <GfsDragSessionProvider>+ <FilesPage pushToast={toast} />+ </GfsDragSessionProvider>+ </QueryClientProvider>+ )++ const dataTransfer = transfer()+ fireEvent.dragStart(screen.getByRole('button', { name: 'Open Source' }), { dataTransfer })+ fireEvent.drop(screen.getByRole('button', { name: 'Open Target' }), { dataTransfer })++ // The session is revoked and the gesture ends: no confirmation, no+ // dispatch, nothing announced.+ await waitFor(() =>+ expect(ctrl.handleAuthorityFailure).toHaveBeenCalledWith(message, 'operation')+ )+ expect(screen.queryByRole('dialog', { name: 'Move folder Source to Target' })).toBeNull()+ expect(moveResource).not.toHaveBeenCalled()+ expect(toast).not.toHaveBeenCalled()+ // The ancestry read is the last thing that ran: no affordance probe+ // followed it.+ expect(resolve).toHaveBeenCalledTimes(1)+ expect(affordances).not.toHaveBeenCalled()+ })+})diff --git a/desktop-app/ui/src/gfs/dragAdjudication.ts b/desktop-app/ui/src/gfs/dragAdjudication.tsindex fd8789c87..0e159311f 100644--- a/desktop-app/ui/src/gfs/dragAdjudication.ts+++ b/desktop-app/ui/src/gfs/dragAdjudication.ts@@ -109,12 +109,22 @@ export function useGfsDragAdjudication(deps: GfsDragAdjudicationDeps) {* it is a session-authority failure. The drop is refused either way; this* is what makes the refusal also REVOKE the session instead of leaving an* active accessState over a dead session.+ *+ * The classification travels back to the caller: a session failure is+ * TERMINAL for the gesture (the session it was reading is gone), while a+ * per-resource policy verdict stays local to the attempted operation.*/const reportAuthorityFailure = useCallback(- (error: unknown): boolean => {+ (error: unknown): { message: string; sessionFailure: boolean; revoked: boolean } => {const message = error instanceof Error ? error.message : String(error ?? '')- if (!isGfsSessionAuthorityFailure(message, 'operation')) return false- return deps.handleAuthorityFailure?.(message) ?? false+ if (!isGfsSessionAuthorityFailure(message, 'operation')) {+ return { message, sessionFailure: false, revoked: false }+ }+ return {+ message,+ sessionFailure: true,+ revoked: deps.handleAuthorityFailure?.(message) ?? false,+ }},[deps])@@ -337,11 +347,16 @@ export function useGfsDragAdjudication(deps: GfsDragAdjudicationDeps) {knownSourceAncestorIds: new Set(source.knownAncestorIds),})} catch (error) {- // Unreadable ancestry stays server-check-required; proceed below —- // a read failure upward is a visibility boundary, not a denial. A- // session failure is not a boundary: report it so the session is- // revoked instead of the drop dying quietly.- reportAuthorityFailure(error)+ // A read failure upward is a visibility boundary, not a denial: the+ // ancestry stays unproven and the server PATCH remains the backstop.+ // A SESSION failure is not a boundary — the session the ancestry+ // would be read from is gone. Report it so the session is revoked+ // and STOP: continuing would let the later probes answer "allowed"+ // over a dead session (RP-002).+ const failure = reportAuthorityFailure(error)+ if (failure.sessionFailure) {+ return { allowed: false, reason: 'session-lost' }+ }}}