Build1 distinct publisher3 min readUpdated
A dev.to post turns one atomic mkdir into a logged, self-healing lock for parallel agents. The mechanism holds up. The shipped defaults are the part to read closely.
The Engineer · Build desk
Compiled by The EngineerSomething wrong?How this is made
The sample log is the strongest evidence in the post, and also the most revealing. Eight agents, first acquire at 23:05:52Z, last release at 23:06:35Z, every hold either zero or one second [7]. That is a 43 second window in which the lock was actually held for seven seconds, about 16 per cent of the wall clock [14]. The gaps between one release and the next acquire run five to six seconds [7], which is shorter than the 15 second default poll interval [9], so whatever produced that log was not running the shipped defaults [15].
Run the defaults and the shape gets worse. A waiter that misses sleeps 15 seconds [9], so each handoff costs roughly seven and a half seconds on average, and the post's own guidance adds a one-off 60 second sleep for every agent that is not first in the batch [12]. For the twelve subagents the piece opens with [5], each holding the resource for a second, that works out at about 155 seconds of wall clock to buy 12 seconds of work at the resource [16]. This is not an argument against the lock. It is an argument for setting `--poll` to the length of the critical section, and for the instruction to release immediately after the last resource command rather than after the thinking and the file writes [12].
The 1800 second default timeout draws a harder line [9]. Queue twelve agents on one resource and the last one in line gives up unless every holder stays under about 164 seconds [17]. So the defaults encode an assumption that nobody states: small fleets, short sections. A dozen agents each driving a five minute job through this lock will simply shed its tail.
Stale breaking is where the design trades safety for liveness, and the trade is worth naming. The next agent removes a lock older than `--stale`, 600 seconds by default, logs the break and proceeds [8]. That test is the directory's age, not whether the holder is still alive, so a command that outruns ten minutes has its lock deleted underneath it and gains a co-tenant [18]. The break lands in the log [6], which is how you find out, afterwards.
What makes the primitive worth the trouble is the thing it does not do. There is no lock file content to write and then read back as two separate operations: `mkdir` either creates the directory or fails because it exists, and release is `rmdir` [2][3]. The failure the post is guarding against is the interleaved command corrupting another agent's work mid-flight with no record of who held the resource [5], and a filesystem primitive settles that without asking twelve prompts to be polite to each other. The startup check closes the adjacent hole: if the lock directory is missing or not writable, the script fails loudly at second zero rather than running as a mutex that never locks anything [11].
One caveat on sourcing. The portability claim, that this holds on macOS, Linux, WSL, the BSDs and a NAS in a cupboard, and that there is no NFS weirdness, is the author's own [13]. Zero dependencies beyond the Python 3 standard library [10] makes it cheap to test that claim yourself on whatever shared storage your fleet actually mounts, which is where an atomic-looking `mkdir` stops being atomic.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
The sample log shows agent-1 through agent-8 in 16 lines with no overlap: first acquire at 2026-08-22T23:05:52Z, last release at 2026-08-22T23:06:35Z, each hold zero or one second, and five to six seconds between a release and the next acquire.
A dev.to post headlined "Lock Folder Util - The Mutex Your Agent Swarm Desperately Needs" presents lock_folder_util.py, described as mutual exclusion for agents sharing one resource via an atomic mkdir.
The post states mkdir is atomic at the filesystem level: it either creates the directory or fails because it already exists, with no lock file content, and the lock is one empty directory.
Release is performed by rmdir on the lock directory (rmdir .tmp/lock.lock).
The run subcommand acquires, executes and releases "no matter what", invoked as ./lock_folder_util.py run --slug agent-7 -- your-command --with args.
The post opens with twelve subagents parallelised into the same shared resource, and lists the failure modes as multiple agents driving one shared resource, interleaved commands corrupting each other's work mid-flight, no audit trail of who held the resource and when, and a crashed agent leaving the resource locked forever or not locked at all.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Mechanism shown, envelope unverified
The core mechanism is fully exposed — two shell commands, a CLI synopsis, documented defaults, a sample log, a reproducible stress loop and a mechanical invariant checker — which is unusually concrete for a single post. But every artefact comes from one self-published source, the demo was run with non-default timings, and the portability and NFS assertions have no test output behind them.
Author-only
The supplied material shows exactly two adoption signals, both from the author: publication of the script and a single local eight-agent demo. There is no third-party deployment, download, star, fork or usage disclosure in the cluster.
Mechanism sound, framing overstated
The mkdir/rmdir mechanism does what the post says, so this is not a hollow claim. The overstatement sits in the framing: 'the mutex your agent swarm desperately needs', 'self-healing, zero babysitting' and 'no NFS weirdness' are presented as settled, while the shipped defaults imply heavy serialisation (about 16 per cent lock utilisation in the demo, roughly 155 seconds of wall clock for 12 seconds of twelve-agent work), the demo itself did not use those defaults, and the stale break can break mutual exclusion for critical sections longer than 600 seconds because it tests age rather than liveness.
Author promoting own utility
The single source is a developer-platform post by the utility's own author, written in promotional voice ('desperately needs', 'That's it. That's the lock.') with no independent review in the cluster. Mitigating the pull: the post ships the code, the exact defaults, a reproducible test loop and a checker that would surface overlaps, which is not the behaviour of a purely promotional piece. No vendor, funding or commercial relationship is disclosed in the supplied material.
Confident on mechanism, thin on practice
Confidence is high for what the post says and for arithmetic derived from its documented defaults and timestamps, because the primitives and numbers are explicit. It is low for real-world behaviour: one publisher, one author, one non-default demo run, no independent corroboration and no adoption data.
build
Invoked in three runs, executed in none: the cost rule that never got asked1 distinct publisher
build
The reason your agent gets worse after an hour is that nothing ever leaves the context window1 distinct publisher
build
Green is four claims wearing one badge, and nobody instruments the fourth1 distinct publisher
build
The kill switch that deletes your evidence is not a kill switch1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 22, 2026