run_with waited up to 10 s for each of stdout and stderr to reach end-of-file after git exited. On Windows a pipe has no end while any process holds a copy of its write end: std makes the child's end of each pipe inheritable when it makes the pipe and starts every child with all inheritable handles, so a process started at the same moment (a `taskkill` that stops another git while a close's own last backup begins) keeps the pipe open until it ends. Each command then cost up to 20 s, and the close's last backup passed its 60 s bound (the open/close hammer on Windows: 106 s). The reader now takes what git wrote as soon as git has ended and the pipe holds nothing (PeekNamedPipe on Windows, poll(2) on Unix, the reader seen blocked in its read for 100 ms), and never loses a byte already in the pipe; the 10 s wait stays only as the last resort. `taskkill` goes through lock::spawn, and on Windows spawns are exclusive, so no child takes a copy of another's pipe ends. WANDERBOOKS_GIT_TIMINGS=<file> appends one line per git command (ran, spawn, pipes, how each pipe ended) for runs nobody can watch. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
64 lines
2.1 KiB
Rust
64 lines
2.1 KiB
Rust
//! `ledger-store`: durable persistence for the books.
|
|
//!
|
|
//! Three pieces, one job — keep the books safe:
|
|
//!
|
|
//! * [`journal`] — the source of truth. An append-only, hash-chained JSONL
|
|
//! journal. Every state change is an immutable fact, fsync'd on append.
|
|
//! * [`blob`] — the bytes. Content-addressed (SHA-256), immutable,
|
|
//! deduplicated receipt and document storage.
|
|
//! * [`Store`] — the SQLite projection plus the write path. SQLite is the
|
|
//! query engine and is disposable by design: [`Store::rebuild`] drops it
|
|
//! and replays the journal. [`Store::verify`] replays the journal into a
|
|
//! fresh engine and diffs its reports against both the live ledger and
|
|
//! the projection.
|
|
//!
|
|
//! The write path is singular: **validate → journal → mutate → apply**.
|
|
//! Journal first means a failed write leaves nothing behind; a failed
|
|
//! SQLite apply leaves the journal ahead, and the next open heals it via
|
|
//! `last_applied_seq`. There is exactly one writer: `Store` is `!Sync` by
|
|
//! construction (it owns a `rusqlite::Connection`).
|
|
|
|
pub mod access;
|
|
pub mod auth;
|
|
pub mod backup;
|
|
pub mod blob;
|
|
pub mod cancel;
|
|
pub mod chain;
|
|
pub mod describe;
|
|
mod drain;
|
|
pub mod error;
|
|
pub mod exports;
|
|
pub mod form1099;
|
|
pub mod format;
|
|
pub mod git_locks;
|
|
pub mod journal;
|
|
pub mod lock;
|
|
pub mod meta;
|
|
pub mod ops;
|
|
pub mod passphrase;
|
|
pub mod reconcilable;
|
|
#[cfg(test)]
|
|
mod refuse;
|
|
pub mod root;
|
|
pub mod saving;
|
|
pub mod schema;
|
|
pub mod snapshot;
|
|
pub mod store;
|
|
pub mod uploads;
|
|
#[cfg(windows)]
|
|
pub mod winsec;
|
|
|
|
pub use blob::BlobStore;
|
|
pub use error::StoreError;
|
|
pub use format::{FormatUpgrade, JournalFormat, SUPPORTED_JOURNAL_FORMAT};
|
|
pub use journal::{GENESIS_PREV, JournalLine, JournalWriter};
|
|
pub use snapshot::{DiskCheck, Snapshot};
|
|
pub use store::audit;
|
|
pub use store::calls;
|
|
pub use store::{
|
|
Attachment, BillPreview, DepreciationRun, DisposalPreview, EntryRow, EventRow, Extraction,
|
|
ExtractionStatus, InvoicePreview, JOURNAL_FILE, LEGACY_DB_FILE, LOCK_FILE, MAX_RECURRING_RUN,
|
|
PayrollLineInput, PreviewPosting, Reconciliation, Statement, Store, Subject, VerifyReport,
|
|
WriteOffEvidence, database_in_use, db_file, db_file_for, is_database_file,
|
|
};
|