Repository navigation
feat(annotations): Name old GitHub Annotations by GitHub's id, and follow renames - #4356
Conversation
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]>
Co-Authored-By: BYK <[email protected]>
… feat/annotation-rename-backfill
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
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
… feat/annotation-rename-backfill Co-Authored-By: BYK <[email protected]>
… feat/annotation-rename-backfill Co-Authored-By: BYK <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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; | ||
| } |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit cc3ce40. Configure here.
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 |  |  | | Mobile |  |  | (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]>


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.annotationsCore 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. Withnamed, the keys whose subject names a provider id. Else the keys whose subject is only alink.nameObject(key, { subject, url }): saves the subject and the current link on eachlinkrow 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.
upsertPluginAnnotationnow finds the row of its object by subject first. When a tool saves an object under a new key, such asgithub_updateIssueafter 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'shtml_url, so a call by a renamed repository's old name keeps the new key.GitHub
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 theowner/repo#nkey. It reads them with one read-only installation token (issues, pull requests, metadata). GitHub's redirect for a renamed repository is followed.namedpass 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.unnamedpass 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.unnamedpass, 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.repositorywebhook withrenamedortransferredcallsobjectsMoved. The one-off repository name repair task does too.idis added to the cached fields). So a newly attached GitHub link saves a real subject instead of alinkrow that the finished backfill would never see.Linear: skipped
Old Linear rows keep the identifier (such as
ENG-123) assubject_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, andpolicies/security.mdallows 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
repositorywebhook event for renames to arrive by webhook. Until then, only the one-time sweep fixes renames.objectsMovedfilters by plugin and prefix with no index, so it scans this plugin's Annotation rows once for each rename. Renames are rare.The design commit deletes the closed Gap line from
design/annotations.md.via @BYK.
--
View Session [Sentry]