Skip to content

A Gen.Const base holding a MockFileSystem is shared and mutable across counter-examples #46

Open

Description

@Mpdreamz

A Gen.Const base that holds a MockFileSystem is shared and mutable. Counter-examples that add files to it race each other, and one that edits a file in place makes other checks fail now and then.

What happened

  • A race. A counter-example adds a symbolic link to the base value's MockFileSystem. Laws apply a counter-example to a base more than once, and the Invariant and Vacancy cases run at the same time in TUnit, so the second CreateSymbolicLink threw "The file 'path' already exists". It failed about one run in four.
  • Edits that persist. A counter-example that grows the base's own file (GetFile(...).Contents = ...) left the base invalid for the checks that ran after it. They failed intermittently, naming rules the counter-example was not about.

What would you like instead

Clone the base's file system per counter-example application, or document that a counter-example must not change the world it was given. The second is the cheap one; the first removes the trap.

Workaround

A helper that adds each file once, under a lock on the file system, and never edits an existing one.

Version or commit

main at f12a258 (0.1.1).

Estimated work: an hour for the docs; a day to clone worlds.

Activity

  1. Mpdreamz commented on Nov 19, 2026

    @Mpdreamz
    ContributorAuthor

    Reproduced and fixed in #103.

    Invariant and Vacancy running at once on a Gen.Const base failed with IOException: The file 'path' already exists. Two causes: FileWorld's name counter was a plain Value++ with unlocked file-system edits, so the library's own edge files could collide, and a counter-example given to AutoTest was applied once per axis to the same base.

    The counter is now atomic, FileWorld draws lock the file system, and a given counter-example runs once per base under a lock, with later axes reusing the result. I did not clone the file system (the day-sized option): a counter-example that edits the base's own file still changes it, so the README says to add files instead. The regression test failed before the fix and passes after, on net10.0 and net11.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

    bugA defect fixed (patch)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions