Skip to content

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

TypeScript

fix(mcp-host): resolve round-5 review findings in the GFS store

Alfredo Lopez223c10dbd5b9
diff --git a/docs/operations/gfs-large-file-host-downloads.md b/docs/operations/gfs-large-file-host-downloads.md
index ee1675502..407265903 100644
--- a/docs/operations/gfs-large-file-host-downloads.md
+++ b/docs/operations/gfs-large-file-host-downloads.md
@@ -334,11 +334,16 @@ Re-pinning a copy the caller already protects adds nothing and is decided
before the volume is measured.
The cap bounds each caller, not their sum. Two callers at their caps together
-protect the whole budget, and then every admission of a positive size is
-refused until a task releases its pins or the pinned copies expire. This is an
-accepted risk: a pin never outlives the copy's `expiresAt` (see
-[Retention pins](#retention-pins-and-cold-resume)), so the state lasts at most
-the retention period, `MCP_HOST_GFS_DOWNLOAD_TTL_HOURS` (168 hours by default).
+protect `2 × floor(budget / 2)` bytes, that is the budget minus `budget mod 2`:
+the whole budget when it is even, all but one byte when it is odd. Every
+admission that does not fit in the rest is then refused (with an even budget,
+every admission of a positive size) until a task releases its pins or the
+pinned copies expire. This is an accepted risk: a pin never outlives the copy's
+`expiresAt` (see [Retention pins](#retention-pins-and-cold-resume)), so each
+pinned copy holds its share for at most the retention period,
+`MCP_HOST_GFS_DOWNLOAD_TTL_HOURS` (168 hours by default). Callers whose tasks
+keep pinning freshly downloaded copies, each with a new expiry, can keep the
+budget saturated for longer than one retention period.
Before refusing, the store plans an eviction of complete copies that are
unpinned or pinned but already expired and are not being transferred, in any
@@ -359,12 +364,17 @@ evicts copies or the next sweep removes expired ones.
Free space is checked before the plan and again after it. Free space must cover
the block-rounded size of the new download, every active reservation and a
16 MiB margin; otherwise the admission is refused with `disk_full`
-(reason `free_space`). The first check runs before any eviction, so a volume
-that cannot hold the download costs no cached copy. A `statfs` that reports a
-block size or block count that is not positive, or a negative available-block
-count, cannot size a budget; the admission is refused as `host_quota_exceeded`
-with reason `free_space`, not as `disk_full`, because an unmeasurable volume is
-not evidence that the disk is full. A Host runs at most 2
+(reason `free_space`). The admission sweep runs before the first check, so
+expired copies (pinned ones included) and incomplete directories are removed
+first and never cause a `disk_full`. The first check still runs before any
+eviction of live copies, so a volume that cannot hold the download costs no
+cached copy. A `statfs` that reports a block size or block count that is not
+positive, or a negative available-block count, cannot size a budget. The store
+then measures the volume once more; if the second reading is valid the
+admission proceeds with it, and if it is still invalid the admission is
+refused with `volume_unmeasurable` (reason `free_space`), not `disk_full`,
+because an unmeasurable volume is not evidence that the disk is full. This
+applies to every measurement of the volume. A Host runs at most 2
transfers at once, and a caller at most its configured concurrency; beyond that
admission returns `download_busy`.
@@ -406,8 +416,11 @@ it` and counts `sweep_failed`. All three log the error code only.
A directory that cannot be listed is skipped and retried by the next sweep
(`sweep_failed`). A removal that fails is logged with its error code
-(`remove_failed`) and retried by the next sweep; the copy stays where it is,
-indexed and charged, and a published copy stays published. A duplicate
+(`remove_failed`) and retried by the next sweep. A removal that fails before
+its rename leaves the copy where it is, indexed and charged, and a published
+copy stays published. A removal that renamed the copy and then failed leaves it
+under its trash name (below): it stays charged there until its removal succeeds
+or its absence is confirmed. A duplicate
directory whose removal failed stays charged against the Host budget until a
removal succeeds or `lstat` proves it gone: `ENOENT`, `ENOTDIR` (a parent such
as the caller root is no longer a directory) or a path that is no longer a
@@ -428,7 +441,14 @@ that parent: `.trash-<uuid>` inside `.gfs-downloads`,
`.gfs-downloads.trash-<uuid>` in a caller root (a replaced `.gfs-downloads`)
and `.gfs-download-store.retired-<uuid>` in the Host root. A removal that stops
between its rename and its `rm` leaves that name behind; the next sweep removes
-it, and workspace tools treat it as protected until then. When the parent
+it, and workspace tools treat it as protected until then. The charge follows the
+renamed directory: its bytes stay charged against the Host budget until a
+removal succeeds or its absence is confirmed, so a trash directory whose
+removal keeps failing stays charged until it is removed. An indexed entry left
+under a trash name is dropped from the index, because its name is gone, and is
+charged only on the trash name, never twice. An unindexed expired copy whose
+removal fails after the rename is charged on its trash name with the size read
+from its `meta.json`. When the parent
check refuses and the rename back also fails, the refusal is reported and the
undo failure is logged as `GFS download store could not restore a directory
after refusing to remove it` with its error code.
@@ -441,7 +461,11 @@ until its `expiresAt`, never beyond, and is released when the task reaches a
terminal state. Expiry is absolute: once a pinned copy expires, it no longer
counts toward its caller's protected bytes, eviction may reclaim it, and the
next sweep removes it even though the task still holds its pin. A task that
-still needs the file downloads it again. Pins are per caller: another caller
+still needs the file downloads it again. A prepared copy past its expiry is
+not marked in the turn context: while it is still on disk, a command that reads
+its path uses it; after the sweep removes it, the command fails (`ENOENT`) and
+the model downloads the file again. A resume after approval replays the
+first-turn context unchanged. Pins are per caller: another caller
using the same owner ID holds a different pin. Pins are held in memory, so after
a restart a resumed task finds its copy unpinned and not reusable, and downloads
it again. A shell command never pins a copy. A pin is not bounded by the task's
@@ -463,18 +487,19 @@ byte is sent to a model.
### Errors visible to the model
-| Code | Meaning |
-| ----------------------- | ---------------------------------------------------------------------------------------------------------------------- |
-| `host_quota_exceeded` | The Host's retained bytes would exceed the volume budget and eviction cannot make room, or the volume is unmeasurable. |
-| `disk_full` | Free space on the Host volume cannot hold the download, every active reservation and the 16 MiB margin. |
-| `limit_exceeded` | The declared size is not a non-negative integer up to `MCP_HOST_GFS_MAX_FILE_BYTES`. |
-| `download_busy` | Too many active transfers, the store is closed or closing, or no such transfer exists. |
-| `download_missing` | No copy this process published for this caller has that path, or the copy failed verification. |
-| `download_expired` | The copy or the transfer is past its expiry. |
-| `publication_cancelled` | The task was cancelled or ran out of time while the copy was being verified or published. |
-| `storage_write_failed` | A filesystem operation failed during admission, publication or removal. |
-| `workspace_unavailable` | The store is not initialized, or the Host root or caller directory is not a real directory inside the Host root. |
-| `caller_mismatch` | The request carries no caller identity, one that is not its caller directory's key, or a malformed retention owner ID. |
+| Code | Meaning |
+| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `host_quota_exceeded` | The Host's retained bytes would exceed the volume budget and eviction cannot make room, or the caller's protected bytes would exceed its cap of half the budget. |
+| `disk_full` | Free space on the Host volume cannot hold the download, every active reservation and the 16 MiB margin. |
+| `volume_unmeasurable` | The Host volume's `statfs` was invalid on two consecutive readings, so no budget or free space could be computed. |
+| `limit_exceeded` | The declared size is not a non-negative integer up to `MCP_HOST_GFS_MAX_FILE_BYTES`. |
+| `download_busy` | Too many active transfers, the store is closed or closing, or no such transfer exists. |
+| `download_missing` | No copy this process published for this caller has that path, or the copy failed verification. |
+| `download_expired` | The copy or the transfer is past its expiry. |
+| `publication_cancelled` | The task was cancelled or ran out of time while the copy was being verified or published. |
+| `storage_write_failed` | A filesystem operation failed during admission, publication or removal. |
+| `workspace_unavailable` | The store is not initialized, or the Host root or caller directory is not a real directory inside the Host root. |
+| `caller_mismatch` | The request carries no caller identity, one that is not its caller directory's key, or a malformed retention owner ID. |
Another caller's download is answered with the same code and message as an ID
that does not exist (`download_missing` for reads and publication,
@@ -483,24 +508,26 @@ that does not exist (`download_missing` for reads and publication,
### Space refusals and the guidance the model receives
The two space refusals carry a fixed guidance text so the model can tell the
-user what happened and offer a cleanup through an approved `shell_exec`:
+user what happened and what they can do:
- `disk_full`: the Host workspace disk is full. The model tells the user and
offers to list the files in the user's own workspace (the shell working
directory, e.g. `du -sh -- * .[!.]* 2>/dev/null | sort -h`) and to delete
- what the user no longer needs with a command the user approves. It never
- lists, reads or deletes another user's directory or anything outside the
- workspace.
+ what the user no longer needs with a `shell_exec` command the user approves.
+ It never lists, reads or deletes another user's directory or anything
+ outside the workspace.
- `host_quota_exceeded`: the Host's cache of downloaded files is full. Space
- frees as other tasks finish and cached copies expire. The model tells the
- user, who may delete their own downloaded copies under `.gfs-downloads` in
- their workspace that no running task is using, with an approved command,
- never another user's. A task that still needs a deleted copy downloads it
- again.
-
-An unmeasurable volume (invalid `statfs`) is refused as `host_quota_exceeded`
-and therefore carries the cache guidance; the condition is not expected on a
-real volume. `limit_exceeded` and every other store code carry no guidance.
+ frees as tasks finish and downloaded copies expire. The model tells the user,
+ who can finish or cancel their own running tasks to free space sooner and
+ then try again. It never acts on another user's tasks or files. The text
+ offers no deletion of downloaded copies: the store has already evicted every
+ copy no running task protects before refusing, and the per-caller cap counts
+ only the caller's protected copies, so deleting copies by hand cannot admit
+ the download.
+
+`volume_unmeasurable` carries no guidance: the volume could not be measured,
+and no cleanup by the user would change that. `limit_exceeded` and every other
+store code carry no guidance either.
Neither text names, counts or hints at whose files use the space, and neither
interpolates any value. The texts live in
@@ -515,9 +542,11 @@ paths:
`code=quota_exceeded`), followed once per code by a
`For code=<code>: <guidance>` line in the turn context. Preparation accepts
the envelope alone or the envelope followed by exactly its own guidance line;
- any other second line maps to `download_failed`.
+ any other second line maps to `download_failed`. The bare
+ `volume_unmeasurable` envelope is rendered as `code=volume_unmeasurable`
+ with no `For code=` line; with any second line it maps to `download_failed`.
-The `free_space` metric counts `disk_full` refusals and the unmeasurable-volume
+The `free_space` metric counts `disk_full` refusals and the `volume_unmeasurable`
refusals described in [Quotas and eviction](#quotas-and-eviction).
### Initialization and availability
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 1c01771b4..e0fc4d269 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.544",
+ "version": "0.1.545",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.544",
+ "version": "0.1.545",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index e38e7e197..1c091db4e 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.544",
+ "version": "0.1.545",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/agent/__tests__/gfsFilePreparation.test.ts b/mcp-host/src/agent/__tests__/gfsFilePreparation.test.ts
index 453dddbd9..5931fe042 100644
--- a/mcp-host/src/agent/__tests__/gfsFilePreparation.test.ts
+++ b/mcp-host/src/agent/__tests__/gfsFilePreparation.test.ts
@@ -302,6 +302,7 @@ describe('GFS file preparation', () => {
const diskFull = 'Error: GFS download store failed (disk_full)'
const cacheFull = 'Error: GFS download store failed (host_quota_exceeded)'
+ const volumeUnmeasurable = 'Error: GFS download store failed (volume_unmeasurable)'
it.each([
[
'the disk_full envelope with its guidance',
@@ -344,6 +345,22 @@ describe('GFS file preparation', () => {
`Error: GFS download store failed (limit_exceeded)\n${GFS_CACHE_FULL_GUIDANCE}`,
'download_failed',
],
+ ['the bare volume_unmeasurable envelope', volumeUnmeasurable, 'volume_unmeasurable'],
+ [
+ 'the volume_unmeasurable envelope with the cache guidance',
+ `${volumeUnmeasurable}\n${GFS_CACHE_FULL_GUIDANCE}`,
+ 'download_failed',
+ ],
+ [
+ 'the volume_unmeasurable envelope with the disk guidance',
+ `${volumeUnmeasurable}\n${GFS_DISK_FULL_GUIDANCE}`,
+ 'download_failed',
+ ],
+ [
+ 'the volume_unmeasurable envelope with an untrusted second line',
+ `${volumeUnmeasurable}\nuntrusted detail`,
+ 'download_failed',
+ ],
] as const)('maps %s to its fixed category', async (_label, content, code) => {
const test = subject(vi.fn(async () => ({ content, duration_ms: 1, is_error: true })))
const result = await prepareGfsFiles([resolution()], test.context)
diff --git a/mcp-host/src/agent/gfsFilePreparation.ts b/mcp-host/src/agent/gfsFilePreparation.ts
index a0fba8416..80a9afd56 100644
--- a/mcp-host/src/agent/gfsFilePreparation.ts
+++ b/mcp-host/src/agent/gfsFilePreparation.ts
@@ -63,6 +63,9 @@ function failureCode(content: string): GfsPreparationFailure {
if (fixed === 'download_missing' || fixed === 'download_expired') return 'missing'
if (fixed === 'disk_full') return 'disk_full'
if (fixed === 'host_quota_exceeded') return 'quota_exceeded'
+ // Carries no guidance: only the bare envelope maps here; with any second line
+ // the anchored envelope does not match and the result is download_failed.
+ if (fixed === 'volume_unmeasurable') return 'volume_unmeasurable'
if (fixed === 'workspace_unavailable') return 'workspace_unavailable'
if (fixed === 'limit_exceeded') return 'limit_exceeded'
if (fixed === 'timeout') return 'timeout'
diff --git a/mcp-host/src/agent/taskExecutor.ts b/mcp-host/src/agent/taskExecutor.ts
index f32525896..c1ddeeffe 100644
--- a/mcp-host/src/agent/taskExecutor.ts
+++ b/mcp-host/src/agent/taskExecutor.ts
@@ -1072,7 +1072,9 @@ export class TaskExecutor {
* no pin and its file may have expired or been evicted, and the model
* downloads it again. Release happens only after this executor reaches a
* terminal state. A failed release leaves the pin in place, so its files stay
- * protected until the Host restarts.
+ * protected until the Host restarts or until each copy reaches its
+ * `expiresAt`, whichever comes first: expiry is absolute and a pin never
+ * protects an expired copy.
*/
private settleGfsRetentionOwner(): Promise<void> {
if (this.state === 'waiting_approval' && !this.abortController.signal.aborted)
@@ -1087,7 +1089,7 @@ export class TaskExecutor {
} catch (error) {
logger.error(
{ taskId: this.taskId, callerIdentity, err: error },
- 'GFS retention owner release failed; retained records remain protected'
+ 'GFS retention owner release failed; retained records remain protected until restart or expiry'
)
}
})()
diff --git a/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts b/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
index fe861db8f..bcd4a04f7 100644
--- a/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
+++ b/mcp-host/src/core/orchestration/__tests__/turnContext.test.ts
@@ -104,19 +104,23 @@ describe('prepared GFS receipts', () => {
expect(block.split('\n').filter(line => line.includes(GFS_DISK_FULL_GUIDANCE))).toHaveLength(1)
})
- it('tells the model the download cache is full and that only the caller may delete its own copies', () => {
+ it('tells the model the download cache is full and that the user can only finish or cancel their own tasks, with no offer to delete copies', () => {
const block = unavailable('quota_exceeded')
expect(block).toContain('status=unavailable code=quota_exceeded')
expect(block).toContain(`For code=quota_exceeded: ${GFS_CACHE_FULL_GUIDANCE}`)
- expect(GFS_CACHE_FULL_GUIDANCE).toContain("Host's cache of downloaded files is full")
- expect(GFS_CACHE_FULL_GUIDANCE).toContain('cached copies expire')
- expect(GFS_CACHE_FULL_GUIDANCE).toContain('Tell the user')
- expect(GFS_CACHE_FULL_GUIDANCE).toContain('under .gfs-downloads in their workspace')
- expect(GFS_CACHE_FULL_GUIDANCE).toContain('that no running task is using')
- expect(GFS_CACHE_FULL_GUIDANCE).toContain(
- 'a task that still needs a deleted copy downloads it again'
+ expect(GFS_CACHE_FULL_GUIDANCE).toBe(
+ "The Host's cache of downloaded files is full, so the file was not downloaded. " +
+ 'Space frees as tasks finish and downloaded copies expire. Tell the user. ' +
+ 'They can finish or cancel their own running tasks to free space sooner, then try again. ' +
+ "Never act on another user's tasks or files."
)
- expect(GFS_CACHE_FULL_GUIDANCE).toContain("Never delete another user's copies.")
+ // The store already evicted every unprotected copy before refusing, so a
+ // manual deletion cannot admit the download (Addendum 12 item 4).
+ const guidanceLine = block
+ .split('\n')
+ .find(line => line.startsWith('For code=quota_exceeded: '))
+ expect(guidanceLine).toBeDefined()
+ expect(guidanceLine).not.toMatch(/delete|\.gfs-downloads|shell_exec/)
expect(block).not.toContain(GFS_DISK_FULL_GUIDANCE)
expect(block.split('\n').filter(line => line.includes(GFS_CACHE_FULL_GUIDANCE))).toHaveLength(1)
})
@@ -167,6 +171,23 @@ describe('prepared GFS receipts', () => {
expect(other).not.toContain(GFS_DISK_FULL_GUIDANCE)
expect(other).not.toContain(GFS_CACHE_FULL_GUIDANCE)
})
+
+ it('renders an unmeasurable volume without any guidance line', () => {
+ const block = buildTurnContextBlock({
+ date: new Date('2026-10-02T00:00:00Z'),
+ channel: { type: 'rpc' },
+ preparedGfsFiles: [
+ { referenceId: 'gfs:main:a@v1', status: 'unavailable', code: 'volume_unmeasurable' },
+ { referenceId: 'gfs:main:b@v1', status: 'unavailable', code: 'disk_full' },
+ ],
+ })
+ expect(block).toContain('status=unavailable code=volume_unmeasurable')
+ // Witness: the guidance path ran for the other refusal in the same block.
+ const guidance = block.split('\n').filter(line => line.startsWith('For code='))
+ expect(guidance).toEqual([`For code=disk_full: ${GFS_DISK_FULL_GUIDANCE}`])
+ expect(block).not.toContain('For code=volume_unmeasurable')
+ expect(block).not.toContain(GFS_CACHE_FULL_GUIDANCE)
+ })
})
describe('buildTurnContextBlock (T2.2)', () => {
diff --git a/mcp-host/src/core/orchestration/turnContext.ts b/mcp-host/src/core/orchestration/turnContext.ts
index 426ed1a1d..230f041cd 100644
--- a/mcp-host/src/core/orchestration/turnContext.ts
+++ b/mcp-host/src/core/orchestration/turnContext.ts
@@ -106,6 +106,8 @@ export type GfsPreparationFailure =
| 'disk_full'
/** The Host's cache of downloaded files has no room for the download. */
| 'quota_exceeded'
+ /** The Host volume could not be measured, so no download was admitted. */
+ | 'volume_unmeasurable'
| 'limit_exceeded'
| 'timeout'
| 'invalid_response'
diff --git a/mcp-host/src/internalTools/gfs.ts b/mcp-host/src/internalTools/gfs.ts
index 56637d354..ca555ad3a 100644
--- a/mcp-host/src/internalTools/gfs.ts
+++ b/mcp-host/src/internalTools/gfs.ts
@@ -92,7 +92,8 @@ function ok(content: unknown): InternalToolResult {
// never the response body, which could carry paths or server internals.
// A store space refusal keeps its fixed envelope as the first line and adds the
// fixed guidance for its code as a second line; gfsFilePreparation accepts that
-// exact second line and nothing else.
+// exact second line and nothing else. Every other store code, including
+// `volume_unmeasurable`, is the bare envelope.
function fail(error: unknown): InternalToolResult {
if (error instanceof VisualInputError) return { success: false, error: error.message }
if (error instanceof GfsDownloadStoreError) {
diff --git a/mcp-host/src/internalTools/gfsDownloadStore.ts b/mcp-host/src/internalTools/gfsDownloadStore.ts
index 51daa6740..47e2d1dbe 100644
--- a/mcp-host/src/internalTools/gfsDownloadStore.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStore.ts
@@ -58,15 +58,18 @@ export type GfsDownloadStoreErrorCode =
| 'download_busy'
| 'download_expired'
| 'download_missing'
- /**
- * The retained-download budget or one caller's protected share of it is
- * full, or the volume cannot be measured.
- */
+ /** The retained-download budget or one caller's protected share of it is full. */
| 'host_quota_exceeded'
/** The declared size is not a safe non-negative integer up to the file limit. */
| 'limit_exceeded'
| 'publication_cancelled'
| 'storage_write_failed'
+ /**
+ * statfs gave an invalid reading (a non-positive block size or block count,
+ * or a negative available-block count) twice in a row, so the volume cannot
+ * be sized: neither the disk nor the cache is known to be full.
+ */
+ | 'volume_unmeasurable'
| 'workspace_unavailable'
export class GfsDownloadStoreError extends Error {
@@ -195,12 +198,36 @@ export interface GfsDownloadInventory {
byCaller: Map<string, { bytes: number; files: number }>
}
+/**
+ * `failed`: the directory was not moved and still holds its bytes under its
+ * own name. `trashed`: it was renamed to its trash name but not removed, so
+ * its bytes are on disk under that name; the retained-byte charge it carried
+ * moved there with it (see removeDirectory).
+ */
+type RemovalResult = 'removed' | 'absent' | 'failed' | 'trashed'
+
+/**
+ * A removal that renamed `directory` to `trash` and then could not remove
+ * `trash` (or could not prove it gone). `code` is the underlying errno or
+ * store code, so logs and errorCode() see the real cause.
+ */
+class TrashLeftError extends Error {
+ readonly code: string
+
+ constructor(
+ readonly trash: string,
+ cause: unknown
+ ) {
+ super('GFS download store left a renamed directory on disk')
+ this.name = 'TrashLeftError'
+ this.code = errorCode(cause)
+ }
+}
+
/**
* `unknown`: the disk did not answer (EMFILE, EIO, ...). Nothing is decided
* about the directory; it is kept as it is and inspected again later.
*/
-type RemovalResult = 'removed' | 'absent' | 'failed'
-
type DirectoryState =
| { state: 'absent' }
| { state: 'incomplete' }
@@ -545,11 +572,15 @@ export class GfsDownloadStore {
throw new GfsDownloadStoreError('download_busy')
}
if (input.retentionOwnerId !== undefined) this.assertReceiptOwner(input.retentionOwnerId)
- // Verified free capacity first: no eviction happens for an admission the
- // volume cannot hold anyway. Measured again after eviction below. The
- // same statfs sizes the budget, so a resized volume counts at once.
- const volume = await this.assertPhysicalCapacity(input.sizeBytes)
+ // The sweep runs first: it removes only expired copies (pinned ones
+ // included) and incomplete directories, so bytes the store must delete
+ // anyway never refuse an admission as disk_full. Then verified free
+ // capacity, before any eviction: no live cached copy is evicted for an
+ // admission the volume cannot hold anyway. Measured again after
+ // eviction below. The same statfs sizes the budget, so a resized volume
+ // counts at once.
await this.sweep(Date.now())
+ const volume = await this.assertPhysicalCapacity(input.sizeBytes)
const budget = retainedBudget(volume)
// The reservation itself is protected until it settles, pinned or not.
this.assertProtectedRoom(input.callerIdentity, budget, { sizeBytes: input.sizeBytes })
@@ -823,6 +854,10 @@ export class GfsDownloadStore {
return undefined
}
this.assertPublicationOpen(bounds)
+ // Expiry may have been crossed while the copy was hashed: an expired
+ // copy is a cache miss, never pinned or returned. The caller downloads
+ // the file again and the sweep removes this copy.
+ if (Date.parse(entry.expiresAt) <= Date.now()) return undefined
entry.lastUsedMs = Date.now()
if (bounds?.retentionOwnerId !== undefined)
this.pin(bounds.retentionOwnerId, callerIdentity, entry.id)
@@ -846,7 +881,8 @@ export class GfsDownloadStore {
if (this.active.get(id) !== transfer) throw new GfsDownloadStoreError('download_busy')
this.releaseActive(id)
this.unpinId(id)
- if ((await this.removeDirectory(transfer.directory, 'incomplete_removed')) === 'failed')
+ const result = await this.removeDirectory(transfer.directory, 'incomplete_removed')
+ if (result === 'failed' || result === 'trashed')
throw new GfsDownloadStoreError('storage_write_failed')
})
}
@@ -1028,11 +1064,16 @@ export class GfsDownloadStore {
for (const { id, directory } of await this.listInputDirectories(totals))
addCandidate(id, directory)
for (const entry of this.entries.values()) addCandidate(entry.id, entry.directory)
- const removeIncomplete = async (directory: string): Promise<boolean> => {
- const result = await this.removeDirectory(directory, 'incomplete_removed')
+ /**
+ * A removal that leaves the directory under its trash name is not 'failed'
+ * for the index: the old name is gone and the charge, when `charge` or a
+ * held charge gives one, moved to the trash name (removeDirectory).
+ */
+ const removeIncomplete = async (directory: string, charge?: number): Promise<RemovalResult> => {
+ const result = await this.removeDirectory(directory, 'incomplete_removed', charge)
if (result === 'removed') totals.removedIncomplete += 1
- else if (result === 'failed') totals.removeFailed += 1
- return result !== 'failed'
+ else if (result === 'failed' || result === 'trashed') totals.removeFailed += 1
+ return result
}
// A duplicate this sweep could not remove is still on disk, so it stays
// charged: a failed cleanup never turns into free capacity. Its charge is
@@ -1040,13 +1081,23 @@ export class GfsDownloadStore {
// directory gone: ENOENT, ENOTDIR (a parent is no longer a directory) or
// a path that is no longer a directory. An inspection or listing that
// fails, or any other lstat answer, carries the previous sweep's charge
- // over instead of reading as zero.
+ // over instead of reading as zero. A charge that a removal moved to a
+ // trash name is held under that name by the same rule. `previousHeld` is
+ // the live `this.held`, so a charge removeDirectory moves during this
+ // sweep is carried by the loop below.
const previousHeld = this.held
const held = new Map<string, HeldCopy>()
const settled = new Set<string>()
const removeDuplicate = async (id: string, directory: string): Promise<void> => {
settled.add(directory)
- if (await removeIncomplete(directory)) return
+ // Sized before the removal when no earlier sweep charged it, so a copy
+ // left under a trash name stays charged.
+ let charge = previousHeld.get(directory)?.sizeBytes
+ if (charge === undefined) {
+ const before = await this.inspectDirectory(directory, id, now)
+ if (before.state === 'complete') charge = before.entry.sizeBytes
+ }
+ if ((await removeIncomplete(directory, charge)) !== 'failed') return
const state = await this.inspectDirectory(directory, id, now)
if (state.state === 'complete') held.set(directory, { sizeBytes: state.entry.sizeBytes })
else if (state.state === 'unknown' || state.state === 'incomplete') {
@@ -1061,11 +1112,13 @@ export class GfsDownloadStore {
this.active.get(id)?.directory ??
(indexed?.provenance === 'published' ? indexed.directory : undefined)
if (owned === undefined && directories.length > 1) {
- // The indexed directory is forgotten only once it is gone; a failed
- // removal leaves it indexed and charged, like any other entry.
+ // The indexed directory is forgotten only once its name is gone; a
+ // failed removal leaves it indexed and charged, like any other entry,
+ // and one left under a trash name is charged there instead.
for (const duplicate of directories) {
if (duplicate !== indexed?.directory) await removeDuplicate(id, duplicate)
- else if (await removeIncomplete(duplicate)) this.forget(id)
+ else if ((await removeIncomplete(duplicate, indexed.sizeBytes)) !== 'failed')
+ this.forget(id)
}
continue
}
@@ -1091,18 +1144,20 @@ export class GfsDownloadStore {
)
continue
}
- // An entry is forgotten only once its directory is gone: a failed
- // removal leaves it indexed, charged and with its provenance.
+ // An entry is forgotten only once its directory name is gone: a failed
+ // removal leaves it indexed, charged and with its provenance; a removal
+ // that left it under a trash name moved its charge there.
if (state.state === 'incomplete') {
- if (await removeIncomplete(directory)) this.forget(id)
+ const charge = indexed?.directory === directory ? indexed.sizeBytes : undefined
+ if ((await removeIncomplete(directory, charge)) !== 'failed') this.forget(id)
continue
}
const entry = state.entry
if (Date.parse(entry.expiresAt) <= now) {
- const result = await this.removeDirectory(directory, 'expired_removed')
+ const result = await this.removeDirectory(directory, 'expired_removed', entry.sizeBytes)
if (result === 'removed') totals.removedExpired += 1
- if (result === 'failed') totals.removeFailed += 1
- else this.forget(id)
+ if (result === 'failed' || result === 'trashed') totals.removeFailed += 1
+ if (result !== 'failed') this.forget(id)
continue
}
this.entries.set(id, entry)
@@ -1228,10 +1283,12 @@ export class GfsDownloadStore {
this.reportSweepFailure(error)
return found
}
+ // A trash directory a held charge names keeps that charge through the
+ // removal: removeDirectory moves it to the next trash name or releases it.
const removeStray = async (directory: string, sweep: SweepTotals) => {
const result = await this.removeDirectory(directory, 'incomplete_removed')
if (result === 'removed') sweep.removedIncomplete += 1
- else if (result === 'failed') sweep.removeFailed += 1
+ else if (result === 'failed' || result === 'trashed') sweep.removeFailed += 1
}
for (const user of users) {
if (!user.isDirectory()) continue
@@ -1442,7 +1499,15 @@ export class GfsDownloadStore {
if (!isDefinitiveMismatch(error)) throw error
}
const replaced = this.idsUnder(downloadsRoot)
- await this.removeVerified(downloadsRoot)
+ try {
+ await this.removeVerified(downloadsRoot)
+ } catch (error) {
+ // Renamed but not removed: every copy charged under the old name is
+ // now on disk under the trash name, so the charge moves there.
+ if (error instanceof TrashLeftError)
+ this.moveChargesToTrash(downloadsRoot, replaced, error.trash)
+ throw error
+ }
for (const id of replaced) this.forget(id)
await fs.mkdir(downloadsRoot, { mode: 0o700 })
await verifyPrivateStoreDirectory(downloadsRoot)
@@ -1455,18 +1520,42 @@ export class GfsDownloadStore {
}
/**
- * A statfs whose block size or block count is not positive cannot size
- * anything; it records `free_space` but keeps `host_quota_exceeded`, because
- * an unmeasurable volume is not proof that the disk is full, and `disk_full`
- * tells the model to offer the user a workspace cleanup.
+ * `root` was renamed to `trash` and not removed: the indexed copies `ids`
+ * and every held charge below `root` are charged once, as one held charge
+ * on `trash`, and the copies are forgotten (their names are gone).
+ */
+ private moveChargesToTrash(root: string, ids: string[], trash: string): void {
+ let bytes = 0
+ for (const id of ids) {
+ const entry = this.entries.get(id)
+ if (entry) bytes += entry.sizeBytes
+ this.forget(id)
+ }
+ for (const [directory, copy] of this.held)
+ if (directory === root || isWithinDirectory(directory, root)) {
+ bytes += copy.sizeBytes
+ this.held.delete(directory)
+ }
+ if (bytes > 0) this.held.set(trash, { sizeBytes: bytes })
+ }
+
+ /**
+ * A statfs reading whose block size or block count is not positive, or
+ * whose available-block count is negative, cannot size anything. The volume
+ * is measured once more at once; a second invalid reading records
+ * `free_space` and refuses with `volume_unmeasurable`, never `disk_full` or
+ * `host_quota_exceeded`: an unmeasurable volume is proof of neither a full
+ * disk nor a full cache, and each of those codes tells the model something
+ * about space. A statfs that rejects is not a reading and propagates as is.
*/
private async measureVolume(): Promise<VolumeSpace> {
- const space = await fs.statfs(this.hostRoot, { bigint: true })
- if (space.bsize <= 0n || space.blocks <= 0n || space.bavail < 0n) {
- recordGfsDownloadQuota('host', 'free_space')
- throw new GfsDownloadStoreError('host_quota_exceeded')
+ for (let reading = 0; reading < 2; reading += 1) {
+ const space = await fs.statfs(this.hostRoot, { bigint: true })
+ if (space.bsize > 0n && space.blocks > 0n && space.bavail >= 0n)
+ return { bsize: space.bsize, blocks: space.blocks, bavail: space.bavail }
}
- return { bsize: space.bsize, blocks: space.blocks, bavail: space.bavail }
+ recordGfsDownloadQuota('host', 'free_space')
+ throw new GfsDownloadStoreError('volume_unmeasurable')
}
private async assertPhysicalCapacity(sizeBytes: number): Promise<VolumeSpace> {
@@ -1510,12 +1599,15 @@ export class GfsDownloadStore {
* Eviction never reclaims an unexpired pinned copy or a reservation, so
* without a bound one caller's open tasks could hold the whole budget and
* refuse every other caller. One caller's protected bytes may therefore
- * reach at most half the budget. That bounds each caller, not their sum:
- * several callers together can protect the whole budget, and then every
- * positive-size admission is refused until protection is released or the
- * pinned copies expire (expiry is absolute, so the retention window bounds
- * that state). Only this caller's own usage decides; the refusal is the
- * fixed code.
+ * reach at most `floor(budget / 2)`. That bounds each caller, not their
+ * sum: two callers at the cap protect `budget - (budget mod 2)` bytes, the
+ * whole budget when it is even and all but one byte when it is odd, and
+ * more callers can protect all of it. Then admissions larger than what is
+ * left are refused until protection is released or the pinned copies
+ * expire. Expiry is absolute, so one pinned copy cannot outlive its
+ * retention window, but re-pinning fresh copies (new downloads or reuse of
+ * unexpired ones) can keep that state beyond one TTL. Only this caller's
+ * own usage decides; the refusal is the fixed code.
*/
private assertProtectedRoom(
callerIdentity: string,
@@ -1583,15 +1675,21 @@ export class GfsDownloadStore {
/**
* Removes an indexed entry's directory, then forgets it. A failed removal
* keeps the entry indexed: still charged to its caller, and a published
- * copy stays published instead of coming back as adopted.
+ * copy stays published instead of coming back as adopted. A removal that
+ * left the directory under its trash name forgets the entry, whose name is
+ * gone, and its charge stays held on the trash name.
*/
private async removeEntry(
entry: Entry,
outcome: 'incomplete_removed' | 'expired_removed',
count = true
): Promise<void> {
- if ((await this.removeDirectory(entry.directory, count ? outcome : undefined)) !== 'failed')
- this.forget(entry.id)
+ const result = await this.removeDirectory(
+ entry.directory,
+ count ? outcome : undefined,
+ entry.sizeBytes
+ )
+ if (result !== 'failed') this.forget(entry.id)
}
/**
@@ -1601,11 +1699,22 @@ export class GfsDownloadStore {
* must therefore be its own real path inside the Host root, and the
* directory must be gone afterwards. A refusal or a failure is logged with
* its code and counted; the next sweep retries what is still listed.
+ *
+ * Retained bytes stay charged while they are on disk. The charge is
+ * `charge` when the caller gives one (an indexed entry's size), otherwise a
+ * held charge already on `directory` (a held duplicate or a trash directory
+ * an earlier removal left). When the rename to the trash name succeeds but
+ * the trash is not removed, the charge moves to the trash name as a held
+ * charge, so the old name's absence never releases it; it is released only
+ * when a later removal of that trash succeeds or lstat proves it gone
+ * (sweep), and a failed retry moves it again to the next trash name.
*/
private async removeDirectory(
directory: string,
- outcome: 'incomplete_removed' | 'expired_removed' | undefined
+ outcome: 'incomplete_removed' | 'expired_removed' | undefined,
+ charge?: number
): Promise<RemovalResult> {
+ const carried = charge ?? this.held.get(directory)?.sizeBytes
let result: RemovalResult
try {
result = await this.removeVerified(directory)
@@ -1615,8 +1724,12 @@ export class GfsDownloadStore {
{ component: GFS_DOWNLOAD_STORE_LOG_COMPONENT, code: errorCode(error) },
'GFS download store could not remove a download directory; the next sweep retries it'
)
- return 'failed'
+ if (!(error instanceof TrashLeftError)) return 'failed'
+ this.held.delete(directory)
+ if (carried !== undefined) this.held.set(error.trash, { sizeBytes: carried })
+ return 'trashed'
}
+ this.held.delete(directory)
// A directory that never existed is not a removal.
if (result === 'removed' && outcome) recordGfsDownloadExpiry(outcome)
return result
@@ -1628,7 +1741,9 @@ export class GfsDownloadStore {
* renamed to a store-private name inside its verified parent; the parent is
* then verified again, and only that private name is removed. When the
* parent moved in between, the rename is undone and the removal refused,
- * so whatever the swapped path led to keeps its name and content.
+ * so whatever the swapped path led to keeps its name and content. A
+ * failure after the rename throws TrashLeftError naming the trash path,
+ * because the bytes are then on disk under that name.
*/
private async removeVerified(directory: string): Promise<'removed' | 'absent'> {
await this.assertRemovable(directory)
@@ -1658,8 +1773,13 @@ export class GfsDownloadStore {
}
throw error
}
- await fs.rm(trash, { recursive: true, force: true })
- await assertAbsent(trash)
+ try {
+ await fs.rm(trash, { recursive: true, force: true })
+ await assertAbsent(trash)
+ } catch (error) {
+ // The bytes are on disk under the trash name now, not under `directory`.
+ throw new TrashLeftError(trash, error)
+ }
return 'removed'
}
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreAdversarial.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreAdversarial.test.ts
index 1f477fca1..3bc6c3992 100644
--- a/mcp-host/src/internalTools/gfsDownloadStoreAdversarial.test.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStoreAdversarial.test.ts
@@ -488,7 +488,7 @@ describe('GFS download store adversarial round: trash, eviction and undo (ADV-2/
expect(await expiryCount('incomplete_removed')).toBe(removed)
})
- it('a sweep keeps an incomplete entry indexed until its removal succeeds', async () => {
+ it('a sweep keeps an incomplete entry charged, under its trash name, until its removal succeeds', async () => {
const store = await openStore()
const root = callerDirectory(hostRoot, KEY)
const { receipt } = await completedCopy(store, root, KEY, 8, 16)
@@ -501,17 +501,27 @@ describe('GFS download store adversarial round: trash, eviction and undo (ADV-2/
await store.cleanupExpired()
faults.clear()
- // Witness: the sweep tried to remove it, and the removal failed.
+ // Witness: the sweep renamed it and its rm failed; the bytes now sit
+ // under the trash name, which carries the entry's 16-byte charge.
expect(removals).toHaveLength(1)
expect(await expiryCount('remove_failed')).toBe(failedRemovals + 1)
- expect(indexedEntry(store, receipt.id)).toBeDefined()
-
- await store.cleanupExpired()
expect(exists(directory)).toBe(false)
+ expect(exists(removals[0]!)).toBe(true)
+ expect(heldCharges(store)).toEqual(new Map([[removals[0]!, 16]]))
expect(() => indexedEntry(store, receipt.id)).toThrow('entry is not indexed')
+
+ await store.cleanupExpired()
+ expect(exists(removals[0]!)).toBe(false)
+ expect(heldCharges(store).size).toBe(0)
})
})
+/** White-box view of the held charges, by directory. */
+function heldCharges(store: GfsDownloadStore): Map<string, number> {
+ const held = (store as unknown as { held: Map<string, { sizeBytes: number }> }).held
+ return new Map([...held].map(([directory, copy]) => [directory, copy.sizeBytes]))
+}
+
interface IndexedEntryView {
sourceIdentity?: { dev: bigint; ino: bigint }
}
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreBudget.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreBudget.test.ts
index 17e65fe4c..51182bae5 100644
--- a/mcp-host/src/internalTools/gfsDownloadStoreBudget.test.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStoreBudget.test.ts
@@ -183,21 +183,28 @@ describe('GFS download store budget: share of the workspace volume', () => {
{ name: 'a zero block size', bsize: 0n, blocks: 1000n },
{ name: 'a zero block count', bsize: 1n, blocks: 0n },
{ name: 'a negative block count', bsize: 1n, blocks: -1n },
- ])('BUD-5: statfs reporting $name refuses with free_space', async ({ bsize, blocks }) => {
- const store = await openStore()
- const observed = await nativeFs.statfs(hostRoot, { bigint: true })
- statfsBoundary.mockResolvedValue({ ...observed, bsize, blocks })
- const denied = await quotaCount('host', 'free_space')
-
- await expect(startTransfer(store, rootA, A, 31, 4)).rejects.toMatchObject({
- code: 'host_quota_exceeded',
- })
- expect(await quotaCount('host', 'free_space')).toBe(denied + 1)
+ ])(
+ 'BUD-5: statfs reporting $name twice refuses as volume_unmeasurable with free_space',
+ async ({ bsize, blocks }) => {
+ const store = await openStore()
+ const observed = await nativeFs.statfs(hostRoot, { bigint: true })
+ statfsBoundary.mockResolvedValue({ ...observed, bsize, blocks })
+ statfsBoundary.mockClear()
+ const denied = await quotaCount('host', 'free_space')
+
+ await expect(startTransfer(store, rootA, A, 31, 4)).rejects.toMatchObject({
+ code: 'volume_unmeasurable',
+ message: 'GFS download store failed (volume_unmeasurable)',
+ })
+ // Exactly one re-measure: the refusal follows the second invalid reading.
+ expect(statfsBoundary).toHaveBeenCalledTimes(2)
+ expect(await quotaCount('host', 'free_space')).toBe(denied + 1)
- // Witness: the real statfs admits the same request.
- statfsBoundary.mockImplementation(nativeFs.statfs)
- await expect(startTransfer(store, rootA, A, 31, 4)).resolves.toBeDefined()
- })
+ // Witness: the real statfs admits the same request.
+ statfsBoundary.mockImplementation(nativeFs.statfs)
+ await expect(startTransfer(store, rootA, A, 31, 4)).resolves.toBeDefined()
+ }
+ )
})
describe('GFS download store budget: a full disk and a full cache are distinct refusals', () => {
@@ -238,22 +245,51 @@ describe('GFS download store budget: a full disk and a full cache are distinct r
await expect(startTransfer(store, rootC, C, 43, 1)).resolves.toBeDefined()
})
- it('DSK-2: statfs reporting a negative available-block count keeps host_quota_exceeded, not disk_full', async () => {
+ it('DSK-2: statfs reporting a negative available-block count twice refuses as volume_unmeasurable, not disk_full or host_quota_exceeded', async () => {
const store = await openStore()
const observed = await nativeFs.statfs(hostRoot, { bigint: true })
statfsBoundary.mockResolvedValue({ ...observed, bavail: -1n })
+ statfsBoundary.mockClear()
const denied = await quotaCount('host', 'free_space')
+ const budgetDenied = await quotaCount('host', 'storage_bytes')
const refusal = await startTransfer(store, rootA, A, 44, 4).catch((error: unknown) => error)
expect(refusal).toBeInstanceOf(GfsDownloadStoreError)
- expect((refusal as GfsDownloadStoreError).code).toBe('host_quota_exceeded')
+ expect((refusal as GfsDownloadStoreError).code).toBe('volume_unmeasurable')
+ expect(statfsBoundary).toHaveBeenCalledTimes(2)
expect(await quotaCount('host', 'free_space')).toBe(denied + 1)
+ expect(await quotaCount('host', 'storage_bytes')).toBe(budgetDenied)
// Witness: the real statfs admits the same request.
statfsBoundary.mockImplementation(nativeFs.statfs)
await expect(startTransfer(store, rootA, A, 44, 4)).resolves.toBeDefined()
})
+ it.each([
+ { name: 'a zero block size', fields: { bsize: 0n } },
+ { name: 'a zero block count', fields: { blocks: 0n } },
+ { name: 'a negative block count', fields: { blocks: -1n } },
+ { name: 'a negative available-block count', fields: { bavail: -1n } },
+ ])(
+ 'DSK-4: one statfs reading with $name is measured again and a valid second reading admits',
+ async ({ fields }) => {
+ const store = await openStore()
+ const observed = await nativeFs.statfs(hostRoot, { bigint: true })
+ statfsBoundary.mockImplementation(nativeFs.statfs)
+ statfsBoundary.mockResolvedValueOnce({ ...observed, ...fields })
+ statfsBoundary.mockClear()
+ const denied = await quotaCount('host', 'free_space')
+
+ const admitted = await startTransfer(store, rootA, A, 46, 4)
+ expect(admitted.transfer.sizeBytes).toBe(4)
+ // The free-space check read twice (invalid, then valid) and the check
+ // after eviction once: a refusal on the first reading would stop at one.
+ expect(statfsBoundary).toHaveBeenCalledTimes(3)
+ expect(await quotaCount('host', 'free_space')).toBe(denied)
+ await store.fail(admitted.transfer.id, A)
+ }
+ )
+
it.each([
{ name: 'one byte above the file limit', size: 11 },
{ name: 'a negative size', size: -1 },
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreNonBlocking.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreNonBlocking.test.ts
index 1e3d939e6..154958857 100644
--- a/mcp-host/src/internalTools/gfsDownloadStoreNonBlocking.test.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStoreNonBlocking.test.ts
@@ -130,10 +130,9 @@ describe('GFS download store: a FIFO in the store tree never blocks', () => {
const root = callerDirectory(hostRoot, KEY)
const directory = plantFifoMeta(root)
const fifo = path.join(directory, 'meta.json')
- // A writer that never writes: a read would get EAGAIN, not end-of-file.
- const reader = syncFs.openSync(fifo, syncFs.constants.O_RDONLY | syncFs.constants.O_NONBLOCK)
- const writer = syncFs.openSync(fifo, syncFs.constants.O_WRONLY)
- syncFs.closeSync(reader)
+ // A writer that never writes: a read would get EAGAIN, not end-of-file. One O_RDWR open attaches
+ // the writer without blocking (Linux and macOS), so there is no separate reader open to race with.
+ const writer = syncFs.openSync(fifo, syncFs.constants.O_RDWR | syncFs.constants.O_NONBLOCK)
try {
const sweep = store.cleanupExpired()
expect(await settleWithin(sweep, fifo, 'reader')).toBe('settled')
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
index 12e8009f3..bf7e79f03 100644
--- a/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
@@ -275,6 +275,32 @@ describe('GFS download store: a caller protects at most half the budget (R3-F1)'
})
describe('GFS download store: retention pins never outlive expiresAt (Addendum 10)', () => {
+ it('an expired copy still on disk is not reused', async () => {
+ const store = await openStore()
+ const pinned = await completedCopy(store, rootA, A, 0, 10, { owner: 'task-a' })
+ const directory = downloadDirectory(rootA, pinned.receipt.id)
+ // Witness: before expiry the same lookup reuses the copy.
+ await expect(store.reusableReceipt(A, sourceFor(0), 10)).resolves.toMatchObject({
+ id: pinned.receipt.id,
+ })
+
+ // Past expiresAt with no sweep in between: the copy is still on disk.
+ vi.setSystemTime(Date.now() + 2 * HOUR_MS)
+ await expect(store.reusableReceipt(A, sourceFor(0), 10)).resolves.toBeUndefined()
+ await expect(
+ store.reusableReceipt(A, sourceFor(0), 10, { retentionOwnerId: 'task-b' })
+ ).resolves.toBeUndefined()
+ expect(exists(directory)).toBe(true)
+ await expect(store.readManagedFile(pinned.receipt.path, A)).rejects.toMatchObject({
+ code: 'download_expired',
+ })
+
+ // Witness: a fresh download of the same source is published and served.
+ const fresh = await completedCopy(store, rootA, A, 0, 10, { owner: 'task-b' })
+ expect(fresh.receipt.id).not.toBe(pinned.receipt.id)
+ await expect(store.readManagedFile(fresh.receipt.path, A)).resolves.toEqual(fresh.bytes)
+ })
+
it('the sweep removes a pinned copy once it is past its expiry', async () => {
const store = await openStore()
const pinned = await completedCopy(store, rootA, A, 0, 10, { owner: 'task-a' })
@@ -373,10 +399,10 @@ describe('GFS download store: re-pinning an already protected copy (R4-F1)', ()
expect(statfsBoundary.mock.calls.length).toBe(callsBefore)
// Control: a copy A does not protect yet must size the budget, and the
- // same armed EIO refuses it.
+ // same armed EIO refuses it with that exact errno.
await expect(
store.reusableReceipt(A, sourceFor(1), 5, { retentionOwnerId: 'task-b' })
- ).rejects.toBeInstanceOf(Error)
+ ).rejects.toMatchObject({ code: 'EIO', message: 'EIO: injected by the test' })
expect(statfsBoundary.mock.calls.length).toBe(callsBefore + 1)
})
})
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreTrashAndExpiry.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreTrashAndExpiry.test.ts
new file mode 100644
index 000000000..edb2ebb6d
--- /dev/null
+++ b/mcp-host/src/internalTools/gfsDownloadStoreTrashAndExpiry.test.ts
@@ -0,0 +1,326 @@
+/**
+ * Round-5 findings of #1028 (Addendum 12), on a real temporary directory.
+ * statfs reports a volume whose available bytes are its total minus the
+ * source bytes actually on disk (trash included), so free space and the
+ * retained budget follow what the store really keeps. Faults are injected
+ * only on the operation under test.
+ *
+ * - M1: expired copies, pinned ones included, are swept before the first
+ * free-space check, so they never refuse an admission as disk_full; live
+ * cached copies are still never evicted before that check.
+ * - R5-F1: a removal that renamed a directory to its trash name and then
+ * could not remove it keeps the retained-byte charge on the trash name.
+ * - R5-F2: a reuse that crosses expiry while hashing is a cache miss.
+ */
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import * as syncFs from 'node:fs'
+import * as fs from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import * as path from 'node:path'
+import {
+ callerDirectory,
+ completedCopy,
+ downloadDirectory,
+ exists,
+ expiryCount,
+ quotaCount,
+ sourceFor,
+ startTransfer,
+ withEnvironment,
+} from '../__tests__/fixtures/gfsStoreTestKit'
+import { GfsDownloadStore } from './gfsDownloadStore'
+
+const { openBoundary, statfsBoundary, rmBoundary } = vi.hoisted(() => ({
+ openBoundary: vi.fn(),
+ statfsBoundary: vi.fn(),
+ rmBoundary: vi.fn(),
+}))
+vi.mock('node:fs/promises', async original => ({
+ ...(await original<typeof fs>()),
+ open: openBoundary,
+ statfs: statfsBoundary,
+ rm: rmBoundary,
+}))
+
+const A = 'caller-a'
+const B = 'caller-b'
+const C = 'caller-c'
+const HOUR_MS = 60 * 60_000
+const MIB = 1024 * 1024
+/** The store's fixed free-space margin. */
+const MARGIN = 16n * BigInt(MIB)
+
+let nativeFs: typeof fs
+let hostRoot: string
+let rootA: string
+let rootB: string
+let rootC: string
+const stores: GfsDownloadStore[] = []
+const releases: Array<() => void> = []
+
+/** Bytes of every `source` and `source.partial` under `directory`, trash included. */
+function storedSourceBytes(directory: string): number {
+ let total = 0
+ for (const entry of syncFs.readdirSync(directory, { withFileTypes: true })) {
+ const target = path.join(directory, entry.name)
+ if (entry.isDirectory()) total += storedSourceBytes(target)
+ else if (entry.isFile() && ['source', 'source.partial'].includes(entry.name))
+ total += syncFs.statSync(target).size
+ }
+ return total
+}
+
+/** A `totalBytes` volume (block size 1) with `freeWhenEmpty` available while the store holds nothing. */
+function coherentVolume(totalBytes: bigint, freeWhenEmpty: bigint): void {
+ statfsBoundary.mockImplementation(async (target: string) => {
+ const real = await nativeFs.statfs(target, { bigint: true })
+ return {
+ ...real,
+ bsize: 1n,
+ blocks: totalBytes,
+ bavail: freeWhenEmpty - BigInt(storedSourceBytes(hostRoot)),
+ }
+ })
+}
+
+async function openStore(): Promise<GfsDownloadStore> {
+ const opened = new GfsDownloadStore(hostRoot)
+ stores.push(opened)
+ await opened.initialize()
+ return opened
+}
+
+/** A store re-imported with environment limits applied. */
+async function limitedStore(env: Record<string, string>): Promise<GfsDownloadStore> {
+ return withEnvironment(env, async () => {
+ vi.resetModules()
+ const { GfsDownloadStore: Store } = await import('./gfsDownloadStore')
+ const opened = new Store(hostRoot) as unknown as GfsDownloadStore
+ stores.push(opened)
+ await opened.initialize()
+ return opened
+ })
+}
+
+/** Trash directories left in one caller's `.gfs-downloads`. */
+function trashIn(root: string): string[] {
+ const downloads = path.join(root, '.gfs-downloads')
+ if (!exists(downloads)) return []
+ return syncFs.readdirSync(downloads).filter(name => name.startsWith('.trash-'))
+}
+
+/** Pauses the next read of a `source` descriptor until `resume()`. */
+function pauseNextSourceRead() {
+ let entered!: () => void
+ let resume!: () => void
+ const reached = new Promise<void>(resolve => {
+ entered = resolve
+ })
+ const resumed = new Promise<void>(resolve => {
+ resume = resolve
+ })
+ releases.push(resume)
+ let armed = true
+ openBoundary.mockImplementation(async (...args: unknown[]) => {
+ const handle = (await Reflect.apply(nativeFs.open, nativeFs, args)) as fs.FileHandle
+ if (armed && String(args[0]).endsWith(`${path.sep}source`)) {
+ armed = false
+ const read = handle.read.bind(handle)
+ vi.spyOn(handle, 'read').mockImplementationOnce(async (...readArgs: unknown[]) => {
+ entered()
+ await resumed
+ return Reflect.apply(read, handle, readArgs)
+ })
+ }
+ return handle
+ })
+ return { reached, resume }
+}
+
+/** White-box view of the pins: owner ids per caller. */
+function pinOwners(store: GfsDownloadStore): string[] {
+ const pins = (store as unknown as { pins: Map<string, Set<string>> }).pins
+ return [...pins.keys()].map(key => (JSON.parse(key) as [string, string]).join('/')).sort()
+}
+
+beforeEach(async () => {
+ nativeFs = await vi.importActual<typeof fs>('node:fs/promises')
+ vi.useFakeTimers({ toFake: ['Date'] })
+ vi.setSystemTime(new Date('2026-10-08T12:00:00.000Z'))
+ openBoundary.mockReset()
+ openBoundary.mockImplementation((...args: unknown[]) =>
+ Reflect.apply(nativeFs.open, nativeFs, args)
+ )
+ rmBoundary.mockReset()
+ rmBoundary.mockImplementation((...args: unknown[]) => Reflect.apply(nativeFs.rm, nativeFs, args))
+ statfsBoundary.mockReset()
+ hostRoot = syncFs.mkdtempSync(path.join(tmpdir(), 'gfs-store-trash-expiry-'))
+ // A 1000-byte volume at the default 85%: budget 850, per-caller cap 425,
+ // so only the free-space check can refuse the small admissions below.
+ coherentVolume(1000n, MARGIN + 20n)
+ rootA = callerDirectory(hostRoot, A)
+ rootB = callerDirectory(hostRoot, B)
+ rootC = callerDirectory(hostRoot, C)
+})
+
+afterEach(async () => {
+ for (const resume of releases.splice(0)) resume()
+ vi.restoreAllMocks()
+ vi.useRealTimers()
+ for (const opened of stores.splice(0)) await opened.close(0)
+ await nativeFs.rm(hostRoot, { recursive: true, force: true })
+})
+
+describe('GFS download store: expired copies never make the disk full (M1)', () => {
+ it('an admission refused as disk_full only because of an expired pinned copy is admitted, and the expired directory is gone', async () => {
+ const store = await openStore()
+ // 6 pinned bytes leave margin + 14 available.
+ const expiring = await completedCopy(store, rootA, A, 0, 6, { owner: 'task-a' })
+ const directory = downloadDirectory(rootA, expiring.receipt.id)
+ const diskDenied = await quotaCount('host', 'free_space')
+
+ // Witness: while the copy is live, 18 bytes do not fit (margin + 14 < margin + 18).
+ await expect(startTransfer(store, rootB, B, 1, 18)).rejects.toMatchObject({ code: 'disk_full' })
+ expect(await quotaCount('host', 'free_space')).toBe(diskDenied + 1)
+ expect(exists(directory)).toBe(true)
+
+ // Past its expiresAt, task-a still open: the admission sweep removes it first.
+ vi.setSystemTime(Date.now() + 2 * HOUR_MS)
+ const removedBefore = await expiryCount('expired_removed')
+ const admitted = await startTransfer(store, rootB, B, 1, 18)
+ expect(admitted.transfer.sizeBytes).toBe(18)
+ expect(await quotaCount('host', 'free_space')).toBe(diskDenied + 1)
+ expect(await expiryCount('expired_removed')).toBe(removedBefore + 1)
+ expect(exists(directory)).toBe(false)
+ await store.fail(admitted.transfer.id, B)
+ })
+
+ it('a disk truly full after the sweep refuses as disk_full and leaves live cached copies intact', async () => {
+ const store = await openStore()
+ // A live unpinned 6-byte copy for a day, and a pinned 6-byte copy for an
+ // hour: margin + 8 available.
+ const live = await completedCopy(store, rootA, A, 0, 6, {
+ expiresAt: new Date(Date.now() + 24 * HOUR_MS).toISOString(),
+ })
+ const expiring = await completedCopy(store, rootA, A, 1, 6, { owner: 'task-a' })
+ vi.setSystemTime(Date.now() + 2 * HOUR_MS)
+ const diskDenied = await quotaCount('host', 'free_space')
+ const removedBefore = await expiryCount('expired_removed')
+
+ // The sweep frees the expired 6 bytes (margin + 14), still short of
+ // margin + 16; evicting the live copy would make it fit, but no live copy
+ // is evicted before the free-space check.
+ await expect(startTransfer(store, rootB, B, 2, 16)).rejects.toMatchObject({ code: 'disk_full' })
+ expect(await quotaCount('host', 'free_space')).toBe(diskDenied + 1)
+ // Witness: the sweep ran before the refusal.
+ expect(await expiryCount('expired_removed')).toBe(removedBefore + 1)
+ expect(exists(downloadDirectory(rootA, expiring.receipt.id))).toBe(false)
+ expect(exists(downloadDirectory(rootA, live.receipt.id))).toBe(true)
+ await expect(store.readManagedFile(live.receipt.path, A)).resolves.toEqual(live.bytes)
+
+ // Witness: what the swept volume holds is admitted, beside the live copy.
+ const admitted = await startTransfer(store, rootB, B, 3, 14)
+ expect(exists(downloadDirectory(rootA, live.receipt.id))).toBe(true)
+ await store.fail(admitted.transfer.id, B)
+ })
+})
+
+describe('GFS download store: a copy left under a trash name stays charged (R5-F1)', () => {
+ it('SOL-R5-TRASH-CHARGE: expired pinned copies whose trash cannot be removed keep their charge until cleanup succeeds', async () => {
+ // 1% of a 1000 MiB volume: budget 10 MiB, caller cap 5 MiB; the free
+ // space always holds the 16 MiB margin, so only the budget can refuse.
+ coherentVolume(1000n * BigInt(MIB), 1000n * BigInt(MIB))
+ const store = await limitedStore({ MCP_HOST_GFS_DOWNLOAD_STORAGE_PERCENT: '1' })
+ const copyA = await completedCopy(store, rootA, A, 0, 4 * MIB, { owner: 'task-a' })
+ const copyB = await completedCopy(store, rootB, B, 1, 4 * MIB, { owner: 'task-b' })
+ vi.setSystemTime(Date.now() + 2 * HOUR_MS)
+ const trashRemovals: string[] = []
+ rmBoundary.mockImplementation((...args: unknown[]) => {
+ if (path.basename(String(args[0])).startsWith('.trash-')) {
+ trashRemovals.push(String(args[0]))
+ return Promise.reject(Object.assign(new Error('EIO: injected'), { code: 'EIO' }))
+ }
+ return Reflect.apply(nativeFs.rm, nativeFs, args)
+ })
+
+ // Both renames succeed and both removals fail: the old names are gone,
+ // the 8 MiB are on disk under trash names.
+ expect((await store.cleanupExpired()).removeFailed).toBe(2)
+ expect(trashRemovals).toHaveLength(2)
+ expect(exists(downloadDirectory(rootA, copyA.receipt.id))).toBe(false)
+ expect(exists(downloadDirectory(rootB, copyB.receipt.id))).toBe(false)
+ expect(trashIn(rootA)).toHaveLength(1)
+ expect(trashIn(rootB)).toHaveLength(1)
+ expect(storedSourceBytes(hostRoot)).toBe(8 * MIB)
+
+ // 8 MiB on disk + 4 MiB requested > 10 MiB: refused while the trash
+ // remains, after the admission sweep failed to remove it again (each
+ // retry renames it to a new trash name, and the charge follows).
+ await expect(startTransfer(store, rootC, C, 2, 4 * MIB)).rejects.toMatchObject({
+ code: 'host_quota_exceeded',
+ })
+ expect(trashRemovals).toHaveLength(4)
+ // The bytes moved to new trash names; the first ones no longer exist.
+ const names = (targets: string[]) => targets.map(target => path.basename(target)).sort()
+ expect([...trashIn(rootA), ...trashIn(rootB)].sort()).toEqual(names(trashRemovals.slice(2)))
+ for (const first of trashRemovals.slice(0, 2)) expect(exists(first)).toBe(false)
+ expect(storedSourceBytes(hostRoot)).toBe(8 * MIB)
+
+ // A second failed cleanup still keeps the charge.
+ expect((await store.cleanupExpired()).removeFailed).toBe(2)
+ await expect(startTransfer(store, rootC, C, 2, 4 * MIB)).rejects.toMatchObject({
+ code: 'host_quota_exceeded',
+ })
+
+ // Fault cleared: the cleanup removes both trash directories and the same
+ // admission succeeds.
+ rmBoundary.mockImplementation((...args: unknown[]) =>
+ Reflect.apply(nativeFs.rm, nativeFs, args)
+ )
+ expect((await store.cleanupExpired()).removedIncomplete).toBe(2)
+ expect(trashIn(rootA)).toHaveLength(0)
+ expect(trashIn(rootB)).toHaveLength(0)
+ expect(storedSourceBytes(hostRoot)).toBe(0)
+ const admitted = await startTransfer(store, rootC, C, 2, 4 * MIB)
+ expect(admitted.transfer.sizeBytes).toBe(4 * MIB)
+ await store.fail(admitted.transfer.id, C)
+ })
+})
+
+describe('GFS download store: reuse that crosses expiry while hashing (R5-F2)', () => {
+ it('SOL-R5-REUSE-CROSS-EXPIRY: a copy that expires while it is hashed is a cache miss and gets no pin', async () => {
+ coherentVolume(1000n, MARGIN + 1000n)
+ const store = await openStore()
+ const held = await completedCopy(store, rootA, A, 0, 30, { owner: 'task-a' })
+ // Witness: before expiry the copy is reused and pinned for task-b.
+ await expect(
+ store.reusableReceipt(A, sourceFor(0), 30, { retentionOwnerId: 'task-b' })
+ ).resolves.toMatchObject({ id: held.receipt.id })
+ expect(pinOwners(store)).toEqual([`${A}/task-a`, `${A}/task-b`])
+
+ vi.setSystemTime(Date.parse(held.receipt.expiresAt) - 1)
+ const gate = pauseNextSourceRead()
+ const reusing = store.reusableReceipt(A, sourceFor(0), 30, {
+ retentionOwnerId: 'task-c',
+ deadlineMs: Date.now() + 60_000,
+ signal: new AbortController().signal,
+ })
+ // Witness: the hash read was reached before expiry and paused there.
+ await gate.reached
+ vi.setSystemTime(Date.parse(held.receipt.expiresAt))
+ gate.resume()
+
+ await expect(reusing).resolves.toBeUndefined()
+ expect(pinOwners(store)).toEqual([`${A}/task-a`, `${A}/task-b`])
+ await expect(store.readManagedFile(held.receipt.path, A)).rejects.toMatchObject({
+ code: 'download_expired',
+ })
+
+ // Witness: the sweep removes the expired copy and a fresh one for
+ // task-c is published, pinned and served.
+ expect((await store.cleanupExpired()).removedExpired).toBe(1)
+ const fresh = await completedCopy(store, rootA, A, 0, 30, { owner: 'task-c' })
+ expect(pinOwners(store)).toEqual([`${A}/task-c`])
+ await expect(store.readManagedFile(fresh.receipt.path, A)).resolves.toEqual(fresh.bytes)
+ })
+})
diff --git a/mcp-host/src/internalTools/gfsManagedImage.test.ts b/mcp-host/src/internalTools/gfsManagedImage.test.ts
index 7a4921242..63ccb2534 100644
--- a/mcp-host/src/internalTools/gfsManagedImage.test.ts
+++ b/mcp-host/src/internalTools/gfsManagedImage.test.ts
@@ -353,9 +353,11 @@ describe('GFS download store errors at the tool boundary', () => {
'limit_exceeded',
'publication_cancelled',
'storage_write_failed',
+ 'volume_unmeasurable',
'workspace_unavailable',
]
- // Only the two space refusals carry guidance, as an exact second line.
+ // Only the two space refusals carry guidance, as an exact second line; an
+ // unmeasurable volume is the bare envelope.
const toolError = (code: GfsDownloadStoreErrorCode): string =>
code === 'disk_full'
? `GFS download store failed (disk_full)\n${GFS_DISK_FULL_GUIDANCE}`
diff --git a/mcp-host/src/internalTools/gfsSpaceGuidance.ts b/mcp-host/src/internalTools/gfsSpaceGuidance.ts
index a0e6d2961..4b9788042 100644
--- a/mcp-host/src/internalTools/gfsSpaceGuidance.ts
+++ b/mcp-host/src/internalTools/gfsSpaceGuidance.ts
@@ -3,7 +3,8 @@ import type { GfsDownloadStoreErrorCode } from './gfsDownloadStore'
/**
* Fixed model-facing guidance for the two space refusals of the GFS download
* store. Both texts are constants: they carry no size, count, path or caller
- * identity, so they cannot reveal whose files use the space.
+ * identity, so they cannot reveal whose files use the space. An unmeasurable
+ * volume (`volume_unmeasurable`) carries no guidance: no user action helps.
*/
export const GFS_DISK_FULL_GUIDANCE =
'The Host workspace disk is full, so the file was not downloaded. Tell the user. ' +
@@ -12,12 +13,14 @@ export const GFS_DISK_FULL_GUIDANCE =
'no longer need with a shell_exec command they approve. Never list, read or delete ' +
"another user's directory or anything outside the workspace."
+// The store evicts every copy no running task protects before it refuses, so
+// deleting downloaded copies by hand cannot admit the download; only tasks
+// finishing (or being cancelled) and copies expiring free that space.
export const GFS_CACHE_FULL_GUIDANCE =
"The Host's cache of downloaded files is full, so the file was not downloaded. " +
- 'Space frees as other tasks finish and cached copies expire. Tell the user. ' +
- 'They may delete their own downloaded copies under .gfs-downloads in their workspace ' +
- 'that no running task is using, with a shell_exec command they approve; a task that ' +
- "still needs a deleted copy downloads it again. Never delete another user's copies."
+ 'Space frees as tasks finish and downloaded copies expire. Tell the user. ' +
+ 'They can finish or cancel their own running tasks to free space sooner, then try again. ' +
+ "Never act on another user's tasks or files."
/** The guidance a store refusal carries to the model, if it has one. */
export function gfsStoreSpaceGuidance(code: GfsDownloadStoreErrorCode): string | undefined {
diff --git a/scripts/ci/pinned-vitest-cases/mcp-host.json b/scripts/ci/pinned-vitest-cases/mcp-host.json
index 4b6a57fad..4d841979b 100644
--- a/scripts/ci/pinned-vitest-cases/mcp-host.json
+++ b/scripts/ci/pinned-vitest-cases/mcp-host.json
@@ -683,10 +683,6 @@
"suite": "gfsDownloadStoreAdversarial.test.ts",
"fullName": "GFS download store adversarial round: trash, eviction and undo (ADV-2/F2/F3/F8) a removal of a directory that never existed is not counted as removed"
},
- {
- "suite": "gfsDownloadStoreAdversarial.test.ts",
- "fullName": "GFS download store adversarial round: trash, eviction and undo (ADV-2/F2/F3/F8) a sweep keeps an incomplete entry indexed until its removal succeeds"
- },
{
"suite": "gfsDownloadStoreAdversarial.test.ts",
"fullName": "GFS download store adversarial round: expiry, close, recency and removal proof S17: createTransfer refuses an expiry at or before its creation instant"
@@ -791,18 +787,6 @@
"suite": "gfsDownloadStoreBudget.test.ts",
"fullName": "GFS download store budget: share of the workspace volume BUD-4: a large volume is sized in bigint without rounding"
},
- {
- "suite": "gfsDownloadStoreBudget.test.ts",
- "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a zero block size' refuses with free_space"
- },
- {
- "suite": "gfsDownloadStoreBudget.test.ts",
- "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a zero block count' refuses with free_space"
- },
- {
- "suite": "gfsDownloadStoreBudget.test.ts",
- "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a negative block count' refuses with free_space"
- },
{
"suite": "gfsDownloadStoreBudget.test.ts",
"fullName": "GFS download store budget: no per-caller storage or file-count limit BUD-6: one caller fills the whole budget with 18 files of 16 MiB and another caller evicts its least recently used copy"
@@ -943,10 +927,6 @@
"suite": "gfsDownloadStoreBudget.test.ts",
"fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-1: a full disk refuses as disk_full while a full budget still refuses as host_quota_exceeded"
},
- {
- "suite": "gfsDownloadStoreBudget.test.ts",
- "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-2: statfs reporting a negative available-block count keeps host_quota_exceeded, not disk_full"
- },
{
"suite": "gfsDownloadStoreBudget.test.ts",
"fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-3: 'one byte above the file limit' is refused as limit_exceeded without a space metric"
@@ -1047,10 +1027,6 @@
"suite": "turnContext.test.ts",
"fullName": "prepared GFS receipts tells the model the workspace disk is full and to offer a cleanup of the caller workspace only"
},
- {
- "suite": "turnContext.test.ts",
- "fullName": "prepared GFS receipts tells the model the download cache is full and that only the caller may delete its own copies"
- },
{
"suite": "turnContext.test.ts",
"fullName": "prepared GFS receipts keeps the two space guidances distinct from each other"
@@ -1062,5 +1038,93 @@
{
"suite": "turnContext.test.ts",
"fullName": "prepared GFS receipts adds each space guidance once for several refusals and none for other codes"
+ },
+ {
+ "suite": "gfsDownloadStoreAdversarial.test.ts",
+ "fullName": "GFS download store adversarial round: trash, eviction and undo (ADV-2/F2/F3/F8) a sweep keeps an incomplete entry charged, under its trash name, until its removal succeeds"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a zero block size' twice refuses as volume_unmeasurable with free_space"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a zero block count' twice refuses as volume_unmeasurable with free_space"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: share of the workspace volume BUD-5: statfs reporting 'a negative block count' twice refuses as volume_unmeasurable with free_space"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-2: statfs reporting a negative available-block count twice refuses as volume_unmeasurable, not disk_full or host_quota_exceeded"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-4: one statfs reading with 'a zero block size' is measured again and a valid second reading admits"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-4: one statfs reading with 'a zero block count' is measured again and a valid second reading admits"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-4: one statfs reading with 'a negative block count' is measured again and a valid second reading admits"
+ },
+ {
+ "suite": "gfsDownloadStoreBudget.test.ts",
+ "fullName": "GFS download store budget: a full disk and a full cache are distinct refusals DSK-4: one statfs reading with 'a negative available-block count' is measured again and a valid second reading admits"
+ },
+ {
+ "suite": "gfsDownloadStoreProtected.test.ts",
+ "fullName": "GFS download store: retention pins never outlive expiresAt (Addendum 10) an expired copy still on disk is not reused"
+ },
+ {
+ "suite": "gfsDownloadStoreTrashAndExpiry.test.ts",
+ "fullName": "GFS download store: expired copies never make the disk full (M1) an admission refused as disk_full only because of an expired pinned copy is admitted, and the expired directory is gone"
+ },
+ {
+ "suite": "gfsDownloadStoreTrashAndExpiry.test.ts",
+ "fullName": "GFS download store: expired copies never make the disk full (M1) a disk truly full after the sweep refuses as disk_full and leaves live cached copies intact"
+ },
+ {
+ "suite": "gfsDownloadStoreTrashAndExpiry.test.ts",
+ "fullName": "GFS download store: a copy left under a trash name stays charged (R5-F1) SOL-R5-TRASH-CHARGE: expired pinned copies whose trash cannot be removed keep their charge until cleanup succeeds"
+ },
+ {
+ "suite": "gfsDownloadStoreTrashAndExpiry.test.ts",
+ "fullName": "GFS download store: reuse that crosses expiry while hashing (R5-F2) SOL-R5-REUSE-CROSS-EXPIRY: a copy that expires while it is hashed is a cache miss and gets no pin"
+ },
+ {
+ "suite": "gfsManagedImage.test.ts",
+ "fullName": "GFS download store errors at the tool boundary surfaces store code volume_unmeasurable to the model"
+ },
+ {
+ "suite": "gfsManagedImage.test.ts",
+ "fullName": "GFS download store errors at the tool boundary surfaces download admission code volume_unmeasurable to the model"
+ },
+ {
+ "suite": "gfsFilePreparation.test.ts",
+ "fullName": "GFS file preparation maps the bare volume_unmeasurable envelope to its fixed category"
+ },
+ {
+ "suite": "gfsFilePreparation.test.ts",
+ "fullName": "GFS file preparation maps the volume_unmeasurable envelope with the cache guidance to its fixed category"
+ },
+ {
+ "suite": "gfsFilePreparation.test.ts",
+ "fullName": "GFS file preparation maps the volume_unmeasurable envelope with the disk guidance to its fixed category"
+ },
+ {
+ "suite": "gfsFilePreparation.test.ts",
+ "fullName": "GFS file preparation maps the volume_unmeasurable envelope with an untrusted second line to its fixed category"
+ },
+ {
+ "suite": "turnContext.test.ts",
+ "fullName": "prepared GFS receipts tells the model the download cache is full and that the user can only finish or cancel their own tasks, with no offer to delete copies"
+ },
+ {
+ "suite": "turnContext.test.ts",
+ "fullName": "prepared GFS receipts renders an unmeasurable volume without any guidance line"
}
]