Files
proxycast/scripts/app-server/cli-structure-inventory.test.mjs
2026-10-25 14:08:53 +08:00

170 lines
5.0 KiB
JavaScript

import { readFileSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
const inventory = JSON.parse(
readFileSync(
path.resolve(
process.cwd(),
"internal/exec-plans/cli-structure-inventory.json",
),
"utf8",
),
);
describe("Codex CLI structure inventory", () => {
it("records CLI, exec and execpolicy source owners", () => {
expect(inventory.schemaVersion).toBe(1);
expect(Object.keys(inventory.trees)).toEqual([
"codex-rs/cli",
"codex-rs/exec",
"codex-rs/execpolicy",
"codex-cli",
"lime-rs/crates/cli",
"lime-rs/crates/cli/src/exec",
"lime-rs/crates/execpolicy",
"packages/cli",
]);
for (const tree of Object.values(inventory.trees)) {
expect(tree.fileCount).toBeGreaterThan(0);
expect(tree.symbolCount).toBeGreaterThan(0);
expect(tree.treeSha256).toMatch(/^[a-f0-9]{64}$/u);
}
});
it("records exec output, session and review owners with upstream source names", () => {
const exec = inventory.trees["lime-rs/crates/cli/src/exec"];
for (const file of [
"cli.rs",
"event_processor.rs",
"event_processor_with_human_output.rs",
"event_processor_with_human_output_tests.rs",
"event_processor_with_jsonl_output.rs",
"exec_events.rs",
"cli_tests.rs",
]) {
expect(exec.files).toContain(file);
expect(inventory.comparisons.execFilesMissingInLime).not.toContain(file);
}
expect(exec.files).not.toContain("human_output.rs");
expect(inventory.comparisons.execSymbolNamesMissingInLime).not.toContain(
"ResumeArgs",
);
expect(inventory.comparisons.execSymbolNamesMissingInLime).not.toContain(
"ForkArgs",
);
expect(inventory.comparisons.execSymbolNamesMissingInLime).not.toContain(
"load_output_schema",
);
expect(inventory.comparisons.execSymbolNamesMissingInLime).not.toContain(
"ReviewArgs",
);
expect(inventory.comparisons.execSymbolNamesMissingInLime).not.toContain(
"build_review_request",
);
});
it("locks Lime-native current names in the Lime command owner", () => {
const symbols = new Set(
inventory.trees["lime-rs/crates/cli"].symbols.map(
(symbol) => symbol.name,
),
);
for (const name of [
"MultitoolCli",
"Subcommand",
"TuiCli",
"ExecCli",
"ResumeCommand",
"ReviewCommand",
"McpCli",
"PluginCli",
"FeaturesCli",
"QueueCommand",
"DebugCommand",
"CompletionCommand",
"SandboxStateArgs",
"SeatbeltCommand",
"LandlockCommand",
"WindowsCommand",
"ExecpolicyCommand",
"ExecpolicySubcommand",
"SandboxSetupCommand",
"SandboxSetupLevel",
"SandboxSetupIdentity",
"handle_exit_status",
]) {
expect(symbols.has(name), name).toBe(true);
}
for (const relativePath of [
"src/debug_sandbox.rs",
"src/exit_status.rs",
"src/lib.rs",
"src/sandbox_setup.rs",
]) {
expect(inventory.comparisons.rustFilesMissingInLime).not.toContain(
relativePath,
);
}
});
it("keeps bidirectional structural differences explicit for follow-up work", () => {
expect(inventory.comparisons.rustFilesMissingInLime).toContain(
"src/doctor.rs",
);
expect(inventory.comparisons.npmFilesMissingInLime).toContain(
"scripts/init_firewall.sh",
);
expect(
inventory.comparisons.rustSymbolNamesMissingInLime.length,
).toBeGreaterThan(0);
expect(inventory.comparisons.rustFilesOnlyInLime).not.toContain(
"src/commands.rs",
);
expect(inventory.comparisons.rustFilesOnlyInLime).not.toContain(
"src/execpolicy.rs",
);
expect(inventory.comparisons.npmFilesOnlyInLime).toContain(
"tests/npm-package.test.mjs",
);
expect(
inventory.comparisons.rustSymbolNamesOnlyInLime.length,
).toBeGreaterThan(0);
expect(
inventory.comparisons.npmSymbolNamesOnlyInLime.length,
).toBeGreaterThan(0);
});
it("records the independent execpolicy owner", () => {
expect(inventory.trees["codex-rs/execpolicy"].fileCount).toBeGreaterThan(0);
expect(
inventory.trees["lime-rs/crates/execpolicy"].fileCount,
).toBeGreaterThan(0);
expect(inventory.comparisons.execpolicyFilesMissingInLime).toEqual([
"examples/example.codexpolicy",
]);
expect(inventory.comparisons.execpolicyFilesOnlyInLime).toContain(
"examples/example.limepolicy",
);
const symbols = new Set(
inventory.trees["lime-rs/crates/execpolicy"].symbols.map(
(symbol) => symbol.name,
),
);
for (const name of [
"ExecPolicyCheckCommand",
"PolicyParser",
"Policy",
"RuleMatch",
"PatternToken",
"PrefixPattern",
"PrefixRule",
]) {
expect(symbols.has(name), name).toBe(true);
}
expect(
inventory.comparisons.execpolicySymbolNamesMissingInLime,
).not.toContain("RequirementsExecPolicy");
});
});