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
// Copyright 2026 AlphaOne LLC
// SPDX-License-Identifier: Apache-2.0
//! HTTP handler module index. Per-domain handler code lives in the
//! sibling sub-modules; this file is the public-facing re-export
//! surface plus the inline test scaffolding.
//!
//! Issue #650 history: the original `src/handlers.rs` was an 18 574-line
//! monolith. The first split (commit `7f3f676`) carved off
//! `federation_receive`, `hook_subscribers`, `http`, and `transport`.
//! The follow-up split (2026-05-18) closed the remaining ≤1200 LOC cap
//! by extracting per-domain modules for the four still-oversize files
//! (`http`, `transport`, `federation_receive`, `hook_subscribers`,
//! `power`) into focused siblings.
//!
//! Sub-modules:
//!
//! - [`transport`] — `AppState`, `Db`, `JsonOrBadRequest`, auth
//! middleware, shared constants (`MAX_BULK_SIZE`,
//! `BULK_FANOUT_CONCURRENCY`), low-level helpers, health, metrics.
//! - [`postgres_gate`] — `#[cfg(feature = "sal")]` postgres
//! route-matrix + middleware + `store_err_to_response` sanitiser.
//! - [`http`] — `maybe_auto_tag` + `maybe_detect_conflicts` +
//! `ConflictReport` (the LLM hooks the create path consumes).
//! - [`create`] — `POST /api/v1/memories` create-path orchestrator
//! + six stage helpers + postgres branch.
//! - [`memories`] — memory CRUD (`get`/`update`/`delete`/`promote`).
//! - [`memories_query`] — list / search / forget / bulk_create.
//! - [`federation_receive`] — federation receive-side `sync_push` body +
//! helpers (clock skew, quota attribution, peer-id extraction).
//! - [`federation_signing_check`] — `#[cfg(feature = "sal")]`
//! `sync_push_via_store` postgres-receive branch + per-message
//! Ed25519 signature verification (#791).
//! - [`federation_sync_since`] — federation `/sync/since` GET pull.
//! - [`hook_subscribers`] — inbox + namespace standard handlers +
//! session-start.
//! - [`subscriptions`] — notify + subscribe + unsubscribe +
//! list_subscriptions.
//! - [`power`] — taxonomy / contradictions / list_namespaces /
//! check_duplicate (non-LLM power-tier reads).
//! - [`power_consolidation`] — consolidate + auto_tag + expand_query +
//! load_family (LLM-backed power-tier writes).
//! - [`errors`] — issue #851 HTTP error-sanitization helpers.
//! - [`system`] — `/api/v1/capabilities` and system reads.
//! - [`parity`] — cross-cutting HTTP-parity helpers.
//! - [`approvals`] — v0.7.0 K10 approval API.
/// Tracing target for HTTP-layer authorization (ownership-gate /
/// caller-resolution) denials, shared across the handler sub-modules
/// (#1558 tracing-target SSOT).
pub const AUTHZ_TRACE_TARGET: &str = "ai_memory::authz";
/// #1558 batch 5 wave 3 — `quota_refused` count field on the
/// federation `/sync/push` response envelope (sqlite + postgres
/// arms, quota-413 + success shapes). One spelling across the four
/// production emit sites in `federation_receive` /
/// `federation_signing_check`.
pub const QUOTA_REFUSED_FIELD: &str = "quota_refused";
/// v0.7.0 #1111 — 14 missing HTTP routes for the MCP-only tools the
/// SR-4 three-surface-parity audit flagged. Each handler is a thin
/// wrapper around the existing `crate::mcp::handle_<name>` substrate
/// primitive; wire envelopes are byte-equal across the two surfaces.
/// #1558 batch 4 — HTTP route-path SSOT: one named const per
/// production route; registration (lib.rs) and match sites
/// (postgres_gate, federation receive, CLI doctor) share them.
// #1579 B4 — HTTP response-format negotiation (json | toon |
// toon_compact) for the recall/search surfaces.
// Re-export the public-facing handler surface so external callers
// (router wiring in `src/lib.rs`, integration tests) can still
// reference `handlers::<name>` without knowing which sub-module the
// item came from. Wire compatibility is preserved verbatim.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
// Inline test scaffold (`#[cfg(test)] mod tests`) preserved verbatim
// from the pre-split mod.rs body. Tracked for future per-domain
// decomposition into `tests/handlers_<domain>.rs` integration test
// crates; the move-out is gated on exposing a stable `AppState`
// constructor helper from production code so tests outside the crate
// can build it without re-inventing fixture wiring (see #650 follow-up).