Repository navigation
Description
Problem Description
The brain sync keeps the near list of an item entry only as fresh as the last write of that entry. _copy_changed in src/devops_cli/roadmap/brain_sync.py writes the entry of each changed issue, with related from the full snapshot, but it does not write the entries of the other items whose near items changed. When the check of one item names a new tool:
- each item of the old tool keeps that item in its
nearlist, and - each item of the new tool does not get that item in its
nearlist,
until that item changes itself, or until the TTL of 45 days ends. The brain digest of the alternatives check (#4682, PR #7496) reads near in order, and the prompt tells the model that each entry of brain "named the same tool". With a stale list, that statement is false for some entries.
Reproduction Steps
- Write the entry of item 3 with the tool
github.com/acme/kit-a, then the entry of item 7 with the same tool andnear = (3,). - Change the check of item 3 to the tool
github.com/acme/kit-b, and run the sync. Item 7 does not change. - Read the digest of item 7 (
read_digest).
Expected vs Actual Behavior
Expected: when the tool of an item changes, the sync also writes the entries of the items of the old tool and of the new tool, so each near list holds only items of the same tool.
Actual: the digest of item 7 holds {"item": 3, "tool": "github.com/acme/kit-b", ...}, an item of another tool.
Environment Diagnostics
Found in the review of PR #7496 on 2026-11-28 with a scratch script on its branch. The cause is in the sync of #4676, which main holds.
Logs, Traces, or Terminal Output
None.
Source
Source: #7496
Alternatives check of 2026-11-28: none.
Tool: none found.
Reason: Searches returned only unrelated pages (MDN list/indentation docs, Docker index images); no tool or library maintains the project's brain near lists. The need is a fix inside the project's own brain_sync._copy_changed to also rewrite neighbour entries.
Lacks:
- Rewrite the entries of items of the old tool
- Add the item to entries of the new tool
- Keep near lists consistent without waiting for TTL or a later item change
Proposed design
Problem statement
Fix the brain sync so it rewrites the entries of the old and new tool when a check changes. The sync writes only the changed entry now. Other items keep stale near lists, and a digest can name an item of another tool. No gate blocks the fix.
Acceptance criteria
Requirement: Old tool near list
The brain sync SHALL rewrite the entries of the other items of an item's previous tool when the item's tool changes.
Scenario: Item leaves its old tool
- WHEN item 3 is stored with tool A and item 7 with tool A and near (3,); item 3 changes to tool B; the sync runs
- THEN the stored near list of item 7 does not name item 3
Requirement: New tool near list
The brain sync SHALL rewrite the entries of the other items of an item's current tool when the item's check changes.
Scenario: Item joins its new tool
- WHEN item 7 is stored with tool B; item 3 changes to tool B; the sync runs
- THEN the stored near list of item 7 names item 3
Requirement: Same tool order
The brain sync SHALL rewrite the entries of the other items of an item's tool when the item's check time changes.
Scenario: New check time reorders near items
- WHEN item 3, item 7 and item 9 are stored with tool A; item 3 gets a newer check; the sync runs
- THEN the stored near list of item 7 lists item 3 before item 9
Requirement: Digest consistency
The brain digest SHALL hold only items of the same tool in a near list after the sync.
Scenario: Digest of an unchanged item
- WHEN item 3 changes to tool B; item 7 keeps tool A; the sync runs; read_digest reads item 7
- THEN the digest of item 7 holds no entry of item 3
Requirement: One write per affected item
The brain sync SHALL write each affected item at most once in one round.
Scenario: Two changed items share a neighbour
- WHEN item 3 and item 5 change in tool A; item 7 is stored with tool A; the sync runs
- THEN the store receives one write of item 7
Requirement: Limit on changed issues
The brain sync SHALL process at most CONST_ROADMAP_BRAIN_SYNC_MAX_ISSUES changed issues in one round.
Scenario: Limit reached
- WHEN the number of changed issues is greater than CONST_ROADMAP_BRAIN_SYNC_MAX_ISSUES; the sync runs
- THEN the sync processes at most CONST_ROADMAP_BRAIN_SYNC_MAX_ISSUES changed issues and leaves the watermark at the last processed issue
Existing Tool Considered
The alternatives check of 2026-11-28 returned verdict none. The block in the issue body holds the searches and what the need lacks. The fix stays in src/devops_cli/roadmap/brain_sync.py. Building and keeping it in the project costs about 15k tokens and 2 hours.
Key questions
- Where does the sync write a changed entry?: The function _copy_changed at src/devops_cli/roadmap/brain_sync.py:174 calls _copy_one with checks.related(entry). [sources: src/devops_cli/roadmap/brain_sync.py:174, src/devops_cli/roadmap/brain_sync.py]
- Which entries must the sync rewrite when a check changes?: The sync rewrites the changed entry, every other entry of its current tool, and every other entry of its previous tool when the tool differs. (best practice) [sources: src/devops_cli/roadmap/brain_sync.py, src/devops_cli/roadmap/brain_entries.py, src/devops_cli/roadmap/brain_index.py]
- Chosen: Rewrite current and previous tool groups. It repairs both stale lists from one changed entry.
- Rejected: Rewrite all entries in the snapshot. It writes many entries that no changed check affects.
- Rejected: Wait for the TTL. It leaves the digest false for up to 45 days.
- How does the sync learn the previous tool of a changed item?: The sync reads the stored entry from the brain index before the write. It compares the stored tool_id with the new entry tool_id. (best practice) [sources: src/devops_cli/roadmap/brain_index.py, src/devops_cli/roadmap/brain_digest.py:159, src/devops_cli/roadmap/brain_sync.py]
- Chosen: Read the stored entry. The index holds the last tool and the current near list.
- Rejected: Infer from the old near list. The near list is capped and holds no tool of the item.
- Rejected: Store the previous tool in the watermark. The watermark holds one place, not one tool for each item.
- How does the sync bound the extra writes?: The round limit counts changed issues, not neighbour writes. One changed issue and its affected neighbours form one unit. The watermark moves after the unit completes. (best practice) [sources: src/devops_cli/roadmap/brain_sync.py, src/devops_cli/config/constants.py]
- Chosen: Limit changed issues and write each unit. It keeps the documented issue limit and avoids a starved unit.
- Rejected: Count each neighbour write in the limit. A large tool group can exceed the limit and never complete.
- Rejected: Write neighbours with no limit. It can make one round unbounded.
- Does the sync also rewrite reference_items when the references of an item change?: No. The sync repairs near lists only. A change to reference_items is a separate defect. (best practice) [sources: src/devops_cli/roadmap/brain_sync.py]
- Chosen: Repair near lists only. It matches the issue and keeps the change small.
- Rejected: Also rewrite reference_items. It expands the scope beyond the reported defect.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
devops-cli-service commentedon Nov 28, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (3)
Searches run:
Sources:
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 28, 2026
Released in v0.240.1: https://github.com/dan-petty/devops-cli/releases/tag/v0.240.1
devops-cli-service commentedon Nov 28, 2026
Live since 2026-11-28 23:51 UTC