Context
PR #1325 (issue #1323) introduced a global vitest harness that sandboxes user-global side effects reachable from test suites: the agy binary (CODEV_AGY_BIN) and the consult metrics DB (CODEV_METRICS_DB). During integration review, the remaining unpinnable user-global surface was identified: ~/.agent-farm/global.db.
Problem
AGENT_FARM_DIR (packages/core/src/constants.ts:5) is a module-load-time resolve(homedir(), '.agent-farm') with no environment override. Any in-process test that touches agent-farm state reads/writes the developer's real global.db, and the #1325 harness has no lever to redirect it.
This is the same failure-of-omission shape #1323 fixed for agy/metrics: safety currently depends on every test remembering not to touch agent-farm paths.
Proposed fix
- Add an env override (e.g.
CODEV_AGENT_FARM_DIR) honoured at the AGENT_FARM_DIR definition. Note it is a module-load-time constant — the override must be read at import time, which the vitest harness's setupFiles ordering already satisfies; document that constraint.
- Pin it to the per-run sandbox in
packages/codev/vitest-setup.ts alongside the existing agy/metrics pins.
- Optional belt-and-braces: refuse to open the real global.db under a test runner without the override, mirroring
resolveDbPath() in metrics.ts.
Origin
Raised by the claude integration-review lane on PR #1325; filed by the architect so #1325 ships without scope growth.
Related
Context
PR #1325 (issue #1323) introduced a global vitest harness that sandboxes user-global side effects reachable from test suites: the agy binary (
CODEV_AGY_BIN) and the consult metrics DB (CODEV_METRICS_DB). During integration review, the remaining unpinnable user-global surface was identified:~/.agent-farm/global.db.Problem
AGENT_FARM_DIR(packages/core/src/constants.ts:5) is a module-load-timeresolve(homedir(), '.agent-farm')with no environment override. Any in-process test that touches agent-farm state reads/writes the developer's real global.db, and the #1325 harness has no lever to redirect it.This is the same failure-of-omission shape #1323 fixed for agy/metrics: safety currently depends on every test remembering not to touch agent-farm paths.
Proposed fix
CODEV_AGENT_FARM_DIR) honoured at theAGENT_FARM_DIRdefinition. Note it is a module-load-time constant — the override must be read at import time, which the vitest harness'ssetupFilesordering already satisfies; document that constraint.packages/codev/vitest-setup.tsalongside the existing agy/metrics pins.resolveDbPath()inmetrics.ts.Origin
Raised by the claude integration-review lane on PR #1325; filed by the architect so #1325 ships without scope growth.
Related