Skip to content

phases

strands_teams.phases

Generic, phase-enum-agnostic phase specification.

The pre-split consumer/phases.py hardcoded a 5-value AnalysisPhase IntEnum plus codebase-specific tool→phase and phase-name maps. PhaseSpec generalizes that: a use case supplies its own phase indices, names, descriptions, tool→phase map, and tool-name prefix rules. The display layer (Wave D) reads count and names instead of a literal /5.

Phases are identified by 1-based integer index (order matters). No enum is imposed — a use case may still back the indices with its own IntEnum and pass int(member) values.

PhaseSpec dataclass

PhaseSpec(
    names,
    descriptions=dict(),
    tool_phase_map=dict(),
    prefix_rules=dict(),
)

Describes the ordered phases of a run for progress display and tagging.

Attributes:

Name Type Description
names Mapping[int, str]

Map of phase index (1-based) to human-readable phase name.

descriptions Mapping[int, str]

Map of phase index to a one-line description.

tool_phase_map Mapping[str, int]

Map of exact tool name to the phase index it belongs to.

prefix_rules Mapping[str, int]

Map of tool-name prefix to a phase index, applied when no exact match is found in tool_phase_map (e.g., "gitnexus_").

count property

count

Total number of phases (the N in a [i/N] indicator).

name

name(phase)

Return the display name for a phase index, or a fallback label.

Source code in packages/strands-teams/src/strands_teams/phases.py
def name(self, phase: int) -> str:
    """Return the display name for a phase index, or a fallback label."""
    return self.names.get(phase, f"Phase {phase}")

description

description(phase)

Return the description for a phase index, or an empty string.

Source code in packages/strands-teams/src/strands_teams/phases.py
def description(self, phase: int) -> str:
    """Return the description for a phase index, or an empty string."""
    return self.descriptions.get(phase, "")

resolve

resolve(tool_name)

Resolve a tool name to its phase index.

Checks the exact tool_phase_map first, then prefix_rules.

Parameters:

Name Type Description Default
tool_name str

The invoked tool's name.

required

Returns:

Type Description
int | None

The phase index, or None if the tool maps to no phase.

Source code in packages/strands-teams/src/strands_teams/phases.py
def resolve(self, tool_name: str) -> int | None:
    """Resolve a tool name to its phase index.

    Checks the exact ``tool_phase_map`` first, then ``prefix_rules``.

    Args:
        tool_name: The invoked tool's name.

    Returns:
        The phase index, or ``None`` if the tool maps to no phase.
    """
    phase = self.tool_phase_map.get(tool_name)
    if phase is not None:
        return phase
    for prefix, mapped in self.prefix_rules.items():
        if tool_name.startswith(prefix):
            return mapped
    return None