Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): rp-032 keep conflicting-only revocation and cover it
M378dfc8059bc
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsxindex ac1cd949c..f84019c40 100644--- a/control-ui/components/GfsGrantPanel.tsx+++ b/control-ui/components/GfsGrantPanel.tsx@@ -624,7 +624,14 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme): Promise<string[]> {const revoked: string[] = []for (const entry of conflictingShareEntries(entries, nextRole)) {- await deleteGfsShare(entry.rowId)+ try {+ await deleteGfsShare(entry.rowId)+ } catch (caught) {+ // The row is already gone: the sharing entry grants nothing, so the+ // outcome is the one a successful delete would have produced. Calling+ // it a failure would claim residual Editor access that cannot exist.+ if (!isAlreadyMissing(caught)) throw caught+ }revoked.push(entry.rowId)}return revoked@@ -888,7 +895,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme}const affected = request.affectedconst affectedNames = affected.map(update => update.source.name)- const revokedFolderNames: string[] = []+ const revokedFolderNames = new Set<string>()let updated = 0for (const { source, permissions } of affected) {try {@@ -918,7 +925,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme// so a sharing entry that still grants Editor goes with it.try {const revoked = await revokeConflictingShares(source.shareEntries, request.nextRole)- if (revoked.length > 0) revokedFolderNames.push(source.name)+ if (revoked.length > 0) revokedFolderNames.add(source.name)} catch (caught) {if (!isAlreadyMissing(caught)) {setError(caught instanceof Error ? caught.message : 'Failed to revoke a sharing entry')@@ -954,7 +961,7 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme// through a link on the item itself.try {const revoked = await revokeConflictingShares(row.direct.shareEntries, request.nextRole)- if (revoked.length > 0) revokedFolderNames.push(resource.name)+ if (revoked.length > 0) revokedFolderNames.add(resource.name)} catch (caught) {if (!isAlreadyMissing(caught)) {setError(caught instanceof Error ? caught.message : 'Failed to revoke a sharing entry')@@ -977,8 +984,8 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme`Updated ${updated} of ${affected.length + request.skippedFolderNames.length} folders. Sharing details on ${joinFolderNames(request.skippedFolderNames)} could not be verified; existing access was kept.`)}- if (revokedFolderNames.length > 0) {- details.push(revokedSharesCopy(revokedFolderNames))+ if (revokedFolderNames.size > 0) {+ details.push(revokedSharesCopy([...revokedFolderNames]))}if (residualNames.length > 0) {details.push(diff --git a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsxindex afce01956..8c410619e 100644--- a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx@@ -324,6 +324,70 @@ describe('GfsGrantPanel bulk access', () => {expect(mockDeleteGfsShare).not.toHaveBeenCalled()})+ // RP-032 — a Read DOWNGRADE on a merged grant+share row revokes the+ // sharing entry that still grants Editor (the server has no share-update+ // surface), while the grant is rewritten with its OWN scope flag. A Read+ // sharing entry is not a conflict and survives.+ it('revokes the conflicting sharing entry when a merged grant and share row is downgraded', async () => {+ const EDITOR_SHARE_ID = '55555555-5555-4555-8555-555555555555'+ const READ_SHARE_ID = '66666666-6666-4666-8666-666666666666'+ mockGetGfsGrants.mockResolvedValue({+ items: [+ {+ id: '33333333-3333-3333-3333-333333333333',+ drive: 'main',+ resourceId: resource.resourceId,+ subject: userSubject,+ permissions: ['read', 'write'],+ inherit: false,+ },+ ],+ })+ mockGetGfsShares.mockResolvedValue({+ items: [+ {+ id: EDITOR_SHARE_ID,+ drive: 'main',+ resourceId: resource.resourceId,+ subject: userSubject,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ {+ id: READ_SHARE_ID,+ drive: 'main',+ resourceId: resource.resourceId,+ subject: userSubject,+ permissions: ['read'],+ includeDescendants: true,+ },+ ],+ })+ mockPutGfsGrant.mockResolvedValue(successfulMutation(userSubject))++ renderPanel()++ const existing = await screen.findByRole('region', { name: 'People with access' })+ fireEvent.click(within(existing).getByRole('button', { name: 'Access role for Ada Lovelace' }))+ fireEvent.click(screen.getByRole('option', { name: 'Read' }))++ // The grant keeps its OWN scope flag (false) — the shares' descendant+ // coverage is never OR'd into the grant write.+ await waitFor(() =>+ expect(mockPutGfsGrant).toHaveBeenCalledWith({+ drive: 'main',+ resourceId: resource.resourceId,+ subject: userSubject,+ permissions: ['read', 'share'],+ inherit: false,+ })+ )+ // Only the CONFLICTING entry is revoked; the Read entry survives.+ await waitFor(() => expect(mockDeleteGfsShare).toHaveBeenCalledWith(EDITOR_SHARE_ID))+ expect(mockDeleteGfsShare).not.toHaveBeenCalledWith(READ_SHARE_ID)+ expect(mockDeleteGfsShare).toHaveBeenCalledTimes(1)+ })+// R1-M5 — a share-only principal has no grant to rewrite and no// share-update surface: the role control is disabled and a role change can// never migrate the share into a grant. Explicit grant creation through thediff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsxindex 8346eb339..b2724e213 100644--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx@@ -422,6 +422,192 @@ describe('GfsGrantPanel inherited access', () => {expect(screen.queryByText(/still grant Editor access/)).toBeNull()})+ // RP-032 — conflicting-only: on the rewritten folder the Editor sharing+ // entry goes, the Read sharing entry stays (with its own descendant+ // coverage), and neither entry is touched on any other resource.+ it('revokes only the conflicting sharing entry on the rewritten folder', async () => {+ const EDITOR_SHARE_ID = '14141414-1414-4141-8141-141414141414'+ const READ_SHARE_ID = '15151515-1515-4151-8151-151515151515'+ mockGetGfsGrants.mockImplementation(async resourceId => {+ if (resourceId === FOLDER_ID) {+ return {+ items: [+ {+ id: FOLDER_GRANT_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ inherit: true,+ },+ ],+ }+ }+ return { items: [] }+ })+ mockGetGfsShares.mockImplementation(async resourceId => {+ if (resourceId === FOLDER_ID) {+ return {+ items: [+ {+ id: EDITOR_SHARE_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ {+ id: READ_SHARE_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read'],+ includeDescendants: true,+ },+ ],+ }+ }+ return { items: [] }+ })+ renderPanel()+ const existing = await screen.findByRole('region', { name: 'People with access' })+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)++ await chooseRole(miguelRow, 'Read')+ const dialog = await screen.findByRole('alertdialog')+ fireEvent.click(within(dialog).getByRole('button', { name: 'Update role' }))++ await waitFor(() => expect(mockDeleteGfsShare).toHaveBeenCalledWith(EDITOR_SHARE_ID))+ // The Read entry already grants the target role: it is not a conflict and+ // survives, with its own descendant coverage intact.+ expect(mockDeleteGfsShare).not.toHaveBeenCalledWith(READ_SHARE_ID)+ expect(mockDeleteGfsShare).toHaveBeenCalledTimes(1)+ })++ // RP-032 — a revocation that fails mid-cascade is a PARTIAL outcome: the+ // folders already written stay written, the folder whose sharing entry+ // could not be revoked keeps granting Editor, and the copy says exactly+ // how far the change got.+ it('states the true partial outcome when a folder sharing entry cannot be revoked', async () => {+ const EDITOR_SHARE_ID = '16161616-1616-4161-8161-161616161616'+ mockGetGfsGrants.mockImplementation(async resourceId => {+ if (resourceId === FOLDER_ID) {+ return {+ items: [+ {+ id: FOLDER_GRANT_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ inherit: true,+ },+ ],+ }+ }+ return { items: [] }+ })+ mockGetGfsShares.mockImplementation(async resourceId => {+ if (resourceId === FOLDER_ID) {+ return {+ items: [+ {+ id: EDITOR_SHARE_ID,+ drive: 'main',+ resourceId: FOLDER_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ ],+ }+ }+ return { items: [] }+ })+ mockDeleteGfsShare.mockRejectedValueOnce(+ Object.assign(new Error('403 share_revocation_rejected'), {+ status: 403,+ code: 'share_revocation_rejected',+ serverMessage: 'share_revocation_rejected',+ })+ )+ renderPanel()+ const existing = await screen.findByRole('region', { name: 'People with access' })+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)++ await chooseRole(miguelRow, 'Read')+ const dialog = await screen.findByRole('alertdialog')+ fireEvent.click(within(dialog).getByRole('button', { name: 'Update role' }))++ // The folder's GRANT was rewritten, but its sharing entry survived: the+ // outcome says so instead of claiming the member lost Editor access.+ expect(+ await screen.findByText(+ 'Updated 1 of 1 folders — a sharing entry on team-docs could not be revoked, so Editor access may remain.'+ )+ ).toBeTruthy()+ const alert = await screen.findByRole('alert')+ expect(alert.textContent).toContain('share_revocation_rejected')+ })++ // RP-032 — a sharing entry that is ALREADY GONE grants nothing: the+ // outcome is the one a successful delete produced, so the panel must not+ // claim residual Editor access that cannot exist.+ it('does not report residual Editor access when the sharing entry is already gone', async () => {+ const FILE_SHARE_ID = '17171717-1717-4171-8171-171717171717'+ mockGetGfsGrants.mockImplementation(async resourceId => ({+ items:+ resourceId === FILE_ID+ ? [+ {+ id: FILE_GRANT_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ inherit: false,+ },+ ]+ : [],+ }))+ mockGetGfsShares.mockImplementation(async resourceId => ({+ items:+ resourceId === FILE_ID+ ? [+ {+ id: FILE_SHARE_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: miguel,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ ]+ : [],+ }))+ mockDeleteGfsShare.mockRejectedValueOnce(+ Object.assign(new Error('404 share_not_found'), {+ status: 404,+ code: 'share_not_found',+ serverMessage: 'share_not_found',+ })+ )+ renderPanel()++ const existing = await screen.findByRole('region', { name: 'People with access' })+ const miguelRow = await within(existing).findByTestId(miguelRowTestId)+ await chooseRole(miguelRow, 'Read')++ expect(+ await screen.findByText(+ 'Changed grant access to Read-only on report.md. The sharing entry on report.md was revoked.'+ )+ ).toBeTruthy()+ expect(screen.queryByText(/could not be revoked/)).toBeNull()+ expect(screen.queryByText(/still grant Editor access/)).toBeNull()+ })+// R1-M5 — a share-only ancestor is never converted into a grant: nothing// is written, the confirmation never opens, and the user is told why.it('refuses a share-only ancestor role change without creating a grant', async () => {@@ -686,6 +872,73 @@ describe('GfsGrantPanel inherited access', () => {expect(await screen.findByText('Miguel is now Read-only.')).toBeTruthy()})+ // RP-032 — an UPGRADE revokes nothing: a Read sharing entry AND an Editor+ // sharing entry both survive, so raising the grant never drops access the+ // operator did not ask to drop. The grant's OWN scope flag is preserved.+ it('keeps both a Read sharing entry and an Editor sharing entry on an upgrade to Editor', async () => {+ const READ_SHARE_ID = '12121212-1212-4121-8121-121212121212'+ const EDITOR_SHARE_ID = '13131313-1313-4131-8131-131313131313'+ mockGetGfsGrants.mockImplementation(async resourceId => ({+ items:+ resourceId === FILE_ID+ ? [+ {+ id: FILE_GRANT_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: marcela,+ permissions: ['read'],+ inherit: false,+ },+ ]+ : [],+ }))+ mockGetGfsShares.mockImplementation(async resourceId => ({+ items:+ resourceId === FILE_ID+ ? [+ {+ id: READ_SHARE_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: marcela,+ permissions: ['read'],+ includeDescendants: true,+ },+ {+ id: EDITOR_SHARE_ID,+ drive: 'main',+ resourceId: FILE_ID,+ subject: marcela,+ permissions: ['read', 'write'],+ includeDescendants: true,+ },+ ]+ : [],+ }))+ renderPanel()++ const existing = await screen.findByRole('region', { name: 'People with access' })+ const marcelaRow = await within(existing).findByTestId(marcelaRowTestId)+ await chooseRole(marcelaRow, 'Editor')++ // The grant is raised to Editor with its OWN scope flag (false) — the+ // shares' includeDescendants is never OR'd into the grant write.+ await waitFor(() =>+ expect(mockPutGfsGrant).toHaveBeenCalledWith({+ drive: 'main',+ resourceId: FILE_ID,+ subject: marcela,+ permissions: ['read', 'write', 'delete', 'manage_acl', 'share'],+ inherit: false,+ })+ )+ // Neither sharing entry conflicts with the target role, so neither is+ // revoked: the Read entry keeps its descendant coverage and the Editor+ // entry survives the upgrade.+ expect(mockDeleteGfsShare).not.toHaveBeenCalled()+ })+// RP-032 — a revocation that fails is a PARTIAL outcome: the role changed,// but the link may still grant Editor, and the copy must say so.it('states the true partial outcome when a sharing entry cannot be revoked', async () => {diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex d03913f1a..e641cf936 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.748",+ "version": "0.1.749","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.748",+ "version": "0.1.749","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 f482cdb9b..ddf3215e6 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.748",+ "version": "0.1.749","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",