Skip to content

Commit d18da58

Browse files
byapparovclaude
andcommitted
test(run): tighten legacy-session checks after review (#181)
- fail on any shadow-dir stat error other than ENOENT instead of treating every readdir error as "no shadow repo" - assert the injected legacy snapshot hashes never reach the model request - drop "and snapshots" from the uninstall --keep-data description Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1ad70b7 commit d18da58

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎packages/cli/src/cli/cmd/uninstall.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const UninstallCommand = {
3636
.option("keep-data", {
3737
alias: "d",
3838
type: "boolean",
39-
describe: "keep session data and snapshots",
39+
describe: "keep session data",
4040
default: false,
4141
})
4242
.option("dry-run", {

‎packages/cli/test/cli/run-legacy-session.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ async function run(input: Fixture, args: string[]) {
114114

115115
const dataDir = (input: Fixture) => path.join(input.home, ".local/share", "aictrl")
116116

117+
/** Whether the removed subsystem's shadow repo dir exists; any error other than ENOENT fails the test. */
118+
async function shadowRepoExists(input: Fixture) {
119+
return fs.stat(path.join(dataDir(input), "snapshot")).then(
120+
() => true,
121+
(error: NodeJS.ErrnoException) => {
122+
if (error.code === "ENOENT") return false
123+
throw error
124+
},
125+
)
126+
}
127+
117128
const legacyDiff = { file: "out.txt", before: "", after: "out\n", additions: 1, deletions: 0, status: "added" }
118129

119130
/**
@@ -183,7 +194,7 @@ describe("snapshot removal (#181)", () => {
183194
expect(result.exit, result.output).toBe(0)
184195
expect(input.requests).toHaveLength(2)
185196
expect(await Bun.file(path.join(input.worktree, "out.txt")).exists()).toBe(true)
186-
expect(await fs.readdir(path.join(dataDir(input), "snapshot")).catch(() => [])).toEqual([])
197+
expect(await shadowRepoExists(input)).toBe(false)
187198
const steps = result.events.filter((event) => event.type === "step_finish")
188199
expect(steps, result.output).toHaveLength(2)
189200
expect(steps.map((event) => event.part.snapshot)).toEqual([undefined, undefined])
@@ -210,8 +221,11 @@ describe("snapshot removal (#181)", () => {
210221
const request = input.requests.at(-1)!
211222
expect(request).toContain("Write out.txt.")
212223
expect(request).toContain("Say done.")
224+
// Legacy hashes live only in the injected parts and fields, so they must never reach the model.
225+
expect(request).not.toContain("1".repeat(40))
226+
expect(request).not.toContain("0".repeat(40))
213227
}
214-
expect(await fs.readdir(path.join(dataDir(input), "snapshot")).catch(() => [])).toEqual([])
228+
expect(await shadowRepoExists(input)).toBe(false)
215229
})
216230
}, 60000)
217231
})

0 commit comments

Comments
 (0)