← Back to Pull requests

--thermal: Return data instead of only printing it #369

Closed
unknown closed this pull request without merging on Sep 16, 2026 14:57 UTC
View on GitHub
unknown unknown commented on Aug 26, 2026 14:11 UTC
Author

Towards #357.

print_thermal and print_thermal_thresholds did the EC reads, the decoding and the formatting in one function, so nothing but the commandline tool could get at the data.

This splits them in two:

| Read the data | Print it |
| --- | --- |
| get_thermal(&CrosEc) -> EcResult<ThermalInfo> | print_thermal(&CrosEc) |
| get_thermal_thresholds(&CrosEc) -> Option<Vec<ThermalThresholds>> | print_thermal_thresholds(&CrosEc) -> Option<()> |

The print functions keep their signatures and their output, they just call the getter and format what comes back.

The decoded values get types instead of raw memmap bytes:

  • TempSensor is pub now. It was private, so nothing outside power.rs could name a temperature reading even where one was already being returned.

  • Fan speeds decode into FanSpeed::{Rpm, Stalled, NotPresent} instead of comparing against 0xFFFE / 0xFFFF at print time.

  • Disabled thresholds are None rather than the string "-".

  • AP throttle status is Option<ApThrottleInfo> with real bools.
  • So a consumer can now do:

    let thermal = power::get_thermal(&ec)?;
    for fan in &thermal.fans {
        if let FanSpeed::Rpm(rpm) = fan.speed {
            println!("{}: {} RPM", fan.name, rpm);
        }
    }
    

    One intentional behaviour change

    print_thermal used .unwrap() on both memmap reads, so a failed read panicked. It now prints Failed to read thermal information: ... and returns.

    Verified

  • cargo fmt --all -- --check is clean, and so is cargo clippy -p framework_lib -- -D warnings

  • cargo check passes for Linux, Windows, FreeBSD and UEFI (--features uefi)

  • cargo doc with RUSTDOCFLAGS=-Dwarnings is clean

  • cargo test -p framework_lib: 45 passed, 0 failed

  • The CLI output is unchanged. The old and new threshold formatting paths produce identical strings for 0..=100000 K plus the edge values.

  • Added four tests for the decoding, power.rs had none before.
  • Two things I could not check locally, both because I develop on macOS, which this project doesn't target: clippy on framework_tool (its libusb1-sys dependency needs a Linux C toolchain to cross-compile) and the EC reads themselves, since no machine here is a Framework one. CI covers the first. For the second, worth running --thermal and --thermalget once on real hardware before merging.

    Scope

    I stopped at thermals because you said that file was the messiest and @mysticmalard mentioned it was where they were headed next. The same treatment still applies to print_sensors, print_switches, get_and_print_power_info, get_and_print_pd_info, get_and_print_cypd_pd_info and the print_fw{12,13,16}_inputdeck_status methods.

    Happy to keep going if this shape looks right to you.

    Diff: 349 lines (+261 / -88) across 4 files Reviewer: blackdragoon26 Review duration: 30285m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 349 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.350
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #369"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.4% (MEDIUM) · Higher = larger blast radius
    42.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.8% · Safe to merge
    16.8%