pactole-core
Pure business domain of Pactole: models, validation invariants, and financial calculations.
Role
pactole-core contains only domain logic: no I/O, no tree-sitter
dependency. It must never depend on pactole-storage-fs,
pactole-syntax, tree-sitter, or any filesystem operation. Any
conversion from a .pactole file (concrete syntax → models) is the
responsibility of pactole-storage-fs.
Main API
Re-exported from src/lib.rs:
- Models (
models/):Journal,Entry,Transaction,Posting,Amount,Balance,Open,Close,Commodity,Payee,TransactionStatus,Metadata, as well as validated newtypes (AccountName,CommodityName,MetadataKey). validate_journal(journal: Journal) -> Result<Journal, ValidationError>(validation.rs): consumes the inputJournaland checks the business invariants — chronological ordering of entries, account lifecycle (opened before use/close, not used after close), commodities declared before use, payees declared before use in a transaction, and balancing of each transaction per commodity. On success, it returns theJournal(sorted chronologically and with self-balanced transactions); on failure, it returns aValidationError.register(journal: &Journal, filter: &RegisterFilter) -> Vec<RegisterEntry>(register.rs): computes a "register" report (running balance per commodity), filterable by account (including sub-accounts), date range, payee, narration, tag, status.ReadableStorage(traits.rs): storage abstraction trait, implemented bypactole-storage-fs::PactoleFileStorage(and intended to be implemented by a future database storage crate).ModelError,ValidationError(errors.rs): structured errors viathiserror.
Dependencies / boundaries
chrono(dates),rust_decimal(financial arithmetic — neverf32/f64for amounts),thiserror(structured errors).- Depends on no other workspace crate.
Tests / validation
Unit tests for domain and validation logic live in this crate (see the
validation.rs, register.rs, and models/ modules).
See also
../../ARCHITECTURE.md— the role ofpactole-corein the overall architecture and its boundaries with the other crates.../../GRAMMAR.md— the language specification of which these models and invariants are the Rust expression.