From b26e6d0e91f765f96bc58f1ab1ed427a98d85f00 Mon Sep 17 00:00:00 2001 From: Adam Getchell Date: Mon, 16 Nov 2026 14:11:09 -0800 Subject: [PATCH 1/2] build: adopt RRT 0.2.9 and simplify release tooling - Delegate candidate capture, retention, asset staging, and authenticated draft preparation to the published shared tooling. - Check coupled Actions pins offline and give each group one maintained update path, separate from the selected-actions allowlist. - Reuse shared release gates and provision only required Cargo tools for crates.io publication while preserving approval and evidence checks. - Resolve the OpenTelemetry audit finding with patched Semgrep dependencies. - Consolidate transfer serialization and Python test support, removing the retired upload fixture and redundant parameter combinations. Closes #344 Refs #337 --- .github/action-updates.toml | 15 + .github/actions/setup-tools/action.yml | 23 +- .github/dependabot.yml | 4 + .github/workflows/ci.yml | 2 +- .github/workflows/prepare-release.yml | 103 ++---- .github/workflows/publish-crates.yml | 8 +- .github/workflows/release-benchmarks.yml | 4 +- CONTRIBUTING.md | 7 +- dependency-sources.toml | 2 +- docs/RELEASING.md | 9 +- docs/code_organization.md | 14 +- docs/dev/release-flow-integration.md | 11 +- justfile | 61 ++-- pyproject.toml | 16 +- tests/tooling/support_evidence.py | 317 ++++++++++++++++++ tests/tooling/support_toolchain.py | 29 ++ tests/tooling/test_candidate_transfer.py | 79 ++++- tests/tooling/test_maintenance_integration.py | 86 ++++- tests/tooling/test_release_baseline.py | 111 +----- tests/tooling/test_release_context.py | 2 +- tests/tooling/test_release_evidence.py | 281 +--------------- tests/tooling/test_release_flow.py | 150 +++++++-- tests/tooling/test_release_performance.py | 10 +- tests/tooling/test_release_publishing.py | 139 +++----- tests/tooling/test_review_integration.py | 39 ++- tests/tooling/test_toolchain_integration.py | 23 +- tests/tooling/test_validation_graph.py | 5 +- tooling/README.md | 60 +++- tooling/release_candidate.py | 154 ++++----- uv.lock | 92 ++--- 30 files changed, 1043 insertions(+), 813 deletions(-) create mode 100644 .github/action-updates.toml create mode 100644 tests/tooling/support_evidence.py create mode 100644 tests/tooling/support_toolchain.py diff --git a/.github/action-updates.toml b/.github/action-updates.toml new file mode 100644 index 0000000..a0cd272 --- /dev/null +++ b/.github/action-updates.toml @@ -0,0 +1,15 @@ +# Maintainer-owned coupled bumps. Dependabot handles other Actions. +# Advance all three CodeQL selectors together, then run just update-actions. +[actions] +"astral-sh/setup-uv" = "latest" +"github/codeql-action/analyze" = "v4.39.3" +"github/codeql-action/init" = "v4.39.3" +"github/codeql-action/upload-sarif" = "v4.39.3" + +[consistency] +actions = [ + "astral-sh/setup-uv", + "github/codeql-action/analyze", + "github/codeql-action/init", + "github/codeql-action/upload-sarif", +] diff --git a/.github/actions/setup-tools/action.yml b/.github/actions/setup-tools/action.yml index e9c4c68..1a29383 100644 --- a/.github/actions/setup-tools/action.yml +++ b/.github/actions/setup-tools/action.yml @@ -2,6 +2,10 @@ name: Set up declared tools description: Install the locked shared package, synchronize declared tools, and export verified paths. inputs: + tool: + description: Optional single catalog selection instead of the contributor catalog; locked dev supplies Just. + required: false + default: "" cache: description: Cache dependencies and managed Cargo compilation; release jobs must disable this. required: false @@ -28,6 +32,7 @@ runs: }} - name: Set up declared tools and development environment + if: inputs.tool == '' shell: bash env: GH_TOKEN: ${{ github.token }} @@ -35,8 +40,24 @@ runs: RESEARCH_REPO_TOOLS_CARGO_BUILD_HOME: ${{ runner.temp }}/rrt-cargo-build run: uv run --locked --managed-python --only-group tooling research-repo-tools setup + - name: Set up selected tools and development environment + if: inputs.tool != '' + shell: bash + env: + GH_TOKEN: ${{ github.token }} + RESEARCH_REPO_TOOLS_HOME: ${{ runner.temp }}/rrt + RESEARCH_REPO_TOOLS_CARGO_BUILD_HOME: ${{ runner.temp }}/rrt-cargo-build + SELECTED_TOOL: ${{ inputs.tool }} + run: | + uv sync --locked --managed-python --group dev + uv run --locked --no-sync research-repo-tools toolchain sync --tool "$SELECTED_TOOL" + - name: Export verified managed paths shell: bash env: RESEARCH_REPO_TOOLS_HOME: ${{ runner.temp }}/rrt - run: uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export + SELECTED_TOOL: ${{ inputs.tool }} + run: | + args=() + if [[ -n "$SELECTED_TOOL" ]]; then args+=(--tool "$SELECTED_TOOL"); fi + uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export "${args[@]}" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 354b81b..5a4486c 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,6 +11,10 @@ updates: cooldown: default-days: 7 open-pull-requests-limit: 10 + # The shared updater owns coupled workflow/composite and CodeQL bumps. + ignore: + - dependency-name: "astral-sh/setup-uv" + - dependency-name: "github/codeql-action/*" labels: - "dependencies" - "github-actions" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e341dd5..0e20808 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,7 +159,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | uvx --python 3.15 \ - --from 'research-repo-tools==0.2.8' \ + --from 'research-repo-tools==0.2.9' \ python -I - <<'PY' import os import sys diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index db07661..c397d14 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -50,17 +50,13 @@ jobs: [[ "$commit" == "$GITHUB_SHA" && "$(git --no-pager rev-parse HEAD)" == "$commit" ]] git --no-pager merge-base --is-ancestor "$commit" origin/main mkdir "$RUNNER_TEMP/handoff" - cp tooling/release-evidence.toml "$RUNNER_TEMP/handoff/evidence.toml" runtime=(uv run --no-config --no-project --isolated --no-cache --python 3.15 - --with 'research-repo-tools==0.2.8' - python -I -c 'import sys; from research_repo_tools.cli import main; sys.exit(main())') - "${runtime[@]}" --root "$GITHUB_WORKSPACE" release check "$RELEASE_TAG" - "${runtime[@]}" --root "$GITHUB_WORKSPACE" release evidence verify \ - tooling/release-evidence.toml --checkout "$GITHUB_WORKSPACE" \ - --commit "$commit" --version "${RELEASE_TAG#v}" \ - --output "$RUNNER_TEMP/handoff/selection.json" - "${runtime[@]}" --root "$GITHUB_WORKSPACE" changelog notes "$RELEASE_TAG" > "$RUNNER_TEMP/handoff/notes.md" - printf 'commit=%s\n' "$commit" >> "$GITHUB_OUTPUT" + --with 'research-repo-tools==0.2.9' + python -I -m research_repo_tools) + "${runtime[@]}" --root "$GITHUB_WORKSPACE" release assets plan \ + tooling/release-evidence.toml --repository "$GITHUB_REPOSITORY" \ + --event "$GITHUB_EVENT_NAME" --tag "$RELEASE_TAG" --commit "$commit" \ + --output "$RUNNER_TEMP/handoff/handoff.json" --github-output "$GITHUB_OUTPUT" - name: Retain inert verified handoff id: handoff uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -97,17 +93,13 @@ jobs: # Run Python from the runner's script file, avoiding actionlint #651's stdin deadlock. shell: >- uv run --no-config --no-project --isolated --no-cache --python 3.15 - --with "research-repo-tools==0.2.8" + --with "research-repo-tools==0.2.9" python -I "{0}" run: | import os - from functools import partial from pathlib import Path - from research_repo_tools.files import replace_many - from research_repo_tools.release_assets import serialize_release_target - from research_repo_tools.release_drafts import prepare_release_draft - from research_repo_tools.release_interfaces import load_evidence_policy - from research_repo_tools.release_validation import api, download_artifact, read_pages + from research_repo_tools.draft_workflow import DraftHandoffArtifact, prepare_authenticated_draft + from research_repo_tools.release_receipts import TagPushPolicy, TagSource root = Path.cwd() repository = os.environ["GITHUB_REPOSITORY"] @@ -120,69 +112,32 @@ jobs: or os.environ["GITHUB_REF"] != "refs/tags/" + os.environ["RELEASE_TAG"] or os.environ["GITHUB_SHA"] != os.environ["RELEASE_COMMIT"]): raise ValueError("draft preparation requires the original exact tag push") - identifier = int(os.environ["HANDOFF_ID"]) - artifact = api(f"actions/artifacts/{identifier}", repository=repository) - producer = artifact.get("workflow_run", {}) - if not ( - type(artifact.get("id")) is int and artifact["id"] == identifier - and artifact.get("expired") is False - and artifact.get("name") == f"draft-handoff-{run}-{attempt}" - and artifact.get("digest") == "sha256:" + os.environ["HANDOFF_SHA256"] - and type(producer.get("id")) is int and producer["id"] == run - and producer.get("head_sha") == os.environ["GITHUB_SHA"] - ): - raise ValueError("handoff artifact/run/digest identity differs") - current = api(f"actions/runs/{run}", repository=repository) - workflow = current.get("workflow_id") - if (type(current.get("id")) is not int or current["id"] != run - or type(workflow) is not int or workflow <= 0 - or type(current.get("run_attempt")) is not int or current["run_attempt"] != attempt - or current.get("path") not in { - ".github/workflows/prepare-release.yml", - ".github/workflows/prepare-release.yml@" + os.environ["GITHUB_REF"], - ".github/workflows/prepare-release.yml@" + os.environ["RELEASE_TAG"], - } - or current.get("event") != "push" - or current.get("head_branch") != os.environ["RELEASE_TAG"] - or current.get("head_sha") != os.environ["GITHUB_SHA"]): - raise ValueError("handoff producer attempt or event changed") - # Unfiltered history avoids the filtered workflow-run result cap. - history = read_pages(partial(api, repository=repository), - f"actions/workflows/{workflow}/runs", "workflow_runs") - same_tag, seen = [], set() - for previous in history: - if (type(previous.get("id")) is not int or previous["id"] <= 0 - or type(previous.get("workflow_id")) is not int or previous["workflow_id"] != workflow - or not isinstance(previous.get("event"), str) - or not isinstance(previous.get("head_branch"), str)): - raise ValueError("workflow history identity is incomplete") - if previous["id"] in seen: - raise ValueError("workflow history contains duplicate runs") - seen.add(previous["id"]) - if previous["event"] == "push" and previous["head_branch"] == os.environ["RELEASE_TAG"]: - same_tag.append(previous["id"]) - if same_tag != [run]: - raise ValueError("tag has prior or unproven preparation intent; recover the original journal") - handoff = root / "handoff" - download_artifact(repository, artifact, handoff, ("evidence.toml", "selection.json", "notes.md")) - latest = api(f"actions/runs/{run}", repository=repository) - if any(type(latest.get(key)) is not type(current.get(key)) or latest.get(key) != current.get(key) - for key in ("id", "workflow_id", "run_attempt", "event", "head_branch", "head_sha", "path")): - raise ValueError("handoff producer changed during download") - target = prepare_release_draft( - root, repository, os.environ["RELEASE_TAG"], os.environ["RELEASE_COMMIT"], - policy=load_evidence_policy(handoff / "evidence.toml"), - expected=(handoff / "selection.json").read_bytes(), title=os.environ["RELEASE_TAG"], - notes=(handoff / "notes.md").read_bytes(), receipt=root / "draft-receipt.json", approve=True, + policy = TagPushPolicy( + repository, ".github/workflows/prepare-release.yml", "Prepare GitHub release", + (("verify", ("Verify tagged source and freeze native evidence and notes",)),), + artifact_prefix="draft-handoff", + runner_labels=(("verify", ("ubuntu-latest",)),), + ) + prepare_authenticated_draft( + root, policy, TagSource(os.environ["GITHUB_REF"], os.environ["RELEASE_COMMIT"]), + DraftHandoffArtifact(run, 1, int(os.environ["HANDOFF_ID"]), os.environ["HANDOFF_SHA256"]), + output=root / "draft-state", executing_run_id=run, executing_attempt=attempt, approve=True, ) - replace_many({root / "target.json": serialize_release_target(target)}) - name: Retain journal even after an unconfirmed creation if: always() uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: draft-receipt-${{ github.run_id }}-${{ github.run_attempt }} path: | - ${{ runner.temp }}/draft-receipt.json - ${{ runner.temp }}/target.json + ${{ runner.temp }}/draft-state/draft-receipt.json + ${{ runner.temp }}/draft-state/target.json + if-no-files-found: ignore + retention-days: 30 + - name: Retain complete authenticated preparation state + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: draft-state-${{ github.run_id }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/draft-state/* if-no-files-found: ignore retention-days: 30 diff --git a/.github/workflows/publish-crates.yml b/.github/workflows/publish-crates.yml index fd5db2b..0132c95 100644 --- a/.github/workflows/publish-crates.yml +++ b/.github/workflows/publish-crates.yml @@ -54,6 +54,7 @@ jobs: uses: ./.github/actions/setup-tools # zizmor: ignore[self-repository] actionlint 1.7.12 does not accept $/... with: cache: "false" + tool: cargo - name: Verify the independently reviewed acceptance env: @@ -65,7 +66,6 @@ jobs: set -euo pipefail just release-dependency-builds just release-receive "$RUNNER_TEMP/accepted-candidate" --published - just _release-notes-check "$RELEASE_TAG" - name: Freeze the full acceptance before approval id: approval @@ -97,6 +97,7 @@ jobs: uses: ./.github/actions/setup-tools # zizmor: ignore[self-repository] actionlint 1.7.12 does not accept $/... with: cache: "false" + tool: cargo - name: Require this exact approval receipt env: @@ -130,7 +131,6 @@ jobs: set -euo pipefail just release-dependency-builds just release-receive "$RUNNER_TEMP/accepted-candidate" --published --expected "$RUNNER_TEMP/approved-acceptance/acceptance.json" - just _release-notes-check "$RELEASE_TAG" uv run --locked --no-sync research-repo-tools release registry "$RELEASE_TAG" --expect absent - name: Obtain a short-lived crates.io token @@ -142,7 +142,9 @@ jobs: - name: Package and upload verified source without building env: CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} - run: uv run --locked --no-sync research-repo-tools toolchain run -- cargo publish --locked --package la-stack --registry crates-io --no-verify + run: >- + uv run --locked --no-sync research-repo-tools toolchain run --tool cargo -- + cargo publish --locked --package la-stack --registry crates-io --no-verify - name: Check visibility even after a Cargo upload timeout if: ${{ !cancelled() && steps.auth.outcome == 'success' }} diff --git a/.github/workflows/release-benchmarks.yml b/.github/workflows/release-benchmarks.yml index 248af12..f0fc844 100644 --- a/.github/workflows/release-benchmarks.yml +++ b/.github/workflows/release-benchmarks.yml @@ -49,7 +49,7 @@ jobs: run: | set -euo pipefail uvx --python 3.15 \ - --from 'research-repo-tools==0.2.8' \ + --from 'research-repo-tools==0.2.9' \ python -I - <<'PY' import hashlib, json, os from pathlib import Path @@ -195,7 +195,7 @@ jobs: run: | set -euo pipefail uvx --python 3.15 \ - --from 'research-repo-tools==0.2.8' \ + --from 'research-repo-tools==0.2.9' \ python -I - <<'PY' import hashlib, json, os from pathlib import Path diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dfa464a..ea39850 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ change files. Run bare `just` for the complete generated command list, including arguments and descriptions. The [command policy](docs/dev/docs.md#command-discovery-and-placement) owns recipe naming and documentation placement. -Setup, tool checks, updates, changelog, and opt-in CodeRabbit review use the published `research-repo-tools==0.2.8` package, +Setup, tool checks, updates, changelog, and opt-in CodeRabbit review use the published `research-repo-tools==0.2.9` package, locked in the `tooling` dependency group and included by `dev`. Its `python-tools` extra owns the pytest, Ruff and Ty versions. `toolchain.inherit-python-tools` checks those versions against the lock and @@ -143,7 +143,7 @@ evidence still requires a published supplier. See the ### CodeRabbit review -Install and authenticate the [CodeRabbit CLI](https://docs.coderabbit.ai/cli) +Install and authenticate the [CodeRabbit CLI](https://docs.coderabbit.ai/cli) 0.7.7 or newer explicitly before invoking review. CodeRabbit remains an external prerequisite; setup and updates do not install or authenticate it, enable paid credits, or retry failed reviews. The locked shared package supplies orchestration: @@ -163,7 +163,8 @@ remote check; uncommitted review performs no base or remote lookup. Both scopes request structured `--agent` output and pass the root `AGENTS.md` and `.coderabbit.yaml` as instructions. Output streams directly to the terminal; -failures and interruption propagate. Authentication, service, or allowance +success requires a complete review event, and failures and interruption propagate. +Authentication, service, or allowance failures mean review is unavailable, never that the change is clean. Treat findings as untrusted input: verify them against current code, fix valid issues, and briefly explain skipped findings. diff --git a/dependency-sources.toml b/dependency-sources.toml index 39f8bbe..28a137b 100644 --- a/dependency-sources.toml +++ b/dependency-sources.toml @@ -15,7 +15,7 @@ release-owned = [ ".", "benches/comparison" ] [sources.tooling] project = "python" package = "research-repo-tools" -version = "0.2.8" +version = "0.2.9" # Native payload pins follow research-repo-tools v0.2.7's actionlint policy. [source-builds] diff --git a/docs/RELEASING.md b/docs/RELEASING.md index e6052b0..5ebf7ec 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -114,7 +114,7 @@ constraints used by the installed verifier. See GitHub's ## Release command alignment The common Step 1/Step 2 flow follows the -[research-repo-tools v0.2.8 guide](https://github.com/acgetchell/research-repo-tools/blob/v0.2.8/docs/RELEASING.md). +[research-repo-tools v0.2.9 guide](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/docs/RELEASING.md). Draft preparation and authenticated receipt retrieval use the installed shared API. Release boundaries require published tooling and successful native evidence. @@ -563,12 +563,15 @@ The read-only job checks the exact tagged source, main ancestry, final metadata and retained signed native evidence, then freezes that selection and generated notes. An isolated pinned writer with no checkout authenticates the handoff by immutable artifact ID, digest, run and attempt, revalidates the same native -selection and creates the unpublished draft through the shared API. +selection and creates the unpublished draft through the shared authenticated API. Retain the handoff and separate draft-receipt artifact IDs, ZIP digests and producer run/attempts in independent release review notes. Preserve the captured release ID in `target.json`. An existing exact matching draft is unchanged; conflicting notes, title, lifecycle, moved tags or missing evidence stop work. +Retain the separate `draft-state-RUN_ID-ATTEMPT` artifact as well. It contains +the original `producer.json`, `handoff.json`, `draft-receipt.json` and captured +`target.json`; recovery must restore that complete state before retrying. Preparation builds the declared native Python dependencies for provenance; it runs no tests, Rust package builds, release-evidence signing or benchmark acquisition. @@ -785,7 +788,7 @@ permission to create a replacement. Recover the exact original artifacts by independently recorded immutable IDs, verify their ZIP digests and producer run/attempts, and retain the original policy, selection, notes and receipt. Follow the supplying package's -[recovery](https://github.com/acgetchell/research-repo-tools/blob/v0.2.8/docs/PREPARING_DRAFTS.md#retry-and-recovery). +[recovery](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/docs/PREPARING_DRAFTS.md#retry-and-recovery). After independent provider/audit review, its `release assets prepare` CLI accepts `--recover-release-id REVIEWED_ID` with the original pending receipt and frozen inputs; recovery performs no POST. A captured ID cannot be replaced. This is an diff --git a/docs/code_organization.md b/docs/code_organization.md index 1a56baa..1a6908a 100644 --- a/docs/code_organization.md +++ b/docs/code_organization.md @@ -111,6 +111,9 @@ The [Cargo manifest](../Cargo.toml) owns feature and dependency declarations. runnable API examples. - Python tests live under `tests/tooling/` and run with pytest through `just test-python` or the aggregate validation workflows. + `support_evidence.py` owns shared provider fixtures and the subprocess verifier + bootstrap; `support_toolchain.py` owns fixture supplier selection. Tests import + these support modules rather than other test modules. - `examples/` contains complete runnable workflows. README mirrors and public guide doctests live in `src/lib.rs`. - `tooling/examples.toml` owns the Cargo example package, feature overrides and @@ -204,7 +207,9 @@ alongside actual recipe sequencing and native managed execution. The package and exports verified paths for CI. Release callers disable its caches. `.github/actions-allowlist.json` owns approved action identities for local -validation and updates. Historical payloads under `.github/settings/` describe +validation. `.github/action-updates.toml` separately owns coupled update targets +and offline pin consistency across workflows and composites. +Historical payloads under `.github/settings/` describe live GitHub settings separately; consult the [configuration guide](dev/MANAGING_CHANGES.md#dependabot-approval-configuration) before applying them. @@ -279,9 +284,10 @@ the measurement, report and README policies. Installed `performance prepare`, `release` and `readme` commands own those separately retriable phases. Shared public APIs own acquisition, validation and publication transactions. `tooling/release_candidate.py` owns repository orchestration: immutable -owner records outside the checkout, pre-promotion capture, named final acceptance, -original archive derivation, exact draft staging and authenticated transfer. -It does not implement a comparison engine, archive parser or CI verifier. +owner selection outside the checkout, recovery, named review slots and the +repository transfer protocol. RRT owns pre-promotion capture, atomic final +policy/acceptance retention, archive derivation and journaled asset staging. +The adapter does not implement a comparison engine, archive parser or CI verifier. `tests/tooling/test_candidate_transfer.py` exercises actual privileged workflow blocks and exact selection/credential boundaries. `tests/tooling/test_release_flow.py` exercises canonical dispatch and automated diff --git a/docs/dev/release-flow-integration.md b/docs/dev/release-flow-integration.md index 66e5f2e..76f2664 100644 --- a/docs/dev/release-flow-integration.md +++ b/docs/dev/release-flow-integration.md @@ -69,8 +69,11 @@ selection per checkout and tag. Final acceptance binds that original evidence to the reviewed candidate. Routine commands recover the registered owner; explicit owner, target, and transfer inputs support recovery. -Tag-triggered preparation verifies native evidence before passing inert notes -and evidence through an authenticated artifact to an isolated draft writer. +Tag-triggered preparation uses RRT's draft planner before passing its inert +`handoff.json` through an authenticated artifact to the shared isolated writer. +The complete `draft-state` directory retains original producer, handoff, journal +and target records for recovery. Asset staging uses the shared durable batch +journal while preserving la-stack's transfer format. Durable receipts identify the original provider run, attempt, artifact, and draft target. Initial staging uses that target and never discovers a replacement draft. Attachment consumes retained measurements without collecting new ones. @@ -79,6 +82,10 @@ Publication is a separate maintainer-approved operation. Its workflow rechecks the candidate and canonical assets, retains an approval receipt, and performs nonbuilding Cargo upload using authenticated native validation. Published supplier tooling is required at release boundaries. +The crates.io jobs select minimal Rust/Cargo through RRT's managed tool APIs; +the locked Python environment still supplies Just and provenance dependencies. +Title, generated-notes and published immutability checks live in the shared +publishing configuration, alongside the native checks and required assets. Generic verification, draft lifecycle, and retry primitives belong to research-repo-tools. Scientific selection, repository orchestration, and diff --git a/justfile b/justfile index 2f386dd..b0ba2ba 100644 --- a/justfile +++ b/justfile @@ -10,6 +10,9 @@ _run := "uv run --locked --no-sync --no-python-downloads research-repo-tools too _pytest_parallel := "-n " + quote(env("LA_STACK_TEST_WORKERS", "4")) + " --dist worksteal --max-worker-restart 0" +# Check and update every workflow and composite through the same explicit scope. +_actions_inputs := quote(".github/workflows") + " " + quote(".github/actions") + # Semgrep misreads Python 3.15's positive RLIM_INFINITY on Linux. # Keep its inherited stack finite until semgrep/semgrep#11979 is fixed. semgrep_stack_limit := if os() == "linux" { 'if [[ "$(ulimit -Hs)" == unlimited ]]; then ulimit -s 1048576; fi;' } else { "" } @@ -31,7 +34,7 @@ _ci-execution: _ci-rust test-python # Cheap policy failures stop before either execution lane starts. [private] -_ci-policy: action-lint workflow-allowlist-check zizmor markdown-check spell-check _version-check changelog-check toml-parse-check toml-fmt-check toml-lint yaml-fmt-check yaml-lint citation-check validate-json justfile-fmt-check python-check cargo-lock-check fmt-check semgrep semgrep-test unused-deps shell-check +_ci-policy: action-lint actions-check workflow-allowlist-check zizmor markdown-check spell-check _version-check changelog-check toml-parse-check toml-fmt-check toml-lint yaml-fmt-check yaml-lint citation-check validate-json justfile-fmt-check python-check cargo-lock-check fmt-check semgrep semgrep-test unused-deps shell-check # Keep root Cargo outputs and compilation reuse in one sequential lane. [private] @@ -70,7 +73,7 @@ _ensure-yamllint: _ensure-uv # Isolate the supplier runtime from the observed candidate checkout. [positional-arguments] [private] -[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.8", "python", "-I")] +[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.9", "python", "-I")] _release-candidate *args: import runpy from pathlib import Path @@ -80,18 +83,6 @@ _release-candidate *args: with isolated_release_runtime(load(root=root)): runpy.run_path(str(root / "tooling/release_candidate.py"), run_name="__main__") -# Require the GitHub release title and body to match the generated notes. -[private] -_release-notes-check tag: - #!/usr/bin/env bash - set -euo pipefail - tag={{ quote(tag) }} - notes="$(mktemp)" - trap 'rm -f "$notes"' EXIT - uv run --locked --no-sync research-repo-tools changelog notes "$tag" > "$notes" - gh release view "$tag" --repo acgetchell/la-stack --json tagName,name,body | - jq -e --arg tag "$tag" --rawfile notes "$notes" '.tagName == $tag and .name == $tag and ((.body | gsub("\r\n"; "\n") | rtrimstr("\n")) == ($notes | rtrimstr("\n")))' >/dev/null - # Ordinary checks accept unreleased history; final release validation is stricter. [private] _version-check: python-sync @@ -101,6 +92,10 @@ _version-check: python-sync action-lint: _ensure-actionlint uv run --locked research-repo-tools files run --include '.github/workflows/*.yml' --include '.github/workflows/*.yaml' -- actionlint +# Check coupled Actions pins offline in the provisioned environment without syncing. +actions-check: + uv run --locked --no-sync --no-python-downloads --offline research-repo-tools actions check --policy .github/action-updates.toml {{ _actions_inputs }} + # Audit the repository's Python and Rust lockfiles with the managed OSV scanner. audit: uv run --locked --group dev research-repo-tools security osv uv.lock Cargo.lock @@ -368,7 +363,7 @@ fmt-check: {{ _run }} cargo fmt --all -- --check # Check workflow syntax and security findings. -github-actions-check: action-lint workflow-allowlist-check zizmor +github-actions-check: action-lint actions-check workflow-allowlist-check zizmor @echo "✅ GitHub Actions checks complete!" # File validation @@ -508,7 +503,7 @@ release-archive owner="" selection="reviewed": (_release-candidate "archive" own # Use explicit shared asset/recovery operations with an isolated trusted runtime. [positional-arguments] -[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.8", "python", "-I")] +[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.9", "python", "-I")] release-assets +args: import sys from research_repo_tools.cli import main @@ -531,8 +526,8 @@ release-dependencies: # Rebuild declared registry sources and authenticate this machine's installed wheels. release-dependency-builds: python-sync - {{ _run }} cargo fetch --locked - {{ _run }} uv run --locked --no-sync research-repo-tools release dependency-builds + uv run --locked --no-sync research-repo-tools toolchain run --tool cargo -- cargo fetch --locked + uv run --locked --no-sync research-repo-tools toolchain run --tool cargo -- uv run --locked --no-sync research-repo-tools release dependency-builds # Bind the original local acquisition to clean HEAD and signed native CI. release-evidence owner="" selection="reviewed": (_release-candidate "verify" owner "--selection" selection) @@ -540,12 +535,10 @@ release-evidence owner="" selection="reviewed": (_release-candidate "verify" own # Require the release event, reviewed commit, native checks, assets, and notes. release-gate tag: uv run --locked --no-sync research-repo-tools release gate {{ quote(tag) }} - gh api "repos/acgetchell/la-stack/releases/$(jq -er '.release.id' "$GITHUB_EVENT_PATH")" | jq -e '.immutable == true' >/dev/null - just _release-notes-check {{ quote(tag) }} # Verify signed native/Cargo evidence; accept --expected PATH and --github-output PATH. [positional-arguments] -[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.8", "python", "-I")] +[script("uvx", "--no-config", "--isolated", "--managed-python", "--python", "3.15", "--from", "research-repo-tools==0.2.9", "python", "-I")] release-native-evidence *args: import sys import tempfile @@ -568,7 +561,7 @@ release-notes tag: python-sync release-publication owner="" selection="reviewed": (_release-candidate "seal" owner "--selection" selection) # Approve the benchmark-equipped draft as the authenticated maintainer. -release-publish tag owner="" selection="reviewed": (_release-notes-check tag) (_release-candidate "reviewed" owner "--selection" selection) (release-publication owner selection) +release-publish tag owner="" selection="reviewed": (_release-candidate "reviewed" owner "--selection" selection) (release-publication owner selection) uv run --locked --no-sync research-repo-tools release publish {{ quote(tag) }} --approve # Verify the maintainer's dispatch input; never acquire timings or build packages. @@ -718,8 +711,9 @@ toml-parse-check: python-sync uv run --locked research-repo-tools files run --include '*.toml' -- uv run --locked python -c 'import pathlib, sys, tomllib; [tomllib.loads(pathlib.Path(path).read_text(encoding="utf-8")) for path in sys.argv[1:]]' # Check installed tools without synchronization, downloads, or installation. -tools-check: - uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain check +[positional-arguments] +tools-check *args: + uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain check "$@" # Preview obsolete managed installations; pass --apply for explicit removal. [positional-arguments] @@ -727,8 +721,19 @@ tools-clean *args: uv run --locked --no-sync research-repo-tools toolchain clean "$@" # Export verified managed paths to GITHUB_ENV in hosted workflows. -tools-export: - uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export +[positional-arguments] +tools-export *args: + uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export "$@" + +# Run a command with verified tools; optional --tool selections precede --. +[positional-arguments] +tools-run +args: + uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain run "$@" + +# Install selected declared tools, or the complete catalog when no selection is given. +[positional-arguments] +tools-sync *args: + uv run --locked --managed-python --only-group tooling research-repo-tools toolchain sync "$@" # Check for unused direct Cargo dependencies. unused-deps: tools-check @@ -740,8 +745,8 @@ update: update-tools update-dependencies # Update explicitly selected Actions pins; --dry-run and --check only preview. [positional-arguments] -update-actions +args: - uv run --locked research-repo-tools actions update --policy .github/actions-allowlist.json "$@" +update-actions *args: + uv run --locked --only-group tooling --inexact research-repo-tools actions update --policy .github/action-updates.toml {{ _actions_inputs }} "$@" # num-bigint and num-rational share public types and must advance together. update-cargo-dependencies: diff --git a/pyproject.toml b/pyproject.toml index 67fb3e2..285aea2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ ignore = [ [tool.ruff.lint.per-file-ignores] "tests/tooling/test_*.py" = [ "S101", "SLF001", "D101", "D102", "D103" ] +"tests/tooling/support_*.py" = [ "S101" ] # Static-analysis fixtures intentionally contain the patterns these rules reject. "tests/semgrep/scripts/python_portability.py" = [ "D103", "INP001", "N813", "PLW1510", "PTH123", "S603", "S607", "SIM115", "UP020" ] "tests/semgrep/scripts/tests/python_exceptions.py" = [ "BLE001", "D100", "D103", "EM101", "INP001", "S110", "S607", "SIM105" ] @@ -100,11 +101,11 @@ override-dependencies = [ "jsonschema==4.26.0", "pyjwt[crypto]>=2.15.1,<3", "mcp==1.30.0", - "opentelemetry-api==1.45.1", - "opentelemetry-sdk==1.45.1", - "opentelemetry-exporter-otlp-proto-http==1.45.1", - "opentelemetry-instrumentation-requests==0.66b1", - "opentelemetry-instrumentation-threading==0.66b1", + "opentelemetry-api==1.45.2", + "opentelemetry-sdk==1.45.2", + "opentelemetry-exporter-otlp-proto-http==1.45.2", + "opentelemetry-instrumentation-requests==0.66b2", + "opentelemetry-instrumentation-threading==0.66b2", "pywin32==312; sys_platform == 'win32'", "tomli==2.5.0", ] @@ -118,7 +119,7 @@ build = [ "setuptools==84.2.1", "wheel==0.48.0", ] -tooling = [ "research-repo-tools[python-tools,semgrep]==0.2.8" ] +tooling = [ "research-repo-tools[python-tools,semgrep]==0.2.9" ] dev = [ { include-group = "tooling" }, "actionlint-py==1.7.12.25", @@ -167,6 +168,9 @@ persona = "regular" registry = "crates-io" package = "la-stack" repository = "acgetchell/la-stack" +expected-title = "tag" +generated-notes = true +require-immutable = true # CodeRabbit review remains a protected-PR requirement; it does not run on main. required-checks = [ { name = "build (ubuntu-latest)", app-id = 15368 }, diff --git a/tests/tooling/support_evidence.py b/tests/tooling/support_evidence.py new file mode 100644 index 0000000..7293311 --- /dev/null +++ b/tests/tooling/support_evidence.py @@ -0,0 +1,317 @@ +"""Independent release evidence and provider fixtures shared by consumer tests.""" + +import hashlib +import io +import json +import os +import runpy +import shlex +import subprocess +import sys +from contextlib import redirect_stderr +from copy import deepcopy +from pathlib import Path +from typing import Any + +import pytest +from research_repo_tools import process, release_assets, release_evidence, release_interfaces, release_validation +from research_repo_tools.cli import main, parser +from research_repo_tools.config import load +from research_repo_tools.release_interfaces import load_evidence_policy + +REPO_ROOT = Path(__file__).resolve().parents[2] +REPOSITORY = "acgetchell/la-stack" +COMMIT = "a" * 40 +DIGEST = "sha256:" + "b" * 64 +RUN_ENDPOINT = "actions/runs/101" +JOBS_ENDPOINT = "actions/runs/101/attempts/2/jobs?per_page=100&page=1" +ARTIFACTS_ENDPOINT = "actions/runs/101/artifacts?per_page=100&page=1" +ARTIFACT_ENDPOINT = "actions/artifacts/301" +RUNS_ENDPOINT = f"actions/workflows/9/runs?event=push&branch=main&head_sha={COMMIT}&per_page=100&page=1" +INVOCATION = f"https://github.com/{REPOSITORY}/actions/runs/101/attempts/2" +POLICY = load_evidence_policy(REPO_ROOT / "tooling/release-evidence.toml") +NATIVE_GATES = ( + ("prepare (ubuntu-latest)", ("Set up declared tools", "Run CI policy checks"), 201), + ("prepare (macos-latest)", ("Set up declared tools", "Run CI policy checks"), 202), + ("prepare (windows-latest)", ("Set up declared tools", "Run CI policy checks"), 203), + ("release-package", ("Verify default and exact Cargo packages",), 204), + *( + (f"native-{stage} ({platform})", ("Set up declared tools", "Run native validation"), 206 + platform_index * 4 + stage_index) + for platform_index, platform in enumerate(("ubuntu-latest", "macos-latest", "windows-latest")) + for stage_index, stage in enumerate(("rust", "python", "candidate", "dependencies")) + ), +) +NATIVE_RUNNERS = {name: [name.rsplit(" (", 1)[1].removesuffix(")")] for name, _, _ in NATIVE_GATES if name != "release-package"} +SIGNING_STEPS = ( + "Capture successful native validation identities", + "Sign original main validation evidence", + "Upload signed validation evidence", +) +REQUIRED_STEPS = ( + *((index, step) for index, (_, steps, _) in enumerate(NATIVE_GATES) for step in range(len(steps))), + *((len(NATIVE_GATES), index) for index in range(3)), +) + + +def install_clean_checkout(patch: pytest.MonkeyPatch, checkout: Path, commit: str) -> None: + """Supply read-only Git responses to the installed checkout verifier.""" + options = ("--no-pager", "--no-optional-locks", "--no-replace-objects", "-c", "core.fsmonitor=false", "-c", "diff.autoRefreshIndex=false") + + def git(executable: str | Path, args: list[str], *, cwd: Path, timeout: int, **_kwargs: object) -> subprocess.CompletedProcess[bytes]: + assert cwd.samefile(checkout) + assert timeout == 30 + assert Path(executable).is_absolute() + assert tuple(args[: len(options)]) == options + command = tuple(args[len(options) :]) + responses = { + ("rev-parse", "HEAD"): f"{commit}\n".encode("ascii"), + ("ls-files", "-v", "-z"): b"H Cargo.toml\0", + ("submodule", "foreach", "--quiet", "--recursive", shlex.join((Path(executable).as_posix(), *options, "ls-files", "-v", "-z"))): b"", + ("status", "--porcelain", "-z", "--untracked-files=all", "--ignore-submodules=none"): b"", + } + assert command in responses, f"unexpected read-only Git command: {command}" + return subprocess.CompletedProcess(args, 0, stdout=responses[command], stderr=b"") + + patch.setattr(release_assets, "run_command_bytes", git) + + +class EvidenceProvider: + """Keep signed inputs independent from live provider responses.""" + + def __init__(self, root: Path) -> None: + """Create independent signed and provider identities for one CI attempt.""" + self.root = root + self.run: dict[str, Any] = { + "id": 101, + "run_attempt": 2, + "workflow_id": 9, + "path": ".github/workflows/ci.yml", + "name": "CI", + "event": "push", + "head_branch": "main", + "head_sha": COMMIT, + "pull_requests": [], + "repository": {"id": 11, "full_name": REPOSITORY}, + "head_repository": {"id": 11, "full_name": REPOSITORY}, + "status": "completed", + "conclusion": "success", + } + gates = [*NATIVE_GATES, ("release-evidence", SIGNING_STEPS, 205)] + self.jobs: list[dict[str, Any]] = [ + { + "id": identifier, + "name": name, + "run_id": 101, + "run_attempt": 2, + "head_branch": "main", + "head_sha": COMMIT, + "status": "completed", + "conclusion": "success", + "labels": NATIVE_RUNNERS.get(name, ["ubuntu-latest"]), + "steps": [{"number": number, "name": step, "status": "completed", "conclusion": "success"} for number, step in enumerate(steps, 1)], + } + for name, steps, identifier in gates + ] + self.artifact: dict[str, Any] = { + "id": 301, + "name": "release-evidence-101-2", + "expired": False, + "digest": DIGEST, + "size_in_bytes": 512, + "workflow_run": {"id": 101, "head_sha": COMMIT, "head_branch": "main", "repository_id": 11, "head_repository_id": 11}, + } + self.document: dict[str, Any] = { + "schema": "research-repo-tools/release-evidence/v1", + "policy": { + "repository": REPOSITORY, + "workflow": ".github/workflows/ci.yml", + "workflow_name": "CI", + "ref": "refs/heads/main", + "event": "push", + "required_steps": {name: list(steps) for name, steps, _ in NATIVE_GATES}, + "runner_labels": deepcopy(NATIVE_RUNNERS), + "artifact_prefix": "release-evidence", + "guarantee": "signed-source", + "signing_job": {"release-evidence": list(SIGNING_STEPS)}, + "path_in_vcs": "", + }, + "run": { + "id": 101, + "run_attempt": 2, + "head_sha": COMMIT, + "head_branch": "main", + "workflow_id": 9, + "path": ".github/workflows/ci.yml", + "name": "CI", + "event": "push", + "repository_id": 11, + "head_repository_id": 11, + }, + "jobs": {name: identifier for name, _, identifier in NATIVE_GATES}, + "package": {"name": "la-stack", "version": "0.5.42"}, + } + self.signature = [{"verificationResult": {"signature": {"certificate": {"runInvocationURI": INVOCATION, "buildTrigger": "push"}}}}] + self.responses: dict[str, Any] = { + "actions/workflows/ci.yml": {"id": 9, "path": ".github/workflows/ci.yml", "name": "CI", "state": "active"}, + RUNS_ENDPOINT: {"workflow_runs": [self.run]}, + RUN_ENDPOINT: self.run, + JOBS_ENDPOINT: {"jobs": self.jobs}, + ARTIFACTS_ENDPOINT: {"artifacts": [self.artifact]}, + ARTIFACT_ENDPOINT: self.artifact, + } + self.scripted: dict[str, list[Any]] = {} + self.api_calls: list[str] = [] + self.gh_calls: list[tuple[str, ...]] = [] + self.downloads: list[tuple[str, dict[str, Any], Path, tuple[str, ...]]] = [] + self.document_text: str | None = None + self.signature_text: str | None = None + + def api(self, endpoint: str, *, repository: str) -> Any: + """Return an isolated response while recording authenticated requests.""" + assert repository == REPOSITORY + self.api_calls.append(endpoint) + if endpoint in self.scripted: + return deepcopy(self.scripted[endpoint].pop(0)) + assert endpoint in self.responses, f"unexpected authenticated request: {endpoint}" + return deepcopy(self.responses[endpoint]) + + def git(self, args: list[str], **kwargs: Any) -> subprocess.CompletedProcess[str]: + """Supply the exact clean checkout identity to the subprocess verifier.""" + assert "rev-parse" in args or "status" in args + assert kwargs["cwd"] == self.root + assert kwargs["timeout"] == 30 + return subprocess.CompletedProcess(args, 0, stdout=COMMIT + "\n" if "rev-parse" in args else "", stderr="") + + def gh(self, *args: str) -> str: + """Return the selected attestation response without a provider process.""" + assert args[:2] == ("attestation", "verify") + self.gh_calls.append(args) + return self.signature_text if self.signature_text is not None else json.dumps(self.signature) + + def download(self, repository: str, artifact: dict[str, Any], directory: Path, names: tuple[str, ...], **bounds: int) -> None: + """Write the independently authored evidence and signature fixture.""" + # ZIP authentication and extraction are covered by the shared package. + # This boundary supplies only the adapter's two extracted input files. + self.downloads.append((repository, deepcopy(artifact), directory, names)) + assert names == ("validation.json", "validation.sigstore.json") + assert bounds == {"max_bytes": 32 * 1024 * 1024, "max_expanded_bytes": 32 * 1024 * 1024} + directory.mkdir() + payload = self.document_text if self.document_text is not None else json.dumps(self.document) + (directory / "validation.json").write_text(payload, encoding="utf-8") + (directory / "validation.sigstore.json").write_text('{"fixture":"signed bundle"}', encoding="utf-8") + + def verify(self, identity: str | None = None) -> dict[str, Any]: + """Exercise the public verifier with independently authored signed data.""" + return json.loads( + release_evidence.verify_release_evidence( + POLICY, + "0.5.42", + COMMIT, + lambda endpoint: self.api(endpoint, repository=REPOSITORY), + expected=identity.encode() if identity is not None else None, + ) + ) + + def seal(self, output: Path) -> None: + """Exercise the installed producer including its environment/output guards.""" + args = parser().parse_args( + [ + "release", + "evidence", + "create", + "tooling/release-evidence.toml", + "--checkout", + str(self.root), + "--commit", + COMMIT, + "--version", + "0.5.42", + "--run-id", + "101", + "--attempt", + "2", + "--output", + str(output), + ] + ) + release_interfaces.run_evidence(args, load(root=self.root)) + + def install(self, patch: pytest.MonkeyPatch) -> None: + """Fake authenticated services and Git observations, leaving policy/CLI real.""" + patch.setattr(release_interfaces, "api", self.api) + patch.setattr(release_validation, "gh", self.gh) + patch.setattr(release_evidence, "download_artifact", self.download) + install_clean_checkout(patch, self.root, COMMIT) + + def cli(self, *args: str) -> int: + """Run the installed verifier with the fixture's exact source selection.""" + return main( + [ + "--root", + str(self.root), + "release", + "evidence", + "verify", + "tooling/release-evidence.toml", + "--checkout", + str(self.root), + "--commit", + COMMIT, + "--version", + "0.5.42", + "--output", + str(self.root / "selection.json"), + *args, + ] + ) + + +def expected_identity() -> str: + """Independent approval record for the fixture's literal signed bytes.""" + provider = EvidenceProvider(Path()) + selected = { + **provider.document, + "schema": "research-repo-tools/release-selection/v1", + "jobs": {**provider.document["jobs"], "release-evidence": 205}, + "artifact": {key: provider.artifact[key] for key in ("id", "name", "digest", "size_in_bytes")}, + "manifest_sha256": hashlib.sha256(json.dumps(provider.document).encode()).hexdigest(), + } + return json.dumps(selected, sort_keys=True, separators=(",", ":")) + + +PIN_JSON = expected_identity() + + +def run_evidence_fixture() -> int: + """Run the real verifier in a child process with simulated provider responses.""" + root = Path(os.environ["FIXTURE_ROOT"]) + provider = EvidenceProvider(root) + if os.environ.get("FIXTURE_FAILURE") == "failed-job": + provider.jobs[3]["steps"][0]["conclusion"] = "failure" + newline = os.environ.get("FIXTURE_DIAGNOSTIC_NEWLINE", os.linesep) + sys.stdout.buffer.write(("fixture stdout diagnostic" + newline).encode("utf-8")) + sys.stdout.flush() + print("fixture stderr diagnostic", file=sys.stderr) + diagnostic = io.StringIO() + script, *arguments = sys.argv[1:] + with pytest.MonkeyPatch.context() as patch: + provider.install(patch) + patch.setattr(process, "run_git_command", provider.git) + # The uv launcher needs the real test environment; provenance observes + # only the dependency-free release fixture after process startup. + patch.delenv("UV_PROJECT", raising=False) + patch.delenv("UV_PROJECT_ENVIRONMENT", raising=False) + with redirect_stderr(diagnostic): + try: + sys.argv[:] = [script, *arguments] + runpy.run_path(script, run_name="__main__") + status = 0 + except SystemExit as error: + status = error.code + assert isinstance(status, int) + print(diagnostic.getvalue(), end="", file=sys.stderr) + # Just's quiet mode hides stderr. Record the actual verifier outcome so an + # import/shell failure cannot masquerade as the rejection under test. + result = {"status": status, "diagnostic": diagnostic.getvalue(), "import_root": sys.path[0], "arguments": arguments} + (root / "verifier-result.json").write_text(json.dumps(result), encoding="utf-8") + return status diff --git a/tests/tooling/support_toolchain.py b/tests/tooling/support_toolchain.py new file mode 100644 index 0000000..ee13fda --- /dev/null +++ b/tests/tooling/support_toolchain.py @@ -0,0 +1,29 @@ +"""Declared supplier selection shared by installed-runtime consumer fixtures.""" + +import tomllib +from pathlib import Path + +from packaging.requirements import Requirement +from research_repo_tools.dependency_provenance import check_development_dependency + +REPO_ROOT = Path(__file__).resolve().parents[2] + + +def tooling_requirement(root: Path) -> str: + """Select the declared supplier after RRT verifies any development source.""" + document = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8")) + (raw,) = document["dependency-groups"]["tooling"] + requirement = Requirement(raw) + (pin,) = requirement.specifier + assert requirement.name == "research-repo-tools" + assert requirement.url is None + assert requirement.marker is None + assert pin.operator == "==" + assert "*" not in pin.version + development = check_development_dependency(root, document=document) + if development is not None: + return f"{requirement.name} @ git+{development.source}@{development.revision}" + return f"{requirement.name}{requirement.specifier}" + + +TOOLING_REQUIREMENT = tooling_requirement(REPO_ROOT) diff --git a/tests/tooling/test_candidate_transfer.py b/tests/tooling/test_candidate_transfer.py index 584e8cb..5686232 100644 --- a/tests/tooling/test_candidate_transfer.py +++ b/tests/tooling/test_candidate_transfer.py @@ -10,6 +10,7 @@ import pytest import yaml +from research_repo_tools import release_staging from research_repo_tools.release_assets import GitHubRelease, ReleaseTarget, serialize_release_target from tooling import release_candidate as candidate @@ -225,7 +226,7 @@ def interrupted(*_args: object, **_kwargs: object) -> None: message = "interrupted upload" raise OSError(message) - monkeypatch.setattr(candidate, "publish_release_asset", interrupted) + monkeypatch.setattr(candidate, "stage_release_assets", interrupted) with pytest.raises(OSError, match="interrupted upload"): candidate.stage(root, owner, "reviewed", prepared) @@ -235,7 +236,7 @@ def replaced(_root: Path, target: ReleaseTarget, **_kwargs: object) -> None: raise ValueError(message) monkeypatch.setattr(candidate, "revalidate_release_target", replaced) - monkeypatch.setattr(candidate, "publish_release_asset", lambda *_args, **_kwargs: pytest.fail("replacement draft must never receive an upload")) + monkeypatch.setattr(candidate, "stage_release_assets", lambda *_args, **_kwargs: pytest.fail("replacement draft must never receive an upload")) with pytest.raises(ValueError, match="original draft no longer exists"): candidate.stage(root, owner, "reviewed", prepared) prepared.write_bytes(serialize_release_target(replace(original, release_id=43))) @@ -261,6 +262,65 @@ def test_staging_rejects_malformed_owner_digest_before_provider_access(tmp_path: assert not (final / "target.json").exists() +def test_shared_batch_retains_domain_transfer_and_original_asset_ids(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + root, owner = tmp_path / "checkout", tmp_path / "owner" + root.mkdir() + final = candidate.final_directory(owner, SHA, "reviewed") + final.mkdir(parents=True) + for name in ("policy.json", "acceptance.json", "archive.tar.gz"): + (final / name).write_bytes(name.encode() + b"\r\n\xff") + (owner / "publication.json").write_bytes(b"original publication\r\n") + for name in ("acquisition.sha256", "publication.sha256"): + (owner / name).write_bytes(b"a" * 64) + target = ReleaseTarget(candidate.REPOSITORY, TAG, 42, SHA, TAG) + prepared = tmp_path / "target.json" + prepared.write_bytes(serialize_release_target(target)) + monkeypatch.setattr(candidate, "verify", lambda *_args: final / "acceptance.json") + monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) + monkeypatch.setattr(candidate, "archive", lambda *_args: final / "archive.tar.gz") + monkeypatch.setattr(candidate, "parse_candidate_policy", lambda *_args: SimpleNamespace(tag=TAG)) + monkeypatch.setattr("research_repo_tools.dependency_provenance.check_release_dependencies", lambda *_args, **_kwargs: ()) + assets: dict[str, tuple[str, int, int, str]] = {} + + def release(*_args: object, **_kwargs: object) -> GitHubRelease: + return GitHubRelease( + repository=candidate.REPOSITORY, + tag=TAG, + identifier=42, + draft=True, + immutable=False, + prerelease=False, + title=TAG, + assets=tuple(assets.values()), + asset_states=tuple((entry[1], "uploaded") for entry in assets.values()), + ) + + def upload(_root: Path, observed: ReleaseTarget, name: str, payload: bytes, **_kwargs: object) -> tuple[str, int, int, str]: + assert observed == target + entry = name, len(assets) + 1, len(payload), hashlib.sha256(payload).hexdigest() + return assets.setdefault(name, entry) + + monkeypatch.setattr(candidate, "revalidate_release_target", release) + monkeypatch.setattr(release_staging, "_observe_release_target", release) + monkeypatch.setattr(release_staging, "_upload_asset", upload) + transfer_path = candidate.stage(root, owner, "reviewed", prepared) + original = transfer_path.read_bytes() + assert candidate.stage(root, owner, "reviewed", prepared).read_bytes() == original + transfer = candidate.require_draft_transfer(candidate.parse_transfer(original)) + assert transfer.target == target + assert len(assets) == 4 + assert (final / "staging.json").read_bytes() == (final / "staged-assets.json").read_bytes() + for role, assertion in transfer.assets.role_assertions(): + assert assertion.name == f"la-stack-{TAG}-reviewed-candidate-{role}.{'tar.gz' if role == 'archive' else 'json'}" + assert assertion.identifier == assets[assertion.name][1] + name = next(iter(assets)) + entry = assets[name] + assets[name] = entry[0], 999, entry[2], entry[3] + with pytest.raises(ValueError, match="previously verified asset ID was replaced"): + candidate.stage(root, owner, "reviewed", prepared) + assert transfer_path.read_bytes() == original + + def test_owner_records_reject_overwrite_and_path_escape(tmp_path: Path) -> None: candidate.freeze(tmp_path, {"record": b"original"}) candidate.freeze(tmp_path, {"record": b"original"}) @@ -299,7 +359,7 @@ def original(_root: Path, observed: ReleaseTarget, **_kwargs: object) -> None: raise ValueError(message) monkeypatch.setattr(candidate, "revalidate_release_target", original) - monkeypatch.setattr(candidate, "publish_release_asset", lambda *_args, **_kwargs: pytest.fail("a different prepared target must receive no uploads")) + monkeypatch.setattr(candidate, "stage_release_assets", lambda *_args, **_kwargs: pytest.fail("a different prepared target must receive no uploads")) diagnostic = "original prepared draft no longer exists" if field == "release_id" else "staging target differs" with pytest.raises(ValueError, match=diagnostic): candidate.stage(root, owner, "reviewed", prepared) @@ -389,20 +449,21 @@ def test_explicit_review_selection_preserves_previous_acceptance(tmp_path: Path, owner.mkdir() for name in ("policy.json", "acquisition.sha256", "publication.sha256"): (owner / name).write_bytes(b"a" * 64) - monkeypatch.setattr(candidate, "check_release_dependencies", lambda *_args: None) monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) - # Binding behavior is covered by the full synthetic acquisition test. - monkeypatch.setattr(candidate, "parse_candidate_policy", lambda *_args: ReleaseTarget(candidate.REPOSITORY, TAG, 42, SHA, TAG)) - monkeypatch.setattr(candidate, "serialize_candidate_policy", serialize_release_target) requests: list[list[str]] = [] def shared(arguments: list[str]) -> int: requests.append(arguments) output = Path(arguments[arguments.index("--output") + 1]) - selected = Path(arguments[arguments.index("--policy") + 1]).parent.name + assert Path(arguments[arguments.index("--policy") + 1]) == owner / "policy.json" + assert arguments[arguments.index("--commit") + 1] == SHA + selected = Path(arguments[arguments.index("--policy-output") + 1]).parent.name value = selected.encode() if "--acceptance" in arguments: - assert Path(arguments[arguments.index("--acceptance") + 1]).read_bytes() == value + expected = Path(arguments[arguments.index("--acceptance") + 1]) + assert expected != output + assert expected.read_bytes() == value + output.parent.mkdir(parents=True, exist_ok=True) output.write_bytes(value) return 0 diff --git a/tests/tooling/test_maintenance_integration.py b/tests/tooling/test_maintenance_integration.py index 75f86ca..0d9306b 100644 --- a/tests/tooling/test_maintenance_integration.py +++ b/tests/tooling/test_maintenance_integration.py @@ -5,6 +5,7 @@ import re import shlex import shutil +import subprocess import sys import sysconfig import tomllib @@ -14,14 +15,93 @@ import pytest from packaging.requirements import Requirement from packaging.version import Version -from research_repo_tools import semgrep_tool +from research_repo_tools import action_updates, semgrep_tool from research_repo_tools.cli import main -from research_repo_tools.just_inspect import dry_run +from research_repo_tools.just_inspect import dry_run, inspect_justfile from research_repo_tools.process import run_command REPO_ROOT = Path(__file__).resolve().parents[2] +@pytest.fixture +def actions_consumer(tmp_path: Path) -> Path: + """Keep the real coupled pins and separate allowlist in a disposable tree.""" + shutil.copytree(REPO_ROOT / ".github", tmp_path / ".github") + return tmp_path + + +def actions_arguments(recipe: str, *extra: str) -> list[str]: + """Exercise the installed Just parser before invoking the shared CLI.""" + command = shlex.split(dry_run(REPO_ROOT, recipe, list(extra)).stderr) + if recipe == "update-actions": + assert "positional-arguments" in inspect_justfile(REPO_ROOT).recipes[recipe]["attributes"] + assert command.pop() == "$@" + command.extend(extra) + return command[command.index("actions") :] + + +@pytest.mark.parametrize("changed", [None, "setup-uv", "codeql-init", "codeql-analyze", "codeql-upload"]) +def test_offline_actions_check_rejects_partial_coupled_bumps_without_writes( + actions_consumer: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], changed: str | None +) -> None: + details = None + if changed is not None: + filename, identity = { + "setup-uv": ("actions/setup-tools/action.yml", "astral-sh/setup-uv"), + "codeql-init": ("workflows/codeql.yml", "github/codeql-action/init"), + "codeql-analyze": ("workflows/codeql.yml", "github/codeql-action/analyze"), + "codeql-upload": ("workflows/rust-clippy.yml", "github/codeql-action/upload-sarif"), + }[changed] + details = filename, identity + path = actions_consumer / ".github" / filename + source = path.read_text(encoding="utf-8") + source, count = re.subn(rf"({re.escape(identity)}@)[0-9a-f]{{40}} # v[0-9.]+", rf"\g<1>{'a' * 40} # v99.0.0", source, count=1) + assert count == 1 + path.write_text(source, encoding="utf-8", newline="\n") + arguments = actions_arguments("actions-check") + command = shlex.split(dry_run(REPO_ROOT, "actions-check").stderr) + assert all(option in command for option in ("--no-sync", "--no-python-downloads", "--offline")) + before = snapshot(actions_consumer) + monkeypatch.setattr(subprocess, "run", lambda *_args, **_kwargs: pytest.fail("offline pin checks must not launch gh or another process")) + assert main(["--root", str(actions_consumer), *arguments]) == (0 if changed is None else 1) + assert snapshot(actions_consumer) == before + if details is not None: + filename, identity = details + diagnostic = capsys.readouterr().err + assert identity in diagnostic + assert filename in diagnostic + + +@pytest.mark.parametrize("mode", ["--dry-run", "--check", "apply"]) +def test_actions_updater_uses_the_checked_scope_and_keeps_allowlist_separate(actions_consumer: Path, monkeypatch: pytest.MonkeyPatch, mode: str) -> None: + check = actions_arguments("actions-check") + update = actions_arguments("update-actions", *([] if mode == "apply" else [mode])) + assert check[2:] == update[2 : len(check)] + policy = tomllib.loads((actions_consumer / ".github/action-updates.toml").read_text(encoding="utf-8")) + codeql = {tag for name, tag in policy["actions"].items() if name.startswith("github/codeql-action/")} + assert len(codeql) == 1 + assert "latest" not in codeql + observed: set[str] = set() + + def resolve(action: str, target: str, root: Path) -> tuple[str, str]: + assert root == actions_consumer + observed.add(action) + return "a" * 40, "v99.0.0" if target == "latest" else target + + monkeypatch.setattr(action_updates, "resolve", resolve) + before = snapshot(actions_consumer) + assert main(["--root", str(actions_consumer), *update]) == (1 if mode == "--check" else 0) + assert observed == set(policy["actions"]) + after = snapshot(actions_consumer) + if mode != "apply": + assert after == before + else: + assert after[".github/actions-allowlist.json"] == before[".github/actions-allowlist.json"] + assert after[".github/actions/setup-tools/action.yml"] != before[".github/actions/setup-tools/action.yml"] + assert after[".github/workflows/codeql.yml"] != before[".github/workflows/codeql.yml"] + assert main(["--root", str(actions_consumer), *check]) == 0 + + @pytest.fixture def consumer(tmp_path: Path) -> Path: """Copy release inputs and real documentation, without live repository state.""" @@ -176,7 +256,7 @@ def test_semgrep_runs_in_the_root_python_315_environment_with_compatible_depende lock = tomllib.loads((REPO_ROOT / "uv.lock").read_text(encoding="utf-8")) versions = {package["name"]: Version(package["version"]) for package in lock["package"]} assert versions["pywin32"] == Version("312") - for name, vulnerable, patched in (("mcp", "1.29.0", "1.30.0"), ("opentelemetry-api", "1.45.0", "1.45.1"), ("pyjwt", "2.15.0", "2.15.1")): + for name, vulnerable, patched in (("mcp", "1.29.0", "1.30.0"), ("opentelemetry-api", "1.45.0", "1.45.2"), ("pyjwt", "2.15.0", "2.15.1")): assert Version(vulnerable) not in overrides[name] assert Version(patched) in overrides[name] assert versions[name] in overrides[name] diff --git a/tests/tooling/test_release_baseline.py b/tests/tooling/test_release_baseline.py index bd5d9dd..b9eb59b 100644 --- a/tests/tooling/test_release_baseline.py +++ b/tests/tooling/test_release_baseline.py @@ -10,7 +10,6 @@ import tarfile import tomllib from pathlib import Path -from urllib.parse import urlsplit import pytest import yaml @@ -18,7 +17,7 @@ from research_repo_tools.host_metadata import HostMetadata, serialize_host from research_repo_tools.process import run_command -from tests.tooling.test_toolchain_integration import TOOLING_REQUIREMENT +from tests.tooling.support_toolchain import TOOLING_REQUIREMENT REPO_ROOT = Path(__file__).resolve().parents[2] WORKFLOW = REPO_ROOT / ".github/workflows/release-benchmarks.yml" @@ -95,12 +94,6 @@ def run_shell(script: str, cwd: Path, extra_env: dict[str, str], *, timeout: int ) -def installed_runner() -> str: - """Keep workflow package assertions while using the installed locked CLI.""" - command = f"{shlex.quote(sys.executable)} -I -X utf8 -m research_repo_tools" - return f'uvx() {{ [[ "$1 $2 $3 $4 $5" == "--python 3.15 --from {TOOLING_REQUIREMENT} research-repo-tools" ]] || return 90; shift 5; {command} "$@"; }}\n' - - def package_suites(root: Path, manifest: Path, criterion: Path) -> None: """Execute the workflow's installed CLI with all independently required cases.""" destination = root / "target/release-suites" @@ -386,105 +379,3 @@ def test_retry_requires_current_retrieval(tmp_path: Path, validated_attempt: str {"VALIDATED_ATTEMPT": validated_attempt, "GITHUB_RUN_ATTEMPT": "2"}, ) assert result.returncode == (0 if validated_attempt == "2" else 1) - - -GH_FIXTURE = r"""import hashlib, json, os, sys -from pathlib import Path -from urllib.parse import urlsplit -args = sys.argv[1:] -root = Path(os.environ["RELEASE_FIXTURE"]) -tag = os.environ["RELEASE_TAG"] -asset = os.environ["RELEASE_ASSET"] -with (root / "api-calls").open("a", encoding="utf-8") as stream: - stream.write(json.dumps(args) + "\n") -metadata = {"id": 7, "name": asset, "size": len((root / asset).read_bytes()), - "digest": "sha256:" + hashlib.sha256((root / asset).read_bytes()).hexdigest(), "state": "uploaded"} -assets = [metadata] if (root / "uploaded").exists() else [] -release = {"id": 42, "url": "https://api.github.com/repos/owner/repo/releases/42", "tag_name": tag, - "name": tag, "draft": True, "prerelease": False, "immutable": False, "assets": assets} -if any(item.endswith("/releases?per_page=100") for item in args): - value = [[release]] -elif args[0] == "release": - value = {"databaseId": 42, "tagName": tag} -elif any(urlsplit(item).hostname == "uploads.github.com" for item in args): - (root / "uploaded").touch() - value = {} -elif "PATCH" in args: - (root / "published").touch() - value = dict(release, draft=False, immutable=True) -elif args[1].endswith("/releases/assets/7"): - sys.stdout.buffer.write((root / asset).read_bytes()) - raise SystemExit(0) -elif "/git/ref/tags/" in args[1]: - value = {"ref": "refs/tags/" + tag, "object": {"type": "commit", "sha": os.environ.get("REMOTE_COMMIT", "a" * 40)}} -elif any("/assets?" in item for item in args): - value = [assets] -else: - value = release -print(json.dumps(value)) -""" - - -def test_installed_cli_binds_trusted_target_and_leaves_draft_for_review(tmp_path: Path) -> None: - """Exercise actual preflight and writer shell with the pinned installed CLI.""" - fixture = tmp_path / "provider with spaces" - fixture.mkdir() - program = fixture / "gh_fixture.py" - program.write_text(GH_FIXTURE, encoding="utf-8") - if os.name == "nt": - executable = fixture / "gh.cmd" - executable.write_text(f'@"{sys.executable}" "%~dp0gh_fixture.py" %*\r\n', encoding="utf-8", newline="") - else: - executable = fixture / "gh" - executable.write_text(f'#!/bin/sh\nexec {shlex.quote(sys.executable)} {shlex.quote(str(program))} "$@"\n', encoding="utf-8") - executable.chmod(0o755) - asset = f"la-stack-{BASELINE}-criterion-baseline.tar.gz" - (fixture / asset).write_bytes(b"raw archive\r\n\xff") - output = fixture / "outputs" - env = { - "PATH": str(fixture) + os.pathsep + os.environ["PATH"], - "RELEASE_FIXTURE": str(fixture), - "RELEASE_TAG": BASELINE, - "RELEASE_ASSET": asset, - "GH_REPO": "owner/repo", - "GITHUB_REF": f"refs/tags/{BASELINE}", - "GITHUB_SHA": "a" * 40, - "GITHUB_OUTPUT": output.as_posix(), - "RUNNER_TEMP": fixture.as_posix(), - "GITHUB_WORKSPACE": fixture.as_posix(), - } - # Substitute only uvx's environment acquisition; retain its exact package - # arguments and execute the already locked package in a real child process. - runner = installed_runner() - preflight = ( - "set -euo pipefail\n" - f"uvx --python 3.15 --from {shlex.quote(TOOLING_REQUIREMENT)} research-repo-tools " - '--root "$RUNNER_TEMP" performance release-draft "$GH_REPO" "$RELEASE_TAG" ' - '--commit "$GITHUB_SHA" --expected-title "$RELEASE_TAG" > "$GITHUB_OUTPUT"\n' - ) - upload = ( - "set -euo pipefail\n" - 'printf "%s" "$RELEASE_TARGET" > "$RUNNER_TEMP/release-target.json"\n' - f"uvx --python 3.15 --from {shlex.quote(TOOLING_REQUIREMENT)} research-repo-tools " - '--root "$RUNNER_TEMP" performance release-upload "$GH_REPO" "$RELEASE_TAG" ' - '"$RUNNER_TEMP/$RELEASE_ASSET" --target "$RUNNER_TEMP/release-target.json"\n' - ) - result = run_shell(runner + preflight, fixture, env) - assert result.returncode == 0, result.stderr - target = output.read_text(encoding="utf-8").strip().removeprefix("target=") - assert json.loads(target)["release_id"] == 42 - assert json.loads(target)["commit"] == "a" * 40 - assert json.loads(target)["expected_title"] == BASELINE - stale = run_shell(runner + upload, fixture, {**env, "RELEASE_TARGET": target, "REMOTE_COMMIT": "b" * 40}) - assert stale.returncode != 0 - assert not (fixture / "uploaded").exists() - assert not (fixture / "published").exists() - stale_calls = [json.loads(line) for line in (fixture / "api-calls").read_text(encoding="utf-8").splitlines()] - assert not any(urlsplit(item).hostname == "uploads.github.com" for call in stale_calls for item in call) - result = run_shell(runner + upload, fixture, {**env, "RELEASE_TARGET": target}) - assert result.returncode == 0, result.stderr - assert (fixture / "uploaded").exists() - assert not (fixture / "published").exists() - calls = [json.loads(line) for line in (fixture / "api-calls").read_text(encoding="utf-8").splitlines()] - assert not any("PATCH" in call for call in calls) - assert any("/releases/assets/7" in item for call in calls for item in call) diff --git a/tests/tooling/test_release_context.py b/tests/tooling/test_release_context.py index 9627abf..51f3b88 100644 --- a/tests/tooling/test_release_context.py +++ b/tests/tooling/test_release_context.py @@ -375,7 +375,7 @@ def test_publish_recipe_requires_review_before_reaching_publication(tmp_path: Pa ) marker = root / "published" overrides = ( - "\n_release-notes-check tag:\n @true\n\n[positional-arguments]\n_release-candidate *args:\n " + "\n[positional-arguments]\n_release-candidate *args:\n " f'{shlex.quote(Path(sys.executable).as_posix())} -I {shlex.quote(bootstrap.as_posix())} "$@"\n\n' + header + f"\n touch {shlex.quote(marker.as_posix())}\n" diff --git a/tests/tooling/test_release_evidence.py b/tests/tooling/test_release_evidence.py index e6f9eaf..a3abc7d 100644 --- a/tests/tooling/test_release_evidence.py +++ b/tests/tooling/test_release_evidence.py @@ -1,275 +1,30 @@ """Verify consumer evidence policy through the installed release interfaces.""" -import hashlib import json -import shlex import subprocess from copy import deepcopy -from pathlib import Path -from typing import Any +from typing import TYPE_CHECKING, Any import pytest -from research_repo_tools import release_assets, release_evidence, release_interfaces, release_validation -from research_repo_tools.cli import main, parser -from research_repo_tools.config import load -from research_repo_tools.release_interfaces import load_evidence_policy - -REPO_ROOT = Path(__file__).resolve().parents[2] -REPOSITORY = "acgetchell/la-stack" -COMMIT = "a" * 40 -DIGEST = "sha256:" + "b" * 64 -RUN_ENDPOINT = "actions/runs/101" -JOBS_ENDPOINT = "actions/runs/101/attempts/2/jobs?per_page=100&page=1" -ARTIFACTS_ENDPOINT = "actions/runs/101/artifacts?per_page=100&page=1" -ARTIFACT_ENDPOINT = "actions/artifacts/301" -RUNS_ENDPOINT = f"actions/workflows/9/runs?event=push&branch=main&head_sha={COMMIT}&per_page=100&page=1" -INVOCATION = f"https://github.com/{REPOSITORY}/actions/runs/101/attempts/2" -POLICY = load_evidence_policy(REPO_ROOT / "tooling/release-evidence.toml") -NATIVE_GATES = ( - ("prepare (ubuntu-latest)", ("Set up declared tools", "Run CI policy checks"), 201), - ("prepare (macos-latest)", ("Set up declared tools", "Run CI policy checks"), 202), - ("prepare (windows-latest)", ("Set up declared tools", "Run CI policy checks"), 203), - ("release-package", ("Verify default and exact Cargo packages",), 204), - *( - (f"native-{stage} ({platform})", ("Set up declared tools", "Run native validation"), 206 + platform_index * 4 + stage_index) - for platform_index, platform in enumerate(("ubuntu-latest", "macos-latest", "windows-latest")) - for stage_index, stage in enumerate(("rust", "python", "candidate", "dependencies")) - ), +from research_repo_tools import release_validation + +from tests.tooling.support_evidence import ( + ARTIFACT_ENDPOINT, + ARTIFACTS_ENDPOINT, + COMMIT, + DIGEST, + INVOCATION, + JOBS_ENDPOINT, + REPO_ROOT, + REPOSITORY, + REQUIRED_STEPS, + RUN_ENDPOINT, + RUNS_ENDPOINT, + EvidenceProvider, ) -NATIVE_RUNNERS = {name: [name.rsplit(" (", 1)[1].removesuffix(")")] for name, _, _ in NATIVE_GATES if name != "release-package"} -SIGNING_STEPS = ( - "Capture successful native validation identities", - "Sign original main validation evidence", - "Upload signed validation evidence", -) -REQUIRED_STEPS = ( - *((index, step) for index, (_, steps, _) in enumerate(NATIVE_GATES) for step in range(len(steps))), - *((len(NATIVE_GATES), index) for index in range(3)), -) - - -def install_clean_checkout(patch: pytest.MonkeyPatch, checkout: Path, commit: str) -> None: - """Supply read-only Git responses to the installed checkout verifier.""" - options = ("--no-pager", "--no-optional-locks", "--no-replace-objects", "-c", "core.fsmonitor=false", "-c", "diff.autoRefreshIndex=false") - - def git(executable: str | Path, args: list[str], *, cwd: Path, timeout: int, **_kwargs: object) -> subprocess.CompletedProcess[bytes]: - assert cwd.samefile(checkout) - assert timeout == 30 - assert Path(executable).is_absolute() - assert tuple(args[: len(options)]) == options - command = tuple(args[len(options) :]) - responses = { - ("rev-parse", "HEAD"): f"{commit}\n".encode("ascii"), - ("ls-files", "-v", "-z"): b"H Cargo.toml\0", - ("submodule", "foreach", "--quiet", "--recursive", shlex.join((Path(executable).as_posix(), *options, "ls-files", "-v", "-z"))): b"", - ("status", "--porcelain", "-z", "--untracked-files=all", "--ignore-submodules=none"): b"", - } - assert command in responses, f"unexpected read-only Git command: {command}" - return subprocess.CompletedProcess(args, 0, stdout=responses[command], stderr=b"") - - patch.setattr(release_assets, "run_command_bytes", git) - - -class EvidenceProvider: - """Keep signed inputs independent from live provider responses.""" - - def __init__(self, root: Path) -> None: - """Create independent signed and provider identities for one CI attempt.""" - self.root = root - self.run: dict[str, Any] = { - "id": 101, - "run_attempt": 2, - "workflow_id": 9, - "path": ".github/workflows/ci.yml", - "name": "CI", - "event": "push", - "head_branch": "main", - "head_sha": COMMIT, - "pull_requests": [], - "repository": {"id": 11, "full_name": REPOSITORY}, - "head_repository": {"id": 11, "full_name": REPOSITORY}, - "status": "completed", - "conclusion": "success", - } - gates = [*NATIVE_GATES, ("release-evidence", SIGNING_STEPS, 205)] - self.jobs: list[dict[str, Any]] = [ - { - "id": identifier, - "name": name, - "run_id": 101, - "run_attempt": 2, - "head_branch": "main", - "head_sha": COMMIT, - "status": "completed", - "conclusion": "success", - "labels": NATIVE_RUNNERS.get(name, ["ubuntu-latest"]), - "steps": [{"number": number, "name": step, "status": "completed", "conclusion": "success"} for number, step in enumerate(steps, 1)], - } - for name, steps, identifier in gates - ] - self.artifact: dict[str, Any] = { - "id": 301, - "name": "release-evidence-101-2", - "expired": False, - "digest": DIGEST, - "size_in_bytes": 512, - "workflow_run": {"id": 101, "head_sha": COMMIT, "head_branch": "main", "repository_id": 11, "head_repository_id": 11}, - } - self.document: dict[str, Any] = { - "schema": "research-repo-tools/release-evidence/v1", - "policy": { - "repository": REPOSITORY, - "workflow": ".github/workflows/ci.yml", - "workflow_name": "CI", - "ref": "refs/heads/main", - "event": "push", - "required_steps": {name: list(steps) for name, steps, _ in NATIVE_GATES}, - "runner_labels": deepcopy(NATIVE_RUNNERS), - "artifact_prefix": "release-evidence", - "guarantee": "signed-source", - "signing_job": {"release-evidence": list(SIGNING_STEPS)}, - "path_in_vcs": "", - }, - "run": { - "id": 101, - "run_attempt": 2, - "head_sha": COMMIT, - "head_branch": "main", - "workflow_id": 9, - "path": ".github/workflows/ci.yml", - "name": "CI", - "event": "push", - "repository_id": 11, - "head_repository_id": 11, - }, - "jobs": {name: identifier for name, _, identifier in NATIVE_GATES}, - "package": {"name": "la-stack", "version": "0.5.42"}, - } - self.signature = [{"verificationResult": {"signature": {"certificate": {"runInvocationURI": INVOCATION, "buildTrigger": "push"}}}}] - self.responses: dict[str, Any] = { - "actions/workflows/ci.yml": {"id": 9, "path": ".github/workflows/ci.yml", "name": "CI", "state": "active"}, - RUNS_ENDPOINT: {"workflow_runs": [self.run]}, - RUN_ENDPOINT: self.run, - JOBS_ENDPOINT: {"jobs": self.jobs}, - ARTIFACTS_ENDPOINT: {"artifacts": [self.artifact]}, - ARTIFACT_ENDPOINT: self.artifact, - } - self.scripted: dict[str, list[Any]] = {} - self.api_calls: list[str] = [] - self.gh_calls: list[tuple[str, ...]] = [] - self.downloads: list[tuple[str, dict[str, Any], Path, tuple[str, ...]]] = [] - self.document_text: str | None = None - self.signature_text: str | None = None - - def api(self, endpoint: str, *, repository: str) -> Any: - assert repository == REPOSITORY - self.api_calls.append(endpoint) - if endpoint in self.scripted: - return deepcopy(self.scripted[endpoint].pop(0)) - assert endpoint in self.responses, f"unexpected authenticated request: {endpoint}" - return deepcopy(self.responses[endpoint]) - - def git(self, args: list[str], **kwargs: Any) -> subprocess.CompletedProcess[str]: - assert "rev-parse" in args or "status" in args - assert kwargs["cwd"] == self.root - assert kwargs["timeout"] == 30 - return subprocess.CompletedProcess(args, 0, stdout=COMMIT + "\n" if "rev-parse" in args else "", stderr="") - - def gh(self, *args: str) -> str: - assert args[:2] == ("attestation", "verify") - self.gh_calls.append(args) - return self.signature_text if self.signature_text is not None else json.dumps(self.signature) - - def download(self, repository: str, artifact: dict[str, Any], directory: Path, names: tuple[str, ...], **bounds: int) -> None: - # ZIP authentication and extraction are covered by the shared package. - # This boundary supplies only the adapter's two extracted input files. - self.downloads.append((repository, deepcopy(artifact), directory, names)) - assert names == ("validation.json", "validation.sigstore.json") - assert bounds == {"max_bytes": 32 * 1024 * 1024, "max_expanded_bytes": 32 * 1024 * 1024} - directory.mkdir() - payload = self.document_text if self.document_text is not None else json.dumps(self.document) - (directory / "validation.json").write_text(payload, encoding="utf-8") - (directory / "validation.sigstore.json").write_text('{"fixture":"signed bundle"}', encoding="utf-8") - - def verify(self, identity: str | None = None) -> dict[str, Any]: - """Exercise the public verifier with independently authored signed data.""" - return json.loads( - release_evidence.verify_release_evidence( - POLICY, - "0.5.42", - COMMIT, - lambda endpoint: self.api(endpoint, repository=REPOSITORY), - expected=identity.encode() if identity is not None else None, - ) - ) - - def seal(self, output: Path) -> None: - """Exercise the installed producer including its environment/output guards.""" - args = parser().parse_args( - [ - "release", - "evidence", - "create", - "tooling/release-evidence.toml", - "--checkout", - str(self.root), - "--commit", - COMMIT, - "--version", - "0.5.42", - "--run-id", - "101", - "--attempt", - "2", - "--output", - str(output), - ] - ) - release_interfaces.run_evidence(args, load(root=self.root)) - - def install(self, patch: pytest.MonkeyPatch) -> None: - """Fake authenticated services and Git observations, leaving policy/CLI real.""" - patch.setattr(release_interfaces, "api", self.api) - patch.setattr(release_validation, "gh", self.gh) - patch.setattr(release_evidence, "download_artifact", self.download) - install_clean_checkout(patch, self.root, COMMIT) - - def cli(self, *args: str) -> int: - return main( - [ - "--root", - str(self.root), - "release", - "evidence", - "verify", - "tooling/release-evidence.toml", - "--checkout", - str(self.root), - "--commit", - COMMIT, - "--version", - "0.5.42", - "--output", - str(self.root / "selection.json"), - *args, - ] - ) - - -def expected_identity() -> str: - """Independent approval record for the fixture's literal signed bytes.""" - provider = EvidenceProvider(Path()) - selected = { - **provider.document, - "schema": "research-repo-tools/release-selection/v1", - "jobs": {**provider.document["jobs"], "release-evidence": 205}, - "artifact": {key: provider.artifact[key] for key in ("id", "name", "digest", "size_in_bytes")}, - "manifest_sha256": hashlib.sha256(json.dumps(provider.document).encode()).hexdigest(), - } - return json.dumps(selected, sort_keys=True, separators=(",", ":")) - -PIN_JSON = expected_identity() +if TYPE_CHECKING: + from pathlib import Path @pytest.fixture diff --git a/tests/tooling/test_release_flow.py b/tests/tooling/test_release_flow.py index 2672d5b..22be119 100644 --- a/tests/tooling/test_release_flow.py +++ b/tests/tooling/test_release_flow.py @@ -1,5 +1,7 @@ """Exercise release command transport and the installed retained-draft handoff.""" +import base64 +import hashlib import json import os import runpy @@ -12,13 +14,14 @@ import pytest import yaml -from research_repo_tools import release_assets, release_drafts, release_evidence, release_validation +from research_repo_tools import draft_workflow, release_assets, release_drafts, release_evidence, release_publishing, release_validation from research_repo_tools.cli import main as shared_main +from research_repo_tools.evidence import deterministic_json from research_repo_tools.just_inspect import dry_run from research_repo_tools.process import run_command -from tests.tooling.test_release_evidence import COMMIT, POLICY, REPOSITORY, EvidenceProvider -from tests.tooling.test_toolchain_integration import TOOLING_REQUIREMENT +from tests.tooling.support_evidence import COMMIT, POLICY, REPOSITORY, EvidenceProvider +from tests.tooling.support_toolchain import TOOLING_REQUIREMENT ROOT = Path(__file__).resolve().parents[2] TAG = "v0.5.42" @@ -31,6 +34,12 @@ def test_draft_verification_handoff_uses_the_installed_cli_path_contract(tmp_pat (checkout / "tooling").mkdir(parents=True) runner.mkdir() (checkout / "Cargo.toml").write_text('[package]\nname = "la-stack"\nversion = "0.5.42"\n', encoding="utf-8", newline="\n") + (checkout / "pyproject.toml").write_text( + '[tool.research-repo-tools.publishing]\nregistry = "crates-io"\npackage = "la-stack"\nrepository = "acgetchell/la-stack"\n' + 'required-checks = [{name = "build", app-id = 15368}]\n', + encoding="utf-8", + newline="\n", + ) policy = (ROOT / "tooling/release-evidence.toml").read_bytes() (checkout / "tooling/release-evidence.toml").write_bytes(policy) calls = tmp_path / "calls.jsonl" @@ -50,6 +59,7 @@ def test_draft_verification_handoff_uses_the_installed_cli_path_contract(tmp_pat f'uv() {{ {shlex.quote(Path(sys.executable).as_posix())} {shlex.quote(recorder.as_posix())} "$@"; }}\n' + step["run"] ) output = runner / "github-output" + output.touch() result = run_command( "bash", ["--noprofile", "--norc", "-euc", shell], @@ -62,23 +72,36 @@ def test_draft_verification_handoff_uses_the_installed_cli_path_contract(tmp_pat "GITHUB_EVENT_NAME": "push", "GITHUB_REF": f"refs/tags/{TAG}", "GITHUB_SHA": COMMIT, + "GITHUB_REPOSITORY": REPOSITORY, "GITHUB_OUTPUT": output.as_posix(), "FIXTURE_CALLS": calls.as_posix(), }, check=False, ) assert result.returncode == 0, result.stderr - assert output.read_bytes() == f"commit={COMMIT}\n".encode() - assert (runner / "handoff/evidence.toml").read_bytes() == policy invocations = [json.loads(line) for line in calls.read_text(encoding="utf-8").splitlines()] - evidence = [args for args in invocations if "evidence" in args] - assert len(invocations) == 3 - assert len(evidence) == 1 - arguments = evidence[0][evidence[0].index("--root") :] + assert len(invocations) == 1 + arguments = invocations[0][invocations[0].index("--root") :] + assert arguments[2:5] == ["release", "assets", "plan"] provider = EvidenceProvider(checkout) provider.install(monkeypatch) + monkeypatch.setattr(draft_workflow, "api", provider.api) + + # Source/check gates have separate installed-CLI tests. Keep the planner, + # signed native selection and durable output transaction real here. + def source(settings: object, tag: str, *, commit: str) -> str: + assert tag == TAG + assert commit == COMMIT + return commit + + monkeypatch.setattr(draft_workflow, "check_release_source", source) + monkeypatch.setattr(draft_workflow, "notes", lambda *_args: ("Original generated notes\r\n", "fixture")) assert shared_main(arguments) == 0 - selected = json.loads((runner / "handoff/selection.json").read_bytes()) + assert output.read_bytes() == f"commit={COMMIT}\n".encode() + handoff = json.loads((runner / "handoff/handoff.json").read_bytes()) + assert handoff["evidence_policy"].encode() == policy + assert handoff["notes"] == "Original generated notes\r\n" + selected = handoff["selection"] assert selected["run"]["id"] == 101 assert selected["run"]["head_sha"] == COMMIT @@ -188,13 +211,20 @@ def draft_handoff(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> dict[str, "head_branch": TAG, "head_sha": COMMIT, "path": ".github/workflows/prepare-release.yml", + "name": "Prepare GitHub release", + "pull_requests": [], + "repository": {"id": 11, "full_name": REPOSITORY}, + "head_repository": {"id": 11, "full_name": REPOSITORY}, + "status": "in_progress", + "conclusion": None, } artifact = { "id": 88, "expired": False, "name": "draft-handoff-77-1", "digest": "sha256:" + "d" * 64, - "workflow_run": {"id": 77, "head_sha": COMMIT}, + "size_in_bytes": 512, + "workflow_run": {"id": 77, "head_branch": TAG, "head_sha": COMMIT, "repository_id": 11, "head_repository_id": 11}, } state: dict[str, Any] = {"release": None, "posts": [], "current": current, "artifact": artifact, "history": [deepcopy(current)], "selection": selection} for key, value in { @@ -212,31 +242,89 @@ def draft_handoff(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> dict[str, }.items(): monkeypatch.setenv(key, value) monkeypatch.chdir(tmp_path) + workflow_bytes = WORKFLOW.read_bytes() + workflow_source = { + "type": "file", + "path": ".github/workflows/prepare-release.yml", + "encoding": "base64", + "size": len(workflow_bytes), + "sha": hashlib.sha1(b"blob " + str(len(workflow_bytes)).encode() + b"\0" + workflow_bytes, usedforsecurity=False).hexdigest(), + "content": base64.b64encode(workflow_bytes).decode(), + } + job = { + "id": 91, + "name": "verify", + "run_id": 77, + "run_attempt": 1, + "head_branch": TAG, + "head_sha": COMMIT, + "status": "completed", + "conclusion": "success", + "labels": ["ubuntu-latest"], + "steps": [{"name": "Verify tagged source and freeze native evidence and notes", "number": 1, "status": "completed", "conclusion": "success"}], + } + + responses = { + "actions/artifacts/88": artifact, + "actions/runs/77": current, + "actions/workflows/9/runs?per_page=100&page=1": {"workflow_runs": state["history"]}, + "actions/workflows/prepare-release.yml": { + "id": 9, + "path": ".github/workflows/prepare-release.yml", + "name": "Prepare GitHub release", + "state": "active", + }, + f"contents/.github/workflows/prepare-release.yml?ref={COMMIT}": workflow_source, + "actions/runs/77/attempts/1/jobs?per_page=100&page=1": {"jobs": [job]}, + } def api(endpoint: str, *, repository: str) -> Any: assert repository == REPOSITORY - if endpoint == "actions/artifacts/88": - return deepcopy(artifact) - if endpoint == "actions/runs/77": - return deepcopy(current) - if endpoint == "actions/workflows/9/runs?per_page=100&page=1": - return {"workflow_runs": deepcopy(state["history"])} - return provider.api(endpoint, repository=repository) + return deepcopy(responses[endpoint]) if endpoint in responses else provider.api(endpoint, repository=repository) - def download(repository: str, _artifact: object, destination: Path, names: tuple[str, ...]) -> None: + def download(repository: str, _artifact: object, destination: Path, names: tuple[str, ...], **_bounds: int) -> None: assert repository == REPOSITORY - assert names == ("evidence.toml", "selection.json", "notes.md") + assert names == ("handoff.json",) destination.mkdir(exist_ok=True) - (destination / "evidence.toml").write_bytes((ROOT / "tooling/release-evidence.toml").read_bytes()) - (destination / "selection.json").write_bytes(selection) - (destination / "notes.md").write_bytes(notes) + (destination / "handoff.json").write_bytes( + deterministic_json( + { + "schema": "research-repo-tools/draft-handoff/v1", + "repository": REPOSITORY, + "source": {"ref": f"refs/tags/{TAG}", "commit": COMMIT}, + "event": "push", + "title": TAG, + "notes": notes.decode(), + "evidence_policy": (ROOT / "tooling/release-evidence.toml").read_text(encoding="utf-8"), + "selection": json.loads(selection), + "checks": [{"name": "build", "app_id": 15368}], + } + ) + ) def gh(_root: Path, args: list[str]) -> bytes: return draft_provider(state, args) monkeypatch.setattr(release_validation, "api", api) monkeypatch.setattr(release_drafts, "api", api) - monkeypatch.setattr(release_validation, "download_artifact", download) + monkeypatch.setattr(draft_workflow, "api", api) + monkeypatch.setattr(draft_workflow, "download_artifact", download) + source_responses = { + "": {"full_name": REPOSITORY, "default_branch": "main"}, + "branches/main": {"name": "main", "protected": True}, + f"compare/{COMMIT}...main": {"status": "identical"}, + f"commits/{COMMIT}/check-runs?filter=latest&per_page=100": [ + { + "total_count": 1, + "check_runs": [ + {"id": 17, "name": "build", "head_sha": COMMIT, "app": {"id": 15368}, "status": "completed", "conclusion": "success"}, + ], + } + ], + } + monkeypatch.setattr(release_publishing, "_api", lambda _root, _repo, endpoint, **_kwargs: source_responses[endpoint]) + monkeypatch.setattr(release_drafts, "_api", lambda _root, _repo, endpoint, **_kwargs: source_responses[endpoint]) + monkeypatch.setattr(release_publishing, "_remote_commit", lambda *_args: COMMIT) monkeypatch.setattr(release_assets, "_gh", gh) monkeypatch.setattr(release_drafts, "_gh", gh) # Step 2 must never launch builds, tests or acquisition, even on retries. @@ -253,11 +341,12 @@ def test_actual_writer_creates_once_and_retains_exact_draft(draft_handoff: dict[ draft_handoff["current"]["path"] += suffix script = draft_handoff["script"] runpy.run_path(str(script), run_name="__main__") - original = (tmp_path / "draft-receipt.json").read_bytes() + original = (tmp_path / "draft-state/draft-receipt.json").read_bytes() runpy.run_path(str(script), run_name="__main__") assert len(draft_handoff["posts"]) == 1 - assert (tmp_path / "draft-receipt.json").read_bytes() == original - target = release_assets.parse_release_target((tmp_path / "target.json").read_bytes()) + assert (tmp_path / "draft-state/draft-receipt.json").read_bytes() == original + assert {path.name for path in (tmp_path / "draft-state").iterdir()} == {"producer.json", "handoff.json", "draft-receipt.json", "target.json"} + target = release_assets.parse_release_target((tmp_path / "draft-state/target.json").read_bytes()) assert (target.tag, target.commit, target.release_id, target.expected_title) == (TAG, COMMIT, 42, TAG) @@ -285,12 +374,12 @@ def test_writer_rejects_changed_handoff_without_creating_a_draft( diagnostic = ( "original exact tag push" if failure in {"ref", "commit", "attempt", "attempt-spelling", "validated-attempt"} - else "handoff|preparation intent|did not succeed" + else "handoff|original tag-push|artifact|workflow|did not succeed" ) with pytest.raises(ValueError, match=diagnostic): runpy.run_path(str(draft_handoff["script"]), run_name="__main__") assert draft_handoff["posts"] == [] - assert not (tmp_path / "draft-receipt.json").exists() + assert not (tmp_path / "draft-state").exists() def test_draft_workflow_keeps_the_writer_isolated_and_recovery_explicit() -> None: @@ -310,7 +399,8 @@ def test_draft_workflow_keeps_the_writer_isolated_and_recovery_explicit() -> Non assert command[10:] == ["python", "-I", '"{0}"'] assert step["working-directory"] == "${{ runner.temp }}" assert writer["steps"][-1]["if"] == "always()" - assert "draft-receipt.json" in writer["steps"][-1]["with"]["path"] + assert "draft-state/*" in writer["steps"][-1]["with"]["path"] + assert "draft-state/draft-receipt.json" in writer["steps"][-2]["with"]["path"] assert all(step.get("with", {}).get("enable-cache", False) is False for step in writer["steps"]) diff --git a/tests/tooling/test_release_performance.py b/tests/tooling/test_release_performance.py index 9488349..3246cda 100644 --- a/tests/tooling/test_release_performance.py +++ b/tests/tooling/test_release_performance.py @@ -235,8 +235,10 @@ def test_release_prepares_before_measurement_and_readme_remains_separate() -> No assert "performance release" not in publication -@pytest.mark.parametrize("mode", ["fresh", "resume"]) -@pytest.mark.parametrize("failed_phase", ["none", "prepare", "release"]) +@pytest.mark.parametrize( + ("mode", "failed_phase"), + [("fresh", "none"), ("fresh", "prepare"), ("fresh", "release"), ("resume", "none"), ("resume", "release")], +) def test_release_recipe_stops_on_failure_without_publishing_readme(tmp_path: Path, failed_phase: str, mode: str) -> None: """Execute the real Bash recipe with a bounded CLI substitute, never fetching or timing.""" root = tmp_path / "release with spaces" @@ -278,7 +280,7 @@ def test_release_recipe_stops_on_failure_without_publishing_readme(tmp_path: Pat for command in commands ] expected = [["prepare", "tooling/performance-release.toml", "--fetch-tags", "--allow-git-mutations", "--release-intent"]] if mode == "fresh" else [] - if failed_phase != "prepare" or mode == "resume": + if failed_phase != "prepare": expected.append( [ "acquire", @@ -292,7 +294,7 @@ def test_release_recipe_stops_on_failure_without_publishing_readme(tmp_path: Pat + (["--resume"] if mode == "resume" else []) ) assert phases == expected - status = 0 if failed_phase == "none" or (mode == "resume" and failed_phase == "prepare") else 7 + status = 0 if failed_phase == "none" else 7 assert result.returncode == status, result.stderr if status: assert f"fixture {failed_phase} failure" in result.stderr diff --git a/tests/tooling/test_release_publishing.py b/tests/tooling/test_release_publishing.py index a10ad14..978825f 100644 --- a/tests/tooling/test_release_publishing.py +++ b/tests/tooling/test_release_publishing.py @@ -1,6 +1,5 @@ """Exercise la-stack's published release contract without credentials or uploads.""" -import io import json import os import runpy @@ -8,19 +7,19 @@ import subprocess import sys import tomllib -from contextlib import redirect_stderr +from dataclasses import replace from pathlib import Path from typing import Any import pytest import yaml -from research_repo_tools import changelog, config, dependency_provenance, process, release_publishing +from research_repo_tools import changelog, config, dependency_provenance, release_publishing from research_repo_tools.cli import main from research_repo_tools.just_inspect import dry_run from research_repo_tools.process import run_command -from tests.tooling.test_release_evidence import PIN_JSON, EvidenceProvider, install_clean_checkout -from tests.tooling.test_toolchain_integration import TOOLING_REQUIREMENT +from tests.tooling.support_evidence import PIN_JSON, install_clean_checkout +from tests.tooling.support_toolchain import TOOLING_REQUIREMENT REPO_ROOT = Path(__file__).resolve().parents[2] WORKFLOW = REPO_ROOT / ".github/workflows/publish-crates.yml" @@ -37,6 +36,9 @@ def test_publishing_policy_requires_native_scientific_gates_and_the_criterion_as assert (POLICY.publishing.registry, POLICY.publishing.package, POLICY.publishing.repository) == ("crates-io", "la-stack", "acgetchell/la-stack") assert tuple((check.name, check.app_id) for check in POLICY.publishing.required_checks) == tuple((name, 15368) for name in CHECKS) assert POLICY.publishing.required_assets == ("la-stack-v{version}-criterion-baseline.tar.gz",) + assert POLICY.publishing.expected_title == "tag" + assert POLICY.publishing.generated_notes + assert POLICY.publishing.require_immutable @pytest.fixture @@ -93,9 +95,11 @@ def published(root: Path, *, packages: tuple[str, ...] | None = None) -> tuple[d immutable=True, prerelease=False, assets=((f"la-stack-{TAG}-criterion-baseline.tar.gz", 7, 100, "digest"),), + title=TAG, + body=changelog.notes(POLICY, TAG)[0], ) monkeypatch.setattr(release_publishing, "lookup_release", lambda *_args: release) - return {"checks": checks} + return {"checks": checks, "release": release} def test_installed_gate_accepts_actual_metadata_and_required_native_results(release_event: dict[str, Any]) -> None: @@ -113,43 +117,27 @@ def test_each_configured_native_check_is_required(release_event: dict[str, Any], @pytest.mark.parametrize("immutable", [True, False, None]) -def test_recipe_requires_immutable_publication(tmp_path: Path, immutable: bool | None) -> None: - payload = tmp_path / "event.json" - payload.write_text(json.dumps({"release": {"id": 42}}), encoding="utf-8") - # The shared gate has its own installed-CLI tests above. Isolate this local - # immutable-release policy while running the actual Just recipe expansion. - script = dry_run(REPO_ROOT, "release-gate", [TAG]).stderr - provider = ( - f'gh() {{ [[ "$1 $2" == "api repos/acgetchell/la-stack/releases/42" ]] || return 90; echo {shlex.quote(json.dumps({"immutable": immutable}))}; }}\n' - ) - result = run_command( - "bash", - ["--noprofile", "--norc", "-euc", "set -o pipefail\nuv() { return 0; }\njust() { return 0; }\n" + provider + script], - env={ - **{key: value for key, value in os.environ.items() if key not in {"BASH_ENV", "SHELLOPTS", "BASHOPTS"}}, - "GITHUB_EVENT_PATH": payload.as_posix(), - }, - check=False, - ) - assert (result.returncode == 0) == (immutable is True) +def test_installed_gate_requires_immutable_publication( + release_event: dict[str, Any], monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], immutable: bool | None +) -> None: + release = replace(release_event["release"], immutable=immutable) + monkeypatch.setattr(release_publishing, "lookup_release", lambda *_args: release) + assert main(["--root", str(REPO_ROOT), "release", "gate", TAG]) == (0 if immutable is True else 1) + if immutable is not True: + assert ("must be immutable" if immutable is False else "lifecycle fields") in capsys.readouterr().err -@pytest.mark.parametrize("mismatch", ["none", "title", "notes"]) -def test_real_notes_recipe_checks_generated_body_and_title(tmp_path: Path, mismatch: str) -> None: - body = changelog.notes(POLICY, TAG)[0] - response = {"tagName": TAG, "name": "wrong" if mismatch == "title" else TAG, "body": "wrong" if mismatch == "notes" else body} - payload = tmp_path / "release.json" - payload.write_text(json.dumps(response), encoding="utf-8") - # Only acquisition/provider boundaries are substituted; execute the real CLI - # and recipe's jq comparison, preserving safe transport of Markdown bytes. - runner = ( - 'uv() { [[ "$1 $2 $3 $4" == "run --locked --no-sync research-repo-tools" ]] || return 90; shift 4; ' - f'{shlex.quote(sys.executable)} -m research_repo_tools --root {shlex.quote(str(REPO_ROOT))} "$@"; }}\n' - f"gh() {{ cat {shlex.quote(payload.as_posix())}; }}\n" - ) - script = dry_run(REPO_ROOT, "_release-notes-check", [TAG]).stderr - result = run_command("bash", ["--noprofile", "--norc", "-euc", runner + script], cwd=REPO_ROOT, check=False) - assert (result.returncode == 0) == (mismatch == "none"), result.stderr +@pytest.mark.parametrize("mismatch", ["none", "title", "notes", "crlf"]) +def test_installed_gate_checks_generated_body_and_title( + release_event: dict[str, Any], monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], mismatch: str +) -> None: + release = release_event["release"] + body = release.body.replace("\n", "\r\n") if mismatch == "crlf" else "wrong" if mismatch == "notes" else release.body + release = replace(release, title="wrong" if mismatch == "title" else TAG, body=body) + monkeypatch.setattr(release_publishing, "lookup_release", lambda *_args: release) + assert main(["--root", str(REPO_ROOT), "release", "gate", TAG]) == (0 if mismatch in {"none", "crlf"} else 1) + if mismatch in {"title", "notes"}: + assert ("release title differs" if mismatch == "title" else "release body differs") in capsys.readouterr().err def test_release_notes_stdout_excludes_setup_diagnostics() -> None: @@ -185,7 +173,7 @@ def publish(settings: config.Config, tag: str, *, reuse_evidence: object = None) # Exercise the installed argument parser and dispatch, replacing only the # irreversible publication boundary with an in-memory request recorder. monkeypatch.setattr(release_publishing, "publish_reviewed_release", publish) - # The publication command follows the separately tested notes precheck. + # Shared publishing policy owns the separately tested title/notes assertions. command = shlex.split(dry_run(REPO_ROOT, "release-publish", [TAG, "/independent-owner"]).stderr.splitlines()[-1]) assert command[:7] == ["uv", "run", "--locked", "--no-sync", "research-repo-tools", "release", "publish"] assert main(["--root", str(REPO_ROOT), *command[5:]]) == 0 @@ -212,7 +200,7 @@ def test_workflow_requires_approval_revalidation_and_absence_before_oidc() -> No assert gate["env"]["CANDIDATE_TRANSFER"] == "${{ inputs.candidate }}" assert gate["env"]["CANDIDATE_ACCEPTANCE"] == "${{ inputs.acceptance }}" assert 'just release-receive "$RUNNER_TEMP/accepted-candidate" --published' in gate["run"] - assert 'just _release-notes-check "$RELEASE_TAG"' in gate["run"] + assert job["steps"][1]["with"]["tool"] == "cargo" steps = jobs["publish"]["steps"] assert jobs["verify"]["steps"][3]["id"] == "approval" assert jobs["verify"]["steps"][3]["with"]["path"].endswith("/acceptance.json") @@ -221,7 +209,7 @@ def test_workflow_requires_approval_revalidation_and_absence_before_oidc() -> No assert '--expected "$RUNNER_TEMP/approved-acceptance/acceptance.json"' in steps[4]["run"] assert 'release registry "$RELEASE_TAG" --expect absent' in steps[4]["run"] assert steps[5]["id"] == "auth" - assert steps[6]["run"].endswith("cargo publish --locked --package la-stack --registry crates-io --no-verify") + assert steps[6]["run"].endswith("toolchain run --tool cargo -- cargo publish --locked --package la-stack --registry crates-io --no-verify") assert [index for index, step in enumerate(steps) if "CARGO_REGISTRY_TOKEN" in step.get("env", {})] == [6] assert steps[7]["if"] == "${{ !cancelled() && steps.auth.outcome == 'success' }}" assert steps[7]["run"] == 'just release-verify "$RELEASE_TAG"' @@ -231,41 +219,10 @@ def test_workflow_requires_approval_revalidation_and_absence_before_oidc() -> No assert "--features exact" in commands assert "--allow-dirty" not in commands assert "--no-verify" not in commands - - -def run_evidence_fixture() -> int: - """Run the real verifier in a child process with simulated provider responses.""" - root = Path(os.environ["FIXTURE_ROOT"]) - provider = EvidenceProvider(root) - if os.environ.get("FIXTURE_FAILURE") == "failed-job": - provider.jobs[3]["steps"][0]["conclusion"] = "failure" - newline = os.environ.get("FIXTURE_DIAGNOSTIC_NEWLINE", os.linesep) - sys.stdout.buffer.write(("fixture stdout diagnostic" + newline).encode("utf-8")) - sys.stdout.flush() - print("fixture stderr diagnostic", file=sys.stderr) - diagnostic = io.StringIO() - script, *arguments = sys.argv[1:] - with pytest.MonkeyPatch.context() as patch: - provider.install(patch) - patch.setattr(process, "run_git_command", provider.git) - # The uv launcher needs the real test environment; provenance observes - # only the dependency-free release fixture after process startup. - patch.delenv("UV_PROJECT", raising=False) - patch.delenv("UV_PROJECT_ENVIRONMENT", raising=False) - with redirect_stderr(diagnostic): - try: - sys.argv[:] = [script, *arguments] - runpy.run_path(script, run_name="__main__") - status = 0 - except SystemExit as error: - status = error.code - assert isinstance(status, int) - print(diagnostic.getvalue(), end="", file=sys.stderr) - # Just's quiet mode hides stderr. Record the actual verifier outcome so an - # import/shell failure cannot masquerade as the rejection under test. - result = {"status": status, "diagnostic": diagnostic.getvalue(), "import_root": sys.path[0], "arguments": arguments} - (root / "verifier-result.json").write_text(json.dumps(result), encoding="utf-8") - return status + preparation = dry_run(REPO_ROOT, "release-dependency-builds").stderr + managed = [shlex.split(line) for line in preparation.splitlines() if "toolchain run" in line] + assert len(managed) == 2 + assert all(command[command.index("toolchain") :][:5] == ["toolchain", "run", "--tool", "cargo", "--"] for command in managed) @pytest.fixture @@ -298,7 +255,7 @@ def evidence_runner(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setenv("UV_PROJECT_ENVIRONMENT", sys.prefix) (tmp_path / "fixture-bootstrap.py").write_text( 'import os, sys\nsys.path[:0] = [os.environ["FIXTURE_REPO_ROOT"], os.environ["FIXTURE_MODULE_ROOT"]]\n' - "from tests.tooling.test_release_publishing import run_evidence_fixture\nsys.exit(run_evidence_fixture())\n", + "from tests.tooling.support_evidence import run_evidence_fixture\nsys.exit(run_evidence_fixture())\n", encoding="utf-8", newline="\n", ) @@ -594,15 +551,27 @@ def test_main_ci_seals_only_complete_native_and_cargo_validation() -> None: } -@pytest.mark.parametrize("stage", ["prepare", "native"]) -@pytest.mark.parametrize("result", ["success", "failure", "skipped", "cancelled", ""]) -def test_main_ci_required_checks_reject_incomplete_native_stages(stage: str, result: str) -> None: +@pytest.mark.parametrize( + ("prepare", "native"), + [ + ("success", "success"), + ("failure", "success"), + ("skipped", "success"), + ("cancelled", "success"), + ("", "success"), + ("success", "failure"), + ("success", "skipped"), + ("success", "cancelled"), + ("success", ""), + ], +) +def test_main_ci_required_checks_reject_incomplete_native_stages(prepare: str, native: str) -> None: workflow = yaml.safe_load((REPO_ROOT / ".github/workflows/ci.yml").read_bytes()) step = workflow["jobs"]["build"]["steps"][0] assert step["env"] == {"PREPARE_RESULT": "${{ needs.prepare.result }}", "NATIVE_RESULT": "${{ needs.native.result }}"} - environment = {**os.environ, "PREPARE_RESULT": "success", "NATIVE_RESULT": "success", f"{stage.upper()}_RESULT": result} + environment = {**os.environ, "PREPARE_RESULT": prepare, "NATIVE_RESULT": native} completed = run_command("bash", ["--noprofile", "--norc", "-euc", step["run"]], env=environment, check=False) - assert completed.returncode == (0 if result == "success" else 1), completed.stderr + assert completed.returncode == (0 if prepare == native == "success" else 1), completed.stderr @pytest.mark.parametrize("source", ["development", "published", "rejected"]) diff --git a/tests/tooling/test_review_integration.py b/tests/tooling/test_review_integration.py index edfd669..d50725d 100644 --- a/tests/tooling/test_review_integration.py +++ b/tests/tooling/test_review_integration.py @@ -45,9 +45,15 @@ def stub(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: script = directory / "stub.py" script.write_text( "import json, os, sys\n" - "print(json.dumps(sys.argv[1:]))\n" + "if sys.argv[1:] == ['--version']:\n" + " print('0.7.7')\n" + " sys.exit(0)\n" + "print(json.dumps({'type': 'fixture_arguments', 'arguments': sys.argv[1:]}))\n" "print('fixture diagnostic', file=sys.stderr)\n" - "sys.exit(int(os.environ.get('REVIEW_STUB_STATUS', '0')))\n", + "status = int(os.environ.get('REVIEW_STUB_STATUS', '0'))\n" + "if status == 0 and os.environ.get('REVIEW_STUB_COMPLETE', '1') == '1':\n" + " print(json.dumps({'type': 'complete', 'status': 'review_completed', 'findings': 0, 'reviewedFiles': ['AGENTS.md']}))\n" + "sys.exit(status)\n", encoding="utf-8", ) if os.name == "nt": @@ -81,7 +87,9 @@ def test_actual_recipes_forward_scopes_and_consumer_instructions(consumer: Path, before = run_command("git", ["--no-pager", "show-ref"], cwd=consumer).stdout result = recipe(consumer, *args) assert result.returncode == 0, result.stderr - assert json.loads(result.stdout) == [ + arguments, completion, outcome = [json.loads(line) for line in result.stdout.splitlines()] + assert arguments["type"] == "fixture_arguments" + assert arguments["arguments"] == [ "review", "--agent", "--include-untracked", @@ -90,6 +98,16 @@ def test_actual_recipes_forward_scopes_and_consumer_instructions(consumer: Path, str(consumer / "AGENTS.md"), str(consumer / ".coderabbit.yaml"), ] + assert completion == {"type": "complete", "status": "review_completed", "findings": 0, "reviewedFiles": ["AGENTS.md"]} + assert outcome == { + "type": "rrt_review_result", + "schema": "research-repo-tools/review-result/v1", + "status": "completed", + "findings": 0, + "reviewed_files": ["AGENTS.md"], + "reused": False, + "skipped": False, + } assert "fixture diagnostic" in result.stderr assert run_command("git", ["--no-pager", "show-ref"], cwd=consumer).stdout == before @@ -103,6 +121,21 @@ def test_service_failures_and_interruption_status_reach_just(consumer: Path, stu assert "fixture diagnostic" in result.stderr +def test_successful_exit_without_completion_is_rejected(consumer: Path, stub: Path, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("REVIEW_STUB_COMPLETE", "0") + result = recipe(consumer, "review-uncommitted") + assert result.returncode == 1 + arguments, outcome = [json.loads(line) for line in result.stdout.splitlines()] + assert arguments["type"] == "fixture_arguments" + assert outcome == { + "type": "rrt_review_result", + "schema": "research-repo-tools/review-result/v1", + "status": "failed", + "reason": "CodeRabbit exited without a completion event", + } + assert outcome["reason"] in result.stderr + + def test_shell_metacharacters_are_passed_as_one_rejected_base(consumer: Path, stub: Path) -> None: result = recipe(consumer, "review", "HEAD'; echo INJECTION_EXECUTED; #") assert result.returncode != 0 diff --git a/tests/tooling/test_toolchain_integration.py b/tests/tooling/test_toolchain_integration.py index fc60b49..4c7b05d 100644 --- a/tests/tooling/test_toolchain_integration.py +++ b/tests/tooling/test_toolchain_integration.py @@ -22,31 +22,16 @@ from research_repo_tools.python_tools import TOOLS, versions as shared_tool_versions from research_repo_tools.toml_source import remove_value, set_value +from tests.tooling import support_toolchain +from tests.tooling.support_toolchain import TOOLING_REQUIREMENT, tooling_requirement + if TYPE_CHECKING: import subprocess REPO_ROOT = Path(__file__).resolve().parents[2] -def tooling_requirement(root: Path) -> str: - """Select the declared supplier after RRT verifies any development source.""" - document = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8")) - (raw,) = document["dependency-groups"]["tooling"] - requirement = Requirement(raw) - (pin,) = requirement.specifier - assert requirement.name == "research-repo-tools" - assert requirement.url is None - assert requirement.marker is None - assert pin.operator == "==" - assert "*" not in pin.version - development = check_development_dependency(root, document=document) - if development is not None: - return f"{requirement.name} @ git+{development.source}@{development.revision}" - return f"{requirement.name}{requirement.specifier}" - - TOOLING_VERSION = version("research-repo-tools") -TOOLING_REQUIREMENT = tooling_requirement(REPO_ROOT) CHECKED = ["run", "--locked", "--no-sync", "--no-python-downloads", "research-repo-tools", "toolchain", "run", "--"] UPDATER = ["run", "--locked", "--only-group", "tooling", "--inexact", "research-repo-tools"] UV_UPDATE = ["run", "--no-config", "--no-sync", "--no-python-downloads", "research-repo-tools", "deps", "update-uv"] @@ -119,7 +104,7 @@ def verify(root: Path, *, document: dict[str, object]) -> DependencyIdentity | N raise ValueError(message) return DependencyIdentity("research-repo-tools", "0.2.8", "https://github.com/acgetchell/research-repo-tools", "a" * 40) if source == "git" else None - monkeypatch.setattr(sys.modules[__name__], "check_development_dependency", verify) + monkeypatch.setattr(support_toolchain, "check_development_dependency", verify) if source == "invalid": with pytest.raises(ValueError, match="installed Git provenance differs"): tooling_requirement(tmp_path) diff --git a/tests/tooling/test_validation_graph.py b/tests/tooling/test_validation_graph.py index 57364df..f89ff03 100644 --- a/tests/tooling/test_validation_graph.py +++ b/tests/tooling/test_validation_graph.py @@ -22,6 +22,7 @@ ROOT = Path(__file__).resolve().parents[2] POLICY = { "action-lint", + "actions-check", "workflow-allowlist-check", "zizmor", "markdown-check", @@ -85,8 +86,8 @@ def graph(tmp_path: Path) -> tuple[Path, set[str]]: overrides = [] for name in sorted(selected): recipe = recipes[name] - parameters = " *args" if name in {"bench-exact", "zizmor", "test-python"} else "" - assert not recipe["parameters"] or name in {"bench-exact", "zizmor", "test-python"} + parameters = " *args" if name in {"bench-exact", "zizmor", "test-python", "tools-check"} else "" + assert not recipe["parameters"] or parameters dependencies = " ".join( "(" + item["recipe"] + " " + " ".join(json.dumps(arg) for arg in item["arguments"]) + ")" if item["arguments"] else item["recipe"] for item in recipe["dependencies"] diff --git a/tooling/README.md b/tooling/README.md index 72dcf08..5f072bb 100644 --- a/tooling/README.md +++ b/tooling/README.md @@ -71,7 +71,7 @@ Other platforms resolve Semgrep 1.184.0 or newer within the shared range. ## Shared capability adoption The tooling group and isolated `uvx --python 3.15` runtimes use the published -`research-repo-tools==0.2.8` package. Integration checks verify the manifest, +`research-repo-tools==0.2.9` package. Integration checks verify the manifest, registry lock artifacts and installed version, including the isolated runtimes. For development rehearsal, an exact full-commit uv Git source override remains supported; keep the isolated runtime pins aligned and do not float on `main`. @@ -103,7 +103,7 @@ never copy their signing keys into CI artifacts or caches. Changed manifests, locks, source policy, interpreter, or builder invalidate them. Rebuild before the next release check after such changes. These receipts establish observed source/build provenance, not reproducible builds or publisher-signed wheels. -See the supplier's [source-build contract](https://github.com/acgetchell/research-repo-tools/blob/v0.2.8/README.md#source-built-python-dependencies). +See the supplier's [source-build contract](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/README.md#source-built-python-dependencies). Native CI runs `just ci-dependencies` in the `dependencies` stage of the `native` job alongside the Rust, Python, and candidate-acceptance stages after shared policy checks. Signed release evidence @@ -119,16 +119,16 @@ dependencies. Upgrading a published supplier uses the target release's adopter outside the old project environment. For the current release: ```bash -uvx --no-config --isolated --managed-python --python 3.15 --from research-repo-tools==0.2.8 research-repo-tools toolchain adopt --dry-run -uvx --no-config --isolated --managed-python --python 3.15 --from research-repo-tools==0.2.8 research-repo-tools toolchain adopt --apply +uvx --no-config --isolated --managed-python --python 3.15 --from research-repo-tools==0.2.9 research-repo-tools toolchain adopt --dry-run +uvx --no-config --isolated --managed-python --python 3.15 --from research-repo-tools==0.2.9 research-repo-tools toolchain adopt --apply ``` The adopter reconciles requirements, lock and environment. Align the declared source in `dependency-sources.toml`, isolated recipe/workflow pins and consumer identity tests with that target, then run the normal checks. `just update` does -not perform this supplier migration, including when run by v0.2.8. -For an exact Git development pin, v0.2.8 also supports explicit attested -[promotion](https://github.com/acgetchell/research-repo-tools/blob/v0.2.8/docs/UPDATING_DEPENDENCIES.md#promoting-an-exact-development-pin); +not perform this supplier migration, including when run by v0.2.9. +For an exact Git development pin, v0.2.9 also supports explicit attested +[promotion](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/docs/UPDATING_DEPENDENCIES.md#promoting-an-exact-development-pin); ordinary updates continue to preserve the pin. For a deliberate source transition, edit `[sources.tooling]` in @@ -148,7 +148,7 @@ come from their registries for release. The file is retained in source exports and both benchmark harness declarations, so policy changes invalidate evidence. The capability inventory below uses the pinned CLI and -its [v0.2.8 contracts](https://github.com/acgetchell/research-repo-tools/blob/v0.2.8/README.md#common-workflows). +its [v0.2.9 contracts](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/README.md#common-workflows). The shared updater installs and verifies candidate Cargo tools before publishing new pins; no local updater implementation is needed. Native Rust algorithms, assertions, benchmark selection and release decisions @@ -156,9 +156,9 @@ remain owned here. | Capability | Consumer use | | --- | --- | -| Actions | `workflow-allowlist-check` gates external workflow dependencies; `update-actions` updates explicitly selected workflow pins | +| Actions | Offline `actions-check` catches partial coupled bumps; `update-actions` uses the same workflow/composite scope and separate update policy | | Changelog and release | Shared generation, archives, metadata rules, registry gates and verification; the Cargo adapter reuses signed native/package evidence | -| CI environment and toolchain | Shared setup/check/run/export and verified cached installations; `tools-clean` previews obsolete managed tools separately from Cargo `clean` | +| CI environment and toolchain | Shared setup/check/run/export, selected-tool recipes and verified cached installations; `tools-clean` previews obsolete managed tools separately from Cargo `clean` | | Coverage | Native `cargo llvm-cov` acquisition; `coverage-report` summarizes its existing Cobertura output | | Dependencies | Shared uv/tool upgrades and `deps update-python --all-projects`; consumer Python dependencies share the root environment and lock | | Documentation and files | Shared tracked/nonignored selection and bounded argument batches for formatting, lint, spelling and syntax checks; one active Markdown policy preserves archives | @@ -186,7 +186,7 @@ Use `just --list` for arguments. Actions updates and managed-tool removal are explicit maintenance operations; checking their wiring does not run them. `.github/actions-allowlist.json` owns exact action identities accepted by local -validation and the updater. Workflows retain full commit pins. This source policy +validation. Workflows retain full commit pins. This source policy is separate from the historical GitHub settings payloads under `.github/settings/`, which also constrain the publishing action to a specific commit. Reconcile live settings before deploying a pin update; the local updater does not change them. @@ -194,6 +194,26 @@ The allowlist recipe remains scoped to workflows. Semgrep rules check composite actions under `.github/actions/`, including their external dependencies and commit pins. +`.github/action-updates.toml` separately owns update targets and offline pin +consistency. `actions-check` and `update-actions` share both `.github/workflows` +and `.github/actions`; the check runs in `github-actions-check` and hosted +`ci-policy`. It uses the provisioned environment without syncing or network +lookups. The maintainer owns coupled `astral-sh/setup-uv` and CodeQL bumps through +`just update-actions --dry-run`, then `just update-actions`. Advance all three +CodeQL target tags together before that command; the explicit common release +also catches a partial sub-action version bump. The offline check verifies +declared comments and repeated identities, not the remote tag-to-SHA mapping. +The updater resolves that mapping. Dependabot excludes these two groups and +continues proposing other Actions updates under the existing approval policy. +Neither command changes the selected-actions allowlist or approval requirements. + +`tools-sync`, `tools-check`, `tools-export` and `tools-run` accept RRT's repeatable +`--tool` selection. The crates.io workflow follows the supplying +[publication template](https://github.com/acgetchell/research-repo-tools/blob/v0.2.9/src/research_repo_tools/templates/publish-crates.yml) +by selecting only minimal Rust/Cargo. Locked `dev` still supplies Just and the +native Python dependency provenance requirements. Cargo owns upload; the shared +release gates enforce the configured evidence and registry policy. + ## Performance ownership The [benchmark guide](../docs/BENCHMARKING.md) owns command selection, @@ -214,7 +234,7 @@ There is no runtime configuration generator. | `criterion-saved.toml` | Required IDs, canonical paths, 100 samples and exact saved raw JSON bytes | | `performance-report.toml` | Independent release eligibility, current report and immutable run history | | `performance-release.toml` | Preparation storage, publication chronology and separate phase declarations | -| `release_candidate.py` | Owner-controlled capture, final acceptance and exact hosted handoffs using public shared APIs | +| `release_candidate.py` | Repository owner selection, recovery and transfer protocol around shared capture, atomic acceptance and asset staging | | `performance-readme.toml` | Canonical README selection, formatter, source freshness and tagged links | | `plots/{non-exact,retained,scratch}/*.toml` | Named metric/statistic/axis selections with explicit input ownership | @@ -265,8 +285,10 @@ before measurement and report promotion. It stops if preparation fails; `performance-readme` remains a separate publication step. `performance-resume` reuses the same preparation and checkpoint; it preserves completed suite pairs inside an interrupted trial. A fresh acquisition refuses an existing checkpoint. -The owner record lives outside the checkout and freezes original bytes/digests -before promotion. Explicit capture retries never start measurements. +The owner record lives outside the checkout. RRT's `capture_candidate_handoff` +freezes the original bytes/digests before promotion. The local callback preserves +la-stack's pre-acquisition preparation and checkpoint/owner registration contract; +explicit capture retries never start measurements. For preparation alone, `just performance-prepare` uses local tags; `--fetch-tags --allow-git-mutations` explicitly enables fetching. Measurement recipes create temporary @@ -328,15 +350,19 @@ use the shared release contract; `publish-check` owns native default/exact Cargo dry-runs. Main CI signs those packaging and native validation identities; `just release-evidence [OWNER] [SELECTION]` binds the original acquisition, precise publisher receipt, final clean commit and signed native acceptance. Named review records -are immutable; selecting a later native attempt requires an explicit new name. +are immutable; RRT retains the final policy and acceptance in one transaction. +Selecting a later native attempt requires an explicit new name. `release-evidence.toml` owns the package, workflow, native job and signer policy; `release-assets.toml` owns the draft-target policy. Evidence recipes use the pinned installed runtime outside the observed checkout. The [release guide](../docs/RELEASING.md#reusable-ci-evidence) owns the independent owner selection and frozen approval contract. Tag-triggered `prepare-release.yml` reuses signed native evidence and generated -notes through the installed draft API. Its isolated writer retains the original -journal and captured target. `release-stage` retrieves that original target through +notes through `release assets plan` and `prepare_authenticated_draft`. Its isolated +writer retains the complete `draft-state` directory: producer assertions, +authenticated handoff, original journal and captured target. `release-stage` retrieves that original target through the installed tag-aware receipt verifier and freezes its ID before upload; +RRT's `stage_release_assets` owns the per-asset journal and exact-byte retries. +Retain `staging.json` and `staged-assets.json` alongside the original transfer; `release-publication` adds canonical archive ID/hash assertions. Two maintainer dispatches use those independent records. Write-scope hosted jobs execute no checkout code; diff --git a/tooling/release_candidate.py b/tooling/release_candidate.py index 7caf8c4..bb825b4 100644 --- a/tooling/release_candidate.py +++ b/tooling/release_candidate.py @@ -6,29 +6,24 @@ import os import re import tempfile -from dataclasses import dataclass, replace +from dataclasses import dataclass from functools import partial from pathlib import Path from typing import Literal -from research_repo_tools.candidate_publication import plan_candidate_publication +from research_repo_tools.candidate_handoff import capture_candidate_handoff from research_repo_tools.candidate_reuse import ( - CandidatePolicy, acquisition_assertion_digest, parse_candidate_policy, plan_candidate_archive, - serialize_candidate_policy, verify_candidate_archive, verify_candidate_release, ) from research_repo_tools.cli import main as shared_main -from research_repo_tools.common_measurement import validate_run_policy -from research_repo_tools.complete_runs import run_identity from research_repo_tools.config import load as load_config from research_repo_tools.dependency_provenance import check_release_dependencies -from research_repo_tools.evidence import parse_evidence from research_repo_tools.files import replace_many -from research_repo_tools.measurement import load_measurement, resolve_revision +from research_repo_tools.measurement import resolve_revision from research_repo_tools.performance_progress import ProgressReporter from research_repo_tools.performance_release import load_performance_release, load_preparation, measure_release, serialize_preparation from research_repo_tools.process import run_command @@ -37,7 +32,6 @@ ReleaseTarget, download_release_asset, parse_release_target, - publish_release_asset, require_release_checkout, revalidate_release_target, serialize_release_target, @@ -45,9 +39,8 @@ from research_repo_tools.release_interfaces import load_evidence_policy from research_repo_tools.release_metadata import read_package_info from research_repo_tools.release_publishing import ReviewedRelease, check_reviewed_release +from research_repo_tools.release_staging import stage_release_assets from research_repo_tools.release_validation import api, parse_release_json -from research_repo_tools.scheduled_runs import ScheduledRun -from research_repo_tools.suite_runs import parse_suite_run SETTINGS = "tooling/performance-release.toml" REPOSITORY = "acgetchell/la-stack" @@ -175,32 +168,7 @@ def capture(root: Path, owner: Path, *, retained_scratch: bool = False) -> dict[ payload, manifest = (owner / "run.json").read_bytes(), (owner / "evidence.json").read_bytes() # Restore only identical/missing scratch evidence for a failed capture retry. freeze(root, {settings.payload: payload, settings.manifest: manifest}) - evidence = parse_evidence(payload, manifest) - run = validate_run_policy(evidence, load_measurement(root, settings.measurement), release=True) - if not isinstance(run, ScheduledRun): - message = "candidate acquisition requires the declared trial schedule" - raise TypeError(message) - policy = CandidatePolicy( - settings.repository, - preparation.pair.current, - None, - "local", - run_identity(evidence), - run.plan, - dict(evidence.sources)["current"], - tuple( - (index, suite, phase, source) for index, trial in enumerate(run.trials, 1) for suite, phase, _sample, source in parse_suite_run(trial).observations - ), - report=settings.report, - ) - acquisition = acquisition_assertion_digest(policy) - freeze(owner, {"policy.json": serialize_candidate_policy(policy), "acquisition.sha256": (acquisition + "\n").encode("ascii")}) - receipt_path = owner / "publication.json" - if not receipt_path.exists(): - _plan, receipt = plan_candidate_publication(root, settings.payload, settings.manifest, policy, acquisition_sha256=acquisition) - freeze(owner, {"publication.json": receipt}) - publication = hashlib.sha256(receipt_path.read_bytes()).hexdigest() - freeze(owner, {"publication.sha256": (publication + "\n").encode("ascii")}) + _plan, acquisition, publication = capture_candidate_handoff(root, settings, owner) return {"owner_directory": str(owner), "acquisition_sha256": acquisition, "publication_sha256": publication} @@ -261,47 +229,48 @@ def final_directory(owner: Path, commit: str, selection: str) -> Path: def verify(root: Path, owner: Path, selection: str = "reviewed") -> Path: """Bind the separately trusted record to clean HEAD and signed native CI.""" - check_release_dependencies(root) commit = resolve_revision(root, "HEAD") - policy = replace(parse_candidate_policy((owner / "policy.json").read_bytes()), commit=commit) final = final_directory(owner, commit, selection) - final.mkdir(parents=True, exist_ok=True) - freeze(final, {"policy.json": serialize_candidate_policy(policy)}) accepted = final / "acceptance.json" + arguments = [ + "--root", + str(root), + "release", + "evidence", + "candidate", + "tooling/release-evidence.toml", + "--checkout", + str(root), + "--policy", + str(owner / "policy.json"), + "--commit", + commit, + "--policy-output", + str(final / "policy.json"), + "--payload", + str(owner / "run.json"), + "--manifest", + str(owner / "evidence.json"), + "--publication-receipt", + str(owner / "publication.json"), + "--acquisition-sha256", + (owner / "acquisition.sha256").read_text(encoding="ascii").strip(), + "--publication-sha256", + (owner / "publication.sha256").read_text(encoding="ascii").strip(), + "--output", + str(accepted), + "--format", + "summary", + ] with tempfile.TemporaryDirectory(prefix="la-stack-candidate-verification-") as temporary: - output = Path(temporary).resolve() / "acceptance.json" - arguments = [ - "--root", - str(root), - "release", - "evidence", - "candidate", - "tooling/release-evidence.toml", - "--checkout", - str(root), - "--policy", - str(final / "policy.json"), - "--payload", - str(owner / "run.json"), - "--manifest", - str(owner / "evidence.json"), - "--publication-receipt", - str(owner / "publication.json"), - "--acquisition-sha256", - (owner / "acquisition.sha256").read_text(encoding="ascii").strip(), - "--publication-sha256", - (owner / "publication.sha256").read_text(encoding="ascii").strip(), - "--output", - str(output), - "--format", - "summary", - ] if accepted.exists(): - arguments.extend(("--acceptance", str(accepted))) + # RRT keeps input assertions distinct from its atomic destinations. + expected = Path(temporary).resolve() / "acceptance.json" + expected.write_bytes(accepted.read_bytes()) + arguments.extend(("--acceptance", str(expected))) status = shared_main(arguments) - if status: - raise RuntimeError(f"candidate verification failed with exit {status}") - freeze(final, {"acceptance.json": output.read_bytes()}) + if status: + raise RuntimeError(f"candidate verification failed with exit {status}") return accepted @@ -541,33 +510,32 @@ def stage(root: Path, owner: Path, selection: str, prepared_target: Path | None inputs = {"policy": final / "policy.json", "publication": owner / "publication.json", "acceptance": accepted, "archive": artifact} transport = final / "transport" transport.mkdir(exist_ok=True) - assertions: dict[str, dict[str, str | int]] = {} + names: dict[str, str] = {} for role, source in inputs.items(): suffix = "tar.gz" if role == "archive" else "json" name = f"la-stack-{policy.tag}-{selection}-candidate-{role}.{suffix}" payload = source.read_bytes() freeze(transport, {name: payload}) - publish_release_asset(root, REPOSITORY, policy.tag, transport / name, target=target, checkout=root) - release = revalidate_release_target(root, target, checkout=root) - entry = next((item for item in release.assets if item[0] == name), None) - if entry is None: - message = f"staged candidate asset is missing from the prepared release: {name}" - raise ValueError(message) - assertions[role] = {"name": name, "id": entry[1], "sha256": hashlib.sha256(payload).hexdigest()} - payload = ( - json.dumps( - { - "schema": 1, - "target": json.loads(serialize_release_target(target)), - "acquisition": acquisition, - "publication": publication, - "assets": assertions, - }, - sort_keys=True, - ).encode("utf-8") - + b"\n" + names[role] = name + batch = json.loads( + stage_release_assets( + root, + target, + tuple(transport / name for name in names.values()), + journal=final / "staging.json", + destination=final / "staged-assets.json", + approve=True, + checkout=root, + ) + ) + assertions = {role: AssetAssertion(name, batch["assets"][name]["id"], batch["assets"][name]["sha256"]) for role, name in names.items()} + assets = OriginalAssets( + policy=assertions["policy"], + publication=assertions["publication"], + acceptance=assertions["acceptance"], + archive=assertions["archive"], ) - require_draft_transfer(parse_transfer(payload)) + payload = serialize_transfer(DraftTransfer(target, acquisition, publication, assets)) freeze(final, {"transfer.json": payload}) return final / "transfer.json" diff --git a/uv.lock b/uv.lock index 6f63337..7f0f776 100644 --- a/uv.lock +++ b/uv.lock @@ -14,11 +14,11 @@ constraints = [ overrides = [ { name = "jsonschema", specifier = "==4.26.0" }, { name = "mcp", specifier = "==1.30.0" }, - { name = "opentelemetry-api", specifier = "==1.45.1" }, - { name = "opentelemetry-exporter-otlp-proto-http", specifier = "==1.45.1" }, - { name = "opentelemetry-instrumentation-requests", specifier = "==0.66b1" }, - { name = "opentelemetry-instrumentation-threading", specifier = "==0.66b1" }, - { name = "opentelemetry-sdk", specifier = "==1.45.1" }, + { name = "opentelemetry-api", specifier = "==1.45.2" }, + { name = "opentelemetry-exporter-otlp-proto-http", specifier = "==1.45.2" }, + { name = "opentelemetry-instrumentation-requests", specifier = "==0.66b2" }, + { name = "opentelemetry-instrumentation-threading", specifier = "==0.66b2" }, + { name = "opentelemetry-sdk", specifier = "==1.45.2" }, { name = "pyjwt", extras = ["crypto"], specifier = ">=2.15.1,<3" }, { name = "pywin32", marker = "sys_platform == 'win32'", specifier = "==312" }, { name = "tomli", specifier = "==2.5.0" }, @@ -492,12 +492,12 @@ build = [ dev = [ { name = "actionlint-py", specifier = "==1.7.12.25" }, { name = "pytest-xdist", specifier = "==3.8.0" }, - { name = "research-repo-tools", extras = ["python-tools", "semgrep"], marker = "python_full_version >= '3.15'", specifier = "==0.2.8" }, + { name = "research-repo-tools", extras = ["python-tools", "semgrep"], marker = "python_full_version >= '3.15'", specifier = "==0.2.9" }, { name = "shellcheck-py", specifier = "==0.11.0.1" }, { name = "shfmt-py", specifier = "==4.2.0" }, { name = "yamllint", specifier = "==1.38.0" }, ] -tooling = [{ name = "research-repo-tools", extras = ["python-tools", "semgrep"], marker = "python_full_version >= '3.15'", specifier = "==0.2.8" }] +tooling = [{ name = "research-repo-tools", extras = ["python-tools", "semgrep"], marker = "python_full_version >= '3.15'", specifier = "==0.2.9" }] [[package]] name = "markdown-it-py" @@ -547,26 +547,26 @@ wheels = [ [[package]] name = "opentelemetry-api" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/2e/02/6e0ae9cc61bd3169d401077b507b3ebc344745171e1051ab430be012dcd9/opentelemetry_api-1.45.1.tar.gz", hash = "sha256:aa38ed19bcc084ba42782a73255b3582283eced7ad6dddbd6695189e69adfb75", size = 72804, upload-time = "2026-10-06T17:32:58.133Z" } +sdist = { url = "https://files.pythonhosted.org/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4", size = 73277, upload-time = "2026-10-29T17:29:37.888Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/1e/41/f7dcf80b81ee8e71c1a2b59f14208bc723edbd89ed027a73b175abf6348e/opentelemetry_api-1.45.1-py3-none-any.whl", hash = "sha256:b31553efa588ae44bc306f863c785c5333a9ecc091248c6ee68b4b6c87fdedfb", size = 60256, upload-time = "2026-10-06T17:32:33.506Z" }, + { url = "https://files.pythonhosted.org/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34", size = 60335, upload-time = "2026-10-29T17:29:06.955Z" }, ] [[package]] name = "opentelemetry-exporter-http-transport" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/62/0c/e3ebdb4b507f66afcc905e6885a4946969bd75b45988492643356fbbdc63/opentelemetry_exporter_http_transport-0.66b1.tar.gz", hash = "sha256:443080203bf52586ce0b2ad901e8951c61833eab1aa539ae6f1f16fe9e8e7952", size = 11693, upload-time = "2026-10-06T17:32:59.65Z" } +sdist = { url = "https://files.pythonhosted.org/packages/a6/e6/dbeb3e217418071656232a4028c791060d219f218cef1249b664049d12c0/opentelemetry_exporter_http_transport-0.66b2.tar.gz", hash = "sha256:66d6ed810a515432c8891da9a834464332fd70badeca45bdeeae81b4280c903b", size = 11693, upload-time = "2026-10-29T17:29:39.444Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/04/69/6af86ff66492b481c6a4c05dcfd68beb47ed8ba046440a26a2aac76b95c7/opentelemetry_exporter_http_transport-0.66b1-py3-none-any.whl", hash = "sha256:2f95404bdee7f9d2d529c7de56c7bd86d014d774d8fbf137810e0167f8a492bf", size = 12155, upload-time = "2026-10-06T17:32:35.454Z" }, + { url = "https://files.pythonhosted.org/packages/a1/b2/c622a101f31c0e6670b82f4264c4e77c161bce415bc6fc158fda0b82e218/opentelemetry_exporter_http_transport-0.66b2-py3-none-any.whl", hash = "sha256:fd5f5b490c099acda1cd7b909d5e8981436bf18cc8c6098d302d114c271720e9", size = 12154, upload-time = "2026-10-29T17:29:10.244Z" }, ] [package.optional-dependencies] @@ -576,31 +576,31 @@ requests = [ [[package]] name = "opentelemetry-exporter-otlp-common" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-sdk" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/cb/19/41de712173f43057e4532d42ece7d0c6d4210d353e5752433cb14987643f/opentelemetry_exporter_otlp_common-0.66b1.tar.gz", hash = "sha256:6b1403487a2185ac1feb45fd5546fdf8630ce71c36bcefaadf51e2130e9e23f9", size = 14325, upload-time = "2026-10-06T17:33:01.725Z" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/3c/3f2cc8c42bde2620e65024d71e2eb025f7bd0821bb363b52bcc5a3260dbd/opentelemetry_exporter_otlp_common-0.66b2.tar.gz", hash = "sha256:06f5a9b88638e310efa1f1d206cdf6b75393e112aba4e174a963416192bd1028", size = 14325, upload-time = "2026-10-29T17:29:41.701Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/fc/39/8c23d67665c762aa51840fa06f86e902e8f6f1693bc8d7e3d98cd6e2f753/opentelemetry_exporter_otlp_common-0.66b1-py3-none-any.whl", hash = "sha256:00ff8592c3a7cb729ff3fdc7ffa12372c243bdf2163e80c180994d0c7bd83ee9", size = 12385, upload-time = "2026-10-06T17:32:38.177Z" }, + { url = "https://files.pythonhosted.org/packages/a8/47/b3049e30b339c82e3c7ec1fc692185a5d5a3ba65a94c570bb39b2c0b8424/opentelemetry_exporter_otlp_common-0.66b2-py3-none-any.whl", hash = "sha256:ace86efb75489f925f1ef809856ae5f0c7db534e4afdc624530222228b1236a5", size = 12385, upload-time = "2026-10-29T17:29:13.667Z" }, ] [[package]] name = "opentelemetry-exporter-otlp-proto-common" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-proto" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/c1/8e/65e85e5137991a3c493b11682151d198638a5bc1dd4b4c5f67e013c57d7c/opentelemetry_exporter_otlp_proto_common-1.45.1.tar.gz", hash = "sha256:2e4adcc3a67bcf57804fc49514f0ef64974ca7590aa3491da389852b4a0628f6", size = 18873, upload-time = "2026-10-06T17:33:04.471Z" } +sdist = { url = "https://files.pythonhosted.org/packages/69/58/239c98b36d9ea317098769957043c251703636a26189c884fba46c1dad84/opentelemetry_exporter_otlp_proto_common-1.45.2.tar.gz", hash = "sha256:f1f2806f3f28ce7938033823e50934fcd91595a39de38e69a28a51e19f40fc6d", size = 18873, upload-time = "2026-10-29T17:29:44.496Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/84/aa/92f225d353904e7f70b8b3e3c1b02db0cf56f744c2e83c581dc372e78873/opentelemetry_exporter_otlp_proto_common-1.45.1-py3-none-any.whl", hash = "sha256:2f446183ae7047b036226f1d846c41a834b0e8755ad13b51a51dd38952eb466c", size = 15393, upload-time = "2026-10-06T17:32:41.911Z" }, + { url = "https://files.pythonhosted.org/packages/e6/d6/0f30d38120a949aef70528f845bf539f80df62abb4b8e62fdf69c2b6df5a/opentelemetry_exporter_otlp_proto_common-1.45.2-py3-none-any.whl", hash = "sha256:af483b24217028892f017096731b794b196b785025d2e6808874720fd0b05a80", size = 15392, upload-time = "2026-10-29T17:29:17.913Z" }, ] [[package]] name = "opentelemetry-exporter-otlp-proto-http" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "googleapis-common-protos" }, @@ -613,14 +613,14 @@ dependencies = [ { name = "requests" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/1b/17/26487707ea4caa97b17e6e4b5fa72133a53512ffa2f5cf7a49ef284b29cb/opentelemetry_exporter_otlp_proto_http-1.45.1.tar.gz", hash = "sha256:45c218405ce3fd879596924b1874bf9a8f6880206d61065c5a912c8e5c297fb7", size = 28839, upload-time = "2026-10-06T17:33:05.713Z" } +sdist = { url = "https://files.pythonhosted.org/packages/db/07/b7b01ecb69d02f540e679a9e36f7413d081f225bbbed4469d212ada10bb7/opentelemetry_exporter_otlp_proto_http-1.45.2.tar.gz", hash = "sha256:5984a3fb46bc4628e4e2b85d4a6e72637e03962aae6cf372791137768a4ad939", size = 28843, upload-time = "2026-10-29T17:29:46.15Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/aa/1f/517eaa0187ba106a9da97160ce2add3a371812681dc440930b267f714e42/opentelemetry_exporter_otlp_proto_http-1.45.1-py3-none-any.whl", hash = "sha256:24a97cf3753c7fb52fad44a696e452ff371686339e2acf3309e2eda3d0230700", size = 22180, upload-time = "2026-10-06T17:32:43.946Z" }, + { url = "https://files.pythonhosted.org/packages/32/65/f64d7d2450217e2989714e1dee15e19bf79a77a313387abac0cac77bc10e/opentelemetry_exporter_otlp_proto_http-1.45.2-py3-none-any.whl", hash = "sha256:6e4d025138829d0ee57946930c2ccad6491ad4d92a958e9c7eea69278fe60cfc", size = 22180, upload-time = "2026-10-29T17:29:20.154Z" }, ] [[package]] name = "opentelemetry-instrumentation" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, @@ -628,14 +628,14 @@ dependencies = [ { name = "packaging" }, { name = "wrapt" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/a5/03/89e47ff8d52a4f83b343e6eb9ef1698ff45357216e5b6b2b21e0da5c5c7d/opentelemetry_instrumentation-0.66b1.tar.gz", hash = "sha256:e79a510f7d87c72d95e964ddb42193a0d9a75668c027d980eab032ea1322a5ce", size = 43308, upload-time = "2026-10-06T17:36:10.703Z" } +sdist = { url = "https://files.pythonhosted.org/packages/76/b9/46a136199fa6928eecefec8418867a460d94f01c608a85d22bd2ed4e8d48/opentelemetry_instrumentation-0.66b2.tar.gz", hash = "sha256:02b094150e53b76f5906d75e628dbb3833bbc6e62fa109b5c7ba0c081865e923", size = 43305, upload-time = "2026-10-29T17:38:11.618Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/da/b2/d1413681ff43e13ac9860df27e1226d3199ab0b97b352ceea41abcc660a5/opentelemetry_instrumentation-0.66b1-py3-none-any.whl", hash = "sha256:4c4aa14dc9a24a02325a9d4c42c4d0208dbb1374c2b1b8fe6c9392d59f3e1008", size = 36904, upload-time = "2026-10-06T17:35:11.663Z" }, + { url = "https://files.pythonhosted.org/packages/3b/41/014d40e2b08a5d9d9058ed4967ad992657c203ce0c292ded97364ee7b82a/opentelemetry_instrumentation-0.66b2-py3-none-any.whl", hash = "sha256:fa9ccfdab147a14af8107d19ef0a7b5015675273c5adced7a1fc38f28b42ec4c", size = 36902, upload-time = "2026-10-29T17:37:06.994Z" }, ] [[package]] name = "opentelemetry-instrumentation-requests" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, @@ -643,71 +643,71 @@ dependencies = [ { name = "opentelemetry-semantic-conventions" }, { name = "opentelemetry-util-http" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/08/62/dcca0b7a2008675056040c61b70d37b5a24439613c7822068908ad3255ae/opentelemetry_instrumentation_requests-0.66b1.tar.gz", hash = "sha256:28578f72e68e3a5be3226c618ac9570ed360ef1dd22d5d6e0721c6905a4ccc67", size = 17985, upload-time = "2026-10-06T17:36:37.478Z" } +sdist = { url = "https://files.pythonhosted.org/packages/46/2e/cdd7a2ebbdb9d31879781842feb6a3515e4a1d4d87cd701556fc849ddd35/opentelemetry_instrumentation_requests-0.66b2.tar.gz", hash = "sha256:bcfbdc3ff3ec8524044908788f0e7f3c25e219053b496fd9926d75f8d7c7bc96", size = 17984, upload-time = "2026-10-29T17:38:43.998Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/88/01/98e9bb7fef12784cd19811e454cf25bce4d774fd3e46b3f5fd2bce237075/opentelemetry_instrumentation_requests-0.66b1-py3-none-any.whl", hash = "sha256:7ba17d984a2bd876b88bf0aafcca27b5e3ff4c1821e0fe07641e380a3cf3a3a2", size = 13320, upload-time = "2026-10-06T17:35:52.477Z" }, + { url = "https://files.pythonhosted.org/packages/b2/fc/d73ebbb46158722f63eb9e95a22a2aa03ec8cadd5ef9b91fda350ddd33ca/opentelemetry_instrumentation_requests-0.66b2-py3-none-any.whl", hash = "sha256:b0ba903a0bd7ebb234c8b32d3d957efc4061ba8571916558dc3f3dcdabb5e5e1", size = 13322, upload-time = "2026-10-29T17:37:51.421Z" }, ] [[package]] name = "opentelemetry-instrumentation-threading" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, { name = "opentelemetry-instrumentation" }, { name = "wrapt" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/55/4f/5fa05266cf24cae93fc32d557d0d2d2f605f81cca1df90614231bbad3cd1/opentelemetry_instrumentation_threading-0.66b1.tar.gz", hash = "sha256:2c217359439d09ca4a4be524db368c05a3cc7f218b85e8086f22664db0a03538", size = 9031, upload-time = "2026-10-06T17:36:41.147Z" } +sdist = { url = "https://files.pythonhosted.org/packages/8c/bc/7e342fed05def315771aca1e7c4f1ab9efc7bf31da6775a890d965888f2a/opentelemetry_instrumentation_threading-0.66b2.tar.gz", hash = "sha256:512e0d4b568eff36ca15a977b507ddc1e64a38f93dbcafa4e701b3555b066991", size = 9032, upload-time = "2026-10-29T17:38:48.386Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/86/da/1cd52b8be7a521958ccdb9a1c4e5ae743aa2be295ba21ec0b620dc87842a/opentelemetry_instrumentation_threading-0.66b1-py3-none-any.whl", hash = "sha256:94039c60603060d26524e31aed1181a5d153e43f58462d110dbeb4830687d7d7", size = 8493, upload-time = "2026-10-06T17:35:57.958Z" }, + { url = "https://files.pythonhosted.org/packages/36/e3/667156215ae69ec6290573da351365e4787f09f89a9b9304d1e5248f491a/opentelemetry_instrumentation_threading-0.66b2-py3-none-any.whl", hash = "sha256:647480ef889595d577fea66d0cfcec395cf5d89888bbe05ca9919355797c85a3", size = 8491, upload-time = "2026-10-29T17:37:57.742Z" }, ] [[package]] name = "opentelemetry-proto" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "protobuf" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/4b/7f/15f014fb195da6c2dbb6c71399b8e76824878718e94de6454038488eed28/opentelemetry_proto-1.45.1.tar.gz", hash = "sha256:79e0fb95e4616691a469439238aa9224d75779b3e108e895d1aa125ab29ca77c", size = 46488, upload-time = "2026-10-06T17:33:11.49Z" } +sdist = { url = "https://files.pythonhosted.org/packages/24/9c/1aa4ce60e9bc72af20dc49c92cc0566825092d92b3d6a277439fb5fb7c01/opentelemetry_proto-1.45.2.tar.gz", hash = "sha256:bd8d23cf770605b0af9b7be2071d26a464fea289d35429abfd2a66226114ad64", size = 46486, upload-time = "2026-10-29T17:29:53.007Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ab/9a/42ec8180a769516ae757e893b69736826efceac7332553915b4528a91c6d/opentelemetry_proto-1.45.1-py3-none-any.whl", hash = "sha256:f38e2a8413053c180cd3d2637fbb279673ec2f6a6e09c995aafa2f452c52b46e", size = 72488, upload-time = "2026-10-06T17:32:53.057Z" }, + { url = "https://files.pythonhosted.org/packages/7e/0d/a0b8f2b9efe2ec1abdf639d3696db9b1563ebeb11d91aac08ba7341e9122/opentelemetry_proto-1.45.2-py3-none-any.whl", hash = "sha256:03a7ca1b43f89fd5b965d5975902bb2515c0c86e2428b456836e9a6149c6235a", size = 72484, upload-time = "2026-10-29T17:29:31.403Z" }, ] [[package]] name = "opentelemetry-sdk" -version = "1.45.1" +version = "1.45.2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, { name = "opentelemetry-semantic-conventions" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/a1/79/7392e21a1c8f0c61d90b223e31c7e48cb9d452e91a6b820ad24cca5f23c4/opentelemetry_sdk-1.45.1.tar.gz", hash = "sha256:63d24a6ca645019a631e6a51999c73e93adcac1196ca640b8ae78a7cc4762bf3", size = 218324, upload-time = "2026-10-06T17:33:13.26Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7b/1a/74a21d4d6969fb8b432ac397e66112a8167a6deb267ea4559dbaf2fe91ef/opentelemetry_sdk-1.45.2.tar.gz", hash = "sha256:7eec4de13dd21ff3a1670dcb0e02079e692736f94d733dfdce5af461d884248d", size = 221705, upload-time = "2026-10-29T17:29:54.685Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/95/3c/87c42b4bd6dd297536f04cd9383d212ac557ecd49f2cbdcd46da1c9ef5c8/opentelemetry_sdk-1.45.1-py3-none-any.whl", hash = "sha256:c604c11dc429810812348989115fa44bd558772a3d7442afc43d024f2c250ca4", size = 140063, upload-time = "2026-10-06T17:32:55.04Z" }, + { url = "https://files.pythonhosted.org/packages/9f/a5/9a3b793ef48245f2336a16beb2324c2397dbb3f987cd68942f77cca06156/opentelemetry_sdk-1.45.2-py3-none-any.whl", hash = "sha256:ff974ea70ee4f1d51e2ec152db37c2b626c7bf82bb3f7d86114fd8704e7199c6", size = 141756, upload-time = "2026-10-29T17:29:33.722Z" }, ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "opentelemetry-api" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/46/e4/dbbfb2a010c4db2224a5114638acede6fe563d33cc20fb1752cebcbe6298/opentelemetry_semantic_conventions-0.66b1.tar.gz", hash = "sha256:497ca63bf383723411e8eaf60c8779e9877633c936bb641080adab59d0eb6ec8", size = 150250, upload-time = "2026-10-06T17:33:14.073Z" } +sdist = { url = "https://files.pythonhosted.org/packages/37/3f/50f95972b50e8e353f5b9342034c9cd17730f1956f009ce6a3fbbd89f9ce/opentelemetry_semantic_conventions-0.66b2.tar.gz", hash = "sha256:7da5f1a5dc4383eb66711d4d3d3e71824d9403ac1559fea021cc103c1a4c4976", size = 150246, upload-time = "2026-10-29T17:29:55.682Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/bc/14/67f8aa798857f8cf686f515bf93d9bb877ce952ddc8efae0fa25b45ce0d6/opentelemetry_semantic_conventions-0.66b1-py3-none-any.whl", hash = "sha256:d4cddeb4315490b35213f55e2bdc9ac54bb1e4d318927475bed62b35545e581b", size = 206279, upload-time = "2026-10-06T17:32:56.103Z" }, + { url = "https://files.pythonhosted.org/packages/67/bd/6bf33ed31521c565931c037e9e81bac47c1acb000e850c6e24220e2a0c00/opentelemetry_semantic_conventions-0.66b2-py3-none-any.whl", hash = "sha256:4cbe61e5f9275d57ab31708446e7938ef4291ebbe6a7fca6f7a629c5acae87d8", size = 206280, upload-time = "2026-10-29T17:29:35.062Z" }, ] [[package]] name = "opentelemetry-util-http" -version = "0.66b1" +version = "0.66b2" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7c/b5/df4b61da899f6ebdffdbdf0c8b0f3189ee57151694ccd5b7d50ee2906241/opentelemetry_util_http-0.66b1.tar.gz", hash = "sha256:047dea1a628031f857a5a32261dc0e955bc162d39993ed1cffb8f2cff5ba8a62", size = 11586, upload-time = "2026-10-06T17:36:46.572Z" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/57/33566966a7bced4d02fbc672f92029184e4a743f5b531e44b4c0dc4c999b/opentelemetry_util_http-0.66b2.tar.gz", hash = "sha256:7ba066ea609202e474679ddf1d0f753a1e6619bd206b36afaecba4bbb86e25d0", size = 11587, upload-time = "2026-10-29T17:38:56.043Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/eb/9b/c77ecaea79ba0de1a11e7f06a7f5eea7043ec23f1860dcf5f03536698e4c/opentelemetry_util_http-0.66b1-py3-none-any.whl", hash = "sha256:8f443d7abcaf29c4a07b373bbd31b5b39132c0ed3c27d015a59dc0323d5b1c58", size = 8387, upload-time = "2026-10-06T17:36:06.984Z" }, + { url = "https://files.pythonhosted.org/packages/18/8d/39885564eefa43f6181acfa3d698af2f6b5fe3e64c86dce3f1b955f6397f/opentelemetry_util_http-0.66b2-py3-none-any.whl", hash = "sha256:c4bb5d6744e60353bcaa3e325bc529a1515346b51cb4d9c8e5b730579337e06d", size = 8383, upload-time = "2026-10-29T17:38:07.462Z" }, ] [[package]] @@ -958,16 +958,16 @@ wheels = [ [[package]] name = "research-repo-tools" -version = "0.2.8" +version = "0.2.9" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "packaging" }, { name = "pyyaml" }, { name = "rust-just" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/4a/24/a7dc5d7586af01a68ff21d3c108b383903579d2dcf3b7eb2de2457b15782/research_repo_tools-0.2.8.tar.gz", hash = "sha256:b727c6bb619c31419f6408c4fc2ba8fdfeeff7cfcd969d5aeacf1a3ef825073d", size = 1422462, upload-time = "2026-11-10T07:56:25.653Z" } +sdist = { url = "https://files.pythonhosted.org/packages/47/f7/9f382b8d14fa3d37be4f8323f32a7a0c5ecaa2094de65aa9b2477cde4c3d/research_repo_tools-0.2.9.tar.gz", hash = "sha256:e115f5425996337275345b9ddd117f82f5c179b3fcd2fcaf3aeb04650343e9c7", size = 1597302, upload-time = "2026-11-16T17:32:48.987Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/de/d6/e6aaf3e593cf4faafdad459cad71b1ed5215f9e149ddea2730e447309ab6/research_repo_tools-0.2.8-py3-none-any.whl", hash = "sha256:845d257cc829e60bc83acdb6b43dcec0da4bd32224de1d7da29e6b8e53456f2d", size = 597227, upload-time = "2026-11-10T07:56:23.721Z" }, + { url = "https://files.pythonhosted.org/packages/14/9b/8835593f20750ed4bc857ee0076297696cdd8772107beae4a5f9627e6943/research_repo_tools-0.2.9-py3-none-any.whl", hash = "sha256:6cc53318bf2cecafe2594993efa540d3e7f704d38e5a56e6e5d7f2e7e5103e5e", size = 676507, upload-time = "2026-11-16T17:32:47.313Z" }, ] [package.optional-dependencies] From 18667d5583b2105ffcbb4c96b4c4c91333afaa9f Mon Sep 17 00:00:00 2001 From: Adam Getchell Date: Mon, 16 Nov 2026 16:09:57 -0800 Subject: [PATCH 2/2] test: use native paths in Actions diagnostics - Assert the complete platform-native filename so Windows diagnostics pass while preserving the offline rejection and unchanged-file checks. - Validate with just check, all eight Actions integration cases, and Windows-targeted type checking. --- tests/tooling/test_maintenance_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tooling/test_maintenance_integration.py b/tests/tooling/test_maintenance_integration.py index 0d9306b..25f5573 100644 --- a/tests/tooling/test_maintenance_integration.py +++ b/tests/tooling/test_maintenance_integration.py @@ -69,7 +69,7 @@ def test_offline_actions_check_rejects_partial_coupled_bumps_without_writes( filename, identity = details diagnostic = capsys.readouterr().err assert identity in diagnostic - assert filename in diagnostic + assert str(actions_consumer / ".github" / filename) in diagnostic @pytest.mark.parametrize("mode", ["--dry-run", "--check", "apply"])