Skip to content

fix(scoring): defensive max(0, ...) age guards + testable current_year param - #5660

Merged
Scottcjn merged 2 commits into
mainfrom
synthesis/current-year-age-scoring-and-arch-detection-2026-05-18
May 18, 2026
Merged

Scottcjn merged 2 commits into
mainfrom
synthesis/current-year-age-scoring-and-arch-detection-2026-05-18

Conversation

@Scottcjn

Copy link
Copy Markdown
Owner

Synthesis of the current-year-age-scoring cluster (2026-05-18)

This PR adds two defensive guards that the per-author cluster work for hardcoded 2025 year-bounds didn't fully apply. Most of the cluster has landed via earlier per-author merges today; this commit just completes it.

What changes

  1. calculate_rust_score_inline (integrated node) — testable current_year=None parameter + max(0, ...) clamp on age bonus
  2. collect_device_oracle (hardware_fingerprint) — max(0, ...) clamp on estimated_age_years against future-dated release_year

Why

A future-dated mfg_year or release_year (sensor error, NTP drift, misconfigured firmware, malicious claim) must not produce a negative age that corrupts scoring downstream. ethever's #4942 introduced this defensive pattern; this PR applies it to the two scoring paths that hadn't yet picked it up.

Cluster credit

Bounty credit splits across the five contributors per first-poster rule on each file's distinct contribution.

…r param

Synthesis of the current-year-age-scoring cluster (2026-05-18). Most of
the cluster work landed earlier today via per-author merges; this commit
adds the two remaining defensive guards that hadn't been picked up:

1. `calculate_rust_score_inline` (node/rustchain_v2_integrated_v2.2.1_rip200.py)
   - Adds optional `current_year=None` parameter for deterministic testing
   - Clamps age bonus with `max(0, ...)` so a future-dated `mfg_year`
     (sensor error, misconfigured firmware) cannot reduce the score
     below the no-age baseline

2. `collect_device_oracle` (node/hardware_fingerprint.py)
   - Clamps `estimated_age_years` with `max(0, ...)` against a
     future-dated release_year (NTP drift, bogus platform claim)

## Credit / cluster contributors

This is a synthesis of work from multiple contributors who independently
identified and patched hardcoded `2025` year-bounds across the codebase.
All filed the same week:

- @saim256 (#4595) — first-poster on `node/hall_of_rust.py`
  `calculate_rust_score` current-year fix
- @slashdevcorpse (#4629) — extended `node/hall_of_rust.py` with
  testable `current_year=None` parameter + 155-line regression suite
- @galpetame (#4938) — first-poster on `node/hardware_fingerprint.py`
  `_current_utc_year()` helper + `collect_device_oracle` age update,
  and `calculate_rust_score_inline` current-year fix
- @ethever (#4932, #4942) — testable `current_year=None` parameter
  pattern + `max(0, ...)` defensive clamp in
  `tools/validator_core_with_badge.py` and the integrated-node
  rust-score helper. **This commit applies that defensive pattern to
  the integrated-node scoring path that hadn't yet picked it up.**
- @junn-dev (#5659) — `cpu_architecture_detection.py` regex
  negative-lookahead anti-collision (Nehalem patterns no longer match
  i7-7900K-era brand strings) and additional brand-string alternates
  (`Core i7-920` without `(R)/(TM)`)

The earlier merges that landed pieces of this cluster:
- The `_current_utc_year()` helpers in `hall_of_rust.py` and
  `hardware_fingerprint.py`
- The `calculate_rust_score(machine, current_year=None)` signature in
  `hall_of_rust.py`
- The `simulate_entropy_score` `current_year=None` parameter in
  `validator_core_with_badge.py`
- The `_current_utc_year()` in `calculate_rust_score_inline`
- The `(?!\d)` Intel-generation pattern guards in
  `cpu_architecture_detection.py`

This commit completes the synthesis with the two remaining defensive
guards that ethever's pattern specifically called for. Bounty credit
splits across the five contributors above per first-poster rule on
each file's distinct contribution.

Co-Authored-By: saim256 <saim256@users.noreply.github.com>
Co-Authored-By: slashdevcorpse <slashdevcorpse@users.noreply.github.com>
Co-Authored-By: galpetame <galpetame@users.noreply.github.com>
Co-Authored-By: ethever <ethever@users.noreply.github.com>
Co-Authored-By: junn-dev <junn-dev@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/S PR: 11-50 lines labels May 18, 2026
@github-actions

github-actions Bot commented May 18, 2026 •

Copy link
Copy Markdown
Contributor

✅ BCOS v2 Scan Results

Metric Value
Trust Score 60/100
Certificate ID BCOS-6a6af664
Tier L1 (met)

BCOS Badge

What does this mean?

The BCOS (Beacon Certified Open Source) engine scans for:

  • SPDX license header compliance
  • Known CVE vulnerabilities (OSV database)
  • Static analysis findings (Semgrep)
  • SBOM completeness
  • Dependency freshness
  • Test infrastructure evidence
  • Review attestation tier

Full report | What is BCOS?


BCOS v2 Engine - Free & Open Source (MIT) - Elyan Labs

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jaxint jaxint left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work on this PR. 🚀

This was referenced May 18, 2026

@HCIE2054 HCIE2054 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Scottcjn
Scottcjn merged commit a7a689f into main May 18, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants