Coverage for lintro / ai / fix_params.py: 100%
26 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Parameter objects for AI fix generation.
3Groups the many parameters passed through the fix pipeline into
4a single frozen dataclass, reducing argument-list bloat and making
5the call signatures easier to read and maintain.
6"""
8from __future__ import annotations
10from collections.abc import Callable
11from dataclasses import dataclass, field
12from pathlib import Path
14from lintro.ai.enums.sanitize_mode import SanitizeMode
15from lintro.ai.fix_context import CONTEXT_LINES
18@dataclass(frozen=True)
19class FixGenParams:
20 """Immutable parameter bundle for fix generation.
22 Passed through ``generate_fixes`` → ``_generate_single_fix`` →
23 ``build_fix_context`` so that adding a new parameter only requires
24 one change site instead of threading it through every function.
26 Attributes:
27 workspace_root: Root directory limiting AI file access.
28 tool_name: Name of the tool that produced these issues.
29 max_tokens: Maximum tokens requested per fix generation call.
30 max_retries: Maximum retry attempts for transient API failures.
31 timeout: Request timeout in seconds per API call.
32 context_lines: Lines of context before/after the issue line.
33 max_prompt_tokens: Token budget for the prompt.
34 base_delay: Initial retry delay in seconds.
35 max_delay: Maximum retry delay in seconds.
36 backoff_factor: Retry backoff multiplier.
37 enable_cache: Whether to use suggestion deduplication cache.
38 cache_ttl: Time-to-live in seconds for cached suggestions.
39 cache_max_entries: Maximum file cache entries to limit memory.
40 max_issues: Maximum number of issues to process.
41 max_workers: Maximum concurrent API calls.
42 fallback_models: Ordered fallback model identifiers.
43 sanitize_mode: How to handle prompt injection patterns.
44 progress_callback: Optional callback after each fix completes.
45 """
47 workspace_root: Path
48 tool_name: str = ""
49 max_tokens: int = 2048
50 max_retries: int = 2
51 timeout: float = 60.0
52 context_lines: int = CONTEXT_LINES
53 max_prompt_tokens: int = 12000
54 base_delay: float = 1.0
55 max_delay: float = 30.0
56 backoff_factor: float = 2.0
57 enable_cache: bool = False
58 cache_ttl: int = 3600
59 cache_max_entries: int = 1000
60 max_issues: int = 20
61 max_workers: int = 5
62 fallback_models: list[str] = field(default_factory=list)
63 sanitize_mode: SanitizeMode = SanitizeMode.WARN
64 progress_callback: Callable[[int, int], None] | None = None