review_pr was registered on every channel and failed on every call with
"worktree manager is not configured". Two independent causes, one contract:
The daemon ran setupGateways before buildTreesAndIdentities, so setupGateways
reached prReviewer() while b.trees was still nil and captured it; the memoised
reviewer then held that nil for the process lifetime. Build the worktree
manager before the gateways, which is the ordering the reviewer depends on.
Ordering alone cannot fix the standalone Gateway, which calls prReviewer() and
never builds trees at all. Have prReviewer() return nil when b.trees is nil, so
a reviewer that can never run is not produced. That is what
gateway.ReviewTools' existing nil-reviewer guard always intended -- "a tool that
cannot run must not be advertised" -- but the guard never fired because the
daemon never passed nil.
TestPrReviewerIsMemoized asserted a trees-less boot yields a non-nil cached
reviewer, encoding the broken precondition as expected behaviour, which is why
a green suite hid this since review_pr shipped. It now gives the boot a real
worktree manager so its actual subject -- one shared in-flight set across
channels -- stays pinned, and two tests are added: one for the nil-trees
invariant, and one that composes the real wiring (prReviewer -> ReviewTools)
and asserts review_pr is registered only when the reviewer can run.
Found by an adversarial package sweep (temp tracker: app-archied-5,
.local/issue-tracker/).