Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(hcc): refuse an unlistable workspace before the layout merge moves anything
Alfredo Lopez2275a91d89d5
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 1b37d4bc0..af0244469 100644--- a/host-context-controller/package-lock.json+++ b/host-context-controller/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-host-context-controller",- "version": "0.1.389",+ "version": "0.1.390","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.389",+ "version": "0.1.390","license": "SEE LICENSE IN LICENSE","dependencies": {"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",diff --git a/host-context-controller/package.json b/host-context-controller/package.jsonindex a9bf36b0e..e2170dab1 100644--- a/host-context-controller/package.json+++ b/host-context-controller/package.json@@ -1,6 +1,6 @@{"name": "clerum-host-context-controller",- "version": "0.1.389",+ "version": "0.1.390","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/src/statelessDeployment.ts b/host-context-controller/src/statelessDeployment.tsindex 456437990..55f31d019 100644--- a/host-context-controller/src/statelessDeployment.ts+++ b/host-context-controller/src/statelessDeployment.ts@@ -35,8 +35,8 @@ function shellSingleQuote(value: string): string {* agent can create those on a stateful Host, so they must not stop it).** Every refusal prints one line and exits 1 before the first move:- * F1 `workspace` is a symlink or not a directory, a real `state/`- * cannot be listed and searched, a `state.db*` entry is a+ * F1 `workspace` is a symlink or not a directory, a real `state/` or a+ * present `workspace/` cannot be listed and searched, a `state.db*` entry is a* symlink or not a regular file, or a directory that decides a* collision cannot be listed;* F2 more than one live database (a `state.db` main file or its journals)@@ -108,6 +108,9 @@ assert_managed_dir "$root/state" stateworkspace_present=0if present "$root/workspace"; thenassert_managed_dir "$root/workspace" workspace+ # The move globs cannot see the entries of a workspace/ they cannot list.+ [ -r "$root/workspace" ] && [ -x "$root/workspace" ] ||+ fail_merge "workspace directory is not readable and searchable: $root/workspace"workspace_present=1fifor dir in "$root" "$root/state" "$root/workspace"; dodiff --git a/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts b/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.tsindex 6963de3b6..bb1f4e809 100644--- a/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts+++ b/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts@@ -351,6 +351,33 @@ describe('workspace layout merge', () => {15_000)+ // A workspace/ that can be entered and written but not listed hides its+ // entries from the globs: without this check the state files and state.db+ // would move, `rmdir workspace` would fail, and the next start (no+ // signature left) would exit 0 with the files stranded under workspace/.+ it.each(['333', '300'])(+ 'refuses a workspace/ directory with mode %s before the first move',+ mode => {+ const root = splitRoot()+ const before = snapshot(root)+ chmodSync(join(root, 'workspace'), parseInt(mode, 8))++ const refused = merge(root)++ chmodSync(join(root, 'workspace'), 0o755)+ expect(refused.status).toBe(1)+ expect(refused.stderr.trim()).toBe(+ `workspace layout merge refused: workspace directory is not readable and searchable: ${root}/workspace`+ )+ expect(snapshot(root)).toEqual(before)+ // Witness: with its mode restored the same tree merges.+ expect(merge(root).status).toBe(0)+ expect(messageCount(join(root, 'state.db'))).toEqual({ rows: ROWS, check: 'ok' })+ expect(readdirSync(root)).not.toContain('workspace')+ },+ 15_000+ )+it('refuses before the first move when a source directory cannot be listed', () => {const root = splitRoot()mkdirSync(join(root, 'cache'))