Skip to content

feat(telemetry): the brain first-reads counter shows answered and partial #7388

Backlog

Description

@devops-cli-service

Split from #4682.

Problem or MotivationnThe live proof of #4682 asks devops_cli_brain_first_reads_total{row=alternative} to show answered or partial for at least 30 % of checks. The counter has the label row only (src/devops_cli/telemetry/instruments.py:811). It counts the checks whose item had no entry in the brain index. It has no answered or partial value.nn## Why this part is deferrednThe counter and its values do not exist. The digest of #4682 cannot prove a ratio that the metric does not show. The rest of #4682 does not wait on this counter.nn## Acceptance Criterian- The counter SHALL give the result of the first brain read of a check with the values answered, partial and none.n- A test SHALL assert each value for a fixture first read.n- The live proof of #4682 SHALL read the ratio of answered and partial from that counter.

Proposed design

Problem statement

The brain first-reads counter devops_cli_brain_first_reads_total carries the label row only, and the brain sync records it for the checks whose item the index held no entry for. The live proof of #4682 needs the share of checks whose brain digest answered or partly answered, and this counter cannot show it. This change records the result of each alternatives check's one brain read in the counter, with a result label of answered, partial or none, and keeps row.

Acceptance criteria

Requirement: One count for each brain read

The alternatives check SHALL record one count of devops_cli_brain_first_reads_total for each brain read it makes, with the label row set to alternatives and a label result set to answered, partial or none, and SHALL record no count for a check that reads no brain.

Scenario: Three checks, three counts

  • WHEN a test runs plan_alternatives for three items whose fixture brain index gives one answered, one partial and one none digest, with the otlp fake installed
  • THEN the fake holds three devops_cli_brain_first_reads_total observations, each with row="alternatives" and a result of answered, partial or none

Requirement: Answered first read

The counter SHALL record result="answered" when the digest holds an entry for every near item that the entry of the item names, with the tool entry that the item names, and the cut leaves out no entry.

Scenario: A digest that answers in full

  • WHEN a test runs the alternatives check of an item whose index entry names two near items, both with an entry and a tool entry
  • THEN the recorded metric has devops_cli_brain_first_reads_total{row="alternatives",result="answered"}

Requirement: Partial first read

The counter SHALL record result="partial" when the digest holds at least one entry but a named near item has no entry, a tool entry that the item names is missing, or the cut leaves out an entry.

Scenario: A digest that answers in part

  • WHEN a test runs the alternatives check of an item whose index entry names three near items and the index holds no entry of one of them
  • THEN the recorded metric has devops_cli_brain_first_reads_total{row="alternatives",result="partial"}

Requirement: First read with no entry

The counter SHALL record result="none" when the digest holds no entry, as for an item with no entry in the brain index, an entry with no near item, or a store that does not answer.

Scenario: A digest with no entry

  • WHEN a test runs the alternatives check of an item whose fixture brain index holds no entry of the item
  • THEN the recorded metric has devops_cli_brain_first_reads_total{row="alternatives",result="none"}

Requirement: The brain sync records no first read

The brain sync SHALL NOT record devops_cli_brain_first_reads_total.

Scenario: A sync of one new entry

  • WHEN a test syncs a round that writes one new entry, with the otlp fake installed
  • THEN the fake holds no devops_cli_brain_first_reads_total observation

Requirement: A test asserts each value

A test SHALL assert each of the values answered, partial and none for a fixture first read.

Scenario: Three fixture first reads

  • WHEN the telemetry test runs the alternatives check for a fixture first read of each kind
  • THEN the test asserts one recorded result value for each of answered, partial and none and passes

Requirement: The telemetry reference names the values

The generated telemetry reference SHALL name devops_cli_brain_first_reads_total by row and result, with the values answered, partial and none.

Scenario: The docs check

  • WHEN uv run devops ci --check --only docs runs after uv run devops docs generate
  • THEN the check passes, and the row of devops_cli_brain_first_reads_total in docs/TELEMETRY.md names row and result with the three values

Requirement: Pending a person after the merge

The live proof of #4682 SHALL read the ratio of the answered and partial values of devops_cli_brain_first_reads_total to all of its values.

Scenario: Live proof of #4682

Existing Tool Considered

OpenTelemetry metrics API and SDK, opentelemetry-sdk==1.45.2 (pyproject.toml:52), through Instrument and emit in src/devops_cli/telemetry/instruments.py:40 and :1152. The counter and its label set are what the need requires: the change adds one label value to an existing counter and builds no new metric code. The alternatives check has not run (alternatives is null). It lacks nothing for this need.

Key questions

  • Which file defines the brain first-reads counter, and which label does it carry today?: BRAIN_FIRST_READS_TOTAL is devops_cli_brain_first_reads_total in src/devops_cli/telemetry/instruments.py:811. The brain sync emits it with the label row only, at src/devops_cli/roadmap/brain_sync.py:216, and counts a new entry of an item that the round checked at src/devops_cli/roadmap/brain_sync.py:170. So it records no answered or partial value. [sources: src/devops_cli/telemetry/instruments.py:811, src/devops_cli/roadmap/brain_sync.py:216, src/devops_cli/roadmap/brain_sync.py:170]
  • Where does the counter record its count, and what decides the result of a check's brain read?: In _verdict_check, after read_digest returns the digest (src/devops_cli/roadmap/alternatives.py:1616), with emit (src/devops_cli/roadmap/alternatives.py:227): one count for each brain read, with row and the digest's result. read_digest already knows whether the digest holds every entry it could hold (src/devops_cli/roadmap/brain_digest.py:159). The sync's emission and its first_reads count are deleted (src/devops_cli/roadmap/brain_sync.py:86, :216). (best practice) [sources: src/devops_cli/roadmap/alternatives.py:1616, src/devops_cli/roadmap/alternatives.py:227, src/devops_cli/roadmap/brain_digest.py:159, src/devops_cli/roadmap/brain_sync.py:170, src/devops_cli/roadmap/brain_digest.py:149]
    • Chosen: The check emits the counter after the digest read. The check knows the digest result, makes one read for each check, and counts a read whose model call later fails. No second emitter can double count.
    • Rejected: The sync keeps emitting the counter. The sync sees only the writes of the round (src/devops_cli/roadmap/brain_sync.py:170), not the digest. A first read has no item entry, so its digest is empty (src/devops_cli/roadmap/brain_digest.py:149), and answered and partial cannot appear.
    • Rejected: The check writes a record mark and the sync counts it. It adds a record key, an entry field and a copy, and a check whose model call fails writes no mark, so its read is not counted.
  • Which values does the result label take, and how does the digest decide them?: A BrainFirstRead StrEnum with ANSWERED = "answered", PARTIAL = "partial" and NONE = "none", as BrainRead and BrainWrite hold the values of their result label (src/devops_cli/config/constants.py:2982, :2999). answered is a digest that holds an entry for every named near item and its tool entry, with no entry cut; partial is a digest that holds at least one entry but lost a named near item, a tool entry or an entry to the cut; none is a digest with no entry. (best practice) [sources: src/devops_cli/config/constants.py:2982, src/devops_cli/config/constants.py:2999, src/devops_cli/roadmap/brain_digest.py:159]
    • Chosen: A StrEnum in config/constants.py. The project keeps each result value in an enum beside its instrument (src/devops_cli/config/constants.py:2982, :2999), and a test can assert each member.
    • Rejected: Plain strings at the call site. The value would be unchecked and would not follow BrainRead and BrainWrite.
    • Rejected: Call every non-empty digest answered. It would hide a digest that lost a near item or a tool name, which is what partial is for.
  • Which value does the row label carry?: alternatives (RoadmapJob.ALTERNATIVES, src/devops_cli/roadmap/job_result.py:72), as the sync sets it today (src/devops_cli/roadmap/brain_sync.py:216). The issue writes row=alternative; the live proof must query row="alternatives". [sources: src/devops_cli/roadmap/job_result.py:72, src/devops_cli/roadmap/brain_sync.py:216]
  • Does the live proof of feat(roadmap): the alternatives check reads the brain digest #4682 belong to this change?: No. feat(roadmap): the alternatives check reads the brain digest #4682's tasks list the answered and partial values as the follow-up of this issue (openspec/changes/archive/2026-11-28-4682-alternatives-check-reads-brain-digest/tasks.md:49) and its live proof as its own pending person step (openspec/changes/archive/2026-11-28-4682-alternatives-check-reads-brain-digest/tasks.md:51). This change delivers the counter and its test; the live proof runs after the merge and stays feat(roadmap): the alternatives check reads the brain digest #4682's. It is the criterion named Pending a person after the merge. [sources: openspec/changes/archive/2026-11-28-4682-alternatives-check-reads-brain-digest/tasks.md:49, openspec/changes/archive/2026-11-28-4682-alternatives-check-reads-brain-digest/tasks.md:51]
  • How does a test read the emitted counter?: The otlp fixture installs FakeCollector as the process's exporter (tests/support/fakes/otlp.py:283), and a test reads the metric it emitted, as tests/roadmap/test_brain_sync.py:369 does for the sync. [sources: tests/support/fakes/otlp.py:283, tests/roadmap/test_brain_sync.py:369]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/telemetry
    on Nov 27, 2026
  2. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    ContributorAuthor
  3. added
    source/agent
    status/new
    value/medium
    effort/low
    priority/p2-medium
    on Nov 27, 2026
  4. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See 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/lowpriority/p2-mediumscope/telemetrysource/agentstatus/newtype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions