GitNexus/gitnexus/bench/swift-package-imports/measure.mjs
Gergő Magyar 51fb64c976
fix(swift): model Swift modules like the compiler (nested packages, Xcode targets, linear visibility) (#3387)
* fix(swift): discover nested Package.swift manifests for module grouping

A Swift monorepo laid out as Core/<pkg>/Package.swift has no root manifest
and no root Sources/, so every Swift file fell into one __default__ module.
The Swift resolver now walks the repo (bounded, skipping dot, ignored, and
Xcode bundle directories) and adds each nested package's targets, keyed by
repo-relative directory and ordered deepest-first so first-match grouping
picks the most specific target. Import resolution keeps the root view.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): bound implicit IMPORTS edges by a total budget

Implicit same-module IMPORTS are n*(n-1) edges per module, and the graph
keeps every relationship in one Map capped by V8 at 2^24 entries. Emission
now fills a 4M-edge budget smallest module first and skips, with a warning,
any module that does not fit, so no module layout can crash analyze.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): skip pairwise sibling passes for oversized modules

The target-siblings and sibling-type-bindings passes copy every file's
declarations into every other file of a module, so heap grows as n^2:
about 3.8 GB at 1,000 files with 15 defs each, about 15 GB at 2,000.
Modules over 1,000 files now skip both passes with a warning and resolve
through the global name fallback. GITNEXUS_SWIFT_MAX_MODULE_FILES changes
the ceiling.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(swift): cover nested SwiftPM packages end to end

A fixture with three nested Package.swift manifests (two declaring a target
named Net) and no root manifest. Each target gets its own implicit IMPORTS,
none cross packages, and Config() resolves to the caller's own package.
The Swift capture golden and scope-capture fingerprint grow with the new
fixture corpus only.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(review): apply review findings

- Rebase nested target paths with the existing Zig path helpers, which also
  reject Windows drive paths and paths that resolve to the repo root (whose
  empty prefix would group every file into one target).
- Document GITNEXUS_SWIFT_MAX_MODULE_FILES in the README env table.
- State that skipped modules resolve through lower-confidence fallback edges,
  why nested-type fragments still run for oversized modules, and fix a stale
  loader name in the target-grouping header.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* test(swift): cover every skipped Xcode bundle suffix in the package walk

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): model modules the way the compiler does

Replace the caps from the first round with representations that stay
linear, and derive module identity from the same sources the compiler uses.

- Same-module visibility is one File -> Module IMPORTS edge per file
  (reason `module-membership`) instead of an edge per ordered file pair.
  Incremental importer expansion treats files sharing a Module hub as
  importers of each other. The 4M edge budget is gone.
- Sibling declarations and type bindings live in one shared table per
  module in the namespace channel C# uses since #1871, instead of being
  copied into every file. The 1,000-file ceiling and
  GITNEXUS_SWIFT_MAX_MODULE_FILES are gone.
- Modules come from root and nested SwiftPM manifests (Sources, Source,
  src, srcs; plugins under Plugins; the newest Package@swift-X.Y.swift)
  and from Xcode native targets in project.pbxproj, including Xcode 16
  synchronized folders. Target paths are matched from the repo root, so
  a vendored copy of the same layout is no longer grouped into a root
  target (this reverses #2931's floating match).
- `import X` resolves to the modules named X instead of any folder named
  X. A name no module carries is external when every manifest and
  project was read completely.
- The global-name-fallback veto uses the same membership, so test
  targets, custom-path targets and Xcode targets have module identity.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(bench): move the Swift package bench to module grouping

The bench still imported the removed groupSwiftFilesBySpmTarget. Its
first-wins probe keeps its meaning under root-anchored grouping: the
clash file sits under Sources/Mod0, and the Sources/Mod1 further down its
path is a vendored copy.

Plugins are now non-importable modules under Plugins/, so parse_targets
counts importable source targets (still 3) and parse_binary_skipped also
checks that the plugin is recorded that way. Baseline values unchanged;
the notes say why the definitions moved.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(swift): match compiler module names, manifests, and target filters

- Module names follow the compiler's c99 mangling (`my-lib` imports as
  `my_lib`); Xcode targets use a literal PRODUCT_MODULE_NAME or
  PRODUCT_NAME when the project sets one.
- Package manifests are one-file modules, as SwiftPM compiles them. Files
  outside every target are one-file modules once every manifest and
  project was read; otherwise they keep the shared __default__ module.
- Xcode 16 synchronized-folder exceptions add a file to a target that
  does not list the folder, and remove it from one that does.
- SwiftPM `sources:` / `exclude:` narrow a target; a computed list marks
  the manifest unreadable.
- The default target folder is chosen once per package, as SwiftPM does,
  instead of per target.

Refs #3355

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Address PR review feedback (#3387)

- Inferred Swift folders keep SwiftPM's first predefined parent when a
  target name repeats (Sources before srcs).
- The pbxproj parser rejects a \U escape without four hex digits instead
  of decoding garbage, so the project reads as incomplete.
- Extension owners are stamped in every Xcode membership of a shared file.
- A plugin name never reaches a plugin: neither the fallback veto nor the
  folder-index fallback treats a known non-importable module as imported.
- A file an Xcode target compiles keeps that membership even when it also
  lies under a SwiftPM target directory.
- The workspace scan bounds the queue, not only the directories read.
- Integration tests require each module hub to exist before comparing.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 06:24:35 +01:00

482 lines
18 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Build-free bench for Swift Package.swift declaration resolve (#2964 / #2931).
*
* WHY THIS EXISTS. `bench/import-target`'s Swift arm never threads a
* `resolutionConfig`. It times the no-manifest directory-segment index
* (`getSwiftModuleIndex`) and cannot see a revert that starts scanning
* `allFilePaths` per `import`, drops declaration-only resolve, treats
* `https://` as a comment, or matches a target dir inside another path
* segment (#2931). Graph output on a tiny fixture is identical either way.
* This file is the same shape as `bench/parse-dispatch-rounds`: exact floors
* first, ratio timing only, never a millisecond ceiling.
*
* ARMS:
*
* - `targets` / `files` / `imports` — EXACT, and they are the FLOOR.
* `declared_resolved` only asserts something while the corpus still has
* many files and imports to walk. Shrink it to one happy-path module and
* the resolve arm still passes, gating a property the corpus no longer has.
*
* - `declared_resolved` / `sdk_external` / `undeclared_external` /
* `empty_declared_external` / `reexport_extra` / `nested_repeat_resolved` /
* `first_wins` — EXACT. Declaration map hits stay hits. Foundation / UIKit
* and an in-repo `CoreUI` folder that is NOT in Package.swift stay
* external. An empty `declaredTargets` map fails every name closed. Import
* of a module that `@_exported import`s another unions that module's files.
* A `#2931` nested `Sources/Mod0` path still belongs to Mod0 for import
* resolve. Grouping anchors target paths at the repo root (#3355), so a
* two-prefix file joins the target it sits under, not a later match.
*
* - `parse_targets` / `parse_binary_skipped` / `url_comment_targets` /
* `parse_complete` — EXACT. Source factories are kept; binary and
* system-library factories are not modules; a plugin is a non-importable
* module under `Plugins/` (#3355); `https://` on the same line does not hide
* a later `.target`.
*
* - `layout_fingerprint` — EXACT. sha256 over sorted `from|target->files`
* rows on the unique query set. Catches a target-set change that leaves
* the counts intact.
*
* - `resolve_scaling_ratio` / `strategy_scaling_ratio` / `parse_scaling_ratio`
* — the only timing arms, RATIOS not millisecond ceilings.
* `(t_4n / t_n) / 4` divides the machine out; ~1.0 is linear.
* Files-per-target is FIXED while target count (and therefore files and
* imports) grow 4x, so a hit returns a constant-size file list. A correct
* once-per-pass index is then linear in imports; a per-import scan of
* allFilePaths scores ~4. Parse scales factory count 4x on a fixed-shape
* manifest.
*
* Usage:
* node --import tsx bench/swift-package-imports/measure.mjs
* node --import tsx bench/swift-package-imports/measure.mjs --check
*/
import { createHash } from 'node:crypto';
import { readFileSync } from 'node:fs';
import { performance } from 'node:perf_hooks';
import { parseSwiftPackageManifest } from '../../src/core/ingestion/language-config.ts';
import { swiftPackageStrategy } from '../../src/core/ingestion/import-resolvers/configs/swift.ts';
import { resolveSwiftImportTarget } from '../../src/core/ingestion/languages/swift/import-target.ts';
import { groupSwiftFilesByModule } from '../../src/core/ingestion/languages/swift/target-grouping.ts';
const baselines = JSON.parse(readFileSync(new URL('./baselines.json', import.meta.url), 'utf8'));
const REPS = 15;
const TARGETS_SMALL = 16;
const FILES_PER_TARGET = 16;
const QUERY_REPEATS = 8;
const PARSE_TARGETS = 256;
const SCALE = 4;
function queryKinds(targetCount) {
return [
(t) => ({ raw: `Mod${(t + 1) % targetCount}`, expect: 'declared' }),
() => ({ raw: 'Foundation', expect: 'sdk' }),
() => ({ raw: 'CoreUI', expect: 'undeclared' }),
(t) => ({ raw: `Mod${(t + 1) % targetCount}.Model`, expect: 'declared' }),
() => ({ raw: 'UIKit', expect: 'sdk' }),
() => ({ raw: 'Ghost', expect: 'miss' }),
];
}
function parsedImport(targetRaw) {
return { kind: 'namespace', localName: targetRaw, importedName: targetRaw, targetRaw };
}
function stubFile(filePath, parsedImports = []) {
return {
filePath,
moduleScope: `module:${filePath}`,
scopes: [],
parsedImports,
localDefs: [],
referenceSites: [],
};
}
function targetMap(targetCount) {
const targets = new Map();
for (let t = 0; t < targetCount; t++) targets.set(`Mod${t}`, `Sources/Mod${t}`);
return targets;
}
function declaredConfig(targets) {
return { origin: 'package.swift', targets, declaredTargets: targets };
}
function buildCorpus(targetCount) {
const targets = targetMap(targetCount);
const files = [];
const parsedFiles = [];
for (let t = 0; t < targetCount; t++) {
for (let i = 0; i < FILES_PER_TARGET; i++) {
const filePath = `Sources/Mod${t}/File${i}.swift`;
files.push(filePath);
const imports =
t === 0 && i === 0
? [{ kind: 'reexport', localName: 'Mod1', importedName: 'Mod1', targetRaw: 'Mod1' }]
: [];
parsedFiles.push(stubFile(filePath, imports));
}
}
const foundation = 'Sources/Foundation/Thing.swift';
const coreUi = 'Sources/CoreUI/View.swift';
const nested = 'vendor/Sources/Mod0/Sources/Mod0/Nested.swift';
const clash = 'Sources/Mod0/Vendor/Sources/Mod1/Clash.swift';
for (const extra of [foundation, coreUi, nested, clash]) {
files.push(extra);
parsedFiles.push(stubFile(extra));
}
const kinds = queryKinds(targetCount);
const queries = [];
for (let t = 0; t < targetCount; t++) {
for (let i = 0; i < FILES_PER_TARGET; i++) {
const from = `Sources/Mod${t}/File${i}.swift`;
for (let r = 0; r < QUERY_REPEATS; r++) {
for (const kind of kinds) {
const { raw, expect } = kind(t);
queries.push({ from, raw, expect, unique: r === 0 && i === 0 });
}
}
}
}
return {
files,
parsedFiles,
queries,
targets,
config: declaredConfig(targets),
extras: { foundation, coreUi, nested, clash },
targetCount,
};
}
function outcomeKey(from, raw, result) {
if (result == null) return `${from}|${raw}-><null>`;
const list = typeof result === 'string' ? [result] : [...result];
return `${from}|${raw}->${list.sort().join(',')}`;
}
function resultFiles(result) {
if (result == null) return [];
return typeof result === 'string' ? [result] : [...result];
}
function resolveOne(query, allFilePaths, config, parsedFiles) {
return resolveSwiftImportTarget(parsedImport(query.raw), {
fromFile: query.from,
allFilePaths,
resolutionConfig: config,
parsedFiles,
});
}
function strategyCtx(files, config) {
return {
allFilePaths: new Set(files),
allFileList: files,
normalizedFileList: files.map((p) => p.replace(/\\/g, '/')),
index: {},
resolveCache: new Map(),
configs: {
tsconfigPaths: null,
goModule: null,
composerConfig: null,
swiftPackageConfig: config,
csharpConfigs: [],
},
};
}
function resolvePass(corpus) {
const allFilePaths = new Set(corpus.files);
let resolved = 0;
for (const query of corpus.queries) {
if (resolveOne(query, allFilePaths, corpus.config, corpus.parsedFiles) != null) resolved++;
}
return resolved;
}
function strategyPass(corpus) {
const ctx = strategyCtx(corpus.files, corpus.config);
let resolved = 0;
for (const query of corpus.queries) {
if (swiftPackageStrategy(query.raw, query.from, ctx) != null) resolved++;
}
return resolved;
}
function manifestFor(targetCount) {
const rows = [];
for (let i = 0; i < targetCount; i++) {
rows.push(
` .target(name: "Mod${i}", dependencies: [.product(name: "X", package: "https://example.com/x")]),`,
);
if (i % 8 === 0) {
rows.push(
` .binaryTarget(name: "Bin${i}", url: "https://example.com/b${i}.xcframework"),`,
);
}
}
return `let package = Package(\n name: "Demo",\n targets: [\n${rows.join('\n')}\n ]\n)\n`;
}
function fastest(fn, reps) {
fn();
let best = Infinity;
for (let r = 0; r < reps; r++) {
const t0 = performance.now();
fn();
best = Math.min(best, performance.now() - t0);
}
return best;
}
function correctness(corpus) {
const allFilePaths = new Set(corpus.files);
const records = [];
let declaredResolved = 0;
let sdkExternal = 0;
let undeclaredExternal = 0;
const unique = corpus.queries.filter((q) => q.unique);
for (const query of unique) {
const result = resolveOne(query, allFilePaths, corpus.config, corpus.parsedFiles);
records.push(outcomeKey(query.from, query.raw, result));
if (query.expect === 'declared' && result != null) declaredResolved++;
if (query.expect === 'sdk' && result == null) sdkExternal++;
if (query.expect === 'undeclared' && result == null) undeclaredExternal++;
}
const fromOther = 'Sources/Mod2/File0.swift';
const reexport = resultFiles(
resolveOne({ from: fromOther, raw: 'Mod0' }, allFilePaths, corpus.config, corpus.parsedFiles),
);
const reexportExtra =
reexport.includes('Sources/Mod0/File0.swift') && reexport.includes('Sources/Mod1/File0.swift')
? 1
: 0;
const nestedRepeatResolved = reexport.includes(corpus.extras.nested) ? 1 : 0;
const empty = resolveOne(
{ from: fromOther, raw: 'Mod0' },
allFilePaths,
{ origin: 'package.swift', targets: corpus.targets, declaredTargets: new Map() },
corpus.parsedFiles,
);
const emptyDeclaredExternal = empty == null ? 1 : 0;
// Anchored at the repo root: Clash.swift is under Sources/Mod0; the
// Sources/Mod1 further down its path is a vendored copy, not Mod1 (#3355).
const groups = groupSwiftFilesByModule(corpus.files, (p) => p, { targets: corpus.targets });
const firstWins =
groups.get('Mod0')?.includes(corpus.extras.clash) === true &&
groups.get('Mod1')?.includes(corpus.extras.clash) !== true
? 1
: 0;
const parseFixed = parseSwiftPackageManifest(`
let package = Package(
name: "Demo",
dependencies: [.package(url: "https://example.com/foo.git", from: "1.0.0")],
targets: [
.target(name: "Models"),
.target(name: "App"),
.binaryTarget(name: "Lib", url: "https://example.com/Lib.xcframework", checksum: "abc"),
.testTarget(name: "AppTests"),
.plugin(name: "Gen"),
.systemLibrary(name: "CFoo"),
]
)
`);
const urlComment = parseSwiftPackageManifest(
'let package = Package(name: "Demo", dependencies: [.package(url: "https://example.com/foo.git", from: "1.0.0")], targets: [.target(name: "T")])',
);
return {
declaredResolved,
sdkExternal,
undeclaredExternal,
emptyDeclaredExternal,
reexportExtra,
nestedRepeatResolved,
firstWins,
// Importable source targets. Plugins are modules (grouped) but never
// `import`-able (#3355), so they are counted by the arm below instead.
parseTargets: parseFixed.targets.size - parseFixed.plugins.size,
parseBinarySkipped:
!parseFixed.targets.has('Lib') &&
!parseFixed.targets.has('CFoo') &&
parseFixed.targets.get('Gen') === 'Plugins/Gen' &&
parseFixed.plugins.has('Gen')
? 1
: 0,
urlCommentTargets: urlComment.targets.get('T') === 'Sources/T' ? 1 : 0,
parseComplete: parseFixed.complete && urlComment.complete ? 1 : 0,
fingerprint: createHash('sha256').update(records.sort().join('\n')).digest('hex'),
};
}
const small = buildCorpus(TARGETS_SMALL);
const large = buildCorpus(TARGETS_SMALL * SCALE);
const shape = correctness(small);
const smallResolveMs = fastest(() => resolvePass(small), REPS);
const largeResolveMs = fastest(() => resolvePass(large), REPS);
const resolveScaling = largeResolveMs / smallResolveMs / SCALE;
const smallStrategyMs = fastest(() => strategyPass(small), REPS);
const largeStrategyMs = fastest(() => strategyPass(large), REPS);
const strategyScaling = largeStrategyMs / smallStrategyMs / SCALE;
const parseSmallSrc = manifestFor(PARSE_TARGETS);
const parseLargeSrc = manifestFor(PARSE_TARGETS * SCALE);
const parseSmall = parseSwiftPackageManifest(parseSmallSrc);
const parseLarge = parseSwiftPackageManifest(parseLargeSrc);
const smallParseMs = fastest(() => parseSwiftPackageManifest(parseSmallSrc), REPS);
const largeParseMs = fastest(() => parseSwiftPackageManifest(parseLargeSrc), REPS);
const parseScaling = largeParseMs / smallParseMs / SCALE;
const files = small.files.length;
const imports = small.queries.length;
console.log(`targets : ${small.targetCount} (expect ${baselines.targets})`);
console.log(`files : ${files} (expect ${baselines.files})`);
console.log(`imports : ${imports} (expect ${baselines.imports})`);
console.log(
`declared_resolved : ${shape.declaredResolved} (expect ${baselines.declared_resolved})`,
);
console.log(`sdk_external : ${shape.sdkExternal} (expect ${baselines.sdk_external})`);
console.log(
`undeclared_external : ${shape.undeclaredExternal} (expect ${baselines.undeclared_external})`,
);
console.log(
`empty_declared_external: ${shape.emptyDeclaredExternal} (expect ${baselines.empty_declared_external})`,
);
console.log(
`reexport_extra : ${shape.reexportExtra} (expect ${baselines.reexport_extra})`,
);
console.log(
`nested_repeat_resolved : ${shape.nestedRepeatResolved} (expect ${baselines.nested_repeat_resolved})`,
);
console.log(`first_wins : ${shape.firstWins} (expect ${baselines.first_wins})`);
console.log(`parse_targets : ${shape.parseTargets} (expect ${baselines.parse_targets})`);
console.log(
`parse_binary_skipped : ${shape.parseBinarySkipped} (expect ${baselines.parse_binary_skipped})`,
);
console.log(
`url_comment_targets : ${shape.urlCommentTargets} (expect ${baselines.url_comment_targets})`,
);
console.log(
`parse_complete : ${shape.parseComplete} (expect ${baselines.parse_complete})`,
);
console.log(`layout_fingerprint : ${shape.fingerprint}`);
console.log(
`resolve_scaling_ratio : ${resolveScaling.toFixed(3)} (budget <= ${baselines.resolve_scaling_budget}; ~1.0 is linear)`,
);
console.log(
`strategy_scaling_ratio : ${strategyScaling.toFixed(3)} (budget <= ${baselines.strategy_scaling_budget}; ~1.0 is linear)`,
);
console.log(
`parse_scaling_ratio : ${parseScaling.toFixed(3)} (budget <= ${baselines.parse_scaling_budget}; ~1.0 is linear)`,
);
console.log(
`reps : ${REPS} resolve ${smallResolveMs.toFixed(2)}ms / 4x ${largeResolveMs.toFixed(2)}ms strategy ${smallStrategyMs.toFixed(2)}ms / 4x ${largeStrategyMs.toFixed(2)}ms parse ${smallParseMs.toFixed(2)}ms / 4x ${largeParseMs.toFixed(2)}ms`,
);
console.log(
`parse_scale_shape : ${parseSmall.targets.size} -> ${parseLarge.targets.size} targets (expect ${PARSE_TARGETS} -> ${PARSE_TARGETS * SCALE})`,
);
if (process.argv.includes('--check')) {
let failed = false;
if (shape.fingerprint !== baselines.layout_fingerprint) {
failed = true;
console.error(
`\nFAIL layout_fingerprint: ${shape.fingerprint}\n` +
` expected ${baselines.layout_fingerprint}\n` +
` Unique-query target set moved. Explain it; do not re-baseline alone.`,
);
}
const exact = [
['targets', small.targetCount],
['files', files],
['imports', imports],
['declared_resolved', shape.declaredResolved],
['sdk_external', shape.sdkExternal],
['undeclared_external', shape.undeclaredExternal],
['empty_declared_external', shape.emptyDeclaredExternal],
['reexport_extra', shape.reexportExtra],
['nested_repeat_resolved', shape.nestedRepeatResolved],
['first_wins', shape.firstWins],
['parse_targets', shape.parseTargets],
['parse_binary_skipped', shape.parseBinarySkipped],
['url_comment_targets', shape.urlCommentTargets],
['parse_complete', shape.parseComplete],
];
for (const [name, value] of exact) {
if (value !== baselines[name]) {
failed = true;
console.error(`\nFAIL ${name}: ${value}, expected exactly ${baselines[name]}.`);
}
}
if (
small.targetCount !== baselines.targets ||
files !== baselines.files ||
imports !== baselines.imports
) {
failed = true;
console.error(
`\nFAIL shape: the corpus must stay large enough that declared_resolved still measures a walk.`,
);
}
if (
parseSmall.targets.size !== PARSE_TARGETS ||
parseLarge.targets.size !== PARSE_TARGETS * SCALE
) {
failed = true;
console.error(
`\nFAIL parse scale shape: ${parseSmall.targets.size} -> ${parseLarge.targets.size}, ` +
`expected ${PARSE_TARGETS} -> ${PARSE_TARGETS * SCALE}.`,
);
}
if (resolveScaling > baselines.resolve_scaling_budget) {
failed = true;
console.error(
`\nFAIL resolve_scaling_ratio: ${resolveScaling.toFixed(3)} exceeds ` +
`${baselines.resolve_scaling_budget} (~1.0 is linear).\n` +
` resolveSwiftImportTarget grew superlinearly in file+import count — a\n` +
` per-import scan of allFilePaths scores ~4 here. Re-run on an idle\n` +
` machine before investigating, and check \`reps\` first.`,
);
}
if (strategyScaling > baselines.strategy_scaling_budget) {
failed = true;
console.error(
`\nFAIL strategy_scaling_ratio: ${strategyScaling.toFixed(3)} exceeds ` +
`${baselines.strategy_scaling_budget} (~1.0 is linear).\n` +
` swiftPackageStrategy grew superlinearly — usually the WeakMap target\n` +
` index falling back to O(imports × files). Re-run idle; check \`reps\`.`,
);
}
if (parseScaling > baselines.parse_scaling_budget) {
failed = true;
console.error(
`\nFAIL parse_scaling_ratio: ${parseScaling.toFixed(3)} exceeds ` +
`${baselines.parse_scaling_budget} (~1.0 is linear).\n` +
` parseSwiftPackageManifest grew superlinearly in factory count.\n` +
` Re-run on an idle machine before investigating, and check \`reps\` first.`,
);
}
if (failed) process.exit(1);
console.log('\nOK — within budget.');
}