diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index fd19a5265..cd80c5873 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -94,7 +94,7 @@ {"_type":"issue","id":"archie-core-b6ew.4","title":"Structured configuration editors: repositories, maps","description":"Repositories currently render as a static read-only table missing AllowConcurrent, MaxRetries, and ReviewEnabled entirely (ReviewEnabled is absent from RepoView in api_config.go, not just unrendered). Add ReviewEnabled to RepoView, and build a dedicated backend-defined editor for the repositories section (and the models/providers maps) so these stop being silently read-only. This is the concrete fix for the allow_concurrent discoverability gap Sam hit, delivered as a typed editor rather than a one-off card patch, since the schema this epic introduces is what should own its shape.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:46Z","dependencies":[{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:51Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} {"_type":"issue","id":"archie-core-b6ew.5","title":"Schema contract tests: metadata completeness and secret-safety","description":"Assert every field the schema exposes carries type, label, and section; assert restart_required and editable are set deliberately (not zero-value defaults hiding an unreviewed field); assert secrets still never appear (extend the existing TestHandleConfigNeverLeaksSecrets pattern to the schema response); assert the frontend's generic renderer can render the full schema fixture without any field-specific branch (a JS test walking the schema and asserting no field key appears literally in settings.js).","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:46Z","dependencies":[{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.3","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.4","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-b6ew.3","title":"Generic frontend renderer for scalar configuration fields","description":"Replace settings.js's hardcoded row(...) calls for scalar/bool/int/enum/duration fields with a renderer that walks the backend's sections/fields schema and builds the section cards, labels, and edit affordances from the descriptor alone -- the frontend must not know that containers.max_concurrency is an int or which card it belongs in. Structured fields (repositories, models, providers maps) are out of scope here and keep their existing bespoke rendering, tagged type=structured so the generic renderer skips them without special-casing each key.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:45Z","dependencies":[{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0} -{"_type":"issue","id":"archie-core-b6ew.1","title":"Backend configuration schema contract: field descriptor types and section metadata","description":"Define the descriptor types (Section, Field, Option) in internal/webui alongside ConfigView -- Key, Label, Description, Section, Type (string|int|bool|duration|enum|structured), Editable, LockedReason, Overridden, Options, RestartRequired. Hand-author one descriptor per existing ConfigView field, grouped into the sections the settings page already renders (identity, repositories, models, providers, budgets, storage, containers, web). No reflection over config.Config -- config.Config is scheduled for dissolution (internal/config/config.go package doc) and every field here is already a deliberate allowlist entry, so this is metadata on fields that already passed the secret-safety allowlist, not a new safety boundary.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:44Z","dependencies":[{"issue_id":"archie-core-b6ew.1","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0} +{"_type":"issue","id":"archie-core-b6ew.1","title":"Backend configuration schema contract: field descriptor types and section metadata","description":"Define the descriptor types (Section, Field, Option) in internal/webui alongside ConfigView -- Key, Label, Description, Section, Type (string|int|bool|duration|enum|structured), Editable, LockedReason, Overridden, Options, RestartRequired. Hand-author one descriptor per existing ConfigView field, grouped into the sections the settings page already renders (identity, repositories, models, providers, budgets, storage, containers, web). No reflection over config.Config -- config.Config is scheduled for dissolution (internal/config/config.go package doc) and every field here is already a deliberate allowlist entry, so this is metadata on fields that already passed the secret-safety allowlist, not a new safety boundary.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:05:40Z","started_at":"2026-09-02T12:02:40Z","closed_at":"2026-09-02T12:05:40Z","close_reason":"Added internal/webui/config_schema.go: ConfigFieldType/ConfigField/ConfigSection descriptor types and configFieldDescriptors(), hand-authoring key/label/type/editable/restart_required for every field ConfigView exposes today, grouped into the sections settings.js already renders. RestartRequired sourced from internal/app/archied/reload.go's reloadableFields/reloadableSubFields allowlist. Contract tests pin key completeness, structured-field non-editability, and locked-storage-field non-editability. Not yet wired into GET /api/config -- that's b6ew.2.","dependencies":[{"issue_id":"archie-core-b6ew.1","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0} {"_type":"issue","id":"archie-core-b6ew.2","title":"Expose the config schema via GET /api/config","description":"Extend handleConfig's response with a schema-driven shape (sections of fields, each carrying its descriptor and current value) built from the field descriptors, replacing the flat ConfigView value tree the frontend currently re-interprets by hand. Keep the existing Locked/Overridden/Reload/Provenance top-level fields -- they describe runtime state, not the field catalog, and the schema-driven fields reference into them (locked_reason, overridden) rather than duplicating that logic.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:44Z","dependencies":[{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew.1","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":2,"comment_count":0} {"_type":"issue","id":"archie-core-b6ew","title":"[EPIC] Backend-owned configuration schema for the webui Configuration page","description":"The Configuration page's field definitions (label, section, type, editability, restart-required, options) are hand-maintained in ui/src/settings/settings.js and config-row.js, disjoint from the backend's own ConfigView allowlist in internal/webui/api_config.go. Adding or changing a runtime-tunable setting today means editing Go and JS in two unrelated places by hand, and nothing catches drift between them. Repo.ReviewEnabled is missing from the API entirely; AllowConcurrent and MaxRetries reach the API but the repositories card never renders them, which is what blocked Sam from discovering the allow_concurrent fix without an agent tracing the Go source directly.\n\nDesign: docs/prds/config-schema.md. The backend keeps its existing hand-picked, secret-free allowlist (ConfigView in api_config.go) -- config.Config is scheduled for dissolution per its own package doc, so this is deliberately NOT a reflection-based schema over config.Config. Instead each already-allowlisted field gains a hand-authored descriptor (label, section, type, editable, restart_required, options) alongside its existing value, and the frontend renders scalar/bool/int/enum/duration fields generically from that descriptor instead of hardcoding rows. Structured fields (repositories, maps) get dedicated typed editors rather than staying silently read-only.","status":"open","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:27Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:27Z","dependency_count":0,"dependent_count":0,"comment_count":0} {"_type":"issue","id":"archie-core-z6wy","title":"Curator action timestamps rendered as '105694 wks ago'","description":"Curator actions built without an explicit At (e.g. sessioncurator before this fix, and skillcurator) serialized time.Time's zero value to the dashboard, which rendered as a nonsense relative time. Fixed by stamping sessioncurator's action with its clock and backfilling any zero Action.At in activityTracker.record from the pass timestamp.","status":"closed","priority":2,"issue_type":"bug","owner":"sam@catlow.tech","created_at":"2026-09-02T11:52:20Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:52:24Z","closed_at":"2026-09-02T11:52:24Z","close_reason":"Fixed: sessioncurator now stamps Action.At from its clock; activityTracker.record backfills any zero Action.At from the pass timestamp as a defense in depth for engines with no clock (skillcurator).","dependency_count":0,"dependent_count":0,"comment_count":0} diff --git a/internal/webui/config_schema.go b/internal/webui/config_schema.go new file mode 100644 index 000000000..050f3d3a3 --- /dev/null +++ b/internal/webui/config_schema.go @@ -0,0 +1,167 @@ +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 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. +type ConfigField struct { + // Key is the dotted path this field is addressed by, matching the key + // space handleConfigUpdate/UpdateConfig already accepts. + 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 (overlay.DeniedKeys). + Editable bool `json:"editable"` + // LockedReason is set per instance from the running config's denied + // keys (overlay.DeniedKeys), not hand-authored here. + LockedReason string `json:"locked_reason,omitempty"` + // Overridden is set per instance from the running config's overlay + // state, not hand-authored here. + Overridden bool `json:"overridden"` + // 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"` + 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, LockedReason and Overridden 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. +// +// RestartRequired is set from internal/app/archied/reload.go as of this +// writing: +// - reloadableFields lists BotUser, BotEmail, Label, DiffCapLines, Budgets, +// Models -- all reloadable. +// - reloadableSubFields["Containers"] allows only LegacyEnabled and +// VolumeTTL -- every other Containers field (Image, MaxConcurrency, +// MaxUptime, PullPolicy, Network) requires a restart. +// - reloadableSubFields["Forge"] allows only Host -- Forge.Type requires a +// restart even though the dashboard already renders it as editable. +// - Web, SkillsDir, PluginDir, SecretEngineDir are absent from both +// allowlists entirely, so they require a restart. +// - WorkDir and DBPath are locked (overlay.DeniedKeys), not merely +// restart-required -- the dashboard cannot change them at all. +func configFieldDescriptors() []ConfigSection { + return []ConfigSection{ + { + ID: "identity", + Label: "Identity", + 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 means unlimited.", Type: FieldInt, Editable: true}, + }, + }, + { + ID: "repositories", + Label: "Repositories", + 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, + Editable: false, + }, + }, + }, + { + ID: "models", + Label: "Models & providers", + Fields: []ConfigField{ + {Key: "models", Label: "Model roles", Type: FieldStructured, Editable: false}, + {Key: "providers", Label: "Providers", Type: FieldStructured, Editable: false}, + }, + }, + { + ID: "budgets", + Label: "Budgets", + 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}, + }, + }, + { + ID: "storage", + Label: "Storage & sandboxing", + Fields: []ConfigField{ + {Key: "work_dir", Label: "Work directory", Type: FieldString, Editable: false}, + {Key: "db_path", Label: "State path prefix", Type: FieldString, Editable: false}, + {Key: "skills_dir", Label: "Shared skills directory", Type: FieldString, Editable: true, RestartRequired: true}, + {Key: "plugin_dir", Label: "Daemon plugin directory", Type: FieldString, Editable: true, RestartRequired: true}, + {Key: "secret_engine_dir", Label: "Secret engine plugin directory", Type: FieldString, Editable: true, RestartRequired: true}, + {Key: "containers.image", Label: "Agent image", Type: FieldString, Editable: true, RestartRequired: true}, + {Key: "containers.max_concurrency", Label: "Max concurrent tasks", Description: "0 means unlimited.", Type: FieldInt, Editable: true, RestartRequired: true}, + {Key: "containers.max_uptime", Label: "Container max lifetime", Type: FieldDuration, Editable: true, RestartRequired: true}, + {Key: "containers.volume_ttl", Label: "Persistent volume retention", Type: FieldDuration, Editable: true}, + {Key: "containers.pull_policy", Label: "How images are refreshed", Type: FieldEnum, Options: []string{"missing", "always"}, Editable: true, RestartRequired: true}, + {Key: "containers.network", Label: "Docker network", Type: FieldString, Editable: true, RestartRequired: true}, + }, + }, + { + ID: "web", + Label: "Dashboard", + Fields: []ConfigField{ + {Key: "web.listen", Label: "Listen address", Type: FieldString, Editable: true, RestartRequired: true}, + }, + }, + } +} diff --git a/internal/webui/config_schema_test.go b/internal/webui/config_schema_test.go new file mode 100644 index 000000000..0ee18da57 --- /dev/null +++ b/internal/webui/config_schema_test.go @@ -0,0 +1,112 @@ +package webui + +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. +func TestConfigFieldDescriptorsAreComplete(t *testing.T) { + seen := map[string]bool{} + for _, section := range configFieldDescriptors() { + if section.ID == "" { + t.Errorf("section with empty ID, label %q", section.Label) + } + if section.Label == "" { + t.Errorf("section %q has no label", section.ID) + } + if len(section.Fields) == 0 { + t.Errorf("section %q has no fields", section.ID) + } + for _, f := range section.Fields { + if f.Key == "" { + t.Fatalf("section %q has a field with no key", section.ID) + } + if seen[f.Key] { + t.Errorf("duplicate field key %q", f.Key) + } + seen[f.Key] = true + if f.Label == "" { + t.Errorf("field %q has no label", f.Key) + } + if f.Type == "" { + t.Errorf("field %q has no type", f.Key) + } + if f.Type == FieldEnum && len(f.Options) == 0 { + t.Errorf("field %q is type enum but has no options", f.Key) + } + if f.Type != FieldEnum && len(f.Options) != 0 { + t.Errorf("field %q has options but is not type enum", f.Key) + } + // Value/LockedReason/Overridden are attached per-instance + // against a live ConfigView (archie-core-b6ew.2), not part of + // the static catalog -- the catalog must not pre-populate them. + if f.Value != nil { + t.Errorf("field %q has a static Value; that is attached per-request", f.Key) + } + if f.LockedReason != "" { + t.Errorf("field %q has a static LockedReason; that is attached per-request", f.Key) + } + if f.Overridden { + t.Errorf("field %q has a static Overridden; that is attached per-request", f.Key) + } + } + } + + // Every dotted key settings.js hardcodes today must have a descriptor, + // so the schema is a superset (ideally exact set) of what the frontend + // currently renders -- see ui/src/settings/settings.js. + wantKeys := []string{ + "bot_user", "bot_email", "label", "forge.type", "forge.host", "diff_cap_lines", + "repos", "models", "providers", + "budgets.max_steps", "budgets.wall_clock", "budgets.gate_max_failures", + "work_dir", "db_path", "skills_dir", "plugin_dir", "secret_engine_dir", + "containers.image", "containers.max_concurrency", "containers.max_uptime", + "containers.volume_ttl", "containers.pull_policy", "containers.network", + "web.listen", + } + for _, key := range wantKeys { + if !seen[key] { + t.Errorf("missing descriptor for %q, which settings.js already hardcodes", key) + } + } + if len(seen) != len(wantKeys) { + t.Errorf("configFieldDescriptors has %d keys, want exactly %d (extra keys need adding to wantKeys deliberately)", len(seen), len(wantKeys)) + } +} + +// 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/db_path 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, "db_path": 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) + } + } + } +}