Skip to content

feat(roadmap): read the Service state from the CLI #4595

Open

Description

@dan-petty

Problem or Motivation

A person on a workstation reads the roadmap Service state through Grafana, kubectl logs or devops roadmap explain. None gives the health, the budgets, the items and claims of each repository or the runs in one command. The read API gives this state.

Proposed Solution & Architectural Design

  • devops roadmap service status|items|item|runs|budgets read the API.
  • The client uses httpx and the same pydantic models as the routes.
  • It uses service.api.url when it is set, else it opens its own kubectl port-forward, and fails with an error that names the setting when neither works (no unconfigured fallback URL).
  • The token cli comes from the keyring.
  • --dry-run makes no request and returns the would-be request.
  • The MCP generator makes read tools of these commands.
  • feat(roadmap): a run console: follow a run and read its history #3076 (devops roadmap follow) can share the client for the run history.

Target Subsystem

SDLC, Git & PR Governance (CLI: src/devops_cli/commands/roadmap.py).

Existing Tool Considered

httpx and the route models (existing dependencies); kubectl port-forward. Cost: about 200,000 tokens and 3 hours to build, about 10,000 tokens a month to keep, about 30,000 tokens to fix.

Acceptance Criteria

  • Each subcommand prints the answer of its route, with --json output.
  • With no service.api.url and no reachable cluster, the command fails with an error that names service.api.url.
  • --dry-run makes no request.
  • The MCP server lists the read tools.
  • Tests use a fake HTTP edge, not a live Service.

Dependencies

  • "feat(service): serve a read-only roadmap API with OpenAPI".
  • "feat(roadmap): keep a record of each roadmap run" (for runs).

Source: #4517

Alternatives check of 2026-11-23: none.
Tool: none found.
Reason: Searches found only generic HTTP clients (HTTPie) and Kubernetes dashboards (k9s); neither reads the project's roadmap Service routes nor supplies the five subcommands, the port-forward fallback, the keyring token, the dry-run preview or the MCP read tools.

Lacks:

  • No status, items, item, runs or budgets subcommands
  • No service.api.url setting with port-forward fallback
  • No keyring cli bearer token or --dry-run request preview
  • No generated MCP read tools

Proposed design

Problem statement

Build the five devops roadmap service read commands after #4581 and #4582 merge; no design question or person decision remains. A person on a workstation cannot read the roadmap Service state in one command. Grafana, kubectl logs and devops roadmap explain each show only part of the health, budgets, items, claims and runs. The read-only API of #4581 holds this state. This change adds devops roadmap service status|items|item|runs|budgets with --json, --dry-run, keyring authentication and generated MCP read tools.

Acceptance criteria

Requirement: Status command

devops roadmap service status SHALL print the JSON answer of the Service status route when --json is set.

Scenario: Status as JSON

  • WHEN A person runs devops roadmap service status --json against the fake HTTP edge.
  • THEN The command sends one GET to the status path. It prints the JSON body and exits 0.

Requirement: Subcommand set

The service group SHALL provide the status, items, item, runs and budgets subcommands.

Scenario: Help lists the subcommands

  • WHEN A person runs devops roadmap service --help.
  • THEN The output lists status, items, item, runs and budgets.

Requirement: One item

devops roadmap service item MUST read one item, named by its number, and print its JSON answer when --json is set.

Scenario: Item by number

  • WHEN A person runs devops roadmap service item 4595 --json against the fake HTTP edge.
  • THEN The client sends one GET to the item path for 4595. It prints the JSON body.

Requirement: Items list

devops roadmap service items SHALL print the JSON answer of the items route when --json is set.

Scenario: Items as JSON

  • WHEN A person runs devops roadmap service items --json against the fake HTTP edge.
  • THEN The command sends one GET to the items path. It prints the JSON body and exits 0.

Requirement: Runs list

devops roadmap service runs SHALL print the JSON answer of the runs route when --json is set.

Scenario: Runs as JSON

  • WHEN A person runs devops roadmap service runs --json against the fake HTTP edge.
  • THEN The command sends one GET to the runs path. It prints the JSON body and exits 0.

Requirement: Budgets list

devops roadmap service budgets SHALL print the JSON answer of the budgets route when --json is set.

Scenario: Budgets as JSON

  • WHEN A person runs devops roadmap service budgets --json against the fake HTTP edge.
  • THEN The command sends one GET to the budgets path. It prints the JSON body and exits 0.

Requirement: Table output

Each service subcommand SHALL print a table when --json is absent.

Scenario: Status as a table

  • WHEN A person runs devops roadmap service status with no --json.
  • THEN The command prints a table of the status fields and exits 0.

Requirement: Configured base URL

The client SHALL send each request to the base URL that the setting service.api.url gives.

Scenario: Setting names the Service

  • WHEN service.api.url is https://roadmap.example.test and a person runs devops roadmap service budgets.
  • THEN The fake transport records one GET to https://roadmap.example.test at the budgets path. It records no request to another host.

Requirement: Port-forward fallback

The client MUST open its own kubectl port-forward to the Service when service.api.url is not set.

Scenario: No setting and a reachable cluster

  • WHEN service.api.url is not set and the process edge reports that kubectl port-forward starts.
  • THEN The process edge records kubectl port-forward for the Service. The fake transport records one GET to the local port, and the process edge records the stop of the forward.

Requirement: Error names the setting

The command MUST fail with an error that names service.api.url when the setting is not set and no port-forward works.

Scenario: No setting and no cluster

  • WHEN service.api.url is not set and kubectl port-forward fails.
  • THEN The command exits 1 and prints an error that contains service.api.url. The fake transport records no request.

Requirement: Keyring token

The client SHALL send the keyring token cli as a bearer token on each request.

Scenario: Token from the keyring

  • WHEN The keyring holds the token cli and a person runs devops roadmap service status.
  • THEN The request carries the header Authorization: Bearer <token> with the keyring value.

Requirement: Missing token

The command MUST fail with an error that names the keyring entry cli when no token is stored.

Scenario: No token

  • WHEN The keyring has no cli entry and a person runs devops roadmap service status.
  • THEN The command exits 1 and prints an error that contains cli. The fake transport records no request.

Requirement: Dry run

--dry-run MUST make no request and print the request that the command would send.

Scenario: Dry run of status

  • WHEN A person runs devops roadmap service status --dry-run.
  • THEN The command prints the method, the URL and the header names with the bearer token masked. The fake transport records no request, and the process edge records no port-forward.

Requirement: MCP read tools

The MCP server SHALL list one read-only tool for each service subcommand.

Scenario: Tool list

  • WHEN A client lists the tools of the devops-cli MCP server.
  • THEN The list holds a read-only tool for service status, items, item, runs and budgets.

Requirement: Offline tests

The tests MUST use a fake HTTP edge and MUST NOT contact a live Service.

Scenario: Tests with no cluster

  • WHEN The tests of the service commands run with no cluster and no network.
  • THEN Each test passes against the installed transport and opens no socket.

Existing Tool Considered

No open tool covers the need; build the thin client on the project's existing HTTP entry point. The alternatives check in the issue body (2026-11-23) recorded verdict none and named no tool; its block lists what the generic tools lack. The change builds a thin client on the project's devops_cli.http.entry.http_client seam and the existing generate_mcp_tools generator. Written cost: about 200,000 tokens and 3 hours to build, about 10,000 tokens a month to keep, and about 30,000 tokens to fix.

Key questions

  • Which HTTP client does the service group use?: The group uses devops_cli.http.entry.http_client with the private egress level and the read retry policy. The client decodes the pydantic models of the routes. It maps a failed response to a CLI error. (best practice) [sources: ARCHITECTURE.md:211, ARCHITECTURE.md:216, src/devops_cli/http/entry.py:55, src/devops_cli/k8s/service_http.py:45]
    • Chosen: The project's http_client entry point. It is the one place that builds the client, so the egress check, the retry policy and the test seam apply.
    • Rejected: A raw HTTP client. It skips the egress check and the one entry point that ARCHITECTURE.md records.
    • Rejected: A client generated from the OpenAPI document. It adds a generator and a second client that builds its own transport, outside the egress check.
  • Which code opens the port-forward?: A kubectl port-forward subprocess on a free loopback port. The client starts it and stops it for the one command. It uses the project's process helpers and the liveness check of port_forward_daemon, not the long-lived daemon manager. (best practice) [sources: src/devops_cli/k8s/port_forward_daemon.py:1, src/devops_cli/commands/k8s/networking.py:1041]
    • Chosen: kubectl port-forward subprocess. It uses the kubectl that the CLI already needs, forwards one Service for one command, and reuses the project's process and liveness helpers.
    • Rejected: txn2/kubefwd. It forwards every Service of a namespace and runs as a long-lived process, not for one command.
    • Rejected: The k8s:// service proxy. The API server consumes the Authorization header, so the Service's cli bearer token cannot reach it. It also needs services/proxy RBAC.
    • Rejected: A port-forward through the Kubernetes Python client. It adds a websocket path and more code than the subprocess.
  • How do the tests reach the API with no live Service?: They install the project's HTTP transport seam with install_transport and the web fixture. The fake answers on a mock transport. No test opens a socket. (best practice) [sources: ARCHITECTURE.md:211, src/devops_cli/http/entry.py:227, tests/support/fakes/http.py:171]
    • Chosen: The web fixture and install_transport. It replaces the transport that the entry point builds, so the real client, egress level and retry policy stay in the test.
    • Rejected: A raw mock transport outside the seam. It bypasses the entry point and tests a client that the product does not build.
    • Rejected: A live Service in CI. It needs a cluster and a token, and the tests must run offline.
    • Rejected: The responses library. It adds a dependency that the project's transport seam replaces.
  • How does the client find the base URL of the Service?: It reads service.api.url, a new nested field of the service settings group. When the setting is empty, it opens its own kubectl port-forward to the Service. When both fail, it exits 1 with an error that names service.api.url. (best practice) [sources: src/devops_cli/config/settings.py:1566, src/devops_cli/k8s/service_http.py:45]
    • Chosen: Setting, then port-forward, then error. A person reaches a deployed Service with the setting, and a local cluster with no setup.
    • Rejected: Setting only. A person with a local cluster must set the URL by hand in each shell.
    • Rejected: Port-forward only. It ignores a deployed Service that the setting names.
    • Rejected: A default URL when both fail. It sends the request to a host that nobody named.
  • Where does the client get the token for the read API?: From the keyring entry cli in the devops-cli service, read with get_keyring_secret('cli'). The client sends it as Authorization: Bearer <token>. When the entry is missing, the command exits 1 with an error that names cli and sends no request. (best practice) [sources: src/devops_cli/config/os_keyring.py:191, src/devops_cli/config/constants.py:28]
    • Chosen: The keyring entry cli. The workstation keyring holds the secrets of the CLI, and no secret lands in a file or a shell history.
    • Rejected: An environment variable. A shell history and a process listing show the value.
    • Rejected: The settings file. The value is a secret, and a plain file holds it.
  • What does --dry-run print, and what does it send?: It prints the method, the URL and the headers of the would-be request through the @dry_run_class("request-plan") path, with the bearer token masked. It sends no request and starts no port-forward. (best practice) [sources: src/devops_cli/commands/roadmap.py:1014, src/devops_cli/roadmap/request_plan.py:1280, src/devops_cli/dry_run/decorator.py:22]
    • Chosen: Print the would-be request and send nothing. It matches the --dry-run rule of every roadmap command.
    • Rejected: Send the request and discard the answer. The rule says that a dry run makes no request.
  • How do the read tools reach the MCP server?: The five commands join CONST_MCP_EXPOSURE_TABLE as read-only entries. generate_mcp_tools registers one tool for each from the command metadata. (best practice) [sources: src/devops_cli/config/constants.py:306, src/devops_cli/ai/mcp/generator.py:528]
    • Chosen: The exposure table and generate_mcp_tools. One table stays the only list of the tools and their read-only mark.
    • Rejected: Hand-written tools in server.py. A second list drifts from the commands.
    • Rejected: FastMCP's OpenAPI generator. It builds a second tool set from the API document and bypasses the CLI registry, the dry run and the keyring token.
  • How does each subcommand format its output?: A table by default and the route JSON with --json, through resolve_format and emit_serialized. (best practice) [sources: src/devops_cli/output/serialization.py:43, src/devops_cli/output/serialization.py:90, src/devops_cli/commands/roadmap.py:1039]
    • Chosen: A table by default and --json. It matches roadmap explain and roadmap plan-check.
    • Rejected: JSON only. A person at a terminal reads a table faster.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#4581, #4582, #4586, #4589

Activity

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

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Useful CLI convenience but not blocking; users can still read state via Grafana or kubectl logs.
    • Value: Medium. Gives a person one command to read all Service state, replacing several manual steps.
    • Effort: Medium. Body estimates about 3 hours to build with existing dependencies (httpx, pydantic models).
    • Related: feat(roadmap): a run console: follow a run and read its history #3076, which asks for a different change. Both read run history from the Service, but the candidate builds multiple CLI subcommands (status, items, item, runs, budgets) while #3076 builds a single follow command for live trace.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 13, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches turned up only generic building blocks — HTTP client libraries such as httpx, a bulk Kubernetes service-forwarding helper (kubefwd) and an OpenAPI-to-MCP framework (fastmcp) — and none of them reads the roadmap Service's status, items, claims, runs or budgets. The state sits behind the project's own read-only API, so the subcommands, keyring cli token, service.api.url/port-forward fallback, --dry-run and generated MCP read tools are new code the issue itself has to build on those dependencies.

    Tool: none found

    Lacks:

    • A CLI with service status|items|item|runs|budgets subcommands over the roadmap read API
    • Responses parsed with the same pydantic route models and --json output
    • service.api.url setting with a fallback that opens its own kubectl port-forward and a clear error when neither works
    • Authentication with the cli token from the keyring
    • --dry-run that makes no request and returns the would-be request
    • Read-only MCP tools generated from these commands
    • A shared client for the run history of feat(roadmap): a run console: follow a run and read its history #3076
    • A fake HTTP edge for tests instead of a live Service

    Tools considered:

    Searches run:

    • generate CLI client from OpenAPI spec read-only API commands, results: 5
    • CLI tool to query Kubernetes service API with automatic kubectl port-forward, results: 5
    • kubefwd port-forward Kubernetes services for local development CLI, results: 5
    • openapi-python-client generate typed Python client from OpenAPI, results: 5
    • FastMCP generate MCP tools from OpenAPI spec, results: 5
    • httpx Python HTTP client library github, results: 5
    • command line client for internal REST API keyring token authentication dry-run, results: 5

    Sources:

    Checked on 2026-11-13. 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 14, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at b15faab while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  7. devops-cli-service commented on Nov 26, 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/roadmapsource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions