Skip to content

evidence_gate

strands_teams.evidence_gate

The evidence gate — a blocking finding must carry evidence.

ASTR §4.5 makes communication evidence-bearing; the NarrativeRubric specificity dimension already scores citation density over a narrative via :data:~strands_teams.rubric.FILE_LINE_PATTERN. This module binds that same citation-density concept to a typed :class:~strands_teams.models.Finding: a blocking=True finding must carry ≥1 evidence ref, or it is flagged rather than silently accepted.

To keep the "evidence density" definition in exactly one place (AC-5-4), the gate reuses FILE_LINE_PATTERN to recognize inline file.ext:line citations in a finding's statement and evidence uris, rather than introducing a second, divergent citation heuristic. An explicit :class:~strands_teams.models.Evidence ref and an inline file:line citation both count toward the same evidence-ref tally.

The gate is a pure function over already-parsed Finding objects; it does no I/O and never raises, so both the write path (write_findings) and the read path (read_team_findings) can call it and surface an evidence_gate summary in their JSON results.

EvidenceGateResult

Bases: FrozenModel

Outcome of running the evidence gate over one or more findings.

Attributes:

Name Type Description
passed bool

True when no blocking finding lacks evidence.

flagged list[str]

Statements of the blocking findings that carry no evidence.

checked int

Total number of findings evaluated.

finding_passes_gate

finding_passes_gate(finding)

Return whether a single finding satisfies the evidence gate (AC-5-1, AC-5-5).

A finding passes when it is non-blocking (evidence optional — AC-5-5) or when it carries ≥1 evidence ref. It fails only when blocking is True and it has zero evidence refs.

Source code in packages/strands-teams/src/strands_teams/evidence_gate.py
def finding_passes_gate(finding: Finding) -> bool:
    """Return whether a single finding satisfies the evidence gate (AC-5-1, AC-5-5).

    A finding passes when it is non-blocking (evidence optional — AC-5-5) or when
    it carries ≥1 evidence ref. It fails only when ``blocking`` is True and it has
    zero evidence refs.
    """
    if not finding.blocking:
        return True
    return _evidence_ref_count(finding) >= 1

evaluate_evidence_gate

evaluate_evidence_gate(findings)

Evaluate the evidence gate over a collection of findings (AC-5-1..5-3).

Parameters:

Name Type Description Default
findings Iterable[Finding]

The typed findings to check.

required

Returns:

Name Type Description
An EvidenceGateResult

class:EvidenceGateResult: passed is False when any

EvidenceGateResult

blocking=True finding lacks evidence, and flagged names each such

EvidenceGateResult

finding's statement so the coordinator can act on the gap.

Source code in packages/strands-teams/src/strands_teams/evidence_gate.py
def evaluate_evidence_gate(findings: Iterable[Finding]) -> EvidenceGateResult:
    """Evaluate the evidence gate over a collection of findings (AC-5-1..5-3).

    Args:
        findings: The typed findings to check.

    Returns:
        An :class:`EvidenceGateResult`: ``passed`` is False when any
        ``blocking=True`` finding lacks evidence, and ``flagged`` names each such
        finding's statement so the coordinator can act on the gap.
    """
    flagged: list[str] = []
    checked = 0
    for finding in findings:
        checked += 1
        if not finding_passes_gate(finding):
            flagged.append(finding.statement)
    return EvidenceGateResult(passed=not flagged, flagged=flagged, checked=checked)

gate_findings

gate_findings(findings)

Return the evidence-gate summary as a plain dict for embedding in tool JSON.

Convenience wrapper around :func:evaluate_evidence_gate producing the evidence_gate block used by the write and read tool results (AC-5-2, AC-5-3).

Source code in packages/strands-teams/src/strands_teams/evidence_gate.py
def gate_findings(findings: Iterable[Finding]) -> dict[str, object]:
    """Return the evidence-gate summary as a plain dict for embedding in tool JSON.

    Convenience wrapper around :func:`evaluate_evidence_gate` producing the
    ``evidence_gate`` block used by the write and read tool results (AC-5-2, AC-5-3).
    """
    result = evaluate_evidence_gate(findings)
    return {"passed": result.passed, "flagged": result.flagged, "checked": result.checked}