Skip to content

refactor(config)!: make config sections orthogonal (#731)#747

Merged
cpcloud merged 1 commit intomainfrom
worktree-lucky-napping-hinton
Mar 11, 2026
Merged

refactor(config)!: make config sections orthogonal (#731)#747
cpcloud merged 1 commit intomainfrom
worktree-lucky-napping-hinton

Conversation

@cpcloud
Copy link
Owner

@cpcloud cpcloud commented Mar 10, 2026

Rearchitect the config system so each section is self-contained with no
cross-section value inheritance. Kill the shared [llm] base section and
replace it with independent [chat.llm] and [extraction.llm] sections.
Move OCR TSV settings into their own [extraction.ocr.tsv] sub-section.

  • Remove all deprecated key migration code, env var renames, and
    backward-compatibility shims
  • Remove deprecated MICASA_CURRENCY env var; only MICASA_LOCALE_CURRENCY
    is supported
  • Remove redundant llmExtraContext field; use chatCfg.ExtraContext
  • Remove dead collectValues/allValues code from ShowConfig
  • Combine env source and deprecation comments in config --dump output
  • Rename persisted settings DB key from llm.model to chat.llm.model
  • Update all docs, VHS tapes, error messages, and codebase maps
  • Add AGENTS.md rules for resisting configuration and orthogonality

BREAKING CHANGE: The [llm] config section and all deprecated env vars
(MICASA_LLM_, MICASA_EXTRACTION_MODEL, MICASA_EXTRACTION_TIMEOUT,
MICASA_CURRENCY) have been removed. Use [chat.llm] and [extraction.llm]
sections with their corresponding MICASA_CHAT_LLM_
and
MICASA_EXTRACTION_LLM_* env vars instead. The persisted model DB key
changed from llm.model to chat.llm.model; existing model preferences
will reset on first use.

Closes #731

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 10, 2026 14:18
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 76.14213% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.51%. Comparing base (bd6f3dc) to head (26144a5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
cmd/micasa/main.go 0.00% 21 Missing ⚠️
internal/app/model.go 38.09% 12 Missing and 1 partial ⚠️
internal/config/config.go 96.63% 2 Missing and 2 partials ⚠️
internal/config/show.go 84.61% 2 Missing and 2 partials ⚠️
internal/app/chat.go 50.00% 2 Missing and 1 partial ⚠️
internal/app/types.go 0.00% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
internal/app/extraction.go 70.71% <100.00%> (ø)
internal/data/settings.go 62.79% <ø> (ø)
internal/llm/client.go 91.40% <100.00%> (-0.35%) ⬇️
internal/locale/currency.go 75.79% <ø> (+1.18%) ⬆️
internal/app/types.go 54.87% <0.00%> (+1.93%) ⬆️
internal/app/chat.go 72.34% <50.00%> (ø)
internal/config/config.go 90.65% <96.63%> (+2.62%) ⬆️
internal/config/show.go 76.25% <84.61%> (-5.45%) ⬇️
internal/app/model.go 62.36% <38.09%> (+<0.01%) ⬆️
cmd/micasa/main.go 3.31% <0.00%> (-0.02%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the application configuration so that each section is fully self-contained with no cross-section value inheritance. Previously, [llm] was a shared base that [llm.chat] and [llm.extraction] overrode; now [chat.llm] and [extraction.llm] are independent with their own defaults. The OCR TSV settings are also reorganized into a dedicated [extraction.ocr.tsv] sub-section. All deprecated key migration code, env var renames, and backward-compatibility shims (except cache_ttl_days) are removed.

Changes:

  • Rearchitected config types: LLM base → Chat/ChatLLM/ExtractionLLM with independent defaults; OCR.TSV/OCRTSV replaces the flat tsv bool and confidence_threshold fields in OCR
  • Removed all deprecated TOML key migrations, env var rename logic, and backward-compat shims (~769 lines)
  • Updated all call sites (main.go, app/types.go, app/model.go, app/chat.go), tests, documentation, and VHS tapes to use the new config paths and env vars

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plans/orthogonal-config.md New design document explaining the orthogonal config architecture
internal/config/config.go Core types rewrite: LLMChat/ChatLLM/ExtractionLLM/OCRTSV; removes migrateRenamedKeys, envRenames, migrateRenamedEnvVars, coalesce, ResolvedLLM, validateOverrideTimeoutvalidateTimeout
internal/config/show.go Removes deprecatedPaths map and deprecated field annotation logic; isEmptyValue updated so non-nil pointer to zero is not considered empty
internal/config/config_test.go Tests updated to new paths/env vars; adds findAll helper; removes ~400 lines of deprecated migration tests
internal/config/show_test.go Tests updated to new section names; removes pipeline override/deprecated section tests
internal/app/types.go llmConfigchatConfig (with Enabled bool); SetLLMSetChat; extractionConfig comment cleaned
internal/app/model.go llmConfig *llmConfigchatCfg chatConfig; extractionLLMClient no longer falls back to chat config
internal/app/chat.go llmConfigchatCfg reference; config hint message updated to new section names
internal/app/extraction_test.go llmConfigchatCfg in test setup; TestExtractionClient_FallsBackToChatConfig replaced with TestExtractionClient_NilWhenNoExtractionModel
cmd/micasa/main.go Updated to call SetChat/SetExtraction with new config field accessors
docs/tapes/llm-chat.tape Env var updated to MICASA_CHAT_LLM_MODEL
docs/tapes/extraction.tape Env var updated to MICASA_EXTRACTION_LLM_MODEL
docs/content/docs/reference/configuration.md Full reference table and section docs updated to new config paths
docs/content/docs/guide/llm-chat.md [llm][chat.llm] references
docs/content/blog/llm-plumbing.md Config examples and env vars updated
cmd/micasa/main_test.go Config key updated to chat.llm.model
.claude/codebase/types.md Config type map updated

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 10, 2026 14:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 10, 2026 15:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

internal/config/config.go:444

  • The applyEnvOverrides function's comment (line 440-441) still mentions "The extra map supplies values migrated from deprecated env var names (checked when the canonical env var is unset)." Since extra is always passed as nil after the refactor removed all deprecated env var migration, the comment is now misleading. The extra parameter and its nil-guard (if val == "" && extra != nil) in walkEnvFields are also now dead code — the function signature and nil check could be simplified by removing the extra parameter entirely.
// applyEnvOverrides walks the Config struct and applies environment variable
// overrides. Env var names are derived from the dotted TOML path via
// [EnvVarName]. The extra map supplies values migrated from deprecated env
// var names (checked when the canonical env var is unset).
func applyEnvOverrides(cfg *Config, extra map[string]string) error {
	return walkEnvFields(reflect.ValueOf(cfg).Elem(), "", extra)
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 10, 2026 16:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 11, 2026 00:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cpcloud cpcloud force-pushed the worktree-lucky-napping-hinton branch from 9fa589d to 405d063 Compare March 11, 2026 00:23
Copilot AI review requested due to automatic review settings March 11, 2026 10:11
@cpcloud cpcloud force-pushed the worktree-lucky-napping-hinton branch from 405d063 to 80bae95 Compare March 11, 2026 10:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

internal/config/show.go:33

  • The ShowConfig-related comments and naming still refer to “overrides” (e.g. ShowConfig says it’s “marking active overrides”, and sectionBlock.override is set by strings.Contains(prefix, ".")). With the new orthogonal config (no inheritance), these are no longer overrides—just nested tables. Updating the comments and renaming override to something like subtable/nested would make the intent clearer, and avoids implying there’s still cross-section override behavior.
// ShowConfig writes the fully resolved configuration as valid TOML to w,
// annotating each field with its env var name and marking active overrides.
func (c Config) ShowConfig(w io.Writer) error {

internal/config/config.go:443

  • applyEnvOverrides still takes an extra map and the comment says it supplies values migrated from deprecated env vars, but LoadFromPath always calls applyEnvOverrides(&cfg, nil) and nothing else passes a non-nil map. This leaves dead code (and a misleading comment) in walkEnvFields (if val == "" && extra != nil { ... }). Consider removing the extra parameter entirely and updating the comment to reflect the current behavior (no deprecated env-var migration).
// applyEnvOverrides walks the Config struct and applies environment variable
// overrides. Env var names are derived from the dotted TOML path via
// [EnvVarName]. The extra map supplies values migrated from deprecated env
// var names (checked when the canonical env var is unset).
func applyEnvOverrides(cfg *Config, extra map[string]string) error {
	return walkEnvFields(reflect.ValueOf(cfg).Elem(), "", extra)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Rearchitect the config system so each section is self-contained with no
cross-section value inheritance. Kill the shared [llm] base section and
replace it with independent [chat.llm] and [extraction.llm] sections.
Move OCR TSV settings into their own [extraction.ocr.tsv] sub-section.

- Remove all deprecated key migration code, env var renames, and
  backward-compatibility shims
- Remove deprecated MICASA_CURRENCY env var; only MICASA_LOCALE_CURRENCY
  is supported
- Remove redundant llmExtraContext field; use chatCfg.ExtraContext
- Remove dead collectValues/allValues code from ShowConfig
- Combine env source and deprecation comments in config --dump output
- Rename persisted settings DB key from llm.model to chat.llm.model
- Update all docs, VHS tapes, error messages, and codebase maps
- Add AGENTS.md rules for resisting configuration and orthogonality

BREAKING CHANGE: The [llm] config section and all deprecated env vars
(MICASA_LLM_*, MICASA_EXTRACTION_MODEL, MICASA_EXTRACTION_TIMEOUT,
MICASA_CURRENCY) have been removed. Use [chat.llm] and [extraction.llm]
sections with their corresponding MICASA_CHAT_LLM_* and
MICASA_EXTRACTION_LLM_* env vars instead. The persisted model DB key
changed from llm.model to chat.llm.model; existing model preferences
will reset on first use.

Closes #731

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpcloud cpcloud force-pushed the worktree-lucky-napping-hinton branch from a8160e2 to 26144a5 Compare March 11, 2026 10:36
@cpcloud cpcloud changed the title refactor(config): make config sections orthogonal refactor(config)!: make config sections orthogonal (#731) Mar 11, 2026
@cpcloud cpcloud merged commit 22ccdd4 into main Mar 11, 2026
25 checks passed
@cpcloud cpcloud deleted the worktree-lucky-napping-hinton branch March 11, 2026 10:58
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.

refactor(config): consider moving [llm.extraction] under [extraction.llm]

2 participants