[Architecture] Promote patch-contract strictness/budgets to a surface-neutral owner
Labels: enhancement, architecture, mcp, cli, change-control
Priority: P2 (architecture triage)
Subject: codeclone/surfaces/mcp/_patch_contract.py
Signal: ownership_drift
Triage run: e28867ed (health 91/A)
Summary
Reusable patch strictness and budget semantics (PatchBudgets, budgets_for_strictness) live in a private MCP module while the CLI surface imports that private owner directly.
Environment
- Product/Service: CodeClone
- Version: 2.1.0a1 (run
e28867ed)
- Area: Structural Change Controller / patch verification
Current State
codeclone/surfaces/mcp/_patch_contract.py defines StrictnessProfile, PatchBudgets, PatchContractStatus, budgets_for_strictness, detect_baseline_abuse.
- CLI import (cross-surface private dependency):
# codeclone/surfaces/cli/patch_verify.py
from ..mcp._patch_contract import (
VALID_STRICTNESS_PROFILES,
StrictnessProfile,
budgets_for_strictness,
)
- MCP consumers:
_session_patch_contract_mixin.py, _session_workflow_mixin.py.
- AGENTS.md documents shared patch-budget helpers under
codeclone/budget/*, but budget/ currently covers token estimation only.
- Impact blast: medium (reaches
main.py and CLI workflow transitively).
- Precedent:
tests/test_architecture.py forbids non-MCP surfaces from importing codeclone.surfaces.mcp._blast_radius — no equivalent guard for _patch_contract.
Expected Behavior
CLI and MCP are sibling surfaces; shared controller contracts (strictness profiles, patch budgets, baseline-abuse rules) live in a surface-neutral module (e.g. extend codeclone/budget or add codeclone/controller/patch_contract.py). Both surfaces import the same owner.
Actual Behavior
CLI --patch-verify depends on MCP-private _patch_contract internals. Contract changes risk breaking CLI without a documented public boundary.
Impact
Medium — Functional today, but wrong dependency direction for a public controller contract shared by CLI and MCP. Increases risk of CLI/MCP strictness drift.
Proposed Direction
- Extract
PatchBudgets, strictness profiles, and baseline-abuse helpers to a non-surfaces.mcp module.
- Update CLI
patch_verify.py and MCP mixins to import the shared owner.
- Add architecture test mirroring the
_blast_radius import ban for _patch_contract from non-MCP packages (or eliminate the need by promoting the contract).
- Keep token payload estimation in
codeclone/budget/estimator.py separate from gate/budget semantics.
Additional Context
- Architecture triage score: B → 25 (P2).
- Tests:
tests/test_cli_patch_verify.py, tests/test_mcp_service.py (test_mcp_patch_contract_profiles_and_baseline_abuse).
[Architecture] Promote patch-contract strictness/budgets to a surface-neutral owner
Labels:
enhancement,architecture,mcp,cli,change-controlPriority: P2 (architecture triage)
Subject:
codeclone/surfaces/mcp/_patch_contract.pySignal:
ownership_driftTriage run:
e28867ed(health 91/A)Summary
Reusable patch strictness and budget semantics (
PatchBudgets,budgets_for_strictness) live in a private MCP module while the CLI surface imports that private owner directly.Environment
e28867ed)Current State
codeclone/surfaces/mcp/_patch_contract.pydefinesStrictnessProfile,PatchBudgets,PatchContractStatus,budgets_for_strictness,detect_baseline_abuse._session_patch_contract_mixin.py,_session_workflow_mixin.py.codeclone/budget/*, butbudget/currently covers token estimation only.main.pyand CLI workflow transitively).tests/test_architecture.pyforbids non-MCP surfaces from importingcodeclone.surfaces.mcp._blast_radius— no equivalent guard for_patch_contract.Expected Behavior
CLI and MCP are sibling surfaces; shared controller contracts (strictness profiles, patch budgets, baseline-abuse rules) live in a surface-neutral module (e.g. extend
codeclone/budgetor addcodeclone/controller/patch_contract.py). Both surfaces import the same owner.Actual Behavior
CLI
--patch-verifydepends on MCP-private_patch_contractinternals. Contract changes risk breaking CLI without a documented public boundary.Impact
Medium — Functional today, but wrong dependency direction for a public controller contract shared by CLI and MCP. Increases risk of CLI/MCP strictness drift.
Proposed Direction
PatchBudgets, strictness profiles, and baseline-abuse helpers to a non-surfaces.mcpmodule.patch_verify.pyand MCP mixins to import the shared owner._blast_radiusimport ban for_patch_contractfrom non-MCP packages (or eliminate the need by promoting the contract).codeclone/budget/estimator.pyseparate from gate/budget semantics.Additional Context
tests/test_cli_patch_verify.py,tests/test_mcp_service.py(test_mcp_patch_contract_profiles_and_baseline_abuse).