Skip to content

Commit 80e1fa1

Browse files
authored
Clean up dead code (google-gemini#17443)
1 parent 84e8827 commit 80e1fa1

File tree

8 files changed

+3
-982
lines changed

8 files changed

+3
-982
lines changed

packages/core/src/confirmation-bus/message-bus.ts

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77
import { randomUUID } from 'node:crypto';
88
import { EventEmitter } from 'node:events';
99
import type { PolicyEngine } from '../policy/policy-engine.js';
10-
import { PolicyDecision, getHookSource } from '../policy/types.js';
11-
import {
12-
MessageBusType,
13-
type Message,
14-
type HookPolicyDecision,
15-
} from './types.js';
10+
import { PolicyDecision } from '../policy/types.js';
11+
import { MessageBusType, type Message } from './types.js';
1612
import { safeJsonStringify } from '../utils/safeJsonStringify.js';
1713
import { debugLogger } from '../utils/debugLogger.js';
1814

@@ -89,39 +85,6 @@ export class MessageBus extends EventEmitter {
8985
default:
9086
throw new Error(`Unknown policy decision: ${decision}`);
9187
}
92-
} else if (message.type === MessageBusType.HOOK_EXECUTION_REQUEST) {
93-
// Handle hook execution requests through policy evaluation
94-
const hookRequest = message;
95-
const decision = await this.policyEngine.checkHook(hookRequest);
96-
97-
// Map decision to allow/deny for observability (ASK_USER treated as deny for hooks)
98-
const effectiveDecision =
99-
decision === PolicyDecision.ALLOW ? 'allow' : 'deny';
100-
101-
// Emit policy decision for observability
102-
this.emitMessage({
103-
type: MessageBusType.HOOK_POLICY_DECISION,
104-
eventName: hookRequest.eventName,
105-
hookSource: getHookSource(hookRequest.input),
106-
decision: effectiveDecision,
107-
reason:
108-
decision !== PolicyDecision.ALLOW
109-
? 'Hook execution denied by policy'
110-
: undefined,
111-
} as HookPolicyDecision);
112-
113-
// If allowed, emit the request for hook system to handle
114-
if (decision === PolicyDecision.ALLOW) {
115-
this.emitMessage(message);
116-
} else {
117-
// If denied or ASK_USER, emit error response (hooks don't support interactive confirmation)
118-
this.emitMessage({
119-
type: MessageBusType.HOOK_EXECUTION_RESPONSE,
120-
correlationId: hookRequest.correlationId,
121-
success: false,
122-
error: new Error('Hook execution denied by policy'),
123-
});
124-
}
12588
} else {
12689
// For all other message types, just emit them
12790
this.emitMessage(message);

packages/core/src/confirmation-bus/types.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export enum MessageBusType {
1818
TOOL_EXECUTION_SUCCESS = 'tool-execution-success',
1919
TOOL_EXECUTION_FAILURE = 'tool-execution-failure',
2020
UPDATE_POLICY = 'update-policy',
21-
HOOK_EXECUTION_REQUEST = 'hook-execution-request',
22-
HOOK_EXECUTION_RESPONSE = 'hook-execution-response',
23-
HOOK_POLICY_DECISION = 'hook-policy-decision',
2421
TOOL_CALLS_UPDATE = 'tool-calls-update',
2522
ASK_USER_REQUEST = 'ask-user-request',
2623
ASK_USER_RESPONSE = 'ask-user-response',
@@ -120,29 +117,6 @@ export interface ToolExecutionFailure<E = Error> {
120117
error: E;
121118
}
122119

123-
export interface HookExecutionRequest {
124-
type: MessageBusType.HOOK_EXECUTION_REQUEST;
125-
eventName: string;
126-
input: Record<string, unknown>;
127-
correlationId: string;
128-
}
129-
130-
export interface HookExecutionResponse {
131-
type: MessageBusType.HOOK_EXECUTION_RESPONSE;
132-
correlationId: string;
133-
success: boolean;
134-
output?: Record<string, unknown>;
135-
error?: Error;
136-
}
137-
138-
export interface HookPolicyDecision {
139-
type: MessageBusType.HOOK_POLICY_DECISION;
140-
eventName: string;
141-
hookSource: 'project' | 'user' | 'system' | 'extension';
142-
decision: 'allow' | 'deny';
143-
reason?: string;
144-
}
145-
146120
export interface QuestionOption {
147121
label: string;
148122
description: string;
@@ -186,9 +160,6 @@ export type Message =
186160
| ToolExecutionSuccess
187161
| ToolExecutionFailure
188162
| UpdatePolicy
189-
| HookExecutionRequest
190-
| HookExecutionResponse
191-
| HookPolicyDecision
192163
| AskUserRequest
193164
| AskUserResponse
194165
| ToolCallsUpdateMessage;

packages/core/src/hooks/hookEventHandler.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
88
import { HookEventHandler } from './hookEventHandler.js';
99
import type { Config } from '../config/config.js';
1010
import type { HookConfig } from './types.js';
11-
import type { Logger } from '@opentelemetry/api-logs';
1211
import type { HookPlanner } from './hookPlanner.js';
1312
import type { HookRunner } from './hookRunner.js';
1413
import type { HookAggregator } from './hookAggregator.js';
@@ -18,7 +17,6 @@ import {
1817
SessionStartSource,
1918
type HookExecutionResult,
2019
} from './types.js';
21-
import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
2220

2321
// Mock debugLogger
2422
const mockDebugLogger = vi.hoisted(() => ({
@@ -54,7 +52,6 @@ vi.mock('../telemetry/clearcut-logger/clearcut-logger.js', () => ({
5452
describe('HookEventHandler', () => {
5553
let hookEventHandler: HookEventHandler;
5654
let mockConfig: Config;
57-
let mockLogger: Logger;
5855
let mockHookPlanner: HookPlanner;
5956
let mockHookRunner: HookRunner;
6057
let mockHookAggregator: HookAggregator;
@@ -74,8 +71,6 @@ describe('HookEventHandler', () => {
7471
}),
7572
} as unknown as Config;
7673

77-
mockLogger = {} as Logger;
78-
7974
mockHookPlanner = {
8075
createExecutionPlan: vi.fn(),
8176
} as unknown as HookPlanner;
@@ -91,11 +86,9 @@ describe('HookEventHandler', () => {
9186

9287
hookEventHandler = new HookEventHandler(
9388
mockConfig,
94-
mockLogger,
9589
mockHookPlanner,
9690
mockHookRunner,
9791
mockHookAggregator,
98-
createMockMessageBus(),
9992
);
10093
});
10194

0 commit comments

Comments
 (0)