Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

refactor(ui): rp-018 drop the legacy role planner from both merge adapters

M81d92d6d7169
diff --git a/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts b/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts
index 5952c1733..0e17e77bd 100644
--- a/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts
+++ b/control-ui/components/__tests__/gfsInheritedAccessMerge.prop.test.ts
@@ -6,9 +6,7 @@ import {
type InheritedAccessFolder,
isEditorPermissions,
mergeInheritedAccessItem,
- planInheritedRoleChange,
roleRank,
- strongestInheritedSource,
} from '../gfsInheritedAccessMerge'
/**
@@ -195,59 +193,11 @@ describe('gfsInheritedAccessMerge properties', () => {
const rightRank = roleRank(right)
const comparisons = [leftRank < rightRank, leftRank === rightRank, leftRank > rightRank]
expect(comparisons.filter(Boolean)).toHaveLength(1)
-
- const toSource = (permissions: string[]): GfsInheritedAccessSource => ({
- resourceId: 'r',
- name: 'r',
- permissions,
- grantId: null,
- shareIds: [],
- })
- const forward = strongestInheritedSource([toSource(left), toSource(right)])
- const backward = strongestInheritedSource([toSource(right), toSource(left)])
- expect(roleRank(forward?.permissions ?? [])).toBe(roleRank(backward?.permissions ?? []))
}),
{ numRuns: 300 }
)
})
- it('the R1-H1 plan never drops an above-target source', () => {
- fc.assert(
- fc.property(
- distinctFoldersArb,
- fc.array(permissionsArb, { minLength: 1, maxLength: 8 }),
- (folders, permissionSets) => {
- const sources: GfsInheritedAccessSource[] = folders.map((folder, index) => ({
- resourceId: folder.resourceId,
- name: folder.name,
- permissions: permissionSets[index % permissionSets.length]!,
- grantId: null,
- shareIds: [],
- }))
- const permissions = [...new Set(sources.flatMap(source => source.permissions))]
- const item = { permissions, sources }
- const editorSources = sources.filter(source => isEditorPermissions(source.permissions))
- const readSources = sources.filter(source => !isEditorPermissions(source.permissions))
-
- const downgrade = planInheritedRoleChange(item, false)
- expect(downgrade).toHaveLength(editorSources.length)
-
- const upgrade = planInheritedRoleChange(item, true)
- if (isEditorPermissions(permissions)) {
- expect(upgrade).toHaveLength(0)
- } else {
- expect(upgrade).toHaveLength(1)
- }
-
- const noOp = planInheritedRoleChange(item, isEditorPermissions(permissions))
- expect(noOp).toHaveLength(0)
- expect(readSources.length + editorSources.length).toBe(sources.length)
- }
- ),
- { numRuns: 300 }
- )
- })
-
// R1-M5 — the adapter projection PRESERVES per-row provenance: a
// grant-backed folder keeps the grant's own bits and scope flag, every
// share keeps its own row id/bits/scope, and re-folding a projected item
diff --git a/control-ui/components/gfsInheritedAccess.ts b/control-ui/components/gfsInheritedAccess.ts
index 78a73bb2f..5cf5b4aac 100644
--- a/control-ui/components/gfsInheritedAccess.ts
+++ b/control-ui/components/gfsInheritedAccess.ts
@@ -18,8 +18,6 @@ import type {
} from './GfsGrantPanel.types'
import { inheritedSubjectKey, mergeInheritedAccessItem } from './gfsInheritedAccessMerge'
-export { planInheritedRoleChange, strongestInheritedSource } from './gfsInheritedAccessMerge'
-
/** `/docs/report.md` → `['/docs', '/']` (nearest ancestor first, depth-capped). */
export function gfsAncestorPaths(path: string): string[] {
return gfsAncestorPathsOf(path)
diff --git a/control-ui/components/gfsInheritedAccessMerge.ts b/control-ui/components/gfsInheritedAccessMerge.ts
index 2e63732bf..7d7eb6efc 100644
--- a/control-ui/components/gfsInheritedAccessMerge.ts
+++ b/control-ui/components/gfsInheritedAccessMerge.ts
@@ -3,12 +3,8 @@ import {
gfsSubjectKeyOf,
isEditorGfsPermissions,
mergeGfsInheritedAccessItem as mergeInheritedAccessPolicy,
- strongestGfsInheritedSource,
-} from '@clerum/gfs-interaction-policy'
-import type {
- GfsInheritedAccessItem as PolicyInheritedAccessItem,
- GfsInheritedAccessSource as PolicyInheritedAccessSource,
} from '@clerum/gfs-interaction-policy'
+import type { GfsInheritedAccessItem as PolicyInheritedAccessItem } from '@clerum/gfs-interaction-policy'
import type { GfsInheritedAccessItem, GfsInheritedAccessSource } from './GfsGrantPanel.types'
/**
@@ -46,41 +42,6 @@ export interface InheritedAccessFolder {
name: string
}
-/** The strongest contributing folder: editor beats read, nearest among equals. */
-export function strongestInheritedSource(
- sources: GfsInheritedAccessSource[]
-): GfsInheritedAccessSource | null {
- return strongestGfsInheritedSource(
- sources as PolicyInheritedAccessSource[]
- ) as GfsInheritedAccessSource | null
-}
-
-/**
- * Which ancestor folders a confirmed role change to the target role must
- * touch (R1-H1 semantics, verified against Google Drive):
- * - downgrade: EVERY source whose role is above the target (ancestors at or
- * below the target stay untouched);
- * - upgrade: the single strongest source (nearest among equals) — the
- * effective role is the strongest across sources, so one raise is enough;
- * - no-op (target equals the effective role): none.
- *
- * Kept flat and order-preserving (the app's established contract): the
- * richer grant-vs-share split planner remains available from the shared
- * package for the scoped per-source edit work.
- */
-export function planInheritedRoleChange(
- item: Pick<GfsInheritedAccessItem, 'permissions' | 'sources'>,
- targetRoleIsEditor: boolean
-): GfsInheritedAccessSource[] {
- const effectiveIsEditor = isEditorGfsPermissions(item.permissions)
- if (targetRoleIsEditor === effectiveIsEditor) return []
- if (!targetRoleIsEditor) {
- return item.sources.filter(source => isEditorGfsPermissions(source.permissions))
- }
- const strongest = strongestInheritedSource(item.sources)
- return strongest ? [strongest] : []
-}
-
/**
* Folds one inheriting row into a subject's derived access item (creating it
* on first sight) through the shared pure core, then projects the result back
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 3ea631711..d03913f1a 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"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.json
index 78f8d639e..f482cdb9b 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.747",
+ "version": "0.1.748",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts b/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts
index 3372c1709..ef6f16bcd 100644
--- a/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts
+++ b/desktop-app/ui/src/gfs/__tests__/inheritedAccessMerge.prop.test.ts
@@ -7,9 +7,7 @@ import {
type InheritedAccessFolder,
isEditorPermissions,
mergeInheritedAccessItem,
- planInheritedRoleChange,
roleRank,
- strongestInheritedSource,
} from '../inheritedAccessMerge'
/**
@@ -196,64 +194,11 @@ describe('inheritedAccessMerge properties', () => {
const rightRank = roleRank(right)
const comparisons = [leftRank < rightRank, leftRank === rightRank, leftRank > rightRank]
expect(comparisons.filter(Boolean)).toHaveLength(1)
-
- const toSource = (permissions: string[]): GfsInheritedAccessSource =>
- mergeInheritedAccessItem(
- null,
- { subject: { type: 'user', id: 'member' }, permissions, grantId: null, shareIds: [] },
- { resourceId: 'r', name: 'r' }
- ).sources[0]!
- const forward = strongestInheritedSource([toSource(left), toSource(right)])
- const backward = strongestInheritedSource([toSource(right), toSource(left)])
- expect(roleRank(forward?.permissions ?? [])).toBe(roleRank(backward?.permissions ?? []))
}),
{ numRuns: 300 }
)
})
- it('the R1-H1 plan never drops an above-target source', () => {
- fc.assert(
- fc.property(
- distinctFoldersArb,
- fc.array(permissionsArb, { minLength: 1, maxLength: 8 }),
- (folders, permissionSets) => {
- const sources: GfsInheritedAccessSource[] = folders.map(
- (folder, index) =>
- mergeInheritedAccessItem(
- null,
- {
- subject: { type: 'user', id: 'member' },
- permissions: permissionSets[index % permissionSets.length]!,
- grantId: null,
- shareIds: [],
- },
- folder
- ).sources[0]!
- )
- const permissions = [...new Set(sources.flatMap(source => source.permissions))]
- const item = { permissions, sources }
- const editorSources = sources.filter(source => isEditorPermissions(source.permissions))
- const readSources = sources.filter(source => !isEditorPermissions(source.permissions))
-
- const downgrade = planInheritedRoleChange(item, false)
- expect(downgrade).toHaveLength(editorSources.length)
-
- const upgrade = planInheritedRoleChange(item, true)
- if (isEditorPermissions(permissions)) {
- expect(upgrade).toHaveLength(0)
- } else {
- expect(upgrade).toHaveLength(1)
- }
-
- const noOp = planInheritedRoleChange(item, isEditorPermissions(permissions))
- expect(noOp).toHaveLength(0)
- expect(readSources.length + editorSources.length).toBe(sources.length)
- }
- ),
- { numRuns: 300 }
- )
- })
-
// R1-M5 — the adapter projection PRESERVES per-row provenance: a
// grant-backed folder keeps the grant's own bits and scope flag, every
// share keeps its own row id/bits/scope, and re-folding a projected item
diff --git a/desktop-app/ui/src/gfs/inheritedAccess.ts b/desktop-app/ui/src/gfs/inheritedAccess.ts
index 5d15a2629..2b81ef087 100644
--- a/desktop-app/ui/src/gfs/inheritedAccess.ts
+++ b/desktop-app/ui/src/gfs/inheritedAccess.ts
@@ -5,8 +5,6 @@ import { isGfsSessionAuthorityFailure, parseHttpStatus } from '@lib/gfsGrantErro
import type { GfsInheritedAccessItem, GfsInheritedAccessResult } from './delegation.types'
import { inheritedSubjectKey, mergeInheritedAccessItem } from './inheritedAccessMerge'
-export { planInheritedRoleChange, strongestInheritedSource } from './inheritedAccessMerge'
-
/**
* Derives the inherited access for one resource on the client. The user-plane
* grants/shares GETs list only the rows configured directly on a resource, so
diff --git a/desktop-app/ui/src/gfs/inheritedAccessMerge.ts b/desktop-app/ui/src/gfs/inheritedAccessMerge.ts
index 32da5821c..906af3671 100644
--- a/desktop-app/ui/src/gfs/inheritedAccessMerge.ts
+++ b/desktop-app/ui/src/gfs/inheritedAccessMerge.ts
@@ -3,12 +3,8 @@ import {
gfsSubjectKeyOf,
isEditorGfsPermissions,
mergeGfsInheritedAccessItem as mergeInheritedAccessPolicy,
- strongestGfsInheritedSource,
-} from '@clerum/gfs-interaction-policy'
-import type {
- GfsInheritedAccessItem as PolicyInheritedAccessItem,
- GfsInheritedAccessSource as PolicyInheritedAccessSource,
} from '@clerum/gfs-interaction-policy'
+import type { GfsInheritedAccessItem as PolicyInheritedAccessItem } from '@clerum/gfs-interaction-policy'
import type { GfsInheritedAccessItem, GfsInheritedAccessSource } from './delegation.types'
/**
@@ -46,41 +42,6 @@ export interface InheritedAccessFolder {
name: string
}
-/** The strongest contributing folder: editor beats read, nearest among equals. */
-export function strongestInheritedSource(
- sources: GfsInheritedAccessSource[]
-): GfsInheritedAccessSource | null {
- return strongestGfsInheritedSource(
- sources as PolicyInheritedAccessSource[]
- ) as GfsInheritedAccessSource | null
-}
-
-/**
- * Which ancestor folders a confirmed role change to the target role must
- * touch (R1-H1 semantics, verified against Google Drive):
- * - downgrade: EVERY source whose role is above the target (ancestors at or
- * below the target stay untouched);
- * - upgrade: the single strongest source (nearest among equals) — the
- * effective role is the strongest across sources, so one raise is enough;
- * - no-op (target equals the effective role): none.
- *
- * Kept flat and order-preserving (the app's established contract): the
- * richer grant-vs-share split planner remains available from the shared
- * package for the scoped per-source edit work.
- */
-export function planInheritedRoleChange(
- item: Pick<GfsInheritedAccessItem, 'permissions' | 'sources'>,
- targetRoleIsEditor: boolean
-): GfsInheritedAccessSource[] {
- const effectiveIsEditor = isEditorGfsPermissions(item.permissions)
- if (targetRoleIsEditor === effectiveIsEditor) return []
- if (!targetRoleIsEditor) {
- return item.sources.filter(source => isEditorGfsPermissions(source.permissions))
- }
- const strongest = strongestInheritedSource(item.sources)
- return strongest ? [strongest] : []
-}
-
/**
* Folds one inheriting row into a subject's derived access item (creating it
* on first sight) through the shared pure core, then projects the result back