Skip to content

mostlyright.core.source_identity

Canonical home for the assert_source_identity source-pinning check.

assert_source_identity validates source identity; it is not a “mode”. Its implementation lives here and is re-exported from mostlyright.core, so callers reach it as from mostlyright.core import assert_source_identity without touching the deprecated mostlyright.mode2 path.

Imports run one way: core defines the function and the deprecated mode2 module imports it for backward compatibility. The reverse (core importing mode2) would be a partial-initialization cycle, because mode2 already imports mostlyright.core.exceptions at module load.

FunctionDescription
assert_source_identity(df, expected_source, *)Raise SourceMismatchError if any row’s source != expected.

mostlyright.core.source_identity.assert_source_identity(df, expected_source, , role=‘observations’)

Section titled “mostlyright.core.source_identity.assert_source_identity(df, expected_source, , role=‘observations’)”

Raise SourceMismatchError if any row’s source != expected.

A defense-in-depth per-row check: it repeats the per-row check in mostlyright.core.validator.validate_dataframe() at the point where a source-pinned fetch is dispatched, so callers get a role-specific error message when a pinned single-source frame carries a foreign row.

  • Parameters:
    • df (DataFrame) – The DataFrame to check. If it has no source column the function is a silent no-op (the Validator handles that case).
    • expected_source (str) – The source every row must carry.
    • role (str) – The role label surfaced on the raised error (default "observations").
  • Raises: SourceMismatchError – when one or more rows carry a source other than expected_source.
  • Return type: None