Skip to content

Commit 8cf2545

Browse files
authored
test(atlas): tripwire the bundled @synsci/atlas dependency against drift (#115)
The agent shells out to the bundled `atlas` CLI to populate the graph (atlas doctor, nodes:create, evidence:add). node_modules had drifted to 0.5.12 while package.json pins ^0.13.2 — a silent skew that runs a different CLI surface than we ship, degrading graph population even when `openscience project init` succeeds. Add a tripwire (mirroring the model-pin delisting test) asserting the installed atlas satisfies the declared range and exposes its `atlas` bin. Gracefully skips when atlas isn't installed (a standalone-compiled build has no node_modules).
1 parent a374b62 commit 8cf2545

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { describe, expect, test } from "bun:test"
2+
import { createRequire } from "module"
3+
import path from "path"
4+
5+
// Tripwire for the bundled `atlas` CLI the agent shells out to (atlas doctor,
6+
// nodes:create, evidence:add). If node_modules drifts from the declared pin, the
7+
// agent runs a different CLI surface than we ship — which silently degrades graph
8+
// population even when `openscience project init` succeeds. Mirrors the model-pin
9+
// delisting tripwire.
10+
describe("@synsci/atlas dependency", () => {
11+
const root = path.join(import.meta.dir, "..", "..")
12+
const req = createRequire(import.meta.url)
13+
14+
async function pkgJson() {
15+
return (await Bun.file(path.join(root, "package.json")).json()) as {
16+
optionalDependencies?: Record<string, string>
17+
}
18+
}
19+
20+
async function installedAtlas(): Promise<{ version: string; bin?: unknown } | null> {
21+
try {
22+
const p = req.resolve("@synsci/atlas/package.json")
23+
const j = (await Bun.file(p).json()) as { version: string; bin?: Record<string, string> }
24+
return { version: j.version, bin: j.bin?.atlas }
25+
} catch {
26+
// Optional dependency: absent in a standalone-compiled build with no
27+
// node_modules. Callers treat that as "skip", not "fail".
28+
return null
29+
}
30+
}
31+
32+
test("declares @synsci/atlas with a concrete version range", async () => {
33+
const range = (await pkgJson()).optionalDependencies?.["@synsci/atlas"]
34+
expect(range).toBeTruthy()
35+
expect(range).toMatch(/\d+\.\d+\.\d+/)
36+
})
37+
38+
test("the installed @synsci/atlas satisfies the declared range (no drift)", async () => {
39+
const range = (await pkgJson()).optionalDependencies!["@synsci/atlas"]
40+
const atlas = await installedAtlas()
41+
if (!atlas) return // not installed in this build — nothing to check
42+
expect(Bun.semver.satisfies(atlas.version, range)).toBe(true)
43+
})
44+
45+
test("the bundled atlas exposes a bin entry named `atlas`", async () => {
46+
const atlas = await installedAtlas()
47+
if (!atlas) return
48+
expect(typeof atlas.bin).toBe("string")
49+
})
50+
})

0 commit comments

Comments
 (0)