Skip to content

feat(fetcher): extend system kind with CPU/memory/kernel/DMI/env identifiers - #225

Merged
unhappychoice merged 2 commits into
mainfrom
feat/system-info-kinds
May 12, 2026
Merged

unhappychoice merged 2 commits into
mainfrom
feat/system-info-kinds

Conversation

@unhappychoice

@unhappychoice unhappychoice commented May 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds 25 single-Text kind variants to the omnibus system fetcher, ticking the Extend system kind checkbox in #62. Covers static identifier reads grouped as: CPU (model / cores / frequency / vendor), memory totals (memory / swap), kernel (name / version), Linux DMI hardware IDs (host / board / BIOS / chassis), locale / timezone, env tools ($EDITOR / $VISUAL / $PAGER), and desktop session (DE / WM / init system).

  • Static reads (CPU model, memory total, etc.) cached in OnceLock since they don't change after boot.
  • cpu_frequency falls back to /proc/cpuinfo when sysinfo returns 0 (WSL, some containers).
  • DMI reads land in a new system_dmi module isolating the Linux-specific /sys/class/dmi/id/* paths; macOS / Windows return "n/a" until IOKit / WMI bindings land.
  • chassis_type mapped via the SMBIOS 7.4.1 code table.
  • Env-driven fallbacks normalized to "(unset)" so labels and values don't collide visually.
  • All variants are single Text reads, Safety::Safe, realtime; no new shape, no new fetcher, no new registration step.

Deferred to follow-up: gpu_model / gpu_vendor / gpu_driver (needs NVML or a PCI ID lookup table) and keymap (Linux /etc/vconsole.conf parser).

Reference

kind values added

Group Values
CPU cpu_model, cpu_cores, cpu_frequency, cpu_vendor
Memory memory_total, swap_total
Kernel kernel, kernel_version
DMI (Linux) host_model, host_vendor, host_serial, board_vendor, board_model, bios_vendor, bios_version, bios_date, chassis
Locale locale, timezone
Env tools editor, visual, pager
Desktop de, wm, init_system

Sample output (WSL2 host)

cpu model  : 13th Gen Intel(R) Core(TM) i9-13900
cpu cores  : 16 cores / 32 threads
cpu freq   : 3000 MHz
cpu vendor : GenuineIntel
memory     : 31.3 GB
swap       : 8.0 GB
kernel     : Linux
kernel ver : 6.6.114.1-microsoft-standard-WSL2
host model : n/a    # WSL does not expose /sys/class/dmi
locale     : C.UTF-8
timezone   : Asia/Tokyo
editor     : (unset)
init       : systemd

Reference page (auto-generated): docs-site/src/content/docs/reference/fetchers/system/system.md.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (2200 tests, all green)
  • cargo run --bin splashboard -- catalog fetcher system shows the expanded kind schema
  • Smoke-tested via a temporary .splashboard/dashboard.toml with cargo run --bin splashboard on a WSL2 host: every variant renders without panic; sysinfo-cached reads return real values; DMI falls back to "n/a" as designed
  • Sign-off on native Linux / macOS / Windows so DMI behaviour can be confirmed against real hardware

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Expanded system info detection with many new options (CPU specs, memory/swap totals, kernel info, hardware identifiers, locale/timezone, editor/visual/pager, desktop environment/window manager, init system).
    • Added cross-platform hardware-identification readers (DMI/SMBIOS) where available.
  • Tests

    • Added unit tests for new detectors and updated live/system test coverage; fixed a test locking issue.

Review Change Stack

…entifiers

Adds 25 single-Text `kind` variants to the omnibus `system` fetcher, covering
the static identifier reads listed in #62:

- CPU: cpu_model / cpu_cores / cpu_frequency / cpu_vendor (sysinfo, with
  a /proc/cpuinfo fallback for cpu_frequency on WSL and containers where
  sysinfo reports 0)
- Memory: memory_total / swap_total (sysinfo, cached via OnceLock)
- Kernel: kernel / kernel_version
- DMI hardware IDs: host_model / host_vendor / host_serial / board_vendor /
  board_model / bios_vendor / bios_version / bios_date / chassis (Linux reads
  /sys/class/dmi/id/*; non-Linux returns "n/a"; chassis_type code mapped via
  the SMBIOS 7.4.1 table)
- Locale / TZ: locale (LC_ALL > LC_CTYPE > LANG, fallback "C"),
  timezone ($TZ then /etc/localtime symlink)
- Env tools: editor / visual / pager ($EDITOR / $VISUAL / $PAGER, file
  basename, "(unset)" fallback)
- Desktop: de ($XDG_CURRENT_DESKTOP family, "tty" fallback),
  wm ($XDG_SESSION_DESKTOP with wayland/x11 detection),
  init_system (/proc/1/comm on Linux, launchd/wininit elsewhere)

Static identifier reads (CPU model/vendor/freq, memory/swap totals) are
cached in OnceLocks since they don't change after boot. DMI reads live in
a new `system_dmi` module so the per-platform conditionals stay isolated.

GPU (`gpu_model` / `gpu_vendor` / `gpu_driver`) and `keymap` are deferred to
a follow-up: GPU needs NVML or a PCI ID lookup table, keymap needs
/etc/vconsole.conf parsing on Linux only.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05897693-87db-4909-8ab4-4a27d438e1ec

📥 Commits

Reviewing files that changed from the base of the PR and between 2ffb24e and fe7f689.

📒 Files selected for processing (1)
  • src/fetcher/git/stash_count.rs

📝 Walkthrough

Walkthrough

The PR expands SystemFetcher to expose CPU, memory, kernel, DMI/SMBIOS hardware IDs, and environment/locale settings by adding a DMI reader module, extending SystemKind with many new variants, and wiring detection helpers with tests.

Changes

Host Identity Detection Expansion

Layer / File(s) Summary
DMI Module Foundation
src/fetcher/system_dmi.rs
New module provides Linux DMI/SMBIOS hardware-identification reads via nine public functions (host_vendor, host_model, host_serial, board_vendor, board_model, bios_vendor, bios_version, bios_date, chassis) that read from /sys/class/dmi/id/ on Linux and return None on other platforms. Includes chassis_label mapping for SMBIOS chassis-type codes and unit tests.
Module Export and SystemKind Contract Expansion
src/fetcher/mod.rs, src/fetcher/system.rs
system_dmi is exported from the fetcher module. SystemKind enum expands from six to many variants, adding CPU model/cores/frequency/vendor, memory/swap totals, kernel/kernel version, DMI-derived hardware identifiers, and environment/locale options (locale, timezone, editor/visual/pager, desktop environment, window manager, init system).
Integration Setup and Schema Documentation
src/fetcher/system.rs (imports, schema)
OnceLock is imported for caching, system_dmi module is imported, and SYSTEM_OPTION_SCHEMAS type hint/description and SystemFetcher::description() are updated to document the expanded kind surface.
Detection Logic Wiring
src/fetcher/system.rs (resolve_system_kind)
resolve_system_kind dispatches each new SystemKind variant to detection helpers, including CPU/memory caching via OnceLock, DMI lookups via system_dmi, Linux /proc/cpuinfo fallback for CPU frequency, and environment/filesystem readers for kernel, locale, timezone, $EDITOR/$VISUAL/$PAGER basenames, desktop environment, window manager, and init system detection.
Test Coverage for New Detection Variants
src/fetcher/system.rs, src/fetcher/git/stash_count.rs (tests)
Live-output tests include the new SystemKind variants; unit tests added for kernel name mapping, CPU frequency formatting, DMI fallback behavior, environment basename extraction, and the git stash-count test now locks TEST_ENV_LOCK.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I sniff the DMI files in the night,

CPUs hum, locales take flight,
Kernel names and chassis show,
Tiny fetcher learns and grows,
A rabbit cheers: the system's bright.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.04% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: extending the system fetcher with CPU, memory, kernel, DMI, and environment identifiers as the primary objective.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/system-info-kinds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/fetcher/system.rs (1)

207-240: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid per-frame filesystem reads in realtime system text kinds.

resolve_system_kind routes realtime text kinds to helpers that hit disk (system_dmi::*, /etc/localtime path resolution). That breaks the realtime no-I/O contract and can introduce frame jitter.

Suggested direction
+// cache static identifiers once; clone on read
+fn cached_timezone() -> String {
+    static TZ: OnceLock<String> = OnceLock::new();
+    TZ.get_or_init(detect_timezone_uncached).clone()
+}
+
+fn cached_dmi(kind: SystemKind) -> String {
+    // one OnceLock per DMI field (or a single struct cache)
+    // fill from system_dmi::* once, then reuse
+}
-        SystemKind::Timezone => detect_timezone(),
-        SystemKind::HostModel => dmi_or_na(system_dmi::host_model()),
+        SystemKind::Timezone => cached_timezone(),
+        SystemKind::HostModel => cached_host_model(),

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7d0b9b8-d12c-461f-95e0-5749c1d656f0

📥 Commits

Reviewing files that changed from the base of the PR and between e0fceab and 2ffb24e.

📒 Files selected for processing (3)
  • src/fetcher/mod.rs
  • src/fetcher/system.rs
  • src/fetcher/system_dmi.rs

@codecov

codecov Bot commented May 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.39560% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.16%. Comparing base (e0fceab) to head (fe7f689).

Files with missing lines Patch % Lines
src/fetcher/system.rs 84.94% 42 Missing ⚠️
src/fetcher/system_dmi.rs 59.75% 33 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #225      +/-   ##
==========================================
- Coverage   95.28%   95.16%   -0.13%     
==========================================
  Files         160      161       +1     
  Lines       47769    48131     +362     
==========================================
+ Hits        45518    45805     +287     
- Misses       2251     2326      +75     
Files with missing lines Coverage Δ
src/fetcher/git/stash_count.rs 99.33% <100.00%> (+0.01%) ⬆️
src/fetcher/mod.rs 99.10% <ø> (ø)
src/fetcher/system_dmi.rs 59.75% <59.75%> (ø)
src/fetcher/system.rs 92.47% <84.94%> (-1.70%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

`fetch_uses_current_repo_for_default_and_explicit_shapes` calls `open_repo()`
which reads `std::env::current_dir()`. Other tests in the crate (latest_tag,
recent_commits, contributors, code::loc, code::todos, ...) mutate the
process-wide CWD via `set_current_dir` inside `TEST_ENV_LOCK`; this one
didn't take the lock, so when the scheduler interleaved them on CI the
stash_count test would observe a tempdir CWD and fail with
`'/tmp/.tmpXxxx/.git/objects' wasn't a directory`. Mirror the lock pattern
used by `latest_tag.rs::fetch_opens_cwd_repo_for_default_and_entries_shapes`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@unhappychoice
unhappychoice merged commit cc61f1e into main May 12, 2026
7 checks passed
@unhappychoice
unhappychoice deleted the feat/system-info-kinds branch May 12, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant