This repository has been archived on 2026-11-17. You can view files and clone it, but cannot push or open issues or pull requests.
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

80 lines
3.0 KiB
TypeScript

/**
* Unit tests for the C++ ADL seq-coverage invariant guard.
*
* `pickCppAdlCandidates` sorts merged candidates by `seqByNodeId`, falling back
* to `?? 0` if a bucketed def has no seq. That fallback is provably unreachable
* (every def pushed into `nsCandidates`/`friendCandidates` is seq-assigned in the
* same build block), but a future regression could break the invariant and
* silently collapse two seq-0 candidates into one. `validateAdlSeqCoverage`
* detects that break; `buildAdlIndex` runs it under the dev/test validation gate
* so a regression fails loudly in CI rather than dropping a CALLS edge in prod.
*/
import { describe, it, expect } from 'vitest';
import {
validateAdlSeqCoverage,
type AdlCandidateIndex,
} from '../../../../src/core/ingestion/languages/cpp/adl.js';
import type { SymbolDefinition } from 'gitnexus-shared';
function def(nodeId: string): SymbolDefinition {
return { nodeId } as unknown as SymbolDefinition;
}
function makeIndex(
nsCandidates: Map<string, Map<string, SymbolDefinition[]>>,
friendCandidates: Map<string, Map<string, SymbolDefinition[]>>,
seqByNodeId: Map<string, number>,
): AdlCandidateIndex {
return {
classDefsBySimple: new Map(),
nsCandidates,
friendCandidates,
nsFunctionsByQName: new Map(),
nsFunctionsBySimple: new Map(),
seqByNodeId,
};
}
describe('validateAdlSeqCoverage', () => {
it('returns no missing ids when every bucketed def has a seq', () => {
const ns = new Map([['lib', new Map([['act', [def('A')]]])]]);
const friend = new Map([['lib', new Map([['swap', [def('B')]]])]]);
const seq = new Map([
['A', 0],
['B', 1],
]);
expect(validateAdlSeqCoverage(makeIndex(ns, friend, seq))).toEqual([]);
});
it('flags a namespace-candidate def missing from seqByNodeId', () => {
const ns = new Map([['lib', new Map([['act', [def('A'), def('C')]]])]]);
const friend = new Map<string, Map<string, SymbolDefinition[]>>();
const seq = new Map([['A', 0]]); // 'C' missing
expect(validateAdlSeqCoverage(makeIndex(ns, friend, seq))).toEqual(['C']);
});
it('flags a friend-candidate def missing from seqByNodeId', () => {
const ns = new Map<string, Map<string, SymbolDefinition[]>>();
const friend = new Map([['lib', new Map([['swap', [def('D')]]])]]);
const seq = new Map<string, number>(); // 'D' missing
expect(validateAdlSeqCoverage(makeIndex(ns, friend, seq))).toEqual(['D']);
});
it('reports each missing nodeId once even when bucketed under multiple keys', () => {
// Inline-namespace transparency registers the same def under its own and
// its parent QName; a missing seq should surface as a single entry.
const inner = new Map([['act', [def('E')]]]);
const ns = new Map([
['lib', inner],
['lib.inline', inner],
]);
const friend = new Map<string, Map<string, SymbolDefinition[]>>();
const seq = new Map<string, number>(); // 'E' missing
expect(validateAdlSeqCoverage(makeIndex(ns, friend, seq))).toEqual(['E']);
});
});