Skip to content

refactor(config): split generator-owned contract from settings - #913

Merged
MintsInc merged 2 commits into
mainfrom
ulysse.mavrocordatos/split-config-contract
Oct 15, 2026
Merged

MintsInc merged 2 commits into
mainfrom
ulysse.mavrocordatos/split-config-contract

Conversation

@MintsInc

Copy link
Copy Markdown
Member

Context

openapi-transformer's pup generator copies its config asset over src/config.rs on every run. Any hand edit to config.rs in pup gets reverted by the next generated PR unless someone also mirrors it into the asset. That has happened twice: the regional OAuth fix (422e481) had to be re-synced into the asset after a generated PR reverted it. #908 currently deletes auth_config_dir() and the XDG-aware config_file_candidates() from #891 (3f5f913). Merging #908 would quietly move macOS auth storage back to the wrong directory.

This is the same fix as the formatter split (b112d16, 4e45407): a small generator-owned contract, with the real logic in a hand-owned module.

Changes

  • src/config.rs becomes a generator-owned shim that re-exports only Config and OutputFormat. Generated code, and the formatter.rs/client.rs assets, use nothing else from crate::config (checked against the generator's assets and templates).
  • The re-export lists the two items explicitly instead of using pub use crate::settings::*. A glob would put everything back behind the generator-owned path and make the boundary meaningless.
  • The previous config.rs moves to src/settings.rs unchanged apart from dropping the DO NOT EDIT header. Callers of anything beyond Config/OutputFormat now import from crate::settings. The ~140 existing crate::config::{Config, OutputFormat} imports are left alone because they go through the contract.
  • Split into two commits so git tracks the config.rs → settings.rs rename and git log --follow keeps working. The first commit doesn't build on its own; the second adds the shim.
  • No behavior change.

Tests

Appendix

  • Sequencing: the generator's config asset must be replaced with a byte-identical copy of this shim right after this merges. Until it is, a generated PR would overwrite the shim with the old 2,645-line asset and fail to compile because of duplicate definitions. Generated PRs are already broken today (opt downtime list into pup generation #908), so nothing working gets worse.
  • After the asset swap, opt downtime list into pup generation #908 should be regenerated rather than hand-edited.
  • Follow-up: a CI guard that fails hand-written PRs touching files with the Code generated by openapi-transformer header, unless a bypass label is set.

🤖 Generated with Claude Code

Rename src/config.rs to src/settings.rs so hand-maintained configuration
loading, precedence, and storage paths live in a module the generator
does not overwrite. Callers of anything beyond Config and OutputFormat
now import from crate::settings.

This commit does not build on its own: the generator-owned
crate::config contract is added in the next commit. It is split out so
git tracks the rename and history follows settings.rs.
openapi-transformer copies its config asset over src/config.rs on every
generation run, reverting hand-written changes. Make src/config.rs a
narrow generator-owned contract that re-exports only Config and
OutputFormat from crate::settings, mirroring the formatter/output split.

The re-export is explicit rather than a glob so the rest of settings
stays out of the generator-owned path.
@MintsInc
MintsInc marked this pull request as ready for review October 14, 2026 13:07
@MintsInc
MintsInc requested a review from a team as a code owner October 14, 2026 13:07

@datadog-datadog-prod-us1 datadog-datadog-prod-us1 Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bits Code Review: PASS

More details

The existing configuration implementation is preserved, helper callers use settings, and both CLI and browser entry points declare the new module. The completed static review found no reportable regression in the Config and OutputFormat contract.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit f8daf4d

@MintsInc
MintsInc merged commit 62c36bc into main Oct 15, 2026
11 checks passed
@MintsInc
MintsInc deleted the ulysse.mavrocordatos/split-config-contract branch October 15, 2026 07:30
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.

2 participants