Repository navigation
ref(fan-out): Map bounded work with mapBounded - #3646
Merged
Merged
Conversation
The pLimit-then-Promise.all(list.map(limit(...))) pattern repeats at most fan-out sites. Add mapBounded(items, fn, concurrency?) to chat/fan-out.ts, defaulting to FAN_OUT_CONCURRENCY, and use it at each core site with one limiter per list. Plugins use pLimit(N).map. Sites that share one limiter across lists keep pLimit.
Flag a p-limit limiter that only wraps the callback of one Promise.all(list.map(...)), and convert the last core site. Co-Authored-By: BYK <[email protected]>
Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
9 screenshot changes — 9 changed · 0 added · 0 removed Review screenshots in Frameshift |
BYK
approved these changes
Nov 18, 2026
BYK
enabled auto-merge (squash)
November 18, 2026 10:09
Keep both new oxlint rules and convert the hand-written limiters that main added in slack-work, agent, task-execution state, agent-invocation stop and event-automation runs to mapBounded.
BYK
added a commit
that referenced
this pull request
Nov 18, 2026
#3635 merged after #3646 last took `main`, so `main` fails `junior/prefer-map-bounded` at six single-use limiters from #3635. This converts them to `mapBounded` with the default cap. The results stay in the same order. - `chat/events/store.ts`: `collectEventMatchKeys` index reads. - `chat/skills.ts`: skill discovery and `loadSkillsByName`. Before, one limiter was shared by the directories of every root. Discovery now lists all roots first, then reads every skill directory under one cap, so the total cap stays the same. The first root that has a skill name still wins. - `chat/slack/app-home.ts`: provider connection reads. - `chat/ingress/slack-conversation-unfurl.ts`: link unfurls. - `chat/conversations/pending-cards.ts`: terminal Turn event reads. <!-- junior-request-attribution:start --> via @BYK. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A7e1432c2f4a2110ee7bb48718f8b6fad --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A7e1432c2f4a2110ee7bb48718f8b6fad/?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]>
24 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bounded fan-out was written out by hand at dozens of sites: build a
pLimitlimiter, map the list, and wrap each call in the limiter insidePromise.all. This PR replaces that pattern with one call and adds a lint rule that rejects the hand-written form.Helper.
mapBounded(items, fn, concurrency = FAN_OUT_CONCURRENCY)inpackages/junior/src/chat/fan-out.tsmaps a list with at mostconcurrencycalls at once. Results keep the order of the input. It wrapspLimit(n).map.Converted sites.
mapBounded. They keep the same cap (8) and the same concurrency.junior-githubsites now callpLimit(N).map(...)with their existing caps, because plugins cannot import core.Exceptions that keep their own limiter.
Promise.allSettled, becausemapBoundedrejects on the first error.listChildAgentsWithoutAgentInvocations.Lint rule. The new oxlint rule
junior/prefer-map-boundedflags ap-limitlimiter that only wraps the callback of onePromise.all(list.map(...)). It catches both a single-useconst limit = pLimit(N)and an inlinepLimit(N)(...). The message points tomapBoundedin core and topLimit(N).mapin plugins. The rule is on forpackages/*/srcand for the dashboard'ssrc, with no baseline and no disables.policies/performance.mdand thebounded-fan-outmessage now point to the helper.Nothing breaks: the behavior and caps are unchanged.
via @BYK.
--
View Session [Sentry]