Version Control
How .duc embeds a Directed Acyclic Graph (DAG) version control engine using pivot checkpoints, SQLite deltas, and schema migration boundaries.
Overview
In traditional engineering workflows, version control is either completely missing or relegated to external tools that treat complex CAD files as black-box binary blobs. This leads to lost work, broken file states, and an inability to inspect historical design decisions.
.duc solves this by embedding a native Version Graph (DAG) directly inside the SQLite database container (version_graph, version_chains, checkpoints, deltas).
Core Philosophy: Safety & Efficiency
The Version Graph balances two fundamental engineering imperatives:
- Absolute Traceability & Safety: Full-state Checkpoints capture self-contained snapshots of the entire project state, guaranteeing zero data corruption.
- Extreme Storage Efficiency: Lightweight Deltas leverage SQLite changeset generation paradigms to record incremental edits with minimal file overhead.
Checkpoints: Unbreakable Safety Pivots
A Checkpoint (C) is a complete, self-contained snapshot of the entire document state at a specific version (version_number).
Key Properties of Checkpoints
- Standalone Recovery: Every checkpoint is 100% self-contained. It can be loaded independently to reconstruct the exact document state without relying on prior versions or external files.
- Cryptographic Integrity: Verified via a SHA-256
data_checksumduring restore operations to guarantee snapshot data remains uncorrupted. - Pivot Anchors: Checkpoints serve as the base pivot for subsequent deltas, preventing diff chains from growing endlessly long.
- Schema Migration Boundaries (
is_schema_boundary = 1): When the.ducfile format undergoes a schema upgrade, a boundary checkpoint is automatically generated in both the old and new schema (schema_migrations). This ensures historical snapshots remain permanently readable decades into the future.
Deltas: Hyper-Compact Changesets
A Delta (D) is an incremental patch that records only the modified elements, geometric changes, or state updates since the last checkpoint.
Engineering Behind Deltas
- SQLite Delta Generation: Deltas leverage SQLite’s core changeset generation paradigms combined with compression to calculate exact relational diffs.
- Pivot Reference: Each delta references its
base_checkpoint_id(the pivot checkpoint) and itsdelta_sequenceposition. - Minimal File Overhead: Storing diffs relative to a pivot checkpoint keeps delta file sizes down to a few kilobytes, even during intense editing sessions with thousands of spatial updates.
- Schema Isolation: Deltas never cross schema boundaries, they execute sequentially from their designated base checkpoint.
The Version Graph DAG
The version control system operates as a Directed Acyclic Graph (DAG), enabling non-linear history, branching, and user-designated save points:
version_graph: Singleton control table trackingcurrent_version,current_schema_version,user_checkpoint_version_id(manual save points), andlatest_version_id.version_chains: Groups contiguous version sequences that share the same schema version.- Parent Lineage (
parent_id): Both checkpoints and deltas maintain parent pointers, supporting visual version graph inspection and branch traversal.
Restoration & Replay Algorithm
To restore any target version N across the version graph, the engine executes a deterministic 3-step algorithm:
- Locate Pivot Checkpoint: Query the nearest checkpoint
CwhereC.version_number <= Nin the target schema. - Hydrate Base State: Load base checkpoint
Cchunks fromcheckpoint_data_chunks(instant full-state hydration). - Replay Delta Sequence: Sequentially apply deltas
D_1, D_2, ...matchingC.idindelta_sequenceorder up to versionN.
This hybrid architecture guarantees instant loading performance, unbreakable data safety, and minimal file storage overhead.
Last updated on
Charter & Issues
How embedded project charters and spatially-anchored issues provide decision traceability, clarity, and geometry-bound intent in .duc.
Chunked Binary Streaming
How .duc streams binary data in small chunks instead of bulk serialization to achieve constant RAM footprint at extreme scale.