From dbc28c89161063010f2769c3786f10c2d9636f28 Mon Sep 17 00:00:00 2001 From: Codex Date: Fri, 17 Jul 2026 14:24:13 +0200 Subject: [PATCH] Fix packaged project archive command --- .../test_sprint234_project_lifecycle_cleanup.py | 16 ++++++++++++++++ scripts/archive_technical_projects.py | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/backend/tests/test_sprint234_project_lifecycle_cleanup.py b/backend/tests/test_sprint234_project_lifecycle_cleanup.py index e5c2c5f1..7a0117e5 100644 --- a/backend/tests/test_sprint234_project_lifecycle_cleanup.py +++ b/backend/tests/test_sprint234_project_lifecycle_cleanup.py @@ -2,6 +2,7 @@ from __future__ import annotations import importlib.util from pathlib import Path +import subprocess import sys from types import SimpleNamespace from uuid import uuid4 @@ -132,6 +133,21 @@ def test_cleanup_script_is_packaged_and_readiness_checked() -> None: assert "py_compile scripts/archive_technical_projects.py" in readiness +def test_cleanup_script_can_start_as_a_direct_operator_command() -> None: + result = subprocess.run( + [sys.executable, str(ROOT / "scripts/archive_technical_projects.py"), "--help"], + cwd=ROOT, + capture_output=True, + check=False, + text=True, + timeout=20, + ) + + assert result.returncode == 0, result.stderr + assert "--apply" in result.stdout + assert "--show-names" in result.stdout + + def test_frontend_lifecycle_and_component_boundaries_are_wired() -> None: app_source = (ROOT / "frontend/src/App.tsx").read_text(encoding="utf-8") project_panel = (ROOT / "frontend/src/components/project/ProjectPanel.tsx").read_text(encoding="utf-8") diff --git a/scripts/archive_technical_projects.py b/scripts/archive_technical_projects.py index 3cabe144..28b46d57 100644 --- a/scripts/archive_technical_projects.py +++ b/scripts/archive_technical_projects.py @@ -2,12 +2,21 @@ from __future__ import annotations import argparse import json +from pathlib import Path import re +import sys from dataclasses import dataclass from uuid import UUID from sqlalchemy.orm import Session +# Direct execution from /app/scripts must resolve the repository's backend +# package before similarly named installed packages. +ROOT = Path(__file__).resolve().parents[1] +BACKEND_ROOT = ROOT / "backend" if (ROOT / "backend" / "app").is_dir() else ROOT +if str(BACKEND_ROOT) not in sys.path: + sys.path.insert(0, str(BACKEND_ROOT)) + from app.db.session import SessionLocal from app.models import Project