Skip to content

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

TypeScript

revert: remove backend changes from GFS UI PR

M5a9dece00078
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 07501440f..211f524b5 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.606",
+ "version": "0.1.604",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.606",
+ "version": "0.1.604",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --git a/control-api/package.json b/control-api/package.json
index 0f2f7f103..64d00e152 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.606",
+ "version": "0.1.604",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/src/gfs/resolve.ts b/control-api/src/gfs/resolve.ts
index 0f65f0948..5581c6a54 100644
--- a/control-api/src/gfs/resolve.ts
+++ b/control-api/src/gfs/resolve.ts
@@ -66,7 +66,6 @@ export interface ResolvedResource {
name: string
kind: string
pathCache: string | null
- version: number
updatedAt: string
}
@@ -100,7 +99,7 @@ export interface ResolveDb {
query(text: string, values?: unknown[]): Promise<{ rows: unknown[] }>
}
-const SELECT_COLS = 'resource_id, drive, name, kind, path_cache, version, updated_at'
+const SELECT_COLS = 'resource_id, drive, name, kind, path_cache, updated_at'
function toIsoTimestamp(value: unknown): string {
if (value instanceof Date) return value.toISOString()
@@ -118,7 +117,6 @@ function rowToResource(row: unknown): ResolvedResource {
name: unknown
kind: unknown
path_cache: unknown
- version: unknown
updated_at: unknown
}
return {
@@ -127,7 +125,6 @@ function rowToResource(row: unknown): ResolvedResource {
name: String(r.name),
kind: String(r.kind),
pathCache: r.path_cache == null ? null : String(r.path_cache),
- version: Number(r.version),
updatedAt: toIsoTimestamp(r.updated_at),
}
}
diff --git a/control-api/src/routes/gfs/resolve.ts b/control-api/src/routes/gfs/resolve.ts
index 37d6fa06a..eb7a44a2d 100644
--- a/control-api/src/routes/gfs/resolve.ts
+++ b/control-api/src/routes/gfs/resolve.ts
@@ -19,7 +19,6 @@ export interface GfsResourceView {
name: string
kind: string
path: string | null
- version: number
updatedAt: string
}
@@ -33,7 +32,6 @@ export function toResolveView(resource: ResolvedResource): GfsResourceView {
name: resource.name,
kind: resource.kind,
path: resource.pathCache,
- version: resource.version,
updatedAt: resource.updatedAt,
}
}
diff --git a/control-api/src/routes/gfs/resources.ts b/control-api/src/routes/gfs/resources.ts
index cd4f9ab0c..7e98337f4 100644
--- a/control-api/src/routes/gfs/resources.ts
+++ b/control-api/src/routes/gfs/resources.ts
@@ -6,16 +6,12 @@
* extraction of the drive-lock + tree-walk skeleton is a known follow-up.
*/
import type { Request, Response, Router } from 'express'
-import { ipKeyGenerator, rateLimit } from 'express-rate-limit'
-import { createHash } from 'node:crypto'
import { withTransaction } from '../../db.js'
import { asyncHandler } from '../../http/asyncHandler.js'
-import { type UiAuthedRequest, requireAuthForControlUI } from '../../middleware/controlUIAuth.js'
-import { rateLimitMiddleware } from '../../middleware/rateLimitMiddleware.js'
+import { requireAuthForControlUI } from '../../middleware/controlUIAuth.js'
import {
type GfsCaller,
type GrantsDb,
- PERMISSIONS,
UUID_RE,
auditMutation,
checkAccess,
@@ -25,8 +21,6 @@ import {
} from './grants.js'
const NAME_MAX = 255
-const GFS_RESOURCE_READ_RATE_LIMIT_PER_MINUTE = 120
-const GFS_RESOURCE_WRITE_RATE_LIMIT_PER_MINUTE = 30
// eslint-disable-next-line no-control-regex
const CONTROL_CHARS = /[\x00-\x1f\x7f]/
export class ResourcePatchError extends Error {
@@ -140,26 +134,6 @@ function directoryPath(rows: AncestorRow[]): string {
}
const sameChain = (a: AncestorRow[], b: AncestorRow[]) =>
a.length === b.length && a.every((row, i) => row.resource_id === b[i]?.resource_id)
-
-function gfsResourceRateLimitKey(prefix: string, req: Request): string {
- const subject = (req as UiAuthedRequest).adminAuth?.sub
- if (subject) {
- const subjectHash = createHash('sha256').update(subject).digest('hex').slice(0, 32)
- return `${prefix}:admin:${subjectHash}`
- }
- return `${prefix}:ip:${ipKeyGenerator(req.ip ?? 'unknown')}`
-}
-
-function gfsResourceRateLimitHandler(_req: Request, res: Response): void {
- const raw = res.getHeader('Retry-After')
- const retryAfterSeconds =
- typeof raw === 'number' && Number.isSafeInteger(raw) && raw > 0
- ? raw
- : typeof raw === 'string' && /^\d+$/.test(raw)
- ? Math.max(1, Number(raw))
- : 60
- res.status(429).json({ error: 'Too Many Requests', retryAfterSeconds })
-}
async function refreshSubtreePaths(
db: GrantsDb,
drive: string,
@@ -373,71 +347,7 @@ export async function applyResourcePatch(
}
export function registerGfsResourceRoutes(router: Router): void {
- // The Postgres buckets enforce the limit across replicas. The direct
- // express-rate-limit guards are an in-process backstop and make the bound
- // visible to CodeQL before the route reaches its ACL work.
- const affordancesRateLimit = rateLimitMiddleware({
- bucketType: 'gfs_resources_read',
- maxPerMinute: GFS_RESOURCE_READ_RATE_LIMIT_PER_MINUTE,
- getBucketKey: req => gfsResourceRateLimitKey('gfsresources-read', req),
- })
- const affordancesEdgeRateLimit = rateLimit({
- windowMs: 60_000,
- limit: GFS_RESOURCE_READ_RATE_LIMIT_PER_MINUTE,
- standardHeaders: 'draft-7',
- legacyHeaders: false,
- keyGenerator: req => gfsResourceRateLimitKey('gfsresources-read-edge', req),
- handler: gfsResourceRateLimitHandler,
- })
- const resourcePatchRateLimit = rateLimitMiddleware({
- bucketType: 'gfs_resources_mutation',
- maxPerMinute: GFS_RESOURCE_WRITE_RATE_LIMIT_PER_MINUTE,
- getBucketKey: req => gfsResourceRateLimitKey('gfsresources-write', req),
- })
- const resourcePatchEdgeRateLimit = rateLimit({
- windowMs: 60_000,
- limit: GFS_RESOURCE_WRITE_RATE_LIMIT_PER_MINUTE,
- standardHeaders: 'draft-7',
- legacyHeaders: false,
- keyGenerator: req => gfsResourceRateLimitKey('gfsresources-write-edge', req),
- handler: gfsResourceRateLimitHandler,
- })
-
- router.get(
- '/gfs/resources/:id/affordances',
- affordancesEdgeRateLimit,
- requireAuthForControlUI,
- affordancesRateLimit,
- asyncHandler(async (req, res) => {
- const id = String(req.params.id)
- if (!UUID_RE.test(id)) {
- res.status(400).json({ error: 'path_invalid' })
- return
- }
- // Control UI is the authenticated operator plane. These are the same
- // concrete affordances the desktop preflight consumes; the operator's
- // intrinsic authority supplies every permission on visible resources.
- const caller = resolveCaller(req)
- if (!caller.isOperator) {
- res.status(403).json({ error: 'forbidden' })
- return
- }
- res.status(200).json({
- resourceId: id,
- held: [...PERMISSIONS],
- canDelegate: true,
- grantableBits: [...PERMISSIONS],
- canCreateShare: true,
- })
- })
- )
- router.patch(
- '/gfs/resources/:id',
- resourcePatchEdgeRateLimit,
- requireAuthForControlUI,
- resourcePatchRateLimit,
- asyncHandler(handlePatch)
- )
+ router.patch('/gfs/resources/:id', requireAuthForControlUI, asyncHandler(handlePatch))
}
export async function handlePatch(req: Request, res: Response): Promise<void> {
diff --git a/control-api/test/gfs.resolve.test.ts b/control-api/test/gfs.resolve.test.ts
index 586f7e533..fb2951b64 100644
--- a/control-api/test/gfs.resolve.test.ts
+++ b/control-api/test/gfs.resolve.test.ts
@@ -46,7 +46,6 @@ function res(partial: Partial<ResolvedResource> & { resourceId: string }): Resol
name: 'n',
kind: 'directory',
pathCache: null,
- version: 1,
updatedAt: '2026-01-01T00:00:00.000Z',
...partial,
}
@@ -115,7 +114,6 @@ const row = (resourceId: string, name = 'n', kind = 'directory') => ({
name,
kind,
path_cache: null,
- version: 1,
updated_at: new Date('2026-01-01T00:00:00.000Z'),
})
diff --git a/control-api/test/gfs.resolveRoutes.test.ts b/control-api/test/gfs.resolveRoutes.test.ts
index f1223d841..4377afdb5 100644
--- a/control-api/test/gfs.resolveRoutes.test.ts
+++ b/control-api/test/gfs.resolveRoutes.test.ts
@@ -11,7 +11,6 @@ function res(partial: Partial<ResolvedResource> & { resourceId: string }): Resol
name: 'n',
kind: 'directory',
pathCache: null,
- version: 1,
updatedAt: '2026-01-01T00:00:00.000Z',
...partial,
}
@@ -34,7 +33,6 @@ describe('toResolveView', () => {
expect(view.rid).toBe(RID)
expect(view.gfsUri).toBe(`gfs://main/${RID}`)
expect(view.path).toBe('/org')
- expect(view.version).toBe(1)
expect(view.updatedAt).toBe('2026-01-01T00:00:00.000Z')
expect(view.updatedAt).toMatch(/^\d{4}-\d{2}-\d{2}T.*Z$/)
})
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsx
index 16afa1b44..1dde5a9b8 100644
--- a/control-ui/components/GfsBrowser.tsx
+++ b/control-ui/components/GfsBrowser.tsx
@@ -1049,7 +1049,8 @@ export function GfsBrowser(): React.JSX.Element {
gfsUri: string
name: string
kind: string
- version: number
+ /** The current resolve contract does not return a mutation version. */
+ version?: number
}
if (view.kind !== 'directory') {
setOpenLinkError('Only folder links can be opened here.')
@@ -1067,7 +1068,7 @@ export function GfsBrowser(): React.JSX.Element {
name: view.name,
kind: 'directory',
gfsUri: view.gfsUri,
- version: view.version,
+ ...(view.version === undefined ? {} : { version: view.version }),
},
])
setLoading(true)
diff --git a/control-ui/components/GfsGrantPanel.tsx b/control-ui/components/GfsGrantPanel.tsx
index 9753d10cd..d66828aa3 100644
--- a/control-ui/components/GfsGrantPanel.tsx
+++ b/control-ui/components/GfsGrantPanel.tsx
@@ -29,7 +29,6 @@ import {
deleteGfsShare,
getAdminTeams,
getAdminUsers,
- getGfsAffordances,
getGfsGrants,
getGfsShares,
getHosts,
@@ -553,10 +552,11 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
}
/**
- * Control UI is the operator plane, but it still preflights every affected
- * ancestor independently. The server remains authoritative; this walk keeps
- * the confirmation dialog from promising a role that one folder cannot
- * express and makes the folder-level decision visible in the UI.
+ * Control UI is the operator plane. The backend remains authoritative for
+ * ACL enforcement, so this client plans the affected ancestor mutations from
+ * the access rows it can already read and lets the server accept or reject
+ * each mutation. Per-folder affordance preflight is deferred to the backend
+ * contract tracked separately from this PR.
*/
async function prepareParentRoleChange(row: GfsFileAccessRow, nextRole: AccessRole) {
const inherited = row.inherited
@@ -568,38 +568,8 @@ export function GfsGrantPanel({ resource }: GfsGrantPanelProps): React.JSX.Eleme
return
}
- const updates: Array<{ source: GfsInheritedAccessSource; permissions: string[] }> = []
- for (const source of affected) {
- let folderAffordances
- try {
- folderAffordances = await getGfsAffordances(source.resourceId, DRIVE)
- } catch (caught) {
- if (!isAlreadyMissing(caught)) {
- setError(caught instanceof Error ? caught.message : 'Could not verify folder access')
- showToast('Could not verify access on the affected folder.', { tone: 'error' })
- }
- return
- }
- const permissions = rolePermissions(nextRole, hostOnlySubject(row.subject)).filter(
- permission => folderAffordances.grantableBits.includes(permission)
- )
- const expressesRole =
- nextRole === 'editor'
- ? permissions.includes('read') && permissions.includes('write')
- : permissions.includes('read')
- if (!folderAffordances.canDelegate || !expressesRole) {
- showToast(
- 'Access on ' +
- source.name +
- ' cannot make ' +
- subjectLabel(row) +
- (nextRole === 'editor' ? ' an Editor.' : ' Read-only.'),
- { tone: 'error' }
- )
- return
- }
- updates.push({ source, permissions })
- }
+ const permissions = rolePermissions(nextRole, hostOnlySubject(row.subject))
+ const updates = affected.map(source => ({ source, permissions }))
setParentUpdate({ row, mode: 'change-role', nextRole, affected: updates })
}
diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsx
index 3f12713c7..b0a06b46d 100644
--- a/control-ui/components/__tests__/GfsBrowser.test.tsx
+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx
@@ -1494,7 +1494,6 @@ describe('GfsBrowser', () => {
gfsUri: 'gfs://main/r3',
name: 'nested',
kind: 'directory',
- version: 7,
}
}
return { items: [], nextCursor: null }
@@ -1527,8 +1526,10 @@ describe('GfsBrowser', () => {
expect(screen.getAllByRole('menuitem').map(item => item.textContent)).toEqual(rowOptions)
expect(rowOptions).toEqual(['Share', 'Open EvenDrive link', 'Rename', 'Move to…', 'Delete'])
- // "Open EvenDrive link" resolves the pasted URI and navigates to it; the
- // menu then follows the newly active folder.
+ // "Open EvenDrive link" resolves the pasted URI and navigates to it. The
+ // current resolve contract does not return a mutation version, so the
+ // active breadcrumb deliberately has no mutating menu until the backend
+ // version contract is delivered.
fireEvent.click(screen.getByRole('menuitem', { name: 'Open EvenDrive link' }))
const dialog = await screen.findByRole('dialog', { name: 'Open EvenDrive link' })
fireEvent.change(within(dialog).getByLabelText('EvenDrive link'), {
@@ -1542,9 +1543,7 @@ describe('GfsBrowser', () => {
await waitFor(() =>
expect(within(breadcrumb).getByRole('button', { name: 'nested' })).toBeTruthy()
)
- await waitFor(() =>
- expect(within(breadcrumb).getByRole('button', { name: 'Actions for nested' })).toBeTruthy()
- )
+ expect(within(breadcrumb).queryByRole('button', { name: 'Actions for nested' })).toBeNull()
expect(within(breadcrumb).queryByRole('button', { name: 'Actions for org' })).toBeNull()
expect(screen.queryByRole('dialog', { name: 'Open EvenDrive link' })).toBeNull()
})
diff --git a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
index 7d0f88932..48ed11164 100644
--- a/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
+++ b/control-ui/components/__tests__/GfsGrantPanel.bulk.test.tsx
@@ -7,7 +7,6 @@ import {
deleteGfsShare,
getAdminTeams,
getAdminUsers,
- getGfsAffordances,
getGfsGrants,
getGfsShares,
getHosts,
@@ -24,7 +23,6 @@ vi.mock('@lib/api', () => ({
getRecipes: vi.fn(),
getGfsGrants: vi.fn(),
getGfsShares: vi.fn(),
- getGfsAffordances: vi.fn(),
deleteGfsGrant: vi.fn(),
deleteGfsShare: vi.fn(),
putGfsGrant: vi.fn(),
diff --git a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
index 72a350441..9214c6d11 100644
--- a/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
+++ b/control-ui/components/__tests__/GfsGrantPanel.inherited.test.tsx
@@ -5,7 +5,6 @@ import {
deleteGfsShare,
getAdminTeams,
getAdminUsers,
- getGfsAffordances,
getGfsGrants,
getGfsResourceByPath,
getGfsShares,
@@ -24,7 +23,6 @@ vi.mock('@lib/api', () => ({
getRecipes: vi.fn(),
getGfsGrants: vi.fn(),
getGfsShares: vi.fn(),
- getGfsAffordances: vi.fn(),
getGfsResourceByPath: vi.fn(),
deleteGfsGrant: vi.fn(),
deleteGfsShare: vi.fn(),
@@ -37,7 +35,6 @@ const mockGetHosts = vi.mocked(getHosts)
const mockGetRecipes = vi.mocked(getRecipes)
const mockGetGfsGrants = vi.mocked(getGfsGrants)
const mockGetGfsShares = vi.mocked(getGfsShares)
-const mockGetGfsAffordances = vi.mocked(getGfsAffordances)
const mockGetGfsResourceByPath = vi.mocked(getGfsResourceByPath)
const mockPutGfsGrant = vi.mocked(putGfsGrant)
const mockDeleteGfsGrant = vi.mocked(deleteGfsGrant)
@@ -131,13 +128,6 @@ describe('GfsGrantPanel inherited access', () => {
})
mockGetHosts.mockResolvedValue({ items: [] })
mockGetRecipes.mockResolvedValue({ items: [] })
- mockGetGfsAffordances.mockResolvedValue({
- resourceId: 'folder',
- held: ['read', 'write', 'delete', 'manage_acl', 'share'],
- canDelegate: true,
- grantableBits: ['read', 'write', 'delete', 'manage_acl', 'share'],
- canCreateShare: true,
- })
mockGetGfsGrants.mockImplementation(async resourceId => {
if (resourceId === FOLDER_ID) {
return {
@@ -271,7 +261,6 @@ describe('GfsGrantPanel inherited access', () => {
const miguelRow = await within(existing).findByTestId(miguelRowTestId)
await chooseRole(miguelRow, 'Read')
- await waitFor(() => expect(mockGetGfsAffordances).toHaveBeenCalledWith(FOLDER_ID, 'main'))
const dialog = await screen.findByRole('alertdialog')
expect(within(dialog).getByText('Update role on parent folder?')).toBeTruthy()
@@ -788,7 +777,6 @@ describe('GfsGrantPanel inherited access', () => {
permissions: VIEWER,
inherit: false,
})
- expect(mockGetGfsAffordances).not.toHaveBeenCalled()
})
it('states the true partial outcome when a folder update fails mid-run', async () => {
diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.ts
index 6c9df281e..8c8cb5ad0 100644
--- a/control-ui/lib/api.ts
+++ b/control-ui/lib/api.ts
@@ -380,14 +380,6 @@ export type GfsShareListItem = {
export type GfsGrantListResponse = { items: GfsGrantListItem[] }
export type GfsShareListResponse = { items: GfsShareListItem[] }
-export type GfsAffordances = {
- resourceId: string
- held: string[]
- canDelegate: boolean
- grantableBits: string[]
- canCreateShare: boolean
-}
-
export type GfsGrantError = Error & {
status?: number
code?: string
@@ -486,19 +478,6 @@ export async function getGfsShares(
)) as GfsShareListResponse
}
-/** Returns the operator-plane affordances used before an inherited role edit. */
-export async function getGfsAffordances(
- resourceId: string,
- drive = 'main',
- signal?: AbortSignal
-): Promise<GfsAffordances> {
- return (await apiGet(
- '/api/v1/gfs/resources/' + encodeURIComponent(resourceId) + '/affordances',
- { drive },
- { signal }
- )) as GfsAffordances
-}
-
export async function deleteGfsShare(id: string): Promise<void> {
await gfsMutate('DELETE', `/api/v1/gfs/shares/${encodeURIComponent(id)}`)
}
@@ -511,7 +490,6 @@ export type GfsResourceByPathView = {
name: string
kind: string
path: string | null
- version: number
updatedAt: string
}