Self-hosted AI workspace.
Python
fix(ci): make maintainer harness contract self-contained and portable
Alexandre Teixeira822ceaaac442
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.ymlindex 0a5e30a4a..0e4f9a1f1 100644--- a/.github/workflows/dependency-review.yml+++ b/.github/workflows/dependency-review.yml@@ -30,7 +30,10 @@ jobs:dependency-review:name: dependency-review (PR gate)# Only meaningful on a pull request -- it needs a base..head diff to review.- if: github.event_name == 'pull_request'+ # dependency-review-action requires GitHub dependency-review support.+ # Keep the blocking gate on the canonical repository; forks and maintainer+ # preview mirrors still run the advisory pip-audit job below.+ if: github.event_name == 'pull_request' && github.repository == 'odysseus-dev/odysseus'runs-on: ubuntu-latestpermissions:contents: readdiff --git a/scripts/test_clean_tool_loop.py b/scripts/test_clean_tool_loop.pyindex a6760c75a..107957d1c 100644--- a/scripts/test_clean_tool_loop.py+++ b/scripts/test_clean_tool_loop.py@@ -9,6 +9,7 @@ import argparseimport copyimport hashlibimport json+import osimport sysimport timefrom pathlib import Path@@ -19,9 +20,17 @@ import jsonschemasys.path.insert(0, str(Path(__file__).resolve().parents[1]))from src.tool_schemas import FUNCTION_TOOL_SCHEMASfrom src.turn_contract import FAMILY_TOOLS, requested_capabilities-CONTRACT_SOURCE = Path(str(Path(__file__).resolve().parents[1] / "scripts"))-sys.path.insert(0, str(CONTRACT_SOURCE))-from eval_alltools_unseen_compare import tools_for_mode+CONTRACT_SOURCE = Path(os.environ.get("ODYSSEUS_TOOL_CONTRACT_ROOT", str(Path(__file__).resolve().parents[1] / "scripts")))+if (CONTRACT_SOURCE / 'eval_alltools_unseen_compare.py').is_file():+ sys.path.insert(0, str(CONTRACT_SOURCE))+ try:+ from eval_alltools_unseen_compare import tools_for_mode+ finally:+ if str(CONTRACT_SOURCE) in sys.path:+ sys.path.remove(str(CONTRACT_SOURCE))+else:+ from src.clean_agent_preview import contract_builder+ tools_for_mode = contract_builder()FAMILIES = tuple(FAMILY_TOOLS)[:10]TRAINED_NAMES = set().union(*(FAMILY_TOOLS[f] for f in FAMILIES))diff --git a/src/clean_agent_preview.py b/src/clean_agent_preview.pyindex 731444f2f..0420b740b 100644--- a/src/clean_agent_preview.py+++ b/src/clean_agent_preview.py@@ -1943,6 +1943,10 @@ def authorized_write_families(user_text):return frozenset(families)+def canonical_tools_for_mode(tools, mode):+ return copy.deepcopy(tools)++@lru_cache(maxsize=1)def contract_builder():root = Path(os.environ.get(@@ -1950,21 +1954,20 @@ def contract_builder():str(Path(__file__).resolve().parents[1] / "scripts"),)).resolve()contract_path = root / 'eval_alltools_unseen_compare.py'- if not contract_path.is_file():- raise FileNotFoundError(- f'Compact-v5 tool contract is missing: {contract_path}'- )- # Load the original promotion protocol, not the description-stripping UI helper.- sys.path.insert(0, str(root))- try:- spec = importlib.util.spec_from_file_location(- 'odysseus_preview_v3_contract', contract_path- )- module = importlib.util.module_from_spec(spec)- spec.loader.exec_module(module)- return module.tools_for_mode- finally:- sys.path.remove(str(root))+ if contract_path.is_file():+ # Load the original promotion protocol, not the description-stripping UI helper.+ sys.path.insert(0, str(root))+ try:+ spec = importlib.util.spec_from_file_location(+ 'odysseus_preview_v3_contract', contract_path+ )+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module.tools_for_mode+ finally:+ if str(root) in sys.path:+ sys.path.remove(str(root))+ return canonical_tools_for_modedef compact_schemas(schemas):