feat(workflow): configure review precision and approval on the review.pr step

This commit is contained in:
sam committed 2026-10-17 17:00:55 +11:00
1 parent a973bd6567
commit 7e940acad4
19 files changed
+107 -267

No files matched your search

-1
View File
@@ -273,7 +273,6 @@ var runtimeResourceKinds = []string{
controlplane.SchedulingPolicyKind,
controlplane.ToolSettingsKind,
controlplane.PluginSettingsKind,
controlplane.ReviewSettingsKind,
controlplane.ChannelSettingsKind,
controlplane.ContainerRuntimePoliciesKind,
controlplane.CredentialBindingsKind,
+1 -1
View File
@@ -8,7 +8,7 @@ import (
// Schemas are not declared here: each Definition names its document type, and
// Definition.Descriptor derives the JSON Schema from it (internal/app/controlplane/schema.go).
func builtinDefinitions(steps workflow.StepRegistry, settings map[string]any) []Definition {
definitions := []Definition{taskPolicyDefinition(), workflowDefinition(), workflowDefinitionsDefinition(steps, settings), workflowEnablementDefinition(), curatorDefinition(), soulDefinition(), scheduleDefinition(), agentProfileDefinition(), playbooksDefinition(), skillsDefinition(), credentialBindingsDefinition(), identityGrantsDefinition(), reviewSettingsDefinition(), orgModelPolicyDefinition(), forgeConnectionsDefinition()}
definitions := []Definition{taskPolicyDefinition(), workflowDefinition(), workflowDefinitionsDefinition(steps, settings), workflowEnablementDefinition(), curatorDefinition(), soulDefinition(), scheduleDefinition(), agentProfileDefinition(), playbooksDefinition(), skillsDefinition(), credentialBindingsDefinition(), identityGrantsDefinition(), orgModelPolicyDefinition(), forgeConnectionsDefinition()}
definitions = append(definitions, modelDefinitions()...)
definitions = append(definitions, operationalDefinitions()...)
return definitions
+1 -1
View File
@@ -156,7 +156,7 @@ func (s *Server) readResource(ctx context.Context, orgID, kind string, into any)
// copy alone. Another org's write would be stored and never applied.
var instanceOnlyKinds = map[string]bool{
ChannelSettingsKind: true, SchedulingPolicyKind: true,
ReviewSettingsKind: true, TaskPolicyKind: true, ToolSettingsKind: true,
TaskPolicyKind: true, ToolSettingsKind: true,
PluginSettingsKind: true, ContainerRuntimePoliciesKind: true, AgentProfileKind: true,
ExtensionSettingsKind: true, UpdateSettingsKind: true, WorkflowExecutionSettingsKind: true,
}
@@ -1,34 +0,0 @@
package controlplane
import (
"github.com/samcharles93/archie-core/internal/config"
)
// ReviewSettingsKind is the control-plane resource holding the pr-review
// workflow's two dials: whether a post-worthiness pass runs before findings are
// posted, and whether a human approves the draft before it posts. The file's
// [review] section seeds it; the stored document outranks the file from then on
const ReviewSettingsKind = "review-settings"
type reviewSettings struct {
PrecisionGate bool `json:"precision_gate" title:"Precision gate" doc:"Run a post-worthiness pass before findings are posted."`
ApproveBeforePost bool `json:"approve_before_post" title:"Approve before posting" doc:"Park a finished review for operator approval before it posts."`
}
func reviewSettingsDefinition() Definition {
return Definition{
Kind: ReviewSettingsKind,
Title: "Review settings",
ApplyMode: "live",
Document: reviewSettings{},
Seed: func(cfg config.Config) any {
return reviewSettings{PrecisionGate: cfg.Review.PrecisionGate, ApproveBeforePost: cfg.Review.ApproveBeforePost}
},
Validate: validateReviewSettings,
}
}
// validateReviewSettings accepts every value.
func validateReviewSettings(input []byte) error {
return validateAs(input, func(reviewSettings) error { return nil })
}
@@ -124,17 +124,6 @@ func runtimeConfigFrom(ctx context.Context, reader controlplanerpc.ResourceReade
}); err != nil {
return config.Config{}, nil, err
}
// review-settings owns the pr-review dials once the store carries a value.
// The two fields are assigned individually, not `out.Review = ...`: a field
// added to config.Review later keeps the file's value until the stored
// document carries it.
if err := layerResource(ctx, reader, versions, ReviewSettingsKind, func(settings reviewSettings) error {
out.Review.PrecisionGate = settings.PrecisionGate
out.Review.ApproveBeforePost = settings.ApproveBeforePost
return nil
}); err != nil {
return config.Config{}, nil, err
}
return runtimeToolConfigFrom(ctx, reader, versions, out)
}
-2
View File
@@ -99,8 +99,6 @@ func Run(ctx context.Context, opts Options, w io.Writer) (bench.Summary, error)
}
// The pipeline resolves its model through the default alias.
cfg.Models = map[string]string{config.DefaultModelAlias: reviewRef}
cfg.Review.ApproveBeforePost = false
cfg.Review.PrecisionGate = false
reviewer := &liveReviewer{cfg: cfg, agent: modelloop.NewLoopRunner(rt, slog.Default()), source: prsource.New(newPublicGitHub())}
judge := &modelJudge{runtime: rt, modelRef: judgeRef}
-18
View File
@@ -244,20 +244,6 @@ type Forge struct {
WebhookAddr string `toml:"webhook_addr" yaml:"webhook_addr"`
}
// Review configures the pr-review workflow.
// Both fields are off by default: the pipeline is recall-first, and posts
// automatically, unless an operator opts into either dial.
type Review struct {
// It trades recall for precision and cuts verification cost by filtering
// early.
PrecisionGate bool `toml:"precision_gate" yaml:"precision_gate"`
// ApproveBeforePost ends the pipeline in waiting_human right after
// synthesis, before the merge gate runs, so an operator can choose which
// findings to post, reject the review, or ask for a re-review with
// instructions. A review with no findings never waits.
ApproveBeforePost bool `toml:"approve_before_post" yaml:"approve_before_post"`
}
// Dispatch configures how archied discovers work and reacts on pickup.
type Dispatch struct {
// Trigger is how tasks are discovered: "assignee" (poll assigned
@@ -401,7 +387,6 @@ type Config struct {
Forge Forge `toml:"forge" yaml:"forge"`
Dispatch Dispatch `toml:"dispatch" yaml:"dispatch"`
Review Review `toml:"review" yaml:"review"`
// Models maps a model alias ("default", "fast", "embedding") to a
// runtime model ref ("provider/model"). Resolve it with ResolveModel.
@@ -489,7 +474,6 @@ type TaskConfig struct {
DiffCapLines int `json:"diff_cap_lines"`
Forge TaskForge `json:"forge"`
ToolPolicy ToolPolicy `json:"tool_policy"`
Review Review `json:"review"`
}
// DiffCap returns the changed-line cap; 0 means no cap.
@@ -519,7 +503,6 @@ func (c Config) ForTask() TaskConfig {
DiffCapLines: c.DiffCap(),
Forge: TaskForge{Host: c.Forge.Host},
ToolPolicy: c.Tools.Policy,
Review: c.Review,
}
}
@@ -555,7 +538,6 @@ func (tc TaskConfig) ToConfig() Config {
DiffCapLines: &tc.DiffCapLines,
Forge: Forge{Host: tc.Forge.Host},
Tools: ToolsConfig{Policy: tc.ToolPolicy},
Review: tc.Review,
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ func Processes() []string { return []string{Daemon, Gateway, Messaging} }
// Applicability names the consumers of each resource, including boot-only settings.
func Applicability() map[string][]string {
kinds := map[string][]string{}
for _, kind := range []string{"task-policy", "provider-settings", "model-aliases", "repository-policies", "scheduling-policy", "tool-settings", "plugin-settings", "review-settings", "channel-settings", "container-runtime-policies", "credential-bindings", "identity-grants", "agent-profiles", "workflow-execution-settings", "extension-settings", "workflow-definitions", "workflow-enablement", "schedules", "eda-playbooks", "forge-connections"} {
for _, kind := range []string{"task-policy", "provider-settings", "model-aliases", "repository-policies", "scheduling-policy", "tool-settings", "plugin-settings", "channel-settings", "container-runtime-policies", "credential-bindings", "identity-grants", "agent-profiles", "workflow-execution-settings", "extension-settings", "workflow-definitions", "workflow-enablement", "schedules", "eda-playbooks", "forge-connections"} {
kinds[kind] = []string{Daemon}
}
for _, kind := range []string{"provider-settings", "model-aliases", "tool-settings", "extension-settings", "soul", "skills", "curators"} {
@@ -8,18 +8,13 @@ import (
"github.com/samcharles93/archie-core/internal/domain/workflow/prreview"
)
// The caller supplies a fresh context with operator approval disabled.
type PRReviewDecision struct {
Comments []prreview.ScoredFinding
SkippedPhases []string
}
// ReviewPullRequest refuses operator approval outright, so the gate is left
// out of the stage list rather than reached and skipped.
// ReviewPullRequest runs the decision stages, which have no operator gate.
func ReviewPullRequest(ctx context.Context, tc *TaskContext) (PRReviewDecision, error) {
if tc.Cfg.Review.ApproveBeforePost {
return PRReviewDecision{}, fmt.Errorf("headless review cannot wait for operator approval")
}
ctx, cancel := context.WithTimeout(ctx, prReviewTotalBudget.WallClock)
defer cancel()
defer func() {
+6 -6
View File
@@ -124,25 +124,25 @@ const prReviewConcurrency = 8
// prReviewDecisionStages are the review stages without the operator gate, so
// the implement workflow can run them before opening its PR.
func prReviewDecisionStages() []Stage {
return append(prReviewPipelineStages(), stagePRMergeGate())
return append(prReviewPipelineStages(false), stagePRMergeGate())
}
func prReviewStandaloneStages() []Stage {
pipeline := prReviewPipelineStages()
func prReviewStandaloneStages(s reviewPRSettings) []Stage {
pipeline := prReviewPipelineStages(s.PrecisionGate)
stages := make([]Stage, 0, len(pipeline)+3)
stages = append(stages, pipeline...)
return append(stages, stagePROperatorApproval(), stagePRMergeGate(), stagePROutput())
return append(stages, stagePROperatorApproval(s.ApproveBeforePost), stagePRMergeGate(), stagePROutput())
}
// prReviewPipelineStages is phases 1 through 7: intake through synthesis, the
// stages every pr-review trigger shares.
func prReviewPipelineStages() []Stage {
func prReviewPipelineStages(precisionGate bool) []Stage {
return []Stage{
stagePRIntake(),
stagePRAnatomy(),
stagePRLenses(),
stagePRReview(),
stagePRPrecisionGate(),
stagePRPrecisionGate(precisionGate),
stagePRVerification(),
stagePRCoverageConsistency(),
stagePRSynthesis(),
@@ -39,12 +39,12 @@ func stagePRVerification() Stage {
}}
}
// stagePRPrecisionGate, when review.precision_gate is set, drops nitpicks,
// stagePRPrecisionGate, when enabled, drops nitpicks,
// style and unverifiable claims between review and verification, keeping a
// finding when unsure. Off by default.
func stagePRPrecisionGate() Stage {
func stagePRPrecisionGate(enabled bool) Stage {
return Stage{Name: "precision-gate", Run: func(ctx context.Context, tc *TaskContext) error {
if !tc.Cfg.Review.PrecisionGate || len(tc.prReview.findings) == 0 {
if !enabled || len(tc.prReview.findings) == 0 {
return nil
}
if budgetExhausted(tc, "precision-gate") {
@@ -130,12 +130,12 @@ func runPrecisionGate(ctx context.Context, tc *TaskContext, findings []prreview.
return kept
}
// stagePROperatorApproval, when review.approve_before_post is set, waits for
// stagePROperatorApproval, when enabled, waits for
// operator approval after synthesis and before the merge gate. A review with no
// findings never waits. Setting tc.Outcome ends the run at this stage.
func stagePROperatorApproval() Stage {
func stagePROperatorApproval(enabled bool) Stage {
return Stage{Name: "operator-approval", Run: func(_ context.Context, tc *TaskContext) error {
if !tc.Cfg.Review.ApproveBeforePost || len(tc.prReview.scored) == 0 {
if !enabled || len(tc.prReview.scored) == 0 {
return nil
}
if tc.prReview.approvedReview != nil {
+11 -3
View File
@@ -19,21 +19,29 @@ const (
// ReviewStepTypes contributes the review step types.
func ReviewStepTypes() []StepType {
return []StepType{
{Name: ReviewPRStepName, Factory: newReviewPRStage},
{Name: ReviewPRStepName, Factory: newReviewPRStage, Settings: reviewPRSettings{}},
{Name: ReviewRoundStepName, Factory: newReviewRoundStage},
{Name: ReviewReplyStepName, Factory: newReviewReplyStage, Settings: reviewReplySettings{}},
}
}
// reviewPRSettings are off by default: the pipeline is recall-first and
// posts automatically unless the workflow opts into either.
type reviewPRSettings struct {
PrecisionGate bool `yaml:"precision_gate" doc:"Drop findings not worth posting before verification."`
ApproveBeforePost bool `yaml:"approve_before_post" doc:"Wait for operator approval before posting findings."`
}
// newReviewPRStage runs the whole review pipeline on the task's pull request:
// intake, anatomy, lenses, review, precision gate, verification, coverage,
// synthesis, operator approval, merge gate and output. Its phases share
// private state, so they run as one step.
func newReviewPRStage(settings yaml.Node) (Stage, error) {
if err := noSettings(ReviewPRStepName, settings); err != nil {
s, err := decodeSettings[reviewPRSettings](ReviewPRStepName, settings)
if err != nil {
return Stage{}, err
}
phases := prReviewStandaloneStages()
phases := prReviewStandaloneStages(s)
return Stage{Name: ReviewPRStepName, Run: func(ctx context.Context, tc *TaskContext) error {
for _, phase := range phases {
if err := phase.Run(ctx, tc); err != nil {
-1
View File
@@ -51,7 +51,6 @@ var dashboardPages = []DashboardPage{
{Path: "/settings/models", Label: "Models", Description: "Instance model aliases and providers."},
{Path: "/org/repositories", Label: "Repositories", Description: "Watched repositories and gate overrides."},
{Path: "/settings/scheduling-policy", Label: "Scheduling policy", Description: "Work discovery and forge labels."},
{Path: "/settings/review", Label: "Review", Description: "Pull request review: precision filter and approval."},
{Path: "/settings/tools", Label: "Tools & MCP", Description: "Agent tools and MCP servers."},
{Path: "/settings/history", Label: "History", Description: "Settings changes: who, when, previous value."},
{Path: "/settings/plugins", Label: "Plugins", Description: "Extension directories loaded at startup."},
+2 -13
View File
@@ -110,12 +110,11 @@ func channelStateDetail(state status.State, configured bool) string {
}
// ConfigView is the daemon's secret-free snapshot for dashboard handlers.
// Only catalog, review and reload are exposed by /api/config.
// Only catalog and reload are exposed by /api/config.
type ConfigView struct {
SecretEngines []secret.EngineInfo `json:"secret_engines"`
Identity IdentityView `json:"identity"`
Repositories []ForgeRepoView `json:"repositories"`
Review ReviewView `json:"review"`
Chat ChatView `json:"chat"`
Catalog []CatalogProviderView `json:"catalog"`
Reload *config.ReloadStatus `json:"reload,omitempty"`
@@ -144,14 +143,6 @@ type ForgeIdentityView struct {
Repos []ForgeRepoView `json:"repos,omitempty"`
}
// ReviewView mirrors config.Review, neither field of which is secret. It
// carries the value in force after the review-settings resource is layered over
// the file's [review] section.
type ReviewView struct {
PrecisionGate bool `json:"precision_gate"`
ApproveBeforePost bool `json:"approve_before_post"`
}
// ChatView carries the chat page's own settings and the facts the setup
// checklist needs. Secret-free by construction: whether a channel has
// credentials, never the credentials.
@@ -197,10 +188,9 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) {
}
writeJSON(w, struct {
Catalog []CatalogProviderView `json:"catalog"`
Review ReviewView `json:"review"`
Reload *config.ReloadStatus `json:"reload,omitempty"`
Bootstrap map[string]string `json:"bootstrap"`
}{Catalog: view.Catalog, Review: view.Review, Reload: view.Reload, Bootstrap: maps.Clone(configuration.DeniedKeys)})
}{Catalog: view.Catalog, Reload: view.Reload, Bootstrap: maps.Clone(configuration.DeniedKeys)})
}
// ConfigViewInput is everything BuildConfigView needs. The configuration
@@ -238,7 +228,6 @@ func BuildConfigView(in ConfigViewInput) ConfigView {
Repositories: reposView(cfg.Repos),
MultiIdentity: len(cfg.Identities) > 0,
Identities: identityForgesView(cfg.Identities),
Review: ReviewView{PrecisionGate: cfg.Review.PrecisionGate, ApproveBeforePost: cfg.Review.ApproveBeforePost},
Catalog: append([]CatalogProviderView{}, in.Catalog...),
Chat: ChatView{ShowToolCalls: cfg.Chat.ShowToolCalls, Operator: strings.TrimSpace(cfg.Chat.Operator), ChannelConfigured: chatChannelConfigured(cfg.Chat)},
Reload: in.Reload,