Skip to content

accept-lib's tree-snapshot test fails on Linux ext4, where a directory's mtime often doesn't advance #595

Done

Description

@SSFSKIM

The test: test/accept-lib.test.mjs L169–184, "a tree snapshot notices added, removed and rewritten entries, and an untouched tree compares equal".

The failure as seen: diff.changed comes back ['a/b/file'], but the test expects ['a', 'a/b/file']. The entry missing is the directory a, whose mtime should move when the test adds a/new.

actual: [ 'a/b/file' ],
expected: [ 'a', 'a/b/file' ],

How often:

Cause (diagnosed): the test assumes the directory's mtimeMs advances when an entry is added right after the previous one, and ext4 doesn't guarantee that. The kernel stamps file times from a coarse clock that ticks once per jiffy. A probe on the same host created a directory, a link in it, and then a file right after: the directory's mtime was unchanged in 192 of 200 tries. The test passes only when a tick happens to pass between the link (L175) and the add (L180).

Ruled out:

  • M6b's code: scripts/accept/lib.mjs's snapshotTree predates M6b, and M6b doesn't touch the file.
  • A false green in the judges that use it (acceptance 12's and 13's tree checks, U2's in particular). An added entry is detected by its own key (diff.added), and a rewritten file by its own size, mtime and inode. Only the parent directory's mtime is timing-dependent, and no judge relies on the parent alone to see an add.
  • macOS: APFS keeps nanosecond times, so the test passes there. The hosted-macOS shards don't hit it; local npm test on Linux and any Linux runner do.

Fix, test-only: before the first snapshot, set a's times to a fixed past value with utimesSync(join(s.dir, 'a'), 1, 1), as the test already does for the file at L179. The add then has to move it.

Proof: red first. A loop running the test alone 12 times on ext4 fails about 8 of 12 before the fix and passes 12 of 12 after.

Activity

  1. added
    bug
    status:ready-for-implementer
    priority:P3
    on Nov 27, 2026
  2. added a commit that references this issue on Nov 27, 2026
  3. removed
    status:ready-for-implementer
    on Nov 27, 2026
  4. SSFSKIM commented on Nov 27, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: Landed via PR #596 (test-only, cua 0.30.0)

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

    bugpriority:P3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions