2026-07-06 05:58:46 +02:00
|
|
|
# retoor <retoor@molodetz.nl>
|
|
|
|
|
|
|
|
|
|
from devplacepy.services.jobs.isslop.agent.classifier import AiVerdict
|
|
|
|
|
from devplacepy.services.jobs.isslop.agent.reporter import _summary_payload, fallback_report
|
|
|
|
|
from devplacepy.services.jobs.isslop.analysis.templates import TemplateEvidence
|
|
|
|
|
from devplacepy.services.jobs.isslop.analysis.scoring import FileScore, aggregate
|
|
|
|
|
from devplacepy.services.jobs.isslop.pipeline import apply_ai_verdicts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _file(relative, sloc, origin, quality=10.0):
|
|
|
|
|
return FileScore(
|
|
|
|
|
relative=relative,
|
|
|
|
|
language="python",
|
|
|
|
|
sloc=sloc,
|
|
|
|
|
origin_score=origin,
|
|
|
|
|
quality_deficit=quality,
|
|
|
|
|
category="human-clean",
|
|
|
|
|
criticality=1.0,
|
|
|
|
|
signals=[],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _verdict(path, probability):
|
|
|
|
|
return AiVerdict(
|
|
|
|
|
path=path,
|
|
|
|
|
origin_score=probability,
|
|
|
|
|
quality_deficit=10.0,
|
|
|
|
|
ai_probability=probability,
|
|
|
|
|
category="uncertain",
|
|
|
|
|
reasoning="",
|
|
|
|
|
notable_signals=[],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_apply_ai_verdicts_only_touches_reviewed_files():
|
|
|
|
|
scores = [_file("a.py", 500, 20.0), _file("b.py", 500, 20.0)]
|
|
|
|
|
adjusted = apply_ai_verdicts(scores, [_verdict("a.py", 80.0)])
|
|
|
|
|
assert adjusted[0].origin_score == round(0.6 * 20.0 + 0.4 * 80.0, 1)
|
|
|
|
|
assert adjusted[1].origin_score == 20.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hedging_verdicts_cannot_dominate_a_large_repo():
|
|
|
|
|
scores = [_file(f"f{i}.py", 200, 15.0) for i in range(100)]
|
|
|
|
|
verdicts = [_verdict(f"f{i}.py", 40.0) for i in range(12)]
|
|
|
|
|
static = aggregate(scores)
|
|
|
|
|
final = aggregate(apply_ai_verdicts(scores, verdicts))
|
|
|
|
|
assert static.ai_percent == 0.0
|
|
|
|
|
assert final.ai_percent < 5.0
|
|
|
|
|
assert final.human_percent > 95.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_strong_verdict_on_heavy_file_moves_the_verdict():
|
|
|
|
|
scores = [_file("huge.py", 5000, 30.0)] + [_file(f"s{i}.py", 50, 15.0) for i in range(10)]
|
|
|
|
|
final = aggregate(apply_ai_verdicts(scores, [_verdict("huge.py", 95.0)]))
|
|
|
|
|
static = aggregate(scores)
|
|
|
|
|
assert final.ai_percent > static.ai_percent + 30.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_report_payload_grade_matches_final_scores():
|
|
|
|
|
scores = [_file("a.py", 300, 60.0, 40.0), _file("b.py", 200, 20.0)]
|
|
|
|
|
verdicts = [_verdict("a.py", 90.0)]
|
|
|
|
|
adjusted = apply_ai_verdicts(scores, verdicts)
|
|
|
|
|
final = aggregate(adjusted)
|
Report every test failure in one pass and fix the whole suite
The suite ran with -x, so a run stopped at the first failure and finding N
failures cost N full runs. Move -rf into the pytest addopts so every run
lists each failure, and add the triage targets test-fast (unit + api, no
browser), test-failed (--last-failed), test-first-failure (the old -x),
test-slowest and test-cache-clean. A stale .pytest_cache holding node ids
from deleted files made --last-failed select everything; make clean and
test-cache-clean drop it.
Fix the fifteen failures this surfaced.
DeepSearch crawling raised AttributeError in its finally block on every run:
async_playwright().__aenter__() returns a Playwright, which has no __aexit__.
Use start()/stop() at both call sites.
Update the tests left behind by changed signatures: VectorStore is async now,
fetch_page takes a browser, _summary_payload takes dom_evidence, and the
messages/notifications page compounds take a user_uid.
Close four real flakes that fail-fast had been hiding, all of them late in
the run. Harvest assertions pinned crop.reward_coins while is_golden pays
five times on about five percent of harvests, so they now assert through
realizable_harvest_coins with the observed golden flag. Market saturation
fixtures assumed a single active farm and landed two tiers milder once the
api and e2e tiers had created farms, so they scale by active_farms(). The
primary-administrator container test raced the one second cross-worker cache
version window and now waits for the server to agree. The isslop tools test
matched the collapsed nav dropdown link instead of the tools grid card.
Stop burning ninety seconds waiting out server-side display caches:
DEVPLACE_RANKING_TTL and DEVPLACE_MARKET_SATURATION_TTL follow the existing
sitemap and home cache precedent and are zero for the suite, taking the
leaderboard test from 60.6s to 4.4s and the saturation test from 30.1s to
under a second.
2881 passed, 1 skipped in 15:13.
2026-07-26 16:02:36 +02:00
|
|
|
payload = _summary_payload(
|
|
|
|
|
"https://x.example/repo",
|
|
|
|
|
"git",
|
|
|
|
|
final,
|
|
|
|
|
adjusted,
|
|
|
|
|
verdicts,
|
|
|
|
|
0,
|
|
|
|
|
[],
|
|
|
|
|
{},
|
|
|
|
|
TemplateEvidence(),
|
|
|
|
|
None,
|
|
|
|
|
)
|
2026-07-06 05:58:46 +02:00
|
|
|
assert payload["repo_scores"]["grade"] == final.grade
|
|
|
|
|
assert payload["repo_scores"]["human_percent"] == final.human_percent
|
|
|
|
|
markdown = fallback_report(payload)
|
|
|
|
|
assert f"grade **{final.grade}**" in markdown
|
|
|
|
|
assert f"**{final.human_percent}% human**" in markdown
|