From 9024b601b312964f8bccbd8c7ecb8ce1dd61d647 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Wed, 28 Oct 2026 11:36:34 -0500 Subject: [PATCH 01/19] chore: configure ANS organization management Signed-off-by: Connor Snitker --- .github/CODEOWNERS | 2 + .github/ISSUE_TEMPLATE/bug.yml | 17 + .github/ISSUE_TEMPLATE/change.yml | 16 + .github/dependabot.yml | 12 + .../workflows/contribution-policy-local.yml | 14 + .github/workflows/contribution-policy.yml | 49 ++ .github/workflows/manage-repository.yml | 104 +++ .github/workflows/org-management.yml | 93 +++ .github/workflows/validate-org-config.yml | 25 + .gitignore | 7 + CODE_OF_CONDUCT.md | 9 + CONTRIBUTING.md | 30 + GITHUB_APP_SETUP.md | 95 +++ LICENSE | 10 + LICENSES/Apache-2.0.txt | 73 +++ LICENSES/CC-BY-4.0.txt | 395 +++++++++++ MAINTAINERS.md | 19 + README.md | 102 +++ SECURITY.md | 12 + SETUP_CHECKLIST.md | 75 +++ package-lock.json | 261 ++++++++ package.json | 8 + safe-settings/deployment-settings.yml | 6 + safe-settings/repos/.github.yml | 33 + safe-settings/settings.yml | 14 + safe-settings/suborgs/defaults.yml | 44 ++ scripts/config.mjs | 142 ++++ scripts/github.mjs | 70 ++ scripts/manage-repository.mjs | 387 +++++++++++ scripts/rosters.mjs | 121 ++++ scripts/sync-rosters.mjs | 247 +++++++ scripts/validate.mjs | 128 ++++ tests/manage.test.mjs | 397 ++++++++++++ tests/rosters.test.mjs | 611 ++++++++++++++++++ tests/sdk-pagination.test.mjs | 53 ++ tests/test_contribution_policy.py | 45 ++ .../ans-contribution-policy.properties.json | 5 + .../ans-contribution-policy.yml | 19 + 38 files changed, 3750 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug.yml create mode 100644 .github/ISSUE_TEMPLATE/change.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/contribution-policy-local.yml create mode 100644 .github/workflows/contribution-policy.yml create mode 100644 .github/workflows/manage-repository.yml create mode 100644 .github/workflows/org-management.yml create mode 100644 .github/workflows/validate-org-config.yml create mode 100644 .gitignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 GITHUB_APP_SETUP.md create mode 100644 LICENSE create mode 100644 LICENSES/Apache-2.0.txt create mode 100644 LICENSES/CC-BY-4.0.txt create mode 100644 MAINTAINERS.md create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 SETUP_CHECKLIST.md create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 safe-settings/deployment-settings.yml create mode 100644 safe-settings/repos/.github.yml create mode 100644 safe-settings/settings.yml create mode 100644 safe-settings/suborgs/defaults.yml create mode 100644 scripts/config.mjs create mode 100644 scripts/github.mjs create mode 100644 scripts/manage-repository.mjs create mode 100644 scripts/rosters.mjs create mode 100644 scripts/sync-rosters.mjs create mode 100644 scripts/validate.mjs create mode 100644 tests/manage.test.mjs create mode 100644 tests/rosters.test.mjs create mode 100644 tests/sdk-pagination.test.mjs create mode 100644 tests/test_contribution_policy.py create mode 100644 workflow-templates/ans-contribution-policy.properties.json create mode 100644 workflow-templates/ans-contribution-policy.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..f0d722d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# Create this team with Write access before enabling required Code Owner review. +* @agentnameservice/tsc-owners diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..62edd45 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,17 @@ +name: Bug report +description: Report a reproducible problem. Use private vulnerability reporting for security issues. +body: + - type: textarea + id: problem + attributes: + label: What happened? + description: Include the affected version and the behavior you expected. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: How can we reproduce it? + description: Provide a minimal example with credentials and personal information removed. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/change.yml b/.github/ISSUE_TEMPLATE/change.yml new file mode 100644 index 0000000..f93d01f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/change.yml @@ -0,0 +1,16 @@ +name: Change request +description: Discuss a change before opening a pull request. +body: + - type: textarea + id: problem + attributes: + label: What problem should this solve? + validations: + required: true + - type: textarea + id: proposal + attributes: + label: What change do you suggest? + description: Describe the behavior and any alternatives. Formal proposals follow the governance repository's proposal process. + validations: + required: true diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..65ba876 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 diff --git a/.github/workflows/contribution-policy-local.yml b/.github/workflows/contribution-policy-local.yml new file mode 100644 index 0000000..6dae576 --- /dev/null +++ b/.github/workflows/contribution-policy-local.yml @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 +name: Check contribution metadata + +on: + pull_request: + types: [opened, edited, synchronize, reopened, labeled, unlabeled, ready_for_review] + merge_group: + +permissions: + contents: read + +jobs: + contribution: + uses: ./.github/workflows/contribution-policy.yml diff --git a/.github/workflows/contribution-policy.yml b/.github/workflows/contribution-policy.yml new file mode 100644 index 0000000..2565ebc --- /dev/null +++ b/.github/workflows/contribution-policy.yml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: Apache-2.0 +name: Contribution policy + +on: + workflow_call: + inputs: + specification: + description: Require exactly one of editorial or normative on specification PRs + type: boolean + default: false + +permissions: + contents: read + +jobs: + metadata: + name: Contribution policy + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + # No checkout and no interpolation of contributor-controlled text into shell code. + - name: Check PR metadata + env: + SPECIFICATION_REPOSITORY: ${{ inputs.specification }} + run: | + python3 - <<'PY' + import json, os, re, sys + with open(os.environ['GITHUB_EVENT_PATH']) as handle: + event = json.load(handle) + pr = event.get('pull_request') + if pr is None: + if os.environ['GITHUB_EVENT_NAME'] == 'merge_group': + print('PR metadata was checked before queue entry; merge groups have no PR metadata.') + sys.exit(0) + raise SystemExit('This workflow requires pull_request or merge_group.') + errors = [] + if not re.match(r'^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert|spec)(\([^\r\n()]+\))?!?: \S', pr['title']): + errors.append('Use a Conventional Commit PR title, such as docs: explain the setup.') + body = re.sub(r'', '', pr.get('body') or '') + if not re.search(r'\b(?:fix(?:es|ed)?|close[sd]?|resolve[sd]?)\s+(?:#\d+|[\w.-]+/[\w.-]+#\d+|https://github\.com/[\w.-]+/[\w.-]+/issues/\d+)\b', body, re.I): + errors.append('Link a real issue using Fixes, Closes, or Resolves.') + if os.environ['SPECIFICATION_REPOSITORY'] == 'true': + labels = {label['name'] for label in pr.get('labels', [])} + if len(labels & {'editorial', 'normative'}) != 1: + errors.append('Apply exactly one specification label: editorial or normative.') + for error in errors: + print(error) + sys.exit(bool(errors)) + PY diff --git a/.github/workflows/manage-repository.yml b/.github/workflows/manage-repository.yml new file mode 100644 index 0000000..bc16a3d --- /dev/null +++ b/.github/workflows/manage-repository.yml @@ -0,0 +1,104 @@ +# SPDX-License-Identifier: Apache-2.0 +name: Manage repository + +on: + workflow_dispatch: + inputs: + operation: + description: Inspect settings, prepare a configuration PR, or pause management + type: choice + options: [Inspect repository, Enroll or update, Pause management] + default: Inspect repository + repository: + description: Repository name within agentnameservice + type: string + required: true + required_checks: + description: Optional CI check names separated by semicolons; blank keeps/imports existing requirements + type: string + bootstrap_access: + description: Keep tsc-owners approval and merge access during setup; new repositories start enabled + type: choice + options: [Keep current, Enable, Remove] + default: Keep current + issue: + description: Issue number in .github for this change (not needed for Inspect) + type: string + signoff: + description: Your own Full Name , published in the commit (not needed for Inspect) + type: string + certify_dco: + description: I certify the DCO and authorize my supplied sign-off on this configuration change + type: boolean + default: false + +permissions: + contents: read + +concurrency: + group: repository-request-${{ inputs.repository }} + cancel-in-progress: false + +jobs: + request: + if: >- + github.repository == 'agentnameservice/.github' && + github.ref == 'refs/heads/main' && + vars.ORG_MANAGEMENT_ENABLED == 'true' + runs-on: ubuntu-latest + timeout-minutes: 15 + environment: org-management + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '24' + - run: npm ci --ignore-scripts --no-audit --no-fund + - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + id: read + with: + client-id: ${{ vars.ORG_APP_CLIENT_ID }} + private-key: ${{ secrets.ORG_APP_PRIVATE_KEY }} + owner: agentnameservice + permission-administration: read + permission-contents: read + permission-members: read + permission-checks: read + permission-statuses: read + permission-pull-requests: read + permission-issues: read + - name: Inspect and prepare the request + id: prepare + env: + GH_TOKEN: ${{ steps.read.outputs.token }} + REQUESTER: ${{ github.triggering_actor }} + run: node scripts/manage-repository.mjs + - name: Validate generated configuration + if: steps.prepare.outputs.changed == 'true' + run: npm run validate + - name: Create a token limited to configuration PRs + if: steps.prepare.outputs.changed == 'true' + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + id: write + with: + client-id: ${{ vars.ORG_APP_CLIENT_ID }} + private-key: ${{ secrets.ORG_APP_PRIVATE_KEY }} + owner: agentnameservice + repositories: .github + permission-contents: write + permission-pull-requests: write + - name: Open or update the configuration PR + if: steps.prepare.outputs.changed == 'true' + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + token: ${{ steps.write.outputs.token }} + base: main + branch: ${{ steps.prepare.outputs.branch }} + title: ${{ steps.prepare.outputs.title }} + body-path: reports/request.md + author: ${{ steps.prepare.outputs.author }} + commit-message: ${{ steps.prepare.outputs.commit_message }} + signoff: false + add-paths: safe-settings/ diff --git a/.github/workflows/org-management.yml b/.github/workflows/org-management.yml new file mode 100644 index 0000000..14d531b --- /dev/null +++ b/.github/workflows/org-management.yml @@ -0,0 +1,93 @@ +# SPDX-License-Identifier: Apache-2.0 +name: Organization management + +on: + workflow_dispatch: + inputs: + mode: + description: Preview changes or apply the reviewed configuration + type: choice + options: [preview, apply] + default: preview + push: + branches: [main] + schedule: + - cron: '23 */6 * * *' + +permissions: + contents: read + +concurrency: + group: organization-management + cancel-in-progress: false + +jobs: + synchronize: + if: >- + github.repository == 'agentnameservice/.github' && + github.ref == 'refs/heads/main' && + vars.ORG_MANAGEMENT_ENABLED == 'true' + environment: org-management + runs-on: ubuntu-latest + timeout-minutes: 30 + env: + APPLY: ${{ (github.event_name == 'workflow_dispatch' && inputs.mode == 'apply') || (github.event_name != 'workflow_dispatch' && vars.ORG_AUTO_APPLY == 'true') }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '24' + - run: npm ci --ignore-scripts --no-audit --no-fund + - run: npm run validate + - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + id: token + with: + client-id: ${{ vars.ORG_APP_CLIENT_ID }} + private-key: ${{ secrets.ORG_APP_PRIVATE_KEY }} + owner: agentnameservice + permission-administration: ${{ env.APPLY == 'true' && 'write' || 'read' }} + permission-members: ${{ env.APPLY == 'true' && 'write' || 'read' }} + permission-contents: read + - name: Verify manual apply requester + if: github.event_name == 'workflow_dispatch' && env.APPLY == 'true' + env: + GH_TOKEN: ${{ steps.token.outputs.token }} + REQUESTER: ${{ github.triggering_actor }} + run: node --input-type=module -e "import {github,owner} from './scripts/github.mjs'; await owner(github(),process.env.REQUESTER)" + - name: Prepare roster teams before resolving rule exceptions + id: teams + env: + GH_TOKEN: ${{ steps.token.outputs.token }} + REQUESTER: ${{ github.triggering_actor }} + GRANT_ACCESS: 'false' + run: node scripts/sync-rosters.mjs + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: github-community-projects/safe-settings + ref: a9a1f366ad6a738b55682d346d94f8d6c4893b09 # 3.0.0 + path: .safe-settings + persist-credentials: false + - run: npm ci --ignore-scripts --omit=dev --no-audit --no-fund + working-directory: .safe-settings + - name: Run the documented Safe Settings synchronizer + id: settings + working-directory: .safe-settings + env: + GH_ORG: agentnameservice + ADMIN_REPO: .github + CONFIG_PATH: safe-settings + DEPLOYMENT_CONFIG_FILE: ${{ github.workspace }}/safe-settings/deployment-settings.yml + APP_ID: ${{ vars.ORG_APP_ID }} + PRIVATE_KEY: ${{ secrets.ORG_APP_PRIVATE_KEY }} + FULL_SYNC_NOP: ${{ env.APPLY != 'true' }} + CREATE_PR_COMMENT: 'false' + CREATE_ERROR_ISSUE: 'false' + run: npm run full-sync + - name: Grant repository access after protections succeed + id: grants + env: + GH_TOKEN: ${{ steps.token.outputs.token }} + REQUESTER: ${{ github.triggering_actor }} + run: node scripts/sync-rosters.mjs diff --git a/.github/workflows/validate-org-config.yml b/.github/workflows/validate-org-config.yml new file mode 100644 index 0000000..2f90491 --- /dev/null +++ b/.github/workflows/validate-org-config.yml @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: Apache-2.0 +name: Validate organization configuration +on: + pull_request: + push: + branches: [main] + merge_group: +permissions: + contents: read +jobs: + validate: + name: Validate organization configuration + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '24' + - run: npm ci --ignore-scripts --no-audit --no-fund + - run: npm run validate + - run: npm test + - run: python3 -m unittest discover -s tests -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f33f3f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +__pycache__/ +*.pyc +reports/ +.safe-settings/ +.venv/ +.DS_Store +node_modules/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9701aa6 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,9 @@ +# Code of conduct + +ANS follows the [LF Projects Code of Conduct](https://lfprojects.org/policies/code-of-conduct/). +It applies to participation in the project's repositories and community spaces. + +Report conduct concerns confidentially to the Manager of LF Projects at +[manager@lfprojects.org](mailto:manager@lfprojects.org). Include what happened, +when and where, and relevant supporting information. Do not publish sensitive +reports in a GitHub issue. The linked policy describes the reporting process. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4c468d2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# Contributing to ANS + +These guidelines apply across `agentnameservice`. Read the affected repository's +README for its build and test commands and its `MAINTAINERS.md` for reviewers. +Repository-specific contribution instructions may add requirements. + +## Pull requests + +Open a tracking issue and reference it with a closing keyword such as `Fixes +#123`. Use a [Conventional Commits](https://www.conventionalcommits.org/) title. +Explain the change and how you tested it, and complete the PR template. For +specification changes, use exactly one of the `editorial` or `normative` labels. + +## Developer Certificate of Origin + +Sign off every contribution commit with `git commit --signoff`, certifying the +[Developer Certificate of Origin](https://developercertificate.org/). The DCO +certification belongs to the human contributor, who is responsible for the +contribution's rights, licensing and correctness. The organization DCO App +checks pull requests. + +## AI-assisted contributions + +AI-assisted contributions are welcome with disclosure. Name the tool and model +in the PR's **AI assistance** section, for example `Assisted-by: Tool (model)`. +Review and test generated changes. AI assistance does not replace human DCO +certification or responsibility for the contribution. + +Follow [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Report vulnerabilities privately +as described in [SECURITY.md](SECURITY.md). diff --git a/GITHUB_APP_SETUP.md b/GITHUB_APP_SETUP.md new file mode 100644 index 0000000..a4d11fd --- /dev/null +++ b/GITHUB_APP_SETUP.md @@ -0,0 +1,95 @@ +# GitHub App setup + +The `agentnameservice` organization owns this App. GitHub Actions runs the +management jobs; there is no webhook server to deploy. Registration and +installation can be completed while `governance` remains private. Installing +the App does not enable synchronization. + +## Register + +1. Open https://github.com/organizations/agentnameservice/settings/apps/new + while signed in as an organization Owner. +2. Set the name to `ANS Org Management` (or a unique variation if unavailable). + Set the homepage to `https://github.com/agentnameservice/.github`. + Suggested description: `Manage ANS repository rules and teams from reviewed configuration.` +3. Leave Callback URL and Setup URL blank. Leave **Request user authorization + (OAuth) during installation** and **Enable Device Flow** unchecked. No + client secret is needed for this installation-token workflow. +4. Under **Webhook**, uncheck **Active**. No webhook URL, secret or event + subscriptions are needed. +5. Set the permissions below. This is the permission set for the prepared + configuration and workflows; do not import every permission from the full + upstream Safe Settings manifest, which supports additional features. + +| Scope | Permission | Access | +| --- | --- | --- | +| Repository | Administration | Read and write | +| Repository | Contents | Read and write | +| Repository | Checks | Read and write | +| Repository | Issues | Read and write | +| Repository | Pull requests | Read and write | +| Repository | Commit statuses | Read-only | +| Repository | Metadata | Read-only (automatic) | +| Organization | Members | Read and write | + +Leave other permissions at No access. Administration manages repository +rulesets and team grants; Members manages teams and memberships; Contents and +Pull requests support configuration PRs; Issues supports labels; Checks and +Commit statuses support check inspection and Safe Settings validation. + +6. For installation availability, choose **Only on this account**, then + **Create GitHub App**. +7. On its General page, record the **App ID** and **Client ID**. These are + identifiers, not secrets. + +## Install + +8. Open **Install App**, choose `agentnameservice`, and select **Only select + repositories**. Initially select `.github` and `governance`. Add the first + public test repository when its configuration is ready. Leave + `governance-archieve` unselected. Click **Install**. +9. In `.github` → **Settings → Secrets and variables → Actions → Variables**, set + `ORG_APP_ID` to the App ID and `ORG_APP_CLIENT_ID` to the Client ID. + Keep the existing `ORG_MANAGEMENT_ENABLED=false` and `ORG_AUTO_APPLY=false`. + +## Key and activation + +10. After the `.github` workflow/configuration review and main-branch + protections are complete, return to the App's General page and choose + **Generate a private key**. Store the downloaded PEM in the approved secret + store. Do not put the key in a commit, issue, PR, or chat. +11. In `.github` → **Settings → Environments → org-management**, create the + environment secret `ORG_APP_PRIVATE_KEY` with the complete PEM contents, + including its BEGIN/END lines. The existing environment is restricted to + branch `main`. Do not use a repository-level secret for this key. +12. Once the configuration is reviewed and merged, + test with `ORG_MANAGEMENT_ENABLED=true` and `ORG_AUTO_APPLY=false`. + Run **Organization management → Run workflow → preview**. Check the proposed + changes and both interim administrators' approval/merge access before any + apply. Enable automatic apply only after the pilot passes. + +## Keeping governance private + +GitHub Apps can read an installed private repository with Contents read +permission. GitHub Free does not provide ruleset enforcement for that private +repository, but this does not prevent App registration or private roster reads. + +The roster reader allows authenticated reads of private `governance/TSC.md` +and the synchronizer permits the TSC's existing Write grant there. It reads the +approved default-branch SHA, never an unmerged PR. Other private repositories, +foreign repositories, forks and the historical archive are not roster sources. +Keep private governance excluded from Safe Settings ruleset management. + +The initial `.github` configuration uses `tsc-owners` and its local roster only, +so the first preview/apply does not depend on TSC roster publication. + +Keep the manually created teams in place until their approved default-branch +rosters are ready for synchronization. Public contribution/security/conduct pointers must continue +to resolve publicly; do not replace public policy text with links to private +governance documents. The App and private roster setup can proceed separately. + +## References + +- [Register a GitHub App](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) +- [Install your own App](https://docs.github.com/en/apps/using-github-apps/installing-your-own-github-app) +- [About rulesets and plan availability](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..05bfad0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,10 @@ +The organization-management software, configuration and tests added in this +repository are licensed under the Apache License, Version 2.0. See +LICENSES/Apache-2.0.txt. + +The accompanying documentation and roster templates are licensed under the +Creative Commons Attribution 4.0 International License. See +LICENSES/CC-BY-4.0.txt. + +This follows Section 7 of the ANS Charter. Pre-existing and third-party +materials retain their applicable licenses and notices. diff --git a/LICENSES/Apache-2.0.txt b/LICENSES/Apache-2.0.txt new file mode 100644 index 0000000..137069b --- /dev/null +++ b/LICENSES/Apache-2.0.txt @@ -0,0 +1,73 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt new file mode 100644 index 0000000..4ea99c2 --- /dev/null +++ b/LICENSES/CC-BY-4.0.txt @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..973208b --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,19 @@ +# Repository access roster + +Connor Snitker and Keith Perry manage `.github` through `@agentnameservice/tsc-owners` during initial setup. Both retain their existing organization Owner roles and their ability to approve and merge across the organization until setup is complete and the access handoff is approved. + +The elected Chair and Vice Chair take over this roster through a reviewed pull request after that handoff. The TSC roster is maintained separately in [governance/TSC.md](https://github.com/agentnameservice/governance/blob/main/TSC.md). + +## Maintainers + +| GitHub | +| --- | +| @csnitker-godaddy | +| @kperry-godaddy | + +## Reviewers + +| GitHub | +| --- | + +Update this file through a reviewed pull request. The organization automation reads the GitHub column in these two sections. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ffe9873 --- /dev/null +++ b/README.md @@ -0,0 +1,102 @@ +# ANS organization configuration + +This repository holds the public organization profile, contribution guidance, +and GitHub administration configuration. GitHub Actions runs Safe Settings +with an organization-owned GitHub App. No server is required. + +## What you manage + +| Change | Where to make it | +| --- | --- | +| Project Maintainers or Reviewers | A PR to that project's `MAINTAINERS.md` | +| TSC membership | A PR to `governance/TSC.md` | +| Initial administrators, then elected officers | A PR to this repository's `MAINTAINERS.md` | +| Repository enrollment, CI checks or pausing | **Actions → Manage repository** | +| Shared protection policy | A PR to `safe-settings/suborgs/defaults.yml` | +| Invitations, org Owners, security managers and 2FA | GitHub organization settings | + +Each roster lives in one place. There are no setup-roster copies to maintain. +The form creates normal PRs containing native Safe Settings YAML. You do not +need to edit a JSON inventory. Go SDK package repositories may reference the +SDK roster with `Roster source: agentnameservice/ans-sdk-go/MAINTAINERS.md`. + +## Initial run + +The initial configuration manages `.github` only, using `tsc-owners`. Connor +and Keith are its interim members and retain their existing org Owner roles. +This first run does not need a public governance repository or a TSC roster. + +Follow [SETUP_CHECKLIST.md](SETUP_CHECKLIST.md) and [GITHUB_APP_SETUP.md](GITHUB_APP_SETUP.md). +Keep `ORG_MANAGEMENT_ENABLED` and `ORG_AUTO_APPLY` false until the reviewed +configuration is merged and the App credentials are ready. Then enable +management with automatic apply still off and run **Organization management → +preview**. Review the plan before running **apply**. + +## Everyday use + +For a new public repository, prepare its roster, CODEOWNERS and real CI checks, +add it to the App installation, and use **Manage repository → Enroll or update**. +The form reports missing prerequisites and imports existing check requirements. +Supply a tracking issue and your own certified DCO sign-off for the configuration +PR. **Inspect repository** is read-only and needs neither. + +**Bootstrap access** defaults to **Keep current**: new project repositories start +with `tsc-owners` as an additional code owner and PR merger. Existing repositories +retain their current choice. After the user approves the final handoff, select +**Remove** and review the configuration PR. The exception applies only to the +merge restriction; DCO, CI and normal review requirements still apply. + +CODEOWNERS must include the project Maintainer team, `@agentnameservice/tsc`, and, +during bootstrap, `@agentnameservice/tsc-owners`. Preserve these shared teams on +path-specific ownership rules as well. `.github` initially needs only +`@agentnameservice/tsc-owners`. Adding TSC fallback there is a later reviewed +CODEOWNERS/configuration change. + +Roster files use `## Maintainers` and `## Reviewers` sections with a `GitHub` +table column containing plain `@handles`. Reviewers may be empty. The TSC uses +its `## Voting members` table. The App reads approved default-branch revisions; +it never takes membership authority from an unmerged PR. + +Governance may remain private. Install the App on it for authenticated roster +reads. Private governance remains excluded from ruleset management on GitHub +Free. Other managed repositories and shared project roster sources must be +public, active ANS repositories. The historical archive stays excluded. + +## What synchronization changes + +An apply prepares team membership, runs Safe Settings, then grants repository +Write access. A failed protection step prevents the access-grant step. Preview +performs no team or repository-access writes. Both modes report failures. + +Safe Settings manages additive repository rulesets and labels. Existing classic +protections and unrelated rulesets remain. Its repository-lifecycle, team and +collaborator plugins are disabled. A small Octokit script reads the rosters, +creates teams, reconciles membership, and grants their declared Write access. +It does not invite people, demote org Owners, delete teams, or remove unrelated +grants. Unexpected elevated, nested or foreign team access needs owner review. +The shared TSC/bootstrap teams may retain Write on other active public ANS repos +and on private governance during the transition. + +The baseline requires reviewed PRs, CODEOWNERS review, DCO, resolved conversations, +and blocks branch deletion and force pushes. Separate rulesets require the +repo's actual CI and restrict merges to its Maintainers plus any explicit +bootstrap exception. The TSC alone grants review eligibility, not project +merge authority; governance itself uses the TSC as its merge team. + +Once the pilot is accepted, `ORG_AUTO_APPLY=true` applies reviewed configuration +and roster updates on pushes and a six-hour schedule. **Pause management** excludes +a repository and any others sharing its Maintainer team; existing access and +protections remain. Set `ORG_MANAGEMENT_ENABLED=false` to stop all management. + +## Development + +```sh +npm ci --ignore-scripts +npm run validate +npm test +python3 -m unittest discover -s tests -v +``` + +Dependencies and Actions are pinned. The native runner is described in the +[Safe Settings Actions guide](https://github.com/github-community-projects/safe-settings/blob/3.0.0/docs/github-action.md). +Follow [CONTRIBUTING.md](CONTRIBUTING.md) for changes. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..606e55d --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,12 @@ +# Security + +Use **Report a vulnerability** under the affected repository's Security tab. +For specification vulnerabilities, use the +[ans-registry reporting form](https://github.com/agentnameservice/ans-registry/security/advisories/new). +For this repository, use [private reporting](https://github.com/agentnameservice/.github/security/advisories/new). + +Include the affected version, reproduction steps, impact, and any proposed fix. +Do not post vulnerability details or credentials in a public issue, PR or chat. +Repository administrators receive the report and coordinate privately with the +relevant Maintainers. Follow supported-version guidance in the affected repo; +the default supported line is its latest minor release. diff --git a/SETUP_CHECKLIST.md b/SETUP_CHECKLIST.md new file mode 100644 index 0000000..26e5123 --- /dev/null +++ b/SETUP_CHECKLIST.md @@ -0,0 +1,75 @@ +# ANS organization setup + +This checklist covers the initial installation. Routine changes use repository +roster PRs and the **Manage repository** form. There is no setup roster inventory. + +## Initial .github setup + +- [x] Create `tsc-owners`, add Connor and Keith, and grant Write on `.github`. +- [x] Record their interim membership in this repository's `MAINTAINERS.md`. +- [x] Apply initial `.github/main` protections: one PR approval, stale-review + dismissal, resolved conversations, DCO, no deletion or force pushes, + and PR merges restricted to `tsc-owners`. +- [ ] Review and merge this branch with human-authorized DCO sign-offs. + Keith's separate contribution-policy PR is not a prerequisite. +- [ ] Confirm the `Validate organization configuration` check passes on the PR + and GitHub recognizes `.github/CODEOWNERS` with `tsc-owners`. +- [ ] Finish App registration and selected-repository installation using + [GITHUB_APP_SETUP.md](GITHUB_APP_SETUP.md). Initially select `.github` + and `governance`; the latter may remain private. Exclude the archive. +- [ ] Set the App identifiers and the `org-management` environment private-key + secret. Keep the environment restricted to `main` and default workflow + token read-only. Keep both management switches false until ready. +- [ ] Set `ORG_MANAGEMENT_ENABLED=true`, leaving `ORG_AUTO_APPLY=false`. + Run **Organization management → preview** and review its plan. +- [ ] Run **apply** for the initial `.github` configuration. This adds the real + configuration-validation requirement and CODEOWNERS review after their + files are on main. Verify that Connor and Keith can approve and merge + compliant PRs and remain org Owners. + +The initial `.github` configuration uses only its own approved roster. It does +not read the TSC roster or require governance publication. + +## Enroll project repositories + +- [ ] Merge the approved TSC voting roster into the default branch of + `governance`. The App can read it privately; keep private governance + excluded from Safe Settings ruleset management. +- [ ] Confirm invited roster members have joined the organization. The initial + teams were created manually; there is no duplicate roster under `.github`. +- [ ] Merge each project's approved `MAINTAINERS.md` and prepare CODEOWNERS for + its Maintainer team, `tsc`, and `tsc-owners` while bootstrap access is on. + Keep shared reviewers on path-specific rules. Package repos can point to + the SDK roster instead of copying its membership. +- [ ] Publish the reusable contribution workflow on `.github/main` before + adding callers. Keep existing CI and use its actual check names. +- [ ] Prepare merge-group CI triggers for repos using merge queues. Prepare + package publishers to create PRs before applying PR-only tap restrictions. +- [ ] Add the public pilot repository to the App installation. Use **Manage + repository → Inspect repository**, then **Enroll or update**. Keep + **Bootstrap access → Keep current** for the initial enrollment. +- [ ] Review and merge the generated native YAML. Run preview, then apply. + Team membership is prepared first; repository access is granted only + after protections succeed. +- [ ] Verify the real approval/merge path: DCO and CI failures block merges; + both interim administrators can review and merge compliant PRs; TSC-only + reviewers do not gain project merge authority. Test merge queues and + release publishing where applicable before extending the rollout. +- [ ] Enroll additional repositories through the same form. Once accepted, + enable `ORG_AUTO_APPLY=true` for routine synchronization. + +Connor and Keith retain their existing Owner roles throughout setup. Bootstrap +exceptions are separate from permanent project Maintainer appointments and do +not bypass DCO or CI. Remove them through the form only after the user approves +the handoff, then review any remaining team grants manually. + +## Separate organization work + +Public policy guidance remains usable in `.github` while governance is private. +Publish central governance before changing public docs to private-only links. +The public security defaults and DCO App are already configured. + +Complete the Security lead/backup and reporting arrangements, notify members +before enabling required 2FA, and resolve final officer/LF ownership handoff +when those decisions are made. Old direct grants, legacy groups and archive +deletion are separate cleanup; do not infer account removals from a roster edit. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..04c3d61 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,261 @@ +{ + "name": "ans-org-management", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "ans-org-management", + "dependencies": { + "@octokit/rest": "22.0.1", + "js-yaml": "4.3.1" + }, + "engines": { + "node": ">=24" + } + }, + "node_modules/@octokit/auth-token": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", + "integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==", + "license": "MIT", + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/core": { + "version": "7.0.8", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.8.tgz", + "integrity": "sha512-L7y8eYc+AwxGr2PWI4WFt1VG4TiJ66c26BD16mXpYIlXxG0SMigM1+m4aTSlYyBr5BlQsGAlz8uDCoZN4SEMcg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-token": "^6.0.0", + "@octokit/graphql": "^9.0.5", + "@octokit/request": "^10.0.16", + "@octokit/request-error": "^7.1.2", + "@octokit/types": "^18.0.0", + "before-after-hook": "^4.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/endpoint": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.5.tgz", + "integrity": "sha512-iXa654H3yFafF/ieHkukfbgWo2rmXD2ceD0ZOtrPhw1bc3FDch1d9N/TNs0FQ1/cIbwb7kspUX8jzIs8nzb9DQ==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^18.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/graphql": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.5.tgz", + "integrity": "sha512-bt/hm03LeU6Vy7FwTrkkC9p3XGT/lBwClglMqxBSe5/q0E5CdJTXeAqEI0vlw89/LF/G6tryTIH8HirZ3prMVg==", + "license": "MIT", + "dependencies": { + "@octokit/request": "^10.0.16", + "@octokit/types": "^18.0.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "29.0.1", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-29.0.1.tgz", + "integrity": "sha512-9qWOMFNxxLokERcms42rU0PTLqQmVs7g5E41TI4mCOxmpFayD1rfC7XxOL55cG9MBZLFlC31BrR37myMKardwg==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", + "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/openapi-types": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", + "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-rest/node_modules/@octokit/types": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", + "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^27.0.0" + } + }, + "node_modules/@octokit/plugin-request-log": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-6.0.0.tgz", + "integrity": "sha512-UkOzeEN3W91/eBq9sPZNQ7sUBvYCqYbrrD8gTbBuGtHEuycE4/awMXcYvx6sVYo7LypPhmQwwpUe4Yyu4QZN5Q==", + "license": "MIT", + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", + "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^16.0.0" + }, + "engines": { + "node": ">= 20" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/openapi-types": { + "version": "27.0.0", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", + "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-rest-endpoint-methods/node_modules/@octokit/types": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", + "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^27.0.0" + } + }, + "node_modules/@octokit/request": { + "version": "10.0.16", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.16.tgz", + "integrity": "sha512-A0zWGjHzISIb+9ccG8s0dq7LKO5zVpJLRICjgUb+sJxEWqn8RUHB1rD3AE51+PECvXHIxqZ1VVvs4fHTSD9nUQ==", + "license": "MIT", + "dependencies": { + "@octokit/endpoint": "^11.0.5", + "@octokit/request-error": "^7.1.2", + "@octokit/types": "^18.0.0", + "content-type": "^3.0.0", + "json-with-bigint": "^3.5.12", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/request-error": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.2.tgz", + "integrity": "sha512-XZRuT3xZ84D3gYErI1DZvhJ33dCWVV6uzBtWkaBB4TvA/L6eOeTZodxLFVB44bBEEo3vEx7y00UfX1tBLrtLRg==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^18.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/rest": { + "version": "22.0.1", + "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-22.0.1.tgz", + "integrity": "sha512-Jzbhzl3CEexhnivb1iQ0KJ7s5vvjMWcmRtq5aUsKmKDrRW6z3r84ngmiFKFvpZjpiU/9/S6ITPFRpn5s/3uQJw==", + "license": "MIT", + "dependencies": { + "@octokit/core": "^7.0.6", + "@octokit/plugin-paginate-rest": "^14.0.0", + "@octokit/plugin-request-log": "^6.0.0", + "@octokit/plugin-rest-endpoint-methods": "^17.0.0" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/@octokit/types": { + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-18.0.0.tgz", + "integrity": "sha512-l6bAF43PNxkJp6g+W4PjoUSSkxHomXw2nOum5CTftJz1NlV3vu93NImgOYtLf6CbBUb5j+fiuzW0PPQ5JTSvZA==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^29.0.1" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "license": "Python-2.0" + }, + "node_modules/before-after-hook": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz", + "integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==", + "license": "Apache-2.0" + }, + "node_modules/content-type": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-3.1.1.tgz", + "integrity": "sha512-GW4qUsfFo59d0HbUibDlWv5wPz+vAAcaTWbKIuKCf0JkC7wWkSyf8f13IpXn5JkeMlB2P8iTSSIjwXljorg2vA==", + "license": "MIT", + "engines": { + "node": ">=22" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/js-yaml": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.1.tgz", + "integrity": "sha512-CY6crGq313MX8GkwvB7tzgp99vjQxY1++5y10/BKN/GUfHqWaOGQMNZkBvqSzsZKWk/ijwHlWzzkLulsGHhjWQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/json-with-bigint": { + "version": "3.5.12", + "resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.5.12.tgz", + "integrity": "sha512-uwbF/wSSuOgC7qqlq27Xp5B6a2MHVug3t0idZdTqu0JnlFvgJuH7ju+KAk/J06C7GfhoYy2gnb9wz2INqcne7w==", + "license": "MIT" + }, + "node_modules/universal-user-agent": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", + "integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..02de69b --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "ans-org-management", + "private": true, + "type": "module", + "engines": { "node": ">=24" }, + "scripts": { "test": "node --test tests/*.test.mjs", "validate": "node scripts/validate.mjs" }, + "dependencies": { "@octokit/rest": "22.0.1", "js-yaml": "4.3.1" } +} diff --git a/safe-settings/deployment-settings.yml b/safe-settings/deployment-settings.yml new file mode 100644 index 0000000..63e44c9 --- /dev/null +++ b/safe-settings/deployment-settings.yml @@ -0,0 +1,6 @@ +# The installation controls scope during the pilot. Once all active repos are +# public, an all-repositories installation also covers newly created repos. +restrictedRepos: + exclude: + - governance-archieve + - governance # Remove through the management form after publication. diff --git a/safe-settings/repos/.github.yml b/safe-settings/repos/.github.yml new file mode 100644 index 0000000..51a885f --- /dev/null +++ b/safe-settings/repos/.github.yml @@ -0,0 +1,33 @@ +# Initial management scope. Other repositories enroll through the Actions form. +teams: + - name: tsc-owners + permission: push +rulesets: + - name: ANS repository checks + target: branch + enforcement: active + conditions: + ref_name: + include: ['~DEFAULT_BRANCH'] + exclude: [] + bypass_actors: [] + rules: + - type: required_status_checks + parameters: + strict_required_status_checks_policy: true + required_status_checks: + - context: Validate organization configuration + integration_id: 15368 + - name: ANS Maintainer merges + target: branch + enforcement: active + conditions: + ref_name: + include: ['~DEFAULT_BRANCH'] + exclude: [] + bypass_actors: + - actor_type: Team + name: tsc-owners + bypass_mode: pull_request + rules: + - type: update diff --git a/safe-settings/settings.yml b/safe-settings/settings.yml new file mode 100644 index 0000000..20d0863 --- /dev/null +++ b/safe-settings/settings.yml @@ -0,0 +1,14 @@ +# Native Safe Settings controls. Shared policy is in suborgs/defaults.yml. +ruleset_scope: repo + +disable_plugins: + - repository + - archive + - branches + - teams + - collaborators + - app_installations + - custom_repository_roles + +# Preserve existing labels and repository rulesets. +additive_plugins: [labels, rulesets] diff --git a/safe-settings/suborgs/defaults.yml b/safe-settings/suborgs/defaults.yml new file mode 100644 index 0000000..3c25daf --- /dev/null +++ b/safe-settings/suborgs/defaults.yml @@ -0,0 +1,44 @@ +# Repository rulesets: additive protections on GitHub Free public repos. +suborgrepos: ['*', '.*'] +ruleset_scope: repo + +rulesets: + - name: ANS baseline + target: branch + enforcement: active + conditions: + ref_name: + include: ['~DEFAULT_BRANCH'] + exclude: [] + bypass_actors: [] + rules: + - type: deletion + - type: non_fast_forward + - type: pull_request + parameters: + required_approving_review_count: 1 + dismiss_stale_reviews_on_push: true + require_code_owner_review: true + require_last_push_approval: false + required_review_thread_resolution: true + - type: required_status_checks + parameters: + strict_required_status_checks_policy: true + required_status_checks: + - context: DCO + integration_id: 1861 + +labels: + include: + - name: editorial + color: '0075ca' + description: No normative specification change + - name: normative + color: d93f0b + description: Changes a specification requirement + - name: stale + color: ededed + description: Waiting on its author; follow GOVERNANCE.md + - name: needs-info + color: d876e3 + description: Additional information is needed diff --git a/scripts/config.mjs b/scripts/config.mjs new file mode 100644 index 0000000..620d61d --- /dev/null +++ b/scripts/config.mjs @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: Apache-2.0 +import fs from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import yaml from "js-yaml"; + +export const ROOT = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + "..", +); +export const ORG = "agentnameservice"; +export const REPO = ".github"; +export const BASELINE = "ANS baseline"; +export const CHECKS = "ANS repository checks"; +export const MERGE = "ANS Maintainer merges"; +export const TSC = "tsc"; +export const BOOTSTRAP = "tsc-owners"; +export const loginPattern = /^[a-z\d](?:[a-z\d-]{0,37}[a-z\d])?$/i; +export const teamPattern = /^[a-z\d]+(?:-[a-z\d]+)*$/; +export function ensure(value, message) { + if (!value) throw new Error(message); +} +export function repositoryName(value) { + const name = String(value || "") + .trim() + .toLowerCase(); + ensure( + name === ".github" || /^[a-z\d][a-z\d_.-]*$/.test(name), + "Use a repository name within agentnameservice", + ); + ensure(name !== "governance-archieve", "The historical archive is excluded"); + return name; +} +export async function readYaml(file) { + return yaml.load(await fs.readFile(file, "utf8")); +} +export async function writeYaml(file, value) { + await fs.mkdir(path.dirname(file), { recursive: true }); + await fs.writeFile(file, yaml.dump(value, { lineWidth: 100, noRefs: true })); +} +export function access(name, config) { + repositoryName(name); + const gate = config.rulesets?.find((r) => r.name === MERGE); + const mergers = gate?.bypass_actors + ?.filter((a) => a.actor_type === "Team") + .map((a) => a.name); + const teams = config.teams || []; + const bootstrap = name !== REPO && mergers?.includes(BOOTSTRAP); + const maintainers = mergers?.filter( + (team) => name === REPO || team !== BOOTSTRAP, + ); + ensure( + maintainers?.length === 1 && + new Set(mergers).size === mergers.length && + teams.length >= 1 && + teams.length <= 4, + `${name}: declare one merge team, optional bootstrap access, and at most one Reviewer team`, + ); + ensure( + teams.every((t) => teamPattern.test(t.name) && t.permission === "push"), + `${name}: roster teams need Write permission`, + ); + ensure( + new Set(teams.map((t) => t.name)).size === teams.length && + teams.some((t) => t.name === maintainers[0]) && + (name === REPO || teams.some((t) => t.name === TSC)) && + (!bootstrap || teams.some((t) => t.name === BOOTSTRAP)), + `${name}: ambiguous team mapping`, + ); + ensure( + name === "governance" + ? maintainers[0] === TSC + : name === ".github" + ? maintainers[0] === BOOTSTRAP + : ![TSC, BOOTSTRAP].includes(maintainers[0]), + `${name}: TSC review access does not confer project merge authority`, + ); + const reviewers = teams.filter( + (t) => + t.name !== maintainers[0] && + t.name !== TSC && + !(bootstrap && t.name === BOOTSTRAP), + ); + ensure(reviewers.length <= 1, `${name}: declare at most one Reviewer team`); + ensure( + !reviewers.some((t) => t.name === "tsc-owners") && + (![".github", "governance"].includes(name) || !reviewers.length), + `${name}: keep officer and TSC membership in their governance rosters`, + ); + return { + maintainers: maintainers[0], + reviewers: reviewers[0]?.name, + bootstrap: Boolean(bootstrap), + }; +} +export function codeOwners(name, settings) { + const mapping = access(name, settings); + return [ + ...new Set([ + mapping.maintainers, + ...(settings.teams.some((t) => t.name === TSC) ? [TSC] : []), + ...(mapping.bootstrap ? [BOOTSTRAP] : []), + ]), + ]; +} +export async function configuration(root = ROOT) { + const settings = await readYaml( + path.join(root, "safe-settings/settings.yml"), + ); + const defaults = await readYaml( + path.join(root, "safe-settings/suborgs/defaults.yml"), + ); + const deployment = await readYaml( + path.join(root, "safe-settings/deployment-settings.yml"), + ); + const excluded = deployment.restrictedRepos?.exclude; + ensure( + Array.isArray(excluded) && excluded.includes("governance-archieve"), + "Keep the archive excluded", + ); + ensure( + excluded.every((n) => n === "governance-archieve" || repositoryName(n)), + "Use explicit exclusions", + ); + const directory = path.join(root, "safe-settings/repos"); + const repositories = Object.create(null); + for (const file of (await fs.readdir(directory)) + .filter((f) => f.endsWith(".yml")) + .sort()) { + const name = repositoryName(file.slice(0, -4)); + ensure(file === name + ".yml", "Use canonical lowercase filenames"); + repositories[name] = await readYaml(path.join(directory, file)); + access(name, repositories[name]); + } + return { + settings, + defaults, + deployment, + excluded: new Set(excluded), + repositories, + }; +} diff --git a/scripts/github.mjs b/scripts/github.mjs new file mode 100644 index 0000000..1d27ad4 --- /dev/null +++ b/scripts/github.mjs @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: Apache-2.0 +import { Octokit } from "@octokit/rest"; +import { ORG, REPO, ensure, loginPattern, repositoryName } from "./config.mjs"; + +export function github() { + return new Octokit({ auth: process.env.GH_TOKEN }); +} +export async function optional(call) { + try { + return await call(); + } catch (error) { + if (error.status === 404) return null; + throw error; + } +} +export async function textFile(gh, repo, file, ref) { + const result = await optional(() => + gh.rest.repos.getContent({ owner: ORG, repo, path: file, ref }), + ); + if (!result) return null; + ensure( + result.data.type === "file" && result.data.encoding === "base64", + `Expected a normal file: ${repo}/${file}`, + ); + return Buffer.from(result.data.content, "base64").toString("utf8"); +} +export async function publicRepository(gh, name) { + return repository(gh, name, false); +} +export async function rosterRepository(gh, name) { + return repository(gh, name, name === "governance"); +} +async function repository(gh, name, allowPrivate) { + repositoryName(name); + const { data } = await gh.rest.repos.get({ owner: ORG, repo: name }); + ensure( + data.full_name.toLowerCase() === `${ORG}/${name}` && + (allowPrivate || !data.private) && + !data.archived && + !data.fork, + `${name}: must be ${allowPrivate ? "" : "public, "}active, non-forked, and owned by ANS`, + ); + return data; +} +export async function head(gh, repo, branch) { + const { data } = await gh.rest.git.getRef({ + owner: ORG, + repo, + ref: `heads/${branch}`, + }); + return data.object.sha; +} +export async function owner(gh, actor) { + ensure(loginPattern.test(actor || ""), "Invalid requester"); + const { data } = await gh.rest.orgs.getMembershipForUser({ + org: ORG, + username: actor, + }); + ensure( + data.state === "active" && data.role === "admin", + "An organization owner must make this request", + ); +} +export function trustedWorkflow() { + ensure( + process.env.GITHUB_REPOSITORY === `${ORG}/${REPO}` && + process.env.GITHUB_REF === "refs/heads/main", + "Run this workflow on agentnameservice/.github main", + ); +} diff --git a/scripts/manage-repository.mjs b/scripts/manage-repository.mjs new file mode 100644 index 0000000..7474ba1 --- /dev/null +++ b/scripts/manage-repository.mjs @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: Apache-2.0 +// A small form adapter: read GitHub, then edit native Safe Settings YAML for a PR. +import fs from "node:fs/promises"; +import path from "node:path"; +import { createHash } from "node:crypto"; +import { pathToFileURL } from "node:url"; +import { + ROOT, + ORG, + REPO, + CHECKS, + MERGE, + TSC, + BOOTSTRAP, + access, + codeOwners, + configuration, + ensure, + repositoryName, + writeYaml, +} from "./config.mjs"; +import { + github, + optional, + owner, + publicRepository, + head, + textFile, + trustedWorkflow, +} from "./github.mjs"; +import { roster } from "./rosters.mjs"; + +export function signoff(inputs) { + ensure( + String(inputs.certify_dco) === "true", + "Certify the DCO before requesting a commit", + ); + const value = String(inputs.signoff || "").trim(); + ensure( + /^[^<>\x00-\x1f]{2,120} <[^<>\s@]+@[^<>\s@]+\.[^<>\s@]+>$/.test(value), + "Supply your own Full Name ; it will appear in the commit", + ); + return value; +} + +export async function observedChecks(gh, repo, sha) { + const prs = await gh.rest.pulls.list({ + owner: ORG, + repo, + state: "all", + sort: "updated", + direction: "desc", + per_page: 5, + }); + const checks = new Set(); + for (const ref of new Set([sha, ...prs.data.map((p) => p.head.sha)])) { + const runs = await gh.paginate(gh.rest.checks.listForRef, { + owner: ORG, + repo, + ref, + per_page: 100, + }); + const statuses = await gh.paginate(gh.rest.repos.listCommitStatusesForRef, { + owner: ORG, + repo, + ref, + per_page: 100, + }); + runs.forEach((c) => checks.add(c.name)); + statuses.forEach((c) => checks.add(c.context)); + } + return [...checks].sort(); +} + +export function codeOwnerEntries(text) { + return (text || "") + .split(/\r?\n/) + .map((line) => line.replace(/\s+#.*$/, "").trim()) + .filter((line) => line && !line.startsWith("#")) + .map((line) => line.split(/\s+/)); +} + +export async function prepare(gh, config, inputs, actor) { + const name = repositoryName(inputs.repository); + ensure( + ["Inspect repository", "Enroll or update", "Pause management"].includes( + inputs.operation, + ), + "Choose a supported operation", + ); + await owner(gh, actor); + const info = await publicRepository(gh, name); + const value = structuredClone(config.repositories[name] || {}); + const deployment = structuredClone(config.deployment); + let observed = []; + const pending = []; + let affected = [name]; + if (inputs.operation === "Pause management") { + if (config.repositories[name]) { + const team = access(name, value).maintainers; + affected = Object.entries(config.repositories) + .filter(([n, c]) => access(n, c).maintainers === team) + .map(([n]) => n); + } + deployment.restrictedRepos.exclude = [ + ...new Set([...config.excluded, ...affected]), + ].sort(); + } else { + const sha = await head(gh, name, info.default_branch); + const existing = + ( + await optional(() => + gh.rest.repos.getBranchProtection({ + owner: ORG, + repo: name, + branch: info.default_branch, + }), + ) + )?.data || {}; + const rules = await gh.paginate( + "GET /repos/{owner}/{repo}/rules/branches/{branch}", + { owner: ORG, repo: name, branch: info.default_branch }, + ); + observed = await observedChecks(gh, name, sha); + const owners = await textFile(gh, name, ".github/CODEOWNERS", sha); + const entries = codeOwnerEntries(owners); + const catchall = entries.filter((entry) => entry[0] === "*").at(-1); + const candidates = (catchall?.slice(1) || []) + .filter( + (owner) => + owner !== `@${ORG}/${TSC}` && + (name === REPO || owner !== `@${ORG}/${BOOTSTRAP}`), + ) + .map( + (owner) => + owner.match(/^@agentnameservice\/([a-z\d]+(?:-[a-z\d]+)*)$/)?.[1], + ); + const mapping = config.repositories[name] + ? access(name, value) + : { + maintainers: + (candidates.length === 1 && candidates[0]) || + { ".github": "tsc-owners", governance: "tsc" }[name] || + `${name.replace(/[^a-z\d]+/g, "-")}-maintainers`, + }; + if (!mapping.reviewers && ![".github", "governance"].includes(name)) + mapping.reviewers = + mapping.maintainers.replace(/-maintainers$/, "") + "-reviewers"; + const bootstrapChoice = inputs.bootstrap_access || "Keep current"; + ensure( + ["Keep current", "Enable", "Remove"].includes(bootstrapChoice), + "Choose a supported bootstrap access option", + ); + mapping.bootstrap = + name !== REPO && + (bootstrapChoice === "Enable" || + (bootstrapChoice === "Keep current" && + (config.repositories[name] ? mapping.bootstrap : true))); + const includeTsc = + name !== REPO || + value.teams?.some((t) => t.name === TSC) || + catchall?.includes(`@${ORG}/${TSC}`); + const previous = + value.rulesets + ?.find((r) => r.name === CHECKS) + ?.rules?.find((r) => r.type === "required_status_checks")?.parameters + ?.required_status_checks || []; + const required = new Set([ + ...previous.map((c) => c.context), + ...(existing.required_status_checks?.contexts || []), + ...(existing.required_status_checks?.checks || []).map((c) => c.context), + ]); + for (const rule of rules) { + if (rule.type === "required_status_checks") + rule.parameters.required_status_checks.forEach((c) => + required.add(c.context), + ); + } + const selected = inputs.required_checks?.trim() + ? new Set( + inputs.required_checks + .split(/[;\n]/) + .map((c) => c.trim()) + .filter(Boolean), + ) + : required; + selected.add("DCO"); + value.teams = [ + ...new Set( + [ + mapping.maintainers, + mapping.reviewers, + ...(includeTsc ? [TSC] : []), + ...(mapping.bootstrap ? [BOOTSTRAP] : []), + ].filter(Boolean), + ), + ].map((team) => ({ name: team, permission: "push" })); + const common = { + target: "branch", + enforcement: "active", + conditions: { ref_name: { include: ["~DEFAULT_BRANCH"], exclude: [] } }, + }; + value.rulesets = [ + ...(value.rulesets || []).filter( + (r) => ![CHECKS, MERGE].includes(r.name), + ), + { + name: CHECKS, + ...common, + bypass_actors: [], + rules: [ + { + type: "required_status_checks", + parameters: { + strict_required_status_checks_policy: true, + required_status_checks: [...selected] + .filter((c) => c !== "DCO") + .sort() + .map((context) => ({ context })), + }, + }, + ], + }, + { + name: MERGE, + ...common, + // Bootstrap access is explicit native YAML and never bypasses DCO/CI. + bypass_actors: [ + mapping.maintainers, + ...(mapping.bootstrap ? [BOOTSTRAP] : []), + ].map((team) => ({ + actor_type: "Team", + name: team, + bypass_mode: "pull_request", + })), + rules: [{ type: "update" }], + }, + ]; + const requiredOwners = codeOwners(name, value).map( + (team) => `@${ORG}/${team}`, + ); + if ( + JSON.stringify([...(catchall?.slice(1) || [])].sort()) !== + JSON.stringify([...requiredOwners].sort()) + ) + pending.push(`Merge CODEOWNERS with * ${requiredOwners.join(" ")}.`); + for (const team of [ + includeTsc ? TSC : null, + mapping.bootstrap ? BOOTSTRAP : null, + ].filter(Boolean)) + if (entries.some((entry) => !entry.slice(1).includes(`@${ORG}/${team}`))) + pending.push( + `Include @${ORG}/${team} on every CODEOWNERS rule, including path-specific overrides.`, + ); + try { + await roster(gh, name, { ...config.repositories, [name]: value }); + if (includeTsc && name !== "governance") + await roster(gh, "governance", config.repositories); + if (mapping.bootstrap) await roster(gh, REPO, config.repositories); + } catch (error) { + pending.push(error.message); + } + if (selected.size < 2) + pending.push( + "Select the actual CI checks from the observed list; requirements are not guessed.", + ); + if ([...selected].some((c) => !observed.includes(c))) + pending.push( + "Run the selected checks on a representative PR before enrolling.", + ); + deployment.restrictedRepos.exclude = [...config.excluded].filter( + (n) => n !== name, + ); + } + const result = { + name, + value, + deployment, + observed, + pending, + affected, + operation: inputs.operation, + }; + result.report = `# ${name}\n\n${inputs.operation}.\n\n`; + if (observed.length) + result.report += + "Observed checks:\n" + + observed.map((c) => "- `" + c.replace(/[\r\n`]/g, " ") + "`").join("\n") + + "\n"; + if (pending.length) + result.report += + "\nSetup needed:\n" + pending.map((p) => "- " + p).join("\n") + "\n"; + if (affected.length > 1) + result.report += + "\nShared-team repositories affected: " + affected.join(", ") + ".\n"; + if (inputs.operation !== "Inspect repository") { + ensure(!pending.length, result.report); + result.signoff = signoff(inputs); + const issue = String(inputs.issue || "") + .trim() + .replace(/^#/, ""); + ensure( + /^[1-9]\d*$/.test(issue), + "Supply the tracking issue number in .github", + ); + const { data } = await gh.rest.issues.get({ + owner: ORG, + repo: REPO, + issue_number: Number(issue), + }); + ensure(!data.pull_request, "Link an issue, not a pull request"); + result.issue = issue; + } + return result; +} + +async function output(name, value) { + if (!process.env.GITHUB_OUTPUT) return; + const delimiter = "ANS_" + createHash("sha256").update(value).digest("hex"); + await fs.appendFile( + process.env.GITHUB_OUTPUT, + `${name}<<${delimiter}\n${value}\n${delimiter}\n`, + ); +} + +async function main() { + trustedWorkflow(); + ensure( + process.env.GITHUB_EVENT_NAME === "workflow_dispatch", + "Use the management form", + ); + const event = JSON.parse( + await fs.readFile(process.env.GITHUB_EVENT_PATH, "utf8"), + ); + const config = await configuration(); + const result = await prepare( + github(), + config, + event.inputs, + process.env.REQUESTER, + ); + console.log(result.report); + if (process.env.GITHUB_STEP_SUMMARY) + await fs.appendFile(process.env.GITHUB_STEP_SUMMARY, result.report); + const updateRepo = + result.operation !== "Pause management" && + JSON.stringify(config.repositories[result.name]) !== + JSON.stringify(result.value); + const changed = + result.operation !== "Inspect repository" && + (updateRepo || + JSON.stringify(config.deployment) !== JSON.stringify(result.deployment)); + await output("changed", String(changed)); + if (!changed) return; + if (updateRepo) + await writeYaml( + path.join(ROOT, "safe-settings/repos", result.name + ".yml"), + result.value, + ); + if (JSON.stringify(config.deployment) !== JSON.stringify(result.deployment)) + await writeYaml( + path.join(ROOT, "safe-settings/deployment-settings.yml"), + result.deployment, + ); + const title = `chore: configure ${result.name}`; + await output("title", title); + await output("branch", "codex/manage-" + result.name.replaceAll(".", "-")); + await output("author", result.signoff); + await output( + "commit_message", + title + "\n\nSigned-off-by: " + result.signoff, + ); + await fs.mkdir(path.join(ROOT, "reports"), { recursive: true }); + await fs.writeFile( + path.join(ROOT, "reports/request.md"), + `## Related issue\n\nFixes #${result.issue}\n\n## Summary\n\n${result.report}\nThe declared teams follow the reviewed repository rosters, including removals. Review this configuration change before merging.\n\n## Testing\n\nNative configuration validation runs in CI.\n\n## AI assistance\n\nNo AI is used by this deterministic workflow.\n`, + ); +} +if ( + process.argv[1] && + import.meta.url === pathToFileURL(process.argv[1]).href +) { + main().catch((error) => { + console.error(error.message); + process.exitCode = 1; + }); +} diff --git a/scripts/rosters.mjs b/scripts/rosters.mjs new file mode 100644 index 0000000..4741fc2 --- /dev/null +++ b/scripts/rosters.mjs @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: Apache-2.0 +import { access, ensure, loginPattern } from "./config.mjs"; +import { + textFile, + publicRepository, + rosterRepository, + head, +} from "./github.mjs"; + +export function parseRoster(text, tsc = false) { + ensure( + text && !text.includes("\nFixes #").returncode, 0) + + def test_normative_and_editorial_are_exclusive(self): + self.assertEqual(self.run_policy(labels=["normative"], specification=True).returncode, 0) + for labels in [[], ["normative", "editorial"]]: + self.assertNotEqual(self.run_policy(labels=labels, specification=True).returncode, 0) + + def test_untrusted_strings_are_data_and_bad_titles_fail(self): + result = self.run_policy(title="fix: $(exit 99)", body="Fixes #123\n`exit 99`") + self.assertEqual(result.returncode, 0) + self.assertNotEqual(self.run_policy(title="please merge").returncode, 0) + + def test_only_queue_metadata_can_skip_pr_metadata_check(self): + self.assertEqual(self.run_policy(event_name="merge_group").returncode, 0) + self.assertNotEqual(self.run_policy(event_name="workflow_dispatch").returncode, 0) diff --git a/workflow-templates/ans-contribution-policy.properties.json b/workflow-templates/ans-contribution-policy.properties.json new file mode 100644 index 0000000..4086f84 --- /dev/null +++ b/workflow-templates/ans-contribution-policy.properties.json @@ -0,0 +1,5 @@ +{ + "name": "ANS contribution policy", + "description": "Check Conventional Commit PR titles, linked issues, and specification labels using the shared ANS policy.", + "categories": ["Automation"] +} diff --git a/workflow-templates/ans-contribution-policy.yml b/workflow-templates/ans-contribution-policy.yml new file mode 100644 index 0000000..147c5a8 --- /dev/null +++ b/workflow-templates/ans-contribution-policy.yml @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# Select this template in each ANS repository's Actions tab. +# main is intentional for this first-party shared policy; changes require review +# in the protected organization configuration repository. +name: Check contribution metadata + +on: + pull_request: + types: [opened, edited, synchronize, reopened, labeled, unlabeled, ready_for_review] + merge_group: + +permissions: + contents: read + +jobs: + contribution: + uses: agentnameservice/.github/.github/workflows/contribution-policy.yml@main + with: + specification: ${{ github.event.repository.name == 'ans-registry' }} From 3383765704ad5ccf62a86fdbe0a639d956873b44 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Wed, 28 Oct 2026 11:38:47 -0500 Subject: [PATCH 02/19] docs: simplify organization management guide Signed-off-by: Connor Snitker --- GITHUB_APP_SETUP.md | 95 ------------------------------- MAINTAINERS.md | 5 +- README.md | 135 ++++++++++++++++---------------------------- SETUP_CHECKLIST.md | 75 ------------------------ 4 files changed, 51 insertions(+), 259 deletions(-) delete mode 100644 GITHUB_APP_SETUP.md delete mode 100644 SETUP_CHECKLIST.md diff --git a/GITHUB_APP_SETUP.md b/GITHUB_APP_SETUP.md deleted file mode 100644 index a4d11fd..0000000 --- a/GITHUB_APP_SETUP.md +++ /dev/null @@ -1,95 +0,0 @@ -# GitHub App setup - -The `agentnameservice` organization owns this App. GitHub Actions runs the -management jobs; there is no webhook server to deploy. Registration and -installation can be completed while `governance` remains private. Installing -the App does not enable synchronization. - -## Register - -1. Open https://github.com/organizations/agentnameservice/settings/apps/new - while signed in as an organization Owner. -2. Set the name to `ANS Org Management` (or a unique variation if unavailable). - Set the homepage to `https://github.com/agentnameservice/.github`. - Suggested description: `Manage ANS repository rules and teams from reviewed configuration.` -3. Leave Callback URL and Setup URL blank. Leave **Request user authorization - (OAuth) during installation** and **Enable Device Flow** unchecked. No - client secret is needed for this installation-token workflow. -4. Under **Webhook**, uncheck **Active**. No webhook URL, secret or event - subscriptions are needed. -5. Set the permissions below. This is the permission set for the prepared - configuration and workflows; do not import every permission from the full - upstream Safe Settings manifest, which supports additional features. - -| Scope | Permission | Access | -| --- | --- | --- | -| Repository | Administration | Read and write | -| Repository | Contents | Read and write | -| Repository | Checks | Read and write | -| Repository | Issues | Read and write | -| Repository | Pull requests | Read and write | -| Repository | Commit statuses | Read-only | -| Repository | Metadata | Read-only (automatic) | -| Organization | Members | Read and write | - -Leave other permissions at No access. Administration manages repository -rulesets and team grants; Members manages teams and memberships; Contents and -Pull requests support configuration PRs; Issues supports labels; Checks and -Commit statuses support check inspection and Safe Settings validation. - -6. For installation availability, choose **Only on this account**, then - **Create GitHub App**. -7. On its General page, record the **App ID** and **Client ID**. These are - identifiers, not secrets. - -## Install - -8. Open **Install App**, choose `agentnameservice`, and select **Only select - repositories**. Initially select `.github` and `governance`. Add the first - public test repository when its configuration is ready. Leave - `governance-archieve` unselected. Click **Install**. -9. In `.github` → **Settings → Secrets and variables → Actions → Variables**, set - `ORG_APP_ID` to the App ID and `ORG_APP_CLIENT_ID` to the Client ID. - Keep the existing `ORG_MANAGEMENT_ENABLED=false` and `ORG_AUTO_APPLY=false`. - -## Key and activation - -10. After the `.github` workflow/configuration review and main-branch - protections are complete, return to the App's General page and choose - **Generate a private key**. Store the downloaded PEM in the approved secret - store. Do not put the key in a commit, issue, PR, or chat. -11. In `.github` → **Settings → Environments → org-management**, create the - environment secret `ORG_APP_PRIVATE_KEY` with the complete PEM contents, - including its BEGIN/END lines. The existing environment is restricted to - branch `main`. Do not use a repository-level secret for this key. -12. Once the configuration is reviewed and merged, - test with `ORG_MANAGEMENT_ENABLED=true` and `ORG_AUTO_APPLY=false`. - Run **Organization management → Run workflow → preview**. Check the proposed - changes and both interim administrators' approval/merge access before any - apply. Enable automatic apply only after the pilot passes. - -## Keeping governance private - -GitHub Apps can read an installed private repository with Contents read -permission. GitHub Free does not provide ruleset enforcement for that private -repository, but this does not prevent App registration or private roster reads. - -The roster reader allows authenticated reads of private `governance/TSC.md` -and the synchronizer permits the TSC's existing Write grant there. It reads the -approved default-branch SHA, never an unmerged PR. Other private repositories, -foreign repositories, forks and the historical archive are not roster sources. -Keep private governance excluded from Safe Settings ruleset management. - -The initial `.github` configuration uses `tsc-owners` and its local roster only, -so the first preview/apply does not depend on TSC roster publication. - -Keep the manually created teams in place until their approved default-branch -rosters are ready for synchronization. Public contribution/security/conduct pointers must continue -to resolve publicly; do not replace public policy text with links to private -governance documents. The App and private roster setup can proceed separately. - -## References - -- [Register a GitHub App](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) -- [Install your own App](https://docs.github.com/en/apps/using-github-apps/installing-your-own-github-app) -- [About rulesets and plan availability](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets) diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 973208b..06b0ebf 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -1,8 +1,7 @@ # Repository access roster -Connor Snitker and Keith Perry manage `.github` through `@agentnameservice/tsc-owners` during initial setup. Both retain their existing organization Owner roles and their ability to approve and merge across the organization until setup is complete and the access handoff is approved. - -The elected Chair and Vice Chair take over this roster through a reviewed pull request after that handoff. The TSC roster is maintained separately in [governance/TSC.md](https://github.com/agentnameservice/governance/blob/main/TSC.md). +Members of `tsc-owners` manage this repository. Membership changes are reviewed +through pull requests to this file. ## Maintainers diff --git a/README.md b/README.md index ffe9873..d5f35e0 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,56 @@ -# ANS organization configuration +# ANS organization management -This repository holds the public organization profile, contribution guidance, -and GitHub administration configuration. GitHub Actions runs Safe Settings -with an organization-owned GitHub App. No server is required. +This repository contains ANS's organization profile, contribution guidance, +and GitHub configuration. Actions runs Safe Settings and synchronizes teams +from repository rosters. -## What you manage +## Making changes -| Change | Where to make it | +| Change | Where | | --- | --- | -| Project Maintainers or Reviewers | A PR to that project's `MAINTAINERS.md` | -| TSC membership | A PR to `governance/TSC.md` | -| Initial administrators, then elected officers | A PR to this repository's `MAINTAINERS.md` | -| Repository enrollment, CI checks or pausing | **Actions → Manage repository** | -| Shared protection policy | A PR to `safe-settings/suborgs/defaults.yml` | -| Invitations, org Owners, security managers and 2FA | GitHub organization settings | - -Each roster lives in one place. There are no setup-roster copies to maintain. -The form creates normal PRs containing native Safe Settings YAML. You do not -need to edit a JSON inventory. Go SDK package repositories may reference the -SDK roster with `Roster source: agentnameservice/ans-sdk-go/MAINTAINERS.md`. - -## Initial run - -The initial configuration manages `.github` only, using `tsc-owners`. Connor -and Keith are its interim members and retain their existing org Owner roles. -This first run does not need a public governance repository or a TSC roster. - -Follow [SETUP_CHECKLIST.md](SETUP_CHECKLIST.md) and [GITHUB_APP_SETUP.md](GITHUB_APP_SETUP.md). -Keep `ORG_MANAGEMENT_ENABLED` and `ORG_AUTO_APPLY` false until the reviewed -configuration is merged and the App credentials are ready. Then enable -management with automatic apply still off and run **Organization management → -preview**. Review the plan before running **apply**. - -## Everyday use - -For a new public repository, prepare its roster, CODEOWNERS and real CI checks, -add it to the App installation, and use **Manage repository → Enroll or update**. -The form reports missing prerequisites and imports existing check requirements. -Supply a tracking issue and your own certified DCO sign-off for the configuration -PR. **Inspect repository** is read-only and needs neither. - -**Bootstrap access** defaults to **Keep current**: new project repositories start -with `tsc-owners` as an additional code owner and PR merger. Existing repositories -retain their current choice. After the user approves the final handoff, select -**Remove** and review the configuration PR. The exception applies only to the -merge restriction; DCO, CI and normal review requirements still apply. - -CODEOWNERS must include the project Maintainer team, `@agentnameservice/tsc`, and, -during bootstrap, `@agentnameservice/tsc-owners`. Preserve these shared teams on -path-specific ownership rules as well. `.github` initially needs only -`@agentnameservice/tsc-owners`. Adding TSC fallback there is a later reviewed -CODEOWNERS/configuration change. - -Roster files use `## Maintainers` and `## Reviewers` sections with a `GitHub` -table column containing plain `@handles`. Reviewers may be empty. The TSC uses -its `## Voting members` table. The App reads approved default-branch revisions; -it never takes membership authority from an unmerged PR. - -Governance may remain private. Install the App on it for authenticated roster -reads. Private governance remains excluded from ruleset management on GitHub -Free. Other managed repositories and shared project roster sources must be -public, active ANS repositories. The historical archive stays excluded. - -## What synchronization changes - -An apply prepares team membership, runs Safe Settings, then grants repository -Write access. A failed protection step prevents the access-grant step. Preview -performs no team or repository-access writes. Both modes report failures. - -Safe Settings manages additive repository rulesets and labels. Existing classic -protections and unrelated rulesets remain. Its repository-lifecycle, team and -collaborator plugins are disabled. A small Octokit script reads the rosters, -creates teams, reconciles membership, and grants their declared Write access. -It does not invite people, demote org Owners, delete teams, or remove unrelated -grants. Unexpected elevated, nested or foreign team access needs owner review. -The shared TSC/bootstrap teams may retain Write on other active public ANS repos -and on private governance during the transition. +| Project Maintainers and Reviewers | The project's `MAINTAINERS.md` | +| TSC members | `governance/TSC.md` | +| Administrators of this repository | [MAINTAINERS.md](MAINTAINERS.md) | +| Enroll, update or pause a repository | **Actions → Manage repository** | +| Shared protections | [defaults.yml](safe-settings/suborgs/defaults.yml) | + +Use the form to inspect a repository or open a configuration PR. It reports +missing rosters, CODEOWNERS and CI checks. Review and merge the PR, then run +**Organization management → preview** before **apply**. + +**Bootstrap access** keeps `tsc-owners` eligible to approve and merge during +setup. **Keep current** preserves the existing choice and enables it for new +repositories. Select **Remove** only after the access handoff is approved. +DCO, CI and review requirements still apply. + +Keep each roster in its own repository, using [MAINTAINERS.md](MAINTAINERS.md) +as the format. The automation reads merged default-branch files. Governance +may remain private if the App can read it; private governance is excluded from +ruleset management on GitHub Free. Organization invitations and Owner roles +are managed directly in GitHub. + +## Running the automation + +The organization-owned App needs repository Administration, Contents, Checks, +Issues and Pull requests write access; Commit statuses read access; and +organization Members write access. Install it only on repositories it should +manage or read. Webhooks are disabled because Actions runs the jobs. + +| Setting | Location | +| --- | --- | +| `ORG_APP_ID`, `ORG_APP_CLIENT_ID` | Repository Actions variables | +| `ORG_APP_PRIVATE_KEY` | Secret in the `org-management` environment, restricted to `main` | +| `ORG_MANAGEMENT_ENABLED` | Repository variable; `false` stops management | +| `ORG_AUTO_APPLY` | Repository variable; `true` applies changes on pushes and the schedule | -The baseline requires reviewed PRs, CODEOWNERS review, DCO, resolved conversations, -and blocks branch deletion and force pushes. Separate rulesets require the -repo's actual CI and restrict merges to its Maintainers plus any explicit -bootstrap exception. The TSC alone grants review eligibility, not project -merge authority; governance itself uses the TSC as its merge team. +Keep automatic apply off until preview and a manual apply have been verified. +An apply prepares teams, applies protections, then grants repository access. +A protection failure stops the access-grant step. Existing unrelated grants +and protections remain. -Once the pilot is accepted, `ORG_AUTO_APPLY=true` applies reviewed configuration -and roster updates on pushes and a six-hour schedule. **Pause management** excludes -a repository and any others sharing its Maintainer team; existing access and -protections remain. Set `ORG_MANAGEMENT_ENABLED=false` to stop all management. +[Repository configurations](safe-settings/repos) and +[exclusions](safe-settings/deployment-settings.yml) define the managed scope. +For App registration details, use [GitHub's documentation](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app). ## Development @@ -97,6 +61,5 @@ npm test python3 -m unittest discover -s tests -v ``` -Dependencies and Actions are pinned. The native runner is described in the -[Safe Settings Actions guide](https://github.com/github-community-projects/safe-settings/blob/3.0.0/docs/github-action.md). -Follow [CONTRIBUTING.md](CONTRIBUTING.md) for changes. +See [CONTRIBUTING.md](CONTRIBUTING.md) and the +[Safe Settings documentation](https://github.com/github-community-projects/safe-settings). diff --git a/SETUP_CHECKLIST.md b/SETUP_CHECKLIST.md deleted file mode 100644 index 26e5123..0000000 --- a/SETUP_CHECKLIST.md +++ /dev/null @@ -1,75 +0,0 @@ -# ANS organization setup - -This checklist covers the initial installation. Routine changes use repository -roster PRs and the **Manage repository** form. There is no setup roster inventory. - -## Initial .github setup - -- [x] Create `tsc-owners`, add Connor and Keith, and grant Write on `.github`. -- [x] Record their interim membership in this repository's `MAINTAINERS.md`. -- [x] Apply initial `.github/main` protections: one PR approval, stale-review - dismissal, resolved conversations, DCO, no deletion or force pushes, - and PR merges restricted to `tsc-owners`. -- [ ] Review and merge this branch with human-authorized DCO sign-offs. - Keith's separate contribution-policy PR is not a prerequisite. -- [ ] Confirm the `Validate organization configuration` check passes on the PR - and GitHub recognizes `.github/CODEOWNERS` with `tsc-owners`. -- [ ] Finish App registration and selected-repository installation using - [GITHUB_APP_SETUP.md](GITHUB_APP_SETUP.md). Initially select `.github` - and `governance`; the latter may remain private. Exclude the archive. -- [ ] Set the App identifiers and the `org-management` environment private-key - secret. Keep the environment restricted to `main` and default workflow - token read-only. Keep both management switches false until ready. -- [ ] Set `ORG_MANAGEMENT_ENABLED=true`, leaving `ORG_AUTO_APPLY=false`. - Run **Organization management → preview** and review its plan. -- [ ] Run **apply** for the initial `.github` configuration. This adds the real - configuration-validation requirement and CODEOWNERS review after their - files are on main. Verify that Connor and Keith can approve and merge - compliant PRs and remain org Owners. - -The initial `.github` configuration uses only its own approved roster. It does -not read the TSC roster or require governance publication. - -## Enroll project repositories - -- [ ] Merge the approved TSC voting roster into the default branch of - `governance`. The App can read it privately; keep private governance - excluded from Safe Settings ruleset management. -- [ ] Confirm invited roster members have joined the organization. The initial - teams were created manually; there is no duplicate roster under `.github`. -- [ ] Merge each project's approved `MAINTAINERS.md` and prepare CODEOWNERS for - its Maintainer team, `tsc`, and `tsc-owners` while bootstrap access is on. - Keep shared reviewers on path-specific rules. Package repos can point to - the SDK roster instead of copying its membership. -- [ ] Publish the reusable contribution workflow on `.github/main` before - adding callers. Keep existing CI and use its actual check names. -- [ ] Prepare merge-group CI triggers for repos using merge queues. Prepare - package publishers to create PRs before applying PR-only tap restrictions. -- [ ] Add the public pilot repository to the App installation. Use **Manage - repository → Inspect repository**, then **Enroll or update**. Keep - **Bootstrap access → Keep current** for the initial enrollment. -- [ ] Review and merge the generated native YAML. Run preview, then apply. - Team membership is prepared first; repository access is granted only - after protections succeed. -- [ ] Verify the real approval/merge path: DCO and CI failures block merges; - both interim administrators can review and merge compliant PRs; TSC-only - reviewers do not gain project merge authority. Test merge queues and - release publishing where applicable before extending the rollout. -- [ ] Enroll additional repositories through the same form. Once accepted, - enable `ORG_AUTO_APPLY=true` for routine synchronization. - -Connor and Keith retain their existing Owner roles throughout setup. Bootstrap -exceptions are separate from permanent project Maintainer appointments and do -not bypass DCO or CI. Remove them through the form only after the user approves -the handoff, then review any remaining team grants manually. - -## Separate organization work - -Public policy guidance remains usable in `.github` while governance is private. -Publish central governance before changing public docs to private-only links. -The public security defaults and DCO App are already configured. - -Complete the Security lead/backup and reporting arrangements, notify members -before enabling required 2FA, and resolve final officer/LF ownership handoff -when those decisions are made. Old direct grants, legacy groups and archive -deletion are separate cleanup; do not infer account removals from a roster edit. From f6ac83184fff87873f2e6b9d7faf7326de045be2 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Wed, 28 Oct 2026 11:50:17 -0500 Subject: [PATCH 03/19] fix: preserve CI bindings and avoid empty reviewer teams Signed-off-by: Connor Snitker --- scripts/manage-repository.mjs | 85 ++++++++++---- scripts/rosters.mjs | 14 +-- scripts/sync-rosters.mjs | 11 ++ tests/manage.test.mjs | 208 +++++++++++++++++++++++++++++++++- tests/rosters.test.mjs | 28 ++++- 5 files changed, 311 insertions(+), 35 deletions(-) diff --git a/scripts/manage-repository.mjs b/scripts/manage-repository.mjs index 7474ba1..46097a5 100644 --- a/scripts/manage-repository.mjs +++ b/scripts/manage-repository.mjs @@ -143,9 +143,6 @@ export async function prepare(gh, config, inputs, actor) { { ".github": "tsc-owners", governance: "tsc" }[name] || `${name.replace(/[^a-z\d]+/g, "-")}-maintainers`, }; - if (!mapping.reviewers && ![".github", "governance"].includes(name)) - mapping.reviewers = - mapping.maintainers.replace(/-maintainers$/, "") + "-reviewers"; const bootstrapChoice = inputs.bootstrap_access || "Keep current"; ensure( ["Keep current", "Enable", "Remove"].includes(bootstrapChoice), @@ -160,21 +157,71 @@ export async function prepare(gh, config, inputs, actor) { name !== REPO || value.teams?.some((t) => t.name === TSC) || catchall?.includes(`@${ORG}/${TSC}`); + try { + const people = await roster(gh, name, config.repositories); + if (people.source !== name) { + const shared = access( + people.source, + config.repositories[people.source], + ); + ensure( + mapping.maintainers === shared.maintainers, + "Shared rosters must use the same Maintainer team", + ); + ensure( + shared.reviewers || !people.reviewers.length, + "Configure the source repository's Reviewer team first", + ); + mapping.reviewers = shared.reviewers; + } else if ( + people.reviewers.length && + !mapping.reviewers && + ![REPO, "governance"].includes(name) + ) { + mapping.reviewers = + mapping.maintainers.replace(/-maintainers$/, "") + "-reviewers"; + } + if (includeTsc && name !== "governance") + await roster(gh, "governance", config.repositories); + if (mapping.bootstrap) await roster(gh, REPO, config.repositories); + } catch (error) { + pending.push(error.message); + } const previous = value.rulesets ?.find((r) => r.name === CHECKS) ?.rules?.find((r) => r.type === "required_status_checks")?.parameters ?.required_status_checks || []; - const required = new Set([ - ...previous.map((c) => c.context), - ...(existing.required_status_checks?.contexts || []), - ...(existing.required_status_checks?.checks || []).map((c) => c.context), - ]); - for (const rule of rules) { - if (rule.type === "required_status_checks") - rule.parameters.required_status_checks.forEach((c) => - required.add(c.context), - ); + const required = new Map(); + for (const check of [ + ...previous, + ...(existing.required_status_checks?.contexts || []).map((context) => ({ + context, + })), + ...(existing.required_status_checks?.checks || []).map( + ({ context, app_id }) => ({ + context, + ...(app_id > 0 ? { integration_id: app_id } : {}), + }), + ), + ...rules + .filter((r) => r.type === "required_status_checks") + .flatMap((r) => r.parameters.required_status_checks), + ]) { + if (check.context === "DCO") continue; + const current = required.get(check.context); + ensure( + current?.integration_id == null || + check.integration_id == null || + current.integration_id === check.integration_id, + `Conflicting App bindings for ${check.context}; resolve its existing requirements first`, + ); + required.set( + check.context, + check.integration_id != null + ? { ...current, ...check } + : current || check, + ); } const selected = inputs.required_checks?.trim() ? new Set( @@ -183,7 +230,7 @@ export async function prepare(gh, config, inputs, actor) { .map((c) => c.trim()) .filter(Boolean), ) - : required; + : new Set(required.keys()); selected.add("DCO"); value.teams = [ ...new Set( @@ -216,7 +263,7 @@ export async function prepare(gh, config, inputs, actor) { required_status_checks: [...selected] .filter((c) => c !== "DCO") .sort() - .map((context) => ({ context })), + .map((context) => required.get(context) || { context }), }, }, ], @@ -252,14 +299,6 @@ export async function prepare(gh, config, inputs, actor) { pending.push( `Include @${ORG}/${team} on every CODEOWNERS rule, including path-specific overrides.`, ); - try { - await roster(gh, name, { ...config.repositories, [name]: value }); - if (includeTsc && name !== "governance") - await roster(gh, "governance", config.repositories); - if (mapping.bootstrap) await roster(gh, REPO, config.repositories); - } catch (error) { - pending.push(error.message); - } if (selected.size < 2) pending.push( "Select the actual CI checks from the observed list; requirements are not guessed.", diff --git a/scripts/rosters.mjs b/scripts/rosters.mjs index 4741fc2..b691cdd 100644 --- a/scripts/rosters.mjs +++ b/scripts/rosters.mjs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 -import { access, ensure, loginPattern } from "./config.mjs"; +import { ensure, loginPattern } from "./config.mjs"; import { textFile, publicRepository, @@ -90,7 +90,8 @@ export async function roster(gh, name, repositories) { pointers.length <= 1, "Malformed roster reference", ); - if (!pointers.length) return parseRoster(text, name === "governance"); + if (!pointers.length) + return { ...parseRoster(text, name === "governance"), source: name }; ensure( name !== "governance", "The TSC roster must come from governance/TSC.md", @@ -103,13 +104,6 @@ export async function roster(gh, name, repositories) { !text.includes("## Reviewers"), "Use one declared shared roster without duplicate tables", ); - const destinationTeams = access(name, repositories[name]); - const sourceTeams = access(source, repositories[source]); - ensure( - destinationTeams.maintainers === sourceTeams.maintainers && - destinationTeams.reviewers === sourceTeams.reviewers, - "Shared rosters must use the same teams", - ); const sourceInfo = await publicRepository(gh, source); const sourceHead = await head(gh, source, sourceInfo.default_branch); const sourceText = await textFile(gh, source, "MAINTAINERS.md", sourceHead); @@ -117,5 +111,5 @@ export async function roster(gh, name, repositories) { sourceText && !sourceText.includes("Roster source:"), "Chained roster references are not supported", ); - return parseRoster(sourceText); + return { ...parseRoster(sourceText), source }; } diff --git a/scripts/sync-rosters.mjs b/scripts/sync-rosters.mjs index 074ca66..70d590b 100644 --- a/scripts/sync-rosters.mjs +++ b/scripts/sync-rosters.mjs @@ -73,6 +73,17 @@ export async function synchronize( ? bootstrap : await readRoster(gh, repo, config.repositories); ensure(people, "The TSC voting roster is unavailable"); + if (people.source && people.source !== repo) { + const source = access( + people.source, + config.repositories[people.source], + ); + ensure( + mapping.maintainers === source.maintainers && + mapping.reviewers === source.reviewers, + "Shared rosters must use the same teams", + ); + } ensure( mapping.reviewers || !people.reviewers.length, "Declare a Reviewer team before adding Reviewers", diff --git a/tests/manage.test.mjs b/tests/manage.test.mjs index 5831dd4..9a3df34 100644 --- a/tests/manage.test.mjs +++ b/tests/manage.test.mjs @@ -78,7 +78,6 @@ test("enrollment writes native configuration and imports existing checks", async const result = await prepare(fake(), config(), inputs(), "requester"); assert.deepEqual(result.value.teams, [ { name: "sample-maintainers", permission: "push" }, - { name: "sample-reviewers", permission: "push" }, { name: "tsc", permission: "push" }, ]); assert.deepEqual( @@ -95,6 +94,213 @@ test("enrollment writes native configuration and imports existing checks", async }); assert.throws(() => validate(full), /additional/); }); + +test("Reviewer teams are created only for nonempty rosters and retained when explicitly configured", async () => { + const empty = await prepare(fake(), config(), inputs(), "requester"); + assert.ok(!empty.value.teams.some((t) => t.name.endsWith("-reviewers"))); + const gh = fake(); + const content = gh.rest.repos.getContent; + gh.rest.repos.getContent = async (args) => { + const response = await content(args); + if (args.repo === "sample" && args.path === "MAINTAINERS.md") + response.data.content = Buffer.from(roster + "| @bob |\n").toString( + "base64", + ); + return response; + }; + const populated = await prepare(gh, config(), inputs(), "requester"); + assert.ok(populated.value.teams.some((t) => t.name === "sample-reviewers")); + const existing = config(); + existing.repositories.sample = populated.value; + const retained = await prepare(fake(), existing, inputs(), "requester"); + assert.ok(retained.value.teams.some((t) => t.name === "sample-reviewers")); +}); + +test("a new package repository reuses the source's actual Reviewer team", async () => { + for (const hasReviewers of [false, true]) { + const sdkGh = fake(); + const sdkContent = sdkGh.rest.repos.getContent; + sdkGh.rest.repos.getContent = async (args) => { + const response = await sdkContent(args); + if ( + args.repo === "sample" && + args.path === "MAINTAINERS.md" && + hasReviewers + ) + response.data.content = Buffer.from(roster + "| @bob |\n").toString( + "base64", + ); + return response; + }; + const { value } = await prepare(sdkGh, config(), inputs(), "requester"); + if (hasReviewers) + value.teams.find((t) => t.name === "sample-reviewers").name = + "sdk-review-team"; + const current = config(); + current.repositories.sample = value; + const gh = fake(); + const original = gh.rest.repos.getContent; + gh.rest.repos.getContent = async (args) => { + const response = await original(args); + if (args.repo === "tap" && args.path === "MAINTAINERS.md") + response.data.content = Buffer.from( + "Roster source: agentnameservice/sample/MAINTAINERS.md\n", + ).toString("base64"); + if ( + args.repo === "sample" && + args.path === "MAINTAINERS.md" && + hasReviewers + ) + response.data.content = Buffer.from(roster + "| @bob |\n").toString( + "base64", + ); + return response; + }; + const result = await prepare( + gh, + current, + { ...inputs(), repository: "tap" }, + "requester", + ); + assert.deepEqual(result.value.teams, value.teams); + } +}); + +test("a shared roster cannot enroll under a different Maintainer team", async () => { + const { value } = await prepare(fake(), config(), inputs(), "requester"); + const current = config(); + current.repositories.sample = value; + const gh = fake( + "admin", + true, + "* @agentnameservice/other-maintainers @agentnameservice/tsc", + ); + const original = gh.rest.repos.getContent; + gh.rest.repos.getContent = async (args) => { + const response = await original(args); + if (args.repo === "tap" && args.path === "MAINTAINERS.md") + response.data.content = Buffer.from( + "Roster source: agentnameservice/sample/MAINTAINERS.md\n", + ).toString("base64"); + return response; + }; + await assert.rejects( + prepare(gh, current, { ...inputs(), repository: "tap" }, "requester"), + /same Maintainer team/, + ); +}); + +test("an existing package configuration can adopt Reviewers added to its source", async () => { + const { value } = await prepare(fake(), config(), inputs(), "requester"); + const current = config(); + current.repositories.sample = structuredClone(value); + current.repositories.tap = structuredClone(value); + current.repositories.sample.teams.push({ + name: "sdk-review-team", + permission: "push", + }); + const gh = fake(); + const original = gh.rest.repos.getContent; + gh.rest.repos.getContent = async (args) => { + const response = await original(args); + if (args.path === "MAINTAINERS.md") + response.data.content = Buffer.from( + args.repo === "tap" + ? "Roster source: agentnameservice/sample/MAINTAINERS.md\n" + : roster + "| @bob |\n", + ).toString("base64"); + return response; + }; + const result = await prepare( + gh, + current, + { ...inputs(), repository: "tap" }, + "requester", + ); + assert.ok(result.value.teams.some((t) => t.name === "sdk-review-team")); +}); + +test("updates retain configured App bindings despite unbound live contexts", async () => { + const { value } = await prepare(fake(), config(), inputs(), "requester"); + value.rulesets[0].rules[0].parameters.required_status_checks = [ + { context: "test", integration_id: 15368 }, + ]; + const current = config(); + current.repositories.sample = value; + for (const required_checks of [undefined, "test;build"]) { + const result = await prepare( + fake(), + current, + { ...inputs(), required_checks }, + "requester", + ); + const checks = + result.value.rulesets[0].rules[0].parameters.required_status_checks; + assert.deepEqual( + checks.find((c) => c.context === "test"), + { context: "test", integration_id: 15368 }, + ); + if (required_checks) + assert.deepEqual( + checks.find((c) => c.context === "build"), + { context: "build" }, + ); + } +}); + +test("imports preserve classic and ruleset App bindings without duplicate checks", async () => { + const gh = fake(); + gh.rest.repos.getBranchProtection = async () => ({ + data: { + required_status_checks: { + contexts: ["DCO", "test"], + checks: [{ context: "test", app_id: 15368 }], + }, + }, + }); + const paginate = gh.paginate; + gh.paginate = async (route, args) => + route.startsWith("GET /repos/") + ? [ + { + type: "required_status_checks", + parameters: { + required_status_checks: [ + { context: "test", integration_id: 15368 }, + { context: "build", integration_id: 42 }, + ], + }, + }, + ] + : paginate(route, args); + const result = await prepare(gh, config(), inputs(), "requester"); + assert.deepEqual( + result.value.rulesets[0].rules[0].parameters.required_status_checks, + [ + { context: "build", integration_id: 42 }, + { context: "test", integration_id: 15368 }, + ], + ); +}); + +test("conflicting App bindings are reported instead of silently choosing one", async () => { + const { value } = await prepare(fake(), config(), inputs(), "requester"); + value.rulesets[0].rules[0].parameters.required_status_checks = [ + { context: "test", integration_id: 15368 }, + ]; + const current = config(); + current.repositories.sample = value; + const gh = fake(); + gh.rest.repos.getBranchProtection = async () => ({ + data: { + required_status_checks: { checks: [{ context: "test", app_id: 42 }] }, + }, + }); + await assert.rejects( + prepare(gh, current, inputs(), "requester"), + /Conflicting App bindings for test/, + ); +}); test("inspection does not require a signoff or issue", async () => { const result = await prepare( fake(), diff --git a/tests/rosters.test.mjs b/tests/rosters.test.mjs index 54f49e8..d421674 100644 --- a/tests/rosters.test.mjs +++ b/tests/rosters.test.mjs @@ -125,7 +125,7 @@ test("package repositories share the SDK roster without coupling bootstrap hando "homebrew-ans": tap, "ans-sdk-go": sdk, }), - { maintainers: ["alice"], reviewers: ["bob"] }, + { maintainers: ["alice"], reviewers: ["bob"], source: "ans-sdk-go" }, ); }); @@ -174,6 +174,7 @@ test("private governance is read by pinned default-branch SHA; other private sou assert.deepEqual(await roster(gh, "governance", {}), { maintainers: ["alice"], reviewers: [], + source: "governance", }); assert.equal(reads[0].path, "TSC.md"); assert.equal(reads[0].ref, "a".repeat(40)); @@ -393,6 +394,31 @@ test("conflicting shared roster blocks that team without blocking others", async ), ); }); + +test("shared-roster team mismatches block access until the configuration is updated", async () => { + const { gh, writes } = fake(); + const source = override("shared"); + const destination = override("shared"); + destination.teams = destination.teams.filter( + (t) => t.name !== "shared-reviewers", + ); + const result = await synchronize( + gh, + { repositories: { a: source, b: destination }, excluded: new Set() }, + true, + async (client, name) => + name === "b" + ? { ...(await people(client, name)), source: "a" } + : people(client, name), + quiet, + ); + assert.ok( + result.errors.some((error) => + error.includes("Shared rosters must use the same teams"), + ), + ); + assert.ok(!writes.some((w) => w.method === "grant" && w.data.repo === "b")); +}); test("nested or externally used teams cannot be overwritten", async () => { for (const state of [ { parent: { slug: "parent" } }, From bcab367e34dc4aa5ed4e2831c9ce404f97d86262 Mon Sep 17 00:00:00 2001 From: Connor Snitker Date: Wed, 28 Oct 2026 12:30:16 -0500 Subject: [PATCH 04/19] chore: manage ANS teams with Peribolos Signed-off-by: Connor Snitker --- .github/CODEOWNERS | 2 +- .github/workflows/manage-repository.yml | 4 +- .github/workflows/org-management.yml | 38 +- MAINTAINERS.md | 21 +- README.md | 69 +-- peribolos.yml | 133 +++++ safe-settings/deployment-settings.yml | 7 +- safe-settings/repos/.github.yml | 6 +- safe-settings/repos/ans.yml | 37 ++ safe-settings/suborgs/defaults.yml | 3 +- scripts/config.mjs | 90 +-- scripts/github.mjs | 10 +- scripts/manage-repository.mjs | 118 ++-- scripts/rosters.mjs | 115 ---- scripts/sync-rosters.mjs | 258 --------- scripts/validate.mjs | 129 +++-- tests/manage.test.mjs | 703 ++++++++---------------- tests/rosters.test.mjs | 637 --------------------- tests/sdk-pagination.test.mjs | 14 - 19 files changed, 626 insertions(+), 1768 deletions(-) create mode 100644 peribolos.yml create mode 100644 safe-settings/repos/ans.yml delete mode 100644 scripts/rosters.mjs delete mode 100644 scripts/sync-rosters.mjs delete mode 100644 tests/rosters.test.mjs diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f0d722d..a611fa8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,2 @@ -# Create this team with Write access before enabling required Code Owner review. +# GitHub requires explicit Write permission for CODEOWNERS teams. * @agentnameservice/tsc-owners diff --git a/.github/workflows/manage-repository.yml b/.github/workflows/manage-repository.yml index bc16a3d..5ab1c12 100644 --- a/.github/workflows/manage-repository.yml +++ b/.github/workflows/manage-repository.yml @@ -101,4 +101,6 @@ jobs: author: ${{ steps.prepare.outputs.author }} commit-message: ${{ steps.prepare.outputs.commit_message }} signoff: false - add-paths: safe-settings/ + add-paths: | + safe-settings/ + peribolos.yml diff --git a/.github/workflows/org-management.yml b/.github/workflows/org-management.yml index 14d531b..5ff6a4a 100644 --- a/.github/workflows/org-management.yml +++ b/.github/workflows/org-management.yml @@ -14,6 +14,9 @@ on: schedule: - cron: '23 */6 * * *' +env: + PERIBOLOS_IMAGE: us-docker.pkg.dev/k8s-infra-prow/images/peribolos@sha256:b8dfdf7af7dc16d1a4b0f3efb760e6468f098f7e5f0fdd6f8271a07f17cba6d2 # v20261028-c06373a3e + permissions: contents: read @@ -47,8 +50,7 @@ jobs: client-id: ${{ vars.ORG_APP_CLIENT_ID }} private-key: ${{ secrets.ORG_APP_PRIVATE_KEY }} owner: agentnameservice - permission-administration: ${{ env.APPLY == 'true' && 'write' || 'read' }} - permission-members: ${{ env.APPLY == 'true' && 'write' || 'read' }} + permission-members: read permission-contents: read - name: Verify manual apply requester if: github.event_name == 'workflow_dispatch' && env.APPLY == 'true' @@ -56,13 +58,19 @@ jobs: GH_TOKEN: ${{ steps.token.outputs.token }} REQUESTER: ${{ github.triggering_actor }} run: node --input-type=module -e "import {github,owner} from './scripts/github.mjs'; await owner(github(),process.env.REQUESTER)" - - name: Prepare roster teams before resolving rule exceptions - id: teams + - name: Prepare the App key for Peribolos env: - GH_TOKEN: ${{ steps.token.outputs.token }} - REQUESTER: ${{ github.triggering_actor }} - GRANT_ACCESS: 'false' - run: node scripts/sync-rosters.mjs + APP_KEY: ${{ secrets.ORG_APP_PRIVATE_KEY }} + run: | + umask 077 + printf '%s\n' "$APP_KEY" > "$RUNNER_TEMP/org-app.pem" + - name: Reconcile teams and membership + env: + APP_ID: ${{ vars.ORG_APP_ID }} + run: | + args=(--config-path=/workspace/peribolos.yml --github-app-id="$APP_ID" --github-app-private-key-path=/key.pem --fix-teams --fix-team-members --maximum-removal-delta=0) + if [ "$APPLY" = true ]; then args+=(--confirm); fi + docker run --rm --user "$(id -u):$(id -g)" -v "$GITHUB_WORKSPACE:/workspace:ro" -v "$RUNNER_TEMP/org-app.pem:/key.pem:ro" "$PERIBOLOS_IMAGE" "${args[@]}" - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: github-community-projects/safe-settings @@ -85,9 +93,13 @@ jobs: CREATE_PR_COMMENT: 'false' CREATE_ERROR_ISSUE: 'false' run: npm run full-sync - - name: Grant repository access after protections succeed - id: grants + - name: Reconcile team repository access after protections succeed env: - GH_TOKEN: ${{ steps.token.outputs.token }} - REQUESTER: ${{ github.triggering_actor }} - run: node scripts/sync-rosters.mjs + APP_ID: ${{ vars.ORG_APP_ID }} + run: | + args=(--config-path=/workspace/peribolos.yml --github-app-id="$APP_ID" --github-app-private-key-path=/key.pem --fix-teams --fix-team-repos --maximum-removal-delta=0) + if [ "$APPLY" = true ]; then args+=(--confirm); fi + docker run --rm --user "$(id -u):$(id -g)" -v "$GITHUB_WORKSPACE:/workspace:ro" -v "$RUNNER_TEMP/org-app.pem:/key.pem:ro" "$PERIBOLOS_IMAGE" "${args[@]}" + - name: Remove temporary App key + if: always() + run: rm -f "$RUNNER_TEMP/org-app.pem" diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 06b0ebf..7ec3b30 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -1,18 +1,5 @@ -# Repository access roster +# Maintainers -Members of `tsc-owners` manage this repository. Membership changes are reviewed -through pull requests to this file. - -## Maintainers - -| GitHub | -| --- | -| @csnitker-godaddy | -| @kperry-godaddy | - -## Reviewers - -| GitHub | -| --- | - -Update this file through a reviewed pull request. The organization automation reads the GitHub column in these two sections. +The [tsc-owners team](https://github.com/orgs/agentnameservice/teams/tsc-owners) +maintains this repository. Membership and access are defined in +[peribolos.yml](peribolos.yml); propose changes through a pull request. diff --git a/README.md b/README.md index d5f35e0..0b89cf7 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,60 @@ # ANS organization management -This repository contains ANS's organization profile, contribution guidance, -and GitHub configuration. Actions runs Safe Settings and synchronizes teams -from repository rosters. +GitHub Actions runs [Peribolos](https://github.com/kubernetes-sigs/prow/tree/main/cmd/peribolos) +for teams and access, and [Safe Settings](https://github.com/github-community-projects/safe-settings) +for repository protections. No server or Kubernetes cluster is required. ## Making changes | Change | Where | | --- | --- | -| Project Maintainers and Reviewers | The project's `MAINTAINERS.md` | -| TSC members | `governance/TSC.md` | -| Administrators of this repository | [MAINTAINERS.md](MAINTAINERS.md) | -| Enroll, update or pause a repository | **Actions → Manage repository** | +| Teams, members and repository access | [peribolos.yml](peribolos.yml) | +| Enroll, update or pause repository settings | **Actions → Manage repository** | | Shared protections | [defaults.yml](safe-settings/suborgs/defaults.yml) | +| Organization Owners and invitations | GitHub organization settings | -Use the form to inspect a repository or open a configuration PR. It reports -missing rosters, CODEOWNERS and CI checks. Review and merge the PR, then run -**Organization management → preview** before **apply**. +Open a PR for membership changes in `peribolos.yml`, with the affected project's +approvals required by governance. Its `members` and +`maintainers` are GitHub team roles; both receive the team's repository access. +Keep governance decisions in governance documents and GitHub access in this +configuration. Repository Maintainer pages link here instead of copying rosters. -**Bootstrap access** keeps `tsc-owners` eligible to approve and merge during -setup. **Keep current** preserves the existing choice and enables it for new -repositories. Select **Remove** only after the access handoff is approved. -DCO, CI and review requirements still apply. +The repository form imports existing checks, preserves their App bindings, and +opens a PR for the native YAML changes. Merge queues retain loose checks; +other repositories require an up-to-date branch. Existing merge queues, +signature requirements and unrelated protections remain in place. -Keep each roster in its own repository, using [MAINTAINERS.md](MAINTAINERS.md) -as the format. The automation reads merged default-branch files. Governance -may remain private if the App can read it; private governance is excluded from -ruleset management on GitHub Free. Organization invitations and Owner roles -are managed directly in GitHub. +**Bootstrap access → Keep current** preserves the existing choice and enables +`tsc-owners` approval/merge access for new enrollments. Select **Remove** only +after the handoff is approved. DCO, CI and review requirements still apply. ## Running the automation -The organization-owned App needs repository Administration, Contents, Checks, -Issues and Pull requests write access; Commit statuses read access; and -organization Members write access. Install it only on repositories it should -manage or read. Webhooks are disabled because Actions runs the jobs. +Install the organization-owned App on the repositories listed in `peribolos.yml`. +It needs repository Administration, Contents, Checks, Issues and Pull requests +write access; Commit statuses read access; and organization Members write access. +Webhooks are disabled. Governance can remain private. | Setting | Location | | --- | --- | | `ORG_APP_ID`, `ORG_APP_CLIENT_ID` | Repository Actions variables | | `ORG_APP_PRIVATE_KEY` | Secret in the `org-management` environment, restricted to `main` | | `ORG_MANAGEMENT_ENABLED` | Repository variable; `false` stops management | -| `ORG_AUTO_APPLY` | Repository variable; `true` applies changes on pushes and the schedule | +| `ORG_AUTO_APPLY` | Repository variable; `true` applies on pushes and the schedule | -Keep automatic apply off until preview and a manual apply have been verified. -An apply prepares teams, applies protections, then grants repository access. -A protection failure stops the access-grant step. Existing unrelated grants -and protections remain. +Run **Organization management → preview**, review the plan, then use **apply**. +Keep automatic apply off until the first run is verified. Teams and memberships +are reconciled first, protections next, and repository grants last. A failed +protection step stops the grant step. -[Repository configurations](safe-settings/repos) and -[exclusions](safe-settings/deployment-settings.yml) define the managed scope. -For App registration details, use [GitHub's documentation](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app). +Peribolos does not manage org Owners, org-wide membership, repository lifecycle, +or direct collaborators. It preserves team names. Team deletion is disabled by +`--maximum-removal-delta=0`; membership and grant changes follow the reviewed YAML. +Manual changes to managed teams are reconciled to that configuration. + +Only repositories in [the settings scope](safe-settings/deployment-settings.yml) +receive Safe Settings changes. [Repository configs](safe-settings/repos) can be +prepared before enrollment. Pausing settings leaves existing access unchanged. ## Development @@ -61,5 +65,4 @@ npm test python3 -m unittest discover -s tests -v ``` -See [CONTRIBUTING.md](CONTRIBUTING.md) and the -[Safe Settings documentation](https://github.com/github-community-projects/safe-settings). +See [CONTRIBUTING.md](CONTRIBUTING.md) and [GitHub's App documentation](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app). diff --git a/peribolos.yml b/peribolos.yml new file mode 100644 index 0000000..14e05a1 --- /dev/null +++ b/peribolos.yml @@ -0,0 +1,133 @@ +orgs: + agentnameservice: + teams: + Maintainers: + privacy: closed + description: '' + maintainers: + - csnitker-godaddy + members: + - bchen-godaddy + - chou-godaddy + - jcrisp-godaddy + - jhateley-godaddy + repos: + agent-trust-discovery: maintain + ans-gateway-auth: maintain + ans-openshell: maintain + ans-sdk-go: maintain + trust-index-spec: maintain + Reviewers: + privacy: closed + description: '' + maintainers: + - kperry-godaddy + members: [] + repos: {} + ans-gateway-auth-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: [] + repos: + ans-gateway-auth: write + ans-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: + - jhateley-godaddy + repos: + ans: write + ans-openshell-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: [] + repos: + ans-openshell: write + sdk-go-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: [] + repos: + ans-sdk-go: write + homebrew-ans: write + scoop-ans: write + sdk-java-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - kperry-godaddy + members: + - jhateley-godaddy + repos: + ans-sdk-java: write + sdk-rust-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: [] + repos: + ans-sdk-rust: write + spec-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + - scourtney-godaddy + members: [] + repos: + ans-registry: write + trust-index-spec-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: + - cyen-godaddy + repos: + trust-index-spec: write + trust-maintainers: + privacy: closed + description: 'ANS governance roster: repository Maintainers' + maintainers: + - kperry-godaddy + members: + - cyen-godaddy + repos: + agent-trust-discovery: write + tsc: + privacy: closed + description: 'ANS governance roster: TSC voting members' + maintainers: + - csnitker-godaddy + - kperry-godaddy + - scourtney-godaddy + members: + - kantorcodes + - kenhuangus + repos: + governance: write + tsc-owners: + privacy: closed + description: Organization configuration administrators + maintainers: + - csnitker-godaddy + - kperry-godaddy + members: [] + repos: + .github: write diff --git a/safe-settings/deployment-settings.yml b/safe-settings/deployment-settings.yml index 63e44c9..b1e2600 100644 --- a/safe-settings/deployment-settings.yml +++ b/safe-settings/deployment-settings.yml @@ -1,6 +1,3 @@ -# The installation controls scope during the pilot. Once all active repos are -# public, an all-repositories installation also covers newly created repos. restrictedRepos: - exclude: - - governance-archieve - - governance # Remove through the management form after publication. + include: + - .github diff --git a/safe-settings/repos/.github.yml b/safe-settings/repos/.github.yml index 51a885f..152b65d 100644 --- a/safe-settings/repos/.github.yml +++ b/safe-settings/repos/.github.yml @@ -1,7 +1,3 @@ -# Initial management scope. Other repositories enroll through the Actions form. -teams: - - name: tsc-owners - permission: push rulesets: - name: ANS repository checks target: branch @@ -16,6 +12,8 @@ rulesets: parameters: strict_required_status_checks_policy: true required_status_checks: + - context: DCO + integration_id: 1861 - context: Validate organization configuration integration_id: 15368 - name: ANS Maintainer merges diff --git a/safe-settings/repos/ans.yml b/safe-settings/repos/ans.yml new file mode 100644 index 0000000..edbf347 --- /dev/null +++ b/safe-settings/repos/ans.yml @@ -0,0 +1,37 @@ +rulesets: + - name: ANS repository checks + target: branch + enforcement: active + conditions: + ref_name: + include: + - ~DEFAULT_BRANCH + exclude: [] + bypass_actors: [] + rules: + - type: required_status_checks + parameters: + strict_required_status_checks_policy: false + required_status_checks: + - context: DCO + - context: Build & Test + integration_id: 15368 + - context: Lint + integration_id: 15368 + - name: ANS Maintainer merges + target: branch + enforcement: active + conditions: + ref_name: + include: + - ~DEFAULT_BRANCH + exclude: [] + bypass_actors: + - actor_type: Team + name: ans-maintainers + bypass_mode: pull_request + - actor_type: Team + name: tsc-owners + bypass_mode: pull_request + rules: + - type: update diff --git a/safe-settings/suborgs/defaults.yml b/safe-settings/suborgs/defaults.yml index 3c25daf..20a2ffe 100644 --- a/safe-settings/suborgs/defaults.yml +++ b/safe-settings/suborgs/defaults.yml @@ -23,10 +23,9 @@ rulesets: required_review_thread_resolution: true - type: required_status_checks parameters: - strict_required_status_checks_policy: true + strict_required_status_checks_policy: false required_status_checks: - context: DCO - integration_id: 1861 labels: include: diff --git a/scripts/config.mjs b/scripts/config.mjs index 620d61d..d8dd09b 100644 --- a/scripts/config.mjs +++ b/scripts/config.mjs @@ -40,68 +40,33 @@ export async function writeYaml(file, value) { } export function access(name, config) { repositoryName(name); - const gate = config.rulesets?.find((r) => r.name === MERGE); - const mergers = gate?.bypass_actors - ?.filter((a) => a.actor_type === "Team") - .map((a) => a.name); - const teams = config.teams || []; - const bootstrap = name !== REPO && mergers?.includes(BOOTSTRAP); - const maintainers = mergers?.filter( - (team) => name === REPO || team !== BOOTSTRAP, - ); - ensure( - maintainers?.length === 1 && - new Set(mergers).size === mergers.length && - teams.length >= 1 && - teams.length <= 4, - `${name}: declare one merge team, optional bootstrap access, and at most one Reviewer team`, - ); + const actors = + config.rulesets?.find((r) => r.name === MERGE)?.bypass_actors || []; ensure( - teams.every((t) => teamPattern.test(t.name) && t.permission === "push"), - `${name}: roster teams need Write permission`, + actors.every( + (a) => + a.actor_type === "Team" && + a.bypass_mode === "pull_request" && + teamPattern.test(a.name), + ), + `${name}: merge access must use named teams through PRs`, ); + const mergers = actors.map((a) => a.name); + const bootstrap = name !== REPO && mergers.includes(BOOTSTRAP); + const primary = mergers.filter((team) => name === REPO || team !== BOOTSTRAP); ensure( - new Set(teams.map((t) => t.name)).size === teams.length && - teams.some((t) => t.name === maintainers[0]) && - (name === REPO || teams.some((t) => t.name === TSC)) && - (!bootstrap || teams.some((t) => t.name === BOOTSTRAP)), - `${name}: ambiguous team mapping`, + primary.length === 1 && new Set(mergers).size === mergers.length, + `${name}: declare one Maintainer team and optional bootstrap access`, ); ensure( name === "governance" - ? maintainers[0] === TSC - : name === ".github" - ? maintainers[0] === BOOTSTRAP - : ![TSC, BOOTSTRAP].includes(maintainers[0]), - `${name}: TSC review access does not confer project merge authority`, + ? primary[0] === TSC + : name === REPO + ? primary[0] === BOOTSTRAP + : ![TSC, BOOTSTRAP].includes(primary[0]), + `${name}: use the repository's merge team`, ); - const reviewers = teams.filter( - (t) => - t.name !== maintainers[0] && - t.name !== TSC && - !(bootstrap && t.name === BOOTSTRAP), - ); - ensure(reviewers.length <= 1, `${name}: declare at most one Reviewer team`); - ensure( - !reviewers.some((t) => t.name === "tsc-owners") && - (![".github", "governance"].includes(name) || !reviewers.length), - `${name}: keep officer and TSC membership in their governance rosters`, - ); - return { - maintainers: maintainers[0], - reviewers: reviewers[0]?.name, - bootstrap: Boolean(bootstrap), - }; -} -export function codeOwners(name, settings) { - const mapping = access(name, settings); - return [ - ...new Set([ - mapping.maintainers, - ...(settings.teams.some((t) => t.name === TSC) ? [TSC] : []), - ...(mapping.bootstrap ? [BOOTSTRAP] : []), - ]), - ]; + return { maintainers: primary[0], bootstrap }; } export async function configuration(root = ROOT) { const settings = await readYaml( @@ -113,14 +78,16 @@ export async function configuration(root = ROOT) { const deployment = await readYaml( path.join(root, "safe-settings/deployment-settings.yml"), ); - const excluded = deployment.restrictedRepos?.exclude; + const included = deployment.restrictedRepos?.include; ensure( - Array.isArray(excluded) && excluded.includes("governance-archieve"), - "Keep the archive excluded", + Array.isArray(included) && included.every((n) => repositoryName(n) === n), + "Explicitly include only repositories ready for settings management", ); + const peribolos = await readYaml(path.join(root, "peribolos.yml")); ensure( - excluded.every((n) => n === "governance-archieve" || repositoryName(n)), - "Use explicit exclusions", + Object.keys(peribolos.orgs || {}).join() === ORG && + Object.keys(peribolos.orgs[ORG]).join() === "teams", + "Peribolos manages only ANS teams; org settings and Owners stay in GitHub", ); const directory = path.join(root, "safe-settings/repos"); const repositories = Object.create(null); @@ -136,7 +103,8 @@ export async function configuration(root = ROOT) { settings, defaults, deployment, - excluded: new Set(excluded), + included: new Set(included), + peribolos, repositories, }; } diff --git a/scripts/github.mjs b/scripts/github.mjs index 1d27ad4..6008e58 100644 --- a/scripts/github.mjs +++ b/scripts/github.mjs @@ -25,20 +25,14 @@ export async function textFile(gh, repo, file, ref) { return Buffer.from(result.data.content, "base64").toString("utf8"); } export async function publicRepository(gh, name) { - return repository(gh, name, false); -} -export async function rosterRepository(gh, name) { - return repository(gh, name, name === "governance"); -} -async function repository(gh, name, allowPrivate) { repositoryName(name); const { data } = await gh.rest.repos.get({ owner: ORG, repo: name }); ensure( data.full_name.toLowerCase() === `${ORG}/${name}` && - (allowPrivate || !data.private) && + !data.private && !data.archived && !data.fork, - `${name}: must be ${allowPrivate ? "" : "public, "}active, non-forked, and owned by ANS`, + `${name}: must be public, active, non-forked, and owned by ANS`, ); return data; } diff --git a/scripts/manage-repository.mjs b/scripts/manage-repository.mjs index 46097a5..8340af4 100644 --- a/scripts/manage-repository.mjs +++ b/scripts/manage-repository.mjs @@ -1,5 +1,4 @@ // SPDX-License-Identifier: Apache-2.0 -// A small form adapter: read GitHub, then edit native Safe Settings YAML for a PR. import fs from "node:fs/promises"; import path from "node:path"; import { createHash } from "node:crypto"; @@ -13,7 +12,6 @@ import { TSC, BOOTSTRAP, access, - codeOwners, configuration, ensure, repositoryName, @@ -28,7 +26,6 @@ import { textFile, trustedWorkflow, } from "./github.mjs"; -import { roster } from "./rosters.mjs"; export function signoff(inputs) { ensure( @@ -92,19 +89,13 @@ export async function prepare(gh, config, inputs, actor) { const info = await publicRepository(gh, name); const value = structuredClone(config.repositories[name] || {}); const deployment = structuredClone(config.deployment); + const peribolos = structuredClone(config.peribolos); let observed = []; const pending = []; - let affected = [name]; if (inputs.operation === "Pause management") { - if (config.repositories[name]) { - const team = access(name, value).maintainers; - affected = Object.entries(config.repositories) - .filter(([n, c]) => access(n, c).maintainers === team) - .map(([n]) => n); - } - deployment.restrictedRepos.exclude = [ - ...new Set([...config.excluded, ...affected]), - ].sort(); + deployment.restrictedRepos.include = [...config.included].filter( + (repo) => repo !== name, + ); } else { const sha = await head(gh, name, info.default_branch); const existing = @@ -153,40 +144,7 @@ export async function prepare(gh, config, inputs, actor) { (bootstrapChoice === "Enable" || (bootstrapChoice === "Keep current" && (config.repositories[name] ? mapping.bootstrap : true))); - const includeTsc = - name !== REPO || - value.teams?.some((t) => t.name === TSC) || - catchall?.includes(`@${ORG}/${TSC}`); - try { - const people = await roster(gh, name, config.repositories); - if (people.source !== name) { - const shared = access( - people.source, - config.repositories[people.source], - ); - ensure( - mapping.maintainers === shared.maintainers, - "Shared rosters must use the same Maintainer team", - ); - ensure( - shared.reviewers || !people.reviewers.length, - "Configure the source repository's Reviewer team first", - ); - mapping.reviewers = shared.reviewers; - } else if ( - people.reviewers.length && - !mapping.reviewers && - ![REPO, "governance"].includes(name) - ) { - mapping.reviewers = - mapping.maintainers.replace(/-maintainers$/, "") + "-reviewers"; - } - if (includeTsc && name !== "governance") - await roster(gh, "governance", config.repositories); - if (mapping.bootstrap) await roster(gh, REPO, config.repositories); - } catch (error) { - pending.push(error.message); - } + const includeTsc = name !== REPO || catchall?.includes(`@${ORG}/${TSC}`); const previous = value.rulesets ?.find((r) => r.name === CHECKS) @@ -208,7 +166,6 @@ export async function prepare(gh, config, inputs, actor) { .filter((r) => r.type === "required_status_checks") .flatMap((r) => r.parameters.required_status_checks), ]) { - if (check.context === "DCO") continue; const current = required.get(check.context); ensure( current?.integration_id == null || @@ -232,16 +189,9 @@ export async function prepare(gh, config, inputs, actor) { ) : new Set(required.keys()); selected.add("DCO"); - value.teams = [ - ...new Set( - [ - mapping.maintainers, - mapping.reviewers, - ...(includeTsc ? [TSC] : []), - ...(mapping.bootstrap ? [BOOTSTRAP] : []), - ].filter(Boolean), - ), - ].map((team) => ({ name: team, permission: "push" })); + const queued = rules.some((rule) => rule.type === "merge_queue"); + if (!queued && !required.has("DCO")) + required.set("DCO", { context: "DCO", integration_id: 1861 }); const common = { target: "branch", enforcement: "active", @@ -259,9 +209,8 @@ export async function prepare(gh, config, inputs, actor) { { type: "required_status_checks", parameters: { - strict_required_status_checks_policy: true, + strict_required_status_checks_policy: !queued, required_status_checks: [...selected] - .filter((c) => c !== "DCO") .sort() .map((context) => required.get(context) || { context }), }, @@ -283,9 +232,34 @@ export async function prepare(gh, config, inputs, actor) { rules: [{ type: "update" }], }, ]; - const requiredOwners = codeOwners(name, value).map( - (team) => `@${ORG}/${team}`, - ); + const ownerTeams = [ + ...new Set([ + mapping.maintainers, + ...(includeTsc ? [TSC] : []), + ...(mapping.bootstrap ? [BOOTSTRAP] : []), + ]), + ]; + const requiredOwners = ownerTeams.map((team) => `@${ORG}/${team}`); + for (const slug of [ + ...new Set([ + ...ownerTeams, + ...(bootstrapChoice === "Remove" && name !== REPO ? [BOOTSTRAP] : []), + ]), + ]) { + const team = await optional(() => + gh.rest.teams.getByName({ org: ORG, team_slug: slug }), + ); + const desired = team && peribolos.orgs[ORG].teams[team.data.name]; + if (!desired) { + pending.push( + `Declare team ${slug} in peribolos.yml and apply its team setup first.`, + ); + continue; + } + desired.repos ||= {}; + if (ownerTeams.includes(slug)) desired.repos[name] = "write"; + else delete desired.repos[name]; + } if ( JSON.stringify([...(catchall?.slice(1) || [])].sort()) !== JSON.stringify([...requiredOwners].sort()) @@ -307,17 +281,17 @@ export async function prepare(gh, config, inputs, actor) { pending.push( "Run the selected checks on a representative PR before enrolling.", ); - deployment.restrictedRepos.exclude = [...config.excluded].filter( - (n) => n !== name, - ); + deployment.restrictedRepos.include = [ + ...new Set([...config.included, name]), + ].sort(); } const result = { name, value, deployment, + peribolos, observed, pending, - affected, operation: inputs.operation, }; result.report = `# ${name}\n\n${inputs.operation}.\n\n`; @@ -329,9 +303,6 @@ export async function prepare(gh, config, inputs, actor) { if (pending.length) result.report += "\nSetup needed:\n" + pending.map((p) => "- " + p).join("\n") + "\n"; - if (affected.length > 1) - result.report += - "\nShared-team repositories affected: " + affected.join(", ") + ".\n"; if (inputs.operation !== "Inspect repository") { ensure(!pending.length, result.report); result.signoff = signoff(inputs); @@ -388,7 +359,8 @@ async function main() { const changed = result.operation !== "Inspect repository" && (updateRepo || - JSON.stringify(config.deployment) !== JSON.stringify(result.deployment)); + JSON.stringify(config.deployment) !== JSON.stringify(result.deployment) || + JSON.stringify(config.peribolos) !== JSON.stringify(result.peribolos)); await output("changed", String(changed)); if (!changed) return; if (updateRepo) @@ -401,6 +373,8 @@ async function main() { path.join(ROOT, "safe-settings/deployment-settings.yml"), result.deployment, ); + if (JSON.stringify(config.peribolos) !== JSON.stringify(result.peribolos)) + await writeYaml(path.join(ROOT, "peribolos.yml"), result.peribolos); const title = `chore: configure ${result.name}`; await output("title", title); await output("branch", "codex/manage-" + result.name.replaceAll(".", "-")); @@ -412,7 +386,7 @@ async function main() { await fs.mkdir(path.join(ROOT, "reports"), { recursive: true }); await fs.writeFile( path.join(ROOT, "reports/request.md"), - `## Related issue\n\nFixes #${result.issue}\n\n## Summary\n\n${result.report}\nThe declared teams follow the reviewed repository rosters, including removals. Review this configuration change before merging.\n\n## Testing\n\nNative configuration validation runs in CI.\n\n## AI assistance\n\nNo AI is used by this deterministic workflow.\n`, + `## Related issue\n\nFixes #${result.issue}\n\n## Summary\n\n${result.report}\nTeam access is declared in peribolos.yml. Review this configuration change before merging.\n\n## Testing\n\nNative configuration validation runs in CI.\n\n## AI assistance\n\nNo AI is used by this deterministic workflow.\n`, ); } if ( diff --git a/scripts/rosters.mjs b/scripts/rosters.mjs deleted file mode 100644 index b691cdd..0000000 --- a/scripts/rosters.mjs +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -import { ensure, loginPattern } from "./config.mjs"; -import { - textFile, - publicRepository, - rosterRepository, - head, -} from "./github.mjs"; - -export function parseRoster(text, tsc = false) { - ensure( - text && !text.includes("