Home / Architecture / Part 10
23 min read 4643 words Part 10 Large Snapshot Streaming Bootstrap
Normative Invariants:

Aequora Sync — Part 10

Large Snapshot, Streaming Bootstrap, and Resumable Transfer Architecture

Implementation status (2026-08-20): Complete at the reusable repository boundary. Durable jobs, deterministic manifests and chunks, range-resume identity, bounded verification/install, staging generations, retention leases, pending-intent preservation, atomic activation evidence, fault tests, telemetry, CLI inspection, and invariants are mapped in docs/large-snapshot-streaming-bootstrap-completion.md. Real database read views, object storage/CDN delivery, native generation transactions, and production-scale resource/catch-up acceptance remain adapter and deployment gates.

1. Purpose

Aequora already supports bootstrap snapshots for bringing a new or reset client to a known authoritative state.

That is sufficient for small datasets, but real deployments may need to bootstrap:

hundreds of thousands of entities
millions of entities
gigabytes of structured data
large offline school/branch datasets
document metadata plus blob references
clients reconnecting after long inactivity
clients rebuilding after corruption
clients moving to a new local database engine

A simple design such as:

GET one giant snapshot
↓
deserialize entire payload
↓
write everything

does not scale.

It causes:

large memory spikes
long transactions
poor resumability
restarts from zero after failure
mobile background execution problems
expensive retries
slow perceived startup

Aequora therefore needs a dedicated architecture for:

streaming snapshot production
chunk manifests
resumable transfer
integrity verification
staging installation
atomic activation
delta catch-up
resource throttling
scope-aware partial bootstrap

The central rule is:

A bootstrap must be resumable, bounded, verifiable, and atomic at the activation boundary even when the physical transfer spans thousands of chunks and many transactions.


2. Goals

The large-bootstrap subsystem should provide:

multi-GB dataset support
bounded RAM
bounded local transaction size
resumable download
resumable install
chunk verification
parallel transfer where useful
network adaptation
mobile-friendly execution
scope independence
safe failure recovery
atomic logical cutover

3. Non-Goals

Bootstrap should not:

hold one DB transaction for hours
require all data in memory
advance normal cursor before install is safe
mix old and new generations invisibly
depend on one uninterrupted HTTP connection

4. Bootstrap Model

Bootstrap should be modeled as a multi-phase durable workflow:

Plan
↓
Acquire Manifest
↓
Download Chunks
↓
Verify Chunks
↓
Install Into Staging
↓
Verify Staging
↓
Activate
↓
Catch Up Delta
↓
Complete

5. BootstrapJob

Define:

pub struct BootstrapJobId(Uuid);

Every large bootstrap is represented by durable local state.


6. Bootstrap State

pub enum BootstrapState {
    Requested,
    Planning,
    Downloading,
    Installing,
    Verifying,
    ReadyToActivate,
    Activating,
    CatchingUp,
    Complete,
    Failed,
    Quarantined,
}

7. Scope Awareness

Bootstrap must be scoped.

Each job is bound to:

ScopeId
ScopeVersion
ScopeGeneration
ProjectionSchemaVersion

This allows one scope to rebuild without resetting unrelated scopes.


8. Snapshot Boundary

Every manifest identifies a consistent authoritative boundary:

pub struct SnapshotBoundary {
    pub scope_id: ScopeId,
    pub scope_generation: ScopeGeneration,
    pub sequence: Sequence,
}

The snapshot represents:

all authoritative state relevant to that scope through sequence N

9. Delta-After-Snapshot Rule

After snapshot at sequence N:

client installs snapshot
↓
normal journal pull starts at N
↓
apply N+1 ...

This is the bridge between bulk state transfer and ordinary synchronization.


10. Snapshot Manifest

Define:

pub struct SnapshotManifest {
    pub snapshot_id: SnapshotId,
    pub boundary: SnapshotBoundary,
    pub schema_version: SnapshotSchemaVersion,
    pub chunk_count: u32,
    pub total_uncompressed_bytes: u64,
    pub total_compressed_bytes: Option<u64>,
    pub root_hash: Digest,
    pub chunks: Vec<ChunkDescriptor>,
}

For very large manifests, chunk descriptors themselves may be paged.


11. ChunkDescriptor

pub struct ChunkDescriptor {
    pub chunk_id: ChunkId,
    pub ordinal: u32,
    pub entity_range: EntityRange,
    pub compressed_bytes: u64,
    pub uncompressed_bytes: u64,
    pub hash: Digest,
    pub compression: CompressionKind,
}

12. Chunk Identity

Chunk ID must be stable for the lifetime of one snapshot.

Do not derive solely from temporary object-storage URL.


13. Deterministic Chunk Ordering

Chunks should have deterministic ordinal/order.

The client must not depend on transfer completion order.


14. Chunking Strategy

Possible strategies:

fixed entity count
fixed uncompressed byte target
entity-range partitions
scope partition
aggregate-grouped chunks

15. Recommended Default

Chunk by:

scope partition
+
target uncompressed size

while never splitting one atomic aggregate representation across incompatible boundaries.


16. Target Chunk Size

Start with configurable target, for example:

4–32 MiB uncompressed

depending on platform and dataset.

Do not hardcode one universal value.


17. Why Not Tiny Chunks

Too-small chunks create:

manifest explosion
request overhead
too many transactions
too many hashes

18. Why Not Huge Chunks

Too-large chunks create:

memory pressure
slow retry
long install transaction
bad mobile behavior

19. Aggregate Boundary

If an aggregate must be installed atomically:

Invoice + lines

do not split it across chunks unless install layer can preserve aggregate atomicity.


20. Snapshot Generation

Server creates snapshot from a consistent read view.

Possible implementations:

MVCC transaction
exported DB snapshot
materialized snapshot table
background snapshot builder consuming journal

21. Snapshot Consistency

All chunks in one snapshot must represent the same boundary.

Never build:

chunk 1 at seq 100
chunk 2 at seq 120

under one manifest pretending to be one snapshot.


22. Snapshot Builder

Server component:

SnapshotCoordinator
↓
SnapshotReader
↓
ChunkEncoder
↓
ChunkStore
↓
ManifestPublisher

23. Snapshot Storage

For small snapshots:

server local disk / DB blob

For large production snapshots:

object storage

is often preferable.


24. Object Storage Role

Object storage stores:

immutable chunk objects
manifest objects

Aequora server still controls:

authorization
snapshot issuance
scope validation
signed/temporary access

25. Database Is Still Authority

Object storage is a delivery mechanism.

It is not the authoritative business database.


26. Signed Download URLs

Server may return temporary signed URLs for chunks.

Benefits:

offload bandwidth
CDN support
large-file efficiency

But authorization must occur before URL issuance.


27. URL Lifetime

Chunk URLs should have limited lifetime.

If expired:

client asks server for refreshed access

without restarting bootstrap.


28. Snapshot Immutability

Once manifest published:

chunk content must never change

If snapshot must be rebuilt:

new SnapshotId

29. Content Addressing

Chunk storage can use:

BLAKE3 digest

as object key or part of key.

This helps deduplication and integrity.


30. Root Hash

Manifest root hash should cover:

ordered chunk descriptors
snapshot metadata
boundary
schema generation

not just concatenate chunk hashes ambiguously.


31. Merkle Manifest

For very large snapshot sets, manifest can itself be Merkle-structured.

This aligns with Part 03 integrity architecture.


32. Client Download State

Persist per chunk:

NotStarted
Downloading
Downloaded
Verified
Installed

33. Durable Chunk Progress

Logical table:

aequora_bootstrap_chunk

Fields:

bootstrap_job_id
chunk_id
ordinal
state
downloaded_bytes
hash
local_path_or_storage_ref
attempts

34. Resume After Restart

Client restarts:

load BootstrapJob
↓
verify manifest still valid
↓
continue from incomplete chunks

No restart from zero.


35. Partial Download Resume

If transport/object storage supports range requests:

resume chunk from byte offset

Otherwise restart only that chunk.


36. Range Request Safety

Resume only when remote object identity is stable.

Use:

ETag/content hash/snapshot ID

to ensure partial file belongs to same object.


37. Temporary File Strategy

Download into:

chunk.tmp

After full verification:

atomic rename → chunk.ready

Do not treat partially downloaded bytes as verified.


38. Chunk Verification

For each chunk:

size check
decompression bound check
BLAKE3 hash check
format validation
schema validation

39. Compression Bomb Protection

Manifest provides expected:

compressed size
uncompressed size

Client enforces configured maximum expansion.

Do not trust compressed stream headers alone.


40. Decode Streaming

Prefer:

stream decompress
↓
stream Postcard records
↓
bounded install buffer

rather than:

decompress whole chunk into RAM

41. Postcard Framing

A chunk containing many records needs explicit record framing.

Example:

chunk header
record_count
[length][record]
[length][record]
...
chunk checksum

Do not rely on ambiguous concatenated Postcard objects.


42. Chunk Header

Potential:

pub struct SnapshotChunkHeader {
    pub magic: [u8; 8],
    pub format_version: u16,
    pub snapshot_id: SnapshotId,
    pub chunk_id: ChunkId,
    pub ordinal: u32,
    pub record_count: u32,
}

43. Record Envelope

pub struct SnapshotRecordEnvelope {
    pub entity: EntityRef,
    pub version: EntityVersion,
    pub projection_schema: ProjectionSchemaVersion,
    pub tombstone: bool,
    pub payload: Bytes,
}

44. Streaming Install

Client should install records incrementally into staging.

Pipeline:

verified chunk
↓
stream decode
↓
bounded batch
↓
staging transaction
↓
checkpoint installed records/chunk

45. No One-Giant Install Transaction

Use bounded DB transactions.

Logical atomicity comes from:

staging generation
+
final activation switch

not from a single hour-long transaction.


46. Staging Generation

Define:

pub struct ReplicaGeneration(u64);

Client currently serves:

generation A

Bootstrap writes:

generation B

in parallel.


47. Staging Isolation

Application reads should continue from active generation A until B is complete.


48. Activation

After all chunks installed and verified:

BEGIN

verify job state
verify scope/manifest
switch active generation A → B
set scope cursor = snapshot boundary
mark bootstrap activation

COMMIT

This is the key logical atomic point.


49. Old Generation Cleanup

Do not immediately delete generation A before B proves usable.

Possible policy:

retain A briefly

for rollback/debug.

Then garbage collect.


50. Activation Crash

If crash before activation commit:

A remains active
B remains staging

If after commit:

B is active

No half-activated state.


51. Catch-Up Phase

Immediately after activation:

cursor = snapshot boundary N
↓
pull journal N+1...

Until current.


52. Snapshot Staleness

Snapshot may have been generated hours earlier.

This is fine if:

journal history after N still retained

53. Retention Contract

Server must not issue a snapshot whose boundary will become unusable before reasonable client completion.

Possible strategy:

pin journal retention for active snapshot

54. Snapshot Lease

Define optional:

pub struct SnapshotLease {
    pub snapshot_id: SnapshotId,
    pub expires_at: Timestamp,
}

While valid, server guarantees:

required post-snapshot journal remains available

55. Long Bootstrap

If job takes longer than lease:

client renews snapshot lease

where policy permits.


56. Snapshot Expiry

If snapshot expires and delta history is gone:

BootstrapRestartRequired

Client can reuse already-downloaded chunks only if new snapshot declares identical content chunks and semantics.

Initial simpler behavior:

restart with new manifest

57. Content Dedup Reuse

Future optimization:

If new snapshot manifest references same content-addressed chunks:

reuse verified local chunks

This can save bandwidth.


58. Parallel Download

Client may download multiple chunks concurrently.

Concurrency bounded by:

device profile
network
battery
memory
server hints

Part 06 scheduler controls this.


59. Parallel Install

Installing chunks concurrently is more complex.

Initial recommendation:

download parallel
install serial or low bounded concurrency

depending on local DB capabilities.


60. Download vs Install Pipeline

Efficient model:

download workers
↓ bounded ready queue
install worker

This overlaps network and disk without unbounded buffering.


61. Backpressure

If installer is slower than downloader:

ready queue fills
↓
download workers pause

62. Disk Budget

Before bootstrap starts, estimate required temporary storage:

compressed chunks
+
staging DB growth
+
safety margin

63. Disk Preflight

If insufficient storage:

do not start large bootstrap

Return:

InsufficientLocalStorage

64. Low-Storage Streaming Mode

If adapter supports streaming direct install without keeping all chunk files:

download one/few chunks
verify
install
delete chunk
continue

This minimizes temporary storage.


65. Resume Tradeoff

Deleting installed chunk means re-download may be needed if staging later becomes invalid.

Policy can choose:

LowStorage
Balanced
FastRecovery

66. Bootstrap Storage Profiles

pub enum BootstrapStorageProfile {
    LowStorage,
    Balanced,
    CacheChunks,
}

67. Mobile Background Constraints

On mobile:

download/install in chunks
persist after every chunk
stop safely when execution budget ends
resume later

68. Foreground Partial Usability

Some applications may want:

core data usable before optional modules finish

Achieve through Part 07 independent scopes.

Do not partially activate one internally inconsistent scope unless projection semantics explicitly support it.


69. Scope-Level Parallel Bootstrap

Example:

Core scope
Attendance scope
Finance scope

Scheduler may bootstrap:

Core first
Attendance second
Finance later

70. Scope Dependency

Respect Part 07 scope dependency graph.

Do not activate dependent scope before required prerequisite scope.


71. Priority

Bootstrap work classes:

RequiredInteractiveBootstrap
NormalBootstrap
BackgroundOptionalBootstrap

Part 06 schedules accordingly.


72. Large Bootstrap Fairness

Do not let one huge bootstrap monopolize all network.

Yield to:

interactive outgoing operations
small journal pulls
critical repairs

73. Live Hint During Bootstrap

Part 08 hints may arrive while bootstrap is running.

Do not process them as direct state changes.

Record:

sync needed after boundary

Catch up after activation.


74. Pending Local Operations During Bootstrap

Critical case.

Client may have pending unsynced operations when rebootstrap begins.

Never discard them.


75. Pending Preservation Flow

freeze/export pending intent metadata
↓
bootstrap staging authoritative base
↓
activate new generation
↓
Part 04 rebase unsent operations
↓
retry sent immutable operations

76. Sent Pending Operations

If an operation may already have reached server:

payload immutable

After bootstrap, retry same OperationId or inspect ledger result.


77. Optimistic Local View During Bootstrap

Application may continue showing old generation + pending overlays until cutover.

Avoid writing new authoritative incoming state into old generation once bootstrap replacement is committed to.


78. New Local Mutations During Bootstrap

Two policies:

AllowAndQueue
TemporarilyReadOnly

Recommended local-first default:

AllowAndQueue

if domain can safely rebase later.

For high-risk modules:

temporarily read-only

may be safer.


79. Bootstrap Mutation Barrier

Per scope/domain profile can declare:

pub enum BootstrapMutationPolicy {
    AllowQueue,
    ReadOnly,
    Custom,
}

80. Anti-Entropy Integration

Part 03 may trigger partial/full bootstrap when divergence is widespread.

The same large-bootstrap machinery should be reused.


81. Repair Bootstrap

A repair bootstrap is not a new business event.

It replaces local replica state.


82. Import Integration

Part 09 server baseline snapshots can be produced in this chunked format.

This gives newly migrated clients scalable first bootstrap.


83. Universal DB Adapter Integration

Server snapshot producer converts DB-specific state into canonical snapshot records.

Client adapter installs into its own schema.

Thus:

PostgreSQL server
→ canonical chunks
→ Stoolap/SQLite/Redb client

remains database-independent.


84. Snapshot Encoder Trait

Conceptually:

pub trait SnapshotSource {
    async fn open_snapshot(
        &self,
        scope: &ResolvedScope,
    ) -> Result<Box<dyn SnapshotReadView>, SnapshotError>;
}

85. SnapshotReadView

Provides:

consistent boundary
stream canonical records

No DB-specific types escape.


86. Snapshot Sink Trait

Client adapter:

pub trait SnapshotSink {
    async fn begin_staging(
        &self,
        manifest: &SnapshotManifest,
    ) -> Result<StagingHandle, SnapshotError>;

    async fn install_chunk(
        &self,
        staging: &mut StagingHandle,
        chunk: SnapshotRecordStream,
    ) -> Result<(), SnapshotError>;

    async fn activate(
        &self,
        staging: StagingHandle,
        boundary: SnapshotBoundary,
    ) -> Result<(), SnapshotError>;
}

87. Adapter Capability

Declare:

SnapshotInstallCapability {
    generation_swap,
    resumable_chunk_install,
    consistent_read,
}

88. Tier-A Requirement

A production local adapter should support either:

generation swap

or an equivalent crash-safe bootstrap install strategy.


89. Same-Table Staging

SQL adapters can stage via:

generation column
staging tables
temporary schema

depending on implementation.


90. KV Staging

KV adapter can use:

generation-prefixed keyspace

Example:

gen/42/student/...
gen/43/student/...

Activation changes one metadata pointer.


91. Snapshot Schema Version

Define:

pub struct SnapshotSchemaVersion(u32);

Separate from:

protocol version
domain schema
projection schema

92. Compatibility

Client must verify it can decode/install snapshot schema before downloading gigabytes.


93. Early Compatibility Check

Manifest negotiation returns:

supported codec
snapshot schema
compression
projection schema

before transfer.


94. Capability Negotiation

Client advertises:

max chunk bytes
supported compression
range resume support
parallelism hint
snapshot schema versions

Server selects compatible snapshot.


95. Server Should Not Tailor Snapshot Per Tiny Client Difference Excessively

Too many variants destroy cacheability.

Prefer a small set of snapshot profiles.


96. Snapshot Profiles

Example:

Standard
LowMemory
LegacyCompatibility

97. Compression

Recommended:

zstd

for larger chunks.

But compression level should favor decompression speed for mobile unless bandwidth constraints justify more CPU.


98. Chunk Encryption

Transport TLS protects in transit.

If chunks stored in third-party object storage and policy requires stronger confidentiality:

encrypt chunk objects

with keys controlled by server/application.

Part 15 will formalize cryptographic protection.


99. Object Storage Naming

Example:

snapshots/<tenant>/<snapshot_id>/<chunk_hash>

Avoid embedding sensitive human-readable entity names.


100. CDN

For geographically distributed large downloads, CDN may accelerate immutable chunks.

Authorization must remain scoped.


101. Signed URL Leakage

Signed URLs are bearer capabilities during lifetime.

Keep expiration short and avoid logging them.


102. Server Bandwidth Fallback

If no object storage configured:

Axum streams chunk directly

using same logical chunk protocol.


103. HTTP Range

Direct Axum/object storage adapter can support:

Range

for resumable chunk transfer.


104. Stream Timeouts

Use:

idle timeout
overall reasonable chunk timeout

not one tiny fixed request deadline for a huge chunk.


105. Chunk Retry

Retry one chunk with:

same ChunkId

not whole snapshot.


106. Retry Backoff

Use Part 06 scheduler.

Interactive required bootstrap may retry sooner than optional background scope.


107. Corrupt Chunk

If hash mismatch:

delete local partial
retry from trusted source

Repeated mismatch:

quarantine / alert

108. Root Verification

After all chunks installed:

compute staging canonical root
compare manifest root

where practical.

This integrates Part 03.


109. Per-Chunk vs Full Verification

Minimum:

every chunk hash

Preferred:

chunk hashes
+
full staging canonical root

for enterprise mode.


110. Snapshot Record Count

Manifest may include:

record count per chunk
total records

Useful for diagnostics, not security alone.


111. Ordering

Client should not rely on record order for semantics except where snapshot format explicitly defines dependency ordering.


112. Referential Installation

If local DB enforces foreign keys and chunks arrive out of parent-child order:

Options:

topologically ordered chunks
deferred constraints
staging tables without final constraints
two-phase install

113. Recommended SQL Strategy

Where practical:

generate chunks in dependency-compatible entity groups

This simplifies install.


114. Two-Phase Snapshot Install

For complex schemas:

Phase 1:
    entities

Phase 2:
    relationships/indexes/derived metadata

115. Derived Local Indexes

Do not necessarily include:

search index
UI caches
derived aggregates

in snapshot.

Rebuild locally after activation if cheaper.


116. Rebuild Phase

Optional:

activate authoritative replica
↓
background rebuild local derived indexes

Application must tolerate temporarily rebuilding non-authoritative caches.


117. Snapshot Manifest Pagination

If millions of chunks unlikely but possible, manifest entries may be paged:

manifest root
↓
manifest pages
↓
chunk descriptors

Initial implementation can use bounded chunk count avoiding this complexity.


118. Snapshot Catalog

Server may maintain:

latest snapshot per scope profile
older retained snapshots

119. Snapshot Reuse Across Clients

Many clients in same scope/profile can download same immutable snapshot.

This is important for cost efficiency.


120. Personalized Scope Problem

If every user has unique scope, snapshot reuse decreases.

Part 07 partitioned scopes can help compose reusable base snapshots plus small deltas.


121. Base + Delta Snapshot

Future optimization:

shared base snapshot
+
user-specific seed delta

Do not build initially unless needed.


122. Snapshot Creation Frequency

Balance:

snapshot freshness
build cost
journal retention
storage cost

123. Snapshot Scheduler

Server background worker can create snapshots:

periodically
after large import
after schema migration
on demand for large scope

124. Snapshot Build Deduplication

If many clients request same missing snapshot:

one build job
many waiters

avoid duplicate expensive builds.


125. Build Lease

Server can use durable job lease to ensure one snapshot builder per scope/profile.

Part 23 durable-job architecture will formalize this.


126. Snapshot Failure

Failed snapshot build never becomes visible.

Publish manifest only after:

all chunks written
all hashes verified
root computed

127. Two-Phase Publish

build unpublished
↓
verify
↓
atomically mark published

Clients only receive published snapshots.


128. Garbage Collection

Snapshot GC considers:

retention period
active SnapshotLease
client download references
journal retention

129. Do Not Delete Active Snapshot

If clients hold valid lease:

retain chunks

until lease expires.


130. Journal Pinning Cost

Long snapshot leases delay journal GC.

Limit:

max lease duration
renewal count

131. Very Slow Client

If client cannot finish before retention window despite renewals:

restart with fresher snapshot

may be better.


132. Multi-Tenant Fairness

Snapshot downloads/builds can be expensive.

Apply:

per-tenant concurrency
global build concurrency
download bandwidth budgets

Part 18 will formalize server admission.


133. Thundering Herd

After app reinstall/update:

many clients request bootstrap

Mitigations:

snapshot reuse
CDN/object storage
jitter
server admission
cached manifests

134. Client Preflight

Before starting:

validate auth
resolve scope
check compatibility
check disk
check network policy
check battery/background constraints

135. Bootstrap Cancellation

User/app may pause.

Persist state.

Do not discard verified chunks unless storage policy requires it.


136. Bootstrap Resume

On resume:

revalidate snapshot lease
refresh signed URLs
continue

137. Scope Revocation During Bootstrap

If access is revoked mid-bootstrap:

stop transfer
invalidate job
delete staged unauthorized data according to policy

Never activate.


138. Scope Version Change During Bootstrap

If compatible:

finish snapshot + apply scope delta

Potentially.

Initial safer rule:

if scope version/generation changed materially:
    restart/upgrade bootstrap plan

139. Authority Epoch Change During Bootstrap

If server authority epoch changes:

manifest may be invalid

Client must revalidate before activation.

Part 16 will formalize authority epochs.


140. Activation Validation

Before activation, client verifies:

auth still valid
scope still valid
snapshot generation still accepted
authority epoch still compatible
manifest root valid
all required chunks installed

141. Bootstrap Status API

Expose:

state
bytes downloaded
chunks completed
chunks total
records installed
current scope

Avoid promising time remaining.


142. UI

Potential user-facing states:

Preparing offline data
Downloading data
Installing data
Finalizing
Catching up
Ready

143. Metrics — Client

bootstrap_started_total
bootstrap_completed_total
bootstrap_resumed_total
bootstrap_bytes_downloaded
bootstrap_chunk_retry_total
bootstrap_verify_failure_total
bootstrap_activation_duration

144. Metrics — Server

snapshot_build_total
snapshot_build_duration
snapshot_bytes
snapshot_reuse_total
snapshot_manifest_requests
snapshot_chunk_requests
snapshot_lease_active

145. Logs

Structured:

snapshot_build_started
snapshot_published
bootstrap_started
chunk_verified
bootstrap_activated
bootstrap_restarted

Do not log signed URLs or sensitive payload.


146. Alerts

Potential:

snapshot build repeatedly failing
hash mismatches across clients
journal retention pinned too long
bootstrap completion rate drops
object storage unavailable

147. Correctness Invariants

Add:

A bootstrap cursor is activated only after the corresponding snapshot state is durably installed.

All chunks in one published snapshot represent one consistent authoritative boundary.

Partial staging data is never exposed as an active complete scope.

Chunk retry cannot duplicate authoritative entities after final activation.

Pending local intent is preserved across rebootstrap.

Snapshot activation followed by journal replay from boundary N yields the same authoritative replica state as continuous journal replication from a valid earlier state.

148. Property Tests

Generate:

random chunk order
chunk duplication
download restart
install restart
activation crash
new journal events during bootstrap

Assert final convergence.


149. Model Checking

Part 01 model can abstract:

old generation
staging generation
activation flag
pending outbox

Explore crash at each transition.


150. Fault Injection

Inject:

network failure halfway chunk
hash mismatch
disk full during install
DB crash before activation
crash after activation before status update
journal event after snapshot boundary

151. Differential Test

Compare:

A. normal incremental replay from empty baseline
B. snapshot bootstrap at N + journal replay N+1...

Canonical final state must match.


152. Cross-Database Test

Build snapshot from PostgreSQL.

Install into:

Stoolap
SQLite
Redb

Canonical root must match authoritative source.


153. Large-Scale Soak Test

Simulate:

10M records
thousands of chunks
repeated pause/resume
network throttling
process restarts

Measure:

peak memory
disk overhead
throughput
retry amplification

154. Resource Invariants

Add:

max decoded record size
max chunk uncompressed size
max concurrent downloads
max ready queue bytes
max staging batch size

155. Memory Architecture

Use bounded pipeline:

Network Reader
    ↓
Decompressor
    ↓
Record Framer
    ↓
Small Decode Buffer
    ↓
Install Batch

No full-snapshot materialization.


156. Zero-Copy

Use:

Bytes
borrowed slices
streamed decode

where practical.

Do not complicate snapshot semantics solely to eliminate every copy.


157. Recommended Modules

aequora-client/
└── bootstrap/
    ├── mod.rs
    ├── job.rs
    ├── manifest.rs
    ├── downloader.rs
    ├── verifier.rs
    ├── installer.rs
    ├── activation.rs
    ├── resume.rs
    └── metrics.rs

aequora-server/
└── snapshot/
    ├── coordinator.rs
    ├── builder.rs
    ├── reader.rs
    ├── chunker.rs
    ├── publisher.rs
    ├── lease.rs
    └── catalog.rs

158. Configuration

Example:

bootstrap: (
    target_chunk_uncompressed_bytes: 8388608,
    max_chunk_uncompressed_bytes: 33554432,

    download: (
        max_concurrency: 4,
        resume_ranges: true,
    ),

    install: (
        records_per_transaction: 1000,
        ready_queue_bytes: 33554432,
    ),

    verification: (
        verify_chunk_hashes: true,
        verify_final_root: true,
    ),

    storage_profile: Balanced,
)

159. Plug-and-Play Experience

Most developers should not manually manage chunks.

Client API:

aequora.bootstrap(scope).await?;

or automatic:

ResyncRequired
↓
client runtime schedules bootstrap
↓
status stream reports progress

Server adapter handles snapshot production.


160. Completion Criteria

Part 10 is complete when:

[x] BootstrapJob state machine defined
[x] snapshot boundary defined
[x] chunk manifest defined
[x] deterministic chunking defined
[x] resumable transfer defined
[x] range retry safety defined
[x] streaming decode/install defined
[x] staging generation defined
[x] atomic activation defined
[x] delta-after-snapshot catch-up defined
[x] journal retention/snapshot lease defined
[x] pending-operation preservation defined
[x] scope/version/revocation handling defined
[x] object-storage/CDN path defined
[x] adapter source/sink traits defined
[x] disk/memory preflight defined
[x] correctness/property/fault tests defined

161. Final Architecture

                   AUTHORITATIVE DATABASE
                            │
                            ▼
                    Consistent Read View
                            │
                            ▼
                      Snapshot Builder
                            │
                ┌───────────┴───────────┐
                ▼                       ▼
             Manifest              Chunk Objects
                │                       │
                └───────────┬───────────┘
                            ▼
                         CLIENT
                            │
                       BootstrapJob
                            │
              ┌─────────────┼─────────────┐
              ▼             ▼             ▼
          Download       Verify        Resume State
              │
              ▼
        Streaming Decode
              │
              ▼
        Staging Generation B
              │
              ▼
         Full Verification
              │
              ▼
       Atomic Activation A → B
              │
              ▼
      Cursor = Snapshot Boundary N
              │
              ▼
        Journal Catch-Up N+1...
              │
              ▼
             Ready

The architectural principle is:

A large bootstrap is not one giant transfer. It is a durable, resumable state machine that progressively builds a verified staging replica and changes logical reality only at one small atomic activation point.

That architecture allows Aequora to bootstrap gigabyte-scale offline datasets on desktop and mobile devices without sacrificing crash safety, memory bounds, database independence, or synchronization correctness.