Skip to content

Audit fix

audit_fix

MCP tool for deterministic test-suite auto-fixing.

AuditFixTool

Bases: AXMTool

Run the deterministic test-suite fix pipeline.

Registered as audit_fix via axm.tools entry point.

Source code in packages/axm-audit/src/axm_audit/tools/audit_fix.py
Python
class AuditFixTool(AXMTool):
    """Run the deterministic test-suite fix pipeline.

    Registered as ``audit_fix`` via axm.tools entry point.
    """

    @property
    def name(self) -> str:
        """Return tool name for registry lookup."""
        return "audit_fix"

    def execute(
        self,
        *,
        path: str = ".",
        apply: bool = False,
        rules: list[str] | None = None,
        **kwargs: object,
    ) -> ToolResult:
        """Run the fix pipeline on a project.

        Args:
            path: Path to project root.
            apply: If True, mutate the tree; otherwise dry-run.
            rules: Optional list of rule ids to filter the pipeline.

        Returns:
            ToolResult with a JSON-serializable ``data`` dict and a
            human-readable ``text`` summary.
        """
        try:
            project_path = Path(path).resolve()
            if not project_path.is_dir():
                return ToolResult(
                    success=False, error=f"Not a directory: {project_path}"
                )

            from axm_audit.core.fix import run
            from axm_audit.core.fix.report import format_report

            rules_set = set(rules) if rules is not None else None
            report = run(project_path, apply=apply, rules=rules_set)

            data = _report_to_dict(report)
            text = format_report(report, project_path)

            return ToolResult(success=True, data=data, text=text)
        except Exception as exc:  # noqa: BLE001
            return ToolResult(success=False, error=str(exc))
name property

Return tool name for registry lookup.

execute(*, path='.', apply=False, rules=None, **kwargs)

Run the fix pipeline on a project.

Parameters:

Name Type Description Default
path str

Path to project root.

'.'
apply bool

If True, mutate the tree; otherwise dry-run.

False
rules list[str] | None

Optional list of rule ids to filter the pipeline.

None

Returns:

Type Description
ToolResult

ToolResult with a JSON-serializable data dict and a

ToolResult

human-readable text summary.

Source code in packages/axm-audit/src/axm_audit/tools/audit_fix.py
Python
def execute(
    self,
    *,
    path: str = ".",
    apply: bool = False,
    rules: list[str] | None = None,
    **kwargs: object,
) -> ToolResult:
    """Run the fix pipeline on a project.

    Args:
        path: Path to project root.
        apply: If True, mutate the tree; otherwise dry-run.
        rules: Optional list of rule ids to filter the pipeline.

    Returns:
        ToolResult with a JSON-serializable ``data`` dict and a
        human-readable ``text`` summary.
    """
    try:
        project_path = Path(path).resolve()
        if not project_path.is_dir():
            return ToolResult(
                success=False, error=f"Not a directory: {project_path}"
            )

        from axm_audit.core.fix import run
        from axm_audit.core.fix.report import format_report

        rules_set = set(rules) if rules is not None else None
        report = run(project_path, apply=apply, rules=rules_set)

        data = _report_to_dict(report)
        text = format_report(report, project_path)

        return ToolResult(success=True, data=data, text=text)
    except Exception as exc:  # noqa: BLE001
        return ToolResult(success=False, error=str(exc))