Skip to content

Compliance: ruleset-drift-pr-quality-require_last_push_approval #420

Closed

Description

@don-petry

Compliance Finding

Category: rulesets
Severity: error
Check: ruleset-drift-pr-quality-require_last_push_approval

Detail

Ruleset pr-quality parameter require_last_push_approval has drifted from the codified standard: expected true, actual false. The codified JSON (standards/rulesets/pr-quality.json) is the source of truth (#575/#580); run scripts/apply-rulesets.sh --repo petry-projects/markets to converge.

Standard Reference

standards/github-settings.md#pr-quality--standard-ruleset-all-repositories

Remediation

Please review the linked standard and bring this repository into compliance.

See the full standards documentation for implementation guidance.


This issue was automatically created by the weekly compliance audit.

Activity

  1. don-petry commented on Aug 14, 2026

    @don-petry
    ContributorAuthor

    Dev-Lead Implementation Plan

    Issue: #420 — Compliance: ruleset-drift-pr-quality-require_last_push_approval

    Root-cause investigation (before writing code)

    Scope

    Make the self-heal's silent authentication failure loud and actionable so the missing-secret root cause is discoverable and the drift stops recurring unnoticed. (The codified ruleset value already matches the standard; the blocker is operational, not the payload.)

    Implementation Checklist

    • Add a preflight step to .github/workflows/apply-repo-settings.yml that fails visibly (GitHub ::error annotation + $GITHUB_STEP_SUMMARY) with actionable remediation when GH_TOKEN_ADMIN is unset.

    Tests to Write

    • Extend .github/scripts/tests/apply-repo-settings-workflow.bats with assertions that the preflight step exists, references GH_TOKEN_ADMIN, and surfaces the failure loudly.

    Test Command

    npx bats .github/scripts/tests/apply-repo-settings-workflow.bats

    Note on live convergence

    Converging the live ruleset requires administration:write. The correct, idempotent tool is the codified self-heal — which only needs the missing GH_TOKEN_ADMIN secret to be provisioned by an org/repo admin. A full-script re-apply would also drop the live RepositoryRole bypass actor (3 live vs 2 codified), which is out of scope for this finding, so live convergence is intentionally left to a scoped admin apply once the secret exists.

  2. don-petry commented on Aug 14, 2026

    @don-petry
    ContributorAuthor

    Dev-Lead: Implementation Complete

    Root cause

    The codified standard was already correct — .github/scripts/apply-pr-quality-ruleset.sh sets require_last_push_approval: true and its bats test asserts it. The drift is on the live ruleset, and it kept recurring (#325 → #403 → #420) for one reason:

    Confirmed live state of ruleset pr-quality (id 14592512): require_last_push_approval: false (also require_code_owner_review: false, dismiss_stale_reviews_on_push: false — separate findings).

    Plan Execution

    • Investigated codified standard vs. live ruleset and the self-heal run history
    • Identified the missing GH_TOKEN_ADMIN secret as the recurrence root cause
    • TDD: added failing bats assertions for a loud preflight, then implemented it
    • Full bats suite (41 tests) + dev-lead-lint + shellcheck of the embedded step all pass

    Test Results

    1..12
    ok 1 workflow file exists
    ok 2 workflow is valid YAML
    ok 3 workflow declares a schedule trigger with a cron entry (issue #403 drift self-heal)
    ok 4 workflow preserves the workflow_dispatch trigger
    ok 5 workflow preserves the push trigger on main touching the ruleset scripts
    ok 6 workflow has a preflight step that verifies GH_TOKEN_ADMIN before applying (issue #420)
    ok 7 preflight step surfaces the missing secret loudly and actionably (issue #420)
    ok 8 preflight runs before the apply-repo-settings step (issue #420)
    ok 9 script exists and is executable
    ok 10 script uses set -euo pipefail
    ok 11 script targets petry-projects/markets repo
    ok 12 script generates correct ruleset payload
    

    Files Changed

    • .github/workflows/apply-repo-settings.yml: added a Verify admin token is configured preflight step that fails visibly (GitHub ::error annotation + $GITHUB_STEP_SUMMARY with remediation) when GH_TOKEN_ADMIN is unset — converting a silent, buried self-heal failure into a discoverable, actionable one.
    • .github/scripts/tests/apply-repo-settings-workflow.bats: added 3 regression tests pinning that the preflight exists, surfaces the failure loudly (error annotation + job summary + non-zero exit), and runs before the apply step.

    What this does NOT do (and why)

    • It does not flip the live require_last_push_approval boolean. Converging the live ruleset needs administration:write; the correct idempotent tool is the existing self-heal, which only needs GH_TOKEN_ADMIN provisioned. A one-off full-script re-apply would also drop the live RepositoryRole bypass actor (3 live actors vs 2 codified), which is out of scope for this finding.

    Remediation to fully close the finding

    1. Provision the GH_TOKEN_ADMIN secret (repo or org admin token, administration:write). Once set, the weekly self-heal converges the ruleset automatically and this drift stops recurring. Until then, the preflight will make each failed run say exactly this.
    2. Or run a scoped admin apply of the pr-quality ruleset once (preserving the current bypass actors).

    Notes

    Phase 2 (TDD) was followed: new tests failed red (steps 6–8) before the workflow change, then passed green. No live infrastructure was mutated.

  3. added a commit that references this issue on Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compliance-auditAutomated compliance audit findingdev-leadFor dev-lead agent pickup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions