ifc_lite_git/lib.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! Graph-based version control for IFC: the addressed node layer.
6//!
7//! Spec set: `docs/architecture/ifc-git/`. This crate is the object layer that
8//! the delivery → layer adapter is built on. The diff that computes a change
9//! lives in `ifc-lite-diff`; history, refs, merge and review belong to Layer
10//! PRs (`docs/architecture/layer-prs/`, see the scope reversal in #8217), not
11//! here.
12//!
13//! # The two decisions this module set carries
14//!
15//! **1. Identity is content and structural position, not `GlobalId`.** A node's
16//! address is the digest of its content plus its children's addresses, and the
17//! entity key lives in the tree that points at the node rather than inside the
18//! node. So a from-scratch re-export that regenerates every `GlobalId` rewrites
19//! tree keys and leaves every node address untouched.
20//!
21//! This is the one place the crate departs from `node-hash-v0` in
22//! `packages/provenance`, which folds the entity `key` into the `element` node
23//! and therefore cannot deliver that property. See [`node`] for the detail, and
24//! the spec set's index §6.1 for the open question of where the canonical
25//! encoding should finally live.
26//!
27//! **2. A change belongs to the node that carries it.** Edit one property
28//! inside one property set and the property-set node's address moves; the
29//! owning element's address moves because it encodes that child address; and
30//! nothing else moves. The element is *marked* at `pset:<Name>`, not blamed.
31//! A set shared by many occurrences is therefore one node change plus N
32//! markers.
33//!
34//! # Evidence, not assertion
35//!
36//! `tools/ifc-git-corpus` (#8129) derives a ten-revision chain from a committed
37//! model and measures each step. Its re-export revision regenerates all 116
38//! `GlobalId`s: paired by key that reads as 39 added and 39 deleted, and under
39//! content-derived identity it is nothing at all. That gap is why this layer
40//! addresses content rather than keys.
41//!
42//! # Scope of this PR
43//!
44//! [`address`] (the BLAKE3 digest and its canonical writer) and [`node`] (the
45//! vertices and their components), with [`tree`] (the keyed, chunked tree
46//! that carries entity keys outside the nodes) and [`adapter`] (one entity's
47//! content projection to nodes) on top of them. The commit object is
48//! deferred: its no-empty-commit rule hinges on the coincident-duplicate
49//! equivalence policy that §2.8 still leaves open. The object store and refs
50//! are **not** coming here at all, because #8217 placed them with Layer PRs.
51
52pub mod adapter;
53pub mod address;
54pub mod node;
55pub mod tree;
56
57pub use adapter::{entity_nodes, AdapterError, EntityNodes};
58pub use address::{Address, AddressError, ADDRESS_ALGORITHM};
59pub use node::{Component, Field, FieldValue, Node, NodeKind, Role, SetKind};
60pub use tree::{build_tree, Tree, TreeChunk, TreeEntry};
61
62#[cfg(test)]
63#[path = "wire_format_tests.rs"]
64mod wire_format_tests;