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
//! `GET /api/v1/manager/version` — the manager surface's self-describing
//! capabilities stub (WI-1, #2578).
//!
//! Why: DOC-36 §4's local-testability bar requires the `/api/v1/manager/*`
//! surface to be reachable and meaningful via `curl` "from day one", before any
//! channel/bot token exists and before the later-phase endpoints (digest, chat,
//! route-task, escalations) are implemented. A version/capabilities endpoint is
//! the smallest thing that makes the scaffold observably alive: it names the
//! manager API version, the delivery phase, the full DOC-36 §3.2 verb set with a
//! per-endpoint `available` flag (so the roadmap is honest — implemented vs.
//! planned), and the portfolio palace status (WI-5, #2582) so provisioning is
//! curl-observable. This single endpoint therefore ties all three phase-1a work
//! items into one hermetic, token-free smoke surface.
//! What: [`ManagerVersionResponse`] + the [`manager_version_route`] handler,
//! which reads the daemon-owned [`crate::daemon::manager::ManagerState`] for
//! live palace availability and returns a static-plus-live capabilities snapshot.
//! Test: `manager_version_route_reports_capabilities` in `tests/manager_routes.rs`.
use Arc;
use ;
use Serialize;
use crateDaemonState;
/// The manager HTTP API version this daemon serves.
///
/// Why: pins a stable contract version for the `/api/v1/manager/*` surface,
/// independent of the crate version, so a channel/CLI client can feature-detect
/// against a value that only changes when the manager wire contract does.
/// What: the manager-surface semantic version string.
/// Test: `manager_version_route_reports_capabilities`.
const MANAGER_API_VERSION: &str = "0.1.0";
/// The DOC-36 delivery phase this build implements.
///
/// Why: DOC-36 §6 phases the manager surface (1 read-only chat → 2 routing → 3
/// proactive → 4 channels); surfacing the phase lets an operator confirm which
/// slice is live. Phase 2 (epic #2109) adds `route-task` + the `act`
/// proposal-and-confirm flow on top of the phase-1 read-only surface.
/// What: the integer phase number.
/// Test: `manager_version_route_reports_capabilities`.
const MANAGER_PHASE: u8 = 2;
/// One entry in the manager surface's advertised verb set.
///
/// Why: makes the DOC-36 §3.2 roadmap self-describing over HTTP — a consumer
/// reads which endpoints exist NOW (`available = true`) versus which are planned
/// for a later phase (`available = false`), instead of discovering a 404 by
/// trial. Later WIs flip their own flag to `true` as they land.
/// What: the HTTP `method`, the `path`, and whether it is live in this build.
/// Test: `manager_version_route_reports_capabilities`.
/// Live status of the portfolio manager palace (WI-5, #2582).
///
/// Why: DOC-36 §4's degrade bar means the palace may be absent (feature not
/// compiled) or unavailable (open failed) while the manager surface still works;
/// surfacing that here makes provisioning success/failure curl-observable without
/// a separate diagnostic endpoint.
/// What: the stable palace id, an `available` flag, and an optional `reason`
/// string when unavailable.
/// Test: `manager_version_route_reports_capabilities`.
/// Response body for `GET /api/v1/manager/version`.
///
/// Why: the single self-describing snapshot of the manager surface — versions,
/// phase, verb-set roadmap, and palace status — that the DOC-36 §4 local-test
/// bar exercises first.
/// What: the manager API version, the crate version, the delivery phase, the
/// advertised endpoint set, and the portfolio palace status.
/// Test: `manager_version_route_reports_capabilities`.
/// The advertised DOC-36 §3.2 verb set for the manager surface.
///
/// Why: centralises the roadmap so `version` stays the single source of truth for
/// "what does `/api/v1/manager/*` offer". Phase-1 ships `version` + `status` +
/// `digest` + `chat`; `route-task` and `escalations` are advertised as planned so
/// the surface documents its own trajectory without pretending to serve endpoints
/// later WIs own.
/// What: the five §3.2 endpoints plus this `version` stub, each tagged with its
/// current availability in this build.
/// Test: `manager_version_route_reports_capabilities`.
/// `GET /api/v1/manager/version` — capabilities + palace status snapshot.
///
/// Why: the curl-first smoke endpoint (DOC-36 §4) that proves the manager
/// scaffold is mounted and reports the live portfolio palace state (§2582)
/// without any LLM call, channel, or bot token.
/// What: reads the daemon-owned [`crate::daemon::manager::ManagerState`] palace
/// handle and returns a [`ManagerVersionResponse`] combining static version/phase
/// /verb-set data with the live palace availability. Read-only; never mutates.
/// Test: `manager_version_route_reports_capabilities` in `tests/manager_routes.rs`.
pub async