# Local snapshots

Using `context` and `whole` from the reference fingerprint example:

```python
from time import time_ns
from uuid import uuid4
from pipewhy.snapshots import LocalSnapshotStore, SnapshotMetadata

captured_at = time_ns()
metadata = SnapshotMetadata(
    snapshot_id=uuid4().hex,
    source_namespace="example", source_version="fixture-v1",
    source_consistency="immutable-input", scope="three example records",
    started_at_ns=captured_at, finished_at_ns=captured_at,
    context=context, resolution="dataset", coverage="COMPLETE",
    expected_records=whole.count, returned_records=whole.count,
)
store = LocalSnapshotStore("snapshots-example")
store.publish(metadata, {"fingerprint": whole.words})
reopened = store.open(metadata.snapshot_id)
```

Publication stages and validates a complete package before its directory becomes
visible. Reopening verifies manifest and payload checksums and returns read-only
arrays. Preserve actual read-window times and coverage evidence for real scans.
Different retained source versions and resolutions remain explicit in metadata.

`store.inspect_incomplete()` reports interrupted attempts without changing them.
Snapshots and attempts are retained until an explicit cleanup policy is applied.
After an error following the final rename, inspect the exact ID before retrying;
the valid snapshot may already be published. The initial qualification covers local
process interruption on Windows/Linux, with no power-loss or remote-filesystem
durability guarantee. See [blueprint/SNAPSHOT_CONTRACT.txt](../development/architecture.rst) for the lifecycle.

`poetry run python -m pytest tests/integration` separately exercises model reopening
and real interrupted writers; CI runs it in addition to unit coverage.
