remediate workflow: one run per review on the existing PR branch #1173

Closed
opened 2026-10-27 13:39:19 +00:00 by sam · 0 comments
Owner

The remediate workflow: react to one review by fixing what it flagged on the
existing PR branch.

Step 5 of docs/prds/pr-review-remediation.md, decision 4. Not a new branch or
PR: refresh the task's worktree onto the PR branch, run a builder agent whose
mission is the review's actionable comments, run the repo gate and
diff_cap_lines unchanged, commit and push to the same branch, reply via
ReplyToReview.

Strictly one run per review, never per comment (decision 5). A review with
eight inline comments arrives as one pull_request_review event plus eight
pull_request_review_comment events; comment events are collected against their
parent ReviewID and remediated together. Per-comment runs mean eight builder
runs, eight gates and eight pushes to answer one review.

Runs for one task serialise regardless of repos.allow_concurrent: two runs
on one PR branch race on the worktree and the push.

Only archie's own comments are excluded, matched on the task's forge identity.
Other bots' comments are actionable: the external review bot is the main
source of findings on an archie-opened PR. There is no "is a bot" test in this
path.

Because of that, remediation rounds are capped by the repo's max_retries. With
bot comments actionable the exchange runs away with no human involved: archie
pushes, the review bot re-reviews the new commit and comments, archie
remediates again. On the cap archie stops, posts one comment saying why, and
parks. Hard stop, not a backoff.

Depends on archie-core-8li9.1 (stream), .2 (owned-task guard) and .3
(envelope).

Acceptance: one review with N comments produces exactly one builder run; the
round cap parks with a comment; a second reaction for a task already
remediating queues behind it.

Notes

2026-09-18: prerequisites are now landed locally on main: reaction stream from upstream 9e8427bc; envelope commit aa646c8b; owned-task lookup/resolver/RPC/index commit 47464881. task check passed at 47464881 with only the pre-existing unrelated go.sum diff left unstaged. Next: implement daemon reaction consumer + per-task serializer and agent remediate workflow using worktree.Manager.Resume (not Prepare/refresh), persisted review unit/round state, forge comment aggregation and ReplyToReview.
2026-09-19: remediate workflow engine landed (internal/domain/workflow/remediate.go): Remediate() with StageCheckReviewPayload, StageRemediationRoundCap (RetryCount doubles as the round counter, capped by repo max_retries), StageResumeWorktree (worktree.Manager.Resume via an unexported resumableTrees capability, not part of the exported Trees interface -- Trees is projected into wfextract's Yaegi table and was already at golangci-lint's interfacebloat cap of 8), remediate-build agent stage, StageRemediationCommitPush (no-changes is a normal outcome here, unlike StageCommitPush), StageRemediationReply (threads via Forger.ReplyToReview onto the first actionable comment, falls back to Forger.Comment for a bare review with no inline comments). Registered as "remediate" in skillbuild.builtins(). Task gained ReviewPayload (JSON-encoded ReviewUnit) with full store/proto/staterpc plumbing. Forger gained Comment/ReplyToReview; forgerpc got a matching NATS RPC (SubjectReplyToReview) for archie-agent. Full test coverage in remediate_test.go including an end-to-end stage-by-stage run. task check: build/vet/all tests/proto:check/docs:check pass; lint clean for every package this change touched (verified in isolation) -- task check itself currently fails on unrelated pre-existing uncommitted lint issues in internal/app/archiemessaging and cmd/archie-messaging (someone else's in-progress service-decomposition work, left untouched).

NOT done, still needed for full 8li9.4 acceptance: the daemon-side reaction consumer that subscribes ARCHIE_REACTIONS, resolves via ReviewTaskResolver, groups review-comment events by parent ReviewID into one ReviewUnit per decision 5, sets Task.Workflow="remediate" and Task.ReviewPayload, and enforces per-task serialization ("a second reaction for a task already remediating queues behind it") regardless of repos.allow_concurrent. Also: daemon must call worktree Resume on the bind-mounted worktree before container start for container/NATS execution mode, the same way it already does for Prepare -- hybridTrees.Resume is currently a no-op stub with this gap documented in its own comment (internal/app/agentworker/task_execution.go).

Close reason

Implemented in main by internal/domain/workflow/remediate.go, landed in the #891 squash e0b6aa61. Verified against this bead's spec: StageResumeWorktree calls rt.Resume(ctx, dir, tc.Task.Branch) to refresh the prepared worktree onto the existing PR branch instead of resetting to base; StageRemediationRoundCap uses Repo.EffectiveMaxRetries; ReviewUnit.ReviewID collects a review's comment events so one review is one run, never one per comment; StageRemediationCommitPush pushes to the same branch; StageRemediationReply calls Forge.ReplyToReview. Covered by remediate_test.go. This also resolves the earlier .local/issue-tracker worktree-1 finding, whose barrier was this bead: Manager.Resume now has a production caller.


Imported from beads archie-core-8li9.4 · GitHub #913 · type feature · priority P1 · created 2026-09-18 · closed 2026-09-19

The remediate workflow: react to one review by fixing what it flagged on the existing PR branch. Step 5 of docs/prds/pr-review-remediation.md, decision 4. Not a new branch or PR: refresh the task's worktree onto the PR branch, run a builder agent whose mission is the review's actionable comments, run the repo gate and diff_cap_lines unchanged, commit and push to the same branch, reply via ReplyToReview. Strictly one run per review, never per comment (decision 5). A review with eight inline comments arrives as one pull_request_review event plus eight pull_request_review_comment events; comment events are collected against their parent ReviewID and remediated together. Per-comment runs mean eight builder runs, eight gates and eight pushes to answer one review. Runs for one task serialise regardless of [[repos]].allow_concurrent: two runs on one PR branch race on the worktree and the push. Only archie's own comments are excluded, matched on the task's forge identity. Other bots' comments are actionable: the external review bot is the main source of findings on an archie-opened PR. There is no "is a bot" test in this path. Because of that, remediation rounds are capped by the repo's max_retries. With bot comments actionable the exchange runs away with no human involved: archie pushes, the review bot re-reviews the new commit and comments, archie remediates again. On the cap archie stops, posts one comment saying why, and parks. Hard stop, not a backoff. Depends on archie-core-8li9.1 (stream), .2 (owned-task guard) and .3 (envelope). Acceptance: one review with N comments produces exactly one builder run; the round cap parks with a comment; a second reaction for a task already remediating queues behind it. ### Notes 2026-09-18: prerequisites are now landed locally on main: reaction stream from upstream 9e8427bc; envelope commit aa646c8b; owned-task lookup/resolver/RPC/index commit 47464881. task check passed at 47464881 with only the pre-existing unrelated go.sum diff left unstaged. Next: implement daemon reaction consumer + per-task serializer and agent remediate workflow using worktree.Manager.Resume (not Prepare/refresh), persisted review unit/round state, forge comment aggregation and ReplyToReview. 2026-09-19: remediate workflow engine landed (internal/domain/workflow/remediate.go): Remediate() with StageCheckReviewPayload, StageRemediationRoundCap (RetryCount doubles as the round counter, capped by repo max_retries), StageResumeWorktree (worktree.Manager.Resume via an unexported resumableTrees capability, not part of the exported Trees interface -- Trees is projected into wfextract's Yaegi table and was already at golangci-lint's interfacebloat cap of 8), remediate-build agent stage, StageRemediationCommitPush (no-changes is a normal outcome here, unlike StageCommitPush), StageRemediationReply (threads via Forger.ReplyToReview onto the first actionable comment, falls back to Forger.Comment for a bare review with no inline comments). Registered as "remediate" in skillbuild.builtins(). Task gained ReviewPayload (JSON-encoded ReviewUnit) with full store/proto/staterpc plumbing. Forger gained Comment/ReplyToReview; forgerpc got a matching NATS RPC (SubjectReplyToReview) for archie-agent. Full test coverage in remediate_test.go including an end-to-end stage-by-stage run. task check: build/vet/all tests/proto:check/docs:check pass; lint clean for every package this change touched (verified in isolation) -- task check itself currently fails on unrelated pre-existing uncommitted lint issues in internal/app/archiemessaging and cmd/archie-messaging (someone else's in-progress service-decomposition work, left untouched). NOT done, still needed for full 8li9.4 acceptance: the daemon-side reaction consumer that subscribes ARCHIE_REACTIONS, resolves via ReviewTaskResolver, groups review-comment events by parent ReviewID into one ReviewUnit per decision 5, sets Task.Workflow="remediate" and Task.ReviewPayload, and enforces per-task serialization ("a second reaction for a task already remediating queues behind it") regardless of [[repos]].allow_concurrent. Also: daemon must call worktree Resume on the bind-mounted worktree before container start for container/NATS execution mode, the same way it already does for Prepare -- hybridTrees.Resume is currently a no-op stub with this gap documented in its own comment (internal/app/agentworker/task_execution.go). ### Close reason Implemented in main by internal/domain/workflow/remediate.go, landed in the #891 squash e0b6aa61. Verified against this bead's spec: StageResumeWorktree calls rt.Resume(ctx, dir, tc.Task.Branch) to refresh the prepared worktree onto the existing PR branch instead of resetting to base; StageRemediationRoundCap uses Repo.EffectiveMaxRetries; ReviewUnit.ReviewID collects a review's comment events so one review is one run, never one per comment; StageRemediationCommitPush pushes to the same branch; StageRemediationReply calls Forge.ReplyToReview. Covered by remediate_test.go. This also resolves the earlier .local/issue-tracker worktree-1 finding, whose barrier was this bead: Manager.Resume now has a production caller. --- _Imported from beads `archie-core-8li9.4` · GitHub #913 · type feature · priority P1 · created 2026-09-18 · closed 2026-09-19_
sam added the highfeature labels 2026-10-27 13:39:19 +00:00
sam self-assigned this 2026-10-27 13:39:19 +00:00
sam closed this issue 2026-10-27 13:39:19 +00:00
sam added a new dependency 2026-10-27 13:42:19 +00:00
sam added a new dependency 2026-10-27 13:42:19 +00:00
sam added a new dependency 2026-10-27 13:42:19 +00:00
sam added a new dependency 2026-10-27 13:42:19 +00:00
sam added a new dependency 2026-10-27 13:42:19 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#1173