fix(FN-2155): require explicit store rootDir in tests
- Add constructor guards in AgentStore and ReflectionStore that throw when rootDir is omitted under Vitest - Keep default .fusion root resolution for non-test execution paths - Prevent accidental test writes to unintended filesystem locations by forcing explicit paths
This commit is contained in:
@@ -134,6 +134,13 @@ export class AgentStore extends EventEmitter {
|
||||
|
||||
constructor(options: AgentStoreOptions = {}) {
|
||||
super();
|
||||
|
||||
if (!options.rootDir && process.env.VITEST === "true") {
|
||||
throw new Error(
|
||||
"AgentStore requires an explicit rootDir during test execution. Pass an absolute path to avoid writing to unintended locations.",
|
||||
);
|
||||
}
|
||||
|
||||
this.rootDir = options.rootDir ?? resolve(".fusion");
|
||||
this.agentsDir = join(this.rootDir, "agents");
|
||||
this.taskStore = options.taskStore;
|
||||
|
||||
@@ -63,6 +63,13 @@ export class ReflectionStore extends EventEmitter {
|
||||
|
||||
constructor(options: ReflectionStoreOptions = {}) {
|
||||
super();
|
||||
|
||||
if (!options.rootDir && process.env.VITEST === "true") {
|
||||
throw new Error(
|
||||
"ReflectionStore requires an explicit rootDir during test execution. Pass an absolute path to avoid writing to unintended locations.",
|
||||
);
|
||||
}
|
||||
|
||||
this.rootDir = options.rootDir ?? resolve(".fusion");
|
||||
this.agentsDir = join(this.rootDir, "agents");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user