Skip to content

tools/test-run.sh's per-worktree lock has no cooperative entry point, so format-sweep.sh reverse-engineers its internals (fd flock, owner files) and will drift with them #671

Description

@lukstafi

What the work ran into

ocannl-staging#385 added tools/format-sweep.sh, which must never rewrite sources under a live dune run. The only mutual-exclusion primitive available was test-run.sh's per-worktree lock, and participating in it from outside took four review rounds of successively deeper coupling to test-run's INTERNALS:

  • probing the flock the way its private lock_held does (round 3);
  • holding the lock across rewrites via the exec-then-flock(STDIN) fd-inheritance pattern copied from take_lock (round 7);
  • clearing .test-run.lock.owner/.launcher under the held flock, because otherwise test-run's own 'stop' attributes the held lock to a finished run and TERMs its recorded process group — which the sweep shares (round 11);
  • making the blocking wait interruptible and bounding it just above test-run's cap (round 12).

Every one of these re-implements or pokes an implementation detail that test-run.sh is free to change; nothing fails at that point except the sweep, at 6am, unattended.

Why it is worth fixing

The lock protocol is now load-bearing for two tools with only convention keeping them compatible. Any third tool that must not race dune (a future benchmark runner, a promotion helper) faces the same reverse-engineering.

What a fix would touch

tools/test-run.sh: expose a small cooperative surface — e.g. 'test-run.sh with-lock [--wait BOUND] <cmd...>' that takes the worktree lock with ownership metadata published correctly, runs the command, and releases; plus a documented 'lock-status' probe. tools/format-sweep.sh then shrinks by the whole hold_test_run_lock/owner-clearing apparatus, and the coupling becomes an interface instead of shared folklore.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions