Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
control: Windows leases lock a byte past the marker so another process can still read the holder (benchmark and calibration worker leases; msvcrt locks are mandatory)
Niko1221a0bd7b25ea5f
diff --git a/strata_control/benchmarking.py b/strata_control/benchmarking.pyindex a63dbdfc0..4fb73ffa8 100644--- a/strata_control/benchmarking.py+++ b/strata_control/benchmarking.py@@ -18,6 +18,10 @@ from strata_control import journal, profiles, runtimefrom strata_control.profiles import ProfileError+#: Windows byte-range locks are mandatory: a locked byte cannot be read through any other handle. The lock+#: therefore sits far past the marker bytes, so another process can still read who holds the lease.+WINDOWS_LOCK_OFFSET = 1 << 16+def _lease_file(profile: str, *, create: bool) -> Path | None:if not profiles.PROFILE_ID.fullmatch(profile):raise ProfileError("benchmark lease needs a saved profile")@@ -52,7 +56,7 @@ def _lock(descriptor: int, *, initialize: bool = False) -> None:os.write(descriptor, b"0")if os.name == "nt":import msvcrt- os.lseek(descriptor, 0, os.SEEK_SET)+ os.lseek(descriptor, WINDOWS_LOCK_OFFSET, os.SEEK_SET)msvcrt.locking(descriptor, msvcrt.LK_NBLCK, 1)else:import fcntl@@ -62,7 +66,7 @@ def _lock(descriptor: int, *, initialize: bool = False) -> None:def _unlock(descriptor: int) -> None:if os.name == "nt":import msvcrt- os.lseek(descriptor, 0, os.SEEK_SET)+ os.lseek(descriptor, WINDOWS_LOCK_OFFSET, os.SEEK_SET)msvcrt.locking(descriptor, msvcrt.LK_UNLCK, 1)else:import fcntldiff --git a/strata_control/calibration_jobs.py b/strata_control/calibration_jobs.pyindex 31153bce8..2f03541c8 100644--- a/strata_control/calibration_jobs.py+++ b/strata_control/calibration_jobs.py@@ -22,6 +22,10 @@ STAGES = frozenset({"preflight", "loading", "pcie_share", "draft_floor", "confir"cpu_workers", "expert_tier", "saving_report"})+#: Windows byte-range locks are mandatory: a locked byte cannot be read through any other handle. The lock+#: therefore sits far past the marker bytes, so another process can still read who holds the lease.+WINDOWS_LOCK_OFFSET = 1 << 16+def _directory(profile: str) -> Path:return journal._directory(profile, create=True)@@ -48,7 +52,7 @@ def _open_lease(profile: str, *, create: bool) -> int | None:def _try_lock(descriptor: int) -> None:if os.name == "nt":import msvcrt- os.lseek(descriptor, 0, os.SEEK_SET)+ os.lseek(descriptor, WINDOWS_LOCK_OFFSET, os.SEEK_SET)msvcrt.locking(descriptor, msvcrt.LK_NBLCK, 1)else:import fcntl@@ -58,7 +62,7 @@ def _try_lock(descriptor: int) -> None:def _unlock(descriptor: int) -> None:if os.name == "nt":import msvcrt- os.lseek(descriptor, 0, os.SEEK_SET)+ os.lseek(descriptor, WINDOWS_LOCK_OFFSET, os.SEEK_SET)msvcrt.locking(descriptor, msvcrt.LK_UNLCK, 1)else:import fcntldiff --git a/tests/terminal/test_bench.py b/tests/terminal/test_bench.pyindex 8bf30494c..962d85d0b 100644--- a/tests/terminal/test_bench.py+++ b/tests/terminal/test_bench.py@@ -126,13 +126,8 @@ class BenchTests(unittest.TestCase):self.assertEqual(benchmarking.benchmark_activity("local", output), "active")self.assertEqual(benchmarking.benchmark_activity("local", self.root / "other-run"),"other_active")- lock_file = self.root / "profiles" / ".bench-local.lock"- if os.name == "nt":- # msvcrt.locking is mandatory: the locked byte cannot be read while the lease is- # held, so only the file's size can be checked (it is a single marker byte).- self.assertLessEqual(lock_file.stat().st_size, 65)- else:- self.assertNotIn(os.fsencode(str(output)), lock_file.read_bytes())+ raw = (self.root / "profiles" / ".bench-local.lock").read_bytes()+ self.assertNotIn(os.fsencode(str(output)), raw)with self.assertRaisesRegex(ProfileError, "another benchmark is running"):with benchmarking.benchmark_lease("local"):self.fail("overlapping benchmark lease was accepted")