Skip to content

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

TypeScript

fix(desktop): rp-008 rp-021 fix the ACL class and the hidden depth cap

M64db40f8cfab
diff --git a/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts
index e0a6e3882..1f923e1d6 100644
--- a/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts
+++ b/desktop-app/ui/src/gfs/__tests__/inheritedAccess.test.ts
@@ -461,6 +461,69 @@ describe('deriveGfsInheritedAccess', () => {
expect(result.items).toEqual([])
})
+ // RP-021 — the depth cap must not hide behind an earlier denial. The
+ // shared precedence ranks "denied" first, so a walk that was denied AND
+ // truncated reported the denial and never said that the rows above the cap
+ // were never seen.
+ it('reports the depth cap even when an earlier ancestor was ACL-denied', async () => {
+ const targetDepthParent = 'depth0'
+ const grantsDenied = await listGrantsFailureMessage()
+ installClerumGfs(
+ async uri => {
+ const rid = uri.split('/').at(-1) ?? ''
+ if (rid === FILE_ID.replace(/-/g, '')) {
+ return resolveView(FILE_ID, 'report.md', targetDepthParent, 'file')
+ }
+ const match = /^depth(\d+)$/.exec(rid)
+ if (match) return resolveView(rid, `folder-${match[1]}`, `depth${Number(match[1]) + 1}`)
+ return null
+ },
+ async resourceId => {
+ // The nearest ancestor's grant listing is denied: a quiet ACL
+ // boundary. The walk continues upward and hits the depth cap.
+ if (resourceId === 'depth0') throw new Error(grantsDenied)
+ return []
+ },
+ async () => []
+ )
+
+ const result = await deriveGfsInheritedAccess(FILE_ID)
+
+ // The cap is the honest terminal state: rows above it were never seen.
+ expect(result.coverage).toBe('unavailable')
+ })
+
+ // RP-008 — the status that decided the response is the VETTED one the
+ // main process appended. A copy carried by the server's own body sits
+ // ahead of it, and the shared reader takes the FIRST `httpStatus=` token
+ // it finds — so a 500 whose body mentioned another status was classified
+ // by that other status.
+ it('classifies a read failure by the vetted status, not by one in the body', async () => {
+ const bodyMentionsForbidden =
+ '500 Internal Server Error: {"detail":"httpStatus=403"} httpStatus=500'
+ installClerumGfs(
+ async uri => {
+ if (uri.endsWith(FILE_ID.replace(/-/g, ''))) {
+ return resolveView(FILE_ID, 'report.md', ROOT_ID, 'file')
+ }
+ if (uri.endsWith(ROOT_ID.replace(/-/g, ''))) {
+ return resolveView(ROOT_ID, '', null)
+ }
+ return null
+ },
+ async () => {
+ throw new Error(bodyMentionsForbidden)
+ },
+ async () => []
+ )
+
+ const result = await deriveGfsInheritedAccess(FILE_ID)
+
+ // The vetted 500 is retryable; the body's 403 would have been a quiet
+ // ACL boundary.
+ expect(result.coverage).toBe('unavailable')
+ })
+
it('maps an unreadable target to read-boundary with no rows', async () => {
const targetDenied = await resolveDeniedMessage(`gfs://main/${FILE_ID.replace(/-/g, '')}`)
installClerumGfs(
diff --git a/desktop-app/ui/src/gfs/inheritedAccess.ts b/desktop-app/ui/src/gfs/inheritedAccess.ts
index 7622189ce..5d15a2629 100644
--- a/desktop-app/ui/src/gfs/inheritedAccess.ts
+++ b/desktop-app/ui/src/gfs/inheritedAccess.ts
@@ -1,7 +1,7 @@
import { classifyGfsAclReadFailure, worstGfsCoverageClass } from '@clerum/gfs-interaction-policy'
import type { GfsCoverageClass } from '@clerum/gfs-interaction-policy'
import { GFS_BREADCRUMB_MAX_DEPTH } from '@constants/gfsBrowser'
-import { isGfsSessionAuthorityFailure } from '@lib/gfsGrantErrors'
+import { isGfsSessionAuthorityFailure, parseHttpStatus } from '@lib/gfsGrantErrors'
import type { GfsInheritedAccessItem, GfsInheritedAccessResult } from './delegation.types'
import { inheritedSubjectKey, mergeInheritedAccessItem } from './inheritedAccessMerge'
@@ -69,10 +69,21 @@ export async function deriveGfsInheritedAccess(
'operation'
)
- /** Classify a resolve failure; session authority rethrows the original error. */
+ /**
+ * Classify a resolve failure; session authority rethrows the original error.
+ *
+ * The status that decided the response is the VETTED one the main process
+ * appended to the message. The shared classifier reads the first
+ * `httpStatus=` token it finds, and a copy carried by the server's own body
+ * sits AHEAD of the vetted suffix — so a 500 whose body mentions another
+ * status was classified by that other status (RP-008). The vetted status is
+ * therefore passed explicitly, and the shared reader's structured field
+ * takes precedence over its own message scan.
+ */
const resolveFailureClass = (error: unknown): GfsCoverageClass => {
if (isAuthorityFailure(error)) throw error
- return classifyGfsAclReadFailure(error)
+ const vetted = parseHttpStatus(error instanceof Error ? error.message : String(error ?? ''))
+ return classifyGfsAclReadFailure(vetted === null ? error : { status: vetted })
}
/** Classify an ACL-list failure (same authority rule as resolve). */
@@ -179,8 +190,14 @@ export async function deriveGfsInheritedAccess(
}
const worst = worstGfsCoverageClass(classes)
+ // The depth cap means the walk never reached the root: the observation is
+ // incomplete in a way the quiet boundary states do not express. It must not
+ // hide behind an earlier denial — the shared precedence ranks "denied"
+ // first, so a walk that was denied AND truncated reported the denial and
+ // never said that rows above the cap were never seen (RP-021).
+ const hitDepthCap = classes.includes('depth-cap')
const coverage =
- worst !== 'complete' && worst !== 'denied'
+ hitDepthCap || (worst !== 'complete' && worst !== 'denied')
? 'unavailable'
: readBoundary
? 'read-boundary'