Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions crates/provui-core/src/config_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ pub fn config_rules(config: &WorkspaceConfig) -> Vec<FieldRule> {
// Closed: every prov build reads all four, so a spelling outside them
// is one prov rejects. `figl` is fig's name for its own dialect, and
// the spelling prov writes back.
//
// Neither axis rewrites anything on Apply. prov's rule for a config
// axis is that it governs what is written next (and `prov new` gives a
// child its parent's carrier before the default), while a document
// keeps its spelling until `prov convert` restates it. A mixed
// workspace is valid and `check`-clean, and the sentence says so.
costly(
choice(
path(&["metadata", "format"]),
Expand All @@ -119,7 +125,9 @@ pub fn config_rules(config: &WorkspaceConfig) -> Vec<FieldRule> {
],
),
Tint::Warning,
"Rewrites the metadata of every document in the workspace.",
"Applies to metadata written from now on: a new document takes its \
parent's format. Existing documents keep theirs until converted \
with `prov convert <root> metadata.format <value> -r`.",
),
costly(
choice(
Expand All @@ -132,7 +140,9 @@ pub fn config_rules(config: &WorkspaceConfig) -> Vec<FieldRule> {
],
),
Tint::Warning,
"Rewrites the metadata of every document in the workspace.",
"Applies to metadata written from now on: a new document takes its \
parent's shape. Existing documents keep theirs until converted \
with `prov convert <root> metadata.embed <value> -r`.",
),
];

Expand Down Expand Up @@ -579,6 +589,41 @@ mod costly_tests {
}
}

/// The metadata axes say what applying them does, which is prov's rule for
/// any config axis: the setting governs what is written next, and a
/// document keeps its spelling until `prov convert` restates it. Nothing on
/// Apply runs that conversion, so a sentence promising a rewrite of every
/// document is one the reader learns to click through.
#[test]
fn a_metadata_axis_says_it_governs_what_is_written_next() {
let schema = schema();
for axis in ["format", "embed"] {
let path = [key("metadata"), key(axis)];
let (_, why) = warned(&path).unwrap_or_else(|| panic!("metadata.{axis} should warn"));
assert!(
!why.contains("Rewrites"),
"metadata.{axis} claims a rewrite nothing performs: {why}"
);
assert!(
why.contains("Existing documents keep"),
"metadata.{axis} does not say existing documents are left alone: {why}"
);
let command = format!("prov convert <root> metadata.{axis} <value> -r");
assert!(
why.contains(&command),
"metadata.{axis} does not name the conversion `{command}`: {why}"
);
// Apply reads the consequence, not the row: it has to say the same.
let rule = schema.rule_for(&path).expect("rule");
let consequence = rule
.on_change
.iter()
.map(|c| c.message.as_str())
.collect::<Vec<_>>();
assert_eq!(consequence, [why.as_str()], "metadata.{axis}");
}
}

/// A field costly in one direction only warns on that direction and stays
/// quiet on the other.
///
Expand Down
3 changes: 2 additions & 1 deletion crates/provui-core/src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ pub fn open_choice_terms(at: PathPat, title: &str, icon: Icon, values: Vec<Term>
/// Mark a rule as one where *every* answer costs the same thing.
///
/// For the axes with no safe direction: whichever value you land on, the
/// workspace gets rewritten. The tint is what draws the row; the
/// change has the same effect, and `why` says what it is. The tint is what
/// draws the row; the
/// [`Consequence`] is what Apply reads before carrying the change out.
///
/// Both, not either — they answer different questions. The tint says how
Expand Down
13 changes: 11 additions & 2 deletions docs/tasks/metadata-axes-claim-a-rewrite.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
---
title: 'The metadata axes say they rewrite every document, and nothing does'
part_of: '[Tasks](/docs/tasks/tasks.md)'
status: open
status: done
author: adammharris
created: 2026-09-20
updated: 2026-09-20
updated: 2026-10-20
---

# The metadata axes say they rewrite every document, and nothing does

**Status.** Done, by the first of the two choices: both consequences now say
what applying the change does. Metadata written from now on takes the new
setting, a new document takes its parent's carrier, and existing documents
keep theirs until `prov convert <root> metadata.<axis> <value> -r`. The tint
and `Confirm` weight are unchanged. `a_metadata_axis_says_it_governs_what_is_written_next`
holds the sentence to that, on the row and on the consequence Apply reads.
The reference axes' "Rewrites every link" sentences fail the same check
and are not changed here.

## The problem

`config_schema.rs` marks `metadata.format` and `metadata.embed` as `costly`,
Expand Down
Loading