Skip to main content

lex_vcs/
lib.rs

1//! Agent-native version control for Lex (#128 tier-2).
2//!
3//! The unit of writing is an [`Operation`] — a typed delta on the AST
4//! identified by `(kind, payload, parents)`. Two agents producing the
5//! same logical change against the same parent state get the same
6//! [`OpId`], so the store can dedup automatically and surface "we
7//! agree" without a merge.
8//!
9//! This crate is the foundation slice of #129. It defines the
10//! operation enum and content-addressed identity. Subsequent slices
11//! add: applying ops to a store state (#129 cont'd), the write-time
12//! type-check gate (#130), intent linkage (#131), attestations
13//! (#132), predicate branches (#133), and the programmatic merge API
14//! (#134).
15//!
16//! # Identity
17//!
18//! [`OpId`] is the lowercase-hex SHA-256 of the canonical JSON form
19//! of `(kind, payload, parents)`. The serializer is deterministic
20//! by construction (struct fields are emitted in declaration order;
21//! [`EffectSet`] is a `BTreeSet`; parents are sorted before
22//! hashing), so two independent runs producing the same logical
23//! operation produce byte-identical canonical bytes.
24//!
25//! `lex-store` already uses SHA-256 (via the `sha2` crate) for stage
26//! and signature identity, so we reuse that here for consistency
27//! and to avoid pulling in a second hash dependency. The issue text
28//! mentions Blake3; if that becomes load-bearing for performance we
29//! can swap with a one-line crate change since `OpId` is opaque.
30
31mod apply;
32mod attestation;
33mod canonical;
34mod compute_diff;
35pub mod diff_report;
36mod diff_to_ops;
37mod gate;
38mod intent;
39mod merge;
40mod merge_session;
41mod op_log;
42mod operation;
43mod predicate;
44
45pub use apply::{apply, ApplyError, NewHead};
46pub use attestation::{
47    is_stage_blocked, Attestation, AttestationId, AttestationKind, AttestationLog,
48    AttestationResult, ContentHash, Cost, ProducerDescriptor, Signature, SpecId, SpecMethod,
49};
50pub use compute_diff::{compute_diff, effect_label, render_signature};
51pub use diff_report::DiffReport;
52pub use diff_to_ops::{diff_to_ops, DiffInputs, DiffMappingError, ImportMap};
53pub use gate::{check_and_apply, GateError};
54pub use intent::{Intent, IntentId, IntentLog, ModelDescriptor, SessionId};
55pub use merge::{merge, ConflictKind, MergeOutcome, MergeOutput};
56pub use merge_session::{
57    CommitError, ConflictId, ConflictRecord, MergeSession, MergeSessionId, ResolveVerdict,
58    Resolution, ResolutionRejection,
59};
60pub use predicate::{evaluate, evaluate_with_resolver, IntentResolver, Predicate};
61pub use op_log::OpLog;
62pub use operation::{
63    EffectSet, ModuleRef, OpId, Operation, OperationRecord, OperationKind, SigId, StageId,
64    StageTransition,
65};