GitNexus/gitnexus/test/unit/move/cross-package.test.ts
zwxxb 282d82f1e0 refactor(move): simplify & harden the Move integration architecture (reduced scope)
Trimmed rebuild of 6ea5aa44 (fork PR #4): Move core (gitnexus/src/core/move/)
and Move tests, plus the functional minimum elsewhere.

Dropped from the original commit:
- .gitignore .codex/ entry (unrelated)
- cli/analyze.ts env-constant swap (cosmetic; same string literal)
- core/logger.ts warnRespectingProgressBar extraction and the
  filesystem-walker.ts reuse of it (Move code never imports the helper)
- scope-resolution callable-value-flow warning aggregation and pipeline/run.ts
  progress-warning formatting, with their two tests (warning-UX hardening,
  not Move-functional)
- process-detection interface doc-comment retuning (DEFAULT_CONFIG runtime
  values already match upstream; region left byte-identical to upstream)

Kept outside src/core/move/ and Move tests (one line each):
- gitnexus-shared/src/graph/types.ts: 'external' locationFidelity for
  dependency symbols
- gitnexus-shared/src/lbug/schema-constants.ts: 'Type' node table registration
- core/lbug/schema.ts: Type table schema + Move rel-table endpoint pairs
- core/lbug/node-table-layout.ts: TYPE_LAYOUT CSV layout
- core/lbug/csv-generator.ts: 'Type' in MULTI_LANG_TYPES routing
- core/lbug/lbug-adapter.ts: deleteAllExternalNodes + shared delete-by-label
  mechanics; Type backtick entry
- core/incremental/subgraph-extract.ts: external nodes get the
  delete-all-then-rebuild treatment
- core/run-analyze.ts: Move consistency digest to meta.json;
  deleteAllExternalNodes call; grouped Move meta; finally-based shutdown
- storage/repo-manager.ts: moveConsistency in RepoMeta;
  INCREMENTAL_SCHEMA_VERSION 13 (Type/EnumVariant persistence)
- core/ingestion/pipeline.ts: generic TStandaloneIngest output threading
- types/pipeline.ts: PipelineResult.standaloneIngest replaces ingestWarnings
- core/ingestion/process-processor.ts: ENTRY_POINT_OF explicit graph roots
- tests: schema, node-table-layout, process-processor,
  repo-manager-reconcile, call-summary-schema-version,
  incremental-subgraph-extract, run-analyze-fts-repair (unit);
  lbug-core-adapter (integration)

Gates: tsc clean; Move unit 185/185; full unit suite green except three
pre-existing Darwin-environment failures reproduced on the pristine base;
integration (move + lbug-core-adapter) 29/29.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 18:58:03 +02:00

66 lines
2.1 KiB
TypeScript

import path from 'node:path';
import { describe, it, expect } from 'vitest';
import { runPipelineFromRepo } from '../../../src/core/ingestion/pipeline.js';
import type { MoveFactsMap } from '../../../src/core/move/compiler-facts.js';
import type { MoveFlowClient } from '../../../src/core/move/mcp-client.js';
import { createMoveIngestPhase } from '../../../src/core/move/move-ingest.js';
const friendGraphFixture = path.resolve(process.cwd(), 'test/fixtures/move/friend_graph');
const factsByPackage: Record<string, MoveFactsMap> = {
pkg_x: {
'0xa::m_x': {
file: path.join(friendGraphFixture, 'pkg_x/sources/x.move'),
span: [1, 11],
friends: [{ module: '0xb::m_y' }],
attributes: [],
functions: [],
structs: [],
constants: [],
},
},
pkg_y: {
'0xb::m_y': {
file: path.join(friendGraphFixture, 'pkg_y/sources/y.move'),
span: [1, 7],
friends: [{ module: '0xa::m_x' }],
attributes: [],
functions: [],
structs: [],
constants: [],
},
},
};
const client: MoveFlowClient = {
async facts(packagePath: string): Promise<MoveFactsMap> {
return packagePath.endsWith('pkg_x') ? factsByPackage.pkg_x : factsByPackage.pkg_y;
},
async callGraph() {
return {};
},
async functionUsage() {
return { called: [], used: [] };
},
async packageStatus() {
return { ok: true, diagnostics: '' };
},
async capabilities() {
return { hasFactsQuery: true, hasFunctionUsageQuery: false, hasStatusTool: false };
},
async shutdown() {},
};
describe('move ingest - cross-package edges', () => {
it('emits cross-package FRIEND_OF edges after the global pass', async () => {
const result = await runPipelineFromRepo(friendGraphFixture, () => {}, {
standaloneIngestPhase: createMoveIngestPhase(client),
skipGraphPhases: true,
});
const edges = [...result.graph.iterRelationships()];
const crossPkgFriend = edges.find(
(e) => e.type === 'FRIEND_OF' && e.sourceId.includes('m_x') && e.targetId.includes('m_y'),
);
expect(crossPkgFriend).toBeDefined();
});
});