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
//! GET /api/v1/sessions/managed/reconcile-worktrees — the report-only
//! worktree inventory (#4207 slice 3, #4288).
//!
//! Why: the reconciled inventory is worthless if nothing surfaces it. Every
//! existing worktree surface (`tm doctor`, `tm session prune-worktrees`) shows
//! only the ADMITTED reclaim candidates, so 33 of the 118 registered worktrees
//! on the dogfood machine — six of them holding uncommitted work, including
//! both landmines #4288 documents — are invisible to an operator today.
//!
//! What: a GET with no body and no side effects. It reads the session store and
//! runs `git worktree list` / `git rev-parse`; it writes nothing, deletes
//! nothing, and takes no `dry_run` parameter because there is no non-dry-run
//! form of it. This is deliberately a separate route from `prune-worktrees`
//! rather than a flag on it: a reporting verb that shares an entry point with a
//! destructive one eventually grows a `force` flag.
//! Test: `reconcile_worktrees_route_reports_without_mutating`.
use Arc;
use ;
use warn;
use crateRouteOutcome;
use crateDaemonState;
/// The two worktree routes as one sub-router (#4288).
///
/// Why: `api.rs` is 1,200+ SLOC and grandfathered under a frozen line-cap
/// budget, so a new route may not simply be appended there. Owning both
/// worktree verbs in one place also keeps them registered as a pair — the
/// destructive one and the read-only one are meant to be read together, and a
/// reviewer looking at either sees the other.
/// What: `POST …/prune-worktrees` (the pre-existing reclaimer, unchanged) and
/// `GET …/reconcile-worktrees` (this module). Both are literal segments, so
/// axum matches them ahead of the `…/managed/{id}` param route regardless of
/// where this sub-router is merged.
/// Test: `reconcile_worktrees_route_reports_without_mutating`;
/// `prune_spares_a_stopped_records_workspace` covers the prune half.
/// GET /api/v1/sessions/managed/reconcile-worktrees (#4288).
///
/// Why: see the module doc — this is the only surface that reports the excluded
/// set, the three-state classification with a reason per row, and the
/// proposed-adoption list.
/// What: delegates to
/// [`SessionManager::reconcile_worktree_inventory`](crate::session_manager::SessionManager::reconcile_worktree_inventory)
/// against the configured managed workspace root and returns the
/// [`ReconcileReport`](crate::session_manager::worktree_reconcile::ReconcileReport)
/// as JSON. A scan panic becomes a 500 rather than a silently empty inventory —
/// an empty report reads as "nothing to reconcile", which is the worst possible
/// lie for this surface.
/// Test: `reconcile_worktrees_route_reports_without_mutating`.
pub async
/// The transport-neutral body of `GET .../managed/reconcile-worktrees` (#6288),
/// served over the socket as `mpm.managed.reconcile_worktrees`.
///
/// Test: `managed_reconcile_worktrees_parity` in `daemon::rpc::managed_tests`.
pub async