Skip to content

Commit fe87c43

Browse files
committed
fix(self-host): make snapshot authority opt-in; default to repo_state_sync
1 parent 9697831 commit fe87c43

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/shieldcraft/services/sync/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ def verify_repo_state_authoritative(repo_root: str = ".") -> Dict[str, str]:
146146
Raises SyncError or SnapshotError on deterministic failures.
147147
"""
148148
import logging
149-
authority = os.getenv("SHIELDCRAFT_SYNC_AUTHORITY", "snapshot")
149+
# Default authority is repo_state_sync (use external repo_state_sync artifacts)
150+
authority = os.getenv("SHIELDCRAFT_SYNC_AUTHORITY", "repo_state_sync")
150151

151152
# External mode: issue migration warning and rely on existing verify_repo_sync.
152153
if authority == "external":
@@ -159,7 +160,13 @@ def verify_repo_state_authoritative(repo_root: str = ".") -> Dict[str, str]:
159160
res["authority"] = "external"
160161
return res
161162

162-
# Snapshot-based authority
163+
# 'repo_state_sync' mode: verify external repo_state_sync.json and associated artifacts
164+
if authority == "repo_state_sync":
165+
res = verify_repo_sync(repo_root)
166+
res["authority"] = "repo_state_sync"
167+
return res
168+
169+
# Snapshot-based authority (opt-in only)
163170
from shieldcraft.snapshot import validate_snapshot, generate_snapshot, DEFAULT_SNAPSHOT_PATH, SnapshotError
164171

165172
snapshot_path = os.path.join(repo_root, DEFAULT_SNAPSHOT_PATH)

tests/ci/test_v1_invariants.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33

44

55
def test_snapshot_authority_is_default(monkeypatch, tmp_path):
6-
from shieldcraft.services.sync import verify_repo_state_authoritative
7-
from shieldcraft.snapshot import SnapshotError
6+
from shieldcraft.services.sync import verify_repo_state_authoritative, SyncError
87

9-
# Unset any explicit authority and ensure snapshot is used by default
8+
# Unset any explicit authority and ensure repo_state_sync is used by default
109
monkeypatch.delenv('SHIELDCRAFT_SYNC_AUTHORITY', raising=False)
1110
monkeypatch.delenv('SHIELDCRAFT_ALLOW_EXTERNAL_SYNC', raising=False)
1211

13-
# In a fresh tmp dir with no snapshot artifact, snapshot mode should raise SnapshotError
14-
with pytest.raises(SnapshotError):
12+
# In a fresh tmp dir with no repo_state_sync artifact, default mode should raise SyncError
13+
with pytest.raises(SyncError):
1514
verify_repo_state_authoritative(str(tmp_path))
1615

1716

0 commit comments

Comments
 (0)