Repository navigation
feat(objects): Share one HTTP cache for live object cards - #4393
Conversation
An Annotation now stores the subject of its object, in the Inbox form (`<plugin>:<kind>` or a core kind), and what the Conversation did to it: created, changed, or attached. Tool and hook results name the subject and the action, with the kinds that the plugin registers in `inboxSubjects`. The subject replaces `objectId`, and the Inbox owner lookup reads it. A trigger fills both columns for rows that old workers write, and for objects whose provider id is not known. Also adds the Annotations design doc and its terms. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…' into feat/annotation-subjects Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Cards read the object live, so a merge, a close, or a new pull request body changes no Annotation. The GitHub plugin no longer updates the status of pull request and issue cards, or their preview images, from webhooks and the daily reconcile. A conversation change batch now holds only Inbox item closes. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…' into feat/annotation-no-status-writes
A core Annotation, such as an Automation card, stores its subject kind without a plugin prefix, so listing it dropped the subject.
Sidebar chips, the Conversation detail, and Slack card details now read each object's title and state live, through the same subject-to-link-to- card resolver as the Inbox. A viewer who cannot read the object, or a failed read, gets only the stored label and link. A delivered Message card reads its object once with the access of the person who started the Conversation, and falls back to the saved facts. The dashboard drops its client-side annotation overlays and renders the server's cards. Preview images come from the live card. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…' into feat/annotation-live-cards Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> # Conflicts: # packages/junior/tests/integration/annotation-cards.test.ts
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…ved label A card no longer shows an Annotation's stored label. It shows the label of the live card, or, when Junior cannot read the object, the label that its link type makes from the link. Link types get an optional `label(url)` method. GitHub issue and pull request links make `owner/repo#n`. A link type without one shows the host of the link. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
… feat/annotation-no-status-writes Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…e detail ETag Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Cards read their object live, so a merge wrote nothing and an open page kept the old card. Plugins now report a changed object with ctx.annotations.objectChanged(subject). Core moves detail_version of each Conversation that annotates it, so the detail ETag and the versions poll change. It writes no Annotation. GitHub calls it from issue and pull request webhooks when the cached object changed. The detail annotation tests move to their own file. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
A check event marks the checks pending, a review clears the cached decision, and a patch fills in merge state and check counts. Each now calls objectChanged when it changes the entry, as pull request and issue webhooks do. The patch read asks GitHub for the pull request id.
Dashboard search matches the stored title, key, and link of an Annotation. A typed `<repository>#<number>` reference, or a link that a plugin link type names that way, resolves to a code change subject through the code change records, which follow repository renames. So a renamed repository's pull request is found by its new name without a provider call. The searchConversations and Slack message search `annotation` filters use the same resolution. Plugin `conversations.search` takes the object's subject instead of a key, and github_getPullRequest finds related conversations by the pull request's GitHub id. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…' into feat/annotation-subject-search Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
A word that every link holds, such as pull or github.com, matched each annotated Conversation.
Annotations now store only the title and the link of an object. Cards read the rest live. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
An Annotation stored a copy of the label, the state, and other facts of its object, and only webhooks kept that copy current. It now stores the subject, the title, and the link. The title and the link are columns, so search reads them directly. Cards read every other fact live, and the plugin makes the label from the link. Old workers still write the old JSON during rollout. The trigger fills the new columns from it and strips the dropped keys. Automation cards read the Automation from the database through a core link type. An Annotation whose plugin has no link type shows its label and its link. The annotation-fields check fails when a column or a saved field is not in its baseline, or when code reads a dropped field from the stored JSON. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…into feat/annotation-drop-facts Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> # Conflicts: # packages/junior/src/api/conversations/list.ts
…e object An object that the viewer cannot read comes back as a resource_link with its label and link. Message refs are always objects, so the transcript showed the card as unavailable instead.
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 <126780+BYK@users.noreply.github.com>
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
… feat/annotation-rename-backfill
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 <126780+BYK@users.noreply.github.com>
Core keeps one HTTP cache of provider GETs under plugin egress. Each entry belongs to one credential scope. A link type sets its TTL, a stale entry revalidates with If-None-Match or If-Modified-Since, and a failed read serves the last entry. GitHub webhook reads use the same cache through ctx.httpCache, so conditional-requests.ts goes away. A card that a cache served after its TTL carries fetchedAt, and the full card shows "Last fetched" again. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…' into feat/shared-object-http-cache Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> # Conflicts: # design/annotations.md # packages/docs/src/content/docs/extend/build-a-plugin.md # packages/junior-dashboard/src/client/conversations/ObjectCard.tsx # packages/junior-github/src/issue-links.ts # packages/junior-github/src/plugin.ts # packages/junior-github/src/pull-request-outcomes/apply.ts # packages/junior-github/src/tools/get-pull-request.ts # packages/junior-github/tests/get-pull-request.test.ts # packages/junior-linear/src/plugin.ts # packages/junior-plugin-api/src/object-links.ts # packages/junior-plugin-api/src/tools.ts # packages/junior/src/api/objects/resolve.ts # packages/junior/src/chat/conversations/plugin-search.ts # packages/junior/tests/component/linear-native-create.test.ts # packages/junior/tests/integration/annotation-cards.test.ts # packages/junior/tests/integration/search-conversations-tool.test.ts
Linear cards read issues through the viewer's MCP login, not egress, so the HTTP cache does not keep them. The link type opts into the card cache, so a card serves for a minute and a failed read shows the last card with when Junior fetched it. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…' into feat/shared-object-http-cache # Conflicts: # packages/junior-github/tests/plugin-harness.ts
BYK
left a comment
There was a problem hiding this comment.
I feel like we can extract a generic http cache or manager library by joining what we do here and over at getsentry/toolkit (mostly CLI there) and stop re-inventing the wheel like my zstd suggestion here. Check that code and see what we can do in a follow up.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 514e8d2. Configure here.
After a card read serves a stale HTTP body, the plugin cache of that read saves nothing. A saved copy would look fresh, so later cards would hide their age.
A 429 says nothing about access, so it now takes the same path as a 5xx: the entry and its validators stay, and staleIfError serves the last body.
|
I looked at the getsentry/toolkit cache for the shared-library follow-up. Most of a generic library already exists:
Junior has parts that toolkit's cache lacks: per-plugin TTLs, stale-if-error with an The plan is in #4397. The shared library becomes a new package, and toolkit and Junior both move onto it. The plugin TTL wins over server headers, so server headers can only shorten freshness. Compression (the zstd idea) comes with the move. |
… onto it (#2509) `@sentry/api/client`, the CLI, and Junior (getsentry/junior#4393) each carry their own HTTP cache and retry code. This adds one publishable, provider-neutral package, **`@sentry/http`**, and plugs it into `@sentry/api` from the toolkit side. `@sentry/api` gets no new dependency: it keeps its injection points and its Sentry-specific rules, and a follow-up in getsentry/sentry removes its generic cache and retry code. This is step 1 of getsentry/junior#4397. ## Package `packages/http`, published as `@sentry/http` (free on npm). It is set up like `@sentry/logger`: the workspace exports `src/`, `publishConfig.exports` points at the tsdown ESM and CJS build, and `test:package` packs the tarball and type-checks and runs it with TypeScript 5 and 7. - `@sentry/http` uses no Node APIs, so it runs in Node 22+, Workers, and browsers. - `@sentry/http/codec` is the zstd level 3 / brotli body codec, moved from `@sentry/toolkit-core/response-cache/codec`. It skips bodies under 256 B and never decompresses past the recorded size. ### Cache - `CacheStore` has `get`, `set(key, entry, ttlMs)`, `delete`, and `deleteMatching(identity, urlPrefix)`. - `createMemoryStore` is a byte-budgeted LRU. - The CLI's file store implements the same interface, and Junior can add a Redis one. - `FreshnessOptions` is `{ ttlMs, maxTtlMs?, retainMs?, staleIfError? }`, passed on each call instead of stored as a tier. - Server freshness headers (`max-age`, `no-cache`, `Expires`) win, longer or shorter. `ttlMs` applies when the server sends none, and `maxTtlMs` is an optional hard ceiling. - An entry is fresh or stale only for a request that matches its `Vary` headers. Any other request is a miss. - `ETag` and `Last-Modified` both count as validators. A stale entry is kept for `retainMs` (24 h by default) when it has one, or always with `staleIfError`. - `lookupResponse` and `storeResponse` are for hosts that own their request loop, as `@sentry/api`'s `TransportCache` seam does. - A `stale` lookup has `createdAt`, and with `staleIfError` it also has `serveStale()`. - `storeResponse` caches any body. `requireJson` keeps the old JSON-only check. - It cancels the body of a response it does not store. - `fetchWithCache({ store, codec, identity, url, ttlMs, send, onStale, onCacheError, ... })` sends one GET through the cache: - a fresh entry is served with no request - a stale one is revalidated - with `staleIfError`, a throw, 429, or 5xx serves the stale entry and calls `onStale(createdAt)` - a 4xx drops the entry - a store failure counts as a miss - `buildCacheKey` is unchanged, so keys from existing entries still match. ### Retries - `nextRetryDelayMs`, `isIdempotentRequest`, `parseRetryAfterMs`, `serverDelayUntil`, and `sleep`. - `RetryableStatuses` is configurable. By default 429 and 5xx replay only idempotent requests. - `fetchWithRetry(send, options)` is the loop. - `withRetry(fetch, options)` wraps any fetch-shaped call with that loop. - Options: `policy`, `retryableStatuses`, `serverDelayMs`, `isRetryableError`, `idempotent`, `isIdempotent({ method, url })`, `onRetry`. - It clones a `Request` input and reads a stream body once, so each attempt can resend it. An abort from the caller's signal stops it at once. ## Plugging it into `@sentry/api` - **Cache.** The CLI keeps using the transport's `cache` seam (`TransportCache`), now backed by `@sentry/http`'s `lookupResponse`, `storeResponse`, and keys. A cache entry needs the credential identity the transport resolves, so the seam is the right place for it. - **Retries.** These wrap the transport, not its `fetch` option. - `@sentry/toolkit-core/sentry-retry` exports `withSentryRetry(transport, options)`, which applies Sentry's rules. A 429 replays any method, since Sentry rejects it before the view runs. A 5xx replays only idempotent requests. Waits come from `@sentry/api`'s `parseRetryDelayMs`. - Each attempt is a whole `transport.request`. So it keeps the transport's own timeout, its body buffering (which the CLI chooses per SDK `Request`), and the 401 credential refresh. - The CLI and MCP transports now send each request once, via `TRANSPORT_SENDS_ONCE`. That constant goes away once `@sentry/api` no longer requires `retry`. - The CLI throws `RateLimitError` itself for a 429 it does not retry. - **Sentry rules stay in `@sentry/api`.** `classifyUrl` and `FALLBACK_TTL_MS` (passed as `ttlMs`; Sentry's `max-age` still wins), `computeInvalidationPrefixes`, `parseRetryDelayMs`, and the idempotent-operations matcher are all still imported from `@sentry/api/client`. With this merged, toolkit no longer uses `@sentry/api`'s generic response cache (`CacheLookup`, `CacheEntry`, `CacheStore`, the memory store, `lookupResponse`/`storeResponse`, keys), its built-in retries, or its `errors.rateLimited` hook. ## Other toolkit changes - `toolkit-core` drops `response-cache/codec`. Its test moved with the code. - Publishing, made generic: - `.craft.yml` has one `packages/{http,logger}` workspace for the standalone libraries (`<name>@` tags, `release/<name>/` branches, npm target). - `merge-jobs.yml` lists the Craft workspaces that use the default artifact provider (`scripts/npm-library-workspaces.mjs`). It packs each one in a parallel matrix job and merges the tarballs into the artifact named after the commit. It runs on `main` and every release branch, and no longer runs its own lint and tests. - `test.yml` now also runs on release branches, so each release commit gets the full per-project matrix. - `release.yml` keeps `product` as a choice. GitHub can't fill it from `.craft.yml`, so `workflow-policy.test.mjs` fails when the options and the `packages/` workspaces differ. - Adding a package means adding its name to the `.craft.yml` key and to the `product` options. No other workflow edits are needed. - The CLI keeps its own artifact provider: its release ships platform binaries, a Homebrew formula, the docs site, and `@sentry/mcp-server`, all built by `cli-build.yml`. - This PR releases nothing. - `@sentry/http` is MIT licensed, and its first release is `1.0.0`. ## Freshness default As in standard HTTP caching and in `@sentry/api` today, a server `max-age` can keep an entry fresh past the caller's `ttlMs`: if the server says a response is good for longer, a refresh would most likely return the same response. The CLI needs no option for this. `maxTtlMs` is an opt-in hard ceiling for callers that learn of changes another way. Junior's GitHub reads are the known case: they use `ttlMs: 0` with webhook invalidation, so they pass `maxTtlMs: 0` to keep a server `max-age` from skipping the revalidation that picks up a change. Next: getsentry/sentry removes the generic response-cache and retry code from `@sentry/api` and makes `retry` optional, as a breaking change. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A672bf07a67118adf395d2ead4a7cd9aa --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A672bf07a67118adf395d2ead4a7cd9aa) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A672bf07a67118adf395d2ead4a7cd9aa/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: BYK <126780+BYK@users.noreply.github.com>

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.tskeeps provider GET responses in the state adapter.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.If-None-Match/If-Modified-Since. A304stores the entry again.httpCache: { ttlMs, staleIfError? }on its definition. The default is 60 s with stale on error.resolveObjectLinkNowandviewerCanViewPluginLinkread 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.cacheCardsflips 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 (throughviewerMcp).GitHub
ctx.httpCachewith scopeinstallation:<id>, TTL 0, and no stale (installation-http-cache.ts).conditional-requests.tsis deleted. Token narrowing does not change.fetchedAt."Last fetched"
OwnedObjectAnnotation.fetchedAtis set only when a cache served an entry past its TTL. Its value is the oldest such entry's store time.fetchedAtis set, so the client needs no TTLs.(Mock dashboard, Notion page card served with a 3-hour-old
fetchedAt.)Linear
Whichever of this PR and #4331 landed second adds the
cacheCardsopt-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.via @BYK.
--
View Session [Sentry]