Skip to content

feat(settings): allow clearing per-account capacity overrides back to environment inheritance #1538

Description

@Soju06

Summary

The per-account capacity family in dashboard settings (proxyAccountResponseCreateLimit, proxyAccountStreamLimit, proxyAccountStreamRecoveryReserve, and now proxyApiKeyFairShareCongestionThresholdPct from #1536) shares a tri-state limitation: once a dashboard override is stored, an operator cannot clear it back to null-inherits-environment. The update path treats an explicit null as "keep stored value" (model_fields_set → repository skips None), so the only recovery is setting an explicit value that happens to match the env var — which then stops tracking future env changes.

Raised by Codex review on #1536 (P2); the new field deliberately matched the existing fields' semantics rather than diverging, so the fix belongs to the whole family at once.

Proposed behavior

  • Settings API: distinguish "field absent" (keep) from "field explicitly null" (clear override → inherit env) for the four capacity fields, using the model_fields_set machinery that already detects explicit nulls.
  • Repository: accept a clear sentinel (the _UNSET pattern already exists in api_keys repository).
  • Frontend: an "inherit environment" affordance (e.g. clear button / placeholder showing the env value).
  • Settings-trace/audit rows record the clear.

Notes

  • Rows created after first boot are seeded with concrete env values, so NULL currently only occurs for migrated rows — this is a small operational gap, not a correctness bug.
  • Should cover the OpenSpec frontend-architecture scenarios for all four fields in one change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions