Skip to content

fix(roadmap): Correct visibility, keys and bounds of Valkey caches - #6625

Merged
dan-petty merged 19 commits into
mainfrom
fix/6611-correct-visibility-keys-and-bounds-of-valkey-caches
Nov 21, 2026
Merged

dan-petty merged 19 commits into
mainfrom
fix/6611-correct-visibility-keys-and-bounds-of-valkey-caches

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

The second review of #4668 found four defects of the shared tier of the brain:

  • A failed visibility read removed the shared copy of a public repository. The check now gives public, private or unknown. A private answer removes the copy. An unknown answer counts unknown, is read again after 60 s, and a script removes the copy only while its last save is older than 30 min. A public answer is kept 30 min, so the copy of a repository that became private goes at most 1 hour after the change, as the owner accepted.
  • The known records of a process used the text of the name, so two spellings wrote all records again. They now use RepoRef.key.
  • A load had no bound on the sum of its expanded records. It now expands at most 128 MiB, and a save past that bound writes no copy.
  • A fact from Valkey got a full new TTL in memory. It now expires with its Valkey key.

Closes #6611

Change: openspec/changes/archive/2026-11-21-6611-correct-visibility-keys-and-bounds-of-valkey-caches/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them labels Nov 21, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

A decision for the owner: the window of a repository that became private.

Before this change, a failed visibility read removed the shared copy, so the copy of a repository that became private stayed at most 1 hour (your decision of 2026-11-21). Now a failed read gives an unknown answer and leaves the copy, so the window is 1 hour after the change plus the time that the visibility reads fail. The TTL of the key (7 days) is the upper limit. During an unknown answer no process writes the copy.

  • A GraphQL quota that is out ends at its reset, at most 1 hour later.
  • A read that fails for good, such as Could not resolve to a Repository for a token that cannot see the repository, keeps the copy until its key expires. A follow-up can treat that answer as private.

Please accept this window, or ask for a code bound. docs/roadmap/intake.md, k8s/README.md and the design of the change give the bound.

…lkey caches

Plan #6611 as the change 6611-correct-visibility-keys-and-bounds-of-valkey-caches.
A failed visibility read becomes unknown and leaves the shared copy, the known
records use the RepoRef key, one load expands at most 128 MiB of records, and an
in-process fact expires with its Valkey key.
The visibility check gives public, private or unknown. A failed read is
unknown: it leaves the shared copy and is kept for 60 s.
The visibility check gives public, private or unknown. Only a private
answer removes the shared copy. An unknown answer does not read, write
or remove the shared copy, counts result unknown, and is kept for 60 s
in a TLRUCache, so a process out of GitHub quota sends no read for each
round.
Two spellings of one repository name in one process use one set of
known records, as they use one key. A save in the other spelling now
sends only the changed records, not a full write to a temporary key.
A load of a shared snapshot expands at most 128 MiB of record JSON in
total, in addition to 1 MiB for each record. Past the bound the load is
a miss and the reader takes the local copy. The local devops-cli
snapshot holds 37,927,266 bytes of JSON, so the bound is 3.5 times it.
A TieredMapping read from Valkey gets the value and the PTTL of its key
in one pipeline round trip, and keeps the value in memory no longer than
the key lives, or the TTL of the mapping when that is sooner. The
in-process tier is a cachetools TLRUCache.
The brain counters can count result unknown for a repository whose
visibility read failed. The intake document says that only a private
answer removes the shared copy, and that a failed read leaves it and is
read again after 60 s.
… load

A writer must not store a shared copy that no load accepts. The bound test
builds the store with a lower bound, and patches no module attribute.
A writer stored a copy that no load accepts, so each cold process scanned
and dropped it, and each later save kept it with EXPIRE. A save past the
bound now writes nothing and counts oversize. The store takes the bound as
its field load_max_bytes, so the tests patch no module attribute.

The documents gave one hour as the bound of a repository that became
private. An unknown visibility answer now keeps the copy, so the bound is
one hour plus the time that the visibility reads fail, at most the 7 days
of the key. The spec gets a requirement for the answer lifetimes, so each
requirement text stays under 500 characters after the archive.
…copy

An unknown visibility answer removes a shared copy whose last save is
older than one hour, and keeps a fresher copy. A key with no TTL, or no
key, gives no age, so the round removes nothing. The read of meta and of
the TTL of the key is one pipeline.
A failed visibility read that goes on, such as for a token that cannot
see the repository, kept the shared copy for the 7 days of its key. A
save comes only after a public answer, so the age of the last save is
the time since a process last saw the repository as public. An unknown
answer now removes a copy whose last save is older than one hour and
counts removed. A fresher copy stays. The read of meta and the PTTL of
the key is one pipeline, so a load sends no extra round trip.
The shared copy of a repository that became private goes at most about
2 h after the change, at the first run after that. The main spec, the
archived change, docs/roadmap/intake.md and k8s/README.md give it.
@dan-petty
dan-petty force-pushed the fix/6611-correct-visibility-keys-and-bounds-of-valkey-caches branch from 507076b to 52e35fd Compare November 21, 2026 14:21
@dan-petty

Copy link
Copy Markdown
Owner Author

Decision of the coordinator: the window of a repository that became private.

This decision replaces the question of 2026-11-21T13:55Z on this pull request (owner rule: decide open design questions with the best-practice answer and report them). No owner answer is necessary.

Decision: an unknown visibility answer removes the shared copy when its last save is older than DEFAULT_BRAIN_VISIBILITY_TTL_SECONDS (1 hour). A save comes only after a public answer, so the age of the last save is the time since a process last saw the repository as public. The age is the TTL of a snapshot (7 days) less the PTTL of the key. The store reads the PTTL with meta in one pipeline, so a load sends no extra round trip. A fresher copy stays, and the process with the unknown answer does not use it. A key with no TTL and a missing key give no age, so the store removes nothing. The removal counts the existing removed result. The store matches no error text.

New bound: a short failure keeps a fresh copy. The copy of a repository that became private goes at most about 2 hours after the change (1 hour of answer lifetime plus 1 hour), at the first run after that, and not after 7 days. This also covers Could not resolve to a Repository for a token that cannot see the repository.

Commits: 44617af (tests, red on 507076b), 9574115 (fix), 52e35fd (specs and documents). The spec, docs/roadmap/intake.md, k8s/README.md and the archived design give the bound.

…lity read

A public answer is kept for 30 min, and a failed visibility read removes a
shared copy saved more than 30 min ago, so the copy of a repository that
became private goes at most 1 h after the change (owner decision of
2026-11-21). A save during a failed visibility read keeps the copy, so the
cache tier removes a key in one script only when it still expires soon.
…when stale

A process keeps a visibility answer for 30 min, and a failed visibility
read removes a shared copy whose last save is older than 30 min. So the
copy of a repository that became private goes at most 1 h after the
change, the bound that the owner accepted on 2026-11-21, not about 2 h.

The removal is one Lua script (ValkeyCacheTier.unlink_if_expiring): Valkey
reads the PTTL again and sends UNLINK only when the copy is still stale, so
a save during the visibility read keeps the copy. The warning of a failed
visibility read and the comment of the failure TTL now say that an unknown
answer removes a copy older than 30 min.
The specs, the archived change, docs/roadmap/intake.md and k8s/README.md
give a visibility answer of 30 min and the bound of 1 h after a repository
becomes private, and name the script that removes only a copy that is
still stale.
@dan-petty

Copy link
Copy Markdown
Owner Author

Correction to the decision of the coordinator (issuecomment-7064030820): the bound is now 1 hour, not about 2 hours.

  • A review found that 1 hour for a public answer plus 1 hour for the age of a save gives about 2 hours. That is two times the 1 hour that the owner accepted on 2026-11-21 (comment on perf(roadmap): share the listing snapshot and facts in Valkey #6583). Only the owner can accept a longer window (AGENTS.md rule 5).
  • Commit 42980a2 keeps the 1 hour bound in code: a process keeps a visibility answer for 30 min (DEFAULT_BRAIN_VISIBILITY_TTL_SECONDS = 1,800 s), and an unknown answer removes a copy whose last save is older than 30 min. The cost is one more visibility read for each repository in each hour.
  • The removal is now one Lua script: Valkey reads the TTL of the key again and removes the key only while it is stale. A save during the visibility read keeps the copy.

The bound stays inside the owner decision, so no owner answer is necessary.

@dan-petty
dan-petty marked this pull request as ready for review November 21, 2026 14:53
@dan-petty
dan-petty merged commit 9d8ee87 into main Nov 21, 2026
36 checks passed
@dan-petty
dan-petty deleted the fix/6611-correct-visibility-keys-and-bounds-of-valkey-caches branch November 21, 2026 15:21
dan-petty pushed a commit that referenced this pull request Nov 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.188.1](v0.188.0...v0.188.1)
(2026-11-21)


### Bug Fixes

* **roadmap:** Correct visibility, keys and bounds of Valkey caches
([#6625](#6625))
([9d8ee87](9d8ee87))
* **roadmap:** keep other projects' workload names out of the review
([#6629](#6629))
([da17ec9](da17ec9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
dan-petty added a commit that referenced this pull request Nov 22, 2026
The delivery body limit has two meanings in the code and in the text
that a person reads. `CONTRIBUTING.md:181:in at most 1,000 characters
before the trailers` and the message field `form_body_long` measure the
text above `Closes`, and `pull_form` measures the `Closes` line, the
empty lines and the `Change:` line as well, about 120 characters of a
typical change folder. A body of 990 characters above `Closes` is
therefore refused at ready, and the merges of #6625 and #6629 waited on
that refusal. Issue #6633 asks for one meaning in the code, the message
and the document, for the plan body, and for the plan check.

Closes #6633

Change:
`openspec/changes/archive/2026-11-22-6633-the-body-limit-counts-the-closes/`

---------

Co-authored-by: devops-cli-service[bot] <349441588+devops-cli-service[bot]@users.noreply.github.com>
Co-authored-by: Daniel Petty <contact@danielpetty.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/roadmap The roadmap jobs: intake, refine, stage, implement and the Service that runs them type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(roadmap): correct visibility, keys and bounds of Valkey caches

1 participant