Repository navigation
Support reviewed repository workflows in Agents and Code - #1096
Conversation
Code now reads, once per login, the repository permission (admin, write, read or none) of each person who submits a CHANGES_REQUESTED review on the pull request head, and reports it as PullRequestReview.authorPermission. A coordinator such as Factory can act on a request for changes from someone who could push the change, and ignore anyone else's. A 403 or 404 from the permission lookup records "none". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each ready Repository publishes a webhook path (status.commandsWebhookPath) carrying an HMAC token over its workspace and name; a repository admin pastes the URL into GitHub for Issue comments events. A delivery records only the comment ID as a PullRequestCommand owned by the Repository. The PullRequestCommand reconciler re-reads the comment and its pull request from GitHub with the Repository's credential and records the verified command, author, author permission and pull request head, or a rejection reason. The repository detail page shows the setup steps and the URL behind a toggle. The chart takes an optional commandsWebhook.keySecretRef (CODE_WEBHOOK_KEY) to keep URLs stable across kubeconfig rotation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…quests Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@mjudeikis-bot review |
mjudeikis
left a comment
There was a problem hiding this comment.
Scope: this PR is about 15k lines across 190 files and the diff API refuses to serve it (over 20000 lines). I read the Code provider's command intake, review actions, backend review path and publication lease in full. I did not review the Agents store/API/portal changes, the runner changes or the Code portal change. Treat those as uncovered.
Not anchored: Agents provider. No Agents code was traced, including the repository-run transcript isolation, run actions and the Postgres store changes. Someone should review them separately.
Checked
- Read beyond the diff:
commandhook/{commandhook,handler}.go,controller/pullrequestcommand/controller.go,actions/{server,pullrequest_actions,review_operation}.go,backend/github/review.go,backend/github/collaboration.go(newIssueComment,RepositoryPermission,ObservePullRequestBase),backend/github/snapshot.goadvance(the--force-with-leasepush), the publication-lease section ofcontroller/pullrequest/controller.go, repository controller webhook-path wiring, chartvalues.yaml/deployment.yaml/README,provider-sdk/servewebhook class. - Correctness: the review/comment receipt state machines (Accepted/Complete/Release/ForgetMissing) are consistent. Release is fenced on
updatedAt, and a payload mismatch is rejected before any mutation. Finding 2 is the one gap. - Concurrency: receipts are claimed with resourceVersion CAS via
RetryOnConflict, so two replicas cannot both claim one key. The webhook create is idempotent through a deterministic object name. - Tenancy/kcp: the webhook cluster comes from the URL, which the HMAC binds to cluster+name, and the handler cross-checks the payload
repository.idagainststatus.repoID. The actions act throughAsProviderand pin repository/connection UIDs. Nothing found, apart from finding 1. - Provider contract: new verbs
submit-review,upsert-commentandreadyare inpullRequestActionsand inmanifest.yaml. The catalog parity test was updated (18 actions, 3 resources). No bearer on the verbs and no/api/*route. The webhook is mounted as class (g) viaExtra. - API/codegen: CRDs, kcp schemas and chart
files/were regenerated alongside the types, as far as I could see. I did not runmake verify-codegen. - Security: the payload is treated as a doorbell and everything is re-read from GitHub. Command arguments are pattern-restricted. The review path rejects non-open and merged PRs, forks and a head mismatch. Review notes are validated against the PR's real diff. See finding 1 for the URL-as-credential concern.
- Tests: the commandhook, receipt, review-action, catalog and subresource tests exist and pass. No test covers a status reader replaying a delivery or a full receipt history.
- Commands run:
cd providers/code && go build ./... && go vet ./... && go test -count=1 ./...passed for every package except the rootprovider-codepackage, which fails in the sandbox withassets.go: pattern all:portal/dist: no matching files foundbecause the portal was not built. I did not build the portal. - Not run:
make build,make lint,make verify-codegen,make verify-provider-contract,make verify-portalkit,make verify-boilerplate, the rootgo test ./pkg/..., the Agents module tests, and every e2e suite (too heavy for this run; the PR body reports a Tilt run).
|
|
||
| func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
| cluster, name := r.PathValue("cluster"), r.PathValue("name") | ||
| if !ValidToken(h.key, cluster, name, r.PathValue("token")) { |
There was a problem hiding this comment.
Warning: Unverified: the webhook URL is the only credential and it is published in Repository.status
The token is the sole check here. It is also written to status.commandsWebhookPath (controller/repository/controller.go:150) and rendered in the portal. I traced the code but could not confirm which workspace roles can read Repository status. If a read-only member can, they can POST forged issue_comment payloads with any comment.id. Each one creates a PullRequestCommand and costs a GitHub GET comments/{id} on the repository's credential, and a 404 deletes the object, so a loop gives unbounded create/delete churn and rate-limit burn. They can also replay a real writer's comment ID within the one-hour window. If the consumer cleans up a Verified command, that re-creates a fresh Verified command and the command runs again. GitHub's X-Hub-Signature-256 is not checked, so the URL cannot be rotated apart from the provider-wide key.
// store a per-Repository secret outside status (provider-owned Secret) and
// verify GitHub's signature before recording anything:
if !validSignature(secret, r.Header.Get("X-Hub-Signature-256"), body) {
http.NotFound(w, r)
return
}| var evicted bool | ||
| ops, evicted = evictCompletedOperation(ops) | ||
| if !evicted { | ||
| return errors.New("review operation history is full") |
There was a problem hiding this comment.
Note: Uncertain receipts are never evicted, so a PR can lock itself out of reviews
A transient error after the forge write was attempted leaves the key Accepted (classifyReviewWrite deliberately keeps it). The same happens if a replica dies mid-call. evictCompletedOperation only removes Complete entries, so after 64 such leftovers every new key on that PR fails with review operation history is full. The action layer reports this as review_operation_conflict (409), which looks like an idempotency clash rather than a full ledger. The comment ledger at line 132 has the same problem. Reconciling stale Accepted entries against the forge marker after a grace period, or at least returning a distinct error code, would avoid the dead end.
if !evicted {
return errors.New("review operation history is full of unconfirmed operations; resolve or recreate the pull request")
}| } | ||
|
|
||
| func (r *Reconciler) verify(ctx context.Context, c client.Client, command *codev1alpha1.PullRequestCommand) (ctrl.Result, error) { | ||
| if !command.DeletionTimestamp.IsZero() || command.Status.Phase == codev1alpha1.PullRequestCommandVerified || command.Status.Phase == codev1alpha1.PullRequestCommandRejected { |
There was a problem hiding this comment.
Note: Verified and Rejected commands are never reaped
Once a command reaches a terminal phase the reconciler returns early and nothing deletes it. The only cleanup is the owner reference to the Repository. Every /railgrid ... comment on a busy repository leaves a cluster-scoped object forever. That includes Rejected ones, which anyone who can comment can generate, such as a read-only user posting /railgrid x. A TTL (delete terminal commands some time after verifiedAt) would bound this.
if phase terminal && r.now().Sub(command.Status.VerifiedAt.Time) > retention {
return ctrl.Result{}, client.IgnoreNotFound(c.Delete(ctx, command))
}Runner: - Skip an unsafe, oversize or unreadable completion artifact with a path-free artifact event instead of failing a completed attempt and discarding its Git result. - Treat an exhausted aggregate artifact budget as a zero limit, not as "no limit". - Name the cleanup retry limit and probe retained process scopes at startup in parallel, each still bounded. Agents: - Keep the verified Git result when a structured result is invalid. - Refuse an attended chat turn whose caller identity cannot be reviewed (retryable 503, nothing stored), so a session is never created without its owner; cache resolved subjects for a minute. - Reuse runner cleanup observations on trace reads. - Fetch the Agent only when a parked inbox item is restored, and do not re-sweep an Agent's parked runs for 30s after a clean sweep. - Cap each session at its newest 500 notifications. - Use the trimmed session ID in every notification handler; validate revoke input in Postgres. - Answer a reuse found after an admission race like one found up front. Code: - Retry a rate-limited 403 on a permission lookup instead of recording "none". - Let a command pin the head commit it means; reject it when the head has moved and record status.headPinned for consumers. - Reject commands that cannot be verified within an hour. - Cache the webhook's Repository and Secret lookup and answer every unauthenticated delivery with the same 404. - Record a publication as Published when the moved branch still contains its candidate. - Share the GitHub App JWT code and cache the App slug. - Tell portal users the webhook Secret needs the railgrid.ai/owner: code label. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Remove the per-session notification feed and the session ownership that existed only to grant access to it: the deliver, notifications and session-access verbs, their request kinds and schemas, the notification store and its Postgres tables, and the portal panel. Nothing outside Factory posted to the feed, and Factory no longer does. Chat turns no longer resolve the caller's kcp identity unless attachments are involved, so an identity lookup failure no longer refuses a turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cwilhit The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Summary
Verification
The private Factory workflow that consumes these APIs is tracked in Providers PR #124.