Skip to content

cacheserver: scope entries by repository ID as well as name - #216

Merged
linyiru merged 3 commits into
mainfrom
cache-scope-repo-id
Nov 8, 2026
Merged

linyiru merged 3 commits into
mainfrom
cache-scope-repo-id

Conversation

@linyiru

@linyiru linyiru commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Job identity and cache scope used the repository's owner/name. That name passes to a different repository once its first owner renames or deletes it. A repository later created under the same name, and served by the same cache, could then read the earlier repository's retained entries, git packs included, through an empty restore prefix and without knowing any key.

Changes:

  • Resolution reads GitHub's repository ID from GET /repos/{name}. The workflow run must report the same ID, or resolution fails.
  • Identity.RepositoryID is required by Validate.
  • The cache server scopes entries by Identity.ScopeKey(), which is <lowercased name>#<id>. Keeping the name in the key also means a repository transferred to another owner does not carry caches built there into its new owner.
  • Entries saved under the name alone match no identity and age out. The first jobs after an upgrade, and a repository's first jobs after a rename or transfer, miss the cache once. Daemon restarts clear identity records, so only a cache-server newer than its daemon denies, until both are upgraded.

Tests:

  • Resolution carries the ID, and fails without it or on a mismatch.
  • A recreated repository reads nothing of its predecessor's.
  • An index saved by the previous version is not restored.
  • Validate requires the ID.
  • scripts/mutate.sh confirmed that the scope key, the required run ID and the Validate check are each caught by a test.

Review: a fresh reviewer agent reviewed the change. It confirmed that the only identity that grants access comes from Registry.Start through GitHub.Resolve, that an old name cannot resolve to a renamed repository's ID, and that nothing builds a URL from the rewritten field. Its should-fixes are fixed here: the run's ID is now required, and the upgrade path has a test.

Job identity and cache scope used the repository's owner/name, which
passes to a different repository once its first owner renames or
deletes it. A repository later created under that name, served by the
same cache, could read the earlier one's retained entries, git packs
included, through an empty restore prefix, without knowing a key.

Resolution now reads GitHub's repository ID and requires the run to
report the same one, Validate requires it, and the cache server scopes
entries by "<name>#<id>". Keeping the name in the key also means a
repository transferred to another owner does not carry caches built
there into its new one. Entries saved under the name alone match no
identity and age out.

Signed-off-by: Yi-Ru Lin <deduce@gmail.com>
@linyiru
linyiru enabled auto-merge November 8, 2026 04:45
Signed-off-by: Yi-Ru Lin <deduce@gmail.com>
…y IDs

The cache-protocol test's identity records had no repository_id, so every request was denied once Validate required one, and the entry-cap test from #215 compared entries against the bare name, which no longer is the scope.

Signed-off-by: Yi-Ru Lin <deduce@gmail.com>
@linyiru
linyiru merged commit c4f5979 into main Nov 8, 2026
7 checks passed
@linyiru
linyiru deleted the cache-scope-repo-id branch November 8, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant