Skip to content

feat(service): map each repository owner to its own App installation #5327

Open

Description

@dan-petty

Problem or Motivation

service.github_app.installation_id holds one ID. Repos under two accounts need two installations. A public App can be installed by any account.

Order 12 of the plan in #5311. The owner approved the plan on 2026-11-13.

Proposed Solution & Architectural Design

Add a map from owner to installation ID. Token minting selects by RepoRef.owner. The Service refuses events and tokens for an installation that is not in the map. Update the ConfigMap example, and apply the live ConfigMap before the image rolls out.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

GitHub App installations (one for each account) and the existing token minting in app_installation.py over gidgethub 6.0.0. No new library.

Cost: Build: about 1.0M tokens, 1.5 days. Keep: about 10k tokens a month. Fix: about 120k tokens.

Acceptance Criteria

Dependencies

Owner decision 8 in #5311; related to #5252 and #4417. Part of #5311.

Source: #5311

Alternatives check of 2026-11-28: in-use.
The repository already uses this tool.
Tool: gidgethub (https://pypi.org/project/gidgethub), Apache-2.0 AND MIT, last activity 2026-11-20, maintained.
Reason: Searches found no library that maps owners to App installations; gidgethub, already used for the token mint, covers the installation-token call but the map, refusals and per-installation identity stay project code.

Covers:

  • Installation access token mint for a given installation ID
  • GitHub App JWT and REST request plumbing
  • Async client the existing token mint already uses

Lacks:

  • Map from owner to installation ID with lookup by RepoRef.owner
  • Typed refusal for an owner or installation the map lacks
  • Identity, quota ledger and session keyed per installation
  • ConfigMap example and generated config docs for installation_ids
  • Start check run for each owner in the map

Proposed design

Problem statement

The Service holds one GitHub App installation ID in service.github_app.installation_id. Repositories under a second owner cannot mint a token from their own installation. The change adds a map from owner to installation ID, selects the installation from RepoRef.owner, keys identity, ledger and session by installation, and refuses an installation that the map lacks.

Acceptance criteria

Requirement: Owner installation map

The service settings SHALL hold a map from each repository owner to that owner's GitHub App installation ID.

Scenario: Two owners in the map

  • WHEN a test loads settings whose service.github_app.installation_ids gives an installation ID to each of two owners
  • THEN the settings return each owner's own ID, matched case-insensitively, and return no ID for an owner that the map does not hold

Requirement: Token minted from the owner's installation

The installation token mint SHALL select the installation ID from the owner of the RepoRef it is given.

Scenario: Two owners mint tokens

  • WHEN a test mints a token for a RepoRef of each of two owners over a stub session
  • THEN each request path names the installation ID of that repo's owner and no other

Requirement: Identity, ledger and session keyed by installation

The process's GitHub identity, quota ledger and session MUST be keyed by the installation of the repository's owner.

Scenario: Two owners in one process

  • WHEN a test asks the GitHub identity for a RepoRef of each of two owners in one process
  • THEN the two identities hold different ledger keys, each naming that owner's installation ID, and the session of one owner is not replaced by the other

Requirement: Unknown installation refuses the token

The token mint MUST refuse a request for an owner that the map does not hold.

Scenario: Owner not in the map

  • WHEN a test mints a token for an owner that the map does not hold
  • THEN the mint raises the typed refusal error and sends no request to GitHub

Requirement: Unknown installation refuses the event

The Service MUST refuse a webhook event whose installation.id the map does not hold.

Scenario: Event from an unknown installation

  • WHEN a test delivers an event whose installation.id no owner in the map holds
  • THEN the route returns the refusal result, logs the installation ID and starts no job

Requirement: ConfigMap example holds each owner

The ConfigMap example SHALL give one installation ID for each owner that its service.repos names.

Scenario: ConfigMap example validates

  • WHEN the change runs uv run devops ci --check --only k8s
  • THEN the k8s check passes with k8s/devops/configmap.example.yaml parsed as a ConfigMap whose devops-cli.yaml holds the service.github_app.installation_ids map

Requirement: Generated config docs name the map

The generated configuration documents SHALL list service.github_app.installation_ids and SHALL NOT list service.github_app.installation_id.

Scenario: Generated docs are current

  • WHEN the change runs uv run devops ci --check --only docs
  • THEN the check passes with docs/ENV_VARS.md and docs/CONFIGURATION.md generated from the new settings

Requirement: Start check runs for each owner

The service start check SHALL run for each owner in the installation map.

Scenario: Two owners at start

  • WHEN a test runs the start check with two owners in the map over a stub GitHub API
  • THEN the check requests a token for each owner's installation and reports one result for each owner

Requirement: Pending a person after the merge

The live ConfigMap MUST hold the service.github_app.installation_ids map for each owner before the image rolls out.

Scenario: Live ConfigMap before rollout

  • WHEN the image is about to roll out
  • THEN a person has applied the live ConfigMap with the service.github_app.installation_ids map for each owner

Existing Tool Considered

Use gidgethub (Apache-2.0 AND MIT, last activity 2026-11-20, maintained). The alternatives check of 2026-11-22 in the issue body gives the verdict in-use. The check records what the tool covers and lacks. The change adds the owner-to-installation map, the selection by RepoRef.owner, the per-installation identity, ledger and session, the refusals, and the ConfigMap example. The written cost for that code is about 1.0M tokens to build, 1.5 days, about 10k tokens a month to keep, and about 120k tokens to fix.

Key questions

  • Does the change keep one App with an installation for each owner, or one App for each owner?: Keep one App with one installation for each owner. One App ID and one private key serve every owner. The map holds installation IDs only. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, docs/CLUSTER.md]
    • Chosen: One App with an installation for each owner. ADR 0015 records one App. A public App can be installed by any account.
    • Rejected: One App for each owner. It needs a private key and a secret for each owner. ADR 0015 records one App.
  • What config shape holds the map from owner to installation ID?: Add the YAML mapping service.github_app.installation_ids with one entry for each owner. The settings parse it at load. The token mint reads it by RepoRef.owner. (best practice) [sources: CONTEXT.md, src/devops_cli/config/settings.py, k8s/devops/configmap.example.yaml]
    • Chosen: YAML mapping service.github_app.installation_ids. The settings already declare mapping values with dict[str, int]. A mapping gives one key for each owner and a parse error for a bad ID.
    • Rejected: List of owner and installation ID objects. It needs a scan and a duplicate check at each mint.
    • Rejected: JSON in an environment variable. It has no example in the ConfigMap and no check at load.
    • Rejected: One service deployment for each owner. It doubles the deployments and the webhook routes.
  • Where does the code select the installation for a repo?: The token mint resolves the installation ID from RepoRef.owner through the map. A caller passes only the RepoRef. (best practice) [sources: src/devops_cli/github/app_installation.py, src/devops_cli/github/repo_ref.py, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md]
    • Chosen: In the mint, from RepoRef.owner. One place reads the map, so every caller gets the same selection. ADR 0015 makes the installation the identity.
    • Rejected: In each caller, which passes the installation ID. Each caller repeats the lookup and can pass the wrong ID.
    • Rejected: From the installation ID of the webhook payload only. A token mint for a roadmap job has no webhook payload.
  • How does the lookup match an owner key?: Store each owner key casefolded and look it up casefolded. GitHub treats a login as case-insensitive. RepoRef.key is already the casefolded owner/name. (best practice) [sources: src/devops_cli/github/repo_ref.py, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md]
    • Chosen: Case-insensitive match. ADR 0022 records that GitHub names ignore case. RepoRef.key is the casefolded form, so a repo full name with a different case still finds its installation.
    • Rejected: Exact match on the login. A repo full name with a different case misses the map and is refused.
  • What does the Service do with a token request or an event for an installation that the map does not hold?: Refuse it. The mint raises a typed refusal error and sends no request. The event handler logs a warning with the installation ID and starts no job. (best practice) [sources: docs/CLUSTER.md, src/devops_cli/server/routes/webhooks.py]
    • Chosen: Refuse with a typed error and no request. The Service fails at once. The log names the installation that the map lacks. It matches the existing refusal of a repository that is not in service.repos.
    • Rejected: Fall back to the one installation in the map. It mints a token from the wrong installation.
    • Rejected: Send the request and log the API failure. The failure comes late and names no owner.
  • Do we keep the single service.github_app.installation_id setting?: Remove it and hold only the map. The map has one entry for a repository set of one owner. Add one dated line to ADR 0015's Status History that records the map. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, docs/adr/README.md, src/devops_cli/config/settings.py]
    • Chosen: Remove the single ID and hold the map only. A fallback can mint a token from the wrong installation. One key holds one fact.
    • Rejected: Keep it as a fallback for an owner that the map lacks. A missing entry then succeeds with the wrong installation.
    • Rejected: Keep it as a deprecated alias for one owner. Two keys hold one fact, and they drift.
  • Is the process's GitHub identity, quota ledger and session keyed by the installation of the repo's owner?: Yes. github_identity takes the RepoRef and resolves that owner's installation. It keys the identity, the quota ledger directory and the session by it. Two owners keep two ledgers and two sessions in one process. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, src/devops_cli/github/rate_limiter.py, src/devops_cli/github/session.py, src/devops_cli/core/process.py]
    • Chosen: Key the identity, ledger and session by the owner's installation. ADR 0015 records that the installation is the identity and that the quota ledger and the GitHub session are keyed by the installation. The quota cache directory is already named by the identity key.
    • Rejected: Keep one process-wide identity and one token cache. The second owner's request would send the first owner's installation token. The two ledgers would share one quota.
  • Does the change amend ADR 0015?: Yes, with one dated line at the end of the Status History section. The body of the accepted record and its body-hash stay as they are. (best practice) [sources: docs/adr/README.md, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md]
    • Chosen: Add one dated Status History line to ADR 0015. An accepted record changes only in a front-matter status key, one dated Status History line, or a broken link target. The settings line of ADR 0015 is now out of date.
    • Rejected: Edit the settings line of the ADR body. The body of an accepted record does not change. Its body-hash would fail.
    • Rejected: Supersede ADR 0015 with a new record. The decision is unchanged. Only one setting shape changes.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5252

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/feature
    scope/service
    status/new
    value/medium
    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 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The searches found no library that maps several GitHub App installations to repository owners; the only tool in play is gidgethub, which the issue already uses for the existing token minting in app_installation.py. gidgethub covers GitHub App authentication and the API call that mints an installation access token, but it does not hold the owner-to-installation map, the RepoRef.owner selection, or the refusal of unknown installations that this issue adds.

    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:

    • GitHub App authentication and installation access-token minting through the GitHub API
    • The HTTP session/transport used for GitHub requests (the library the issue already mints tokens over)

    Lacks:

    • A map from repository owner to installation ID
    • Selecting the installation token by RepoRef.owner
    • Refusing events and tokens for an installation that is not in the map
    • Updating the ConfigMap example and applying the live ConfigMap

    Tools considered:

    Searches run:

    • GitHub App installation token library multiple installations per owner python, results: 5
    • list GitHub App installations for an account and mint installation access token library, results: 5
    • gidgethub GitHub App installation access token, results: 5
    • githubkit PyGithub GitHub App multiple installations token per repository, results: 5
    • gidgethub python package, results: 5

    Sources:

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

  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Owner question: Who installs the App on the second owner's account and gives its installation ID? (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  7. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. devops-cli-service commented on Nov 22, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: in-use, tool https://github.com/gidgethub/gidgethub. A person decides what the new result means for the item.

    Searches (6)

    Tools considered:

    Searches run:

    • GitHub App multiple installations installation token per repository owner library, results: 5
    • gidgethub apps get_installation_access_token documentation, results: 5
    • python library manage GitHub App installations for multiple accounts mint installation tokens, results: 5
    • githubkit multiple installations installation token auth, results: 5
    • "gidgethub" installation access token app, results: 5
    • octokit app auth multiple installations installation id map tool, results: 5

    Sources:

  9. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

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/servicesource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions