Run staged Python file in AppContainer probe

This commit is contained in:
Hamza Ayed
2026-10-03 13:17:47 +03:00
parent fc4e9ee40f
commit 5652db5dbc
5 changed files with 354 additions and 48 deletions
@@ -0,0 +1,38 @@
"""Stage a tiny workspace and pass it to the Windows AppContainer probe."""
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
REPOSITORY = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPOSITORY))
from app.execution_snapshot import stage_selected_files
def main() -> int:
if len(sys.argv) != 2:
print("usage: run_appcontainer_probe.py <probe-executable>", file=sys.stderr)
return 2
repository = REPOSITORY
os.environ["SOVEREIGNAI_ALLOWED_WORKSPACES"] = str(repository)
os.environ["SOVEREIGNAI_WORKSPACE"] = str(repository)
files = ["README.md", "scripts/appcontainer_user_code_smoke.py"]
with stage_selected_files(repository, files) as snapshot:
environment = os.environ.copy()
environment["SOVEREIGNAI_STAGING_ROOT"] = str(snapshot.root)
environment["SOVEREIGNAI_ENTRY_SCRIPT"] = "scripts/appcontainer_user_code_smoke.py"
completed = subprocess.run(
[str(Path(sys.argv[1]).resolve(strict=True))],
cwd=repository,
env=environment,
check=False,
)
return completed.returncode
if __name__ == "__main__":
raise SystemExit(main())