From 1794c8f95484e684be62a859befe81be78a7011d Mon Sep 17 00:00:00 2001 From: AIOSAI Date: Thu, 25 Jun 2026 04:01:50 -0700 Subject: [PATCH] fix(spawn): use json_handler.read_json for passport in adopt path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit core.py adopt-path read the passport via json.loads(read_text()) — a direct file op that fails the json_handler standard and the CI seedgo-audit gate. Switch to json_handler.read_json() (matches the pattern ~90 lines above), drop the now-unused 'import json as _json'. @spawn 100%; 315 spawn tests green. --- CHANGELOG.md | 7 +++++++ src/aipass/spawn/apps/modules/core.py | 11 +++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04092360..09ae5ead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,13 @@ PyPI version — not the changelog header. ### Fixed +- **seedgo-audit — @spawn direct JSON read** — `core.py` adopt-path read a + passport via `json.loads(path.read_text())` (direct file op), failing the + `json_handler` standard and the CI seedgo-audit gate. Switched to + `json_handler.read_json()` (the same pattern used a few lines above), dropping + the now-unused `import json as _json`. @spawn back to 100%; 315 spawn tests + green. + - **Windows CI — telegram `bot_registry` crashed test collection** — the module did a bare `import fcntl` (POSIX-only), so on Windows all 8 telegram test modules that transitively import it failed at *collection* with diff --git a/src/aipass/spawn/apps/modules/core.py b/src/aipass/spawn/apps/modules/core.py index d86fe78a..9ead8266 100644 --- a/src/aipass/spawn/apps/modules/core.py +++ b/src/aipass/spawn/apps/modules/core.py @@ -327,8 +327,6 @@ def _adopt_existing(target, purpose, profile, registry_path): Returns: Result dict matching _spawn_agent return format. """ - import json as _json - folder_name = get_branch_name(target) branch_upper = normalize_branch_name(folder_name, "upper") branch_lower = normalize_branch_name(folder_name, "lower") @@ -339,12 +337,9 @@ def _adopt_existing(target, purpose, profile, registry_path): # Read purpose from passport if not provided if not purpose: passport_path = target / ".trinity" / "passport.json" - try: - passport = _json.loads(passport_path.read_text(encoding="utf-8")) - purpose = passport.get("identity", {}).get("purpose", "Adopted agent") - except (ValueError, OSError) as e: - logger.warning("Failed to read passport for purpose: %s", e) - purpose = "Adopted agent" + # read_json returns None on failure (and logs) — same pattern as line ~250. + passport = json_handler.read_json(passport_path) + purpose = (passport or {}).get("identity", {}).get("purpose", "Adopted agent") # Fix registry_id in passport if it doesn't match the current registry fix_passport_registry_id(target, reg_path)