#![forbid(unsafe_code)]
#![warn(missing_docs)]

//! Storage crate for Prikk repositories.
//!
//! This crate provides persistent layout, object storage, WAL durability, deeper read-only
//! repository verification, initial ref-state/ref-log publication primitives, a narrow
//! active-session append API, opt-in safe doctor repairs, conservative snapshot materialization,
//! read-only worktree status, minimal worktree-to-patch draft generation, supported patch replay
//! planning and materialization, explicit opt-in deletion of patch-removed files, deterministic
//! arbitrary-span text edit replay and generation from worktree changes, explicit unborn local branch
//! genesis through active-WAL ref ownership, and
//! read-only inverse planning for the supported patch subset, non-mutating rollback preview,
//! conservative rollback draft append to an empty active WAL, rollback draft verification, and sealed rollback block classification.
//! Full patch algebra, plugin execution, and remote sync remain separate increments.

mod active;
mod author_signing;
mod blob_access;
mod byte_cursor;
mod checkout;
mod doctor;
mod file_codec;
mod fsutil;
mod history;
mod layout;
// Lifecycle cache codec/importer (DC-09 Phase 4.4-2b.1). Not wired into replay yet;
// `dead_code` allowed until the reconstruct/compare + threading slice.
#[allow(dead_code)]
mod lifecycle_cache;
mod lock;
mod maintainer_signing;
mod memory_store;
// Production node-id minting (DC-09 Phase 4.4a-1), consumed by node-addressed worktree authoring
// (4.4a-2) for fresh-node creation.
mod node_id_gen;
// Node-aware replay substrate (DC-09 Phase 4.4). Threaded into replay/inverse/
// rollback in the following increment; `dead_code` allowed until that wiring lands.
#[allow(dead_code)]
mod node_lifecycle;
mod object_store;
mod patch_checkout;
mod patch_inverse;
mod patch_replay;
mod path;
mod refs;
mod rollback_draft;
mod rollback_preview;
mod rollback_verify;
mod snapshot;
mod text_span;
mod trust;
mod verify;
mod wal;
mod worktree;
mod worktree_patch;
mod worktree_status;

#[cfg(test)]
mod test_support;

pub use active::{
    ActiveCommitResult, ActiveRefMetadata, ActiveSession, read_active_ref_metadata,
    remove_active_ref_metadata, write_active_ref_metadata,
};
pub use author_signing::{AuthorSigner, Ed25519AuthorSigner, author_signature};
pub use checkout::{
    CheckoutMaterialization, CheckoutPlan, DEFAULT_CHECKOUT_REF, SnapshotCheckoutPlan,
    prepare_checkout_plan, prepare_snapshot_checkout_plan,
};
pub use doctor::{
    DoctorIssue, DoctorRepairOptions, DoctorRepairReport, DoctorReport, DoctorSeverity,
    doctor_repository, repair_repository,
};
pub use history::{DEFAULT_HISTORY_LIMIT, HistoryEntry, RefHistory, load_ref_history};
pub use layout::RepositoryLayout;
pub use lock::{ActiveLock, RefLock};
pub use maintainer_signing::{Ed25519MaintainerSigner, MaintainerSigner, maintainer_signature};
pub use memory_store::MemoryObjectStore;
pub use object_store::{FileObjectStore, ObjectReader, ObjectWriter};
pub use patch_checkout::{
    PatchDeletionConflict, PatchDeletionPlan, PatchMaterializationReport,
    materialize_patch_checkout, materialize_patch_checkout_with_deletions,
    plan_patch_checkout_deletions,
};
pub use patch_inverse::{
    PatchInverseOperationKind, PatchInverseOperationSummary, PatchInversePlan,
    prepare_patch_inverse_plan,
};
pub use patch_replay::{PatchReplayPlan, prepare_patch_replay_plan};
pub use path::{RepoPath, validate_no_path_collisions, validate_repo_path};
pub use refs::{
    RefLogRecord, RefLogReplay, RefPublication, RefRecoveryCandidate, RefRecoveryRepair, RefStore,
    validate_local_branch_ref,
};
pub use rollback_draft::{RollbackDraftReport, append_rollback_draft};
pub use rollback_preview::{
    RollbackPreviewChange, RollbackPreviewChangeKind, RollbackPreviewPlan, prepare_rollback_preview,
};
pub use rollback_verify::{RollbackDraftVerification, verify_active_rollback_draft};
pub use snapshot::{SnapshotEntry, SnapshotManifest};
pub use trust::{
    MaintainerTrustPolicy, PublicationTrustIssue, add_trusted_maintainer,
    load_maintainer_trust_policy, verify_signer_trusted, verify_trusted_publication_envelope,
};
pub use verify::{ObjectVerification, RepositoryVerification, verify_repository};
pub use wal::{Wal, WalRecord, WalRepair, WalReplay};
pub use worktree::{SnapshotMaterializationReport, materialize_snapshot_checkout};
pub use worktree_patch::{
    WorktreePatchCommitOptions, WorktreePatchCommitReport, WorktreePatchOperationKind,
    WorktreePatchOperationSummary, commit_worktree_changes_signed,
};
pub use worktree_status::{
    WorktreeChange, WorktreeChangeKind, WorktreeStatusReport, worktree_status,
};
