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>
98 lines
3.0 KiB
TypeScript
98 lines
3.0 KiB
TypeScript
import * as fs from "fs";
|
|
import * as os from "os";
|
|
import * as path from "path";
|
|
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
import { TimeMachineEngine } from "../src/core/engine.js";
|
|
import { TrainingExporter } from "../src/export/training-exporter.js";
|
|
import { DataExporter } from "../src/export/data-exporter.js";
|
|
import { saveConsent, assertConsent, ConsentError } from "../src/auth/consent-policy.js";
|
|
|
|
describe("consent policy enforcement", () => {
|
|
let projectDir: string;
|
|
|
|
beforeEach(() => {
|
|
projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "aitm-consent-test-"));
|
|
fs.mkdirSync(path.join(projectDir, ".aitimemachine"), { recursive: true });
|
|
fs.writeFileSync(path.join(projectDir, "main.ts"), "export const ok = true;\n", "utf-8");
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(projectDir, { recursive: true, force: true });
|
|
});
|
|
|
|
it("blocks capture when operational_capture is disabled", () => {
|
|
saveConsent(projectDir, {
|
|
policy: {
|
|
operational_capture: false,
|
|
training_export: false,
|
|
},
|
|
});
|
|
|
|
const engine = new TimeMachineEngine(projectDir);
|
|
expect(() => engine.capture("blocked capture", { type: "manual" })).toThrow(ConsentError);
|
|
});
|
|
|
|
it("blocks training export when training_export is disabled", async () => {
|
|
saveConsent(projectDir, {
|
|
policy: {
|
|
operational_capture: true,
|
|
training_export: false,
|
|
},
|
|
});
|
|
|
|
const exporter = new TrainingExporter();
|
|
await expect(
|
|
exporter.exportTrainingData({
|
|
projectPath: projectDir,
|
|
outputPath: path.join(projectDir, "training.jsonl"),
|
|
})
|
|
).rejects.toThrow(ConsentError);
|
|
});
|
|
|
|
it("blocks operational export when operational_capture is disabled", async () => {
|
|
saveConsent(projectDir, {
|
|
policy: {
|
|
operational_capture: false,
|
|
training_export: true,
|
|
},
|
|
});
|
|
|
|
const exporter = new DataExporter(projectDir);
|
|
await expect(
|
|
exporter.exportAll({
|
|
projectPath: projectDir,
|
|
format: "json",
|
|
outputPath: path.join(projectDir, "full-export.json"),
|
|
})
|
|
).rejects.toThrow(ConsentError);
|
|
});
|
|
|
|
it("allows capture and training export when both consents are enabled", async () => {
|
|
saveConsent(projectDir, {
|
|
policy: {
|
|
operational_capture: true,
|
|
training_export: true,
|
|
},
|
|
});
|
|
|
|
const engine = new TimeMachineEngine(projectDir);
|
|
expect(() => engine.capture("allowed capture", { type: "manual" })).not.toThrow();
|
|
|
|
const exporter = new TrainingExporter();
|
|
const result = await exporter.exportTrainingData({
|
|
projectPath: projectDir,
|
|
outputPath: path.join(projectDir, "training.jsonl"),
|
|
});
|
|
expect(result.success).toBe(true);
|
|
expect(fs.existsSync(result.outputPath)).toBe(true);
|
|
});
|
|
|
|
it("defaults to deny training export without explicit opt-in", () => {
|
|
expect(() =>
|
|
assertConsent(projectDir, "export_training", {
|
|
source: "tests.default-training-deny",
|
|
})
|
|
).toThrow(ConsentError);
|
|
});
|
|
});
|