feat(config): default the schema version when omitted - #69
Open
srnnkls wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The config schema version is now documented as fixed but is not enforced (unsupported versions can still parse), and the updated README fence detection should trim indentation to avoid missing valid fences.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR makes version optional in phora.toml / phora.local.toml by defaulting it to schema version 1, and updates documentation/tests so README and example configs remain valid without requiring a leading version = 1.
Changes:
- Default
Config.versionto schema version 1 when omitted (and add a regression test). - Update README and
phora.example.tomlto documentversion = 1as optional. - Update README doc-invariant selection logic to detect “self-contained” config fences based on
[sources.<s>]+[targets.<t>]tables.
File summaries
| File | Description |
|---|---|
| tests/doc_invariants.rs | Updates README fence selection heuristic for “self-contained” config examples. |
| src/config/tests.rs | Adds test ensuring configs parse when version is omitted. |
| src/config/mod.rs | Introduces SCHEMA_VERSION and defaults Config.version via serde. |
| README.md | Documents version = 1 as optional in the configuration example. |
| phora.example.toml | Comments out version = 1 to demonstrate omission/default behavior. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+60
to
71
| /// The only schema version phora speaks; omitting `version` selects it. | ||
| pub const SCHEMA_VERSION: u32 = 1; | ||
|
|
||
| const fn default_schema_version() -> u32 { | ||
| SCHEMA_VERSION | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct Config { | ||
| #[serde(default = "default_schema_version")] | ||
| pub version: u32, |
Comment on lines
+156
to
+160
| .filter(|block| { | ||
| let lines: Vec<&str> = block.lines().collect(); | ||
| lines.iter().any(|line| line.starts_with("[sources.")) | ||
| && lines.iter().any(|line| line.starts_with("[targets.")) | ||
| }) |
`version` is now optional in phora.toml and phora.local.toml; 1 is the only schema version and serves as the default. Explicit `version = 1` keeps parsing unchanged. The README self-contained-fence invariant selected blocks by their leading `version = 1` line; it now selects any fence declaring both a [sources.<s>] and a [targets.<t>] table, which is what "self-contained" actually means.
srnnkls
force-pushed
the
feat/optional-config-version
branch
from
September 1, 2026 10:05
07fc424 to
5584552
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #68 (
feat/history-overlay).versionbecomes optional inphora.toml/phora.local.toml. 1 is the only schema version, so an omitted key defaults to it; explicitversion = 1parses exactly as before.The README self-contained-fence invariant keyed off a leading
version = 1line to decide which fences are complete configs. It now selects fences declaring both a[sources.<s>]and a[targets.<t>]table — the actual definition — and every fence it now picks up parses and validates.phora addstill scaffolds a new config withversion = 1; nothing writes fewer keys, only the parser accepts more.Verified: 2142 tests pass,
cargo clippy --all-targets -- -D warningsclean,cargo fmt --checkclean.