Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): harden breadcrumb drop-move races per QA review
M4975f265dd70
diff --git a/control-ui/components/GfsBrowser.tsx b/control-ui/components/GfsBrowser.tsxindex a0149f27a..54e18e922 100644--- a/control-ui/components/GfsBrowser.tsx+++ b/control-ui/components/GfsBrowser.tsx@@ -40,6 +40,7 @@ import {} from '@components/icons'import { Button, Field, TextInput } from '@components/ui'import {+ AuthExpiredError,apiGet,apiSend,getGfsResourceByPath,@@ -66,7 +67,9 @@ import {import type {GfsDropHoverVerdict,GfsDropRefusalReason,+ GfsEndpointRead,GfsMoveDestination,+ GfsResolvedEndpointView,} from '@lib/gfsDragFeedback.types'import {GfsUploadCapabilityError,@@ -185,14 +188,6 @@ interface GfsResolvedLocation {version: number}-/** The slice of a resolve response the drag admission/commit reads. */-interface GfsResolvedEndpointView {- resourceId: string- kind: string- path: string | null- version?: number-}-/** Project every response-backed folder source through one version-preserving* breadcrumb adapter. An incomplete runtime payload remains browseable but* never gains a fabricated mutation precondition. */@@ -437,6 +432,9 @@ export function GfsBrowser(): React.JSX.Element {destination: GfsMoveDestinationsuggestedName?: stringepoch: number+ /** Physical source parent captured at the drop boundary (R7): drives+ * convergence invalidation when the commit finally runs. */+ oldParentId: string | null} | null>(null)const moveTargetRef = useRef(moveTarget)moveTargetRef.current = moveTarget@@ -453,6 +451,11 @@ export function GfsBrowser(): React.JSX.Element {gfsUri: stringreason: 'move' | 'hierarchy'} | null>(null)+ // Matrix A11: an endpoint read that came back 401 during a drag move.+ // Session loss is TERMINAL for the gesture and must stay visible while the+ // surface is mounted — a transient toast read as a connection hiccup and+ // invited retries that could never succeed.+ const [sessionLost, setSessionLost] = useState(false)// Monotonic epoch for breadcrumb-reconstruction attempts (R7-M1 race). A// reconstruction (a move's rebuild or a Retry) captures the epoch at start// and may apply its result only while it is still the LATEST attempt. Any@@ -1351,6 +1354,16 @@ export function GfsBrowser(): React.JSX.Element {await load(current)}+ /** Refresh whatever folder is LIVE on screen, read at call time. Async+ * drag work must use this: a render-time `current` can name a folder the+ * operator navigated away from while the work was in flight, and loading+ * it would clear-and-discard against the visible listing. */+ async function refreshLiveCurrent(): Promise<void> {+ const liveCrumb = currentCrumbRef.current+ if (!liveCrumb) return+ await load(liveCrumb)+ }+function handleResourceDragStart(event: React.DragEvent<HTMLLIElement>, child: GfsChild): void {// Files AND folders drag (rev-2 D2); an in-flight move freezes sources.if (movingResourceRef.current) {@@ -1525,7 +1538,16 @@ export function GfsBrowser(): React.JSX.Element {const source = draggingResourceRef.currentif (!source) returnconst epoch = dragGestureEpochRef.current- void admitCrumbDropMove(source, crumb, index, epoch)+ // EVERY same-parent/no-op fact is computed synchronously HERE, against+ // the trail as dropped on (R7): a reconstruction landing while admission+ // awaits must never turn a captured ancestor index into the live active+ // index and falsely refuse same-parent. Nothing after an await may read+ // live trail state for these checks.+ const parentId = dragSourceParentIdRef.current+ const sameParentDrop =+ index === crumbsRef.current.length - 1 ||+ (parentId !== null ? crumb.id === parentId : isDriveRootCrumb(crumb) && parentId === null)+ void admitCrumbDropMove(source, crumb, sameParentDrop, epoch)}/** Refuse a drop honestly: matrix wording, reason tone, no mutation. */@@ -1538,11 +1560,29 @@ export function GfsBrowser(): React.JSX.Element {})}- /** One bounded read to (re)hydrate the drive root's resource identity. */- async function hydrateDriveRootIdentity(epoch: number): Promise<string | null> {+ /** Matrix A11: a 401 from the drag pipeline's own reads. The API layer's+ * unauthorized boundary has already run (global auth-error handler); this+ * surfaces the session loss persistently for this surface instead of a+ * connection-flavored warning. */+ function raiseSessionLostNotice(): void {+ setSessionLost(true)+ }++ /** True when a read error is an authentication expiry: either the API+ * layer's AuthExpiredError or a raw 401 status (tests and non-GET paths). */+ function isUnauthorizedRead(error: unknown): boolean {+ return error instanceof AuthExpiredError || entityChangeErrorStatus(error) === 401+ }++ /** One bounded read to (re)hydrate the drive root's resource identity.+ * A 401 stays session-lost (matrix A11): the persistent sign-in alert is+ * raised and the caller must NOT report a connection warning. */+ async function hydrateDriveRootIdentity(+ epoch: number+ ): Promise<{ kind: 'hydrated'; rootId: string } | { kind: 'session-lost' } | { kind: 'failed' }> {try {const page = (await apiGet('/api/v1/gfs/tree', { drive: DRIVE })) as TreePage- if (!page.rootResourceId || !isGestureEpochCurrent(epoch)) return null+ if (!page.rootResourceId || !isGestureEpochCurrent(epoch)) return { kind: 'failed' }const rootRid = ridOfResourceId(page.rootResourceId)setCrumbs(prev => {const root = prev[0]@@ -1550,9 +1590,13 @@ export function GfsBrowser(): React.JSX.Element {if (root.id === page.rootResourceId && root.rid === rootRid) return prevreturn [{ ...root, id: page.rootResourceId, rid: rootRid }, ...prev.slice(1)]})- return page.rootResourceId- } catch {- return null+ return { kind: 'hydrated', rootId: page.rootResourceId }+ } catch (error) {+ if (isUnauthorizedRead(error)) {+ raiseSessionLostNotice()+ return { kind: 'session-lost' }+ }+ return { kind: 'failed' }}}@@ -1601,41 +1645,38 @@ export function GfsBrowser(): React.JSX.Element {async function admitCrumbDropMove(source: GfsChild,crumb: Crumb,- index: number,+ sameParentDrop: boolean,epoch: number): Promise<void> {// 1. Destination identity. The unhydrated root retries resolution here- // (plan §3.1); a failed retry warns honestly and dispatches nothing.+ // (plan §3.1); a failed retry warns honestly and dispatches nothing,+ // and a session-lost retry raises the sign-in alert instead.let destination = crumbToMoveDestination(crumb)if (!destination) {- const rootId = await hydrateDriveRootIdentity(epoch)+ const hydration = await hydrateDriveRootIdentity(epoch)if (!isGestureEpochCurrent(epoch)) return- if (!rootId) {+ if (hydration.kind === 'session-lost') return+ if (hydration.kind === 'failed') {refuseDropMove('unavailable', { targetName: DRIVE })return}destination = {- resourceId: rootId,- rid: ridOfResourceId(rootId),+ resourceId: hydration.rootId,+ rid: ridOfResourceId(hydration.rootId),name: DRIVE,kind: 'directory',- gfsUri: `gfs://${DRIVE}/${ridOfResourceId(rootId)}`,+ gfsUri: `gfs://${DRIVE}/${ridOfResourceId(hydration.rootId)}`,path: '/',origin: 'crumb',}}- // 2. Synchronous identity/no-op checks from the dragstart observation.+ // 2. Identity/no-op checks from the drop-boundary capture — the boolean+ // was computed synchronously at drop, never from live trail state.if (destination.resourceId === source.resourceId) {refuseDropMove('self', { sourceName: source.name, targetName: destination.name })return}- const parentId = dragSourceParentIdRef.current- const isSourceParent =- index === crumbsRef.current.length - 1 ||- (parentId !== null- ? destination.resourceId === parentId- : isDriveRootCrumb(crumb) && parentId === null)- if (isSourceParent) {+ if (sameParentDrop) {refuseDropMove('same-parent', {sourceName: source.name,targetName: destination.name,@@ -1647,6 +1688,7 @@ export function GfsBrowser(): React.JSX.Element {// feedback, a missing path defers to the atomic server guard.const admitted = await admitMoveEndpoints(source, destination, epoch)if (!admitted.ok) {+ if (admitted.sessionLost) returnif (admitted.refusal) {refuseDropMove(admitted.refusal.reason, {sourceName: source.name,@@ -1656,24 +1698,33 @@ export function GfsBrowser(): React.JSX.Element {return}// 4. ONE confirmation for both files and folders (plan §3.2).- openMoveConfirmation(source, destination, epoch)+ openMoveConfirmation(source, destination, epoch, dragSourceParentIdRef.current)}/** Fresh endpoint resolution + structural check shared by row and crumb- * admissions. `refusal` is set for every honest refusal; ok=true means- * the move is structurally admissible (observed or deferred to the server- * guard). */+ * admissions. `refusal` is set for every honest refusal; `sessionLost`+ * outranks it (the persistent sign-in alert was already raised);+ * ok=true means the move is structurally admissible (observed or+ * deferred to the server guard). */async function admitMoveEndpoints(source: GfsChild,destination: GfsMoveDestination,epoch: number- ): Promise<{ ok: boolean; refusal?: { reason: GfsDropRefusalReason } }> {+ ): Promise<{+ ok: boolean+ refusal?: { reason: GfsDropRefusalReason }+ sessionLost?: boolean+ }> {if (!destination.gfsUri) return { ok: false, refusal: { reason: 'unavailable' } }const [sourceRead, targetRead] = await Promise.all([resolveEndpointView(source.gfsUri, source.resourceId),- resolveEndpointView(destination.gfsUri!, destination.resourceId),+ resolveEndpointView(destination.gfsUri, destination.resourceId),])if (!isGestureEpochCurrent(epoch)) return { ok: false }+ if (sourceRead.status === 'unauthorized' || targetRead.status === 'unauthorized') {+ raiseSessionLostNotice()+ return { ok: false, sessionLost: true }+ }if (sourceRead.status === 'missing' || sourceRead.status === 'mismatched') {return { ok: false, refusal: { reason: 'source-location-unknown' } }}@@ -1701,7 +1752,8 @@ export function GfsBrowser(): React.JSX.Element {function openMoveConfirmation(source: GfsChild,destination: GfsMoveDestination,- epoch: number+ epoch: number,+ oldParentId: string | null): void {const occupiedNames = new Set<string>((childCacheRef.current.get(destination.resourceId)?.items ?? []).map(item => item.name)@@ -1715,21 +1767,20 @@ export function GfsBrowser(): React.JSX.Element {destination,...(suggested !== undefined ? { suggestedName: suggested } : {}),epoch,+ oldParentId,})}/** GET /gfs/resolve by immutable URI, classified for admission/commit.* `expectedResourceId` turns an identity drift (the immutable URI now- * resolves to a different resource id) into an explicit mismatch. */+ * resolves to a different resource id) into an explicit mismatch, and a+ * 401 stays session-lost (matrix A11) instead of reading as a connection+ * failure. The API layer's own unauthorized boundary (global auth-error+ * handler + AuthExpiredError) remains untouched. */async function resolveEndpointView(uri: string,expectedResourceId?: string- ): Promise<- | { status: 'resolved'; view: GfsResolvedEndpointView }- | { status: 'missing' }- | { status: 'mismatched' }- | { status: 'failed' }- > {+ ): Promise<GfsEndpointRead> {try {const view = (await apiGet('/api/v1/gfs/resolve', { uri })) as GfsResolvedEndpointViewif (expectedResourceId && view.resourceId !== expectedResourceId) {@@ -1737,6 +1788,7 @@ export function GfsBrowser(): React.JSX.Element {}return { status: 'resolved', view }} catch (error) {+ if (isUnauthorizedRead(error)) return { status: 'unauthorized' }if (entityChangeErrorStatus(error) === 404) return { status: 'missing' }return { status: 'failed' }}@@ -1762,7 +1814,7 @@ export function GfsBrowser(): React.JSX.Element {// Files cannot be ancestors: no structural risk; move directly — the// commit runner still re-resolves both endpoints before dispatch.await moveResource(source, destination, {- revalidate: { epoch },+ revalidate: { epoch, oldParentId: dragSourceParentIdRef.current },})return}@@ -1770,6 +1822,7 @@ export function GfsBrowser(): React.JSX.Element {// structural guard — the impact dialog also records the naming policy.const admitted = await admitMoveEndpoints(source, destination, epoch)if (!admitted.ok) {+ if (admitted.sessionLost) returnif (admitted.refusal) {refuseDropMove(admitted.refusal.reason, {sourceName: source.name,@@ -1778,7 +1831,7 @@ export function GfsBrowser(): React.JSX.Element {}return}- openMoveConfirmation(source, destination, epoch)+ openMoveConfirmation(source, destination, epoch, dragSourceParentIdRef.current)}async function moveResource(@@ -1805,7 +1858,15 @@ export function GfsBrowser(): React.JSX.Element {* dispatching when the gesture epoch was superseded. The keyboard Move* dialog keeps its established single-read behavior.*/- revalidate?: { epoch: number }+ revalidate?: {+ epoch: number+ /**+ * The physical old parent observed at the drag boundary, used for+ * convergence invalidation — never a response-time guess at what+ * folder held the source.+ */+ oldParentId: string | null+ }} = {}): Promise<void> {const { bubbleError = false, allowNumberedRename = true } = options@@ -1821,12 +1882,16 @@ export function GfsBrowser(): React.JSX.Element {setMovingResourceId(source.resourceId)try {let ifMatchVersion = source.version- let verifiedDestinationPath: string | null = destination.path ?? null+ let verifiedDestinationPath: string | null = nullif (options.revalidate) {const epoch = options.revalidate.epochif (!isGestureEpochCurrent(epoch)) returnconst sourceRead = await resolveEndpointView(source.gfsUri, source.resourceId)if (!isGestureEpochCurrent(epoch)) return+ if (sourceRead.status === 'unauthorized') {+ raiseSessionLostNotice()+ return+ }if (sourceRead.status === 'missing' || sourceRead.status === 'mismatched') {throw new GfsMoveRefusalError('source-location-unknown',@@ -1836,46 +1901,70 @@ export function GfsBrowser(): React.JSX.Element {if (sourceRead.status === 'failed') {throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))}- ifMatchVersion = Number.isSafeInteger(sourceRead.view.version)- ? (sourceRead.view.version as number)- : source.version- if (destination.gfsUri) {- const targetRead = await resolveEndpointView(destination.gfsUri, destination.resourceId)- if (!isGestureEpochCurrent(epoch)) return- if (targetRead.status === 'missing' || targetRead.status === 'mismatched') {- throw new GfsMoveRefusalError(- 'target-unavailable',- gfsDropRefusalMessage('target-unavailable')- )- }- if (targetRead.status === 'failed') {- throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))- }- if (targetRead.view.kind !== 'directory') {- throw new GfsMoveRefusalError(- 'target-unavailable',- gfsDropRefusalMessage('target-unavailable')- )- }- verifiedDestinationPath = destination.path === '/' ? '/' : targetRead.view.path- const structure = decideDragPathStructure({- sourcePath: sourceRead.view.path,- targetPath: verifiedDestinationPath,- })- if (structure.kind === 'deny') {- throw new GfsMoveRefusalError(- structure.reason,- gfsDropRefusalMessage(structure.reason, {- sourceName: source.name,- targetName: destination.name,- })- )- }- } else if (verifiedDestinationPath === null) {- // No immutable key and no path observation: the destination cannot- // be validated or verified — refuse honestly instead of guessing.+ // The captured source kind must still be the resource's kind: a+ // flip means the immutable URI no longer names the captured item.+ if (sourceRead.view.kind !== source.kind) {+ throw new GfsMoveRefusalError(+ 'source-location-unknown',+ gfsDropRefusalMessage('source-location-unknown', { sourceName: source.name })+ )+ }+ // Fresh-precondition contract: the dispatched ifMatch must be the+ // version the fresh authorized read just returned. A missing,+ // negative, or non-safe-integer version is NOT downgraded to the+ // stale row version — the move refuses instead.+ const freshVersion = sourceRead.view.version+ if (+ typeof freshVersion !== 'number' ||+ !Number.isSafeInteger(freshVersion) ||+ freshVersion < 0+ ) {+ throw new GfsMoveRefusalError(+ 'source-precondition-unavailable',+ gfsDropRefusalMessage('source-precondition-unavailable')+ )+ }+ ifMatchVersion = freshVersion+ // The destination identity is ALWAYS revalidated through its+ // immutable URI; a cached path observation is never a substitute.+ if (!destination.gfsUri) {+ throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))+ }+ const targetRead = await resolveEndpointView(destination.gfsUri, destination.resourceId)+ if (!isGestureEpochCurrent(epoch)) return+ if (targetRead.status === 'unauthorized') {+ raiseSessionLostNotice()+ return+ }+ if (targetRead.status === 'missing' || targetRead.status === 'mismatched') {+ throw new GfsMoveRefusalError(+ 'target-unavailable',+ gfsDropRefusalMessage('target-unavailable')+ )+ }+ if (targetRead.status === 'failed') {throw new GfsMoveRefusalError('unavailable', gfsDropRefusalMessage('unavailable'))}+ if (targetRead.view.kind !== 'directory') {+ throw new GfsMoveRefusalError(+ 'target-unavailable',+ gfsDropRefusalMessage('target-unavailable')+ )+ }+ verifiedDestinationPath = destination.path === '/' ? '/' : targetRead.view.path+ const structure = decideDragPathStructure({+ sourcePath: sourceRead.view.path,+ targetPath: verifiedDestinationPath,+ })+ if (structure.kind === 'deny') {+ throw new GfsMoveRefusalError(+ structure.reason,+ gfsDropRefusalMessage(structure.reason, {+ sourceName: source.name,+ targetName: destination.name,+ })+ )+ }}// Seed the ladder with the destination's known children (the same cache// the confirmation suggestion came from, plus whatever the caller@@ -1919,9 +2008,14 @@ export function GfsBrowser(): React.JSX.Element {// Transport loss with the request possibly dispatched: the// outcome is UNKNOWN. Never claim the move failed and never// repeat the PATCH — verify once by identity (matrix B7/B8).+ // Anything the single read cannot PROVE stays unknown: the+ // PATCH may still be executing, or another actor may have+ // moved the source, so a differing parent is not a failure+ // verdict.const settled = await settleUnknownTransportMove(source,- verifiedDestinationPath,+ destination,+ moveName,options.revalidate.epoch)if (!isGestureEpochCurrent(options.revalidate.epoch)) return@@ -1930,12 +2024,6 @@ export function GfsBrowser(): React.JSX.Element {moveResult = undefinedbreak}- if (settled === 'not-moved') {- throw new GfsMoveRefusalError(- 'move-not-completed',- gfsDropRefusalMessage('move-not-completed')- )- }throw new GfsMoveRefusalError('unknown-outcome',gfsDropRefusalMessage('unknown-outcome')@@ -1965,14 +2053,18 @@ export function GfsBrowser(): React.JSX.Element {? undefined: movedResource?.version// plan §3.4 convergence: invalidate the observed OLD and NEW parent- // listings through the shared pure planner. The old parent is the- // observed folder whose listing held the source — the trail parent for- // a trail folder, otherwise the folder currently on screen.+ // listings through the shared pure planner. For drag commits the old+ // parent is the PHYSICAL source parent captured at the drag boundary —+ // never a response-time guess, because the operator may have navigated+ // while the commit was in flight. Non-drag callers (the Move dialog)+ // keep the trail-derived observation.const movedCrumbIndex = crumbs.findIndex(crumb => crumb.id === source.resourceId)const oldParentId =- movedCrumbIndex > 0- ? (crumbs[movedCrumbIndex - 1]?.id ?? null)- : (currentCrumbRef.current?.id ?? null)+ options.revalidate?.oldParentId !== undefined+ ? options.revalidate.oldParentId+ : movedCrumbIndex > 0+ ? (crumbs[movedCrumbIndex - 1]?.id ?? null)+ : (currentCrumbRef.current?.id ?? null)const childParentByResourceId = new Map<string, string | null>()for (const [folderId, page] of childCacheRef.current.entries()) {for (const item of page.items) childParentByResourceId.set(item.resourceId, folderId)@@ -2034,9 +2126,12 @@ export function GfsBrowser(): React.JSX.Element {}return}- // Refresh the live current location — the user stays where they are;+ // Refresh the LIVE current location — the user stays where they are;// a drag move never auto-navigates to the destination (plan §3.4).- await refreshCurrent()+ // Reading currentCrumbRef HERE (not a render-time crumb) is what makes+ // the refresh truthful when the operator navigated while the commit+ // was in flight: the folder on screen is the one that reloads.+ await refreshLiveCurrent()} catch (err) {if (bubbleError) throw errif (err instanceof GfsMoveRefusalError) {@@ -2052,27 +2147,47 @@ export function GfsBrowser(): React.JSX.Element {}}- /** Resolve the moved source ONCE by immutable URI after a transport loss- * on the move PATCH (matrix B7/B8): a fresh path whose parent IS the- * destination proves the move landed; an unchanged path proves it did- * not; a failed verification keeps the outcome honestly unknown. */+ /** Resolve the outcome of a transport-lost move PATCH (matrix B7/B8) with+ * ONE bounded read per endpoint and no repeat dispatch.+ *+ * 'moved' requires POSITIVE proof: the source resolves by immutable URI+ * under the destination's CURRENT canonical path — re-resolved by URI so+ * a remotely moved destination still verifies identity-correctly — AND+ * carries the exact name this PATCH requested (or its unrenamed name).+ * Everything else stays 'unknown': the PATCH may still be executing, the+ * source may have been moved by another actor, or the endpoints cannot+ * be established at all. A differing parent NEVER reads as a failure+ * verdict, and a source resolved AT the root path ('/' — the drive root+ * itself) can never prove a move into root landed: a moved item lives at+ * '/<name>'. */async function settleUnknownTransportMove(source: GfsChild,- destinationPath: string | null,+ destination: { resourceId: string; gfsUri?: string | null },+ requestedName: string,epoch: number- ): Promise<'moved' | 'not-moved' | 'unknown'> {- if (destinationPath === null) return 'unknown'- const read = await resolveEndpointView(source.gfsUri, source.resourceId)+ ): Promise<'moved' | 'unknown'> {+ if (!destination.gfsUri) return 'unknown'+ const [sourceRead, targetRead] = await Promise.all([+ resolveEndpointView(source.gfsUri, source.resourceId),+ resolveEndpointView(destination.gfsUri, destination.resourceId),+ ])if (!isGestureEpochCurrent(epoch)) return 'unknown'- if (read.status !== 'resolved' || typeof read.view.path !== 'string') return 'unknown'- const destinationCanonical = normalizeCanonicalPath(destinationPath)- if (destinationCanonical === null) return 'unknown'- const parent = parentPathOf(read.view.path)- // null → the resolved path IS the root itself (parent is root by- // definition); undefined → the path could not be classified.- if (parent === undefined) return 'unknown'- const landedParent = parent ?? '/'- return landedParent === destinationCanonical ? 'moved' : 'not-moved'+ if (sourceRead.status !== 'resolved' || targetRead.status !== 'resolved') return 'unknown'+ if (targetRead.view.kind !== 'directory') return 'unknown'+ if (typeof sourceRead.view.path !== 'string' || typeof targetRead.view.path !== 'string') {+ return 'unknown'+ }+ const sourcePath = normalizeCanonicalPath(sourceRead.view.path)+ const destinationPath = normalizeCanonicalPath(targetRead.view.path)+ if (sourcePath === null || destinationPath === null) return 'unknown'+ // The drive root itself: a completed move into any folder — including+ // the root — lands at '/<name>', never at '/'.+ if (sourcePath === '/') return 'unknown'+ const parent = parentPathOf(sourcePath)+ if (parent !== destinationPath) return 'unknown'+ const leaf = sourcePath.split('/').filter(Boolean).pop()+ if ((leaf ?? '') !== requestedName) return 'unknown'+ return 'moved'}/** Rebuild the breadcrumb trail ANCESTRY for a moved trail-folder. The@@ -2719,7 +2834,12 @@ export function GfsBrowser(): React.JSX.Element {// live region.const draggedSourceNow = draggingResourceId !== null ? draggingResourceRef.current : nulllet dropHoverAnnouncement = ''- if (draggedSourceNow && dragOverCrumbIndex !== null) {+ if (sessionLost) {+ // Matrix A11: the session-lost sentence is spoken once through the same+ // live region that carries hover verdicts, alongside the persistent+ // banner for sighted users.+ dropHoverAnnouncement = gfsDropRefusalMessage('session-lost')+ } else if (draggedSourceNow && dragOverCrumbIndex !== null) {const hoveredCrumb = crumbs[dragOverCrumbIndex]const verdict = crumbHoverVerdict(draggedSourceNow, dragOverCrumbIndex)if (verdict && hoveredCrumb) {@@ -2780,6 +2900,12 @@ export function GfsBrowser(): React.JSX.Element {</div>) : null}+ {sessionLost ? (+ <div className="cu-banner cu-banner--error" role="alert">+ {gfsDropRefusalMessage('session-lost')}+ </div>+ ) : null}+{trailRecovery ? (<div className="cu-banner cu-banner--warning cu-banner--dismissible" role="alert">{trailRecovery.reason === 'move' ? (@@ -2842,7 +2968,9 @@ export function GfsBrowser(): React.JSX.Element {aria-current={index === crumbs.length - 1 ? 'page' : undefined}data-drop-state={crumbVerdict ? crumbVerdict.state : undefined}data-drop-reason={- crumbVerdict && crumbVerdict.state === 'denied'+ crumbVerdict &&+ crumbVerdict.state !== 'allowed' &&+ crumbVerdict.state !== 'checking'? crumbVerdict.reason: undefined}@@ -2961,7 +3089,11 @@ export function GfsBrowser(): React.JSX.Element {data-drop-target={rowVerdict?.state === 'allowed' ? 'true' : undefined}data-drop-state={rowVerdict ? rowVerdict.state : undefined}data-drop-reason={- rowVerdict && rowVerdict.state === 'denied' ? rowVerdict.reason : undefined+ rowVerdict &&+ rowVerdict.state !== 'allowed' &&+ rowVerdict.state !== 'checking'+ ? rowVerdict.reason+ : undefined}role={rowOpenable ? 'button' : undefined}tabIndex={rowOpenable ? 0 : undefined}@@ -3301,7 +3433,7 @@ export function GfsBrowser(): React.JSX.Element {if (pending) {void moveResource(pending.source, pending.destination, {allowNumberedRename,- revalidate: { epoch: pending.epoch },+ revalidate: { epoch: pending.epoch, oldParentId: pending.oldParentId },})}}}diff --git a/control-ui/components/__tests__/GfsBrowser.test.tsx b/control-ui/components/__tests__/GfsBrowser.test.tsxindex e38042069..33721af8f 100644--- a/control-ui/components/__tests__/GfsBrowser.test.tsx+++ b/control-ui/components/__tests__/GfsBrowser.test.tsx@@ -40,6 +40,12 @@ vi.mock('@lib/api', () => ({apiSend: vi.fn(),controlApiUrl: (path: string) => `/control-api${path}`,handleControlUIUnauthorized: vi.fn(),+ AuthExpiredError: class AuthExpiredError extends Error {+ constructor(message = 'Auth expired') {+ super(message)+ this.name = 'AuthExpiredError'+ }+ },GFS_UPLOAD_TIMEOUT_MS: 300000,getAdminTeams: vi.fn(),getAdminUsers: vi.fn(),@@ -4309,17 +4315,30 @@ describe('GfsBrowser — breadcrumb drop moves', () => {let treeReads = 0let sourceResolveReads = 0const parkedSourceReads: Array<(view: EndpointView) => void> = []+ const parkedTreeReads: Array<(page: unknown) => void> = []const hydrateRoot = options?.hydrateRoot !== false// Test-side knobs that do not clobber the base listing mocks.const policy = {/** Tree reads (1-based) at and after this index throw transport errors. */treeErrorFromRead: 0,- /** Per-read (1-based) overrides for the SOURCE resolve: a view, or 'failed'. */- sourceReadResults: new Map<number, EndpointView | 'failed'>(),+ /** One exact tree read (1-based) that answers 401 (session lost). */+ treeUnauthorizedAt: 0,+ /** Tree reads (1-based) at/after this index park until released. */+ parkTreeReadsFrom: 0,+ /** Per-read (1-based) overrides for the SOURCE resolve: a view, 'failed', or 'unauthorized'. */+ sourceReadResults: new Map<number, EndpointView | 'failed' | 'unauthorized'>(),/** Park source reads at/after this index until released. */parkSourceReadFrom: 0,}- const resolveOverride: { uri?: string; result?: 'missing' | 'failed' | EndpointView } = {}+ const resolveOverride: {+ uri?: string+ result?: 'missing' | 'failed' | 'unauthorized' | EndpointView+ } = {}+ const treePageFor = (includeRoot: boolean) => ({+ ...(includeRoot ? { rootResourceId: rootId } : {}),+ items: [product],+ nextCursor: null,+ })mockApiGet.mockImplementation(async (path: string, query?: Record<string, string>) => {if (path === '/api/v1/gfs/resolve' && query?.uri) {if (resolveOverride.uri === query.uri) {@@ -4329,12 +4348,18 @@ describe('GfsBrowser — breadcrumb drop moves', () => {if (resolveOverride.result === 'failed') {throw new TypeError('fetch failed')}+ if (resolveOverride.result === 'unauthorized') {+ throw Object.assign(new Error('401 Unauthorized'), { status: 401 })+ }if (resolveOverride.result) return resolveOverride.result}if (query.uri === 'gfs://main/r2') {sourceResolveReads += 1const readResult = policy.sourceReadResults.get(sourceResolveReads)if (readResult === 'failed') throw new TypeError('fetch failed')+ if (readResult === 'unauthorized') {+ throw Object.assign(new Error('401 Unauthorized'), { status: 401 })+ }if (readResult) return readResultif (policy.parkSourceReadFrom > 0 && sourceResolveReads >= policy.parkSourceReadFrom) {return new Promise<EndpointView>(resolve => {@@ -4349,17 +4374,20 @@ describe('GfsBrowser — breadcrumb drop moves', () => {}if (path === '/api/v1/gfs/tree') {treeReads += 1+ if (policy.treeUnauthorizedAt === treeReads) {+ throw Object.assign(new Error('401 Unauthorized'), { status: 401 })+ }if (policy.treeErrorFromRead > 0 && treeReads >= policy.treeErrorFromRead) {throw new TypeError('fetch failed')}+ if (policy.parkTreeReadsFrom > 0 && treeReads >= policy.parkTreeReadsFrom) {+ return new Promise(resolve => {+ parkedTreeReads.push(resolve)+ })+ }// First load leaves the root synthetic when hydration is disabled;// the drop-time retry then hydrates on the next tree read.- const includeRoot = hydrateRoot || treeReads > 1- return {- ...(includeRoot ? { rootResourceId: rootId } : {}),- items: [product],- nextCursor: null,- }+ return treePageFor(hydrateRoot || treeReads > 1)}if (path === '/api/v1/gfs/by-path' && query?.path === '/live tests') {return { ...views['r3']!, path: '/live tests' }@@ -4390,6 +4418,9 @@ describe('GfsBrowser — breadcrumb drop moves', () => {releaseParkedSourceReads(view: EndpointView) {for (const release of parkedSourceReads.splice(0)) release(view)},+ releaseParkedTreeReads() {+ for (const release of parkedTreeReads.splice(0)) release(treePageFor(true))+ },}}@@ -4544,8 +4575,10 @@ describe('GfsBrowser — breadcrumb drop moves', () => {const rootCrumb = crumbButton('main')const transfer = dragRowOverCrumb(abacRow, rootCrumb)- // Identity not available yet: warning paint, never a fake denial.+ // Identity not available yet: warning paint, never a fake denial, with+ // the reason carried on the dedicated attribute.expect(rootCrumb).toHaveAttribute('data-drop-state', 'unavailable')+ expect(rootCrumb).toHaveAttribute('data-drop-reason', 'target-unavailable')expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent('EvenDrive could not confirm whether you can move into main.')@@ -4600,6 +4633,7 @@ describe('GfsBrowser — breadcrumb drop moves', () => {const transfer = dragRowOverCrumb(abacRow, activeCrumb)expect(activeCrumb).toHaveAttribute('data-drop-state', 'same-parent')+ expect(activeCrumb).toHaveAttribute('data-drop-reason', 'same-parent')expect(screen.getByTestId('gfs-drop-announce')).toHaveTextContent('abac.md is already in live tests.')@@ -4904,8 +4938,16 @@ describe('GfsBrowser — breadcrumb drop moves', () => {expect(mockApiSend).toHaveBeenCalledTimes(1)})- it('reports a transport-lost PATCH as not-completed when verification proves no move', async () => {- breadcrumbTrailFixture()+ it('keeps a transport-lost PATCH unknown when the source lands under a third folder', async () => {+ // A differing parent does NOT prove the PATCH failed: it may still be+ // executing, or another actor may have moved the source. The single+ // verification read must report unknown — with refresh guidance, never a+ // failure verdict and never a repeat PATCH.+ const fixture = breadcrumbTrailFixture()+ fixture.policy.sourceReadResults.set(3, {+ ...fixture.views['r2']!,+ path: '/Elsewhere/abac.md',+ })mockApiSend.mockImplementation(async () => {throw new TypeError('fetch failed')})@@ -4920,10 +4962,68 @@ describe('GfsBrowser — breadcrumb drop moves', () => {fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))expect(- await screen.findByText(- 'EvenDrive couldn’t complete this move. Check your connection and try again.'- )+ await screen.findByText(/Couldn.t confirm the move\. Refresh before trying again\./)+ ).toBeTruthy()+ expect(screen.getByText(/confirm the move/).closest('.cu-toast')).toHaveClass(+ 'cu-toast--warning'+ )+ expect(mockApiSend).toHaveBeenCalledTimes(1)+ })++ it('keeps a transport-lost PATCH unknown when the destination cannot be established', async () => {+ const fixture = breadcrumbTrailFixture()+ // The PATCH "transport-fails" while the source read would prove the+ // move — but the destination itself is no longer resolvable, so the+ // positive proof is incomplete and the outcome stays unknown.+ mockApiSend.mockImplementation(async () => {+ fixture.resolveOverride.uri = 'gfs://main/r1'+ fixture.resolveOverride.result = 'missing'+ throw new TypeError('fetch failed')+ })+ fixture.policy.sourceReadResults.set(3, {+ ...fixture.views['r2']!,+ path: '/Product/abac.md',+ })+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ expect(+ await screen.findByText(/Couldn.t confirm the move\. Refresh before trying again\./)+ ).toBeTruthy()+ expect(screen.queryByText(/Moved "abac\.md"/)).toBeNull()+ expect(mockApiSend).toHaveBeenCalledTimes(1)+ })++ it('never reads a source resolved at the drive root as a completed move to root', async () => {+ const fixture = breadcrumbTrailFixture()+ // The verification read resolves the source AT '/' (the drive root+ // itself). A completed move lands at '/<name>', so '/' can never prove+ // this move — the outcome stays unknown.+ fixture.policy.sourceReadResults.set(3, { ...fixture.views['r2']!, path: '/' })+ mockApiSend.mockImplementation(async () => {+ throw new TypeError('fetch failed')+ })+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ expect(+ await screen.findByText(/Couldn.t confirm the move\. Refresh before trying again\./)).toBeTruthy()+ expect(screen.queryByText(/Moved "abac\.md"/)).toBeNull()expect(mockApiSend).toHaveBeenCalledTimes(1)})@@ -4976,4 +5076,259 @@ describe('GfsBrowser — breadcrumb drop moves', () => {expect(mockApiSend).not.toHaveBeenCalled()expect(within(list).getByText('specs')).toBeTruthy()})++ it('refuses without a PATCH when the fresh source version is missing', async () => {+ const fixture = breadcrumbTrailFixture()+ // Commit-time source read succeeds but carries NO version: the fresh+ // precondition contract forbids downgrading to the stale row version.+ fixture.policy.sourceReadResults.set(2, {+ resourceId: 'id-2',+ kind: 'file',+ path: '/Product/live tests/abac.md',+ })+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ expect(+ await screen.findByText(+ /EvenDrive couldn.t confirm this item.s current version\. Refresh the folder and try again\./+ )+ ).toBeTruthy()+ expect(mockApiSend).not.toHaveBeenCalled()+ expect(screen.queryByText(/Moved "abac\.md"/)).toBeNull()+ })++ it('refuses without a PATCH when the fresh source version is negative', async () => {+ const fixture = breadcrumbTrailFixture()+ fixture.policy.sourceReadResults.set(2, { ...fixture.views['r2']!, version: -1 })+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ expect(await screen.findByText(/couldn.t confirm this item.s current version/)).toBeTruthy()+ expect(mockApiSend).not.toHaveBeenCalled()+ })++ it('refuses without a PATCH when the fresh source kind no longer matches the captured one', async () => {+ const fixture = breadcrumbTrailFixture()+ // The immutable URI now resolves to a directory while the captured+ // source is a file: the read no longer names the captured item.+ fixture.policy.sourceReadResults.set(2, {+ ...fixture.views['r2']!,+ kind: 'directory',+ })+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ expect(+ await screen.findByText(+ 'EvenDrive cannot verify this item’s current location. Refresh and try again.'+ )+ ).toBeTruthy()+ expect(mockApiSend).not.toHaveBeenCalled()+ })++ it('keeps same-parent facts captured at drop when a reconstruction lands during root hydration (R7)', async () => {+ const streamControllers: ReadableStreamDefaultController<Uint8Array>[] = []+ const fixture = breadcrumbTrailFixture({ hydrateRoot: false })+ // Park the drop-time root hydration read so the trail can change while+ // the admission awaits.+ fixture.policy.parkTreeReadsFrom = 2+ vi.stubGlobal(+ 'fetch',+ vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) => {+ const body = new ReadableStream<Uint8Array>({+ start(controller) {+ streamControllers.push(controller)+ init?.signal?.addEventListener('abort', () => controller.close(), { once: true })+ },+ })+ return new Response(body, {+ status: 200,+ headers: { 'content-type': 'application/x-ndjson' },+ })+ })+ )+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ // Drop onto the (synthetic, unhydrated) root crumb at index 0 of a+ // three-crumb trail: a real upward move, NOT the active crumb.+ const transfer = dragRowOverCrumb(abacRow, crumbButton('main'))+ fireEvent.drop(crumbButton('main'), { dataTransfer: transfer })+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })++ // While hydration is pending, a remote change removes the current+ // folder's ancestry: the hierarchy refresh collapses the trail to the+ // root alone. Comparing the CAPTURED index (0) against the LIVE active+ // index would now falsely read as same-parent.+ fixture.resolveOverride.uri = 'gfs://main/r3'+ fixture.resolveOverride.result = 'missing'+ const frame = await controlApiProducerFrame()+ await act(async () => {+ streamControllers[0]!.enqueue(new TextEncoder().encode(`${frame}\n`))+ })+ await waitFor(() =>+ expect(within(breadcrumbNav()).queryByRole('button', { name: 'live tests' })).toBeNull()+ )++ fixture.releaseParkedTreeReads()++ // The admission continues from the drop-boundary facts: no false+ // "already in" refusal — the confirmation for the root move appears.+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to main',+ })+ expect(screen.queryByText(/is already in/)).toBeNull()+ void dialog+ })++ it('refreshes the live folder and captured old parent when the operator navigates mid-commit', async () => {+ const fixture = breadcrumbTrailFixture()+ // Park the commit-time SOURCE read so the operator can navigate while+ // the commit is in flight.+ fixture.policy.parkSourceReadFrom = 2+ const { unmount } = renderBrowser()+ void unmount+ await waitFor(() => expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull())+ fireEvent.click((await screen.findAllByRole('button', { name: 'Product' }))[0]!)+ let list = screen.getByRole('list', { name: 'Current folder resources' })+ fireEvent.click(await within(list).findByRole('button', { name: 'live tests', exact: true }))+ await waitFor(() => expect(crumbButton('live tests')).toHaveAttribute('aria-current', 'page'))+ list = screen.getByRole('list', { name: 'Current folder resources' })+ await within(list).findByText('abac.md')+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ const childrenOfOldParentBefore = mockApiGet.mock.calls.filter(+ ([path]) => path === '/api/v1/gfs/resources/id-3/children'+ ).length+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))+ // The commit is parked on its source read; navigate to the drive root.+ fireEvent.click(crumbButton('main'))+ await waitFor(() => expect(crumbButton('main')).toHaveAttribute('aria-current', 'page'))++ fixture.releaseParkedSourceReads(fixture.views['r2']!)++ // The commit completes against the captured destination and the LIVE+ // location refreshes: the operator stays at the root with its rows on+ // screen — never navigated away, never stuck loading.+ await waitFor(() =>+ expect(mockApiSend).toHaveBeenCalledWith(+ 'PATCH',+ '/api/v1/gfs/resources/id-2',+ { drive: 'main', newParentId: 'id-1', ifMatch: 5 },+ { drive: 'main' }+ )+ )+ expect(await screen.findByText('Moved "abac.md" to "Product".')).toBeTruthy()+ await waitFor(() => {+ expect(screen.queryByRole('status', { name: 'Loading files' })).toBeNull()+ expect(+ within(screen.getByRole('list', { name: 'Current folder resources' })).getByText('Product')+ ).toBeTruthy()+ })+ expect(crumbButton('main')).toHaveAttribute('aria-current', 'page')+ // The OLD source parent's listing was invalidated through the captured+ // drop-boundary parent: re-entering it must re-fetch, not serve cache.+ const childrenOfOldParentAfter = mockApiGet.mock.calls.filter(+ ([path]) => path === '/api/v1/gfs/resources/id-3/children'+ ).length+ expect(childrenOfOldParentAfter).toBeGreaterThanOrEqual(childrenOfOldParentBefore)+ await act(async () => {+ fireEvent.click(+ within(screen.getByRole('list', { name: 'Current folder resources' })).getByRole('button', {+ name: 'Product',+ exact: true,+ })+ )+ })+ await waitFor(() =>+ expect(+ mockApiGet.mock.calls.filter(([path]) => path === '/api/v1/gfs/resources/id-3/children')+ .length+ ).toBeGreaterThan(childrenOfOldParentAfter)+ )+ })++ it('raises the persistent sign-in alert when an admission read comes back 401 (A11)', async () => {+ const fixture = breadcrumbTrailFixture()+ fixture.resolveOverride.uri = 'gfs://main/r1'+ fixture.resolveOverride.result = 'unauthorized'+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })++ const alert = await screen.findByRole('alert')+ expect(alert).toHaveTextContent('Your session ended. Sign in again to continue moving files.')+ // Session loss is NOT a connection hiccup: no generic warning toast and+ // no move admission.+ expect(screen.queryByText(/couldn.t verify this move/)).toBeNull()+ expect(mockApiSend).not.toHaveBeenCalled()+ expect(screen.queryByRole('dialog')).toBeNull()+ })++ it('raises the persistent sign-in alert when a commit read comes back 401 (A11)', async () => {+ const fixture = breadcrumbTrailFixture()+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('Product'))+ fireEvent.drop(crumbButton('Product'), { dataTransfer: transfer })+ const dialog = await screen.findByRole('dialog', {+ name: 'Move file abac.md to Product',+ })+ fixture.resolveOverride.uri = 'gfs://main/r2'+ fixture.resolveOverride.result = 'unauthorized'+ fireEvent.click(within(dialog).getByRole('button', { name: 'Move', exact: true }))++ const alert = await screen.findByRole('alert')+ expect(alert).toHaveTextContent('Your session ended. Sign in again to continue moving files.')+ expect(screen.queryByText(/couldn.t verify this move/)).toBeNull()+ expect(mockApiSend).not.toHaveBeenCalled()+ })++ it('raises the persistent sign-in alert when root hydration comes back 401 (A11)', async () => {+ const fixture = breadcrumbTrailFixture({ hydrateRoot: false })+ fixture.policy.treeUnauthorizedAt = 2+ const list = await browseToLiveTests()+ const abacRow = rowOf(list, 'abac.md')++ const transfer = dragRowOverCrumb(abacRow, crumbButton('main'))+ fireEvent.drop(crumbButton('main'), { dataTransfer: transfer })+ fireEvent.dragEnd(abacRow, { dataTransfer: transfer })++ const alert = await screen.findByRole('alert')+ expect(alert).toHaveTextContent('Your session ended. Sign in again to continue moving files.')+ expect(screen.queryByText(/couldn.t verify this move/)).toBeNull()+ expect(mockApiSend).not.toHaveBeenCalled()+ expect(screen.queryByRole('dialog')).toBeNull()+ })})diff --git a/control-ui/lib/__tests__/gfsDragFeedback.test.ts b/control-ui/lib/__tests__/gfsDragFeedback.test.tsindex 1545748c8..60d8d413f 100644--- a/control-ui/lib/__tests__/gfsDragFeedback.test.ts+++ b/control-ui/lib/__tests__/gfsDragFeedback.test.ts@@ -28,6 +28,7 @@ describe('gfsDropRefusalTone', () => {'source-delete','target-unavailable','source-location-unknown',+ 'session-lost',] as const) {expect(gfsDropRefusalTone(reason)).toBe('error')}@@ -38,7 +39,11 @@ describe('gfsDropRefusalTone', () => {})it('maps unknown/unverifiable outcomes to warning (matrix A10/B7)', () => {- for (const reason of ['unavailable', 'unknown-outcome', 'move-not-completed'] as const) {+ for (const reason of [+ 'unavailable',+ 'unknown-outcome',+ 'source-precondition-unavailable',+ ] as const) {expect(gfsDropRefusalTone(reason)).toBe('warning')}})@@ -73,13 +78,19 @@ describe('gfsDropRefusalMessage', () => {)})- it('distinguishes the three vanish/verify outcomes honestly (A10/B4/B5/B7)', () => {+ it('distinguishes the three vanish/verify outcomes honestly (A10/A11/B4/B5/B7)', () => {expect(gfsDropRefusalMessage('target-unavailable', names)).toBe('This folder is no longer available.')expect(gfsDropRefusalMessage('source-location-unknown', names)).toBe('EvenDrive cannot verify this item’s current location. Refresh and try again.')+ expect(gfsDropRefusalMessage('source-precondition-unavailable', names)).toBe(+ 'EvenDrive couldn’t confirm this item’s current version. Refresh the folder and try again.'+ )+ expect(gfsDropRefusalMessage('session-lost', names)).toBe(+ 'Your session ended. Sign in again to continue moving files.'+ )expect(gfsDropRefusalMessage('unavailable', names)).toBe('EvenDrive couldn’t verify this move. Check your connection and try again.')@@ -109,7 +120,7 @@ describe('gfsDropHoverAnnouncement', () => {it('speaks the same reason sentence a refused drop would toast', () => {const denied: GfsDropHoverVerdict = { state: 'denied', reason: 'descendant' }expect(gfsDropHoverAnnouncement(denied, names)).toBe(gfsDropRefusalMessage('descendant', names))- expect(gfsDropHoverAnnouncement({ state: 'same-parent' }, names)).toBe(+ expect(gfsDropHoverAnnouncement({ state: 'same-parent', reason: 'same-parent' }, names)).toBe(gfsDropRefusalMessage('same-parent', names))})@@ -154,6 +165,7 @@ describe('computeGfsDropHoverVerdict', () => {it('marks an unhydrated root target unavailable without denying (plan §3.1)', () => {expect(computeGfsDropHoverVerdict(crumbFacts({ targetResourceId: null }))).toEqual({state: 'unavailable',+ reason: 'target-unavailable',})})@@ -168,12 +180,13 @@ describe('computeGfsDropHoverVerdict', () => {it('reports the active crumb and the observed own parent as same-parent info (A4)', () => {expect(computeGfsDropHoverVerdict(crumbFacts({ targetIsActiveLocation: true }))).toEqual({state: 'same-parent',+ reason: 'same-parent',})expect(computeGfsDropHoverVerdict(crumbFacts({ targetResourceId: 'live-tests-id', targetName: 'live tests' }))- ).toEqual({ state: 'same-parent' })+ ).toEqual({ state: 'same-parent', reason: 'same-parent' })})it('allows an observed ancestor crumb through the common-anchor proof', () => {diff --git a/control-ui/lib/gfsDragFeedback.ts b/control-ui/lib/gfsDragFeedback.tsindex 3f7337ca8..3f791a75d 100644--- a/control-ui/lib/gfsDragFeedback.ts+++ b/control-ui/lib/gfsDragFeedback.ts@@ -23,15 +23,15 @@ export function gfsDropRefusalTone(reason: GfsDropRefusalReason): GfsFeedbackToncase 'same-parent':return 'info'case 'unavailable':+ case 'source-precondition-unavailable':case 'unknown-outcome':- case 'move-not-completed':return 'warning'default:return 'error'}}-/** The persistent (toast) message for a refused or uncertain move. */+/** The persistent (toast/banner) message for a refused or uncertain move. */export function gfsDropRefusalMessage(reason: GfsDropRefusalReason,names: { sourceName?: string; targetName?: string } = {}@@ -59,10 +59,12 @@ export function gfsDropRefusalMessage(return 'This folder is no longer available.'case 'source-location-unknown':return 'EvenDrive cannot verify this item’s current location. Refresh and try again.'+ case 'source-precondition-unavailable':+ return 'EvenDrive couldn’t confirm this item’s current version. Refresh the folder and try again.'+ case 'session-lost':+ return 'Your session ended. Sign in again to continue moving files.'case 'unavailable':return 'EvenDrive couldn’t verify this move. Check your connection and try again.'- case 'move-not-completed':- return 'EvenDrive couldn’t complete this move. Check your connection and try again.'case 'unknown-outcome':return 'Couldn’t confirm the move. Refresh before trying again.'default:@@ -104,14 +106,14 @@ export function gfsDropHoverAnnouncement(* atomic server guard to adjudicate.*/export function computeGfsDropHoverVerdict(facts: GfsDropHoverFacts): GfsDropHoverVerdict {- if (!facts.targetResourceId) return { state: 'unavailable' }+ if (!facts.targetResourceId) return { state: 'unavailable', reason: 'target-unavailable' }if (facts.targetResourceId === facts.sourceResourceId) return { state: 'denied', reason: 'self' }if (facts.targetIsActiveLocation ||(facts.sourceParentKnown && facts.sourceParentResourceId === facts.targetResourceId) ||facts.targetIsSourceParent) {- return { state: 'same-parent' }+ return { state: 'same-parent', reason: 'same-parent' }}const structure = decideDragStructure({source: {@@ -126,7 +128,7 @@ export function computeGfsDropHoverVerdict(facts: GfsDropHoverFacts): GfsDropHovknownSourceAncestorIds: facts.knownSourceAncestorIds,})if (structure.kind === 'deny') {- if (structure.reason === 'same-parent') return { state: 'same-parent' }+ if (structure.reason === 'same-parent') return { state: 'same-parent', reason: 'same-parent' }return { state: 'denied', reason: structure.reason }}if (structure.kind === 'server-check-required') return { state: 'checking' }diff --git a/control-ui/lib/gfsDragFeedback.types.ts b/control-ui/lib/gfsDragFeedback.types.tsindex 3e23baaa9..01fe3869d 100644--- a/control-ui/lib/gfsDragFeedback.types.ts+++ b/control-ui/lib/gfsDragFeedback.types.ts@@ -14,8 +14,8 @@ export type GfsFeedbackTone = 'info' | 'error' | 'warning'* Structure denies (A1–A5) and the operator-plane authority denies (A6–A8,* copy-mapped here but never fabricated from local permission bits — the* operator plane holds intrinsic authority) come from the shared policy.- * Resolution/outcome reasons (A10, B4, B5, B7) come from endpoint reads and- * transport results around the move PATCH.+ * Resolution/outcome reasons (A10, A11, B4, B5, B7) come from endpoint reads+ * and transport results around the move PATCH.*/export type GfsDropRefusalReason =| GfsStructureRefusalReason@@ -25,8 +25,9 @@ export type GfsDropRefusalReason =| 'unavailable'| 'target-unavailable'| 'source-location-unknown'+ | 'source-precondition-unavailable'+ | 'session-lost'| 'unknown-outcome'- | 'move-not-completed'export type GfsStructureRefusalReason =| 'self'@@ -46,8 +47,8 @@ export type GfsDropHoverVerdict =| { state: 'allowed'; evidence: GfsDragStructureEvidence }| { state: 'checking' }| { state: 'denied'; reason: Exclude<GfsStructureRefusalReason, 'same-parent'> }- | { state: 'unavailable' }- | { state: 'same-parent' }+ | { state: 'unavailable'; reason: 'target-unavailable' }+ | { state: 'same-parent'; reason: 'same-parent' }/** Observed facts one hover verdict is computed from (zero network). */export interface GfsDropHoverFacts {@@ -84,3 +85,27 @@ export interface GfsMoveDestination {version?: numberorigin: 'row' | 'crumb'}++/**+ * The slice of a /gfs/resolve response the drag admission/commit reads.+ * Shared by every endpoint re-resolution path in the drag pipeline.+ */+export interface GfsResolvedEndpointView {+ resourceId: string+ kind: string+ path: string | null+ version?: number+}++/**+ * A classified endpoint read. `unauthorized` preserves the session-lost+ * distinction (matrix A11) so it never reads as a generic connection+ * failure; `mismatched` marks an immutable URI that now resolves to a+ * different resource identity.+ */+export type GfsEndpointRead =+ | { status: 'resolved'; view: GfsResolvedEndpointView }+ | { status: 'missing' }+ | { status: 'mismatched' }+ | { status: 'unauthorized' }+ | { status: 'failed' }diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex 99dd39c39..3ea631711 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.746",+ "version": "0.1.747","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.746",+ "version": "0.1.747","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 b868a6196..f2e710a39 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.746",+ "version": "0.1.747","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/docs/design/gfs-breadcrumb-drop-move.md b/docs/design/gfs-breadcrumb-drop-move.mdindex ffd441afd..fa4551b56 100644--- a/docs/design/gfs-breadcrumb-drop-move.md+++ b/docs/design/gfs-breadcrumb-drop-move.md@@ -218,3 +218,41 @@ decision the plan left open.`REQUIRED_JOURNEY_INVENTORY` and fails the selection phase when thebreadcrumb lanes (file move, root move, active same-parent, ancestor foldermove) are absent, with unit tests in `test/__tests__/gfsDragAndDropGate.test.ts`.++### QA corrections (2026-10-23, supervisor review round 1)++- **Drop-boundary capture (R7).** Same-parent/no-op facts and the destination+ identity are computed synchronously in `handleCrumbDrop`; nothing after an+ await reads live trail state for those checks. A trail reconstruction that+ lands while root hydration is pending can no longer turn a captured+ ancestor index into the live active index (regression covered).+- **Fresh precondition.** The commit re-resolve refuses without a PATCH when+ the fresh source version is missing, negative, or not a safe integer —+ never downgraded to the stale row version — and when the fresh source kind+ no longer matches the captured kind. The destination identity is ALWAYS+ revalidated through its immutable URI; a cached path observation is never a+ substitute.+- **Live-location convergence.** The commit refresh loads the LIVE+ `currentCrumbRef` location (a render-time crumb could name a folder the+ operator navigated away from mid-commit), and convergence invalidation uses+ the physical old parent captured at the drag boundary (regression:+ navigation mid-commit refreshes the live folder, invalidates the captured+ old parent and the destination, never navigates away).+- **Unknown transport outcomes.** The single post-transport verification+ proves `moved` only positively: source resolves under the destination's+ CURRENT path (re-resolved by URI) with the exact requested name. A+ differing parent, a source resolved at `/`, an unreachable destination, or+ a failed read all stay UNKNOWN with refresh guidance ("Couldn't confirm the+ move. Refresh before trying again.") and no repeat PATCH — the former+ `move-not-completed` verdict was removed because one GET cannot prove the+ PATCH did not land.+- **Session loss (A11).** A 401 from any drag-pipeline read — admission,+ commit, or root hydration — classifies as session-lost and raises a+ persistent sign-in alert (plus the announcement wording) instead of a+ connection-flavored warning. The API layer's own unauthorized boundary+ (`AuthExpiredError` + global auth-error handler) is unchanged.+- **Reason attribute contract.** `data-drop-reason` now carries its reason+ for every defined state: `denied`, `unavailable` (`target-unavailable`),+ and `same-parent`; only `allowed`/`checking` stay reason-free. The shared+ endpoint view/read types moved to `lib/gfsDragFeedback.types.ts` per the+ frontend style rules.