Refactor PolicyEngine to Core Package (#12325)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Allen Hutchison
2025-11-03 15:41:00 -08:00
committed by GitHub
parent 60d2c2cc90
commit ffc5e4d048
35 changed files with 1357 additions and 2156 deletions

View File

@@ -96,6 +96,7 @@ describe('BuiltinCommandLoader', () => {
mockConfig = {
getFolderTrust: vi.fn().mockReturnValue(true),
getUseModelRouter: () => false,
getEnableMessageBusIntegration: () => false,
} as unknown as Config;
restoreCommandMock.mockReturnValue({
@@ -187,6 +188,28 @@ describe('BuiltinCommandLoader', () => {
const modelCmd = commands.find((c) => c.name === 'model');
expect(modelCmd).toBeUndefined();
});
it('should include policies command when message bus integration is enabled', async () => {
const mockConfigWithMessageBus = {
...mockConfig,
getEnableMessageBusIntegration: () => true,
} as unknown as Config;
const loader = new BuiltinCommandLoader(mockConfigWithMessageBus);
const commands = await loader.loadCommands(new AbortController().signal);
const policiesCmd = commands.find((c) => c.name === 'policies');
expect(policiesCmd).toBeDefined();
});
it('should exclude policies command when message bus integration is disabled', async () => {
const mockConfigWithoutMessageBus = {
...mockConfig,
getEnableMessageBusIntegration: () => false,
} as unknown as Config;
const loader = new BuiltinCommandLoader(mockConfigWithoutMessageBus);
const commands = await loader.loadCommands(new AbortController().signal);
const policiesCmd = commands.find((c) => c.name === 'policies');
expect(policiesCmd).toBeUndefined();
});
});
describe('BuiltinCommandLoader profile', () => {
@@ -198,6 +221,7 @@ describe('BuiltinCommandLoader profile', () => {
getFolderTrust: vi.fn().mockReturnValue(false),
getUseModelRouter: () => false,
getCheckpointingEnabled: () => false,
getEnableMessageBusIntegration: () => false,
} as unknown as Config;
});