Skip to content

feat(roadmap): each roadmap Job gets its keys and a scoped token #5498

Done

Description

@dan-petty

Problem or Motivation

The approved pipeline split design (tracker #5482) applies least privilege to each roadmap job. Each job gets only the Secret keys and the token permissions of its row, and a template test keeps it so. Today no table states which keys and which permissions each job needs. The suspended CronJob templates and the Job builder of src/devops_cli/k8s/cluster_job.py give each Job the same keys.

Proposed Solution & Architectural Design

  • Add a permission table in code: for each job, its Secret keys and its token permissions. Examples: stage needs contents, pull_requests and issues write; research needs issues write; fix-plan needs contents and pull_requests write.
  • Each unit mints its installation access token with POST /app/installations/{id}/access_tokens and the permissions and repositories fields of its row.
  • The templates use secretKeyRef for only the keys of their job, in place of envFrom of the whole Secret.
  • A template test reads each roadmap Job template. It fails when a template loads a key that is not in the list of its job.
  • Apply the table to the templates of k8s/devops/cronjob-runner.yaml and of the devops-cli CronJob. feat(roadmap): add the stage Job template and one-item entry point #5483 gives the stage template its 3 keys; the table states the same 3 keys for stage.
  • The App permissions do not change (D8: O2 is deferred). The split of the model container comes later (feat(roadmap): the model container of a unit holds no credential #5506).

Target Subsystem

Roadmap Service and roadmap jobs (src/devops_cli/k8s/cluster_job.py, src/devops_cli/github/, k8s/devops/).

Acceptance Criteria

  • Test first: the template test fails on the base runner template. The test fails on the base.
  • A test: the mint request sends the permissions and the repository of the row (fake GitHub).
  • A test: a job with no row gets no access token and stops with a typed error.
  • Live proof: after the merge and the release, a runner Job of the implement job and a manual Job made from the runner template run as the App on live items with their key lists. A comment on this issue gives their result lines and the permissions of each minted access token, with no token value.

Existing Tool Considered

GitHub App installation access tokens with permissions and repositories (standard API), Kubernetes secretKeyRef and gidgethub cover the need. No new dependency. Build: 150,000 to 300,000 agent tokens and 0.5 to 1 day.

Related

Tracker #5482, Phase 1. #5483 (the stage keys). #5506 (Phase 4). #2473 (closed) limits the installation access tokens to the permissions of all roadmap jobs together; this item limits them for each job. #3700 (two-container runner Job). SECURITY.md.

Source: #5482

Alternatives check of 2026-11-23: in-use.
The repository already uses this tool.
Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub), Apache-2.0, last activity 2026-11-20, maintained.
Reason: Searches returned nothing on point beyond the repository facts; gidgethub is already the project's GitHub client and can mint a scoped installation token, but the table, templates and tests must be built in project code.

Covers:

  • Installation access token request with permissions and repositories fields
  • Existing GitHub App client, no new dependency
  • App authentication already used by roadmap jobs

Lacks:

  • Per-job table of Secret keys and token permissions
  • secretKeyRef templates in place of envFrom of the whole Secret
  • Template test that fails on an unlisted Secret key
  • Typed error when a job has no permission row

Proposed design

Problem statement

Roadmap jobs mint installation tokens with permission sets that follow the purpose of a call, not the job. Each ServiceRow needs only its own permissions. This issue adds a per-ServiceRow token permission table, makes each mint use the row of its job, and stops a job with no row with a typed error. The runner and stage templates already load only their own Secret keys (#6518, #5483, #3700), so this issue changes no template. The App permissions do not change.

Acceptance criteria

Requirement: Per-row token permission table

The GitHub token module SHALL hold one permission row for each ServiceRow, and the stage row SHALL name contents, pull_requests and issues at write.

Scenario: Table covers each row

  • WHEN uv run pytest tests/github/test_job_token_permissions.py runs.
  • THEN The test passes and asserts a row for each member of ServiceRow and the three write permissions of the stage row.

Requirement: Scoped installation token

Each roadmap job SHALL mint its installation access token with the permissions and the repository of its ServiceRow.

Scenario: Stage mint uses its row

  • WHEN uv run pytest tests/github/test_job_token_permissions.py runs the stage case with the fake GitHub.
  • THEN The fake records a POST /app/installations/{id}/access_tokens request whose permissions equal the stage row and whose repositories field holds only the repository of the stage job.

Requirement: Missing permission row

A job with no permission row MUST stop with a typed error and send no token request.

Scenario: Unknown row stops

  • WHEN uv run pytest tests/github/test_job_token_permissions.py runs the unknown-row case.
  • THEN The test passes and asserts the GitHub App error with the row name and no token request in the fake GitHub.

Requirement: The row is required

The installation token function MUST take the ServiceRow as a required argument.

Scenario: A call with no row fails

  • WHEN uv run pytest tests/github/test_job_token_permissions.py runs the no-row case.
  • THEN The test passes and asserts a TypeError with no token request in the fake GitHub.

Existing Tool Considered

The alternatives check in the issue body records gidgethub (Apache-2.0, maintained) as in-use. It covers the scoped installation-token request. The proposal builds the per-row table, the required row argument and the typed error in project code, and adds no dependency. The Secret-key templates and their gate checks are already delivered by #6518, #5483 and #3700, so this issue changes no template. The issue estimates 150,000 to 300,000 agent tokens and 0.5 to 1 day.

Key questions

  • Do the runner and stage Job templates already load only their own Secret keys?: Yes. k8s/devops/cronjob-runner.yaml loads DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY in prepare and publish and DEVOPS_CLI_AI_API_KEY in agent through secretKeyRef, with no envFrom. k8s/devops/cronjob-stage.yaml loads the same 2 keys. tests/gate/k8s_checks/runner.py and tests/gate/k8s_checks/stage_job.py assert both. [sources: k8s/devops/cronjob-runner.yaml, k8s/devops/cronjob-stage.yaml, tests/gate/k8s_checks/runner.py, tests/gate/k8s_checks/stage_job.py]
  • Does the devops-cli CronJob template serve one ServiceRow?: No. k8s/devops/cronjob.yaml is the default template of devops k8s run-job and loads the whole Secret with envFrom for any command. It has no ServiceRow, so this issue does not change it. [sources: k8s/devops/cronjob.yaml, src/devops_cli/k8s/cluster_job.py]
  • Does tests/k8s/test_cluster_secret_key_refs.py test the per-row rules?: No. It tests devops_cli.k8s.cluster_secrets.check_secret_key_refs, which matches secretKeyRef keys against the Secret generator table. It tests no per-row rule. [sources: tests/k8s/test_cluster_secret_key_refs.py, src/devops_cli/k8s/cluster_secrets.py]
  • Where does the per-row token permission table live?: In src/devops_cli/github/app_installation.py, next to CONST_GITHUB_APP_TOKEN_PERMISSIONS and the metrics and read sets. The module already holds the permission sets and the mint. (best practice) [sources: src/devops_cli/github/app_installation.py:67, src/devops_cli/github/app_installation.py:108, src/devops_cli/github/app_token.py:88]
    • Chosen: Add the table to src/devops_cli/github/app_installation.py. The module holds the permission sets and the mint, so the table stays with its only reader.
    • Rejected: Add a new module under src/devops_cli/roadmap/. Only the mint reads the table now, so a second module adds a path with one caller.
    • Rejected: Add the table to src/devops_cli/config/constants.py. The constants module holds scalars and tuples, and the table pairs a ServiceRow with a record.
  • How does the mint learn the ServiceRow of its job?: The caller passes the ServiceRow to the token function. The command knows its job, and the pod reads no Kubernetes label. (best practice) [sources: src/devops_cli/k8s/cluster_job.py, CONTEXT.md]
    • Chosen: The caller passes the row. The command knows the job it runs, and no new setting is needed.
    • Rejected: Read the component label of the pod. The pod has no Kubernetes token, so the code cannot read its own labels.
    • Rejected: Read an environment value that the Job builder sets. It adds a setting that the admission policy must pin.
  • Which token permissions does each row get?: The stage row gets contents, pull_requests and issues at write. The research row gets issues at write. The fix-plan row gets contents and pull_requests at write. Each other row gets only the permissions that its code calls. (best practice) [sources: src/devops_cli/github/app_installation.py:67, src/devops_cli/github/app_installation.py:108, src/devops_cli/github/app_token.py:88]
  • What does a job with no permission row do?: It raises the GitHub App error that the token module raises today, names the row, and sends no request. (best practice) [sources: src/devops_cli/github/app_installation.py, tests/github/test_github_errors.py, src/devops_cli/k8s/cluster_job.py]
    • Chosen: Raise the existing GitHub App error of the token module. The module already raises it for a refused request, and no new type is needed.
    • Rejected: Add a new exception class. It adds a type that no caller catches and the issue does not need.
    • Rejected: Raise ClusterJobError. It is the k8s template error, and the mint is no k8s module.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#7075, #7076

Activity

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

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found no tool or library that supplies a per-job permission/key table, per-job Secret key scoping or a template test that checks a Job template's keys — those stay project code. The one relevant tool the project already uses, gidgethub (the GitHub transport of ADR 0006), covers only the minting request: it can POST /app/installations/{id}/access_tokens with the permissions and repositories body of a row, and it needs no new dependency.

    The repository already uses this tool.

    Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub)

    • License: Apache-2.0
    • Last activity: 2026-09-25
    • Maintained: yes

    Covers:

    • Sends the installation access token request (POST /app/installations/{id}/access_tokens) from the Python code that builds each Job, so the permissions and repositories fields of a job's row can be put in the request body
    • Is the project's existing GitHub transport (ADR 0006), so the scoped mint needs no new dependency

    Lacks:

    • No permission table in code: it holds no list of a job's Secret keys and token permissions
    • No Kubernetes work: it does not write secretKeyRef templates in place of envFrom, nor scope the suspended CronJob templates
    • No template test that fails when a roadmap Job template loads a key that is not in its job's list
    • No typed error for a job that has no row

    Tools considered:

    Searches run:

    • gidgethub python create installation access token permissions, results: 5
    • GitHub App installation access token API permissions repositories fields, results: 5
    • gidgethub GitHub API library documentation, results: 5
    • "create-github-app-token" action permission-repositories, results: 5
    • actions/create-github-app-token repository, results: 5

    Sources:

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

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

    @devops-cli-service
    Contributor

    Status set to Ready at fd00bf1 (see proposed design in issue body).

  8. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    #6520 (for #6518) gives the runner Job template the 2 keys of the stage Job, DEVOPS_CLI_SERVICE_GITHUB_APP_PRIVATE_KEY and DEVOPS_CLI_AI_API_KEY, through secretKeyRef, and no envFrom. The admission policy roadmap-service-jobs admits those 2 keys for a runner Job too. This is the runner row of the table of this issue, set by hand. It builds no table, no scoped token and no template test.

    Two points for this issue:

    • envFrom is still admitted for a runner Job. The policy checks an UPDATE as a CREATE, and the Service patches the deadline of a runner Job and resumes a waiting fix-checks Job. A Job made before the sync of fix(k8s): load only the needed Secret keys in runner Jobs #6520 keeps envFrom, so a policy that refuses envFrom would refuse those patches. When no such Job is left (deadline cap 14400 s, plus roadmap.fix_checks.max_wait_minutes for a waiting fix Job), this issue can make the policy refuse envFrom in each Job of the Service. Today no template of the Service uses it.
    • The gateway key of a Job. cluster_secrets.py can adopt DEVOPS_CLI_AI_API_KEY from key master-key of Secret llm/llm-gateway-secrets (adopt_from). If the key came from there, each runner and stage pod holds the master key of the gateway. A virtual key for each Job, with a spend limit, removes that. A person makes that key. I did not compare the values: no Secret value was read.
  9. 4 remaining items

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-28 17:56 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions