Skip to content

Point laptop Science paths at Workspace/Science #592

Point laptop Science paths at Workspace/Science

Point laptop Science paths at Workspace/Science #592

Workflow file for this run

name: Brain Tests
# Brain's own unit suite — the reasoning layer's self-test. Until this existed,
# PyAutoBrain PRs carried ZERO check runs (`docs.yml` is path-filtered to
# `docs/**`, `nightly-release.yml` is a cron release scheduler), so ~190 tests
# covering the conductors, faculties, worktree helpers, skill install and policy
# seams ran in no CI at all and a Brain PR's only gate was whatever the
# authoring session happened to run locally.
#
# pytest plus ONE drift leg. The suite must not run `pyauto-brain <agent>`
# against live repos or reach the network — those need the full workspace and
# belong to the scheduled health/nightly drivers, not a PR gate. The suite is
# stdlib + PyYAML only, so it stays fast (~30s) and flake-free. The one
# non-pytest step is the tenant-firewall gate (PyAutoMind#198): every firewall
# finding to date merged through a green PR because no PR CI ran the check, so
# the leg a Brain PR can cause is verified here, in the PR that authors it.
# `--only` keeps Mind-side legs (map blocks, registries) from reddening Brain
# PRs on drift Brain cannot cause; organs not checked out (Heart, Hands) are
# skipped by the check itself, so this gates exactly Brain.
#
# THREE repos are checked out on purpose. PyAutoBrain alone cannot even COLLECT
# the suite: `agents/faculties/sizing/_sizing.py` reads the body map
# (`BRAIN_HOME.parent / "PyAutoMind" / "repos.yaml"`) at import time and is
# deliberately strict, so `test_policy_seams.py` and `test_sizing_paths.py`
# error out before a single test runs. Checking PyAutoMind out as a sibling
# reproduces the workspace layout the code assumes — the same layout the
# firewall gate's `--root` needs. PyAutoCortex is the third: the cortex
# conductor imports the Cortex's own `scripts/cortex.py` at runtime and its
# tests render the board against that repo's `tests/fixtures/skeleton`, the
# fixture that IS the schema's witness — a copied fixture here would drift
# from the schema it claims to test (the tests skip cleanly when the checkout
# is absent, so a local run without it still passes). All three repos are
# public, so the default GITHUB_TOKEN suffices — no PAT. No other sibling repo
# is needed (verified by running the suite against exactly this layout).
# One run per commit: PR events carry the CI; pushes only build main.
# Superseded runs are cancelled on PR refs only — a cancelled main run would
# read as red CI (cancelled is in Heart's FAILURE_CONCLUSIONS).
on:
push:
branches: [main]
pull_request:
concurrency:
group: brain-tests-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
pytest:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]
steps:
- name: Checkout PyAutoBrain
uses: actions/checkout@v4
with:
path: PyAutoBrain
# The body map `_sizing.py` imports. Pinned to main: this gate tests
# Brain against the CURRENT organism identity, the same pairing a local
# workspace has.
- name: Checkout PyAutoMind (the body map — required to import)
uses: actions/checkout@v4
with:
repository: PyAutoLabs/PyAutoMind
path: PyAutoMind
# The science organ the cortex conductor reasons over: its
# `scripts/cortex.py` is the schema API and its skeleton fixture is
# what `test_cortex_conductor.py` renders.
- name: Checkout PyAutoCortex (the Cortex schema + fixture)
uses: actions/checkout@v4
with:
repository: PyAutoLabs/PyAutoCortex
path: PyAutoCortex
# A Brain branch that changes the conductor alongside a Cortex schema
# change is tested against the Cortex branch of the SAME NAME when one
# exists (the two land as a pair), and against Cortex main otherwise.
- name: Prefer the same-named PyAutoCortex branch, if any
working-directory: PyAutoCortex
env:
BR: ${{ github.head_ref || github.ref_name }}
run: |
if git fetch --depth 1 origin "$BR" 2>/dev/null; then
git checkout -q FETCH_HEAD && echo "PyAutoCortex @ $BR"
else
echo "PyAutoCortex @ main (no branch named $BR)"
fi
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install (pytest + PyYAML — the whole dependency set)
run: pip install pytest PyYAML
- name: Run tests
working-directory: PyAutoBrain
run: pytest tests/ -q
# The committed `.claude/` + `.codex/` discovery trees are generated
# symlinks, and nothing regenerated them: three skills (batch,
# ci_speedup, start_bundle) were never registered and two deleted ones
# (register_and_iterate, run_queue) stayed linked, so a web session —
# which loads only committed files — silently lacked those verbs. The
# generator has always had a drift mode; it just ran in no CI. Only the
# repos checked out above are examined (the check skips the rest), so
# this gates Brain and Mind and nothing a Brain PR cannot fix.
- name: Skill discovery trees are current (.claude/ + .codex/ symlinks)
run: bash PyAutoBrain/bin/install.sh --check-project-discovery
# A skill's SKILL.md + body is MANDATORY context every time the skill
# loads, so line count is a per-invocation token cost, not a style
# preference. Report-only: `batch` and `prm` are over the 200-line budget
# today and trimming them is its own task — this step makes the debt
# visible on every PR without reddening a gate nobody can currently pass.
- name: Skill line-count budget (report-only — known offenders)
continue-on-error: true
working-directory: PyAutoBrain
run: bash bin/check_skill_line_counts.sh
- name: Tenant firewall (instance facts stay in declared config surfaces)
run: >
python3 PyAutoMind/scripts/repos_sync.py --check
--only "tenant firewall (organ code)"
--root "$GITHUB_WORKSPACE"