perf(executors): lazy-load the executor registry — defer class imports + construction to first use (#11220) (#11421)

Validated in a combined 3-PR batch worktree off release/v3.8.51 tip (a sibling PR from the same author, #11495, was held out — a typecheck error in zai-web.ts only reproduced with this PR + #11495 boarded together, and cleared without #11495; isolated this PR alone confirmed clean on its own too, so the interaction belonged to #11495's side — see its comment).
- Golden lock: executor-map-golden.test.ts — passes byte-identical (same keys, classes, provider identities, dispatch guards)
- Focused tests part of batch's 94/94 node:test run
- typecheck:core, file-size, changelog-integrity, complexity, cognitive-complexity — all OK
- Full-repo lint: 228 pre-existing dashboard react-hooks/* findings, unrelated to this diff

Thanks for the measured, careful methodology here — the golden-lock contract plus the isolated DATA_DIR benchmarking make this an easy PR to trust despite the wide surface (72 files).
This commit is contained in:
Paijo
2026-08-26 04:22:46 +07:00
committed by GitHub
parent 026d26edb7
commit 7cfabfc5c9
72 changed files with 562 additions and 590 deletions

View File

@@ -19,11 +19,11 @@ function jsonResponse(body: unknown, status = 200) {
});
}
test("GitlabExecutor is registered in the executor index", () => {
test("GitlabExecutor is registered in the executor index", async () => {
assert.equal(hasSpecializedExecutor("gitlab"), true);
assert.ok(getExecutor("gitlab") instanceof GitlabExecutor);
assert.ok((await getExecutor("gitlab")) instanceof GitlabExecutor);
assert.equal(hasSpecializedExecutor("gitlab-duo"), true);
assert.ok(getExecutor("gitlab-duo") instanceof GitlabExecutor);
assert.ok((await getExecutor("gitlab-duo")) instanceof GitlabExecutor);
});
test("GitlabExecutor posts PAT-backed code suggestion requests to the configured instance", async () => {
@@ -147,7 +147,7 @@ test("GitlabExecutor maps upstream auth failures to OpenAI-style errors", async
});
test("GitlabExecutor uses GitLab direct_access for gitlab-duo and persists the cache", async () => {
const executor = getExecutor("gitlab-duo") as GitlabExecutor;
const executor = (await getExecutor("gitlab-duo")) as GitlabExecutor;
const originalFetch = globalThis.fetch;
const calls: Array<{ url: string; headers: Record<string, string> }> = [];
const refreshedPatches: Array<Record<string, unknown>> = [];
@@ -223,7 +223,7 @@ test("GitlabExecutor uses GitLab direct_access for gitlab-duo and persists the c
});
test("GitlabExecutor falls back to the public Code Suggestions endpoint when direct_access is disabled", async () => {
const executor = getExecutor("gitlab-duo") as GitlabExecutor;
const executor = (await getExecutor("gitlab-duo")) as GitlabExecutor;
const originalFetch = globalThis.fetch;
const calls: string[] = [];
@@ -274,7 +274,7 @@ test("GitlabExecutor falls back to the public Code Suggestions endpoint when dir
// Code Suggestions completions endpoint (same resilience as the 403-disabled case
// above), instead of surfacing an opaque 401 token error with no fallback.
test("GitlabExecutor falls back to the public Code Suggestions endpoint when direct_access returns 401", async () => {
const executor = getExecutor("gitlab-duo") as GitlabExecutor;
const executor = (await getExecutor("gitlab-duo")) as GitlabExecutor;
const originalFetch = globalThis.fetch;
const calls: string[] = [];