Repository navigation
Description
Problem
Deterministic checks are declared in three places that have already drifted apart:
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.scripts/pr-preflight→.github/scripts/pr_preflight.pyruns a different set viaselect_checks(): diff-hygiene, architecture-guardrails, product-invariants, desktop-changelog, e2e flow coverage.- CI workflow YAMLs hardcode a third set:
repo-checks.ymlrunscheck_brand_ui.py,check_product_invariants.py,deferred-work-marker-count.py,check_arch_guardrails.py,pr_preflight.py;backend-checks.ymlrunsscan_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-pushScope 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'striggers, runs matching checks, streams output, exits non-zero if any fail.--lane local|cifilters by lane.--listprints 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'scilane. Keeppr_preflight.pyas the entry point CI already calls — least workflow churn.scripts/pre-push: add a single step that invokesrun_checks.py --lane local --base <merge-base>(through the existingpreflight_runner.pysingleflight, 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 callingrun_checks.py --lane ci --base "$GITHUB_BASE_REF". Keep separate steps only where the workflow needs distinct artifacts/permissions.
- Add
make preflight(rootMakefiletarget) →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/*.ymlfor 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 explicitexempt: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 therun_checks.pycall) — assertrepo-checks.ymlinvokes 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: "Runmake preflightbefore 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 preflighton a clean feature branch: green, and prints the resolved check plan. - Introduce a purple color in a Swift file locally →
make preflightfails onbrand-ui(the check that today only CI catches). Same for a TODO without issue reference →deferred-work-markersfails. Revert. - Add a fake
check_something.pyinvocation to a workflow YAML without registering it →test_run_checks.pyfails 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.ymlpasses on the PR itself, executing via the runner. -
--listoutput identical for--lane cion 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
ci: unify deterministic checks behind manifest (#9458)