Skip to content

Run the shared CV-005 contracts instead of a local copy - #603

Merged
leynos merged 1 commit into
mainfrom
jm5-cv005-sweep-rust
Sep 29, 2026
Merged

leynos merged 1 commit into
mainfrom
jm5-cv005-sweep-rust

Conversation

@leynos

@leynos leynos commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Replaces this repository's Rust copy of the CV-005 contract with cv005-contracts check from leynos/shared-actions, pinned to a full commit (a38feb9b, the merge of shared-actions #540) in CV005_CONTRACTS_REF. The repository's only parameter is repository in .github/cv005.toml. make test-workflow-contracts runs the CLI, and CI runs that target in a "Check the CV-005 contracts" step, because the deleted cargo tests were the only thing running the contract there.

Removed: tests/coverage_workflows.rs, its module directory and tests/codescene_environment.rs. The runner-placement contract in that directory is not CV-005 and stays, as tests/runner_placement.rs with tests/runner_placement/{placement,placement_cases,reader}.rs; its reader is trimmed to what placement reads, so no dependency changes. tests/codescene_uploader_contract.rs stays: the library holds that the two coverage actions share one commit, not which commit is approved.

The library found the publisher still in the older token shape, so coverage-main.yml now takes the shape the estate rule holds:

  • publisher.upload / token.scope: the upload step bound CS_ACCESS_TOKEN in its env and passed ${{ env.CS_ACCESS_TOKEN }} as access-token. The upload action is composite and hands its step's env to the nested steps it runs, so the token now enters no env: a Check CodeScene token step (id codescene-token) runs exactly echo "available=${{ secrets.CS_ACCESS_TOKEN != '' }}" >> "$GITHUB_OUTPUT", the upload's if: is steps.codescene-token.outputs.available == 'true' && github.ref == 'refs/heads/main', and it passes access-token: ${{ secrets.CS_ACCESS_TOKEN }} directly.
  • publisher.least-privilege: the publisher's checkout sets persist-credentials: false.

ci.yml had no uv, which the target needs, so the job gains a Setup uv step before the new "Check the CV-005 contracts" step.

Proof:

  • make test-workflow-contracts passes; on the base it fails the six findings above.
  • Setting cancel-in-progress: true fails it with publisher.concurrency; removing persist-credentials: false fails it with publisher.least-privilege; deleting the check step fails it with token.check-step; restoring access-token: ${{ env.CS_ACCESS_TOKEN }} fails it with publisher.upload.
  • cargo fmt --check, mdtablefix --check, markdownlint-cli2, cargo clippy --all-targets --all-features -- -D warnings, cargo test --test runner_placement (19 tests) and cargo test --test codescene_uploader_contract pass. make lint and make test run in CI.

Developers' guide updated: the "Only the upload step holds the token" bullet described the old shape.

Summary by Sourcery

Replace the local CV-005 workflow contract implementation with the pinned shared contract checker and align the coverage workflow with its requirements.

Enhancements:

  • Use the shared, pinned CV-005 contract checker instead of maintaining a local Rust implementation.
  • Separate runner-placement coverage from the shared workflow contract checks while retaining the CodeScene uploader consistency contract.
  • Harden the CodeScene coverage workflow to satisfy token-handling and least-privilege requirements.

Build:

  • Add a Make target for running the pinned CV-005 contracts and include it in the default build checks.

CI:

  • Install uv and run the shared CV-005 contract checks in CI.

Documentation:

  • Update the developers' guide to describe the shared CV-005 checker and the revised token-handling contract.

Tests:

  • Remove the local CV-005 contract test suite while retaining runner-placement and CodeScene uploader contract tests.

Chores:

  • Configure the repository parameter for CV-005 contract validation.

The repository's Rust copy of the CV-005 contract is replaced by
cv005-contracts check, pinned to a shared-actions commit in the Makefile,
with the repository's one parameter in .github/cv005.toml. CI runs the
target in its own step, since no cargo test carries the contract now. The
library also holds the publisher's checkout to persist-credentials: false,
so the checkout sets it.
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 66d28348-b242-4ffd-bbc9-61d11e902086

📥 Commits

Reviewing files that changed from the base of the PR and between 54ca63d and b3d0e04.

📒 Files selected for processing (17)
  • .github/cv005.toml
  • .github/workflows/ci.yml
  • .github/workflows/coverage-main.yml
  • Makefile
  • docs/developers-guide.md
  • tests/codescene_environment.rs
  • tests/coverage_workflows.rs
  • tests/coverage_workflows/closure_properties.rs
  • tests/coverage_workflows/publisher_cases.rs
  • tests/coverage_workflows/pull_request_cases.rs
  • tests/coverage_workflows/reader.rs
  • tests/coverage_workflows/rules.rs
  • tests/coverage_workflows/text.rs
  • tests/runner_placement.rs
  • tests/runner_placement/placement.rs
  • tests/runner_placement/placement_cases.rs
  • tests/runner_placement/reader.rs
💤 Files with no reviewable changes (8)
  • tests/coverage_workflows/pull_request_cases.rs
  • tests/coverage_workflows/closure_properties.rs
  • tests/coverage_workflows/publisher_cases.rs
  • tests/codescene_environment.rs
  • tests/coverage_workflows.rs
  • tests/coverage_workflows/rules.rs
  • tests/coverage_workflows/text.rs
  • tests/coverage_workflows/reader.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


Summary

  • Replace the repository’s local CV-005 workflow contracts with the pinned cv005-contracts check CLI from leynos/shared-actions.
  • Add .github/cv005.toml and the make test-workflow-contracts target. Run the target in CI after setting up uv.
  • Remove the local coverage-workflow and CodeScene-environment contract tests. Retain runner-placement tests and the CodeScene uploader consistency contract.
  • Update coverage-main.yml to check token availability through a step output, pass the secret directly to the upload action, and disable persisted checkout credentials.
  • Update the developers’ guide with the new contract command and token-handling approach.

Testing

The author reports that the contract target passes and that reverting specified changes triggers the corresponding findings. The author also reports successful formatting, lint, and retained-test runs.

Walkthrough

The coverage workflow now gates CodeScene uploads on token availability and the main branch. A pinned shared CV-005 checker replaces local workflow-contract tests. Runner-placement tests gain a separate workflow reader.

Changes

Workflow contracts and runner placement

Layer / File(s) Summary
Coverage publication token handling
.github/workflows/coverage-main.yml, docs/developers-guide.md
The workflow records whether the token is available, then gates upload on that output and the main ref. The upload action receives the secret directly. The developer guide documents this pattern.
Shared workflow contract checker
.github/cv005.toml, .github/workflows/ci.yml, Makefile, docs/developers-guide.md, tests/codescene_environment.rs, tests/coverage_workflows*
The Makefile adds a pinned shared CV-005 checker target, and CI runs it. Local workflow-contract tests are removed. The developer guide describes the shared checker and its documented checks.
Runner-placement test reader
tests/runner_placement.rs, tests/runner_placement/*, docs/developers-guide.md
Runner-placement tests gain a workflow reader and use it to parse fixtures. The developer guide records the updated test location.

Priority: ⬇️ Low

Change: Refactor

Merge Risk: ⚪ Minimal · up to b3d0e

No concrete merge-blocking issue is established in the workflow-contract migration or token handling changes. Merge after normal checks pass.

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarises the main change: replacing the local CV-005 contract tests with the shared contracts checker. No issue or roadmap reference is required by the provided context.
Description check ✅ Passed The description accurately explains the shared checker, workflow changes, removed tests, retained tests, CI updates, documentation changes, and validation results.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (5 skipped: 5 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Overall) ✅ Passed The changed workflow behaviour is guarded by the new CI step make test-workflow-contracts, which runs the pinned shared cv005-contracts check against the repository. The retained runner-placement …
User-Facing Documentation ✅ Passed Pass the user-facing documentation check. The pull request changes CI workflow contracts, Makefile targets, and developer test infrastructure. It does not change mdtablefix behaviour or its end-user…
Developer Documentation ✅ Passed Pass this check. The changed developer guide clearly documents the new make test-workflow-contracts target, the pinned cv005-contracts source, the CV005_CONTRACTS_REF update path, the uv and P…
Module-Level Documentation ✅ Passed All Rust modules introduced or moved by the pull request have module-level //! documentation. tests/runner_placement.rs explains the contract and its relationship to placement, placement_cases…
Testing (Unit And Behavioural) ✅ Passed Pass the testing check. The PR exercises the changed workflow contract at the correct boundary: make test-workflow-contracts runs the pinned cv005-contracts check --repository . CLI, and CI invoke…
Testing (Property / Proof) ✅ Passed The pull request changes workflow-contract ownership and test-file organisation. It does not introduce a new production invariant over a broad input space. The deleted closure_properties.rs tested t…
Testing (Compile-Time / Ui) ✅ Passed PASS — The pull request introduces no Rust or TypeScript compile-time behaviour, so no trybuild test is required. The Rust changes are test-only runner-placement modules and use focused, parameterised…
Unit Architecture ✅ Passed Accept the change. The new workflow reader keeps filesystem and YAML parsing fallibility explicit through Result, while get, jobs, and placement functions remain read-only transformations. The r…
Domain Architecture ✅ Passed PASS — The pull request changes CI, Make targets, workflow configuration, documentation, and contract-test infrastructure only. The added tests/runner_placement/reader.rs is test-side filesystem/YAM…
Observability ✅ Passed Treat this check as passed. The pull request changes CI, coverage publication, build checks, documentation, and tests. It does not change application runtime behaviour. The coverage workflow exposes t…

Check the token, record the sign
Gate the upload on branch and line
Run the shared contracts in CI
Read runner workflows locally
Keep each check in its own place

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR moves CV-005 validation from a large local Rust implementation to the pinned shared cv005-contracts CLI, integrates it into Make and CI, updates the coverage workflow to comply with the shared token-scope and checkout rules, and preserves only the repository-specific runner-placement and uploader contracts.

Sequence diagram for CI CV-005 contract checks

sequenceDiagram
    participant CI as GitHub Actions CI
    participant Make as Makefile
    participant UV as uv
    participant CLI as cv005-contracts
    participant Repo as Repository workflows

    CI->>UV: Setup uv
    CI->>Make: make test-workflow-contracts
    Make->>UV: tool run --python 3.13
    UV->>CLI: Fetch pinned shared-actions commit
    Make->>CLI: check --repository .
    CLI->>Repo: Read .github/cv005.toml and workflows
    CLI-->>CI: Pass or fail CV-005 contracts
Loading

Sequence diagram for scoped CodeScene token upload

sequenceDiagram
    participant Workflow as coverage-main.yml
    participant GitHub as GitHub expressions
    participant Upload as CodeScene upload action
    participant CodeScene as CodeScene

    Workflow->>GitHub: Evaluate secrets.CS_ACCESS_TOKEN != ''
    GitHub-->>Workflow: codescene-token output
    alt Token available and main ref
        Workflow->>Upload: access-token: secrets.CS_ACCESS_TOKEN
        Upload->>CodeScene: Upload lcov.info
    else Token unavailable or non-main ref
        Workflow-->>Upload: Skip upload
    end
Loading

File-Level Changes

Change Details Files
Replace the repository-local CV-005 Rust contract suite with the shared pinned cv005-contracts CLI and wire it into local and CI validation.
  • Add .github/cv005.toml with the repository parameter.
  • Define a Make target that runs the shared CLI via uv from a full shared-actions commit, and include it in all.
  • Run the contract target in CI after provisioning uv.
  • Delete the local CV-005 readers, rules, fixtures, and environment tests while retaining the separate runner-placement and CodeScene uploader contracts.
.github/cv005.toml
.github/workflows/ci.yml
Makefile
tests/codescene_environment.rs
tests/coverage_workflows.rs
tests/coverage_workflows/closure_properties.rs
tests/coverage_workflows/publisher_cases.rs
tests/coverage_workflows/pull_request_cases.rs
tests/coverage_workflows/reader.rs
tests/coverage_workflows/rules.rs
tests/coverage_workflows/text.rs
tests/runner_placement.rs
tests/runner_placement/placement_cases.rs
tests/runner_placement/reader.rs
Adjust the coverage workflow to satisfy the shared CV-005 token-scope and least-privilege contracts.
  • Disable checkout credential persistence in the publisher job.
  • Add an exact token-presence check step that emits a boolean output without binding the secret to env.
  • Gate the upload on the check output and main-branch ref, passing the secret directly as the action input.
  • Update comments to reference the shared Make target.
.github/workflows/coverage-main.yml
Rewrite developer documentation to describe the shared contract implementation and the new token-handling shape.
  • Document the pinned shared library, repository configuration, uv requirement, and CI target.
  • Replace the old upload-step env guidance with the token check/output and direct secret-input behavior.
  • Update references to the relocated runner-placement contract and retained uploader contract.
docs/developers-guide.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@leynos
leynos marked this pull request as ready for review September 29, 2026 23:05
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @leynos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 16 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@leynos
leynos merged commit 71ff87f into main Sep 29, 2026
13 checks passed
@leynos
leynos deleted the jm5-cv005-sweep-rust branch September 29, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant