Skip to content

feat(annotations): Name old GitHub Annotations by GitHub's id, and follow renames - #4356

Merged
BYK merged 9 commits into
feat/annotation-drop-factsfrom
feat/annotation-rename-backfill
Nov 25, 2026
Merged

BYK merged 9 commits into
feat/annotation-drop-factsfrom
feat/annotation-rename-backfill

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes the last GitHub rename gap of the Annotations stack. A GitHub Annotation now names its object by GitHub's id, and a repository rename moves its keys and links. So search by the new name or link finds the object, and a later tool change hits the existing Annotation.

Core: three provider-neutral methods on ctx.annotations

Core owns the rows. The plugin owns the GitHub reads.

  • listObjects({ after, limit, named }): the keys of this plugin's Annotations, in key order after a cursor. With named, the keys whose subject names a provider id. Else the keys whose subject is only a link.
  • nameObject(key, { subject, url }): saves the subject and the current link on each link row with that key. The update time stays, so the row keeps its place.
  • objectsMoved({ from, to }): replaces a key prefix (in the column and in the saved Annotation) and a link prefix (links compare without case). A key moves only when its Conversation has no row of the same kind with the new key, so the primary key holds.

All three mark the touched Conversations' detail as changed.

upsertPluginAnnotation now finds the row of its object by subject first. When a tool saves an object under a new key, such as github_updateIssue after a rename, the existing row gets the new key and the upsert changes it. Before, the upsert added a second row. If the new key is already taken, nothing is rekeyed. GitHub tools key the Annotation by the repository in GitHub's html_url, so a call by a renamed repository's old name keeps the new key.

GitHub

  • Backfill and one-time sweep (annotation-names.ts): a started task with a payload schema. The heartbeat starts one slice at a time. The task key holds the slice number, and the progress (pass, after, slices, done) is kept in plugin state, so the job runs once per install. A slice reads at most 50 objects, by the link when it is a GitHub issue or pull request URL, else by the owner/repo#n key. It reads them with one read-only installation token (issues, pull requests, metadata). GitHub's redirect for a renamed repository is followed.
    • The named pass re-reads, once, each object whose Annotations already have GitHub's id. A rename from before this release then moves the repository's Annotations to the new name.
    • The unnamed pass then saves the id and current link of each object that has none. A pull request gets its own id, not its issues-API id.
    • A 404 or 410 (the object is gone, or the App cannot read it) leaves the row alone, and the cursor moves past it.
    • Any other error fails the slice, so the queue retries it, after the slice applies the moves it found. On the last delivery, that object is skipped, so one bad object cannot stall the job.
    • When GitHub answers with another repository name, the task reads the old repository name to tell a rename from a transferred issue. On a rename, the whole repository's Annotations move after the batch. In the unnamed pass, the pass then starts over, because the move can give unnamed rows keys before the cursor. Each such move names at least one object, so the restarts end.
  • Renames from now on: a repository webhook with renamed or transferred calls objectsMoved. The one-off repository name repair task does too.
  • Attached links: the issue and pull request cards now carry GitHub's id (id is added to the cached fields). So a newly attached GitHub link saves a real subject instead of a link row that the finished backfill would never see.

Linear: skipped

Old Linear rows keep the identifier (such as ENG-123) as subject_id. In this stack, the Linear plugin still names new rows by the identifier, because the hosted MCP server gives no other stable id here. The uuid change is in #4331, which is not in this stack. Reading the uuid also needs a viewer's MCP credentials. A background job has no viewer, and policies/security.md allows user-owned access only for the current actor or an explicitly delegated subject. So this PR does not borrow a person's credentials for a background read.

Security

This adds one credential path: a read-only installation token (issues, pull requests, metadata) for every repository of the installation. It lives in memory for one slice and is used only for GET requests. It is not scoped to repository names, because a renamed repository's old name fails a name-scoped token request. A breach of the task exposes read access to the installation's issues, pull requests, and repository metadata, which is the same scope as the existing repository name repair token plus issues and pull requests.

Notes

  • The App must subscribe to the repository webhook event for renames to arrive by webhook. Until then, only the one-time sweep fixes renames.
  • The sweep reads each GitHub object that an Annotation names once, at 50 a heartbeat.
  • objectsMoved filters by plugin and prefix with no index, so it scans this plugin's Annotation rows once for each rename. Renames are rare.
  • A transferred issue that already has an id keeps its old key and link. The sweep moves only renamed repositories.

The design commit deletes the closed Gap line from design/annotations.md.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 3 commits November 25, 2026 19:25
A bounded GitHub plugin job reads each old GitHub Annotation that names
its object only by a link, and saves the object's id and current link
through a provider-neutral `listUnnamed` and `nameObject`. A repository
rename moves the keys and links of its Annotations through
`objectsMoved`, from the `repository` webhook, the name repair, or the
job when GitHub answers an old name. An upsert finds the Annotation of
its object by subject, so a change after a rename keeps one Annotation.
Cards of attached GitHub links name their object too.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from BYK November 25, 2026 19:36
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 25, 2026 10:31pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 25, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

A move now also sets the key in the saved Annotation, which lists read.
A GitHub tool keys its Annotation by the repository in GitHub's link, so
a call by a renamed repository's old name no longer moves it back. A
failed read fails a backfill slice only after the slice applies the
moves that it found.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

A move changes keys before the cursor, so a retry of a slice that moved a repository reads from the start, as the next slice does after a move.
The backfill now first re-reads, once, each GitHub object whose
Annotations already have its id, in the same bounded slices. When GitHub
answers with a new repository name, the repository's Annotations move to
it, so a rename from before this release is found by its new name. Then
it names the objects without an id, as before. A slice reads at most one
batch across both passes, and the progress in plugin state marks the
sweep done. `listUnnamed` becomes `listObjects` with a `named` choice.

Co-Authored-By: BYK <[email protected]>
… feat/annotation-rename-backfill

Co-Authored-By: BYK <[email protected]>

# Conflicts:
#	packages/junior-github/src/plugin.ts
@BYK
BYK merged commit 38768f0 into feat/github-issue-assignee-items Nov 25, 2026
6 checks passed
@BYK
BYK deleted the feat/annotation-rename-backfill branch November 25, 2026 22:31

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cc3ce40. Configure here.

}
ctx.log.error("GitHub Annotation object read failed", {}, error);
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename-check errors skip object naming

Medium Severity

The try block wraps both readObject and the extra renamedTo repository lookup. When that lookup throws, the handler returns without calling nameObject, even though the object id and current link are already in hand. On the last delivery those rows stay unnamed for good. renames also caches a rejected promise per repository, so one repo-metadata failure skips every remaining object of that repository in the slice.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cc3ce40. Configure here.

BYK added a commit that referenced this pull request Nov 26, 2026
Fixes #4374

Live object cards now read through one HTTP cache that core owns.
Before, each provider cached in its own way. A card that a cache serves
after its TTL, because a read failed, shows "Last fetched …" again.

## HTTP cache in core
`chat/egress/http-cache.ts` keeps provider GET responses in the state
adapter.

- **Key:** each entry is keyed by credential scope, URL, and `Accept`.
Egress entries use the egress credential context as the scope, so a
viewer never gets another viewer's entry, and the system Actor never
shares one with a viewer. Viewers do share the system Actor's entry for
app-credential reads, because those reads are the same for everyone.
- **Fresh entries:** within its TTL, an entry serves with no request.
- **Stale entries:** an entry past its TTL asks the provider again with
`If-None-Match` / `If-Modified-Since`. A `304` stores the entry again.
- **Errors:** a network error or 5xx serves the last entry when the link
type allows stale. Any other non-200 deletes the entry, so a credential
that lost access can never be served it later.
- **Limits:** entries stay for TTL + 6 h, and bodies over 256 KiB are
not saved.
- **Link types:** each link type sets `httpCache: { ttlMs, staleIfError?
}` on its definition. The default is 60 s with stale on error.
- **Access checks:** `resolveObjectLinkNow` and
`viewerCanViewPluginLink` read with TTL 0 and no stale, so a change of
access counts at once.

The module header states what a breach of this store exposes: up to 6 h
of provider reads (card data and plugin webhook reads such as pull
requests, commit authors, and collaborator roles), and no token.

## Plugin API
- `RouteRegistrationHookContext.httpCache` (`PluginHttpCache`) is for
reads with a token that the plugin minted, such as webhook reads. Plugin
scopes are namespaced per plugin and never serve stale.
- `cacheCards` flips from an opt-out (`false`) to an opt-in (`true`).
Only link types that read their provider without egress keep the
per-viewer card cache: Slack and Conversation in core, Notion, and
Linear (through `viewerMcp`).

## GitHub
- Webhook reads go through `ctx.httpCache` with scope
`installation:<id>`, TTL 0, and no stale (`installation-http-cache.ts`).
`conditional-requests.ts` is deleted. Token narrowing does not change.
- GitHub cards read with HTTP TTL 0 and no stale. The object cache and
its webhook invalidation stay the freshness layer, so a stale body never
gets stored as a fresh object entry. An object-cache entry served after
its TTL also sets `fetchedAt`.

## "Last fetched"
- `OwnedObjectAnnotation.fetchedAt` is set only when a cache served an
entry past its TTL. Its value is the oldest such entry's store time.
- The full card footer shows "Last fetched …" when `fetchedAt` is set,
so the client needs no TTLs.

| | Light | Dark |
| --- | --- | --- |
| Desktop | ![light
desktop](https://junior-prod.sentry.dev/public/artifacts/583964b9-6bfc-4968-9a59-ac15cce51049.png)
| ![dark
desktop](https://junior-prod.sentry.dev/public/artifacts/b1b02f39-aedb-4a51-a4fc-7d1d8599cc1b.png)
|
| Mobile | ![light
mobile](https://junior-prod.sentry.dev/public/artifacts/ec70a7a2-2df4-45db-9a26-93482c93f024.png)
| ![dark
mobile](https://junior-prod.sentry.dev/public/artifacts/aeaaeda8-1bea-4fe5-814d-9c2b5f68f012.png)
|

(Mock dashboard, Notion page card served with a 3-hour-old `fetchedAt`.)

## Linear
Whichever of this PR and #4331 landed second adds the `cacheCards`
opt-in for Linear's link type. #4331 landed first, so this PR adds it in
its own commit, with a stale-on-error test.

## Base
This PR targets `feat/github-issue-assignee-items`, because the
Annotations stack (#4334, #4340, #4351, #4356) and Linear live cards
(#4331) are merged there. It brings that branch in with a merge commit.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A405f29e35c9132aca395b41d3747e969 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A405f29e35c9132aca395b41d3747e969)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A405f29e35c9132aca395b41d3747e969/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — cc3ce405 Deployed Nov 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant