fix(spawn): use json_handler.read_json for passport in adopt path

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.
This commit is contained in:
AIOSAI
2026-06-25 04:01:50 -07:00
parent 7e9c0cfca7
commit 1794c8f954
2 changed files with 10 additions and 8 deletions
+7
View File
@@ -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
+3 -8
View File
@@ -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)