Skip to content

fix(ci): credit takeover authors and exempt stacked PR bases - #742

Merged
Wibias merged 3 commits into
lidge-jun:devfrom
Wibias:fix/takeover-changelog-and-stacked-prs
Jul 30, 2026
Merged

fix(ci): credit takeover authors and exempt stacked PR bases#742
Wibias merged 3 commits into
lidge-jun:devfrom
Wibias:fix/takeover-changelog-and-stacked-prs

Conversation

@Wibias

@Wibias Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Release notes: after generate-notes, rewrite maintainer-takeover changelog lines so the original PR author is credited (by @Original (takeover by @Landing) in …/pull/P), not only the landing maintainer.
  • Stacked PRs: if a PR’s base matches another open PR’s head ref/repo, treat it as stacked and skip wrong-base enforcement (no [WRONG BRANCH] / draft). Orphan non-dev bases stay enforced.
  • AGENTS.md: remove the retired dev2-go dual-track essay so agent guidance only carries current branch policy (dev / main / preview). The historical retirement record stays in MAINTAINERS.md and Contributing (all locales); those were left unchanged on purpose.

Test plan

  • bun test tests/release-notes.test.ts
  • bun test tests/ci-workflows.test.ts (includes stacked vs orphan base cases)
  • node --test .github/scripts/pr-quality.test.cjs
  • bun run typecheck

Summary by CodeRabbit

  • New Features

    • Stacked pull requests can now target an open parent pull request without triggering an incorrect target-branch failure.
    • Release notes now credit the original author when a maintainer takes over a pull request.
  • Documentation

    • Updated branch policy guidance to reflect the current development workflow and stacked pull request practices.
  • Bug Fixes

    • Improved release processing to apply takeover attribution consistently across preview and stable release notes.

Release notes attributed maintainer takeovers to the landing author only, and enforce-pr-target drafted stacked children that correctly targeted a parent head. Rewrite takeover credits to name the original creator, skip wrong-base for open stacked parents, and drop the retired dual-track essay from AGENTS.md so agent guidance stays current-policy only.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Wibias, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 3 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: dc5c97a9-5e08-4fb2-ae6a-3a21f5cd3f36

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7622d and fafbaf0.

📒 Files selected for processing (5)
  • .github/scripts/pr-quality.test.cjs
  • scripts/release-notes.ts
  • tests/ci-workflows.test.ts
  • tests/helpers/enforce-pr-target-harness.ts
  • tests/release-notes.test.ts
📝 Walkthrough

Walkthrough

This PR adds stacked-base exceptions to PR target enforcement and introduces release-note takeover-credit rewriting. It updates workflow permissions, test harnesses, CI assertions, branch-policy documentation, exported release-note helpers, and release creation integration.

Changes

Stacked PR enforcement

Layer / File(s) Summary
Stacked-base validation contract
.github/scripts/pr-quality.cjs, .github/scripts/pr-quality.test.cjs
collectPrQualityFailures accepts stackedBase, suppresses wrong_base and wrong_ancestry for stacked children, and preserves wrong-base reporting otherwise.
Open-parent detection and enforcement wiring
.github/workflows/enforce-pr-target.yml, tests/helpers/enforce-pr-target-harness.ts, tests/ci-workflows.test.ts, .github/scripts/enforce-pr-target.test.cjs
The workflow lists paginated open PRs, matches the current base to an open PR head in the same repository, passes stackedBase into validation, and tests stacked and non-stacked enforcement paths.
Stacked PR branch policy
AGENTS.md
Branch guidance now describes the single dev runtime line, stacked child PR targets, enforcement behavior, and rebase conventions.

Release takeover credits

Layer / File(s) Summary
Takeover credit parsing and rewriting
scripts/release-notes.ts, tests/release-notes.test.ts
Adds takeover source PR parsing, injected PR metadata lookups, conditional author-credit rewriting, and helper coverage for supported and unchanged cases.
Release workflow integration
.github/workflows/release.yml, tests/ci-workflows.test.ts
Grants pull request read access and conditionally runs credit-takeovers for non-empty carried and delta release-note files, with corresponding workflow assertions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: enhancement

Suggested reviewers: ingwannu, lidge-jun

Sequence Diagram(s)

Stacked PR target detection

sequenceDiagram
  participant EnforceTarget
  participant GitHubPullsAPI
  participant QualityValidation
  EnforceTarget->>GitHubPullsAPI: list open pull requests
  GitHubPullsAPI-->>EnforceTarget: return open PR heads
  EnforceTarget->>QualityValidation: pass stackedBase when base matches an open head
  QualityValidation-->>EnforceTarget: return quality failures
Loading

Release takeover-credit processing

sequenceDiagram
  participant ReleaseWorkflow
  participant CreditTakeovers
  participant GitHubAPI
  ReleaseWorkflow->>CreditTakeovers: process carried and delta notes
  CreditTakeovers->>GitHubAPI: resolve landing and source PR metadata
  GitHubAPI-->>CreditTakeovers: return authors and takeover details
  CreditTakeovers-->>ReleaseWorkflow: write rewritten release notes
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main CI changes: takeover author crediting and stacked PR base exemption.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Jul 30, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2324c8d086

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}) {
const failures = [];
const wrongBase = !allowedBases.includes(baseRef);
const wrongBase = !allowedBases.includes(baseRef) && !stackedBase;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve dev-only enforcement for stacked PRs

When stackedBase is true, this condition allows a PR targeting any non-allow-listed branch to pass the required target check, and the subsequent branch also skips ancestry enforcement. An open PR with a matching head therefore permits changes to be merged into a non-dev branch, contrary to the repository policy whose only stated exceptions are releases and maintainer promotions; retain wrong_base enforcement or obtain and document an explicit stacked-PR policy exception.

AGENTS.md reference: AGENTS.md:L132-L133

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the stacked exemption (intentional review workflow, not a second integration line). Documented it in AGENTS.md: open-parent-head children skip wrong-base; after the parent lands/closes, retarget to dev.

Also addressed the P2s in this push: pull-requests: read on the release workflow, fail-closed takeover lookups (404 on source PR still leaves the line unchanged), and credit-takeovers on both carried + delta notes.

Comment thread .github/workflows/release.yml Outdated
Comment on lines +396 to +399
bun scripts/release-notes.ts credit-takeovers \
--repo "$GITHUB_REPOSITORY" \
--in "$delta_file" \
--out "$delta_file"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Grant read access before querying pull requests

This new command calls GET /repos/{owner}/{repo}/pulls/{number}, but the workflow-level permissions at lines 32–35 grant only contents, actions, and id-token, so the GITHUB_TOKEN has no pull-requests: read permission. The pull-request lookups will be rejected, and because ghJson converts those errors to null, the release still succeeds with every takeover credit unchanged; add the least-privilege pull-requests: read permission and assert it in the workflow test.

Useful? React with 👍 / 👎.

Comment thread scripts/release-notes.ts Outdated
Comment on lines +427 to +429
if (exitCode !== 0) {
console.error(`gh api ${path} failed: ${stderr.trim() || `exit ${exitCode}`}`);
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail the release when takeover lookups fail

When GitHub returns a transient error, rate limit, permission error, or malformed response for either the landing or source PR, this path logs the error and returns null; the resolvers then retain the old attribution and the command exits successfully, after which the workflow publishes release notes it never edits. Propagate lookup and JSON errors as a nonzero exit so the release can be retried instead of silently publishing incorrect credits.

AGENTS.md reference: scripts/AGENTS.md:L14-L18

Useful? React with 👍 / 👎.

Comment thread .github/workflows/release.yml Outdated
printf '%s\n' "$pr_notes" | sed '/^\*\*Full Changelog\*\*:/d' > "$delta_file"
bun scripts/release-notes.ts credit-takeovers \
--repo "$GITHUB_REPOSITORY" \
--in "$delta_file" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Rewrite credits in carried preview notes

When a stable release carries a matching preview created before this helper was introduced, the takeover PR is excluded from the generated delta because notes_range_start advances to the preview tag. This invocation rewrites only delta_file, while the uncorrected carried_file goes directly into assemble, so the stable release still credits only the landing maintainer; run the rewrite over carried content or the final assembled notes as well.

Useful? React with 👍 / 👎.

Grant pull-requests:read for PR author lookups, fail closed on non-404 gh api errors, rewrite carried preview notes as well as the delta, and record the stacked-child wrong-base exemption in AGENTS.md.
@Wibias

Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Wibias

Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/pr-quality.test.cjs:
- Around line 258-265: Update the test fixture in the ancestry exemption case to
use the existing ancestry-failure values for behindBase and aheadMain instead of
zero, while keeping stackedBase enabled. Preserve the assertions that neither
wrong_base nor wrong_ancestry is reported so the test fails if the stackedBase
exemption is removed.

In `@scripts/release-notes.ts`:
- Around line 237-272: Update rewriteTakeoverCredits to pre-parse
match.groups.prefix with parseTakeoverSourcePr before calling resolveLanding.
When the title identifies a takeover, reuse that source PR and skip the network
lookup; otherwise fall back to resolveLanding for ambiguous or body-only
markers, preserving the existing author comparison and output behavior.
- Around line 450-487: Update the landing PR lookup callback in
rewriteTakeoverCredits to call ghJson with allowNotFound enabled, matching the
source PR lookup. Return null when the landing PR is missing so
rewriteTakeoverCredits can preserve the original line via its existing fallback,
while continuing to abort on other invalid lookup results; add a unit test
covering a null resolveLanding result if the test suite supports this flow.

In `@tests/helpers/enforce-pr-target-harness.ts`:
- Around line 555-559: Update tests/helpers/enforce-pr-target-harness.ts lines
555-559 to return the page-specific entry from an openPullPages fixture instead
of making every page after the first empty; update lines 92-96 to define and use
the openPullPages fixture type. In tests/ci-workflows.test.ts lines 1015-1043,
provide a full first page plus a matching parent on page two and assert that the
page-two parent remains exempt from wrong-base enforcement, ensuring pagination
is exercised.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 768a80a0-5c97-446e-a9b7-9b7a5c0566aa

📥 Commits

Reviewing files that changed from the base of the PR and between 0666b41 and 9c7622d.

📒 Files selected for processing (10)
  • .github/scripts/enforce-pr-target.test.cjs
  • .github/scripts/pr-quality.cjs
  • .github/scripts/pr-quality.test.cjs
  • .github/workflows/enforce-pr-target.yml
  • .github/workflows/release.yml
  • AGENTS.md
  • scripts/release-notes.ts
  • tests/ci-workflows.test.ts
  • tests/helpers/enforce-pr-target-harness.ts
  • tests/release-notes.test.ts

Comment thread .github/scripts/pr-quality.test.cjs
Comment thread scripts/release-notes.ts
Comment thread scripts/release-notes.ts
Comment thread tests/helpers/enforce-pr-target-harness.ts Outdated
…d PRs

Tighten stacked ancestry regression inputs, skip non-takeover gh lookups, tolerate missing landing PRs, and paginate open-PR fixtures so stacked parents beyond page one stay covered.
@Wibias

Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Wibias

Wibias commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

Merge ready

Head fafbaf07. Cross-platform CI (ubuntu/macos/windows + npm-global), issue-quality tests, React Doctor, and labeler are all green. No new actionable review comments after the follow-up push.

What landed

  • Takeover changelog credits — rewrite generate-notes lines to by @Original (takeover by @Landing); also rewrite carried preview notes; pull-requests: read on release; fail closed on non-404 gh api errors; skip network for ordinary non-takeover lines.
  • Stacked PR exception — open parent-head bases skip wrong-base (documented in AGENTS.md); pagination covered beyond page one.
  • AGENTS.md — dropped the retired dual-track essay; MAINTAINERS.md / Contributing keep the historical retirement record.

Review triage

  • Codex P1 (stacked vs dev-only): kept the exception; documented it.
  • Codex P2s: permissions, fail-closed lookups, carried-notes rewrite — fixed.
  • CodeRabbit: ancestry regression inputs, title prefilter, landing 404 tolerance, open-PR pagination — fixed.
  • Re-review after the last push was rate-limited / no new findings; Codex cloud review hit usage limits earlier.

Ready to merge into dev.

@Wibias
Wibias merged commit 45e9dc4 into lidge-jun:dev Jul 30, 2026
10 checks passed
@Wibias
Wibias deleted the fix/takeover-changelog-and-stacked-prs branch July 30, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant