Skip to content

feat(llm): persist provider affinity settings (2/3) - #897

Draft
renaesop wants to merge 2 commits into
BaaRai:mainfrom
renaesop:codex/maas-cache-affinity-config
Draft

renaesop wants to merge 2 commits into
BaaRai:mainfrom
renaesop:codex/maas-cache-affinity-config

Conversation

@renaesop

@renaesop renaesop commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Profiles need to persist the provider affinity policy and apply the same settings to saved profiles, legacy updates and connection tests. This adds the configuration backend for #750, including migration, API validation and compatibility tests. Legacy updates preserve the configured output-token limit.

Dependency draft: blocked by #750. The base is main; the contributor cannot create an upstream base branch for a cross-fork stack. The current PR therefore includes the provider commit: 17 cumulative files. The configuration subsystem itself is 10 files, +515/-75 lines: review only this layer.

Keep this draft until #750 merges, then rebase onto main and drop the inherited provider commit before requesting review. That leaves only the configuration subsystem within the repository's review-size limit.

Behavior

  • Persist independent header, recovery and prompt-cache-key modes. Migrate nonempty legacy headers to custom and empty ones to auto; repeated migrations preserve explicit off settings.
  • Preserve omitted API fields and interpret a legacy explicitly cleared header as off.
  • Validate incompatible protocol changes before saving. Rebuild active providers from complete persisted settings, retaining output-token caps and explicit overrides.
  • Activate normalized policies in profile loading, connection tests and the environment fallback. Include policy changes in side-question provider identity.

Validation

Rebased onto main 2f065a958e4bc84e300ece4af501a5cdd3ed08cd, after its route-permission refactor.

  • 189 isolated PostgreSQL migration/profile/API, LLM and route-permission tests/subtests passed with -race.
  • go build ./... and go vet ./... passed on this branch.
  • Coverage includes omitted fields, explicit clearing, automatic/off modes, invalid headers, rejected protocol changes, preserved credentials and output-token limits, and consistency between saved and runtime policy.
  • No live provider calls or deployment were performed.

#750's upstream Norma #15 release prerequisite also applies. The settings UI and read-only preview are in the separate dependent draft #898.

@renaesop

renaesop commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

This is the configuration-backend layer of the split requested on #750. Dependency order: #750 → #897 → #898.

Its own change is commit a714955e: 10 files, +515/-75 (layer-only diff). The GitHub PR currently shows 17 cumulative files because its base is main and it also carries #750. It remains Draft until #750 merges and the inherited commit is removed by rebasing onto updated main; the 10-file count describes this layer, not today's complete PR diff.

This layer owns the transition from stored/user intent to an effective provider configuration. Migration preserves existing custom headers and explicit off settings; API parsing distinguishes omitted fields from an explicitly cleared header. Both saving and runtime reload use the complete persisted configuration, preserving the output-token limit. It activates the provider capability from #750 only after these compatibility rules are in place.

File Responsibility
db/schema.sql Add policy modes and migrate legacy headers without overwriting explicit modes on later startups.
db/config.go Profile fields, normalization, save/load and query wiring.
db/llm_affinity_test.go Persistence round trips and repeatable migration behavior.
server/dto.go Expose saved policy modes in profile responses.
server/llm_affinity.go Resolve omitted versus explicit API settings.
server/llm_affinity_test.go Legacy/profile API compatibility, rejected updates, runtime consistency and preserved output caps.
server/server.go Load/apply policy, preserve legacy updates, configure connection tests and normalize the environment fallback.
server/server_mgmt.go Profile-save validation and preservation of omitted settings.
server/side_questions.go Include affinity settings in provider identity so policy changes invalidate the appropriate state.
docs/maas-cache-affinity.md Document profile migration, API semantics and activation.

Provider implementation and its tests belong to #750. Settings controls, translations and the draft-policy preview belong to #898. The configuration tests stay here so migration and compatibility can be reviewed together with their implementation.

On this branch rebased onto main 2f065a95, 189 database/server tests and subtests passed with -race, using an isolated PostgreSQL instance; go build ./... and go vet ./... also passed. Coverage includes omitted fields, explicit clearing, automatic/off modes, invalid headers, incompatible protocol changes, saved/runtime consistency and token-cap preservation. No live provider calls were used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant