Files
archie/internal/app/controlplane/review_settings.go
T
sam 3a65fd2ee1 feat(controlplane): add the writable review-settings resource
review.precision_gate and review.approve_before_post were file-only, so the
dashboard had no way to write them: no control-plane resource carried them.
Add the review-settings kind (docs/prds/review-settings-resource.md), seed it
from the file's [review] section, layer it field-by-field into cfg.Review,
watch it live, and publish it through ConfigView.Review. The dashboard gets a
Review settings page bound to the kind through PAGE_RESOURCES, showing each
dial beside the value in force.
2026-10-02 11:08:44 +10:00

40 lines
1.6 KiB
Go

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
// (docs/prds/review-settings-resource.md).
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, deliberately: both dials are free
// booleans with no cross-field rule, and a stored value reaches its consumers
// through the same layered cfg.Review boot validates. It stays a real function
// rather than an inline no-op so a rule, if one is ever settled, has one
// obvious home (validatePluginSettings is the precedent).
func validateReviewSettings(input []byte) error {
return validateAs(input, func(reviewSettings) error { return nil })
}