Skip to content

ci: approval-policy file and check (P10) - #215

Open
jarvis-drakon wants to merge 1 commit into
masterfrom
ci/approval-policy
Open

jarvis-drakon wants to merge 1 commit into
masterfrom
ci/approval-policy

Conversation

@jarvis-drakon

Copy link
Copy Markdown
Contributor

What this adds

An approval policy for this repo as a reviewable file, plus a dependency-free check that enforces it.
Owner-approved design (28 Nov 2026): an approval file in each repo plus a matching GitHub branch rule.

  • .github/approval-policy.yml: rules keyed on the paths, labels and title a PR touches. The strictest rule wins.
    • owner-only (prices, legal/terms/privacy text, licence, .env, labels owner-only/frozen/freeze/needs-michael, destructive migrations): only the owner's own GitHub APPROVE at the exact head clears it. The policy can never approve these.
    • rule-files (.github/, CODEOWNERS, CLAUDE.md, AGENTS.md, REVIEW.md, .claude/, .codex/, git hooks, other CI config): full review plus a FABLE GREEN-LIGHT at the head (review-protocol P5).
    • security (auth, sessions, crypto, signing, secrets, billing, payments, webhooks, plus repo-specific paths; label security/release; title release…/GHSA-): the full panel. No other rule can relax it.
    • migrations: the full panel, a MIGRATION GATE line at the head (tested downgrade, backward-compatible, backup id), per DECISIONS 2026-10-27 16:0xZ. A DROP, TRUNCATE or DELETE in the forward half is owner-only. A migration file whose patch the API omits is also treated as owner-only (fail closed).
    • dependencies and docs-tests: one reviewer plus green CI.
    • default: the existing lane rule (DECISIONS 2026-11-15 12:5xZ/13:0xZ seat counts).
  • .github/scripts/approval_policy_check.py: Python 3 standard library only. It posts the commit status approval-policy on the PR head. The status is green only when every matched rule is evidenced at the exact head and CI is green. It fails closed on an unparseable policy, unknown keys, an unclassified path, a truncated file list, any API error, or evidence that changed while it was being evaluated. It evaluates twice and posts only when both runs agree.
  • .github/workflows/approval-policy.yml: runs on pull_request_target, issue_comment, workflow_run, check_suite and workflow_dispatch. All of these run default-branch code. The workflow fetches the check and the policy from the default branch and never checks out or runs PR code, so a PR cannot change the rules it is judged by. It uses no third-party actions. Permissions: read, plus statuses: write.
  • .github/workflows/approval-policy-review-relay.yml: has no permissions. It turns formal review events into a workflow_run trigger, so a submitted or dismissed review re-runs the check without a PR-head workflow ever holding a write token.
  • .github/workflows/approval-policy-selftest.yml: runs the unit tests and validates this repo's policy when the check or the policy changes. It uses a read-only token.

Evidence formats (P10 in skills/fleet-doctrine/references/review-protocol.md): REVIEW head <sha> | <seat>: APPROVE …, FABLE GREEN-LIGHT head <sha> | decision: MERGE | ref: …, MIGRATION GATE head <sha> | downgrade: … | backward-compatible: yes | backup: …. A fleet account's formal APPROVE at the head, or its APPROVE at <sha> comment, fills one seat. Its CHANGES_REQUESTED blocks the PR until it is lifted. Only the logins listed in trusted count.

Notes

  • This PR adds the file, so it is not itself judged by the check: pull_request_target runs the base branch's workflows, and the base has none yet. It is a P5 rule-file PR: its own review plus a Fable decision.
  • After it merges, the first PR that runs the check proves it works.
  • The policy is a floor. Stricter lane rules, DECISIONS rows, freezes, room gates and migration windows still apply.

Evidence

  • Unit tests: python3 -B -m unittest test_approval_policy_check, run under scripts/hermetic_test.sh (empty env, throwaway HOME): Ran 22 tests … OK. That covers 77 fixture cases plus parser and glob tests.
  • The parser matches PyYAML: parse_yaml_subset(text) == yaml.safe_load(text) is True for all 7 generated policies.
  • A backtest replayed recent merged PRs against this policy (--backtest, no status posted). Results are listed per repo below.

Self-review (P1)

code-review at effort high was run on the branch before the first push. It found 8 issues (marked important) and 2 nits. All 10 were confirmed and fixed before this push:

  1. A negated verdict ("not approve") was read as APPROVE.
  2. An API error left an older green status in place.
  3. A stale workflow_run could overwrite a newer status (now evaluated twice and posted only when both agree; concurrency keyed on the PR).
  4. Formal reviews did not re-trigger the check (fixed with the review relay).
  5. A SQL -- down comment could hide a DROP.
  6. ekho's boot-time schema.ts was outside the migrations class.
  7. Fable decisions were prefix-matched.
  8. A fleet comment CHANGES_REQUESTED could never be lifted by a later APPROVE.
  9. (nit) Pending CI is now posted as pending, and check_suite was added as a trigger.
  10. (nit) The migration gate now rejects none and not tested.

Self-review: no findings rejected.

This repo

multi-clawd is public and has a default-branch ruleset, but adding approval-policy as a required check there was not part of the approved change. Until then, lanes enforce it (P10).

Backtest: recent merged PRs replayed against this policy (observe only; nothing posted)

Red rows show what the policy would have required. Most are rule-file PRs from before P5 (28 Nov), when no Fable line was needed, or PRs whose reviews were not posted on the PR.

Adds .github/approval-policy.yml and a dependency-free check that posts the commit status
approval-policy on each PR head. The check and the policy are read from the default branch only.
It is red unless every rule matched by the touched paths, labels or title is evidenced at the
exact head (panel seats, Fable decision for rule files, migration gate, owner approval for
owner-only paths) and CI is green. It fails closed on an unparseable policy or an unclassified path.
Owner-approved design, 28 Nov 2026 (review-protocol P10).
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