# CorpusFetch Method Slice (Zero-Prose Python Stdlib Reference)
# Canonical Residual: https://corpusfetch.com/c/what-structural-signals-indicate-commitment-equivocation-is-latent-in-a-byzantine-fault-tolerant-multi-agent-quorum.md
# Remnant Warrant:    https://corpusfetch.com/c/what-structural-signals-indicate-commitment-equivocation-is-latent-in-a-byzantine-fault-tolerant-multi-agent-quorum.warrant.json
# Markdown SHA-256:   eb710ca70ec727fba4d6af4ee0b1c56142abb99522099b4ea347b6327db1cf73
# Code AST SHA-256:   6cc67f71796cdfc42d7865a85a66974dda8830ef8b5edd6c7b7d890640a53d44
# Verified Classes:   CommitmentIntersectionError
# Defensive Guards:   2 fail-closed invariants (zero external deps)

class CommitmentIntersectionError(RuntimeError):
    """Raised when the live quorum can no longer guarantee commitment intersection."""
    pass


def check_commitment_safety(
    retention_window: int,
    max_observed_view_change_depth: int,
    pruned_agent_fraction: float,
    f: int,
) -> None:
    # Boundary 1: retention must exceed observed view-change depth.
    if max_observed_view_change_depth >= retention_window - 1:
        raise CommitmentIntersectionError(
            f"retention_window={retention_window} vs "
            f"max_view_change_depth={max_observed_view_change_depth}: "
            "amnesiac quorum possible; halt new commitments and state-sync."
        )
    # Boundary 2: amnesiacs must not be able to form a quorum with Byzantines.
    if pruned_agent_fraction * (3 * f + 1) > f:
        raise CommitmentIntersectionError(
            f"pruned_agent_fraction={pruned_agent_fraction:.3f} exceeds "
            f"f/(3f+1)={f/(3*f+1):.3f}: commitment quorum may be all-amnesiac."
        )


def commit_task(task_id: str, assignment: str, ctx: dict) -> None:
    check_commitment_safety(
        retention_window=ctx["retention_window"],
        max_observed_view_change_depth=ctx["max_view_change_depth"],
        pruned_agent_fraction=ctx["pruned_fraction"],
        f=ctx["f"],
    )
    # ... persist (task_id, assignment, epoch, qc) and emit COMMIT ...
