container-runtime-policies renders Go-cased keys from an untagged config.ContainerConfig #1525

Closed
opened 2026-10-27 13:40:45 +00:00 by sam · 0 comments
Owner

Found by the audit that archie-core-02rm asked for ('check the other operational kinds for the same leak before fixing only this one'). 02rm fixed channel-settings (commit 092194cd); this is the one remaining instance.

EVIDENCE

internal/app/controlplane/operational_settings.go registers the kind with Seed: func(cfg config.Config) any { return cfg.Containers }, so the stored document is a JSON projection of config.ContainerConfig. validateContainers decodes it with validateAs(input, func(settings config.ContainerConfig) error {...}) and runtime_config.go layers it with layerResourceJSON(ctx, reader, versions, ContainerRuntimePoliciesKind, &out.Containers) -- i.e. the internal config struct IS the wire shape.

config.ContainerConfig (internal/config/config.go) has 7 fields and ZERO json tags, so encoding/json falls back to the Go field names and the Web UI labels them: LegacyEnabled, Image, MaxConcurrency, MaxUptime, VolumeTTL, PullPolicy, Network. Every sibling resource in the same registry is snake_case.

Different from channel-settings in one respect, worth stating so the fix is not over-scoped: its two duration fields (MaxUptime, VolumeTTL) are config.Duration, which already marshals as the string "1h0m0s". So this leak is the KEYS only -- there is no nanosecond integer here.

Same document, second shape: LegacyEnabled decodes the removed containers.enabled switch and, by its own comment, has no runtime consumer. It is the not-consumed shape inside the same resource that will now read as an editable setting in the Web UI.

AUDIT RESULT (why this is the last one)

Field-vs-json-tag count for every type a resource seeds or mirrors: config.Repo 12/12, config.Provider 4/4, config.ToolPolicy 2/2, config.WebFetchConfig 4/4, config.MinimaxConfig 3/3, config.Dispatch 3/3, config.SecretRef 2/2, cronstore.JobSpec 4/4, config.ContainerConfig 7/0. The tool-settings kind mirrors MCPServer into an explicitly tagged mcpServerSettings, which is the shape to copy.

FIX DIRECTION

Same treatment as 092194cd: define the document type in internal/app/controlplane with explicit snake_case tags, tolerate the Go-cased keys an existing store holds while keeping DisallowUnknownFields so a misspelling cannot decode as 'unset', and register a Normalize that rewrites a legacy document on write. Note the migration consequence that makes this risk-routed: the control plane fails closed, so a shape change without read tolerance stops archied starting on a store that already holds the old document.

Close reason

Delivered and pinned; verified against HEAD this session (#1171 via internal/app/controlplane/container_settings.go, #1174 via internal/app/archied/sd_notify.go call sites). Container tests ok 1.828s; archied notify tests ok 5.880s.


Imported from beads archie-core-q4og · GitHub #1171 · type bug · priority P3 · created 2026-09-21 · closed 2026-09-30

Found by the audit that archie-core-02rm asked for ('check the other operational kinds for the same leak before fixing only this one'). 02rm fixed channel-settings (commit 092194cd); this is the one remaining instance. EVIDENCE internal/app/controlplane/operational_settings.go registers the kind with Seed: func(cfg config.Config) any { return cfg.Containers }, so the stored document is a JSON projection of config.ContainerConfig. validateContainers decodes it with validateAs(input, func(settings config.ContainerConfig) error {...}) and runtime_config.go layers it with layerResourceJSON(ctx, reader, versions, ContainerRuntimePoliciesKind, &out.Containers) -- i.e. the internal config struct IS the wire shape. config.ContainerConfig (internal/config/config.go) has 7 fields and ZERO json tags, so encoding/json falls back to the Go field names and the Web UI labels them: LegacyEnabled, Image, MaxConcurrency, MaxUptime, VolumeTTL, PullPolicy, Network. Every sibling resource in the same registry is snake_case. Different from channel-settings in one respect, worth stating so the fix is not over-scoped: its two duration fields (MaxUptime, VolumeTTL) are config.Duration, which already marshals as the string "1h0m0s". So this leak is the KEYS only -- there is no nanosecond integer here. Same document, second shape: LegacyEnabled decodes the removed containers.enabled switch and, by its own comment, has no runtime consumer. It is the not-consumed shape inside the same resource that will now read as an editable setting in the Web UI. AUDIT RESULT (why this is the last one) Field-vs-json-tag count for every type a resource seeds or mirrors: config.Repo 12/12, config.Provider 4/4, config.ToolPolicy 2/2, config.WebFetchConfig 4/4, config.MinimaxConfig 3/3, config.Dispatch 3/3, config.SecretRef 2/2, cronstore.JobSpec 4/4, config.ContainerConfig 7/0. The tool-settings kind mirrors MCPServer into an explicitly tagged mcpServerSettings, which is the shape to copy. FIX DIRECTION Same treatment as 092194cd: define the document type in internal/app/controlplane with explicit snake_case tags, tolerate the Go-cased keys an existing store holds while keeping DisallowUnknownFields so a misspelling cannot decode as 'unset', and register a Normalize that rewrites a legacy document on write. Note the migration consequence that makes this risk-routed: the control plane fails closed, so a shape change without read tolerance stops archied starting on a store that already holds the old document. ### Close reason Delivered and pinned; verified against HEAD this session (#1171 via internal/app/controlplane/container_settings.go, #1174 via internal/app/archied/sd_notify.go call sites). Container tests ok 1.828s; archied notify tests ok 5.880s. --- _Imported from beads `archie-core-q4og` · GitHub #1171 · type bug · priority P3 · created 2026-09-21 · closed 2026-09-30_
sam added the lowbug labels 2026-10-27 13:40:45 +00:00
sam self-assigned this 2026-10-27 13:40:45 +00:00
sam closed this issue 2026-10-27 13:40:45 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1525