Skip to content

fix(validate): read each version directory's inventory - #8

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-validate-never-reads-a-version-inventory
Nov 6, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-validate-never-reads-a-version-inventory

Conversation

@adammharris

Copy link
Copy Markdown
Member

What changed

validate and validate_deep now read the inventory in every version directory that holds one, and report:

  • a sidecar that is missing or disagrees with its inventory (VersionSidecarMissing, VersionSidecarMismatch)
  • an inventory that cannot be read or parsed (VersionInventoryUnreadable)
  • a head inventory that is not byte for byte the root's (HeadInventoryDiffers)
  • an id that differs from the root's (VersionIdDiffers)
  • a type older than the version before it (SpecVersionMovedBack)
  • a version block whose logical state differs from the root's (VersionStateDiffers), or that the root lacks (VersionUnknownToRoot)

Logical state is compared by digest and by content path. Where the digest algorithm changed, only the content paths are compared. An inventory's content paths for a logical path must all be listed for that path in the root, the rule ocfl-py applies.

A version directory with no inventory is still not a violation, since the spec has it as SHOULD. The root's sidecar check now shares a helper with the version directories.

Why

An object whose version inventories were corrupt, or disagreed with the root, got valid, and with --deep, content verified, where rocfl refuses it. "Not checked" read as "checked and fine".

Closes the task docs/tasks/validate-never-reads-a-version-inventory.md, marked done in this branch.

Behaviour

Objects that used to pass can now fail validate. This is recorded in the commit's Behavioural-change: trailer. The new Violation variants are additive, and the enum is #[non_exhaustive].

Verification

  • Tests were written first: ten new unit tests failed before the fix and pass after it.
  • The task's repro now exits 1 with three findings. The same object before the junk line exits 0.
  • objects_whose_version_inventories_disagree_are_caught in tests/fixtures.rs holds the task's eleven fixtures by name.
  • The fixtures count moves from 51 to 68 of 107, and the README says so. That is six more than the task's eleven: E011_E013_invalid_padded_head_version, E040_head_not_most_recent and E060_E064_root_inventory_digest_mismatch, in both spec versions. All three are bad objects, caught because they disagree with the root. Every good fixture still validates clean.
  • Every CI lane was run locally: cargo fmt --all --check, cargo clippy --all-targets -- -D warnings, cargo test --all-targets with OCFL_FIXTURES set, cargo test --doc, cargo +1.88 check --all-targets, and rocfl validate (1.7.0) on the interop object, which is valid with warnings.
  • The four table rows in the task are covered by unit tests against mocfl only. They were not re-run through rocfl.

validate read the root inventory and its sidecar and never opened
vN/inventory.json, so an object whose version inventories were corrupt or
disagreed with the root got the verdict a sound object gets.

Behavioural-change: validate and validate_deep report new Violation variants for objects they used to call valid: a version directory's sidecar missing or disagreeing, its inventory unreadable, a head inventory not identical to the root, an id that differs, a spec version moving back, and a version block that differs from the root's. An object with no inventory in a version directory still validates clean.
@adammharris
adammharris merged commit 9ea9b90 into main Nov 6, 2026
3 checks passed
@adammharris
adammharris deleted the agent/backlog-validate-never-reads-a-version-inventory branch November 6, 2026 17:01
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