Repository navigation
Description
Problem or Motivation
Verdicts, tools and references exist only as 330 issue blocks and comment text. No reader joins them. pydantic-ai is on 10 items, gidgethub on 6 and OpenSpec on 9, and each check searches again (5.3 searches a check, measured). Refine reads only its own item.
Proposed Solution & Architectural Design
brain-syncin the listing owner (the Service now, the sweep later, as the feat(service): keep a Valkey read model of each item #4582 writer moves). AfterIncrementalListing.read, it parses the alternatives block and job record of each changed issue from the snapshot (0 GitHub requests) into:roadmap:v1:brain-item:<owner>/<name>:<n>(hash: verdict, tool id, at most 3 reference ids, at most 5 near items,checked_at,body_hash,adr_hash, state, uses, schema; TTL 45 days);roadmap:v1:brain-tool:<owner>/<name>:<h16(canonical id)>(TTL 45 days);roadmap:v1:brain-ref:<owner>/<name>:<h16(repository URL)>(TTL 45 days).
- It adds the uses of
alternatives.brain_usedand XADDs onebrain-eventsentry (MAXLEN ~ 10000; audit only, never a trigger queue). One MULTI/EXEC for each item. - The watermark key
roadmap:v1:brain-sync:<owner>/<name>. After an outage,brain-synccopies every issue changed since its watermark (at most 500 a tick). - Keys come from
RepoRef(ADR 0022 section 5). No field that the feat(service): keep a Valkey read model of each item #4582 read model holds. GitHub wins: the entry with the newerchecked_atandbody_hashfrom the block wins. - ACL: a
brainuser onvalkey-roadmap(read and write~roadmap:v1:brain-*); theagentuser only reads~roadmap:v1:brain-*. - Instruments:
devops_cli_brain_entries,devops_cli_brain_sync_lag_seconds,devops_cli_brain_first_reads_total. - Tests T7 (
brain-syncafter an outage copies the 3 issues that changed in it) and T8 (the check with no brain writes the verdict of today). - Spec in
openspec/specs/project-brain/index/spec.md.
Target Subsystem
Workstation Caching & Valkey (valkey-roadmap, the roadmap listing owner).
Existing Tool Considered
Valkey core types through valkey-py, the IncrementalListing and SnapshotStore seams of #4552, and RepoRef keys. No module, no Lua and no vector store: 395 open items fit an in-memory cosine, as intake does. Cost: about 150,000 tokens and 4 hours to build.
Acceptance Criteria
- A test:
brain-syncfor 3 changed issues makes 0 GitHub requests and writes 3brain-itemhashes. - A test: with
connected = False, the listing round finishes and countsfallback. - A SCAN test: every key has a TTL or one owner.
- A test: the SCAN pattern for
o/nnever matcheso/nn. - Live:
devops_cli_brain_sync_lag_seconds{store="brain_index"}stays under 600 s for 24 h.
Dependencies
#7294, #4625, #4661, #4668. 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 and writes their results to the brain index. A comment gives the result lines and the index entries.
Owner decision 2026-11-26
The index depends on #7294 and no longer on #4563. #7294 holds the three parts of #4563 that the index needs: the valkey-roadmap instance, the setting of its URL and its ACL users, with the brain user. The request budget, the hold, the halt and the delivery ids stay in #4563, and the index does not wait for them.
Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: valkey (https://pypi.org/project/valkey), MIT License, last activity 2026-10-12, maintained.
Reason: Searches found only Valkey clients and RedisVL-style vector search demos; no tool indexes alternatives verdicts across issues. Valkey covers the hash, TTL, transaction and ACL store access, while the snapshot parsing, watermark catch-up and instruments stay project code.
Covers:
- Hashes with 45-day TTL for item, tool and ref entries
- MULTI/EXEC transaction for the keys of one item
- ACL users scoped by key pattern for brain and agent
- SCAN and a watermark key for per-repository catch-up
Lacks:
- Parsing the alternatives block from the listing snapshot
- Joining verdicts, tools and references across 330 issues
- Sync lag, entry count and first-read instruments
Proposed design
Problem statement
Alternatives checks record a verdict, a tool and references in issue blocks and comments. The repository holds about 330 such blocks, and no reader joins them. Each check searches again, at 5.3 searches for a check. This change keeps the result of each check in a Valkey brain index. The index holds one hash for the item, one for the tool and one for each reference. Each hash has a 45-day TTL. The alternatives step writes the index from its listing snapshot and sends no GitHub request. The change adds the key schema, the watermark catch-up, the audit stream, the ACL split and the instruments.
Acceptance criteria
Requirement: Snapshot-only sync
The brain-sync step SHALL build the brain entries of each changed issue from the listing snapshot and send no GitHub request.
Scenario: Three changed issues and no GitHub call
- WHEN The snapshot holds 3 changed issues and the brain index is empty.
- THEN The sync writes 3
brain-itemhashes, and the fake GitHub client records 0 requests.
Requirement: Item hash contents
Each roadmap:v1:brain-item:<owner>/<name>:<n> hash SHALL hold the verdict, the tool id, at most 3 reference ids, at most 5 near items, checked_at, body_hash, adr_hash, state, uses and schema, with a 45-day TTL.
Scenario: A check with 4 references keeps 3
- WHEN The alternatives block of an issue gives the verdict
covers, one tool id and 4 reference ids. - THEN The item hash holds 3 reference ids and each named field, and
TTLreturns 3888000.
Requirement: Catch-up after an outage
The brain-sync step SHALL copy each issue whose updated_at is newer than the watermark roadmap:v1:brain-sync:<owner>/<name>, at most 500 in one tick.
Scenario: Three issues changed during an outage
- WHEN The watermark is older than the
updated_atof 3 issues and the sync runs. - THEN The sync writes the 3
brain-itemhashes, copies exactly 3 issues and advances the watermark.
Requirement: Newer check wins
The brain entry MUST keep the copy that the alternatives block gives with the newer checked_at and body_hash.
Scenario: An older index entry meets a newer block
- WHEN The index holds an entry with an older
checked_at, and the block gives a newerchecked_atand anotherbody_hash. - THEN The sync overwrites the entry, and the hash holds the newer
checked_atandbody_hash.
Requirement: One transaction for each item
The brain-sync step SHALL write the keys of one item and its brain-events entry in one MULTI/EXEC transaction.
Scenario: One item, one transaction
- WHEN The sync writes the keys of one changed item.
- THEN The fake Valkey records one MULTI/EXEC that holds the item hash, the tool hash, the ref hashes and one
brain-eventsentry with MAXLEN 10000.
Requirement: Instruments
The brain-sync step SHALL observe devops_cli_brain_entries, devops_cli_brain_sync_lag_seconds{store="brain_index"} and devops_cli_brain_first_reads_total.
Scenario: A round reports the three instruments
- WHEN The sync writes one item and the last success was 120 s before.
- THEN
devops_cli_brain_entriesreads 1,devops_cli_brain_sync_lag_seconds{store="brain_index"}reads 120, anddevops_cli_brain_first_reads_totalreads 0.
Requirement: Prefix scan stays in one repository
The SCAN pattern of one repository SHALL NOT match a key of a repository whose name starts with the same characters.
Scenario: o/n does not match o/nn
- WHEN The index holds the keys of
o/nando/nn, and the sync scansroadmap:v1:brain-item:o/n:*. - THEN The scan returns the keys of
o/nonly.
Requirement: TTL or one owner
Each brain key SHALL have a TTL, except the watermark key, which MUST have one owner.
Scenario: Scan of the brain prefix
- WHEN The sync wrote the item, tool, ref and watermark keys of one repository.
- THEN Each
brain-item,brain-toolandbrain-refkey has a TTL of 45 days, and thebrain-syncwatermark key has no TTL and one writer.
Requirement: A round without a connection
The listing round SHALL finish and count fallback when the brain index is not connected.
Scenario: No connection to Valkey
- WHEN
connectedisFalseand a round reads 3 changed issues. - THEN The round finishes, counts one
fallback, and writes no brain key.
Requirement: First read of an unchecked item
The alternatives check SHALL write the verdict that it finds when the brain index has no entry for the item.
Scenario: T8, the index is empty
- WHEN The index holds no entry for the item and the check finds the verdict
none. - THEN The check writes
noneto the block and to the index, anddevops_cli_brain_first_reads_totalcounts 1.
Requirement: Two ACL users
The ACL configuration of valkey-roadmap SHALL give the brain user read and write on ~roadmap:v1:brain-* and the agent user read only.
Scenario: The k8s check validates the ACL file
- WHEN
uv run devops ci --check --only k8svalidates the manifests ofvalkey-roadmap. - THEN The command exits 0 and reports no finding for the ACL file of
valkey-roadmap.
Requirement: Pending a person after the merge
After the merge and the release, the alternatives step MUST run as the App on 3 items and write their results to the brain index.
Scenario: Live proof on 3 items
- WHEN The owner runs the alternatives step as the App on 3 items after the merge and the release.
- THEN A comment gives the result line of each item, its brain index entry, and
devops_cli_brain_sync_lag_seconds{store="brain_index"}against the alternatives row interval.
Existing Tool Considered
valkey (valkey-py, https://pypi.org/project/valkey) holds the verdict in-use: the repository already uses the tool. The alternatives check of 2026-11-26 in the issue body gives what the tool covers and what it lacks. This change adds the parts that the block lists as lacking: it parses the alternatives block from the listing snapshot, joins the verdicts, tools and references across the items, catches up from the watermark key, and observes the sync lag, the entry count and the first-read count. No open tool indexes check results across issues, so the change builds that code at about 150,000 tokens and 4 hours.
Key questions
- Which unit writes the brain index?: The alternatives step of the research unit writes the index after its listing read. The owner decision of 2026-11-13 keeps this scope in that step, and the step holds the check result and the snapshot. (best practice) [sources: docs/roadmap/alternatives.md, docs/adr/0028-a-research-agent-composes-open-tools-and-a-research-index.md, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md]
- Chosen: The alternatives step writes the index after its listing read. The owner decision of 2026-11-13 keeps the scope in that step, and the step holds the check result and the listing snapshot.
- Rejected: The Service sweep row writes the index. A second writer reads the same blocks again, and the owner decision puts the scope in the alternatives step.
- Which items does this change depend on?: feat(k8s): add the valkey-roadmap instance, its setting and ACL users #7294, docs(roadmap): record the project brain and its upkeep runs #4625, fix(roadmap): the alternatives check reads the tools in use #4661 and perf(roadmap): share the listing snapshot and tool facts in Valkey #4668. The owner decision of 2026-11-26 takes feat(service): share the GitHub budget and holds in Valkey #4563 out: feat(k8s): add the valkey-roadmap instance, its setting and ACL users #7294 holds the
valkey-roadmapinstance, its URL setting and its ACL users with thebrainuser. The request budget, the hold, the halt and the delivery ids stay in feat(service): share the GitHub budget and holds in Valkey #4563. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md]- Chosen: Wait on feat(k8s): add the valkey-roadmap instance, its setting and ACL users #7294 only. The owner decision of 2026-11-26 moves the instance, its URL setting and its ACL users to feat(k8s): add the valkey-roadmap instance, its setting and ACL users #7294.
- Rejected: Wait on feat(service): share the GitHub budget and holds in Valkey #4563. The owner decision of 2026-11-26 takes feat(service): share the GitHub budget and holds in Valkey #4563 out, and the index needs none of its budget, hold, halt or delivery ids.
- Which code builds the brain key of each repository?:
RepoRefbuilds it. Each key followsroadmap:v1:brain-<kind>:<owner>/<name>:<id>and holds no hand-parsedowner/name. (best practice) [sources: src/devops_cli/github/repo_ref.py:103, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, tests/roadmap/stores/test_brain_issues.py]- Chosen: Build each key from
RepoRef. ADR 0022 gives one builder for each key that holds a repository, andRepoRefis that builder. - Rejected: Build the key from an
owner/namestring in the module. ADR 0022 says code does not parseowner/nameitself.
- Chosen: Build each key from
- How does the sync catch up on the issues that changed during an outage?: It reads the watermark
roadmap:v1:brain-sync:<owner>/<name>and copies each issue changed since it, at most 500 in one tick.IncrementalListingkeeps the same kind of watermark for each snapshot. (best practice) [sources: src/devops_cli/roadmap/stores/listing_snapshot.py:195, docs/roadmap/intake.md]- Chosen: Copy from the watermark key.
IncrementalListingkeeps the same kind of watermark, and one tick does a bounded copy. - Rejected: Read every issue in each tick. A full read of each issue at each tick costs GitHub requests and time.
- Chosen: Copy from the watermark key.
- Which copy wins when the index and the alternatives block disagree?: The block wins when its
checked_atandbody_hashare newer. The index is derived, and GitHub holds the durable copy. (best practice) [sources: docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, CONTEXT.md]- Chosen: The block wins on a newer
checked_atandbody_hash. The block is the durable copy of the check, and the index is derived. - Rejected: The index wins. The index holds no only copy of a fact.
- Rejected: The last write wins. A late write of an older block would drop a newer check.
- Chosen: The block wins on a newer
- Which store holds the index?: Valkey core types through valkey-py: hashes, TTLs and one MULTI/EXEC for each item. The change adds no module, no Lua and no vector store. (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, docs/roadmap/alternatives.md]
- Chosen: Valkey hashes, TTLs and MULTI/EXEC through valkey-py. The project brain lives in Valkey, and the core types cover the need with no server module.
- Rejected: Redis OM over RediSearch. It adds a server module that the item rules out, and it models hashes only.
- Rejected: A vector store. 395 open items fit an in-memory cosine, and a vector store adds a component to keep.
- Which bound does
devops_cli_brain_sync_lag_secondstake when the alternatives row runs about six times a day?: The bound follows the alternatives row interval. The sync runs in the alternatives step, so the index lags a check by at most one row interval and one round. The live check compares the lag with the row interval and never with a fixed 600 s. (best practice) [sources: docs/roadmap/alternatives.md, docs/CLUSTER.md]- Chosen: Bound the lag by the alternatives row interval plus one round. The alternatives row runs about six times a day, so a 600 s bound does not hold.
- Rejected: Keep 600 s and run the sync in each sweep. That adds a second writer and a sweep read, and the owner decision keeps the scope in the alternatives step.
- Rejected: Set no bound. A stopped sync would go unseen.
- Where does the change write its spec?: The change writes the spec delta at
openspec/changes/<issue>-<slug>/specs/project-brain/index/spec.md.openspec archivewrites the living specopenspec/specs/project-brain/index/spec.mdfrom it. (best practice) [sources: CONTEXT.md, openspec/config.yaml]- Chosen: Write the spec delta in the change folder. Only
openspec archivewrites the living spec, and the pull request that delivers the item writes the delta. - Rejected: Edit
openspec/specs/project-brain/index/spec.mdby hand. The living spec comes fromopenspec archiveonly.
- Chosen: Write the spec delta in the change folder. Only
- What does the listing round do when Valkey is not connected?: It finishes and counts
fallback. The brain is derived and holds no only copy, so a missing index costs a first read and never stops the round. (best practice) [sources: ARCHITECTURE.md, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md, CONTEXT.md]- Chosen: Finish the round and count
fallback. The check writes its verdict anyway, and the brain catches up on the next tick. - Rejected: Stop the round. A missing index would stop the check that fills it.
- Chosen: Finish the round and count
- What is
brain-eventsfor, and who reads it?: It is an audit stream only. The sync adds one entry with MAXLEN 10000, and no job reads it as a trigger. Work that the index makes due uses a due mark, which has a TTL and is never the only copy of a decision. (best practice) [sources: CONTEXT.md, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md]- Chosen: An audit stream only. A lost entry cannot stop work, and a due mark is the trigger that the Service reads.
- Rejected: A trigger queue. A lost entry would stop the work that it holds.
- How does the index keep a check from writing another user's keys?: ADR 0021 records the
router,sweepandagentusers ofvalkey-roadmap. The change adds a fourth user,brain, which holds read and write on~roadmap:v1:brain-*; the alternatives step connects asbrain. Every other unit, refine's read included, connects asagent, which holds read commands only on the same pattern. (best practice) [sources: docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md, docs/adr/0022-one-repository-reference-names-the-objects-labels-and-keys-of-each-repository.md, docs/adr/0023-the-project-brain-is-a-derived-index-in-two-cache-tiers-and-two-scheduled-runs-keep-it.md]- Chosen: Two ACL users,
brainwrites andagentreads. ADR 0022 says the role ACLs select by key kind, and ADR 0021 givesvalkey-roadmapits ACL users. - Rejected: One shared user with write on the brain keys. A check or any other job could change the index, and the reader and the writer would share one credential.
- Rejected: No ACL change, the default user. Every job could write every key, so the brain index would have no key-space separation.
- Chosen: Two ACL users,
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It is a planned feature in the project brain plan with open dependencies, not a defect or security fix.It lets checks join alternatives results without re-searching, saving repeated model calls.The body estimates about 150,000 tokens and 4 hours to build, including tests and spec.Both write to valkey-roadmap under the roadmap:v1: prefix, but #4582 holds the item read model and the candidate holds the alternatives brain index.devops-cli-service commentedon Nov 14, 2026
Alternatives check: none
Reason: Searches found no open tool or library that indexes alternatives-check results (verdict, tool, references) per roadmap item; the closest generic options are Redis hash object mappers/secondary indexes such as Redis OM, which only store and query hashes. The snapshot parsing, watermark-based catch-up sync, RepoRef key schema, TTL/ACL split and instruments are project-specific, and ADR 0023 already makes the brain a derived index the project builds and keeps itself, so nothing off the shelf covers the need.
Tool: none found
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 14, 2026
Refine cannot set this item to Ready at de100a0 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.
devops-cli-service commentedon Nov 20, 2026
The result in the alternatives block of the issue body changed. Before this check:
none, no tool. A person decides what the new result means for the item.Searches (7)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 26, 2026
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 remaining items
docs(spec): archive the change of #4676
Revert "docs(spec): archive the change of #4676"
docs(spec): archive the change of #4676
devops-cli-service commentedon Nov 26, 2026
Released in v0.223.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.223.0
dan-petty commentedon Nov 26, 2026
Change of the live ConfigMap
devops-cli-config, 2026-11-26 18:44:03 UTC, byuv run devops k8s deploy-stack --stack devops --no-push-secrets --no-configure-urls --no-port-forwardfrommainat release 0.223.0 (template commit ef01e07):roadmap.state.urlvalkey-roadmapfor the brain index (#4676)roadmap.state.usernamebrainroadmap.alternatives.referencesplanroadmap.implement.max_refusals,roadmap.implement.max_consecutive_refusalsNo other key changed: a comparison of the rendered ConfigMap with the live one before the write gave these 5 keys only.
devops k8s push-secrets --stack devops --planshowed each keyunchanged, and the command pushed no Secret. Argo CD manages the manifests, so the command applied the ConfigMap, its sandbox copy and the change record only.The Service pod ran release 0.223.0 before the write. It was restarted at 18:45 UTC and reads the new keys.
devops-cli-service commentedon Nov 26, 2026
Live since 2026-11-26 18:50 UTC
dan-petty commentedon Nov 26, 2026
Live proof, 2026-11-26, release 0.223.0. The Service pod reads
roadmap.state.urlandroadmap.state.username: brainsince 18:45 UTC and holds the password of the userbrain.The sync of the row (log of the Service, 19:27:48 UTC): "The brain index of dan-petty/devops-cli: 500 items copied, 0 kept, 500 entries." The first sync copies the oldest 500 checks, which is its bound for one round; the next rounds go on from the watermark.
The store, read as the user
agentat 19:29 UTC:brain-item, 118brain-tool, 1brain-sync, 1brain-events(500 entries), 0brain-ref(no item holdsalternatives.refswhile the reference step is in modeplan)schema1,changed2026-11-22T23:55:56Z,number3932,synced_at2026-11-26T19:27:43Znone173,not-applicable137,in-use89,partly85,covers11,rejected5agentNOPERM)Three entries:
roadmap:v1:brain-item:dan-petty/devops-cli:6774:verdictin-use,tool_idgithub.com/qdrant/qdrant,near4921 4971 3771 3823,checked_at2026-11-22T14:57:10Z,stateclosed.roadmap:v1:brain-item:dan-petty/devops-cli:6736:verdictnone, no tool,checked_at2026-11-22T06:54:17Z,stateclosed.roadmap:v1:brain-item:dan-petty/devops-cli:6775:verdictnone, no tool,checked_at2026-11-22T14:57:10Z,stateclosed.Instruments (Prometheus, 19:28 UTC):
devops_cli_brain_entries{store="brain_index",repo="dan-petty/devops-cli"}is 500,devops_cli_brain_writes_total{store="brain_index",result="shared"}is 500,devops_cli_brain_first_reads_total{row="alternatives"}is 0, and nofallbackread is counted.devops_cli_brain_sync_lag_secondshas no series yet, because the first sync has no earlier sync to measure from. A later comment gives the lag against the row interval.Of the 190 tool verdicts in these entries, 89 are
in-use(47 percent). The measure of the tracker #4624 asks for more than 25 percent.docs(adr): record two facts of ADR 0023 that are out of date (#7360)
dan-petty commentedon Nov 27, 2026
24-hour check of the sync, 2026-11-27 15:40 UTC (Prometheus):
devops_cli_brain_sync_lag_seconds{store="brain_index"}, by repository: from 12,971 s to 15,623 s for dan-petty/devops-cli, and from 14,221 s to 14,870 s for each of the other 6 public repositories. The interval of the alternatives row is 239 minutes (14,340 s), and the lag is the time since the end of the last sync. So each repository synced in each round; the spread comes from the length of each round.devops_cli_brain_reads_total{store="brain_index",result="fallback"}: 0 in 24 hours, so no round lost the store.The first criterion of the issue body ("under 600 s for 24 h") assumed a sync in each listing round. The delivered spec (
openspec/specs/project-brain/index/spec.md, #7320) runsbrain-syncin the alternatives row and compares the lag with the interval of that row. Measured against that rule, the sync passes.feat(ai): give every agent brain tools via MCP, CLI and skill (#4671) (…