margin-ai-code-detector 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/.gitignore +5 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/CHANGELOG.md +6 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/PKG-INFO +1 -1
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/tools/find_ai_candidates.py +1 -1
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/pyproject.toml +1 -1
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/__init__.py +1 -1
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/agent.py +1 -1
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/aggregate.py +13 -5
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_aggregate.py +9 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_detector.py +2 -2
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/LICENSE +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/README.md +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/dataset.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v0/README.md +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v0/manifest.jsonl +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/README.md +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/build.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/manifest.jsonl +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/sources/ai_javascript.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/sources/ai_python.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/sources/human_javascript_pre2021.jsonl +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/sources/human_python_gentoo_post2023.jsonl +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/sources/human_python_pre2021.jsonl +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/fit.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/metrics.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/judge_comparison_train.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/judge_comparison_train_v2.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/v0.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/v1_dev_judge_qwen3.5-9b.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/v1_dev_methodology_v0.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/v1_final_methodology-v1_judge-qwen3.5-9b.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/results/v1_final_methodology-v1_signals-only.json +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/run.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/tools/compare_judges.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/tools/pin_before.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/llm_judge.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/prompts/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/prompts/judge_v1.md +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/prompts/judge_v2.md +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/judge/sampler.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/markers/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/markers/v1.toml +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/methodology/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/methodology/v0.toml +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/methodology/v1.toml +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/models.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/pipeline.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/py.typed +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/report.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/base.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/file.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/repo.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/source/__init__.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/source/javascript.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/source/python.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/conftest.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/ai_style.py.txt +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/ai_style.ts.txt +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/human_style.js.txt +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/human_style.py.txt +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_eval.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_judge.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_markers.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_report.py +0 -0
- {margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/test_signals.py +0 -0
|
@@ -75,6 +75,11 @@ tmp/
|
|
|
75
75
|
|
|
76
76
|
# Private planning notes (kept locally, not published)
|
|
77
77
|
PLAN.md
|
|
78
|
+
# notes for Claude Code sessions; a CLAUDE.md in the repo is one of the detector's markers
|
|
79
|
+
CLAUDE.md
|
|
78
80
|
|
|
79
81
|
# the web UI bundled into margin-api at release time (scripts/build_release.py)
|
|
80
82
|
packages/api/src/margin_api/ui/
|
|
83
|
+
|
|
84
|
+
# local agent plugins and state
|
|
85
|
+
.agents/
|
|
@@ -4,6 +4,12 @@ All notable changes to this agent are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
5
|
[Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.2.2] - 2026-11-20
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- The confidence reasons count in plain words: "only 1 file could be analysed", "1 kind of
|
|
11
|
+
signal", and "no kind of signal gave any evidence" instead of "0 kind(s) of signals".
|
|
12
|
+
|
|
7
13
|
## [0.2.1] - 2026-10-21
|
|
8
14
|
|
|
9
15
|
### Security
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: margin-ai-code-detector
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Estimates how likely a codebase was written with AI assistance, as a range with the evidence for and against.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Waddah0-0/margin
|
|
6
6
|
Project-URL: Source, https://github.com/Waddah0-0/margin/tree/main/agents/ai_code_detector
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/tools/find_ai_candidates.py
RENAMED
|
@@ -61,7 +61,7 @@ def search_repos(query: str, pages: int) -> list[str]:
|
|
|
61
61
|
url = "https://api.github.com/search/commits?per_page=100&sort=committer-date&page="
|
|
62
62
|
url += f"{page}&q=" + urllib.parse.quote(query)
|
|
63
63
|
headers = {"Accept": "application/vnd.github+json", "User-Agent": "margin-eval"}
|
|
64
|
-
secret = get_settings().github_token # GITHUB_TOKEN env var or
|
|
64
|
+
secret = get_settings().github_token # GITHUB_TOKEN env var or MARGIN_ENV_FILE
|
|
65
65
|
token = secret.get_secret_value() if secret else None
|
|
66
66
|
if token:
|
|
67
67
|
headers["Authorization"] = f"Bearer {token}"
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/agent.py
RENAMED
|
@@ -21,7 +21,7 @@ class AICodeDetector(BaseAgent):
|
|
|
21
21
|
"Estimates how likely a repository was written with AI assistance, as a range with a "
|
|
22
22
|
"confidence level and the evidence for and against."
|
|
23
23
|
)
|
|
24
|
-
version = "0.2.
|
|
24
|
+
version = "0.2.2"
|
|
25
25
|
InputModel = DetectorInput
|
|
26
26
|
OutputModel = DetectorOutput
|
|
27
27
|
primary_input = "target"
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/aggregate.py
RENAMED
|
@@ -15,6 +15,11 @@ from ai_code_detector.methodology import Methodology
|
|
|
15
15
|
from ai_code_detector.models import Confidence, FileScore, SignalHit
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
def _count(n: int, one: str, many: str) -> str:
|
|
19
|
+
"""'1 file', '3 files'."""
|
|
20
|
+
return f"{n} {one if n == 1 else many}"
|
|
21
|
+
|
|
22
|
+
|
|
18
23
|
def sigmoid(x: float) -> float:
|
|
19
24
|
return 1.0 / (1.0 + math.exp(-x))
|
|
20
25
|
|
|
@@ -152,10 +157,11 @@ def confidence_level(
|
|
|
152
157
|
c = methodology.section("confidence")
|
|
153
158
|
high_checks = [
|
|
154
159
|
(facts.families >= c["high_families"],
|
|
155
|
-
f"evidence came from {facts.families
|
|
156
|
-
f"{c['high_families']})"),
|
|
160
|
+
f"evidence came from {_count(facts.families, 'kind', 'kinds')} of signals (high "
|
|
161
|
+
f"confidence needs {c['high_families']})"),
|
|
157
162
|
(facts.files >= c["high_files"],
|
|
158
|
-
f"{facts.files
|
|
163
|
+
f"{_count(facts.files, 'file', 'files')} could be analysed (high confidence needs "
|
|
164
|
+
f"{c['high_files']})"),
|
|
159
165
|
(facts.width <= c["high_max_width"],
|
|
160
166
|
f"the range is {facts.width:.2f} wide (high confidence needs "
|
|
161
167
|
f"at most {c['high_max_width']})"),
|
|
@@ -164,8 +170,10 @@ def confidence_level(
|
|
|
164
170
|
] # fmt: skip
|
|
165
171
|
medium_checks = [
|
|
166
172
|
(facts.families >= c["medium_families"],
|
|
167
|
-
f"evidence came from only {facts.families
|
|
168
|
-
|
|
173
|
+
f"evidence came from only {_count(facts.families, 'kind', 'kinds')} of signal"
|
|
174
|
+
if facts.families else "no kind of signal gave any evidence"),
|
|
175
|
+
(facts.files >= c["medium_files"],
|
|
176
|
+
f"only {_count(facts.files, 'file', 'files')} could be analysed"),
|
|
169
177
|
(facts.width <= c["medium_max_width"], f"the range is wide ({facts.width:.2f})"),
|
|
170
178
|
] # fmt: skip
|
|
171
179
|
uncalibrated = (
|
|
@@ -68,6 +68,15 @@ def test_confidence_levels() -> None:
|
|
|
68
68
|
assert level == "low" and len(reasons) == 3
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
def test_confidence_reasons_count_in_plain_words() -> None:
|
|
72
|
+
_, reasons = confidence_level(ConfidenceFacts(0, 1, 0.8, 0.9), M)
|
|
73
|
+
assert "no kind of signal gave any evidence" in reasons
|
|
74
|
+
assert "only 1 file could be analysed" in reasons
|
|
75
|
+
_, reasons = confidence_level(ConfidenceFacts(1, 2, 0.8, 0.9), M)
|
|
76
|
+
assert "evidence came from only 1 kind of signal" in reasons
|
|
77
|
+
assert "only 2 files could be analysed" in reasons
|
|
78
|
+
|
|
79
|
+
|
|
71
80
|
def test_repo_model_parameters_default_to_v0_behaviour() -> None:
|
|
72
81
|
files = [file(0.8), file(0.6)]
|
|
73
82
|
assert M.repo_intercept == 0.0 and M.repo_file_coefficient == 1.0
|
|
@@ -107,7 +107,7 @@ async def test_frozen_smoke_scores(ai_repo: Path, human_repo: Path) -> None:
|
|
|
107
107
|
"""CI regression guard: methodology v0 scores for the fixtures must not drift silently."""
|
|
108
108
|
ai = (await detect(ai_repo))["data"]
|
|
109
109
|
human = (await detect(human_repo))["data"]
|
|
110
|
-
assert ai["methodology_version"] == "detector-0.2.
|
|
110
|
+
assert ai["methodology_version"] == "detector-0.2.2+methodology-v0+markers-v1"
|
|
111
111
|
assert (round(ai["estimate"], 2), round(human["estimate"], 2)) == (SMOKE["ai"], SMOKE["human"])
|
|
112
112
|
|
|
113
113
|
|
|
@@ -145,7 +145,7 @@ async def test_javascript_and_typescript_repositories(tmp_path: Path) -> None:
|
|
|
145
145
|
async def test_v1_without_a_model_falls_back_to_signals_with_low_confidence(ai_repo: Path) -> None:
|
|
146
146
|
data = (await detect(ai_repo, methodology="v1"))["data"]
|
|
147
147
|
result = (await detect(ai_repo, methodology="v1"))["result"]
|
|
148
|
-
assert data["methodology_version"] == "detector-0.2.
|
|
148
|
+
assert data["methodology_version"] == "detector-0.2.2+methodology-v1+markers-v1"
|
|
149
149
|
assert data["confidence"] == "low"
|
|
150
150
|
assert "LLM judge did not run" in data["confidence_reasons"][0]
|
|
151
151
|
assert result.status == "ok" # auto mode: no model is not a failure
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v0/manifest.jsonl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/datasets/v1/manifest.jsonl
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/eval/tools/compare_judges.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/markers/v1.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/models.py
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/pipeline.py
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/py.typed
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/report.py
RENAMED
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/base.py
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/file.py
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/src/ai_code_detector/signals/repo.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/ai_style.py.txt
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/ai_style.ts.txt
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/human_style.js.txt
RENAMED
|
File without changes
|
{margin_ai_code_detector-0.2.1 → margin_ai_code_detector-0.2.2}/tests/fixtures/human_style.py.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|