43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
# SPDX-FileCopyrightText: 2026 Art Sea LLC
|
|
#
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
"""Construct failure-source candidates from canonical managed paths."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from band_aider.context.class_meta import ClassMeta
|
|
from band_aider.context.failing_test import FailingTest
|
|
from band_aider.judgement.failure_source_candidate_selection_strategy import (
|
|
FailureCandidateScope,
|
|
FailureSourceCandidateSelectionStrategy,
|
|
)
|
|
from band_aider.judgement.file_manager import FileManager
|
|
from band_aider.judgement.source_needed_to_understand_failure_check import SourceNeededToUnderstandFailureCheck
|
|
|
|
|
|
class MechanicalFailureSourceCandidateSelectionStrategy(FailureSourceCandidateSelectionStrategy):
|
|
"""Construct scoped managed candidates named in a failure trace.
|
|
|
|
Example: a trace containing ``source/component:12`` selects the manager-owned
|
|
``source/component`` metadata without assuming a language or file extension.
|
|
"""
|
|
|
|
def candidates_for_failure(
|
|
self,
|
|
*,
|
|
file_manager: FileManager,
|
|
failure: FailingTest,
|
|
scope: FailureCandidateScope,
|
|
) -> list[ClassMeta]:
|
|
"""Return managed files whose canonical paths occur in the failure trace."""
|
|
|
|
check = SourceNeededToUnderstandFailureCheck(
|
|
file_manager=file_manager,
|
|
scope=scope,
|
|
failure_error_message="",
|
|
failure_stack_trace=list(failure.stack_trace),
|
|
failure_raw_output="",
|
|
)
|
|
check()
|
|
return list(check.matching_files)
|