Skip to content

Commit e7856a9

Browse files
committed
test: hold the lock and guard while release waits; scope the ADR release bound
The contended-release test now asserts that the lock and the externally held guard both stand while release waits, so a release that removed the guard would fail. ADR 0030 says the release bound covers waiting for the guard, not every unverified release.
1 parent ba51ec2 commit e7856a9

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎docs/adr/0030-process-lock-exclusion.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ is unsupported.
1010
- Publication, reclaim and release hold the same non-expiring mutation guard.
1111
- The guard covers only filesystem compare-and-mutate steps. Owner liveness is judged before
1212
the guard is taken; under it, a reclaim only confirms that the record it judged is unchanged.
13-
- Release waits a bounded time for a held guard. Only a guard still held after that bound makes
14-
the release unverified.
13+
- Release waits a bounded time for a held guard. A guard still held after that bound leaves the
14+
release unverified, as an unprovable owner record or a directory it cannot remove also does.
1515
- A claim identifies an acquisition; a PID alone cannot authorize release.
1616
- Unknown owners and abandoned guards remain retained. Age never proves abandonment.
1717
- Before upgrading, stop every legacy process using the shared state or cache paths. Keep

‎packages/host-kit/src/internal/process-lock.test.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,12 @@ test('release waits for a guard another process holds for a filesystem step', as
957957
timeoutMs: 0,
958958
});
959959
fs.writeFileSync(mutexPath, '');
960-
const guardReleased = setTimeout(() => fs.unlinkSync(mutexPath), 50);
961-
try {
962-
await acquisition.release();
963-
} finally {
964-
clearTimeout(guardReleased);
965-
}
960+
const releasing = acquisition.release();
961+
await new Promise((resolve) => setTimeout(resolve, 20));
962+
assert.equal(fs.existsSync(lockDirPath), true);
963+
assert.equal(fs.existsSync(mutexPath), true);
964+
fs.unlinkSync(mutexPath);
965+
await releasing;
966966

967967
assert.equal(fs.existsSync(lockDirPath), false);
968968
const next = tryAcquireProcessLock({ lockDirPath, owner: currentProcessOwner() });

0 commit comments

Comments
 (0)