Repository Analysis

google/magika

Fast and accurate AI powered file content types detection

4.9 Likely human-written View on GitHub

Analysis Overview

This report presents the forensic synthetic code analysis of google/magika, a Python project with 17,249 GitHub stars. SynthScan v2.0 examined 52,163 lines of code across 318 source files, recording 243 pattern matches distributed across 10 syntactic categories. The overall adjusted score of 4.9 places this repository in the Likely human-written band.

The scanner applied 160+ deterministic lexical heuristics, multi-line block detectors, abstract syntax tree depth profilers, and a cross-file Jaccard similarity matrix to construct a statistically normalised synthetic code estimate. All matches are individually weighted by severity coefficient and contextual multiplier before summation, and the resulting headline score is temporally discounted to account for the repository's development history relative to the commercial emergence of large language model coding tooling (November 2022 onward).

4.9
Adjusted Score
4.9
Raw Score
100%
Time Factor
2026-06-23
Last Push
17.2K
Stars
Python
Language
52.2K
Lines of Code
318
Files
243
Pattern Hits
2026-07-14
Scan Date
0.00
HC Hit Rate

What These Metrics Mean

Adjusted Score
Primary synthetic code indicator. Raw score normalised per 1,000 lines of code and multiplied by the temporal discount factor. This is the definitive comparative metric — use it to rank repositories by AI authorship density.
Raw Score
The unmodified sum of all severity-weighted, context-multiplied pattern match scores before temporal discounting. Reflects the absolute signal strength independent of when the repository was last active.
Time Factor
The temporal discount multiplier (0–100%) applied to the raw score. Repositories last updated before ChatGPT's launch (Nov 2022) receive a 5% factor. Full signal is only assigned to repositories active in the post-adoption era (Jan 2024+).
Pattern Hits
Total count of individual pattern matches across all files and categories. A high hit count with a low score may indicate a very large codebase with isolated AI snippets; a low count with a high score indicates dense, concentrated AI signatures.
HC Hit Rate
High+Critical pattern hits per file, averaged across the repository. This orthogonal signal catches repositories where a few files are densely packed with high-severity AI tells — a strong indicator even when the normalised score appears moderate due to codebase size.
Lines of Code / Files
Total lines and files analysed. The scanner examines 94 file extensions. These denominators are used to normalise the score, enabling fair comparison between repositories of vastly different sizes.

Score History

This chart maps the temporal evolution of the adjusted synthetic code score across successive scan runs. An upward trajectory indicates ongoing incorporation of AI-generated code or expanding LLM-assisted scaffolding; a stable or declining trajectory may reflect active human refactoring, code removal, or the adoption of stricter authorship policies. The dashed secondary line (right axis) independently tracks total raw pattern hit count, which can diverge from the normalised score when codebase size changes significantly between scans.

Severity Breakdown

Classifies detected patterns by their diagnostic confidence and structural impact. CRITICAL patterns (coefficient 10) represent definitive synthetic signatures — hallucinated imports, explicit LLM attribution metadata — virtually never produced by human authors. HIGH (5) indicates strong structural tells such as cross-file repetition or cross-linguistic idioms. MEDIUM (2) covers recognisable conversational padding and AI-specific vocabulary. LOW (1) captures subtle indicators like tautological comments and generic boilerplate that require density to carry independent signal.

CRITICAL 0HIGH 0MEDIUM 4LOW 239

Directory Score Breakdown

This horizontal bar chart decomposes the repository's raw synthetic code score by top-level directory, allowing you to pinpoint precisely which modules or components carry the highest AI authorship density. Directories with disproportionately high scores relative to their size warrant targeted manual review: concentrated AI signatures often trace back to mass-generated configuration layers, auto-ported test suites, LLM-scaffolded boilerplate classes, or entire subsystems authored under heavy copilot assistance. Use this view to prioritise your human code-review effort.

Pattern Findings

The scanner identified 243 distinct pattern matches across 10 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a statistically significant AI authorship indicator. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.

Reading the findings table: The Severity column indicates the diagnostic confidence level (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — comment-context matches receive a ×1.5 weight because LLMs systematically over-annotate. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier as dense clusters constitute far stronger evidence of synthetic authorship than isolated hits.

Hyper-Verbose Identifiers94 hits · 98 pts
SeverityFileLineSnippetContext
LOWpython/tests/test_features_extraction_vs_reference.py59def test_features_extraction_vs_reference(debug: bool = False) -> None:CODE
LOWpython/tests/test_features_extraction_vs_reference.py81def test_reference_generation() -> None:CODE
LOWpython/tests/test_features_extraction_vs_reference.py85def _generate_reference_features_extraction(test_mode: bool) -> None:CODE
LOWpython/tests/test_features_extraction_vs_reference.py92def _dump_reference_features_extraction_examples(CODE
LOWpython/tests/test_features_extraction_vs_reference.py114def _generate_reference_features_extraction_tests_cases() -> List[CODE
LOWpython/tests/test_features_extraction_vs_reference.py145def _generate_reference_features_extraction_tests_cases_inputs() -> List[CODE
LOWpython/tests/test_features_extraction_vs_reference.py211def _generate_content_from_metadata(CODE
LOWpython/tests/test_features_extraction_vs_reference.py238def _get_examples_from_reference() -> List[FeaturesExtractionExample]:CODE
LOWpython/tests/test_features_extraction_vs_reference.py253def _check_features_vs_reference_example_features(CODE
LOWpython/tests/test_magika_python_module.py76def test_magika_module_with_basic_tests_by_paths() -> None:CODE
LOWpython/tests/test_magika_python_module.py84def test_magika_module_with_basic_tests_by_path() -> None:CODE
LOWpython/tests/test_magika_python_module.py94def test_magika_module_with_basic_tests_by_bytes() -> None:CODE
LOWpython/tests/test_magika_python_module.py36def test_magika_module_check_version() -> None:CODE
LOWpython/tests/test_magika_python_module.py50def test_magika_module_with_one_test_file() -> None:CODE
LOWpython/tests/test_magika_python_module.py63def test_magika_module_with_explicit_model_dir() -> None:CODE
LOWpython/tests/test_magika_python_module.py107def test_magika_module_with_basic_tests_by_stream() -> None:CODE
LOWpython/tests/test_magika_python_module.py120def test_magika_module_with_all_models() -> None:CODE
LOWpython/tests/test_magika_python_module.py131def test_magika_module_with_previously_missdetected_samples() -> None:CODE
LOWpython/tests/test_magika_python_module.py140def test_magika_module_with_empty_content() -> None:CODE
LOWpython/tests/test_magika_python_module.py170def test_magika_module_with_short_content() -> None:CODE
LOWpython/tests/test_magika_python_module.py208def test_magika_module_with_python_and_non_python_content() -> None:CODE
LOWpython/tests/test_magika_python_module.py225def test_magika_module_identify_stream_does_not_alter_position() -> None:CODE
LOWpython/tests/test_magika_python_module.py245def test_magika_module_with_whitespaces() -> None:CODE
LOWpython/tests/test_magika_python_module.py302def test_magika_module_with_different_prediction_modes() -> None:CODE
LOWpython/tests/test_magika_python_module.py401def test_magika_module_overwrite_reason() -> None:CODE
LOWpython/tests/test_magika_python_module.py470def test_magika_module_with_directory() -> None:CODE
LOWpython/tests/test_magika_python_module.py483def test_magika_module_multiple_copies_of_the_same_file() -> None:CODE
LOWpython/tests/test_magika_python_module.py499def test_magika_module_with_symlink() -> None:CODE
LOWpython/tests/test_magika_python_module.py528def test_magika_module_with_non_existing_file() -> None:CODE
LOWpython/tests/test_magika_python_module.py540def test_magika_module_with_permission_error() -> None:CODE
LOWpython/tests/test_magika_python_module.py573def test_magika_module_with_really_many_files() -> None:CODE
LOWpython/tests/test_magika_python_module.py588def test_magika_module_with_big_file() -> None:CODE
LOWpython/tests/test_magika_python_module.py612def test_api_call_with_bad_types() -> None:CODE
LOWpython/tests/test_magika_python_module.py645def test_access_magika_result_and_prediction():CODE
LOWpython/tests/test_magika_python_module.py692def test_access_backward_compatibility_layer() -> None:CODE
LOWpython/tests/test_magika_python_module.py721def test_get_model_and_output_content_types() -> None:CODE
LOWpython/tests/test_magika_python_module.py795def get_expected_content_type_label_from_test_file_path(CODE
LOWpython/tests/test_magika_python_module.py801def check_result_vs_expected_result(CODE
LOWpython/tests/test_magika_python_module.py812def check_results_vs_expected_results(CODE
LOWpython/tests/utils.py39def get_basic_tests_files_dir() -> Path:CODE
LOWpython/tests/utils.py45def get_mitra_tests_files_dir() -> Path:CODE
LOWpython/tests/utils.py51def get_previously_missdetected_files_dir() -> Path:CODE
LOWpython/tests/utils.py57def get_basic_test_files_paths() -> List[Path]:CODE
LOWpython/tests/utils.py63def get_mitra_test_files_paths() -> List[Path]:CODE
LOWpython/tests/utils.py69def get_previously_missdetected_files_paths() -> List[Path]:CODE
LOWpython/tests/utils.py75def get_reference_features_extraction_examples_path() -> Path:CODE
LOWpython/tests/utils.py79def get_reference_for_inference_examples_by_path_path(model_name: str) -> Path:CODE
LOWpython/tests/utils.py87def get_reference_for_inference_examples_by_content_path(model_name: str) -> Path:CODE
LOWpython/tests/utils.py95def get_one_basic_test_file_path() -> Path:CODE
LOWpython/tests/utils.py123def write_random_file_with_size(sample_path: Path, sample_size: int) -> None:CODE
LOWpython/tests/utils.py177def get_imported_objects_after_wildcard() -> Dict[str, Any]:CODE
LOWpython/tests/test_python_magika_client.py19def test_python_magika_client() -> None:CODE
LOWpython/tests/test_inference_vs_reference.py63def test_inference_vs_reference(debug: bool = False) -> None:CODE
LOWpython/tests/test_inference_vs_reference.py129def test_reference_generation() -> None:CODE
LOWpython/tests/test_inference_vs_reference.py175def _generate_reference_for_inference(test_mode: bool) -> None:CODE
LOWpython/tests/test_inference_vs_reference.py183def _generate_examples_by_path(CODE
LOWpython/tests/test_inference_vs_reference.py226def _generate_examples_by_content(CODE
LOWpython/tests/test_inference_vs_reference.py367def _dump_examples_by_content(CODE
LOWpython/tests/test_inference_vs_reference.py476 def _get_cornern_case_example(CODE
LOWpython/tests/test_inference_vs_reference.py526 def get_corner_case_candidates_generator(CODE
34 more matches not shown…
Over-Commented Block92 hits · 92 pts
SeverityFileLineSnippetContext
LOWpython/tests/test_features_extraction_vs_reference.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/tests/test_magika_python_module.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/tests/utils.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/tests/test_python_magika_client.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/tests/test_inference_vs_reference.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/scripts/sync.py1#!/usr/bin/env python3COMMENT
LOWpython/scripts/sync.py121 python_model_dir = PYTHON_MODELS_DIR / model_nameCOMMENT
LOWpython/scripts/sync.py181 + "\n"COMMENT
LOWpython/scripts/check_copyright.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/scripts/run_quick_test_magika_module.py1#!/usr/bin/env pythonCOMMENT
LOWpython/scripts/check_source.sh1#!/bin/bashCOMMENT
LOWpython/scripts/check_changelog.sh1#!/bin/bashCOMMENT
LOWpython/scripts/pre_release_check.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/scripts/test_magika_model.py1#!/usr/bin/env python3COMMENT
LOWpython/scripts/run_quick_test_magika_cli.py1#!/usr/bin/env pythonCOMMENT
LOWpython/scripts/generate_reference.py1# Copyright 2025 Google LLCCOMMENT
LOW…hon/scripts/prepare_pyproject_for_pure_python_wheel.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/scripts/check_documentation.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/src/magika/magika.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/__init__.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/logger.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/colors.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/prediction_mode.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/magika_error.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/src/magika/types/content_type_info.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/src/magika/types/__init__.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/model.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/content_type_label.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/overwrite_reason.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/magika_prediction.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/magika_result.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/seekable.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/types/strenum.py1# Copyright 2025 Google LLCCOMMENT
LOWpython/src/magika/types/status.py1# Copyright 2024 Google LLCCOMMENT
LOWpython/src/magika/cli/magika_client.py1#!/usr/bin/env python3COMMENT
LOW…src/magika/cli/magika_rust_client_not_found_warning.py1#!/usr/bin/env pythonCOMMENT
LOWjs/magika-cli.ts1#! /usr/bin/env nodeCOMMENT
LOWjs/magika-node.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/magika.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/tfnHook.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/magika-cli.test.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/inference-vs-reference.test.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/utils.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/features-extraction-vs-reference.test.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/test/magika.test.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model-prediction.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/content-type-info.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/status.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/magika-prediction.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model-node.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/magika-result.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/overwrite-reason.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/content-types-infos.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/prediction-mode.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/magika-options.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/content-type-label.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model-config-node.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model-features.ts1// Copyright 2024 Google LLCCOMMENT
LOWjs/src/model-config.ts1// Copyright 2024 Google LLCCOMMENT
32 more matches not shown…
Unused Imports28 hits · 28 pts
SeverityFileLineSnippetContext
LOWpython/tests/test_features_extraction_vs_reference.py15CODE
LOWpython/tests/test_inference_vs_reference.py15CODE
LOWpython/scripts/check_documentation.py18CODE
LOWpython/src/magika/__init__.py20CODE
LOWpython/src/magika/__init__.py21CODE
LOWpython/src/magika/__init__.py22CODE
LOWpython/src/magika/__init__.py23CODE
LOWpython/src/magika/__init__.py24CODE
LOWpython/src/magika/__init__.py25CODE
LOWpython/src/magika/__init__.py26CODE
LOWpython/src/magika/__init__.py27CODE
LOWpython/src/magika/__init__.py28CODE
LOWpython/src/magika/logger.py17CODE
LOWpython/src/magika/types/prediction_mode.py17CODE
LOWpython/src/magika/types/__init__.py18CODE
LOWpython/src/magika/types/__init__.py19CODE
LOWpython/src/magika/types/__init__.py20CODE
LOWpython/src/magika/types/__init__.py21CODE
LOWpython/src/magika/types/__init__.py22CODE
LOWpython/src/magika/types/__init__.py23CODE
LOWpython/src/magika/types/__init__.py23CODE
LOWpython/src/magika/types/__init__.py23CODE
LOWpython/src/magika/types/__init__.py28CODE
LOWpython/src/magika/types/__init__.py29CODE
LOWpython/src/magika/types/__init__.py30CODE
LOWpython/src/magika/types/__init__.py31CODE
LOWpython/src/magika/types/magika_prediction.py17CODE
LOWpython/src/magika/types/strenum.py26CODE
Fake / Example Data7 hits · 9 pts
SeverityFileLineSnippetContext
LOWtests_data/basic/txt/lorem-small.txt2Lorem ipsum dolor sit amet, consectetur adipiscing elit. Collatio igitur ista te nihil iuvat. Honesta oratio, Socratica,CODE
LOWtests_data/basic/txt/lorem-small.txt2Lorem ipsum dolor sit amet, consectetur adipiscing elit. Collatio igitur ista te nihil iuvat. Honesta oratio, Socratica,CODE
LOWtests_data/basic/txt/lorem-big.txt1Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquam dui sit amet justo eleifend ullamcorper. Class CODE
LOWtests_data/basic/txt/lorem-big.txt1Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer aliquam dui sit amet justo eleifend ullamcorper. Class CODE
LOWtests_data/basic/txt/lorem-big.txt7Ut eleifend lectus et ullamcorper interdum. Sed laoreet, quam at placerat viverra, ipsum erat rhoncus dolor, sit amet elCODE
LOWtests_data/basic/txt/lorem-big.txt7Ut eleifend lectus et ullamcorper interdum. Sed laoreet, quam at placerat viverra, ipsum erat rhoncus dolor, sit amet elCODE
LOWtests_data/basic/markdown/simple.md9Lorem ipsum?CODE
Excessive Try-Catch Wrapping5 hits · 7 pts
SeverityFileLineSnippetContext
MEDIUMpython/CHANGELOG.md82 print(f"Error: {result.status}")CODE
LOWpython/scripts/pre_release_check.py81 except Exception:CODE
LOWpython/scripts/pre_release_check.py174 except Exception:CODE
LOWpython/scripts/run_quick_test_magika_cli.py52 except Exception as e:CODE
MEDIUMwebsite-ng/src/content/docs/cli-and-bindings/python.md92... print(f"Error: {result.status.message}")CODE
Deep Nesting7 hits · 7 pts
SeverityFileLineSnippetContext
LOWpython/scripts/run_quick_test_magika_module.py35CODE
LOWpython/scripts/pre_release_check.py147CODE
LOWpython/scripts/run_quick_test_magika_cli.py37CODE
LOWpython/scripts/check_documentation.py165CODE
LOWpython/scripts/check_documentation.py222CODE
LOWpython/src/magika/magika.py578CODE
LOWpython/src/magika/cli/magika_client.py133CODE
Self-Referential Comments2 hits · 6 pts
SeverityFileLineSnippetContext
MEDIUMpython/src/magika/magika.py588 # The following code checks whether the score is "high enough", whereCOMMENT
MEDIUM.github/workflows/cli-release.yml270 # Create a GitHub Release while uploading all files to itCOMMENT
Modern Structural Boilerplate5 hits · 4 pts
SeverityFileLineSnippetContext
LOWpython/scripts/sync.py107def update_python_content_type_kb() -> None:CODE
LOWpython/scripts/sync.py154def update_python_content_type_label_py() -> None:STRING
LOWpython/scripts/sync.py218def update_js_content_type_files() -> None:STRING
LOWpython/src/magika/__init__.py36__all__ = [CODE
LOWpython/src/magika/types/__init__.py33__all__ = [CODE
Redundant / Tautological Comments2 hits · 3 pts
SeverityFileLineSnippetContext
LOWpython/scripts/pre_release_check.py166 # Check if it is a python scriptCOMMENT
LOWpython/src/magika/magika.py234 # Check if we would overwrite this target label; if not, use theCOMMENT
AI Structural Patterns1 hit · 1 pts
SeverityFileLineSnippetContext
LOWpython/src/magika/cli/magika_client.py346CODE