Skip to content

pyflightstream.qa.drift (stable)

Generated from the docstrings at build time: every one of the 6 names in the __all__ of pyflightstream.qa.drift has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

Cross-version drift suite (FR-27, SAD Section 11).

Pipeline role: diffs the same physics case set measured on two FlightStream versions, so a solver release cannot silently move the physics the research depends on. The case set is the Tier 3 registry of :mod:pyflightstream.qa.physics, and the two measurements are two runs of the workspace's physics matrix under two registries, made by :func:pyflightstream.qa.matrix.drift_from_workspace (PFS-2031.17); this module owns the diff and the report and runs nothing itself.

Drift needs no stored references: version A is the baseline and version B is judged against it inside the same WARN and FAIL half widths the case metrics declare, so "the physics moved more than a reference regression would tolerate" means the same thing in both suites. The degenerate self-comparison (same version twice) exercises the whole machinery and must land every delta at zero, since repeat runs on 26.120 proved bit-identical (PHY-26120_2026-07-21_full).

Every executable path is explicit input, one per version, never guessed (SAD Section 5).

Advanced

pyflightstream.qa.drift.DriftCaseResult dataclass

DriftCaseResult(
    case_id: str,
    title: str,
    metrics: dict[str, DriftMetric],
    error: str | None = None,
)

Drift outcome of one physics case.

error carries the failure text when the case aborted on either version; a failed case reports instead of hiding the others.

pyflightstream.qa.drift.DriftMetric dataclass

DriftMetric(
    value_a: float,
    value_b: float,
    delta: float,
    verdict: Verdict,
    warn: float,
    fail: float,
    kind: str,
)

One metric compared across the two versions.

Attributes:

Name Type Description
value_a, value_b float

Measured values on the baseline and the compared version.

delta float

value_b - value_a.

verdict Verdict

Judgment of value_b against the case's declared bands centered on value_a (NO_REFERENCE when the metric is missing from the case's specifications).

warn, fail float

The half widths applied, from the case metric specification.

kind str

Band kind applied (rel or abs).

pyflightstream.qa.drift.DriftRun dataclass

DriftRun(
    version_a: str,
    version_b: str,
    fs_exe_names: dict[str, str],
    package_version: str,
    results: tuple[DriftCaseResult, ...],
    solver_identity: tuple[str, ...] = (),
    fs_exe_sha256s: dict[str, str | None] = dict(),
    executors: dict[str, ExecutorRecord | None] = dict(),
)

One complete cross-version drift comparison.

verdict_counts

verdict_counts() -> dict[str, int]

Count metric verdicts over every case, for the summary line.

aborted_count

aborted_count() -> int

Count the cases that aborted: they carry no metric, so no verdict count holds them.

pyflightstream.qa.drift.diff_runs

diff_runs(run_a: PhysicsRun, run_b: PhysicsRun) -> DriftRun

Diff two physics runs case by case and metric by metric.

Pure reduction over already-measured runs, so the drift judgment is testable without a solver. Metrics are judged with the case's declared bands centered on the version-A value; a metric absent from the case specifications judges NO_REFERENCE rather than inventing a band, and so does a relative metric whose A value is exactly zero. A metric one run lacks judges FAIL, and a case one run lacks is an aborted comparison: neither is skipped.

Parameters:

Name Type Description Default
run_a PhysicsRun

The baseline and compared runs, normally of two different versions on the same case set.

required
run_b PhysicsRun

The baseline and compared runs, normally of two different versions on the same case set.

required

Returns:

Type Description
DriftRun

The comparison: one entry per case present in both runs, then one aborted entry (no metrics, an error naming the run that has it) per case present in one run only.

pyflightstream.qa.drift.drift_report_paths

drift_report_paths(
    out_dir: str | Path,
    *,
    version_a: str,
    version_b: str,
    date: str | None = None,
    label: str | None = None,
) -> tuple[Path, Path]

Return where a drift report for one comparison WOULD be written.

The DRF counterpart of :func:pyflightstream.qa.physics.physics_report_paths, and the one with the most to lose from a second copy: its stem joins TWO build identifiers, so the CLI predicting the name had to reproduce both the dot-stripping and the join order. The two builds are stated in the order compared, A then B, which is the order the report's own body uses; the join is not sorted, so swapping the arguments names a different report rather than the same one.

Parameters:

Name Type Description Default
out_dir str or Path

Target directory, normally reports/physics/.

required
version_a (str, keyword - only)

Version identifiers, as :attr:DriftRun.version_a and :attr:DriftRun.version_b carry. Keyword-only precisely because they are a swappable pair: positionally, transposing them names a different report and complains about nothing.

required
version_b (str, keyword - only)

Version identifiers, as :attr:DriftRun.version_a and :attr:DriftRun.version_b carry. Keyword-only precisely because they are a swappable pair: positionally, transposing them names a different report and complains about nothing.

required
date (str, optional, keyword - only)

ISO date stamped into the stem; defaults to today. A caller that will also write the report should resolve the date once and pass it here AND to :func:write_drift_report.

None
label str

Stem suffix distinguishing several reports on one day.

None

Returns:

Type Description
tuple of Path

The YAML path and the Markdown path, in that order. Neither is created and the directory is not made.

pyflightstream.qa.drift.write_drift_report

write_drift_report(
    run: DriftRun,
    out_dir: str | Path,
    *,
    date: str | None = None,
    label: str | None = None,
) -> tuple[Path, Path]

Write one drift comparison as a report pair (YAML plus Markdown).

Same evidence discipline as the physics reports: the stem is DRF-<A digits>-<B digits>_<date> plus the optional label, under reports/physics/, and an existing report is never overwritten.

Parameters:

Name Type Description Default
run DriftRun

The comparison to record.

required
out_dir str or Path

Target directory, normally reports/physics/.

required
date str

ISO date stamped into the report; defaults to today.

None
label str

Stem suffix distinguishing several reports on one day.

None

Returns:

Type Description
tuple of Path

The YAML path and the Markdown path, in that order.

Raises:

Type Description
FileExistsError

When a report with the same stem already exists.

QaEvidenceError

When the date is not spelled YYYY-MM-DD. The stem carries the string, so a value that cannot go in a file name is refused before the write rather than after it.

(UnknownVersionError, AmbiguousVersionAliasError)

When the run's version is not a registered build, or is a vendor release name shared by several. The stem's build key is resolved through the registry, so these reach a direct Python caller where they did not before. pyfs-qa resolves first and never meets them.