Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(ix-cli): gate cross-repo edges on PRODUCTION deps only, not dev/test deps (Ix#225) (#244)
Joseph Mikhail83004e1d8232
diff --git a/ix-cli/src/cli/__tests__/system.test.ts b/ix-cli/src/cli/__tests__/system.test.tsindex a94cd673..b3e4f159 100644--- a/ix-cli/src/cli/__tests__/system.test.ts+++ b/ix-cli/src/cli/__tests__/system.test.ts@@ -69,6 +69,32 @@ describe("Maven name + declared-dependency graph", () => {expect(readPackageDeps(nodePath.join(root, "consumer"))).toContain("acme-lib");});+ it("readPackageDeps returns PRODUCTION deps only (dev/test deps are not architectural coupling)", () => {+ const d = nodePath.join(root, "proddep");+ fs.mkdirSync(d, { recursive: true });+ fs.writeFileSync(nodePath.join(d, "package.json"), JSON.stringify({+ name: "proddep",+ dependencies: { "real-dep": "^1.0.0" },+ peerDependencies: { "peer-dep": "*" },+ optionalDependencies: { "opt-dep": "^1.0.0" },+ devDependencies: { "test-dep": "^1.0.0" },+ }));+ const deps = readPackageDeps(d);+ expect(deps).toEqual(expect.arrayContaining(["real-dep", "peer-dep", "opt-dep"]));+ expect(deps).not.toContain("test-dep");+ });++ it("readPackageDeps excludes Cargo [dev-dependencies] and [build-dependencies]", () => {+ const d = nodePath.join(root, "rustdep");+ fs.mkdirSync(d, { recursive: true });+ fs.writeFileSync(nodePath.join(d, "Cargo.toml"),+ '[package]\nname = "rustdep"\n\n[dependencies]\nserde = "1"\n\n[dev-dependencies]\ncriterion = "0.5"\n\n[build-dependencies]\ncc = "1"\n');+ const deps = readPackageDeps(d);+ expect(deps).toContain("serde");+ expect(deps).not.toContain("criterion");+ expect(deps).not.toContain("cc");+ });+it("detectSystem builds the ground-truth repoDeps graph (consumer -> lib)", () => {const d = detectSystem(root)!;expect(d.repoDeps["consumer"]).toContain("lib");diff --git a/ix-cli/src/cli/system.ts b/ix-cli/src/cli/system.tsindex 25112bc5..81bc88bd 100644--- a/ix-cli/src/cli/system.ts+++ b/ix-cli/src/cli/system.ts@@ -197,17 +197,29 @@ export function readPackageDeps(dir: string): string[] {};const add = (n: unknown) => { if (typeof n === "string" && n.trim()) deps.add(n.trim()); };+ // PRODUCTION deps only. The declared-dependency graph gates cross-repo edges,+ // i.e. it asserts "repo A's code genuinely depends on repo B's code." dev/test+ // and build-tool deps are NOT production architecture: every repo dev-depends on+ // its test/build tooling, and treating those as coupling falsely merges+ // unrelated repos into one system (e.g. express dev-depends on morgan only for+ // its tests; chalk dev-depends on execa; lodash dev-depends on chalk) and lets+ // symbol-name collisions slip the gate. So devDependencies / Cargo+ // [dev-dependencies] / [build-dependencies] are intentionally excluded; runtime+ // peer/optional deps are kept (they are real runtime coupling).const pkg = read("package.json"); // JS / TSif (pkg) { try {const j = JSON.parse(pkg);- for (const s of ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"])+ for (const s of ["dependencies", "peerDependencies", "optionalDependencies"])if (j[s] && typeof j[s] === "object") for (const k of Object.keys(j[s])) add(k);} catch { /* ignore */ } }const cargo = read("Cargo.toml"); // Rustif (cargo) {- for (const sect of cargo.matchAll(/\[(?:dev-|build-)?dependencies(?:\.[^\]\n]+)?\]([\s\S]*?)(?:\n\[|$)/g)) {- for (const dm of sect[1].matchAll(/^\s*([A-Za-z0-9_-]+)\s*(?:=|\.)/gm)) add(dm[1]);+ // Match [dependencies], [dependencies.x], [target.'cfg'.dependencies], but+ // skip [dev-dependencies] / [build-dependencies] (not runtime coupling).+ for (const sect of cargo.matchAll(/\[([^\]\n]*\bdependencies\b[^\]\n]*)\]([\s\S]*?)(?:\n\[|$)/g)) {+ if (/\b(?:dev|build)-dependencies\b/.test(sect[1])) continue;+ for (const dm of sect[2].matchAll(/^\s*([A-Za-z0-9_-]+)\s*(?:=|\.)/gm)) add(dm[1]);}}