Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(gfs): align inherited access and breadcrumb versions
Me724f112f008
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex 1dde5a9b8..21235946f 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -624,9 +624,10 @@ export function GfsBrowser(): React.JSX.Element {const occupiedNames = new Set<string>()let moveName = source.namelet moved = false+ let moveResult: unknownfor (let attempt = 0; attempt < GFS_UPLOAD_NAME_RETRY_LIMIT; attempt += 1) {try {- await apiSend(+ moveResult = await apiSend('PATCH',`/api/v1/gfs/resources/${encodeURIComponent(source.resourceId)}`,{@@ -649,6 +650,24 @@ export function GfsBrowser(): React.JSX.Element {}}if (!moved) throw new Error(GFS_MOVE_NAME_EXHAUSTED_MESSAGE)+ const movedResource = (+ moveResult as { data?: { resourceId?: string; version?: number } } | undefined+ )?.data+ const nextVersion =+ movedResource?.resourceId && movedResource.resourceId !== source.resourceId+ ? undefined+ : movedResource?.version+ setCrumbs(prev =>+ prev.map(crumb =>+ crumb.id === source.resourceId+ ? {+ ...crumb,+ name: moveName,+ ...(nextVersion === undefined ? {} : { version: nextVersion }),+ }+ : crumb+ )+ )// The destination may have been prefetched while it was visible. Its// cached listing is stale after a move and must be revalidated before it// is opened.@@ -1297,26 +1316,38 @@ export function GfsBrowser(): React.JSX.Element {return (<span className="cu-gfs-breadcrumb__item" key={`${crumb.id ?? 'root'}-${index}`}>{index > 0 ? <IconChevronRight width={14} height={14} /> : null}- <button- className={`cu-gfs-breadcrumb__button${- crumb.name === '/' ? ' cu-gfs-breadcrumb__button--root' : ''- }`}- type="button"- onClick={() => goToCrumb(index)}- aria-current={index === crumbs.length - 1 ? 'page' : undefined}- >- {crumb.name === '/' ? (- <>- <span className="cu-gfs-breadcrumb__drive-icon" aria-hidden="true">- <IconFolder />- </span>- <span>{DRIVE}</span>- </>- ) : (- crumb.name- )}- </button>- {activeFolder ? <GfsResourceMenu {...folderMenuProps(activeFolder)} /> : null}+ {activeFolder && renameTarget?.resourceId === activeFolder.resourceId ? (+ <GfsInlineRename+ onCancel={() => setRenameTarget(null)}+ onChange={setRenameName}+ onSubmit={() => void renameResource(activeFolder, renameName)}+ value={renameName}+ busy={renaming}+ />+ ) : (+ <button+ className={`cu-gfs-breadcrumb__button${+ crumb.name === '/' ? ' cu-gfs-breadcrumb__button--root' : ''+ }`}+ type="button"+ onClick={() => goToCrumb(index)}+ aria-current={index === crumbs.length - 1 ? 'page' : undefined}+ >+ {crumb.name === '/' ? (+ <>+ <span className="cu-gfs-breadcrumb__drive-icon" aria-hidden="true">+ <IconFolder />+ </span>+ <span>{DRIVE}</span>+ </>+ ) : (+ crumb.name+ )}+ </button>+ )}+ {activeFolder && renameTarget?.resourceId !== activeFolder.resourceId ? (+ <GfsResourceMenu {...folderMenuProps(activeFolder)} />+ ) : null}</span>)})}diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsxindex b0a06b46d..a4ea63f4b 100644--- a/control-ui/components/__tests__/GfsBrowser.test.tsx+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx@@ -1548,6 +1548,125 @@ describe('GfsBrowser', () => {expect(screen.queryByRole('dialog', { name: 'Open EvenDrive link' })).toBeNull()})+ // R1-M5 / R1-L7 (R2-M2): model a versioned resolve producer response, then+ // prove Move and subsequent breadcrumb actions use each returned version.+ // Production resolve version support remains owned by backend issue #774.+ it('carries an opened breadcrumb version through Move, Rename, and Delete', async () => {+ const folder = child('org', 'directory', 1, 7)+ const archive = child('archive', 'directory', 2)+ mockApiGet.mockImplementation(async (path: string) => {+ if (path === '/api/v1/gfs/tree') {+ return {+ items: [folder, archive],+ nextCursor: null,+ }+ }+ if (path === '/api/v1/gfs/resolve') {+ return {+ resourceId: folder.resourceId,+ rid: folder.rid,+ gfsUri: folder.gfsUri,+ name: folder.name,+ kind: folder.kind,+ version: 7,+ }+ }+ if (path === `/api/v1/gfs/resources/${folder.resourceId}/children`) {+ return { items: [], nextCursor: null }+ }+ return { items: [], nextCursor: null }+ })+ mockApiSend+ .mockResolvedValueOnce({+ ok: true,+ data: { resourceId: folder.resourceId, version: 8 },+ })+ .mockResolvedValueOnce({+ ok: true,+ data: { resourceId: folder.resourceId, version: 9 },+ })+ renderBrowser()++ await waitFor(() =>+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/tree', { drive: 'main' })+ )+ await screen.findByText('org')+ await openResourceMenu('org')+ fireEvent.click(screen.getByRole('menuitem', { name: 'Open EvenDrive link' }))+ const openLinkDialog = await screen.findByRole('dialog', { name: 'Open EvenDrive link' })+ fireEvent.change(within(openLinkDialog).getByLabelText('EvenDrive link'), {+ target: { value: folder.gfsUri },+ })+ fireEvent.click(within(openLinkDialog).getByRole('button', { name: 'Open' }))+ await waitFor(() =>+ expect(mockApiGet).toHaveBeenCalledWith('/api/v1/gfs/resolve', { uri: folder.gfsUri })+ )+ await waitFor(() =>+ expect(mockApiGet).toHaveBeenCalledWith(+ `/api/v1/gfs/resources/${folder.resourceId}/children`,+ { drive: 'main' }+ )+ )+ await screen.findByText('No resources are visible in this folder.')++ const breadcrumb = screen.getByRole('navigation', { name: 'Breadcrumb' })+ await waitFor(() =>+ expect(within(breadcrumb).getByRole('button', { name: 'Actions for org' })).toBeTruthy()+ )+ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Move to…' }))+ const moveDialog = await screen.findByRole('dialog', { name: 'Move folder org' })+ fireEvent.click(await within(moveDialog).findByRole('button', { name: 'archive' }))+ fireEvent.click(within(moveDialog).getByRole('button', { name: 'Move here (archive)' }))++ await waitFor(() =>+ expect(mockApiSend).toHaveBeenNthCalledWith(+ 1,+ 'PATCH',+ `/api/v1/gfs/resources/${folder.resourceId}`,+ { drive: 'main', newParentId: archive.resourceId, ifMatch: 7 },+ { drive: 'main' }+ )+ )+ await waitFor(() =>+ expect(screen.queryByRole('dialog', { name: 'Move folder org' })).toBeNull()+ )++ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Rename' }))+ const renameForm = await within(breadcrumb).findByRole('form', { name: 'Rename resource' })+ fireEvent.change(within(renameForm).getByLabelText('New name'), {+ target: { value: 'org-renamed' },+ })+ fireEvent.click(within(renameForm).getByRole('button', { name: 'Save name' }))++ await waitFor(() =>+ expect(mockApiSend).toHaveBeenNthCalledWith(+ 2,+ 'PATCH',+ `/api/v1/gfs/resources/${folder.resourceId}`,+ { drive: 'main', newName: 'org-renamed', ifMatch: 8 },+ { drive: 'main' }+ )+ )+ await waitFor(() =>+ expect(within(breadcrumb).getByRole('button', { name: 'org-renamed' })).toBeTruthy()+ )++ fireEvent.click(within(breadcrumb).getByRole('button', { name: 'Actions for org-renamed' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Delete' }))+ const deleteDialog = await screen.findByRole('alertdialog', { name: 'Delete resource' })+ fireEvent.click(within(deleteDialog).getByRole('button', { name: 'Delete' }))+ await waitFor(() =>+ expect(mockApiSend).toHaveBeenNthCalledWith(+ 3,+ 'DELETE',+ `/api/v1/gfs/proxy/v1/resources/${folder.rid}`,+ { ifMatch: 9 }+ )+ )+ })+it('does not fall back to legacy when replacing a persisted resumable session', async () => {const lastModified = 1_725_000_000_000const uploadId = '66666666-6666-4666-8666-666666666666'diff --git a/control-ui/components/__tests__/gfsInheritedAccess.test.ts b/control-ui/components/__tests__/gfsInheritedAccess.test.tsindex 54e30296a..f4ffd733b 100644--- a/control-ui/components/__tests__/gfsInheritedAccess.test.ts+++ b/control-ui/components/__tests__/gfsInheritedAccess.test.ts@@ -32,7 +32,7 @@ describe('loadGfsInheritedAccess', () => {mockGetGfsShares.mockResolvedValue({ items: [] })})- it('skips an ancestor ACL failure and continues with higher ancestors', async () => {+ it('fails when an ancestor ACL read fails instead of returning a partial role', async () => {mockGetGfsResourceByPath.mockImplementation(async (_drive, path) => {if (path === '/nested') return resourceView('nested-folder', 'nested', '/nested')if (path === '/') return resourceView('root-folder', '', '/')@@ -54,22 +54,22 @@ describe('loadGfsInheritedAccess', () => {}})- await expect(loadGfsInheritedAccess('/nested/report.md', 'main')).resolves.toEqual([- {- subject: { type: 'user', id: 'member-1' },- permissions: ['read'],- inheritedFrom: ['main'],- sources: [- {- resourceId: 'root-folder',- name: 'main',- permissions: ['read'],- grantId: 'root-grant',- shareIds: [],- },- ],- },- ])- expect(mockGetGfsResourceByPath.mock.calls.map(([, path]) => path)).toEqual(['/nested', '/'])+ await expect(loadGfsInheritedAccess('/nested/report.md', 'main')).rejects.toThrow(+ 'inherited_access_derivation_failed'+ )+ expect(mockGetGfsResourceByPath.mock.calls.map(([, path]) => path)).toEqual(['/nested'])+ })++ it('fails when an ancestor cannot be resolved, matching Desktop walk semantics', async () => {+ mockGetGfsResourceByPath.mockImplementation(async (_drive, path) => {+ if (path === '/nested') throw new Error('403 forbidden')+ if (path === '/') return resourceView('root-folder', '', '/')+ throw new Error('unexpected path')+ })++ await expect(loadGfsInheritedAccess('/nested/report.md', 'main')).rejects.toThrow(+ 'inherited_access_derivation_failed'+ )+ expect(mockGetGfsResourceByPath.mock.calls.map(([, path]) => path)).toEqual(['/nested'])})})diff --git a/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts b/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.tsindex 2cdc25ab3..5005149d7 100644--- a/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts+++ b/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts@@ -12,9 +12,9 @@ import {} from '../gfsInheritedAccessMerge'/**- * R1-M2 — property suite for the pure inherited-access merge core:- * merge idempotency, no source dropped, effective role = strongest of- * sources, and a total role order.+ * R1-M4 — property suite for the pure inherited-access merge core:+ * merge idempotency/composability, unique retained sources, effective role =+ * strongest of sources, and a total role order.*/const PERMISSION_BITS = ['read', 'write', 'delete', 'manage_acl', 'share'] as const@@ -66,8 +66,8 @@ describe('gfsInheritedAccessMerge properties', () => {distinctFoldersArb,distinctFoldersArb,(seed, repeat, seedFolders, repeatFolders) => {- const seedFolder = seedFolders[0]- const repeatFolder = repeatFolders[0]+ const seedFolder = seedFolders[0]!+ const repeatFolder = repeatFolders[0]!const a = mergeInheritedAccessItem(null, seed, seedFolder)const once = mergeInheritedAccessItem(a, repeat, repeatFolder)const twice = mergeInheritedAccessItem(once, repeat, repeatFolder)@@ -81,14 +81,42 @@ describe('gfsInheritedAccessMerge properties', () => {it('merging the same contribution twice changes nothing', () => {fc.assert(fc.property(contributionArb, distinctFoldersArb, (contribution, folders) => {- const once = mergeInheritedAccessItem(null, contribution, folders[0])- const twice = mergeInheritedAccessItem(once, contribution, folders[0])+ const once = mergeInheritedAccessItem(null, contribution, folders[0]!)+ const twice = mergeInheritedAccessItem(once, contribution, folders[0]!)expect(twice).toEqual(once)}),{ numRuns: 300 })})+ it('is composable when an earlier source is folded again after another source', () => {+ fc.assert(+ fc.property(+ subjectArb,+ contributionArb,+ contributionArb,+ distinctFoldersArb,+ (subject, firstContribution, nextContribution, folders) => {+ const firstFolder = folders[0]!+ const secondFolder = folders[1] ?? {+ resourceId: `${firstFolder.resourceId}:second`,+ name: `${firstFolder.name}:second`,+ }+ const first = { ...firstContribution, subject }+ const next = { ...nextContribution, subject }+ const mergeInner = mergeInheritedAccessItem(+ mergeInheritedAccessItem(null, first, firstFolder),+ next,+ secondFolder+ )+ const mergeOuter = mergeInheritedAccessItem(mergeInner, first, firstFolder)+ expect(mergeOuter).toEqual(mergeInner)+ }+ ),+ { numRuns: 300 }+ )+ })+it('never drops a source: every contributing folder survives the fold', () => {fc.assert(fc.property(@@ -99,7 +127,7 @@ describe('gfsInheritedAccessMerge properties', () => {let item = mergeInheritedAccessItem(null,{ subject, permissions: permissionSets[0] ?? ['read'], grantId: null, shareIds: [] },- folders[0]+ folders[0]!)folders.slice(1).forEach((folder, index) => {item = mergeInheritedAccessItem(@@ -115,9 +143,11 @@ describe('gfsInheritedAccessMerge properties', () => {folder)})- expect(new Set(item.sources.map(source => source.resourceId))).toEqual(- new Set(folders.map(folder => folder.resourceId))- )+ const sourceIds = item.sources.map(source => source.resourceId)+ const expectedIds = folders.map(folder => folder.resourceId)+ expect(sourceIds).toHaveLength(expectedIds.length)+ expect(new Set(sourceIds).size).toBe(sourceIds.length)+ expect(sourceIds).toEqual(expectedIds)}),{ numRuns: 300 }@@ -132,19 +162,19 @@ describe('gfsInheritedAccessMerge properties', () => {fc.array(permissionsArb, { minLength: 1, maxLength: 8 }),(subject, folders, permissionSets) => {let item: ReturnType<typeof mergeInheritedAccessItem> | null = null- folders.forEach((folder, index) => {+ for (const [index, folder] of folders.entries()) {item = mergeInheritedAccessItem(item,{subject,- permissions: permissionSets[index % permissionSets.length],+ permissions: permissionSets[index % permissionSets.length]!,grantId: null,shareIds: [],},folder)- })- const merged = item as NonNullable<typeof item>+ }+ const merged = item!const strongestRank = Math.max(...merged.sources.map(source => roleRank(source.permissions)))@@ -190,7 +220,7 @@ describe('gfsInheritedAccessMerge properties', () => {const sources: GfsInheritedAccessSource[] = folders.map((folder, index) => ({resourceId: folder.resourceId,name: folder.name,- permissions: permissionSets[index % permissionSets.length],+ permissions: permissionSets[index % permissionSets.length]!,grantId: null,shareIds: [],}))diff --git a/control-ui/components/gfsInheritedAccess.ts b/control-ui/components/gfsInheritedAccess.tsindex 01f93b1f6..968673ec8 100644--- a/control-ui/components/gfsInheritedAccess.ts+++ b/control-ui/components/gfsInheritedAccess.ts@@ -17,28 +17,25 @@ export { planInheritedRoleChange, strongestInheritedSource } from './gfsInherite* (grants with inherit=true, shares with includeDescendants=true — the same* rule the server's allow() evaluation uses). Rows are merged per subject* through the pure merge core (`gfsInheritedAccessMerge.ts`, property tested- * in R1-M2); EVERY contributing ancestor folder is kept as an editable source+ * in R1-M4); EVERY contributing ancestor folder is kept as an editable source* (with the grant/share ids to mutate), so a confirmed removal revokes all of* them and a confirmed downgrade lowers each one above the target role- * (R1-H1).+ * (R1-H1). If any required ancestor or ACL read fails, the derivation fails+ * visibly instead of returning a result that looks complete.*//**- * Walk semantics (R1-L3, unified with the desktop walk in+ * Walk semantics (R1-M1, unified with the desktop walk in* desktop-app/ui/src/gfs/inheritedAccess.ts):* - BOUNDED in depth: at most GFS_INHERITED_WALK_MAX_DEPTH ancestors are* visited (the desktop rid-chain walk bounds itself with the same number* via GFS_BREADCRUMB_MAX_DEPTH).- * - BEST-EFFORT skip-and-continue: an ancestor that cannot be resolved or- * whose ACL cannot be listed (moved, deleted, rate-limited, unviewable) is- * skipped and the walk CONTINUES with the remaining ancestors — per-ancestor- * failures never fail the derivation. Only a walk that resolves NO ancestor- * at all reports a total failure (R1-M3).- * - Because this walk addresses ancestors by canonical PATH, each ancestor is- * independent: skipping one still leaves every higher path reachable. The- * desktop walk chains parent ids instead and can only stop when an ancestor- * cannot be resolved at all — that single divergence is documented at its- * walk site.+ * - COMPLETE or FAILED: every ancestor path must resolve to a directory and+ * both ACL lists must load. Any failure throws the same derivation error as+ * Desktop, so the UI cannot mistake partial data for no inherited access.+ * - This walk addresses ancestors by canonical PATH while Desktop follows+ * parent resource IDs. The traversal differs, but the failure contract is+ * shared.*/const GFS_INHERITED_WALK_MAX_DEPTH = 64@@ -94,13 +91,11 @@ async function listInheritingRows(}/**- * Derives the inherited access for one resource path. Ancestors that cannot be- * resolved or listed (moved, deleted, rate-limited) are skipped — the walk is- * best-effort. A walk that resolves NO ancestor at all learned nothing about- * the file's ancestry and throws, so the caller can say the derivation failed- * instead of trusting an empty list (R1-M3). The drive root carries an empty- * name, so its label falls back to the drive name, matching the browser- * breadcrumb.+ * Derives inherited access only when every ancestor and ACL list is available.+ * Any incomplete walk throws `inherited_access_derivation_failed`, so the+ * caller can distinguish a read failure from a complete empty result. The+ * drive root carries an empty name, so its label falls back to the drive name,+ * matching the browser breadcrumb.*/export async function loadGfsInheritedAccess(path: string,@@ -109,22 +104,23 @@ export async function loadGfsInheritedAccess(): Promise<GfsInheritedAccessItem[]> {const bySubject = new Map<string, GfsInheritedAccessItem>()const ancestorPaths = gfsAncestorPaths(path)- let resolvedAncestors = 0for (const ancestorPath of ancestorPaths) {let folder: GfsResourceByPathViewtry {folder = await getGfsResourceByPath(drive, ancestorPath, signal)} catch (error) {if (signal?.aborted) throw error- continue+ throw new Error('inherited_access_derivation_failed')+ }+ if (folder.kind !== 'directory') {+ throw new Error('inherited_access_derivation_failed')}- resolvedAncestors += 1let rows: InheritingRow[]try {rows = await listInheritingRows(folder, drive, signal)} catch (error) {if (signal?.aborted) throw error- continue+ throw new Error('inherited_access_derivation_failed')}const folderLabel = folder.name || drivefor (const row of rows) {@@ -138,11 +134,5 @@ export async function loadGfsInheritedAccess()}}- // Every ancestor path failed to resolve: the derivation as a whole- // failed. An empty list here would silently read as "no inherited- // access", so the caller gets a failure it can surface (R1-M3).- if (ancestorPaths.length > 0 && resolvedAncestors === 0) {- throw new Error('inherited_access_derivation_failed')- }return [...bySubject.values()]}diff --git a/control-ui/components/gfsInheritedAccessMerge.ts b/control-ui/components/gfsInheritedAccessMerge.tsindex 014be52a4..1244ea765 100644--- a/control-ui/components/gfsInheritedAccessMerge.ts+++ b/control-ui/components/gfsInheritedAccessMerge.ts@@ -2,7 +2,7 @@ import type { GfsSubjectInput } from '@lib/api'import type { GfsInheritedAccessItem, GfsInheritedAccessSource } from './GfsGrantPanel.types'/**- * Pure merge core for the client-side inherited-access derivation (R1-M2).+ * Pure merge core for the client-side inherited-access derivation (R1-M4).* No network — everything here is a function of its inputs, which is what* the fast-check property suite in* `__tests__/gfsInheritedAccessMerge.prop.test.ts` relies on: mergediff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 2f7f229cf..d7ae0683f 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.609",+ "version": "0.1.610","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.609",+ "version": "0.1.610","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 38857b5dc..71611322d 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.609",+ "version": "0.1.610","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.tsindex 657a001b5..cf11d7260 100644--- a/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts+++ b/desktop-app/ui/src/gfs/GfsInheritedAccessDialog/types.ts@@ -1,6 +1,7 @@export type GfsInheritedAccessRole = 'read' | 'editor'export type GfsInheritedAccessDialogFolder = {+ resourceId: stringname: string/** Role the member holds on that ancestor folder today. */currentRole: GfsInheritedAccessRolediff --git a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsxindex 117f859dc..cde00ca7f 100644--- a/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/GfsGrantList.test.tsx@@ -339,7 +339,7 @@ describe('GfsGrantList', () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))fireEvent.click(screen.getByRole('option', { name: 'Read' }))expect(onChangeInheritedRole).toHaveBeenCalledTimes(1)- const [changedRow, label, role] = onChangeInheritedRole.mock.calls[0]+ const [changedRow, label, role] = onChangeInheritedRole.mock.calls[0]!expect(changedRow.inherited).toBe(item)expect(changedRow.permissions).toEqual(['read', 'write'])expect(label).toBe('Test Two')diff --git a/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx b/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsxindex e5c7606b2..3e0bb1900 100644--- a/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx+++ b/desktop-app/ui/src/gfs/__tests__/GfsInheritedAccessDialog.test.tsx@@ -13,7 +13,7 @@ describe('GfsInheritedAccessDialog', () => {mode: 'change-role' as const,memberLabel: 'Test Two',fileName: 'report.txt',- folders: [{ name: 'Team folder', currentRole: 'editor' as const }],+ folders: [{ resourceId: 'team-folder', name: 'Team folder', currentRole: 'editor' as const }],fileCurrentRole: 'editor' as const,nextRole: 'read' as const,}@@ -46,8 +46,8 @@ describe('GfsInheritedAccessDialog', () => {memberLabel: 'Test Two',fileName: 'report.txt',folders: [- { name: 'Campaigns', currentRole: 'editor' },- { name: 'Marketing', currentRole: 'read' },+ { resourceId: 'campaigns', name: 'Campaigns', currentRole: 'editor' },+ { resourceId: 'marketing', name: 'Marketing', currentRole: 'read' },],fileCurrentRole: 'editor',}}diff --git a/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.tsindex d660b8891..f01ef0aab 100644--- a/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts+++ b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts@@ -133,7 +133,7 @@ describe('deriveGfsInheritedAccess', () => {])})- it('stops the walk at an ancestor the caller cannot resolve and skips unviewable ACLs', async () => {+ it('fails the derivation when a required ancestor cannot be resolved', async () => {const listGrants = vi.fn(async () => {throw new Error('403 manage_acl_required')})@@ -151,12 +151,37 @@ describe('deriveGfsInheritedAccess', () => {async () => [])- const items = await deriveGfsInheritedAccess(FILE_ID)-- expect(items).toEqual([])+ await expect(deriveGfsInheritedAccess(FILE_ID)).rejects.toThrow(+ 'inherited_access_derivation_failed'+ )expect(listGrants).not.toHaveBeenCalled()})+ it('fails the derivation when a resolved ancestor ACL cannot be listed', async () => {+ installClerumGfs(+ async uri => {+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {+ return resolveView(FILE_ID, 'report.md', FOLDER_ID, 'file')+ }+ if (uri.endsWith(FOLDER_ID.replace(/-/g, ''))) {+ return resolveView(FOLDER_ID, 'team-docs', ROOT_ID)+ }+ if (uri.endsWith(ROOT_ID.replace(/-/g, ''))) {+ return resolveView(ROOT_ID, '', null)+ }+ return null+ },+ async () => {+ throw new Error('403 manage_acl_required')+ },+ async () => []+ )++ await expect(deriveGfsInheritedAccess(FILE_ID)).rejects.toThrow(+ 'inherited_access_derivation_failed'+ )+ })+it('merges one subject inherited through multiple folders into a single strongest-source row', async () => {installClerumGfs(async uri => {diff --git a/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts b/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.tsindex bbe004f68..7bce6d577 100644--- a/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts+++ b/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts@@ -13,9 +13,9 @@ import {} from '../inheritedAccessMerge'/**- * R1-M2 — property suite for the pure inherited-access merge core:- * merge idempotency, no source dropped, effective role = strongest of- * sources, and a total role order.+ * R1-M4 — property suite for the pure inherited-access merge core:+ * merge idempotency/composability, unique retained sources, effective role =+ * strongest of sources, and a total role order.*/const PERMISSION_BITS = ['read', 'write', 'delete', 'manage_acl', 'share'] as const@@ -67,8 +67,8 @@ describe('inheritedAccessMerge properties', () => {distinctFoldersArb,distinctFoldersArb,(seed, repeat, seedFolders, repeatFolders) => {- const seedFolder = seedFolders[0]- const repeatFolder = repeatFolders[0]+ const seedFolder = seedFolders[0]!+ const repeatFolder = repeatFolders[0]!const a = mergeInheritedAccessItem(null, seed, seedFolder)const once = mergeInheritedAccessItem(a, repeat, repeatFolder)const twice = mergeInheritedAccessItem(once, repeat, repeatFolder)@@ -82,14 +82,42 @@ describe('inheritedAccessMerge properties', () => {it('merging the same contribution twice changes nothing', () => {fc.assert(fc.property(contributionArb, distinctFoldersArb, (contribution, folders) => {- const once = mergeInheritedAccessItem(null, contribution, folders[0])- const twice = mergeInheritedAccessItem(once, contribution, folders[0])+ const once = mergeInheritedAccessItem(null, contribution, folders[0]!)+ const twice = mergeInheritedAccessItem(once, contribution, folders[0]!)expect(twice).toEqual(once)}),{ numRuns: 300 })})+ it('is composable when an earlier source is folded again after another source', () => {+ fc.assert(+ fc.property(+ subjectArb,+ contributionArb,+ contributionArb,+ distinctFoldersArb,+ (subject, firstContribution, nextContribution, folders) => {+ const firstFolder = folders[0]!+ const secondFolder = folders[1] ?? {+ resourceId: `${firstFolder.resourceId}:second`,+ name: `${firstFolder.name}:second`,+ }+ const first = { ...firstContribution, subject }+ const next = { ...nextContribution, subject }+ const mergeInner = mergeInheritedAccessItem(+ mergeInheritedAccessItem(null, first, firstFolder),+ next,+ secondFolder+ )+ const mergeOuter = mergeInheritedAccessItem(mergeInner, first, firstFolder)+ expect(mergeOuter).toEqual(mergeInner)+ }+ ),+ { numRuns: 300 }+ )+ })+it('never drops a source: every contributing folder survives the fold', () => {fc.assert(fc.property(@@ -100,7 +128,7 @@ describe('inheritedAccessMerge properties', () => {let item = mergeInheritedAccessItem(null,{ subject, permissions: permissionSets[0] ?? ['read'], grantId: null, shareIds: [] },- folders[0]+ folders[0]!)folders.slice(1).forEach((folder, index) => {item = mergeInheritedAccessItem(@@ -116,9 +144,11 @@ describe('inheritedAccessMerge properties', () => {folder)})- expect(new Set(item.sources.map(source => source.resourceId))).toEqual(- new Set(folders.map(folder => folder.resourceId))- )+ const sourceIds = item.sources.map(source => source.resourceId)+ const expectedIds = folders.map(folder => folder.resourceId)+ expect(sourceIds).toHaveLength(expectedIds.length)+ expect(new Set(sourceIds).size).toBe(sourceIds.length)+ expect(sourceIds).toEqual(expectedIds)}),{ numRuns: 300 }@@ -133,19 +163,19 @@ describe('inheritedAccessMerge properties', () => {fc.array(permissionsArb, { minLength: 1, maxLength: 8 }),(subject, folders, permissionSets) => {let item: ReturnType<typeof mergeInheritedAccessItem> | null = null- folders.forEach((folder, index) => {+ for (const [index, folder] of folders.entries()) {item = mergeInheritedAccessItem(item,{subject,- permissions: permissionSets[index % permissionSets.length],+ permissions: permissionSets[index % permissionSets.length]!,grantId: null,shareIds: [],},folder)- })- const merged = item as NonNullable<typeof item>+ }+ const merged = item!const strongestRank = Math.max(...merged.sources.map(source => roleRank(source.permissions)))@@ -191,7 +221,7 @@ describe('inheritedAccessMerge properties', () => {const sources: GfsInheritedAccessSource[] = folders.map((folder, index) => ({resourceId: folder.resourceId,name: folder.name,- permissions: permissionSets[index % permissionSets.length],+ permissions: permissionSets[index % permissionSets.length]!,grantId: null,shareIds: [],}))diff --git a/desktop-app/ui/src/gfs/inheritedAccess.ts b/desktop-app/ui/src/gfs/inheritedAccess.tsindex ff3732138..e39fe40b7 100644--- a/desktop-app/ui/src/gfs/inheritedAccess.ts+++ b/desktop-app/ui/src/gfs/inheritedAccess.ts@@ -10,11 +10,12 @@ export { planInheritedRoleChange, strongestInheritedSource } from './inheritedAc* inheritance is reconstructed by walking the ancestor folders (the same* resolve-based walk the breadcrumb trail uses) and keeping the rows that* apply to descendants: grants with inherit=true and shares with- * includeDescendants=true — the server's allow() rule. The walk is- * best-effort: ancestors this caller cannot resolve or whose ACL it may not- * view (view-ACL = manage-ACL server-side) are skipped. Rows are merged per- * subject through the pure merge core (`inheritedAccessMerge.ts`, property- * tested in R1-M2); EVERY contributing ancestor folder is kept as an editable+ * includeDescendants=true — the server's allow() rule. Derivation is+ * all-or-nothing: if a required ancestor or its ACL cannot be read, callers+ * must show an incomplete-access notice rather than an empty/partial result.+ * Rows are merged per subject through the pure merge core+ * (`inheritedAccessMerge.ts`, property+ * tested in R1-M4); EVERY contributing ancestor folder is kept as an editable* source, so a confirmed removal revokes all of them and a confirmed* downgrade lowers each one above the target role (R1-H1).*/@@ -26,20 +27,16 @@ function ridOf(resourceId: string): string {}/**- * Walk semantics (R1-L3, unified with the control-ui walk in+ * Walk semantics (R1-M1, unified with the control-ui walk in* control-ui/components/gfsInheritedAccess.ts):* - BOUNDED in depth: at most GFS_BREADCRUMB_MAX_DEPTH ancestors are visited* (the control-ui path walk caps itself with the same number via* GFS_INHERITED_WALK_MAX_DEPTH).- * - BEST-EFFORT skip-and-continue: an ancestor whose ACL cannot be listed- * (view-ACL = manage-ACL server-side) is skipped and the walk CONTINUES- * upward — per-ancestor failures never fail the derivation.- * - One documented divergence: this walk chains parent ids, so each ancestor- * is only reachable by resolving the one below it. An ancestor that cannot- * be RESOLVED at all therefore ends the walk — its parent id (the only- * route to higher ancestors) is unavailable. The control-ui walk addresses- * ancestors by canonical path instead and skips unresolvable ones while- * continuing with the rest.+ * - COMPLETE or FAILED: every ancestor must resolve and both ACL lists must+ * load. Any failure throws the same derivation error used by Control UI;+ * the UI can then distinguish incomplete data from no inherited access.+ * - Desktop follows parent resource IDs and Control UI follows canonical+ * paths, but both surfaces use the same failure rule.*/export async function deriveGfsInheritedAccess(resourceId: string,@@ -51,18 +48,18 @@ export async function deriveGfsInheritedAccess(let parentResourceId = target.parentResourceIdwhile (parentResourceId && seenResourceIds.size - 1 < GFS_BREADCRUMB_MAX_DEPTH) {- if (seenResourceIds.has(parentResourceId)) break+ if (seenResourceIds.has(parentResourceId)) {+ throw new Error('inherited_access_derivation_failed')+ }seenResourceIds.add(parentResourceId)let parent: Awaited<ReturnType<typeof window.clerum.gfs.resolve>>try {parent = await window.clerum.gfs.resolve(`gfs://${drive}/${ridOf(parentResourceId)}`)} catch {- // A direct file grant can be readable while its parent is not; stop at- // the first ancestor the caller may not resolve.- break+ throw new Error('inherited_access_derivation_failed')}- if (parent.kind !== 'directory') break+ if (parent.kind !== 'directory') throw new Error('inherited_access_derivation_failed')// The drive root carries an empty name; its label falls back to the drive.const folderLabel = parent.name || drive@@ -80,8 +77,9 @@ export async function deriveGfsInheritedAccess(merge(share.subject, share.permissions, null, [share.id], parent.resourceId, folderLabel)}} catch {- // Viewing an ancestor's ACL requires manage_acl on it; an ancestor- // this caller may not view contributes no rows.+ // A missing ACL read can hide inherited access, so do not return a+ // partial result that looks complete.+ throw new Error('inherited_access_derivation_failed')}parentResourceId = parent.parentResourceIddiff --git a/desktop-app/ui/src/gfs/inheritedAccessMerge.ts b/desktop-app/ui/src/gfs/inheritedAccessMerge.tsindex f9db5a11e..40ec8cf34 100644--- a/desktop-app/ui/src/gfs/inheritedAccessMerge.ts+++ b/desktop-app/ui/src/gfs/inheritedAccessMerge.ts@@ -1,7 +1,7 @@import type { GfsInheritedAccessItem, GfsInheritedAccessSource } from './delegation.types'/**- * Pure merge core for the client-side inherited-access derivation (R1-M2).+ * Pure merge core for the client-side inherited-access derivation (R1-M4).* No window, no network — everything here is a function of its inputs, which* is what the fast-check property suite in `__tests__/inheritedAccessMerge.prop.test.ts`* relies on: merge idempotency, no source dropped, effective role = strongestdiff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex 07ff2f8fe..67291218c 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -768,7 +768,7 @@ export function FilesPage({} catch (updateError) {await failPartially(updateError,- `Updated ${updates.length} of ${updates.length} folders — direct access on ${current?.name ?? 'this file'} still shows the old role`+ `Updated ${updates.length} of ${updates.length} folders — direct access on ${current?.name ?? 'this file'} could not be fully aligned`)return}@@ -2102,10 +2102,12 @@ export function FilesPage({folders:parentUpdate.mode === 'remove'? parentUpdate.row.inherited.sources.map(source => ({+ resourceId: source.resourceId,name: source.name,currentRole: roleForAccessPermissions(source.permissions),})): parentUpdate.updates.map(update => ({+ resourceId: update.source.resourceId,name: update.source.name,currentRole: roleForAccessPermissions(update.source.permissions),})),diff --git a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsxindex b16b7a156..a9599643c 100644--- a/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx+++ b/desktop-app/ui/src/pages/__tests__/FilesPage.test.tsx@@ -1848,7 +1848,7 @@ describe('FilesPage', () => {it('confirms an inherited role change against the parent folder and applies it there', async () => {installInheritedDirectoryMocks()- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grantconst refreshGrants = vi.fn(async () => undefined)const refreshInheritedAccess = vi.fn(async () => undefined)const fileGrant = vi.fn(async () => undefined)@@ -1918,7 +1918,7 @@ describe('FilesPage', () => {// while the toast claims Read-only.it('revokes the file’s direct shares when a confirmed parent role change downgrades the member', async () => {installInheritedDirectoryMocks()- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grantconst directShare = {id: 'file-share-1',drive: 'main',@@ -1941,30 +1941,37 @@ describe('FilesPage', () => {},],}- let removeDirectShare: (() => void) | undefined+ const inheritedSource = inheritedEditor.sources[0]!+ let refreshShareQuery: (() => void) | undefined+ let completeShareRefresh: (() => void) | undefinedlet downgradeInherited: (() => void) | undefinedparentGrant.mockImplementation(async () => {downgradeInherited?.()})const fileGrant = vi.fn(async () => undefined)const revokeShare = vi.fn(async () => undefined)- const refreshShares = vi.fn(async () => undefined)+ const refreshShares = vi.fn(+ () =>+ new Promise<void>(resolve => {+ completeShareRefresh = () => {+ refreshShareQuery?.()+ resolve()+ }+ })+ )const pushToast = vi.fn()hookMock.useGfsBrowserController.mockImplementation(() => {const [shares, setShares] = useState([directShare])const [inheritedAccess, setInheritedAccess] = useState([inheritedEditor])- removeDirectShare = () => setShares([])+ refreshShareQuery = () => setShares([])downgradeInherited = () =>setInheritedAccess([{...inheritedEditor,permissions: ['read'],- sources: [{ ...inheritedEditor.sources[0], permissions: ['read'] }],+ sources: [{ ...inheritedSource, permissions: ['read'] }],},])- revokeShare.mockImplementation(async () => {- removeDirectShare?.()- })return inheritedFileController({grants: [],shares,@@ -1981,6 +1988,9 @@ describe('FilesPage', () => {// The direct share row is consumed by the deduped merged row.expect(within(manageDialog).queryByTestId('gfs-access-row-share-file-share-1')).toBeNull()const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')+ expect(+ within(row).getByRole('button', { name: 'Access role for Test Two' }).textContent+ ).toContain('Editor')await act(async () => {fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))@@ -1993,13 +2003,26 @@ describe('FilesPage', () => {fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Update role' }))})- // The direct share is superseded by the aligned grant and revoked…+ // The revoke mutation does not alter rendered/query state by itself.await waitFor(() => expect(revokeShare).toHaveBeenCalledWith('file-share-1'))+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Editor')// …after the replacement grant expresses the confirmed role.await waitFor(() =>expect(fileGrant).toHaveBeenCalledWith(['user:user-2'], ['read', 'share'], false))- await waitFor(() => expect(refreshShares).toHaveBeenCalled())+ await waitFor(() => expect(refreshShares).toHaveBeenCalledTimes(1))+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Editor')+ await act(async () => {+ completeShareRefresh?.()+ })await waitFor(() =>expect(within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {@@ -2013,14 +2036,131 @@ describe('FilesPage', () => {)})+ // R1-H2 — a partial revoke also waits for refreshed server-backed shares+ // before showing the effective role.+ it('refreshes shares after a partial inherited-access mutation failure', async () => {+ installInheritedDirectoryMocks()+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grant+ const editorShare = {+ id: 'file-editor-share',+ drive: 'main',+ resourceId: 'file-1',+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ includeDescendants: false,+ }+ const readShare = {+ ...editorShare,+ id: 'file-read-share',+ permissions: ['read'],+ }+ const inheritedEditor = {+ subject: { type: 'user', id: 'user-2' },+ permissions: ['read', 'write'],+ inheritedFrom: ['Team folder'],+ sources: [+ {+ resourceId: 'folder-1',+ name: 'Team folder',+ permissions: ['read', 'write'],+ grantId: 'parent-grant-1',+ shareIds: [],+ },+ ],+ }+ const inheritedSource = inheritedEditor.sources[0]!+ let refreshShareQuery: (() => void) | undefined+ let completeShareRefresh: (() => void) | undefined+ let downgradeInherited: (() => void) | undefined+ parentGrant.mockImplementation(async () => downgradeInherited?.())+ const revokeShare = vi+ .fn<(shareId: string) => Promise<void>>()+ .mockResolvedValueOnce(undefined)+ .mockRejectedValueOnce(new Error('share revoke failed'))+ const refreshShares = vi.fn(+ () =>+ new Promise<void>(resolve => {+ completeShareRefresh = () => {+ refreshShareQuery?.()+ resolve()+ }+ })+ )+ const pushToast = vi.fn()+ hookMock.useGfsBrowserController.mockImplementation(() => {+ const [shares, setShares] = useState([editorShare, readShare])+ const [inheritedAccess, setInheritedAccess] = useState([inheritedEditor])+ refreshShareQuery = () => setShares([readShare])+ downgradeInherited = () =>+ setInheritedAccess([+ {+ ...inheritedEditor,+ permissions: ['read'],+ sources: [{ ...inheritedSource, permissions: ['read'] }],+ },+ ])+ return inheritedFileController({+ grants: [],+ shares,+ inheritedAccess,+ revokeShare,+ refreshShares,+ })+ })++ renderFilesPage(pushToast)+ await openManageDialog('report.txt')+ const manageDialog = await screen.findByRole('dialog', { name: 'Share file report.txt' })+ const row = await within(manageDialog).findByTestId('gfs-access-row-inherited-user:user-2')++ expect(+ within(row).getByRole('button', { name: 'Access role for Test Two' }).textContent+ ).toContain('Editor')+ await act(async () => {+ fireEvent.click(within(row).getByRole('button', { name: 'Access role for Test Two' }))+ })+ await act(async () => {+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))+ })+ const confirmDialog = await screen.findByRole('alertdialog')+ await act(async () => {+ fireEvent.click(within(confirmDialog).getByRole('button', { name: 'Update role' }))+ })++ await waitFor(() => expect(revokeShare).toHaveBeenCalledTimes(2))+ expect(revokeShare).toHaveBeenNthCalledWith(1, 'file-editor-share')+ expect(revokeShare).toHaveBeenNthCalledWith(2, 'file-read-share')+ await waitFor(() => expect(refreshShares).toHaveBeenCalledTimes(1))+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Editor')+ await act(async () => {+ completeShareRefresh?.()+ })+ await waitFor(() =>+ expect(+ within(screen.getByTestId('gfs-access-row-inherited-user:user-2')).getByRole('button', {+ name: 'Access role for Test Two',+ }).textContent+ ).toContain('Read')+ )+ expect(pushToast).toHaveBeenCalledWith(+ expect.stringContaining('direct access on report.txt could not be fully aligned'),+ 'error'+ )+ })+// R1-M1 — the parent grant's bits are judged by the PARENT folder's// grantable bits, never by the open file's affordances (which may be null// or narrower than what the folder allows).it('derives the parent grant bits from the parent folder affordances, not the file', async () => {installInheritedDirectoryMocks()- const folderAffordances = (window.clerum.gfs as { affordances: ReturnType<typeof vi.fn> })- .affordances- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const folderAffordances = (+ window.clerum.gfs as unknown as { affordances: ReturnType<typeof vi.fn> }+ ).affordances+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grantconst pushToast = vi.fn()// The file's grantable bits came back empty (failed/narrow probe) — the// legacy path built the parent bits from these and confirmed a [] grant.@@ -2071,15 +2211,15 @@ describe('FilesPage', () => {it('refuses a role the parent folder cannot grant, before opening the confirmation', async () => {installInheritedDirectoryMocks()- ;(window.clerum.gfs as { affordances: ReturnType<typeof vi.fn> }).affordances.mockResolvedValue(- {- held: ['read', 'share'],- canDelegate: true,- grantableBits: ['read', 'share'],- canCreateShare: false,- }- )- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ ;(+ window.clerum.gfs as unknown as { affordances: ReturnType<typeof vi.fn> }+ ).affordances.mockResolvedValue({+ held: ['read', 'share'],+ canDelegate: true,+ grantableBits: ['read', 'share'],+ canCreateShare: false,+ })+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> }).grantconst pushToast = vi.fn()// Read-only inherited floor: upgrading to Editor must be judged against// the folder, which cannot grant write.@@ -2286,7 +2426,8 @@ describe('FilesPage', () => {it('downgrades only the ancestors above the target role', async () => {installInheritedDirectoryMocks()- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> })+ .grantconst pushToast = vi.fn()// Marketing is already at Read; Campaigns sits above the target.hookMock.useGfsBrowserController.mockReturnValue(@@ -2328,7 +2469,8 @@ describe('FilesPage', () => {it('raises exactly one strongest ancestor on upgrade', async () => {installInheritedDirectoryMocks()- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> })+ .grantconst readCampaigns = { ...CAMPAIGNS, permissions: ['read', 'share'] }const readMarketing = { ...MARKETING }hookMock.useGfsBrowserController.mockReturnValue(@@ -2366,9 +2508,11 @@ describe('FilesPage', () => {// inherited-floor comparison that escalates the parent folder.it('re-selecting the displayed merged role opens no modal and issues no writes', async () => {installInheritedDirectoryMocks()- const folderAffordances = (window.clerum.gfs as { affordances: ReturnType<typeof vi.fn> })- .affordances- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const folderAffordances = (+ window.clerum.gfs as unknown as { affordances: ReturnType<typeof vi.fn> }+ ).affordances+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> })+ .grantconst pushToast = vi.fn()// Direct Editor grant on the file + inherited Read floor: the row// displays Editor even though the inherited-only role is Read.@@ -2436,7 +2580,8 @@ describe('FilesPage', () => {// the parent update.it('revokes an unexpressible direct grant and renders the effective role after refresh', async () => {installInheritedDirectoryMocks()- const parentGrant = (window.clerum.gfs as { grant: ReturnType<typeof vi.fn> }).grant+ const parentGrant = (window.clerum.gfs as unknown as { grant: ReturnType<typeof vi.fn> })+ .grantconst editorGrant = {id: 'file-editor-grant',drive: 'main',@@ -2480,7 +2625,7 @@ describe('FilesPage', () => {{...inheritedEditor,permissions: ['read'],- sources: [{ ...inheritedEditor.sources[0], permissions: ['read'] }],+ sources: [{ ...inheritedEditor.sources[0]!, permissions: ['read'] }],},])return inheritedFileController({@@ -4073,7 +4218,7 @@ describe('FilesPage', () => {renderFilesPage()let breadcrumbs = screen.getByRole('navigation', { name: 'File location' })- let titleRow = document.querySelector('.da-gfs-drive__title-row')+ let titleRow = document.querySelector<HTMLElement>('.da-gfs-drive__title-row')expect(within(breadcrumbs).queryByRole('button', { name: 'Options for Product' })).toBeNull()expect(within(breadcrumbs).queryByRole('button', { name: 'Options for report.md' })).toBeNull()expect(within(titleRow!).queryByRole('button', { name: 'Options for report.md' })).toBeNull()@@ -4112,7 +4257,7 @@ describe('FilesPage', () => {renderFilesPage()breadcrumbs = screen.getByRole('navigation', { name: 'File location' })- titleRow = document.querySelector('.da-gfs-drive__title-row')+ titleRow = document.querySelector<HTMLElement>('.da-gfs-drive__title-row')expect(within(breadcrumbs).queryByRole('button', { name: 'Options for Product' })).toBeNull()expect(within(breadcrumbs).queryByRole('button', { name: 'Options for Nested' })).toBeNull()