Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/queue/patchless-secret-scan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { FileFetcher } from "../review/review-grounding";
import { mapWithConcurrency } from "./map-with-concurrency";
import type { AdvisoryFinding, PullRequestFileRecord } from "../types";

/** Per-file cap when synthesizing a patch for GitHub's patch-less (binary/large) PR files. */
Expand Down Expand Up @@ -154,22 +155,14 @@ export function incompletePatchLessSecretScanFinding(
};
}

// Bounded-concurrency fan-out over the patch-less files. Delegates to the canonical `mapWithConcurrency`
// (#6602) — the worker-pool loop lives in exactly one place under src/queue and src/signals.
async function mapPatchLessSecretScanFilesWithConcurrency<T, R>(
items: T[],
limit: number,
mapper: (item: T) => Promise<R>,
): Promise<R[]> {
const results: R[] = new Array(items.length);
let nextIndex = 0;
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
while (nextIndex < items.length) {
const index = nextIndex;
nextIndex += 1;
results[index] = await mapper(items[index]!);
}
});
await Promise.all(workers);
return results;
return mapWithConcurrency(items, limit, mapper);
}

/** When GitHub omits inline `patch` (binary/large files), fetch post-change content and synthesize `+` lines so
Expand Down
17 changes: 5 additions & 12 deletions src/signals/focus-manifest-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { listSignalSnapshots, persistSignalSnapshot } from "../db/repositories";
import { mapWithConcurrency } from "../queue/map-with-concurrency";
import type { JsonValue } from "../types";
import { nowIso } from "../utils/json";
import { contentLaneConfigToJson, experimentalConfigToJson, featuresConfigToJson, gateConfigToJson, MAX_FOCUS_MANIFEST_BYTES, parseFocusManifest, parseFocusManifestContent, repoDocGenerationConfigToJson, reviewConfigToJson, reviewRecapConfigToJson, maintainerRecapConfigToJson, opsConfigToJson, publicStatsConfigToJson, draftFlowConfigToJson, upstreamDriftIssuesConfigToJson, sweepWatchdogConfigToJson, prReconciliationConfigToJson, federatedIntelligenceConfigToJson, settingsOverrideToJson, type FocusManifest, type FocusManifestSource, type RepoReviewContext } from "./focus-manifest";
Expand Down Expand Up @@ -235,19 +236,11 @@ async function readBoundedResponseText(response: Response): Promise<string | nul
}
}

/** Bounded-concurrency fan-out: runs `mapper` over `items` with at most `limit` in flight at once (#3899). */
/** Bounded-concurrency fan-out: runs `mapper` over `items` with at most `limit` in flight at once (#3899).
* Delegates to the canonical `mapWithConcurrency` (#6602) so the worker-pool loop lives in exactly one place;
* the name and `(items, limit, mapper)` signature are preserved for existing callers. */
export async function mapWithConcurrencyLimit<T, U>(items: T[], limit: number, mapper: (item: T) => Promise<U>): Promise<U[]> {
const results: U[] = new Array(items.length);
let nextIndex = 0;
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
while (nextIndex < items.length) {
const index = nextIndex;
nextIndex += 1;
results[index] = await mapper(items[index]!);
}
});
await Promise.all(workers);
return results;
return mapWithConcurrency(items, limit, mapper);
}

/**
Expand Down
Loading