Skip to main content

txgate_policy/
lib.rs

1//! # txgate-policy
2//!
3//! Policy engine for transaction approval rules in the `TxGate` signing service.
4//!
5//! ## Internal Crate Warning
6//!
7//! **This crate is an internal implementation detail of [`txgate`](https://crates.io/crates/txgate).**
8//!
9//! It is published to crates.io only because Cargo requires all dependencies to be
10//! published. The API is **unstable** and may change without notice between any versions,
11//! including patch releases.
12//!
13//! **Do not depend on this crate directly.** Instead:
14//! - For the signing server binary: `cargo install txgate`
15//! - For programmatic access: Open an issue at <https://github.com/txgate-project/txgate>
16//!   to discuss a stable public API.
17//!
18//! This crate provides the policy evaluation and rule management system:
19//!
20//! ## Modules
21//!
22//! - [`config`] - Policy configuration types
23//! - [`history`] - Transaction history tracking with `SQLite`
24//!
25//! ## Modules (planned)
26//!
27//! - `engine` - Policy evaluation engine
28//! - `rules` - Rule definitions and parsing
29//! - `conditions` - Condition types (amount limits, address allowlists, etc.)
30//! - `actions` - Policy actions (approve, deny, `require_approval`)
31//!
32//! ## Policy Features (planned)
33//!
34//! - Transaction amount limits (per-tx, daily, monthly)
35//! - Address allowlists and blocklists
36//! - Contract function restrictions
37//! - Time-based rules (business hours, rate limiting)
38//! - Multi-signature approval workflows
39//! - Chain-specific policies
40//!
41//! ## Policy Format
42//!
43//! Policies are defined in YAML/JSON format and can be:
44//! - Loaded from files
45//! - Fetched from remote configuration servers
46//! - Defined programmatically
47//!
48//! ## Example Policy (conceptual)
49//!
50//! ```yaml
51//! policies:
52//!   - name: "high_value_transfer"
53//!     conditions:
54//!       - type: "amount_greater_than"
55//!         value: "10 ETH"
56//!     action: "require_approval"
57//!     approvers: ["admin@company.com"]
58//! ```
59
60#![forbid(unsafe_code)]
61#![warn(missing_docs)]
62#![warn(clippy::all)]
63#![warn(clippy::pedantic)]
64
65pub mod config;
66pub mod engine;
67pub mod history;
68
69pub use config::PolicyConfig;
70pub use engine::{DefaultPolicyEngine, PolicyCheckResult, PolicyEngine};
71pub use history::{TransactionHistory, TransactionRecord};
72
73// Placeholder for future modules
74// pub mod rules;
75// pub mod conditions;
76// pub mod actions;