Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { findImportCycles } from '../../src/core/graph/import-cycles.js';
|
|
|
|
describe('findImportCycles', () => {
|
|
it('returns no cycles for an acyclic graph', () => {
|
|
expect(
|
|
findImportCycles([
|
|
{ source: 'src/a.ts', target: 'src/b.ts' },
|
|
{ source: 'src/b.ts', target: 'src/c.ts' },
|
|
]),
|
|
).toEqual([]);
|
|
});
|
|
|
|
it('returns deterministic concrete paths for cyclic components', () => {
|
|
expect(
|
|
findImportCycles([
|
|
{ source: 'src/b.ts', target: 'src/a.ts' },
|
|
{ source: 'src/a.ts', target: 'src/b.ts' },
|
|
{ source: 'src/y.ts', target: 'src/z.ts' },
|
|
{ source: 'src/z.ts', target: 'src/y.ts' },
|
|
]),
|
|
).toEqual([
|
|
['src/a.ts', 'src/b.ts', 'src/a.ts'],
|
|
['src/y.ts', 'src/z.ts', 'src/y.ts'],
|
|
]);
|
|
});
|
|
|
|
it('deduplicates edges and reports self-imports', () => {
|
|
expect(
|
|
findImportCycles([
|
|
{ source: 'src/a.ts', target: 'src/a.ts' },
|
|
{ source: 'src/a.ts', target: 'src/a.ts' },
|
|
]),
|
|
).toEqual([['src/a.ts', 'src/a.ts']]);
|
|
});
|
|
|
|
it('returns the shortest deterministic path through the component root', () => {
|
|
expect(
|
|
findImportCycles([
|
|
{ source: 'src/a.ts', target: 'src/b.ts' },
|
|
{ source: 'src/b.ts', target: 'src/c.ts' },
|
|
{ source: 'src/c.ts', target: 'src/d.ts' },
|
|
{ source: 'src/d.ts', target: 'src/a.ts' },
|
|
{ source: 'src/a.ts', target: 'src/z.ts' },
|
|
{ source: 'src/z.ts', target: 'src/a.ts' },
|
|
]),
|
|
).toEqual([['src/a.ts', 'src/z.ts', 'src/a.ts']]);
|
|
});
|
|
|
|
it('finds an edge-connected path when component sort order is not a path', () => {
|
|
expect(
|
|
findImportCycles([
|
|
{ source: 'src/a.ts', target: 'src/c.ts' },
|
|
{ source: 'src/c.ts', target: 'src/b.ts' },
|
|
{ source: 'src/b.ts', target: 'src/a.ts' },
|
|
]),
|
|
).toEqual([['src/a.ts', 'src/c.ts', 'src/b.ts', 'src/a.ts']]);
|
|
});
|
|
|
|
it('handles deep import graphs without recursive traversal', () => {
|
|
const size = 20_000;
|
|
const edges = Array.from({ length: size - 1 }, (_, index) => ({
|
|
source: `src/${index}.ts`,
|
|
target: `src/${index + 1}.ts`,
|
|
}));
|
|
expect(findImportCycles(edges)).toEqual([]);
|
|
});
|
|
});
|