Public report — coreai-models, published 1 Oct 2026.
Concrete security findings (which rule fired, in which file, on which line; CVE IDs, secret matches,
dependency versions) are REDACTED in this version; ask the repo owner for the full report.
Public
Codebase surveyMeasured under the Code Assurance Index · rubric rubric-2026.09.18 (frozen) · verify this surveyFiledcd_baada263ad6648ce84907276aae4014b
Filed 1 October 2026, 09:46 UTC
Public
Medium · 65,366 LoC · 19 projects · rebuild ~0.8 person-years · weakest lens: Readiness (54%)
Findings by grade
7 critical428 serious34 minor38 could not be resolved — could be critical — see Limitations
This survey was produced by
Watchdog
Producer
Canine Development
Analyzer
Watchdog engine 1.0.0
Measured
1 October 2026, 09:37 UTC
A measurement, not a certificate. The Code Assurance Index does not certify,
approve or guarantee this codebase; it records a reproducible number and the evidence it was computed from. The
standard is authored by Canine Development, who also build Watchdog — its only implementation today. That is said
here so the number is checked rather than believed.
Grounded in facts. Every number here is computed, not narrated — reproducible, tool-backed, and traceable to a line of code. How to trust this ▸
445findings with an exact file:lineof 469 — the remainder are repo-wide signals (a dimension-level measurement, not a single line); open any file:line and verify
43/120dimensions across the health lenses65366 LoC · 19 projects — wide & deep
⚠ A critical security finding caps this grade — resolve it before relying on the score below; see the Security lens.
Preview (pre-1.0). This repo hasn't declared a stable release, so it's judged against a relaxed, pre-production bar.
The system holds a 64% health score, indicating a workable asset carrying real operational risk. While the codebase is well-structured and architecturally sound, its readiness for production is insufficient for a system of this size. This gap exposes the business to potential delivery delays and reliability issues that could erode user trust and increase support costs.
The value at stake is significant, with over 65,000 lines of production code representing roughly 0.8 person-years of effort to rebuild. This is not a trivial utility; it is a core component where changes ripple. The high cost of rebuilding underscores the importance of maintaining stability. However, the current state suggests that while the foundation is strong, the operational safeguards are lagging, creating a bottleneck for safe, rapid iteration.
The primary risk lies in production readiness. At 54%, the system lacks the necessary testing, observability, and security gates to ensure consistent, safe releases. This weakness means that defects are more likely to reach users, leading to outages or degraded performance. Without robust operational controls, every new feature release carries a higher probability of introducing regressions, directly impacting customer satisfaction and engineering velocity.
Conversely, the code’s maintainability and architecture are strong points. With high scores in code health and architecture, the system is easy to understand and modify. This strength provides a solid foundation for future improvements. The team can confidently refactor and extend the system without fearing widespread structural collapse, provided they address the operational gaps.
To maximize leverage, the team should prioritize adding automated security scanning to the CI pipeline. This single action addresses the most critical readiness gap by preventing security regressions from reaching production. It is a low-effort, high-impact change that immediately reduces risk. Following this, the team should implement a changelog and document key architectural decisions to improve transparency and onboarding for new engineers.
Note that domain modeling, event-driven patterns, and accessibility were not measured, so the full picture is partial. The assessment focuses on the measured areas, which currently present the most immediate business risk.
How the score is built — each lens's share of the headlineWidth is the lens's weight in the worst-heaviest fold (the weakest area pulls hardest); colour is that lens's own band. A lens fixes the score in proportion to its width.
208 finding(s) are new versus the previous scan (2026-09-15) — surfaced by this scheduled scan itself, no pull request required. Showing the first 100; the full set is in the report.
A full-fidelity diff against the previous run's complete recorded findings — line-move tolerant: a finding that only shifted line counts as unchanged, only genuinely new titles/files surface here.
0.9× (at 64% quality) — the last 20% of quality is most of the work
Size & shape
Medium · effort split not classified (source measured from disk; the effort-tier breakdown is a C#-only syntax walk)
This codebase represents roughly ~0.8 person-years of build effort (about ~€120,000 to rebuild). Its weakest lens is Readiness at 54% — the part of that asset most exposed by the findings below.
How we model this: boilerplate at a scaffolding rate + logic × domain Standard (×1.0) — standard service × a 0.9× quality factor, at €60–95/h; indicative, ±~30% · size measured directly from source · effort from total production LoC as straight-line logic (the tier split is a C#-only syntax walk), a conservative lower bound. Indicative only — most sensitive to the hourly rate and the domain tier (both tunable in config).
Top priorities
The highest-leverage moves; the full ranked list is in the Roadmap below.
1
Resolve the 1 No ADRs found finding(s) in ADR Quality.
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Value concentrated against a weak lens · Medium · Value at risk
This is a Medium asset (~0.8 person-years to rebuild), and its weakest lens is Readiness at 54%. The operational and business risk on an asset this size concentrates there — that's where remediation buys the most protection.
→ Direct remediation budget at Readiness first — highest risk-reduction per euro on an asset this size.
Highest-leverage move · Medium · Leverage
Of everything flagged, the best return on effort is: Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing. The rest can wait behind it.
Evidence: priority ranking: top of 5 ranked by impact/effort
→ Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Architecture — module dependency graph
Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways — a layering smell or cycle. A clean layered graph has none.
Architecture — module dependency matrix
Rows and columns are the same modules, ordered so that a module only depends on ones above it. A cell means the row depends on the column, and its number is how many type pairs create that dependency. Read one thing: is anything above the diagonal? A mark there is a dependency cycle. (A cycle is all this shows — an unusual but cycle-free dependency sits below the diagonal like any other.)
128 modules, 78 dependencies. 1 dependency cycle across 5 modules, marked above the diagonal.
Showing the 40 most-connected modules; 88 more are not drawn.
Module dependency matrix. The row depends on the column; the number is how many type pairs create the dependency. A cell above the diagonal is part of a dependency cycle.
python.src.coreai_models uses python.src.coreai_models.model_registry. Changing python.src.coreai_models.model_registry can break python.src.coreai_models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
14→2 python.src.coreai_models.diffusion depends on python.src.coreai_models.diffusion.pipeline✕
Type pairs
1 distinct (type in python.src.coreai_models.diffusion → type in python.src.coreai_models.diffusion.pipeline) reference.
python.src.coreai_models.diffusion uses python.src.coreai_models.diffusion.pipeline. Changing python.src.coreai_models.diffusion.pipeline can break python.src.coreai_models.diffusion, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
15→3 python.src.coreai_models.export depends on python.src.coreai_models.export.pipeline✕
Type pairs
1 distinct (type in python.src.coreai_models.export → type in python.src.coreai_models.export.pipeline) reference.
python.src.coreai_models.export uses python.src.coreai_models.export.pipeline. Changing python.src.coreai_models.export.pipeline can break python.src.coreai_models.export, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
15→6 python.src.coreai_models.export depends on python.src.coreai_models.models.base✕
Type pairs
3 distinct (type in python.src.coreai_models.export → type in python.src.coreai_models.models.base) references.
python.src.coreai_models.export uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.export, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
16→3 python.src.coreai_models.llm depends on python.src.coreai_models.export.pipeline✕
Type pairs
1 distinct (type in python.src.coreai_models.llm → type in python.src.coreai_models.export.pipeline) reference.
python.src.coreai_models.llm uses python.src.coreai_models.export.pipeline. Changing python.src.coreai_models.export.pipeline can break python.src.coreai_models.llm, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
17→6 python.src.coreai_models.models.ios.mistral depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.ios.mistral → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.ios.mistral uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.ios.mistral, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
18→6 python.src.coreai_models.models.ios.olmo2 depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.ios.olmo2 → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.ios.olmo2 uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.ios.olmo2, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
19→6 python.src.coreai_models.models.ios.qwen2 depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.ios.qwen2 → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.ios.qwen2 uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.ios.qwen2, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
20→6 python.src.coreai_models.models.ios.qwen3 depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.ios.qwen3 → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.ios.qwen3 uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.ios.qwen3, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
21→6 python.src.coreai_models.models.macos.diffusion_gemma depends on python.src.coreai_models.models.base✕
Type pairs
2 distinct (type in python.src.coreai_models.models.macos.diffusion_gemma → type in python.src.coreai_models.models.base) references.
python.src.coreai_models.models.macos.diffusion_gemma uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.macos.diffusion_gemma, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
21→7 python.src.coreai_models.models.macos.diffusion_gemma depends on python.src.coreai_models.models.macos.diffusion_gemma_config✕
Type pairs
8 distinct (type in python.src.coreai_models.models.macos.diffusion_gemma → type in python.src.coreai_models.models.macos.diffusion_gemma_config) references.
python.src.coreai_models.models.macos.diffusion_gemma uses python.src.coreai_models.models.macos.diffusion_gemma_config. Changing python.src.coreai_models.models.macos.diffusion_gemma_config can break python.src.coreai_models.models.macos.diffusion_gemma, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
22→6 python.src.coreai_models.models.macos.gemma3_text depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.macos.gemma3_text → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.macos.gemma3_text uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.macos.gemma3_text, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
23→6 python.src.coreai_models.models.macos.gemma3n depends on python.src.coreai_models.models.base✕
Type pairs
1 distinct (type in python.src.coreai_models.models.macos.gemma3n → type in python.src.coreai_models.models.base) reference.
python.src.coreai_models.models.macos.gemma3n uses python.src.coreai_models.models.base. Changing python.src.coreai_models.models.base can break python.src.coreai_models.models.macos.gemma3n, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
24→10 python.tests._runner_infra.common.types.export_types depends on python.tests._runner_infra.common.types.source_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.common.types.export_types → type in python.tests._runner_infra.common.types.source_types) reference.
python.tests._runner_infra.common.types.export_types uses python.tests._runner_infra.common.types.source_types. Changing python.tests._runner_infra.common.types.source_types can break python.tests._runner_infra.common.types.export_types, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
25→34 swift~CoreAILMCommon depends on swift~CoreAIDiffusionPipelinecycle✕
Type pairs
37 distinct (type in swift~CoreAILMCommon → type in swift~CoreAIDiffusionPipeline) references. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
python.src.coreai_models.models.macos uses python.src.coreai_models.primitives.macos.cache. Changing python.src.coreai_models.primitives.macos.cache can break python.src.coreai_models.models.macos, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
27→21 python.src.coreai_models.models.macos depends on python.src.coreai_models.models.macos.diffusion_gemma✕
Type pairs
2 distinct (type in python.src.coreai_models.models.macos → type in python.src.coreai_models.models.macos.diffusion_gemma) references.
python.src.coreai_models.models.macos uses python.src.coreai_models.models.macos.diffusion_gemma. Changing python.src.coreai_models.models.macos.diffusion_gemma can break python.src.coreai_models.models.macos, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
28→24 python.tests._runner_infra.common.types.run_types depends on python.tests._runner_infra.common.types.export_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.common.types.run_types → type in python.tests._runner_infra.common.types.export_types) reference.
python.tests._runner_infra.common.types.run_types uses python.tests._runner_infra.common.types.export_types. Changing python.tests._runner_infra.common.types.export_types can break python.tests._runner_infra.common.types.run_types, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
29→24 python.tests._runner_infra.export.service.service depends on python.tests._runner_infra.common.types.export_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.export.service.service → type in python.tests._runner_infra.common.types.export_types) reference.
python.tests._runner_infra.export.service.service uses python.tests._runner_infra.common.types.export_types. Changing python.tests._runner_infra.common.types.export_types can break python.tests._runner_infra.export.service.service, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
30→26 swift~CoreAISpeech depends on swift~CoreAIShared✕
Type pairs
6 distinct (type in swift~CoreAISpeech → type in swift~CoreAIShared) references.
python.tests._runner_infra.run.service.service uses python.tests._runner_infra.common.types.run_types. Changing python.tests._runner_infra.common.types.run_types can break python.tests._runner_infra.run.service.service, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
32→25 swift~CoreAILanguageModels depends on swift~CoreAILMCommon✕
Type pairs
1 distinct (type in swift~CoreAILanguageModels → type in swift~CoreAILMCommon) reference.
swift~CoreAILanguageModels uses swift~CoreAILMCommon. Changing swift~CoreAILMCommon can break swift~CoreAILanguageModels, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
32→26 swift~CoreAILanguageModels depends on swift~CoreAIShared✕
Type pairs
29 distinct (type in swift~CoreAILanguageModels → type in swift~CoreAIShared) references. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
swift~CoreAILanguageModels uses swift~CoreAISpeech. Changing swift~CoreAISpeech can break swift~CoreAILanguageModels, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
32→34 swift~CoreAILanguageModels depends on swift~CoreAIDiffusionPipelinecycle✕
Type pairs
114 distinct (type in swift~CoreAILanguageModels → type in swift~CoreAIDiffusionPipeline) references. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
swift~CoreAILanguageModels uses swift~CoreAIDiffusionPipeline. Changing swift~CoreAIDiffusionPipeline can break swift~CoreAILanguageModels, not the reverse.
Position
Above the diagonal — a cycle. Neither module can be changed, tested or deployed independently until one of these dependencies goes.
33→10 python.tests._runner_infra.models.model depends on python.tests._runner_infra.common.types.source_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.models.model → type in python.tests._runner_infra.common.types.source_types) reference.
python.tests._runner_infra.models.model uses python.tests._runner_infra.common.types.source_types. Changing python.tests._runner_infra.common.types.source_types can break python.tests._runner_infra.models.model, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→24 python.tests._runner_infra.models.model depends on python.tests._runner_infra.common.types.export_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.models.model → type in python.tests._runner_infra.common.types.export_types) reference.
python.tests._runner_infra.models.model uses python.tests._runner_infra.common.types.export_types. Changing python.tests._runner_infra.common.types.export_types can break python.tests._runner_infra.models.model, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→28 python.tests._runner_infra.models.model depends on python.tests._runner_infra.common.types.run_types✕
Type pairs
1 distinct (type in python.tests._runner_infra.models.model → type in python.tests._runner_infra.common.types.run_types) reference.
python.tests._runner_infra.models.model uses python.tests._runner_infra.common.types.run_types. Changing python.tests._runner_infra.common.types.run_types can break python.tests._runner_infra.models.model, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→29 python.tests._runner_infra.models.model depends on python.tests._runner_infra.export.service.service✕
Type pairs
1 distinct (type in python.tests._runner_infra.models.model → type in python.tests._runner_infra.export.service.service) reference.
python.tests._runner_infra.models.model uses python.tests._runner_infra.export.service.service. Changing python.tests._runner_infra.export.service.service can break python.tests._runner_infra.models.model, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
33→31 python.tests._runner_infra.models.model depends on python.tests._runner_infra.run.service.service✕
Type pairs
1 distinct (type in python.tests._runner_infra.models.model → type in python.tests._runner_infra.run.service.service) reference.
python.tests._runner_infra.models.model uses python.tests._runner_infra.run.service.service. Changing python.tests._runner_infra.run.service.service can break python.tests._runner_infra.models.model, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
34→26 swift~CoreAIDiffusionPipeline depends on swift~CoreAIShared✕
Type pairs
9 distinct (type in swift~CoreAIDiffusionPipeline → type in swift~CoreAIShared) references.
swift~CoreAIDiffusionPipeline uses swift~CoreAILanguageModels. Changing swift~CoreAILanguageModels can break swift~CoreAIDiffusionPipeline, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
35→10 python.tests.test_model_units.test_primitives.test_macos._random_input_models depends on python.tests._runner_infra.common.types.source_types✕
Type pairs
1 distinct (type in python.tests.test_model_units.test_primitives.test_macos._random_input_models → type in python.tests._runner_infra.common.types.source_types) reference.
python.tests.test_model_units.test_primitives.test_macos._random_input_models uses python.tests._runner_infra.common.types.source_types. Changing python.tests._runner_infra.common.types.source_types can break python.tests.test_model_units.test_primitives.test_macos._random_input_models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
35→33 python.tests.test_model_units.test_primitives.test_macos._random_input_models depends on python.tests._runner_infra.models.model✕
Type pairs
1 distinct (type in python.tests.test_model_units.test_primitives.test_macos._random_input_models → type in python.tests._runner_infra.models.model) reference.
python.tests.test_model_units.test_primitives.test_macos._random_input_models uses python.tests._runner_infra.models.model. Changing python.tests._runner_infra.models.model can break python.tests.test_model_units.test_primitives.test_macos._random_input_models, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
36→26 swift~CoreAIImageSegmenter depends on swift~CoreAIShared✕
Type pairs
5 distinct (type in swift~CoreAIImageSegmenter → type in swift~CoreAIShared) references.
swift~CoreAIImageSegmenter uses swift~CoreAIDiffusionPipeline. Changing swift~CoreAIDiffusionPipeline can break swift~CoreAIImageSegmenter, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
37→34 swift~CoreAIObjectDetector depends on swift~CoreAIDiffusionPipeline✕
Type pairs
4 distinct (type in swift~CoreAIObjectDetector → type in swift~CoreAIDiffusionPipeline) references.
swift~CoreAIObjectDetector uses swift~CoreAIDiffusionPipeline. Changing swift~CoreAIDiffusionPipeline can break swift~CoreAIObjectDetector, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
38→26 swift~CoreAIVideoDiffusionPipeline depends on swift~CoreAIShared✕
Type pairs
1 distinct (type in swift~CoreAIVideoDiffusionPipeline → type in swift~CoreAIShared) reference.
swift~CoreAIVideoDiffusionPipeline uses swift~CoreAILanguageModels. Changing swift~CoreAILanguageModels can break swift~CoreAIVideoDiffusionPipeline, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
38→34 swift~CoreAIVideoDiffusionPipeline depends on swift~CoreAIDiffusionPipeline✕
Type pairs
6 distinct (type in swift~CoreAIVideoDiffusionPipeline → type in swift~CoreAIDiffusionPipeline) references.
swift~CoreAIVideoDiffusionPipeline uses swift~CoreAIDiffusionPipeline. Changing swift~CoreAIDiffusionPipeline can break swift~CoreAIVideoDiffusionPipeline, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
39→26 swift~CoreAIVideoSegmenter depends on swift~CoreAIShared✕
Type pairs
18 distinct (type in swift~CoreAIVideoSegmenter → type in swift~CoreAIShared) references.
swift~CoreAIVideoSegmenter uses swift~CoreAIDiffusionPipeline. Changing swift~CoreAIDiffusionPipeline can break swift~CoreAIVideoSegmenter, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→25 swift~Tools depends on swift~CoreAILMCommon✕
Type pairs
16 distinct (type in swift~Tools → type in swift~CoreAILMCommon) references.
swift~Tools uses swift~CoreAISpeech. Changing swift~CoreAISpeech can break swift~Tools, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→32 swift~Tools depends on swift~CoreAILanguageModels✕
Type pairs
27 distinct (type in swift~Tools → type in swift~CoreAILanguageModels) references. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
swift~Tools uses swift~CoreAILanguageModels. Changing swift~CoreAILanguageModels can break swift~Tools, not the reverse.
Position
Below the diagonal — points down the layering, which is what you want.
40→34 swift~Tools depends on swift~CoreAIDiffusionPipeline✕
Type pairs
42 distinct (type in swift~Tools → type in swift~CoreAIDiffusionPipeline) references. Showing 25 of them; the rest are in namespace-graph.json in this report's bundle.
Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).
OWASP category
Findings
Severity
A06:2021 — Vulnerable & Outdated Components
9
High / Critical
A03:2021 — Injection
3
High / Critical
Roadmap
First, integrate automated security scanning into the CI pipeline to block regressions before they land. Next, maintain a changelog for every release and document significant architectural decisions in a dedicated, discoverable folder. Finally, update the README to clearly explain how to run the test suite.
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Resolve the 1 No ADRs found finding(s) in ADR Quality.
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
Add an explicit build step to your CI pipeline — your stack's own build command, or, if the pipeline delegates to a task runner, a build task that runner executes in CI — so every change is built before merge.
Every finding carries one of four grades. Three say how serious it is. The fourth says this
survey could not settle it — and it is a grade, not a gap.
Critical — 7
A definite problem that already costs you something and drags the score down: a
missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here
tends to cause failures elsewhere.
Serious — 428
Likely wrong, but not failing yet. It degrades
the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to
carry for two years either.
Minor — 34
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 38
Something this survey could not settle
from the outside, and which could be critical or serious. Either a control was required and no
positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves
nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean
result. These are excluded from the score rather than awarded a pass, so the number on the cover neither
rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each
one is named under Limitations.
Methodology & how to trust this report
Watchdog is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. 38 of 43 evaluated dimensions are computed purely by tools and static analysis (confidence 1.0); 5 documentation/naming judgement(s) are LLM-assisted and labelled advisory. Overall confidence is 0.9 — the weighted average across measured dimensions; it falls as more of the score leans on LLM-assisted judgement and rises when it's fully tool-backed.
Every figure here is one of three kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact; ◐ Advisory — an LLM prose judgement. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10; ◐ Sampled · advisory marks an LLM verdict over a bounded sample — advisory, never a deterministic measurement.
What we checked — 43 dimensions across the health lenses
Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.
How to trust any code-health report — three questions
Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 445 of 469 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
Is there a tool behind the number? Every score below names the method that produced it — Roslyn, git, a scanner, or (for a handful of documentation/naming dimensions) an LLM labelled sampled · advisory — not a narrative.
Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.
This report answers yes to all three. That's the bar to hold any assessment to.
Tools & methods
The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.
D10 Test Quality — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. The 1,212 test(s) behind this row are the ones the code-model census could read, and this repository also carries at least 101 test source file(s) (.py) that it cannot: it reads the test types the .swift frontend declared, so a suite in any other language is invisible to it. Skipped tests, zero-assertion tests and the other quality signals on this row are UNMEASURED in that suite — their absence from the counts above is a gap in this analyzer's language coverage, not a finding that those tests are sound.
D11 Test Reliability — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.py, .swift) and this repository declares a SwiftPM test suite (coreai-models), but it was not re-run: no test result was produced. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
D14 License Compliance — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares a Swift Package.swift/Package.resolved, but the licence verdict published here was taken over its Python distribution dependencies. Nothing was read about its SwiftPM dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
D32 Data Compliance (PII/GDPR) — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Resources.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedGenerator.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/VanillaDecodingStrategy.swift`, `swift/Sources/CoreAILanguageModels/GuidedGeneration/ConstrainedGenerationSession.swift`, … (+34 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
AX6 Interface segregation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
C1 Data Protection — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
C2 Access Controls — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These authorization controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks authorization controls.
C3 Audit Trail — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These audit controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks audit controls.
C4 Data Retention — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These retention controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks retention controls.
C5 Data-Subject Rights — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These data-subject rights controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks data-subject rights controls.
ED5 Idempotency — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check finds retry-prone mutations by walking the repository's declared types, and NONE was loaded on this run, so it had nothing to look at. That is a limit of the analyzer's reach — it reads .NET projects — not a finding that this repository has no command handlers or message consumers.
GD1 Unfinished & placeholder code — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
IC1 Incompleteness & stubs — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
PF3 Async & latency hygiene — measured, with a gap in what it reached — Watchdog measured this, but not all of it. What it did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Those languages colour their functions async, so blocking inside them is the same defect this card counts elsewhere, but their blocking vocabulary is not modelled yet. That is a gap in this analyzer's language reach — not a finding that the code is free of it.
S1 Web-Security Posture — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
X1 Async correctness — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X12 Unreachable branch — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X13 Undrained process stream — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X14 Bypassable address classification — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X15 Unvalidated length from an untrusted reader — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X16 Unfloored truncation loop — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X17 Uncapped recursion over a caller-supplied document — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X18 Disposal-pattern correctness — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X19 Unrestored process-global state — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X2 Cancellation propagation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X20 Mistyped argument guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X21 Side-effecting pattern guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X22 Contradicted release guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X23 Unguarded diagnostic materialisation — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X24 Document value interpolated into markup unescaped — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript and Java source only, and no C# was loaded and no JavaScript/TypeScript or Java was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X25 Inert configuration knob — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript and Java source only, and no C# was loaded and no JavaScript/TypeScript or Java was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X26 Unsynchronised callback handoff — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and Java, Kotlin and Scala source only, and no C# was loaded, no Java, Kotlin or Scala was found, and this repository's C, C++, Python, Swift is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X27 Collection changed while being enumerated — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and Java and Rust source only, and no C# was loaded and no Java or Rust was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X28 Index access outside its own emptiness guard — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and Scala source only, and no C# was loaded and no Scala was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X29 Per-element action decided by a fixed element — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java or Rust was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X3 Exception handling — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X30 Support guard that admits what it rejects — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and Scala source only, and no C# was loaded and no Scala was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X4 Structured logging — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X5 Nullable reference types — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is implemented over the C# syntax tree, and no C# was loaded on this run, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
X7 Silent fallback defaults — not measured this run — Watchdog could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. X7 measured the part of this repository it reads (C#, Python, TypeScript/JavaScript, Rust, Go, Java and Kotlin), and its Swift source is outside the check's reach, so the card covers only part of the product. That is a gap in this analyzer's language reach — not a finding that the unread source is free of silent defaults.
Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.
Limitations & what we did not check
Watchdog assesses the repository exactly as committed, and only the repository. By design it does not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.
Per-dimension blind spots
For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.
D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
D10 Test Quality: Assertion density is structural — it cannot tell a meaningful behavioural assertion from a trivial one, only that an assertion is present.
D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
D19 Documentation Quality: Documentation quality is judged by an LLM over a bounded sample of docs — it reads what is written, not whether the docs match the running system, and it is advisory, not a measurement. Its critique rows are drawn from a closed category vocabulary and each row means the same thing in every run, so two scans can be compared row by row; the SET that fires is still a sample, and does not repeat exactly. Measured on one frozen input, six scans at one engine SHA: 2-5 critique rows per scan, 8 distinct rows across the six, 3 of those 8 seen in only one scan. So a D19 row is evidence about the documentation, but a COUNT of D19 rows is not a quantity — never read a change in it as an improvement or a regression.
D20 ADR Quality: ADR quality is an LLM read of the decision records present — it cannot know about decisions made and never recorded, and its verdict is sampled and advisory.
D21 Naming Consistency: Naming quality is an LLM judgement over a bounded sample — it assesses clarity/consistency of the names it sees, not domain-correctness, and is advisory.
D22 Internal API Consistency: API-surface coherence is an LLM judgement over a sample of the public surface — consistency of intent across the whole API is approximated, not exhaustively verified.
D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
M4 Documentation accuracy: Onboarding quality is an LLM read of the docs/setup present — it cannot run the onboarding or measure how long a real new joiner takes; the verdict is sampled and advisory.
P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.
The LLM boundary
LLM-set scores this run (5): D19, D21, D22, D26, M4 (model: Local LLM). For these, a model reads a bounded sample and sets the numeric score; each names its own sample and method on its card. They are sampled and advisory by design: they vary at the margins between runs and are never a deterministic measurement. Every other score in this report is tool-computed at confidence 1.0.
What it measures: How tangled the control flow is — methods with many branches are hard to test and change.
Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.
52 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was LLMRunner.runModel at 48. A further 2 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being SignpostCategory.staticString at 20 — they are counted neither in the figure above nor in this dimension's score. 2 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: swift/Sources/CoreAILanguageModels/Profiling/InstrumentsProfiler.swift (SignpostCategory.staticString at 20), swift/Sources/CoreAILanguageModels/InferenceEngines/InferenceEngine.swift (InferenceRuntimeError.errorDescription at 16). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.
+ 47 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 LLMRunner.runModel (cyclomatic 48) finding(s) in Cyclomatic Complexity — start with LLMRunnerMain.swift. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 export.main (cyclomatic 45) finding(s) in Cyclomatic Complexity — start with export.py. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 pipeline._async_export_model (cyclomatic 42) finding(s) in Cyclomatic Complexity — start with pipeline.py. — One of this dimension's main actionable groups (1 warning-level).
Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How hard the code is for a person to follow, beyond raw branching.
Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.
+ 84 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 1 LanguageConfig.additionalStopTokenIds (cognitive 79) finding(s) in Cognitive Complexity — start with LanguageConfig.swift. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 export.main (cognitive 75) finding(s) in Cognitive Complexity — start with export.py. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 LLMRunner.runModel (cognitive 61) finding(s) in Cognitive Complexity — start with LLMRunnerMain.swift. — One of this dimension's main actionable groups (1 warning-level).
Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D3 · God Classes8.3 / 10Strong✓ Tool-verified
What it measures: Over-large classes that try to do too much ("god classes").
Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.
Resolve the 13 FileTooLong finding(s) in God Classes — start with CoreAIPipelinedEngine.swift, model_registry.py, MPSGraphSamplers.swift. — One of this dimension's main actionable groups (13 warning-level).
Resolve the 12 MethodTooLong finding(s) in God Classes — start with CoreAIPipelinedEngine.swift (2), FlowTransformerPipeline.swift, LLMRunnerMain.swift. — One of this dimension's main actionable groups (12 warning-level).
Resolve the 9 ClassTooLong finding(s) in God Classes — start with CoreAIPipelinedEngine.swift, LLMRunnerMain.swift, ImageSegmentationEngine.swift. — One of this dimension's main actionable groups (9 warning-level).
Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Copy-pasted code that should be shared instead.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.
159 duplicated block group(s) detected. A further 18 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted.
+ 96 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Resolve the 13 Duplicated block (5 lines × 2) finding(s) in Code Duplication — start with SegmentationPostprocessor.swift, CoreAIPipelinedEngine.swift, MPSGraphSamplers.swift. — One of this dimension's main actionable groups (13 warning-level).
Resolve the 8 Duplicated block (12 lines × 2) finding(s) in Code Duplication — start with NumPyRandomSource.swift, LanguageConfig.swift, CoreAIPipelinedEngine.swift. — One of this dimension's main actionable groups (8 warning-level).
Resolve the 8 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with export.py (2), CoreAIDiffusionModelFunction.swift, LatentPreviewTuner.swift. — One of this dimension's main actionable groups (8 warning-level).
Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D5 · Coupling10.0 / 10Stronggated by 2 serious findings✓ Tool-verified
What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.
Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.
Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.
19 production modules (Python+SwiftPM), 0 dependency cycle(s), 0 unstable depended-on module(s). Read from the build's own module declarations; 2 module(s) off the main sequence, with abstractness counted on 18 of the 19 (the rest declare no modelled class or interface, export only macros, or have no source directory of their own).
Off the main sequence: CoreAILMCommon · ×2
What to do
Resolve the 2 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (2 warning-level).
Enforce Coupling in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether a class's methods are focused on a single responsibility.
Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.
Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.
D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified
What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.
Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.
1685 test methods: 1685 unit, 0 integration, 0 BDD, 0 e2e. The Python suite contributes 473 test function(s) across 47 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.
✓ On the Gold path — maintain.
Detailed fixes: d9_recommendation.md.
Do you agree with this assessment?
D10 · Test Quality9.6 / 10Stronggated by 30 serious findings✓ Tool-verified
What it measures: Whether the tests truly assert behaviour rather than just running the code.
Method: Per-test assertions, skips, and mock references analyzed via Roslyn; structured skip-reason tags (BUG:/ENV:) separate documented deferrals from debt. Deterministic.
9 skipped (9 with a documented reason), 30 zero-assertion, no mocking-framework packages referenced (hand-written doubles or no mocking) across 1212 tests. Measured on the .swift suite only — at least 101 test source file(s) (.py) went unread, so its test quality is unmeasured and is not in these counts.
No assertions: malformedLineReportsIndex · ×30swift/Tests/CoreAILMCommonTests/ReplayTypesTests.swift:60
Resolve the 30 No assertions finding(s) in Test Quality — start with BilinearResamplerTests.swift (6), InputFillerTests.swift (5), StateHandlerTests.swift (4). — One of this dimension's main actionable groups (30 warning-level).
Enforce Test Quality in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d10_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether dependencies are current, secure, and not bloated.
Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (saturating for vulnerabilities, capped-linear for deprecation/outdated) per KLoC. Exhaustive, deterministic.
4 outdated direct SwiftPM dependencies, 0 pinning defect(s). SwiftPM has no package registry: a dependency is a repository URL and its releases are that repository's semver tags, so currency is answered by listing tags rather than by querying an index. Only a newer tag on the SAME MAJOR is reported — a `from:` requirement admits everything below the next major and nothing above it, so a major crossing needs a Package.swift edit rather than an update, and naming the update as its remedy would be wrong. Whether any dependency is DEPRECATED or ABANDONED is not graded and cannot be: a repository publishes no such marker, and there is no registry that could carry one. Known CVEs in this dependency graph are D30's question.
Outdated: hummingbird · ×4
✓ On the Gold path — maintain.
Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.
Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.
What it measures: Whether the licenses of third-party packages are compatible with your policy.
Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.
0 of 84 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 17 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (67 reached that way). Requirements it states ONLY under an extra, a PEP 735 dependency group, a Poetry dev group or a dev-named requirements file are excluded: pip does not install any of them for a consumer. ★ This repository commits no dependency lockfile that this pass reads, so each licence is the one PyPI publishes for the distribution's CURRENT release rather than for a pinned version. 12 of them publish no licence on PyPI this pass can read; that is missing data, not a violation, and none of them is charged. ★ COVERAGE OF THIS VERDICT: it grades this repository's Python distribution dependencies and nothing else. The repository also declares a Swift Package.swift/Package.resolved, and the licences of those dependencies were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.
What it measures: Files that change often and are also complex — the riskiest hotspots.
Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.
Resolve the 17 Hotspot finding(s) in Churn × Complexity Hotspots — start with export.py (3), pipeline.py (2), LLMRunnerMain.swift. — One of this dimension's main actionable groups (17 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor8.5 / 10Strong✓ Tool-verified
What it measures: Whether knowledge is concentrated in too few people (the "bus factor").
Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.
35 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift. Counted over 232 of the 304 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Off-boarding risk: anonymized user #1 · ×3
Further sole-owners (lower concentration)
What to do
Resolve the 3 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (3 recommendation-level).
Resolve the 1 Further sole-owners (lower concentration) finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.
Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.
9 deducted task-comment markers across 65366 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.
Resolve the 9 TodoComment finding(s) in Explicit Debt — start with graph.py, test_macos_models.py, LanguageConfig.swift. — One of this dimension's main actionable groups (9 warning-level).
Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether the project's documentation is clear, complete, and useful.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic doc sample (READMEs plus first 25 architecture docs), with two-pass stability filtering. Advisory, sampled.
The repository's root README gives an overview of the project (Core AI models for on-device AI) and links to directory-level READMEs that document each model type (export recipes, CLAP, CLIP, depth anything, diffusion Gemma, EDSR, efficient SAM, FLUX.2, Gemma 3). The architecture/design docs are absent from this summary. All visible documents are directory-specific READMEs; the root README is judged by its own scope. The Qwen2.5/Qwen3/MoE/SAM3 and roBERTa model READMEs are all focused on their own directories (models/qwen2/, models/qwen3/, models/qwen3_moe/, models/sam3/, models/roberta/) rather than the repository root, so each is a directory README documenting its contents. The Qwen2.5 export guide shows setup and options for the uv CoreAI CLI; the roBERTa README covers model variants, dtype flags, supported models, and an output-dir option table with defaults and overwrite behavior. All four SAM3 branches (image_encode, text_encode, detect, tracker) are present in a detailed table plus gated-access notes and export commands. (9 of 25 sampled documents could not be assessed: 1 of 3 evaluation groups failed.)
What to do
Improve Documentation Quality — currently 8.6/10. — The repository's root README gives an overview of the project (Core AI models for on-device AI) and links to directory-level READMEs that document each model type (export recipes, CLAP, CLIP, depth anything, diffusion Gemma, EDSR, efficient SAM, FLUX.2, Gemma 3). The architecture/design docs are absent from this summary. All visible documents are directory-specific READMEs; the root README is judged by its own scope. The Qwen2.5/Qwen3/MoE/SAM3 and roBERTa model READMEs are all focused on their own directories (models/qwen2/, models/qwen3/, models/qwen3_moe/, models/sam3/, models/roberta/) rather than the repository root, so each is a directory README documenting its contents. The Qwen2.5 export guide shows setup and options for the uv CoreAI CLI; the roBERTa README covers model variants, dtype flags, supported models, and an output-dir option table with defaults and overwrite behavior. All four SAM3 branches (image_encode, text_encode, detect, tracker) are present in a detailed table plus gated-access notes and export commands. (9 of 25 sampled documents could not be assessed: 1 of 3 evaluation groups failed.)
Detailed fixes: d19_recommendation.md.
Do you agree with this assessment?
D20 · ADR Quality0.0 / 10Critical✓ Tool-verified
What it measures: Whether architecture decisions are recorded well (context, decision, consequences).
Method: Per-ADR judgment by language model at low temperature with two-pass stability; confidence is share of ADRs evaluated; enforcement-field presence detected deterministically. Advisory.
What it measures: Whether names — types, methods, variables — are clear and consistent.
Method: Judged by language model at low temperature (0.0-0.1) on a deterministic random symbol sample (fixed size, not exhaustive), with disclosed confidence band. Advisory, sampled.
0 naming inconsistencies across 0 sampled symbols.
✓ On the Gold path — maintain.
Detailed fixes: d21_recommendation.md.
Do you agree with this assessment?
D22 · Internal API ConsistencyAdequate◐ Sampled · advisory
What it measures: Whether the internal API surface is consistent and coherent.
Method: Judged by language model at low temperature over a sample of the public API surface (IsPackable or .Contracts types). Sampled, advisory; confidence discounted by model uncertainty.
3 API inconsistencies across a 400-member sample of 255 exposed types.
Highly fragmented and inconsistent execution API. The type exposes 7 different methods for running inference, mixing naming conventions ('run' vs 'predict'), input formats (raw arrays, ModelInput, NDArray, String-keyed dicts), and output formats (flat Float arrays, String-keyed dicts, NDArray). This forces users to guess the correct method for their specific data type and output needs.
Inconsistent method signatures for the same core operation. `DiffusionPipeline.generateImages` lacks a progress handler, while `FlowTransformerPipeline.generateImages` includes it. This creates an inconsistent developer experience when switching between pipeline types, as the async/streaming capability is not uniformly exposed.
Inconsistent return types and naming between the high-level `ImageSegmenter` and low-level `CoreAISegmentationEngine`. `ImageSegmenter` returns `SegmentationResponse` (processed/high-level), while `CoreAISegmentationEngine` returns `SegmentationOutput` (raw model output). Additionally, `ImageSegmenter` offers a convenience overload accepting `String` for prompts, while the engine requires a typed `TextQuery`. This inconsistency makes it unclear when to use which type and what the output format will be.
What to do
Resolve the 1 Highly fragmented and inconsistent execution API. The type exposes 7… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Inconsistent method signatures for the same core operation.… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Resolve the 1 Inconsistent return types and naming between the high-level… finding(s) in Internal API Consistency. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d22_recommendation.md · top locations in Appendix A, every location in findings.md.
1 of 1 build units (Python) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesion
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.
What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.
Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.
Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).
Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
Resolve the 1 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.
Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05.
Resolve the 5 Medium CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (5). — One of this dimension's main actionable groups (5 warning-level).
Resolve the 3 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (3). — One of this dimension's main actionable groups (3 issue-level).
Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.
Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.
1 of 232 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is swift/Sources/CoreAILanguageModels/InferenceEngines/InferenceOutputSequence.swift. Counted over 232 of the 304 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.
Orphaned files with no living knowledge
✓ On the Gold path — maintain.
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.
Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.
Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.
Resolve the 2 Change coupling finding(s) in Change Coupling — start with CoreAISequentialVLMEngine.swift, LLMRunnerMain.swift. — One of this dimension's main actionable groups (2 warning-level).
Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Scored apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.
Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. SCORED, not informational.
What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.
Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.
0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 17 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.
Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.
Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.
Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.
What to do
The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
Other · Architecture — Whether singleton services avoid mutable shared instance state that concurrent callers would race on.
Method: Roslyn scan: singleton field mutations unguarded by lock or Interlocked, per type; syntax-based guard detection. Deterministic, traceable per field.
Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).
Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.
Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.
Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.
Do you agree with this assessment?
AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified
Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.
Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.
Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.
Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.
Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.
Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.
Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.
What to do
Add a 'Testing' section to the root README — how to run the test suite.
Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
Add a README to the 1 of 1 project(s) that lack one — worth up to 2 pts.
Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.
Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.
No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
What to do
Record significant decisions one document per decision — dated, stating the context, the decision and its consequences — and keep them together wherever your design docs already live (a conventional `docs/adr/` tree, with each file named `NNNN-title` in whatever markup those docs already use, is the most discoverable form).
Add a C4 context/container diagram (Structurizr, PlantUML or Mermaid) or an architecture.md overview.
Maturity · Maturity — Whether the README actually describes the code that exists (LLM-judged, advisory).
Method: Judged by language model at low temperature: README accuracy versus actual projects, within a disclosed tolerance. Advisory, not a measured number.
Do you agree with this assessment?
P1 · CI/CD gates8.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether an automated pipeline builds and tests every change.
Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.
A CI pipeline exists but no build step was matched — changes may merge without the build ever running. A build step may be invoked directly as a command, or declared as a task that a runner named in the pipeline resolves.
What to do
Add an explicit build step to your CI pipeline — your stack's own build command, or, if the pipeline delegates to a task runner, a build task that runner executes in CI — so every change is built before merge.
Do you agree with this assessment?
P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged
Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.
Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.
Do you agree with this assessment?
P2 · Observability7.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).
Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.
No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 1583 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
What to do
Add a SAST step to CI running what this repository's stack ships: CodeQL's Swift pack (Swift/Xcode) — or `semgrep --config=auto`, which runs on any language — so a security regression fails the build instead of landing.
Enable Dependabot/Renovate or a dependency-review gate.
Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.
Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.
No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
What to do
Keep a changelog (e.g. Keep-a-Changelog) recording what shipped in each release.
Readiness · Performance — Whether the code is written to minimise allocations so it doesn't pressure its host's memory manager — buffer/slice views over copies, object pooling, stack or value-type allocation, and buffer writers. Reward-only: credited where present, never penalised where a simpler style is fine.
Method: Production-source scan: density (per 1k LoC) of allocation-aware APIs — in .NET Span/Memory, ArrayPool/ObjectPool, stackalloc, ValueTask, value-type structs, IBufferWriter, string.Create, SkipLocalsInit; off .NET, with comments and strings blanked, Go's sync.Pool, preallocated slices/maps, Grow, strconv.Append* and buf[:0] reuse; the JVM's NIO buffer views, MemorySegment, primitive collections, pools and literal presizes (plus Kotlin primitive arrays and value classes, Scala AnyVal and @specialized); Swift's reserveCapacity, ContiguousArray, withUnsafe* access and ~Copyable. Activated off .NET on the same floor (400 lines, and benchmarks or 8 uses); Rust and garbage-collected scripting languages are not applicable. Reward-only. Deterministic, syntax/text detection.
What to do
Raise allocation-aware density on the hot paths — currently 92 use(s) across 46,470 production line(s) (~2.0/1k). More of the idioms below on the allocation-heavy paths climbs this toward 10.
Swift: on hot paths, reserveCapacity before appending, use ContiguousArray for class-element arrays, work in place with withUnsafeBufferPointer/withUnsafeTemporaryAllocation, and make large values ~Copyable with borrowing/consuming parameters.
Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.
Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from the language model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin) or inside a Java method returning a Reactor Mono/Flux — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.
Do you agree with this assessment?
Reference — by lens
The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.
Unscored — 1 check(s) recorded observations but carry no score
These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.
X10 Duplicated predicate — 8 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 5 control(s) we could not find positive evidence for
These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.
C3 Audit Trail — Not assessed: these audit controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks audit controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C4 Data Retention — Not assessed: these retention controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks retention controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C5 Data-Subject Rights — Not assessed: these data-subject rights controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks data-subject rights controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
P4 Deployment & Rollback — not evidenced — no deploy/rollback/approval signal in the repo; absence of evidence is not evidence of a manual release
P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 71 check(s) not relevant to this codebase
These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.
AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
AX1 Captive dependencies — Not applicable: this repository's Python imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; this repository's Swift imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
AX7 Slice cohesion — not applicable — not a vertical-slice architecture
AXB1 Runtime evidence locked — no reproducible boot — This repository has nothing the runtime tiers could boot or serve — no markup, no UI framework or web-server dependency, no UI component source, no native UI project and no API definition — nothing here is a surface to boot — so runtime a11y/egress/header evidence has no subject here. Not applicable: this is neither a gap in the scan nor a finding about your code.
AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
C2 Access Controls — Not assessed: these authorization controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks authorization controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
D11 Test Reliability — Test reliability not included — the .swift suite was found but not re-run
D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout nor 2+ sibling source directories each declaring an aggregate root. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
D24 Comment Value — No inline comments to assess — comment value is not applicable here.
D25 ADR Conformance — no ADRs to check
D27 Navigability — symbol resolution incomplete — navigability not assessed
D31 IaC & Container Security — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
D32 Data Compliance (PII/GDPR) — 39 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
D36 Supply-chain Provenance & Signing — The CI pipeline builds and tests but publishes no released artifact — no package publish, container push, GitHub release or deployment step. Supply-chain provenance, signing and SBOM attest RELEASED artifacts, so there is nothing to attest here. Add them to the release pipeline when this repo starts shipping artifacts (a published package, a container image, a deployed service or a tagged release). Build integrity and workflow-token hygiene are reported below: they describe what the CI runs and the token it runs with, neither of which is affected by whether the pipeline ships an artifact.
D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
D8 Code Coverage — Coverage NOT MEASURED: the Swift half could not be measured — the Swift suite in . produced no coverage export. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
DM1 Domain Modelling — applicable but not scored (2 of 3 signals for this style — below the bar we score at): 3 aggregate root(s) (types guarding their own state behind command methods — this language has no AggregateRoot base to inherit); 13 value object(s); its 3 aggregate(s) are ORM models only — persistence, not behaviour: a CRUD model, measured, not claimed as DDD
ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and this analysis resolves a call's owner only where the receiver's type is written down in the source. Reported as guidance rather than measured
ED5 Idempotency — This check finds retry-prone mutations (command handlers and message/event consumers) by walking the repository's declared types, and none was loaded here, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
GD1 Unfinished & placeholder code — no source files were read — this check reads C# syntax, and none was loaded for this repository. That is a limit of the analyzer, not a finding about your code.
IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
P7 Outbound HTTP resilience — no outbound HTTP usage detected — no HTTP client call or construction in the Python, Swift source (service entry point: swift/Sources/Tools/llm-server/ChatHandler.swift:79 (Application())
P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (lcov — `swift test --enable-code-coverage` (SwiftPM) or `xcodebuild test -scheme <YourScheme> -enableCodeCoverage YES` (an .xcodeproj/.xcworkspace suite), then `xcrun llvm-cov export -format=lcov`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for `Benchmark("…")` in a file importing package-benchmark, or package-benchmark in Package.swift, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
X1 Async correctness — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X12 Unreachable branch — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X13 Undrained process stream — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X14 Bypassable address classification — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X15 Unvalidated length from an untrusted reader — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X16 Unfloored truncation loop — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X17 Uncapped recursion over a caller-supplied document — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X18 Disposal-pattern correctness — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X19 Unrestored process-global state — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X2 Cancellation propagation — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X20 Mistyped argument guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X21 Side-effecting pattern guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X22 Contradicted release guard — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X23 Unguarded diagnostic materialisation — This check reads C# syntax; no C# was loaded for this repository, so it has nothing to report. That is a limit of the analyzer, not a finding about your code.
X24 Document value interpolated into markup unescaped — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X25 Inert configuration knob — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X26 Unsynchronised callback handoff — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X27 Collection changed while being enumerated — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X28 Index access outside its own emptiness guard — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X29 Per-element action decided by a fixed element — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X3 Exception handling — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X30 Support guard that admits what it rejects — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
X4 Structured logging — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X7 Silent fallback defaults — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
Appendix A — Findings (grouped)
The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.
No assertions: malformedLineReportsIndex swift/Tests/CoreAILMCommonTests/ReplayTypesTests.swift:60— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: upsample swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:36— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: antialiasIgnoredWhenUpsampling swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:54— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: downsamplePlain swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:69— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: downsampleAntialiased swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:77— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: nonIntegerDownsample swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:89— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: nonSquare swift/Tests/CoreAISharedTests/BilinearResamplerTests.swift:116— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: findJumpForwardStringReturnsNilAtChoice swift/Tests/GuidedGenerationTests/ConstrainedGenerationSessionTests.swift:186— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: benchmarkPrefill swift/Tests/LanguageModelsTests/InputFillerTests.swift:119— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: benchmarkPositionIdsIsolated swift/Tests/LanguageModelsTests/InputFillerTests.swift:165— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: benchmarkStepScalar swift/Tests/LanguageModelsTests/InputFillerTests.swift:214— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: benchmarkAsDict swift/Tests/LanguageModelsTests/InputFillerTests.swift:258— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: benchmarkModifySubscript swift/Tests/LanguageModelsTests/InputFillerTests.swift:278— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: tokenConformance swift/Tests/LanguageModelsTests/InputHandlerTests.swift:13— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: coveragePass swift/Tests/LanguageModelsTests/InputHandlerTests.swift:41— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: parseFull swift/Tests/LanguageModelsTests/LogitsWriterTests.swift:154— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: matchingDescriptorValidates swift/Tests/LanguageModelsTests/PrefillGraphTests.swift:217— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: stateOrderDoesNotMatter swift/Tests/LanguageModelsTests/PrefillGraphTests.swift:228— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: pipelinedGuardAllowsUnseeded swift/Tests/LanguageModelsTests/SeededSamplingTests.swift:186— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: growingConformance swift/Tests/LanguageModelsTests/StateHandlerTests.swift:99— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: fixedConformance swift/Tests/LanguageModelsTests/StateHandlerTests.swift:104— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: bindsVariousCounts swift/Tests/LanguageModelsTests/StateHandlerTests.swift:148— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: composesHandlers swift/Tests/LanguageModelsTests/StateHandlerTests.swift:172— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: agenticPriorityOverTagPair swift/Tests/LanguageModelsTests/ThinkTagParserTests.swift:302— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
No assertions: eomEotWithoutMessageFallsBack swift/Tests/LanguageModelsTests/ThinkTagParserTests.swift:317— This method's body runs code, and no assertion call was recognised in it. Recognised by name: Assert*, *Should*/ShouldBe*, Verify, Expect, Throws, Record, Received/DidNotReceive, MustHaveHappened/MustNotHaveHappened, EnsureSuccessStatusCode and *AndEnsure* — so verification routed through a helper of your own naming, through a base-class or callback object whose members hold the assertions, or through a harness that fails by throwing under some other name, is not visible to this check and is not counted here. Read it as 'no assertion this check knows how to see', and if that is right, add one.
Hotspot: swift/Sources/Tools/llm-runner/LLMRunnerMain.swift swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:348— swift/Sources/Tools/llm-runner/LLMRunnerMain.swift changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 48 in LLMRunner.runModel at line 348. 3 of those changes were fix/bug commits, and the other 16 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/Tools/llm-runner/LLMRunnerMain.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:619— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 33 in EngineImpl.init at line 619. 3 of those changes were fix/bug commits, and the other 12 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:190— swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 41 in LanguageConfig.additionalStopTokenIds at line 190. 2 of those changes were fix/bug commits, and the other 8 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:147— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in CoreAISequentialVLMEngine.init at line 147. 1 of those changes was a fix/bug commit, and the other 12 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/export/pipeline.py python/src/coreai_models/export/pipeline.py:146— python/src/coreai_models/export/pipeline.py changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 42 in pipeline._async_export_model at line 146. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/export/pipeline.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/Tools/llm-server/ChatHandler.swift swift/Sources/Tools/llm-server/ChatHandler.swift:184— swift/Sources/Tools/llm-server/ChatHandler.swift changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 25 in ChatHandler.swift.runChatCompletion at line 184. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/Tools/llm-server/ChatHandler.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/Tools/llm-server/LLMServerMain.swift swift/Sources/Tools/llm-server/LLMServerMain.swift:114— swift/Sources/Tools/llm-server/LLMServerMain.swift changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 20 in LLMServer.run at line 114. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/Tools/llm-server/LLMServerMain.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift:115— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 22 in StaticShapeEngine.init at line 115. 1 of those changes was a fix/bug commit, and the other 8 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift:613— swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 15 in CoreAIExecutor.makeTokens at line 613. 2 of those changes were fix/bug commits, and the other 11 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/llm/export.py python/src/coreai_models/llm/export.py:292— python/src/coreai_models/llm/export.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 38 in export._resolve_export_config at line 292. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/llm/export.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/diffusion/export.py python/src/coreai_models/diffusion/export.py:141— python/src/coreai_models/diffusion/export.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 45 in export.main at line 141. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/diffusion/export.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift:103— swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in DiffusionRunner.run at line 103. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/diffusion/pipeline.py python/src/coreai_models/diffusion/pipeline.py:61— python/src/coreai_models/diffusion/pipeline.py changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in pipeline.export_diffusion at line 61. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/diffusion/pipeline.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/segmentation/export.py python/src/coreai_models/segmentation/export.py:289— python/src/coreai_models/segmentation/export.py changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in export.main at line 289. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/segmentation/export.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift:173— swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift changed 4 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in ThinkTagParser.drainAgentic at line 173. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: python/src/coreai_models/primitives/macos/rope.py python/src/coreai_models/primitives/macos/rope.py:316— python/src/coreai_models/primitives/macos/rope.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in rope.initialize_rope at line 316. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- python/src/coreai_models/primitives/macos/rope.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
Hotspot: swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:280— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift changed 2 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 16 in MultiFunctionContext.init at line 280. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-07-02..2026-09-30, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-07-02 18:20:47 -07:00' --until='2026-09-30 18:20:47 -07:00' --full-history --no-merges -- swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
FileTooLong: InferenceEngines/CoreAIPipelinedEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift— FileTooLong — 1200 significant lines (blank, comment-only and punctuation-only lines excluded), about 72% of them inside a single declaration: EngineImpl (550-1910). The bar is 500 significant lines; this is 700 over it, 2.40× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: coreai_models/model_registry.py python/src/coreai_models/model_registry.py— FileTooLong — 1001 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 501 over it, 2.00× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: Samplers/MPSGraphSamplers.swift swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift— FileTooLong — 876 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 376 over it, 1.75× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: llm-runner/LLMRunnerMain.swift swift/Sources/Tools/llm-runner/LLMRunnerMain.swift— FileTooLong — 859 significant lines (blank, comment-only and punctuation-only lines excluded), about 96% of them inside a single declaration: LLMRunner (70-1291). The bar is 500 significant lines; this is 359 over it, 1.72× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: CoreAIImageSegmenter/ImageSegmentationEngine.swift swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift— FileTooLong — 824 significant lines (blank, comment-only and punctuation-only lines excluded), about 100% of them inside a single declaration: CoreAISegmentationEngine (23-1276). The bar is 500 significant lines; this is 324 over it, 1.65× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: macos/muse_glimmer.py python/src/coreai_models/models/macos/muse_glimmer.py— FileTooLong — 694 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 194 over it, 1.39× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: vlm/export.py python/src/coreai_models/vlm/export.py— FileTooLong — 670 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 170 over it, 1.34× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: models/base.py python/src/coreai_models/models/base.py— FileTooLong — 610 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 110 over it, 1.22× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: InferenceEngines/CoreAISequentialVLMEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift— FileTooLong — 603 significant lines (blank, comment-only and punctuation-only lines excluded), about 75% of them inside a single declaration: CoreAISequentialVLMEngine (72-914). The bar is 500 significant lines; this is 103 over it, 1.21× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: segmentation/video_pipeline.py python/src/coreai_models/segmentation/video_pipeline.py— FileTooLong — 558 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 58 over it, 1.12× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: InferenceEngines/CoreAIStaticShapeEngine.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift— FileTooLong — 551 significant lines (blank, comment-only and punctuation-only lines excluded), about 81% of them inside a single declaration: StaticShapeEngine (20-728). The bar is 500 significant lines; this is 51 over it, 1.10× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
FileTooLong: macos/diffusion_gemma.py python/src/coreai_models/models/macos/diffusion_gemma.py— FileTooLong — 537 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 37 over it, 1.07× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
FileTooLong: llm-server/ChatHandler.swift swift/Sources/Tools/llm-server/ChatHandler.swift— FileTooLong — 523 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 23 over it, 1.05× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
Duplicated block (5 lines × 2) swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:251— swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:251-255 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:286-290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:251` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:690— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:690-694 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialEngine.swift:147-151 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:690` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:352— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:352-357 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:993-997 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) swift/Sources/CoreAIShared/Image/CGImageUtils.swift:31— swift/Sources/CoreAIShared/Image/CGImageUtils.swift:31-36 | swift/Sources/CoreAIVideoSegmenter/FramePreprocessor.swift:42-46 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIShared/Image/CGImageUtils.swift:31` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (5 lines × 2) swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:346— swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:346-350 | swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:366-370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (5 lines × 2) swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:61— swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:61-65 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:62-66 — before extracting anything, compare `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift` and `swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (5 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialEngine.swift:434— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialEngine.swift:434-438 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:894-898 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (5 lines × 2) swift/Sources/Tools/llm-server/CompletionHandler.swift:49— swift/Sources/Tools/llm-server/CompletionHandler.swift:49-53 | swift/Sources/Tools/llm-server/CompletionHandler.swift:59-63 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/Tools/llm-server/CompletionHandler.swift:49` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (5 lines × 2) python/src/coreai_models/models/base.py:251— python/src/coreai_models/models/base.py:251-255 | python/src/coreai_models/models/macos/gemma3n.py:469-473 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) python/src/coreai_models/primitives/ios/bidirectional_sdpa.py:88— python/src/coreai_models/primitives/ios/bidirectional_sdpa.py:88-92 | python/src/coreai_models/primitives/ios/sdpa.py:117-123 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (5 lines × 2) python/src/coreai_models/segmentation/pipeline.py:423— python/src/coreai_models/segmentation/pipeline.py:423-427 | python/src/coreai_models/segmentation/video_pipeline.py:695-699 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `FullExportConfig` in one and `VideoExportConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 2) models/parakeet/export.py:388— models/parakeet/export.py:388-394 | python/src/coreai_models/segmentation/pipeline.py:322-326 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (5 lines × 2) python/src/coreai_models/models/macos/qwen3.py:44— python/src/coreai_models/models/macos/qwen3.py:44-48 | python/src/coreai_models/models/macos/qwen3_moe.py:45-49 — before extracting anything, compare `python/src/coreai_models/models/macos/qwen3.py` and `python/src/coreai_models/models/macos/qwen3_moe.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 174 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Qwen3Config` in one and `Qwen3MoeConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
MethodTooLong: FlowTransformerPipeline.sanaSprintSigmas swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:23— MethodTooLong — sanaSprintSigmas runs 276 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 176 over it, 2.76× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: LLMRunner.runModel swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:348— MethodTooLong — runModel runs 269 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 169 over it, 2.69× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: EngineImpl.init swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:619— MethodTooLong — init runs 163 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 63 over it, 1.63× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: WanPipeline.generateVideo swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/WanPipeline.swift:139— MethodTooLong — generateVideo runs 153 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 53 over it, 1.53× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: DiffusionRunner.runParityTest swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift:17— MethodTooLong — runParityTest runs 150 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 50 over it, 1.50× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: EngineImpl._encodeNextStepGPU swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:922— MethodTooLong — _encodeNextStepGPU runs 146 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 46 over it, 1.46× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: StaticShapeEngine.init swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift:115— MethodTooLong — init runs 127 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 27 over it, 1.27× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: MPSGraphCompositeSampler.init swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:746— MethodTooLong — init runs 124 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 24 over it, 1.24× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: VideoDiffusionRunner.run swift/Sources/Tools/videodiffusion-runner/VideoRunnerMain.swift:131— MethodTooLong — run runs 117 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 17 over it, 1.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: CoreAISequentialVLMEngine.init swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:147— MethodTooLong — init runs 107 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 7 over it, 1.07× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: LLMServer.run swift/Sources/Tools/llm-server/LLMServerMain.swift:114— MethodTooLong — run runs 104 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 4 over it, 1.04× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
MethodTooLong: Stream.decodeFrames swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:213— MethodTooLong — decodeFrames runs 101 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 1 over it, 1.01× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
TodoComment python/tests/_runner_infra/common/utils/coreai/graph.py:16— # TODO: migrate once Core AI adds APIs to retrieve shape info from Type object — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment python/tests/test_model_conversion/test_macos_models.py:569— # TODO: Make dynamic KV cache the default behavior for all models once mainstream — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:188— /// TODO: Upstream this to swift-transformers as `Tokenizer.additionalEosTokenIds` — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/CoreAILanguageModels/InferenceEngines/InputEmbeddings.swift:35— // TODO: Multi-turn support — allow multiple image regions per input, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/CoreAILanguageModels/InferenceEngines/InferenceEngine.swift:351— // TODO: Multi-turn — caller can cache InputEmbeddings across turns and pass it — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:6— // TODO: Add pipelined engine variant for higher throughput — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/CoreAIShared/Runtime/ModelStructure.swift:94— // TODO: the optimized export will need different specialization options. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/Tools/llm-server/ChatHandler.swift:85— // Process lifecycle is left to the supervising process. TODO: any in-process — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
TodoComment swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:299— // TODO: Pinned to CPU because the monolithic f16/f32 Whisper export decodes incorrectly on the — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
ClassTooLong: EngineImpl swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:550— ClassTooLong — 866 significant lines (blank, comment-only and punctuation-only lines excluded), 14 methods. The bar is 400 significant lines; this is 466 over it, 2.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: LLMRunner swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:70— ClassTooLong — 821 significant lines (blank, comment-only and punctuation-only lines excluded), 14 methods. The bar is 400 significant lines; this is 421 over it, 2.05× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CoreAISegmentationEngine swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:23— ClassTooLong — 820 significant lines (blank, comment-only and punctuation-only lines excluded), 36 methods. The bar is 400 significant lines; this is 420 over it, 2.05× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: MPSGraphCompositeSampler swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:667— ClassTooLong — 518 significant lines (blank, comment-only and punctuation-only lines excluded), 17 methods. The bar is 400 significant lines; this is 118 over it, 1.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CoreAISequentialVLMEngine swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:72— ClassTooLong — 455 significant lines (blank, comment-only and punctuation-only lines excluded), 22 methods. The bar is 400 significant lines; this is 55 over it, 1.14× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: CoreAILanguageModel swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift:32— ClassTooLong — 451 significant lines (blank, comment-only and punctuation-only lines excluded), 4 methods. The bar is 400 significant lines; this is 51 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: StaticShapeEngine swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift:20— ClassTooLong — 447 significant lines (blank, comment-only and punctuation-only lines excluded), 23 methods. The bar is 400 significant lines; this is 47 over it, 1.12× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: ImageSegmenterCLI swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:14— ClassTooLong — 428 significant lines (blank, comment-only and punctuation-only lines excluded), 20 methods. The bar is 400 significant lines; this is 28 over it, 1.07× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
ClassTooLong: WanPipeline swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/WanPipeline.swift:21— ClassTooLong — 417 significant lines (blank, comment-only and punctuation-only lines excluded), 12 methods. The bar is 400 significant lines; this is 17 over it, 1.04× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
Duplicated block (12 lines × 2) swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:48— swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:48-59 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:49-60 — before extracting anything, compare `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift` and `swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:48` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:129— swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:129-140 | swift/Sources/CoreAILanguageModels/InferenceEngines/ModelConfig.swift:92-103 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:129` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1262— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1262-1273 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1434-1445 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1262` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:364— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:364-375 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1034-1045 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:364` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (12 lines × 2) swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:246— swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:246-257 | swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:442-453 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:246` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 2) python/src/coreai_models/export/pipeline.py:366— python/src/coreai_models/export/pipeline.py:366-378 | python/src/coreai_models/export/pipeline.py:410-421 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 2) python/src/coreai_models/models/ios/qwen2.py:177— python/src/coreai_models/models/ios/qwen2.py:177-188 | python/src/coreai_models/models/ios/qwen3.py:182-193 — before extracting anything, compare `python/src/coreai_models/models/ios/qwen2.py` and `python/src/coreai_models/models/ios/qwen3.py` as WHOLE FILES: this scan already matched 14 separate duplicated blocks between them, totalling at least 224 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/ios/qwen2.py:177` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Qwen2Config` in one and `Qwen3Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (12 lines × 2) python/src/coreai_models/models/macos/muse_glimmer.py:932— python/src/coreai_models/models/macos/muse_glimmer.py:932-943 | python/src/coreai_models/models/macos/qwen3_vl.py:346-357 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/muse_glimmer.py:932` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:306— swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:306-315 | swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:265-274 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:306` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:353— swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:353-362 | swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:481-490 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:353` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 2) swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:18— swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:18-27 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:19-28 — before extracting anything, compare `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift` and `swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:410— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:410-419 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:803-812 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:410` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) models/depth-anything/export.py:153— models/depth-anything/export.py:153-162 | models/yolo/export.py:127-136 — `models/depth-anything/export.py` and `models/yolo/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 49 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/depth-anything/export.py:153` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) models/t5/export.py:152— models/t5/export.py:152-161 | models/whisper/export.py:121-130 — `models/t5/export.py` and `models/whisper/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 4 separate duplicated blocks between them, totalling at least 49 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/t5/export.py:152` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (10 lines × 2) python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:64— python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:64-73 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:50-59 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (10 lines × 2) python/src/coreai_models/primitives/macos/cache.py:52— python/src/coreai_models/primitives/macos/cache.py:52-61 | python/src/coreai_models/primitives/macos/cache_scatter.py:41-50 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1372— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1372-1379 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1406-1414 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1372` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) swift/Sources/CoreAILanguageModels/ToolCallParser.swift:189— swift/Sources/CoreAILanguageModels/ToolCallParser.swift:189-196 | swift/Sources/CoreAILanguageModels/ToolCallParser.swift:238-245 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (8 lines × 2) python/src/coreai_models/models/ios/sam3/detr.py:163— python/src/coreai_models/models/ios/sam3/detr.py:163-170 | python/src/coreai_models/models/ios/sam3/mask_decoder.py:197-204 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 2) python/src/coreai_models/models/macos/gemma3n.py:159— python/src/coreai_models/models/macos/gemma3n.py:159-166 | python/src/coreai_models/models/macos/qwen3_vl.py:70-77 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (8 lines × 2) python/src/coreai_models/models/macos/mistral.py:51— python/src/coreai_models/models/macos/mistral.py:51-58 | python/src/coreai_models/models/macos/qwen3_vl.py:57-64 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/qwen3_vl.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 98 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `python/src/coreai_models/models/macos/qwen3_vl.py:65` calls `narrow`, `qk_norm` and `python/src/coreai_models/models/macos/mistral.py:60` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (8 lines × 2) python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:219— python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:219-226 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:152-159 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 2) python/src/coreai_models/models/macos/olmo2.py:69— python/src/coreai_models/models/macos/olmo2.py:69-76 | python/src/coreai_models/models/macos/qwen3_vl.py:70-77 — before extracting anything, compare `python/src/coreai_models/models/macos/olmo2.py` and `python/src/coreai_models/models/macos/qwen3_vl.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 91 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (8 lines × 2) python/src/coreai_models/vlm/export.py:429— python/src/coreai_models/vlm/export.py:429-436 | python/src/coreai_models/vlm/export.py:837-844 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:123— swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:123-136 | swift/Sources/CoreAIDiffusionPipeline/Components/CoreAIDiffusionModelFunction.swift:252-265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:327— swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:327-340 | swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:463-476 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:327` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:382— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:382-395 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1051-1064 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:382` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (14 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:503— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:503-517 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1225-1238 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14 lines × 2) python/src/coreai_models/models/ios/mistral.py:174— python/src/coreai_models/models/ios/mistral.py:174-187 | python/src/coreai_models/models/ios/olmo2.py:172-185 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `Olmo2Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (14 lines × 2) python/src/coreai_models/models/macos/mistral.py:27— python/src/coreai_models/models/macos/mistral.py:27-40 | python/src/coreai_models/models/macos/olmo2.py:25-38 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/olmo2.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 97 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `Olmo2Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (14 lines × 2) python/src/coreai_models/models/macos/mixtral.py:276— python/src/coreai_models/models/macos/mixtral.py:276-289 | python/src/coreai_models/models/macos/qwen3_moe.py:321-334 — before extracting anything, compare `python/src/coreai_models/models/macos/mixtral.py` and `python/src/coreai_models/models/macos/qwen3_moe.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 147 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (9 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:249— swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:249-257 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:259-267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:108— swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:108-116 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:124-132 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:108` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) swift/Sources/CoreAILanguageModels/Handlers/InputHandler+StaticBucket.swift:96— swift/Sources/CoreAILanguageModels/Handlers/InputHandler+StaticBucket.swift:96-104 | swift/Sources/CoreAILanguageModels/Handlers/InputHandler.swift:84-92 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Handlers/InputHandler+StaticBucket.swift:96` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `handlers` to `[any StaticInputHandler]` in one and `[any SyncInputHandler]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (9 lines × 2) swift/Sources/CoreAILanguageModels/ToolCallParser.swift:161— swift/Sources/CoreAILanguageModels/ToolCallParser.swift:161-169 | swift/Sources/CoreAILanguageModels/ToolCallParser.swift:220-228 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/ToolCallParser.swift:161` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 2) swift/Sources/Tools/llm-server/ChatHandler.swift:108— swift/Sources/Tools/llm-server/ChatHandler.swift:108-116 | swift/Sources/Tools/llm-server/CompletionHandler.swift:33-41 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/Tools/llm-server/ChatHandler.swift:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (9 lines × 2) python/src/coreai_models/models/macos/muse_glimmer.py:532— python/src/coreai_models/models/macos/muse_glimmer.py:532-540 | python/src/coreai_models/models/macos/muse_glimmer.py:927-935 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9 lines × 2) python/src/coreai_models/models/registry.py:23— python/src/coreai_models/models/registry.py:23-31 | python/src/coreai_models/models/registry.py:62-70 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (11 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Components/CoreAILatentCodec.swift:72— swift/Sources/CoreAIDiffusionPipeline/Components/CoreAILatentCodec.swift:72-82 | swift/Sources/CoreAIShared/Image/CGImageUtils.swift:31-41 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Components/CoreAILatentCodec.swift:72` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:567— swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:567-577 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:593-603 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:567` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:29— swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:29-39 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:30-40 — before extracting anything, compare `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift` and `swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 38 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 2) swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:183— swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:183-193 | swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:215-225 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:183` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (11 lines × 2) swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:676— swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:676-686 | swift/Sources/Tools/object-detector/ObjectDetectionMain.swift:235-245 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (11 lines × 2) python/src/coreai_models/models/macos/qwen3_vl.py:155— python/src/coreai_models/models/macos/qwen3_vl.py:155-165 | python/src/coreai_models/models/macos/qwen3_vl.py:307-317 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 2) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:1003— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:1003-1008 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:1041-1046 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:1003` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift:167— swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift:167-172 | swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift:378-383 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (6 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:637— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:637-642 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialEngine.swift:110-115 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:637` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) swift/Sources/CoreAIShared/Runtime/MaskBitset.swift:30— swift/Sources/CoreAIShared/Runtime/MaskBitset.swift:30-35 | swift/Sources/CoreAIShared/Runtime/MaskBitset.swift:41-47 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIShared/Runtime/MaskBitset.swift:41` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (6 lines × 2) swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:238— swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:238-243 | swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:431-439 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (6 lines × 2) python/src/coreai_models/segmentation/video_pipeline.py:477— python/src/coreai_models/segmentation/video_pipeline.py:477-482 | python/src/coreai_models/segmentation/video_pipeline.py:587-592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×5
Members sharing a duplicated core (4 members, 50+ identical tokens) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:481— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:481-538 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:552-642 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1195-1258 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1261-1339 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) python/src/coreai_models/models/ios/mistral.py:169— python/src/coreai_models/models/ios/mistral.py:169-187 | python/src/coreai_models/models/ios/olmo2.py:167-185 | python/src/coreai_models/models/ios/qwen2.py:172-188 | python/src/coreai_models/models/ios/qwen3.py:177-193 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) python/src/coreai_models/models/ios/mistral.py:199— python/src/coreai_models/models/ios/mistral.py:199-230 | python/src/coreai_models/models/ios/olmo2.py:197-228 | python/src/coreai_models/models/ios/qwen2.py:200-231 | python/src/coreai_models/models/ios/qwen3.py:205-236 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) python/src/coreai_models/models/ios/sam3/detr.py:39— python/src/coreai_models/models/ios/sam3/detr.py:39-46 | python/src/coreai_models/models/ios/sam3/image_encoder.py:45-53 | python/src/coreai_models/models/ios/sam3/mask_decoder.py:28-35 | python/src/coreai_models/models/ios/sam3/sam3_reauthored.py:35-42 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Members sharing a duplicated core (4 members, 50+ identical tokens) python/src/coreai_models/models/macos/muse_glimmer.py:103— python/src/coreai_models/models/macos/muse_glimmer.py:103-151 | python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:136-171 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:87-123 | python/src/coreai_models/models/macos/phi3.py:82-132 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
Duplicated block (7 lines × 2) swift/Sources/CoreAILanguageModels/Profiling/InstrumentsProfiler.swift:637— swift/Sources/CoreAILanguageModels/Profiling/InstrumentsProfiler.swift:637-643 | swift/Sources/CoreAILanguageModels/Profiling/InstrumentsProfiler.swift:657-663 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (7 lines × 2) swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:213— swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:213-219 | swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:227-233 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:213` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:292— swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:292-298 | swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:326-332 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:292` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7 lines × 2) swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:371— swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:371-377 | swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:396-402 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:371` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (7 lines × 2) python/src/coreai_models/llm/export.py:38— python/src/coreai_models/llm/export.py:38-47 | python/src/coreai_models/vlm/export.py:868-874 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
TooManyMethods: FlowTransformerPipeline swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:33— TooManyMethods — 39 methods. The bar is 30 methods; this is 9 over it, 1.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: CoreAISegmentationEngine swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:23— TooManyMethods — 36 methods. The bar is 30 methods; this is 6 over it, 1.20× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
TooManyMethods: InstrumentsProfiler swift/Sources/CoreAILanguageModels/Profiling/InstrumentsProfiler.swift:469— TooManyMethods — 31 methods. The bar is 30 methods; this is 1 over it, 1.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
FunctionTooLong: ChatHandler.swift.runChatCompletion swift/Sources/Tools/llm-server/ChatHandler.swift:184— FunctionTooLong — runChatCompletion runs 130 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 30 over it, 1.30× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: ChatHandler.swift.runStreamingLoop swift/Sources/Tools/llm-server/ChatHandler.swift:449— FunctionTooLong — runStreamingLoop runs 102 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 2 over it, 1.02× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
FunctionTooLong: SpeechRecognizerMain.swift.runLegacy swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:295— FunctionTooLong — runLegacy runs 102 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 2 over it, 1.02× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
Duplicated block (10 lines × 4) python/src/coreai_models/models/ios/mistral.py:172— python/src/coreai_models/models/ios/mistral.py:172-181 | python/src/coreai_models/models/ios/olmo2.py:170-179 | python/src/coreai_models/models/ios/qwen2.py:175-184 | python/src/coreai_models/models/ios/qwen3.py:180-189 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `Olmo2Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (10 lines × 4) python/src/coreai_models/models/ios/mistral.py:155— python/src/coreai_models/models/ios/mistral.py:155-164 | python/src/coreai_models/models/ios/olmo2.py:153-162 | python/src/coreai_models/models/ios/qwen2.py:158-167 | python/src/coreai_models/models/ios/qwen3.py:163-172 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (10 lines × 4) python/src/coreai_models/models/ios/mistral.py:248— python/src/coreai_models/models/ios/mistral.py:248-257 | python/src/coreai_models/models/ios/olmo2.py:246-255 | python/src/coreai_models/models/ios/qwen2.py:249-258 | python/src/coreai_models/models/ios/qwen3.py:254-263 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Change coupling: CoreAISequentialVLMEngine.swift ↔ LLMRunnerMain.swift swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift— `swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift` and `swift/Sources/Tools/llm-runner/LLMRunnerMain.swift` change together 57% of the time (8 of the 14 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `b63133bb` Consolidate VLM sequential engine: route construction through EngineF…; `0d6c0bf4` Layered prefill chunk size (#240); `5660fc66` Add repetition penalty to the llm-runner (#176) — run `git show` on any of them.
Change coupling: LLMRunnerMain.swift ↔ LLMServerMain.swift swift/Sources/Tools/llm-runner/LLMRunnerMain.swift— `swift/Sources/Tools/llm-runner/LLMRunnerMain.swift` and `swift/Sources/Tools/llm-server/LLMServerMain.swift` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets). They sit in different directories, but in this ecosystem the namespace is declared in the FILE, not by the folder — so the two may well share one namespace and reference each other with no import for this pass to see. Read the pair before acting: if one derives from or overrides the other, the dependency is explicit in the type declaration and the co-change is definitional; if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE and the thing to add is a comment saying so; if they simply belong together, co-locate them; if none of these holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `7ec0a710` Rename LanguageBundle -> LanguageModelBundle (#307); `a59026f6` Consolidate model-bundle and diffusion asset resolution (#304); `3efa838e` Remove silent .aimodelc fallback and better naming, polish error mess… — run `git show` on any of them.
D4 · Code Duplication· Members sharing a duplicated core (8 members, 50+ identical tokens) · ×2
Members sharing a duplicated core (8 members, 50+ identical tokens) swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:59— swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:59-99 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:75-107 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/PipelineConfiguration.swift:85-117 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:170-250 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:280-400 | swift/Sources/CoreAILMCommon/ReplayTypes.swift:59-79 | swift/Sources/CoreAISpeech/MelSpectrogram.swift:62-81 | swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/VideoConfiguration.swift:67-97 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Members sharing a duplicated core (8 members, 50+ identical tokens) python/src/coreai_models/models/macos/mistral.py:117— python/src/coreai_models/models/macos/mistral.py:117-123 | python/src/coreai_models/models/macos/mixtral.py:153-159 | python/src/coreai_models/models/macos/olmo2.py:118-124 | python/src/coreai_models/models/macos/phi3.py:171-177 | python/src/coreai_models/models/macos/qwen2.py:124-130 | python/src/coreai_models/models/macos/qwen3.py:135-141 | python/src/coreai_models/models/macos/qwen3_moe.py:183-189 | python/src/coreai_models/models/macos/qwen3_vl.py:118-124 — These 8 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 8 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 8 times.
Duplicated block (24 lines × 2) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:952— swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:952-975 | swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:1018-1041 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:952` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:1043` calls `withFrameCount` and `swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:977` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (24 lines × 2) python/src/coreai_models/diffusion/export.py:96— python/src/coreai_models/diffusion/export.py:96-120 | python/src/coreai_models/vlm/export.py:920-943 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/diffusion/export.py:96` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16 lines × 2) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:731— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:731-746 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:907-922 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:731` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (16 lines × 2) python/src/coreai_models/models/macos/muse_glimmer.py:229— python/src/coreai_models/models/macos/muse_glimmer.py:229-244 | python/src/coreai_models/models/macos/muse_glimmer.py:584-599 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (13–14 lines × 2) swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:88— swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:88-100 | swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:142-155 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:88` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13–14 lines × 2) python/src/coreai_models/segmentation/pipeline.py:293— python/src/coreai_models/segmentation/pipeline.py:293-306 | python/src/coreai_models/segmentation/pipeline.py:471-483 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/segmentation/pipeline.py:293` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (13 lines × 2) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:544— swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:544-556 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:617-629 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Flux2.swift:544` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (13 lines × 2) swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:63— swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:63-75 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:140-152 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:63` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11 lines × 3) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:400— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:400-410 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1075-1085 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1177-1187 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1175` calls `buildInputs` and `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:399` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (11 lines × 3) python/src/coreai_models/models/ios/mistral.py:124— python/src/coreai_models/models/ios/mistral.py:124-134 | python/src/coreai_models/models/ios/qwen2.py:127-137 | python/src/coreai_models/models/ios/qwen3.py:132-142 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/qwen2.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8–10 lines × 2) swift/Sources/CoreAIShared/Video/SequentialVideoReader.swift:32— swift/Sources/CoreAIShared/Video/SequentialVideoReader.swift:32-39 | swift/Sources/CoreAIShared/Video/VideoFrameExtractor.swift:26-35 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
Duplicated block (8–10 lines × 2) python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:164— python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:164-171 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:114-123 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (9 lines × 4) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:598— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:598-606 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:686-694 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:697-705 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:950-958 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (9 lines × 4) python/src/coreai_models/models/macos/muse_glimmer.py:117— python/src/coreai_models/models/macos/muse_glimmer.py:117-125 | python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:146-154 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:96-104 | python/src/coreai_models/models/macos/phi3.py:99-107 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/muse_glimmer.py:117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (7–8 lines × 2) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:719— swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:719-726 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:756-762 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:756` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (7–8 lines × 2) python/src/coreai_models/models/macos/diffusion_gemma.py:593— python/src/coreai_models/models/macos/diffusion_gemma.py:593-600 | python/src/coreai_models/models/macos/diffusion_gemma.py:656-662 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `python/src/coreai_models/models/macos/diffusion_gemma.py:655` calls `DiffusionGemmaSelfConditioning` and `python/src/coreai_models/models/macos/diffusion_gemma.py:592` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12–14 lines × 3) python/src/coreai_models/models/macos/gemma3n.py:475— python/src/coreai_models/models/macos/gemma3n.py:475-486 | python/src/coreai_models/models/macos/muse_glimmer.py:343-356 | python/src/coreai_models/models/macos/muse_glimmer.py:805-817 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (12–14 lines × 3) python/src/coreai_models/models/macos/gemma3n.py:494— python/src/coreai_models/models/macos/gemma3n.py:494-505 | python/src/coreai_models/models/macos/muse_glimmer.py:364-377 | python/src/coreai_models/models/macos/muse_glimmer.py:834-846 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `python/src/coreai_models/models/macos/gemma3n.py:506` calls `_mutate_state_dict` and `python/src/coreai_models/models/macos/muse_glimmer.py:847` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7 lines × 3) python/src/coreai_models/models/macos/gemma3n.py:579— python/src/coreai_models/models/macos/gemma3n.py:579-585 | python/src/coreai_models/models/macos/muse_glimmer.py:530-536 | python/src/coreai_models/models/macos/muse_glimmer.py:925-931 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (7 lines × 3) python/src/coreai_models/models/macos/muse_glimmer.py:60— python/src/coreai_models/models/macos/muse_glimmer.py:60-66 | python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:68-74 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:54-60 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Off the main sequence: CoreAILMCommon — CoreAILMCommon: abstractness 0.00, instability 0.00, distance 1.00 — the shape a shared-kernel / building-block library has BY DESIGN — concrete and widely depended-on is what makes it useful, and this dimension does not penalise it (the distance is reported for completeness, not as a defect). Worth a look only if it has grown past one coherent kernel into an everything-bucket.
Off the main sequence: CoreAIShared — CoreAIShared: abstractness 0.04, instability 0.00, distance 0.96 — the shape a shared-kernel / building-block library has BY DESIGN — concrete and widely depended-on is what makes it useful, and this dimension does not penalise it (the distance is reported for completeness, not as a defect). Worth a look only if it has grown past one coherent kernel into an everything-bucket.
LLMRunner.runModel (cyclomatic 48) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:348— LLMRunner.runModel has cyclomatic complexity 48 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
export.main (cyclomatic 45) python/src/coreai_models/diffusion/export.py:141— export.main has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pipeline._async_export_model (cyclomatic 42) python/src/coreai_models/export/pipeline.py:146— pipeline._async_export_model has cyclomatic complexity 42 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LanguageConfig.additionalStopTokenIds (cyclomatic 41) swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:190— LanguageConfig.additionalStopTokenIds has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
export._resolve_export_config (cyclomatic 38) python/src/coreai_models/llm/export.py:292— export._resolve_export_config has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EngineImpl.init (cyclomatic 33) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:619— EngineImpl.init has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
HotstartHeuristics.process (cyclomatic 31) swift/Sources/CoreAIVideoSegmenter/Tracking/HotstartHeuristics.swift:21— HotstartHeuristics.process has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FlowTransformerPipeline.init (cyclomatic 27) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:20— FlowTransformerPipeline.init has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Stream.decodeFrames (cyclomatic 27) swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:213— Stream.decodeFrames has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
FlowTransformerPipeline.makeFlux2Plan (cyclomatic 26) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:69— FlowTransformerPipeline.makeFlux2Plan has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
WanPipeline.generateVideo (cyclomatic 25) swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/WanPipeline.swift:139— WanPipeline.generateVideo has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ChatHandler.swift.runChatCompletion (cyclomatic 25) swift/Sources/Tools/llm-server/ChatHandler.swift:184— ChatHandler.swift.runChatCompletion has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
ChatHandler.swift.runStreamingLoop (cyclomatic 25) swift/Sources/Tools/llm-server/ChatHandler.swift:449— ChatHandler.swift.runStreamingLoop has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LatentPreviewTuner.fitFromDirectory (cyclomatic 22) swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:326— LatentPreviewTuner.fitFromDirectory has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
EngineImpl.runConstrainedCompletion (cyclomatic 22) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1281— EngineImpl.runConstrainedCompletion has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StaticShapeEngine.init (cyclomatic 22) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift:115— StaticShapeEngine.init has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CoreAISequentialVLMEngine.init (cyclomatic 21) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:147— CoreAISequentialVLMEngine.init has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LLMRunner.validate (cyclomatic 20) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:253— LLMRunner.validate has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
LLMServer.run (cyclomatic 20) swift/Sources/Tools/llm-server/LLMServerMain.swift:114— LLMServer.run has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
VideoSegmenterCLI.runParity (cyclomatic 20) swift/Sources/Tools/video-segmenter/VideoSegmenterMain.swift:289— VideoSegmenterCLI.runParity has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
model_registry._action_model_info (cyclomatic 20) python/src/coreai_models/model_registry.py:1194— model_registry._action_model_info has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
diffusion_gemma._mutate_diffusion_gemma_state_dict (cyclomatic 20) python/src/coreai_models/models/macos/diffusion_gemma.py:718— diffusion_gemma._mutate_diffusion_gemma_state_dict has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MuseGlimmerForCausalLMEmbeddings.from_hf_memory_efficient (cyclomatic 20) python/src/coreai_models/models/macos/muse_glimmer.py:766— MuseGlimmerForCausalLMEmbeddings.from_hf_memory_efficient has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
export.load_model_from_safetensors (cyclomatic 20) python/src/coreai_models/vlm/export.py:131— export.load_model_from_safetensors has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CoreAIPipelinedEngine.generate (cyclomatic 19) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:115— CoreAIPipelinedEngine.generate has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
export.main (cyclomatic 19) python/src/coreai_models/llm/export.py:407— export.main has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Qwen3VLForCausalLMEmbeddings._mutate_state_dict (cyclomatic 19) python/src/coreai_models/models/macos/qwen3_vl.py:337— Qwen3VLForCausalLMEmbeddings._mutate_state_dict has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MelSpectrogram.normalize (cyclomatic 18) swift/Sources/CoreAISpeech/MelSpectrogram.swift:478— MelSpectrogram.normalize has cyclomatic complexity 18 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
ConnectedComponents.areas (cyclomatic 18) swift/Sources/CoreAIVideoSegmenter/Postprocessing/ConnectedComponents.swift:13— ConnectedComponents.areas has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SpeechRecognizerMain.swift.runLegacy (cyclomatic 18) swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:295— SpeechRecognizerMain.swift.runLegacy has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
StreamingRun.swift.runStreaming (cyclomatic 18) swift/Sources/Tools/speech-recognizer/StreamingRun.swift:41— StreamingRun.swift.runStreaming has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Qwen3MoeForCausalLM._mutate_state_dict (cyclomatic 18) python/src/coreai_models/models/macos/qwen3_moe.py:234— Qwen3MoeForCausalLM._mutate_state_dict has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
export.main (cyclomatic 18) python/src/coreai_models/segmentation/export.py:289— export.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
CoreAIVLMExecutor.respond (cyclomatic 17) swift/Sources/CoreAILanguageModels/VLM/CoreAIVisionLanguageModel.swift:104— CoreAIVLMExecutor.respond has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Weights.init (cyclomatic 17) swift/Sources/CoreAIShared/Runtime/BilinearResampler.swift:185— Weights.init has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
VideoSegmenter.run (cyclomatic 17) swift/Sources/CoreAIVideoSegmenter/VideoSegmenter.swift:237— VideoSegmenter.run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
Associator.associate (cyclomatic 17) swift/Sources/CoreAIVideoSegmenter/Tracking/Associator.swift:35— Associator.associate has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
DiffusionRunner.run (cyclomatic 17) swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift:103— DiffusionRunner.run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
VideoDiffusionRunner.run (cyclomatic 17) swift/Sources/Tools/videodiffusion-runner/VideoRunnerMain.swift:131— VideoDiffusionRunner.run has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
pipeline.export_diffusion (cyclomatic 17) python/src/coreai_models/diffusion/pipeline.py:61— pipeline.export_diffusion has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Gemma3nForCausalLM.from_hf_memory_efficient (cyclomatic 17) python/src/coreai_models/models/macos/gemma3n.py:428— Gemma3nForCausalLM.from_hf_memory_efficient has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MuseGlimmerForCausalLM.from_hf_memory_efficient (cyclomatic 17) python/src/coreai_models/models/macos/muse_glimmer.py:299— MuseGlimmerForCausalLM.from_hf_memory_efficient has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MuseGlimmerDrafterForCausalLM.from_hf (cyclomatic 17) python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:237— MuseGlimmerDrafterForCausalLM.from_hf has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
rope.initialize_rope (cyclomatic 17) python/src/coreai_models/primitives/macos/rope.py:316— rope.initialize_rope has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MultiFunctionContext.init (cyclomatic 16) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:280— MultiFunctionContext.init has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ThinkTagParser.drainAgentic (cyclomatic 16) swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift:173— ThinkTagParser.drainAgentic has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
SpeechRecognitionModel.runHopIfReady (cyclomatic 16) swift/Sources/CoreAISpeech/SpeechRecognitionModel.swift:280— SpeechRecognitionModel.runHopIfReady has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
VideoSegmentationEngine.resolveShapes (cyclomatic 16) swift/Sources/CoreAIVideoSegmenter/VideoSegmentationEngine.swift:371— VideoSegmentationEngine.resolveShapes has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
ObjectDetectorCLI.run (cyclomatic 16) swift/Sources/Tools/object-detector/ObjectDetectionMain.swift:90— ObjectDetectorCLI.run has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
Qwen2ForCausalLMForiOS._mutate_state_dict (cyclomatic 16) python/src/coreai_models/models/ios/qwen2.py:260— Qwen2ForCausalLMForiOS._mutate_state_dict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
MixtralForCausalLM._mutate_state_dict (cyclomatic 16) python/src/coreai_models/models/macos/mixtral.py:202— MixtralForCausalLM._mutate_state_dict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
Qwen3VLForCausalLM._mutate_state_dict (cyclomatic 16) python/src/coreai_models/models/macos/qwen3_vl.py:192— Qwen3VLForCausalLM._mutate_state_dict has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
LanguageConfig.additionalStopTokenIds (cognitive 79) swift/Sources/CoreAILanguageModels/Bundle/LanguageConfig.swift:190— LanguageConfig.additionalStopTokenIds has cognitive complexity 79 (threshold 15). Drivers by points: if/else 20 (48 pts), boolean chains 13, loops 5 (9 pts), ternaries 3 (9 pts) (nesting depth added 38). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export.main (cognitive 75) python/src/coreai_models/diffusion/export.py:141— export.main has cognitive complexity 75 (threshold 15). Drivers by points: if/else 29 (50 pts), ternaries 5 (10 pts), boolean chains 7, loops 2 (7 pts), error handling 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMRunner.runModel (cognitive 61) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:348— LLMRunner.runModel has cognitive complexity 61 (threshold 15). Drivers by points: if/else 32 (40 pts), ternaries 7 (10 pts), boolean chains 8, match/switch 2 (3 pts) (nesting depth added 12). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
pipeline._async_export_model (cognitive 57) python/src/coreai_models/export/pipeline.py:146— pipeline._async_export_model has cognitive complexity 57 (threshold 15). Drivers by points: if/else 31 (42 pts), boolean chains 12, ternaries 3 (nesting depth added 11). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
Stream.decodeFrames (cognitive 49) swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:213— Stream.decodeFrames has cognitive complexity 49 (threshold 15). Drivers by points: if/else 15 (34 pts), boolean chains 8, loops 2 (3 pts), match/switch 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EngineImpl.runConstrainedCompletion (cognitive 45) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1281— EngineImpl.runConstrainedCompletion has cognitive complexity 45 (threshold 15). Drivers by points: if/else 18 (33 pts), error handling 3 (6 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EngineImpl.init (cognitive 44) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:619— EngineImpl.init has cognitive complexity 44 (threshold 15). Drivers by points: if/else 22 (27 pts), loops 6 (8 pts), ternaries 2 (6 pts), boolean chains 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHandler.swift.runChatCompletion (cognitive 43) swift/Sources/Tools/llm-server/ChatHandler.swift:184— ChatHandler.swift.runChatCompletion has cognitive complexity 43 (threshold 15). Drivers by points: if/else 13 (22 pts), match/switch 2 (7 pts), ternaries 4 (7 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ThinkTagParser.drainAgentic (cognitive 42) swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift:173— ThinkTagParser.drainAgentic has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (32 pts), ternaries 2 (8 pts), boolean chains 1, loops 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export.load_model_from_safetensors (cognitive 42) python/src/coreai_models/vlm/export.py:131— export.load_model_from_safetensors has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (33 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 24). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
WanPipeline.generateVideo (cognitive 41) swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/WanPipeline.swift:139— WanPipeline.generateVideo has cognitive complexity 41 (threshold 15). Drivers by points: if/else 27 (33 pts), loops 3 (8 pts) (nesting depth added 11). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
export._resolve_export_config (cognitive 41) python/src/coreai_models/llm/export.py:292— export._resolve_export_config has cognitive complexity 41 (threshold 15). Drivers by points: if/else 15 (24 pts), boolean chains 14, ternaries 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHandler.swift.runStreamingLoop (cognitive 40) swift/Sources/Tools/llm-server/ChatHandler.swift:449— ChatHandler.swift.runStreamingLoop has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (20 pts), match/switch 3 (9 pts), loops 4 (7 pts), ternaries 4 (nesting depth added 13). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
HotstartHeuristics.process (cognitive 39) swift/Sources/CoreAIVideoSegmenter/Tracking/HotstartHeuristics.swift:21— HotstartHeuristics.process has cognitive complexity 39 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 9 (11 pts), boolean chains 10, ternaries 4 (5 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FlowTransformerPipeline.makeFlux2Plan (cognitive 37) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:69— FlowTransformerPipeline.makeFlux2Plan has cognitive complexity 37 (threshold 15). Drivers by points: if/else 21 (26 pts), boolean chains 6, ternaries 1 (3 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
ConnectedComponents.areas (cognitive 35) swift/Sources/CoreAIVideoSegmenter/Postprocessing/ConnectedComponents.swift:13— ConnectedComponents.areas has cognitive complexity 35 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 5 (6 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MuseGlimmerForCausalLMEmbeddings.from_hf_memory_efficient (cognitive 35) python/src/coreai_models/models/macos/muse_glimmer.py:766— MuseGlimmerForCausalLMEmbeddings.from_hf_memory_efficient has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (22 pts), loops 7 (9 pts), boolean chains 2, ternaries 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LatentPreviewTuner.fitFromDirectory (cognitive 34) swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:326— LatentPreviewTuner.fitFromDirectory has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (21 pts), loops 6 (10 pts), boolean chains 3 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MelSpectrogram.normalize (cognitive 34) swift/Sources/CoreAISpeech/MelSpectrogram.swift:478— MelSpectrogram.normalize has cognitive complexity 34 (threshold 15). Drivers by points: loops 11 (28 pts), if/else 2 (4 pts), match/switch 1, ternaries 1 (nesting depth added 19). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Weights.init (cognitive 33) swift/Sources/CoreAIShared/Runtime/BilinearResampler.swift:185— Weights.init has cognitive complexity 33 (threshold 15). Drivers by points: if/else 6 (15 pts), loops 4 (10 pts), ternaries 4 (6 pts), boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FlowTransformerPipeline.init (cognitive 32) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:20— FlowTransformerPipeline.init has cognitive complexity 32 (threshold 15). Drivers by points: if/else 17 (24 pts), ternaries 3 (4 pts), match/switch 3, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VideoSegmenterCLI.runParity (cognitive 32) swift/Sources/Tools/video-segmenter/VideoSegmenterMain.swift:289— VideoSegmenterCLI.runParity has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 4 (9 pts), boolean chains 6, ternaries 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
diffusion_gemma._mutate_diffusion_gemma_state_dict (cognitive 32) python/src/coreai_models/models/macos/diffusion_gemma.py:718— diffusion_gemma._mutate_diffusion_gemma_state_dict has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (23 pts), loops 5 (6 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3MoeForCausalLM._mutate_state_dict (cognitive 32) python/src/coreai_models/models/macos/qwen3_moe.py:234— Qwen3MoeForCausalLM._mutate_state_dict has cognitive complexity 32 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 7 (12 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoreAIPipelinedEngine.generate (cognitive 30) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:115— CoreAIPipelinedEngine.generate has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (21 pts), error handling 3 (4 pts), loops 1 (3 pts), boolean chains 2 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export.main (cognitive 30) python/src/coreai_models/llm/export.py:407— export.main has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 6 (12 pts), boolean chains 1, ternaries 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MixtralForCausalLM._mutate_state_dict (cognitive 29) python/src/coreai_models/models/macos/mixtral.py:202— MixtralForCausalLM._mutate_state_dict has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 7 (12 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TiledDecode3D.swift.blendTileIntoOutput (cognitive 28) swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/TiledDecode3D.swift:129— TiledDecode3D.swift.blendTileIntoOutput has cognitive complexity 28 (threshold 15). Drivers by points: if/else 5 (18 pts), loops 4 (10 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SpeechParity.parakeetRows (cognitive 28) swift/Sources/Tools/speech-recognizer/SpeechParity.swift:99— SpeechParity.parakeetRows has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (19 pts), ternaries 3 (8 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Gemma3nForCausalLM.from_hf_memory_efficient (cognitive 28) python/src/coreai_models/models/macos/gemma3n.py:428— Gemma3nForCausalLM.from_hf_memory_efficient has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 5 (7 pts), boolean chains 2, ternaries 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MuseGlimmerForCausalLM.from_hf_memory_efficient (cognitive 28) python/src/coreai_models/models/macos/muse_glimmer.py:299— MuseGlimmerForCausalLM.from_hf_memory_efficient has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 6 (8 pts), boolean chains 2, ternaries 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3VLForCausalLMEmbeddings._mutate_state_dict (cognitive 28) python/src/coreai_models/models/macos/qwen3_vl.py:337— Qwen3VLForCausalLMEmbeddings._mutate_state_dict has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 5 (6 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoreAISequentialVLMEngine.init (cognitive 27) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAISequentialVLMEngine.swift:147— CoreAISequentialVLMEngine.init has cognitive complexity 27 (threshold 15). Drivers by points: if/else 19 (25 pts), boolean chains 1, ternaries 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
StaticShapeEngine.init (cognitive 27) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIStaticShapeEngine.swift:115— StaticShapeEngine.init has cognitive complexity 27 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 5, loops 3, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoreAIVLMExecutor.respond (cognitive 27) swift/Sources/CoreAILanguageModels/VLM/CoreAIVisionLanguageModel.swift:104— CoreAIVLMExecutor.respond has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 3 (4 pts), match/switch 1 (3 pts), boolean chains 1, ternaries 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Associator.associate (cognitive 27) swift/Sources/CoreAIVideoSegmenter/Tracking/Associator.swift:35— Associator.associate has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StreamingRun.swift.runStreaming (cognitive 27) swift/Sources/Tools/speech-recognizer/StreamingRun.swift:41— StreamingRun.swift.runStreaming has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 4 (6 pts), loops 3 (4 pts), match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pipeline.export_diffusion (cognitive 27) python/src/coreai_models/diffusion/pipeline.py:61— pipeline.export_diffusion has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 4, ternaries 1 (3 pts), loops 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model_registry._action_model_info (cognitive 27) python/src/coreai_models/model_registry.py:1194— model_registry._action_model_info has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MuseGlimmerDrafterForCausalLM.from_hf (cognitive 27) python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:237— MuseGlimmerDrafterForCausalLM.from_hf has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 5 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen2ForCausalLM._mutate_state_dict (cognitive 27) python/src/coreai_models/models/macos/qwen2.py:175— Qwen2ForCausalLM._mutate_state_dict has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (21 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
MelSpectrogram.fromPCM (cognitive 26) swift/Sources/CoreAISpeech/MelSpectrogram.swift:170— MelSpectrogram.fromPCM has cognitive complexity 26 (threshold 15). Drivers by points: loops 5 (10 pts), if/else 5 (7 pts), ternaries 3 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMServer.run (cognitive 26) swift/Sources/Tools/llm-server/LLMServerMain.swift:114— LLMServer.run has cognitive complexity 26 (threshold 15). Drivers by points: if/else 13 (17 pts), ternaries 4 (6 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SpeechRecognizerMain.swift.runLegacy (cognitive 26) swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift:295— SpeechRecognizerMain.swift.runLegacy has cognitive complexity 26 (threshold 15). Drivers by points: if/else 11 (14 pts), ternaries 3 (6 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VideoDiffusionRunner.run (cognitive 25) swift/Sources/Tools/videodiffusion-runner/VideoRunnerMain.swift:131— VideoDiffusionRunner.run has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (18 pts), ternaries 1 (3 pts), error handling 2, match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
OcclusionSuppressor.suppressAreaShrinkage (cognitive 24) swift/Sources/CoreAIVideoSegmenter/Tracking/OcclusionSuppressor.swift:130— OcclusionSuppressor.suppressAreaShrinkage has cognitive complexity 24 (threshold 15). Drivers by points: loops 7 (16 pts), if/else 3 (8 pts) (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Qwen2ForCausalLMForiOS._mutate_state_dict (cognitive 24) python/src/coreai_models/models/ios/qwen2.py:260— Qwen2ForCausalLMForiOS._mutate_state_dict has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 7 (11 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
export.main (cognitive 24) python/src/coreai_models/segmentation/export.py:289— export.main has cognitive complexity 24 (threshold 15). Drivers by points: ternaries 5 (9 pts), if/else 5 (8 pts), boolean chains 7 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoreAISegmentationEngine.validate (cognitive 23) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:1112— CoreAISegmentationEngine.validate has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (15 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CLIPTokenizer.splitTokens (cognitive 23) swift/Sources/CoreAIShared/Text/CLIPTokenizer.swift:149— CLIPTokenizer.splitTokens has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (9 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DiffusionRunner.run (cognitive 23) swift/Sources/Tools/diffusion-runner/DiffusionRunnerMain.swift:103— DiffusionRunner.run has cognitive complexity 23 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
mlir_ops._replace_cache_update_autofuncs (cognitive 23) python/src/coreai_models/export/mlir_ops.py:269— mlir_ops._replace_cache_update_autofuncs has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), ternaries 1 (4 pts), loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
compression.quantize_pytorch_model (cognitive 22) python/src/coreai_models/export/compression.py:120— compression.quantize_pytorch_model has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), loops 2 (4 pts), ternaries 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
GptOssForCausalLM.from_hf (cognitive 22) python/src/coreai_models/models/macos/gpt_oss.py:299— GptOssForCausalLM.from_hf has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (16 pts), loops 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LatentPreviewTuner.exportStepPreviewsFromDirectory (cognitive 21) swift/Sources/CoreAIDiffusionPipeline/Preview/LatentPreviewTuner.swift:460— LatentPreviewTuner.exportStepPreviewsFromDirectory has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ThinkTagParser.drainTagPair (cognitive 21) swift/Sources/CoreAILanguageModels/LanguageModel/ThinkTagParser.swift:74— ThinkTagParser.drainTagPair has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (13 pts), ternaries 3 (7 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ConstrainedGenerationSession.swift._applyBitmask (cognitive 21) swift/Sources/CoreAILanguageModels/GuidedGeneration/ConstrainedGenerationSession.swift:302— ConstrainedGenerationSession.swift._applyBitmask has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (7 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
TrackerLoop.propagate (cognitive 21) swift/Sources/CoreAIVideoSegmenter/Tracking/TrackerLoop.swift:108— TrackerLoop.propagate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 3, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ObjectDetectorCLI.run (cognitive 21) swift/Sources/Tools/object-detector/ObjectDetectionMain.swift:90— ObjectDetectorCLI.run has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (15 pts), loops 2 (5 pts), ternaries 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
Qwen3VLForCausalLM._mutate_state_dict (cognitive 21) python/src/coreai_models/models/macos/qwen3_vl.py:192— Qwen3VLForCausalLM._mutate_state_dict has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 4 (5 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
rope.initialize_rope (cognitive 21) python/src/coreai_models/primitives/macos/rope.py:316— rope.initialize_rope has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 5, ternaries 1 (2 pts), match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
FlowTransformerPipeline.generateImages (cognitive 20) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:152— FlowTransformerPipeline.generateImages has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 3 (5 pts), match/switch 1, ternaries 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
StaticStateFactory.makeStateSet (cognitive 20) swift/Sources/CoreAILanguageModels/Handlers/StateHandler+Static.swift:360— StaticStateFactory.makeStateSet has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3 (6 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMRunner.runVLMGeneration (cognitive 20) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:1071— LLMRunner.runVLMGeneration has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 4, loops 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ChatHandler.swift.tokenizeMessages (cognitive 20) swift/Sources/Tools/llm-server/ChatHandler.swift:641— ChatHandler.swift.tokenizeMessages has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, ternaries 1 (2 pts), error handling 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
pipeline._save_flux2_sidecar_assets (cognitive 20) python/src/coreai_models/diffusion/pipeline.py:234— pipeline._save_flux2_sidecar_assets has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (13 pts), error handling 2 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model_registry._action_list_models (cognitive 20) python/src/coreai_models/model_registry.py:1036— model_registry._action_list_models has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 3 (7 pts), boolean chains 2, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Gemma3ForCausalLM._mutate_state_dict (cognitive 20) python/src/coreai_models/models/macos/gemma3_text.py:250— Gemma3ForCausalLM._mutate_state_dict has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3ForCausalLM._mutate_state_dict (cognitive 20) python/src/coreai_models/models/macos/qwen3.py:186— Qwen3ForCausalLM._mutate_state_dict has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EngineImpl.performWarmup (cognitive 19) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1774— EngineImpl.performWarmup has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 2 (3 pts), ternaries 2 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CLIPTokenizer.bpe (cognitive 19) swift/Sources/CoreAIShared/Text/CLIPTokenizer.swift:193— CLIPTokenizer.bpe has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (5 pts), boolean chains 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
VideoSegmenter.run (cognitive 19) swift/Sources/CoreAIVideoSegmenter/VideoSegmenter.swift:237— VideoSegmenter.run has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (10 pts), loops 4 (6 pts), match/switch 2, boolean chains 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
OcclusionSuppressor.applyObjectWiseNonOverlap (cognitive 19) swift/Sources/CoreAIVideoSegmenter/Tracking/OcclusionSuppressor.swift:183— OcclusionSuppressor.applyObjectWiseNonOverlap has cognitive complexity 19 (threshold 15). Drivers by points: loops 4 (8 pts), if/else 3 (7 pts), boolean chains 4 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
LLMRunner.validate (cognitive 19) swift/Sources/Tools/llm-runner/LLMRunnerMain.swift:253— LLMRunner.validate has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, boolean chains 9. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
MistralForCausalLMForiOS._mutate_state_dict (cognitive 19) python/src/coreai_models/models/ios/mistral.py:259— MistralForCausalLMForiOS._mutate_state_dict has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 6 (8 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Olmo2ForCausalLMForiOS._mutate_state_dict (cognitive 19) python/src/coreai_models/models/ios/olmo2.py:257— Olmo2ForCausalLMForiOS._mutate_state_dict has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 6 (8 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
Qwen3ForCausalLMForiOS._mutate_state_dict (cognitive 19) python/src/coreai_models/models/ios/qwen3.py:265— Qwen3ForCausalLMForiOS._mutate_state_dict has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (10 pts), loops 6 (8 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
SingleFunctionContext.init (cognitive 18) swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:170— SingleFunctionContext.init has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
EngineImpl._encodeNextStepGPU (cognitive 18) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:922— EngineImpl._encodeNextStepGPU has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (8 pts), ternaries 4, boolean chains 3, loops 1 (2 pts), error handling 1 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
CoreAIExecutor.respondVanilla (cognitive 18) swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift:322— CoreAIExecutor.respondVanilla has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 4 (6 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
CoreAIExecutor.makeTokens (cognitive 18) swift/Sources/CoreAILanguageModels/LanguageModel/CoreAILanguageModel.swift:613— CoreAIExecutor.makeTokens has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), ternaries 2 (3 pts), match/switch 1 (2 pts), error handling 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
ObjectDetector.buildInputNDArray (cognitive 18) swift/Sources/CoreAIObjectDetector/ObjectDetector.swift:195— ObjectDetector.buildInputNDArray has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 4 (6 pts), boolean chains 2 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
Attention.__init__ (cognitive 18) python/src/coreai_models/models/macos/gemma3_text.py:53— Attention.__init__ has cognitive complexity 18 (threshold 15). Drivers by points: ternaries 6 (8 pts), if/else 6 (7 pts), boolean chains 3 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
FlowTransformerPipeline.blendTile (cognitive 17) swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:408— FlowTransformerPipeline.blendTile has cognitive complexity 17 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
model_registry._action_list_variants (cognitive 17) python/src/coreai_models/model_registry.py:1126— model_registry._action_list_variants has cognitive complexity 17 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
NDArray+Helpers.swift.fillNDArray (cognitive 16) swift/Sources/CoreAIShared/Runtime/NDArray+Helpers.swift:68— NDArray+Helpers.swift.fillNDArray has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (10 pts), if/else 3 (6 pts) (nesting depth added 9). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
model_registry._print_all_tables (cognitive 16) python/src/coreai_models/model_registry.py:1098— model_registry._print_all_tables has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (9 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
GptOssForCausalLM._mutate_state_dict (cognitive 16) python/src/coreai_models/models/macos/gpt_oss.py:247— GptOssForCausalLM._mutate_state_dict has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
DecomposedRoPE.forward (cognitive 16) python/src/coreai_models/primitives/macos/rope.py:74— DecomposedRoPE.forward has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (11 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D22 · Internal API Consistency· Highly fragmented and inconsistent execution API. The type exposes 7 different methods for running inference, mixing naming conventions ('run' vs 'predict'), input formats (raw arrays, ModelInput, NDArray, String-keyed dicts), and output formats (flat Float arrays, String-keyed dicts, NDArray). This forces users to guess the correct method for their specific data type and output needs. · ×1
Highly fragmented and inconsistent execution API. The type exposes 7 different methods for running inference, mixing naming conventions ('run' vs 'predict'), input formats (raw arrays, ModelInput, NDArray, String-keyed dicts), and output formats (flat Float arrays, String-keyed dicts, NDArray). This forces users to guess the correct method for their specific data type and output needs. — Unify into a single primary execution method, e.g., `run(inputs: [String: NDArray]) -> [String: NDArray]`, with optional convenience overloads for specific common cases (like returning a single NDArray). Remove the low-level raw array methods (`run(floatInputs:...)`, `run(intInputs:...)`) or move them to a private/internal helper. (signatures: CoreAIDiffusionModelFunction.run(floatInputs: [([Float], [Int])], functionName: swift~String): [Float] | CoreAIDiffusionModelFunction.run(inputs: [ModelInput], functionName: swift~String): [Float] | CoreAIDiffusionModelFunction.run(intInputs: [([Int32], [Int])]): [Float] | CoreAIDiffusionModelFunction.predict(inputs: [String: NDArray]): [String: [Float]] | CoreAIDiffusionModelFunction.predictAllOutputs(inputs: [String: NDArray]): [String: [Float]] | CoreAIDiffusionModelFunction.predictAutoNamed(inputs: [NDArray]): [String: [Float]] | CoreAIDiffusionModelFunction.runReturningNDArray(inputs: [ModelInput]): swift~NDArray)
D22 · Internal API Consistency· Inconsistent method signatures for the same core operation. `DiffusionPipeline.generateImages` lacks a progress handler, while `FlowTransformerPipeline.generateImages` includes it. This creates an inconsistent developer experience when switching between pipeline types, as the async/streaming capability is not uniformly exposed. · ×1
Inconsistent method signatures for the same core operation. `DiffusionPipeline.generateImages` lacks a progress handler, while `FlowTransformerPipeline.generateImages` includes it. This creates an inconsistent developer experience when switching between pipeline types, as the async/streaming capability is not uniformly exposed. — Add the optional `progressHandler` parameter to `DiffusionPipeline.generateImages` to match `FlowTransformerPipeline`, or remove it from `FlowTransformerPipeline` if progress tracking is not supported by the underlying engine. (signatures: CoreAIDiffusionPipeline.generateImages(configuration: swift~PipelineConfiguration): swift~GenerationResult | FlowTransformerPipeline.generateImages(configuration: swift~PipelineConfiguration, progressHandler: ((PipelineProgress) -> Bool)?): swift~GenerationResult)
D22 · Internal API Consistency· Inconsistent return types and naming between the high-level `ImageSegmenter` and low-level `CoreAISegmentationEngine`. `ImageSegmenter` returns `SegmentationResponse` (processed/high-level), while `CoreAISegmentationEngine` returns `SegmentationOutput` (raw model output). Additionally, `ImageSegmenter` offers a convenience overload accepting `String` for prompts, while the engine requires a typed `TextQuery`. This inconsistency makes it unclear when to use which type and what the output format will be. · ×1
Inconsistent return types and naming between the high-level `ImageSegmenter` and low-level `CoreAISegmentationEngine`. `ImageSegmenter` returns `SegmentationResponse` (processed/high-level), while `CoreAISegmentationEngine` returns `SegmentationOutput` (raw model output). Additionally, `ImageSegmenter` offers a convenience overload accepting `String` for prompts, while the engine requires a typed `TextQuery`. This inconsistency makes it unclear when to use which type and what the output format will be. — Ensure the high-level wrapper (`ImageSegmenter`) clearly delegates to the engine. Consider renaming `SegmentationOutput` to `RawSegmentationOutput` to distinguish it from the processed `SegmentationResponse`. Ensure the `String` prompt overload in `ImageSegmenter` explicitly handles tokenization internally to avoid confusion about where that logic resides. (signatures: ImageSegmenter.segment(image: CGImage, textQuery: swift~TextQuery, parameters: swift~SegmentationParameters): swift~SegmentationResponse | ImageSegmenter.segment(image: CGImage, prompt: swift~String, parameters: swift~SegmentationParameters): swift~SegmentationResponse | CoreAISegmentationEngine.segment(image: CGImage, textQuery: swift~TextQuery, parameters: swift~SegmentationParameters): swift~SegmentationOutput | CoreAISegmentationEngine.segment(image: CGImage, pointQuery: swift~PointQuery, parameters: swift~SegmentationParameters): swift~SegmentationOutput)
D4 · Code Duplication· Near-duplicate member family (5 members, 37 shared lines) · ×1
Near-duplicate member family (5 members, 37 shared lines) python/src/coreai_models/models/macos/gemma3_text.py:116— python/src/coreai_models/models/macos/gemma3_text.py:116-164 | python/src/coreai_models/models/macos/mixtral.py:78-120 | python/src/coreai_models/models/macos/qwen2.py:55-97 | python/src/coreai_models/models/macos/qwen3.py:60-108 | python/src/coreai_models/models/macos/qwen3_moe.py:61-109 — These 5 members are variants of one another: a block of 37 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication· Near-duplicate member family (4 members, 37 shared lines) · ×1
Near-duplicate member family (4 members, 37 shared lines) python/src/coreai_models/models/ios/mistral.py:53— python/src/coreai_models/models/ios/mistral.py:53-101 | python/src/coreai_models/models/ios/olmo2.py:57-104 | python/src/coreai_models/models/ios/qwen2.py:56-104 | python/src/coreai_models/models/ios/qwen3.py:58-109 — These 4 members are variants of one another: a block of 37 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 39 shared lines) · ×1
Near-duplicate member family (3 members, 39 shared lines) python/src/coreai_models/models/macos/gemma3n.py:439— python/src/coreai_models/models/macos/gemma3n.py:439-518 | python/src/coreai_models/models/macos/muse_glimmer.py:310-392 | python/src/coreai_models/models/macos/muse_glimmer.py:777-861 — These 3 members are variants of one another: a block of 39 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Near-duplicate member family (3 members, 21 shared lines) · ×1
Near-duplicate member family (3 members, 21 shared lines) models/t5/export.py:173— models/t5/export.py:173-224 | models/whisper/export.py:142-184 | models/yolo/export.py:148-200 — These 3 members are variants of one another: a block of 21 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 3 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 3 times.
D4 · Code Duplication· Edited copy of a member (31 corresponding lines) · ×1
Edited copy of a member (31 corresponding lines) swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:29— swift/Sources/CoreAIDiffusionPipeline/RNG/NumPyRandomSource.swift:29-59 | swift/Sources/CoreAIDiffusionPipeline/RNG/TorchRandomSource.swift:30-60 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (29 corresponding lines) · ×1
Edited copy of a member (29 corresponding lines) swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:222— swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:222-276 | swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:337-389 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Edited copy of a member (14 corresponding lines) · ×1
Edited copy of a member (14 corresponding lines) python/src/coreai_models/models/ios/mistral.py:28— python/src/coreai_models/models/ios/mistral.py:28-42 | python/src/coreai_models/models/ios/olmo2.py:28-46 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication· Members sharing a duplicated core (13 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (13 members, 50+ identical tokens) python/src/coreai_models/models/ios/mistral.py:260— python/src/coreai_models/models/ios/mistral.py:260-319 | python/src/coreai_models/models/ios/olmo2.py:258-313 | python/src/coreai_models/models/ios/qwen2.py:261-327 | python/src/coreai_models/models/ios/qwen3.py:266-325 | python/src/coreai_models/models/macos/gemma3_text.py:251-300 | python/src/coreai_models/models/macos/mistral.py:169-195 | python/src/coreai_models/models/macos/mixtral.py:203-289 | python/src/coreai_models/models/macos/olmo2.py:166-192 | python/src/coreai_models/models/macos/qwen2.py:176-217 | python/src/coreai_models/models/macos/qwen3.py:187-237 | python/src/coreai_models/models/macos/qwen3_moe.py:235-334 | python/src/coreai_models/models/macos/qwen3_vl.py:198-256 | python/src/coreai_models/models/macos/qwen3_vl.py:339-402 — These 13 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 13 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 13 times.
D4 · Code Duplication· Members sharing a duplicated core (11 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (11 members, 50+ identical tokens) models/clap/export.py:138— models/clap/export.py:138-172 | models/clip/export.py:144-178 | models/depth-anything/export.py:141-170 | models/edsr/export.py:99-128 | models/efficient-sam/export.py:137-193 | models/pvt/export.py:97-126 | models/roberta/export.py:100-131 | models/t5/export.py:140-169 | models/wav2vec2/export.py:107-136 | models/whisper/export.py:104-138 | models/yolo/export.py:115-144 — These 11 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 11 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 11 times.
D4 · Code Duplication· Members sharing a duplicated core (10 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (10 members, 50+ identical tokens) models/clap/export.py:107— models/clap/export.py:107-117 | models/clip/export.py:113-123 | models/depth-anything/export.py:111-121 | models/edsr/export.py:68-78 | models/pvt/export.py:66-76 | models/roberta/export.py:69-79 | models/t5/export.py:109-119 | models/wav2vec2/export.py:76-86 | models/whisper/export.py:74-84 | models/yolo/export.py:84-94 — These 10 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 10 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 10 times.
D4 · Code Duplication· Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
Members sharing a duplicated core (6 members, 50+ identical tokens) python/src/coreai_models/models/macos/mistral.py:95— python/src/coreai_models/models/macos/mistral.py:95-101 | python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:176-181 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:128-133 | python/src/coreai_models/models/macos/qwen2.py:102-108 | python/src/coreai_models/models/macos/qwen3.py:113-119 | python/src/coreai_models/models/macos/qwen3_vl.py:96-102 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
Duplicated block (44–45 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:423— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:423-467 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1099-1142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29–36 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:986— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:986-1021 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1532-1560 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (29–31 lines × 2) swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift:125— swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift:125-155 | swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedGenerator.swift:193-221 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift:125` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (29 lines × 2) swift/Sources/Tools/llm-server/ChatHandler.swift:194— swift/Sources/Tools/llm-server/ChatHandler.swift:194-222 | swift/Sources/Tools/llm-server/ChatHandler.swift:409-437 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `swift/Sources/Tools/llm-server/ChatHandler.swift:192` calls `Int`, `Date` and `swift/Sources/Tools/llm-server/ChatHandler.swift:407` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (27 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:250— swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:250-276 | swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:363-389 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:250` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (26 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:581— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:581-606 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1282-1307 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (22 lines × 2) swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:27— swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:27-48 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationVisualization.swift:97-118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (20 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519-538 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:623-642 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12–19 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:612— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:612-630 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1317-1328 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:612` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (19 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1240— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1240-1258 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1321-1339 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1240` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–17 lines × 3) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:988— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:988-1004 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1534-1549 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1715-1725 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
Duplicated block (16–17 lines × 3) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:621— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:621-637 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1238-1253 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1319-1334 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:621` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–17 lines × 2) swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:137— swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:137-152 | swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:196-212 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:137` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:133` calls `Array` and `swift/Sources/CoreAILanguageModels/TextGeneration/TextGenerator.swift:194` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (14–16 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:950— swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:950-965 | swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift:1511-1524 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (14–15 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:398— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:398-411 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1073-1087 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:398` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (14 lines × 4) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519-533 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:623-637 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1240-1253 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:1321-1334 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:519` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
Duplicated block (12 lines × 7) swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:88— swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:88-99 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/PipelineConfiguration.swift:106-117 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:239-250 | swift/Sources/CoreAIImageSegmenter/ImageSegmentationEngine.swift:387-400 | swift/Sources/CoreAILMCommon/ReplayTypes.swift:68-79 | swift/Sources/CoreAISpeech/MelSpectrogram.swift:70-81 | swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/VideoConfiguration.swift:86-97 — there are 7 copies across 6 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 7 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:88` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (12 lines × 6) swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:79— swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:79-90 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline.swift:88-99 | swift/Sources/CoreAIDiffusionPipeline/Pipelines/PipelineConfiguration.swift:101-112 | swift/Sources/CoreAILMCommon/ReplayTypes.swift:65-76 | swift/Sources/CoreAISpeech/MelSpectrogram.swift:68-79 | swift/Sources/CoreAIVideoDiffusionPipeline/Pipelines/VideoConfiguration.swift:82-93 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAIDiffusionPipeline/Bundle/DiffusionConfig.swift:79` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11–12 lines × 2) swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:525— swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:525-536 | swift/Sources/CoreAILanguageModels/InferenceEngines/KVCache+CoreAI.swift:540-550 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (9–12 lines × 2) swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:636— swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:636-644 | swift/Sources/Tools/speech-recognizer/SpeechParity.swift:459-470 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/Tools/speech-recognizer/SpeechParity.swift:459` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `swift/Sources/Tools/speech-recognizer/SpeechParity.swift:471` calls `zip`, `reduce`, `Float` and `swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift:645` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (9–11 lines × 2) swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:342— swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:342-352 | swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:980-988 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift:342` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (4–8 lines × 4) swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:256— swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:256-259 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:262-269 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:291-294 | swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:297-304 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:262` calls `Int`, `rounded` and `swift/Sources/CoreAIImageSegmenter/Postprocessing/SegmentationPostprocessor.swift:256` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (5–6 lines × 2) swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:91— swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:91-95 | swift/Sources/CoreAISpeech/SpeechRecognitionModel.swift:67-72 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift:91` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (42–45 lines × 4) python/src/coreai_models/models/ios/mistral.py:275— python/src/coreai_models/models/ios/mistral.py:275-319 | python/src/coreai_models/models/ios/olmo2.py:272-313 | python/src/coreai_models/models/ios/qwen2.py:283-327 | python/src/coreai_models/models/ios/qwen3.py:281-325 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (37–43 lines × 2) python/src/coreai_models/models/macos/muse_glimmer.py:321— python/src/coreai_models/models/macos/muse_glimmer.py:321-363 | python/src/coreai_models/models/macos/muse_glimmer.py:788-824 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (29–33 lines × 2) python/src/coreai_models/models/ios/sam3/sam3_reauthored.py:96— python/src/coreai_models/models/ios/sam3/sam3_reauthored.py:96-128 | python/src/coreai_models/segmentation/pipeline.py:90-118 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
Duplicated block (30–32 lines × 4) python/src/coreai_models/models/ios/mistral.py:70— python/src/coreai_models/models/ios/mistral.py:70-101 | python/src/coreai_models/models/ios/olmo2.py:74-104 | python/src/coreai_models/models/ios/qwen2.py:73-104 | python/src/coreai_models/models/ios/qwen3.py:80-109 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/ios/mistral.py:70` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `python/src/coreai_models/models/ios/qwen3.py:77` calls `q_norm`, `k_norm` and `python/src/coreai_models/models/ios/mistral.py:70` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (31 lines × 4) python/src/coreai_models/models/ios/mistral.py:199— python/src/coreai_models/models/ios/mistral.py:199-229 | python/src/coreai_models/models/ios/olmo2.py:197-227 | python/src/coreai_models/models/ios/qwen2.py:200-230 | python/src/coreai_models/models/ios/qwen3.py:205-235 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (28 lines × 3) models/clap/export.py:183— models/clap/export.py:183-210 | models/t5/export.py:180-207 | models/wav2vec2/export.py:147-174 — `models/clap/export.py` and `models/t5/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 124 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (25–26 lines × 8) models/clap/export.py:193— models/clap/export.py:193-217 | models/clip/export.py:199-224 | models/edsr/export.py:149-174 | models/pvt/export.py:147-172 | models/roberta/export.py:152-177 | models/t5/export.py:190-214 | models/wav2vec2/export.py:157-181 | models/yolo/export.py:165-190 — `models/clap/export.py` and `models/clip/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 77 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:193` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (24–25 lines × 8) python/src/coreai_models/models/macos/gemma3_text.py:254— python/src/coreai_models/models/macos/gemma3_text.py:254-277 | python/src/coreai_models/models/macos/mistral.py:172-195 | python/src/coreai_models/models/macos/mixtral.py:206-229 | python/src/coreai_models/models/macos/olmo2.py:169-192 | python/src/coreai_models/models/macos/qwen3.py:190-214 | python/src/coreai_models/models/macos/qwen3_moe.py:238-262 | python/src/coreai_models/models/macos/qwen3_vl.py:216-239 | python/src/coreai_models/models/macos/qwen3_vl.py:362-385 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/mistral.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (25 lines × 2) python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:137— python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:137-161 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:87-111 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (24 lines × 3) python/src/coreai_models/models/macos/gemma3_text.py:123— python/src/coreai_models/models/macos/gemma3_text.py:123-146 | python/src/coreai_models/models/macos/qwen3.py:67-90 | python/src/coreai_models/models/macos/qwen3_moe.py:68-91 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/qwen3.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 148 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/gemma3_text.py:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (22–23 lines × 7) models/clip/export.py:188— models/clip/export.py:188-209 | models/edsr/export.py:138-159 | models/efficient-sam/export.py:203-224 | models/pvt/export.py:136-157 | models/roberta/export.py:141-162 | models/whisper/export.py:148-170 | models/yolo/export.py:154-175 — `models/clip/export.py` and `models/edsr/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 6 separate duplicated blocks between them, totalling at least 100 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clip/export.py:188` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (20–22 lines × 10) models/clap/export.py:199— models/clap/export.py:199-219 | models/clip/export.py:205-226 | models/depth-anything/export.py:192-211 | models/edsr/export.py:155-176 | models/pvt/export.py:153-174 | models/roberta/export.py:158-179 | models/t5/export.py:196-216 | models/wav2vec2/export.py:163-183 | models/whisper/export.py:160-181 | models/yolo/export.py:171-192 — `models/clap/export.py` and `models/clip/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 77 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:199` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (15–22 lines × 2) python/src/coreai_models/models/macos/mixtral.py:242— python/src/coreai_models/models/macos/mixtral.py:242-256 | python/src/coreai_models/models/macos/qwen3_moe.py:289-310 — before extracting anything, compare `python/src/coreai_models/models/macos/mixtral.py` and `python/src/coreai_models/models/macos/qwen3_moe.py` as WHOLE FILES: this scan already matched 10 separate duplicated blocks between them, totalling at least 147 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `python/src/coreai_models/models/macos/mixtral.py:259` calls `pop` and `python/src/coreai_models/models/macos/qwen3_moe.py:311` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (21–22 lines × 2) python/src/coreai_models/models/macos/muse_glimmer.py:371— python/src/coreai_models/models/macos/muse_glimmer.py:371-392 | python/src/coreai_models/models/macos/muse_glimmer.py:841-861 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (21 lines × 5) python/src/coreai_models/models/macos/gemma3_text.py:139— python/src/coreai_models/models/macos/gemma3_text.py:139-159 | python/src/coreai_models/models/macos/mixtral.py:95-115 | python/src/coreai_models/models/macos/qwen2.py:72-92 | python/src/coreai_models/models/macos/qwen3.py:83-103 | python/src/coreai_models/models/macos/qwen3_moe.py:84-104 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/gemma3_text.py:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (16–20 lines × 5) python/src/coreai_models/models/macos/gemma3_text.py:281— python/src/coreai_models/models/macos/gemma3_text.py:281-300 | python/src/coreai_models/models/macos/qwen3.py:218-237 | python/src/coreai_models/models/macos/qwen3_moe.py:266-285 | python/src/coreai_models/models/macos/qwen3_vl.py:241-256 | python/src/coreai_models/models/macos/qwen3_vl.py:387-402 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/qwen3.py` as WHOLE FILES: this scan already matched 9 separate duplicated blocks between them, totalling at least 148 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (20 lines × 3) models/clap/export.py:178— models/clap/export.py:178-197 | models/parakeet/export.py:631-650 | models/wav2vec2/export.py:142-161 — `models/clap/export.py` and `models/wav2vec2/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 8 separate duplicated blocks between them, totalling at least 144 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:178` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (19 lines × 4) models/clap/export.py:182— models/clap/export.py:182-200 | models/parakeet/export.py:635-653 | models/t5/export.py:179-197 | models/wav2vec2/export.py:146-164 — `models/clap/export.py` and `models/t5/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 124 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:182` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `models/parakeet/export.py:654` calls `add_mutually_exclusive_group` and `models/clap/export.py:201` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (18 lines × 4) models/edsr/export.py:111— models/edsr/export.py:111-128 | models/pvt/export.py:109-126 | models/roberta/export.py:114-131 | models/wav2vec2/export.py:119-136 — `models/edsr/export.py` and `models/pvt/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 7 separate duplicated blocks between them, totalling at least 118 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/edsr/export.py:111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (17–18 lines × 2) python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:76— python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:76-93 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:62-78 — before extracting anything, compare `python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py` and `python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 94 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (17 lines × 3) python/src/coreai_models/models/ios/mistral.py:54— python/src/coreai_models/models/ios/mistral.py:54-70 | python/src/coreai_models/models/ios/qwen2.py:57-73 | python/src/coreai_models/models/ios/qwen3.py:59-75 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/qwen2.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `python/src/coreai_models/models/ios/qwen3.py:77` calls `q_norm`, `k_norm` and `python/src/coreai_models/models/ios/mistral.py:72` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (16 lines × 5) python/src/coreai_models/models/macos/gemma3_text.py:116— python/src/coreai_models/models/macos/gemma3_text.py:116-131 | python/src/coreai_models/models/macos/mixtral.py:78-93 | python/src/coreai_models/models/macos/qwen2.py:55-70 | python/src/coreai_models/models/macos/qwen3.py:60-75 | python/src/coreai_models/models/macos/qwen3_moe.py:61-76 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (15 lines × 3) python/src/coreai_models/models/macos/gemma3n.py:450— python/src/coreai_models/models/macos/gemma3n.py:450-464 | python/src/coreai_models/models/macos/muse_glimmer.py:313-327 | python/src/coreai_models/models/macos/muse_glimmer.py:780-794 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (14 lines × 3) python/src/coreai_models/models/macos/qwen3.py:29— python/src/coreai_models/models/macos/qwen3.py:29-42 | python/src/coreai_models/models/macos/qwen3_moe.py:30-43 | python/src/coreai_models/models/macos/qwen3_vl.py:29-42 — before extracting anything, compare `python/src/coreai_models/models/macos/qwen3.py` and `python/src/coreai_models/models/macos/qwen3_moe.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 174 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/qwen3.py:29` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `Qwen3Config` in one and `Qwen3MoeConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (13 lines × 12) python/src/coreai_models/models/ios/mistral.py:261— python/src/coreai_models/models/ios/mistral.py:261-273 | python/src/coreai_models/models/ios/olmo2.py:259-271 | python/src/coreai_models/models/ios/qwen2.py:262-274 | python/src/coreai_models/models/ios/qwen3.py:267-279 | python/src/coreai_models/models/macos/gemma3_text.py:252-264 | python/src/coreai_models/models/macos/mistral.py:170-182 | python/src/coreai_models/models/macos/mixtral.py:204-216 | python/src/coreai_models/models/macos/olmo2.py:167-179 | python/src/coreai_models/models/macos/qwen3.py:188-200 | python/src/coreai_models/models/macos/qwen3_moe.py:236-248 | python/src/coreai_models/models/macos/qwen3_vl.py:214-226 | python/src/coreai_models/models/macos/qwen3_vl.py:360-372 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (11–13 lines × 2) python/src/coreai_models/models/macos/qwen3_vl.py:198— python/src/coreai_models/models/macos/qwen3_vl.py:198-210 | python/src/coreai_models/models/macos/qwen3_vl.py:339-349 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
Duplicated block (12 lines × 13) python/src/coreai_models/models/ios/mistral.py:260— python/src/coreai_models/models/ios/mistral.py:260-271 | python/src/coreai_models/models/ios/olmo2.py:258-269 | python/src/coreai_models/models/ios/qwen2.py:261-272 | python/src/coreai_models/models/ios/qwen3.py:266-277 | python/src/coreai_models/models/macos/gemma3_text.py:251-262 | python/src/coreai_models/models/macos/mistral.py:169-180 | python/src/coreai_models/models/macos/mixtral.py:203-214 | python/src/coreai_models/models/macos/olmo2.py:166-177 | python/src/coreai_models/models/macos/qwen2.py:176-187 | python/src/coreai_models/models/macos/qwen3.py:187-198 | python/src/coreai_models/models/macos/qwen3_moe.py:235-246 | python/src/coreai_models/models/macos/qwen3_vl.py:213-224 | python/src/coreai_models/models/macos/qwen3_vl.py:359-370 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `python/src/coreai_models/models/macos/qwen2.py:189` calls `getattr` and `python/src/coreai_models/models/macos/gemma3_text.py:264` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (12 lines × 9) models/clap/export.py:147— models/clap/export.py:147-158 | models/clip/export.py:153-164 | models/edsr/export.py:108-119 | models/efficient-sam/export.py:167-178 | models/pvt/export.py:106-117 | models/roberta/export.py:111-122 | models/t5/export.py:149-160 | models/wav2vec2/export.py:116-127 | models/yolo/export.py:124-135 — `models/clap/export.py` and `models/clip/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 77 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `models/clap/export.py:147` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (11 lines × 10) models/clap/export.py:107— models/clap/export.py:107-117 | models/clip/export.py:113-123 | models/depth-anything/export.py:111-121 | models/edsr/export.py:68-78 | models/pvt/export.py:66-76 | models/roberta/export.py:69-79 | models/t5/export.py:109-119 | models/wav2vec2/export.py:76-86 | models/whisper/export.py:74-84 | models/yolo/export.py:84-94 — `models/clap/export.py` and `models/clip/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 77 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
Duplicated block (10–11 lines × 2) python/src/coreai_models/diffusion/flux2.py:162— python/src/coreai_models/diffusion/flux2.py:162-171 | python/src/coreai_models/diffusion/flux2.py:258-268 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/diffusion/flux2.py:258` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Duplicated block (10 lines × 7) python/src/coreai_models/models/macos/mistral.py:80— python/src/coreai_models/models/macos/mistral.py:80-89 | python/src/coreai_models/models/macos/mixtral.py:110-119 | python/src/coreai_models/models/macos/olmo2.py:79-88 | python/src/coreai_models/models/macos/phi3.py:122-131 | python/src/coreai_models/models/macos/qwen2.py:87-96 | python/src/coreai_models/models/macos/qwen3.py:98-107 | python/src/coreai_models/models/macos/qwen3_vl.py:81-90 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `python/src/coreai_models/models/macos/mistral.py:78` calls `narrow` and `python/src/coreai_models/models/macos/mixtral.py:108` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
Duplicated block (7–10 lines × 2) python/src/coreai_models/models/macos/gpt_oss.py:123— python/src/coreai_models/models/macos/gpt_oss.py:123-132 | python/src/coreai_models/models/macos/olmo2.py:74-80 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/gpt_oss.py:123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
Duplicated block (9 lines × 6) python/src/coreai_models/models/macos/gemma3_text.py:151— python/src/coreai_models/models/macos/gemma3_text.py:151-159 | python/src/coreai_models/models/macos/mixtral.py:107-115 | python/src/coreai_models/models/macos/olmo2.py:76-84 | python/src/coreai_models/models/macos/qwen2.py:84-92 | python/src/coreai_models/models/macos/qwen3.py:95-103 | python/src/coreai_models/models/macos/qwen3_moe.py:96-104 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 104 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/gemma3_text.py:151` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
Duplicated block (9 lines × 3) python/src/coreai_models/models/macos/muse_glimmer.py:226— python/src/coreai_models/models/macos/muse_glimmer.py:226-234 | python/src/coreai_models/models/macos/muse_glimmer.py:581-589 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:167-175 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
Duplicated block (2–9 lines × 3) python/src/coreai_models/models/ios/mistral.py:28— python/src/coreai_models/models/ios/mistral.py:28-36 | python/src/coreai_models/models/ios/olmo2.py:28-36 | python/src/coreai_models/models/ios/qwen3.py:38-39 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `Olmo2Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (8 lines × 8) python/src/coreai_models/models/macos/gemma3n.py:195— python/src/coreai_models/models/macos/gemma3n.py:195-202 | python/src/coreai_models/models/macos/mistral.py:83-90 | python/src/coreai_models/models/macos/mixtral.py:113-120 | python/src/coreai_models/models/macos/olmo2.py:82-89 | python/src/coreai_models/models/macos/phi3.py:125-132 | python/src/coreai_models/models/macos/qwen2.py:90-97 | python/src/coreai_models/models/macos/qwen3.py:101-108 | python/src/coreai_models/models/macos/qwen3_vl.py:84-91 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `python/src/coreai_models/models/macos/gemma3n.py:195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 4) python/src/coreai_models/models/ios/sam3/detr.py:39— python/src/coreai_models/models/ios/sam3/detr.py:39-46 | python/src/coreai_models/models/ios/sam3/image_encoder.py:46-53 | python/src/coreai_models/models/ios/sam3/mask_decoder.py:28-35 | python/src/coreai_models/models/ios/sam3/sam3_reauthored.py:35-42 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (8 lines × 3) python/src/coreai_models/models/ios/mistral.py:106— python/src/coreai_models/models/ios/mistral.py:106-113 | python/src/coreai_models/models/ios/qwen2.py:109-116 | python/src/coreai_models/models/ios/qwen3.py:114-121 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/qwen2.py` as WHOLE FILES: this scan already matched 13 separate duplicated blocks between them, totalling at least 212 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `Qwen2Config` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7 lines × 8) python/src/coreai_models/models/macos/mistral.py:117— python/src/coreai_models/models/macos/mistral.py:117-123 | python/src/coreai_models/models/macos/mixtral.py:153-159 | python/src/coreai_models/models/macos/olmo2.py:118-124 | python/src/coreai_models/models/macos/phi3.py:171-177 | python/src/coreai_models/models/macos/qwen2.py:124-130 | python/src/coreai_models/models/macos/qwen3.py:135-141 | python/src/coreai_models/models/macos/qwen3_moe.py:183-189 | python/src/coreai_models/models/macos/qwen3_vl.py:118-124 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/mixtral.py` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 83 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `MixtralConfig` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (6–7 lines × 6) python/src/coreai_models/models/macos/mistral.py:95— python/src/coreai_models/models/macos/mistral.py:95-101 | python/src/coreai_models/models/macos/muse_glimmer_drafter_dflash.py:176-181 | python/src/coreai_models/models/macos/muse_glimmer_drafter_ring.py:128-133 | python/src/coreai_models/models/macos/qwen2.py:102-108 | python/src/coreai_models/models/macos/qwen3.py:113-119 | python/src/coreai_models/models/macos/qwen3_vl.py:96-102 — before extracting anything, compare `python/src/coreai_models/models/macos/mistral.py` and `python/src/coreai_models/models/macos/qwen2.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 52 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: the declarations holding them bind `config` to `MistralConfig` in one and `SimpleNamespace` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (7 lines × 4) python/src/coreai_models/models/ios/mistral.py:53— python/src/coreai_models/models/ios/mistral.py:53-59 | python/src/coreai_models/models/ios/olmo2.py:57-63 | python/src/coreai_models/models/ios/qwen2.py:56-62 | python/src/coreai_models/models/ios/qwen3.py:58-64 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
Duplicated block (3–7 lines × 3) python/src/coreai_models/models/ios/sam3/detr.py:136— python/src/coreai_models/models/ios/sam3/detr.py:136-142 | python/src/coreai_models/models/ios/sam3/image_encoder.py:74-76 | python/src/coreai_models/models/ios/sam3/mask_decoder.py:177-183 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once.
Duplicated block (6 lines × 11) models/clap/export.py:122— models/clap/export.py:122-127 | models/clip/export.py:128-133 | models/depth-anything/export.py:126-131 | models/edsr/export.py:83-88 | models/efficient-sam/export.py:106-111 | models/pvt/export.py:81-86 | models/roberta/export.py:84-89 | models/t5/export.py:124-129 | models/wav2vec2/export.py:91-96 | models/whisper/export.py:89-94 | models/yolo/export.py:99-104 — `models/clap/export.py` and `models/clip/export.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 5 separate duplicated blocks between them, totalling at least 77 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
Duplicated block (6 lines × 5) python/src/coreai_models/models/ios/mistral.py:139— python/src/coreai_models/models/ios/mistral.py:139-144 | python/src/coreai_models/models/ios/olmo2.py:137-142 | python/src/coreai_models/models/ios/qwen2.py:142-147 | python/src/coreai_models/models/ios/qwen3.py:147-152 | python/src/coreai_models/models/macos/qwen3_vl.py:273-278 — before extracting anything, compare `python/src/coreai_models/models/ios/mistral.py` and `python/src/coreai_models/models/ios/olmo2.py` as WHOLE FILES: this scan already matched 12 separate duplicated blocks between them, totalling at least 199 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Note first that the copies are not typed on the same thing: `RMSNorm` names `coreai_models.primitives.ios.rms_norm` in one and `coreai_models.primitives.macos.rms_norm` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
Duplicated block (5 lines × 10) python/src/coreai_models/models/macos/gemma3_text.py:240— python/src/coreai_models/models/macos/gemma3_text.py:240-247 | python/src/coreai_models/models/macos/gpt_oss.py:422-429 | python/src/coreai_models/models/macos/mistral.py:158-165 | python/src/coreai_models/models/macos/mixtral.py:192-199 | python/src/coreai_models/models/macos/olmo2.py:158-162 | python/src/coreai_models/models/macos/phi3.py:221-228 | python/src/coreai_models/models/macos/qwen2.py:165-172 | python/src/coreai_models/models/macos/qwen3.py:176-183 | python/src/coreai_models/models/macos/qwen3_moe.py:224-231 | python/src/coreai_models/models/macos/qwen3_vl.py:182-189 — before extracting anything, compare `python/src/coreai_models/models/macos/gemma3_text.py` and `python/src/coreai_models/models/macos/mistral.py` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 58 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
Coverage not measured — Swift suite — Coverage NOT MEASURED: the Swift half could not be measured — the Swift suite in . produced no coverage export. Coverage is excluded from the score rather than counted as a near-zero. The named suite step is one the repository's maintainers can perform; once it passes, the real number is measured on the next scan. Alternatively, commit the lcov/Cobertura report your CI produces and it is read without a re-run.
Duplicated predicate python/src/coreai_models/diffusion/export.py:24— `(d / "REDACTED").exists() and (d / "python").exists()` appears character-identically in 4 files — python/src/coreai_models/diffusion/export.py, python/src/coreai_models/llm/export.py, python/src/coreai_models/segmentation/export.py, python/src/coreai_models/vlm/export.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/ios/mistral.py:184— `getattr(config, "head_dim", None) or config.hidden_size // config.num_attention_heads` appears character-identically in 2 files — python/src/coreai_models/models/ios/mistral.py, python/src/coreai_models/models/ios/olmo2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/ios/mistral.py:34— `getattr(config, "head_dim", None) or dim // n_heads` appears character-identically in 5 files — python/src/coreai_models/models/ios/mistral.py, python/src/coreai_models/models/ios/olmo2.py, python/src/coreai_models/models/macos/mistral.py, python/src/coreai_models/models/macos/olmo2.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/macos/mixtral.py:56— `hasattr(config, "head_dim") and config.head_dim is not None` appears character-identically in 3 files — python/src/coreai_models/models/macos/mixtral.py, python/src/coreai_models/primitives/macos/cache.py, python/src/coreai_models/primitives/macos/cache_scatter.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/ios/mistral.py:307— `k.startswith("model.") and "gather_embeddings" not in k` appears character-identically in 4 files — python/src/coreai_models/models/ios/mistral.py, python/src/coreai_models/models/ios/olmo2.py, python/src/coreai_models/models/ios/qwen2.py, python/src/coreai_models/models/ios/qwen3.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/macos/muse_glimmer.py:538— `key.startswith("layers.") or key.startswith("norm.") or key == "embed_tokens.weight"` appears character-identically in 2 files — python/src/coreai_models/models/macos/muse_glimmer.py, python/src/coreai_models/models/macos/qwen3_vl.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/models/base.py:590— `max_context_length is not None and hasattr(hf_config, "max_position_embeddings")` appears character-identically in 2 files — python/src/coreai_models/models/base.py, python/src/coreai_models/models/macos/phi3.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Duplicated predicate python/src/coreai_models/export/pipeline.py:99— `stem == base or stem.startswith(f"{base}_")` appears character-identically in 2 files — python/src/coreai_models/export/pipeline.py, python/src/coreai_models/model_registry.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 23 significant file(s) lose their only recent owner: swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift, swift/Sources/CoreAILanguageModels/Samplers/MPSGraphSamplers.swift, swift/Sources/Tools/llm-server/ChatHandler.swift, swift/Sources/CoreAILMCommon/ServerAPITypes.swift, swift/Sources/CoreAILanguageModels/Output/LogitsWriter.swift, swift/Sources/CoreAILanguageModels/InferenceEngines/InferenceEngine.swift, swift/Sources/CoreAILanguageModels/GuidedGeneration/ConstrainedGenerationSession.swift, swift/Sources/Tools/llm-server/ServerState.swift (+15 more). Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 6 significant file(s) lose their only recent owner: swift/Sources/CoreAISpeech/ParakeetTDTDecoder.swift, swift/Sources/Tools/speech-recognizer/SpeechParity.swift, swift/Sources/Tools/speech-recognizer/SpeechRecognizerMain.swift, swift/Sources/CoreAISpeech/SpeechRecognitionModel.swift, python/src/coreai_models/diffusion/flux2.py, swift/Sources/CoreAIShared/Text/CLIPTokenizer.swift. Pair on, review, or document these before any departure.
Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 3 significant file(s) lose their only recent owner: swift/Sources/CoreAILanguageModels/Profiling/PerformanceMetrics.swift, swift/Sources/CoreAIImageSegmenter/ImageSegmenter.swift, swift/Sources/CoreAIDiffusionPipeline/Components/CoreAILatentCodec.swift. Pair on, review, or document these before any departure.
D16 · Bus Factor· Further sole-owners (lower concentration) · ×1
Further sole-owners (lower concentration) — 3 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (35 single-owned of 232 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 232 of the 304 production source files in this repository met that bar). They are anonymized user #4 (1 file(s)), anonymized user #5 (1 file(s)), anonymized user #6 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above.
No ADRs found — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`.
D26 · Project Cohesion· Projects may be oversized for their cohesion · ×1
Projects may be oversized for their cohesion — 1 of 1 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (41319 LoC, 346 public types across 39 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D34 · Knowledge Freshness· Orphaned files with no living knowledge · ×1
Orphaned files with no living knowledge — 1 of 232 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated and example/demo trees and test files identified by path convention, largest first; 232 of the 304 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: swift/Sources/CoreAILanguageModels/InferenceEngines/InferenceOutputSequence.swift. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
M2 · Architecture documentation· No architecture diagram/doc · ×1
No architecture diagram/doc — No C4/Structurizr/PlantUML/Mermaid/Graphviz/D2 diagram, no drawn diagram named for the architecture, no file named `architecture` or `design` in any markup this check reads, and nothing in the README, docs or contributor guides that announces the shape — no `## Architecture` heading, no "architecture overview"/"high-level design" phrasing, no "the architecture is …" introduction, no guided code tour. A shape laid out in prose that never names itself as the architecture is not visible to this check, and neither is one kept outside the repository, so this row reports the absence of a re-findable shape document — not evidence that nobody wrote the shape down.
P1 · CI/CD gates· CI build step not evidenced · ×1
CI build step not evidenced — A CI pipeline exists but no build step was matched — changes may merge without the build ever running. A build step may be invoked directly as a command, or declared as a task that a runner named in the pipeline resolves.
No SAST — No static application security testing detected. For this repository's stack, add CodeQL's Swift pack (Swift/Xcode) (or `semgrep --config=auto`, which runs on any language) as a CI step. What was searched, so you can tell an absence from a miss: the 1583 CI workflow file(s) in this repository, and the scanner and linter configuration checked in beside them. A scan that runs outside CI, one configured in your forge's web UI rather than in a committed file, or a tool whose name is none of those this check carries, is not seen — if that is your case the row is wrong, and saying so is more useful than adding a second scanner.
No changelog — No CHANGELOG/HISTORY/RELEASES file — what shipped when isn't easy to reconstruct for support or audit. (Versioning/tagging makes releases traceable, but a changelog records the what.)
Skipped (documented): acceptsExactCount swift/Tests/DiffusionPipelineTests/InputValidationTests.swift:43— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): rejectsShortBuffer swift/Tests/DiffusionPipelineTests/InputValidationTests.swift:67— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): rejectsOversizedBuffer swift/Tests/DiffusionPipelineTests/InputValidationTests.swift:83— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): prepackRejectsMisSizedBuffer swift/Tests/DiffusionPipelineTests/InputValidationTests.swift:100— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): clipLMultiOutput swift/Tests/DiffusionPipelineTests/MultiOutputModelFunctionTests.swift:28— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): predictRejectsMultiOutputAsset swift/Tests/DiffusionPipelineTests/MultiOutputModelFunctionTests.swift:62— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): textEncoderPooledOutputPresent swift/Tests/DiffusionPipelineTests/MultiOutputModelFunctionTests.swift:86— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): incrementalSpeedup swift/Tests/LanguageModelsTests/InputHandlerHarnessTests.swift:550— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Skipped (documented): minMaxTracking swift/Tests/LanguageModelsTests/ProfileSpanTests.swift:70— Skipped with a documented reason — a deferral, not lazy debt: conditionally enabled — runs only when its .enabled(if:) condition holds
Outdated: hummingbird — `hummingbird` is resolved at 2.22.0, but 2.27.0 is the newest release tagged on https://github.com/hummingbird-project/hummingbird within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update hummingbird` reaches this one with no change to Package.swift.
Outdated: swift-argument-parser — `swift-argument-parser` is resolved at 1.7.0, but 1.8.2 is the newest release tagged on https://github.com/apple/swift-argument-parser within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-argument-parser` reaches this one with no change to Package.swift.
Outdated: swift-transformers — `swift-transformers` is resolved at 1.2.0, but 1.3.4 is the newest release tagged on https://github.com/huggingface/swift-transformers within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update swift-transformers` reaches this one with no change to Package.swift.
Outdated: xgrammar — `xgrammar` is resolved at 0.2.2, but 0.2.8 is the newest release tagged on https://github.com/mlc-ai/xgrammar within the same major. SwiftPM resolves from git tags, and a `from:` requirement admits every release below the next major — so `swift package update xgrammar` reaches this one with no change to Package.swift.
Appendix B — Reproduction & audit trail
Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.
trivy: not applicable — No Infrastructure-as-Code or container manifests found (Dockerfile, Docker Compose, Terraform, Kubernetes/Helm, CloudFormation, ARM, Bicep, Ansible); nothing to scan.
semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 39 file(s) — `swift/Sources/CoreAIDiffusionPipeline/Pipelines/FlowTransformerPipeline+Resources.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedDecodingStrategy.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/ConstrainedGenerator.swift`, `swift/Sources/CoreAILanguageModels/DecodingStrategies/VanillaDecodingStrategy.swift`, `swift/Sources/CoreAILanguageModels/GuidedGeneration/ConstrainedGenerationSession.swift`, … (+34 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.
disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
Run 01a0f6d3-aedf-7097-b255-9e67f7b53709 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 7 · Warnings: 428 · Recommendations: 21 · Info: 13 — Appendix A · all findings · full markdown report.
Generated by Watchdog — deterministic code-health analysis. 01-10-2026 @ 09:37 UTC.
Downloadable artifacts
Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.