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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
//! Forward-compat seam for the eventual `aicx` library crate.
//!
//! # Why this trait exists
//!
//! Loctree currently consumes the AICX memory store through a CLI
//! subprocess (and optionally `aicx-mcp` over stdio JSON-RPC). Both
//! paths are encapsulated by [`crate::aicx::AicxClient`].
//!
//! The AICX team is mid-flight on shipping `aicx-retrieve` as a
//! consumable Cargo crate (`aicx-retrieve::OracleContract` +
//! `aicx-retrieve::HybridIndex` are the planned public surface).
//! Once that lands, loctree will swap the subprocess wrapper for an
//! in-process library handle and erase one process-spawn per query.
//!
//! Wave 6b (actual library linking) is BLOCKED on AICX shipping
//! `aicx = { features = ["canonical-store"] }` with a stable trait
//! shape. Until then, loctree carries this trait as a
//! *structurally-identical* mirror of the eventual
//! `aicx::IntentStore` so the eventual swap is a one-line `use`
//! change: `pub use aicx::IntentStore as IntentSource;` plus
//! deleting the [`crate::aicx::AicxClient`] impl block.
//!
//! # Reference shape (from the AICX action plan)
//!
//! ```ignore
//! // aicx side, eventual:
//! pub trait IntentStore: Send + Sync {
//! fn intents(&self, query: IntentsQuery) -> Result<IntentsResponse, RetrieveError>;
//! fn steer(&self, filters: SteerFilters) -> Result<SteerResponse, RetrieveError>;
//! fn search_literal(&self, query: &str, opts: SearchOptions)
//! -> Result<SearchResponse, RetrieveError>;
//! fn read(&self, source_chunk: &Path) -> Result<String, RetrieveError>;
//! fn oracle(&self) -> OracleContract;
//! }
//! ```
//!
//! Loctree-side today uses simpler signatures because:
//!
//! - `IntentsResponse`/`SearchResponse`/`SteerResponse` envelope types
//! do not exist yet on the AICX side. Loctree returns the bare
//! `Vec<…>` rows it already consumes; per-row `oracle_status` is
//! the operative provenance hook.
//! - `RetrieveError` does not exist yet either. The current contract
//! is "empty on failure" (see [`crate::aicx::AicxClient`] doc) —
//! the library will tighten this later.
//! - `read(source_chunk)` and `oracle()` are deliberately omitted —
//! loctree consumers do not need either today. They will be added
//! when Wave 6b actually links the library.
//!
//! # Why a trait instead of a concrete swap-out
//!
//! Holding the trait gives future code a single seam for:
//!
//! - Fakes in unit tests (today: shell-script mocks per test;
//! tomorrow: a `MockIntentSource` that hands back canned rows
//! without touching env vars).
//! - The blocker doc cited at
//! `~/.vibecrafted/inbox/Loctree/aicx/blockers/loctree-side-needs.md`.
//! - The eventual paid-tier vs. free-tier split (`aicx = { features =
//! ["canonical-store"] }` for free; add `"semantic"` for the
//! embedding/LLM-enriched paid build). Loctree's trait surface does
//! not change; only the impl behind it does.
//!
//! # Today's impl
//!
//! [`CliIntentSource`] is the type alias for the only impl that ships
//! today — [`crate::aicx::AicxClient`]. Existing call sites that hold
//! `&AicxClient` are unaffected; new call sites should prefer
//! `&dyn IntentSource` so they swap cleanly when Wave 6b lands.
use ;
/// Read-only intent / steer / search retrieval surface.
///
/// Structurally mirrors the eventual `aicx::IntentStore` trait so
/// that wiring up Wave 6b is a one-line `use` swap rather than a
/// signature migration. See the module-level docs for the full
/// rationale and the divergence list.
///
/// # Contract
///
/// All methods are **read-only** and **failure-soft**: on transport
/// failure the impl returns an empty `Vec` rather than propagating
/// the error. This mirrors today's [`AicxClient`] contract — agents
/// composing context must not be killed by an AICX hiccup. The
/// per-row [`super::OracleStatus`] still carries provenance so
/// callers know whether a row came from the semantic oracle or a
/// fuzzy fallback (see [`super::OracleStatus::readiness`]).
///
/// # Implementor obligations
///
/// - `Send + Sync` so a single instance can be shared across the
/// composition pipeline by `&` reference.
/// - Cache hygiene is implementor-side. The today-impl
/// ([`AicxClient`]) caches successful empty results but never
/// caches failures (see Plan L03 / Finding #8).
/// - Per-row `oracle_status` MUST be populated whenever the wire
/// transport delivers it. Consumers gate scope-narrowing decisions
/// on `oracle_status.loctree_scope_safe`; dropping the field
/// silently promotes fuzzy-fallback rows to oracle authority.
/// Type alias for the only [`IntentSource`] impl that ships today —
/// the subprocess-backed [`AicxClient`].
///
/// Held as an alias rather than a `pub use` rename so the existing
/// `AicxClient` type stays the documented entry point for direct
/// construction (the trait is the consumption surface; the alias is
/// the documentation handle for "this is the CLI-backed impl").
///
/// When Wave 6b lands a second impl (`LibIntentSource` over the
/// in-process `aicx-retrieve::HybridIndex`), this alias stays
/// pointing at the CLI variant so legacy operator workflows that
/// rely on the subprocess still resolve.
pub type CliIntentSource = AicxClient;