Skip to content

[codex] Introduce config generation storage#39

Merged
Pectics merged 1 commit into
mainfrom
codex/issue-3-config-generations
Jun 24, 2026
Merged

[codex] Introduce config generation storage#39
Pectics merged 1 commit into
mainfrom
codex/issue-3-config-generations

Conversation

@Pectics

@Pectics Pectics commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • add config generation storage for source, overlay, candidate, active, last-good, and compat config paths
  • render Mihomo overrides from source into candidate without mutating source.yaml
  • route init, update --config, and apply through candidate activation while preserving config.yaml as the runtime entrypoint
  • document the generated config files

Closes #3

Verification

  • cargo fmt --all -- --check
  • cargo check --all-targets
  • cargo clippy
  • cargo test

Add source, overlay, candidate, active, last-good, and compatibility config paths for Mihomo config rendering.

Wire init, update, and apply flows through candidate rendering while preserving config.yaml as the runtime entrypoint.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Copilot AI review requested due to automatic review settings June 24, 2026 12:13
@Pectics Pectics merged this pull request into main Jun 24, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

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 introduces a config “generation store” to persist multiple Mihomo config generations (source/overlay/candidate/active/last-good/compat), and routes existing flows (init/update/apply) through candidate rendering + activation so overrides can be applied without mutating the raw subscription config.

Changes:

  • Add ConfigGenerationStore with well-defined generation paths and seed/activate behaviors.
  • Switch ensure_remote_config, update_config, and apply to render candidate.yaml (plus overlay.yaml) and then activate to active.yaml and runtime config.yaml.
  • Update tests and README to reflect the new on-disk config state and behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/mihoro.rs Routes config flows through generation seeding, candidate rendering, and activation.
src/main.rs Registers the new config_store module.
src/config.rs Splits override logic into overlay rendering and source→output override rendering.
src/config_store.rs New generation store managing paths, seeding from legacy config.yaml, and candidate activation with last-good backups.
README.md Documents generated config files and runtime config.yaml compatibility.

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

Comment thread src/config.rs
Comment on lines +318 to +324
if let Ok(existing) = fs::read_to_string(path) {
let existing_value: serde_yaml::Value = serde_yaml::from_str(&existing)?;
let overlay_value: serde_yaml::Value = serde_yaml::from_str(&serialized_overlay)?;
if existing_value == overlay_value {
return Ok(false);
}
}
Comment thread src/config.rs
Comment on lines +359 to 365
if let Ok(current_output) = fs::read_to_string(output_path) {
let raw_value: serde_yaml::Value = serde_yaml::from_str(&current_output)?;
let serialized_value: serde_yaml::Value = serde_yaml::from_str(&serialized_mihomo_yaml)?;
if raw_value == serialized_value {
return Ok(false);
}
}
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.

Introduce source, candidate, active and last-good config generations

2 participants