Repository navigation
Description
Problem Statement
The roadmap jobs run when they are due. Deciding what is due is devops roadmap run (#981, split from #741; the service's Deployment is #1083, on #741's in-cluster runtime). GitHub sends no webhook when a board owned by a personal account changes (projects_v2_item is organization-only), and it does not redeliver failed deliveries. So polling is how the service sees changes, and a webhook only makes a job due sooner (ADR 0003, docs/adr/0003-polling-is-how-the-roadmap-sees-changes.md). GitHub expects a 2XX answer within 10 seconds, caps payloads at 25 MB, and keeps the same X-GitHub-Delivery on a manual redelivery.
What exists at HEAD (9c879ae, branch release/v0.2.25):
-
The server.
devops serveis a Typer callback (commands/serve.py:32-133) that buildscreate_app(server/app.py:29-124). It mounts:/, which lists the other routes (app.py:103-115);/healthand/healthz, one handler that always answers ok (server/routes/health.py:27-37);/metrics(server/routes/telemetry.py:60-91), and/api/v1/telemetry, which pings the OTLP collector (telemetry.py:38-57);/api/v1/status(server/routes/status.py:16,:36),/api/v1/workspaces(absolute paths on disk,server/routes/workspace.py:48,:81),/api/v1/config(workspace.py:128) and a simulated reasoning stream under/v1(server/routes/stream.py:20,:60);- Swagger and ReDoc by default (
serve.py:65-69,:102-104), and CORS for localhost (app.py:48-65).
There is no webhook route and no readiness probe.
serveprints a Rich banner before it starts uvicorn (serve.py:75-99, strings inServeMessages,lang/en/messages.py:846), and binds127.0.0.1by default (DEFAULT_REST_HOST,config/defaults.py:458;DEFAULT_SERVER_WORKERS = 1,:316). -
One process.
servepasses an app object touvicorn.run(serve.py:127-133);--reloadpasses an import string instead (:116-124). uvicorn 0.53.0 (pyproject.toml:35) exits at startup when it gets an app object withreloadorworkers > 1(uvicorn/main.py:614-618). So the server runs as one process today, which in-memory queues need.uvicorn.runaccepts alog_configdict (uvicorn/main.py:528). -
Unused webhook code.
CONST_GH_WEBHOOK_SIGNATURE_HEADER(config/constants.py:682) is defined and never read.verify_webhook_signature(github/graphql.py:278-292) computes HMAC-SHA256 and compares withhmac.compare_digest. Only tests call it (tests/test_github_graphql.py:212-228).WebhookEventDispatcher(graphql.py:295-353) andWebhookEvent(:115) are also called only by tests (tests/test_github_graphql.py:230-281,:607-619). The dispatcher skips verification when no secret is passed (:316). Without a raw body it verifies a re-serialized payload (:317-321), which never matches GitHub's signature.GitHubWebhookVerificationError(exceptions/git.py:142-157, exported atexceptions/__init__.py:59,:148, listed indocs/ERRORS.md:60) is raised only by the dispatcher (graphql.py:323).github/__init__.py:37-40,:184-185,:241export all four names.- refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26, lands before this item) removes
GitHubGraphQLClient(graphql.py:657),GraphQLTokenBucket(:225) andRFC7234ETagCache(:135) from the same module and their exports fromgithub/__init__.py, and deletestests/test_github_graphql.pywith the client; it does not name the webhook code. Its transport half, refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28), lands after this item and leaves the webhook code to this item (its Out of Scope namesverify_webhook_signatureandWebhookEventDispatcheras feat(cli): service mode fordevops servewith github webhooks, a polling tick and per-repo job queues #752's).
-
Metrics. The registry
InMemoryMetricsRegistry(telemetry/metrics.py:41) has counters and gauges with labels (increment_counter:61,set_gauge:77,reset:143,export_prometheus_text:164), capped at 1,000 names and 5,000 label sets per name (:25-26). Its histograms keep the last 10,000 samples (:24,:53) and export_countand_sumfrom those samples with no buckets (:178-185). In a long-running service_countstops at 10,000 and_sumcan fall, so neither behaves as a counter. The/metricshandlerget_metrics(telemetry.py:60-91) readsGLOBAL_METRICS(metrics.py:191) and adds AI spend and uptime. -
Logs. Nothing in
src/formats logs as JSON (git grep -iE "jsonformatter|class .*Formatter" -- srcprints nothing).telemetry/logging_bridge.pyis an OTLP correlation bridge, not a formatter. -
Config and credentials. Settings read
DEVOPS_CLI_variables, with__for nesting (config/settings.py:597-598). There is noServiceConfigand noSettings.service. Credentials resolve through one chain: keyring, then Vault, then environment, then config (security/secrets.py:408-456,settings.py:958-965).cloudflare.api_tokenis the precedent for a managed credential with no Settings field:config/options.py:93, inSECRET_CONFIG_OPTIONS(:220-234) andKEYRING_KEYS(:236-248),config/env.py:84,:169, registry entrysecrets.py:439-444;CloudflareConfig(settings.py:325) has no token field.devops config showprints such options asset (****)(commands/config.py:102-116,:314-338). -
GitHub calls.
run_ghtimes out after 30 s by default (github/rate_limiter.py:1874-1883), so a job can't hang forever on one GitHub call. -
Tests.
tests/test_server.pyalready usesTestClient(:9) and patchesuvicorn.rununderCliRunner(:225-232). The network guard (fix(test): the test network guard refuses loopback connects to services the test did not start #837, shipped in v0.2.24,e6ce3db) refuses non-loopback connects and loopback connects to ports the test process did not open (tests/conftest.py:66-160);TestClientruns in process and opens no socket.
Proposed Solution
A service mode, devops serve --service, added to the existing callback in commands/serve.py.
-
Webhook route.
POST /webhooks/githubchecks the request, verifiesX-Hub-Signature-256over the raw body and queues a trigger for the repo. It never runs a job inside the request. Its answers:- 202: verified and queued, or merged into the repo's pending batch;
- 200: verified but not queued: a
ping, a repeatedX-GitHub-Delivery, or an event sent by the machine account (ADR 0002); - 400:
X-GitHub-EventorX-GitHub-Deliveryis missing, or the body is not a JSON object; - 401: the signature is missing or wrong, or the repo is not managed;
- 413: the body is over 25 MiB. This is decided from
Content-Lengthwhen it is present, and otherwise while the body streams in, so no more than the limit is ever read; - 415: the content type is not
application/json; - 503: the service is shutting down.
-
Polling tick. At startup, and then every
service.poll_interval_seconds(default 300, minimum 60), it queues apolltrigger for every managed repo. The tick reads nothing from GitHub. The job function reads what changed through the roadmap store (refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768, delivered inbf746de:roadmap/store.py,roadmap/github_store.py). -
Per-repo queues.
- One queue per repo in
service.repos. Each runs one job at a time, on its own thread, and calls the job function with the repo and the triggers queued since its last run. - Job threads are started with
daemon=True, not on asyncio's default executor, so a job cut off at the drain timeout does not keep the process alive. - Triggers that arrive while a job runs merge into one pending batch, counted by source, event and action. A burst makes one more run, not many.
- Different repos run at the same time.
- A job that raises is logged and counted, and its queue goes on.
- One queue per repo in
-
Job function.
create_service_app(job=...)takes it as a parameter. Its contract isCallable[[str, TriggerBatch], None]: the repo asowner/name, and a frozenTriggerBatchmodel exported fromserver/service.pyholdingrepo,counts: dict[tuple[str, str, str], int]keyed by(source, event, action)(sourceiswebhookorpoll;eventandactionare empty strings forpoll),first_atandlast_at. The function runs synchronously on the repo's thread. Until feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 lands,devops serve --servicepasses one that logs the batch and changes nothing. feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 replaces it withdevops roadmap run'sservice_jobadapter; feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083's deployment is proven on the cluster against the log-only function first. -
Probes.
/healthzanswers 503 once the tick task or any repo's queue task has exited, so the kubelet restarts the pod. The service app defines its own handler; it does not includehealth_router, whose one handler always answers ok (health.py:27-29)./readyzanswers 503 until startup completes and while draining.
-
Graceful shutdown. On SIGTERM:
/readyzand the webhook route answer 503;- the tick stops;
- pending batches are dropped, and the startup tick finds the work again;
- shutdown waits at most
service.drain_timeout_seconds(default 120) in total for running jobs to finish, then exits.
-
Logs. In service mode every line the process writes, uvicorn's included, is one JSON object.
serveprints no Rich banner; the startup details are logged instead. A line hastime,level,loggerandmessage, plusrepo,source,event,action,delivery,outcome,duration_sandresultwhere they apply. Bodies, signatures, secrets and tokens are never logged. -
Metrics on
/metrics, counters and gauges only, registered onGLOBAL_METRICS:devops_cli_service_webhook_deliveries_total{outcome};devops_cli_service_triggers_total{repo,source};devops_cli_service_pending_triggers{repo};devops_cli_service_jobs_total{repo,result};devops_cli_service_job_seconds_total{repo};devops_cli_service_job_start_timestamp_seconds{repo}, 0 when idle;devops_cli_service_last_tick_timestamp_seconds.
The service app mounts the existing
get_metricshandler (telemetry.py:65) on its own router, nottelemetry_router, which also carries/api/v1/telemetry. -
Routes. The service app mounts only
POST /webhooks/github,GET /healthz,GET /readyzandGET /metrics. It has no docs, no CORS, no/, and none of the/api/v1or/v1routes. -
Config.
ServiceConfigunderSettings.service:repos(a list ofowner/name),machine_account(a login),poll_interval_seconds(at least 60) anddrain_timeout_seconds(above 0). Values outside these rules fail validation.- Webhook secrets are one managed credential,
service.webhook_secrets: a JSON object from repo to secret. It is declared inbuild_secret_registry(secrets.py:408) with the environment variableDEVOPS_CLI_SERVICE_WEBHOOK_SECRETS, listed inSECRET_CONFIG_OPTIONSandKEYRING_KEYS(options.py:220,:236) and inconfig/env.py, and is not a Settings field. It follows thecloudflare.api_tokenpattern.
-
CLI checks.
--servicewith--reload, or with--workersabove 1, exits 2.- An empty
service.reposor an unsetservice.machine_accountexits 1, with a message naming the setting. - A
service.webhook_secretsvalue that is not a JSON object from repo to string exits 1, with a message naming the credential and never its value. - A repo with no secret logs a warning at startup. Its deliveries get 401, and polling still covers it.
-
Cleanup.
verify_webhook_signaturemoves fromgithub/graphql.py:278-292intoserver/routes/webhooks.py; its test (tests/test_github_graphql.py:212-228) moves intotests/test_server_service.py.- The route reads
CONST_GH_WEBHOOK_SIGNATURE_HEADER(constants.py:682), plus new constants forX-GitHub-EventandX-GitHub-Delivery. WebhookEventDispatcher,WebhookEvent, their exports ingithub/__init__.py(:37-38,:184-185) and their tests (tests/test_github_graphql.py:230-281,:607-619) are deleted.GitHubWebhookVerificationError(exceptions/git.py:142-157) and its exports inexceptions/__init__.py(:59,:148) are deleted, because the route answers 401 and raises nothing.docs/ERRORS.mdis regenerated withuv run devops docs generate(commands/docs.py:54;generator.py:797,:1046), anduv run devops docs check(docs.py:157) passes.- refactor(github): one github session per identity owning token, quota and transport #767 merges first. Its removals leave
graphql.pyandgithub/__init__.pywithout the GraphQL client, andtests/test_github_graphql.pyalready deleted; this item's rebase then drops the hunks that are already gone, and the cleanup criterion below holds either way.
-
Where the code goes.
server/service.py: queues,TriggerBatch, tick, lifespan and probes;server/routes/webhooks.py: the route and the verifier;server/json_logs.py: the formatter and thelog_config(notlogging.py, which would shadow the standard library module);create_service_appinserver/app.py, exported fromserver/__init__.pybesidecreate_app(:5-7);ServiceConfiginconfig/settings.py;- the credential in
config/options.py,config/env.pyandsecurity/secrets.py; - messages in
lang/en/messages.py(ServeMessages,:846) and help inlang/en/help.py(ServeCommandHelp,:629); - the changelog fragment
changelog.d/752.md; the task filedocs/agent/tasks/task-752-serve-service-mode.md.
Scope
One pull request. It adds the service mode (route, tick, queues, probes, shutdown, JSON logs, metrics, config, credential, CLI checks) and removes the dead webhook code it replaces. No new dependency: FastAPI 0.141.1 (pyproject.toml:34) and pydantic-settings 2.15.0 (:27) are pinned, and httpx 0.28.1, which TestClient needs, is already in the lock (tests/test_server.py:9 imports TestClient today).
Key Questions
All answered.
- Does the tick read GitHub, or only make each repo due? It only makes each repo due. The job function (
devops roadmap run, feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981) reads changes and their actors through the store (refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768, delivered), which owns conditional polling over refactor(github): one github session per identity owning token, quota and transport #767's session. This keeps "what is due" in one place, lets the service be tested without GitHub, and frees this item from depending on the store. A side note for ADR 0003, from the issue: GraphQL answers carry noETag(the issue reports checking withgh api graphql -i), so board reads cost points even when nothing changed. - What runs before feat(roadmap): run the roadmap jobs when they are due (
devops roadmap run) #981 lands? A job function that logs the batch and changes nothing.create_service_app(job=...)takes the real one from feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981. feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083's Deployment and feat(release): production service image for scheduled jobs and webhook handlers #753's image ship against the log-only function, sodevops serve --serviceis a working entry point and the deployment is proven on the cluster before any job exists. - What is the job function's contract?
Callable[[str, TriggerBatch], None], withTriggerBatchthe frozen model above, called synchronously on the repo's thread. The issue already fixes the unit: triggers "merge into one pending batch, counted by source, event and action", so the function receives that batch, not a raw list, which would be unbounded in a burst and lose the merging. feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's original text says only that the worker "calls the same function with the triggers it queued" (741.md:64) and fixes no type, so this item names the type and exports it fromserver/service.py. feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 builds against it: its body restates the sameTriggerBatchfields, keys its due table onTriggerBatch.countskeys such as("webhook", "issues", "opened"), and uses{("poll", "", ""): 1}for a terminal run. - How do triggers queue? Each repo has at most one running job and one pending batch. New triggers merge into the batch, counted by source, event and action, so the batch's size is bounded by the number of distinct event kinds. Repos run in parallel with no global cap: the service manages few repos, and quota belongs to refactor(github): one github session per identity owning token, quota and transport #767's session (one process, one identity; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 keeps it that way for the per-repo workers).
- Which secret verifies a delivery, and is the body parsed first? One secret per repo, carried in feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's
devops-cliSecret asDEVOPS_CLI_SERVICE_WEBHOOK_SECRETS(thedevops k8s push-secretsrow feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 adds). The route computes the HMAC with each configured secret before parsing anything and keeps the repos whose secret matches. Only then does it parse the JSON and requirerepository.full_name, compared case-insensitively, to be one of those repos. Untrusted JSON is never parsed before a signature matches. A single shared secret would be simpler; one per repo limits a leaked secret to its own repo and matches GitHub's per-webhook setting. - Where do the secrets live? In one managed credential,
service.webhook_secrets, resolved through the existing chain (security/secrets.py:408-456) fromDEVOPS_CLI_SERVICE_WEBHOOK_SECRETSin the cluster. It has no Settings field, so config dumps can't show it (devops config showmasks keyring-backed options,commands/config.py:116,:338), and it is resolved and parsed once at startup. - Which events are queued? Every verified event except
pingand the machine account's own. The job function decides which events matter (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740's triggers, feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981's due table). feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083's setup chooses which events each webhook sends (issues, pull requests and milestones). - How is the machine account recognized? By
service.machine_account, compared case-insensitively withsender.login. It is required: without it, each change a job makes would come back as a webhook and make the job due again. feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 applies the same rule on the poll side, dropping changes whose actor is the session's login before its due table is evaluated. - How are repeated deliveries caught? By keeping the last 10,000 verified delivery IDs in memory. Only verified deliveries are recorded, so unsigned requests can't fill the set. The set is lost on restart. A replay after that only makes a job due early, and the jobs' compare-before-write rule (ADR 0002) makes a rerun harmless.
- How many processes? One. The queues, the pending batches and the delivery IDs live in memory, so
--servicerefuses--reloadand--workersabove 1. feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 runs a single replica withstrategy: Recreate. - What do the probes mean? Liveness fails only when a background task has died, which a restart fixes. Readiness fails before startup and while draining. Neither checks GitHub, because GitHub being down is not fixed by a restart, and the tick retries anyway.
- How long does shutdown wait, and what is lost? Up to 120 s in total by default. feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 sets
terminationGracePeriodSecondsabove it (150). Pending batches are dropped, and the startup tick finds the work again. A job cut off at the timeout is re-run by a later tick: feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 moves a job's last-success time only when the job succeeds, so the cut-off job is due again. Its thread hasdaemonset, so it does not keep the process alive; asyncio's default executor would, because the event loop and the interpreter both wait for its threads at exit. - Is there a job timeout? No. A thread can't be cancelled safely, and each
ghcall already times out after 30 s (rate_limiter.py:1883).job_start_timestamp_secondslets an alert catch a stuck job. - Which routes does service mode serve, and how are the rest kept private? Only the four listed. feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 exposes only
/webhooks/github(a Traefik Ingress with oneExactpath behind the tunnel), and its NetworkPolicy limits the rest. Not mounting the other routes means a wrong Ingress or tunnel rule exposes nothing else, in particular the disk paths from/api/v1/workspaces, the config from/api/v1/configand the collector probe from/api/v1/telemetry. - Why no histogram for job duration? The registry's histograms stop counting at 10,000 samples, and their
_sumcan fall (telemetry/metrics.py:53,:178-185).job_seconds_totaldivided byjobs_totalgives the average throughrate(). Fixing the registry is out of scope. The OTLP instruments intelemetry/instruments.pystay for short-lived commands; the service is scraped on/metrics. - Library or stdlib for JSON logs? Stdlib. A
logging.Formattersubclass is about 20 lines, and uvicorn takes it throughlog_config. No new dependency. - Who deletes the dead dispatcher code, given refactor(github): one github session per identity owning token, quota and transport #767 edits the same files? This item, as the Cleanup section says. refactor(github): one github session per identity owning token, quota and transport #767's removal list (767.md:60-65) names
GitHubGraphQLClient,GraphQLTokenBucketandRFC7234ETagCacheand not the webhook code, so no one else owns the deletion; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (its transport half, v0.2.28) lands after this item and leaves the webhook code to it. refactor(github): one github session per identity owning token, quota and transport #767 merges first, so this item rebases onto agraphql.pyandgithub/__init__.pywithout the client and onto a tree wheretests/test_github_graphql.pyis already deleted; the hunks that are gone are dropped and the webhook tests live intests/test_server_service.py. Handing the deletion to refactor(github): one github session per identity owning token, quota and transport #767 would leave this item's route importing from a module refactor(github): one github session per identity owning token, quota and transport #767 is gutting. - How do the tests stay under 1 s with no sockets? They use
TestClient, which runs in process, and an injected clock and sleep that the tick loop awaits, so a test advances time instead of waiting. No test sleeps longer than 50 ms, and the 413 tests patch the limit instead of sending 25 MiB.
Acceptance Criteria
Unless a criterion says otherwise, it is verified by an in-process test in tests/test_server_service.py. The tests use FastAPI's TestClient, a fake job function, and an injected clock and sleep. Assertions use structural tuple equality (AGENTS.md:15-17).
-
With repo A idle, a delivery signed with A's secret gets 202 while the job it started is still blocked on an unset
threading.Event. The fake job function records that it ran on a thread other than the request's and received aTriggerBatchwithcounts == {("webhook", "issues", "opened"): 1}. A second delivery then gets 202 and lands in A's pending batch. This shows no job runs inside a request. (tests/test_server_service.py) -
Each of these gets 401 and queues nothing: no signature; a wrong signature; a body signed with another managed repo's secret; a repo not in
service.repos; a managed repo with no secret, which also logs one warning at startup. (tests/test_server_service.py) -
The same
X-GitHub-Deliverysent twice gets 202 and then 200, and queues one trigger. (tests/test_server_service.py) -
A
ping, and an event whosesender.loginis the machine account in any letter case, each get 200 and queue nothing. (tests/test_server_service.py) -
With the size limit patched to 1 KiB: a 1 KiB + 1 byte body gets 413; the same body sent in chunks with no
Content-Length(a generator body) also gets 413. (tests/test_server_service.py) -
A form-encoded body gets 415. A request without
X-GitHub-Eventgets 400, and a signed body that is a JSON array gets 400. (tests/test_server_service.py) -
Ten triggers for repo A while A's job runs produce exactly one more run of A, whose batch counts all ten. A job for repo B runs while A's job runs. A per-repo concurrency counter kept by the fake job function never exceeds 1. (
tests/test_server_service.py) -
The test drives the running tick loop through the injected clock and sleep, not by calling a tick method. Startup queues one
polltrigger per repo, and advancing past one interval queues exactly one more per repo. Apoll_interval_secondsbelow 60 and adrain_timeout_secondsof 0 each failServiceConfigvalidation. (tests/test_server_service.py) -
A job function that raises adds 1 to
jobs_total{result="error"}and logs the exception, and the repo's next trigger still runs. (tests/test_server_service.py) -
/readyzgives 503 before startup completes and during drain, and 200 in between./healthzgives 503 after a queue task is cancelled from outside, and in a separate case after the tick task is. (tests/test_server_service.py) -
Leaving the
TestClientcontext while a job runs waits for that job to finish. With the drain timeout patched to 0.05 s, a job blocked until the test releases it does not hold the context exit past 0.3 s, and its thread hasdaemonset. The test then releases the job. During drain the webhook route answers 503. (tests/test_server_service.py) -
The service app's routes are exactly the four listed, asserted over
app.routes.GET /,GET /docsandGET /api/v1/configreturn 404. (tests/test_server_service.py) -
With
GLOBAL_METRICS.reset()first, one delivery and one job leave each metric above onGET /metrics, with the expected labels and values. (tests/test_server_service.py) -
Every captured log line parses with
json.loads. The delivery and job lines carry the fields above. No line contains the secret, the signature or the body. (tests/test_server_service.py) -
In
tests/test_server.py, withCliRunneranduvicorn.runpatched:--service --workers 2and--service --reloadexit 2; an emptyservice.repos, or noservice.machine_account, exits 1; aDEVOPS_CLI_SERVICE_WEBHOOK_SECRETSthat is not a JSON object exits 1, and the output names the credential but not the value; a valid config callsuvicorn.runonce, withworkers=1and the JSONlog_config, and every line the command prints parses withjson.loads. (tests/test_server.py) -
With
DEVOPS_CLI_SERVICE_WEBHOOK_SECRETSset throughmonkeypatch, the service resolves both repos' secrets, anddevops config showprints neither value. (tests/test_server_service.py,tests/test_server.py) -
git grep -n -E "WebhookEventDispatcher|WebhookEvent\b|GitHubWebhookVerificationError" -- src tests docs/ERRORS.mdprints nothing.git grep -n "def verify_webhook_signature" -- srcprints one line, inserver/routes/webhooks.py.git grep -n CONST_GH_WEBHOOK_SIGNATURE_HEADER -- srcshows the route reading it.uv run devops docs checkpasses. (commands, recorded in the task file) -
The new tests open no sockets and pass under the network guard (
tests/conftest.py:66-160).uv run pytest tests/test_server_service.py --durations=0totals under 1 s, anduv run devops cipasses. (commands) -
changelog.d/752.mdexists;CHANGELOG.mdanddocs/ROADMAP.mdare untouched. (devops pr check-readiness) -
Pending a person: the local smoke check below, run once. It needs no cluster and is not part of the gate.
export DEVOPS_CLI_SERVICE__REPOS='["dan-petty/devops-cli"]' export DEVOPS_CLI_SERVICE__MACHINE_ACCOUNT=example-machine-account export DEVOPS_CLI_SERVICE_WEBHOOK_SECRETS='{"dan-petty/devops-cli":"local-test-secret"}' uv run devops serve --service --port 8787 & body='{"action":"opened","repository":{"full_name":"dan-petty/devops-cli"},"sender":{"login":"someone"}}' sig=$(printf '%s' "$body" | openssl dgst -sha256 -hmac local-test-secret -r | cut -d' ' -f1) id=$(python3 -c 'import uuid; print(uuid.uuid4())') for i in 1 2; do curl -s -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:8787/webhooks/github -H 'Content-Type: application/json' -H 'X-GitHub-Event: issues' -H "X-GitHub-Delivery: $id" -H "X-Hub-Signature-256: sha256=$sig" --data "$body"; done curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8787/readyz curl -s http://127.0.0.1:8787/metrics | grep devops_cli_service_ kill -TERM %1; wait
Expected:
202, then200, then200; the service metrics are listed; every line the service printed is JSON; and the process exits 0 within the drain timeout.
Out of Scope
- What is due, the due table, the per-repo state file and the clones (feat(roadmap): run the roadmap jobs when they are due (
devops roadmap run) #981), and the jobs themselves (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740, feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742, feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743, feat(ai): item refinement to ready with proposed decisions (devops roadmap refine) #744). - The store and its conditional reads (refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768, delivered).
- The GitHub session and the machine account's token (refactor(github): one github session per identity owning token, quota and transport #767); its transport, ledger and pagination (refactor(github): the github session owns transport, ledger, error classes and link pagination #983).
- The image (feat(release): production service image for scheduled jobs and webhook handlers #753).
- The Deployment, the webhook settings, the Ingress path rule and the tunnel route (feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083); the namespace, the
devops-cliSecret and the ConfigMap (feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741). - The registry's histograms, and
devops serve --workers Nfailing outside service mode. - Constraints that hold throughout: only
/webhooks/githubis meant to be reachable from outside the cluster; no job runs inside a request, and no two jobs run for the same repo at once; no new dependency; tests never touch the network or GitHub.
Dependencies
Depends on: none. The tick reads nothing from GitHub, the tests use a fake job function, and nothing here reads session.login, so this item does not wait on #767 (the cross-check corrects #767's claim that it does). #768, which the job function reads through, is delivered (bf746de). #837's network guard shipped in v0.2.24 (e6ce3db, tests/conftest.py:66-160).
Order in v0.2.26 (owner, 2026-10-03): #753, then #741, then #420, with #742 starting in parallel on day one; on the service side #767, then this item, then #1083, then #981 last.
-
feat(cli): extend the ruff rule set to the correctness families #420 (v0.2.26): merges first. It widens the ruff rule set over every file;
server/service.py,server/routes/webhooks.pyandserver/json_logs.pyare written against the widened set. -
refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26): merges before this item. Not a dependency, but both edit
src/devops_cli/github/graphql.pyandsrc/devops_cli/github/__init__.py(767.md:65), and refactor(github): one github session per identity owning token, quota and transport #767's refined body deletestests/test_github_graphql.pywith the client, which this item edits at:212-281and:607-619. With refactor(github): one github session per identity owning token, quota and transport #767 first, this item's rebase drops the hunks that are already gone. -
feat(release): production service image for scheduled jobs and webhook handlers #753 (v0.2.26): independent; its default command runs today's
devops serveon0.0.0.0without the docs routes, and feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 passes--serviceas an argument. No shared files. -
feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 (v0.2.26): depends on this item. It supplies:
- the Deployment, with probes on
/healthzand/readyz, argsserve --service --host 0.0.0.0 --port 8000 --workers 1andterminationGracePeriodSeconds: 150; service.reposandservice.machine_accountin feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741'sdevops-cli-config;- the
DEVOPS_CLI_SERVICE_WEBHOOK_SECRETSpush row; - the webhook settings (
application/json), the Ingress path rule and the tunnel route.
It is proven against this item's log-only function.
- the Deployment, with probes on
-
feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 (v0.2.26, lands before): related. It supplies the namespace, Secret and config the Deployment runs on.
-
feat(roadmap): run the roadmap jobs when they are due (
devops roadmap run) #981 (v0.2.26, lands last): depends on this item. It suppliesdevops roadmap runand theservice_jobadapter thatdevops serve --servicepasses tocreate_service_app(job=...)in place of the log-only function, and builds its due table on theTriggerBatchcontract fixed here. -
refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28): refactor(github): one github session per identity owning token, quota and transport #767's transport half, landing after this item. It answers that the per-repo workers share one session (one process, one identity), edits none of the modules this item adds, and leaves the webhook code to this item.
-
feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740 (v0.2.25): its triggers, and its rule that its own changes never trigger it, are what feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981's due table and this item's machine-account check implement. Not a dependency of this item. -
Design:
CONTEXT.md(Service), ADR 0002, ADR 0003.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
chore(docs): record roadmap service decisions and the machine-account…
feat(release): v0.2.24 (#905)
dan-petty commentedon Oct 3, 2026
References to #741's Deployment now point at #1083 (split 2026-10-03). The webhook secrets reach the pod through #741's
devops-cliSecret, as apush-secretsrow #1083 adds.feat(cli): service mode for devops serve with github webhook verifica…
dan-petty commentedon Oct 4, 2026
What changed
#1171, merged into
release/v0.2.26as aeb4119.27 file(s) changed.
How it was verified
Check runs at f7a2691:
Acceptance Criteria of
docs/agent/tasks/task-752-serve-service-mode.md:tests/test_server_service.pyproves a delivery signed with a repo's secret receives 202 while the job is blocked on an unset event, executing on a separate daemon thread with a coalescedTriggerBatch(counts == {("webhook", "issues", "opened"): 1}). A second delivery receives 202 and coalesces into the pending batch.X-GitHub-Deliverywithin the 10,000 in-memory LRU window receive 202 on initial delivery and 200 on duplicate replay, queueing exactly one trigger.pingevents and deliveries wheresender.loginmatchesservice.machine_account(case-insensitive) receive 200 and queue nothing.Content-Lengthor streaming chunked transfer receive 413.Content-Typeheaders receive 415. MissingX-GitHub-Eventor bodies that are not JSON objects receive 400.TriggerBatchcounts all ten. Different repositories execute concurrently without cross-blocking. Per-repo concurrency never exceeds 1.polltrigger per repo at startup and after eachpoll_interval_secondsinterval.ServiceConfigenforcespoll_interval_seconds >= 60anddrain_timeout_seconds > 0.jobs_total{result="error"}and log details while allowing subsequent triggers to run./readyzreturns 503 prior to startup completion and during shutdown drain, and 200 while ready./healthzreturns 503 if any queue worker or the tick task fails or is cancelled.drain_timeout_secondsfor active jobs to complete while rejecting new webhook requests with 503. Job threads usedaemon=Trueto allow clean termination.POST /webhooks/github,GET /readyz,GET /healthz, andGET /metrics. Unmounted routes (/,/docs,/api/v1/config) return 404.GET /metricsrecordwebhook_deliveries_total,triggers_total,jobs_total,job_seconds_total,job_start_timestamp_seconds, andqueue_depth.time,level,logger,message, and contextual fields, with zero credential/secret/signature leakage.devops serve --servicerejects--workers > 1and--reloadwith exit code 2. Requires non-emptyservice.repos, presentservice.machine_account, and valid JSON object forservice.webhook_secrets(failing with exit code 1 naming the credential).git grep -n -E "WebhookEventDispatcher|WebhookEvent\b|GitHubWebhookVerificationError" -- src tests docs/ERRORS.mdreturns 0 lines. Canonicalverify_webhook_signatureresides insrc/devops_cli/server/routes/webhooks.pyand readsCONST_GH_WEBHOOK_SIGNATURE_HEADER.tests/test_server_service.pytotal under 1 s and open no network sockets.uv run devops cipasses.changelog.d/752.mdcreated;CHANGELOG.mdanddocs/ROADMAP.mdremain untouched.devops serve --service --port 8787, verifying delivery flow, ready probe, and metrics emission.feat(release): v0.2.26 (#1178)