Repository navigation
Description
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_alternativesfor three items whose fixture brain index gives one answered, one partial and one none digest, with theotlpfake installed - THEN the fake holds three
devops_cli_brain_first_reads_totalobservations, each withrow="alternatives"and aresultofanswered,partialornone
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
otlpfake installed - THEN the fake holds no
devops_cli_brain_first_reads_totalobservation
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
resultvalue for each ofanswered,partialandnoneand 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 docsruns afteruv run devops docs generate - THEN the check passes, and the row of
devops_cli_brain_first_reads_totalindocs/TELEMETRY.mdnamesrowandresultwith 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
- WHEN the live proof of feat(roadmap): the alternatives check reads the brain digest #4682 runs on the cluster after this change merges
- THEN the proof shows the ratio of
answeredandpartialto all first reads, fromdevops_cli_brain_first_reads_total{row="alternatives"}
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_TOTALisdevops_cli_brain_first_reads_totalinsrc/devops_cli/telemetry/instruments.py:811. The brain sync emits it with the labelrowonly, atsrc/devops_cli/roadmap/brain_sync.py:216, and counts a new entry of an item that the round checked atsrc/devops_cli/roadmap/brain_sync.py:170. So it records noansweredorpartialvalue. [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, afterread_digestreturns the digest (src/devops_cli/roadmap/alternatives.py:1616), withemit(src/devops_cli/roadmap/alternatives.py:227): one count for each brain read, withrowand the digest's result.read_digestalready knows whether the digest holds every entry it could hold (src/devops_cli/roadmap/brain_digest.py:159). The sync's emission and itsfirst_readscount 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), andansweredandpartialcannot 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
resultlabel take, and how does the digest decide them?: ABrainFirstReadStrEnum withANSWERED = "answered",PARTIAL = "partial"andNONE = "none", asBrainReadandBrainWritehold the values of theirresultlabel (src/devops_cli/config/constants.py:2982,:2999).answeredis a digest that holds an entry for every named near item and its tool entry, with no entry cut;partialis a digest that holds at least one entry but lost a named near item, a tool entry or an entry to the cut;noneis 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 eachresultvalue 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
BrainReadandBrainWrite. - Rejected: Call every non-empty digest answered. It would hide a digest that lost a near item or a tool name, which is what
partialis for.
- Chosen: A StrEnum in
- Which value does the
rowlabel 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 writesrow=alternative; the live proof must queryrow="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
answeredandpartialvalues 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 namedPending 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
otlpfixture installsFakeCollectoras the process's exporter (tests/support/fakes/otlp.py:283), and a test reads the metric it emitted, astests/roadmap/test_brain_sync.py:369does 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
devops-cli-service commentedon Nov 27, 2026
Both add a value to a counter so a ratio can be charted, but #812 targets devops_cli_findings_total by verdict while this targets devops_cli_brain_first_reads_total by read result.devops-cli-service commentedon Nov 28, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.