mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-28 06:22:22 +00:00
* fix(taint): cover inline and returned handlers (U8) Join expression-handler CFG summaries to distinct graph functions without changing existing anonymous-owner identities. Keep named function expressions private to their lexical scope. Related: #3489 * fix(ci): encode inline handler taint paths (U8) Use codec-safe generated display names while preserving positional function identity. Verify persisted hop continuity and remove the repaired inline-flow accuracy allowance. * fix: keep anonymous names unbound (U8) * test: pin inline callback captures (U8) * ci: run inline taint guard (U8) * test: align inline handler contracts (U8) Pin callback-owned call edges while preserving nested callable IDs and module-level HOC attribution. Assert repaired inline flows and the retained captured-closure limitation. * ci: run native inline proofs on all OSes (U8) Register real-worker identity/CFG and persisted explain cases on the existing Windows/macOS matrix. Charge explicit scheduling estimates without changing watchdogs or runtime behavior. * test(taint): reject all enclosing factory sources --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
206 lines
11 KiB
TypeScript
206 lines
11 KiB
TypeScript
/**
|
|
* Weight-aware partitioning for the cross-platform test matrix.
|
|
*
|
|
* WHY THIS EXISTS. `run-cross-platform.ts` used to hand vitest the whole file
|
|
* list plus `--shard=i/n`, and vitest partitions by file COUNT. Runtime on this
|
|
* suite is wildly uneven — measured on the Windows runner, `cli-e2e` is 621 s
|
|
* and `worker-pool` 221 s, while most files are under a second — so a
|
|
* count-split routinely put several of the heaviest suites on one shard. That
|
|
* is #2449, and this file's sibling header has documented the symptom ("the
|
|
* heaviest spawn suites can cluster on one shard") since the watchdog was first
|
|
* raised from 15 to 20 minutes.
|
|
*
|
|
* It went from a latent hazard to a red matrix when three CHEAP files (the
|
|
* `dist/` module-load closure guards: 448 ms, 53 ms, sub-second) were added to
|
|
* `SPAWN_CLI`. They cost nothing to run, but a count-split re-partitions on
|
|
* every insertion, and the reshuffle happened to land `cli-e2e` + `cli-limit-e2e`
|
|
* + `analyze-heap-oom-e2e` together on shard 1/3 — 32 files against 26 and 29 —
|
|
* which blew the 20-minute budget with four files still queued. Nothing about
|
|
* the added files caused it; they were simply the perturbation.
|
|
*
|
|
* So the split is done HERE, by weight, and only the chosen shard's files are
|
|
* handed to vitest. Two properties follow, and both are pinned in
|
|
* `test/unit/cross-platform-shard.test.ts`:
|
|
*
|
|
* - the heaviest suites are spread across shards by construction, so the
|
|
* busiest shard tracks the ideal rather than the luck of the sort order;
|
|
* - adding or removing a CHEAP file cannot move a heavy one, so registering a
|
|
* new platform-sensitive test is no longer a CI-stability gamble. That is the
|
|
* property whose absence caused this.
|
|
*/
|
|
|
|
/**
|
|
* Measured wall-clock on the WINDOWS runner (the slowest platform, so it is the
|
|
* one that decides the budget), in seconds, from the last fully-green matrix run
|
|
* plus the timed files of the run that failed.
|
|
*
|
|
* Only files heavy enough to matter are listed; everything else is carried by
|
|
* {@link PER_FILE_OVERHEAD_SEC} alone. These are load-balancing hints, NOT
|
|
* assertions — no test measures elapsed time against this table. Missing or
|
|
* stale heavy entries can still overload a shard; refresh them from failed
|
|
* CI logs and replay that profile in the partition tests. Deliberately not
|
|
* auto-generated: a committed table is reviewable and works offline, and the
|
|
* alternative (timing files at CI runtime to decide the split) would make the
|
|
* partition depend on the very machine load it is trying to protect against.
|
|
*/
|
|
export const WINDOWS_WEIGHTS_SEC: Readonly<Record<string, number>> = {
|
|
// Provisional Windows estimates, not Windows measurements: these native
|
|
// inline-handler proofs took 7.25/6.86/6.52s on Node24 Linux. Apply the
|
|
// runner's documented ~5x slowdown and round up; keep the watchdog unchanged.
|
|
'test/integration/cfg/interproc-taint.test.ts': 40,
|
|
'test/integration/function-local-identity.test.ts': 35,
|
|
'test/integration/taint-explain.test.ts': 35,
|
|
// Conservative estimates from Windows run 38144297115: persisted
|
|
// rename cases include native indexing and take up to ~25s each. Keep
|
|
// each language together while charging its complete fixture inventory.
|
|
// Refresh underestimates from run 38697469283; Zig's higher measurement
|
|
// comes from 38693066214. Stale weights packed too much native work ahead
|
|
// of cli-e2e and exhausted its shard's 20-minute watchdog.
|
|
'test/integration/rename-provider-c.test.ts': 202,
|
|
'test/integration/rename-provider-cobol.test.ts': 75,
|
|
'test/integration/rename-provider-cpp.test.ts': 250,
|
|
'test/integration/rename-provider-csharp.test.ts': 200,
|
|
'test/integration/rename-provider-dart.test.ts': 425,
|
|
'test/integration/rename-provider-go.test.ts': 221,
|
|
'test/integration/rename-provider-java.test.ts': 300,
|
|
'test/integration/rename-provider-javascript.test.ts': 225,
|
|
'test/integration/rename-provider-kotlin.test.ts': 300,
|
|
'test/integration/rename-provider-objective-c.test.ts': 285,
|
|
'test/integration/rename-provider-php.test.ts': 100,
|
|
'test/integration/rename-provider-python.test.ts': 375,
|
|
'test/integration/rename-provider-ruby.test.ts': 100,
|
|
'test/integration/rename-provider-rust.test.ts': 75,
|
|
'test/integration/rename-provider-swift.test.ts': 300,
|
|
'test/integration/rename-provider-typescript.test.ts': 625,
|
|
'test/integration/rename-provider-vue.test.ts': 200,
|
|
'test/integration/rename-provider-zig.test.ts': 183,
|
|
// Provisional: seven real-indexing child cases, using the existing ~25s
|
|
// Windows persisted-fixture profile above. Replace with observed CI timing.
|
|
'test/integration/rename-preview-plan.test.ts': 175,
|
|
'test/integration/mcp-index-generation.test.ts': 201,
|
|
'test/unit/incremental-dirty-recovery.test.ts': 76,
|
|
// Re-measured after the analyze --watch e2e landed in #3072. The previous
|
|
// 361 s entry undercharged this suite and left shard 1 close to the watchdog.
|
|
'test/integration/cli-e2e.test.ts': 621,
|
|
'test/integration/worker-pool.test.ts': 254,
|
|
'test/unit/incremental-vector-extension-ordering.test.ts': 87,
|
|
// Measured on Windows in run 34014266125 (#3190, 2026-09-06). These DB
|
|
// suites landed together on shard 3: the old 180s estimate and missing
|
|
// entries made a ~27-minute recorded load look like an ~12-minute shard.
|
|
// Upstream speedups may reduce these figures; retaining conservative weights
|
|
// keeps the expensive suites distributed without changing the watchdog.
|
|
'test/unit/incremental-index-extension-dml-gate.test.ts': 414,
|
|
// Re-measured on windows-latest run 34815870795 after vendored-first FTS
|
|
// rewrote the HOME-layout e2e (373s) and skills-e2e grew to 542s. The old
|
|
// 146s/444s entries packed both onto shard 2/3 and blew the 20-minute
|
|
// watchdog with one file still queued.
|
|
'test/integration/skills-e2e.test.ts': 550,
|
|
'test/integration/fts-extension-e2e.test.ts': 380,
|
|
'test/integration/skip-fts.test.ts': 110,
|
|
// Provisional: twice the local native-suite duration, pending Windows CI.
|
|
// These scheduling hints do not change test timeouts or pass/fail gates.
|
|
'test/integration/embedding-identity-integrity.test.ts': 180,
|
|
'test/integration/shared-store-embedding-reuse.test.ts': 140,
|
|
// Provisional: twice the 88.42s local native run, pending Windows CI timing.
|
|
'test/integration/embedding-input-isolation.test.ts': 180,
|
|
'test/integration/analyze-wal-checkpoint-failure.test.ts': 86,
|
|
// Windows run 39046807237 measured 308s before two cases reached recovery.
|
|
// Allow the measured ~19s recovery cost for each corrected in-place case.
|
|
'test/unit/incremental-write-integrity.test.ts': 360,
|
|
'test/integration/cli-limit-e2e.test.ts': 75,
|
|
'test/unit/hooks.test.ts': 26,
|
|
'test/integration/analyze-heap-oom-e2e.test.ts': 23,
|
|
'test/unit/git-utils.test.ts': 18,
|
|
'test/integration/hooks-e2e.test.ts': 15,
|
|
'test/integration/tree-sitter-languages.test.ts': 9,
|
|
'test/unit/repo-manager.test.ts': 9,
|
|
'test/unit/detect-changes-worktree.test.ts': 9,
|
|
'test/integration/antigravity-hook-e2e.test.ts': 7,
|
|
'test/unit/index-lock.test.ts': 5,
|
|
'test/unit/setup.test.ts': 5,
|
|
// ESTIMATE, not a measurement. This file asserts almost nothing; it READS —
|
|
// one 4893-file pass over every tracked text file, plus an 830-file pass over
|
|
// `src/`. Measured at 2.3 s and 0.3 s per pass on a virtualised and a local
|
|
// Linux filesystem respectively, so the cost is entirely per-file open
|
|
// latency, which is the term Windows inflates most (NTFS plus Defender on
|
|
// every read). Scaled from the slower Linux figure to keep the split
|
|
// conservative rather than let the 8 s PER_FILE_OVERHEAD floor under-charge
|
|
// a file that touches more paths than anything else here. Replace with a real
|
|
// figure after the first green Windows matrix run.
|
|
'test/unit/source-control-bytes.test.ts': 15,
|
|
};
|
|
|
|
/**
|
|
* Fixed cost every file pays regardless of what it asserts: a pool worker start,
|
|
* module graph evaluation, and (for most of this list) a native addon load.
|
|
*
|
|
* Added to EVERY file's weight, not just unmeasured ones, and that is the point.
|
|
* Calibrated against the last green Windows matrix: its busiest shard ran 736 s
|
|
* of wall clock over ~511 s of measured file time, so roughly 8 s per file is
|
|
* unattributed setup. Without this term the balancer treats a light file as
|
|
* nearly free and, having isolated the two monsters, piles every remaining file
|
|
* onto the other shards — trading a runtime imbalance for a file-count one that
|
|
* costs just as much. With it, the split balances runtime AND count together.
|
|
*/
|
|
const PER_FILE_OVERHEAD_SEC = 8;
|
|
|
|
/**
|
|
* Scheduling weight for `file`: its measured runtime (0 if it was fast enough
|
|
* that vitest printed no duration) plus the per-file floor above.
|
|
*/
|
|
export function weightOf(file: string): number {
|
|
return (WINDOWS_WEIGHTS_SEC[file] ?? 0) + PER_FILE_OVERHEAD_SEC;
|
|
}
|
|
|
|
/**
|
|
* Partition `files` into `total` shards and return the 1-based `index` one.
|
|
*
|
|
* Longest-processing-time first: sort by weight descending, then repeatedly give
|
|
* the next file to the lightest shard so far. LPT is the standard greedy for
|
|
* multiprocessor scheduling and is guaranteed within 4/3 of optimal — far more
|
|
* than enough here, where the goal is only "no shard gets two monsters".
|
|
*
|
|
* Ties break on the file path so the partition is DETERMINISTIC: every shard
|
|
* computes the same split independently, on a different machine, with no
|
|
* coordination — which is what lets each runner select its own slice.
|
|
*
|
|
* Returns files in the input list's original order, not weight order, so failure
|
|
* output and reruns stay readable.
|
|
*/
|
|
export function shardFiles(
|
|
files: readonly string[],
|
|
index: number,
|
|
total: number,
|
|
): readonly string[] {
|
|
if (!Number.isInteger(total) || total < 1) {
|
|
throw new Error(`shard total must be a positive integer, got ${total}`);
|
|
}
|
|
if (!Number.isInteger(index) || index < 1 || index > total) {
|
|
throw new Error(`shard index must be in 1..${total}, got ${index}`);
|
|
}
|
|
if (total === 1) return [...files];
|
|
|
|
const byWeightDesc = [...files].sort((a, b) => {
|
|
const diff = weightOf(b) - weightOf(a);
|
|
return diff !== 0 ? diff : a.localeCompare(b);
|
|
});
|
|
|
|
const loads = Array.from({ length: total }, () => 0);
|
|
const assigned = Array.from({ length: total }, () => new Set<string>());
|
|
for (const file of byWeightDesc) {
|
|
let lightest = 0;
|
|
for (let i = 1; i < total; i++) {
|
|
if (loads[i]! < loads[lightest]!) lightest = i;
|
|
}
|
|
assigned[lightest]!.add(file);
|
|
loads[lightest]! += weightOf(file);
|
|
}
|
|
|
|
const mine = assigned[index - 1]!;
|
|
return files.filter((f) => mine.has(f));
|
|
}
|
|
|
|
/** Total weight of a file set — the shard cost this balancer is minimising. */
|
|
export function shardWeight(files: readonly string[]): number {
|
|
return files.reduce((sum, f) => sum + weightOf(f), 0);
|
|
}
|