Skip to content

The differential oracle covers one file and no namespace operation, so rename has no oracle #566

Open

Description

@scttfrdmn

The gap

internal/difftest is the project's best test asset — one operation sequence run against ObjectFS and
against the local OS filesystem, asserting they agree. CLAUDE.md names it as the thing to prefer over
a mock, and the reasoning is right: a mock on the far side of a seam agrees with its caller by
construction.

But its vocabulary is six operations on one file, and the filename is a constant:

// internal/difftest/program.go
OpWrite OpKind = iota
OpRead
OpTruncate
OpFlush
OpReopen
OpStat
// internal/difftest/fs.go:75
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
//                    ^ "there is no caller-controlled component in the path"

So the oracle covers the single-file data path — offsets, extents, read-modify-write, durability
across reopen — and covers it well. It covers no namespace operation at all:

Operation Oracle
rename none
unlink none
mkdir / rmdir none
readdir none
link count / multiple files interacting none

Why this is the gap worth closing

rename is the operation README's contract flags as not atomic, with a documented three-way
outcome on interruption (data at the old name, the new name, or both — deliberately never neither).
That is a subtle, stateful, ordering-sensitive guarantee, and the only thing checking it is
hand-written tests that assert what their author expected to happen.

A differential oracle is exactly the instrument for it, because the local filesystem is a reference
implementation of the parts that should agree — a rename's effect on readdir, on a subsequent
stat of both names, on an open handle to the source — and the places it legitimately cannot agree
(atomicity) are then an explicit, enumerated allowance rather than an untested assumption.

The same argument applies to unlink while a handle is open, and to rmdir on a prefix that exists
only because objects share it — a concept the local filesystem has no equivalent for, which is
precisely the interesting part.

Shape of the work

This is a real extension, not a parameter change. Sketch, in the order that keeps each step
verifiable:

  1. Widen FS from one open file to a namespace: Create(name), Open(name), Unlink(name),
    Rename(from, to), Mkdir, Rmdir, ReadDir. Keep the existing single-file ops addressed to a
    named handle.
  2. Generate names from a small alphabet. A fuzzer that invents arbitrary strings will spend its
    budget on encoding questions rather than on ordering; a handful of names is what produces
    collisions, and collisions are where the bugs are.
  3. Enumerate the legitimate divergences explicitly, with a comment per entry saying why. Rename
    atomicity is one. A directory that exists only as a shared prefix is another — mkdir a/b/c
    followed by rmdir a/b/c leaves different state on the two sides, and that difference is correct.
    An allowance without a stated reason is how an oracle gets quietly weakened until it agrees with
    whatever the code does.
  4. Extend shrink.go so a namespace counterexample minimizes. A 40-operation divergence nobody
    can read is a bug report nobody acts on.
  5. Add the target to the fuzz matrix — and see the completeness test proposed in 12 of the 22 fuzz targets are never fuzzed by CI, including the one that decides whether checksums are verified #565.

Acceptance criteria

  • difftest programs can address more than one file, by name
  • rename, unlink, mkdir, rmdir and readdir are in the operation vocabulary
  • Every permitted divergence is enumerated with a stated reason, not a blanket tolerance
  • Counterexamples shrink
  • Mutation-verified: break rename's copy-before-delete ordering and confirm a named test fails
  • Any divergence found is either fixed or documented in README's contract table

Activity

  1. added
    type: testing
    priority: high
    area: core
    area: tests
    effort: large
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: corearea: testseffort: largepriority: hightype: testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions