-
Notifications
You must be signed in to change notification settings - Fork 1
[SUPERSEDED by #899] Establish autonomous repository governance and delivery state #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: PR Governance | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, edited, reopened, synchronize, ready_for_review] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: read | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: pr-governance-${{ github.event.pull_request.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| policy: | ||
| name: Canonical issue and evidence | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate delivery contract | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const pr = context.payload.pull_request; | ||
| if (pr.draft) { | ||
| core.notice("Draft PR: governance enforcement begins when marked ready."); | ||
| return; | ||
| } | ||
|
|
||
| const body = pr.body || ""; | ||
| const requiredSections = [ | ||
| "## Canonical issue", | ||
| "## Outcome", | ||
| "## Risk", | ||
| "## Verification", | ||
| "## Production evidence" | ||
| ]; | ||
| const missing = requiredSections.filter(section => !body.includes(section)); | ||
|
|
||
| const closingPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; | ||
| const issueNumbers = [...body.matchAll(closingPattern)].map(match => Number(match[1])); | ||
| const canonicalIssues = [...new Set(issueNumbers)]; | ||
|
|
||
| if (canonicalIssues.length !== 1) { | ||
| missing.push("exactly one closing reference: Closes #<issue>"); | ||
| } | ||
|
|
||
| if (canonicalIssues.length === 1) { | ||
| const canonical = canonicalIssues[0]; | ||
| const pulls = await github.paginate(github.rest.pulls.list, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: "open", | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const competing = pulls.filter(candidate => { | ||
| if (candidate.number === pr.number) return false; | ||
| const matches = [...(candidate.body || "").matchAll(closingPattern)] | ||
| .map(match => Number(match[1])); | ||
| return matches.includes(canonical); | ||
| }); | ||
|
|
||
| if (competing.length) { | ||
| const links = competing.map(candidate => `#${candidate.number}`).join(", "); | ||
| core.setFailed( | ||
| `Issue #${canonical} already has another open implementation PR: ${links}. ` + | ||
| "Supersede, close, or explicitly consolidate it before this PR becomes canonical." | ||
| ); | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| if (missing.length) { | ||
| core.setFailed(`PR delivery contract is incomplete: ${missing.join("; ")}`); | ||
| return; | ||
| } | ||
|
|
||
| core.notice("PR has one canonical issue and the required delivery evidence sections."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: Repository Reconciliation | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 13 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: read | ||
|
|
||
| concurrency: | ||
| group: repository-reconciliation | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| report: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Reconcile canonical delivery state | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const now = Date.now(); | ||
| const staleAfterMs = 14 * 24 * 60 * 60 * 1000; | ||
| const closingPattern = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; | ||
|
|
||
| const pulls = await github.paginate(github.rest.pulls.list, { | ||
| owner, repo, state: "open", per_page: 100 | ||
| }); | ||
| const branches = await github.paginate(github.rest.repos.listBranches, { | ||
| owner, repo, protected: false, per_page: 100 | ||
| }); | ||
| const activeHeads = new Set(pulls.map(pr => pr.head.ref)); | ||
|
|
||
| const untracked = []; | ||
| const issueToPulls = new Map(); | ||
| for (const pr of pulls) { | ||
| const issues = [...(pr.body || "").matchAll(closingPattern)] | ||
| .map(match => Number(match[1])); | ||
| const unique = [...new Set(issues)]; | ||
| if (unique.length !== 1) untracked.push(pr); | ||
| for (const issue of unique) { | ||
| const existing = issueToPulls.get(issue) || []; | ||
| existing.push(pr.number); | ||
| issueToPulls.set(issue, existing); | ||
| } | ||
| } | ||
|
|
||
| const duplicates = [...issueToPulls.entries()] | ||
| .filter(([, numbers]) => numbers.length > 1); | ||
|
|
||
| const staleBranches = []; | ||
| for (const branch of branches) { | ||
| if (branch.name === "main" || activeHeads.has(branch.name)) continue; | ||
| const commit = await github.rest.repos.getCommit({ | ||
| owner, repo, ref: branch.commit.sha | ||
| }); | ||
| const date = commit.data.commit.committer?.date || commit.data.commit.author?.date; | ||
| if (date && now - new Date(date).getTime() > staleAfterMs) { | ||
| staleBranches.push({ name: branch.name, date, sha: branch.commit.sha.slice(0, 8) }); | ||
| } | ||
| } | ||
|
|
||
| const lines = [ | ||
| "## Canonical delivery-state reconciliation", | ||
| "", | ||
| `Generated: ${new Date().toISOString()}`, | ||
| "", | ||
| `- Open PRs: **${pulls.length}**`, | ||
| `- Remote branches: **${branches.length}**`, | ||
| `- Ready PRs without exactly one canonical issue: **${untracked.length}**`, | ||
| `- Issues with competing implementation PRs: **${duplicates.length}**`, | ||
| `- Unattached branches older than 14 days: **${staleBranches.length}**`, | ||
| "", | ||
| "### PRs requiring canonical issue", | ||
| untracked.length | ||
| ? untracked.map(pr => `- #${pr.number} — ${pr.title}`).join("\n") | ||
| : "- None", | ||
| "", | ||
| "### Competing PRs", | ||
| duplicates.length | ||
| ? duplicates.map(([issue, numbers]) => `- Issue #${issue}: ${numbers.map(n => `#${n}`).join(", ")}`).join("\n") | ||
| : "- None", | ||
| "", | ||
| "### Stale unattached branches", | ||
| staleBranches.length | ||
| ? staleBranches.slice(0, 100).map(branch => | ||
| `- \`${branch.name}\` — ${branch.sha}, last commit ${branch.date}` | ||
| ).join("\n") | ||
| : "- None", | ||
| "", | ||
| "> This report is intentionally non-destructive. Branch deletion requires a merged PR or an explicit retention decision.", | ||
| "", | ||
| "Canonical governance: #898" | ||
| ]; | ||
|
|
||
| const title = "[automation] Repository drift report"; | ||
| const query = `repo:${owner}/${repo} is:issue is:open in:title "${title}"`; | ||
| const existing = await github.rest.search.issuesAndPullRequests({ | ||
| q: query, per_page: 10 | ||
| }); | ||
| const report = existing.data.items.find(item => item.title === title); | ||
| const body = lines.join("\n"); | ||
|
|
||
| if (report) { | ||
| await github.rest.issues.update({ | ||
| owner, repo, issue_number: report.number, body | ||
| }); | ||
| } else { | ||
| await github.rest.issues.create({ owner, repo, title, body }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| { | ||
| "framework": "nextjs", | ||
| "installCommand": "cd ../.. && npm install --legacy-peer-deps", | ||
| "ignoreCommand": "bash ../../scripts/deployment/vercel-ignore-command.sh", | ||
| "buildCommand": "npm run build", | ||
| "outputDirectory": ".next" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Vercel ignored-build command semantics: | ||
| # - exit 0 => skip build | ||
| # - exit 1 => continue build | ||
| # | ||
| # We skip only when the diff is strictly docs/workflow metadata. | ||
|
|
||
| head_sha="${VERCEL_GIT_COMMIT_SHA:-}" | ||
| base_sha="${VERCEL_GIT_PREVIOUS_SHA:-}" | ||
|
|
||
| if [[ -z "${head_sha}" || -z "${base_sha}" ]]; then | ||
| echo "preview-ignore: missing commit context; running build" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git cat-file -e "${head_sha}^{commit}" 2>/dev/null; then | ||
| echo "preview-ignore: head commit not available locally; running build" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git cat-file -e "${base_sha}^{commit}" 2>/dev/null; then | ||
| echo "preview-ignore: base commit not available locally; running build" | ||
| exit 1 | ||
| fi | ||
|
|
||
| mapfile -t changed < <(git diff --name-only "${base_sha}" "${head_sha}") | ||
| if [[ ${#changed[@]} -eq 0 ]]; then | ||
| echo "preview-ignore: no changed files detected; running build" | ||
| exit 1 | ||
| fi | ||
|
|
||
| for path in "${changed[@]}"; do | ||
| if [[ "${path}" == docs/* ]]; then | ||
| continue | ||
| fi | ||
| if [[ "${path}" == .github/workflows/* ]]; then | ||
| continue | ||
| fi | ||
| if [[ "${path}" == .github/ISSUE_TEMPLATE/* ]]; then | ||
| continue | ||
| fi | ||
| if [[ "${path}" == .github/pull_request_template.md ]]; then | ||
| continue | ||
| fi | ||
| if [[ "${path}" == *.md ]]; then | ||
| continue | ||
| fi | ||
|
|
||
| echo "preview-ignore: app-impacting change detected (${path}); running build" | ||
| exit 1 | ||
| done | ||
|
|
||
| echo "preview-ignore: docs/workflow-only change; skipping preview build" | ||
| exit 0 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
.vercelignoreexcludes the entirescripts/directory, so theignoreCommandscript referenced inapps/web/vercel.jsonis removed during clone and the build fails with "No such file or directory".