Skip to content

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++

bench tests: no real GPU in the telemetry fixture (its first reading raced the second run), Windows ACL check for the job receipt, lease marker size on Windows; private_files.is_unshared

Niko122118bb5b793bcc
diff --git a/strata_control/private_files.py b/strata_control/private_files.py
index 6ec8f5c10..5d2f02206 100644
--- a/strata_control/private_files.py
+++ b/strata_control/private_files.py
@@ -154,3 +154,25 @@ def is_private(path: str | os.PathLike) -> bool:
return False
fields = entries[0].split(";")
return len(fields) >= 6 and fields[0] == "A" and fields[5] == current_user_sid()
+
+
+_PRIVILEGED = {"SY", "BA", "OW", "CO", "CG", "S-1-5-18", "S-1-5-32-544", "S-1-3-4"}
+
+
+def is_unshared(path: str | os.PathLike) -> bool:
+ """True when nobody but this user, SYSTEM and the administrators can reach ``path``.
+
+ The relaxed form of :func:`is_private`, for files created under the user's profile where the
+ inherited ACL already shuts out other accounts: any allow entry for Everyone, Users,
+ Authenticated Users or another account makes it False. POSIX is the same check as
+ :func:`is_private`.
+ """
+ if not WINDOWS:
+ return is_private(path)
+ sddl = dacl_sddl(path)
+ allowed = _PRIVILEGED | {current_user_sid()}
+ for entry in re.findall(r"\(([^()]*)\)", sddl):
+ fields = entry.split(";")
+ if len(fields) >= 6 and fields[0] in ("A", "OA") and fields[5] not in allowed:
+ return False
+ return True
diff --git a/tests/terminal/test_bench.py b/tests/terminal/test_bench.py
index b4e4f9767..8bf30494c 100644
--- a/tests/terminal/test_bench.py
+++ b/tests/terminal/test_bench.py
@@ -21,14 +21,33 @@ from strata_cli import bench
from strata_cli.cli import main
from strata_cli.client import Endpoint
from strata_control import benchmarking, journal, management
+from strata_control.private_files import is_unshared
from strata_control.profiles import ProfileError
+class _NoGpu:
+ note = None
+
+ def ok(self):
+ return False
+
+ def name(self):
+ return None
+
+ def read(self):
+ return {}
+
+
class BenchTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
+ # The telemetry sampler reads the machine's real GPU on a timer; a card's first reading lands
+ # between two benchmark runs and makes their reported environments differ. Use no GPU.
+ patcher = mock.patch("serve.telemetry.gpu_reader", lambda index=0, amd=False: _NoGpu())
+ patcher.start()
+ self.addCleanup(patcher.stop)
tok = ByteTokenizer()
service = Service(MockEngine(tok, "Benchmark mock answer.", max_context=4096), tok,
ChatTemplate(Path(__file__).resolve().parents[2] / "serve/chat_template.jinja"))
@@ -107,8 +126,13 @@ class BenchTests(unittest.TestCase):
self.assertEqual(benchmarking.benchmark_activity("local", output), "active")
self.assertEqual(benchmarking.benchmark_activity("local", self.root / "other-run"),
"other_active")
- raw = (self.root / "profiles" / ".bench-local.lock").read_bytes()
- self.assertNotIn(os.fsencode(str(output)), raw)
+ 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())
with self.assertRaisesRegex(ProfileError, "another benchmark is running"):
with benchmarking.benchmark_lease("local"):
self.fail("overlapping benchmark lease was accepted")
@@ -220,8 +244,11 @@ class BenchTests(unittest.TestCase):
self.assertEqual(recovered["result"]["run_id"], bench.load(output)["run_id"])
self.assertEqual(recovered["progress"]["state"], "report_saved")
self.assertEqual(journal.load("local", job_id)["state"], "succeeded")
- self.assertEqual(stat.S_IMODE((self.root / "profiles" / ".ops" / "local" /
- ".runs" / f"{job_id}.json").stat().st_mode), 0o600)
+ receipt = self.root / "profiles" / ".ops" / "local" / ".runs" / f"{job_id}.json"
+ if os.name == "nt":
+ self.assertTrue(is_unshared(receipt)) # NTFS has no mode bits: assert the effective ACL
+ else:
+ self.assertEqual(stat.S_IMODE(receipt.stat().st_mode), 0o600)
failed_path = self.root / "failed-job"
failed_params = {**params, "path": str(failed_path)}
diff --git a/tests/terminal/test_private_files.py b/tests/terminal/test_private_files.py
index 3a908858d..8e4aa8b87 100644
--- a/tests/terminal/test_private_files.py
+++ b/tests/terminal/test_private_files.py
@@ -67,6 +67,21 @@ class PrivateFileTests(unittest.TestCase):
for sid in ("WD", "BU", "AU", "SY", "BA", "S-1-1-0", "S-1-5-32-545"):
self.assertNotIn(f";;;{sid})", sddl)
+ def test_a_file_made_in_the_profile_is_unshared_but_not_strictly_private(self):
+ path = self.root / "inherited.json"
+ path.write_text("{}")
+ self.assertTrue(pf.is_unshared(path))
+ if pf.WINDOWS:
+ self.assertFalse(pf.is_private(path)) # SYSTEM and Administrators still inherit
+
+ @unittest.skipUnless(pf.WINDOWS, "NTFS ACLs")
+ def test_everyone_is_noticed_by_the_relaxed_check_too(self):
+ import subprocess
+ path = self.root / "shared.json"
+ path.write_text("{}")
+ subprocess.run(["icacls", str(path), "/grant", "*S-1-1-0:R"], check=True, capture_output=True)
+ self.assertFalse(pf.is_unshared(path))
+
@unittest.skipUnless(pf.WINDOWS, "NTFS ACLs")
def test_widening_the_acl_is_noticed(self):
path = self.root / "key.json"