diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index cd80c5873..2fd766d12 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -95,7 +95,7 @@ {"_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":"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.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":"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:07:58Z","started_at":"2026-09-02T12:06:31Z","closed_at":"2026-09-02T12:07:58Z","close_reason":"ConfigView gains a Schema []ConfigSection field, populated in handleConfig via buildConfigSchema(view), which attaches each request's Value/LockedReason/Overridden onto the static configFieldDescriptors() catalog. The flat ConfigView fields (Identity, Repositories, etc.) are untouched -- Schema is additive. Tests confirm schema values match the flat fields they derive from, locked reasons propagate, structured fields stay non-editable, and secrets never reach the schema block.","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} {"_type":"issue","id":"archie-core-enfj","title":"[EPIC] Dynamic workflow routing: route task intent to the cheapest sufficient workflow","description":"workflow.Route() (internal/domain/workflow/workflow.go:237) only checks an explicit t.Workflow, then label match, then falls back unconditionally to 'implement' -- the heaviest workflow. There is no content/intent-based routing at all. task_spawn's own tool schema actively overpromises: 'workflow: ... Omit to let the daemon route it' (internal/gateway/task_tools.go:240), implying real routing exists when it means only 'check labels, then give up and run the heaviest workflow anyway'.\n\nConfirmed via production task 6 (2026-09-02): a chat-spawned task whose entire content was 'this is just a test, close it when you receive it' ran the full implement pipeline (prepare, baseline, plan, build, commit-push) end to end, burning 669,421 tokens and ~7 minutes, when nothing about the request needed a worktree, a plan, or a build at all.\n\nNeeds a design doc before any code lands per CLAUDE.md's scope-discipline rule (no settled design exists).","status":"closed","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T11:29:07Z","created_by":"Sam Catlow","updated_at":"2026-09-02T11:40:00Z","closed_at":"2026-09-02T11:40:00Z","close_reason":"Implemented internal/domain/workflow/triage.go: a cheap classify-only-once AgentStage (still runs StagePrepareWorktree -- AgentStage requires tc.Dir to mount into the container, no cheaper primitive exists) that either closes a task needing no code change (reusing the CloseIssue/StatusMerged pattern feasibility.go's OnResult already established for the same ctx-less constraint) or sets tc.Task.Workflow and requeues under the chosen workflow (implement/tdd/feasibility, defaulting to implement for a missing/unrecognized choice). Route()'s fallback (workflow.go) now prefers reg[\"triage\"] over reg[\"implement\"] when registered, falling back unchanged when it isn't -- fully backward compatible. Registered in skillbuild.builtins(). 9 new tests (triage_test.go, routing_test.go) plus the design doc at docs/prds/dynamic-workflow-triage.md. task check clean.","dependency_count":0,"dependent_count":0,"comment_count":0} diff --git a/internal/webui/api_config.go b/internal/webui/api_config.go index 48f36a8f0..15f1b94dc 100644 --- a/internal/webui/api_config.go +++ b/internal/webui/api_config.go @@ -224,6 +224,14 @@ type ConfigView struct { // runtime overlay, so the UI can mark those rows (their file value // is shadowed until reset) and offer a per-row reset. Overridden []string `json:"overridden,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. + Schema []ConfigSection `json:"schema"` } // IdentityView is who Archie is on the forge -- never the token that @@ -372,6 +380,7 @@ func (s *Server) handleConfig(w http.ResponseWriter, r *http.Request) { rs := s.LastReload() view.Reload = &rs } + view.Schema = buildConfigSchema(view) writeJSON(w, view) } diff --git a/internal/webui/api_config_test.go b/internal/webui/api_config_test.go index aa0e48ce1..2a99e342d 100644 --- a/internal/webui/api_config_test.go +++ b/internal/webui/api_config_test.go @@ -256,6 +256,99 @@ func TestHandleConfigReportsLockedKeys(t *testing.T) { } } +// TestHandleConfigIncludesSchemaWithLiveValues proves the schema (archie-core-b6ew.2) +// carries the same values as the flat ConfigView fields it is built from, +// not a stale or empty catalog. +func TestHandleConfigIncludesSchemaWithLiveValues(t *testing.T) { + srv := newTestServer(t) + srv.Cfg = configWithFakeSecrets() + + req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil) + w := httptest.NewRecorder() + srv.Handler().ServeHTTP(w, req) + + var got ConfigView + if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil { + t.Fatalf("decode: %v", err) + } + if len(got.Schema) == 0 { + t.Fatal("Schema is empty, want the field descriptor catalog") + } + + fields := map[string]ConfigField{} + for _, section := range got.Schema { + for _, f := range section.Fields { + fields[f.Key] = f + } + } + + botUser, ok := fields["bot_user"] + if !ok { + t.Fatal(`Schema has no "bot_user" field`) + } + 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. + workDir, ok := fields["work_dir"] + if !ok { + t.Fatal(`Schema has no "work_dir" field`) + } + if workDir.LockedReason == "" { + t.Error("Schema[work_dir].LockedReason is empty, want the overlay-denied reason") + } + if workDir.LockedReason != got.Locked["work_dir"] { + 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. + 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) + } +} + +// 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 +// be caught even if leakCandidates never appears in the flat fields. +func TestHandleConfigSchemaNeverLeaksSecrets(t *testing.T) { + srv := newTestServer(t) + srv.Cfg = configWithFakeSecrets() + + req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/config", nil) + w := httptest.NewRecorder() + srv.Handler().ServeHTTP(w, req) + + var got ConfigView + if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil { + t.Fatalf("decode: %v", err) + } + schemaJSON, err := json.Marshal(got.Schema) + if err != nil { + t.Fatalf("marshal schema: %v", err) + } + for _, leak := range leakCandidates() { + if strings.Contains(string(schemaJSON), leak) { + t.Errorf("schema leaked secret value %q:\n%s", leak, schemaJSON) + } + } +} + // TestHandleConfigUpdateAppliesViaSeam proves the PATCH handler passes // the decoded updates to the wired UpdateConfig seam and answers ok. func TestHandleConfigUpdateAppliesViaSeam(t *testing.T) { diff --git a/internal/webui/config_schema.go b/internal/webui/config_schema.go index 050f3d3a3..f55d1b232 100644 --- a/internal/webui/config_schema.go +++ b/internal/webui/config_schema.go @@ -165,3 +165,64 @@ func configFieldDescriptors() []ConfigSection { }, } } + +// 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, + "db_path": view.Storage.DBPath, + "skills_dir": view.Storage.SkillsDir, + "plugin_dir": view.Storage.PluginDir, + "secret_engine_dir": view.Storage.SecretEngineDir, + "containers.image": view.Containers.Image, + "containers.max_concurrency": view.Containers.MaxConcurrency, + "containers.max_uptime": view.Containers.MaxUptime, + "containers.volume_ttl": view.Containers.VolumeTTL, + "containers.pull_policy": view.Containers.PullPolicy, + "containers.network": view.Containers.Network, + "web.listen": view.Web.Listen, + } +} + +// buildConfigSchema attaches a live ConfigView's values, locked reasons, and +// overridden markers to the static descriptor catalog, producing the +// sections handleConfig returns to the dashboard. The catalog +// (configFieldDescriptors) and the per-request state (configFieldValues, +// view.Locked, view.Overridden) 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) + overridden := make(map[string]bool, len(view.Overridden)) + for _, key := range view.Overridden { + overridden[key] = true + } + + 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] + f.Overridden = overridden[f.Key] + } + } + return sections +}