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
(295f8d69), 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.
199 lines
8.9 KiB
Go
199 lines
8.9 KiB
Go
package webui
|
|
|
|
// Configuration schema contract (archie-core-b6ew.1): descriptor types and
|
|
// hand-authored field/section metadata for the Configuration page.
|
|
//
|
|
// This is deliberately NOT a reflection-based schema over config.Config.
|
|
// internal/config/config.go's own package doc marks it "scheduled for
|
|
// dissolution: its types and methods are to be reassigned to the domains
|
|
// whose behaviour they describe" -- a generic schema-from-struct-tags
|
|
// mechanism would be built on a foundation this repo has already decided to
|
|
// remove. Every field below is already a deliberate ConfigView allowlist
|
|
// entry (see api_config.go's own comment on why that allowlist exists); this
|
|
// attaches a label to a value that was already vetted as safe to show,
|
|
// rather than inventing a new safety boundary.
|
|
//
|
|
// See docs/prds/config-schema.md for the full design.
|
|
|
|
// ConfigFieldType is how the frontend's generic renderer decides what
|
|
// control to show for a field. FieldStructured fields (repositories,
|
|
// models, providers) opt out of the generic renderer entirely and keep
|
|
// their dedicated editors (archie-core-b6ew.4).
|
|
type ConfigFieldType string
|
|
|
|
const (
|
|
FieldString ConfigFieldType = "string"
|
|
FieldInt ConfigFieldType = "int"
|
|
FieldBool ConfigFieldType = "bool"
|
|
FieldDuration ConfigFieldType = "duration"
|
|
FieldEnum ConfigFieldType = "enum"
|
|
FieldStructured ConfigFieldType = "structured"
|
|
)
|
|
|
|
// 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.
|
|
Key string `json:"key"`
|
|
Label string `json:"label"`
|
|
Description string `json:"description,omitempty"`
|
|
Type ConfigFieldType `json:"type"`
|
|
Value any `json:"value,omitempty"`
|
|
// LockedReason is set per instance from the running config's denied
|
|
// keys (configuration.DeniedKeys), not hand-authored here.
|
|
LockedReason string `json:"locked_reason,omitempty"`
|
|
// Options lists the valid values for a FieldEnum field.
|
|
Options []string `json:"options,omitempty"`
|
|
// RestartRequired reports that changing this field through the
|
|
// dashboard will not take effect until archied restarts. Sourced from
|
|
// internal/app/archied/reload.go's reloadableFields/reloadableSubFields
|
|
// allowlist -- webui does not import that app-layer package (dependency
|
|
// direction: app -> infrastructure, not the reverse), so the answer is
|
|
// copied by hand per field below and must be re-checked whenever
|
|
// reload.go's allowlist changes.
|
|
RestartRequired bool `json:"restart_required"`
|
|
}
|
|
|
|
// ConfigSection groups fields the same way the settings page's cards
|
|
// already do -- no new sections, this is metadata on existing rows.
|
|
type ConfigSection struct {
|
|
ID string `json:"id"`
|
|
Label string `json:"label"`
|
|
Description string `json:"description,omitempty"`
|
|
Fields []ConfigField `json:"fields"`
|
|
}
|
|
|
|
// configFieldDescriptors is the hand-authored catalog: one entry per field
|
|
// 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
|
|
// 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.
|
|
// - 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.
|
|
func configFieldDescriptors() []ConfigSection {
|
|
return []ConfigSection{
|
|
{
|
|
ID: "identity",
|
|
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},
|
|
{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},
|
|
},
|
|
},
|
|
{
|
|
ID: "repositories",
|
|
Label: "Repositories",
|
|
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
|
Fields: []ConfigField{
|
|
{
|
|
Key: "repos",
|
|
Label: "Repositories",
|
|
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
|
Type: FieldStructured,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
ID: "models",
|
|
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},
|
|
{Key: "providers", Label: "Providers", Type: FieldStructured},
|
|
},
|
|
},
|
|
{
|
|
ID: "budgets",
|
|
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},
|
|
{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},
|
|
},
|
|
},
|
|
{
|
|
ID: "storage",
|
|
Label: "Storage",
|
|
Description: "Where archied keeps its state.",
|
|
Fields: []ConfigField{
|
|
{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},
|
|
},
|
|
},
|
|
{
|
|
ID: "web",
|
|
Label: "Dashboard",
|
|
Description: "This dashboard's listen address.",
|
|
Fields: []ConfigField{
|
|
{Key: "web.listen", Label: "Listen address", Description: `"off" disables the dashboard.`, Type: FieldString, RestartRequired: true},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
// configFieldValues maps each descriptor key to its current value out of a
|
|
// live ConfigView. A plain switch, not reflection, for the same reason
|
|
// configFieldDescriptors is hand-authored: every value here already passed
|
|
// through ConfigView's own secret-safe allowlist, so this only has to
|
|
// answer "which already-safe field does this key mean," never "is this
|
|
// field safe to show."
|
|
func configFieldValues(view ConfigView) map[string]any {
|
|
return map[string]any{
|
|
"bot_user": view.Identity.BotUser,
|
|
"bot_email": view.Identity.BotEmail,
|
|
"label": view.Identity.Label,
|
|
"forge.type": view.Identity.ForgeType,
|
|
"forge.host": view.Identity.ForgeHost,
|
|
"diff_cap_lines": view.Identity.DiffCapLines,
|
|
"repos": view.Repositories,
|
|
"models": view.Models,
|
|
"providers": view.Providers,
|
|
"budgets.max_steps": view.Budgets.MaxSteps,
|
|
"budgets.wall_clock": view.Budgets.WallClock,
|
|
"budgets.gate_max_failures": view.Budgets.GateMaxFailures,
|
|
"work_dir": view.Storage.WorkDir,
|
|
"state_dir": view.Storage.StateDir,
|
|
"database_url": view.Storage.DatabaseURL,
|
|
"web.listen": view.Web.Listen,
|
|
}
|
|
}
|
|
|
|
// 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
|
|
// data-independent and safe to unit-test as a fixed catalog, the other is
|
|
// "what does this specific running config say."
|
|
func buildConfigSchema(view ConfigView) []ConfigSection {
|
|
values := configFieldValues(view)
|
|
sections := configFieldDescriptors()
|
|
for i := range sections {
|
|
for j := range sections[i].Fields {
|
|
f := §ions[i].Fields[j]
|
|
f.Value = values[f.Key]
|
|
f.LockedReason = view.Locked[f.Key]
|
|
}
|
|
}
|
|
return sections
|
|
}
|