Coverage for lintro / config / execution_config.py: 100%
17 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"""Execution configuration model."""
3import os
4from typing import Literal
6from pydantic import BaseModel, ConfigDict, Field
8# Supported artifact formats for side-channel output
9ArtifactFormat = Literal["json", "csv", "markdown", "html", "sarif", "plain"]
12def _get_default_max_workers() -> int:
13 """Get default max workers based on CPU count.
15 Returns:
16 Number of CPUs available, clamped between 1 and 32.
17 """
18 cpu_count = os.cpu_count() or 4
19 return max(1, min(cpu_count, 32))
22class ExecutionConfig(BaseModel):
23 """Execution control settings.
25 Attributes:
26 model_config: Pydantic model configuration.
27 enabled_tools: List of tool names to run. If empty/None, all tools run.
28 tool_order: Execution order strategy. One of:
29 - "priority": Use default priority (formatters before linters)
30 - "alphabetical": Alphabetical order
31 - list[str]: Custom order as explicit list
32 fail_fast: Stop on first tool failure.
33 parallel: Run tools in parallel where possible.
34 max_workers: Maximum number of parallel workers (default: CPU count).
35 auto_install_deps: Auto-install Node.js dependencies if node_modules
36 is missing. None means unset (falls back to container detection),
37 True/False explicitly enables/disables.
38 max_fix_retries: Maximum number of fix→verify cycles for converging
39 formatters (default: 3). Some formatters need multiple passes.
40 artifacts: Side-channel artifact formats to write alongside the
41 primary output. Supports all output formats: json, csv,
42 markdown, html, sarif, plain. When ``GITHUB_ACTIONS=true``
43 is detected, SARIF is emitted automatically even if this
44 list is empty.
45 """
47 model_config = ConfigDict(frozen=False, extra="forbid")
49 enabled_tools: list[str] = Field(default_factory=list)
50 tool_order: str | list[str] = "priority"
51 fail_fast: bool = False
52 parallel: bool = True
53 max_workers: int = Field(default_factory=_get_default_max_workers, ge=1, le=32)
54 auto_install_deps: bool | None = None
55 max_fix_retries: int = Field(default=3, ge=1, le=10)
56 artifacts: list[ArtifactFormat] = Field(default_factory=list)