Skip to content

fix(roadmap): the brain issue cache follows the shared-tier rules #7292

Done

Description

@dan-petty

Problem Description

The brain issue cache of #6013 breaks two rules of the shared cache tier (ADR 0023 section 8, openspec/specs/project-brain/shared-cache/spec.md).

  1. It holds private repositories. issue_cache (src/devops_cli/roadmap/stores/brain_issues.py:54) has no visibility check. Each read of GitHubStore.issue (src/devops_cli/roadmap/stores/github_store.py:874) and each webhook delivery (_remember_delivery_issue, src/devops_cli/server/routes/webhooks.py:417) writes the issue record to valkey-devops. ADR 0023 section 8 keeps the shared tier to public repositories until each client sends a role user and the default user is off (feat(k8s): turn off the valkey-devops default user #6600). The listing snapshot obeys this rule (Visibility, SWEEP_USER in src/devops_cli/roadmap/stores/listing_shared.py). The issue cache does not.
  2. Its key is outside each ACL role. The prefix comes from RepoRef.valkey_key("brain-issue"), which gives roadmap:v1:brain-issue:<owner>/<name>. That is the key form of valkey-roadmap (ADR 0022 section 5), but the cache writes to valkey-devops. The ACL users of feat(k8s): give valkey-devops one ACL user for each role #4704 (DEVOPS_CACHE_VALKEY_ACL_TEMPLATE, src/devops_cli/k8s/cluster_secrets.py:58) reach only valkey:roadmap:*, valkey:gh:*, valkey:brain:* and valkey:rag:*. When a client sends a role user, each command of the issue cache gets NOPERM, and each read is a miss.

Measured on 2026-11-26 with a read-only SCAN of valkey-devops: 453 keys have the prefix roadmap:v1:brain-issue. 32 of them hold issue records of the 2 private repositories of the Service. The other key families are valkey:rag:embedding (3,306), valkey:brain:v1 (29) and valkey:roadmap:v1 (7).

Reach of the data: the NetworkPolicy admits namespace devops only, and a reader needs the shared password. Each pod that holds the password can also read the repositories as the App. So this is a break of the rule, with no known path for an outside reader.

Reproduction Steps

  1. Read src/devops_cli/roadmap/stores/brain_issues.py:54-66: no visibility read, and the prefix ref.valkey_key("brain-issue").
  2. With a client of valkey-devops, run SCAN 0 MATCH roadmap:v1:brain-issue:* COUNT 2000 until the cursor is 0.
  3. Count the keys of each repository, and read the visibility of each repository from GitHub.

Expected vs Actual Behavior

  • Expected: the shared tier holds the issue record of a public repository only, until the process sends the role user that may hold private data. The key of the record starts with a prefix that the role user of its writer reaches.
  • Actual: the shared tier holds the issue records of each repository, under a key that no role user reaches.

Proposed Fix

  • The issue cache uses the visibility check of the listing snapshot (one check, no second copy). A private repository, and a repository whose visibility is unknown, gets no shared read and no shared write, unless the process sends SWEEP_USER.
  • The prefix moves under CONST_VALKEY_ROADMAP_PREFIX (valkey:roadmap:v1:issue:<owner>/<name>), which sweep writes and brain reads.
  • The records under the old prefix have a TTL of 24 hours (DEFAULT_BRAIN_ISSUE_TTL_SECONDS), so they go without a step of a person. State this in the pull request.
  • Spec delta in openspec/specs/project-brain/shared-cache/spec.md.

Acceptance Criteria

  • Test first: a read and a webhook delivery of a private repository write no key to the valkey_server fake, and each read answers from GitHub, as before feat(service): Cache GitHub issue and PR state in the brain from webhooks #6013 (the issue cache keeps no copy in the process). The test fails on the base.
  • A test: with valkey.username set to sweep, the record of a private repository reaches the shared tier.
  • A test: each key of the issue cache starts with valkey:roadmap:v1:.
  • A test: a public repository keeps the shared read and write of today.
  • Live proof after the release: 25 hours after the deploy, a SCAN of valkey-devops finds no key with the prefix roadmap:v1:brain-issue, and no key of a private repository under the new prefix. A comment gives the counts.

Environment Diagnostics

devops-cli 0.221.13, valkey-devops (valkey 9.2.0), Service ConfigMap with no valkey.username.

Dependencies

None.

Related: #6013 (the issue cache), #6611 (the same rules for the snapshot and fact caches), #6589 (private repositories under role users), #6600 (default user off), #4624 (tracker). This item must merge before a client of valkey-devops sends a role user.

Alternatives check of 2026-11-26: none.
Tool: none found.
Reason: The searches returned only generic browser Cache API documentation, no open tool or library that adds a public-only visibility gate or a role-reachable key prefix to the project's Valkey issue cache; the fix stays in devops-cli's own store code.

Lacks:

  • No per-repository visibility gate before a shared cache write
  • No key prefix constrained to the writer's ACL role
  • No reuse of the listing snapshot's existing visibility check

Proposed design

Problem statement

Gate the brain issue cache by repository visibility and move its key under valkey:roadmap:v1:issue:. The cache writes private issue records to the shared valkey-devops tier today. It also uses roadmap:v1:brain-issue:*, which no ACL role reaches. The change reuses the listing snapshot visibility check and SWEEP_USER gate. It adds the spec delta to openspec/specs/project-brain/shared-cache/spec.md.

Acceptance criteria

Requirement: Private issue read skips the shared tier

A read of an issue of a private repository SHALL write no key to the shared tier when the process sends no ACL user.

Scenario: Private issue read

  • WHEN A test reads issue 6013 of a private repository through issue_cache on the valkey_server fake with no valkey.username.
  • THEN The fake holds no key under valkey:roadmap:v1:issue:, and the read returns the issue from the fake GitHub.

Requirement: Private webhook delivery skips the shared tier

A webhook delivery for an issue of a private repository SHALL write no key to the shared tier when the process sends no ACL user.

Scenario: Private webhook

  • WHEN A signed issues webhook for a private repository reaches _remember_delivery_issue on the valkey_server fake with no valkey.username.
  • THEN The fake holds no key under valkey:roadmap:v1:issue:.

Requirement: Sweep user shares a private issue

The issue cache SHALL write and read the shared record of a private repository when the process sends the ACL user sweep.

Scenario: Private repository under sweep

  • WHEN A test writes issue 7 of a private repository through issue_cache with valkey.username set to sweep on the valkey_server fake.
  • THEN The fake holds the key valkey:roadmap:v1:issue:<owner>/<name>:7, and a second issue_cache read returns the stored issue.

Requirement: Issue keys use the roadmap prefix

Each key that the issue cache writes SHALL start with valkey:roadmap:v1:issue:.

Scenario: Issue key prefix

  • WHEN A test writes an issue of a public repository through issue_cache on the valkey_server fake.
  • THEN Each key that the fake holds starts with valkey:roadmap:v1:issue:.

Requirement: Public repository keeps shared read and write

A read and a write of an issue of a public repository SHALL use the shared tier as today.

Scenario: Public issue cache

  • WHEN A test writes an issue of a public repository through issue_cache and a second issue_cache reads it on the same valkey_server fake.
  • THEN The second read returns the stored issue and sends no GitHub request.

Requirement: Unknown visibility never shares

The issue cache SHALL write no shared key and read no shared record for a repository whose visibility is unknown, even when the process sends sweep.

Scenario: Unknown visibility

  • WHEN A test reads and writes an issue of a repository whose visibility read fails on the valkey_server fake with valkey.username set to sweep.
  • THEN The fake holds no key under valkey:roadmap:v1:issue:, and each read returns the issue from the fake GitHub.

Requirement: Pending a person after the merge

After the release, the shared tier MUST hold no key under the old issue prefix and no private issue key under the new prefix.

Scenario: Live scan after 25 hours

  • WHEN A person runs SCAN 0 MATCH roadmap:v1:brain-issue:* COUNT 2000 and SCAN 0 MATCH valkey:roadmap:v1:issue:* COUNT 2000 with a client of valkey-devops 25 hours after the deploy, and reads the visibility of each repository.
  • THEN The first scan returns no key, the second scan returns no key of a private repository, and a comment gives the counts.

Existing Tool Considered

The alternatives check of 2026-11-26 in the issue body gives verdict none: no open tool or library covers the need. The proposal meets the missing capabilities by reusing the listing snapshot visibility check and SWEEP_USER gate and by moving the key under CONST_VALKEY_ROADMAP_PREFIX. The fix stays in devops-cli store code. Written cost: about 3,000 tokens and 2 hours to build, and about 500 tokens per later fix to keep it.

Key questions

  • How should the issue cache apply the shared-tier visibility rule?: Reuse the listing snapshot visibility check and SWEEP_USER gate. A private repository shares only under sweep. A repository with unknown visibility shares never. (best practice) [sources: openspec/specs/project-brain/shared-cache/spec.md, src/devops_cli/roadmap/stores/listing_shared.py]
    • Chosen: Reuse the listing visibility check. One check, no second copy; matches the shared-cache spec and ADR 0023 section 8.
    • Rejected: Add a second visibility check in brain_issues. Duplicates logic and can drift from the listing snapshot.
    • Rejected: Share every repository. Breaks ADR 0023 section 8 and puts private issue data in the shared tier.
  • Which key prefix should the issue cache use?: Use CONST_VALKEY_ROADMAP_PREFIX with :issue:<casefolded RepoRef.key>:<number>. The key is valkey:roadmap:v1:issue:<owner>/<name>:<number>. (best practice) [sources: src/devops_cli/config/constants.py:2955, src/devops_cli/roadmap/stores/listing_shared.py, src/devops_cli/k8s/cluster_secrets.py:58]
    • Chosen: Prefix under CONST_VALKEY_ROADMAP_PREFIX. The ACL template reaches valkey:roadmap:*, and the listing snapshot uses the same constant.
    • Rejected: Keep RepoRef.valkey_key("brain-issue"). It gives roadmap:v1:brain-issue:*, which no ACL role reaches.
    • Rejected: Use valkey:gh:*. The prefix is for GitHub objects, not brain issue records.
  • What happens to existing keys under the old prefix?: Do not migrate the old keys. The 24-hour TTL of DEFAULT_BRAIN_ISSUE_TTL_SECONDS removes them. State this in the pull request. (best practice) [sources: src/devops_cli/config/defaults.py:773, openspec/specs/project-brain/shared-cache/spec.md]
    • Chosen: Let the TTL remove old keys. No person step and no live migration.
    • Rejected: Run a migration or delete command. Adds an operational step and a risk.
  • When should the live proof run?: Wait 25 hours after the deploy. Then scan for the old and the new prefixes. A person runs the live proof after the merge. (best practice) [sources: src/devops_cli/config/defaults.py:773, openspec/specs/project-brain/shared-cache/spec.md]
    • Chosen: Scan 25 hours after the deploy. The old keys have a 24-hour TTL, so a later scan proves they are gone.
    • Rejected: Scan at the deploy. The old keys can stay for up to 24 hours.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    on Nov 26, 2026
  2. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor
    • Priority: Private repository data sits in a shared cache tier and the key prefix causes NOPERM for role users, a security rule violation with functional impact.
  3. added
    source/agent
    scope/roadmap
    status/new
    effort/medium
    value/high
    priority/p1-high
    on Nov 26, 2026
  4. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    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:

    • Valkey ACL key pattern per user cache key prefix isolation library, results: 5
    • Python cache library per-repository visibility aware keys GitHub issue cache, results: 5
    • open source cache library tenant namespacing ACL key prefix enforcement, results: 5

    Sources:

  5. added
    owner/agent
    on Nov 26, 2026
  6. added
    status/ready
    and removed
    status/new
    on Nov 26, 2026
  7. 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.

  8. added
    status/in-progress
    and removed
    status/ready
    on Nov 26, 2026
  9. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor

    Delivery note for pull request #7297.

    Left out of the pull request

    1. The pull request does not remove the cached issues of a repository that becomes private. A process that sends no sweep user stops its reads and writes of these entries when its public answer ends, at most 30 minutes after the change. Each key then expires 24 hours after its last write. The listing snapshot removes its copy at the first round after the change. To remove the entries sooner, the cache needs a SCAN of valkey:roadmap:v1:issue:<owner>/<name>:*, or one hash for each repository as the snapshot has.
    2. RepoRef.valkey_key and RepoRef.valkey_patterns (src/devops_cli/github/repo_ref.py) have no caller in src/ after the change. They build the key form of valkey-roadmap (ADR 0022 section 5).

    Webhook path

    The route sends no GitHub read. It takes repository.private of the signed delivery, else the visibility answer that the process holds, and writes nothing with neither. An unknown answer writes nothing under each ACL user, as the snapshot store has it.

  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 26, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 26, 2026
  12. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-26 15:07 UTC

  13. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor

    Live proof, 2026-11-27 15:40 UTC, more than 25 hours after the deploy: a read-only SCAN of valkey-devops (4,610 keys, 82 MiB of 256 MiB).

    • Keys with the old prefix roadmap:v1:brain-issue: 0. On 2026-11-26 there were 453, and 32 of them held issue records of private repositories.
    • Keys under the new prefix valkey:roadmap:v1:issue:: 554, in 7 repositories: dan-petty/devops-cli 516, dan-petty/infra 25, dan-petty/devtools 5, dan-petty/dotfiles 3, dan-petty/devcontainer-features 3, dan-petty/dreamscaper 1, dan-petty/vibes 1. GitHub gives private: false for each of the 7. No key of a private repository.
    • Key families: valkey:rag:embedding 3,831, valkey:roadmap:v1 561, valkey:brain:v1 218.

    The live criterion passes. The bound for a repository that becomes private later is #7298.

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/p1-highscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions