Skip to content

fix(inventory): a padded version name stops at the last that keeps its zero - #13

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-a-padded-object-commits-past-its-width
Nov 11, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-a-padded-object-commits-past-its-width

Conversation

@adammharris

Copy link
Copy Markdown
Member

Closes the task A padded object commits a version past its width, which this branch marks done.

What changed

  • VersionNum::next (mocfl/src/inventory.rs) refused a padded successor only when its digits outran the whole width, so v01 counted on to v99 and v0999 to v1000. A padded name has to keep its leading zero: OCFL's own example allows v00001 to v09999 and not v10000. next now refuses the successor of v09, v0999 and every padded name whose successor would fill the width, with the same Error::Conflict it already used for overflow. Its doc comment now gives the right ceiling.
  • validate (mocfl/src/validate.rs) has a new Violation::VersionNamesDiffer (summary key version-names-differ). It reports every version whose name doesn't follow the convention the first version sets (unpadded, or padded to one width) (E011, E012, E013). So v10 among v01 … v09, or v2 after v01, is no longer called clean.

Why

mocfl pads only what it opens, so this only bites on an object another tool wrote with padded names. That object's next commit, once it reached its last name, landed beside the padded ones under a second naming convention, and validate and validate_deep both called the result clean.

Behavioural change

Committing onto a padded object at its last name (v09, v0999, …) now fails with Error::Conflict and writes nothing, where it used to write v10 or v1000. validate now reports mixed version names. Both are recorded in the commit's Behavioural-change: trailer.

Verified

  • Tests first: the rewritten ceiling test in inventory.rs and the new a_padded_object_at_its_last_name_commits_no_further both failed on main (v01 counted to v99, and the tenth commit returned Ok(v10)). Both pass with the fix.
  • New tests: a padded object validates clean; mixed names (v01, v2) give exactly one VersionNamesDiffer; tests/fixtures.rs checks that E011_E013_invalid_padded_head_version (v01 … v09, v10) is reported for its names, in both spec versions. On main that fixture was only caught because of an unrelated disagreement in its v08 inventory.
  • CI's test job run locally: cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo test --all-targets with OCFL_FIXTURES pointing at a fresh clone of OCFL/fixtures, and cargo test --doc. All green. The msrv job (cargo +1.88 check --all-targets) passes too.
  • I didn't run the interop job locally because rocfl isn't installed on this machine. The objects it emits are unpadded, which this change doesn't touch.

…s zero

VersionNum::next refused a padded successor only once its digits outran the
whole width, so v01 counted on to v99 and v0999 to v1000. A padded name keeps
its leading zero, so those successors drop it, read back unpadded, and leave
the object under two naming conventions (OCFL E011, E012, E013). next now
refuses the successor of v09, v0999 and every padded name whose successor
would fill the width, with Error::Conflict as before.

validate reports the same thing from the other side: a new
Violation::VersionNamesDiffer for every version not named the way the first
is, so v10 among v01 … v09 is no longer called clean.

Behavioural-change: committing onto a zero-padded object at its last name that keeps the leading zero (v09, v0999, …) now fails with Error::Conflict instead of writing v10 or v1000, and validate reports an object whose version names mix conventions as VersionNamesDiffer.
@adammharris
adammharris merged commit 785da7e into main Nov 11, 2026
3 checks passed
@adammharris
adammharris deleted the agent/backlog-a-padded-object-commits-past-its-width branch November 11, 2026 17:02
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.

1 participant