Skip to content

[audit] convention: OperationMode type duplicated across 7 MCP bridge files #366

@claude

Description

@claude

Problem

The type type OperationMode = "apply" | "suggest" | "dryRun" is independently defined in 7 separate MCP bridge handler files. If the allowed modes ever change, all 7 definitions must be updated — easy to miss one, causing silent divergence.

Files with duplicate definition

File Line
src/hooks/mcpBridge/smartInsertHandlers.ts 18
src/hooks/mcpBridge/batchEditHandler.ts 26
src/hooks/mcpBridge/paragraphHandlers.ts 19
src/hooks/mcpBridge/sectionHandlers.ts 19
src/hooks/mcpBridge/replaceAnchoredHandler.ts 26
src/hooks/mcpBridge/applyDiffHandler.ts 26
src/hooks/mcpBridge/batchOpHandlers.ts 17

Suggested Fix

Extract to a shared types file and co-locate with the runtime validator from issue #366:

// src/hooks/mcpBridge/types.ts
export type OperationMode = "apply" | "suggest" | "dryRun";
export const OPERATION_MODES = ["apply", "suggest", "dryRun"] as const;

export type MatchPolicy = "first" | "all" | "nth" | "error_if_multiple";
export const MATCH_POLICIES = ["first", "all", "nth", "error_if_multiple"] as const;

Import from ./types in all 7 files instead of redefining locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditCodebase audit findingconventionConvention violation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions