Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(hcc): pin the exit-0 contract for split trees without a real workspace
Alfredo Lopez785b6a38dd66
diff --git a/docs/architecture/host-storage-layout.md b/docs/architecture/host-storage-layout.mdindex e81de9838..31b03f322 100644--- a/docs/architecture/host-storage-layout.md+++ b/docs/architecture/host-storage-layout.md@@ -94,6 +94,23 @@ Two agent-made folder pairs on a stateful Host do stop it from starting:In both cases the operator renames the folder from a helper Pod.+A split tree whose `workspace` is missing, a symlink or a regular file also+carries no signature, because the earlier init always leaves a real+`workspace/` directory. The merge exits 0 and changes nothing; mcp-host then+finds no `state.db` at the root and creates an empty one, while the history+stays in `state/state.db`. No dev or prod Host had this tree when #825 shipped+(all five dev stateless roots had a real `workspace/`; prod had no stateless+Host). Recovery, with the Host stopped and the PVC mounted in a helper Pod:++1. restore `workspace` as a real directory (move the symlink target or the+ file aside and `mkdir workspace`);+2. if mcp-host already created a root `state.db`, rename the root+ `state.db`, `state.db-wal` and `state.db-shm` to `state.db.<label>.bak`+ names, or the next start refuses with F2 (two live databases). Chats+ written to that database stay in the backup;+3. start the Host: the signature holds and the merge moves the history to+ the root.+**Moves**, in this order:1. every entry of `workspace/`, dotfiles and symlinks included, to the rootdiff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.jsonindex 8bfacf3be..62d2d01a8 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.393",+ "version": "0.1.394","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-host-context-controller",- "version": "0.1.393",+ "version": "0.1.394","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 2946c2a43..30e935205 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.393",+ "version": "0.1.394","description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API","main": "dist/main.js","engines": {diff --git a/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts b/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.tsindex cc62502e8..a47ec924f 100644--- a/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts+++ b/host-context-controller/test/statelessDeployment.workspaceLayoutMerge.test.ts@@ -642,6 +642,41 @@ describe('workspace layout merge', () => {expect(snapshot(split)).not.toEqual(splitBefore)}, 30_000)+ // The base init always leaves a real workspace/ directory. A split tree+ // without one carries no signature: the merge leaves it for an operator+ // (docs/architecture/host-storage-layout.md) rather than adopting it.+ it('leaves a split tree whose workspace/ is missing, a symlink or a file unchanged', () => {+ const cases: Record<string, (root: string) => void> = {+ 'workspace/ is missing': root => {+ rmSync(join(root, 'workspace'), { recursive: true })+ },+ 'workspace is a symlink': root => {+ renameSync(join(root, 'workspace'), join(root, 'workspace-real'))+ symlinkSync(join(root, 'workspace-real'), join(root, 'workspace'))+ },+ 'workspace is a regular file': root => {+ renameSync(join(root, 'workspace'), join(root, 'workspace-real'))+ writeFileSync(join(root, 'workspace'), 'not a directory')+ },+ }+ for (const [name, prepare] of Object.entries(cases)) {+ const root = splitRoot()+ prepare(root)+ const before = snapshot(root)+ expect.soft(merge(root), name).toEqual({ status: 0, stderr: '' })+ expect.soft(snapshot(root), name).toEqual(before)+ // The history stays where the base init put it.+ expect.soft(messageCount(join(root, 'state', 'state.db')), name).toEqual({+ rows: ROWS,+ check: 'ok',+ })+ }+ // Witness: an intact split tree is merged by the same script.+ const split = splitRoot()+ expect(merge(split)).toEqual({ status: 0, stderr: '' })+ expect(messageCount(join(split, 'state.db'))).toEqual({ rows: ROWS, check: 'ok' })+ }, 30_000)+it('restores the merged tree after a rollback re-splits it with the base init', () => {const root = splitRoot()expect(merge(root).status).toBe(0)