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