Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): open meta.json before classifying its type
Alfredo Lopezbce40d1d1ee2
diff --git a/docs/operations/gfs-large-file-host-downloads.md b/docs/operations/gfs-large-file-host-downloads.mdindex 8defe2c1a..228756d57 100644--- a/docs/operations/gfs-large-file-host-downloads.md+++ b/docs/operations/gfs-large-file-host-downloads.md@@ -275,10 +275,11 @@ rename and its delete leaves behind and the next sweep removes.### What counts as a complete download-A directory is complete when `meta.json` is a regular file (checked with-`lstat` before it is opened, so a socket, FIFO, device, directory or symlink-makes the directory incomplete) of at most the metadata size limit, opens-without following a symlink, and parses as a schema-1+A directory is complete when `meta.json` opens without following a symlink+and without blocking, the opened descriptor is a regular file of at most the+metadata size limit (a FIFO, device or directory makes the directory+incomplete; a socket, which cannot be opened, is classified by `lstat` only+after the open failed), and it parses as a schema-1receipt for the directory's own ID; its source fields, size, digest and datesare well formed; the size is within the GFS admission limit; `expiresAt` is notbefore `createdAt` and not later than `createdAt` plus the retention period; anddiff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 0ad408cea..c6d00618c 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.552",+ "version": "0.1.553","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.552",+ "version": "0.1.553","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex a560ecc85..3d2893b68 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.552",+ "version": "0.1.553","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/internalTools/gfsDownloadStore.ts b/mcp-host/src/internalTools/gfsDownloadStore.tsindex 83b03abc7..4a1d0d2b9 100644--- a/mcp-host/src/internalTools/gfsDownloadStore.ts+++ b/mcp-host/src/internalTools/gfsDownloadStore.ts@@ -378,6 +378,24 @@ function stateFor(error: unknown): DirectoryState {: { state: 'unknown', code: errorCode(error) }}+/**+ * Only a regular file can be a receipt. Opening a socket fails with an errno+ * that is not definitive by itself (ENXIO on Linux; on macOS an EOPNOTSUPP that+ * Node reports as an unknown system error), which would keep the directory as+ * unknown forever; after such a failure the type of the name is the answer.+ * The type is read only after the open failed, so nothing is opened on the+ * strength of a check that may be stale.+ */+async function metaOpenFailureState(metaPath: string, error: unknown): Promise<DirectoryState> {+ if (isDefinitiveMismatch(error)) return { state: 'incomplete' }+ try {+ if (!(await fs.lstat(metaPath)).isFile()) return { state: 'incomplete' }+ } catch (lstatError) {+ return stateFor(lstatError)+ }+ return stateFor(error)+}+/** A removal is proven by ENOENT, not by `fs.rm` returning. */async function assertAbsent(target: string): Promise<void> {try {@@ -1512,14 +1530,6 @@ export class GfsDownloadStore {}if (!info.isDirectory()) return { state: 'incomplete' }const metaPath = path.join(directory, META_FILE)- try {- // Only a regular file can be a receipt. Opening a socket fails with an- // errno that is not definitive (ENXIO, EOPNOTSUPP), which would keep the- // directory as unknown forever; its type is the answer.- if (!(await fs.lstat(metaPath)).isFile()) return { state: 'incomplete' }- } catch (error) {- return stateFor(error)- }let raw: stringtry {// Anything in the tree may have been replaced from a shell. A FIFO with@@ -1538,7 +1548,7 @@ export class GfsDownloadStore {await handle.close()}} catch (error) {- return stateFor(error)+ return metaOpenFailureState(metaPath, error)}const meta = parseMeta(raw, id, now)if (!meta) return { state: 'incomplete' }