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.
gitgram-ai/aitimemachine/gitnexus/test/unit/clone-safety-payloads.test.ts
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

45 lines
2.4 KiB
TypeScript

/**
* #2143 — the concrete worker-boundary payload types are `Cloneable`.
*
* The provider hooks (`extractTemplateConstraints`, `collectCaptureSideChannel`)
* feed `unknown`-typed worker-result sinks and are wrapped in `assertCloneable`
* at their source sites (c-cpp.ts, kotlin.ts). These type-level assertions pin
* the guarantee INDEPENDENTLY of that wiring: if a future field added to any of
* these payloads is non-serializable (a function, symbol, …), `Cloneable<T>`
* resolves to a type containing `never` at that key and `[T] extends
* [Cloneable<T>]` becomes `false`, so the `: true` annotation fails the
* type-check (`tsconfig.test.json`) — catching the regression even if someone
* later removes the `assertCloneable` wrapper from the provider.
*
* Type-only imports (erased at runtime); the single runtime assertion exists so
* the file is a real, runnable test.
*/
import { describe, it, expect } from 'vitest';
import type { Cloneable } from '../../src/core/ingestion/workers/clone-safety.js';
import type { CppConstraintPayload } from '../../src/core/ingestion/languages/cpp/constraint-extractor.js';
import type { CppCaptureSideChannel } from '../../src/core/ingestion/languages/cpp/capture-side-channel.js';
import type { CCaptureSideChannel } from '../../src/core/ingestion/languages/c/capture-side-channel.js';
import type { KotlinCaptureSideChannel } from '../../src/core/ingestion/languages/kotlin/capture-side-channel.js';
// `[T] extends [Cloneable<T>] ? true : false` is `true` iff T is wholly
// clone-safe. Tuple-wrapped to avoid distributing over unions / `never`.
type IsCloneable<T> = [T] extends [Cloneable<T>] ? true : false;
describe('#2143: worker-boundary payload types are Cloneable', () => {
it('CppConstraintPayload / CppCaptureSideChannel / CCaptureSideChannel / KotlinCaptureSideChannel', () => {
const cppConstraint: IsCloneable<CppConstraintPayload> = true;
const cppSideChannel: IsCloneable<CppCaptureSideChannel> = true;
const cSideChannel: IsCloneable<CCaptureSideChannel> = true;
const kotlinSideChannel: IsCloneable<KotlinCaptureSideChannel> = true;
// Array equality (not `&&`) so this isn't a trivial-always-true conditional;
// the real assertions are the `: IsCloneable<…> = true` annotations above.
expect([cppConstraint, cppSideChannel, cSideChannel, kotlinSideChannel]).toEqual([
true,
true,
true,
true,
]);
});
});