- Evolucao: Round 14 (Agency Engineering)
- Fonte: agency-agents/engineering/engineering-minimal-change-engineer.md
- Categoria: agency/engineering
- Versao: 1.0.0
Motor de validacao de diffs minimos. Analisa patches/diffs para detectar scope creep, mudancas desnecessarias, refatoracoes prematuras e alteracoes fora do escopo declarado. Opera offline com stdlib Python 3.12.
- Dado: diff com arquivos modificados e escopo declarado (ex: ["src/auth.py"])
- Quando:
engine.check_scope(diff_text, scope_files)e chamado - Entao: retorna
ScopeCheckcomout_of_scopelistando arquivos nao declarados eviolation= True se houver violacoes
- Dado: diff que renomeia variaveis/funcoes alem do necessario para o bugfix
- Quando:
engine.detect_premature_refactor(diff_text)e chamado - Entao: retorna
RefactorDetectioncomsuspicious_renameserisk_score> 0
- Dado: diff com multiplos hunks
- Quando:
engine.measure_entropy(diff_text)e chamado - Entao: retorna
DiffEntropycomfiles_changed,hunks_count,lines_added,lines_removedeentropy_score(0-100)
- Dado: diff onde 80% das alteracoes sao formatacao/estilo
- Quando:
engine.validate_change_ratio(diff_text)e chamado - Entao: retorna
ChangeRatiocomfunctional_changes,cosmetic_changes,ratioewarningse ratio < 0.3
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class ScopeCheck:
in_scope: list[str]
out_of_scope: list[str]
violation: bool
available: bool = True
@dataclass
class RefactorDetection:
suspicious_renames: list[dict] # [{old_name, new_name, line, reason}]
risk_score: int # 0-100
available: bool = True
@dataclass
class DiffEntropy:
files_changed: int
hunks_count: int
lines_added: int
lines_removed: int
entropy_score: int # 0-100, higher = more scattered
available: bool = True
@dataclass
class ChangeRatio:
functional_changes: int
cosmetic_changes: int
ratio: float # functional / total
warning: bool # True se muito cosmetico
available: bool = True
class MinimalChangeEngine:
@property
def available(self) -> bool: ...
def check_scope(self, diff_text: str, scope_files: list[str]) -> ScopeCheck: ...
def detect_premature_refactor(self, diff_text: str) -> RefactorDetection: ...
def measure_entropy(self, diff_text: str) -> DiffEntropy: ...
def validate_change_ratio(self, diff_text: str) -> ChangeRatio: ...