Skip to content

feat(roadmap): the token of each phase asks only for its permissions #6780

Done

Description

@dan-petty

Problem

Each installation token of a roadmap Job asks for the one set CONST_GITHUB_APP_TOKEN_PERMISSIONS in src/devops_cli/config/constants.py: contents: write, issues: write, pull_requests: write and workflows: write, with others. ADR 0030 says: "Until #3700, one process mints one token for the three phases, so the token keeps workflows: write."

#3700 is live since 2026-11-22. prepare and publish now run in their own containers and mint their own tokens. prepare only reads: it clones and reads the item and the pull request. But its token can still write contents and workflow files.

Change

  • Give each phase a token with only the permissions that it uses. prepare gets read permissions.
  • publish asks for workflows: write only when the merged plan names a workflow file, which publish already checks.
  • Change ADR 0030 and the token documents to match.

Acceptance criteria

Dependencies

Source

Source: #3700

Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches found only GitHub Actions token actions and Python API clients that accept a permission map; none scopes this repository's prepare and publish tokens, tests them, or updates ADR 0030, so the change stays in-house.

Lacks:

  • No tool mints a read-only token for the prepare phase
  • No tool ties workflows: write to the merged plan's files
  • No tool rewrites ADR 0030 or the token documents
  • No tool adds the two permission tests the issue requires

Proposed design

Problem statement

The installation token of each roadmap Job asks for the one set CONST_GITHUB_APP_TOKEN_PERMISSIONS, which holds contents: write, issues: write, pull_requests: write and workflows: write. Since #3700 the prepare and publish phases run in their own containers and mint their own tokens. prepare writes issue status and marks, and it reads checks and Actions runs, but its token can still write contents and workflow files. The change gives each phase a token with only the permissions that it uses, and removes the Until #3700 sentence from ADR 0030.

Acceptance criteria

Requirement: Prepare token holds the permissions of the prepare phase

The installation token of each prepare phase SHALL request contents: read, pull_requests: read, issues: write, checks: read and actions: read, and SHALL NOT request workflows.

Scenario: Prepare phase token request

  • WHEN the test builds the token request of the prepare phase with a fake GitHub client
  • THEN the requested permissions equal contents: read, pull_requests: read, issues: write, checks: read and actions: read, and hold no workflows key.

Requirement: Publish token omits workflows write for a plan with no workflow file

The publish phase SHALL NOT request workflows: write when the merged plan names no workflow file.

Scenario: Publish token for a plan with no workflow file

  • WHEN the test builds the token request of publish for a merged plan that names no file under .github/workflows/
  • THEN the requested permissions hold no workflows key, and contents and pull_requests stay write.

Requirement: Publish token asks workflows write for a workflow file

The publish phase MUST request workflows: write when the merged plan names a workflow file.

Scenario: Publish token for a plan with a workflow file

  • WHEN the test builds the token request of publish for a merged plan that names .github/workflows/ci.yml
  • THEN the requested permissions hold workflows: write.

Requirement: ADR 0030 has no deferred token sentence

ADR 0030 SHALL hold no Until #3700 sentence about the token.

Scenario: ADR 0030 text

  • WHEN rg -n 'Until #3700' docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md runs
  • THEN it prints no match.

Existing Tool Considered

The alternatives check of 2026-11-23 in the issue body gives the verdict none with Tool: none found, and the Lacks: list of that block holds the reasons; the change covers each reason in-house. Cost to build: about 2 500 tokens of edits (one map for prepare, one builder for publish, two call sites, two tests and the ADR text) and about 30 minutes of review. Cost to keep: low, because a permission map changes only when a phase changes the GitHub calls that it makes.

Key questions

  • Which permissions does the prepare phase request?: The permissions that the phase uses: contents: read to clone, pull_requests: read to read the pull request, issues: write to write the status, the marks and the stage records, and checks: read and actions: read to read the check runs and the Actions runs. The set holds no workflows key. The implement, stage, fix-checks and fix-conflict prepare phases share this one map, because each makes the same calls. (best practice) [sources: src/devops_cli/config/constants.py:1628, src/devops_cli/roadmap/implement/implement_phases.py:309, src/devops_cli/roadmap/stores/github_store.py:1087, src/devops_cli/roadmap/stage/stage_job_phases.py:387, src/devops_cli/roadmap/steps/fix_checks_phases.py:301]
    • Chosen: Read for contents, pull requests, checks and actions, and write for issues. It covers the clone, the two reads and the issue writes that each prepare phase makes, and it removes contents: write and workflows: write.
    • Rejected: Read-only set with no write permission. The prepare phase calls write_status, set_marks, StageWriter.begin, settle and judge_round, so a read-only token fails at the first issue write.
    • Rejected: Keep the one shared write set. It keeps contents: write and workflows: write in a phase that uses neither.
  • How does publish decide to ask for workflows: write?: The token request takes the flag that publish already computes from the merged plan's file list. The flag is true only when the plan names a path under .github/workflows/, and the permission builder adds workflows: write only then. (best practice) [sources: src/devops_cli/github/app_installation.py, tests/roadmap/phases/test_roadmap_phase_publish.py]
    • Chosen: Reuse the merged-plan check that publish runs. The phase reads the merged plan already, so one boolean drives the token request and no second scan is needed.
    • Rejected: Read the plan a second time in the token helper. It puts the same check in two modules, and the two can disagree.
    • Rejected: Always request workflows: write. It keeps the over-broad grant that the issue removes.
  • Where do the per-phase permission maps live?: In src/devops_cli/config/constants.py, beside CONST_GITHUB_APP_TOKEN_PERMISSIONS: one map for prepare and one builder for publish that adds workflows: write when its flag is true. src/devops_cli/github/app_installation.py takes the map as a parameter. (best practice) [sources: src/devops_cli/config/constants.py:1628, src/devops_cli/github/app_installation.py]
    • Chosen: One constant for each phase in constants.py. The maps are constants of the CLI, and the existing constant already lives there with its caller.
    • Rejected: Build each map at the call site. It puts the same permission names in several modules.
    • Rejected: A settings key for the permissions. It makes a security boundary configurable and adds a surface to test.
  • Which callers use CONST_GITHUB_APP_TOKEN_PERMISSIONS?: One production caller, src/devops_cli/github/app_installation.py, and the constant module itself. [sources: src/devops_cli/config/constants.py:1628, src/devops_cli/github/app_installation.py]
  • Does ADR 0030 need a body-hash update?: No. ADR 0030 is proposed, and docs/adr/README.md:30 sets body-hash only on accepted records. The change updates the text of ADR 0030 and leaves its frontmatter unchanged. [sources: docs/adr/README.md:30, docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6691

Activity

  1. added
    type/feature
    source/agent
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 22, 2026
  2. dan-petty commented on Nov 22, 2026

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 22, 2026
  4. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • Python library mint GitHub App installation token with subset of permissions, results: 5
    • create-github-app-token action specify permissions per step, results: 5
    • actions/create-github-app-token permission-contents input, results: 5
    • PyGithub installation token permissions parameter create installation access token, results: 5
    • create-github-app-token, results: 5
    • github app token least privilege permissions per job, results: 5
    • githubkit create installation token permissions, results: 5
    • GitHub App installation access token restrict permissions API, results: 5
    • installation access token github app, results: 5
    • GitHub App token minting library, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 23, 2026
  6. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. dan-petty commented on Nov 25, 2026

    @dan-petty
    OwnerAuthor

    This issue cannot be built as written on origin/main (3734bc156). Its acceptance criterion and design require a prepare installation token with read permissions only (contents: read, issues: read, pull_requests: read, and no write value). Every prepare phase on main writes to GitHub issues and reads Actions/Checks: prepare_implement calls write_status, set_marks, report.yield_to, and report.stop (src/devops_cli/roadmap/implement/implement_phases.py:309,347,369,378; src/devops_cli/roadmap/stores/github_store.py:1087); prepare_stage_job calls StageWriter.begin, settle, finish_stage_job, and job_time_decision (src/devops_cli/roadmap/stage/stage_job_phases.py:387,394,396; src/devops_cli/roadmap/stage/stage.py:3034); fix-checks prepare_phase calls judge_round (src/devops_cli/roadmap/steps/fix_checks_phases.py:301); and fix-conflict prepare records attempt rounds. Also docs/adr/0030-roadmap-steps-run-their-agent-apart-from-the-app-key.md has status: proposed, and docs/adr/README.md:30 sets body-hash only on accepted records. Please refine the permission sets to keep issues: write, checks: read, and actions: read where prepare uses them, and remove the body-hash requirement while ADR 0030 is proposed.

  8. added
    status/new
    and removed
    status/ready
    on Nov 25, 2026
  9. added
    status/ready
    and removed
    status/new
    on Nov 25, 2026
  10. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  11. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 25, 2026
  12. removed
    status/in-review
    owner/agent
    on Nov 25, 2026
  13. devops-cli-service commented on Nov 25, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-25 17:09 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions