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
//! `g8-core` — canonical data model for the G8.
//!
//! This crate is the root of the g8 crate DAG. It owns all shared types;
//! every other workspace crate consumes them. No I/O, no tokio, no rusqlite.
//!
//! # Modules
//! - [`ids`] — typed ID newtypes (nanoid-backed)
//! - [`model`] — domain structs: ConvergenceSpace, Project, Capability, Intent, Plan, Decision
//! - [`annotation`] — Annotation, AnnotationKind, SourceLocation, RawAnnotation
//! - [`plan`] — PlanStatus, PlanDraft, FitReport, Recommendation, and free functions
//! - [`conflict`] — Conflict, ConflictKind, Severity, Evidence
//! - [`contract`] — CheckPayload, CheckErrorItem, PairingReason (`g8 check --json`)
//! - [`substrate`] — SubstrateName, SubstrateBudget
//! - [`owner`] — Owner
//! - [`error`] — G8Error top-level enum
//! - [`time`] — EpochMillis newtype + helpers
// ── Flat re-exports of all public types ─────────────────────────────────────
pub use ;
pub use ;
pub use ;
pub use G8Error;
pub use ;
pub use ;
pub use Owner;
pub use ;
pub use SubstrateBudget;
pub use EpochMillis;
// ── Free functions ───────────────────────────────────────────────────────────
/// Returns the current wall-clock time as epoch milliseconds.
///
/// # Examples
///
/// ```
/// let ms = g8_core::now_millis();
/// // It should be a reasonably large number (post-2020 epoch).
/// assert!(ms.as_i64() > 1_600_000_000_000);
/// ```
/// Parse a magic-comment annotation string into a [`RawAnnotation`].
///
/// Accepts the `@g8.<kind>(key = "value", ...)` form as produced by the
/// extractor after stripping comment prefixes (`//` or `#`). Whitespace
/// between tokens is ignored; multi-line forms should be concatenated by the
/// caller before parsing.
///
/// # Examples
///
/// ```
/// use g8_core::parse_annotation_grammar;
///
/// // Single-line capability annotation
/// let raw = parse_annotation_grammar(
/// r#"@g8.capability(name = "http-fetch", status = "in_flight", substrate = "net")"#
/// ).unwrap();
/// assert_eq!(raw.kind_str, "capability");
/// assert!(raw.fields.contains_key("name"));
///
/// // Multi-line form (caller concatenates with spaces after stripping // prefix)
/// let multi = parse_annotation_grammar(
/// r#"@g8.capability(name = "claim-validation", consumes = ["Claim", "Source"], produces = ["Event"])"#
/// ).unwrap();
/// let produces = multi.fields.get("produces").unwrap();
/// let json = serde_json::to_string(produces).unwrap();
/// assert!(json.contains("Event"));
/// ```
/// Derive a [`Recommendation`] from a [`DecisionInput`] via a fixed lookup table.
///
/// The lookup table is deterministic: same input always yields same output.
/// Order matters — first matching branch wins.
///
/// # Examples
///
/// ```
/// use g8_core::{recommend, DecisionInput, Recommendation};
///
/// let proceed = recommend(&DecisionInput {
/// any_over_budget: false,
/// has_exact_match: false,
/// near_match_count: 0,
/// has_parked_match: false,
/// bottleneck_count: 0,
/// });
/// assert_eq!(proceed, Recommendation::Proceed);
///
/// let drop = recommend(&DecisionInput {
/// any_over_budget: false,
/// has_exact_match: true,
/// near_match_count: 1,
/// has_parked_match: false,
/// bottleneck_count: 0,
/// });
/// assert_eq!(drop, Recommendation::Drop);
/// ```
/// Validate a [`PlanStatus`] transition, returning an error if the transition
/// is illegal per the plan lifecycle graph.
///
/// Legal transitions:
/// - `Idea` → `Scoped | Parked`
/// - `Scoped` → `Dispatched | Parked`
/// - `Dispatched` → `Blocked | Done | Parked`
/// - `Blocked` → `Dispatched | Parked`
/// - `Parked` → `Scoped`
/// - `Done` — terminal; no outgoing edges
///
/// # Examples
///
/// ```
/// use g8_core::{validate_status_transition, PlanStatus};
///
/// // Legal transition
/// assert!(validate_status_transition(PlanStatus::Idea, PlanStatus::Scoped).is_ok());
///
/// // Illegal: Done is terminal
/// assert!(validate_status_transition(PlanStatus::Done, PlanStatus::Idea).is_err());
/// ```
/// Default WIP cap applied per-substrate when no override is configured.
pub const DEFAULT_WIP_CAP: u32 = 3;