Skip to content

fix(object): refuse a commit whose logical paths conflict - #6

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-fix-commit-accepts-conflicting-logical-paths
Nov 3, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-fix-commit-accepts-conflicting-logical-paths

Conversation

@adammharris

Copy link
Copy Markdown
Member

Closes the task Commit accepts logical paths that conflict, and marks it done in this branch.

What changed

  • Object::commit now checks a version's logical paths against each other after staging and before anything is written. A path given twice, or a path with another beneath it (a and a/b), returns Error::Conflict naming both paths. Paths that only start with the same string (a, a-b, ab) still commit.
  • validate and validate_deep report two new Violation variants for objects another tool wrote: LogicalPathConflict (a version's state) and ContentPathConflict (the manifest). summarize counts them as logical-path-conflict and content-path-conflict.
  • A crate-private helper, inventory::conflicting_paths, finds the conflicts for both callers.
  • README: the structural pass now detects 51 of the 107 bad-objects fixtures, up from 45, and "non-unique logical paths" comes off the list of gaps.

Why

Each of the task's three cases got through: a twice wrote one content path for two digests, so the first file's bytes were lost and only validate_deep noticed; a with a/b failed with Io(AlreadyExists) after writing v1/content/a; and the same pair across versions committed a state no filesystem can hold.

Behavioural change

  • commit refuses what it used to accept or half-write, including one path given twice with the same bytes, which it used to merge silently.
  • validate reports violations it used to miss. Violation is #[non_exhaustive], so the new variants do not break callers that match on it.

Verification

  • The three cases from the task are tests in mocfl/src/object.rs, plus one for paths that only share a leading string. Three tests in mocfl/src/validate.rs cover the new violations. All six failed before the fix.
  • 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 (every good object still validates clean), cargo test --doc, the interop emit test, and cargo +1.88 check --all-targets.
  • I did not run the rocfl validation step locally because rocfl is not installed on hbox. CI runs it. Nothing in this change alters the bytes the interop object is written with.

Object::commit checked each logical path on its own, so a path given twice,
or a path with another beneath it, got through: the first wrote one content
path for two digests, the second failed after writing part of a version, or
succeeded when the shorter path's bytes were already stored. commit now
checks the version's paths against each other before anything is written
and returns Error::Conflict naming both. validate reports the same
conflicts, as LogicalPathConflict for a version's state and
ContentPathConflict for the manifest, in an object another tool wrote; the
structural pass now catches 51 of the 107 bad-object fixtures, up from 45.

Behavioural-change: Object::commit returns Error::Conflict for a version that lists one logical path twice (even with the same bytes) or a path with another beneath it, where it used to accept or half-write it.
Behavioural-change: validate and validate_deep report LogicalPathConflict and ContentPathConflict, two new Violation variants, for inventories they used to pass.
@adammharris
adammharris merged commit 496bad2 into main Nov 3, 2026
3 checks passed
@adammharris
adammharris deleted the agent/backlog-fix-commit-accepts-conflicting-logical-paths branch November 3, 2026 04:40
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