feat(prompts): implement Phase 6 - Incremental Execution (FR-7, FR-8)
Add change detection, structural diff-based impact analysis, configurable-depth incremental recomputation with circular suppression, and impact debt tracking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
markitect/prompts/incremental/impact.py
Normal file
57
markitect/prompts/incremental/impact.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""
|
||||
Impact analyzer for assessing change significance.
|
||||
|
||||
Implements FR-8: Impact Analysis
|
||||
Stateless analyzer that computes change magnitude and decides
|
||||
whether recomputation is warranted based on configurable thresholds.
|
||||
"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from markitect.prompts.incremental.metrics import calculate_change_magnitude
|
||||
from markitect.prompts.incremental.models import RecomputeConfig
|
||||
|
||||
|
||||
class ImpactAnalyzer:
|
||||
"""
|
||||
Stateless impact analyzer for artifact changes.
|
||||
|
||||
Computes change magnitude using diff metrics and compares against
|
||||
configurable thresholds to determine whether recomputation is needed.
|
||||
"""
|
||||
|
||||
def calculate_magnitude(
|
||||
self,
|
||||
old_content: Optional[str],
|
||||
new_content: Optional[str],
|
||||
method: str = "structural",
|
||||
) -> float:
|
||||
"""
|
||||
Calculate the magnitude of a change.
|
||||
|
||||
Args:
|
||||
old_content: Previous content (None for creation)
|
||||
new_content: Current content (None for deletion)
|
||||
method: Diff method ("structural" or "line")
|
||||
|
||||
Returns:
|
||||
Change magnitude from 0.0 to 1.0
|
||||
"""
|
||||
return calculate_change_magnitude(old_content, new_content, method)
|
||||
|
||||
def should_recompute(
|
||||
self,
|
||||
magnitude: float,
|
||||
config: RecomputeConfig,
|
||||
) -> bool:
|
||||
"""
|
||||
Determine whether a dependent should be recomputed based on magnitude.
|
||||
|
||||
Args:
|
||||
magnitude: Change magnitude (0.0-1.0)
|
||||
config: Recompute configuration with threshold
|
||||
|
||||
Returns:
|
||||
True if magnitude meets or exceeds threshold
|
||||
"""
|
||||
return magnitude >= config.impact_threshold
|
||||
Reference in New Issue
Block a user