From d703bb248cfee0d526b83342b94fef53c19358f2 Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:25:22 -0500 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=92=20Protect=20bylaws=20with=20in?= =?UTF-8?q?dependent=20approval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Require review for changes to docs/bylaws.md alongside version archives. Keep the existing required status context while clarifying its descriptions. Co-authored-by: ChatGPT 6 --- .github/scripts/version-archive-review.cjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/scripts/version-archive-review.cjs b/.github/scripts/version-archive-review.cjs index 9dbace9..9624293 100644 --- a/.github/scripts/version-archive-review.cjs +++ b/.github/scripts/version-archive-review.cjs @@ -3,6 +3,7 @@ const STATUS_CONTEXT = 'version-archives'; const POLICY_PATHS = new Set([ '.github/version_protection.md', + 'docs/bylaws.md', '.github/workflows/version-archive-review.yml', '.github/workflows/version-archive-review-signal.yml', '.github/scripts/version-archive-review.cjs', @@ -68,10 +69,10 @@ async function run({ github, context, core, pull_number }) { if (files.length >= 3000) throw new Error('PR has 3000+ files; cannot verify complete changes'); const paths = protectedFiles(files); if (!paths.length) { - await status('success', 'No archive approval required'); + await status('success', 'No protected-file approval required'); return; } - await status('pending', 'Checking approvals for archived documentation changes'); + await status('pending', 'Checking approvals for protected documentation changes'); const reviews = await github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: prNumber, per_page: 100 }); @@ -83,14 +84,14 @@ async function run({ github, context, core, pull_number }) { if (['admin', 'write'].includes(data.permission)) eligible.push(reviewer); } if (eligible.length) { - await status('success', 'Archive changes approved by ' + eligible[0]); + await status('success', 'Protected changes approved by ' + eligible[0]); } else { - await status('failure', 'Archived documentation changes require approval'); + await status('failure', 'Protected documentation changes require approval'); core.setFailed('Changes to ' + paths.join(', ') + ' require a fresh APPROVED review from a different human with write/admin access on SHA ' + sha); } } catch (error) { - await status('failure', 'Unable to verify version archive approvals'); + await status('failure', 'Unable to verify protected-file approvals'); throw error; } } From 8f7b6fe68f482af2f765efb2dcd5c3f5c3c2c9ee Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:25:24 -0500 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=A7=AA=20Test=20bylaws=20approval=20c?= =?UTF-8?q?hecks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verify adds, edits, deletions, and renames for the bylaws path, including approval-required failures and valid independent human approvals. Co-authored-by: ChatGPT 6 --- .../scripts/version-archive-review.test.cjs | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/scripts/version-archive-review.test.cjs b/.github/scripts/version-archive-review.test.cjs index 5183931..45706a6 100644 --- a/.github/scripts/version-archive-review.test.cjs +++ b/.github/scripts/version-archive-review.test.cjs @@ -7,6 +7,8 @@ const { run, protectedFiles, approvedReviewers } = require('./version-archive-re test('detects all protected version paths and historic rename sources', () => { assert.deepEqual(protectedFiles([ { filename: 'docs/intro.md' }, + { filename: 'docs/bylaws.md' }, + { filename: 'docs/renamed-bylaws.md', previous_filename: 'docs/bylaws.md' }, { filename: 'versions/archive-0.1.0/intro.md' }, { filename: 'new/location.md', previous_filename: 'versions/archive-0.1.0/old.md' }, { filename: 'versions/sidebars/version-0.1.0.json' }, @@ -17,6 +19,7 @@ test('detects all protected version paths and historic rename sources', () => { '.github/scripts/version-archive-review.cjs', '.github/version_protection.md', '.github/workflows/version-archive-review.yml', + 'docs/bylaws.md', 'versions/archive-0.1.0/intro.md', 'versions/archive-0.1.0/old.md', 'versions/sidebars/version-0.1.0.json' @@ -24,6 +27,19 @@ test('detects all protected version paths and historic rename sources', () => { assert.deepEqual(protectedFiles([{ filename: 'docs/intro.md' }]), []); }); +test('protects bylaws additions, edits, deletions, and both rename directions', () => { + for (const file of [ + { filename: 'docs/bylaws.md', status: 'added' }, + { filename: 'docs/bylaws.md', status: 'modified' }, + { filename: 'docs/bylaws.md', status: 'removed' }, + { filename: 'docs/relocated.md', previous_filename: 'docs/bylaws.md', status: 'renamed' }, + { filename: 'docs/bylaws.md', previous_filename: 'docs/old.md', status: 'renamed' } + ]) { + assert.ok(protectedFiles([file]).includes('docs/bylaws.md')); + } + assert.deepEqual(protectedFiles([{ filename: 'docs/bylaws-notes.md' }]), []); +}); + test('only most recent independent human approval on exact head counts', () => { assert.deepEqual(approvedReviewers([ { id: 1, user: { login: 'author', type: 'User' }, state: 'APPROVED', commit_id: 'new' }, @@ -85,7 +101,8 @@ test('unrelated docs changes pass automatically without fetching reviews', async for (const filename of [ 'versions/archive-0.1.0/intro.md', 'versions/sidebars/version-0.1.0.json', '.github/scripts/version-archive-review.cjs', - '.github/version_protection.md' + '.github/version_protection.md', + 'docs/bylaws.md' ]) { test('unapproved protected change fails: ' + filename, async () => { const gh = fake({ files: [{ filename }] }); @@ -104,14 +121,16 @@ test('renaming a file out of versions still requires approval', async () => { assert.equal(errors.length, 1); }); -test('fresh independent contributor approval passes', async () => { - const gh = fake({ - files: [{ filename: 'versions/sidebars/version-0.1.0.json' }], - reviews: [{ id: 1, user: { login: 'reviewer', type: 'User' }, state: 'APPROVED', commit_id: 'head' }] +for (const filename of ['versions/sidebars/version-0.1.0.json', 'docs/bylaws.md']) { + test('fresh independent contributor approval passes: ' + filename, async () => { + const gh = fake({ + files: [{ filename }], + reviews: [{ id: 1, user: { login: 'reviewer', type: 'User' }, state: 'APPROVED', commit_id: 'head' }] + }); + await run({ github: gh, context, core: { setFailed: () => { throw new Error('unexpected'); } } }); + assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'success']); }); - await run({ github: gh, context, core: { setFailed: () => { throw new Error('unexpected'); } } }); - assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'success']); -}); +} test('stale review, bot review, self approval, or read-only reviewer fail', async () => { for (const [reviewer, permission] of [ From 4123e682fa15be1355fd40f7b888d90069197f14 Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Wed, 11 Nov 2026 13:25:26 -0500 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=96=8B=EF=B8=8F=20Document=20protecte?= =?UTF-8?q?d=20bylaws=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clarify that docs/bylaws.md is governed by the existing approval rule while other documentation remains unaffected. Co-authored-by: ChatGPT 6 --- .github/version_protection.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/version_protection.md b/.github/version_protection.md index 4bddc0b..9b91f21 100644 --- a/.github/version_protection.md +++ b/.github/version_protection.md @@ -11,6 +11,8 @@ The root manifest is ignored by Git. Do **not** create `versions/history.json`. Protected changes include: - All paths under `versions/`, including archived snapshots and sidebars. +- `docs/bylaws.md`, the governing bylaws path proposed in PR #56, including + additions, amendments, deletions, and renames to or from this path. - The version generation, staging and cleanup scripts under `scripts/`. - `package.json`, `.gitignore`, the version-protection policy, and the privileged verifier workflow and helper files to prevent unreviewed bypasses. @@ -45,7 +47,8 @@ create an active branch ruleset called **Version archive protection**: 4. Prohibit force pushes and deletions; do not configure bypass permissions. 5. Verify a test PR changing `versions/archive-0.1.0/` is blocked until another write/admin collaborator approves the current head SHA. - Confirm that a `docs/`-only PR passes without this approval. + Confirm that an unrelated `docs/`-only PR passes without this approval, + while a PR modifying `docs/bylaws.md` requires approval. After merging the workflow, open or update a PR to produce the first `version-archives` check if the ruleset UI does not yet list it. From cc4a3c6bbc372fa797978f96f3842c0e45be93ce Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Mon, 30 Nov 2026 13:59:47 -0500 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=94=92=20Separate=20bylaws=20approval?= =?UTF-8?q?=20from=20version=20archives?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore the existing archive policy and verifier unchanged. Add the independent bylaws-approval status, trusted workflow, review signal, admin-only review tests, and temporary account-bound amendment exception. Recheck open pull requests daily and on manual dispatch, and document the separate required ruleset activation after deployment. Co-authored-by: ChatGPT 6.2 --- .github/bylaws-protection.md | 44 +++++++ .github/scripts/bylaws-review.cjs | 103 ++++++++++++++++ .github/scripts/bylaws-review.test.cjs | 111 ++++++++++++++++++ .github/scripts/version-archive-review.cjs | 40 ++----- .../scripts/version-archive-review.test.cjs | 75 ++---------- .github/version_protection.md | 21 +--- .github/workflows/bylaws-review-signal.yml | 23 ++++ .github/workflows/bylaws-review.yml | 71 +++++++++++ .github/workflows/documentation-tests.yml | 2 + 9 files changed, 374 insertions(+), 116 deletions(-) create mode 100644 .github/bylaws-protection.md create mode 100644 .github/scripts/bylaws-review.cjs create mode 100644 .github/scripts/bylaws-review.test.cjs create mode 100644 .github/workflows/bylaws-review-signal.yml create mode 100644 .github/workflows/bylaws-review.yml diff --git a/.github/bylaws-protection.md b/.github/bylaws-protection.md new file mode 100644 index 0000000..eb57ab8 --- /dev/null +++ b/.github/bylaws-protection.md @@ -0,0 +1,44 @@ +# Bylaws approval policy + +The independent `bylaws-approval` commit status protects `docs/bylaws.md` +(including additions, amendments, removals, and both rename directions) +and this policy, its verifier, its review signal, and its regression tests. + +A protected change on a PR targeting main requires an explicit APPROVED +review of the current head SHA by a different human with repository admin +permission. Write access alone, stale reviews, self approvals, bots, and +dismissed or superseded approvals do not qualify. Unrelated changes +automatically receive a successful bylaws status. API failures fail closed. + +## Temporary exception + +Until December 31, 2026, at 00:00 UTC, a PR authored by the human GitHub +account `JFWooten4` (ID `60260750`) can pass without independent approval +if the author retains admin permission and the PR only modifies +`docs/bylaws.md`. Additions, deletions, renames, verifier changes, and mixed +PRs are excluded. This is a repository review exception, not a substitute +for any legally required governance action. + +The cutoff applies at verification time. The trusted workflow rechecks open +PRs daily at 00:07 UTC and can be dispatched manually from main. GitHub +may delay scheduled execution; an already successful status is not +automatically revoked at the exact cutoff. Recheck outstanding exempt PRs +at expiration and remove the transition exception when no longer needed. + +## Separate required check + +After this workflow is merged to main, run Bylaws review against open PRs +to establish the new commit status. In repository settings, create an active +branch ruleset targeting the default branch that requires the exact status +context `bylaws-approval` with no bypass actors. Keep the existing +`version-archives` required status and archive policy unchanged. +Do not make this new status required before the trusted workflow is deployed. + +The workflows check out trusted main only. Review events trigger a separate +unprivileged signal that passes only a validated decimal PR number. +The privileged verifier fetches changed paths, reviews, and permissions +through the GitHub API. Never execute PR-controlled code with status-write +permissions. The archive verifier remains independent; a mixed PR must +satisfy both checks when applicable. + +Run `node --test .github/scripts/bylaws-review.test.cjs` for regression tests. diff --git a/.github/scripts/bylaws-review.cjs b/.github/scripts/bylaws-review.cjs new file mode 100644 index 0000000..a2747f9 --- /dev/null +++ b/.github/scripts/bylaws-review.cjs @@ -0,0 +1,103 @@ +'use strict'; + +const STATUS_CONTEXT = 'bylaws-approval'; +const BYLAWS_PATH = 'docs/bylaws.md'; +// Temporary transition exception; remove after bylaws governance is established. +const BYLAWS_EXCEPTION_UNTIL = Date.parse('2026-12-31T00:00:00Z'); +const POLICY_PATHS = new Set([ + BYLAWS_PATH, + '.github/bylaws-protection.md', + '.github/workflows/bylaws-review.yml', + '.github/workflows/bylaws-review-signal.yml', + '.github/scripts/bylaws-review.cjs', + '.github/scripts/bylaws-review.test.cjs' +]); + +function protectedFiles(files) { + const matches = new Set(); + for (const file of files) { + for (const path of [file.filename, file.previous_filename]) { + if (POLICY_PATHS.has(path)) matches.add(path); + } + } + return [...matches].sort(); +} + +function approvedReviewers(reviews, headSha, author) { + const decisions = new Map(); + for (const review of [...reviews].sort((a, b) => a.id - b.id)) { + const login = review.user?.login; + if (!login || login.toLowerCase() === author.toLowerCase()) continue; + if (['APPROVED', 'CHANGES_REQUESTED', 'DISMISSED'].includes(review.state)) { + decisions.set(login.toLowerCase(), review); + } + } + return [...decisions.values()].filter(review => + review.state === 'APPROVED' && review.commit_id === headSha && + review.user.type === 'User' && !review.user.login.endsWith('[bot]') + ).map(review => review.user.login); +} + +function temporaryBylawsException(pr, files, now) { + return now < BYLAWS_EXCEPTION_UNTIL && + pr.user?.id === 60260750 && + pr.user?.login?.toLowerCase() === 'jfwooten4' && + pr.user?.type === 'User' && + files.length === 1 && + files[0].filename === BYLAWS_PATH && + files[0].status === 'modified' && + !files[0].previous_filename; +} + +async function run({ github, context, core, pull_number, now = Date.now() }) { + const { owner, repo } = context.repo; + const prNumber = pull_number || context.payload.pull_request?.number; + if (!prNumber) throw new Error('No PR associated with event'); + const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: prNumber }); + if (pr.base.ref !== 'main' || pr.state === 'closed') return; + const sha = pr.head.sha; + async function status(state, description) { + await github.rest.repos.createCommitStatus({ + owner, repo, sha, context: STATUS_CONTEXT, state, + description: description.slice(0, 140), + target_url: context.serverUrl + '/' + owner + '/' + repo + '/actions/runs/' + context.runId + }); + } + async function isAdmin(username) { + const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username }); + return data.permission === 'admin'; + } + try { + const files = await github.paginate(github.rest.pulls.listFiles, { + owner, repo, pull_number: prNumber, per_page: 100 + }); + if (files.length >= 3000) throw new Error('PR has 3000+ files; cannot verify complete changes'); + const paths = protectedFiles(files); + if (!paths.length) { + await status('success', 'No bylaws approval required'); + return; + } + await status('pending', 'Checking bylaws approval'); + if (temporaryBylawsException(pr, files, now) && await isAdmin(pr.user.login)) { + await status('success', 'Temporary JFWooten4 bylaws amendment exception'); + return; + } + const reviews = await github.paginate(github.rest.pulls.listReviews, { + owner, repo, pull_number: prNumber, per_page: 100 + }); + for (const reviewer of approvedReviewers(reviews, sha, pr.user.login)) { + if (await isAdmin(reviewer)) { + await status('success', 'Bylaws changes approved by ' + reviewer); + return; + } + } + await status('failure', 'Bylaws changes require admin approval'); + core.setFailed('Changes to ' + paths.join(', ') + + ' require a fresh APPROVED review from a different human with admin access on SHA ' + sha); + } catch (error) { + await status('failure', 'Unable to verify bylaws approvals'); + throw error; + } +} + +module.exports = { run, protectedFiles, approvedReviewers }; diff --git a/.github/scripts/bylaws-review.test.cjs b/.github/scripts/bylaws-review.test.cjs new file mode 100644 index 0000000..3c9043d --- /dev/null +++ b/.github/scripts/bylaws-review.test.cjs @@ -0,0 +1,111 @@ +'use strict'; + +const { test } = require('node:test'); +const assert = require('node:assert/strict'); +const { run, protectedFiles } = require('./bylaws-review.cjs'); + +const author = { id: 100, login: 'author', type: 'User' }; +const exceptionAuthor = { id: 60260750, login: 'JFWooten4', type: 'User' }; +const amendment = { filename: 'docs/bylaws.md', status: 'modified' }; +const beforeExpiry = Date.parse('2026-12-30T23:59:59Z'); +const atExpiry = Date.parse('2026-12-31T00:00:00Z'); +const context = { repo: { owner: 'blocktransfer', repo: 'org-docs' }, + payload: { pull_request: { number: 1 } }, serverUrl: 'https://github.com', runId: 10 }; +const approval = { id: 1, user: { login: 'reviewer', type: 'User' }, state: 'APPROVED', commit_id: 'head' }; + +function fake({ files = [amendment], reviews = [], permission = 'admin', + prAuthor = author, throwFiles = false, throwPermissions = false } = {}) { + const statuses = [], failures = []; + const github = { rest: { + pulls: { + get: async () => ({ data: { state: 'open', base: { ref: 'main' }, head: { sha: 'head' }, user: prAuthor } }), + listFiles() {}, listReviews() {} + }, + repos: { + createCommitStatus: async item => { statuses.push(item); }, + getCollaboratorPermissionLevel: async () => { + if (throwPermissions) throw new Error('permission API failed'); + return { data: { permission } }; + } + } + }}; + github.paginate = async method => { + if (method === github.rest.pulls.listFiles) { + if (throwFiles) throw new Error('files API failed'); + return files; + } + return reviews; + }; + return { github, statuses, failures, core: { setFailed: error => failures.push(error) } }; +} +async function check(options, expected, now = beforeExpiry) { + const f = fake(options); + await run({ github: f.github, core: f.core, context, now }); + assert.equal(f.statuses.at(-1).state, expected); + assert.ok(f.statuses.every(s => s.context === 'bylaws-approval' && s.sha === 'head')); + assert.equal(f.failures.length, expected === 'failure' ? 1 : 0); + return f; +} + +test('ordinary docs and archive changes do not require bylaws approval', async () => { + await check({ files: [{ filename: 'docs/intro.md' }, { filename: 'versions/archive-0.1.0/bylaws.md' }] }, 'success'); +}); +test('bylaws path and both rename directions are protected', () => { + for (const file of [ + { filename: 'docs/bylaws.md', status: 'added' }, amendment, + { filename: 'docs/bylaws.md', status: 'removed' }, + { filename: 'docs/relocated.md', previous_filename: 'docs/bylaws.md' }, + { filename: 'docs/bylaws.md', previous_filename: 'docs/old.md' } + ]) assert.deepEqual(protectedFiles([file]), ['docs/bylaws.md']); +}); +test('the bylaws verifier and policy protect themselves', async () => { + for (const filename of [ + '.github/bylaws-protection.md', '.github/workflows/bylaws-review.yml', + '.github/workflows/bylaws-review-signal.yml', '.github/scripts/bylaws-review.cjs', + '.github/scripts/bylaws-review.test.cjs' + ]) await check({ files: [{ filename }] }, 'failure'); +}); +test('independent current-head admin approval passes', async () => { + await check({ reviews: [approval] }, 'success'); +}); +for (const [label, options] of [ + ['missing review', {}], + ['write permission', { reviews: [approval], permission: 'write' }], + ['read permission', { reviews: [approval], permission: 'read' }], + ['self approval', { reviews: [{ ...approval, user: author }] }], + ['bot approval', { reviews: [{ ...approval, user: { login: 'bot[bot]', type: 'Bot' } }] }], + ['stale approval', { reviews: [{ ...approval, commit_id: 'old' }] }], + ['dismissed approval', { reviews: [approval, { ...approval, id: 2, state: 'DISMISSED' }] }], + ['changes requested', { reviews: [approval, { ...approval, id: 2, state: 'CHANGES_REQUESTED' }] }] +]) test('rejects ' + label, async () => { await check(options, 'failure'); }); + +test('temporary exception permits the designated admin to amend only the bylaws', async () => { + const f = await check({ prAuthor: exceptionAuthor }, 'success'); + assert.match(f.statuses.at(-1).description, /Temporary JFWooten4/); +}); +for (const [label, options, now = beforeExpiry] of [ + ['different account', { prAuthor: { ...exceptionAuthor, id: 101 } }], + ['non-admin author', { permission: 'write' }], + ['bot author', { prAuthor: { ...exceptionAuthor, type: 'Bot' } }], + ['expiration', {}, atExpiry], + ['deletion', { files: [{ ...amendment, status: 'removed' }] }], + ['addition', { files: [{ ...amendment, status: 'added' }] }], + ['rename', { files: [{ ...amendment, status: 'renamed', previous_filename: 'docs/old.md' }] }], + ['mixed archive changes', { files: [amendment, { filename: 'versions/archive-0.1.0/bylaws.md' }] }], + ['policy changes', { files: [{ filename: '.github/bylaws-protection.md' }] }], + ['mixed ordinary changes', { files: [amendment, { filename: 'docs/intro.md' }] }] +]) test('temporary exception rejects ' + label, async () => { + await check({ prAuthor: exceptionAuthor, ...options }, 'failure', now); +}); + +test('API errors and incomplete changed-file listings fail closed', async () => { + for (const [options, error] of [ + [{ throwFiles: true }, /files API failed/], + [{ reviews: [approval], throwPermissions: true }, /permission API failed/], + [{ files: Array.from({ length: 3000 }, (_, i) => ({ filename: 'docs/' + i })) }, /3000/] + ]) { + const f = fake(options); + await assert.rejects(run({ github: f.github, core: f.core, context }), error); + assert.equal(f.statuses.at(-1).state, 'failure'); + } +}); diff --git a/.github/scripts/version-archive-review.cjs b/.github/scripts/version-archive-review.cjs index 20a609d..0607c34 100644 --- a/.github/scripts/version-archive-review.cjs +++ b/.github/scripts/version-archive-review.cjs @@ -1,12 +1,8 @@ 'use strict'; const STATUS_CONTEXT = 'version-archives'; -const BYLAWS_PATH = 'docs/bylaws.md'; -// Temporary transition exception; remove after bylaws governance is established. -const BYLAWS_EXCEPTION_UNTIL = Date.parse('2026-12-31T00:00:00Z'); const POLICY_PATHS = new Set([ '.github/version_protection.md', - BYLAWS_PATH, '.github/workflows/version-archive-review.yml', '.github/workflows/version-archive-review-signal.yml', '.github/scripts/version-archive-review.cjs', @@ -158,18 +154,7 @@ function approvedReviewers(reviews, headSha, author) { ).map(review => review.user.login); } -function temporaryBylawsException(pr, files, now) { - return now < BYLAWS_EXCEPTION_UNTIL && - pr.user?.id === 60260750 && - pr.user?.login?.toLowerCase() === 'jfwooten4' && - pr.user?.type === 'User' && - files.length === 1 && - files[0].filename === BYLAWS_PATH && - files[0].status === 'modified' && - !files[0].previous_filename; -} - -async function run({ github, context, core, pull_number, now = Date.now() }) { +async function run({ github, context, core, pull_number }) { const { owner, repo } = context.repo; const prNumber = pull_number || context.payload.pull_request?.number; if (!prNumber) throw new Error('No PR associated with event'); @@ -190,23 +175,14 @@ async function run({ github, context, core, pull_number, now = Date.now() }) { if (files.length >= 3000) throw new Error('PR has 3000+ files; cannot verify complete changes'); const paths = protectedFiles(files); if (!paths.length) { - await status('success', 'No protected-file approval required'); + await status('success', 'No archive approval required'); return; } - await status('pending', 'Checking archive integrity and protected-file approvals'); + await status('pending', 'Checking archive integrity and approvals'); if (await exactNewArchive({ github, owner, repo, pr, files })) { await status('success', 'New archive exactly matches current documentation and sidebar'); return; } - if (temporaryBylawsException(pr, files, now)) { - const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ - owner, repo, username: pr.user.login - }); - if (data.permission === 'admin') { - await status('success', 'Temporary JFWooten4 bylaws amendment exception'); - return; - } - } const reviews = await github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: prNumber, per_page: 100 }); @@ -215,17 +191,17 @@ async function run({ github, context, core, pull_number, now = Date.now() }) { const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username: reviewer }); - if (data.permission === 'admin') eligible.push(reviewer); + if (['admin', 'write'].includes(data.permission)) eligible.push(reviewer); } if (eligible.length) { - await status('success', 'Protected changes approved by ' + eligible[0]); + await status('success', 'Archive changes approved by ' + eligible[0]); } else { - await status('failure', 'Protected documentation changes require admin approval'); + await status('failure', 'Archived documentation changes require approval'); core.setFailed('Changes to ' + paths.join(', ') + - ' require a fresh APPROVED review from a different human with admin access on SHA ' + sha); + ' require a fresh APPROVED review from a different human with write/admin access on SHA ' + sha); } } catch (error) { - await status('failure', 'Unable to verify protected-file approvals'); + await status('failure', 'Unable to verify version archive approvals'); throw error; } } diff --git a/.github/scripts/version-archive-review.test.cjs b/.github/scripts/version-archive-review.test.cjs index a8e8212..66f9af8 100644 --- a/.github/scripts/version-archive-review.test.cjs +++ b/.github/scripts/version-archive-review.test.cjs @@ -35,7 +35,7 @@ test('only most recent independent human approval on exact head counts', () => { ], 'new', 'author'), ['real']); }); -function fake({ files = [], reviews = [], permission = 'admin', author = { login: 'author', type: 'User' }, throwFiles = false, throwPermissions = false } = {}) { +function fake({ files = [], reviews = [], permission = 'write', throwFiles = false, throwPermissions = false } = {}) { const statuses = []; const gh = { statuses, @@ -45,7 +45,7 @@ function fake({ files = [], reviews = [], permission = 'admin', author = { login state: 'open', base: { ref: 'main' }, head: { sha: 'head' }, - user: author + user: { login: 'author' } }}), listFiles() {}, listReviews() {} }, @@ -85,8 +85,7 @@ test('unrelated docs changes pass automatically without fetching reviews', async for (const filename of [ 'versions/archive-0.1.0/intro.md', 'versions/sidebars/version-0.1.0.json', '.github/scripts/version-archive-review.cjs', - '.github/version_protection.md', - 'docs/bylaws.md' + '.github/version_protection.md' ]) { test('unapproved protected change fails: ' + filename, async () => { const gh = fake({ files: [{ filename }] }); @@ -105,7 +104,7 @@ test('renaming a file out of versions still requires approval', async () => { assert.equal(errors.length, 1); }); -test('fresh independent admin approval passes', async () => { +test('fresh independent contributor approval passes', async () => { const gh = fake({ files: [{ filename: 'versions/sidebars/version-0.1.0.json' }], reviews: [{ id: 1, user: { login: 'reviewer', type: 'User' }, state: 'APPROVED', commit_id: 'head' }] @@ -114,13 +113,12 @@ test('fresh independent admin approval passes', async () => { assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'success']); }); -test('stale review, bot review, self approval, or non-admin reviewer fail', async () => { +test('stale review, bot review, self approval, or read-only reviewer fail', async () => { for (const [reviewer, permission] of [ - [{ id: 1, user: { login: 'author', type: 'User' }, state: 'APPROVED', commit_id: 'head' }, 'admin'], - [{ id: 1, user: { login: 'other', type: 'User' }, state: 'APPROVED', commit_id: 'old' }, 'admin'], + [{ id: 1, user: { login: 'author', type: 'User' }, state: 'APPROVED', commit_id: 'head' }, 'write'], + [{ id: 1, user: { login: 'other', type: 'User' }, state: 'APPROVED', commit_id: 'old' }, 'write'], [{ id: 1, user: { login: 'foo[bot]', type: 'Bot' }, state: 'APPROVED', commit_id: 'head' }, 'admin'], - [{ id: 1, user: { login: 'other', type: 'User' }, state: 'APPROVED', commit_id: 'head' }, 'read'], - [{ id: 1, user: { login: 'other', type: 'User' }, state: 'APPROVED', commit_id: 'head' }, 'write'] + [{ id: 1, user: { login: 'other', type: 'User' }, state: 'APPROVED', commit_id: 'head' }, 'read'] ]) { const gh = fake({ files: [{ filename: 'versions/sidebars/version-0.1.0.json' }], reviews: [reviewer], permission }); const failures = []; @@ -250,60 +248,3 @@ test('new snapshot Git API failure fails closed', async () => { await assert.rejects(run({ github: f.github, context, core: { setFailed() {} } }), /Incomplete Git tree/); assert.equal(f.github.statuses.at(-1).state, 'failure'); }); - -test('bylaws protection includes additions, amendments, deletions, and both rename directions', () => { - for (const file of [ - { filename: 'docs/bylaws.md', status: 'added' }, - { filename: 'docs/bylaws.md', status: 'modified' }, - { filename: 'docs/bylaws.md', status: 'removed' }, - { filename: 'docs/relocated.md', previous_filename: 'docs/bylaws.md', status: 'renamed' }, - { filename: 'docs/bylaws.md', previous_filename: 'docs/old.md', status: 'renamed' } - ]) { - assert.deepEqual(protectedFiles([file]), ['docs/bylaws.md']); - } - assert.deepEqual(protectedFiles([{ filename: 'docs/bylaws-notes.md' }]), []); -}); - -test('fresh independent admin approval qualifies for a bylaws amendment', async () => { - const gh = fake({ - files: [{ filename: 'docs/bylaws.md', status: 'modified' }], - reviews: [{ id: 1, user: { login: 'reviewer', type: 'User' }, state: 'APPROVED', commit_id: 'head' }] - }); - await run({ github: gh, context, core: { setFailed: () => { throw new Error('unexpected'); } } }); - assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'success']); -}); - -const exceptionAuthor = { id: 60260750, login: 'JFWooten4', type: 'User' }; -const beforeExpiry = Date.parse('2026-12-30T23:59:59Z'); -const atExpiry = Date.parse('2026-12-31T00:00:00Z'); -const amendment = { filename: 'docs/bylaws.md', status: 'modified' }; - -test('temporary exception permits only the designated admin author to amend the bylaws', async () => { - const gh = fake({ author: exceptionAuthor, files: [amendment] }); - await run({ github: gh, context, now: beforeExpiry, core: { setFailed: () => { throw new Error('unexpected'); } } }); - assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'success']); - assert.match(gh.statuses.at(-1).description, /Temporary JFWooten4/); -}); - -for (const [label, options, now = beforeExpiry] of [ - ['different author', { author: { id: 123, login: 'other', type: 'User' } }], - ['same login but different account', { author: { ...exceptionAuthor, id: 123 } }], - ['non-admin author', { permission: 'write' }], - ['bot author', { author: { ...exceptionAuthor, type: 'Bot' } }], - ['expired exception', {}, atExpiry], - ['bylaws deletion', { files: [{ ...amendment, status: 'removed' }] }], - ['bylaws addition', { files: [{ ...amendment, status: 'added' }] }], - ['bylaws rename', { files: [{ ...amendment, status: 'renamed', previous_filename: 'docs/old.md' }] }], - ['archive changes', { files: [{ filename: 'versions/archive-0.2.0/intro.md', status: 'modified' }] }], - ['policy changes', { files: [{ filename: '.github/scripts/version-archive-review.cjs', status: 'modified' }] }], - ['mixed protected changes', { files: [amendment, { filename: '.github/version_protection.md', status: 'modified' }] }], - ['mixed ordinary changes', { files: [amendment, { filename: 'docs/intro.md', status: 'modified' }] }] -]) { - test('temporary exception rejects ' + label, async () => { - const gh = fake({ author: exceptionAuthor, files: [amendment], ...options }); - const failures = []; - await run({ github: gh, context, now, core: { setFailed: x => failures.push(x) } }); - assert.deepEqual(gh.statuses.map(x => x.state), ['pending', 'failure']); - assert.equal(failures.length, 1); - }); -} diff --git a/.github/version_protection.md b/.github/version_protection.md index 9db2ac7..7850a3b 100644 --- a/.github/version_protection.md +++ b/.github/version_protection.md @@ -11,8 +11,6 @@ The root manifest is ignored by Git. Do **not** create `versions/history.json`. Protected changes include: - All paths under `versions/`, including archived snapshots and sidebars. -- `docs/bylaws.md`, including additions, amendments, deletions, and renames - to or from this path. - The version generation, staging and cleanup scripts under `scripts/`. - `package.json`, `.gitignore`, the version-protection policy, and the privileged verifier workflow and helper files to prevent unreviewed bypasses. @@ -27,19 +25,10 @@ qualify for the exemption. Any other PR targeting main that modifies a protected path (including removals and old names of renamed files) requires an explicit APPROVED review of -the PR's **current head commit** from another human with admin -permission on this repository. A stale, self, bot, dismissed, or non-admin +the PR's **current head commit** from another human with write/admin +permission on this repository. A stale, self, bot, dismissed, or read-only review does not qualify. -Temporary exception: until December 31, 2026, at 00:00 UTC, the verifier -may pass a PR authored by GitHub account `JFWooten4` (ID `60260750`) without -an independent review if the author still has admin permission and the only -changed file is an amendment to `docs/bylaws.md`. This does not exempt -additions, deletions, renames, archives, verifier changes, or mixed PRs. -The cutoff applies when the check runs; recheck any outstanding exempt PRs -at expiry to invalidate previously recorded successful statuses. Remove this -transition exception when it is no longer needed. - Other PRs automatically receive a passing `version-archives` status without any approval requirement. GitHub API failures fail closed. @@ -63,10 +52,8 @@ create an active branch ruleset called **Version archive protection**: for this SEC-publications-style implementation. 4. Prohibit force pushes and deletions; do not configure bypass permissions. 5. Verify a test PR changing `versions/archive-0.1.0/` is blocked until - another admin collaborator approves the current head SHA. - Confirm that ordinary `docs/` changes and an exact new archive pass without - this approval, while bylaws changes require approval unless the temporary - exception applies. + another write/admin collaborator approves the current head SHA. + Confirm that a `docs/`-only PR and an exact new archive pass without this approval. After merging the workflow, open or update a PR to produce the first `version-archives` check if the ruleset UI does not yet list it. diff --git a/.github/workflows/bylaws-review-signal.yml b/.github/workflows/bylaws-review-signal.yml new file mode 100644 index 0000000..fd2adf8 --- /dev/null +++ b/.github/workflows/bylaws-review-signal.yml @@ -0,0 +1,23 @@ +name: Bylaws review signal + +on: + pull_request_review: + types: [submitted, dismissed, edited] + +# Review workflows can be changed by a contributor's PR; NEVER give this write access. +permissions: + contents: read + +jobs: + signal: + runs-on: ubuntu-latest + steps: + - name: Record PR number as untrusted data + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: printf '%s\n' "$PR_NUMBER" > pr-number.txt + - uses: actions/upload-artifact@v4 + with: + name: bylaws-review-pr + path: pr-number.txt + retention-days: 1 diff --git a/.github/workflows/bylaws-review.yml b/.github/workflows/bylaws-review.yml new file mode 100644 index 0000000..f9c7f80 --- /dev/null +++ b/.github/workflows/bylaws-review.yml @@ -0,0 +1,71 @@ +name: Bylaws review + +on: + pull_request_target: + branches: [main] + types: [opened, reopened, synchronize, ready_for_review, edited] + schedule: + - cron: '7 0 * * *' + workflow_dispatch: + workflow_run: + workflows: [Bylaws review signal] + types: [completed] + +permissions: + contents: read + pull-requests: read + actions: read + statuses: write + +jobs: + verify-bylaws: + if: github.event_name != 'workflow_run' || (github.event.workflow_run.event == 'pull_request_review' && github.event.workflow_run.conclusion == 'success') + runs-on: ubuntu-latest + steps: + # The workflow and checked-out code both originate from trusted main. + - uses: actions/checkout@v4 + with: + ref: main + persist-credentials: false + - uses: actions/github-script@v7 + with: + script: | + const { run } = require('./.github/scripts/bylaws-review.cjs'); + let pull_number = context.payload.pull_request?.number; + if (context.eventName === 'workflow_run') { + // The artifact is untrusted: extract ONLY a decimal PR number. + const { owner, repo } = context.repo; + const run_id = context.payload.workflow_run.id; + const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, { + owner, repo, run_id, per_page: 100 + }); + const artifact = artifacts.find(a => a.name === 'bylaws-review-pr' && !a.expired); + if (!artifact) throw new Error('Review signal artifact is missing'); + const response = await github.rest.actions.downloadArtifact({ + owner, repo, artifact_id: artifact.id, archive_format: 'zip' + }); + const fs = require('node:fs'); + const cp = require('node:child_process'); + const filename = process.env.RUNNER_TEMP + '/review-signal.zip'; + fs.writeFileSync(filename, Buffer.from(response.data)); + const text = cp.execFileSync('unzip', ['-p', filename, 'pr-number.txt'], { + encoding: 'utf8', maxBuffer: 1024 + }).trim(); + if (!/^[1-9][0-9]{0,8}$/.test(text)) throw new Error('Invalid review signal PR number'); + pull_number = Number(text); + } + if (context.eventName === 'schedule' || context.eventName === 'workflow_dispatch') { + const { owner, repo } = context.repo; + const prs = await github.paginate(github.rest.pulls.list, { + owner, repo, state: 'open', base: 'main', per_page: 100 + }); + for (const pr of prs) { + try { + await run({ github, context, core, pull_number: pr.number }); + } catch (error) { + core.setFailed('PR #' + pr.number + ': ' + error.message); + } + } + } else { + await run({ github, context, core, pull_number }); + } diff --git a/.github/workflows/documentation-tests.yml b/.github/workflows/documentation-tests.yml index e5163fc..ccac1c5 100644 --- a/.github/workflows/documentation-tests.yml +++ b/.github/workflows/documentation-tests.yml @@ -23,6 +23,8 @@ jobs: run: node --test .github/scripts/section-sidebars.test.cjs - name: Test archive approval policy run: node --test .github/scripts/version-archive-review.test.cjs + - name: Test bylaws approval policy + run: node --test .github/scripts/bylaws-review.test.cjs - name: Test historical asset link handling run: node --test .github/scripts/remark-archived-assets.test.cjs - name: Test 404 history links From b63feca4b975457a540e35047958a33ca26a4f08 Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:00:23 -0500 Subject: [PATCH 5/7] =?UTF-8?q?=F0=9F=97=9C=EF=B8=8F=20Inline=20stable=20b?= =?UTF-8?q?ylaws=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the redundant global path constant and use the stable literal directly in the protected paths and temporary exception check. Co-authored-by: ChatGPT 6.2 --- .github/scripts/bylaws-review.cjs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/scripts/bylaws-review.cjs b/.github/scripts/bylaws-review.cjs index a2747f9..d84d9b0 100644 --- a/.github/scripts/bylaws-review.cjs +++ b/.github/scripts/bylaws-review.cjs @@ -1,11 +1,10 @@ 'use strict'; const STATUS_CONTEXT = 'bylaws-approval'; -const BYLAWS_PATH = 'docs/bylaws.md'; // Temporary transition exception; remove after bylaws governance is established. const BYLAWS_EXCEPTION_UNTIL = Date.parse('2026-12-31T00:00:00Z'); const POLICY_PATHS = new Set([ - BYLAWS_PATH, + 'docs/bylaws.md', '.github/bylaws-protection.md', '.github/workflows/bylaws-review.yml', '.github/workflows/bylaws-review-signal.yml', @@ -44,7 +43,7 @@ function temporaryBylawsException(pr, files, now) { pr.user?.login?.toLowerCase() === 'jfwooten4' && pr.user?.type === 'User' && files.length === 1 && - files[0].filename === BYLAWS_PATH && + files[0].filename === 'docs/bylaws.md' && files[0].status === 'modified' && !files[0].previous_filename; } From 774ce81c7ca1538a6e9cea36896ca7b9948413ed Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:02:12 -0500 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=97=9C=EF=B8=8F=20Use=20bylaws-specif?= =?UTF-8?q?ic=20verifier=20naming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename protectedFiles to bylawsProtectedFiles throughout the independent bylaws verifier and its regression tests, without changing the archive verifier or approval behavior. Co-authored-by: ChatGPT 6.2 --- .github/scripts/bylaws-review.cjs | 6 +++--- .github/scripts/bylaws-review.test.cjs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/scripts/bylaws-review.cjs b/.github/scripts/bylaws-review.cjs index d84d9b0..483984a 100644 --- a/.github/scripts/bylaws-review.cjs +++ b/.github/scripts/bylaws-review.cjs @@ -12,7 +12,7 @@ const POLICY_PATHS = new Set([ '.github/scripts/bylaws-review.test.cjs' ]); -function protectedFiles(files) { +function bylawsProtectedFiles(files) { const matches = new Set(); for (const file of files) { for (const path of [file.filename, file.previous_filename]) { @@ -71,7 +71,7 @@ async function run({ github, context, core, pull_number, now = Date.now() }) { owner, repo, pull_number: prNumber, per_page: 100 }); if (files.length >= 3000) throw new Error('PR has 3000+ files; cannot verify complete changes'); - const paths = protectedFiles(files); + const paths = bylawsProtectedFiles(files); if (!paths.length) { await status('success', 'No bylaws approval required'); return; @@ -99,4 +99,4 @@ async function run({ github, context, core, pull_number, now = Date.now() }) { } } -module.exports = { run, protectedFiles, approvedReviewers }; +module.exports = { run, bylawsProtectedFiles, approvedReviewers }; diff --git a/.github/scripts/bylaws-review.test.cjs b/.github/scripts/bylaws-review.test.cjs index 3c9043d..6db9106 100644 --- a/.github/scripts/bylaws-review.test.cjs +++ b/.github/scripts/bylaws-review.test.cjs @@ -2,7 +2,7 @@ const { test } = require('node:test'); const assert = require('node:assert/strict'); -const { run, protectedFiles } = require('./bylaws-review.cjs'); +const { run, bylawsProtectedFiles } = require('./bylaws-review.cjs'); const author = { id: 100, login: 'author', type: 'User' }; const exceptionAuthor = { id: 60260750, login: 'JFWooten4', type: 'User' }; @@ -56,7 +56,7 @@ test('bylaws path and both rename directions are protected', () => { { filename: 'docs/bylaws.md', status: 'removed' }, { filename: 'docs/relocated.md', previous_filename: 'docs/bylaws.md' }, { filename: 'docs/bylaws.md', previous_filename: 'docs/old.md' } - ]) assert.deepEqual(protectedFiles([file]), ['docs/bylaws.md']); + ]) assert.deepEqual(bylawsProtectedFiles([file]), ['docs/bylaws.md']); }); test('the bylaws verifier and policy protect themselves', async () => { for (const filename of [ From 599f75c9d07edc7feb8c0ebf05eaed1d31dd70c5 Mon Sep 17 00:00:00 2001 From: John Wooten <60260750+JFWooten4@users.noreply.github.com> Date: Mon, 30 Nov 2026 14:05:09 -0500 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=96=8B=EF=B8=8F=20Remove=20redundant?= =?UTF-8?q?=20bylaws=20deployment=20instructions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep the bylaws approval policy and temporary exception without the separate required-check setup and implementation notes. Co-authored-by: ChatGPT 6.2 --- .github/bylaws-protection.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/bylaws-protection.md b/.github/bylaws-protection.md index eb57ab8..de3e9ad 100644 --- a/.github/bylaws-protection.md +++ b/.github/bylaws-protection.md @@ -24,21 +24,3 @@ PRs daily at 00:07 UTC and can be dispatched manually from main. GitHub may delay scheduled execution; an already successful status is not automatically revoked at the exact cutoff. Recheck outstanding exempt PRs at expiration and remove the transition exception when no longer needed. - -## Separate required check - -After this workflow is merged to main, run Bylaws review against open PRs -to establish the new commit status. In repository settings, create an active -branch ruleset targeting the default branch that requires the exact status -context `bylaws-approval` with no bypass actors. Keep the existing -`version-archives` required status and archive policy unchanged. -Do not make this new status required before the trusted workflow is deployed. - -The workflows check out trusted main only. Review events trigger a separate -unprivileged signal that passes only a validated decimal PR number. -The privileged verifier fetches changed paths, reviews, and permissions -through the GitHub API. Never execute PR-controlled code with status-write -permissions. The archive verifier remains independent; a mixed PR must -satisfy both checks when applicable. - -Run `node --test .github/scripts/bylaws-review.test.cjs` for regression tests.