Repository navigation
Description
Problem or Motivation
The pipeline dashboard (Infinity lists), the start page health widget and the CLI need a read of the roadmap Service state. The Service has no API and turns OpenAPI off.
Proposed Solution & Architectural Design
- The routes of the read API ADR, except the run routes:
GET /api/v1/roadmap/health,/repos,/repos/{owner}/{name}/items,/repos/{owner}/{name}/items/{number},/claims,/budgets,/openapi.json. ValkeyReaderis the only read seam. The routes depend on it alone; a test fake replaces it.- Named tokens from the managed credential
service.api.tokens(a JSON object, token name to token, asservice.webhook_secretsis). Owner decision 2026-11-11: register it as a generated managed credential insrc/devops_cli/k8s/cluster_secrets.pywith onetoken_urlsafe(32)value for each reader (grafana,startpage,cli), sodevops k8s push-secretsmakes the values, keeps them in the keyring, writes the JSON to Secretdevops/devops-cliand each single token to the reader's Secret (namespacesmonitoringand the start page namespace). Agents write no secret value; the person runsuv run devops k8s push-secretsafter the merge. Every token is read-only. A request with no valid token gets 401. The app compares the SHA-256 of the token in constant time.devops k8s push-secretswrites the setting to Secretdevops-cli. FastAPI(openapi_url="/api/v1/roadmap/openapi.json", docs_url=None, redoc_url=None). The webhook routes and the probes haveinclude_in_schema=False. Swagger UI stays off (its page loads files from a CDN).- A snapshot test writes the document and compares it with
docs/roadmap/service-api.openapi.json. - Each answer has
as_ofandlinks./healthreads the sentinel, the halt, the GraphQL hold, thelimitswindow stats and the schedules, and givesstatus(ok,degraded,down). - With
valkey-roadmapdown, the read routes answer 503 and/healthsaysdown. - Each request logs and traces the token name, never the token.
- No new Ingress; the hooks Ingress test still pins
/webhooks/githubas the only public path.
Target Subsystem
SDLC, Git & PR Governance (roadmap Service: src/devops_cli/server/).
Existing Tool Considered
FastAPI routers and its OpenAPI generator (already a dependency). Cost: about 300,000 tokens and 4 hours to build, about 10,000 tokens a month to keep, about 50,000 tokens to fix.
Acceptance Criteria
- The routes above answer with
as_of,linksand one list or object field; lists have a cursor and a limit of 50 (at most 100). - A request with no valid token gets 401.
/api/v1/roadmap/openapi.jsonholds the API router only; the snapshot test passes; probes and webhooks are unchanged and out of the schema./healthreports the sentinel, halt, hold, window stats and schedules.- The token name is a span attribute, and no token value is in a log.
README.mdand the ConfigMap example listservice.api.tokens.
Dependencies
- "feat(service): keep a Valkey read model of each item".
- Person step: the three read token values.
Source: #4517
Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: fastapi/fastapi (https://github.com/fastapi/fastapi), MIT, last activity 2026-11-24, maintained.
Reason: Searches found FastAPI, already a dependency and used for the Service app, as the framework that serves the routes and writes the OpenAPI document; the tokens, envelope, paging, health aggregation and snapshot stay project code.
Covers:
- Route registration with path and query validation
- Generated OpenAPI document at a configurable openapi_url
- Dependency injection seam that a test fake replaces
- ASGI app already serving the webhook router
Lacks:
- Named token credential and SHA-256 constant-time check
as_of/linksenvelope and cursor paging/healthaggregation of sentinel, halt, hold, limits and schedules- Snapshot file and its comparison test
ValkeyReaderread model of items
Proposed design
Problem statement
The roadmap Service keeps its state in Valkey and serves no read API, so the pipeline dashboard, the start page health widget and the CLI cannot read it. This change adds a read-only API under /api/v1/roadmap over the ValkeyReader of the item read model (#4582), with one read-only token for each reader, an OpenAPI document with a snapshot test, and no new Ingress. Swagger UI and ReDoc stay off, and a person runs the secret push after the merge.
Acceptance criteria
Requirement: Read routes are served
The Service SHALL serve GET health, repos, repos/{owner}/{name}/items, repos/{owner}/{name}/items/{number}, claims, budgets and openapi.json under /api/v1/roadmap.
Scenario: Each read route answers a valid token
- WHEN A test client sends a GET request with a valid
clitoken to each read route and the fakeValkeyReaderanswers. - THEN Each route answers 200, and the
openapi.jsonroute answers a JSON document.
Requirement: Read routes depend on ValkeyReader alone
Each read route SHALL read through the ValkeyReader dependency and no other read seam.
Scenario: The fake reader replaces the seam
- WHEN A test builds the Service app with a fake
ValkeyReaderand no Valkey client. - THEN Each read route answers from the fake reader.
Requirement: Each answer holds the envelope
Each read answer SHALL hold as_of, links and one list or object field.
Scenario: The repos answer holds the envelope
- WHEN A request with a valid token reads
/api/v1/roadmap/repos. - THEN The answer holds
as_of,linksand areposlist.
Requirement: A request with no valid token gets 401
The Service MUST refuse a request with no valid token with status 401.
Scenario: An unknown token is refused
- WHEN A request carries no token or a token that no reader of
service.api.tokensholds. - THEN The answer has status 401 and holds no roadmap data.
Requirement: The token check compares SHA-256 digests in constant time
The app MUST compare the SHA-256 digest of a presented token with each stored digest with hmac.compare_digest.
Scenario: A wrong token takes the constant-time path
- WHEN A test sends a wrong token and patches
hmac.compare_digestto record each call. - THEN The check calls
hmac.compare_digestonce for each stored digest and the request gets 401.
Requirement: The token credential is declared
service.api.tokens SHALL be a declared managed credential whose DEVOPS_CLI_SERVICE_API_TOKENS value is a JSON object with one token_urlsafe(32) value for each reader grafana, startpage and cli.
Scenario: The derived value holds one token for each reader
- WHEN A test builds the
devops/devops-clientries with an empty keyring and reads the derivedDEVOPS_CLI_SERVICE_API_TOKENSvalue. - THEN The value is a JSON object with keys
grafana,startpageandcli, and each value is at least 32 characters.
Requirement: The push writes the token map and each reader token
devops k8s push-secrets SHALL write the JSON value to Secret devops/devops-cli and one token to each reader Secret.
Scenario: The push plan names the JSON key and each reader Secret
- WHEN A test plans the push with an empty keyring.
- THEN The plan writes
DEVOPS_CLI_SERVICE_API_TOKENStodevops/devops-cliand one token key to each reader Secret.
Requirement: The Service pod reads the token map
Deployment devops/roadmap-service SHALL read DEVOPS_CLI_SERVICE_API_TOKENS from Secret devops/devops-cli as an optional key, so a pod that starts before the push answers 401 to each read request.
Scenario: The k8s check renders the Service deployment
- WHEN
uv run devops ci --check --only k8sruns. - THEN The command passes.
Requirement: The OpenAPI document holds the read routes only
The Service SHALL serve the OpenAPI document at /api/v1/roadmap/openapi.json with the read routes and no webhook or probe path.
Scenario: Webhooks and probes are out of the schema
- WHEN A test reads the paths of
create_service_app(...).openapi(). - THEN The paths hold each read route and no webhook or probe path.
Requirement: The snapshot test holds the document
A test MUST compare the generated document with docs/roadmap/service-api.openapi.json.
Scenario: A route change without a new snapshot fails
- WHEN The document gains a path and the snapshot file does not change.
- THEN The snapshot test fails and names
docs/roadmap/service-api.openapi.json.
Requirement: Swagger UI and ReDoc answer 404
The app MUST serve no Swagger UI page and no ReDoc page.
Scenario: The docs paths are absent
- WHEN A test requests
/docsand/redoc. - THEN Each answers 404.
Requirement: Health reports each state input
/api/v1/roadmap/health SHALL report the sentinel, the halt, the GraphQL hold, the limits window stats and the schedules.
Scenario: The health answer names each input
- WHEN The fake
ValkeyReaderreports the sentinel, the halt, the GraphQL hold, thelimitswindow stats and the schedules. - THEN The answer holds one field for each input and a
statusvalue.
Requirement: A read route answers 503 when Valkey is down
Each read route MUST answer 503 when the Valkey read fails.
Scenario: The reader raises a connection error
- WHEN The fake
ValkeyReaderraises a connection error on a read route. - THEN The route answers 503 and
/healthanswersstatusdown.
Requirement: Lists page with a cursor
Each list route SHALL take a limit with a default of 50 and a cap of 100, and return a cursor for the next page.
Scenario: Fifty of sixty repos come back with a cursor
- WHEN The fake
ValkeyReaderholds 60 repos and a request reads/reposwith nolimit. - THEN The answer holds 50 repos and a cursor that reads the remaining 10.
Requirement: A limit over 100 is refused
Each list route MUST refuse a limit over 100.
Scenario: A limit of 101 is refused
- WHEN A request sets
limit=101. - THEN The answer has status 422.
Requirement: The token name is a span attribute
Each request MUST record the token name as a span attribute and MUST log no token value.
Scenario: The grafana token names the span
- WHEN A request carries the
grafanatoken. - THEN The span holds
token.name=grafanaand the captured log holds no token value.
Requirement: The documentation lists the token credential
README.md and docs/ENV_VARS.md SHALL list service.api.tokens.
Scenario: The docs name the credential
- WHEN A test in
tests/docs/readsREADME.mdanddocs/ENV_VARS.md. - THEN Each document names
service.api.tokens.
Requirement: The cluster-secret table lists the token credential
The cluster-secret table of k8s/README.md SHALL hold the service.api.tokens row of Secret devops/devops-cli.
Scenario: The README table holds the row
- WHEN
uv run devops ci test tests/invariants/test_k8s_manifests.py -k readme_lists_the_tableruns. - THEN The command passes.
Requirement: The ConfigMap example holds no token value
k8s/devops/configmap.example.yaml SHALL name service.api.tokens in a comment only and SHALL hold no token value.
Scenario: The k8s check accepts the example
- WHEN
uv run devops ci --check --only k8sruns. - THEN The command passes.
Requirement: The read routes stay private
The change MUST add no Ingress, and the Ingress devops/roadmap-service SHALL keep /webhooks/github as its only path.
Scenario: The k8s check keeps the webhook path only
- WHEN
uv run devops ci --check --only k8sruns. - THEN The command passes.
Requirement: Pending a person after the merge
The owner MUST run uv run devops k8s push-secrets after the merge.
Scenario: The push plan shows the token key
- WHEN The owner runs
uv run devops k8s push-secrets --only devops/devops-cli --planafter the merge. - THEN The plan lists
DEVOPS_CLI_SERVICE_API_TOKENSand prints no token value.
Existing Tool Considered
FastAPI (https://github.com/fastapi/fastapi, MIT, verdict in-use). The block of the alternatives check in the issue body lists what FastAPI lacks, and this change supplies and tests each of those parts as project code. The written cost of that code is about 300,000 tokens and 4 hours to build, about 10,000 tokens a month to keep and about 50,000 tokens to fix.
Key questions
- Which open, maintained tool serves the read routes and writes the OpenAPI document?: FastAPI, which the repository already pins and uses for the Service app (
create_service_app). Theblockof the alternatives check in the issue body gives the verdictin-use. The roadmap-specific read seam, tokens, envelope, paging, health aggregation and snapshot stay project code. (best practice) [sources: pyproject.toml, src/devops_cli/server/service.py:1253]- Chosen: FastAPI routers and its OpenAPI generator. It is already a dependency, the repository builds the Service app with it, and the alternatives check gives the verdict in-use.
- Rejected: Litestar. It adds a dependency and repeats what FastAPI already does.
- Rejected: A hand-written OpenAPI document. It drifts from the routes and needs a second test to hold it.
- What is the only read seam, and what does a route answer when Valkey is down?:
ValkeyReaderis the only read seam, and a test fake replaces it. When the Valkey read fails, each read route answers 503 and/healthanswersdown, as the Service's/readyzroute already answers 503 when the Service is not ready. (best practice) [sources: docs/adr/0029-the-roadmap-service-serves-a-read-only-api.md:30, src/devops_cli/server/service.py:1332]- Chosen: One
ValkeyReaderseam with 503 on failure. A test fake replaces the seam, and the existing/readyzroute shows the 503 answer for an unavailable Service. - Rejected: A route that calls the Valkey client directly. Each route would need its own fake and its own outage test.
- Rejected: A cached copy that answers stale data. It hides an outage and needs a second store.
- Chosen: One
- How does the Service hold and check the read tokens?:
service.api.tokensis a declared managed credential, soDEVOPS_CLI_SERVICE_API_TOKENSnames its variable and the generated docs list it. The keyring holds one generated key for each reader (grafana,startpage,cli), as the ACL row of the cache Valkey holds its passwords, and one derived entry builds the JSON object from them: the template doubles the JSON braces, andtoken_urlsafeyields only letters, digits,-and_, whichquoteleaves unchanged. The app reads the JSON, hashes each presented token with SHA-256 and compares withhmac.compare_digest; a request with no valid token gets 401. (best practice) [sources: src/devops_cli/k8s/cluster_secrets.py:137, src/devops_cli/k8s/cluster_secrets.py:523, src/devops_cli/config/env.py:129, src/devops_cli/ai/mcp/remote.py:56]- Chosen: A derived JSON value over one generated entry for each reader.
DerivedSourcebuilds a value from other entries of the same push, as the ACL row does, and keeps one token for each reader. - Rejected: One generated JSON value. No generator makes a JSON object;
SecretGeneratormakes one random value. - Rejected: Three separate managed credentials. It adds three rows, and the body asks for one credential.
- Rejected: One token shared by the three readers. The span cannot name the reader, and a rotation touches all three.
- Chosen: A derived JSON value over one generated entry for each reader.
- In which order does the push resolve a derived entry and its inputs?: The push resolves every entry that is not derived first, so the reader entries generate the tokens and the derived JSON entry reads their values. [sources: src/devops_cli/k8s/cluster_secrets.py:141]
- Which Secret path holds the token map, and does it stay on
devops k8s push-secrets?: Secretdevops/devops-cliholds the map and is a platform Secret of the stack ink8s/, so it stays ondevops k8s push-secrets(ADR 0033, section 1). The same push writes each generated reader token to the reader's Secret, so no person types a value. (best practice) [sources: docs/adr/0033-service-secrets-come-from-external-secrets-operator.md:38, src/devops_cli/k8s/cluster_secrets.py:652]- Chosen: A platform Secret on
devops k8s push-secrets. ADR 0033 keeps a Secret of a stack ink8s/on the push, and the map is a key of Secretdevops/devops-cli. - Rejected: External Secrets Operator for the map. ESO makes a service Secret; the map is a key of the platform Secret that the Service already reads.
- Rejected: A person types the JSON. A typed secret reaches a shell history and a person must invent it, against SECURITY.md rule 1.
- Chosen: A platform Secret on
- Does the read API need a new Ingress?: No. The Ingress
devops/roadmap-serviceholds one path,/webhooks/github, and ADR 0029 keeps the read routes in the cluster only. (best practice) [sources: k8s/devops/roadmap-service/ingress.yaml:18, docs/adr/0029-the-roadmap-service-serves-a-read-only-api.md:62]- Chosen: No new Ingress. The Ingress pins
/webhooks/github, and the read API stays private. - Rejected: A public Ingress for the read API. It exposes roadmap state and needs a second tunnel path.
- Chosen: No new Ingress. The Ingress pins
- Do Swagger UI and ReDoc stay off?: Yes. The Service app builds
FastAPI(docs_url=None, redoc_url=None, openapi_url=None, ...), as the MCP server app does, so this change sets onlyopenapi_urlto/api/v1/roadmap/openapi.jsonand leaves the two page routes off. The Service is cluster-private (ADR 0029, section 6). (best practice) [sources: src/devops_cli/server/service.py:1317, src/devops_cli/ai/mcp/remote.py:131, docs/adr/0029-the-roadmap-service-serves-a-read-only-api.md:62]- Chosen: Keep
docs_url=Noneandredoc_url=None. The repository's two FastAPI apps already turn both off, the page loads files from a CDN, and the Service is private. - Rejected: Serve Swagger UI. It needs a public CDN and widens the reach of a private Service.
- Chosen: Keep
- How do the list routes page?: Each list route takes a
limitwith a default of 50 and a cap of 100, and returns a cursor for the next page. The default follows the 50 of the repository's existing listing reads, the cap follows the 100 of the project item page, and the cursor followsProjectPage.next_cursor, so an insert moves no item across pages. (best practice) [sources: src/devops_cli/github/metrics.py:389, src/devops_cli/config/defaults.py:918, src/devops_cli/github/project_read.py:237]- Chosen: A cursor with
limitdefault 50 and a cap of 100. The repository already pages by cursor with a page size of 100, and its listing reads default to 50, so a cursor holds under writes and the cap bounds one answer. - Rejected: Offset paging. An insert moves an item across pages, and a reader sees it twice or not at all.
- Rejected: No paging. An answer grows without a bound.
- Chosen: A cursor with
- Which inputs set the
/healthstatus?:/healthreads the sentinel, the halt, the GraphQL hold, thelimitswindow stats and the schedules, and givesstatusok,degradedordown. A failed Valkey read givesdown. (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:86, docs/CLUSTER.md:50, docs/adr/0029-the-roadmap-service-serves-a-read-only-api.md:34]- Chosen: One
statusfrom the five inputs. The widget reads one field, and the answer names each input. - Rejected: One field for each input and no status. Each caller repeats the rule that combines them.
- Chosen: One
- Does the ConfigMap example hold a token value?: No. The example's header states that it holds no credential, so it names
service.api.tokensin a comment only. The value is a Secret, and SECURITY.md rule 1 asks for zero plaintext credentials. (best practice) [sources: k8s/devops/configmap.example.yaml:1, SECURITY.md:17]- Chosen: Name the setting in a comment only and hold no token value. The file holds no credential by its own header, and a ConfigMap is not encrypted.
- Rejected: A placeholder token value. A placeholder invites a real value in the same field.
- Who makes the three token values in the cluster?: No person makes a value: the push generates each reader token with
SecretGenerator("urlsafe", 32), which callssecrets.token_urlsafe(32), keeps it in the keyring and writes it to the Secrets. The person runs the push after the merge, and its plan names keys and states, never a value. [sources: src/devops_cli/k8s/cluster_secrets.py:168, SECURITY.md:64]
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 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.Multiple consumers need the API but it is a new feature, not a defect or security fix.The pipeline dashboard, start page widget, and CLI all depend on this read API.Multiple routes, token auth, OpenAPI snapshot test, ValkeyReader seam, and secret wiring span several files.Both concern the roadmap Service's network surface; #1083 sets the Ingress to /webhooks/github only, the candidate adds in-cluster read routes without new Ingress.dan-petty commentedon Nov 11, 2026
Scope from the project brain plan (2026-11-11)
The project brain plan #4624 adds one route to this item (child 15 of that plan).
Problem: the Service dashboard cannot show a list of insights from Prometheus without an id label, which #3851 forbids. The route list of this item has no brain route.
Added scope:
GET /api/v1/roadmap/repos/{owner}/{name}/insights?limit=20: aValkeyReaderoverroadmap:v1:brain-insights:<owner>/<name>and the insight hashes.as_ofand links. No body text (docs(service): decide the roadmap Service read API #4581).valkey-roadmapis down; a cursor, and alimitof at most 50.Added acceptance criteria:
as_ofand no body text.Added dependency: the insights route needs the brain index (#4676). The other routes of this item do not wait for it. The dependency on #4582 stays. This item stays a child of #4517.
devops-cli-service commentedon Nov 13, 2026
Alternatives check: in-use
Reason: FastAPI, which the issue itself names as an existing dependency, is the maintained library that supplies the API router, the configurable OpenAPI document (custom
openapi_url,docs_url=None,include_in_schema=False) and the dependency seam for token auth. It does not supply the roadmap-specific parts: theValkeyReaderread model and its 503 behaviour, the managed credential/token handling, theas_of/linksenvelope with cursors, the health aggregation or the snapshot test, so it covers only part of the issue.The repository already uses this tool.
Tool: fastapi/fastapi (https://github.com/fastapi/fastapi)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-13. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 14, 2026
Refine cannot set this item to Ready at b15faab 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 17, 2026
Owner question: Who makes the three token values in the cluster? (a person decides)
Options
Recommendation: Decide the question: only a person can answer it.
Evidence
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
dan-petty commentedon Nov 21, 2026
Answer to the owner question "Who makes the three token values in the cluster?": no person makes a value.
devops k8s push-secretsgenerates them, and I run the push. This keeps my decision of 2026-11-11. Only the order changes: I push from the branch of the pull request before the merge, not after it (k8s/README.md, Cluster Secrets).Steps, from the branch, before the merge:
uv run devops devcontainer unlock-keyring.uv run devops k8s push-secrets --only devops/devops-cli --plan, with one more--onlyfor each reader Secret that the pull request names. A new derived key showswould create.--plan. It restartsdeployment/roadmap-service. Do not run it during a long stage or implement round.unchanged.Keep the design of
service.api.tokensin this body.After the merge and the release, an agent checks that a read route with no token answers 401 and that a request with the
clitoken answers 200. No token value goes into a log or a comment.devops-cli-service commentedon Nov 21, 2026
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.