Fix 3 architectural bottlenecks blocking cross-domain adoption
Bottleneck 1: ImageHashes generalization
- phash and dhash now default to "" (optional), enabling attestation
of CSV datasets, sensor logs, documents, and any non-image file
- Added ImageHashes.from_file() for arbitrary file attestation
(SHA-256 only, no perceptual hashes)
- Added ImageHashes.is_image property to check if perceptual matching
is meaningful
- Added content_type field to AttestationRecord ("image", "document",
"data", "audio", "video") — backward compatible, defaults to "image"
- from_dict() now tolerates missing phash/dhash fields
Bottleneck 2: Lazy path resolution
- Converted 5 modules from eager top-level path imports to lazy
access via `import soosef.paths as _paths`:
config.py, deadman.py, usb_monitor.py, tamper.py, anchors.py
- Paths now resolve at use-time, not import-time, so --data-dir
and SOOSEF_DATA_DIR overrides propagate correctly to all modules
- Enables portable mode (run entirely from USB stick)
- Updated deadman enforcement tests for new path access pattern
Bottleneck 3: Delivery acknowledgment chain records
- New CONTENT_TYPE_DELIVERY_ACK = "soosef/delivery-ack-v1"
- ChainStore.append_delivery_ack() records bundle receipt with
sender fingerprint and record count
- import_attestation_bundle() auto-generates ack when chain store
and private key are provided
- Enables two-way federation handshakes (art provenance, legal
chain of custody, multi-org evidence exchange)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -64,7 +64,7 @@ def test_enforcement_loop_no_op_when_disarmed(tmp_path: Path, monkeypatch: pytes
|
||||
|
||||
# Redirect the module-level DEADMAN_STATE constant so DeadmanSwitch() default is our tmp file
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
check_calls = []
|
||||
|
||||
@@ -94,7 +94,7 @@ def test_enforcement_loop_fires_when_overdue(tmp_path: Path, monkeypatch: pytest
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
last_checkin = datetime.now(UTC) - timedelta(hours=100)
|
||||
_write_deadman_state(
|
||||
@@ -124,7 +124,7 @@ def test_enforcement_loop_exits_after_firing(tmp_path: Path, monkeypatch: pytest
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
last_checkin = datetime.now(UTC) - timedelta(hours=100)
|
||||
_write_deadman_state(state_file, armed=True, last_checkin=last_checkin)
|
||||
@@ -149,7 +149,7 @@ def test_enforcement_loop_tolerates_exceptions(tmp_path: Path, monkeypatch: pyte
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
call_count = [0]
|
||||
|
||||
@@ -212,7 +212,7 @@ def test_check_deadman_disarmed(
|
||||
|
||||
# Point at an empty tmp dir so the real ~/.soosef/fieldkit/deadman.json isn't read
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
result = cli_runner.invoke(main, ["fieldkit", "check-deadman"])
|
||||
assert result.exit_code == 0
|
||||
@@ -227,7 +227,7 @@ def test_check_deadman_armed_ok(
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
last_checkin = datetime.now(UTC) - timedelta(hours=1)
|
||||
_write_deadman_state(
|
||||
@@ -251,7 +251,7 @@ def test_check_deadman_overdue_in_grace(
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
# Past 24h interval but within 26h total (grace=2)
|
||||
last_checkin = datetime.now(UTC) - timedelta(hours=25)
|
||||
@@ -277,7 +277,7 @@ def test_check_deadman_fires_when_expired(
|
||||
from soosef.fieldkit import deadman as deadman_mod
|
||||
|
||||
state_file = tmp_path / "deadman.json"
|
||||
monkeypatch.setattr(deadman_mod, "DEADMAN_STATE", state_file)
|
||||
monkeypatch.setattr(deadman_mod, "_paths", type("P", (), {"DEADMAN_STATE": state_file}))
|
||||
|
||||
last_checkin = datetime.now(UTC) - timedelta(hours=100)
|
||||
_write_deadman_state(
|
||||
|
||||
Reference in New Issue
Block a user