Skip to content

chore(telemetry): measure run records and cache-read share after release #6238

Open

Description

@devops-cli-service

Split from #5460.

Problem: The new run, step, path-class and cache-read records need a measurement on real runs. A pull request cannot show this measurement before a release. Deferral: the proof waits on a release and on real Service runs. Acceptance criteria: after release, one Prometheus query gives the cache-read share of the rows stage and refine. The count of step start lines of each implement run equals its count of groups. The next start-context review gives, for each run, the first 10 calls by tool, the calls of retry runs, the repeat reads, and the cache-read share of each row. The issue records the query and the result.

Proposed design

Problem statement

The records of #5460 for runs, steps, path classes and cache reads need a measurement on real Service runs. A pull request cannot show this measurement before a release. This item records one PromQL query and its result for the cache-read share of the stage row and of the refine row. It compares the step start lines of each implement run with its task groups. It records the tool calls, the retry calls, the repeat reads and the cache-read share in the next start-context review.

Acceptance criteria

Requirement: Cache-read share query

The item MUST record one PromQL expression that gives the cache-read share of the stage row and of the refine row.

Scenario: One expression gives one share for each row

  • WHEN A person runs the recorded expression on the Service Prometheus after the release that writes devops_cli_ai_tokens_total{type="cache_read"}.
  • THEN The result holds one series for row="stage" and one for row="refine", and each value is between 0 and 1.

Requirement: Step start count

The item MUST show that the count of step start lines of each implement run equals the count of task groups that have an unticked task at the start of that run.

Scenario: One implement run has one step start line for each unticked group

  • WHEN A live check counts the step start lines of one implement run in Loki and counts the task groups of its change that had an unticked task at the start of the run.
  • THEN The two counts are equal.

Requirement: Start-context review record

The next start-context review MUST record for each run the first 10 calls by tool, the calls of the retry runs, the repeat reads and the cache-read share of each row.

Scenario: The review gives the four items for each run

  • WHEN The next start-context review runs after the release.
  • THEN Its record gives the first 10 calls by tool, the retry calls, the repeat reads and the cache-read share of each row.

Requirement: Pending a person after the merge

A person MUST record the query text and its result in one comment on issue #6238 after the measurement.

Scenario: One comment holds the query text and the result

Existing Tool Considered

No alternatives check has run on this item. Prometheus with PromQL covers the cache-read share query of the stage and refine rows. Loki with LogQL covers the count of step start lines of an implement run. Both tools are open and maintained. Prometheus lacks log-line counting, and Loki lacks metric arithmetic. The item adds no code, so it has no build cost.

Key questions

  • Which PromQL expression gives the cache-read share of the stage and refine rows?: The share is the cache-read tokens divided by the prompt tokens of the row. Use one expression with a 7-day window and a zero for a row with no cache-read series: (sum by (row) (increase(devops_cli_ai_tokens_total{type="cache_read",row=~"stage|refine"}[7d])) or on (row) 0 * sum by (row) (increase(devops_cli_ai_tokens_total{type="prompt",row=~"stage|refine"}[7d]))) / sum by (row) (increase(devops_cli_ai_tokens_total{type="prompt",row=~"stage|refine"}[7d])). The cache_read series exists only when its count is above 0. The or on (row) part gives 0 to a row with no cache reads. The 7-day window matches the live proof that reads the values 7 days after the merge. (best practice) [sources: src/devops_cli/ai/spend/ledger.py:1099, openspec/specs/command-telemetry/spec.md:327, docs/guidelines/agentic-jobs.md:107, docs/ROADMAP_WORKFLOW.md:286]
    • Chosen: One expression with a 7-day increase, sum by (row), and an or on (row) zero. One query gives one share for each row. A row with no cache read gets 0. The 7-day window matches the live-proof precedent.
    • Rejected: One expression with a 24-hour window. A day holds too few real runs for a stable share.
    • Rejected: Two expressions, one for each row. The body asks for one query that gives both rows.
    • Rejected: An instant rate expression. A rate needs a short window and is noisy. An increase over the stated window gives the share.
  • Which row labels do the stage and the refine records carry?: The row label carries the job row of the Service. The stage command sets row="stage" on its request scope. The refine run sets row="refine" on its RunTrace, and the run loop sets the request scope to the job row. [sources: src/devops_cli/commands/roadmap_jobs.py:628, src/devops_cli/roadmap/refine/refine.py:4656, openspec/specs/ai-spend-pricing/spec.md]
  • Does the count of step start lines of one implement run equal the count of task groups of its change?: The runner logs one step start group=<n> line when each implement step begins. The implement job makes one step for each task group that has an unticked task. So the two counts are equal when every group has an unticked task at the start of the run. A run that resumes an item with ticked groups logs fewer step start lines than the change has groups. [sources: src/devops_cli/roadmap/implement/implement_step.py:2593, openspec/specs/roadmap-implement-step/trace/spec.md:333, CONTEXT.md:146]
  • Which record holds the first 10 calls by tool, the retry calls and the repeat reads that the start-context review gives for each run?: The record is RunTrace.tool_calls. The stage job writes it into the stage comment on the item issue with run_report, one group for each run_index and its row. Each ToolCallRecord holds name, masked argument, outcome, run_index and row. A retry run has its own run_index group, so the calls of a retry run are the calls of that group. A repeat read is a read_file call with the same path argument. [sources: src/devops_cli/roadmap/agent_run.py:404, src/devops_cli/roadmap/stage/stage.py:3938, openspec/specs/roadmap-stage/toolbox/spec.md:341, tests/roadmap/stage/test_roadmap_stage_trace_runs.py:131]
  • Where does the item keep the query and the result?: One comment on issue chore(telemetry): measure run records and cache-read share after release #6238 holds the query text and the result table for the stage and refine rows. The body asks the issue to record the query and the result. The item adds no file, because the record is one measurement. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:286]
    • Chosen: One comment on issue chore(telemetry): measure run records and cache-read share after release #6238. The body asks the issue to record the query and the result.
    • Rejected: One new document under docs/. It adds a file to keep for one measurement.
    • Rejected: The body of the issue. Each refine round rewrites the refine block of the body.
    • Rejected: One dashboard panel query in k8s/devops/dashboard_queries/devops-roadmap-service.yaml. The item records one measurement. A panel adds a chart and keeps no record of the measurement.

Fit

Fits in one pull request.

Suspected block

The next devops-cli release that holds the records of #5460, and the real Service runs after that release.

Dependencies

#5460

Watched files

A commit on the default branch that changes one of these files starts the next refine round.

  • src/devops_cli/ai/spend/ledger.py
  • src/devops_cli/roadmap/agent_run.py
  • src/devops_cli/roadmap/stage/stage.py
  • src/devops_cli/telemetry/instruments.py

Activity

  1. added
    type/chore
    scope/telemetry
    source/agent
    status/new
    value/medium
    effort/low
    on Nov 18, 2026
  2. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    ContributorAuthor
  3. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    Refine cannot set this item to Ready at 6ff83d4 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.

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

    @devops-cli-service
    ContributorAuthor

    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.

  5. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

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

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

    Evidence

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

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

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

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

    Evidence

  7. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

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

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

    Evidence

  8. devops-cli-service commented on Dec 1, 2026

    @devops-cli-service
    ContributorAuthor

    Owner question: See Suspected block and Watched files in the section Proposed design of the body.

    Options

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

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

    Evidence

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/lowpriority/p2-mediumscope/telemetrysource/agentstatus/newtype/chorevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions