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 body_merge;
34mod canonical;
35mod compute_diff;
36pub mod diff_report;
37mod diff_to_ops;
38mod gate;
39mod intent;
40mod merge;
41mod merge_session;
42pub mod migrate;
43mod op_log;
44mod operation;
45mod predicate;
46pub mod signing;
47
48pub use apply::{apply, ApplyError, NewHead};
49pub use body_merge::{merge_bodies, BodyMerge};
50pub use attestation::{
51    active_producer_block, is_stage_blocked, Attestation, AttestationId, AttestationKind,
52    AttestationLog, AttestationResult, ContentHash, Cost, ProducerDescriptor, Signature, SpecId,
53    ReviewVerdict, SpecMethod, TraceRunId,
54};
55pub use compute_diff::{compute_diff, effect_label, render_signature};
56pub use diff_report::DiffReport;
57pub use diff_to_ops::{diff_to_ops, DiffInputs, DiffMappingError, ImportMap};
58pub use gate::{check_and_apply, GateError};
59pub use intent::{Intent, IntentId, IntentLog, ModelDescriptor, SessionId};
60pub use merge::{merge, ConflictKind, MergeOutcome, MergeOutput};
61pub use merge_session::{
62    CommitError, ConflictId, ConflictRecord, MergeSession, MergeSessionId, ResolutionChecker,
63    ResolveVerdict, Resolution, ResolutionRejection,
64};
65pub use predicate::{evaluate, evaluate_with_resolver, IntentResolver, Predicate};
66pub use signing::{verify_message, verify_stage_id, Keypair, SigningError};
67pub use op_log::OpLog;
68pub use operation::{
69    budget_from_effects as operation_budget_from_effects, EffectSet, ModuleRef, OpId, Operation,
70    OperationFormat, OperationKind, OperationRecord, SigId, StageId, StageTransition,
71};