From b719a3dfa240d1f4fde3f59be40b860bc886b667 Mon Sep 17 00:00:00 2001 From: yousizaitianqiong <98396370+yousizaitianqiong@users.noreply.github.com> Date: Tue, 24 Nov 2026 13:10:37 +0800 Subject: [PATCH] fix(python): align local score rounding with reference --- packages/ghfind-py/ghfind/_risk.py | 30 +- packages/ghfind-py/ghfind/_rounding.py | 25 + packages/ghfind-py/ghfind/_score.py | 26 +- .../tests/fixtures/rounding-v3-ts.json | 2798 +++++++++++++++++ .../ghfind-py/tests/test_rounding_extremes.py | 84 + .../ghfind-py/tests/test_rounding_parity.py | 40 + .../tests/test_rounding_v3_reference.py | 66 + scoring/fixtures/rounding-parity.json | 862 +++++ scoring/rounding_parity_test.go | 86 + scoring/test/rounding-parity.test.ts | 41 + 10 files changed, 4031 insertions(+), 27 deletions(-) create mode 100644 packages/ghfind-py/ghfind/_rounding.py create mode 100644 packages/ghfind-py/tests/fixtures/rounding-v3-ts.json create mode 100644 packages/ghfind-py/tests/test_rounding_extremes.py create mode 100644 packages/ghfind-py/tests/test_rounding_parity.py create mode 100644 packages/ghfind-py/tests/test_rounding_v3_reference.py create mode 100644 scoring/fixtures/rounding-parity.json create mode 100644 scoring/rounding_parity_test.go create mode 100644 scoring/test/rounding-parity.test.ts diff --git a/packages/ghfind-py/ghfind/_risk.py b/packages/ghfind-py/ghfind/_risk.py index e3447268..c183f2b9 100644 --- a/packages/ghfind-py/ghfind/_risk.py +++ b/packages/ghfind-py/ghfind/_risk.py @@ -10,6 +10,8 @@ import math from typing import Any, Dict, List, Mapping, Optional, Tuple +from ._rounding import round_half_even + RISK_VERSION = "v10" TOTAL_CAP = 25.0 CONTRIBUTION_CAP = 16.0 @@ -74,9 +76,9 @@ def _coverage(m: Mapping[str, Any]) -> Dict[str, float]: all_sample = max(0.0, _finite(m.get("recent_pr_sample"))) all_total = max(1.0, min(_finite(m.get("total_pr_count")), 30.0)) return { - "repo": round(_clamp01(fetched / public_repos), 4), - "merged_pr": round(_clamp01(merged_sample / merged_total), 4), - "all_pr": round(_clamp01(all_sample / all_total), 4), + "repo": round_half_even(_clamp01(fetched / public_repos), 4), + "merged_pr": round_half_even(_clamp01(merged_sample / merged_total), 4), + "all_pr": round_half_even(_clamp01(all_sample / all_total), 4), } @@ -111,8 +113,8 @@ def _candidate( "flag": flag, "family": family, "disposition": "note", - "severity": round(_clamp01(severity), 4), - "confidence": round(_clamp01(confidence), 4), + "severity": round_half_even(_clamp01(severity), 4), + "confidence": round_half_even(_clamp01(confidence), 4), "penalty": 0.0, "detail": detail, "evidence": _evidence(m, observed, sample, threshold), @@ -135,15 +137,15 @@ def _apply_cap(candidates: List[Dict[str, Any]], family: str, cap: float) -> flo raw_total = sum(item["raw"] for item in active) if raw_total <= 0: return 0.0 - target = round(min(cap, raw_total), 2) + target = round_half_even(min(cap, raw_total), 2) factor = target / raw_total assigned = 0.0 for index, item in enumerate(active): - penalty = round(max(0.0, target - assigned), 2) if index == len(active) - 1 else round(item["raw"] * factor, 2) + penalty = round_half_even(max(0.0, target - assigned), 2) if index == len(active) - 1 else round_half_even(item["raw"] * factor, 2) item["signal"]["penalty"] = penalty if penalty > 0: item["signal"]["disposition"] = "penalty" - assigned = round(assigned + penalty, 2) + assigned = round_half_even(assigned + penalty, 2) return assigned @@ -195,7 +197,7 @@ def assess_risk(m: Mapping[str, Any]) -> Tuple[Dict[str, Any], List[Dict[str, An trivial_raw = 8 * _clamp01((trivial_rate - TRIVIAL_RATE) / TRIVIAL_TRANSITION) * _sample_factor(merged_sample) if merged_sample >= MIN_CONTRIBUTION_SAMPLE and trivial_rate > TRIVIAL_RATE else 0.0 if merged_sample > 0 and external_trivial > 0 and external_trivial / merged_sample > 0.3: detail = "外部热门仓库中的低实质 PR 比例偏高,但合并样本不足 20 个,仅作风险提示。" if merged_sample < MIN_CONTRIBUTION_SAMPLE else "外部热门仓库中的低实质 PR 比例达到量化阈值;仅统计他人仓库,不惩罚正常自提 PR。" - _add_contribution(m, candidates, "trivial_pr_farming", trivial_raw, trivial_severity, detail, {"external_trivial_pr_count": external_trivial, "merged_pr_sample": merged_sample, "smoothed_rate": round(trivial_rate, 4)}, merged_sample, {"minimum_sample": MIN_CONTRIBUTION_SAMPLE, "smoothed_rate": TRIVIAL_RATE}, coverage_confidence) + _add_contribution(m, candidates, "trivial_pr_farming", trivial_raw, trivial_severity, detail, {"external_trivial_pr_count": external_trivial, "merged_pr_sample": merged_sample, "smoothed_rate": round_half_even(trivial_rate, 4)}, merged_sample, {"minimum_sample": MIN_CONTRIBUTION_SAMPLE, "smoothed_rate": TRIVIAL_RATE}, coverage_confidence) rejection_measured = m.get("maintainer_closed_unmerged_pr_count") is not None rejected = max(0.0, _finite(m.get("maintainer_closed_unmerged_pr_count"))) if rejection_measured else 0.0 @@ -206,7 +208,7 @@ def assess_risk(m: Mapping[str, Any]) -> Tuple[Dict[str, Any], List[Dict[str, An rejection_raw = 4 * _clamp01((rejection_lower - REJECTION_WILSON_LOWER) / REJECTION_WILSON_LOWER) if rejection_measured and decided >= MIN_REJECTION_DECISIONS and rejection_lower >= REJECTION_WILSON_LOWER else 0.0 if rejection_measured and decided > 0 and rejection_rate >= REJECTION_WILSON_LOWER: detail = "维护者关闭未合并的 PR 比例偏高,但样本量或 Wilson 95% 下界未达到扣分门槛,仅作风险提示。" if decided < MIN_REJECTION_DECISIONS or rejection_lower < REJECTION_WILSON_LOWER else "维护者关闭未合并的 PR 的 Wilson 95% 下界达到量化阈值。" - _add_contribution(m, candidates, "high_pr_rejection", rejection_raw, rejection_severity, detail, {"maintainer_closed_unmerged_pr_count": rejected, "merged_pr_count": _finite(m.get("merged_pr_count")), "decided_pr_count": decided, "wilson_lower": round(rejection_lower, 4)}, decided, {"minimum_decisions": MIN_REJECTION_DECISIONS, "wilson_lower": REJECTION_WILSON_LOWER}, coverage_confidence) + _add_contribution(m, candidates, "high_pr_rejection", rejection_raw, rejection_severity, detail, {"maintainer_closed_unmerged_pr_count": rejected, "merged_pr_count": _finite(m.get("merged_pr_count")), "decided_pr_count": decided, "wilson_lower": round_half_even(rejection_lower, 4)}, decided, {"minimum_decisions": MIN_REJECTION_DECISIONS, "wilson_lower": REJECTION_WILSON_LOWER}, coverage_confidence) flood_sample = max(0.0, _finite(m.get("recent_pr_sample"))) share = _clamp01(_finite(m.get("top_repo_pr_share"))) @@ -230,7 +232,7 @@ def assess_risk(m: Mapping[str, Any]) -> Tuple[Dict[str, Any], List[Dict[str, An follow_raw = 4 * _clamp01((FOLLOW_RATIO - follower_ratio) / FOLLOW_RATIO) * _clamp01((following - FOLLOW_MINIMUM) / 3000) if following >= FOLLOW_MINIMUM and follower_ratio < FOLLOW_RATIO else 0.0 follow: Optional[Dict[str, Any]] = None if follow_observed: - follow = _candidate(m, "follow_farming", "social", 0.0, _clamp01((FOLLOW_RATIO - follower_ratio) / FOLLOW_RATIO), coverage_confidence, "关注数量与粉丝数量明显失衡;当前只有单次快照,没有关注增长时间序列,不能单独判定刷粉。", {"following": following, "followers": followers, "follower_ratio": round(follower_ratio, 4)}, threshold={"minimum_following": FOLLOW_MINIMUM, "follower_ratio": FOLLOW_RATIO}) + follow = _candidate(m, "follow_farming", "social", 0.0, _clamp01((FOLLOW_RATIO - follower_ratio) / FOLLOW_RATIO), coverage_confidence, "关注数量与粉丝数量明显失衡;当前只有单次快照,没有关注增长时间序列,不能单独判定刷粉。", {"following": following, "followers": followers, "follower_ratio": round_half_even(follower_ratio, 4)}, threshold={"minimum_following": FOLLOW_MINIMUM, "follower_ratio": FOLLOW_RATIO}) candidates.append(follow) engagement = m.get("top_repo_engagement_ratio") @@ -252,7 +254,7 @@ def assess_risk(m: Mapping[str, Any]) -> Tuple[Dict[str, Any], List[Dict[str, An contribution_penalty = _apply_cap(candidates, "contribution", CONTRIBUTION_CAP) social_penalty = _apply_cap(candidates, "social", SOCIAL_CAP) - total_penalty = round(min(TOTAL_CAP, contribution_penalty + social_penalty), 2) + total_penalty = round_half_even(min(TOTAL_CAP, contribution_penalty + social_penalty), 2) signals = [item["signal"] for item in candidates] notes = [] red_flags = [] @@ -264,13 +266,13 @@ def assess_risk(m: Mapping[str, Any]) -> Tuple[Dict[str, Any], List[Dict[str, An note["penalty"] = 0.0 note["disposition"] = "note" notes.append(note) - risk_score = round(total_penalty / TOTAL_CAP * 100, 2) + risk_score = round_half_even(total_penalty / TOTAL_CAP * 100, 2) level = "high" if risk_score >= HIGH_MINIMUM else "review" if risk_score >= REVIEW_MINIMUM else "none" assessment = { "version": RISK_VERSION, "risk_score": risk_score, "level": level, - "confidence": round(_confidence(coverage) * 100, 2), + "confidence": round_half_even(_confidence(coverage) * 100, 2), "applied_penalty": total_penalty, "signals": signals, "coverage": coverage, diff --git a/packages/ghfind-py/ghfind/_rounding.py b/packages/ghfind-py/ghfind/_rounding.py new file mode 100644 index 00000000..1fde58da --- /dev/null +++ b/packages/ghfind-py/ghfind/_rounding.py @@ -0,0 +1,25 @@ +"""Rounding used by the TypeScript and Go scoring implementations.""" + +import math + + +def round_half_even(value: float, digits: int = 0) -> float: + """Match the reference's scaled half-even rule, including its tolerance.""" + factor = 10.0 ** digits + scaled = value * factor + # Python's round(value, digits) preserves large finite values and passes + # through NaN/Infinity even when scaling cannot remain finite. + if not math.isfinite(scaled): + return value + lower = math.floor(scaled) + if abs(scaled - lower - 0.5) < 1e-9: + rounded = lower if lower % 2 == 0 else lower + 1 + else: + # Compare the fraction instead of adding 0.5: that addition can + # round an already-integral binary64 value at or above 2**52. + rounded = lower + (1 if scaled - lower >= 0.5 else 0) + # Math.round retains negative zero; the half-even branch above can + # instead produce positive zero, including for an exact negative half. + if rounded == 0 and math.copysign(1.0, scaled) < 0: + return -0.0 + return rounded / factor diff --git a/packages/ghfind-py/ghfind/_score.py b/packages/ghfind-py/ghfind/_score.py index 2ec2548f..5a373cfd 100644 --- a/packages/ghfind-py/ghfind/_score.py +++ b/packages/ghfind-py/ghfind/_score.py @@ -4,10 +4,9 @@ The number is the single source of truth; the LLM only writes prose/roast on top of this output. -Parity notes (why this reproduces the TS output bit-for-bit): -- TS reimplemented Python's ``round()`` (round-half-to-even / banker's) as its own - ``round()``. Python's built-in ``round()`` IS banker's, so we use it directly for - every TS ``round(...)`` call. +Parity notes for TypeScript rounding: +- TS and Go scale values before applying half-even with a tolerance around the + midpoint; ``round_half_even`` mirrors that rule for the scoring calculations. - TS ``Math.round(...)`` is round-half-UP, NOT banker's. We replicate it with ``_math_round`` = ``floor(x + 0.5)`` wherever the TS uses ``Math.round``. - ``??`` (nullish) defaults only on null/undefined; ``_nz`` mirrors that (defaults @@ -22,6 +21,7 @@ from typing import Any, Dict, List, Mapping, Optional from ._risk import assess_risk +from ._rounding import round_half_even SUBSCORE_MAX: Dict[str, float] = { "account_maturity": 10, @@ -52,7 +52,7 @@ def log_ratio(value: float, full_at: float) -> float: def clamp_score(value: float) -> float: """Clamp a score to [0, 100] and round to 2 decimals (banker's).""" - return round(max(0, min(value, 100)), 2) + return round_half_even(max(0, min(value, 100)), 2) def star_engagement_multiplier(ratio: Any) -> float: @@ -393,7 +393,7 @@ def original_project_quality(m): * content_skill_discount(m) ) project_substance = max(0, min(_nz(m.get("best_original_repo_quality_score"), 0), 1)) * 6 - return round(star_pts + project_substance, 1) + return round_half_even(star_pts + project_substance, 1) def score(m: Mapping[str, Any]) -> Dict[str, Any]: @@ -410,7 +410,7 @@ def score(m: Mapping[str, Any]) -> Dict[str, Any]: age_pts = min(m["account_age_years"] / 6.0, 1.0) * 7 years = m["contribution_years_active"] span_pts = 0 if years == 0 else 1 if years == 1 else 2 if years == 2 else 3 - sub["account_maturity"] = round(age_pts + span_pts, 1) + sub["account_maturity"] = round_half_even(age_pts + span_pts, 1) # 2. Original Project Quality (18) sub["original_project_quality"] = max(original_project_quality(m), max(0,min(18,m.get("personal_original_project_quality_score",0)))) @@ -444,7 +444,7 @@ def score(m: Mapping[str, Any]) -> Dict[str, Any]: + high_impact_core_pr_bonus(m) * (1-(1-presentation_discount(m))*.8) - author_self_closed_external_penalty(m) ) - sub["contribution_quality"] = round( + sub["contribution_quality"] = round_half_even( saturate_toward(max(0, contribution_quality_raw), contribution_evidence_ceiling(m)), 1, ) @@ -457,7 +457,7 @@ def score(m: Mapping[str, Any]) -> Dict[str, Any]: from ._presentation import ecosystem_presentation_discount external_share = min(1,max(0,_nz(m.get("external_merged_pr_count"),0))/max(1,m["merged_pr_count"])) ecosystem_raw = (prestige + depth) * ecosystem_presentation_discount(m) * (1-(1-content_skill_discount(m))*(1-external_share)) - sub["ecosystem_impact"] = round( + sub["ecosystem_impact"] = round_half_even( ecosystem_raw, 1, ) @@ -474,7 +474,7 @@ def score(m: Mapping[str, Any]) -> Dict[str, Any]: ratio = followers / following ratio_pts = 3 if ratio >= 2 else 2 if ratio >= 1 else 1.5 if ratio >= 0.5 else 1 community_raw = follower_pts + ratio_pts - sub["community_influence"] = round( + sub["community_influence"] = round_half_even( min(community_raw, 2.5) if _has_social_only_dormant_signal(m) else community_raw, 1 ) @@ -490,12 +490,12 @@ def score(m: Mapping[str, Any]) -> Dict[str, Any]: else: recency_pts = 0.0 diversity_pts = min(m["activity_type_count"], 4) * 1.125 - sub["activity_authenticity"] = round(contrib_pts + recency_pts + diversity_pts, 1) + sub["activity_authenticity"] = round_half_even(contrib_pts + recency_pts + diversity_pts, 1) - base = round(sum(sub.values()), 1) + base = round_half_even(sum(sub.values()), 1) risk_assessment, risk_notes, flags, penalty = assess_risk(m) - final = clamp_score(round(base - penalty, 2)) + final = clamp_score(round_half_even(base - penalty, 2)) t = tier_for(final) return { diff --git a/packages/ghfind-py/tests/fixtures/rounding-v3-ts.json b/packages/ghfind-py/tests/fixtures/rounding-v3-ts.json new file mode 100644 index 00000000..f49049af --- /dev/null +++ b/packages/ghfind-py/tests/fixtures/rounding-v3-ts.json @@ -0,0 +1,2798 @@ +{ + "generator": "actual scoring/src/score.ts score and roundHalfEven", + "scans": { + "normal": { + "metrics": { + "username": "synthetic-fixture", + "profile_url": null, + "avatar_url": null, + "name": null, + "bio": null, + "company": null, + "account_age_years": 1.5, + "created_at": null, + "followers": 0, + "following": 0, + "public_repos": 0, + "fetched_repo_count": 0, + "original_repo_count": 0, + "nonempty_original_repo_count": 0, + "fork_repo_count": 0, + "empty_original_repo_count": 0, + "total_stars": 0, + "max_stars": 0, + "merged_pr_count": 0, + "total_pr_count": 0, + "issues_created": 0, + "last_year_contributions": 0, + "activity_type_count": 0, + "contribution_years_active": 0, + "days_since_last_activity": null, + "recent_merged_pr_sample": 0, + "recent_trivial_pr_count": 0, + "external_trivial_pr_count": 0, + "max_impact_repo_stars": 0, + "impact_pr_count": 0, + "impact_depth_raw": 0, + "star_inflation_suspect": false, + "closed_unmerged_pr_count": 0, + "pr_rejection_rate": 0, + "recent_pr_sample": 0, + "top_repo_pr_target": null, + "top_repo_pr_share": 0, + "templated_pr_ratio": 0, + "pr_flood_suspect": false + }, + "scoring": { + "sub_scores": { + "account_maturity": 1.8, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 1.8, + "red_flags": [], + "risk_assessment": { + "version": "v10", + "risk_score": 0, + "level": "none", + "confidence": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + } + }, + "risk_notes": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "total_penalty": 0, + "final_score": 1.8, + "tier": "拉完了", + "tier_label": "起步阶段 · 多练多攒作品" + } + }, + "age_edge": { + "metrics": { + "username": "synthetic-fixture", + "profile_url": null, + "avatar_url": null, + "name": null, + "bio": null, + "company": null, + "account_age_years": -386022825203185.44, + "created_at": null, + "followers": 0, + "following": 0, + "public_repos": 0, + "fetched_repo_count": 0, + "original_repo_count": 0, + "nonempty_original_repo_count": 0, + "fork_repo_count": 0, + "empty_original_repo_count": 0, + "total_stars": 0, + "max_stars": 0, + "merged_pr_count": 0, + "total_pr_count": 0, + "issues_created": 0, + "last_year_contributions": 0, + "activity_type_count": 0, + "contribution_years_active": 0, + "days_since_last_activity": null, + "recent_merged_pr_sample": 0, + "recent_trivial_pr_count": 0, + "external_trivial_pr_count": 0, + "max_impact_repo_stars": 0, + "impact_pr_count": 0, + "impact_depth_raw": 0, + "star_inflation_suspect": false, + "closed_unmerged_pr_count": 0, + "pr_rejection_rate": 0, + "recent_pr_sample": 0, + "top_repo_pr_target": null, + "top_repo_pr_share": 0, + "templated_pr_ratio": 0, + "pr_flood_suspect": false + }, + "scoring": { + "sub_scores": { + "account_maturity": -450359962737049.7, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": -450359962737049.7, + "red_flags": [], + "risk_assessment": { + "version": "v10", + "risk_score": 0, + "level": "none", + "confidence": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + } + }, + "risk_notes": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "total_penalty": 0, + "final_score": 0, + "tier": "拉完了", + "tier_label": "起步阶段 · 多练多攒作品" + } + }, + "activity_edge": { + "metrics": { + "username": "synthetic-fixture", + "profile_url": null, + "avatar_url": null, + "name": null, + "bio": null, + "company": null, + "account_age_years": 0, + "created_at": null, + "followers": 0, + "following": 0, + "public_repos": 0, + "fetched_repo_count": 0, + "original_repo_count": 0, + "nonempty_original_repo_count": 0, + "fork_repo_count": 0, + "empty_original_repo_count": 0, + "total_stars": 0, + "max_stars": 0, + "merged_pr_count": 0, + "total_pr_count": 0, + "issues_created": 0, + "last_year_contributions": 0, + "activity_type_count": -400319966877420, + "contribution_years_active": 0, + "days_since_last_activity": null, + "recent_merged_pr_sample": 0, + "recent_trivial_pr_count": 0, + "external_trivial_pr_count": 0, + "max_impact_repo_stars": 0, + "impact_pr_count": 0, + "impact_depth_raw": 0, + "star_inflation_suspect": false, + "closed_unmerged_pr_count": 0, + "pr_rejection_rate": 0, + "recent_pr_sample": 0, + "top_repo_pr_target": null, + "top_repo_pr_share": 0, + "templated_pr_ratio": 0, + "pr_flood_suspect": false + }, + "scoring": { + "sub_scores": { + "account_maturity": 0, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": -450359962737097.5 + }, + "base_score": -450359962737097.5, + "red_flags": [], + "risk_assessment": { + "version": "v10", + "risk_score": 0, + "level": "none", + "confidence": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + } + }, + "risk_notes": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "total_penalty": 0, + "final_score": 0, + "tier": "拉完了", + "tier_label": "起步阶段 · 多练多攒作品" + } + }, + "negative_zero": { + "metrics": { + "username": "synthetic-fixture", + "profile_url": null, + "avatar_url": null, + "name": null, + "bio": null, + "company": null, + "account_age_years": -0.001, + "created_at": null, + "followers": 0, + "following": 0, + "public_repos": 0, + "fetched_repo_count": 0, + "original_repo_count": 0, + "nonempty_original_repo_count": 0, + "fork_repo_count": 0, + "empty_original_repo_count": 0, + "total_stars": 0, + "max_stars": 0, + "merged_pr_count": 0, + "total_pr_count": 0, + "issues_created": 0, + "last_year_contributions": 0, + "activity_type_count": 0, + "contribution_years_active": 0, + "days_since_last_activity": null, + "recent_merged_pr_sample": 0, + "recent_trivial_pr_count": 0, + "external_trivial_pr_count": 0, + "max_impact_repo_stars": 0, + "impact_pr_count": 0, + "impact_depth_raw": 0, + "star_inflation_suspect": false, + "closed_unmerged_pr_count": 0, + "pr_rejection_rate": 0, + "recent_pr_sample": 0, + "top_repo_pr_target": null, + "top_repo_pr_share": 0, + "templated_pr_ratio": 0, + "pr_flood_suspect": false + }, + "scoring": { + "sub_scores": { + "account_maturity": 0, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 0, + "red_flags": [], + "risk_assessment": { + "version": "v10", + "risk_score": 0, + "level": "none", + "confidence": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + } + }, + "risk_notes": [ + { + "flag": "no_original_work", + "family": "footprint", + "disposition": "note", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "detail": "当前公开采集范围内没有非空原创仓库;这只代表足迹有限,不代表作弊。", + "evidence": { + "observed": { + "nonempty_original_repo_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + }, + { + "flag": "ghost_profile", + "family": "footprint", + "disposition": "note", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "detail": "个人资料和公开项目足迹都很少,当前数据不足以判断行为真实性。", + "evidence": { + "observed": { + "has_bio": false, + "followers": 0, + "total_stars": 0, + "merged_pr_count": 0 + }, + "sample_size": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "window": "bounded public snapshot: up to 200 repositories, up to 50 merged PRs, up to 30 all-state PRs" + } + } + ], + "total_penalty": 0, + "final_score": 0, + "tier": "拉完了", + "tier_label": "起步阶段 · 多练多攒作品" + } + } + }, + "public_negative_zero": true, + "helper": [ + { + "name": "p52--1-down2", + "value": -450359962737049.8, + "value_negative_zero": false, + "digits": 1, + "result": -450359962737049.8, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370498 + }, + { + "name": "p52--1-down", + "value": -450359962737049.7, + "value_negative_zero": false, + "digits": 1, + "result": -450359962737049.7, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370497 + }, + { + "name": "p52--1-center", + "value": -450359962737049.6, + "value_negative_zero": false, + "digits": 1, + "result": -450359962737049.6, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370496 + }, + { + "name": "p52--1-up", + "value": -450359962737049.56, + "value_negative_zero": false, + "digits": 1, + "result": -450359962737049.6, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -4503599627370495.5 + }, + { + "name": "p52--1-up2", + "value": -450359962737049.5, + "value_negative_zero": false, + "digits": 1, + "result": -450359962737049.5, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370495 + }, + { + "name": "half--1-0--2e-9", + "value": -0.0499999998, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.499999998 + }, + { + "name": "half--1-0--1e-9", + "value": -0.049999999899999995, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.4999999989999999 + }, + { + "name": "half--1-0--5e-10", + "value": -0.04999999995, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.49999999949999996 + }, + { + "name": "half--1-0-0", + "value": -0.05, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "half--1-0-5e-10", + "value": -0.05000000005000001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5000000005 + }, + { + "name": "half--1-0-1e-9", + "value": -0.0500000001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.500000001 + }, + { + "name": "half--1-0-2e-9", + "value": -0.050000000200000005, + "value_negative_zero": false, + "digits": 1, + "result": -0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -0.500000002 + }, + { + "name": "half--1-1--2e-9", + "value": -0.1499999998, + "value_negative_zero": false, + "digits": 1, + "result": -0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999998 + }, + { + "name": "half--1-1--1e-9", + "value": -0.1499999999, + "value_negative_zero": false, + "digits": 1, + "result": -0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999999 + }, + { + "name": "half--1-1--5e-10", + "value": -0.14999999995, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.4999999995 + }, + { + "name": "half--1-1-0", + "value": -0.15, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.5 + }, + { + "name": "half--1-1-5e-10", + "value": -0.15000000005, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.5000000005 + }, + { + "name": "half--1-1-1e-9", + "value": -0.1500000001, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.500000001 + }, + { + "name": "half--1-1-2e-9", + "value": -0.15000000019999998, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.5000000019999997 + }, + { + "name": "half--1-2--2e-9", + "value": -0.24999999979999998, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999998 + }, + { + "name": "half--1-2--1e-9", + "value": -0.2499999999, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999999 + }, + { + "name": "half--1-2--5e-10", + "value": -0.24999999995, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.4999999995 + }, + { + "name": "half--1-2-0", + "value": -0.25, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5 + }, + { + "name": "half--1-2-5e-10", + "value": -0.25000000005, + "value_negative_zero": false, + "digits": 1, + "result": -0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5000000005 + }, + { + "name": "half--1-2-1e-9", + "value": -0.2500000001, + "value_negative_zero": false, + "digits": 1, + "result": -0.3, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.500000001 + }, + { + "name": "half--1-2-2e-9", + "value": -0.2500000002, + "value_negative_zero": false, + "digits": 1, + "result": -0.3, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.500000002 + }, + { + "name": "half--1-10--2e-9", + "value": -1.0499999998, + "value_negative_zero": false, + "digits": 1, + "result": -1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999998 + }, + { + "name": "half--1-10--1e-9", + "value": -1.0499999999, + "value_negative_zero": false, + "digits": 1, + "result": -1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999999 + }, + { + "name": "half--1-10--5e-10", + "value": -1.04999999995, + "value_negative_zero": false, + "digits": 1, + "result": -1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.4999999995 + }, + { + "name": "half--1-10-0", + "value": -1.05, + "value_negative_zero": false, + "digits": 1, + "result": -1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5 + }, + { + "name": "half--1-10-5e-10", + "value": -1.05000000005, + "value_negative_zero": false, + "digits": 1, + "result": -1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5000000005 + }, + { + "name": "half--1-10-1e-9", + "value": -1.0500000001, + "value_negative_zero": false, + "digits": 1, + "result": -1.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000001 + }, + { + "name": "half--1-10-2e-9", + "value": -1.0500000002, + "value_negative_zero": false, + "digits": 1, + "result": -1.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000002 + }, + { + "name": "p52-1-down2", + "value": 450359962737049.5, + "value_negative_zero": false, + "digits": 1, + "result": 450359962737049.5, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370495 + }, + { + "name": "p52-1-down", + "value": 450359962737049.56, + "value_negative_zero": false, + "digits": 1, + "result": 450359962737049.6, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 4503599627370495.5 + }, + { + "name": "p52-1-center", + "value": 450359962737049.6, + "value_negative_zero": false, + "digits": 1, + "result": 450359962737049.6, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370496 + }, + { + "name": "p52-1-up", + "value": 450359962737049.7, + "value_negative_zero": false, + "digits": 1, + "result": 450359962737049.7, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370497 + }, + { + "name": "p52-1-up2", + "value": 450359962737049.8, + "value_negative_zero": false, + "digits": 1, + "result": 450359962737049.8, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370498 + }, + { + "name": "half-1-0--2e-9", + "value": 0.0499999998, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.499999998 + }, + { + "name": "half-1-0--1e-9", + "value": 0.049999999899999995, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.4999999989999999 + }, + { + "name": "half-1-0--5e-10", + "value": 0.04999999995, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.49999999949999996 + }, + { + "name": "half-1-0-0", + "value": 0.05, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5 + }, + { + "name": "half-1-0-5e-10", + "value": 0.05000000005000001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5000000005 + }, + { + "name": "half-1-0-1e-9", + "value": 0.0500000001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.500000001 + }, + { + "name": "half-1-0-2e-9", + "value": 0.050000000200000005, + "value_negative_zero": false, + "digits": 1, + "result": 0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.500000002 + }, + { + "name": "half-1-1--2e-9", + "value": 0.1499999998, + "value_negative_zero": false, + "digits": 1, + "result": 0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999998 + }, + { + "name": "half-1-1--1e-9", + "value": 0.1499999999, + "value_negative_zero": false, + "digits": 1, + "result": 0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999999 + }, + { + "name": "half-1-1--5e-10", + "value": 0.14999999995, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.4999999995 + }, + { + "name": "half-1-1-0", + "value": 0.15, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.5 + }, + { + "name": "half-1-1-5e-10", + "value": 0.15000000005, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.5000000005 + }, + { + "name": "half-1-1-1e-9", + "value": 0.1500000001, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.500000001 + }, + { + "name": "half-1-1-2e-9", + "value": 0.15000000019999998, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.5000000019999997 + }, + { + "name": "half-1-2--2e-9", + "value": 0.24999999979999998, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999998 + }, + { + "name": "half-1-2--1e-9", + "value": 0.2499999999, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999999 + }, + { + "name": "half-1-2--5e-10", + "value": 0.24999999995, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.4999999995 + }, + { + "name": "half-1-2-0", + "value": 0.25, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5 + }, + { + "name": "half-1-2-5e-10", + "value": 0.25000000005, + "value_negative_zero": false, + "digits": 1, + "result": 0.2, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5000000005 + }, + { + "name": "half-1-2-1e-9", + "value": 0.2500000001, + "value_negative_zero": false, + "digits": 1, + "result": 0.3, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.500000001 + }, + { + "name": "half-1-2-2e-9", + "value": 0.2500000002, + "value_negative_zero": false, + "digits": 1, + "result": 0.3, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.500000002 + }, + { + "name": "half-1-10--2e-9", + "value": 1.0499999998, + "value_negative_zero": false, + "digits": 1, + "result": 1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999998 + }, + { + "name": "half-1-10--1e-9", + "value": 1.0499999999, + "value_negative_zero": false, + "digits": 1, + "result": 1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999999 + }, + { + "name": "half-1-10--5e-10", + "value": 1.04999999995, + "value_negative_zero": false, + "digits": 1, + "result": 1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.4999999995 + }, + { + "name": "half-1-10-0", + "value": 1.05, + "value_negative_zero": false, + "digits": 1, + "result": 1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5 + }, + { + "name": "half-1-10-5e-10", + "value": 1.05000000005, + "value_negative_zero": false, + "digits": 1, + "result": 1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5000000005 + }, + { + "name": "half-1-10-1e-9", + "value": 1.0500000001, + "value_negative_zero": false, + "digits": 1, + "result": 1.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000001 + }, + { + "name": "half-1-10-2e-9", + "value": 1.0500000002, + "value_negative_zero": false, + "digits": 1, + "result": 1.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000002 + }, + { + "name": "negative-zero", + "value": 0, + "value_negative_zero": true, + "digits": 1, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "positive-zero", + "value": 0, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "negative-small", + "value": -0.0001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.001 + }, + { + "name": "negative-half", + "value": -0.05, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "positive-small", + "value": 0.0001, + "value_negative_zero": false, + "digits": 1, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.001 + }, + { + "name": "p52--1-down2", + "value": -45035996273704.98, + "value_negative_zero": false, + "digits": 2, + "result": -45035996273704.98, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370498 + }, + { + "name": "p52--1-down", + "value": -45035996273704.97, + "value_negative_zero": false, + "digits": 2, + "result": -45035996273704.97, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370497 + }, + { + "name": "p52--1-center", + "value": -45035996273704.96, + "value_negative_zero": false, + "digits": 2, + "result": -45035996273704.96, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370496 + }, + { + "name": "p52--1-up", + "value": -45035996273704.95, + "value_negative_zero": false, + "digits": 2, + "result": -45035996273704.96, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -4503599627370495.5 + }, + { + "name": "p52--1-up2", + "value": -45035996273704.95, + "value_negative_zero": false, + "digits": 2, + "result": -45035996273704.96, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -4503599627370495.5 + }, + { + "name": "half--1-0--2e-9", + "value": -0.00499999998, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.499999998 + }, + { + "name": "half--1-0--1e-9", + "value": -0.00499999999, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.49999999900000003 + }, + { + "name": "half--1-0--5e-10", + "value": -0.0049999999950000006, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.49999999950000007 + }, + { + "name": "half--1-0-0", + "value": -0.005, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "half--1-0-5e-10", + "value": -0.0050000000050000005, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5000000005 + }, + { + "name": "half--1-0-1e-9", + "value": -0.00500000001, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.500000001 + }, + { + "name": "half--1-0-2e-9", + "value": -0.005000000020000001, + "value_negative_zero": false, + "digits": 2, + "result": -0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -0.500000002 + }, + { + "name": "half--1-1--2e-9", + "value": -0.014999999980000001, + "value_negative_zero": false, + "digits": 2, + "result": -0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999998 + }, + { + "name": "half--1-1--1e-9", + "value": -0.014999999989999999, + "value_negative_zero": false, + "digits": 2, + "result": -0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999999 + }, + { + "name": "half--1-1--5e-10", + "value": -0.014999999994999999, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.4999999995 + }, + { + "name": "half--1-1-0", + "value": -0.015, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.5 + }, + { + "name": "half--1-1-5e-10", + "value": -0.015000000005, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.5000000005 + }, + { + "name": "half--1-1-1e-9", + "value": -0.01500000001, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.500000001 + }, + { + "name": "half--1-1-2e-9", + "value": -0.01500000002, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.500000002 + }, + { + "name": "half--1-2--2e-9", + "value": -0.02499999998, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999998 + }, + { + "name": "half--1-2--1e-9", + "value": -0.02499999999, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999999 + }, + { + "name": "half--1-2--5e-10", + "value": -0.024999999995, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.4999999995 + }, + { + "name": "half--1-2-0", + "value": -0.025, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5 + }, + { + "name": "half--1-2-5e-10", + "value": -0.025000000005000002, + "value_negative_zero": false, + "digits": 2, + "result": -0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5000000005 + }, + { + "name": "half--1-2-1e-9", + "value": -0.025000000010000002, + "value_negative_zero": false, + "digits": 2, + "result": -0.03, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.500000001 + }, + { + "name": "half--1-2-2e-9", + "value": -0.025000000020000003, + "value_negative_zero": false, + "digits": 2, + "result": -0.03, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.500000002 + }, + { + "name": "half--1-10--2e-9", + "value": -0.10499999998, + "value_negative_zero": false, + "digits": 2, + "result": -0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999998 + }, + { + "name": "half--1-10--1e-9", + "value": -0.10499999999, + "value_negative_zero": false, + "digits": 2, + "result": -0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999999 + }, + { + "name": "half--1-10--5e-10", + "value": -0.104999999995, + "value_negative_zero": false, + "digits": 2, + "result": -0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.4999999995 + }, + { + "name": "half--1-10-0", + "value": -0.105, + "value_negative_zero": false, + "digits": 2, + "result": -0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5 + }, + { + "name": "half--1-10-5e-10", + "value": -0.105000000005, + "value_negative_zero": false, + "digits": 2, + "result": -0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5000000005 + }, + { + "name": "half--1-10-1e-9", + "value": -0.10500000001, + "value_negative_zero": false, + "digits": 2, + "result": -0.11, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000001 + }, + { + "name": "half--1-10-2e-9", + "value": -0.10500000002, + "value_negative_zero": false, + "digits": 2, + "result": -0.11, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000002 + }, + { + "name": "p52-1-down2", + "value": 45035996273704.95, + "value_negative_zero": false, + "digits": 2, + "result": 45035996273704.96, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 4503599627370495.5 + }, + { + "name": "p52-1-down", + "value": 45035996273704.95, + "value_negative_zero": false, + "digits": 2, + "result": 45035996273704.96, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 4503599627370495.5 + }, + { + "name": "p52-1-center", + "value": 45035996273704.96, + "value_negative_zero": false, + "digits": 2, + "result": 45035996273704.96, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370496 + }, + { + "name": "p52-1-up", + "value": 45035996273704.97, + "value_negative_zero": false, + "digits": 2, + "result": 45035996273704.97, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370497 + }, + { + "name": "p52-1-up2", + "value": 45035996273704.98, + "value_negative_zero": false, + "digits": 2, + "result": 45035996273704.98, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370498 + }, + { + "name": "half-1-0--2e-9", + "value": 0.00499999998, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.499999998 + }, + { + "name": "half-1-0--1e-9", + "value": 0.00499999999, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.49999999900000003 + }, + { + "name": "half-1-0--5e-10", + "value": 0.0049999999950000006, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.49999999950000007 + }, + { + "name": "half-1-0-0", + "value": 0.005, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5 + }, + { + "name": "half-1-0-5e-10", + "value": 0.0050000000050000005, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5000000005 + }, + { + "name": "half-1-0-1e-9", + "value": 0.00500000001, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.500000001 + }, + { + "name": "half-1-0-2e-9", + "value": 0.005000000020000001, + "value_negative_zero": false, + "digits": 2, + "result": 0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.500000002 + }, + { + "name": "half-1-1--2e-9", + "value": 0.014999999980000001, + "value_negative_zero": false, + "digits": 2, + "result": 0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999998 + }, + { + "name": "half-1-1--1e-9", + "value": 0.014999999989999999, + "value_negative_zero": false, + "digits": 2, + "result": 0.01, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999999 + }, + { + "name": "half-1-1--5e-10", + "value": 0.014999999994999999, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.4999999995 + }, + { + "name": "half-1-1-0", + "value": 0.015, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.5 + }, + { + "name": "half-1-1-5e-10", + "value": 0.015000000005, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.5000000005 + }, + { + "name": "half-1-1-1e-9", + "value": 0.01500000001, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.500000001 + }, + { + "name": "half-1-1-2e-9", + "value": 0.01500000002, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.500000002 + }, + { + "name": "half-1-2--2e-9", + "value": 0.02499999998, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999998 + }, + { + "name": "half-1-2--1e-9", + "value": 0.02499999999, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999999 + }, + { + "name": "half-1-2--5e-10", + "value": 0.024999999995, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.4999999995 + }, + { + "name": "half-1-2-0", + "value": 0.025, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5 + }, + { + "name": "half-1-2-5e-10", + "value": 0.025000000005000002, + "value_negative_zero": false, + "digits": 2, + "result": 0.02, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5000000005 + }, + { + "name": "half-1-2-1e-9", + "value": 0.025000000010000002, + "value_negative_zero": false, + "digits": 2, + "result": 0.03, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.500000001 + }, + { + "name": "half-1-2-2e-9", + "value": 0.025000000020000003, + "value_negative_zero": false, + "digits": 2, + "result": 0.03, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.500000002 + }, + { + "name": "half-1-10--2e-9", + "value": 0.10499999998, + "value_negative_zero": false, + "digits": 2, + "result": 0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999998 + }, + { + "name": "half-1-10--1e-9", + "value": 0.10499999999, + "value_negative_zero": false, + "digits": 2, + "result": 0.1, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999999 + }, + { + "name": "half-1-10--5e-10", + "value": 0.104999999995, + "value_negative_zero": false, + "digits": 2, + "result": 0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.4999999995 + }, + { + "name": "half-1-10-0", + "value": 0.105, + "value_negative_zero": false, + "digits": 2, + "result": 0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5 + }, + { + "name": "half-1-10-5e-10", + "value": 0.105000000005, + "value_negative_zero": false, + "digits": 2, + "result": 0.1, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5000000005 + }, + { + "name": "half-1-10-1e-9", + "value": 0.10500000001, + "value_negative_zero": false, + "digits": 2, + "result": 0.11, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000001 + }, + { + "name": "half-1-10-2e-9", + "value": 0.10500000002, + "value_negative_zero": false, + "digits": 2, + "result": 0.11, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000002 + }, + { + "name": "negative-zero", + "value": 0, + "value_negative_zero": true, + "digits": 2, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "positive-zero", + "value": 0, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "negative-small", + "value": -0.00001, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.001 + }, + { + "name": "negative-half", + "value": -0.005, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "positive-small", + "value": 0.00001, + "value_negative_zero": false, + "digits": 2, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.001 + }, + { + "name": "p52--1-down2", + "value": -450359962737.0498, + "value_negative_zero": false, + "digits": 4, + "result": -450359962737.0498, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370498 + }, + { + "name": "p52--1-down", + "value": -450359962737.0497, + "value_negative_zero": false, + "digits": 4, + "result": -450359962737.0497, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370497 + }, + { + "name": "p52--1-center", + "value": -450359962737.0496, + "value_negative_zero": false, + "digits": 4, + "result": -450359962737.0496, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370496 + }, + { + "name": "p52--1-up", + "value": -450359962737.04956, + "value_negative_zero": false, + "digits": 4, + "result": -450359962737.0496, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -4503599627370495.5 + }, + { + "name": "p52--1-up2", + "value": -450359962737.0495, + "value_negative_zero": false, + "digits": 4, + "result": -450359962737.0495, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -4503599627370495 + }, + { + "name": "half--1-0--2e-9", + "value": -0.0000499999998, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.499999998 + }, + { + "name": "half--1-0--1e-9", + "value": -0.0000499999999, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.499999999 + }, + { + "name": "half--1-0--5e-10", + "value": -0.00004999999995, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.4999999995 + }, + { + "name": "half--1-0-0", + "value": -0.00005, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "half--1-0-5e-10", + "value": -0.000050000000050000005, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5000000005 + }, + { + "name": "half--1-0-1e-9", + "value": -0.000050000000099999994, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.500000001 + }, + { + "name": "half--1-0-2e-9", + "value": -0.000050000000200000006, + "value_negative_zero": false, + "digits": 4, + "result": -0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -0.500000002 + }, + { + "name": "half--1-1--2e-9", + "value": -0.0001499999998, + "value_negative_zero": false, + "digits": 4, + "result": -0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999998 + }, + { + "name": "half--1-1--1e-9", + "value": -0.00014999999989999998, + "value_negative_zero": false, + "digits": 4, + "result": -0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.499999999 + }, + { + "name": "half--1-1--5e-10", + "value": -0.00014999999995, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.4999999995 + }, + { + "name": "half--1-1-0", + "value": -0.00015, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.4999999999999998 + }, + { + "name": "half--1-1-5e-10", + "value": -0.00015000000005, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -1.5000000005 + }, + { + "name": "half--1-1-1e-9", + "value": -0.00015000000010000002, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.500000001 + }, + { + "name": "half--1-1-2e-9", + "value": -0.0001500000002, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -1.500000002 + }, + { + "name": "half--1-2--2e-9", + "value": -0.0002499999998, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999998 + }, + { + "name": "half--1-2--1e-9", + "value": -0.0002499999999, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.499999999 + }, + { + "name": "half--1-2--5e-10", + "value": -0.00024999999995, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.4999999995 + }, + { + "name": "half--1-2-0", + "value": -0.00025, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5 + }, + { + "name": "half--1-2-5e-10", + "value": -0.00025000000005, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5000000005 + }, + { + "name": "half--1-2-1e-9", + "value": -0.0002500000001, + "value_negative_zero": false, + "digits": 4, + "result": -0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -2.5000000009999996 + }, + { + "name": "half--1-2-2e-9", + "value": -0.0002500000002, + "value_negative_zero": false, + "digits": 4, + "result": -0.0003, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -2.500000002 + }, + { + "name": "half--1-10--2e-9", + "value": -0.0010499999998, + "value_negative_zero": false, + "digits": 4, + "result": -0.001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999998 + }, + { + "name": "half--1-10--1e-9", + "value": -0.0010499999999, + "value_negative_zero": false, + "digits": 4, + "result": -0.001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.499999999 + }, + { + "name": "half--1-10--5e-10", + "value": -0.00104999999995, + "value_negative_zero": false, + "digits": 4, + "result": -0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.4999999995 + }, + { + "name": "half--1-10-0", + "value": -0.00105, + "value_negative_zero": false, + "digits": 4, + "result": -0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5 + }, + { + "name": "half--1-10-5e-10", + "value": -0.00105000000005, + "value_negative_zero": false, + "digits": 4, + "result": -0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -10.5000000005 + }, + { + "name": "half--1-10-1e-9", + "value": -0.0010500000001, + "value_negative_zero": false, + "digits": 4, + "result": -0.0011, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000001 + }, + { + "name": "half--1-10-2e-9", + "value": -0.0010500000002, + "value_negative_zero": false, + "digits": 4, + "result": -0.0011, + "result_negative_zero": false, + "branch": "math-round", + "scaled": -10.500000002000002 + }, + { + "name": "p52-1-down2", + "value": 450359962737.0495, + "value_negative_zero": false, + "digits": 4, + "result": 450359962737.0495, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370495 + }, + { + "name": "p52-1-down", + "value": 450359962737.04956, + "value_negative_zero": false, + "digits": 4, + "result": 450359962737.0496, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 4503599627370495.5 + }, + { + "name": "p52-1-center", + "value": 450359962737.0496, + "value_negative_zero": false, + "digits": 4, + "result": 450359962737.0496, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370496 + }, + { + "name": "p52-1-up", + "value": 450359962737.0497, + "value_negative_zero": false, + "digits": 4, + "result": 450359962737.0497, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370497 + }, + { + "name": "p52-1-up2", + "value": 450359962737.0498, + "value_negative_zero": false, + "digits": 4, + "result": 450359962737.0498, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 4503599627370498 + }, + { + "name": "half-1-0--2e-9", + "value": 0.0000499999998, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.499999998 + }, + { + "name": "half-1-0--1e-9", + "value": 0.0000499999999, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.499999999 + }, + { + "name": "half-1-0--5e-10", + "value": 0.00004999999995, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.4999999995 + }, + { + "name": "half-1-0-0", + "value": 0.00005, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5 + }, + { + "name": "half-1-0-5e-10", + "value": 0.000050000000050000005, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.5000000005 + }, + { + "name": "half-1-0-1e-9", + "value": 0.000050000000099999994, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 0.500000001 + }, + { + "name": "half-1-0-2e-9", + "value": 0.000050000000200000006, + "value_negative_zero": false, + "digits": 4, + "result": 0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.500000002 + }, + { + "name": "half-1-1--2e-9", + "value": 0.0001499999998, + "value_negative_zero": false, + "digits": 4, + "result": 0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999998 + }, + { + "name": "half-1-1--1e-9", + "value": 0.00014999999989999998, + "value_negative_zero": false, + "digits": 4, + "result": 0.0001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.499999999 + }, + { + "name": "half-1-1--5e-10", + "value": 0.00014999999995, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.4999999995 + }, + { + "name": "half-1-1-0", + "value": 0.00015, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.4999999999999998 + }, + { + "name": "half-1-1-5e-10", + "value": 0.00015000000005, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 1.5000000005 + }, + { + "name": "half-1-1-1e-9", + "value": 0.00015000000010000002, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.500000001 + }, + { + "name": "half-1-1-2e-9", + "value": 0.0001500000002, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 1.500000002 + }, + { + "name": "half-1-2--2e-9", + "value": 0.0002499999998, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999998 + }, + { + "name": "half-1-2--1e-9", + "value": 0.0002499999999, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.499999999 + }, + { + "name": "half-1-2--5e-10", + "value": 0.00024999999995, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.4999999995 + }, + { + "name": "half-1-2-0", + "value": 0.00025, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5 + }, + { + "name": "half-1-2-5e-10", + "value": 0.00025000000005, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5000000005 + }, + { + "name": "half-1-2-1e-9", + "value": 0.0002500000001, + "value_negative_zero": false, + "digits": 4, + "result": 0.0002, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 2.5000000009999996 + }, + { + "name": "half-1-2-2e-9", + "value": 0.0002500000002, + "value_negative_zero": false, + "digits": 4, + "result": 0.0003, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 2.500000002 + }, + { + "name": "half-1-10--2e-9", + "value": 0.0010499999998, + "value_negative_zero": false, + "digits": 4, + "result": 0.001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999998 + }, + { + "name": "half-1-10--1e-9", + "value": 0.0010499999999, + "value_negative_zero": false, + "digits": 4, + "result": 0.001, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.499999999 + }, + { + "name": "half-1-10--5e-10", + "value": 0.00104999999995, + "value_negative_zero": false, + "digits": 4, + "result": 0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.4999999995 + }, + { + "name": "half-1-10-0", + "value": 0.00105, + "value_negative_zero": false, + "digits": 4, + "result": 0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5 + }, + { + "name": "half-1-10-5e-10", + "value": 0.00105000000005, + "value_negative_zero": false, + "digits": 4, + "result": 0.001, + "result_negative_zero": false, + "branch": "half-even", + "scaled": 10.5000000005 + }, + { + "name": "half-1-10-1e-9", + "value": 0.0010500000001, + "value_negative_zero": false, + "digits": 4, + "result": 0.0011, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000001 + }, + { + "name": "half-1-10-2e-9", + "value": 0.0010500000002, + "value_negative_zero": false, + "digits": 4, + "result": 0.0011, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 10.500000002000002 + }, + { + "name": "negative-zero", + "value": 0, + "value_negative_zero": true, + "digits": 4, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "positive-zero", + "value": 0, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0 + }, + { + "name": "negative-small", + "value": -1e-7, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": true, + "branch": "math-round", + "scaled": -0.001 + }, + { + "name": "negative-half", + "value": -0.00005, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "half-even", + "scaled": -0.5 + }, + { + "name": "positive-small", + "value": 1e-7, + "value_negative_zero": false, + "digits": 4, + "result": 0, + "result_negative_zero": false, + "branch": "math-round", + "scaled": 0.001 + } + ] +} diff --git a/packages/ghfind-py/tests/test_rounding_extremes.py b/packages/ghfind-py/tests/test_rounding_extremes.py new file mode 100644 index 00000000..4f533c10 --- /dev/null +++ b/packages/ghfind-py/tests/test_rounding_extremes.py @@ -0,0 +1,84 @@ +"""Regression coverage for synthetic values outside normal scoring ranges.""" +import json +import math +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path + +from ghfind._rounding import round_half_even +from ghfind.local import score_metrics, verify_scan + +PACKAGE = Path(__file__).resolve().parents[1] +FIXTURE = PACKAGE.parents[1] / "scoring/fixtures/rounding-parity.json" +BASE_METRICS = json.loads(FIXTURE.read_text(encoding="utf-8"))["base_metrics"] + + +class FiniteRoundingRegressionTests(unittest.TestCase): + def test_large_negative_finite_age_retains_finite_score(self): + metrics = {**BASE_METRICS, "account_age_years": -1e308} + expected = round((-1e308 / 6.0) * 7, 1) + result = score_metrics(metrics) + self.assertTrue(math.isfinite(result["sub_scores"]["account_maturity"])) + self.assertEqual(result["sub_scores"]["account_maturity"], expected) + self.assertEqual(result["base_score"], expected) + + def test_large_negative_activity_retains_finite_score(self): + metrics = {**BASE_METRICS, "activity_type_count": -1e308} + expected = round(-1e308 * 1.125, 1) + result = score_metrics(metrics) + self.assertEqual(result["sub_scores"]["activity_authenticity"], expected) + self.assertTrue(math.isfinite(result["base_score"])) + scan = {"metrics": metrics, "scoring": score_metrics(BASE_METRICS)} + self.assertFalse(verify_scan(scan)["verified"]) + + def test_large_and_nonfinite_values_at_scoring_precisions(self): + for value in (-1e308, 1e308, -1e307, 1e307, -math.inf, math.inf, math.nan): + for digits in (1, 2, 4): + with self.subTest(value=value, digits=digits): + expected = round(value, digits) + result = round_half_even(value, digits) + if math.isnan(expected): + self.assertTrue(math.isnan(result)) + else: + self.assertEqual(result, expected) + + def test_bounded_positive_and_negative_half_even_cases(self): + for value, digits, expected in ((2.25, 1, 2.2), (-2.25, 1, -2.2), + (1.245, 2, 1.24), (-1.245, 2, -1.24), + (0.00625, 4, 0.0062), (-0.00625, 4, -0.0062)): + with self.subTest(value=value, digits=digits): + self.assertEqual(round_half_even(value, digits), expected) + + def test_public_verify_and_cli_for_synthetic_ages(self): + normal = {**BASE_METRICS, "account_age_years": 1.5} + server = score_metrics(normal) + cases = ((1.5, 1.8, True), (-2.0, -2.3, False), (2.0, 2.3, False), + (-1e308, round((-1e308 / 6.0) * 7, 1), False), (1e308, 7.0, False), + (math.nan, math.nan, False), (math.inf, 7.0, False), (-math.inf, -math.inf, False)) + for age, expected, verified in cases: + with self.subTest(age=age): + metrics = {**BASE_METRICS, "account_age_years": age} + scan = {"metrics": metrics, "scoring": server} + maturity = score_metrics(metrics)["sub_scores"]["account_maturity"] + if math.isnan(expected): + self.assertTrue(math.isnan(maturity)) + else: + self.assertEqual(maturity, expected) + self.assertEqual(verify_scan(scan)["verified"], verified) + with tempfile.TemporaryDirectory() as tmp: + path = Path(tmp) / "scan.json" + # NaN and Infinity exercise Python's JSON extensions, not standard JSON. + path.write_text(json.dumps(scan), encoding="utf-8") + # Enter the real module CLI with an explicit source path, including on + # Python's isolated Windows embedded distribution. + launch = "import runpy,sys;sys.path.insert(0,sys.argv.pop(1));runpy.run_module('ghfind',run_name='__main__')" + result = subprocess.run( + [sys.executable, "-I", "-B", "-c", launch, str(PACKAGE), + "verify", str(path), "--json"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False, + ) + self.assertEqual(result.returncode, 0 if verified else 3, result.stderr) + self.assertEqual(result.stderr, b"") + self.assertEqual(json.loads(result.stdout.decode("utf-8"))["verified"], verified) diff --git a/packages/ghfind-py/tests/test_rounding_parity.py b/packages/ghfind-py/tests/test_rounding_parity.py new file mode 100644 index 00000000..5cab1599 --- /dev/null +++ b/packages/ghfind-py/tests/test_rounding_parity.py @@ -0,0 +1,40 @@ +"""The Python port matches the shared TypeScript/Go rounding cases.""" +import json +import unittest +from pathlib import Path + +from ghfind._score import _math_round, score +from ghfind._rounding import round_half_even + +FIXTURE = Path(__file__).resolve().parents[3] / "scoring/fixtures/rounding-parity.json" +DATA = json.loads(FIXTURE.read_text(encoding="utf-8")) + + +class RoundingParityTests(unittest.TestCase): + def test_scaled_midpoint_tolerance_and_math_round_remain_distinct(self): + for case in DATA["rounding_edges"]: + with self.subTest(case=case): + self.assertEqual(round_half_even(case["value"], case["digits"]), case["expected"]) + self.assertEqual(_math_round(2.5), 3) + self.assertEqual(round_half_even(2.5), 2) + + def test_shared_scoring_and_risk_cases(self): + for case in DATA["cases"]: + result = score({**DATA["base_metrics"], **case["overrides"]}) + expected = case["expected"] + for field in ("sub_scores", "base_score", "final_score", "total_penalty"): + with self.subTest(case=case["name"], field=field): + self.assertEqual(result[field], expected[field]) + risk = result["risk_assessment"] + for field in ("coverage", "confidence", "risk_score", "applied_penalty"): + with self.subTest(case=case["name"], field="risk." + field): + self.assertEqual(risk[field], expected["risk"][field]) + signals = [ + {**{key: signal[key] for key in ("flag", "severity", "confidence", "penalty")}, + "coverage": signal["evidence"]["coverage"], + "observed": {key: value for key, value in signal["evidence"]["observed"].items() + if key in ("smoothed_rate", "wilson_lower", "follower_ratio")}} + for signal in risk["signals"] + ] + with self.subTest(case=case["name"], field="risk.signals"): + self.assertEqual(signals, expected["risk"]["signals"]) diff --git a/packages/ghfind-py/tests/test_rounding_v3_reference.py b/packages/ghfind-py/tests/test_rounding_v3_reference.py new file mode 100644 index 00000000..0ea06808 --- /dev/null +++ b/packages/ghfind-py/tests/test_rounding_v3_reference.py @@ -0,0 +1,66 @@ +"""Regressions against synthetic scans produced by the TypeScript scorer.""" +import json +import math +from pathlib import Path +import subprocess +import sys +import tempfile +import unittest + +from ghfind._rounding import round_half_even +from ghfind.local import score_metrics, verify_scan + +PACKAGE = Path(__file__).resolve().parents[1] +REFERENCE = json.loads((Path(__file__).parent / "fixtures/rounding-v3-ts.json").read_text(encoding="utf-8")) + + +def negative_zero(value): + return value == 0 and math.copysign(1.0, value) < 0 + + +class TypeScriptRoundingRegressionTests(unittest.TestCase): + def test_large_finite_public_score_and_verify(self): + for name, field in (("age_edge", "account_maturity"), ("activity_edge", "activity_authenticity")): + scan = REFERENCE["scans"][name] + with self.subTest(name=name): + score = score_metrics(scan["metrics"]) + self.assertEqual(score["sub_scores"][field], scan["scoring"]["sub_scores"][field]) + self.assertTrue(verify_scan(scan)["verified"]) + + def test_large_finite_actual_module_cli(self): + for name in ("normal", "age_edge", "activity_edge"): + scan = REFERENCE["scans"][name] + with self.subTest(name=name), tempfile.TemporaryDirectory() as directory: + path = Path(directory) / "scan.json" + path.write_text(json.dumps(scan, allow_nan=False), encoding="utf-8") + launch = ("import runpy,sys\n" + "sys.path.insert(0,sys.argv.pop(1))\n" + "def audit(event,args):\n" + " if event.startswith('socket.'): raise RuntimeError('network disabled')\n" + "sys.addaudithook(audit)\n" + "runpy.run_module('ghfind',run_name='__main__')") + proc = subprocess.run([sys.executable, "-I", "-B", "-c", launch, str(PACKAGE), + "verify", str(path), "--json"], + stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False) + self.assertEqual(proc.returncode, 0, (proc.stdout, proc.stderr)) + self.assertTrue(json.loads(proc.stdout)["verified"]) + + def test_public_score_and_verify_retain_negative_zero(self): + scan = REFERENCE["scans"]["negative_zero"] + self.assertTrue(REFERENCE["public_negative_zero"]) + score = score_metrics(scan["metrics"]) + self.assertTrue(negative_zero(score["sub_scores"]["account_maturity"])) + verified = verify_scan(scan) + self.assertTrue(verified["verified"]) + self.assertTrue(negative_zero(verified["local"]["sub_scores"]["account_maturity"])) + + def test_typescript_boundary_values_and_zero_signs(self): + cases = REFERENCE["helper"] + self.assertEqual(len(cases), 213) + for case in cases: + with self.subTest(name=case["name"], digits=case["digits"], branch=case["branch"]): + value = -0.0 if case["value_negative_zero"] else case["value"] + result = round_half_even(value, case["digits"]) + self.assertEqual(result, case["result"]) + if result == 0: + self.assertEqual(negative_zero(result), case["result_negative_zero"]) diff --git a/scoring/fixtures/rounding-parity.json b/scoring/fixtures/rounding-parity.json new file mode 100644 index 00000000..2a2366a6 --- /dev/null +++ b/scoring/fixtures/rounding-parity.json @@ -0,0 +1,862 @@ +{ + "description": "Synthetic offline inputs; expected fields generated by the unchanged TypeScript scorer.", + "base_metrics": { + "username": "synthetic-fixture", + "profile_url": null, + "avatar_url": null, + "name": null, + "bio": null, + "company": null, + "account_age_years": 0, + "created_at": null, + "followers": 0, + "following": 0, + "public_repos": 0, + "fetched_repo_count": 0, + "original_repo_count": 0, + "nonempty_original_repo_count": 0, + "fork_repo_count": 0, + "empty_original_repo_count": 0, + "total_stars": 0, + "max_stars": 0, + "merged_pr_count": 0, + "total_pr_count": 0, + "issues_created": 0, + "last_year_contributions": 0, + "activity_type_count": 0, + "contribution_years_active": 0, + "days_since_last_activity": null, + "recent_merged_pr_sample": 0, + "recent_trivial_pr_count": 0, + "external_trivial_pr_count": 0, + "max_impact_repo_stars": 0, + "impact_pr_count": 0, + "impact_depth_raw": 0, + "star_inflation_suspect": false, + "closed_unmerged_pr_count": 0, + "pr_rejection_rate": 0, + "recent_pr_sample": 0, + "top_repo_pr_target": null, + "top_repo_pr_share": 0, + "templated_pr_ratio": 0, + "pr_flood_suspect": false + }, + "cases": [ + { + "name": "age-09-below", + "overrides": { + "account_age_years": 0.89999999 + }, + "expected": { + "sub_scores": { + "account_maturity": 1, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 1, + "final_score": 1, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-09-tie", + "overrides": { + "account_age_years": 0.9 + }, + "expected": { + "sub_scores": { + "account_maturity": 1, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 1, + "final_score": 1, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-09-above", + "overrides": { + "account_age_years": 0.9000000100000001 + }, + "expected": { + "sub_scores": { + "account_maturity": 1.1, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 1.1, + "final_score": 1.1, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-15-control", + "overrides": { + "account_age_years": 1.5 + }, + "expected": { + "sub_scores": { + "account_maturity": 1.8, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 1.8, + "final_score": 1.8, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-27-below", + "overrides": { + "account_age_years": 2.6999999900000002 + }, + "expected": { + "sub_scores": { + "account_maturity": 3.1, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 3.1, + "final_score": 3.1, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "burst_then_dormant", + "severity": 0.5, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-27-tie", + "overrides": { + "account_age_years": 2.7 + }, + "expected": { + "sub_scores": { + "account_maturity": 3.2, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 3.2, + "final_score": 3.2, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "burst_then_dormant", + "severity": 0.5, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "age-27-above", + "overrides": { + "account_age_years": 2.70000001 + }, + "expected": { + "sub_scores": { + "account_maturity": 3.2, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 3.2, + "final_score": 3.2, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "burst_then_dormant", + "severity": 0.5, + "confidence": 0, + "penalty": 0, + "coverage": { + "repo": 0, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + }, + { + "name": "coverage-below", + "overrides": { + "account_age_years": 1.5, + "public_repos": 161, + "fetched_repo_count": 1, + "followers": 1, + "following": 160 + }, + "expected": { + "sub_scores": { + "account_maturity": 1.8, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 1.5, + "activity_authenticity": 0 + }, + "base_score": 3.3, + "final_score": 3.3, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0.25, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "follow_farming", + "severity": 0.9688, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": { + "follower_ratio": 0.0062 + } + } + ] + } + } + }, + { + "name": "coverage-tie", + "overrides": { + "account_age_years": 1.5, + "public_repos": 160, + "fetched_repo_count": 1, + "followers": 1, + "following": 160 + }, + "expected": { + "sub_scores": { + "account_maturity": 1.8, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 1.5, + "activity_authenticity": 0 + }, + "base_score": 3.3, + "final_score": 3.3, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0.25, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "follow_farming", + "severity": 0.9688, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0062, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": { + "follower_ratio": 0.0062 + } + } + ] + } + } + }, + { + "name": "coverage-above", + "overrides": { + "account_age_years": 1.5, + "public_repos": 159, + "fetched_repo_count": 1, + "followers": 1, + "following": 160 + }, + "expected": { + "sub_scores": { + "account_maturity": 1.8, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 1.5, + "activity_authenticity": 0 + }, + "base_score": 3.3, + "final_score": 3.3, + "total_penalty": 0, + "risk": { + "coverage": { + "repo": 0.0063, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 0.25, + "risk_score": 0, + "applied_penalty": 0, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0063, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "ghost_profile", + "severity": 0.6, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0063, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "follow_farming", + "severity": 0.9688, + "confidence": 0.0025, + "penalty": 0, + "coverage": { + "repo": 0.0063, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": { + "follower_ratio": 0.0062 + } + } + ] + } + } + }, + { + "name": "social-penalty-cent-tie", + "overrides": { + "account_age_years": 6, + "public_repos": 1, + "fetched_repo_count": 1, + "followers": 0, + "following": 4500, + "total_stars": 500, + "max_stars": 500, + "star_inflation_suspect": true, + "top_repo_engagement_ratio": 0.019175 + }, + "expected": { + "sub_scores": { + "account_maturity": 7, + "original_project_quality": 0, + "contribution_quality": 0, + "ecosystem_impact": 0, + "community_influence": 0, + "activity_authenticity": 0 + }, + "base_score": 7, + "final_score": 1.84, + "total_penalty": 5.16, + "risk": { + "coverage": { + "repo": 1, + "merged_pr": 0, + "all_pr": 0 + }, + "confidence": 40, + "risk_score": 20.64, + "applied_penalty": 5.16, + "signals": [ + { + "flag": "no_original_work", + "severity": 0.7, + "confidence": 0.4, + "penalty": 0, + "coverage": { + "repo": 1, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "burst_then_dormant", + "severity": 0.5, + "confidence": 0.4, + "penalty": 0, + "coverage": { + "repo": 1, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + }, + { + "flag": "follow_farming", + "severity": 1, + "confidence": 0.4, + "penalty": 4.5, + "coverage": { + "repo": 1, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": { + "follower_ratio": 0 + } + }, + { + "flag": "possible_star_inflation", + "severity": 0.0412, + "confidence": 0.4, + "penalty": 0.66, + "coverage": { + "repo": 1, + "merged_pr": 0, + "all_pr": 0 + }, + "observed": {} + } + ] + } + } + } + ], + "rounding_edges": [ + { + "value": 2.5, + "digits": 0, + "expected": 2 + }, + { + "value": 3.5, + "digits": 0, + "expected": 4 + }, + { + "value": -2.5, + "digits": 0, + "expected": -2 + }, + { + "value": -3.5, + "digits": 0, + "expected": -4 + }, + { + "value": 1.0499999998, + "digits": 1, + "expected": 1 + }, + { + "value": 1.04999999999, + "digits": 1, + "expected": 1 + }, + { + "value": 1.05, + "digits": 1, + "expected": 1 + }, + { + "value": 1.05000000001, + "digits": 1, + "expected": 1 + }, + { + "value": 1.0500000002, + "digits": 1, + "expected": 1.1 + }, + { + "value": 2.675, + "digits": 2, + "expected": 2.68 + }, + { + "value": 5.165, + "digits": 2, + "expected": 5.16 + }, + { + "value": -2.675, + "digits": 2, + "expected": -2.68 + }, + { + "value": 0.006249999999800001, + "digits": 4, + "expected": 0.0062 + }, + { + "value": 0.006249999999980001, + "digits": 4, + "expected": 0.0062 + }, + { + "value": 0.00625, + "digits": 4, + "expected": 0.0062 + }, + { + "value": 0.00625000000002, + "digits": 4, + "expected": 0.0062 + }, + { + "value": 0.0062500000002, + "digits": 4, + "expected": 0.0063 + } + ] +} diff --git a/scoring/rounding_parity_test.go b/scoring/rounding_parity_test.go new file mode 100644 index 00000000..f65b5cc4 --- /dev/null +++ b/scoring/rounding_parity_test.go @@ -0,0 +1,86 @@ +package scoring + +import ( + "encoding/json" + "os" + "reflect" + "testing" +) + +func TestSharedRoundingParity(t *testing.T) { + contents, err := os.ReadFile("fixtures/rounding-parity.json") + if err != nil { + t.Fatal(err) + } + var fixture struct { + BaseMetrics map[string]json.RawMessage `json:"base_metrics"` + RoundingEdges []struct { + Value float64 `json:"value"` + Digits int `json:"digits"` + Expected float64 `json:"expected"` + } `json:"rounding_edges"` + Cases []struct { + Name string `json:"name"` + Overrides map[string]json.RawMessage `json:"overrides"` + Expected any `json:"expected"` + } `json:"cases"` + } + if err := json.Unmarshal(contents, &fixture); err != nil { + t.Fatal(err) + } + for _, edge := range fixture.RoundingEdges { + if got := roundToEven(edge.Value, edge.Digits); got != edge.Expected { + t.Errorf("roundToEven(%v, %d) = %v, want %v", edge.Value, edge.Digits, got, edge.Expected) + } + } + if roundJS(2.5) != 3 { + t.Fatal("JavaScript Math.round semantics changed") + } + for _, test := range fixture.Cases { + t.Run(test.Name, func(t *testing.T) { + metrics := make(map[string]json.RawMessage) + for key, value := range fixture.BaseMetrics { + metrics[key] = value + } + for key, value := range test.Overrides { + metrics[key] = value + } + encoded, err := json.Marshal(metrics) + if err != nil { + t.Fatal(err) + } + var input RawMetrics + if err := json.Unmarshal(encoded, &input); err != nil { + t.Fatal(err) + } + result := Score(input) + risk := result.RiskAssessment + signals := make([]any, 0, len(risk.Signals)) + for _, s := range risk.Signals { + observed := make(map[string]any) + for _, key := range []string{"smoothed_rate", "wilson_lower", "follower_ratio"} { + if value, ok := s.Evidence.Observed[key]; ok { + observed[key] = value + } + } + signals = append(signals, map[string]any{"flag": s.Flag, "severity": s.Severity, "confidence": s.Confidence, "penalty": s.Penalty, "coverage": s.Evidence.Coverage, "observed": observed}) + } + actual := map[string]any{ + "sub_scores": result.SubScores, "base_score": result.BaseScore, "final_score": result.FinalScore, "total_penalty": result.TotalPenalty, + "risk": map[string]any{"coverage": risk.Coverage, "confidence": risk.Confidence, "risk_score": risk.RiskScore, "applied_penalty": risk.AppliedPenalty, "signals": signals}, + } + encoded, err = json.Marshal(actual) + if err != nil { + t.Fatal(err) + } + var normalized any + if err := json.Unmarshal(encoded, &normalized); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(normalized, test.Expected) { + expected, _ := json.Marshal(test.Expected) + t.Errorf("rounding mismatch\ngot: %s\nwant: %s", encoded, expected) + } + }) + } +} diff --git a/scoring/test/rounding-parity.test.ts b/scoring/test/rounding-parity.test.ts new file mode 100644 index 00000000..0c76029b --- /dev/null +++ b/scoring/test/rounding-parity.test.ts @@ -0,0 +1,41 @@ +import { describe, expect, it } from "vitest"; +import { roundHalfEven, score } from "../src/score"; +import type { RawMetrics } from "../src/types"; +import fixture from "../fixtures/rounding-parity.json"; + +describe("shared rounding parity", () => { + it("rounds tolerance boundaries in each supported precision", () => { + for (const edge of fixture.rounding_edges) { + expect(roundHalfEven(edge.value, edge.digits)).toBe(edge.expected); + } + expect(Math.round(2.5)).toBe(3); + }); + for (const test of fixture.cases) { + it(test.name, () => { + const result = score({ ...fixture.base_metrics, ...test.overrides } as RawMetrics); + const risk = result.risk_assessment!; + expect({ + sub_scores: result.sub_scores, + base_score: result.base_score, + final_score: result.final_score, + total_penalty: result.total_penalty, + risk: { + coverage: risk.coverage, + confidence: risk.confidence, + risk_score: risk.risk_score, + applied_penalty: risk.applied_penalty, + signals: risk.signals.map((signal) => ({ + flag: signal.flag, + severity: signal.severity, + confidence: signal.confidence, + penalty: signal.penalty, + coverage: signal.evidence.coverage, + observed: Object.fromEntries(Object.entries(signal.evidence.observed).filter( + ([key]) => ["smoothed_rate", "wilson_lower", "follower_ratio"].includes(key), + )), + })), + }, + }).toEqual(test.expected); + }); + } +});