fix(archied): build the Gateway's worktree manager so it serves review_pr

boot.prReviewer returns nil without a worktree manager, and a nil reviewer
omits review_pr from every channel's tool set. RunGateway never called
buildTreesAndIdentities, so the Gateway resolved a nil reviewer and no
channel could review a PR.

Extract the manager's construction into boot.buildWorktreeManager, called
by buildTreesAndIdentities (daemon, unchanged field-for-field) and by
startGatewayRuntime before setupGatewayChat. The Gateway does not call
buildTreesAndIdentities: that also registers daemon identity runners the
Gateway must not own, and PR review only needs a clone of the PR head,
which worktree.Manager.CheckoutPR does from the forge.

Pin the ordering by source position in composition_order_test.go, alongside
the memory-engine ordering the same function already carries, and pin both
compositions behaviourally in worktree_manager_composition_test.go: the
Gateway's step must yield a reviewer that advertises review_pr, and the
daemon must still build its root manager plus one runner per identity with
a distinct WorkDir.

Correct docs/prds/operator-pr-review.md, which still asserted the daemon
supplies ChatPRReviewer and holds the review in-flight set.
This commit is contained in:
sam committed 2026-09-22 03:44:45 +10:00
1 parent a45aebcf14
commit 7fd01992d3
5 files changed
+164 -13

No files matched your search

+8 -6
View File
@@ -50,18 +50,20 @@ planner/builder.
4. **Command.** A gateway tool `review_pr` (toolset `tasks`) bound to the
channel's identity at construction — the model never names an identity,
matching `task_spawn`/`task_action`. The daemon supplies `ChatPRReviewer`,
a narrow gateway interface; the daemon adapter maps `workflow.ReviewReport`
into a gateway-owned result shape (gateway states what it needs, the daemon
adapts — the `ChatTaskActor` pattern).
matching `task_spawn`/`task_action`. The Gateway process serves it: it
composes the worktree manager it needs to materialise the PR head, and the
composition root supplies `ChatPRReviewer`, a narrow gateway interface
whose adapter maps `workflow.ReviewReport` into a gateway-owned result
shape (gateway states what it needs, the composition root adapts — the
`ChatTaskActor` pattern).
5. **Authorization.** Identity-scoped repository allow-list, the
`task_spawn` rule: a chat identity may only review a repo in its
`TaskProfile.Repos`. `identity == nil` denotes an authenticated dashboard
operator who may review any configured repository.
6. **Determinism.** One review per (owner, repo, number) at a time: the daemon
holds an in-flight set; a concurrent request for the same PR returns
6. **Determinism.** One review per (owner, repo, number) at a time: the
Gateway holds an in-flight set; a concurrent request for the same PR returns
"review already in progress" rather than launching a second reviewer and
racing on the snapshot.