Skip to content

feat(config): default the schema version when omitted - #69

Open
srnnkls wants to merge 1 commit into
feat/history-overlayfrom
feat/optional-config-version
Open

feat(config): default the schema version when omitted#69
srnnkls wants to merge 1 commit into
feat/history-overlayfrom
feat/optional-config-version

Conversation

@srnnkls

@srnnkls srnnkls commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Stacked on #68 (feat/history-overlay).

version becomes optional in phora.toml / phora.local.toml. 1 is the only schema version, so an omitted key defaults to it; explicit version = 1 parses exactly as before.

The README self-contained-fence invariant keyed off a leading version = 1 line 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 add still scaffolds a new config with version = 1; nothing writes fewer keys, only the parser accepts more.

Verified: 2142 tests pass, cargo clippy --all-targets -- -D warnings clean, cargo fmt --check clean.

@srnnkls
srnnkls marked this pull request as ready for review September 1, 2026 09:47
Copilot AI lite review requested due to automatic review settings September 1, 2026 09:47

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.

🟡 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.version to schema version 1 when omitted (and add a regression test).
  • Update README and phora.example.toml to document version = 1 as 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 thread src/config/mod.rs
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 thread tests/doc_invariants.rs
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
srnnkls force-pushed the feat/optional-config-version branch from 07fc424 to 5584552 Compare September 1, 2026 10:05
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