Skip to content

Unified check manifest: one source of truth for deterministic checks across pre-push, pr-preflight, and CI #9448

Closed

Description

@Git-on-my-level

Problem

Deterministic checks are declared in three places that have already drifted apart:

  1. scripts/pre-push (~700-line bash hook, singleflight-wrapped by .github/scripts/preflight_runner.py) runs: scan_import_time_side_effects.py, scan_async_blockers.py, check_module_stub_pollution.py, check_workflow_contracts.py, check_arch_guardrails.py, check-async-after-ratchet.py, check-userdefaults-key-ratchet.py, changelog checks, typecheck, OpenAPI contract sync, backend unit test selection.
  2. scripts/pr-preflight → .github/scripts/pr_preflight.py runs a different set via select_checks(): diff-hygiene, architecture-guardrails, product-invariants, desktop-changelog, e2e flow coverage.
  3. CI workflow YAMLs hardcode a third set: repo-checks.yml runs check_brand_ui.py, check_product_invariants.py, deferred-work-marker-count.py, check_arch_guardrails.py, pr_preflight.py; backend-checks.yml runs scan_async_blockers.py.

Concrete drift today: check_brand_ui.py and deferred-work-marker-count.py run only in CI — neither local entry point executes them. A PR that adds an off-brand purple accent or an untracked TODO marker learns about it from a red CI run instead of pre-push. More generally: with three declaration sites, every new check must be wired in three places or the sets diverge again. There is no guard that detects the divergence.

The invariant this issue establishes: CI must never be the first execution of a deterministic diff-scoped check.

Prescribed implementation (single PR)

1. Check manifest — the single source of truth

Create .github/checks-manifest.yaml. One entry per diff-scoped deterministic check:

checks:
  - id: brand-ui
    command: ["python3", ".github/scripts/check_brand_ui.py"]
    pass_changed_files: true          # runner appends changed file list (or a @file), per script's existing CLI
    triggers: ["all"]                 # or path globs, e.g. ["backend/**/*.py"]
    lanes: [local, ci]                # local = pre-push + `make preflight`; ci = PR workflow
  - id: deferred-work-markers
    command: ["python3", ".github/scripts/deferred-work-marker-count.py"]
    triggers: ["all"]
    lanes: [local, ci]
  # ... every check currently invoked by repo-checks.yml, pr_preflight.select_checks(),
  #     and the diff-scoped section of scripts/pre-push

Scope rule for what belongs in the manifest: deterministic, diff-scoped, stdlib-or-repo-only checks (lint/ratchet/contract/scan scripts). Component test suites (backend/test.sh, Swift tests), builds, and anything needing live services stay out.

2. One runner, consumed by all three surfaces

Create .github/scripts/run_checks.py (stdlib only):

  • --base <ref> computes changed files (git diff --name-only <merge-base>..HEAD), matches each manifest entry's triggers, runs matching checks, streams output, exits non-zero if any fail. --lane local|ci filters by lane. --list prints the resolved plan without running (used by tests).
  • Wire the three surfaces to it:
    • pr_preflight.py: select_checks() is replaced by (or delegates to) manifest resolution, so the PR contract check runs the manifest's ci lane. Keep pr_preflight.py as the entry point CI already calls — least workflow churn.
    • scripts/pre-push: add a single step that invokes run_checks.py --lane local --base <merge-base> (through the existing preflight_runner.py singleflight, same as its other sections). Remove the pre-push sections that duplicate manifest entries (check_arch_guardrails, changelog data checks) so each check runs exactly once. The non-manifest sections of pre-push (typecheck, OpenAPI sync, unit-test selection) are untouched.
    • repo-checks.yml: replace the individually enumerated check steps with one step calling run_checks.py --lane ci --base "$GITHUB_BASE_REF". Keep separate steps only where the workflow needs distinct artifacts/permissions.
  • Add make preflight (root Makefile target) → python3 .github/scripts/run_checks.py --lane local --base origin/main.

3. Drift guard — what makes this permanent

Add .github/scripts/test_run_checks.py (runs in the same CI job, standard unittest like the existing test_check_brand_ui.py):

  • Coverage direction 1: grep all .github/workflows/*.yml for invocations of .github/scripts/check_*, .github/scripts/*-count.py, backend/scripts/scan_*, backend/scripts/check_*. Every hit must be either (a) registered in the manifest, or (b) listed in an explicit exempt: block in the manifest with a one-line reason (e.g. release-pipeline-only scripts). Unregistered + unexempted = test failure naming the script.
  • Coverage direction 2: every manifest entry with lanes: [.., ci] must be reachable from a workflow (via the run_checks.py call) — assert repo-checks.yml invokes the runner.
  • Manifest validity: ids unique, commands exist on disk, globs parse, lanes non-empty.
  • Runner behavior: unit tests for trigger matching (changed file → selected checks) and failure propagation, using a temp manifest.

4. Documentation (same PR, per repo docs-move-with-code rule)

  • AGENTS.md: replace scattered "run X before committing" bullets for manifest-covered checks with one mechanical rule: "Run make preflight before opening a PR. It runs the same manifest CI runs (.github/checks-manifest.yaml). A check failing in CI that did not run locally is a manifest bug — fix the manifest, don't add a one-off workflow step. New deterministic checks are registered in the manifest, never hardcoded in workflow YAML."
  • Short header comment in the manifest explaining the scope rule and how to add a check.

Verification (all in one go)

  • make preflight on a clean feature branch: green, and prints the resolved check plan.
  • Introduce a purple color in a Swift file locally → make preflight fails on brand-ui (the check that today only CI catches). Same for a TODO without issue reference → deferred-work-markers fails. Revert.
  • Add a fake check_something.py invocation to a workflow YAML without registering it → test_run_checks.py fails naming it. Revert.
  • Remove a ci-laned entry from the manifest → drift guard fails. Revert.
  • scripts/pre-push (via .github/scripts/run-pre-push.sh) runs the manifest lane exactly once (singleflight state shows one execution; no duplicate arch-guardrails run).
  • repo-checks.yml passes on the PR itself, executing via the runner.
  • --list output identical for --lane ci on the PR's diff and what the CI log shows executed.

Out of scope

  • Migrating pre-push's non-diff-scoped sections (typecheck, OpenAPI sync, test selection) into the manifest.
  • Adding new checks (in-flight elsewhere; they should register in this manifest when they land — this issue defines where they go).
  • Any change to component test suites or release workflows.

Activity

  1. added a commit that references this issue on Jul 12, 2026
    f703329
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions