From 5e78db927e90c6eebf48a34d69e726474b125224 Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Sun, 29 Nov 2026 18:38:17 +0800 Subject: [PATCH] CI: fail closed when the YAML parser for the overlay contract is missing tests/test_isolated_bot_social.py guarded the isolated Bot Social overlay contract behind `try: import yaml ... @skipUnless(yaml, ...)`, and no workflow ever installed PyYAML. In CI the whole contract class was skipped and the job still reported success, so the only assertion over deploy/isolated/ bot-social.compose.yml never ran. Install the pinned parser in the management job and drop the fallback: - tests/test_isolated_bot_social.py: hard `import yaml`, no skipUnless; a missing parser now fails the module at import time instead of skipping it. - .github/workflows/tests.yml: after setup-node and before the unittest step, `python -m pip install --disable-pip-version-check 'PyYAML==6.0.2'`. Both matrix versions (3.11, 3.13) have manylinux x86_64 wheels at this pin. - docs/RUNTIME_IMPLEMENTATION.md: "No pip/npm dependency install required" no longer held for the test suite; state the pin and that a missing parser fails rather than skips. - docs/COMPOSE_MANAGER.md: same install line in the repeatable acceptance block. 4 files, +15/-7. Local verification (not CI): base content with a parser-less interpreter gives `OK (skipped=1)` and exit 0; this patch on the same interpreter gives `ModuleNotFoundError: No module named 'yaml'` and exit 1; with PyYAML 6.0 the test passes, exit 0. Four mutations of the overlay (all-interfaces health port, extra exposed port, added networks block, bind mount instead of the named volume) each fail with a distinct message and exit 1; the unmutated overlay passes. Related #3442 --- .github/workflows/tests.yml | 5 +++++ docs/COMPOSE_MANAGER.md | 1 + docs/RUNTIME_IMPLEMENTATION.md | 3 ++- tests/test_isolated_bot_social.py | 13 +++++++------ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ccf1d5e52..112f7ff53 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,6 +50,11 @@ jobs: - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: '22' + # tests/test_isolated_bot_social.py parses the isolated overlay with PyYAML, so the + # dependency is pinned here rather than skipped: a missing parser must fail this job. + # Both matrix versions (3.11, 3.13) have manylinux x86_64 wheels at this pin. + - name: Install the pinned YAML parser for the overlay contract + run: python -m pip install --disable-pip-version-check 'PyYAML==6.0.2' - name: Python tests with explicit trusted runner Node run: | install -d -m 0700 "$RUNNER_TEMP/flybot-workspace-planner-bin" diff --git a/docs/COMPOSE_MANAGER.md b/docs/COMPOSE_MANAGER.md index 157189716..692c11124 100644 --- a/docs/COMPOSE_MANAGER.md +++ b/docs/COMPOSE_MANAGER.md @@ -303,6 +303,7 @@ resume, data deletion or purge. Owner may explicitly start only after STOP conve # Safe temporary SQLite + local HTTP + actual subprocess STUB only: scripts/accept-compose-manager-stub.sh # Full original + new suite (Node planner requires trusted Node per runtime docs): +python3 -m pip install 'PyYAML==6.0.2' # isolated Bot Social overlay contract test FLYBOT_WORKSPACE_PLANNER_NODE="$(command -v node)" python3 -m unittest discover -s tests -v node --test manager/compose-planner/compose-command-planner.test.js ``` diff --git a/docs/RUNTIME_IMPLEMENTATION.md b/docs/RUNTIME_IMPLEMENTATION.md index efa34fcc8..91209ec0b 100644 --- a/docs/RUNTIME_IMPLEMENTATION.md +++ b/docs/RUNTIME_IMPLEMENTATION.md @@ -45,9 +45,10 @@ Manager headers: `Authorization: Bearer .<43-character-opaque-token> ## Running and configuration -Python3.11+; **Node18+ is additionally needed for planner integration/tests** (local verification used Node24.22.1). No pip/npm dependency install required. The manager-side adapter defaults to the system executable search path only. For an operator-installed/CI tool-cache Node outside that path, explicitly set `FLYBOT_WORKSPACE_PLANNER_NODE` to its absolute executable path (or inject the constructor argument); relative paths, non-Node filenames and group/world-writable executables are refused. This is operator process configuration, never an HTTP/JSON selector. CI stages its preinstalled runner Node into a private0700 job directory with an0500 executable, then exports that absolute path before Python tests. The application permission check is not relaxed for writable hosted-tool-cache binaries. The Web/API remains Python stdlib only. +Python3.11+; **Node18+ is additionally needed for planner integration/tests** (local verification used Node24.22.1). No pip/npm dependency install is required for the manager or the server; the test suite additionally parses the isolated Bot Social overlay with PyYAML 6.0.2, so a local `python3 -m pip install 'PyYAML==6.0.2'` is needed before `unittest discover`. A missing parser fails the suite instead of skipping the overlay contract. The manager-side adapter defaults to the system executable search path only. For an operator-installed/CI tool-cache Node outside that path, explicitly set `FLYBOT_WORKSPACE_PLANNER_NODE` to its absolute executable path (or inject the constructor argument); relative paths, non-Node filenames and group/world-writable executables are refused. This is operator process configuration, never an HTTP/JSON selector. CI stages its preinstalled runner Node into a private0700 job directory with an0500 executable, then exports that absolute path before Python tests. The application permission check is not relaxed for writable hosted-tool-cache binaries. The Web/API remains Python stdlib only. ```sh +python3 -m pip install 'PyYAML==6.0.2' # isolated Bot Social overlay contract test python3 -m unittest discover -s tests -v node --test manager/compose-planner/compose-command-planner.test.js python3 -m compileall -q flybot-workspace tests diff --git a/tests/test_isolated_bot_social.py b/tests/test_isolated_bot_social.py index eebabc249..757674640 100644 --- a/tests/test_isolated_bot_social.py +++ b/tests/test_isolated_bot_social.py @@ -1,17 +1,18 @@ -"""Isolated FlyBot Bot Social overlay: additive, loopback-only, no FlyBot hooks.""" +"""Isolated FlyBot Bot Social overlay: additive, loopback-only, no FlyBot hooks. + +The overlay contract is a YAML parse, so PyYAML is a hard requirement: if the parser is missing, +this module must fail to import instead of skipping the only test that checks the contract. CI +installs the pinned version in .github/workflows/tests.yml. +""" import unittest from pathlib import Path -try: - import yaml -except ImportError: # pragma: no cover - PyYAML is in the usual test env - yaml = None +import yaml ROOT = Path(__file__).resolve().parents[1] OVERLAY = ROOT / 'deploy' / 'isolated' / 'bot-social.compose.yml' -@unittest.skipUnless(yaml, 'PyYAML is required to parse the overlay') class IsolatedBotSocialOverlayTests(unittest.TestCase): def test_overlay_adds_only_bot_social_on_loopback(self): text = OVERLAY.read_text()