From aee28993f52407ae221f02599492eb5b85a606a7 Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Sun, 10 May 2026 20:02:08 -0700 Subject: [PATCH] =?UTF-8?q?feat(system):=20fix=20spawn=20fcntl=20import=20?= =?UTF-8?q?for=20Windows=20=E2=80=94=20platform=20guard=20like=20trigger/w?= =?UTF-8?q?atchdog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: @devpulse --- src/aipass/spawn/apps/handlers/registry.py | 23 +++++++++++++------ .../builder/.spawn/.template_registry.json | 8 +++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/aipass/spawn/apps/handlers/registry.py b/src/aipass/spawn/apps/handlers/registry.py index 5e55edec..2d150283 100644 --- a/src/aipass/spawn/apps/handlers/registry.py +++ b/src/aipass/spawn/apps/handlers/registry.py @@ -8,8 +8,8 @@ """*_REGISTRY.json discovery and CRUD operations.""" -import fcntl import os +import sys from datetime import datetime from pathlib import Path @@ -179,8 +179,8 @@ def add_to_registry(registry_path, branch_name, branch_path, profile, email, pur """ Add a new branch entry to the registry. - Uses file locking (fcntl.LOCK_EX) around the entire read-modify-write - cycle to prevent corruption from concurrent spawns. + Uses file locking around the entire read-modify-write cycle to prevent + corruption from concurrent spawns. Skips locking on Windows. Args: registry_path: Path to AIPASS_REGISTRY.json @@ -201,10 +201,16 @@ def add_to_registry(registry_path, branch_name, branch_path, profile, email, pur lock_path = registry_path.parent / f".{registry_path.stem}.lock" lock_path.parent.mkdir(parents=True, exist_ok=True) - lock_fd = open(lock_path, "w", encoding="utf-8") # noqa: SIM115 - try: + + if sys.platform == "win32": + lock_fd = None + else: + import fcntl + + lock_fd = open(lock_path, "w", encoding="utf-8") # noqa: SIM115 fcntl.flock(lock_fd, fcntl.LOCK_EX) + try: registry = load_registry(registry_path) branches = registry.get("branches", []) @@ -239,8 +245,11 @@ def add_to_registry(registry_path, branch_name, branch_path, profile, email, pur return save_registry(registry_path, registry) finally: - fcntl.flock(lock_fd, fcntl.LOCK_UN) - lock_fd.close() + if lock_fd is not None: + import fcntl + + fcntl.flock(lock_fd, fcntl.LOCK_UN) + lock_fd.close() def fix_passport_registry_id(branch_dir: Path, registry_path: Path) -> bool: diff --git a/src/aipass/spawn/templates/builder/.spawn/.template_registry.json b/src/aipass/spawn/templates/builder/.spawn/.template_registry.json index e096093c..fc793adb 100644 --- a/src/aipass/spawn/templates/builder/.spawn/.template_registry.json +++ b/src/aipass/spawn/templates/builder/.spawn/.template_registry.json @@ -1,7 +1,7 @@ { "metadata": { "version": "1.0.0", - "last_updated": "2026-05-02", + "last_updated": "2026-05-10", "description": "Template file tracking registry for ID-based updates" }, "files": { @@ -155,7 +155,7 @@ "content_hash": "a4cf0a8e3b4f", "has_branch_placeholder": false }, - "f026": { + "f015": { "path": "apps/modules/__init__.py", "name": "__init__.py", "content_hash": "e3b0c44298fc", @@ -170,7 +170,7 @@ "f027": { "path": "apps/{{BRANCH}}.py", "name": "{{BRANCH}}.py", - "content_hash": "39db2c4f8160", + "content_hash": "024209a8c889", "has_branch_placeholder": true }, "f028": { @@ -263,7 +263,7 @@ "content_hash": "28e9ae373563", "has_branch_placeholder": false }, - "f015": { + "f026": { "path": "apps/plugins/__init__.py", "name": "__init__.py", "content_hash": "e3b0c44298fc",