Skip to content

feat(roadmap): the alternatives check reads the brain digest #4682

Done

Description

@dan-petty

Problem or Motivation

Each alternatives check sees only its own item (alternatives_request, src/devops_cli/roadmap/alternatives.py:825). 4 open merge-conflict items got 4 different tools (#3968, #3969, #4027, #4076). Durable-run items got 5 tools, and ADR 0008 rejects 2 of them. A decision on one item is not used again on the next item.

Proposed Solution & Architectural Design

Target Subsystem

SDLC, Git & PR Governance (the roadmap alternatives check).

Existing Tool Considered

The brain index (Valkey through valkey-py) and the existing investigate run of the alternatives check. No new tool and no extra model call. Cost: about 100,000 tokens and 3 hours to build.

Acceptance Criteria

  • A test: the digest of a fixture brain holds the near verdicts and stays under 2,000 tokens.
  • A test (T8): with Valkey down, the check writes the verdict of today.
  • Live, 7 days: prompt tokens for each check rise by at most 1,500 (devops_cli_ai_tokens_total{row="alternatives"} over checks).
  • Live, 7 days: devops_cli_brain_first_reads_total{row="alternatives"} shows answered or partial for at least 30 % of checks. Fact of 2026-11-26: the counter that feat(roadmap): keep alternatives results in a brain index #4676 built has the label row only, and it counts the checks whose item had no entry in the index (src/devops_cli/telemetry/instruments.py:811). It has no answered or partial value.

Dependencies

#4676, #4672. Part of the project brain plan #4624.

Source: #4624

Owner decision 2026-11-13

The approved pipeline split (tracker #5482, Phase 6) keeps this scope in the alternatives step of the research unit.

  • Live proof: after the merge and the release, the alternatives step runs as the App on 3 items of the stage window. A comment gives the result lines and the digest entries that it read.

Alternatives check of 2026-11-26: none.
Tool: none found.
Reason: Searches found only general agent memory layers such as mem0, which keep their own vector store and extract memories with extra model calls; none builds a dated digest of this project's brain index with rings, ADR status and the area verdict.

Lacks:

  • No digest of the existing Valkey brain index
  • No ring or in-force ADR status for a tool
  • No 2,000-token cut over whole entries
  • Memory writes need extra model and embedding calls

Proposed design

Problem statement

Each alternatives check sees only its own item, so a decision on one item is not used on the next item. Four open merge-conflict items got four different tools, and durable-run items got five tools that ADR 0008 partly rejects. This change gives each check a dated digest of the project brain before its one model call, bounded at 2,000 tokens, and records the brain entries that the digest used.

Acceptance criteria

Requirement: The digest holds the near items of the index entry

The alternatives check SHALL build the digest from the near field of the item's entry in the brain index, and SHALL hold at most 5 near items with their verdicts and canonical tool ids.

Scenario: Five near items

  • WHEN the fixture brain holds an entry for the item whose near field lists 5 items, each with a verdict and a canonical tool id
  • THEN the digest holds the 5 items with their verdicts and canonical tool ids

Requirement: The digest stays at or below 2,000 tokens

The digest SHALL stay at or below 2,000 tokens, and SHALL cut whole entries to do so.

Scenario: More entries than the cap

  • WHEN the fixture brain holds entries whose total is more than 2,000 tokens
  • THEN the digest holds whole entries only, and its token count is at most 2,000

Requirement: Each digest fact has its date

The digest SHALL hold the date of each fact that it takes from the brain index.

Scenario: A dated verdict

  • WHEN the fixture brain holds a verdict with the date 2026-11-01
  • THEN the digest holds that verdict with the date 2026-11-01

Requirement: The digest holds the ADR status of a tool

The digest SHALL hold the number of each ADR in force that rejects a tool that the digest names.

Scenario: A tool that an ADR rejects

  • WHEN the fixture brain names a tool, and a fixture ADR in force rejects that tool under a rejected option
  • THEN the digest holds the tool with the number of that ADR

Requirement: The digest holds the area verdict

The digest SHALL hold the area verdict when the brain index holds an area check for the item's area.

Scenario: An area check

  • WHEN the fixture brain holds an area check for the item's area with the verdict partly
  • THEN the digest holds the area verdict partly

Requirement: The request holds the digest

alternatives_request SHALL hold the digest under the key brain, and SHALL hold no brain key when the digest is empty.

Scenario: A digest and an empty digest

  • WHEN the digest holds 2 near items, and a later request of another item has an empty digest
  • THEN the first request holds the key brain with 2 entries, and the second request holds no brain key

Requirement: The digest adds no model call

The check SHALL add the digest to its existing model request and SHALL make no extra model call.

Scenario: One model call

  • WHEN one item is checked with a digest of 5 near items, and the same item is checked with an empty digest
  • THEN each run makes the same number of model calls

Requirement: No brain gives an empty digest

The check SHALL use an empty digest and SHALL run as today when the brain is unavailable.

Scenario: Valkey down

  • WHEN the Valkey read fails, the index is not built, or the run is on a workstation
  • THEN the request holds no brain key, and the check writes the verdict of its reply

Requirement: The digest switch turns the digest off

The setting roadmap.brain.digest SHALL take off or on, SHALL default to on, and SHALL make no brain read when it is off.

Scenario: The default and the off value

  • WHEN roadmap.brain.digest is unset in one run and set to off in the next run
  • THEN the first run reads the brain, and the second run makes no brain read and its request holds no brain key

Requirement: The check records the brain entries that it used

A written check SHALL record alternatives.brain_used with the ids of at most 10 brain entries that its digest used.

Scenario: Eleven entries

  • WHEN the digest takes 11 brain entries
  • THEN alternatives.brain_used holds 10 entry ids, and the check writes one PATCH of the issue

Requirement: The digest requirements live in a nested capability

The change SHALL add the digest requirements to the nested capability openspec/specs/project-brain/digest/spec.md, and SHALL add no requirement to openspec/specs/roadmap-alternatives/spec.md.

Scenario: The nested capability holds the digest requirements

  • WHEN a person runs uv run devops openspec check and git grep -c '^### Requirement:' openspec/specs/roadmap-alternatives/spec.md
  • THEN uv run devops openspec check exits 0, and the grep prints at most 80 requirements for openspec/specs/roadmap-alternatives/spec.md

Requirement: Pending a person after the merge

After the merge and the release, the alternatives step SHALL run as the App on 3 items of the stage window, and a comment SHALL give the result lines, the digest entries and the token rise of each check.

Scenario: The live proof of the digest

  • WHEN a person runs the alternatives step as the App on 3 items of the stage window after the release, and 7 days pass
  • THEN a comment gives the result line of each item, the brain entries of each digest, and the lines of devops_cli_ai_tokens_total{row="alternatives"} that rise by at most 1,500 per check

Existing Tool Considered

The alternatives check of 2026-11-26 in the issue body gives the verdict none and names no tool. Its Lacks: list gives what no tool covers: a digest of the existing Valkey brain index, the ADR status of a tool, the 2,000-token cut over whole entries, and no extra model call. The change builds the digest in-house for about 100,000 tokens and 3 hours of build, keep and fix work. It reads the existing Valkey brain index through src/devops_cli/valkey/tiered.py, adds no dependency, and adds no model call.

Key questions

  • Where does the check build the digest, and does it add a model call?: _check_one builds the digest before its one model call at src/devops_cli/roadmap/alternatives.py:1527, and passes it to alternatives_request at src/devops_cli/roadmap/alternatives.py:829. alternatives_request adds the digest under the key brain of the existing request. The check makes no extra model call. (best practice) [sources: src/devops_cli/roadmap/alternatives.py:829, src/devops_cli/roadmap/alternatives.py:1527, openspec/specs/roadmap-alternatives/spec.md]
    • Chosen: Build the digest in _check_one and add it to the existing request. It adds no model call and no dependency, and _check_one holds the store and builds the request.
    • Rejected: A second model call that summarizes the brain. It adds cost and latency, and the issue rules out an extra model call.
  • Which list gives the 5 near items of the digest?: The digest reads the near field of the item's entry in the brain index at src/devops_cli/roadmap/brain_sync.py:137. The field lists at most 5 other items of the repository that name the same tool, the newest check first. (best practice) [sources: src/devops_cli/roadmap/brain_sync.py:137, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md]
  • What does the digest hold, and how is it bounded?: The digest holds the near items, each with its date, verdict and canonical tool id. It holds the ADR status of each tool and the area verdict when one exists. It cuts whole entries at 2,000 tokens. (best practice) [sources: docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, CONTEXT.md, src/devops_cli/roadmap/brain_index.py:222]
    • Chosen: The near items with dated verdicts, tools, ADR status and the area verdict. It gives the model the nearest decisions in one block that fits the 2,000-token budget of ADR 0023.
    • Rejected: Every brain entry of the item's area. It exceeds the 2,000-token cap and the prompt budget.
  • Which token count bounds the digest?: The digest reuses the token count that the check already makes on the ADR text with CONST_ROADMAP_ALTERNATIVES_MAX_ADR_TOKENS at src/devops_cli/config/constants.py:3896. The change adds a constant for the 2,000-token cap and adds no tokenizer dependency. (best practice) [sources: src/devops_cli/config/constants.py:3896, src/devops_cli/roadmap/alternatives.py]
    • Chosen: Reuse the token count of the ADR cut. The check already counts the ADR text, so the digest needs no new dependency.
    • Rejected: Add a new tokenizer dependency. It adds a dependency for a count that the check already makes.
  • What does the check do when the brain is unavailable?: The digest is empty, the request holds no brain key, and the check runs as today. A slow or down Valkey, an index that is not built, and a workstation take this path. The tiered mapping sends no error to the caller while Valkey fails. (best practice) [sources: src/devops_cli/valkey/tiered.py, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, CONTEXT.md]
    • Chosen: Empty digest and run as today. ADR 0023 gives this path for a cache failure, and the failure does not change the verdict.
    • Rejected: Skip the item when the brain is down. It stops the check for a failure that does not change the verdict.
  • What is the default of roadmap.brain.digest?: The setting takes off or on and defaults to on. The empty-digest fallback keeps the check safe when the brain is down. The live proof of the owner decision needs the digest on after the release. (best practice) [sources: src/devops_cli/config/defaults.py, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, docs/ROADMAP_WORKFLOW.md]
    • Chosen: Default on. ADR 0023 records the digest as the input of the check, and the empty-digest fallback covers a brain that is down.
    • Rejected: Default off until the live proof. The off-by-default rule governs a decision step in roadmap.decisions (ADR 0020); the digest makes no decision, and off would leave the live proof without the digest.
  • What does alternatives.brain_used record, and where is it written?: It records the ids of at most 10 brain entries that the digest used. The check writes it in the one PATCH that carries its block and its other marks. (best practice) [sources: openspec/specs/roadmap-alternatives/spec.md, src/devops_cli/roadmap/alternatives.py]
    • Chosen: The used entry ids, capped at 10. It shows which entries shaped the verdict and keeps the record small in the one PATCH.
    • Rejected: Record the digest text. It copies prompt text into the issue body and grows the record.
  • Which capability holds the digest requirements?: The nested capability openspec/specs/project-brain/digest/spec.md. The roadmap-alternatives capability is at the 80-requirement limit of openspec/config.yaml:24, so it gets no new requirement. (best practice) [sources: openspec/config.yaml:24, openspec/specs/roadmap-alternatives/spec.md]
    • Chosen: Nested capability openspec/specs/project-brain/digest/spec.md. The roadmap-alternatives capability holds 80 requirements, which is the limit of a capability.
    • Rejected: Add the requirements to openspec/specs/roadmap-alternatives/spec.md. It exceeds the 80-requirement limit of one capability.
  • Which pipeline step holds the brain digest?: The alternatives step of the research unit. The owner decision of 2026-11-13 in the issue body keeps this scope in that step (tracker feat(roadmap): track the roadmap pipeline split into jobs #5482, Phase 6). (best practice) [sources: docs/ROADMAP_WORKFLOW.md]
    • Chosen: Keep the scope in the alternatives step. The owner decision of 2026-11-13 records the approved pipeline split of tracker feat(roadmap): track the roadmap pipeline split into jobs #5482 and keeps the digest in that step.
    • Rejected: Move the digest to the retrieval step of the research unit. The owner decision keeps it in the alternatives step, and ADR 0023 puts the digest in the check of one item.
  • Where does the project brain live?: Valkey holds the project brain index. The check reads it through the tiered mapping of the process and the shared cache tier at src/devops_cli/valkey/tiered.py. The change adds no store. [sources: CONTEXT.md, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, src/devops_cli/valkey/tiered.py, src/devops_cli/roadmap/brain_index.py]
  • Why does the digest hold no ring of a tool?: The brain index holds no ring at src/devops_cli/roadmap/brain_index.py:222, and feat(roadmap): the brain files project insights through intake #4693, which gives the ring, is not built. The ring is deferred to its own issue. [sources: src/devops_cli/roadmap/brain_index.py:222]
  • Why does the live proof use no answered or partial value?: devops_cli_brain_first_reads_total has the label row only at src/devops_cli/telemetry/instruments.py:811, and it counts the checks whose item had no entry in the index. It has no answered or partial value. That part of the live proof is deferred to its own issue. [sources: src/devops_cli/telemetry/instruments.py:811]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Moved to new items

#7388, #7389

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. The change improves decision consistency across items but does not fix a defect or block a release.
    • Value: Medium. Consistent tool verdicts reduce rework and user confusion across related items.
    • Effort: Medium. Building the digest, adding the switch, writing two tests, and updating the spec is a focused but multi-part change.
    • Related: feat(roadmap): the Service runs the alternatives job once a day, and refine reads the recorded tool verdict #2652, which asks for a different change. Both items extend the alternatives check execution flow, but 2652 adds scheduling and refine reading the verdict while the candidate adds a brain digest as input context to the check itself.
  4. added
    priority/p2-medium
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches turned up only generic retrieval/tokenising frameworks (e.g. llama-index, MIT), none of which builds a digest from this project's own brain index or feeds it into the existing alternatives check. The issue itself asks for no new tool and no extra model call: the digest is built in-repo from the existing brain index (Valkey through valkey-py, in-memory cosine), and ADR 0023 rejected a vector store for those entries, so no external tool covers the need.

    Tool: none found

    Lacks:

    • No tool builds a ≤2,000-token digest from the project's brain index (the item's 5 nearest items, their verdicts and canonical tools, ring/ADR status, area verdict) with a date on each fact.
    • No tool records alternatives.brain_used or reads the roadmap.brain.digest off/on switch.
    • No tool keeps the empty-digest fallback when Valkey is slow or down, the index is unbuilt, or the run is on a workstation.
    • A general framework such as llama-index would add a new dependency and its own index, which the issue rules out and ADR 0023 rejected as a vector store for the entries.

    Tools considered:

    Searches run:

    • valkey-py vector similarity search in-memory cosine nearest neighbours python, results: 5
    • python library build token-bounded digest of nearest items for LLM prompt context, results: 5
    • tiktoken token counting library GitHub, results: 5
    • langchain retriever document compressor token limit context injection, results: 5
    • llama-index VectorStoreIndex nearest neighbours retrieval package, results: 5

    Sources:

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

    @devops-cli-service
    Contributor

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

  8. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor

    Two facts for this item, from the work of 2026-11-26 on the project brain (#4624):

  9. added
    status/ready
    and removed
    status/new
    on Nov 26, 2026
  10. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  11. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    Design check, 2026-11-26

    Body, 5 corrections

    • The request function is alternatives_request (src/devops_cli/roadmap/alternatives.py:825).
    • The near list is the near field of the index (src/devops_cli/roadmap/brain_sync.py:137). The aggregate task of feat(roadmap): the brain files project insights through intake #4693 is not built.
    • The index holds no ring (src/devops_cli/roadmap/brain_index.py:222).
    • The spec delta goes to project-brain/digest: a capability holds at most 80 requirements (openspec/config.yaml:24).
    • devops_cli_brain_first_reads_total has the label row only (src/devops_cli/telemetry/instruments.py:811).

    Refine block

    • It cites _request at alternatives.py:637. No function starts at that line now.
    • It takes the near items from the nearest-item function of intake. The index holds a different list. A person decides which list the digest uses.
    • Its last scenario keeps the values answered and partial. No series has them.

    Dependencies: #4676 and #4672 are closed. No open item blocks this item.

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See Moved to new items in the section Proposed design of the body.

  13. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  14. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  15. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-28 02:40 UTC

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/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions