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