fix(webui): drop the config schema's editability advert
No process writes configuration through the dashboard: the write
handlers, their UpdateConfig/ResetConfig/UpdateRepoField seams and
ConfigView.Editable were deleted with the runtime config overlay
(2311529d), and database-backed settings are written through the control
plane. That left producer-side residue behind:
- ConfigField.Editable and the descriptor literals setting it, which
emitted editable=true for fields no process can change, and which
ui/src/settings/types.ts's ConfigField deliberately omits from the
reader side of the wire shape
- ErrConfigUpdateUnavailable/ErrConfigUpdateInvalid, with neither a
producer nor a consumer since handleConfigUpdate was deleted
- comments pointing at handleConfigUpdate/UpdateConfig,
ConfigView.Editable, the overlay's overridden markers and a deleted
test name
The two Editable-only descriptor tests go with the field; the deleted
write path is what they pinned.
This commit is contained in:
1 parent
c6623d5300
commit
5e9d706c22
5 files changed
+78
-111
No files matched your search
@@ -32,8 +32,7 @@ func (s *Server) handleCapabilities(w http.ResponseWriter, _ *http.Request) {
|
||||
// and its definition list from the local registry, so it is
|
||||
// worth showing with only the former.
|
||||
"workflows": true,
|
||||
// Configuration renders from whichever source is wired; the
|
||||
// page reports its own editability (see ConfigView.Editable).
|
||||
// Configuration renders from whichever source is wired.
|
||||
"settings": true,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ package webui
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
@@ -15,21 +14,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
||||
)
|
||||
|
||||
// Sentinel errors for handleConfigUpdate status classification. The
|
||||
// composition root wraps its UpdateConfig errors with these so the
|
||||
// handler can answer 400 (invalid input) or 503 (unavailable) without
|
||||
// reaching into infrastructure internals.
|
||||
var (
|
||||
// ErrConfigUpdateUnavailable reports that config editing is not
|
||||
// wired (no UpdateConfig seam, or the overlay is skipped by the
|
||||
// recovery flag).
|
||||
ErrConfigUpdateUnavailable = errors.New("config editing unavailable")
|
||||
// ErrConfigUpdateInvalid reports a rejected update: a denylisted
|
||||
// key, a failed validation of the materialised config, or an
|
||||
// unparseable value.
|
||||
ErrConfigUpdateInvalid = errors.New("config update invalid")
|
||||
)
|
||||
|
||||
// ChannelView is one conversational front-end as shown on the dashboard's
|
||||
// Channels page: whether it is reachable today, and what configuring it
|
||||
// would unlock.
|
||||
@@ -168,12 +152,12 @@ type ConfigView struct {
|
||||
// deployment, whose forge is Identity above.
|
||||
Identities []ForgeIdentityView `json:"identities,omitempty"`
|
||||
// Schema is the field-descriptor catalog (archie-core-b6ew) attached to
|
||||
// this view's own values, locked reasons, and overridden markers -- see
|
||||
// config_schema.go. The dashboard's generic renderer (archie-core-b6ew.3)
|
||||
// reads this instead of the flat fields above to decide labels,
|
||||
// sections, types, and editability; the flat fields stay for existing
|
||||
// consumers (structured cards, provenance, reload/lock plumbing) rather
|
||||
// than being removed in the same change that adds their replacement.
|
||||
// this view's own values and locked reasons -- see config_schema.go. It
|
||||
// carries the labels, sections and types a generic configuration renderer
|
||||
// needs, instead of making each rendering process hardcode them; the flat
|
||||
// fields stay for existing consumers (structured cards, provenance,
|
||||
// reload/lock plumbing) rather than being removed in the same change that
|
||||
// adds their replacement.
|
||||
Schema []ConfigSection `json:"schema"`
|
||||
}
|
||||
|
||||
@@ -363,9 +347,6 @@ type CatalogProviderView struct {
|
||||
// It is deliberately a function, not a method: rendering the view is not a
|
||||
// property of an HTTP server, and the process that owns configuration is not
|
||||
// the process that serves this page (archie-core-ml30).
|
||||
//
|
||||
// Editable is not set here. It describes the rendering process's own write
|
||||
// path, so handleConfig decides it -- see ConfigView.Editable.
|
||||
func BuildConfigView(in ConfigViewInput) ConfigView {
|
||||
cfg := in.Config
|
||||
provenance := append([]ConfigOrigin(nil), in.Provenance...)
|
||||
|
||||
@@ -382,9 +382,6 @@ func TestHandleConfigIncludesSchemaWithLiveValues(t *testing.T) {
|
||||
if botUser.Value != got.Identity.BotUser {
|
||||
t.Errorf("Schema[bot_user].Value = %v, want %v (ConfigView.Identity.BotUser)", botUser.Value, got.Identity.BotUser)
|
||||
}
|
||||
if !botUser.Editable {
|
||||
t.Error("Schema[bot_user].Editable = false, want true")
|
||||
}
|
||||
|
||||
// A locked field's schema entry carries the reason the flat Locked map
|
||||
// carries, so the generic renderer does not need to cross-reference it.
|
||||
@@ -399,22 +396,54 @@ func TestHandleConfigIncludesSchemaWithLiveValues(t *testing.T) {
|
||||
t.Errorf("Schema[work_dir].LockedReason = %q, want %q (ConfigView.Locked[work_dir])", workDir.LockedReason, got.Locked["work_dir"])
|
||||
}
|
||||
|
||||
// Structured fields still carry their value (for the dedicated editors
|
||||
// archie-core-b6ew.4 adds) but are not marked editable by the generic
|
||||
// scalar renderer.
|
||||
// Structured fields still carry their value, for the dedicated editors
|
||||
// archie-core-b6ew.4 adds.
|
||||
repos, ok := fields["repos"]
|
||||
if !ok {
|
||||
t.Fatal(`Schema has no "repos" field`)
|
||||
}
|
||||
if repos.Editable {
|
||||
t.Error("Schema[repos].Editable = true, want false (structured fields need a dedicated editor)")
|
||||
}
|
||||
reposValue, ok := repos.Value.([]any)
|
||||
if !ok || len(reposValue) != 1 {
|
||||
t.Errorf("Schema[repos].Value = %#v, want the one configured repository", repos.Value)
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigSchemaCarriesNoEditabilityAdvert pins that the schema
|
||||
// response stops advertising a write capability no process has. Configuration
|
||||
// settings are written through the control plane, not the dashboard (see
|
||||
// docs/architecture/configuration.md, "Settings writes go through the
|
||||
// control plane"), and ui/src/settings/types.ts's ConfigField -- the
|
||||
// reader-side declaration of this wire shape -- carries every descriptor
|
||||
// property except an editability one. A descriptor that emits one offers the
|
||||
// dashboard an affordance nothing on the server can honour.
|
||||
func TestHandleConfigSchemaCarriesNoEditabilityAdvert(t *testing.T) {
|
||||
srv := newTestServer(t)
|
||||
localConfig(srv, configWithFakeSecrets())
|
||||
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil)
|
||||
w := httptest.NewRecorder()
|
||||
srv.Handler().ServeHTTP(w, req)
|
||||
|
||||
var wire struct {
|
||||
Schema []struct {
|
||||
Fields []map[string]any `json:"fields"`
|
||||
} `json:"schema"`
|
||||
}
|
||||
if err := json.Unmarshal(w.Body.Bytes(), &wire); err != nil {
|
||||
t.Fatalf("decode: %v", err)
|
||||
}
|
||||
if len(wire.Schema) == 0 {
|
||||
t.Fatal("schema is empty, want the field descriptor catalog")
|
||||
}
|
||||
for _, section := range wire.Schema {
|
||||
for _, field := range section.Fields {
|
||||
if editable, ok := field["editable"]; ok {
|
||||
t.Errorf("schema field %v carries editable=%v; nothing writes configuration through the dashboard, so the descriptor must not offer the affordance", field["key"], editable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestHandleConfigSchemaNeverLeaksSecrets extends the secret-leak guard to
|
||||
// the schema block specifically, so a future field added to
|
||||
// configFieldDescriptors without going through ConfigView's allowlist would
|
||||
@@ -502,9 +531,7 @@ func TestHandleChannelsUsesRuntimeManager(t *testing.T) {
|
||||
|
||||
// TestRemoteConfigViewRendersThePublishedSnapshot: the UI process has no
|
||||
// configuration of its own, so the page it serves is whatever the owner
|
||||
// published. Whether that page is editable is decided by the process that
|
||||
// renders it, not by the document -- see
|
||||
// TestConfigViewEditableFollowsThisProcessWritePath.
|
||||
// published.
|
||||
func TestRemoteConfigViewRendersThePublishedSnapshot(t *testing.T) {
|
||||
published := ConfigView{
|
||||
Identity: IdentityView{BotUser: "archie", ForgeType: "github"},
|
||||
|
||||
@@ -30,24 +30,17 @@ const (
|
||||
FieldStructured ConfigFieldType = "structured"
|
||||
)
|
||||
|
||||
// ConfigField is one field's rendering and editing contract: what it is,
|
||||
// what it means, and whether the dashboard may change it right now. Value
|
||||
// is attached by the caller building the schema against a live ConfigView
|
||||
// (archie-core-b6ew.2) -- the descriptor itself is data-independent.
|
||||
// ConfigField is one field's rendering contract: what it is, what it means,
|
||||
// and what changing it would require. Value is attached by the caller
|
||||
// building the schema against a live ConfigView (archie-core-b6ew.2) -- the
|
||||
// descriptor itself is data-independent.
|
||||
type ConfigField struct {
|
||||
// Key is the dotted path this field is addressed by, matching the key
|
||||
// space handleConfigUpdate/UpdateConfig already accepts.
|
||||
// Key is the dotted path this field is addressed by.
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Type ConfigFieldType `json:"type"`
|
||||
Value any `json:"value,omitempty"`
|
||||
// Editable is false for a field this page shows but the dashboard
|
||||
// cannot change yet (structured fields without an editor). It is
|
||||
// distinct from LockedReason: Editable is a schema-time property of
|
||||
// the field itself; LockedReason is a runtime property of the running
|
||||
// config (configuration.DeniedKeys).
|
||||
Editable bool `json:"editable"`
|
||||
// LockedReason is set per instance from the running config's denied
|
||||
// keys (configuration.DeniedKeys), not hand-authored here.
|
||||
LockedReason string `json:"locked_reason,omitempty"`
|
||||
@@ -76,16 +69,16 @@ type ConfigSection struct {
|
||||
// ConfigView exposes today, in the section grouping settings.js already
|
||||
// renders. Values and LockedReason are attached separately
|
||||
// against a live ConfigView (archie-core-b6ew.2); this list is the
|
||||
// data-independent half of the contract -- key, label, type, and the two
|
||||
// safety-relevant properties (editable, restart_required) that must be
|
||||
// decided deliberately rather than defaulted.
|
||||
// data-independent half of the contract -- key, label, type, and the
|
||||
// safety-relevant property (restart_required) that must be decided
|
||||
// deliberately rather than defaulted.
|
||||
//
|
||||
// RestartRequired is set from internal/app/archied/reload.go as of this
|
||||
// writing:
|
||||
// - reloadableFields lists BotUser, BotEmail, Label, DiffCapLines, Budgets,
|
||||
// Models -- all reloadable.
|
||||
// - reloadableSubFields["Forge"] allows only Host -- Forge.Type requires a
|
||||
// restart even though the dashboard already renders it as editable.
|
||||
// restart.
|
||||
// - Web is absent from both allowlists entirely, so it requires a restart.
|
||||
// - WorkDir and DatabaseURL are locked (configuration.DeniedKeys), not merely
|
||||
// restart-required -- the dashboard cannot change them at all.
|
||||
@@ -96,12 +89,12 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Identity",
|
||||
Description: "Who Archie is on the forge, and how it addresses commits and comments.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "bot_user", Label: "Bot account", Type: FieldString, Editable: true},
|
||||
{Key: "bot_email", Label: "Commit author email", Type: FieldString, Editable: true},
|
||||
{Key: "label", Label: "Pickup label", Type: FieldString, Editable: true},
|
||||
{Key: "forge.type", Label: "Forge type", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "forge.host", Label: "Forge host", Type: FieldString, Editable: true},
|
||||
{Key: "diff_cap_lines", Label: "Max diff size (lines)", Description: "0 switches the cap off; leave unset for the default.", Type: FieldInt, Editable: true},
|
||||
{Key: "bot_user", Label: "Bot account", Type: FieldString},
|
||||
{Key: "bot_email", Label: "Commit author email", Type: FieldString},
|
||||
{Key: "label", Label: "Pickup label", Type: FieldString},
|
||||
{Key: "forge.type", Label: "Forge type", Type: FieldString, RestartRequired: true},
|
||||
{Key: "forge.host", Label: "Forge host", Type: FieldString},
|
||||
{Key: "diff_cap_lines", Label: "Max diff size (lines)", Description: "0 switches the cap off; leave unset for the default.", Type: FieldInt},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -114,7 +107,6 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Repositories",
|
||||
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
||||
Type: FieldStructured,
|
||||
Editable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -123,8 +115,8 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Models & providers",
|
||||
Description: "Which model handles each stage of work. Only the environment variable NAME is shown, never its value.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "models", Label: "Model roles", Type: FieldStructured, Editable: false},
|
||||
{Key: "providers", Label: "Providers", Type: FieldStructured, Editable: false},
|
||||
{Key: "models", Label: "Model roles", Type: FieldStructured},
|
||||
{Key: "providers", Label: "Providers", Type: FieldStructured},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -132,9 +124,9 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Budgets",
|
||||
Description: "The limits every autonomous stage runs under, so a stuck task cannot run forever.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "budgets.max_steps", Label: "Max steps", Description: "0 means unlimited.", Type: FieldInt, Editable: true},
|
||||
{Key: "budgets.wall_clock", Label: "Wall clock", Type: FieldDuration, Editable: true},
|
||||
{Key: "budgets.gate_max_failures", Label: "Max gate failures before parking", Description: "0 means unlimited.", Type: FieldInt, Editable: true},
|
||||
{Key: "budgets.max_steps", Label: "Max steps", Description: "0 means unlimited.", Type: FieldInt},
|
||||
{Key: "budgets.wall_clock", Label: "Wall clock", Type: FieldDuration},
|
||||
{Key: "budgets.gate_max_failures", Label: "Max gate failures before parking", Description: "0 means unlimited.", Type: FieldInt},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -142,9 +134,9 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Storage",
|
||||
Description: "Where archied keeps its state.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "work_dir", Label: "Work directory", Type: FieldString, Editable: false},
|
||||
{Key: "state_dir", Label: "State directory", Description: "Embedded NATS store, task logs and the readiness disk probe.", Type: FieldString, Editable: false},
|
||||
{Key: "database_url", Label: "PostgreSQL URL", Description: "The State Store's database connection; set at boot, restart required.", Type: FieldString, Editable: false},
|
||||
{Key: "work_dir", Label: "Work directory", Type: FieldString},
|
||||
{Key: "state_dir", Label: "State directory", Description: "Embedded NATS store, task logs and the readiness disk probe.", Type: FieldString},
|
||||
{Key: "database_url", Label: "PostgreSQL URL", Description: "The State Store's database connection; set at boot, restart required.", Type: FieldString},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -152,7 +144,7 @@ func configFieldDescriptors() []ConfigSection {
|
||||
Label: "Dashboard",
|
||||
Description: "This dashboard's listen address.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "web.listen", Label: "Listen address", Description: `"off" disables the dashboard.`, Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "web.listen", Label: "Listen address", Description: `"off" disables the dashboard.`, Type: FieldString, RestartRequired: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -185,8 +177,8 @@ func configFieldValues(view ConfigView) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
// buildConfigSchema attaches a live ConfigView's values, locked reasons, and
|
||||
// overridden markers to the static descriptor catalog, producing the
|
||||
// buildConfigSchema attaches a live ConfigView's values and locked reasons to
|
||||
// the static descriptor catalog, producing the
|
||||
// sections handleConfig returns to the dashboard. The catalog
|
||||
// (configFieldDescriptors) and the per-request state (configFieldValues,
|
||||
// view.Locked) are kept as two separate functions deliberately: one is
|
||||
|
||||
@@ -4,12 +4,12 @@ import "testing"
|
||||
|
||||
// TestConfigFieldDescriptorsAreComplete guards the deliberateness the design
|
||||
// doc asks for (docs/prds/config-schema.md): every field must carry a key,
|
||||
// label, and type, and every field's Editable/RestartRequired must have been
|
||||
// set by a case in configFieldDescriptors rather than defaulted to Go's
|
||||
// zero value. Since Go cannot distinguish "explicitly false" from
|
||||
// "unset," this test instead pins the exact set of keys and their
|
||||
// deliberate values, so a new field added to the catalog without visiting
|
||||
// this test fails loudly rather than silently inheriting Editable: false.
|
||||
// label, and type, and every field's RestartRequired must have been set by a
|
||||
// case in configFieldDescriptors rather than defaulted to Go's zero value.
|
||||
// Since Go cannot distinguish "explicitly false" from "unset," this test
|
||||
// instead pins the exact set of keys and their deliberate values, so a new
|
||||
// field added to the catalog without visiting this test fails loudly rather
|
||||
// than silently inheriting a zero value.
|
||||
func TestConfigFieldDescriptorsAreComplete(t *testing.T) {
|
||||
seen := map[string]bool{}
|
||||
for _, section := range configFieldDescriptors() {
|
||||
@@ -110,35 +110,3 @@ func TestConfigFieldDescriptorsRestartRequiredIsDeliberate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestConfigFieldDescriptorsStructuredFieldsAreNotEditable pins the design
|
||||
// decision that structured fields (repositories, models, providers) stay
|
||||
// read-only until archie-core-b6ew.4 gives them a dedicated editor -- the
|
||||
// generic scalar renderer (archie-core-b6ew.3) must skip them, not attempt
|
||||
// a text-input edit on a field whose Value is an array or map.
|
||||
func TestConfigFieldDescriptorsStructuredFieldsAreNotEditable(t *testing.T) {
|
||||
for _, section := range configFieldDescriptors() {
|
||||
for _, f := range section.Fields {
|
||||
if f.Type == FieldStructured && f.Editable {
|
||||
t.Errorf("field %q is type structured but marked editable; structured fields need archie-core-b6ew.4's dedicated editor first", f.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestConfigFieldDescriptorsLockedStorageFieldsAreNotEditable pins
|
||||
// work_dir/database_url as Editable: false in the static catalog. They are also
|
||||
// reported LockedReason at runtime via overlay.DeniedKeys (api_config.go),
|
||||
// but the catalog marks them non-editable independently so the generic
|
||||
// renderer does not need runtime state to know not to offer an edit
|
||||
// affordance for a key that can never succeed.
|
||||
func TestConfigFieldDescriptorsLockedStorageFieldsAreNotEditable(t *testing.T) {
|
||||
locked := map[string]bool{"work_dir": true, "state_dir": true, "database_url": true}
|
||||
for _, section := range configFieldDescriptors() {
|
||||
for _, f := range section.Fields {
|
||||
if locked[f.Key] && f.Editable {
|
||||
t.Errorf("field %q is denied at runtime (overlay.DeniedKeys) but marked editable in the static catalog", f.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user