Skip to content

Mint the merge-master token with pull_requests: write only — the App holds no issues permission - #781

Merged
brettheap merged 1 commit into
mainfrom
fix/merge-master-mint-scope-pull-requests-only
Sep 8, 2026
Merged

brettheap merged 1 commit into
mainfrom
fix/merge-master-mint-scope-pull-requests-only

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Lane: openxfactory-4-opendox-extraction (formerly openxfactory-opendox)

The defect

.github/workflows/merge-master-approval.yml minted the merge-master App
token with BOTH permission-pull-requests: write AND
permission-issues: write. The merge-master identity is the codeXfactory
GitHub App (App ID 4312542), installed on opensoft as installation
159938946. That installation's live permission set is exactly:

$ gh api orgs/opensoft/installations --jq '.installations[]|select(.app_id==4312542)|.permissions'
{"checks":"write","contents":"write","metadata":"read","pull_requests":"write"}

No issues permission at all. Requesting permission-issues: write on the
mint does not merely ask for an unused scope — actions/create-github-app-token
refuses the mint outright ("requested permission not granted") when a
requested permission is not held by the installation, failing the whole
approval lane at the mint step before any review or comment is attempted.

permission-issues: write was added by PR #735's verify-and-fix round on the
belief that posting the sticky comment via
POST/PATCH /repos/{o}/{r}/issues/{n}/comments requires an issues
permission. It does not: GitHub accepts EITHER Issues: write OR
Pull requests: write for issue-comment endpoints on a pull request, even
though the endpoint path is /issues/.... xFactory's production
merge-master-approval.yml proves this live — it mints with
permission-pull-requests: write only (no permission-issues) and posts its
own sticky comment through the identical /issues/{n}/comments endpoint:

$ gh api repos/opensoft/xFactory/contents/.github/workflows/merge-master-approval.yml --jq '.content' | base64 -d | sed -n '746,763p'
        uses: actions/create-github-app-token@v2
        ...
          permission-pull-requests: write

codexFactory's merge-master-approval spec is explicit on this too: "The
runtime installation token SHALL request only pull_requests: write and
mandatory Metadata read, scoped to the xFactory repository"
(opensoft/codexFactory:openspec/specs/merge-master-approval/spec.md).

Fix

  1. Removed permission-issues: write from the mint step; kept
    permission-pull-requests: write.
  2. Corrected the three comment blocks (top-of-file grant summary, the
    permissions: block header, and the mint step's own "PER-MINT NARROWING"
    comment) that claimed both scopes are needed — they now state that
    pull-requests: write alone covers the review AND the sticky comment
    (GitHub accepts either permission on the issue-comments endpoint), and
    that the App holds no issues permission by design.
  3. Narrowed tests/review_lane_pin/test_review_lane_caller.py's mint-scope
    test back to asserting exactly permission-pull-requests: write, with an
    explicit assertNotIn("permission-issues", ...) and nothing wider
    (contents/administration/actions/workflows still refused). Docstring
    cites the live installation's permission set as the reason.

Nothing else changed — no envelope change, no other workflow.

Proof

  • actionlint .github/workflows/merge-master-approval.yml — clean, exit 0.
  • python3 -m pytest -q tests/review_lane_pin — 156 passed, 2 skipped, 48 subtests passed.
  • Mutation: re-adding permission-issues: write to the mint step reds
    test_the_app_token_mint_is_scoped_to_pull_requests_only with
    AssertionError: 'permission-issues' unexpectedly found in {...};
    reverting restores green. Confirmed locally before this push.

Refs #656

Awaiting Brett's word before this merges — no auto-merge, no ruleset touch,
no merge performed by this lane.

🤖 Generated with Claude Code

https://claude.ai/code/session_013zUwKfdNgAyNuUAUs3WTDU

The codeXfactory App (App ID 4312542, installation 159938946 on
opensoft) holds exactly `checks: write, contents: write, metadata:
read, pull_requests: write` — no `issues` permission at all. PR #735's
verify-and-fix round added `permission-issues: write` to the mint step
in `.github/workflows/merge-master-approval.yml` on the belief that
posting the sticky comment through the Issues Comments API needs an
`issues` scope; GitHub accepts EITHER `issues: write` OR
`pull_requests: write` on that endpoint when the target is a pull
request, so the extra scope was never needed, and requesting a
permission the installation does not grant makes
`create-github-app-token` refuse the mint outright rather than merely
omit an unused scope. xFactory's production
`merge-master-approval.yml` mints with `permission-pull-requests:
write` only and posts its own sticky comment through the same
endpoint. codexFactory's `merge-master-approval` spec requires the
runtime installation token request "only `pull_requests: write` and
mandatory Metadata read".

Remove `permission-issues: write` from the mint step, correct the
three comment blocks that claimed both scopes, and narrow
`tests/review_lane_pin/test_review_lane_caller.py`'s mint-scope test
back to asserting `pull-requests: write` alone with nothing wider
(`permission-issues` included).

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_013zUwKfdNgAyNuUAUs3WTDU
Copilot AI lite review requested due to automatic review settings September 8, 2026 04:08

@sourcery-ai sourcery-ai 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.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

Copilot AI 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.

🟢 Approval recommended

The changes are narrowly scoped to removing an invalid requested permission and updating the corresponding assertions/documentation, with no remaining workflow scope mismatches observed.

Pull request overview

This PR fixes the merge-master-approval lane’s GitHub App token minting so it no longer requests issues: write, aligning the requested scopes with the merge-master App installation’s actual permissions and preventing token-mint failure.

Changes:

  • Removed permission-issues: write from the actions/create-github-app-token@v2 mint step, leaving permission-pull-requests: write only.
  • Updated workflow commentary to reflect that PR sticky comments can be posted via the issues-comments endpoint using pull_requests: write (without issues: write).
  • Updated the review-lane pinning test to assert permission-issues is not requested and to document why.
File summaries
File Description
.github/workflows/merge-master-approval.yml Removes permission-issues from the App token mint and updates explanatory comments to match the installation’s permission set.
tests/review_lane_pin/test_review_lane_caller.py Tightens the mint-scope assertion to require only permission-pull-requests: write and explicitly forbid permission-issues.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@brettheap
brettheap merged commit 450bb60 into main Sep 8, 2026
10 checks passed
brettheap added a commit that referenced this pull request Sep 9, 2026
…1/5.2 ticked on the D-2 evidence) (#832)

Path A PR-5, the last of the 2026-09-06 plan memo's sequence, on Brett Heap's word "merge pr-5 when green" (2026-09-09). Authority: his ruling of 2026-09-05T23:38Z "rule path A, 4.5 is a deferred successor" (#656) and ruling D-2 (the live exercise).

- tasks.md: § 4.4 / § 5.1 / § 5.2 ticked on the D-2 evidence (three `- [ ]` heads removed, every ratified sentence kept byte-identical); § 4.5 untouched as a DEFERRED SUCCESSOR (#714 → 3d1b8cc).
- Archived WITH promotion via `scripts/proposal-support.py . archive --date 2026-09-09` under the pinned @fission-ai/[email protected] (never a bare `openspec archive`); origin retained (declaration unchanged since da1b0e9); six frozen files R100.
- Promoted: `openspec/specs/ideation-intent-plane/spec.md` NEW (7 requirements / 11 scenarios, every block byte-identical to the archived delta) and `openspec/specs/document-lifecycle/spec.md` 18 → 19 requirements ("Gates happen on main"); the new capability's `## Purpose` written by this act (no SHALL; replaces the CLI's TBD stub). openspec/specs 60 → 61; floor regeneration OWED (GRACED covered-pending 1, `created_by_candidate`), `contracts/review-lane-floor-snapshot.yaml` deliberately not edited here.
- README OpenSpec Records row → archived; sweep-ledger row re-seeded with the tool (`--seed-ledger --moved-by '#832'`, one line moved); no thirteenth archive-date disposition.
- Evidence (merged + green): #718 d179cc0, #727 07624d5, #735 6d3237e, xFactory #304 b2db7e47, #313 ddd19650, #345 90435875, #781 450bb60, #808 2ef7d8c, #814 c991c0f, #816 8924230, xFactory #362 119280a8, #830 202c170, xFactory #369 c2313277; D-2 live exercise: act B refusal 36d07ec, act A apply e970dfe, first autonomous merge #176 → 7681e40 (codexfactory[bot] APPROVED 2026-09-09T06:37:22Z).
- Copilot round 1: one factual finding taken (a missing "where" in Purpose); two wording findings answered and resolved.

Refs #656 (stays OPEN). Rule 6 LANDING window observed.

Lane: openxfactory-4-opendox-extraction
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_012LiNG5Ume1boEfxSNeCmpu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants