1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
//! Zero-boilerplate hexagonal architecture with graph-based introspection.
//!
//! `hexser` provides reusable traits and types for building applications with Hexagonal
//! Architecture (Ports and Adapters). Components you derive are automatically registered into
//! an in-memory architecture graph you can query, validate, visualize, and export for AI
//! agents — no manual wiring.
//!
//! # Architecture Layers
//!
//! - **Domain**: Core business logic (`HexEntity`, `HexValueItem`, `Aggregate`)
//! - **Ports**: Interface definitions (`Repository`, `QueryRepository`, `UseCase`, `Query`)
//! - **Adapters**: Port implementations (`Adapter`, `Mapper`)
//! - **Application**: Use case orchestration (`Directive`, `DirectiveHandler`)
//! - **Infrastructure**: External concerns (`Config`)
//!
//! # Quick Start
//!
//! ```rust
//! use hexser::prelude::*;
//!
//! // A domain entity: derive HexEntity (Id is taken from the `id` field) and HexDomain to
//! // register it in the architecture graph.
//! #[derive(HexEntity, HexDomain)]
//! struct User {
//! id: String,
//! email: String,
//! }
//!
//! // A repository port. Repository is save-only; reads live on QueryRepository.
//! trait UserRepository: Repository<User> {
//! fn find_by_email(&self, email: &str) -> HexResult<Option<User>>;
//! }
//!
//! // An adapter implementing the port. Deriving HexAdapter registers it in the graph and
//! // implements the `Adapter` marker trait for you.
//! #[derive(HexAdapter)]
//! struct InMemoryUserRepository {
//! users: Vec<User>,
//! }
//! ```
//!
//! # Feature Flags
//!
//! `default = ["macros", "static-di"]`.
//!
//! - `macros`: derive macros (`HexEntity`, `HexDomain`, `HexPort`, …) — on by default.
//! - `static-di`: zero-cost, WASM-friendly static dependency injection — on by default.
//! - `serde`: `Serialize`/`Deserialize` for the rich error types (see also the
//! `HEXSER_INCLUDE_SOURCE_LOCATION` env var, which gates whether source locations are
//! included in serialized errors).
//! - `ai`: machine-readable architecture context export (`AIContext`, `ContextBuilder`).
//! - `mcp`: Model Context Protocol server (implies `ai`).
//! - `visualization`: DOT / Mermaid / JSON diagram export.
//! - `container`: dynamic (runtime) DI container (uses tokio).
//! - `async`: enables tokio / async-trait for downstream async adapters.
//! - `full`: all of the above.
//!
//! Revision History
//! - 2026-09-11T00:00:00Z @AI: Declare the private `clock` module — single guard for the `SystemTime::now()` panic on wasm32-unknown-unknown.
//! - 2026-07-21T00:00:00Z @AI: Rewrite crate header — correct feature list/default, drop the stale Phase-1/future-phases framing and nonexistent graph/analysis features; Quick Start now derives the real macros.
//! - 2025-10-09T14:14:00Z @AI: Remove Entity derive alias, expose HexEntity at crate root for qualified addressing.
//! - 2025-10-02T13:00:00Z @AI: Re-export inventory and error_codes for proc macros.
//! - 2025-10-02T12:00:00Z @AI: Add showcase module with Describable and Inspectable traits.
//! - 2025-10-01T00:01:00Z @AI: Added comprehensive re-exports and prelude module.
//! - 2025-10-01T00:00:00Z @AI: Initial Phase 1 implementation with core traits and types.
// Private: clockless-target-safe wall-clock reads, an implementation detail of the metadata
// timestamps rather than part of the public surface.
// Re-export commonly used items at crate root for convenience
pub use crate::;
// Re-export all domain traits
pub use crate;
// Re-export all port traits
pub use crate;
// Re-export all adapter traits
pub use crate;
// Re-export all application traits
pub use crate;
// Re-export infrastructure traits
pub use crateConfig;
// Re-export inventory for proc macros
pub use inventory;
// Re-export error codes module
pub use cratecodes as error_codes;
// Re-export graph types (Phase 2)
pub use crate;
// Re-export showcase traits
pub use crate;
// Re-export derive macros at crate root for qualified addressing (e.g., hexser::HexEntity)
pub use ;
/// Prelude module for convenient imports.
///
/// Import everything you need with a single use statement:
///
/// ```rust
/// use hexser::prelude::*;
/// ```