From 4863854376c01c7ada24aed6e3ff862188d4dc87 Mon Sep 17 00:00:00 2001 From: Timothy Wayne Gregg Date: Thu, 12 Nov 2026 21:46:31 -0500 Subject: [PATCH 1/2] Harden CI workflow triggers, pins, timeouts, and installs Limit push runs to main, cancel superseded pull request runs, set 20 minute job timeouts, pin checkout and setup-python to verified commit SHAs, retry pip installs up to three times, and add Python 3.14 to the core matrix. Refs #50 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 70 ++++++++++++++++++++++---- CHANGELOG.md | 4 ++ MANIFEST.sha256 | 2 +- docs/HIERARCHY_RELEASE_VERIFICATION.md | 2 +- 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cfd74f..92d4ad9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,22 +1,43 @@ name: tests on: push: + branches: [main] pull_request: permissions: contents: read +# Pull request runs superseded by a newer push are cancelled; runs on main are never cancelled. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: core: runs-on: ubuntu-latest + # Observed runs take about 1 minute; the limit leaves room for install retries and slow runners. + timeout-minutes: 20 strategy: matrix: - python: ['3.11', '3.12', '3.13'] + python: ['3.11', '3.12', '3.13', '3.14'] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: ${{ matrix.python }} - - run: python -m pip install -e '.[dev]' - - run: python -m pip install -r examples/ai-gateway/requirements.txt + - name: Install package with dev extras + run: | + for attempt in 1 2 3; do + if python -m pip install -e '.[dev]'; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done + - name: Install example requirements + run: | + for attempt in 1 2 3; do + if python -m pip install -r examples/ai-gateway/requirements.txt; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done - run: python -m ruff check src tests examples - run: python -m pytest -q --cov=typewright - run: python -m typewright demo --out runs/ci-demo @@ -27,7 +48,12 @@ jobs: run: | temp_dir="$(mktemp -d)" python -m venv "$temp_dir/venv" - "$temp_dir/venv/bin/python" -m pip install "$GITHUB_WORKSPACE"/dist/typewright-*.whl + for attempt in 1 2 3; do + if "$temp_dir/venv/bin/python" -m pip install "$GITHUB_WORKSPACE"/dist/typewright-*.whl; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done cp -R "$GITHUB_WORKSPACE/examples/hierarchy/support" "$temp_dir/study-inputs" cd "$temp_dir" unset PYTHONPATH @@ -46,18 +72,40 @@ jobs: "$temp_dir/venv/bin/typewright-study" report --frozen study-frozen --execution study-execution optional-contracts: runs-on: ubuntu-latest + timeout-minutes: 20 strategy: matrix: # Both ends of the supported range in pyproject.toml (issue #90). dspy: ['3.3.1', '3.4.0'] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: python-version: '3.11' - - run: python -m pip install -e '.[all,dev]' - - run: python -m pip install -r examples/ai-gateway/requirements.txt - - run: python -m pip install 'dspy[litellm]==${{ matrix.dspy }}' 'gepa==0.1.4' + - name: Install package with all and dev extras + run: | + for attempt in 1 2 3; do + if python -m pip install -e '.[all,dev]'; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done + - name: Install example requirements + run: | + for attempt in 1 2 3; do + if python -m pip install -r examples/ai-gateway/requirements.txt; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done + - name: Install pinned DSPy and GEPA + run: | + for attempt in 1 2 3; do + if python -m pip install 'dspy[litellm]==${{ matrix.dspy }}' 'gepa==0.1.4'; then break; fi + if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 + done - run: python -m typewright doctor --check-optional - run: python -m pytest -q # This workflow never uses API secrets and does not run paid inference. diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a5e7f..5090dac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ stale, Windows/CPython 3.13-only historical freeze in `reports/`. Regression tests check the tables against `pyproject.toml` and require every lock-like file in the tree to be named (#50). No lock was generated. +- CI hardening (#50): the `push` trigger is limited to `main` (pull requests still run), superseded + pull request runs are cancelled by a concurrency group, each job has a 20 minute timeout, + `actions/checkout` and `actions/setup-python` are pinned to verified commit SHAs, pip installs + retry up to three times before failing, and the core matrix adds Python 3.14. - Frozen hierarchy artifacts are now checked for lexical scope on load: node origins must match their export chain, references, `after` edges, and finals may not cross subgraph scopes (except through the inputs an export passes down), and exports must have descendant nodes (#85). diff --git a/MANIFEST.sha256 b/MANIFEST.sha256 index 7ba7bf3..24dda7d 100644 --- a/MANIFEST.sha256 +++ b/MANIFEST.sha256 @@ -1,5 +1,5 @@ cfbc27a244debce6413733798800282eb90aa96e12c97120bffedc05b6783964 .env.example -b4a064c3a119736216efaca4188b17c9829ba8fef12312ea1c067d3fe638b0e4 .github/workflows/ci.yml +cea8dce8c8e9ec17e10e1128f875bdb9d30a4807578a1ae88f88f020053a2968 .github/workflows/ci.yml 0550ea438f0ef6f2ea54da31c25f93f2e0176d5a271f133b31efffa783955b76 .gitignore 30a02d4b567c1cb152c54ec29668d31a69f069e1b7cfd4aad770e37f45024431 AGENTS.md 2e7d278cb4a2bad1de30725a7d02b20d44e88891396f51ac046711923ba51409 CLAUDE.md diff --git a/docs/HIERARCHY_RELEASE_VERIFICATION.md b/docs/HIERARCHY_RELEASE_VERIFICATION.md index 475ccdf..4cf6e25 100644 --- a/docs/HIERARCHY_RELEASE_VERIFICATION.md +++ b/docs/HIERARCHY_RELEASE_VERIFICATION.md @@ -24,7 +24,7 @@ This is the software evidence map for epic [#6](https://github.com/CompleteTech- `tests/test_hierarchy_validation.py` covers cycles, typed references, contract drift, and conditional dominance. `tests/test_hierarchy_artifact.py` covers size limits, path-like definition references, format dispatch, and flat hash compatibility. Runtime, budget, data, evidence, architect, GEPA, compiler, metrics, examples, and study test modules cover malformed responses, model drift, split leakage, small-branch review, cancellation, retries, lost attempt receipts, strict replay, and held-out freeze order. `tests/test_hierarchy_security.py` guards the hierarchy modules against dynamic execution and unsafe serialization/process imports. These are software tests; model prompt-injection resistance is not established by them. -The CI matrix runs pytest, Ruff, wheel build, installed-wheel flat and hierarchy no-key demos, and runtime import isolation on Python 3.11–3.13. Its optional job installs the pinned SDK/DSPy/GEPA extras and runs interface tests with fake providers. No CI job uses a live key. The exact results belong to the PR's check runs; a green configuration file alone proves nothing. +The CI matrix runs pytest, Ruff, wheel build, installed-wheel flat and hierarchy no-key demos, and runtime import isolation on Python 3.11–3.14. Its optional job installs the pinned SDK/DSPy/GEPA extras and runs interface tests with fake providers. No CI job uses a live key. The exact results belong to the PR's check runs; a green configuration file alone proves nothing. Prior flat-study test-input and normalized-text exclusion lists were generated in the original local checkout under ignored `runs/hierarchy-issues-20260930/`; they are not published because hashes of low-entropy text can be sensitive. A new checkout needs independently verified exclusion lists. Live registration checks both lists against every split; a human must still review semantic and near-duplicate independence. `typewright-study manifest` now writes the complete pre-spend live manifest from a registered live protocol, `typewright-study review` binds a human review of the required attestations to that exact digest, and live selection refuses to start unless the reviewed manifest matches the protocol and current software parameters. The software can therefore produce and enforce a complete manifest, but the live scope retained in issue #74 still needs the human inputs: a new independently human-reviewed four-split dataset, a completed review with verified price quote and externally enforced billing cap, paid and teacher-sharing approvals, and after live selection the frozen graph digests and semantic review. Paid calls and teacher-example sharing each require separate explicit authorization. The owner explicitly approved splitting software and live tracking on 2026-10-03. Issues #20/#21 are closed for their delivered software scope; their original reviewed-live-manifest and empirical all-child requirements remain assigned to #74 and epic #6. Both live trackers stay open until their acceptance criteria are verified. This decision supersedes the earlier conflicting close/reopen comments and does not authorize any live execution. The existing flat benchmark is not the new hierarchy holdout. From 7b7f13b90eaef808c2f4d9526e9a1d4dabd4fc57 Mon Sep 17 00:00:00 2001 From: Timothy Wayne Gregg Date: Thu, 12 Nov 2026 21:55:28 -0500 Subject: [PATCH 2/2] Give each main CI run its own concurrency group; share pip retry script The shared push group let GitHub cancel a pending main run when a newer one queued, despite cancel-in-progress being false. Non-PR runs now use github.run_id as their group key, so main runs are never queued or cancelled; PR runs keep one group per PR with cancellation. The six copied pip retry loops are replaced by scripts/ci_pip_install.sh. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 51 ++++++++++----------------------------- CHANGELOG.md | 7 +++--- MANIFEST.sha256 | 3 ++- scripts/ci_pip_install.sh | 24 ++++++++++++++++++ 4 files changed, 43 insertions(+), 42 deletions(-) create mode 100755 scripts/ci_pip_install.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92d4ad9..6b0e455 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,14 @@ on: pull_request: permissions: contents: read -# Pull request runs superseded by a newer push are cancelled; runs on main are never cancelled. +# Pull request runs share one group per PR, so a newer push cancels the superseded run. +# Every other run (pushes to main) gets its own group keyed by run_id, so main runs are never +# queued behind, or cancelled by, another run. run_id is unique per workflow run and is kept +# across re-runs, so a re-run cannot collide with a different run (a sha key would group two +# runs of the same commit). GitHub cancels a pending run when a newer one joins its group even +# with cancel-in-progress false, which is why a shared main group is not used. concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.run_id }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: core: @@ -24,20 +29,10 @@ jobs: python-version: ${{ matrix.python }} - name: Install package with dev extras run: | - for attempt in 1 2 3; do - if python -m pip install -e '.[dev]'; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh python -e '.[dev]' - name: Install example requirements run: | - for attempt in 1 2 3; do - if python -m pip install -r examples/ai-gateway/requirements.txt; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh python -r examples/ai-gateway/requirements.txt - run: python -m ruff check src tests examples - run: python -m pytest -q --cov=typewright - run: python -m typewright demo --out runs/ci-demo @@ -48,12 +43,7 @@ jobs: run: | temp_dir="$(mktemp -d)" python -m venv "$temp_dir/venv" - for attempt in 1 2 3; do - if "$temp_dir/venv/bin/python" -m pip install "$GITHUB_WORKSPACE"/dist/typewright-*.whl; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh "$temp_dir/venv/bin/python" "$GITHUB_WORKSPACE"/dist/typewright-*.whl cp -R "$GITHUB_WORKSPACE/examples/hierarchy/support" "$temp_dir/study-inputs" cd "$temp_dir" unset PYTHONPATH @@ -84,28 +74,13 @@ jobs: python-version: '3.11' - name: Install package with all and dev extras run: | - for attempt in 1 2 3; do - if python -m pip install -e '.[all,dev]'; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh python -e '.[all,dev]' - name: Install example requirements run: | - for attempt in 1 2 3; do - if python -m pip install -r examples/ai-gateway/requirements.txt; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh python -r examples/ai-gateway/requirements.txt - name: Install pinned DSPy and GEPA run: | - for attempt in 1 2 3; do - if python -m pip install 'dspy[litellm]==${{ matrix.dspy }}' 'gepa==0.1.4'; then break; fi - if [ "$attempt" -eq 3 ]; then echo "::error::pip install failed after 3 attempts"; exit 1; fi - echo "::warning::pip install attempt $attempt failed; retrying in 15s" - sleep 15 - done + bash scripts/ci_pip_install.sh python 'dspy[litellm]==${{ matrix.dspy }}' 'gepa==0.1.4' - run: python -m typewright doctor --check-optional - run: python -m pytest -q # This workflow never uses API secrets and does not run paid inference. diff --git a/CHANGELOG.md b/CHANGELOG.md index 5090dac..7fdeac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,10 @@ tables against `pyproject.toml` and require every lock-like file in the tree to be named (#50). No lock was generated. - CI hardening (#50): the `push` trigger is limited to `main` (pull requests still run), superseded - pull request runs are cancelled by a concurrency group, each job has a 20 minute timeout, - `actions/checkout` and `actions/setup-python` are pinned to verified commit SHAs, pip installs - retry up to three times before failing, and the core matrix adds Python 3.14. + pull request runs are cancelled by a per-PR concurrency group (runs on `main` each get their own + group, so none is queued or cancelled), each job has a 20 minute timeout, `actions/checkout` and + `actions/setup-python` are pinned to verified commit SHAs, pip installs retry up to three times + through `scripts/ci_pip_install.sh` before failing, and the core matrix adds Python 3.14. - Frozen hierarchy artifacts are now checked for lexical scope on load: node origins must match their export chain, references, `after` edges, and finals may not cross subgraph scopes (except through the inputs an export passes down), and exports must have descendant nodes (#85). diff --git a/MANIFEST.sha256 b/MANIFEST.sha256 index 24dda7d..366f9bd 100644 --- a/MANIFEST.sha256 +++ b/MANIFEST.sha256 @@ -1,5 +1,5 @@ cfbc27a244debce6413733798800282eb90aa96e12c97120bffedc05b6783964 .env.example -cea8dce8c8e9ec17e10e1128f875bdb9d30a4807578a1ae88f88f020053a2968 .github/workflows/ci.yml +bb4bbaa645f3a3993bff02ab4dca4441ab252225e711b64e01e8d5be7ea3145f .github/workflows/ci.yml 0550ea438f0ef6f2ea54da31c25f93f2e0176d5a271f133b31efffa783955b76 .gitignore 30a02d4b567c1cb152c54ec29668d31a69f069e1b7cfd4aad770e37f45024431 AGENTS.md 2e7d278cb4a2bad1de30725a7d02b20d44e88891396f51ac046711923ba51409 CLAUDE.md @@ -42,6 +42,7 @@ aa89862d423e9345e9d2cc643d69c79c93763ea0686f906c02c047156e891112 schemas/hierar b400d15eb1d0b4729aa16b52efe4db432bf222a805a8e4816eb3be2b9678abb8 schemas/hierarchy-source.schema.json 2bd89ad29a0a0e1b10f2cb0dc20ac79929fe1058cd4a130e31e519907d4057bd schemas/program.schema.json f52b7d9f7682d4a21a1b9076551e33d86702ca80c1580d1e420d1f96b84c8085 schemas/usecase.schema.json +bd6cf7a8acdb312db66345e5b23ab78c44ba41888ae6d2dd864f3b5fa0a065e0 scripts/ci_pip_install.sh efb40e872ef8ad4a65a16b561a32a38237f95aeb2791cd082ed29e0df76ec6b1 scripts/setup.ps1 ea58da181cabe222f88aa559d2de331b685e2eb92004bb12e476e3bf14781470 scripts/setup.sh 3d43521e9b072f66f553ecfc4221298031714b8cf50c4f89b7a48980a6628ecd src/s1compiler/__init__.py diff --git a/scripts/ci_pip_install.sh b/scripts/ci_pip_install.sh new file mode 100755 index 0000000..555124d --- /dev/null +++ b/scripts/ci_pip_install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# CI helper: run ` -m pip install ` up to 3 times, 15 s apart. +# Used by .github/workflows/ci.yml so every install step shares one retry policy. +# pip exit codes do not separate network failures from resolver errors, so every +# failure is retried; a deterministic error costs about 30 s before the step fails. +set -euo pipefail +if [ "$#" -lt 2 ]; then + echo "usage: $0 " >&2 + exit 2 +fi +python_bin="$1" +shift +attempts=3 +for attempt in $(seq 1 "$attempts"); do + if "$python_bin" -m pip install "$@"; then + exit 0 + fi + if [ "$attempt" -eq "$attempts" ]; then + echo "::error::pip install failed after $attempts attempts" + exit 1 + fi + echo "::warning::pip install attempt $attempt failed; retrying in 15s" + sleep 15 +done