Repository navigation
Description
Problem or Motivation
ADR 0015 (docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, line 37) moved the Service to a GitHub App (devops-cli-service) and explicitly deferred webhook consolidation: "The webhooks of each repository stay. The App's own webhook can replace them in a later item."
Keeping per-repository webhooks causes three operational and architectural problems:
- Onboarding each repository requires creating a separate repository webhook and updating a JSON map in
service.webhook_secrets(k8s/README.mdsteps 2, 8, and 9). HmacSha256.signers(src/devops_cli/server/routes/webhooks.py:86-93) computes an HMAC-SHA256 digest over the request body against every configured repository secret on every incoming GitHub delivery.- As noted in feat(roadmap): onboard checks the webhook of a repository #3772, the App installation token holds no repository Administration permission, so
GET repos/<owner>/<name>/hooksreturns HTTP 403. By contrast, the App's own JWT can readGET /app/hook/configdirectly without repository Administration permission. - App-level events such as
installationandinstallation_repositoriescarry no top-levelrepositoryobject.GitHubWebhookPayload(src/devops_cli/models/webhooks.py:38) rejects them with HTTP400 invalid payloadinstead of acknowledging them cleanly.
Proposed Solution & Architectural Design
- Replace
service.webhook_secrets(DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS) with one string secretservice.github_app.webhook_secret, keeping no legacy shim (AGENTS.md). - Update
HmacSha256and_authenticated_payload(src/devops_cli/server/routes/webhooks.py) to verifyX-Hub-Signature-256once againstservice.github_app.webhook_secret. - Make
GitHubWebhookPayload.repositoryoptional (src/devops_cli/models/webhooks.py). - Return
200 {"status": "no_subscriber"}(orpongonping) for App events that carry norepositoryfield. - Require
payload.repository.full_nameto matchservice.repos(managed_repos) for repository events, refusing unmanaged repositories. - Update
cluster_secrets.py,docs/ENV_VARS.md, andk8s/README.md, and align onboarding checks (feat(roadmap): onboard checks the webhook of a repository #3772) withGET /app/hook/config.
Target Subsystem
Kubernetes & Minikube Automation
Existing Tool Considered
gidgethub (gidgethub.sansio.Event.from_http) verifies single-secret X-Hub-Signature-256 headers, and webhooks.py already implements streaming body caps (_read_capped_body), pre-read header refusals, and HmacSha256.verify (hmac.compare_digest) in standard-library Python. Replacing the multi-secret map with a single App secret simplifies HmacSha256 and removes code rather than adding a new library. The change costs about 95,000 tokens to build, maintain, and fix, and about 2 hours of elapsed time.
Acceptance Criteria
-
service.github_app.webhook_secret(DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET) replacesservice.webhook_secretsacrosssettings.py,env.py,cluster_secrets.py,service.py,docs/ENV_VARS.md, andk8s/README.md, with no backward-compatibility shim. -
_authenticated_payloadverifies each GitHub delivery with one constant-time HMAC-SHA256 check and accepts repository events only whenrepository.full_nameis inservice.repos. - Validly signed App-level events without a top-level
repositoryfield (such asping,installation, andinstallation_repositories) return200(pongorno_subscriber) instead of400or401. - Offline unit tests cover single-secret HMAC verification, unmanaged-repository refusal, and repository-less App events.
Standards Compliance
- I confirm this proposal aligns with AGENTS.md engineering principles (cyclomatic complexity <= 10, nesting <= 5, zero bare exceptions, tests that cover the changed lines).
- I am willing to submit a pull request implementing this feature with accompanying tests.
Alternatives check of 2026-11-25: 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 surfaced no broader tool; gidgethub's Event.from_http already verifies one X-Hub-Signature-256 secret and the project uses it, but the body cap, header refusals, managed-repository check and App-event answers stay custom.
Covers:
- Single-secret X-Hub-Signature-256 check in sansio Event.from_http
- Sans-I/O event parsing of delivery headers and body
- Already a dependency, so no new library
Lacks:
- Capped streaming read that refuses bodies above 25 MiB
- Pre-read header refusals before the body is read
- Exact repository.full_name membership check against service.repos
- 200 no_subscriber or pong answer for repository-less App events
Proposed design
Problem statement
ADR 0015 moved the Service to the GitHub App devops-cli-service and deferred the App webhook. The Service still keeps a per-repository webhook secret map and checks every secret on each delivery. It rejects valid App-level events that carry no repository. This change uses one App webhook secret, verifies each delivery once, accepts App-level events, limits repository events to service.repos, and updates onboarding row 12 and hook delivery reads.
Acceptance criteria
Requirement: Single App webhook secret
The Service SHALL replace service.webhook_secrets with service.github_app.webhook_secret and DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET, and it MUST keep no backward-compatibility shim.
Scenario: Load the App webhook secret
- WHEN The offline settings test runs
uv run pytest tests/server/test_server.pywith DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET set and DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS unset. - THEN The test reads service.github_app.webhook_secret as the configured value, and the settings model exposes no service.webhook_secrets field.
Requirement: Environment declaration
The environment declaration SHALL list DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET and MUST NOT list DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS.
Scenario: Config declaration check
- WHEN The config declaration test runs
uv run pytest tests/security/test_config_declarations.py. - THEN The test passes and asserts that DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET is declared and DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS is absent.
Requirement: Optional cluster secret
The cluster secret table SHALL replace service.webhook_secrets with the optional service.github_app.webhook_secret.
Scenario: Deploy without the App webhook secret
- WHEN The offline cluster secret plan test runs
uv run pytest tests/k8s/test_cluster_secret_plan.pywith no keyring value and no cluster value for service_github_app_webhook_secret. - THEN The test shows the push skips the key with a warning and the deploy plan continues.
Requirement: One signature check
The webhook route SHALL verify each GitHub delivery with one constant-time HMAC-SHA256 check against service.github_app.webhook_secret before it parses the payload.
Scenario: Valid and invalid signatures
- WHEN The offline webhook test runs
uv run pytest tests/server/test_server_service.pyand sends a validly signed delivery and a delivery signed with another secret. - THEN The test shows the valid delivery passes authentication, and the other delivery gets HTTP 401 invalid signature with no payload parse.
Requirement: Managed repository only
The webhook route MUST accept a repository event only when payload.repository.full_name is one of service.repos.
Scenario: Unmanaged repository event
- WHEN The offline webhook test runs
uv run pytest tests/server/test_server_service.pyand sends a validly signed repository event whose repository.full_name is absent from service.repos. - THEN The test shows HTTP 403 and no round starts.
Requirement: Repository-less App event
The webhook route SHALL return HTTP 200 with {"status": "no_subscriber"} for a validly signed App-level event that has no top-level repository field.
Scenario: Installation event without repository
- WHEN The offline webhook test runs
uv run pytest tests/server/test_server_service.pyand sends a validly signed installation or installation_repositories delivery with no top-level repository field. - THEN The test shows HTTP 200 with {"status": "no_subscriber"} and no round starts.
Requirement: Ping event
The webhook route SHALL answer a validly signed ping delivery with HTTP 200 and a pong body.
Scenario: Ping without repository
- WHEN The offline webhook test runs
uv run pytest tests/server/test_server_service.pyand sends a validly signed ping delivery with no top-level repository field. - THEN The test shows HTTP 200, a body that contains pong, and no round starts.
Requirement: Repository field optional
GitHubWebhookPayload SHALL make repository optional while it keeps validation of the other declared fields.
Scenario: App-level payload validation
- WHEN The offline model test runs
uv run pytest tests/models/test_webhooks.pyand validates an installation payload with sender and no repository. - THEN The test shows the model accepts the payload and exposes repository as None.
Requirement: Existing webhook guards
The webhook route SHALL keep the existing 25 MiB body cap and pre-read header refusals after the secret change.
Scenario: Oversized delivery
- WHEN The offline webhook test runs
uv run pytest tests/server/test_server_service.pyand sends a delivery with a Content-Length above 25 MiB. - THEN The test shows HTTP 413 before the route reads the body.
Requirement: Onboarding row 12
The onboarding webhook row and the repos-onboard spec SHALL replace rows 12 and 13 with a GET /app/hook/config check and MUST NOT create or patch /repos/<owner>/<name>/hooks or write service.webhook_secrets.
Scenario: Onboarding row 12 request
- WHEN The offline onboarding test runs
uv run pytest tests/github/onboard/test_onboard_rows.pywith a stubbed GitHub API. - THEN The test shows row 12 sends GET /app/hook/config, sends no POST or PATCH request for /repos/<owner>/<name>/hooks, and writes no service.webhook_secrets key.
Requirement: App hook deliveries
The hook delivery reader SHALL read App webhook deliveries with GET /app/hook/deliveries and MUST NOT read per-repository /repos/<owner>/<name>/hooks deliveries.
Scenario: Read App hook deliveries
- WHEN The offline hook delivery test runs
uv run pytest tests/github/test_hook_deliveries.pywith a stubbed GitHub API. - THEN The test shows the reader requests GET /app/hook/deliveries and sends no per-repository hook delivery request.
Requirement: Deployment manifest
The roadmap-service deployment SHALL read service.github_app.webhook_secret and MUST NOT set DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS.
Scenario: Kubernetes manifest check
- WHEN The Kubernetes check runs
uv run devops ci --check --only k8s. - THEN The check passes and the rendered roadmap-service deployment sets DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET and no DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS.
Requirement: Documentation
The documentation in docs/ENV_VARS.md and k8s/README.md SHALL name service.github_app.webhook_secret and DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET in place of service.webhook_secrets and DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS.
Scenario: Documentation check
- WHEN The documentation check runs
uv run devops ci --check --only docs. - THEN The check passes and reports no documentation error for the changed files.
Requirement: Offline webhook tests
The change SHALL add offline unit tests for single-secret HMAC verification, unmanaged-repository refusal, and repository-less App events.
Scenario: Webhook test suite
- WHEN The offline webhook tests run
uv run pytest tests/server/test_server_service.py. - THEN The tests cover the single-secret signature, the unmanaged repository refusal, and the App-level event acknowledgement.
Requirement: Pending a person after the merge
A person SHALL enable the App webhook and set service.github_app.webhook_secret after the merge.
Scenario: App webhook configured
- WHEN A person enables the App webhook at
https://hooks.<domain>/webhooks/github, sets the same secret in the App settings and the keyring, and runsdevops k8s push-secrets --only devops/devops-cli. - THEN A live GitHub ping delivery returns HTTP 200 with a pong body, and the Service log shows no signature error.
Existing Tool Considered
The issue body's alternatives check gives gidgethub (https://github.com/gidgethub/gidgethub) the verdict in-use, and it lists what gidgethub covers and lacks. The proposal keeps HmacSha256 and the webhook route to supply the lacks that the block names. The issue estimates about 95,000 tokens to build, keep and fix this change, and about 2 hours of elapsed time.
Key questions
- Which onboarding row verifies the App webhook after feat(repos): onboard a repository in one command #6806 and fix(repos): onboard writes no webhook from a default URL #7308?: Replace webhook_row (row 12) in src/devops_cli/github/onboard/service_rows.py with an App webhook config check. The row calls GET /app/hook/config. Remove row 13 and the per-repository hook create and patch steps. Remove the service.webhook_secrets write. Update openspec/specs/repos-onboard/spec.md and tests/github/onboard/test_onboard_rows.py. (best practice) [sources: src/devops_cli/github/onboard/service_rows.py, tests/github/onboard/test_onboard_rows.py, openspec/specs/repos-onboard/spec.md, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md]
- Chosen: Replace row 12 with GET /app/hook/config. The App JWT reads the App webhook configuration, and the App webhook replaces per-repository hooks.
- Rejected: Keep rows 12 and 13 for per-repository hooks. This keeps the per-repository webhook and service.webhook_secrets map that the issue removes.
- Rejected: Remove the onboarding webhook check. Onboarding must verify that the App webhook is configured.
- What does hook_deliveries.py read after the App webhook replaces per-repository hooks?: Read App webhook deliveries with GET /app/hook/deliveries and GET /app/hook/deliveries/{delivery_id} by using the Service App JWT. Remove per-repository /repos/{owner}/{repo}/hooks/{hook_id}/deliveries reads. Add an offline test in tests/github/test_hook_deliveries.py. (best practice) [sources: src/devops_cli/github/hook_deliveries.py, docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md]
- Chosen: Use App hook deliveries. The App webhook is the only webhook after the change, and the Service token can read its deliveries.
- Rejected: Keep per-repository hook deliveries. No per-repository hooks remain after rows 12 and 13 are removed.
- Rejected: Drop delivery metrics. The metrics row needs the deliveries, and the App endpoint gives them.
- Which secret setting replaces the per-repository webhook secret map?: Use one string secret, service.github_app.webhook_secret, and its variable DEVOPS_CLI_SERVICE_GITHUB_APP_WEBHOOK_SECRET. Remove service.webhook_secrets and add no compatibility shim. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md, src/devops_cli/k8s/cluster_secrets.py, docs/ENV_VARS.md, k8s/README.md, k8s/devops/roadmap-service/deployment.yaml, AGENTS.md]
- Chosen: Single App webhook secret. ADR 0015 defers the App webhook replacement. One App secret removes per-repository onboarding and repeated HMAC checks.
- Rejected: Keep the per-repository map. It keeps one repository webhook for each repository and checks every configured secret on each delivery.
- Rejected: Add a compatibility shim. AGENTS.md forbids backward-compatibility shims before 1.0.
- Must the new App webhook secret be required for a devops stack deploy?: No. Keep the cluster secret row optional, as the old webhook secret map was optional. A missing secret leaves the webhook route refusing deliveries while polling continues. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, k8s/README.md, src/devops_cli/k8s/cluster_secrets.py]
- Chosen: Optional secret. The old map was optional, and polling continues when webhook verification has no secret.
- Rejected: Required secret. It would stop deploy-stack for a feature that only cuts webhook latency.
- Rejected: Generate the secret automatically. A person must set the same secret in the GitHub App settings, so a generated value alone does not configure the webhook.
- How does the route verify a delivery with one secret?: Verify the raw body once with HmacSha256 and hmac.compare_digest against service.github_app.webhook_secret before parsing. Keep the capped streaming read and the pre-read header refusals. (best practice) [sources: src/devops_cli/server/routes/webhooks.py:88, src/devops_cli/server/routes/webhooks.py:781]
- Chosen: Use existing HmacSha256 with one secret. It already uses hmac.compare_digest and keeps the existing body cap and pre-read refusals.
- Rejected: Adopt gidgethub Event.from_http. It does not supply the route guards that the alternatives block lists.
- Rejected: Keep HmacSha256.signers over every repository secret. It does unnecessary work on each delivery and keeps the per-repository secret map.
- What does a validly signed App-level event with no repository return?: Return HTTP 200 with {"status": "no_subscriber"}. Return HTTP 200 with a pong body for ping. Start no round. (best practice) [sources: src/devops_cli/models/webhooks.py:124, src/devops_cli/server/routes/webhooks.py]
- Chosen: Acknowledge with HTTP 200. App-level events have no subscriber. A 200 stops GitHub retries and matches the route's existing no-subscriber answer.
- Rejected: Reject with HTTP 400 invalid payload. The current model rejects valid App-level events because repository is required.
- Rejected: Return HTTP 202 with an empty body. The route reports its result as a JSON status, and a test can assert the 200 and the status body.
- How does the route decide that a repository event is managed?: Compare payload.repository.full_name with service.repos. Accept the event only on an exact match. Refuse an unmanaged repository with HTTP 403. (best practice) [sources: src/devops_cli/server/routes/webhooks.py, docs/ENV_VARS.md, k8s/README.md]
- Chosen: Exact membership in service.repos. It uses the existing managed repository list and refuses an unmanaged repository before any round starts.
- Rejected: Trust every validly signed App event. A valid App signature does not prove that the repository is in service.repos.
- Rejected: Normalize the names to lower case. The configured values and the current route use exact owner/name strings. Normalization is a separate change.
- Which payload fields become optional for App-level events?: Make repository optional. Keep sender required because installation and installation_repositories events carry it. (best practice) [sources: src/devops_cli/models/webhooks.py:124]
- Chosen: Only repository optional. It matches the issue and keeps sender validation for App-level events that carry a sender.
- Rejected: Make repository and sender optional. It weakens validation with no evidence that the App events lack a sender.
- Rejected: Keep repository required and special-case event names. It moves payload validation into the route and misses future App events.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 10, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(service)scope of the title gives the scope.It reduces onboarding friction and fixes a 400 for App events, but the current multi-secret path still works for repository events.Simplifies operations for every new repository and removes a 400 error class, but does not unblock a broken feature.It touches settings, env, cluster_secrets, webhooks.py, models, docs, and k8s README, plus new unit tests.Both work on the webhook router in webhooks.py, but #1386 built the router structure while the candidate changes the secret from a per-repo map to one App secret.devops-cli-service commentedon Nov 10, 2026
Refine cannot set this item to Ready at 1ca0133 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.
devops-cli-service commentedon Nov 11, 2026
Alternatives check: partly
Reason: Searches for a library that verifies a GitHub App webhook with one secret found gidgethub, whose
sansio.Event.from_httpchecks a singleX-Hub-Signature-256against one secret in constant time, so it covers the signature-verification part of this change. It covers nothing else the issue needs: the settings/env/cluster-secret migration away fromservice.webhook_secrets, the capped streaming body read and pre-read header refusals, theservice.reposmembership refusal, the 200no_subscriber/ponganswer for repository-less App events, and theGET /app/hook/configonboarding check.Tool: gidgethub/gidgethub (https://github.com/gidgethub/gidgethub)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-11. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 19, 2026
The result in the alternatives block of the issue body changed. Before this check:
partly, tool https://github.com/gidgethub/gidgethub. A person decides what the new result means for the item.Searches (6)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 20, 2026
Owner question: See the first point of Open questions in the section Proposed design of the body.
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
devops-cli-service commentedon Nov 26, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
3 remaining items
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
feat(service): verify GitHub App webhooks with one secret (#4417)
chore(main): release 0.246.0 (#7697)
devops-cli-service commentedon Nov 29, 2026
Released in v0.246.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.246.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 11:55 UTC