feat(workflow): watched-repos triggers pr-review via the generic binding system
Watched-repos needs no bespoke webhook-parsing code: the existing generic capture+binding system (internal/infrastructure/captureintake, internal/domain/binding.Binding) already turns any inbound webhook into a task on any workflow, via a dashboard-editable matcher, CEL filter and payload-to-input mapping. pr-review just needed to become a binding-targetable workflow. - Workflow gains an Interface field (task.WorkflowInterface) so a Go-literal builtin can declare inputs the same way a YAML-defined one does; ShippedDefinitions emits an inputs: block only when non-empty, so every other builtin's generated YAML is byte-identical to before. - PRReview() declares pr_number as a required number input. - Task gains EffectivePRNumber(): PRNumber when a producer set it directly (archie's own PRs), else the pr_number input a binding assigned generically through Task.Inputs. Handles json.Number (the store's round-trip encoding), float64 and int. - The daemon resolves it once in acquireTaskContainer, before the task brief is written and before the pr-review prefetch runs, so everything downstream agrees. stagePRIntake falls back to the same resolution for any dispatch path that bypasses container acquisition, and fails loudly if neither PRNumber nor the input is set. An operator wires up watched-repos entirely through the dashboard: a Binding matching the webhook's source, a CEL filter for pull_request events, workflow: pr-review, and an Inputs mapping pr_number from the payload. No code change needed for a new repo or a new source. Operator/chat trigger remains open, left as a precise continuation: EnqueueChatTask is part of the State Store's protobuf-generated gRPC contract (proto/state/v1/state.proto), not just a Go interface -- extending it for a generic inputs parameter needs a proto field addition + regen, a new SQL query (StampTaskBinding cannot be reused, since it unconditionally stamps binding_id/version, which a plain chat task must never carry), and updates across staterpc's client/server and ~20 call sites. Real plumbing, not a quick tool rewrite -- scoped correctly as its own pass rather than rushed here.
This commit is contained in:
8 files changed
+176
-1
No files matched your search
@@ -1522,6 +1522,16 @@ func (d *Daemon) acquireTaskContainer(
|
||||
d.parkRunningTask(ctx, task.ID, reason+": "+err.Error(), taskstate.ParkTransient)
|
||||
}
|
||||
|
||||
// A watched-repositories binding or the operator chat trigger assigns
|
||||
// the pull request generically through Task.Inputs (its declared
|
||||
// pr_number input); archie's own PRs sets PRNumber directly and never
|
||||
// goes through either path. Resolving here, before the brief is
|
||||
// written, means task.json and the prefetch below always agree with
|
||||
// what every later reader (stagePRIntake, output posting) sees.
|
||||
if task.Workflow == "pr-review" {
|
||||
task.PRNumber = task.EffectivePRNumber()
|
||||
}
|
||||
|
||||
if err := writeTaskBrief(workDir, task); err != nil {
|
||||
park("task.json write failed", err)
|
||||
return nil, nil, false
|
||||
|
||||
Reference in new issue
Block a user