Review triggers: operator, watched repositories, archie's own PRs #132

Closed
opened 2026-10-27 13:35:05 +00:00 by sam · 6 comments
Owner

PR update cancels the in-flight review; own-PR pipeline replaces the single-reviewer stage. See docs/prds/pr-review-agent.md.

Close reason

Two of three triggers delivered. Archie's own PRs: StagePRReviewAndOpenPR runs the decision phases against the task's own worktree, parks on an unchallenged blocking finding, opens the PR, posts advisory findings from the same stage body (148a7645). Watched repositories: no bespoke webhook code, the generic capture+binding system carries any inbound PR event to the pr-review workflow, with an operator wiring a Binding (source matcher, CEL filter for pull_request, pr_number inputs mapping) entirely from the dashboard (7fb1ccd2), plus a fix so archie's own PRs need no PR number (5264d5d8). The operator/chat trigger is not delivered here: it is split to archie-core-afbk.14, which carries the concrete plan, because EnqueueChatTask is part of the State Store's protobuf gRPC contract and extending it for a generic inputs parameter needs a proto field, regen, a new narrow SQL query, and signature threading across the store/staterpc/gateway layers. Closing this bead with that split named rather than leaving it open, per the maintainer's decision. 7-10 are the afbk.3/.4/.5/.8 Stage design, the removal of the superseded adversarial-self-review system, the HTTP-based PRSource rebuild, the daemon prefetch that keeps every forge credential out of the container, and archie's-own-PRs wiring, all shipped.


Imported from beads archie-core-afbk.7 · GitHub #1197 · type task · priority P1 · created 2026-09-25 · closed 2026-09-28

PR update cancels the in-flight review; own-PR pipeline replaces the single-reviewer stage. See docs/prds/pr-review-agent.md. ### Close reason Two of three triggers delivered. Archie's own PRs: StagePRReviewAndOpenPR runs the decision phases against the task's own worktree, parks on an unchallenged blocking finding, opens the PR, posts advisory findings from the same stage body (148a7645). Watched repositories: no bespoke webhook code, the generic capture+binding system carries any inbound PR event to the pr-review workflow, with an operator wiring a Binding (source matcher, CEL filter for pull_request, pr_number inputs mapping) entirely from the dashboard (7fb1ccd2), plus a fix so archie's own PRs need no PR number (5264d5d8). The operator/chat trigger is not delivered here: it is split to archie-core-afbk.14, which carries the concrete plan, because EnqueueChatTask is part of the State Store's protobuf gRPC contract and extending it for a generic inputs parameter needs a proto field, regen, a new narrow SQL query, and signature threading across the store/staterpc/gateway layers. Closing this bead with that split named rather than leaving it open, per the maintainer's decision. 7-10 are the afbk.3/.4/.5/.8 Stage design, the removal of the superseded adversarial-self-review system, the HTTP-based PRSource rebuild, the daemon prefetch that keeps every forge credential out of the container, and archie's-own-PRs wiring, all shipped. --- _Imported from beads `archie-core-afbk.7` · GitHub #1197 · type task · priority P1 · created 2026-09-25 · closed 2026-09-28_
sam added the hightask labels 2026-10-27 13:35:05 +00:00
sam self-assigned this 2026-10-27 13:35:05 +00:00
sam closed this issue 2026-10-27 13:35:05 +00:00
Author
Owner

sam wrote (originally 2026-09-28):

Partial progress this pass -- not closing, real trigger surfaces remain unwired:

Committed: 697971bb -- internal/infrastructure/prsource, a real workflow.PRSource implementation (Metadata/Diff/Snapshot) against narrow Forge (GetPullRequest) and Trees (CheckoutPR/Diff/Snapshot) contracts. worktree.Manager already satisfies Trees structurally; forge.PullRequestReader needs a small field-mapping adapter at whichever composition root wires it (not yet written). task check clean.

Real blocker found before wiring it into production, via codegraph + reading code (not guessed past): CheckoutPR needs the forge credential, which only archied holds. The sandboxed agent-worker's hybridTrees (internal/app/agentworker/task_execution.go) has a bare worktree.Manager with BotUser/BotEmail only, no token -- confirmed by reading how Prepare/Push already avoid this exact problem: they proxy over worktreerpc to archied instead of running locally, because those also need the credential. PRSource's checkout has the identical shape and needs the identical treatment (a new worktreerpc-style proxy, or the pr-review pipeline running daemon-side like the existing operator reviewer does), not a direct construction inside agentworker. Building it the naive way would either silently fail in the container path or violate 'no pipeline agent holds a forge credential.'

This blocks all three trigger surfaces, since every one of them ultimately has to hand the sandboxed pr-review workflow run a working PRSource:

  1. Watched repositories: needs a NEW per-repo config field (Repo.ReviewEnabled already means something else -- it gates the older adversarial-self-review stage in internal/domain/workflow/review.go / docs/prds/adversarial-self-review.md, confirmed via codegraph search before assuming it was free to reuse). Needs the credential-boundary problem solved first.
  2. Operator: internal/app/archied/pr_review.go's prReviewer/gateway.ChatPRReviewer.ReviewPR already does a synchronous single-reviewer PR review today (fetches PR, checks out via trees.CheckoutPR, runs the OLD Reviewer). It runs entirely daemon-side, which is exactly why it doesn't hit the credential problem -- but it's synchronous and returns a result in the same request, not an async tracked pr-review workflow run. Replacing/complementing it with 'starts a run' (StepExecution-tracked, dashboard-visible) is a user-facing behavior change worth a maintainer call, not a decision to make silently mid-bead.
  3. Archie's own PRs: internal/domain/workflow/review.go's StageReview/StagePostReviewComments is the existing single-reviewer stage the PRD says the new pipeline replaces. It runs inside the same sandboxed implement-workflow execution the credential problem already blocks.

Recommend: solve the credential-boundary question once (a worktreerpc PRSource proxy, or running pr-review daemon-side unconditionally like the operator reviewer already does) before attempting any of the three triggers, rather than solving it three times inconsistently. Filed nowhere new since this is squarely this bead's own scope, not a side-discovery.

_sam wrote (originally 2026-09-28):_ Partial progress this pass -- not closing, real trigger surfaces remain unwired: Committed: 697971bb -- internal/infrastructure/prsource, a real workflow.PRSource implementation (Metadata/Diff/Snapshot) against narrow Forge (GetPullRequest) and Trees (CheckoutPR/Diff/Snapshot) contracts. worktree.Manager already satisfies Trees structurally; forge.PullRequestReader needs a small field-mapping adapter at whichever composition root wires it (not yet written). task check clean. Real blocker found before wiring it into production, via codegraph + reading code (not guessed past): CheckoutPR needs the forge credential, which only archied holds. The sandboxed agent-worker's hybridTrees (internal/app/agentworker/task_execution.go) has a bare worktree.Manager with BotUser/BotEmail only, no token -- confirmed by reading how Prepare/Push already avoid this exact problem: they proxy over worktreerpc to archied instead of running locally, because those also need the credential. PRSource's checkout has the identical shape and needs the identical treatment (a new worktreerpc-style proxy, or the pr-review pipeline running daemon-side like the existing operator reviewer does), not a direct construction inside agentworker. Building it the naive way would either silently fail in the container path or violate 'no pipeline agent holds a forge credential.' This blocks all three trigger surfaces, since every one of them ultimately has to hand the sandboxed pr-review workflow run a working PRSource: 1. Watched repositories: needs a NEW per-repo config field (Repo.ReviewEnabled already means something else -- it gates the older adversarial-self-review stage in internal/domain/workflow/review.go / docs/prds/adversarial-self-review.md, confirmed via codegraph search before assuming it was free to reuse). Needs the credential-boundary problem solved first. 2. Operator: internal/app/archied/pr_review.go's prReviewer/gateway.ChatPRReviewer.ReviewPR already does a synchronous single-reviewer PR review today (fetches PR, checks out via trees.CheckoutPR, runs the OLD Reviewer). It runs entirely daemon-side, which is exactly why it doesn't hit the credential problem -- but it's synchronous and returns a result in the same request, not an async tracked pr-review workflow run. Replacing/complementing it with 'starts a run' (StepExecution-tracked, dashboard-visible) is a user-facing behavior change worth a maintainer call, not a decision to make silently mid-bead. 3. Archie's own PRs: internal/domain/workflow/review.go's StageReview/StagePostReviewComments is the existing single-reviewer stage the PRD says the new pipeline replaces. It runs inside the same sandboxed implement-workflow execution the credential problem already blocks. Recommend: solve the credential-boundary question once (a worktreerpc PRSource proxy, or running pr-review daemon-side unconditionally like the operator reviewer already does) before attempting any of the three triggers, rather than solving it three times inconsistently. Filed nowhere new since this is squarely this bead's own scope, not a side-discovery.
Author
Owner

sam wrote (originally 2026-09-28):

Continuation (2026-09-28, this pass): commit d73e0748 removed the superseded adversarial-self-review system in full per the maintainer's decision -- review.go/review_findings.go/review_report_md.go/pr_review.go/agentworker's review.go and their tests all deleted, config.Repo.ReviewEnabled and its dashboard exposure removed, ChatPRReviewer wiring left dormant (review_pr chat tool self-omits with a nil reviewer) rather than replaced. Grepped the whole tree after: zero references remain. task check clean.

Also split PRReview()'s Stage list into prReviewDecisionStages() (phases 1-8, through the merge gate) and stagePROutput() (phase 9), anticipating the archie's-own-PRs trigger's real requirement: the park-or-proceed decision must happen before a PR exists (no PR number to post to yet), posting must happen after. Carried ScoredFinding.Adversary through synthesis so that trigger's 'blocking finding the adversary did not challenge' check has both facts on one struct.

None of the three trigger surfaces are wired yet. Two real blockers, not implementation details:

  1. Archie's own PRs (should have been the easy one -- local Trees, no forge network needed): blocked on verifying whether workflow.go's literal Run() loop (which ends the moment any stage sets tc.Outcome, per its 'if tc.Outcome.Status != "" { finish(...); return }' check) is actually what executes Implement() in production, or whether the compiled-workflow-definition engine (internal/infrastructure/workflowsteps, reached via CompilePinnedWorkflow -- confirmed via pr_impact that PRReview()/Implement() both compile through legacyBuiltinWorkflows/BuiltinStepRegistry/ShippedDefinitions) has different semantics for an Outcome-setting stage like StageOpenPR (which sets StatusPROpen). If the raw Run() semantics hold, splicing stagePROutput() after StageOpenPR in the same flat Stage list is dead code -- StageOpenPR's own Outcome assignment would end the workflow before it ran. Needs a symbol_context/read pass on the compiled engine before wiring this, not a guess.

  2. Watched-repositories and operator triggers: both need a real PRSource (commit 697971bb) inside the sandboxed archie-agent process, which holds no forge credential today. Maintainer's interim decision: 'environment variables available to the agent could work' for now, org-configured credential-binding long-term (filed as archie-core-afbk.13). The env-var route needs one more concrete design call before building: prsource.Trees (CheckoutPR/Diff/Snapshot) is presently modeled on *worktree.Manager, a git-shell implementation needing a local clone and a git-level credential (SSH/HTTPS) -- the sandboxed container may have neither, even with a bare API token in its environment. The token alone is enough for prsource.Forge (a REST/GraphQL call), but Trees likely needs a parallel HTTP-API-backed implementation (fetch diff via the compare/pulls endpoint, snapshot via the Contents API) rather than reusing worktree.Manager, unless the container turns out to already have local git-over-HTTPS egress with a viable credential. Whoever picks this up should confirm what the sandboxed container's actual network/git capability is before choosing between 'new HTTP-based Trees impl' and 'give the container real git credentials too.'

Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out mechanism, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision itself (done).

_sam wrote (originally 2026-09-28):_ Continuation (2026-09-28, this pass): commit d73e0748 removed the superseded adversarial-self-review system in full per the maintainer's decision -- review.go/review_findings.go/review_report_md.go/pr_review.go/agentworker's review.go and their tests all deleted, config.Repo.ReviewEnabled and its dashboard exposure removed, ChatPRReviewer wiring left dormant (review_pr chat tool self-omits with a nil reviewer) rather than replaced. Grepped the whole tree after: zero references remain. task check clean. Also split PRReview()'s Stage list into prReviewDecisionStages() (phases 1-8, through the merge gate) and stagePROutput() (phase 9), anticipating the archie's-own-PRs trigger's real requirement: the park-or-proceed decision must happen before a PR exists (no PR number to post to yet), posting must happen after. Carried ScoredFinding.Adversary through synthesis so that trigger's 'blocking finding the adversary did not challenge' check has both facts on one struct. None of the three trigger surfaces are wired yet. Two real blockers, not implementation details: 1. Archie's own PRs (should have been the easy one -- local Trees, no forge network needed): blocked on verifying whether workflow.go's literal Run() loop (which ends the moment any stage sets tc.Outcome, per its 'if tc.Outcome.Status != "" { finish(...); return }' check) is actually what executes Implement() in production, or whether the compiled-workflow-definition engine (internal/infrastructure/workflowsteps, reached via CompilePinnedWorkflow -- confirmed via pr_impact that PRReview()/Implement() both compile through legacyBuiltinWorkflows/BuiltinStepRegistry/ShippedDefinitions) has different semantics for an Outcome-setting stage like StageOpenPR (which sets StatusPROpen). If the raw Run() semantics hold, splicing stagePROutput() after StageOpenPR in the same flat Stage list is dead code -- StageOpenPR's own Outcome assignment would end the workflow before it ran. Needs a symbol_context/read pass on the compiled engine before wiring this, not a guess. 2. Watched-repositories and operator triggers: both need a real PRSource (commit 697971bb) inside the sandboxed archie-agent process, which holds no forge credential today. Maintainer's interim decision: 'environment variables available to the agent could work' for now, org-configured credential-binding long-term (filed as archie-core-afbk.13). The env-var route needs one more concrete design call before building: prsource.Trees (CheckoutPR/Diff/Snapshot) is presently modeled on *worktree.Manager, a git-shell implementation needing a local clone and a git-level credential (SSH/HTTPS) -- the sandboxed container may have neither, even with a bare API token in its environment. The token alone is enough for prsource.Forge (a REST/GraphQL call), but Trees likely needs a parallel HTTP-API-backed implementation (fetch diff via the compare/pulls endpoint, snapshot via the Contents API) rather than reusing worktree.Manager, unless the container turns out to already have local git-over-HTTPS egress with a viable credential. Whoever picks this up should confirm what the sandboxed container's actual network/git capability is before choosing between 'new HTTP-based Trees impl' and 'give the container real git credentials too.' Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out mechanism, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision itself (done).
Author
Owner

sam wrote (originally 2026-09-28):

Update: commit 148a7645 builds the 'archie's own PRs' trigger in full.
StagePRReviewAndOpenPR (prreview_own_pr.go) runs the pr-review decision
phases (1-8) against the task's own worktree via a new localPRSource
(reads Diff/Snapshot straight from Trees, no forge fetch -- there is no
PR number yet to fetch one by), then opens the PR and posts advisory
findings, all from inside one Stage.Run body. Implement() now uses it in
place of the plain StageOpenPR. task check clean, tests added.

This resolved the first blocker directly: read task_execution.go and
confirmed CompilePinnedWorkflow returns the identical workflow.Workflow
type and runs through the identical workflow.Run either compilation
path, so splicing stagePROutput() as a separate Stage after StageOpenPR
would indeed have been dead code -- fixed by calling the output phase's
logic (factored into runPROutputPhase) from inside the open-PR stage's
own body instead.

Still genuinely open (not built this pass): watched-repositories and
operator triggers. Both need PRSource's real forge-backed implementation
(commit 697971bb) reaching the sandboxed archie-agent process, which
holds no forge credential. Concrete, unbuilt design for whoever picks
this up next:

  1. internal/infrastructure/egress/ (grants.go, credentials.go) already
    implements the maintainer's described 'org-configured, allowed-use
    policy' mechanism: GrantResolver.Grant(run, secrets)/RevokeGrant(run)
    scopes a credential per run, and the egress proxy's inject()
    transparently attaches a resolved secret to outbound requests the
    sandboxed container makes. Declare a forge-read CredentialCapability
    for the pr-review workflow (match existing CredentialCapability/
    CredentialBinding naming), grant it through this mechanism scoped to
    the pr-review task's run.
  2. internal/infrastructure/prsource's real Source currently uses
    worktree.Manager (git-shell CheckoutPR/Diff/Snapshot) for its Trees
    half -- that needs a local clone and a git-level credential the
    sandboxed container likely does not have even with a bare API token.
    Rebuild it against the forge's HTTP API instead: internal/forge/'s
    client (go-github v78 / gitea SDK) already exposes GetPullRequest;
    it needs two more narrow additions -- a PR-diff fetch (go-github:
    PullRequests.GetRaw with RawOptions{Type: Diff}; gitea SDK: check its
    equivalent) and a repo-archive-at-ref fetch (go-github:
    Repositories.GetArchiveLink; gitea SDK: GetArchive/DownloadArchive)
    plus tar.gz extraction into destDir with no .git present (no existing
    helper for this in the repo -- internal/infrastructure/storepkg/
    registry.go's archive/tar usage is for container images, not
    reusable as-is). This is real, untrivial work: budget it as its own
    pass, not a quick addition.
  3. Once (1)+(2) land: watched-repos needs a fresh config field (the old
    ReviewEnabled is gone, confirmed zero references) gating per-repo,
    wired to the existing task-cancellation mechanism on PR update.
    Operator trigger needs internal/gateway/review_tools.go's review_pr
    chat tool (currently self-omitting, nil reviewer) rebuilt to enqueue
    an async pr-review task via EnqueueChatTask instead of the deleted
    synchronous path, keeping its identity-scoped repo authorization.

Not re-litigating: pipeline shape, lens count, precision-dial semantics,
StepExecution fan-out mechanism, benchmark harness, afbk.3/.4/.5/.8's
Stage design, the removal decision, blocker 1's resolution (done).

_sam wrote (originally 2026-09-28):_ Update: commit 148a7645 builds the 'archie's own PRs' trigger in full. StagePRReviewAndOpenPR (prreview_own_pr.go) runs the pr-review decision phases (1-8) against the task's own worktree via a new localPRSource (reads Diff/Snapshot straight from Trees, no forge fetch -- there is no PR number yet to fetch one by), then opens the PR and posts advisory findings, all from inside one Stage.Run body. Implement() now uses it in place of the plain StageOpenPR. task check clean, tests added. This resolved the first blocker directly: read task_execution.go and confirmed CompilePinnedWorkflow returns the identical workflow.Workflow type and runs through the identical workflow.Run either compilation path, so splicing stagePROutput() as a separate Stage after StageOpenPR would indeed have been dead code -- fixed by calling the output phase's logic (factored into runPROutputPhase) from inside the open-PR stage's own body instead. Still genuinely open (not built this pass): watched-repositories and operator triggers. Both need PRSource's real forge-backed implementation (commit 697971bb) reaching the sandboxed archie-agent process, which holds no forge credential. Concrete, unbuilt design for whoever picks this up next: 1. internal/infrastructure/egress/ (grants.go, credentials.go) already implements the maintainer's described 'org-configured, allowed-use policy' mechanism: GrantResolver.Grant(run, secrets)/RevokeGrant(run) scopes a credential per run, and the egress proxy's inject() transparently attaches a resolved secret to outbound requests the sandboxed container makes. Declare a forge-read CredentialCapability for the pr-review workflow (match existing CredentialCapability/ CredentialBinding naming), grant it through this mechanism scoped to the pr-review task's run. 2. internal/infrastructure/prsource's real Source currently uses worktree.Manager (git-shell CheckoutPR/Diff/Snapshot) for its Trees half -- that needs a local clone and a git-level credential the sandboxed container likely does not have even with a bare API token. Rebuild it against the forge's HTTP API instead: internal/forge/'s client (go-github v78 / gitea SDK) already exposes GetPullRequest; it needs two more narrow additions -- a PR-diff fetch (go-github: PullRequests.GetRaw with RawOptions{Type: Diff}; gitea SDK: check its equivalent) and a repo-archive-at-ref fetch (go-github: Repositories.GetArchiveLink; gitea SDK: GetArchive/DownloadArchive) plus tar.gz extraction into destDir with no .git present (no existing helper for this in the repo -- internal/infrastructure/storepkg/ registry.go's archive/tar usage is for container images, not reusable as-is). This is real, untrivial work: budget it as its own pass, not a quick addition. 3. Once (1)+(2) land: watched-repos needs a fresh config field (the old ReviewEnabled is gone, confirmed zero references) gating per-repo, wired to the existing task-cancellation mechanism on PR update. Operator trigger needs internal/gateway/review_tools.go's review_pr chat tool (currently self-omitting, nil reviewer) rebuilt to enqueue an async pr-review task via EnqueueChatTask instead of the deleted synchronous path, keeping its identity-scoped repo authorization. Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out mechanism, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, blocker 1's resolution (done).
Author
Owner

sam wrote (originally 2026-09-28):

Continuation update: commit 7ddaed38 rebuilds PRSource fully over the forge's HTTP API (GetPullRequestDiff, GetRepoArchive on both GitHub and Gitea clients, plus a tested extractTarGz that strips the wrapper directory and drops .git). task check clean. Not wired into any trigger yet.

Correction to the previous pass's plan: investigated internal/infrastructure/egress/ (grants.go, credentials.go) via codegraph search before building against it, per the maintainer's standing feedback to investigate proactively. Its GrantResolver/CredentialCapability mechanism only wires into kitrun.Launcher (the Kit/harness launch path) -- zero references from internal/app/agentworker or internal/agentexec, which is what actually runs pr-review's Stage.Run bodies today. Routing PRSource's forge calls through it as previously planned is not viable without restructuring pr-review onto the harness-launch path, which is a bigger decision than this bead should make unilaterally.

Real open question for whoever picks this up (or the maintainer, if it needs a decision): where does PRSource actually get constructed and called from for the watched-repos and operator triggers? Two live options, neither built yet:
(a) Construct it daemon-side (archied already holds the forge token) and have the daemon run the pr-review workflow's Stage-driving Go code in-process -- TaskContext.Agent (the actual LLM calls) can still dispatch to the normal agent execution path regardless of which process runs the surrounding orchestration loop, so this does not require every agent call to also run daemon-side, only the Stage.Run bodies that touch PRSource directly (intake, anatomy). This mirrors how the now-deleted pr_review.go's prReviewer used to work, minus the synchronous single-reviewer design.
(b) A worktreerpc-style RPC proxy from the sandboxed archie-agent process back to archied for just these three calls, keeping 100% of pr-review's orchestration in the sandbox. Larger surface (a new RPC service, and Snapshot's payload is an entire repo tree, not a single small response -- needs either chunking or a shared-volume handoff, not a bare request/reply).

(a) is very likely the smaller, more consistent-with-existing-patterns change, but that's an assessment, not a decision already made -- flagging it as a real fork point rather than picking one silently.

Once that's settled: watched-repos still needs a fresh config field (old ReviewEnabled is gone) wired to task-cancellation-on-update; operator trigger still needs review_tools.go's review_pr rebuilt to enqueue via EnqueueChatTask.

Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, archie's-own-PRs (148a7645, done).

_sam wrote (originally 2026-09-28):_ Continuation update: commit 7ddaed38 rebuilds PRSource fully over the forge's HTTP API (GetPullRequestDiff, GetRepoArchive on both GitHub and Gitea clients, plus a tested extractTarGz that strips the wrapper directory and drops .git). task check clean. Not wired into any trigger yet. Correction to the previous pass's plan: investigated internal/infrastructure/egress/ (grants.go, credentials.go) via codegraph search before building against it, per the maintainer's standing feedback to investigate proactively. Its GrantResolver/CredentialCapability mechanism only wires into kitrun.Launcher (the Kit/harness launch path) -- zero references from internal/app/agentworker or internal/agentexec, which is what actually runs pr-review's Stage.Run bodies today. Routing PRSource's forge calls through it as previously planned is not viable without restructuring pr-review onto the harness-launch path, which is a bigger decision than this bead should make unilaterally. Real open question for whoever picks this up (or the maintainer, if it needs a decision): where does PRSource actually get constructed and called from for the watched-repos and operator triggers? Two live options, neither built yet: (a) Construct it daemon-side (archied already holds the forge token) and have the daemon run the pr-review workflow's Stage-driving Go code in-process -- TaskContext.Agent (the actual LLM calls) can still dispatch to the normal agent execution path regardless of which process runs the surrounding orchestration loop, so this does not require every agent call to also run daemon-side, only the Stage.Run bodies that touch PRSource directly (intake, anatomy). This mirrors how the now-deleted pr_review.go's prReviewer used to work, minus the synchronous single-reviewer design. (b) A worktreerpc-style RPC proxy from the sandboxed archie-agent process back to archied for just these three calls, keeping 100% of pr-review's orchestration in the sandbox. Larger surface (a new RPC service, and Snapshot's payload is an entire repo tree, not a single small response -- needs either chunking or a shared-volume handoff, not a bare request/reply). (a) is very likely the smaller, more consistent-with-existing-patterns change, but that's an assessment, not a decision already made -- flagging it as a real fork point rather than picking one silently. Once that's settled: watched-repos still needs a fresh config field (old ReviewEnabled is gone) wired to task-cancellation-on-update; operator trigger still needs review_tools.go's review_pr rebuilt to enqueue via EnqueueChatTask. Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, archie's-own-PRs (148a7645, done).
Author
Owner

sam wrote (originally 2026-09-28):

Continuation from 2142e446 (credential mechanism done): the daemon now prefetches a pull request's metadata/diff/snapshot over its own forge client and writes it under workDir/.archie-pr-review before the container starts (prefetchPRReview, daemon.go's acquireTaskContainer); the container reads it back with prsource.MountSource (runTask wires tc.PRSource for pr-review tasks). No forge credential ever enters the container -- confirmed against docs/development/agent.md's stated rule and internal/forgerpc's existing pattern for forge writes. task check clean.

Two trigger surfaces remain, both needing real new plumbing, not just wiring:

  1. Watched repositories: needs actual PR-event detection, which does not exist anywhere yet. internal/forge/webhook/receiver.go only handles IssuesEvent, PullRequestReviewEvent and PullRequestReviewCommentEvent -- no PullRequestEvent (opened/synchronize) handler. The poll loop (daemon.go's pollIssuesWithConfig/AssignedIssues/IssuesWithLabel) is issue-shaped too. This needs either a new webhook handler + a poll-side PR-diff cursor (mirroring how issue polling already dedups), a fresh config field (the old ReviewEnabled is gone, confirmed zero references) to gate it per repo, and the update-cancels-in-flight-run logic wired to whatever cancellation mechanism already exists for task updates.

  2. Operator trigger: internal/gateway/review_tools.go's review_pr tool still expects ChatPRReviewer.ReviewPR to run synchronously and return full findings -- that contract doesn't fit an async enqueued pr-review task at all (no findings exist yet when the tool returns). The natural replacement is StoreTaskCreator.CreateTask (the same machinery /spawn already uses), but chatTaskWriter.EnqueueChatTask(ctx, owner, repo, title, body, workflow, identity) has no parameter to carry the PR number through to Task.PRNumber, which stagePRIntake reads directly. Extending EnqueueChatTask's signature reaches into the store layer (postgres, possibly the staterpc wire contract) -- a real, non-trivial change, not a quick tool rewrite. Whoever picks this up should decide whether to extend EnqueueChatTask for a PRNumber, or find another already-existing channel to carry it (Task.Inputs exists but nothing currently promotes it into PRNumber at creation).

Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, the HTTP-based PRSource rebuild, archie's-own-PRs (148a7645, done), the credential mechanism (2142e446, done).

_sam wrote (originally 2026-09-28):_ Continuation from 2142e446 (credential mechanism done): the daemon now prefetches a pull request's metadata/diff/snapshot over its own forge client and writes it under workDir/.archie-pr-review before the container starts (prefetchPRReview, daemon.go's acquireTaskContainer); the container reads it back with prsource.MountSource (runTask wires tc.PRSource for pr-review tasks). No forge credential ever enters the container -- confirmed against docs/development/agent.md's stated rule and internal/forgerpc's existing pattern for forge writes. task check clean. Two trigger surfaces remain, both needing real new plumbing, not just wiring: 1. Watched repositories: needs actual PR-event detection, which does not exist anywhere yet. internal/forge/webhook/receiver.go only handles IssuesEvent, PullRequestReviewEvent and PullRequestReviewCommentEvent -- no PullRequestEvent (opened/synchronize) handler. The poll loop (daemon.go's pollIssuesWithConfig/AssignedIssues/IssuesWithLabel) is issue-shaped too. This needs either a new webhook handler + a poll-side PR-diff cursor (mirroring how issue polling already dedups), a fresh config field (the old ReviewEnabled is gone, confirmed zero references) to gate it per repo, and the update-cancels-in-flight-run logic wired to whatever cancellation mechanism already exists for task updates. 2. Operator trigger: internal/gateway/review_tools.go's review_pr tool still expects ChatPRReviewer.ReviewPR to run synchronously and return full findings -- that contract doesn't fit an async enqueued pr-review task at all (no findings exist yet when the tool returns). The natural replacement is StoreTaskCreator.CreateTask (the same machinery /spawn already uses), but chatTaskWriter.EnqueueChatTask(ctx, owner, repo, title, body, workflow, identity) has no parameter to carry the PR number through to Task.PRNumber, which stagePRIntake reads directly. Extending EnqueueChatTask's signature reaches into the store layer (postgres, possibly the staterpc wire contract) -- a real, non-trivial change, not a quick tool rewrite. Whoever picks this up should decide whether to extend EnqueueChatTask for a PRNumber, or find another already-existing channel to carry it (Task.Inputs exists but nothing currently promotes it into PRNumber at creation). Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, the HTTP-based PRSource rebuild, archie's-own-PRs (148a7645, done), the credential mechanism (2142e446, done).
Author
Owner

sam wrote (originally 2026-09-28):

Watched repositories and archie's own PRs are both done (commits 7fb1ccd2, 5264d5d8). Not closing -- the operator/chat trigger is genuinely still open.

Design correction from this pass: the generic capture+binding system (internal/infrastructure/captureintake, internal/domain/binding.Binding) already covers watched-repos with zero new webhook-parsing Go code -- an operator configures a Binding through the dashboard (matcher/CEL filter/Inputs mapping) targeting the pr-review workflow. The prior passes' plan to extend internal/forge/webhook/receiver.go with a bespoke pull_request event handler was superseded before being built.

Landed to make this work: Workflow gained an Interface field (task.WorkflowInterface) so a Go-literal builtin can declare inputs the way a YAML workflow does; PRReview() declares pr_number as required; ShippedDefinitions() emits the inputs: block only for workflows that declare one (every other builtin's generated YAML is unchanged). Task.EffectivePRNumber() resolves PRNumber directly (archie's own PRs) or falls back to Inputs["pr_number"] (a binding or future chat task assigned it generically) -- handles json.Number (the store's real round-trip encoding), float64 and int. The daemon resolves it once in acquireTaskContainer before the task brief is written and the pr-review prefetch runs. stagePRIntake falls back to the same resolution for any dispatch path that bypasses container acquisition, and only hard-fails on a still-missing number for the standalone pr-review workflow -- NOT when embedded in archie's own PRs (Task.Workflow == "implement"), which legitimately has no PR number yet. That distinction was a real bug caught and fixed within this pass (5264d5d8), not shipped -- the existing StagePRReviewAndOpenPR tests substitute a fake decision-stage list by design and would not have caught it; added a test that calls stagePRIntake directly with Workflow: "implement" and no PR number.

Operator/chat trigger: filed as archie-core-afbk.14 with the concrete plan (proto field + regen, a new narrow SQL query -- StampTaskBinding cannot be reused, it stamps fake binding provenance -- store/staterpc/gateway signature threading, ~20 call sites, then the review_pr tool rebuild). Real plumbing across the State Store's protobuf-generated wire contract, correctly scoped as its own pass.

Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, the HTTP-based PRSource rebuild, the credential/prefetch mechanism, archie's-own-PRs wiring, or the capture+binding design for watched-repos (all done).

_sam wrote (originally 2026-09-28):_ Watched repositories and archie's own PRs are both done (commits 7fb1ccd2, 5264d5d8). Not closing -- the operator/chat trigger is genuinely still open. Design correction from this pass: the generic capture+binding system (internal/infrastructure/captureintake, internal/domain/binding.Binding) already covers watched-repos with zero new webhook-parsing Go code -- an operator configures a Binding through the dashboard (matcher/CEL filter/Inputs mapping) targeting the pr-review workflow. The prior passes' plan to extend internal/forge/webhook/receiver.go with a bespoke pull_request event handler was superseded before being built. Landed to make this work: Workflow gained an Interface field (task.WorkflowInterface) so a Go-literal builtin can declare inputs the way a YAML workflow does; PRReview() declares pr_number as required; ShippedDefinitions() emits the inputs: block only for workflows that declare one (every other builtin's generated YAML is unchanged). Task.EffectivePRNumber() resolves PRNumber directly (archie's own PRs) or falls back to Inputs["pr_number"] (a binding or future chat task assigned it generically) -- handles json.Number (the store's real round-trip encoding), float64 and int. The daemon resolves it once in acquireTaskContainer before the task brief is written and the pr-review prefetch runs. stagePRIntake falls back to the same resolution for any dispatch path that bypasses container acquisition, and only hard-fails on a still-missing number for the standalone pr-review workflow -- NOT when embedded in archie's own PRs (Task.Workflow == "implement"), which legitimately has no PR number yet. That distinction was a real bug caught and fixed within this pass (5264d5d8), not shipped -- the existing StagePRReviewAndOpenPR tests substitute a fake decision-stage list by design and would not have caught it; added a test that calls stagePRIntake directly with Workflow: "implement" and no PR number. Operator/chat trigger: filed as archie-core-afbk.14 with the concrete plan (proto field + regen, a new narrow SQL query -- StampTaskBinding cannot be reused, it stamps fake binding provenance -- store/staterpc/gateway signature threading, ~20 call sites, then the review_pr tool rebuild). Real plumbing across the State Store's protobuf-generated wire contract, correctly scoped as its own pass. Not re-litigating: pipeline shape, lens count, precision-dial semantics, StepExecution fan-out, benchmark harness, afbk.3/.4/.5/.8's Stage design, the removal decision, the HTTP-based PRSource rebuild, the credential/prefetch mechanism, archie's-own-PRs wiring, or the capture+binding design for watched-repos (all done).
sam added a new dependency 2026-10-27 13:41:45 +00:00
sam added a new dependency 2026-10-27 13:41:45 +00:00
sam added a new dependency 2026-11-14 14:45:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#132