@@ -6,7 +6,7 @@ import os from "node:os";
66import path from "node:path" ;
77import { test } from "node:test" ;
88import { FileAutoresearchBridgePreparer } from "../src/adapters/autoresearch-bridge.js" ;
9- import { FileKapiStore } from "../src/adapters/file-store.js" ;
9+ import { FileWorkflowStore } from "../src/adapters/file-store.js" ;
1010import { createWorkflowState } from "../src/domain/state-machine.js" ;
1111
1212const execFileAsync = promisify ( execFile ) ;
@@ -32,7 +32,7 @@ test("retired autoresearch bridge cleans Kapi-owned project-root artifacts", asy
3232 try {
3333 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
3434 await execFileAsync ( "git" , [ "init" ] , { cwd : workspace } ) ;
35- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
35+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
3636 await symlink ( path . relative ( workspace , path . join ( state . artifactRoot , "contract.md" ) ) , path . join ( workspace , "autoresearch.md" ) ) ;
3737 await symlink ( path . relative ( workspace , path . join ( state . artifactRoot , "benchmark.sh" ) ) , path . join ( workspace , "autoresearch.sh" ) ) ;
3838 await symlink ( path . relative ( workspace , path . join ( state . artifactRoot , "ledger.jsonl" ) ) , path . join ( workspace , "autoresearch.jsonl" ) ) ;
@@ -60,7 +60,7 @@ test("retired autoresearch bridge leaves user-owned root files untouched", async
6060 const workspace = await mkdtemp ( path . join ( os . tmpdir ( ) , "kapi-autoresearch-retired-user-owned-" ) ) ;
6161 try {
6262 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
63- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
63+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
6464 await writeFile ( path . join ( workspace , "autoresearch.md" ) , "user contract\n" , "utf8" ) ;
6565 await writeFile ( path . join ( workspace , "autoresearch.config.json" ) , "{\"maxIterations\":1}\n" , "utf8" ) ;
6666
@@ -78,7 +78,7 @@ test("retired autoresearch bridge leaves external gitdir excludes untouched", as
7878 const externalGitDir = await mkdtemp ( path . join ( os . tmpdir ( ) , "kapi-autoresearch-external-gitdir-" ) ) ;
7979 try {
8080 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
81- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
81+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
8282 await mkdir ( path . join ( externalGitDir , "info" ) , { recursive : true } ) ;
8383 await writeFile ( path . join ( workspace , ".git" ) , `gitdir: ${ externalGitDir } \n` , "utf8" ) ;
8484 await writeFile ( path . join ( externalGitDir , "info" , "exclude" ) , "/autoresearch.md\n/keep-external\n" , "utf8" ) ;
@@ -97,7 +97,7 @@ test.skip("autoresearch bridge records project-root links in git exclude when wo
9797 try {
9898 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
9999 await execFileAsync ( "git" , [ "init" ] , { cwd : workspace } ) ;
100- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
100+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
101101
102102 await new FileAutoresearchBridgePreparer ( ) . prepare ( state ) ;
103103
@@ -115,7 +115,7 @@ test.skip("autoresearch bridge refuses repo-like workspaces when git probing fai
115115 const workspace = await mkdtemp ( path . join ( os . tmpdir ( ) , "kapi-autoresearch-broken-git-" ) ) ;
116116 try {
117117 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ; await writeFile ( path . join ( workspace , ".git" ) , "gitdir: ../missing-gitdir\n" , "utf8" ) ;
118- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
118+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
119119 await assert . rejects ( new FileAutoresearchBridgePreparer ( ) . prepare ( state ) , / C a n n o t v e r i f y g i t w o r k t r e e s t a t e / ) ;
120120 } finally {
121121 await rm ( workspace , { recursive : true , force : true } ) ;
@@ -128,7 +128,7 @@ test.skip("autoresearch bridge refuses symlinked durable source artifacts", asyn
128128 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
129129 const contract = path . join ( state . artifactRoot , "contract.md" ) ;
130130 const outside = path . join ( workspace , "outside-contract.md" ) ;
131- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
131+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
132132 await unlink ( contract ) ;
133133 await writeFile ( outside , "outside" , "utf8" ) ;
134134 await symlink ( outside , contract ) ;
@@ -149,7 +149,7 @@ test.skip("autoresearch bridge refuses to overwrite user-owned project-root file
149149 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
150150 const rootFile = path . join ( workspace , "autoresearch.md" ) ;
151151 await writeFile ( rootFile , "user owned" , "utf8" ) ;
152- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
152+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
153153
154154 await assert . rejects (
155155 new FileAutoresearchBridgePreparer ( ) . prepare ( state ) ,
@@ -168,7 +168,7 @@ test.skip("autoresearch bridge refuses to overwrite user-owned project-root syml
168168 const userTarget = path . join ( workspace , "user-autoresearch.md" ) ;
169169 await writeFile ( userTarget , "user owned" , "utf8" ) ;
170170 await symlink ( path . basename ( userTarget ) , path . join ( workspace , "autoresearch.md" ) ) ;
171- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
171+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
172172
173173 await assert . rejects (
174174 new FileAutoresearchBridgePreparer ( ) . prepare ( state ) ,
@@ -184,7 +184,7 @@ test.skip("autoresearch bridge retargets stale Kapi-owned project-root symlinks"
184184 const workspace = await mkdtemp ( path . join ( os . tmpdir ( ) , "kapi-autoresearch-retarget-" ) ) ;
185185 try {
186186 const bridge = new FileAutoresearchBridgePreparer ( ) ;
187- const store = new FileKapiStore ( ) ;
187+ const store = new FileWorkflowStore ( ) ;
188188 const oldState = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize old" , workspace, slug : "old" , now : "2026-05-04T00:00:00.000Z" } ) ;
189189 const newState = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize new" , workspace, slug : "new" , now : "2026-05-04T00:00:01.000Z" } ) ;
190190 await store . ensureArtifacts ( oldState ) ;
@@ -204,7 +204,7 @@ test.skip("autoresearch bridge removes stale Kapi-owned root links that are no l
204204 try {
205205 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
206206 const staleRoot = path . join ( state . artifactRoot , "autoresearch.config.json" ) ;
207- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
207+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
208208 await writeFile ( staleRoot , "{}\n" , "utf8" ) ;
209209 await symlink ( path . relative ( workspace , staleRoot ) , path . join ( workspace , "autoresearch.config.json" ) ) ;
210210
@@ -222,7 +222,7 @@ test.skip("autoresearch bridge refuses user-owned runtime config", async () => {
222222 try {
223223 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
224224 await writeFile ( path . join ( workspace , "autoresearch.config.json" ) , "{\"artifactRoot\":\"elsewhere\"}\n" , "utf8" ) ;
225- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
225+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
226226
227227 await assert . rejects ( new FileAutoresearchBridgePreparer ( ) . prepare ( state ) , / a u t o r e s e a r c h \. c o n f i g \. j s o n a l r e a d y e x i s t s a n d i s n o t K a p i - m a n a g e d / ) ;
228228 await writeFile ( path . join ( workspace , "autoresearch.config.json" ) , `{"$comment":"Kapi-managed pi-autoresearch bridge config","artifactRoot":"elsewhere"}\n` , "utf8" ) ;
@@ -240,7 +240,7 @@ test.skip("autoresearch bridge refuses symlinked runtime config", async () => {
240240 const external = path . join ( externalRoot , "autoresearch.config.json" ) ;
241241 await writeFile ( external , `{"$comment":"Kapi-managed pi-autoresearch bridge config"}\n` , "utf8" ) ;
242242 await symlink ( external , path . join ( workspace , "autoresearch.config.json" ) ) ;
243- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
243+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
244244
245245 await assert . rejects ( new FileAutoresearchBridgePreparer ( ) . prepare ( state ) , / a u t o r e s e a r c h \. c o n f i g \. j s o n m u s t n o t b e a s y m l i n k / ) ;
246246 assert . match ( await readFile ( external , "utf8" ) , / K a p i - m a n a g e d p i - a u t o r e s e a r c h b r i d g e c o n f i g / ) ;
@@ -256,7 +256,7 @@ test.skip("autoresearch bridge blocks dirty pre-existing git candidate changes",
256256 await execFileAsync ( "git" , [ "init" ] , { cwd : workspace } ) ;
257257 await writeFile ( path . join ( workspace , "tracked.txt" ) , "dirty\n" , "utf8" ) ;
258258 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
259- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
259+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
260260
261261 await assert . rejects ( new FileAutoresearchBridgePreparer ( ) . prepare ( state ) , / d i r t y p r e - e x i s t i n g w o r k t r e e .* t r a c k e d \. t x t / ) ;
262262 } finally {
@@ -268,7 +268,7 @@ test.skip("autoresearch bridge links project-root pi-autoresearch files to durab
268268 const workspace = await mkdtemp ( path . join ( os . tmpdir ( ) , "kapi-autoresearch-bridge-" ) ) ;
269269 try {
270270 const state = createWorkflowState ( { workflowId : "kapi-autoresearch" , task : "Optimize benchmark" , workspace, slug : "bench" , now : "2026-05-04T00:00:00.000Z" } ) ;
271- await new FileKapiStore ( ) . ensureArtifacts ( state ) ;
271+ await new FileWorkflowStore ( ) . ensureArtifacts ( state ) ;
272272
273273 const notes = await new FileAutoresearchBridgePreparer ( ) . prepare ( state ) ;
274274
0 commit comments