Repository navigation
ci: enforce PMC vote on format-spec changes via CI gate - #7399
Conversation
82c8775 to
9e23be5
Compare
|
Important This PR touches the Lance format specification. Substantive changes to the format specification — the If this is a meaningful format change:
|
There was a problem hiding this comment.
Gate recommendation: request changes. The enforcement problem is real and a repository-local gate is a reasonable low-cost solution, but this revision does not yet provide a trustworthy authority boundary. Scope and waiver decisions must use trusted, revision-bound evidence; review-triggered code must execute from the base revision; and reevaluation errors must fail closed. A dedicated App is stronger but carries higher operational cost.
| issue = self.repo.get_issue(number) | ||
| facts = self.timeline_facts(issue) | ||
|
|
||
| if WAIVED_LABEL in labels and facts.waived: |
There was a problem hiding this comment.
The waiver is not bound to the revision it authorized. After a PMC member waives a typo, format-waived and the historical label event survive a later substantive push, so the new head succeeds without votes. Bind the waiver to the exact head/diff fingerprint and latest authorized transition, and invalidate it on synchronization.
Reproducer
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import sys
from datetime import datetime, timezone
sys.path.insert(0, 'ci')
from format_vote_gate import Gate
class Label:
def __init__(self, name): self.name = name
class Commit:
def __init__(self): self.statuses = []
def create_status(self, **status): self.statuses.append(status)
class Pull:
state = 'open'; draft = False
created_at = datetime(2026, 1, 1, tzinfo=timezone.utc)
labels = [Label('format-change'), Label('format-waived')]
head = type('Head', (), {'sha': 'new-head-after-substantive-push'})()
class Event:
event = 'labeled'; label = Label('format-waived')
actor = type('Actor', (), {'login': 'alice'})()
created_at = datetime(2026, 1, 1, tzinfo=timezone.utc)
class Issue:
def get_events(self): return [Event()]
class Repo:
def __init__(self): self.commit = Commit()
def get_pull(self, number): return Pull()
def get_issue(self, number): return Issue()
def get_commit(self, sha): return self.commit
repo = Repo()
Gate(repo, {'alice'}, 'run-url').evaluate(7399)
observed = repo.commit.statuses[-1]['state']
print(f'observed status on new head with historical waiver: {observed}')
assert observed != 'success', 'a waiver for an earlier revision must not authorize a new substantive head'
PYExpected: the new head needs a new waiver or vote. Observed: success and the assertion fails.
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout base | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
There was a problem hiding this comment.
This checkout is not pinned to the trusted base SHA. For pull_request_review, the event-default ref is the PR merge ref, so a same-repository PR can alter the gate script or PMC roster that this write-capable job executes. Pin PR events to ${{ github.event.pull_request.base.sha }} (with a trusted default for scheduled runs).
The GitHub-hosted ref transition cannot be executed locally; this bounded configuration regression was run against the head:
python3 - <<'PY'
from pathlib import Path
workflow = Path('.github/workflows/format-vote-gate.yml').read_text().splitlines()
assert any(line.strip() == 'pull_request_review:' for line in workflow)
checkout = next(i for i, line in enumerate(workflow) if 'uses: actions/checkout@' in line)
step = workflow[checkout:]
next_step = next((i for i, line in enumerate(step[1:], 1) if line.startswith(' - ')), len(step))
assert any(line.strip().startswith('ref:') for line in step[:next_step]), 'review-triggered checkout is not pinned to the trusted base revision'
PYExpected: an explicit trusted ref. Observed: the assertion fails.
| print(f"Scheduled sweep: {len(pulls)} open {FORMAT_LABEL} PR(s).") | ||
| for pr in pulls: | ||
| try: | ||
| gate.evaluate(pr.number) |
There was a problem hiding this comment.
A reevaluation error leaves any prior format-spec-vote success on the same SHA intact, and this catch makes the scheduled run succeed. A new veto or roster change can therefore fail to reconcile while the merge-authorizing status stays green. Publish a pending/error status before fallible reads and a non-success status on evaluation failure.
Reproducer
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import sys
sys.path.insert(0, 'ci')
from format_vote_gate import Gate
class Label:
def __init__(self, name): self.name = name
class Commit:
def __init__(self): self.statuses = [{'state': 'success'}]
def create_status(self, **status): self.statuses.append(status)
class Pull:
state = 'open'; draft = False
labels = [Label('format-change')]
head = type('Head', (), {'sha': 'same-head'})()
class Repo:
def __init__(self): self.commit = Commit()
def get_pull(self, number): return Pull()
def get_issue(self, number): raise RuntimeError('simulated timeline API outage')
def get_commit(self, sha): return self.commit
repo = Repo()
try:
Gate(repo, {'alice'}, 'run-url').evaluate(7399)
except RuntimeError as error:
print(error)
observed = repo.commit.statuses[-1]['state']
print(f'observed status after reevaluation failure: {observed}')
assert observed != 'success', 'a failed reevaluation must not preserve a merge-authorizing success'
PYExpected: reevaluation failure cannot retain success. Observed: success and the assertion fails.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Format-specification changes (the `.proto` definitions and `docs/src/format/**`) require 3 binding +1 votes from PMC members, but nothing structurally enforced it — the requirement was only a reminder comment, caught socially if at all. This adds a CI gate that blocks merging a format-spec change until it has the required votes. A touched PR is labelled `format-change` and the gate publishes a `format-spec-vote` commit status that stays red until: - 3 PMC members have approved the PR (excluding the author), counted only on the latest commit so new pushes invalidate stale approvals; - no PMC member has an outstanding "Request changes" review (a veto); and - the 1-week voting period (from when the label was first applied) has elapsed. The gate posts a live tally comment and runs on PR events, review events, and an 8-hourly cron (so the voting-period clock is re-checked even when no event fires). It uses pull_request_target to label/status fork PRs but never checks out or runs PR code. A PMC member can waive a trivial edit by removing the `format-change` label. The PMC roster moves to `docs/src/community/pmc.yaml` as the source of truth; `ci/sync_pmc_docs.py` regenerates the table in pmc.md (checked in docs-check), and the gate reads the roster from the base checkout so a PR cannot enlarge the electorate. The old reminder-only job is removed. To activate, add `format-spec-vote` as a required status check on protected branches. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Responds to PR review feedback: - Rewrite the gate in Python (PyGithub) instead of JS, for readability — most maintainers are more familiar with Python. - Apply the `format-change` label via the existing path labeler (.github/labeler-area.yml) instead of the gate. The gate now reads the label and leaves PRs without it alone, posting only a passing status (so the required check never blocks non-format PRs). Trivial edits are waived with a `format-waived` label applied by a PMC member. - Render the PMC roster table at docs build time via an MkDocs hook (docs/hooks/pmc_roster.py) instead of a committed table kept in sync by a script; pmc.yaml stays the source of truth. Drops ci/sync_pmc_docs.py. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Adopts part 3 of lance-format#7112, which was deferred pending the vote gate: the PR is now the canonical venue for a format-specification proposal, not a GitHub Discussion. `voting.md` and `contributing.md` say so, and both add the rule that a format PR should carry only the spec change plus the minimum library edits needed to compile — the implementation belongs in follow-up PRs, so voters can read the contract without an ordinary code review being dragged through a voting period. The voting period drops from 1 week to 72 hours, with weekends excluded so a proposal opened on a Friday afternoon still gets three working days of attention. Weekend boundaries are fixed in UTC (no DST to reason about, and no member's local zone defines when everyone's clock pauses); the gate's PR comment states the exact closing time in both UTC and Pacific. The clock now starts when the PR is both labeled and marked ready for review, rather than at labeling alone, so time spent drafting doesn't count against the period. The gate stays quiet on drafts: no vote is open to comment on. The cron sweep moves to hourly to match the finer deadline. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
9e23be5 to
2f3dced
Compare
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
The in-repository gate accepted in Discussion #7112 is a viable direction, but this head still leaves five independent ways for mutable, stale, or untrusted state to authorize merge. Four previously reported authority-boundary failures remain; the resolved label-scope thread is re-projected on the current diff, and the stale-evaluation race is newly verified.
A viable revision should make evaluation a single trusted, revision-bound, fail-closed path with freshness or serialization across every status writer.
| labels = {label.name for label in pr.labels} | ||
|
|
||
| # Non-format PRs get a passing status and are otherwise left alone. | ||
| if FORMAT_LABEL not in labels: |
There was a problem hiding this comment.
The earlier scope finding still reproduces on this head: this branch emits success solely from the mutable format-change label. A label-capable non-PMC can remove it after the last synchronization event and bypass the required vote. Derive scope from the complete current PR file list on every evaluation, including pagination, deletions, and renames; keep the label informational.
Reproducer
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import sys
sys.path.insert(0, 'ci')
from format_vote_gate import Gate
class Commit:
def __init__(self): self.statuses = []
def create_status(self, **status): self.statuses.append(status)
class Pull:
state = 'open'
draft = False
labels = []
head = type('Head', (), {'sha': 'head'})()
class Repo:
def __init__(self): self.commit = Commit()
def get_pull(self, number): return Pull()
def get_commit(self, sha): return self.commit
repo = Repo()
Gate(repo, {'alice', 'bob', 'carol'}, 'run-url').evaluate(7399)
observed = repo.commit.statuses[-1]['state']
print(f'observed status after format-change label removal: {observed}')
assert observed != 'success', 'a format PR must not pass merely because its scope label was removed'
PYExpected: label removal cannot authorize a format PR. Observed: success; the assertion failed.
There was a problem hiding this comment.
It's intentional that maintainers can edit those labels. We trust them to exercise judgement. If they show they can't be trusted, the PMC can always remove them.
But also keep in mind, the format-change label isn't not at all perfect. It misses some things that might be format changes, and it captures some things that just aren't meaningful changes. Given that, we don't need to take the safety of this label too seriously. It will always require judgement.
There was a problem hiding this comment.
The documented contract says format-spec PRs require PMC votes and provides format-waived specifically for a PMC to exercise trivial-change judgment. Letting any label-capable maintainer instead remove format-change transfers that waiver authority outside the PMC and turns the claimed enforcement back into convention, so this authority finding remains.
| - cron: "0 * * * *" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} |
There was a problem hiding this comment.
Scheduled sweeps and PR/review events use different concurrency groups because a schedule falls back to the unique run_id. They can therefore evaluate the same PR concurrently; since reviews are snapshotted before the status write and there is no freshness check, an older schedule can overwrite a newer veto with success. Put every writer behind one per-PR generation/serialization boundary so stale evaluations cannot publish an authorizing status.
Reproducer
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import sys
from datetime import datetime, timezone
from types import SimpleNamespace as O
sys.path.insert(0, 'ci')
from format_vote_gate import Gate
class Comment:
def __init__(self, body): self.body = body
def edit(self, body): self.body = body
class Issue:
def __init__(self): self.comments = []
def get_events(self):
return [O(event='labeled', label=O(name='format-change'),
actor=O(login='maintainer'),
created_at=datetime(2026, 1, 1, tzinfo=timezone.utc))]
def get_comments(self): return self.comments
def create_comment(self, body): self.comments.append(Comment(body))
class Pull:
state = 'open'; draft = False
created_at = datetime(2026, 1, 1, tzinfo=timezone.utc)
labels = [O(name='format-change')]
head = O(sha='same-head'); user = O(login='author')
def __init__(self, repo): self.repo = repo
def get_reviews(self):
rows = [O(user=O(login=x), state='APPROVED', commit_id='same-head')
for x in ('alice', 'bob', 'carol')]
if self.repo.phase == 'fresh':
rows.append(O(user=O(login='dave'), state='CHANGES_REQUESTED',
commit_id='same-head'))
return rows
class Commit:
def __init__(self, repo): self.repo = repo
def create_status(self, **status):
if self.repo.phase == 'stale' and not self.repo.interleaved:
self.repo.interleaved = True
self.repo.phase = 'fresh'
Gate(self.repo, self.repo.pmc, 'fresh-event').evaluate(1)
self.repo.phase = 'stale'
self.repo.states.append(status['state'])
class Repo:
pmc = {'alice', 'bob', 'carol', 'dave'}
def __init__(self):
self.phase = 'stale'; self.interleaved = False; self.states = []
self.issue = Issue(); self.pull = Pull(self); self.commit = Commit(self)
def get_pull(self, number): return self.pull
def get_issue(self, number): return self.issue
def get_commit(self, sha): return self.commit
repo = Repo()
Gate(repo, repo.pmc, 'older-schedule').evaluate(1)
print(repo.states)
assert repo.states[-1] != 'success', 'newer veto must remain authoritative'
PYExpected final status: failure. Observed: ['failure', 'success']; the assertion failed because the stale schedule won.
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
The in-repository gate accepted in Discussion #7112 is a viable direction, but this head still leaves six independent ways for mutable, stale, or untrusted state to authorize merge. The five current authority and freshness findings remain, and the login-only PMC identity model adds a sixth authorization failure.
A viable revision should make evaluation a single trusted, revision-bound, fail-closed path with durable voter identity and freshness or serialization across every status writer.
| self.run_url = run_url | ||
|
|
||
| def is_pmc(self, login): | ||
| return login is not None and login.lower() in self.pmc |
There was a problem hiding this comment.
PMC authority is bound only to mutable login strings. GitHub documents that after an account changes its username, the old username becomes available for anyone else to claim; a different account can therefore inherit approval and waiver authority from this roster. Store immutable GitHub user IDs in the protected roster and compare review.user.id and timeline actor.id; keep handles only for display.
Reproducer
PYTHONDONTWRITEBYTECODE=1 python3 - <<'PY'
import sys
sys.path.insert(0, 'ci')
from format_vote_gate import tally_reviews
pmc = {'retired-handle'}
reviews = [{
'login': 'retired-handle',
'user_id': 999, # a different account that later claimed the old login
'state': 'APPROVED',
'commit_id': 'head',
}]
approvals, _, _ = tally_reviews(
reviews, 'head', 'author', lambda login: login.lower() in pmc
)
print(approvals)
assert approvals == [], 'a different account must not inherit PMC authority'
PYExpected: the different account is rejected. Observed: ['retired-handle']; the assertion failed because account identity is never carried into the tally.
There was a problem hiding this comment.
I think you are taking the security here much too seriously. There's still human review, and attention paid to changes. We can always revert changes that should not have gone through.
There was a problem hiding this comment.
This is the PMC authorization boundary the gate claims to enforce: human attention and a post-merge revert do not establish that the approving or waiving account is a PMC member. Because the code grants binding vote authority to any future claimant of a retired handle, the finding remains.
There was a problem hiding this comment.
I believe it is ok to waive this finding.
There was a problem hiding this comment.
Waiving this would let a non-PMC account receive binding vote or waiver authority after claiming a retired PMC handle. That crosses the PMC authorization boundary this gate exists to enforce, so the finding remains.
| @@ -0,0 +1,153 @@ | |||
| """Unit tests for the format-spec vote gate logic. | |||
There was a problem hiding this comment.
Does any CI job actually run these unit tests? Is this something that needs to be checked in?
There was a problem hiding this comment.
I don't think they are run. I'm fine removing them.
There was a problem hiding this comment.
Actually, they do run in CI. There is a ci-scripts.yml workflow that they are part of. So let's keep them.
| # Adding or removing a member is itself a PMC vote (roster change). After the | ||
| # vote passes, edit this file; the docs table updates automatically. |
There was a problem hiding this comment.
Heh, if PMC votes weren't private we could just add pmc.yaml to the format vote gate and make the changes to this file be the vote 😛
| Discussion happens as review comments on the PR, so reviewers can respond to | ||
| specific lines of the specification. Open the PR as a draft while it is still | ||
| taking shape; the voting period starts when you mark it ready for review. |
There was a problem hiding this comment.
Users can still open general discussion about a potential change if they want to correct?
There was a problem hiding this comment.
They can. I don't like discussions personally, but they are always free to create a discussion as well. Or a google doc or similar.
|
FYI, it looks like the job is currently failing due to 403: https://github.com/lance-format/lance/actions/runs/33172657935/job/98853353865?pr=7399 |
A workflow run triggered by a fork PR's review event receives a read-only GITHUB_TOKEN regardless of the workflow's `permissions` block, so the gate could not post its commit status and failed with 403 "Resource not accessible by integration" on every review. Format proposals from non-committers are exactly the fork-PR case. Drop the trigger and let the schedule sweep observe votes instead, tightened from hourly to every 15 minutes since it is now the only path that sees a review. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The gate now observes votes only on its 15-minute sweep, so a PMC member who has just approved may see a stale tally. Add a workflow_dispatch trigger with an optional PR number (blank sweeps every open format-change PR), and link the dispatch page from the gate's PR comment and the job log. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Implements the accepted parts of #7112: the pull request becomes the canonical venue for a Lance format-specification proposal, and the required PMC vote is enforced by a CI gate instead of by convention.
Governance changes
voting.mdandcontributing.mdare updated to say so. Cast +1 by approving, −1 by requesting changes. Discussions remain the venue for release votes and general design proposals; migrating the existing format discussions is follow-up work.docs/src/format/) plus only the library edits needed to keep the build green, with the implementation in follow-up PRs. The same rule is added toprotos/AGENTS.mdanddocs/src/format/AGENTS.mdso coding agents follow it. Rationale in the docs: voters need to read the contract, and an ordinary code review shouldn't be dragged through a 72-hour voting period.How the gate works
The path labeler (
.github/labeler-area.yml) appliesformat-changeto PRs touchingprotos/**/*.protoordocs/src/format/**. The gate (ci/format_vote_gate.py, run byformat-vote-gate.yml) reads that label and publishes aformat-spec-votecommit status that stays red until all hold:format-changefirst applied, PR marked ready for review), with Saturday and Sunday UTC not counting.It posts/updates a single live-tally comment carrying the exact deadline, and runs on PR events (including
ready_for_review/converted_to_draft) and a 15-minutecron. The cron has no PR context, so it sweeps every openformat-changePR — this is what observes approvals and re-checks the clock when no PR event fires.There is deliberately no
pull_request_reviewtrigger: a run triggered by a fork PR's review event gets a read-onlyGITHUB_TOKENregardless of the workflow'spermissionsblock, so it cannot post the status (403Resource not accessible by integration). Format proposals from non-committers are exactly the fork-PR case, so reviews are picked up by the sweep instead. The tally therefore trails a review by up to 15 minutes, which is immaterial against a 72-hour period; a voter who doesn't want to wait can trigger the gate from its Run workflow button (workflow_dispatch, optional PR number — blank re-checks every open format PR), which the gate's own comment links to. It usespull_request_targetso it can status/comment fork PRs, but never checks out or runs PR code: it reads the trusted base checkout and the API only.PRs without the label are left alone: the gate posts only a passing
format-spec-votestatus (so the required check never blocks unrelated PRs) and does nothing else. A PMC member waives a trivial edit (typo, wording, formatting) with theformat-waivedlabel.PMC roster
docs/src/community/pmc.yamlis the source of truth. The roster table inpmc.mdis rendered at docs build time by an MkDocs hook (docs/hooks/pmc_roster.py), and the gate reads the roster from the base checkout so a PR can't enlarge the electorate by editing it.Tests
ci/test_format_vote_gate.py(pytest, run byci-scripts.yml) covers the pure logic: vote counting (latest-review-wins, stale-approval filtering, author/non-PMC/dismissed exclusion, verdict priority) and the deadline arithmetic (weekend exclusion from either side of a boundary, multi-weekend spans, non-UTC start zones, and when the clock does and doesn't open).Activation (after merge)
format-waivedlabel (format-changealready exists) so PMC members can pick it in the UI.format-spec-voteas a required status check on protected branches (main+ release branches). It's posted on every PR — success immediately for non-format PRs — so it never leaves a required check pending.Note
The gate does not run on this PR itself:
pull_request_targetandscheduleboth resolve the workflow from the base branch, which doesn't yet contain it. Soformat-spec-voteis absent here rather than green — don't make the check required until this is merged.🤖 Generated with Claude Code