Skip to content

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

TypeScript

fix(mcp-host): keep the free-space share on a deployed Host's node disk

marcoteb9fda25aedea8
diff --git a/mcp-host/src/core/tools/__tests__/generatedOutputsPrivacy.test.ts b/mcp-host/src/core/tools/__tests__/generatedOutputsPrivacy.test.ts
index fbc46ed8a..a03b6bd4f 100644
--- a/mcp-host/src/core/tools/__tests__/generatedOutputsPrivacy.test.ts
+++ b/mcp-host/src/core/tools/__tests__/generatedOutputsPrivacy.test.ts
@@ -268,15 +268,34 @@ describe('generated documents are private to their caller', () => {
expect(fs.readdirSync(outputsOf(a))).toEqual(['kept.md'])
})
- it('keeps only the minimum free space on a disk the Host shares with the root', async () => {
+ it('keeps only the minimum free space on the root disk in development', async () => {
const a = rootOf('user-a')
- volume.mode = 'busy-shared'
- expect((await markdown(a, 'shared.md', '# fine\n')).is_error).toBe(false)
- // The same reading on a volume of the Host's own keeps its 15%.
- volume.mode = 'busy-own'
- const refused = await markdown(a, 'own.md', '# refused\n')
- expect(refused.is_error).toBe(true)
- expect(refused.content).toMatch(/Not enough free space/)
+ vi.stubEnv('CLERUM_DEV_MODE', 'true')
+ try {
+ volume.mode = 'busy-shared'
+ expect((await markdown(a, 'shared.md', '# fine\n')).is_error).toBe(false)
+ // The same reading on a volume of the Host's own keeps its 15%.
+ volume.mode = 'busy-own'
+ const refused = await markdown(a, 'own.md', '# refused\n')
+ expect(refused.is_error).toBe(true)
+ expect(refused.content).toMatch(/Not enough free space/)
+ } finally {
+ vi.unstubAllEnvs()
+ }
+ })
+
+ it("keeps the volume's share on the node disk of a deployed Host", async () => {
+ // A local-path volume reports the node's root disk, as the root does.
+ const a = rootOf('user-a')
+ vi.stubEnv('CLERUM_DEV_MODE', '')
+ try {
+ volume.mode = 'busy-shared'
+ const refused = await markdown(a, 'node.md', '# refused\n')
+ expect(refused.is_error).toBe(true)
+ expect(refused.content).toMatch(/Not enough free space/)
+ } finally {
+ vi.unstubAllEnvs()
+ }
})
it('writes when the volume cannot be measured, and says so once', async () => {
diff --git a/mcp-host/src/workflow/artifactOutput.ts b/mcp-host/src/workflow/artifactOutput.ts
index df94c5542..bae21e911 100644
--- a/mcp-host/src/workflow/artifactOutput.ts
+++ b/mcp-host/src/workflow/artifactOutput.ts
@@ -393,14 +393,21 @@ function sharesRootVolume(space: fs.BigIntStatsFs): boolean {
let unmeasurableVolumeReported = false
+/** CLERUM_DEV_MODE, read as config.ts reads it. */
+function devMode(): boolean {
+ const value = process.env.CLERUM_DEV_MODE
+ return !!value && (value.toLowerCase() === 'true' || value === '1')
+}
+
/**
* Every caller's folder shares the Host volume, so their quotas together do
* not bound it: a write must leave the free space GFS keeps (freeSpaceFloor).
- * On a filesystem the Host does not have to itself, the root's, as in
- * development or on a hostPath volume, that share would be of the whole disk,
- * so only the minimum is kept there. Nothing is removed to make room. A
- * volume that cannot be measured does not refuse the write; that is logged
- * once.
+ * In development on the root's filesystem, the developer's own disk, that
+ * share would be of the whole disk, so only the minimum is kept there. A
+ * deployed Host keeps the share even on the node's disk (a local-path
+ * volume), where filling it would put the node under disk pressure. Nothing is
+ * removed to make room. A volume that cannot be measured does not refuse the
+ * write; that is logged once.
*/
function enforceFreeSpaceFloor(outputDir: string, incomingBytes: number): void {
let space: fs.BigIntStatsFs | undefined
@@ -420,7 +427,8 @@ function enforceFreeSpaceFloor(outputDir: string, incomingBytes: number): void {
return
}
const blocks = (BigInt(incomingBytes) + space.bsize - 1n) / space.bsize
- const floor = sharesRootVolume(space) ? FREE_SPACE_FLOOR_MIN_BYTES : freeSpaceFloor(space)
+ const floor =
+ devMode() && sharesRootVolume(space) ? FREE_SPACE_FLOOR_MIN_BYTES : freeSpaceFloor(space)
if (blocks * space.bsize + floor > space.bavail * space.bsize) {
const mb = (bytes: bigint) => (Number(bytes) / (1024 * 1024)).toFixed(1)
throw new Error(