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>
83 lines
3.4 KiB
TypeScript
83 lines
3.4 KiB
TypeScript
/**
|
|
* Coverage for `interpretCsharpTypeBinding` type normalization, focused on the
|
|
* F41 analog (#1928): the qualifier strip must not reach into generic type
|
|
* ARGUMENTS. `Dictionary<string, Ns.User>` was corrupted into `User>` by an
|
|
* unguarded `lastIndexOf('.')`. Multi-arg generics must stay intact so the
|
|
* collection-accessor (`.Values`/`.Keys`) unwrap keeps working.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
import type { Capture, CaptureMatch } from 'gitnexus-shared';
|
|
import { interpretCsharpTypeBinding } from '../../../../src/core/ingestion/languages/csharp/interpret.js';
|
|
|
|
const ZERO = { startLine: 0, startCol: 0, endLine: 0, endCol: 0 } as const;
|
|
const cap = (name: string, text: string): Capture => ({ name, text, range: ZERO });
|
|
|
|
function raw(typeText: string): string | undefined {
|
|
const m: CaptureMatch = {
|
|
'@type-binding.name': cap('@type-binding.name', 'x'),
|
|
'@type-binding.type': cap('@type-binding.type', typeText),
|
|
'@type-binding.annotation': cap('@type-binding.annotation', typeText),
|
|
};
|
|
return interpretCsharpTypeBinding(m)?.rawTypeName;
|
|
}
|
|
|
|
describe('interpretCsharpTypeBinding — type normalization (F41 analog #1928)', () => {
|
|
it('does not corrupt a qualified generic TYPE ARGUMENT (the bug)', () => {
|
|
// Was `User>` before the fix.
|
|
expect(raw('Dictionary<string, Ns.User>')).toBe('Dictionary<string, Ns.User>');
|
|
});
|
|
|
|
it('leaves an unqualified multi-arg generic intact (collection-accessor unwrap)', () => {
|
|
expect(raw('Dictionary<string, Widget>')).toBe('Dictionary<string, Widget>');
|
|
});
|
|
|
|
it('strips the OUTER qualifier of a generic while keeping the type args', () => {
|
|
expect(raw('Ns.Dictionary<string, User>')).toBe('Dictionary<string, User>');
|
|
});
|
|
|
|
it('unwraps a single-arg known container to its (qualified) element type', () => {
|
|
expect(raw('List<Ns.User>')).toBe('User');
|
|
expect(raw('List<User>')).toBe('User');
|
|
expect(raw('Task<User>')).toBe('User');
|
|
});
|
|
|
|
it('strips a plain qualifier', () => {
|
|
expect(raw('Ns.User')).toBe('User');
|
|
expect(raw('A.B.User')).toBe('User');
|
|
});
|
|
|
|
it('strips a nullable suffix', () => {
|
|
expect(raw('User?')).toBe('User');
|
|
});
|
|
|
|
it('unwraps a nullable single-arg generic (`List<User>?` → `User`)', () => {
|
|
expect(raw('List<User>?')).toBe('User');
|
|
});
|
|
|
|
it('does not corrupt a nested generic — keeps it intact (no `>>` artifact)', () => {
|
|
expect(raw('List<Dictionary<string, User>>')).toBe('List<Dictionary<string, User>>');
|
|
});
|
|
|
|
it('strips the outer qualifier of an unrecognized generic, keeping its args', () => {
|
|
// Accepted limitation: unknown generics are not erased to the bare base —
|
|
// only the OUTER qualifier is removed; the generic suffix is preserved.
|
|
expect(raw('Ns.Box<User>')).toBe('Box<User>');
|
|
});
|
|
|
|
it('passes through a plain simple type', () => {
|
|
expect(raw('User')).toBe('User');
|
|
});
|
|
|
|
it('preserves a collection-accessor suffix (`data.Values`)', () => {
|
|
expect(raw('data.Values')).toBe('data.Values');
|
|
});
|
|
|
|
it('strips nested types through a generic outer (`Ns.Outer<int>.Inner` → `Inner`)', () => {
|
|
// Prior generic-aware strip sliced at the first `<` and regressed to
|
|
// `Outer<int>.Inner` (unresolvable). Last `.` at bracket depth 0 fixes both
|
|
// this shape and the F41 `Dictionary<string, Ns.User>` case (#2046 P3).
|
|
expect(raw('Ns.Outer<int>.Inner')).toBe('Inner');
|
|
expect(raw('Outer.Inner')).toBe('Inner');
|
|
});
|
|
});
|