caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
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>
2026-06-23 14:14:09 +03:00

91 lines
4.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Regression tests for Rust scope-resolution coverage gaps (issue #1934).
*/
import { describe, it, expect } from 'vitest';
import { emitRustScopeCaptures } from '../../../src/core/ingestion/languages/rust/index.js';
import type { CaptureMatch } from 'gitnexus-shared';
// ---------------------------------------------------------------------------
// F66/F68 — let binding patterns (identifier-only, works with let mut x)
// ---------------------------------------------------------------------------
describe('F66/F68 — let binding pattern shapes', () => {
it('bare identifier let binding emits @declaration.variable', () => {
const src = `fn f() { let x = 1; }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const vars = matches.filter((m) => m['@declaration.variable']);
expect(vars.length).toBe(1);
expect(vars[0]['@declaration.name'].text).toBe('x');
});
it('let mut x emits @declaration.variable', () => {
const src = `fn f() { let mut x = 1; }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const vars = matches.filter((m) => m['@declaration.variable']);
expect(vars.length).toBe(1);
expect(vars[0]['@declaration.name'].text).toBe('x');
});
});
// ---------------------------------------------------------------------------
// F71 — union declarations
// ---------------------------------------------------------------------------
describe('F71 — union declaration', () => {
it('union item emits @scope.class and @declaration.struct', () => {
const src = `union MyUnion { x: i32, y: f64 }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const scopes = matches.filter((m) => m['@scope.class']);
expect(scopes.length).toBe(1);
const decls = matches.filter((m) => m['@declaration.struct']);
expect(decls.length).toBe(1);
expect(decls[0]['@declaration.name'].text).toBe('MyUnion');
});
});
// ---------------------------------------------------------------------------
// F72 — macro invocations (capture layer)
//
// These pin the tree-sitter CAPTURE shape only. End-to-end macro RESOLUTION
// (the @reference.macro → MacroRegistry → USES-edge-to-a-Macro-node path, and
// the guarantee that a macro never binds to a same-named function) is asserted
// at the pipeline level in `rust.test.ts` › "Rust macro resolution (issue #1934 F72)".
// ---------------------------------------------------------------------------
describe('F72 — macro invocations (capture layer)', () => {
it('macro_invocation with bare identifier emits @reference.macro', () => {
const src = `fn f() { println!("hi"); }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const macroRefs = matches.filter((m) => m['@reference.macro']);
const macroNames = macroRefs.map((m) => m['@reference.name']?.text);
expect(macroNames).toContain('println');
});
it('vec! macro emits @reference.macro', () => {
const src = `fn f() { let v = vec![1, 2, 3]; }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const macroRefs = matches.filter((m) => m['@reference.macro']);
const macroNames = macroRefs.map((m) => m['@reference.name']?.text);
expect(macroNames).toContain('vec');
});
it('scoped macro invocation captures the TAIL identifier, not the full path', () => {
const src = `fn f() { log::info!("hi"); }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const macroRefs = matches.filter((m) => m['@reference.macro']);
const macroNames = macroRefs.map((m) => m['@reference.name']?.text);
// Must be the tail `info`, not the whole path `log::info` — mirrors the
// scoped free-call pattern. Guards the P3 fix.
expect(macroNames).toContain('info');
expect(macroNames).not.toContain('log::info');
});
it('macro_rules! definition emits a @declaration.macro capture', () => {
const src = `macro_rules! greet { () => {}; }\n`;
const matches = emitRustScopeCaptures(src, 'test.rs') as CaptureMatch[];
const macroDecls = matches.filter((m) => m['@declaration.macro']);
expect(macroDecls.length).toBe(1);
expect(macroDecls[0]['@declaration.name'].text).toBe('greet');
});
});