Skip to content

feat(config): derive env var names from dotted config paths#725

Merged
cpcloud merged 1 commit intomainfrom
worktree-jiggly-churning-forest
Mar 9, 2026
Merged

feat(config): derive env var names from dotted config paths#725
cpcloud merged 1 commit intomainfrom
worktree-jiggly-churning-forest

Conversation

@cpcloud
Copy link
Copy Markdown
Collaborator

@cpcloud cpcloud commented Mar 9, 2026

Summary

  • Make the dotted TOML config path the single source of truth for env var names: MICASA_ + UPPER(key with "." → "_"). Users can look at any config key and immediately infer the env var.
  • Remove all env:"..." struct tags; derive names at runtime via EnvVarName(key).
  • Refactor migrateRenamedEnvVars as a table-driven function returning an overrides map instead of mutating config fields directly. Handles multi-generation chains (e.g. MICASA_MAX_OCR_PAGESMICASA_MAX_EXTRACT_PAGESMICASA_EXTRACTION_MAX_PAGES).
  • Rename extraction.max_extract_pagesextraction.max_pages with TOML key and env var deprecation migrations.
  • All old env var names still accepted with deprecation warnings.
  • Update show config dump to derive fallback env var sources from the same rename table.

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 81.60920% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.36%. Comparing base (8ae9b82) to head (aed17bc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/config/config.go 83.82% 10 Missing and 1 partial ⚠️
internal/locale/currency.go 0.00% 4 Missing ⚠️
cmd/micasa/main.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
internal/config/show.go 81.36% <100.00%> (+0.69%) ⬆️
internal/extract/ocr.go 83.58% <ø> (ø)
cmd/micasa/main.go 3.36% <0.00%> (ø)
internal/locale/currency.go 74.60% <0.00%> (-1.19%) ⬇️
internal/config/config.go 86.90% <83.82%> (-1.21%) ⬇️

... and 1 file with indirect coverage changes

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

Make the dotted TOML path the single source of truth for env var names:
MICASA_ + UPPER(key with "." replaced by "_"). Users can now look at any
config key and immediately know its env var without consulting a table.

Remove all `env:"..."` struct tags and derive names at runtime via
EnvVarName(). Refactor migrateRenamedEnvVars as a table-driven function
returning an overrides map (no os.Setenv mutation). Rename
extraction.max_extract_pages to extraction.max_pages.

Env vars that changed (old names accepted with deprecation warnings):
- MICASA_CURRENCY -> MICASA_LOCALE_CURRENCY
- MICASA_MAX_DOCUMENT_SIZE -> MICASA_DOCUMENTS_MAX_FILE_SIZE
- MICASA_CACHE_TTL -> MICASA_DOCUMENTS_CACHE_TTL
- MICASA_CACHE_TTL_DAYS -> MICASA_DOCUMENTS_CACHE_TTL_DAYS
- MICASA_FILE_PICKER_DIR -> MICASA_DOCUMENTS_FILE_PICKER_DIR
- MICASA_MAX_EXTRACT_PAGES -> MICASA_EXTRACTION_MAX_PAGES
- MICASA_TEXT_TIMEOUT -> MICASA_EXTRACTION_TEXT_TIMEOUT
- MICASA_EXTRACTION_MAX_EXTRACT_PAGES -> MICASA_EXTRACTION_MAX_PAGES

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cpcloud cpcloud force-pushed the worktree-jiggly-churning-forest branch from 3c35061 to aed17bc Compare March 9, 2026 14:43
@cpcloud cpcloud merged commit b1d4283 into main Mar 9, 2026
17 checks passed
@cpcloud cpcloud deleted the worktree-jiggly-churning-forest branch March 9, 2026 14:49
cpcloud added a commit that referenced this pull request Mar 19, 2026
## Summary

- Make the dotted TOML config path the single source of truth for env
var names: `MICASA_` + `UPPER(key with "." → "_")`. Users can look at
any config key and immediately infer the env var.
- Remove all `env:"..."` struct tags; derive names at runtime via
`EnvVarName(key)`.
- Refactor `migrateRenamedEnvVars` as a table-driven function returning
an overrides map instead of mutating config fields directly. Handles
multi-generation chains (e.g. `MICASA_MAX_OCR_PAGES` →
`MICASA_MAX_EXTRACT_PAGES` → `MICASA_EXTRACTION_MAX_PAGES`).
- Rename `extraction.max_extract_pages` → `extraction.max_pages` with
TOML key and env var deprecation migrations.
- All old env var names still accepted with deprecation warnings.
- Update `show config` dump to derive fallback env var sources from the
same rename table.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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