Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 0 additions & 111 deletions polylogue/maintenance/raw_authority_reset.py

This file was deleted.

5 changes: 4 additions & 1 deletion tests/unit/cli/test_archive_maintenance_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,9 +1989,12 @@ def test_raw_authority_frontier_cli_rejects_removed_apply_options(


def test_raw_authority_recovery_cli_refuses_plan_for_another_operation(
cli_workspace: dict[str, Path], cli_runner: CliRunner, tmp_path: Path
cli_workspace: dict[str, Path], cli_runner: CliRunner, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""The required operation is bound before a destructive plan artifact is consumed."""
from polylogue.version import VERSION_INFO

monkeypatch.setattr(VERSION_INFO, "dirty", False)

plan = inspect_raw_authority_recovery(cli_workspace["archive_root"], RecoveryOperation.RESET_CENSUS)
plan_file = tmp_path / "census-reset.plan.json"
Expand Down
27 changes: 18 additions & 9 deletions tests/unit/maintenance/test_raw_authority_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
resume_raw_authority_recovery,
write_recovery_plan,
)
from polylogue.maintenance.raw_authority_reset import (
prune_orphaned_index_revision_seeds,
reset_raw_authority_census,
)
from polylogue.operations.mutation_transaction import OperationExecutor
from polylogue.storage.sqlite.archive_tiers.bootstrap import initialize_active_archive_root
from polylogue.storage.sqlite.archive_tiers.types import ArchiveTier
Expand All @@ -37,6 +33,12 @@
from polylogue.version import VERSION_INFO


@pytest.fixture(autouse=True)
def _clean_recovery_build(monkeypatch: pytest.MonkeyPatch) -> None:
"""Exercise recovery against the signed-build condition each test models."""
monkeypatch.setattr(VERSION_INFO, "dirty", False)


def _seed_ledger(source_db: Path) -> None:
with sqlite3.connect(source_db) as conn:
conn.execute(
Expand Down Expand Up @@ -534,10 +536,11 @@ def test_census_reset_dry_run_does_not_mutate_and_apply_requires_backup(tmp_path
_seed_ledger(tmp_path / "source.db")
_seed_raw(tmp_path / "source.db", "r-keep")
before = (tmp_path / "source.db").read_bytes()
reset_raw_authority_census(tmp_path, dry_run=True)
inspect_raw_authority_recovery(tmp_path, RecoveryOperation.RESET_CENSUS)
assert (tmp_path / "source.db").read_bytes() == before
plan = inspect_raw_authority_recovery(tmp_path, RecoveryOperation.RESET_CENSUS)
with pytest.raises(RawAuthorityRecoveryError, match="backup authority"):
reset_raw_authority_census(tmp_path, dry_run=False)
apply_raw_authority_recovery(plan)
assert (tmp_path / "source.db").read_bytes() == before


Expand Down Expand Up @@ -963,11 +966,17 @@ def test_index_recovery_actuator_receipt_retains_authorized_plan_identity(
assert receipt.affected_count == 2


def test_named_compatibility_facade_requires_index_backup(tmp_path: Path) -> None:
def test_index_prune_requires_index_backup(tmp_path: Path) -> None:
initialize_active_archive_root(tmp_path)
_seed_index_seeds(tmp_path)
active_index = _seed_index_seeds(tmp_path)
archive_index = tmp_path / "index.db"
before_active = active_index.read_bytes()
before_archive = archive_index.read_bytes()
plan = inspect_raw_authority_recovery(tmp_path, RecoveryOperation.PRUNE_INDEX_SEEDS)
with pytest.raises(RawAuthorityRecoveryError, match="backup authority"):
prune_orphaned_index_revision_seeds(tmp_path, dry_run=False)
apply_raw_authority_recovery(plan)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
assert active_index.read_bytes() == before_active
assert archive_index.read_bytes() == before_archive


def test_storage_compatibility_helpers_refuse_direct_mutation(tmp_path: Path) -> None:
Expand Down