Compare commits

...
Author SHA1 Message Date
poli0981andClaude Fable 5.1 31b7500768 style: one property per line in the trend test's object initialiser
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 17:46:08 +07:00
poli0981andClaude Fable 5.1 c8a996a929 feat: CPU load, memory and (elevated) CPU temperature are measured; trend metrics per game; Settings shows this PC
Telemetry. sessions.avg_cpu_load / avg_cpu_temp / max_cpu_temp / avg_ram_mb and the cpu_load / cpu_temp / ram_mb
series were in schema 0001 with no producer. TelemetryPoller now reads the machine beside the GPU on the same 1 Hz
tick through ISystemTelemetrySource, and the reading rides each TelemetrySample as a SystemReading - outside GpuSample,
whose capability bits and layer attribution mean nothing here. Two unprivileged Win32 calls, no process opened:
GetSystemTimes (time busy across every logical processor; the first tick has no interval and is null, never 0) and
GlobalMemoryStatusEx. CPU temperature is the one privileged reading: a separate CPU-only LibreHardwareMonitor Computer,
opened only when the Agent is elevated AND PawnIO is installed. It is UNMEASURED on real hardware (20_OPEN_QUESTIONS
M10 carries the one session that settles it). HelloAck.cpuTempAvailable reports those two conditions instead of a
constant false. The .partial sensor chunk carries the three values in bits 12-14 of its existing presence mask, so an
older file reads back with an empty reading. No migration; older sessions keep their nulls.

App. The game page's Trend tab gains average GPU load, average GPU power, max VRAM (game), average CPU load, max CPU
temperature, average memory in use and the xFG factor - a factor that is its session's steady state (rule 6) is a
partial point: left out by default, drawn marked when mid-session changes are included. The Sensors chart draws CPU
temperature, CPU load and system memory; Compare gains three rows; the session summary gains GPU and CPU cards and the
session's hardware snapshot under its header; the live card carries cpuLoadPct. Settings > System states this PC as a
session's snapshot would record it (the same IHardwareSnapshotSource), with Copy; nothing is sent anywhere. --diag
prints it; the bug bundle's sysinfo.json is deliberately unchanged (its keys are the issue link's prefill).

legal/ACCURACY.md and its two embedded copies say what is and is not measured about the processor.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-21 17:42:36 +07:00
59 changed files with 1514 additions and 43 deletions

No files matched your search

+18
View File
@@ -60,6 +60,24 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
### Added
- **CPU load, memory in use and (elevated) CPU temperature are measured.** `sessions.avg_cpu_load`, `avg_cpu_temp`,
`max_cpu_temp` and `avg_ram_mb`, and the `cpu_load` / `cpu_temp` / `ram_mb` sensor series, were in the schema from
0001 with no producer. The telemetry poller now reads the machine beside the GPU on the same 1 Hz tick: CPU time
busy across every logical processor (`GetSystemTimes` — not Task Manager's frequency-scaled "utility") and physical
memory in use, both unprivileged and opening no process. **CPU temperature is read only when the Agent runs as
administrator with PawnIO installed, and has not been checked on real hardware yet**; everywhere else it is N/A,
never 0. Sessions recorded before this keep their nulls; no migration. The live card carries CPU load and
temperature (`SessionProgress.cpuLoadPct`, optional).
- **One game's sessions over time, beyond the frame rate.** The game page's Trend tab gains average GPU load, average
GPU power, max VRAM (game), average CPU load, max CPU temperature, average memory in use, and the **×FG factor**. A
factor that is its session's steady state (rule 6) covers part of the session, so it is left out by default and
drawn marked when "include mid-session changes" is on — never as the session's. The Sensors chart draws CPU
temperature, CPU load and system memory; Compare gains average GPU load, average CPU load and max CPU temperature;
the session summary gains GPU and CPU cards (average load · peak temperature).
- **Settings ▸ System shows this PC** — processor, graphics card and driver, memory, Windows build, primary display —
as FrameLedger records it with every session, with a Copy button; nothing is sent anywhere. The session summary
shows that session's snapshot under its header, and `--diag` prints the machine's. The bug bundle is unchanged.
- **Game page: the row's executable is shown, and "Change executable…" re-points it.** The remedy for a wrong import
guess used to be remove-and-add. The row comes back exactly as a new game would — hooking off, no consent, pre-scan
not run — with consent revoked over the pipe first, as removal does; a block is never cleared by it, and a path
+8 -3
View File
@@ -49,8 +49,13 @@
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Video memory:** in use on the whole graphics card, recorded from Windows and GPU-driver telemetry
> and charted. **Not measured at all:** each game's own video-memory use and budget, which frame
> spikes were shader compilation, PC latency (Reflex), HDR, and CPU temperature. Stutter count and
> stutter time are measured from frame times.
> spikes were shader compilation, PC latency (Reflex), and HDR. Stutter count and stutter time are
> measured from frame times.
> - **Processor and memory:** how busy the processor was (time busy, all cores together — not the
> frequency-scaled figure Task Manager draws) and how much system memory was in use, read from
> Windows once a second and charted. Processor temperature is read only when the Agent runs as
> administrator with PawnIO installed, and that reading has not yet been checked on real hardware;
> everywhere else it is `N/A`.
> - **Safety:** every pre-injection check runs before injection, including the signed-by-a-known-vendor
> half of the suspicious-module rule. During every capture the Agent re-runs the checks every 30 s and
> stops capturing on a refusal: a Direct3D or OpenGL game's hooks are removed, and the Vulkan layer
@@ -124,7 +129,7 @@ Elevation is **optional — for everything.** Hooked capture is the normal path
- Windows 10 (22H2) or Windows 11, 64-bit
- A 64-bit DirectX 11/12 or OpenGL game, or a Vulkan game FrameLedger starts, for hooked (Tier-1) capture. **32-bit games — including most DirectX 9 titles — cannot be measured at all**: the component FrameLedger loads is x64 and an x64 DLL cannot enter a 32-bit process. Such a title records duration and hardware telemetry and nothing else. *(This line previously said "supported at Tier 2 only", which meant frame times without injection. That tier no longer exists.)*
- Optional: [PawnIO](https://pawnio.eu/) for CPU temperature, which is not read yet (GPU telemetry works without it, through your graphics driver's own libraries)
- Optional: [PawnIO](https://pawnio.eu/) for CPU temperature, read only when the Agent runs as administrator (since 0.1.0-beta.3; not yet checked on real hardware). CPU load, memory in use and all GPU telemetry work without it
## Install
+3 -1
View File
@@ -668,7 +668,9 @@ Per session over 1 Hz samples: `avg` (mean of non-null), `max`. Sensor timeline
| Per-process VRAM | exact | not available |
| PC latency | as reported by Reflex | not available |
| GPU temp / load / power | vendor API accuracy, ±1 s sampling | same |
| CPU temperature | sensor-inherent ±1–2 °C, needs LHM + PawnIO + elevation | same |
| CPU temperature | sensor-inherent ±1–2 °C, needs LHM + PawnIO + elevation. **Read since 2026-09-21** (`Telemetry.LhmCpuTemperatureReader`: the package sensor, else the hottest core) and **unmeasured on real hardware** — no elevated run with PawnIO has been taken (`20_OPEN_QUESTIONS` §CPU) | same |
| CPU load | **time busy over elapsed, every logical processor** (`GetSystemTimes`, 1 Hz, unprivileged; since 2026-09-21). Not Task Manager's "utility", which is frequency-scaled and exceeds 100 under turbo — the two are different numbers and this one is stated as what it is. Null on a session's first tick (no interval yet), never 0 | same |
| System memory in use | physical memory in use machine-wide, MiB (`GlobalMemoryStatusEx`, 1 Hz, unprivileged; since 2026-09-21). The machine's, not the game's | same |
> **The Tier-2 column is now "not available" for everything except sensors, and that is the whole change.** It previously claimed frame times within 0.1% without injection. Nothing produces them.
+3
View File
@@ -282,6 +282,9 @@ CREATE TABLE frame_blobs (
CREATE TABLE sensor_blobs (
session_id INTEGER NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
series TEXT NOT NULL, -- cpu_temp|gpu_temp|gpu_hotspot|gpu_load|gpu_power|vram_proc|vram_adapter|cpu_load|ram_mb
-- cpu_load / ram_mb / cpu_temp and sessions.avg_cpu_load, avg_cpu_temp, max_cpu_temp,
-- avg_ram_mb were in schema 0001 with NO producer until 2026-09-21 (Telemetry.SystemTelemetrySource
-- on the poller's tick). Rows before that date hold NULL, which is what they measured; no migration.
hz REAL NOT NULL, codec TEXT NOT NULL, data BLOB NOT NULL,
PRIMARY KEY (session_id, series)
);
+1 -1
View File
@@ -334,7 +334,7 @@ Unchanged in spirit from v1, bumped to `v2` for the new message set.
| `Shutdown` | UI→A | graceful stop → `ShutdownAck`, then the host stops (sessions finalize inside its grace window). *(Built 2026-09-13, PR-1b: `IAgentLifetime`, the host's under `--serve`, a logged no-op under `--console`.)* |
| `SweepRetention` | UI→A | **no payload** — a trigger, like `UpdateRules`: the Agent applies `06_DATA_MODEL` §Retention to every game with the `retention.raw_sessions_per_game` it reads itself → `SweepRetentionAck { keep, games, sessions }` (`keep` 0 = unlimited, and then nothing was swept). *(Built 2026-09-15, P4 PR-7, for Tools ▸ Database maintenance: `Application.Recording.RetentionSweep` over `ISessionRepository.SweepRetentionAllAsync`, composed into `AgentCommandHandler` under `--serve`. The client names no number because the rows are the Agent's (§Writer ownership). Additive: an older Agent answers `Error UnknownType`, which the dialog reads as "restart the Agent". Carries no safety fact.)* |
| `SessionStarted` | A→UI | `{ sessionGuid, gameId, gameName, pid, tier, startedAt }` — **published at the attach**, i.e. when the session becomes Tier 1 and the live card has something to show; a session that never attaches has no `SessionStarted`, only its `SessionCompleted` (tier 2) and, when a refusal or error caused that, the event below that names it |
| `SessionProgress` | A→UI | 1 Hz: `{ sessionGuid, elapsedS, presents5s, presentedFps5s?, presentedQualifier, nativeFps5s?, displayedFps5s?, fgFactor?, fgMode, upscaler?, upscalerQuality?, upscalerDriverReported?, renderW/H?, outputW/H?, rtActive?, gpuTempC?, cpuTempC?, vramProcMb?, latencyUs?, fgRefusal?, fgRuntimeCensus? }` — a 5 s rolling window over the ring through the SAME Domain calculators the row uses (`SessionProgressCalculator`, D13). **`upscalerDriverReported` added 2026-09-21, optional:** `dlss` when the NVIDIA driver reports an NGX super-resolution feature created and evaluated in the target (`03_METRICS` §The driver-reported rung), so the live card says `DLSS (driver-reported)` where no hook can name the upscaler; identity only. **Two fields added 2026-09-14, both optional (an older client ignores them, §C):** `fgRefusal` is the row's `fg_refusal` (schema 0003) — present when `fgMode` names a technology and `fgFactor` is absent, so the live card can say "DLSS-G active — factor not counted" rather than N/A; `fgRuntimeCensus` is the raw census so the `fg_runtime_loaded` chip can name the module. **Rule 6 at the wire (2026-09-13):** `nativeFps5s` / `displayedFps5s` / `fgFactor` are present only when frame generation was measured in the window; otherwise `presentedFps5s` stands alone with `presentedQualifier` (`census_not_run` · `no_fg_runtime` · `fg_runtime_loaded` · `none_withheld`, the row's `presented_qualifier` from the same function). Every unmeasured field is absent, never 0. Suppressed when no client is connected |
| `SessionProgress` | A→UI | 1 Hz: `{ sessionGuid, elapsedS, presents5s, presentedFps5s?, presentedQualifier, nativeFps5s?, displayedFps5s?, fgFactor?, fgMode, upscaler?, upscalerQuality?, upscalerDriverReported?, renderW/H?, outputW/H?, rtActive?, gpuTempC?, cpuTempC?, cpuLoadPct?, vramProcMb?, latencyUs?, fgRefusal?, fgRuntimeCensus? }` — a 5 s rolling window over the ring through the SAME Domain calculators the row uses (`SessionProgressCalculator`, D13). **`upscalerDriverReported` added 2026-09-21, optional:** `dlss` when the NVIDIA driver reports an NGX super-resolution feature created and evaluated in the target (`03_METRICS` §The driver-reported rung), so the live card says `DLSS (driver-reported)` where no hook can name the upscaler; identity only. **`cpuLoadPct` added 2026-09-21, optional** (CPU time busy over the last telemetry tick, 0–100; `cpuTempC` has a producer from the same date, present only when the Agent is elevated with PawnIO). **Two fields added 2026-09-14, both optional (an older client ignores them, §C):** `fgRefusal` is the row's `fg_refusal` (schema 0003) — present when `fgMode` names a technology and `fgFactor` is absent, so the live card can say "DLSS-G active — factor not counted" rather than N/A; `fgRuntimeCensus` is the raw census so the `fg_runtime_loaded` chip can name the module. **Rule 6 at the wire (2026-09-13):** `nativeFps5s` / `displayedFps5s` / `fgFactor` are present only when frame generation was measured in the window; otherwise `presentedFps5s` stands alone with `presentedQualifier` (`census_not_run` · `no_fg_runtime` · `fg_runtime_loaded` · `none_withheld`, the row's `presented_qualifier` from the same function). Every unmeasured field is absent, never 0. Suppressed when no client is connected |
| `SessionCompleted` | A→UI | `{ sessionGuid, sessionId?, exitStatus, tier, finalize, reason }` — UI loads the full row from SQLite; `sessionId` is null and `finalize` is `discarded` when the row was not stored (under the minimum length); `exitStatus` is the row's vocabulary (`normal` · `crashed` · `unhooked_safety` · `degraded`); `reason` is the loop's `SessionEndReason` |
| `CaptureRefused` | A→UI | `{ gameId, gameName, reason, family?, signal? }` — **guard fired**; UI shows the plain-language explanation — ~~and the Tier-2 offer~~; there is no alternative measurement to offer, only the option to record the session unmeasured (`08_UI` §Safety events). *(Built: for `RefusedByGuard`, `RefusedPreviouslyBlocked`, `RefusedKillSwitch` and `PreScanCouldNotVerify` — the last with no family, because "could not verify" is neither a hit nor a pass; `family`/`signal` are the verdict's. A game merely not enabled or not consented raises nothing: that is an ordinary Tier-2 row, not a refusal to explain.)* |
| `CaptureDegraded` | A→UI | `{ sessionGuid, from: 1, to: 2, reason }` — Tier 1 → Tier 2 mid-flight, or overlay self-disabled. **Under a two-rung ladder this means measurement STOPPED**, not that it continued at lower fidelity, and the notice must say so. *(Built: `SupervisionLost`, `WriterSelfDisabled`, `WriterStoppedBlocklisted`, `WriterNeverInstalledHooks`, `SupervisionFaulted`, `KillSwitchEngaged` — `RecordedSessionEvents.Classify` is the table.)* |
+2
View File
@@ -252,6 +252,8 @@ Tail view of `ui-*.log` / `agent-*.log` (toggle), level filter, search (`ui:Auto
### Settings
Sections per FR-10 using the WPF UI settings idiom: `ui:CardControl`/`ui:CardExpander` rows with `ToggleSwitch`, `ComboBox`, `ui:NumberBox` (numeric inputs — min session length, sensor interval, retention). Language switch applies immediately (09_I18N). Theme selector (Light/Dark/System) drives `ApplicationThemeManager` (16 §Theming). **Capture section (top, most important):** the global **hooking kill switch** (`ToggleSwitch`, prominent) with a one-line summary of what it does; a list of games currently hook-enabled with a per-game revoke; Vulkan layer registration state + Register/Unregister; a link to the safety documentation. Turning the global switch off must take effect immediately, including for the Vulkan layer.
**System (2026-09-21, FR "show the user's hardware"):** a card above Legal stating this PC as a session's hardware snapshot would record it right now — processor, graphics card, graphics driver, memory, Windows build, primary display — through the same `IHardwareSnapshotSource` the Agent stamps sessions with, read on the thread pool when the page opens, a field that could not be read as N/A, with **Copy** (the same lines as text) and a note that nothing is sent anywhere and what CPU temperature needs. Its own `SystemInfoViewModel`, not `SettingsViewModel`'s. The same snapshot is one tertiary line under the session summary's header (it was loaded for the export and shown nowhere), and `--diag` prints it; the bug bundle's `sysinfo.json` is deliberately NOT given it — its keys are the issue link's prefill.
Agent section: elevation state with a plain explanation of what elevation *optionally* unlocks (CPU temperature, elevated-game attach — ~~ETW fallback~~, which no longer exists) and that it is **not required by any capture tier**; task state, Register/Repair/Remove task, "Start agent at logon", background capture toggle. Privacy: online-metadata opt-in with plain-language explanation. Legal: reopen documents.
> **Built 2026-09-14 (P3 PR-8a), with three rows deferred to PR-8b and one to PR-9.** `SettingsViewModel` over
+15
View File
@@ -112,6 +112,21 @@ L1 gives no temperatures on its own (unless the D3DKMT probe pans out). That is
CPU and motherboard sensors remain LHM-only, elevated-only, PawnIO-dependent, and optional.
> **The machine beside the GPU — built 2026-09-21, and deliberately NOT a fourth layer.** `ISystemTelemetrySource`
> (`Telemetry.SystemTelemetrySource`) is read by `TelemetryPoller` on the same tick as the composite and rides each
> `TelemetrySample` as a `SystemReading` — outside `GpuSample`, because the per-field capability bits and layer
> attribution above mean nothing for "how busy was the CPU". Two unprivileged Win32 calls, no process opened:
> `GetSystemTimes` (busy = (kernel + user) − idle over the interval; kernel INCLUDES idle in that API; the first tick has
> no interval and is null) and `GlobalMemoryStatusEx` (physical memory in use). **CPU temperature is the one privileged
> reading**: `LhmCpuTemperatureReader.TryOpen` opens a SEPARATE `Computer` (CPU group only — L2's stays GPU-only and
> unelevated by design, so the unprivileged layer's behaviour never depends on privilege) only when the process is
> elevated AND `PawnIo.IsInstalled`; it takes the package sensor (`CPU Package`, `Core (Tctl/Tdie)`) and falls back to the
> hottest core. **Unmeasured on real hardware**: exercised against a fake `ILhmComputer` only; the first elevated run
> with PawnIO is the measurement. `HelloAck.cpuTempAvailable` reports those same two conditions (it was a constant
> `false`). A tick only the machine answered is still queued, under a placeholder `GpuSample` with
> `TelemetryLayer.None` and no field. The `.partial` sensor chunk carries the three values in bits 12–14 of the
> existing 16-bit presence mask, so an older file reads back with an empty reading.
## L3 — NVAPI (MIT, NVIDIA only)
**Integration: vendored headers + import library, linked normally. ✅ Vendored 2026-08-05** at `src/native/third_party/nvapi/` — nine headers (`nvapi.h`'s include closure plus `nvapi_interface.h`), `License.txt`, and `amd64/nvapi64.lib`; **x64 only**, `x86/nvapi.lib` deliberately not taken. Consumed through the `fl_nvapi` INTERFACE target. NVIDIA publishes the NVAPI SDK — headers, interface definitions, and `nvapi64.lib` — under the **MIT licence** (verified 2026-08-02 and re-verified on the vendored copy: `amd64/nvapi64.lib` is a tracked file in the MIT repo and `License.txt` names the import libraries as the subject of the grant, so the binary is covered and not only the headers), so the SDK material can live in our GPL-3.0 repository with only the usual MIT attribution obligation. The runtime implementation lives in `nvapi64.dll`, which ships with the installed NVIDIA driver.
+1
View File
@@ -4260,6 +4260,7 @@ instead, which needs no thread at all.
| M7 ✅ | ~~`18_GPU_VENDOR_APIS` §Runtime policy says telemetry is never read from the game process, but `17_HOOK_ENGINE` reads per-process VRAM and Reflex latency there. Reconcile the wording — the rule means "no vendor SDK polling loops in the game", not "no measurement in the game"~~ **Closed 2026-09-09 (PR-E1) by the code taking exactly that shape.** The rule is *no telemetry polling loop in the game*: the one 1 Hz loop is `TelemetryPoller` on the Agent's `fl-telemetry` thread, and it reads L1/L2/L3 only. Per-process VRAM stays an in-process read on the present path (`vram_proc`, `17_HOOK_ENGINE`), and PR-E1 measured why that must be so: `IDXGIAdapter3::QueryVideoMemoryInfo`'s `CurrentUsage` is the *calling process's* figure — 0 bytes from the Agent — so it is a measurement only where the game is. Adapter-wide usage is L1's PDH counter. §Runtime policy's sentence stands as written; this row is the reconciliation |
| M8 ✅ | ~~The `GpuSample` type has no latency field, yet L3 is credited with Reflex/PC latency. Latency is per-frame and arrives via the ring, not the 1 Hz sample. Fix the layering description~~ **Closed 2026-09-09 (PR-E1): the description now matches the type.** `GpuSample` has no latency field by design (its own remarks said so since 2026-09-03), `TelemetrySample` carries a 1 Hz reading stamped with QPC, and per-frame latency is `FlFrameRecord.reflexLatencyUs` in the ring. The §L3 table row "Reflex / PC latency" is an *in-process hook fact* the Overlay records (`SetSleepMode` / `SetLatencyMarker`, `17_HOOK_ENGINE`), never a poller field; `NvapiTelemetrySource` (PR-E2) will not call `NvAPI_D3D_GetLatency` |
| M9 ✅ | **Closed 2026-08-02 by a decision.** The old file/module detection does not exist in this repository and the owner confirmed there is no copy elsewhere, so **"build a minimal static-hint detector as the measurement baseline" is now P0 item 3** (`15_ROADMAP`). It needs no guard and no injection. Until it exists, ADR-7's headline claim stays out of the README rather than being asserted unmeasured |
| M10 ❓ | **§CPU — is the CPU temperature this build reads the right sensor, and does it read at all on the owner's machine?** `LhmCpuTemperatureReader` (2026-09-21) opens a CPU-only LibreHardwareMonitor `Computer` when the Agent is elevated AND `PawnIo.IsInstalled`, takes the package sensor (`CPU Package` / `Core (Tctl/Tdie)`) and falls back to the hottest core. It was written against LHM's sensor names and a fake `ILhmComputer`; **no elevated run with PawnIO has been taken.** | **The measurement is one session:** Agent elevated, PawnIO installed, a five-minute capture with HWiNFO or Ryzen Master open beside it. Pre-committed: `max_cpu_temp` within 3 °C of the reference's package peak → keep; a core sensor picked where a package sensor exists, or a reading tens of degrees off (a distance-to-TjMax sensor mistaken for a temperature) → fix `Pick` and re-run; nothing read at all → `cpu_temp` stays N/A and `legal/ACCURACY.md` says processor temperature is not measured. CPU **load** and memory are not in question: `TheRealCountersAnswerOnThisMachine` reads them on every gate run. |
| M10 ✅ | ~~PDH `\GPU Engine(*)\Utilization Percentage` summed across engines does not reproduce the Task Manager figure the doc invokes. Decide what we actually report and label it accordingly~~ **Decided 2026-09-09 (PR-E1): L1 does not read the engine counters at all.** `LoadPct` is L2's vendor-reported `GPU Core` load (measured ✓ on NVIDIA, §M5 row R1) and is labelled *GPU load (vendor)* wherever it is shown; on a machine without L2 the field is N/A, never a sum that is not the number the user expects. What L1 does read from PDH is one counter, `\GPU Adapter Memory(luid_…_phys_0)\Dedicated Usage`, bound by LUID — the figure Task Manager labels "Dedicated GPU memory", measured 1301 MB at an idle desktop on the RTX 5080. Reopening this needs a measurement of `max(engine)` against Task Manager's own number, not a decision |
#### §M5 — the decision table, pre-committed 2026-09-03 BEFORE the first run
+7 -2
View File
@@ -55,8 +55,13 @@
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Video memory:** in use on the whole graphics card, recorded from Windows and GPU-driver telemetry
> and charted. **Not measured at all:** each game's own video-memory use and budget, which frame
> spikes were shader compilation, PC latency (Reflex), HDR, and CPU temperature. Stutter count and
> stutter time are measured from frame times.
> spikes were shader compilation, PC latency (Reflex), and HDR. Stutter count and stutter time are
> measured from frame times.
> - **Processor and memory:** how busy the processor was (time busy, all cores together — not the
> frequency-scaled figure Task Manager draws) and how much system memory was in use, read from
> Windows once a second and charted. Processor temperature is read only when the Agent runs as
> administrator with PawnIO installed, and that reading has not yet been checked on real hardware;
> everywhere else it is `N/A`.
> - **Safety:** every pre-injection check runs before injection, including the signed-by-a-known-vendor
> half of the suspicious-module rule. During every capture the Agent re-runs the checks every 30 s and
> stops capturing on a refusal: a Direct3D or OpenGL game's hooks are removed, and the Vulkan layer
+7 -2
View File
@@ -116,8 +116,13 @@ Frame timing is derived from high-resolution timestamps taken at the moment the
> calls; the technique and path tracing are `N/A`, and so is ray tracing on other APIs.
> - **Video memory:** in use on the whole graphics card, recorded from Windows and GPU-driver telemetry
> and charted. **Not measured at all:** each game's own video-memory use and budget, which frame
> spikes were shader compilation, PC latency (Reflex), HDR, and CPU temperature. Stutter count and
> stutter time are measured from frame times.
> spikes were shader compilation, PC latency (Reflex), and HDR. Stutter count and stutter time are
> measured from frame times.
> - **Processor and memory:** how busy the processor was (time busy, all cores together — not the
> frequency-scaled figure Task Manager draws) and how much system memory was in use, read from
> Windows once a second and charted. Processor temperature is read only when the Agent runs as
> administrator with PawnIO installed, and that reading has not yet been checked on real hardware;
> everywhere else it is `N/A`.
> - **Safety:** every pre-injection check runs before injection, including the signed-by-a-known-vendor
> half of the suspicious-module rule. During every capture the Agent re-runs the checks every 30 s and
> stops capturing on a refusal: a Direct3D or OpenGL game's hooks are removed, and the Vulkan layer
@@ -21,8 +21,9 @@ internal static class AgentIdentityFactory
// The layer reaches a launched process through VK_ADD_IMPLICIT_LAYER_PATH; the HKCU registration is the
// repair tool --register-vklayer writes (P3 PR-8b), read here as it stands at this process's start.
VulkanLayerRegistered: new VkLayerRegistration().IsRegistered(Path.Combine(vkLayerDirectory, VkLayerLaunchEnvironment.ManifestFileName)),
// AgentRecording.Poller composes LhmComputerAdapter(enableCpuAndMemory: false): no CPU sensor unelevated.
CpuTempAvailable: false,
// The same two conditions SystemTelemetrySource.Create opens the CPU reader under (2026-09-21): elevated AND
// PawnIO installed. It was a constant false while nothing read a CPU sensor at all.
CpuTempAvailable: Infrastructure.Telemetry.LhmEnvironment.IsElevated && Infrastructure.Telemetry.LhmEnvironment.IsPawnIoInstalled == true,
// D14: the FR-2.1 text this build stamps against; the App compares it with its own before showing the dialog.
DisclosureVersion: SafetyDisclosure.Version);
}
@@ -117,6 +117,7 @@ internal sealed class AgentRecording
LhmTelemetrySource? l2 = null;
NvapiTelemetrySource? l3 = null;
CompositeTelemetrySource? composite = null;
SystemTelemetrySource? system = null;
try
{
pdh = new PdhAdapterMemoryCounter();
@@ -131,8 +132,12 @@ internal sealed class AgentRecording
l1 = null;
l2 = null;
l3 = null;
var poller = new TelemetryPoller(composite, new TelemetryPollerOptions { Interval = interval }, TimeProvider.System, ownsSource: true);
// The machine beside the GPU (2026-09-21): CPU busy time and memory unprivileged, the CPU temperature only
// where this process is elevated and PawnIO is installed. The poller owns it with the layers.
system = SystemTelemetrySource.Create();
var poller = new TelemetryPoller(composite, new TelemetryPollerOptions { Interval = interval }, TimeProvider.System, ownsSource: true, system);
composite = null;
system = null;
return poller;
}
finally
@@ -142,6 +147,7 @@ internal sealed class AgentRecording
l2?.Dispose();
l3?.Dispose();
composite?.Dispose();
system?.Dispose();
}
}
+14 -1
View File
@@ -155,7 +155,17 @@ public partial class App : System.Windows.Application
Log.Warning(ex, "diag: the ledger could not be opened; settings are reported at their defaults");
}
string report = DiagReport.Build(UiIdentity.Version, UiPaths.DataDirectory, UiPaths.Logs, schema, values, new AgentLauncher().CanLaunch, now);
Application.Persistence.HardwareSnapshot? hardware = null;
try
{
hardware = new Infrastructure.Recording.HardwareSnapshotSource(new Infrastructure.Telemetry.DxgiAdapters()).Take();
}
catch (Exception ex) when (ex is not OutOfMemoryException)
{
Log.Warning(ex, "diag: the hardware could not be read; its lines are n/a");
}
string report = DiagReport.Build(UiIdentity.Version, UiPaths.DataDirectory, UiPaths.Logs, schema, values, new AgentLauncher().CanLaunch, now, hardware);
string path = DiagReport.Write(UiPaths.Logs, report, now);
await Console.Out.WriteLineAsync(string.Format(CultureInfo.CurrentCulture, Strings.Diag_Written_Format, path)).ConfigureAwait(true);
Log.Information("ui: --diag written to {Path}", path);
@@ -297,6 +307,9 @@ public partial class App : System.Windows.Application
// The session summary (P3 PR-6): the series loader over the ports, the exports' file picker, the window opener.
services.AddSingleton<IHardwareSnapshotRepository, SqliteHardwareSnapshotRepository>();
// Settings > System (2026-09-21): the same source the Agent stamps every session with, read for this PC now.
services.AddSingleton<Application.Recording.IHardwareSnapshotSource>(static _ => new Infrastructure.Recording.HardwareSnapshotSource(new Infrastructure.Telemetry.DxgiAdapters()));
services.AddTransient<SystemInfoViewModel>();
services.AddSingleton<Charts.SessionSeriesLoader>();
services.AddSingleton<IFileSaver, FileSaver>();
services.AddSingleton<ISessionSummaryOpener, SessionSummaryOpener>();
@@ -41,6 +41,8 @@ public partial class SensorsChart : UserControl
Line(plot, series, "gpu_hotspot", Strings.Sensors_Series_GpuHotspot, p.Stutter, null);
Line(plot, series, "gpu_load", Strings.Sensors_Series_GpuLoad, p.Native, null);
Line(plot, series, "gpu_power", Strings.Sensors_Series_GpuPower, p.SensorSecondary, plot.Axes.Right);
Line(plot, series, "cpu_temp", Strings.Sensors_Series_CpuTemp, p.Percentile, null);
Line(plot, series, "cpu_load", Strings.Sensors_Series_CpuLoad, p.Displayed, null);
plot.Axes.AutoScale();
plot.ShowLegend(Alignment.UpperRight);
}
@@ -69,6 +71,7 @@ public partial class SensorsChart : UserControl
}
Line(plot, series, "vram_adapter", Strings.Sensors_Series_VramAdapter, p.SensorSecondary, null);
Line(plot, series, "ram_mb", Strings.Sensors_Series_Ram, p.Percentile, null);
plot.Axes.AutoScale();
plot.ShowLegend(Alignment.UpperRight);
}
+19
View File
@@ -14,4 +14,23 @@ public enum TrendMetric
P01Low,
MaxGpuTemp,
/// <summary>The seven below are 2026-09-21's: one game's sessions over time, beyond the frame rate.</summary>
AvgGpuLoad,
AvgGpuPower,
MaxVramProcess,
AvgCpuLoad,
MaxCpuTemp,
AvgRam,
/// <summary>
/// The counted ×FG factor. A session whose factor is its STEADY STATE's (CLAUDE.md rule 6, 2026-09-17) describes part
/// of the session, so it is treated as a mid-session change: left out by default, drawn marked when those are included.
/// </summary>
FgFactor,
}
@@ -20,7 +20,8 @@ public static class TrendSeriesBuilder
var points = new List<TrendPoint>();
foreach (SessionRow row in rows.Where(static r => r.Tier == CaptureTier.Hooked).OrderBy(static r => r.StartedAt))
{
if (row.SettingsChangedMidSession && !includeMidSessionChanges)
bool partial = IsPartial(row, metric);
if (partial && !includeMidSessionChanges)
{
continue;
}
@@ -28,7 +29,7 @@ public static class TrendSeriesBuilder
double? value = ValueOf(row, metric);
if (value is double v)
{
points.Add(new TrendPoint(row.StartedAt, v, row.Id, row.SettingsChangedMidSession));
points.Add(new TrendPoint(row.StartedAt, v, row.Id, partial));
}
}
@@ -36,10 +37,23 @@ public static class TrendSeriesBuilder
}
/// <summary>How many sessions FR-6.4 leaves out at the default setting.</summary>
public static int ExcludedCount(IReadOnlyList<SessionRow> rows)
public static int ExcludedCount(IReadOnlyList<SessionRow> rows) => ExcludedCount(rows, TrendMetric.Average);
public static int ExcludedCount(IReadOnlyList<SessionRow> rows, TrendMetric metric)
{
ArgumentNullException.ThrowIfNull(rows);
return rows.Count(static r => r.Tier == CaptureTier.Hooked && r.SettingsChangedMidSession);
return rows.Count(r => r.Tier == CaptureTier.Hooked && IsPartial(r, metric));
}
/// <summary>
/// A point that describes only part of its session: the settings changed mid-session (FR-6.4), or — for the factor
/// — the number is the steady state's and covers a share of the session (rule 6: never shown as the session's).
/// </summary>
public static bool IsPartial(SessionRow row, TrendMetric metric)
{
ArgumentNullException.ThrowIfNull(row);
return row.SettingsChangedMidSession
|| (metric == TrendMetric.FgFactor && string.Equals(row.FgFactorScope, "steady", StringComparison.Ordinal));
}
/// <summary>The metric's value on a row, or null when that row cannot have it (FR-4.9: never an estimate).</summary>
@@ -59,6 +73,13 @@ public static class TrendSeriesBuilder
TrendMetric.P1Low => row.P1LowFps,
TrendMetric.P01Low => row.P01LowFps,
TrendMetric.MaxGpuTemp => row.MaxGpuTemp,
TrendMetric.AvgGpuLoad => row.AvgGpuLoad,
TrendMetric.AvgGpuPower => row.AvgGpuPowerW,
TrendMetric.MaxVramProcess => row.VramProcMaxMb,
TrendMetric.AvgCpuLoad => row.AvgCpuLoad,
TrendMetric.MaxCpuTemp => row.MaxCpuTemp,
TrendMetric.AvgRam => row.AvgRamMb,
TrendMetric.FgFactor => readout.Kind == FpsReadoutKind.Generated ? readout.Factor : null,
_ => null,
};
}
@@ -257,6 +257,28 @@
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_LogDebug_Label}" IsChecked="{Binding ViewModel.LogDebug, Mode=TwoWay}" />
</ui:CardControl>
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static vm:SystemInfoViewModel.Header}" />
<ui:Card Margin="0,4,0,0">
<StackPanel>
<ItemsControl ItemsSource="{Binding SystemInfo.Lines}" Focusable="False">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Column="0" Appearance="Secondary" Text="{Binding Label}" />
<ui:TextBlock Grid.Column="1" TextWrapping="Wrap" Text="{Binding Value}" />
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ui:TextBlock Margin="0,8,0,0" Appearance="Tertiary" TextWrapping="Wrap" Text="{x:Static vm:SystemInfoViewModel.Note}" />
<ui:Button Margin="0,8,0,0" Command="{Binding SystemInfo.CopyCommand}" Content="{x:Static vm:SystemInfoViewModel.CopyText}" Icon="{ui:SymbolIcon Copy24}" />
</StackPanel>
</ui:Card>
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Legal_Header}" />
<ui:CardAction Margin="0,4,0,24" Command="{Binding ViewModel.ReopenLegalCommand}" Icon="{ui:SymbolIcon DocumentText24}">
<ui:TextBlock Text="{x:Static res:Strings.Settings_Legal_Reopen}" />
@@ -5,12 +5,16 @@ namespace FrameLedger.App.Pages;
public partial class SettingsPage : INavigableView<SettingsViewModel>
{
public SettingsPage(SettingsViewModel viewModel)
public SettingsPage(SettingsViewModel viewModel, SystemInfoViewModel system)
{
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
SystemInfo = system ?? throw new ArgumentNullException(nameof(system));
DataContext = this;
InitializeComponent();
}
public SettingsViewModel ViewModel { get; }
/// <summary>Settings ▸ System: this PC as a session's hardware snapshot would record it (2026-09-21).</summary>
public SystemInfoViewModel SystemInfo { get; }
}
+10 -1
View File
@@ -1,6 +1,7 @@
using System.Globalization;
using System.IO;
using System.Text;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Settings;
namespace FrameLedger.App.Services;
@@ -22,7 +23,7 @@ public static class DiagReport
}
/// <summary>The report text. <paramref name="settings"/> is every registry key's effective value; <paramref name="schemaVersion"/> null when the ledger could not be opened.</summary>
public static string Build(string appVersion, string dataDirectory, string logsDirectory, long? schemaVersion, IReadOnlyDictionary<string, string> settings, bool agentBesideApp, DateTimeOffset now)
public static string Build(string appVersion, string dataDirectory, string logsDirectory, long? schemaVersion, IReadOnlyDictionary<string, string> settings, bool agentBesideApp, DateTimeOffset now, HardwareSnapshot? hardware = null)
{
ArgumentNullException.ThrowIfNull(settings);
var sb = new StringBuilder();
@@ -36,6 +37,14 @@ public static class DiagReport
sb.AppendLine(CultureInfo.InvariantCulture, $"logs_dir: {logsDirectory}");
sb.AppendLine(CultureInfo.InvariantCulture, $"ledger_schema: {(schemaVersion is long v ? v.ToString(CultureInfo.InvariantCulture) : "could not open")}");
sb.AppendLine(CultureInfo.InvariantCulture, $"agent_beside_app: {agentBesideApp}");
// The machine (2026-09-21), as a session's hardware snapshot records it. A local file the user reads and chooses to
// share; the bug bundle's sysinfo.json is deliberately NOT given these (its keys are the issue link's prefill).
sb.AppendLine(CultureInfo.InvariantCulture, $"cpu: {hardware?.CpuName ?? "n/a"}");
sb.AppendLine(CultureInfo.InvariantCulture, $"gpu: {hardware?.GpuName ?? "n/a"}");
sb.AppendLine(CultureInfo.InvariantCulture, $"gpu_driver: {hardware?.GpuDriver ?? "n/a"}");
sb.AppendLine(CultureInfo.InvariantCulture, $"ram_gb: {(hardware?.RamGb is double gb ? gb.ToString("0.#", CultureInfo.InvariantCulture) : "n/a")}");
sb.AppendLine(CultureInfo.InvariantCulture, $"display: {hardware?.DisplayRes ?? "n/a"}{(hardware?.DisplayHz is double hz ? " @ " + hz.ToString("0.#", CultureInfo.InvariantCulture) + " Hz" : string.Empty)}");
sb.AppendLine("settings:");
foreach (SettingDefinition definition in SettingsRegistry.All)
{
+3
View File
@@ -39,6 +39,9 @@ public static class Formats
public static string Temperature(double? celsius) => celsius is double c ? string.Format(CultureInfo.CurrentCulture, Strings.Format_Temperature_Format, c) : Strings.Common_NotAvailable;
/// <summary>A 0–100 load as <c>42%</c>; null → N/A, never 0%.</summary>
public static string Percent(double? value) => value is double v ? v.ToString("0", CultureInfo.CurrentCulture) + "%" : Strings.Common_NotAvailable;
/// <summary><c>1485×835 → 2560×1440</c>, or one pair when only one is known, or N/A.</summary>
public static string Resolution(int? renderW, int? renderH, int? outputW, int? outputH)
{
+84
View File
@@ -106,8 +106,11 @@ public static class Strings
nameof(Compare_Export_Png),
nameof(Compare_Header),
nameof(Compare_Legend_Format),
nameof(Compare_Metric_AvgCpuLoad),
nameof(Compare_Metric_AvgGpuLoad),
nameof(Compare_Metric_Displayed),
nameof(Compare_Metric_Duration),
nameof(Compare_Metric_MaxCpuTemp),
nameof(Compare_Metric_MaxGpuTemp),
nameof(Compare_Metric_Median),
nameof(Compare_Metric_Native),
@@ -399,10 +402,13 @@ public static class Strings
nameof(Rules_Update_Title),
nameof(Sensors_Axis_Mb),
nameof(Sensors_Empty),
nameof(Sensors_Series_CpuLoad),
nameof(Sensors_Series_CpuTemp),
nameof(Sensors_Series_GpuHotspot),
nameof(Sensors_Series_GpuLoad),
nameof(Sensors_Series_GpuPower),
nameof(Sensors_Series_GpuTemp),
nameof(Sensors_Series_Ram),
nameof(Sensors_Series_VramAdapter),
nameof(Sensors_Series_VramProcess),
nameof(Sensors_Temps_Header),
@@ -473,6 +479,10 @@ public static class Strings
nameof(Settings_SafetyDocs),
nameof(Settings_StartWithWindows_Body),
nameof(Settings_StartWithWindows_Label),
nameof(Settings_System_Copied),
nameof(Settings_System_Copy),
nameof(Settings_System_Header),
nameof(Settings_System_Note),
nameof(Settings_Theme_Dark),
nameof(Settings_Theme_Label),
nameof(Settings_Theme_Light),
@@ -514,7 +524,10 @@ public static class Strings
nameof(Summary_Show_Displayed),
nameof(Summary_Show_Sensors),
nameof(Summary_Stat_Avg),
nameof(Summary_Stat_Cpu),
nameof(Summary_Stat_Duration),
nameof(Summary_Stat_Gpu),
nameof(Summary_Stat_LoadTemp_Format),
nameof(Summary_Stat_Median),
nameof(Summary_Stat_MinMax),
nameof(Summary_Stat_MinMax_Format),
@@ -529,6 +542,14 @@ public static class Strings
nameof(Summary_Title_Format),
nameof(Summary_Unhooked_Body),
nameof(Summary_Unhooked_Title),
nameof(System_Cpu),
nameof(System_Display),
nameof(System_Display_Format),
nameof(System_Gpu),
nameof(System_GpuDriver),
nameof(System_Os),
nameof(System_Ram),
nameof(System_Ram_Format),
nameof(Tabs_SelectASession),
nameof(Tabs_SelectedNoFrames),
nameof(Tabs_SelectedNotHooked),
@@ -561,9 +582,16 @@ public static class Strings
nameof(Trend_Excluded_Format),
nameof(Trend_IncludeMidSession),
nameof(Trend_Metric_Average),
nameof(Trend_Metric_AvgCpuLoad),
nameof(Trend_Metric_AvgGpuLoad),
nameof(Trend_Metric_AvgGpuPower),
nameof(Trend_Metric_AvgRam),
nameof(Trend_Metric_Displayed),
nameof(Trend_Metric_FgFactor),
nameof(Trend_Metric_Label),
nameof(Trend_Metric_MaxCpuTemp),
nameof(Trend_Metric_MaxGpuTemp),
nameof(Trend_Metric_MaxVramProcess),
nameof(Trend_Metric_P01Low),
nameof(Trend_Metric_P1Low),
nameof(Uninstall_DataFolder_Body),
@@ -759,10 +787,16 @@ public static class Strings
public static string Compare_Legend_Format => ResourceManager.GetString(nameof(Compare_Legend_Format), Culture) ?? nameof(Compare_Legend_Format);
public static string Compare_Metric_AvgCpuLoad => ResourceManager.GetString(nameof(Compare_Metric_AvgCpuLoad), Culture) ?? nameof(Compare_Metric_AvgCpuLoad);
public static string Compare_Metric_AvgGpuLoad => ResourceManager.GetString(nameof(Compare_Metric_AvgGpuLoad), Culture) ?? nameof(Compare_Metric_AvgGpuLoad);
public static string Compare_Metric_Displayed => ResourceManager.GetString(nameof(Compare_Metric_Displayed), Culture) ?? nameof(Compare_Metric_Displayed);
public static string Compare_Metric_Duration => ResourceManager.GetString(nameof(Compare_Metric_Duration), Culture) ?? nameof(Compare_Metric_Duration);
public static string Compare_Metric_MaxCpuTemp => ResourceManager.GetString(nameof(Compare_Metric_MaxCpuTemp), Culture) ?? nameof(Compare_Metric_MaxCpuTemp);
public static string Compare_Metric_MaxGpuTemp => ResourceManager.GetString(nameof(Compare_Metric_MaxGpuTemp), Culture) ?? nameof(Compare_Metric_MaxGpuTemp);
public static string Compare_Metric_Median => ResourceManager.GetString(nameof(Compare_Metric_Median), Culture) ?? nameof(Compare_Metric_Median);
@@ -1345,6 +1379,10 @@ public static class Strings
public static string Sensors_Empty => ResourceManager.GetString(nameof(Sensors_Empty), Culture) ?? nameof(Sensors_Empty);
public static string Sensors_Series_CpuLoad => ResourceManager.GetString(nameof(Sensors_Series_CpuLoad), Culture) ?? nameof(Sensors_Series_CpuLoad);
public static string Sensors_Series_CpuTemp => ResourceManager.GetString(nameof(Sensors_Series_CpuTemp), Culture) ?? nameof(Sensors_Series_CpuTemp);
public static string Sensors_Series_GpuHotspot => ResourceManager.GetString(nameof(Sensors_Series_GpuHotspot), Culture) ?? nameof(Sensors_Series_GpuHotspot);
public static string Sensors_Series_GpuLoad => ResourceManager.GetString(nameof(Sensors_Series_GpuLoad), Culture) ?? nameof(Sensors_Series_GpuLoad);
@@ -1353,6 +1391,8 @@ public static class Strings
public static string Sensors_Series_GpuTemp => ResourceManager.GetString(nameof(Sensors_Series_GpuTemp), Culture) ?? nameof(Sensors_Series_GpuTemp);
public static string Sensors_Series_Ram => ResourceManager.GetString(nameof(Sensors_Series_Ram), Culture) ?? nameof(Sensors_Series_Ram);
public static string Sensors_Series_VramAdapter => ResourceManager.GetString(nameof(Sensors_Series_VramAdapter), Culture) ?? nameof(Sensors_Series_VramAdapter);
public static string Sensors_Series_VramProcess => ResourceManager.GetString(nameof(Sensors_Series_VramProcess), Culture) ?? nameof(Sensors_Series_VramProcess);
@@ -1493,6 +1533,14 @@ public static class Strings
public static string Settings_StartWithWindows_Label => ResourceManager.GetString(nameof(Settings_StartWithWindows_Label), Culture) ?? nameof(Settings_StartWithWindows_Label);
public static string Settings_System_Copied => ResourceManager.GetString(nameof(Settings_System_Copied), Culture) ?? nameof(Settings_System_Copied);
public static string Settings_System_Copy => ResourceManager.GetString(nameof(Settings_System_Copy), Culture) ?? nameof(Settings_System_Copy);
public static string Settings_System_Header => ResourceManager.GetString(nameof(Settings_System_Header), Culture) ?? nameof(Settings_System_Header);
public static string Settings_System_Note => ResourceManager.GetString(nameof(Settings_System_Note), Culture) ?? nameof(Settings_System_Note);
public static string Settings_Theme_Dark => ResourceManager.GetString(nameof(Settings_Theme_Dark), Culture) ?? nameof(Settings_Theme_Dark);
public static string Settings_Theme_Label => ResourceManager.GetString(nameof(Settings_Theme_Label), Culture) ?? nameof(Settings_Theme_Label);
@@ -1575,8 +1623,14 @@ public static class Strings
public static string Summary_Stat_Avg => ResourceManager.GetString(nameof(Summary_Stat_Avg), Culture) ?? nameof(Summary_Stat_Avg);
public static string Summary_Stat_Cpu => ResourceManager.GetString(nameof(Summary_Stat_Cpu), Culture) ?? nameof(Summary_Stat_Cpu);
public static string Summary_Stat_Duration => ResourceManager.GetString(nameof(Summary_Stat_Duration), Culture) ?? nameof(Summary_Stat_Duration);
public static string Summary_Stat_Gpu => ResourceManager.GetString(nameof(Summary_Stat_Gpu), Culture) ?? nameof(Summary_Stat_Gpu);
public static string Summary_Stat_LoadTemp_Format => ResourceManager.GetString(nameof(Summary_Stat_LoadTemp_Format), Culture) ?? nameof(Summary_Stat_LoadTemp_Format);
public static string Summary_Stat_Median => ResourceManager.GetString(nameof(Summary_Stat_Median), Culture) ?? nameof(Summary_Stat_Median);
public static string Summary_Stat_MinMax => ResourceManager.GetString(nameof(Summary_Stat_MinMax), Culture) ?? nameof(Summary_Stat_MinMax);
@@ -1605,6 +1659,22 @@ public static class Strings
public static string Summary_Unhooked_Title => ResourceManager.GetString(nameof(Summary_Unhooked_Title), Culture) ?? nameof(Summary_Unhooked_Title);
public static string System_Cpu => ResourceManager.GetString(nameof(System_Cpu), Culture) ?? nameof(System_Cpu);
public static string System_Display => ResourceManager.GetString(nameof(System_Display), Culture) ?? nameof(System_Display);
public static string System_Display_Format => ResourceManager.GetString(nameof(System_Display_Format), Culture) ?? nameof(System_Display_Format);
public static string System_Gpu => ResourceManager.GetString(nameof(System_Gpu), Culture) ?? nameof(System_Gpu);
public static string System_GpuDriver => ResourceManager.GetString(nameof(System_GpuDriver), Culture) ?? nameof(System_GpuDriver);
public static string System_Os => ResourceManager.GetString(nameof(System_Os), Culture) ?? nameof(System_Os);
public static string System_Ram => ResourceManager.GetString(nameof(System_Ram), Culture) ?? nameof(System_Ram);
public static string System_Ram_Format => ResourceManager.GetString(nameof(System_Ram_Format), Culture) ?? nameof(System_Ram_Format);
public static string Tabs_SelectASession => ResourceManager.GetString(nameof(Tabs_SelectASession), Culture) ?? nameof(Tabs_SelectASession);
public static string Tabs_SelectedNoFrames => ResourceManager.GetString(nameof(Tabs_SelectedNoFrames), Culture) ?? nameof(Tabs_SelectedNoFrames);
@@ -1669,12 +1739,26 @@ public static class Strings
public static string Trend_Metric_Average => ResourceManager.GetString(nameof(Trend_Metric_Average), Culture) ?? nameof(Trend_Metric_Average);
public static string Trend_Metric_AvgCpuLoad => ResourceManager.GetString(nameof(Trend_Metric_AvgCpuLoad), Culture) ?? nameof(Trend_Metric_AvgCpuLoad);
public static string Trend_Metric_AvgGpuLoad => ResourceManager.GetString(nameof(Trend_Metric_AvgGpuLoad), Culture) ?? nameof(Trend_Metric_AvgGpuLoad);
public static string Trend_Metric_AvgGpuPower => ResourceManager.GetString(nameof(Trend_Metric_AvgGpuPower), Culture) ?? nameof(Trend_Metric_AvgGpuPower);
public static string Trend_Metric_AvgRam => ResourceManager.GetString(nameof(Trend_Metric_AvgRam), Culture) ?? nameof(Trend_Metric_AvgRam);
public static string Trend_Metric_Displayed => ResourceManager.GetString(nameof(Trend_Metric_Displayed), Culture) ?? nameof(Trend_Metric_Displayed);
public static string Trend_Metric_FgFactor => ResourceManager.GetString(nameof(Trend_Metric_FgFactor), Culture) ?? nameof(Trend_Metric_FgFactor);
public static string Trend_Metric_Label => ResourceManager.GetString(nameof(Trend_Metric_Label), Culture) ?? nameof(Trend_Metric_Label);
public static string Trend_Metric_MaxCpuTemp => ResourceManager.GetString(nameof(Trend_Metric_MaxCpuTemp), Culture) ?? nameof(Trend_Metric_MaxCpuTemp);
public static string Trend_Metric_MaxGpuTemp => ResourceManager.GetString(nameof(Trend_Metric_MaxGpuTemp), Culture) ?? nameof(Trend_Metric_MaxGpuTemp);
public static string Trend_Metric_MaxVramProcess => ResourceManager.GetString(nameof(Trend_Metric_MaxVramProcess), Culture) ?? nameof(Trend_Metric_MaxVramProcess);
public static string Trend_Metric_P01Low => ResourceManager.GetString(nameof(Trend_Metric_P01Low), Culture) ?? nameof(Trend_Metric_P01Low);
public static string Trend_Metric_P1Low => ResourceManager.GetString(nameof(Trend_Metric_P1Low), Culture) ?? nameof(Trend_Metric_P1Low);
+112
View File
@@ -2312,4 +2312,116 @@
<value>{0}(ドライバー報告)</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_AvgGpuLoad" xml:space="preserve">
<value>平均GPU負荷 %</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_AvgGpuPower" xml:space="preserve">
<value>平均GPU電力 W</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_MaxVramProcess" xml:space="preserve">
<value>最大VRAM(ゲーム)MB</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_AvgCpuLoad" xml:space="preserve">
<value>平均CPU負荷 %</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_MaxCpuTemp" xml:space="preserve">
<value>最大CPU °C</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_AvgRam" xml:space="preserve">
<value>平均メモリ使用量 MB</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_FgFactor" xml:space="preserve">
<value>FG倍率 ×</value>
<comment>review</comment>
</data>
<data name="Sensors_Series_CpuTemp" xml:space="preserve">
<value>CPU °C</value>
<comment>review</comment>
</data>
<data name="Sensors_Series_CpuLoad" xml:space="preserve">
<value>CPU負荷 %</value>
<comment>review</comment>
</data>
<data name="Sensors_Series_Ram" xml:space="preserve">
<value>メモリ使用量(システム)</value>
<comment>review</comment>
</data>
<data name="Compare_Metric_AvgGpuLoad" xml:space="preserve">
<value>平均GPU負荷</value>
<comment>review</comment>
</data>
<data name="Compare_Metric_AvgCpuLoad" xml:space="preserve">
<value>平均CPU負荷</value>
<comment>review</comment>
</data>
<data name="Compare_Metric_MaxCpuTemp" xml:space="preserve">
<value>最大CPU温度</value>
<comment>review</comment>
</data>
<data name="Summary_Stat_Gpu" xml:space="preserve">
<value>GPU</value>
<comment>review</comment>
</data>
<data name="Summary_Stat_Cpu" xml:space="preserve">
<value>CPU</value>
<comment>review</comment>
</data>
<data name="Summary_Stat_LoadTemp_Format" xml:space="preserve">
<value>平均 {0} · 最大 {1}</value>
<comment>review</comment>
</data>
<data name="Settings_System_Header" xml:space="preserve">
<value>システム</value>
<comment>review</comment>
</data>
<data name="Settings_System_Note" xml:space="preserve">
<value>FrameLedger が各セッションとともに記録するこの PC の情報です。このページを開いたときに読み取られ、どこにも送信されません。CPU 温度は、Agent を管理者として実行し PawnIO をインストールしている場合のみ取得でき、それ以外は N/A です。</value>
<comment>review</comment>
</data>
<data name="Settings_System_Copy" xml:space="preserve">
<value>コピー</value>
<comment>review</comment>
</data>
<data name="Settings_System_Copied" xml:space="preserve">
<value>システム情報をクリップボードにコピーしました。</value>
<comment>review</comment>
</data>
<data name="System_Cpu" xml:space="preserve">
<value>プロセッサ</value>
<comment>review</comment>
</data>
<data name="System_Gpu" xml:space="preserve">
<value>グラフィックスカード</value>
<comment>review</comment>
</data>
<data name="System_GpuDriver" xml:space="preserve">
<value>グラフィックスドライバー</value>
<comment>review</comment>
</data>
<data name="System_Ram" xml:space="preserve">
<value>メモリ</value>
<comment>review</comment>
</data>
<data name="System_Ram_Format" xml:space="preserve">
<value>{0:0.#} GB</value>
<comment>review</comment>
</data>
<data name="System_Os" xml:space="preserve">
<value>Windows ビルド</value>
<comment>review</comment>
</data>
<data name="System_Display" xml:space="preserve">
<value>プライマリディスプレイ</value>
<comment>review</comment>
</data>
<data name="System_Display_Format" xml:space="preserve">
<value>{0} @ {1:0.#} Hz</value>
<comment>review</comment>
</data>
</root>
+84
View File
@@ -1743,4 +1743,88 @@ Open the log folder?</value>
<data name="Upscaler_DriverReported_Format" xml:space="preserve">
<value>{0} (driver-reported)</value>
</data>
<data name="Trend_Metric_AvgGpuLoad" xml:space="preserve">
<value>Avg GPU load %</value>
</data>
<data name="Trend_Metric_AvgGpuPower" xml:space="preserve">
<value>Avg GPU power W</value>
</data>
<data name="Trend_Metric_MaxVramProcess" xml:space="preserve">
<value>Max VRAM (game) MB</value>
</data>
<data name="Trend_Metric_AvgCpuLoad" xml:space="preserve">
<value>Avg CPU load %</value>
</data>
<data name="Trend_Metric_MaxCpuTemp" xml:space="preserve">
<value>Max CPU °C</value>
</data>
<data name="Trend_Metric_AvgRam" xml:space="preserve">
<value>Avg RAM in use MB</value>
</data>
<data name="Trend_Metric_FgFactor" xml:space="preserve">
<value>FG factor ×</value>
</data>
<data name="Sensors_Series_CpuTemp" xml:space="preserve">
<value>CPU °C</value>
</data>
<data name="Sensors_Series_CpuLoad" xml:space="preserve">
<value>CPU load %</value>
</data>
<data name="Sensors_Series_Ram" xml:space="preserve">
<value>RAM in use (system)</value>
</data>
<data name="Compare_Metric_AvgGpuLoad" xml:space="preserve">
<value>Avg GPU load</value>
</data>
<data name="Compare_Metric_AvgCpuLoad" xml:space="preserve">
<value>Avg CPU load</value>
</data>
<data name="Compare_Metric_MaxCpuTemp" xml:space="preserve">
<value>Max CPU temp</value>
</data>
<data name="Summary_Stat_Gpu" xml:space="preserve">
<value>GPU</value>
</data>
<data name="Summary_Stat_Cpu" xml:space="preserve">
<value>CPU</value>
</data>
<data name="Summary_Stat_LoadTemp_Format" xml:space="preserve">
<value>{0} avg · {1} max</value>
</data>
<data name="Settings_System_Header" xml:space="preserve">
<value>System</value>
</data>
<data name="Settings_System_Note" xml:space="preserve">
<value>This PC as FrameLedger records it with every session. Read when this page opens; nothing is sent anywhere. CPU temperature needs the Agent running as administrator with PawnIO installed, and is N/A otherwise.</value>
</data>
<data name="Settings_System_Copy" xml:space="preserve">
<value>Copy</value>
</data>
<data name="Settings_System_Copied" xml:space="preserve">
<value>System information copied to the clipboard.</value>
</data>
<data name="System_Cpu" xml:space="preserve">
<value>Processor</value>
</data>
<data name="System_Gpu" xml:space="preserve">
<value>Graphics card</value>
</data>
<data name="System_GpuDriver" xml:space="preserve">
<value>Graphics driver</value>
</data>
<data name="System_Ram" xml:space="preserve">
<value>Memory</value>
</data>
<data name="System_Ram_Format" xml:space="preserve">
<value>{0:0.#} GB</value>
</data>
<data name="System_Os" xml:space="preserve">
<value>Windows build</value>
</data>
<data name="System_Display" xml:space="preserve">
<value>Primary display</value>
</data>
<data name="System_Display_Format" xml:space="preserve">
<value>{0} @ {1:0.#} Hz</value>
</data>
</root>
+84
View File
@@ -1738,4 +1738,88 @@ Mở thư mục log?</value>
<data name="Upscaler_DriverReported_Format" xml:space="preserve">
<value>{0} (driver báo cáo)</value>
</data>
<data name="Trend_Metric_AvgGpuLoad" xml:space="preserve">
<value>Tải GPU TB %</value>
</data>
<data name="Trend_Metric_AvgGpuPower" xml:space="preserve">
<value>Công suất GPU TB (W)</value>
</data>
<data name="Trend_Metric_MaxVramProcess" xml:space="preserve">
<value>VRAM tối đa (game) MB</value>
</data>
<data name="Trend_Metric_AvgCpuLoad" xml:space="preserve">
<value>Tải CPU TB %</value>
</data>
<data name="Trend_Metric_MaxCpuTemp" xml:space="preserve">
<value>CPU °C tối đa</value>
</data>
<data name="Trend_Metric_AvgRam" xml:space="preserve">
<value>RAM đang dùng TB (MB)</value>
</data>
<data name="Trend_Metric_FgFactor" xml:space="preserve">
<value>Hệ số FG ×</value>
</data>
<data name="Sensors_Series_CpuTemp" xml:space="preserve">
<value>CPU °C</value>
</data>
<data name="Sensors_Series_CpuLoad" xml:space="preserve">
<value>Tải CPU %</value>
</data>
<data name="Sensors_Series_Ram" xml:space="preserve">
<value>RAM đang dùng (hệ thống)</value>
</data>
<data name="Compare_Metric_AvgGpuLoad" xml:space="preserve">
<value>Tải GPU TB</value>
</data>
<data name="Compare_Metric_AvgCpuLoad" xml:space="preserve">
<value>Tải CPU TB</value>
</data>
<data name="Compare_Metric_MaxCpuTemp" xml:space="preserve">
<value>Nhiệt độ CPU tối đa</value>
</data>
<data name="Summary_Stat_Gpu" xml:space="preserve">
<value>GPU</value>
</data>
<data name="Summary_Stat_Cpu" xml:space="preserve">
<value>CPU</value>
</data>
<data name="Summary_Stat_LoadTemp_Format" xml:space="preserve">
<value>TB {0} · tối đa {1}</value>
</data>
<data name="Settings_System_Header" xml:space="preserve">
<value>Hệ thống</value>
</data>
<data name="Settings_System_Note" xml:space="preserve">
<value>Máy tính này, đúng như FrameLedger ghi lại cùng mỗi phiên. Được đọc khi mở trang này; không gửi đi đâu cả. Nhiệt độ CPU cần Agent chạy quyền quản trị và đã cài PawnIO, nếu không sẽ là N/A.</value>
</data>
<data name="Settings_System_Copy" xml:space="preserve">
<value>Sao chép</value>
</data>
<data name="Settings_System_Copied" xml:space="preserve">
<value>Đã sao chép thông tin hệ thống vào clipboard.</value>
</data>
<data name="System_Cpu" xml:space="preserve">
<value>Bộ xử lý</value>
</data>
<data name="System_Gpu" xml:space="preserve">
<value>Card đồ hoạ</value>
</data>
<data name="System_GpuDriver" xml:space="preserve">
<value>Driver đồ hoạ</value>
</data>
<data name="System_Ram" xml:space="preserve">
<value>Bộ nhớ</value>
</data>
<data name="System_Ram_Format" xml:space="preserve">
<value>{0:0.#} GB</value>
</data>
<data name="System_Os" xml:space="preserve">
<value>Bản dựng Windows</value>
</data>
<data name="System_Display" xml:space="preserve">
<value>Màn hình chính</value>
</data>
<data name="System_Display_Format" xml:space="preserve">
<value>{0} @ {1:0.#} Hz</value>
</data>
</root>
@@ -187,6 +187,9 @@ public sealed partial class CompareViewModel : ObservableObject
Rows.Add(Row(Strings.Compare_Metric_P01Low, rows, static r => r.Tier == Domain.Sessions.CaptureTier.Hooked ? r.P01LowFps : null, Formats.Fps, higherIsBetter: true));
Rows.Add(Row(Strings.Compare_Metric_StutterPct, rows, static r => r.Tier == Domain.Sessions.CaptureTier.Hooked ? r.StutterTimePct : null, static v => v is double d ? d.ToString("0.0", CultureInfo.CurrentCulture) + "%" : Strings.Common_NotAvailable, higherIsBetter: false));
Rows.Add(Row(Strings.Compare_Metric_MaxGpuTemp, rows, static r => r.MaxGpuTemp, Formats.Temperature, higherIsBetter: false));
Rows.Add(Row(Strings.Compare_Metric_AvgGpuLoad, rows, static r => r.AvgGpuLoad, Formats.Percent, higherIsBetter: true));
Rows.Add(Row(Strings.Compare_Metric_AvgCpuLoad, rows, static r => r.AvgCpuLoad, Formats.Percent, higherIsBetter: false));
Rows.Add(Row(Strings.Compare_Metric_MaxCpuTemp, rows, static r => r.MaxCpuTemp, Formats.Temperature, higherIsBetter: false));
Rows.Add(new CompareRowViewModel(Strings.Compare_Metric_Duration, [.. rows.Select(static r => new CompareCell(Formats.Duration(r.DurationSeconds), false))]));
}
@@ -201,6 +201,13 @@ public sealed partial class GameDetailViewModel : ObservableObject
new(TrendMetric.P1Low, Strings.Trend_Metric_P1Low),
new(TrendMetric.P01Low, Strings.Trend_Metric_P01Low),
new(TrendMetric.MaxGpuTemp, Strings.Trend_Metric_MaxGpuTemp),
new(TrendMetric.AvgGpuLoad, Strings.Trend_Metric_AvgGpuLoad),
new(TrendMetric.AvgGpuPower, Strings.Trend_Metric_AvgGpuPower),
new(TrendMetric.MaxVramProcess, Strings.Trend_Metric_MaxVramProcess),
new(TrendMetric.AvgCpuLoad, Strings.Trend_Metric_AvgCpuLoad),
new(TrendMetric.MaxCpuTemp, Strings.Trend_Metric_MaxCpuTemp),
new(TrendMetric.AvgRam, Strings.Trend_Metric_AvgRam),
new(TrendMetric.FgFactor, Strings.Trend_Metric_FgFactor),
];
/// <summary>The selected session's decoded series (null: none selected, Tier 2, or swept).</summary>
@@ -313,7 +320,7 @@ public sealed partial class GameDetailViewModel : ObservableObject
}
TrendPoints = TrendSeriesBuilder.Points(_detail.Sessions, TrendMetric, IncludeMidSession);
int excluded = IncludeMidSession ? 0 : TrendSeriesBuilder.ExcludedCount(_detail.Sessions);
int excluded = IncludeMidSession ? 0 : TrendSeriesBuilder.ExcludedCount(_detail.Sessions, TrendMetric);
TrendExcludedText = excluded > 0 ? string.Format(CultureInfo.CurrentCulture, Strings.Trend_Excluded_Format, excluded) : string.Empty;
TrendEmpty = TrendPoints.Count == 0;
OnPropertyChanged(nameof(TrendMetricText));
@@ -0,0 +1,7 @@
using System.Runtime.InteropServices;
namespace FrameLedger.App.ViewModels;
/// <summary>One stated fact: what it is, and its value as text (N/A included).</summary>
[StructLayout(LayoutKind.Auto)]
public readonly record struct LabelledValue(string Label, string Value);
@@ -40,6 +40,10 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
[ObservableProperty]
private string _line = string.Empty;
/// <summary>The session's hardware snapshot in one line (2026-09-21): it was loaded for the export and shown nowhere.</summary>
[ObservableProperty]
private string _hardwareLine = string.Empty;
[ObservableProperty]
private FpsReadoutModel _readout = FpsReadoutModel.Unavailable;
@@ -278,6 +282,9 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
Line = string.Format(CultureInfo.CurrentCulture, Strings.Summary_Line_Format,
IsHooked ? Formats.Api(row.Api) : Strings.Tier_NotHooked, row.PresentMode ?? Strings.Common_NotAvailable,
IsHooked ? Formats.Upscaler(row.Upscaler, row.UpscalerQuality, row.UpscalerDriverReported) : Strings.Common_NotAvailable, Formats.Resolution(row.RenderW, row.RenderH, row.OutputW, row.OutputH));
HardwareLine = _snapshot is null
? string.Empty
: string.Join(" · ", SystemInfoViewModel.Describe(_snapshot).Where(static l => !string.Equals(l.Value, Strings.Common_NotAvailable, StringComparison.Ordinal)).Select(static l => l.Value));
Tags = _annotation is null ? string.Empty : string.Join(", ", _annotation.Tags);
Notes = _annotation?.Notes ?? string.Empty;
HasDisplayed = Series?.HasGenerated == true;
@@ -301,6 +308,10 @@ public sealed partial class SessionSummaryViewModel : ObservableObject
Stats.Add(new StatCardModel(Strings.Summary_Stat_Stutter, IsHooked && row.StutterCount is long count && row.StutterTimePct is double pct
? string.Format(CultureInfo.CurrentCulture, Strings.Summary_Stat_Stutter_Format, count, pct) : Strings.Common_NotAvailable));
Stats.Add(new StatCardModel(Strings.Summary_Stat_Duration, Formats.Duration(row.DurationSeconds)));
// The machine, both tiers: telemetry is what a not-hooked session still has. Load is the average, temperature the peak.
Stats.Add(new StatCardModel(Strings.Summary_Stat_Gpu, string.Format(CultureInfo.CurrentCulture, Strings.Summary_Stat_LoadTemp_Format, Formats.Percent(row.AvgGpuLoad), Formats.Temperature(row.MaxGpuTemp))));
Stats.Add(new StatCardModel(Strings.Summary_Stat_Cpu, string.Format(CultureInfo.CurrentCulture, Strings.Summary_Stat_LoadTemp_Format, Formats.Percent(row.AvgCpuLoad), Formats.Temperature(row.MaxCpuTemp))));
}
private void PresentChips()
@@ -0,0 +1,107 @@
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FrameLedger.App.Services;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Recording;
namespace FrameLedger.App.ViewModels;
/// <summary>
/// Settings ▸ System (2026-09-21): this PC as a session's hardware snapshot would record it right now — the same
/// <see cref="IHardwareSnapshotSource"/> the Agent stamps every session with (DXGI adapter 0, the registry's processor
/// name, physical memory, the OS build, the primary display). Until this existed the snapshot was stored on every
/// session and shown nowhere but the trend's change markers and the exports.
/// </summary>
/// <remarks>
/// Read once when the page opens, on the thread pool (DXGI and the registry are quick, never instant), and never sent
/// anywhere: <c>Copy</c> puts the same lines on the clipboard for a bug report the user writes themselves. A field the
/// source could not read is N/A, never a guess.
/// </remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public sealed partial class SystemInfoViewModel : ObservableObject
{
private readonly IHardwareSnapshotSource _source;
private readonly IClipboard _clipboard;
private readonly IMessageStrip _strip;
public SystemInfoViewModel(IHardwareSnapshotSource source, IClipboard clipboard, IMessageStrip strip)
{
_source = source ?? throw new ArgumentNullException(nameof(source));
_clipboard = clipboard ?? throw new ArgumentNullException(nameof(clipboard));
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
Pending = LoadAsync();
}
public static string Header => Strings.Settings_System_Header;
public static string Note => Strings.Settings_System_Note;
public static string CopyText => Strings.Settings_System_Copy;
public ObservableCollection<LabelledValue> Lines { get; } = [];
/// <summary>The load in flight, for a test to await.</summary>
public Task Pending { get; private set; }
/// <summary>The snapshot as label/value lines, in the order the page and the clipboard state them.</summary>
public static IReadOnlyList<LabelledValue> Describe(HardwareSnapshot? snapshot)
{
string na = Strings.Common_NotAvailable;
string display = snapshot?.DisplayRes is { Length: > 0 } res
? snapshot.DisplayHz is double hz ? string.Format(CultureInfo.CurrentCulture, Strings.System_Display_Format, res, hz) : res
: na;
return
[
new(Strings.System_Cpu, Text(snapshot?.CpuName)),
new(Strings.System_Gpu, Text(snapshot?.GpuName)),
new(Strings.System_GpuDriver, Text(snapshot?.GpuDriver)),
new(Strings.System_Ram, snapshot?.RamGb is double gb ? string.Format(CultureInfo.CurrentCulture, Strings.System_Ram_Format, gb) : na),
new(Strings.System_Os, Text(snapshot?.OsBuild)),
new(Strings.System_Display, display),
];
string Text(string? value) => string.IsNullOrWhiteSpace(value) ? na : value;
}
[RelayCommand]
private void Copy()
{
var text = new StringBuilder();
foreach (LabelledValue line in Lines)
{
text.Append(line.Label).Append(": ").AppendLine(line.Value);
}
if (_clipboard.SetText(text.ToString()))
{
_strip.Info(Header, Strings.Settings_System_Copied);
}
else
{
_strip.Warn(Header, Strings.BugReport_ClipboardRefused);
}
}
private async Task LoadAsync()
{
HardwareSnapshot? snapshot;
try
{
snapshot = await Task.Run(_source.Take).ConfigureAwait(true);
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
// A machine that will not describe itself is a page of N/A, never a Settings page that does not open.
snapshot = null;
}
Lines.Clear();
foreach (LabelledValue line in Describe(snapshot))
{
Lines.Add(line);
}
}
}
@@ -37,6 +37,7 @@
<!-- header line + chips -->
<ui:TextBlock Appearance="Secondary" Text="{Binding ViewModel.Line}" />
<ui:TextBlock Appearance="Tertiary" TextWrapping="Wrap" Text="{Binding ViewModel.HardwareLine}" />
<ItemsControl Margin="0,8,0,0" ItemsSource="{Binding ViewModel.Chips}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@@ -102,6 +102,7 @@ public sealed class SessionEventPublisher : ISessionObserver
if (drained.Count > 0)
{
t.LastGpu = drained[^1].Sample;
t.LastSystem = drained[^1].System;
}
if (t.AttachedAt is null || !_pipe.HasClients)
@@ -153,7 +154,7 @@ public sealed class SessionEventPublisher : ISessionObserver
try
{
double elapsed = _clock.GetElapsedTime(t.AttachedTimestamp, now).TotalSeconds;
SessionProgressEvent e = SessionProgressCalculator.Compute(sessionGuid, progress, t.Info.QpcFrequency, elapsed, t.LastGpu);
SessionProgressEvent e = SessionProgressCalculator.Compute(sessionGuid, progress, t.Info.QpcFrequency, elapsed, t.LastGpu, t.LastSystem);
_pipe.Publish(IpcMessageType.SessionProgress, e);
Interlocked.Increment(ref _progressPublished);
}
@@ -195,5 +196,7 @@ public sealed class SessionEventPublisher : ISessionObserver
public long? LastProgress { get; set; }
public GpuSample? LastGpu { get; set; }
public SystemReading LastSystem { get; set; }
}
}
@@ -28,7 +28,7 @@ public static class SessionProgressCalculator
{
public const double WindowSeconds = 5;
public static SessionProgressEvent Compute(Guid sessionGuid, CaptureProgress progress, long qpcFrequency, double elapsedSeconds, GpuSample? gpu)
public static SessionProgressEvent Compute(Guid sessionGuid, CaptureProgress progress, long qpcFrequency, double elapsedSeconds, GpuSample? gpu, SystemReading system = default)
{
ArgumentNullException.ThrowIfNull(progress);
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(qpcFrequency);
@@ -68,7 +68,8 @@ public static class SessionProgressCalculator
OutputH = extent?.OutputH,
RtActive = RtActive(w.All),
GpuTempC = gpu?.TempCoreC,
CpuTempC = null,
CpuTempC = system.CpuTempC,
CpuLoadPct = system.CpuLoadPct,
VramProcMb = Newest(w.All, MeasuredFields.Vram, static s => s.VramUsedMb > 0 ? (int)s.VramUsedMb : null),
LatencyUs = Newest(w.All, MeasuredFields.Latency, static s => s.ReflexLatencyUs > 0 ? (int)s.ReflexLatencyUs : null),
};
@@ -183,8 +183,18 @@ public static class SessionAggregator
SeriesAggregates power = SeriesAggregates.Of(s.Select(static x => x.PowerW));
SeriesAggregates adapter = SeriesAggregates.Of(s.Select(static x => x.VramAdapterMb));
int throttleSamples = s.Count(static x => x.ThrottleReasons is not null);
// The machine beside the GPU: these four columns are schema 0001's and had no producer until 2026-09-21. A
// session recorded before then, or one whose ticks never carried a reading, keeps its nulls.
SeriesAggregates cpuLoad = SeriesAggregates.Of(c.Input.Sensors.Select(static t => t.System.CpuLoadPct));
SeriesAggregates cpuTemp = SeriesAggregates.Of(c.Input.Sensors.Select(static t => t.System.CpuTempC));
SeriesAggregates ram = SeriesAggregates.Of(c.Input.Sensors.Select(static t => t.System.RamUsedMb));
return row with
{
AvgCpuLoad = cpuLoad.Average,
AvgCpuTemp = cpuTemp.Average,
MaxCpuTemp = cpuTemp.Max,
AvgRamMb = ram.Average,
AvgGpuTemp = temp.Average,
MaxGpuTemp = temp.Max,
MaxGpuHotspot = hotspot.Max,
@@ -212,6 +212,9 @@ public sealed class SessionFinalizer
AddIfAny(blobs, "gpu_load", sensors, static s => s.Sample.LoadPct);
AddIfAny(blobs, "gpu_power", sensors, static s => s.Sample.PowerW);
AddIfAny(blobs, "vram_adapter", sensors, static s => s.Sample.VramAdapterMb);
AddIfAny(blobs, "cpu_load", sensors, static s => s.System.CpuLoadPct);
AddIfAny(blobs, "cpu_temp", sensors, static s => s.System.CpuTempC);
AddIfAny(blobs, "ram_mb", sensors, static s => s.System.RamUsedMb);
return blobs;
}
@@ -0,0 +1,18 @@
namespace FrameLedger.Application.Telemetry;
/// <summary>
/// The machine beside the GPU, read on the telemetry poller's tick. Separate from <see cref="IGpuTelemetrySource"/> on
/// purpose: the GPU layers compose per field with a capability bit and a layer attribution each
/// (<c>18_GPU_VENDOR_APIS</c>), and none of that machinery means anything for "how busy was the CPU".
/// </summary>
/// <remarks>
/// A read that fails returns false and the tick goes without: a sensor that stopped answering must never cost the
/// session its GPU sample, let alone the capture.
/// </remarks>
public interface ISystemTelemetrySource : IDisposable
{
/// <summary>True when this source can ever produce a CPU temperature (elevated, PawnIO present, a sensor found).</summary>
bool CpuTemperatureAvailable { get; }
bool TryRead(out SystemReading reading);
}
@@ -0,0 +1,26 @@
using System.Runtime.InteropServices;
namespace FrameLedger.Application.Telemetry;
/// <summary>
/// One tick of the machine beside the GPU (2026-09-21): how busy the CPU was since the previous tick, how much
/// physical memory is in use, and — only where something can read it — the CPU's temperature. Every field is nullable
/// and a field nobody measured is null, never 0: <c>sessions.avg_cpu_load</c>, <c>avg_cpu_temp</c>,
/// <c>max_cpu_temp</c> and <c>avg_ram_mb</c> existed from schema 0001 with no producer, and a zero there would have
/// been a measurement nobody made.
/// </summary>
/// <param name="CpuLoadPct">
/// Busy time over elapsed time across every logical processor, 0–100, between this reading and the one before it. Null
/// on a source's first reading (there is no interval yet). This is TIME busy, the classic definition; Task Manager's
/// "utility" on a CPU with turbo can read higher, and the two are not the same number.
/// </param>
/// <param name="RamUsedMb">Physical memory in use machine-wide, MiB.</param>
/// <param name="CpuTempC">
/// The package temperature. Null unless the Agent runs elevated with PawnIO installed (<c>18_GPU_VENDOR_APIS</c> §L2):
/// no unprivileged API reads a CPU's thermal sensor.
/// </param>
[StructLayout(LayoutKind.Auto)]
public readonly record struct SystemReading(double? CpuLoadPct, double? RamUsedMb, double? CpuTempC)
{
public bool IsEmpty => CpuLoadPct is null && RamUsedMb is null && CpuTempC is null;
}
@@ -19,5 +19,8 @@ namespace FrameLedger.Application.Telemetry;
/// last published — and the gap between them is the layer's own cadence, at most one interval.
/// </para>
/// </remarks>
/// <param name="QpcTicks">The raw performance counter at the read.</param>
/// <param name="Sample">The GPU layers' composed sample; a placeholder with <see cref="TelemetryLayer.None"/> and no field on a tick only the system source answered.</param>
/// <param name="System">The machine beside the GPU on the same tick (2026-09-21): CPU busy %, memory in use, CPU temperature where readable. Empty when no system source is composed, which is every sample recorded before that date.</param>
[StructLayout(LayoutKind.Auto)]
public readonly record struct TelemetrySample(long QpcTicks, GpuSample Sample);
public readonly record struct TelemetrySample(long QpcTicks, GpuSample Sample, SystemReading System = default);
@@ -32,3 +32,8 @@ ENUM_DISPLAY_SETTINGS_MODE
// memory into a file under crashdumps\, never another process's.
MiniDumpWriteDump
MINIDUMP_TYPE
// The machine beside the GPU (Telemetry.SystemTelemetrySource, 2026-09-21): CPU busy time and physical memory in use,
// two system-wide counters that open no process.
GetSystemTimes
GlobalMemoryStatusEx
MEMORYSTATUSEX
@@ -10,10 +10,12 @@ namespace FrameLedger.Infrastructure.Recording;
/// </summary>
internal static class SensorSampleCodec
{
private const int _fieldCount = 12;
// 12 GPU fields + 3 system fields (2026-09-21) in one 16-bit mask. A .partial written before that date has bits
// 12..14 clear and reads back with an empty SystemReading, which is what it recorded.
private const int _fieldCount = 15;
private const int _fixedBytes = 8 + 8 + 1 + 2;
public static int SizeOf(in TelemetrySample sample) => _fixedBytes + 8 * PresentCount(sample.Sample);
public static int SizeOf(in TelemetrySample sample) => _fixedBytes + 8 * PresentCount(in sample);
public static int Write(Span<byte> into, in TelemetrySample sample)
{
@@ -23,7 +25,7 @@ internal static class SensorSampleCodec
into[16] = (byte)s.Layer;
ushort mask = 0;
int at = _fixedBytes;
double?[] fields = Fields(s);
double?[] fields = Fields(in sample);
for (int i = 0; i < _fieldCount; i++)
{
if (fields[i] is { } v)
@@ -84,15 +86,20 @@ internal static class SensorSampleCodec
ThrottleReasons = fields[9] is { } t ? (uint)t : null,
PcieGen = fields[10] is { } g ? (int)g : null,
PcieWidth = fields[11] is { } w ? (int)w : null,
});
}, new SystemReading(fields[12], fields[13], fields[14]));
return at;
}
private static int PresentCount(GpuSample s) => Fields(s).Count(static f => f is not null);
private static int PresentCount(in TelemetrySample sample) => Fields(in sample).Count(static f => f is not null);
private static double?[] Fields(GpuSample s) =>
[
s.TempCoreC, s.TempHotspotC, s.TempMemoryC, s.LoadPct, s.VramAdapterMb, s.CoreClockMhz, s.MemClockMhz,
s.PowerW, s.FanRpm, s.ThrottleReasons, s.PcieGen, s.PcieWidth,
];
private static double?[] Fields(in TelemetrySample sample)
{
GpuSample s = sample.Sample;
return
[
s.TempCoreC, s.TempHotspotC, s.TempMemoryC, s.LoadPct, s.VramAdapterMb, s.CoreClockMhz, s.MemClockMhz,
s.PowerW, s.FanRpm, s.ThrottleReasons, s.PcieGen, s.PcieWidth,
sample.System.CpuLoadPct, sample.System.RamUsedMb, sample.System.CpuTempC,
];
}
}
@@ -0,0 +1,7 @@
namespace FrameLedger.Infrastructure.Telemetry;
/// <summary>A CPU package temperature, where something privileged enough to read one exists; null when this tick had none.</summary>
public interface ICpuTemperatureReader : IDisposable
{
double? Read();
}
@@ -0,0 +1,9 @@
namespace FrameLedger.Infrastructure.Telemetry;
/// <summary>The seam under <see cref="SystemTelemetrySource"/>: the two Win32 reads, so the arithmetic is testable without a machine.</summary>
public interface ISystemCounters
{
bool TryReadTimes(out SystemTimes times);
bool TryReadMemoryInUseBytes(out ulong inUse);
}
@@ -23,11 +23,11 @@ public sealed class LhmComputerAdapter : ILhmComputer
{
private readonly Computer _computer;
public LhmComputerAdapter(bool enableCpuAndMemory)
public LhmComputerAdapter(bool enableCpuAndMemory, bool enableGpu = true)
{
_computer = new Computer
{
IsGpuEnabled = true,
IsGpuEnabled = enableGpu,
IsCpuEnabled = enableCpuAndMemory,
IsMemoryEnabled = enableCpuAndMemory,
};
@@ -0,0 +1,106 @@
using LibreHardwareMonitor.Hardware;
namespace FrameLedger.Infrastructure.Telemetry;
/// <summary>
/// The CPU package temperature through LibreHardwareMonitor's CPU group — the one reading in this project that needs
/// privilege (<c>18_GPU_VENDOR_APIS</c> §L2: elevated, with the PawnIO driver installed). Opened only where it can work;
/// everywhere else <see cref="TryOpen"/> returns null and <c>cpu_temp</c> is N/A, which is the honest answer.
/// </summary>
/// <remarks>
/// <para>
/// <b>Unmeasured on real hardware as of 2026-09-21.</b> The sensor choice below is LibreHardwareMonitor's naming
/// (<c>CPU Package</c> on Intel, <c>Core (Tctl/Tdie)</c> on AMD), exercised against a fake <see cref="ILhmComputer"/>.
/// No elevated run with PawnIO has been taken on the owner's machine; the first one is the measurement, and
/// <c>20_OPEN_QUESTIONS</c> carries it.
/// </para>
/// <para>
/// A separate <c>Computer</c> from L2's on purpose: L2 is GPU-only and unelevated by design
/// (<see cref="LhmComputerAdapter"/>), and enabling the CPU group there would make the unprivileged layer's behaviour
/// depend on privilege.
/// </para>
/// </remarks>
public sealed class LhmCpuTemperatureReader : ICpuTemperatureReader
{
private readonly ILhmComputer _computer;
private bool _disposed;
public LhmCpuTemperatureReader(ILhmComputer computer)
{
_computer = computer ?? throw new ArgumentNullException(nameof(computer));
_computer.Open();
}
/// <summary>Null unless the process is elevated AND PawnIO is installed AND the CPU group opened.</summary>
public static LhmCpuTemperatureReader? TryOpen()
{
if (!LhmEnvironment.IsElevated || LhmEnvironment.IsPawnIoInstalled != true)
{
return null;
}
try
{
return new LhmCpuTemperatureReader(new LhmComputerAdapter(enableCpuAndMemory: true, enableGpu: false));
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
return null;
}
}
public double? Read()
{
if (_disposed)
{
return null;
}
_computer.Update();
return Pick(_computer.Hardware);
}
/// <summary>
/// The package sensor where the CPU names one, else the hottest core: a session's <c>max_cpu_temp</c> is about the
/// hottest the part got, and a package sensor is that by definition.
/// </summary>
public static double? Pick(IReadOnlyList<IHardware> hardware)
{
ArgumentNullException.ThrowIfNull(hardware);
double? package = null;
double? hottestCore = null;
foreach (IHardware cpu in hardware.Where(static h => h.HardwareType == HardwareType.Cpu))
{
foreach (ISensor sensor in SensorMap.AllSensors(cpu))
{
if (sensor.SensorType != SensorType.Temperature || sensor.Value is not float value || value <= 0)
{
continue;
}
string name = sensor.Name ?? string.Empty;
if (name.Contains("Package", StringComparison.OrdinalIgnoreCase) || name.Contains("Tctl", StringComparison.OrdinalIgnoreCase) || name.Contains("Tdie", StringComparison.OrdinalIgnoreCase))
{
package = package is { } p ? Math.Max(p, value) : value;
}
else if (name.Contains("Core", StringComparison.OrdinalIgnoreCase) && !name.Contains("Distance", StringComparison.OrdinalIgnoreCase))
{
hottestCore = hottestCore is { } c ? Math.Max(c, value) : value;
}
}
}
return package ?? hottestCore;
}
public void Dispose()
{
if (_disposed)
{
return;
}
_disposed = true;
_computer.Close();
}
}
@@ -0,0 +1,139 @@
using FrameLedger.Application.Telemetry;
using Windows.Win32;
using Windows.Win32.System.SystemInformation;
namespace FrameLedger.Infrastructure.Telemetry;
/// <summary>
/// <see cref="ISystemTelemetrySource"/> over two unprivileged Win32 calls and one optional privileged reader
/// (2026-09-21): <c>GetSystemTimes</c> for how busy the CPU was between two ticks, <c>GlobalMemoryStatusEx</c> for the
/// physical memory in use, and an <see cref="ICpuTemperatureReader"/> where one could be opened.
/// </summary>
/// <remarks>
/// <para>
/// <b>Why not a PDH counter.</b> <c>\Processor Information(_Total)\% Processor Utility</c> is what Task Manager draws, and
/// it is a frequency-scaled figure that exceeds 100 under turbo; <c>% Processor Time</c> is this same busy-time ratio
/// with a localisation and a counter-registry dependency added. <c>GetSystemTimes</c> is the ratio with neither, and the
/// number is stated as what it is: time busy, all logical processors.
/// </para>
/// <para>
/// The first read has no interval behind it and reports no load — a null, never a zero. Kernel time INCLUDES idle time
/// in this API, so busy = (kernel + user) − idle.
/// </para>
/// <para>
/// The machine is sampled, never the game: nothing here opens the target process (CLAUDE.md rule 4 is about memory, and
/// this is further from it still — two system-wide counters).
/// </para>
/// </remarks>
public sealed class SystemTelemetrySource : ISystemTelemetrySource
{
private const double _bytesPerMb = 1024.0 * 1024.0;
private readonly ISystemCounters _counters;
private readonly ICpuTemperatureReader? _temperature;
private SystemTimes? _previous;
private bool _disposed;
public SystemTelemetrySource(ISystemCounters counters, ICpuTemperatureReader? temperature)
{
_counters = counters ?? throw new ArgumentNullException(nameof(counters));
_temperature = temperature;
}
public bool CpuTemperatureAvailable => _temperature is not null;
/// <summary>The shipped composition: the Win32 counters, and the LHM CPU reader only where it can work at all.</summary>
public static SystemTelemetrySource Create() => new(new Win32SystemCounters(), LhmCpuTemperatureReader.TryOpen());
public bool TryRead(out SystemReading reading)
{
reading = default;
if (_disposed)
{
return false;
}
double? load = null;
if (_counters.TryReadTimes(out SystemTimes now))
{
if (_previous is { } before)
{
load = Load(before, now);
}
_previous = now;
}
double? ram = _counters.TryReadMemoryInUseBytes(out ulong inUse) ? inUse / _bytesPerMb : null;
double? temp = null;
if (_temperature is not null)
{
try
{
temp = _temperature.Read();
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
// A sensor library throwing on one tick is that tick without a temperature, never a lost sample.
temp = null;
}
}
reading = new SystemReading(load, ram, temp);
return !reading.IsEmpty;
}
public void Dispose()
{
if (_disposed)
{
return;
}
_disposed = true;
_temperature?.Dispose();
}
/// <summary>Busy time over elapsed time, 0–100; null when the counters did not advance (two reads inside one clock tick).</summary>
public static double? Load(SystemTimes before, SystemTimes now)
{
ulong total = (now.Kernel - before.Kernel) + (now.User - before.User);
ulong idle = now.Idle - before.Idle;
if (total == 0 || idle > total)
{
return null;
}
return Math.Clamp(100.0 * (total - idle) / total, 0.0, 100.0);
}
private sealed class Win32SystemCounters : ISystemCounters
{
public bool TryReadTimes(out SystemTimes times)
{
times = default;
if (!PInvoke.GetSystemTimes(out System.Runtime.InteropServices.ComTypes.FILETIME idle, out System.Runtime.InteropServices.ComTypes.FILETIME kernel, out System.Runtime.InteropServices.ComTypes.FILETIME user))
{
return false;
}
times = new SystemTimes(Ticks(idle), Ticks(kernel), Ticks(user));
return true;
}
public bool TryReadMemoryInUseBytes(out ulong inUse)
{
inUse = 0;
var status = new MEMORYSTATUSEX { dwLength = (uint)System.Runtime.InteropServices.Marshal.SizeOf<MEMORYSTATUSEX>() };
if (!PInvoke.GlobalMemoryStatusEx(ref status) || status.ullTotalPhys < status.ullAvailPhys)
{
return false;
}
inUse = status.ullTotalPhys - status.ullAvailPhys;
return true;
}
private static ulong Ticks(System.Runtime.InteropServices.ComTypes.FILETIME t) => ((ulong)(uint)t.dwHighDateTime << 32) | (uint)t.dwLowDateTime;
}
}
@@ -0,0 +1,7 @@
using System.Runtime.InteropServices;
namespace FrameLedger.Infrastructure.Telemetry;
/// <summary><c>GetSystemTimes</c> in 100 ns units. Kernel INCLUDES idle, as the API reports it.</summary>
[StructLayout(LayoutKind.Auto)]
public readonly record struct SystemTimes(ulong Idle, ulong Kernel, ulong User);
@@ -29,6 +29,7 @@ namespace FrameLedger.Infrastructure.Telemetry;
public sealed class TelemetryPoller : ITelemetryPoller
{
private readonly IGpuTelemetrySource _source;
private readonly ISystemTelemetrySource? _system;
private readonly TelemetryPollerOptions _options;
private readonly TimeProvider _clock;
private readonly ConcurrentQueue<TelemetrySample> _queue = new();
@@ -49,9 +50,11 @@ public sealed class TelemetryPoller : ITelemetryPoller
/// True when the poller is the source's only owner and should dispose it — a composition root that
/// builds the layers for one session and hands them over. False (the default) when the container owns them.
/// </param>
public TelemetryPoller(IGpuTelemetrySource source, TelemetryPollerOptions options, TimeProvider clock, bool ownsSource = false)
/// <param name="system">The machine beside the GPU, read on the same tick (2026-09-21); owned and disposed with <paramref name="source"/> when <paramref name="ownsSource"/> is set. Null composes none, and every sample's <see cref="TelemetrySample.System"/> is empty.</param>
public TelemetryPoller(IGpuTelemetrySource source, TelemetryPollerOptions options, TimeProvider clock, bool ownsSource = false, ISystemTelemetrySource? system = null)
{
_source = source ?? throw new ArgumentNullException(nameof(source));
_system = system;
_ownsSource = ownsSource;
_options = options ?? throw new ArgumentNullException(nameof(options));
_clock = clock ?? throw new ArgumentNullException(nameof(clock));
@@ -96,14 +99,22 @@ public sealed class TelemetryPoller : ITelemetryPoller
/// One tick: read the source, stamp, queue. Public so a test can drive the poller without
/// its thread; the thread calls exactly this.
/// </summary>
/// <summary>True when the composed system source can produce a CPU temperature (elevated, PawnIO, a sensor).</summary>
public bool CpuTemperatureAvailable => _system?.CpuTemperatureAvailable == true;
public void PollOnce()
{
if (!_source.TryRead(out GpuSample? sample))
bool gpu = _source.TryRead(out GpuSample? sample);
SystemReading system = default;
bool machine = _system is not null && _system.TryRead(out system);
if (!gpu && !machine)
{
return;
}
_queue.Enqueue(new TelemetrySample(_clock.GetTimestamp(), sample));
// A tick only the machine answered still carries its CPU and memory: the placeholder names no layer and no field.
sample ??= new GpuSample { TakenAt = _clock.GetUtcNow(), Layer = TelemetryLayer.None };
_queue.Enqueue(new TelemetrySample(_clock.GetTimestamp(), sample, system));
if (Interlocked.Increment(ref _queued) > _options.QueueCapacity && _queue.TryDequeue(out _))
{
Interlocked.Decrement(ref _queued);
@@ -139,6 +150,7 @@ public sealed class TelemetryPoller : ITelemetryPoller
if (_ownsSource)
{
_source.Dispose();
_system?.Dispose();
}
}
+4 -1
View File
@@ -204,9 +204,12 @@ public sealed record SessionProgressEvent
public double? GpuTempC { get; init; }
/// <summary>Null until the Agent composes a CPU sensor (it does not, unelevated).</summary>
/// <summary>Null unless the Agent is elevated with PawnIO installed: no unprivileged API reads a CPU's thermal sensor.</summary>
public double? CpuTempC { get; init; }
/// <summary>CPU time busy across every logical processor over the last telemetry tick, 0-100 (2026-09-21, optional). Null before the second tick.</summary>
public double? CpuLoadPct { get; init; }
public int? VramProcMb { get; init; }
public int? LatencyUs { get; init; }
@@ -41,6 +41,11 @@ public sealed class DiagReportTests
string report = DiagReport.Build("1", "d", "l", null, new Dictionary<string, string>(StringComparer.Ordinal), false, DateTimeOffset.UnixEpoch);
report.Should().Contain("ledger_schema: could not open");
report.Should().Contain("cpu: n/a").And.Contain("ram_gb: n/a").And.Contain("display: n/a", "no snapshot: every hardware line says so");
string withHardware = DiagReport.Build("1", "d", "l", null, new Dictionary<string, string>(StringComparer.Ordinal), false, DateTimeOffset.UnixEpoch,
new Application.Persistence.HardwareSnapshot { CpuName = "Test CPU", GpuName = "Test GPU", GpuDriver = "1.2.3", RamGb = 31.9, DisplayRes = "2560x1440", DisplayHz = 240 });
withHardware.Should().Contain("cpu: Test CPU").And.Contain("gpu: Test GPU").And.Contain("gpu_driver: 1.2.3").And.Contain("ram_gb: 31.9").And.Contain("display: 2560x1440 @ 240 Hz");
DiagReport.FileName(new DateTimeOffset(2026, 9, 14, 12, 0, 0, TimeSpan.Zero)).Should().MatchRegex(@"^diag-\d{8}-\d{6}\.txt$");
}
}
+11 -1
View File
@@ -112,6 +112,16 @@ public sealed class PagesLoadTests
public string? PickSavePath(string filter, string suggestedName) => null;
}
private sealed class FixedHardware : Application.Recording.IHardwareSnapshotSource
{
public HardwareSnapshot Take() => new() { CpuName = "Test CPU", GpuName = "Test GPU", GpuDriver = "1.2.3", RamGb = 32, OsBuild = "26100", DisplayRes = "2560x1440", DisplayHz = 165 };
}
private sealed class NoClipboard : IClipboard
{
public bool SetText(string text) => true;
}
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
@@ -375,7 +385,7 @@ public sealed class PagesLoadTests
Render(new GamesPage(games));
Render(new GameDetailPage(detail));
Render(new ComparePage(compare));
Render(new SettingsPage(settings));
Render(new SettingsPage(settings, new SystemInfoViewModel(new FixedHardware(), new NoClipboard(), strip)));
Render(new LogsPage(logs));
RenderFirstRun(s);
RenderControls(detail);
@@ -58,7 +58,8 @@ public sealed class SessionSummaryViewModelTests
vm.NotFound.Should().BeFalse();
vm.IsHooked.Should().BeTrue();
vm.Series.Should().NotBeNull();
vm.Stats.Should().HaveCount(8);
vm.Stats.Should().HaveCount(10, "eight frame statistics, then the machine: GPU and CPU (2026-09-21)");
vm.Stats.Single(c => string.Equals(c.Label, "CPU", StringComparison.Ordinal)).Value.Should().Be("N/A avg · N/A max", "this row carries no CPU reading: N/A, never 0%");
vm.Stats.Single(c => string.Equals(c.Label, "Median", StringComparison.Ordinal)).Value.Should().Be("60");
vm.Stats.Single(c => string.Equals(c.Label, "1% Low", StringComparison.Ordinal)).Value.Should().Be("48");
vm.Stats.Single(c => string.Equals(c.Label, "Duration", StringComparison.Ordinal)).Value.Should().Be(Formats.Duration(vm.Row!.DurationSeconds));
@@ -0,0 +1,117 @@
using System.Globalization;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.App.ViewModels;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Recording;
namespace FrameLedger.App.Tests;
/// <summary>
/// Settings ▸ System (2026-09-21): this PC through the same source every session's snapshot comes from. A field the
/// source could not read is N/A, a source that throws is a card of N/A, and Copy is the same lines as text.
/// </summary>
[Collection(StringsCultureCollection.Name)]
public sealed class SystemInfoViewModelTests
{
private sealed class FixedSource(Func<HardwareSnapshot> take) : IHardwareSnapshotSource
{
public HardwareSnapshot Take() => take();
}
private sealed class FakeClipboard(bool accepts) : IClipboard
{
public string? Text { get; private set; }
public bool SetText(string text)
{
Text = text;
return accepts;
}
}
private sealed class FakeStrip : IMessageStrip
{
public List<string> Lines { get; } = [];
public void Info(string title, string body) => Lines.Add("info:" + body);
public void Success(string title, string body) => Lines.Add("success:" + body);
public void Warn(string title, string body) => Lines.Add("warn:" + body);
}
private static async Task<T> InEnglishAsync<T>(Func<Task<T>> work)
{
CultureInfo? previous = Strings.Culture;
CultureInfo previousThread = CultureInfo.CurrentCulture;
try
{
Strings.Culture = CultureInfo.GetCultureInfo("en");
CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
return await work().ConfigureAwait(false);
}
finally
{
Strings.Culture = previous;
CultureInfo.CurrentCulture = previousThread;
}
}
[Fact]
public async Task TheSnapshotIsStatedLineByLineAndCopyIsTheSameLines()
{
var clipboard = new FakeClipboard(accepts: true);
var strip = new FakeStrip();
(SystemInfoViewModel vm, string[] lines) = await InEnglishAsync(async () =>
{
var model = new SystemInfoViewModel(new FixedSource(static () => new HardwareSnapshot
{
CpuName = "AMD Ryzen 7 9800X3D",
GpuName = "NVIDIA GeForce RTX 5080",
GpuDriver = "32.0.15.8180",
RamGb = 31.9,
OsBuild = "10.0.26200",
DisplayRes = "2560x1440",
DisplayHz = 239.96,
}), clipboard, strip);
await model.Pending.ConfigureAwait(false);
model.CopyCommand.Execute(null);
return (model, model.Lines.Select(static l => l.Label + "=" + l.Value).ToArray());
});
lines.Should().Equal(
"Processor=AMD Ryzen 7 9800X3D",
"Graphics card=NVIDIA GeForce RTX 5080",
"Graphics driver=32.0.15.8180",
"Memory=31.9 GB",
"Windows build=10.0.26200",
"Primary display=2560x1440 @ 240 Hz");
clipboard.Text.Should().Contain("Processor: AMD Ryzen 7 9800X3D").And.Contain("Primary display: 2560x1440 @ 240 Hz");
strip.Lines.Should().ContainSingle().Which.Should().StartWith("info:");
vm.Lines.Should().HaveCount(6);
}
[Fact]
public async Task WhatCouldNotBeReadIsNotAvailableAndAThrowingSourceIsACardOfNotAvailable()
{
string[] partial = await InEnglishAsync(async () =>
{
var model = new SystemInfoViewModel(new FixedSource(static () => new HardwareSnapshot { GpuName = "Some GPU", DisplayRes = "1920x1080" }), new FakeClipboard(true), new FakeStrip());
await model.Pending.ConfigureAwait(false);
return model.Lines.Select(static l => l.Value).ToArray();
});
partial.Should().Equal("N/A", "Some GPU", "N/A", "N/A", "N/A", "1920x1080");
var strip = new FakeStrip();
string[] thrown = await InEnglishAsync(async () =>
{
var model = new SystemInfoViewModel(new FixedSource(static () => throw new InvalidOperationException("DXGI is not answering")), new FakeClipboard(accepts: false), strip);
await model.Pending.ConfigureAwait(false);
model.CopyCommand.Execute(null);
return model.Lines.Select(static l => l.Value).ToArray();
});
thrown.Should().AllBe("N/A").And.HaveCount(6);
strip.Lines.Should().ContainSingle().Which.Should().StartWith("warn:", "a clipboard another process holds is a refusal, never a crash");
}
}
@@ -76,6 +76,46 @@ public sealed class TrendSeriesBuilderTests
TrendSeriesBuilder.Points([generated, none, presented], TrendMetric.Displayed, true).Should().ContainSingle();
}
/// <summary>
/// 2026-09-21: one game's sessions over time beyond the frame rate — the machine, and the ×FG factor. A column nobody
/// measured is no point (never a zero on the chart), and a factor that is its session's STEADY STATE describes part of
/// the session (CLAUDE.md rule 6), so it is left out by default and drawn marked when the partial ones are included.
/// </summary>
[Fact]
public void TheMachineMetricsAreTheRowsColumnsAndASteadyStateFactorIsAPartialPoint()
{
SessionRow measured = Row(1, 1, fgMode: "dlssg", native: 62, displayed: 118, factor: 1.9) with
{
AvgGpuLoad = 97,
AvgGpuPowerW = 310,
VramProcMaxMb = 9000,
AvgCpuLoad = 41.5,
MaxCpuTemp = 78,
AvgRamMb = 18000,
};
SessionRow steady = Row(2, 1, fgMode: "dlssg", native: 70, displayed: 280, factor: 4) with { FgFactorScope = "steady", FgSteadyShare = 0.75, AvgCpuLoad = 50 };
SessionRow before = Row(3, 1);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.AvgGpuLoad).Should().Be(97);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.AvgGpuPower).Should().Be(310);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.MaxVramProcess).Should().Be(9000);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.AvgCpuLoad).Should().Be(41.5);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.MaxCpuTemp).Should().Be(78);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.AvgRam).Should().Be(18000);
TrendSeriesBuilder.ValueOf(measured, TrendMetric.FgFactor).Should().Be(1.9);
TrendSeriesBuilder.ValueOf(before, TrendMetric.AvgCpuLoad).Should().BeNull("recorded before anything read the CPU");
TrendSeriesBuilder.ValueOf(before, TrendMetric.FgFactor).Should().BeNull("a measured none has no factor to plot");
SessionRow[] rows = [measured, steady, before];
TrendSeriesBuilder.Points(rows, TrendMetric.AvgCpuLoad, includeMidSessionChanges: false).Select(static p => p.Value).Should().Equal([41.5, 50], "the steady state is about the FACTOR; the machine's averages are the whole session's");
TrendSeriesBuilder.Points(rows, TrendMetric.FgFactor, includeMidSessionChanges: false).Select(static p => p.Value).Should().Equal(1.9);
TrendSeriesBuilder.ExcludedCount(rows, TrendMetric.FgFactor).Should().Be(1);
TrendSeriesBuilder.ExcludedCount(rows, TrendMetric.AvgCpuLoad).Should().Be(0);
IReadOnlyList<TrendPoint> all = TrendSeriesBuilder.Points(rows, TrendMetric.FgFactor, includeMidSessionChanges: true);
all.Select(static p => p.Value).Should().Equal(1.9, 4);
all[1].SettingsChangedMidSession.Should().BeTrue("drawn marked: it covers a share of its session, never the session");
}
[Fact]
public void MarkersAppearWhereConsecutiveSnapshotsDiffer()
{
@@ -50,6 +50,20 @@ public sealed class SessionProgressCalculatorTests
.UpscalerDriverReported.Should().BeNull("no probe ran: AMD, Intel, or no bridge beside the Agent");
}
[Fact]
public void TheMachinesLatestReadingIsOnTheLiveCardAndAbsentWhenNothingReadIt()
{
List<FlFrameRecord> records = SessionFixtures.Stream(1000, FlMeasured.OutputRes | FlMeasured.PresentArgs);
SessionProgressEvent e = SessionProgressCalculator.Compute(_guid, Progress(records), SessionFixtures.QpcFrequency, 12.5, gpu: null, new SystemReading(CpuLoadPct: 41.5, RamUsedMb: 9000, CpuTempC: 66));
e.CpuLoadPct.Should().Be(41.5);
e.CpuTempC.Should().Be(66);
SessionProgressEvent none = SessionProgressCalculator.Compute(_guid, Progress(records), SessionFixtures.QpcFrequency, 12.5, gpu: null);
none.CpuLoadPct.Should().BeNull();
none.CpuTempC.Should().BeNull();
}
[Fact]
public void OnlyTheLastFiveSecondsCountAndThePresentedRateStandsAloneWithItsQualifier()
{
@@ -231,6 +231,34 @@ public sealed class SessionAggregatorTests
row.ThrottlePct.Should().BeNull("no sample carried throttle reasons (L3 only)");
}
/// <summary>
/// <c>avg_cpu_load</c>, <c>avg_cpu_temp</c>, <c>max_cpu_temp</c> and <c>avg_ram_mb</c> are schema 0001's and had no
/// producer until 2026-09-21. A tick without a reading is left out of the average, never counted as zero; a session
/// with no system reading at all keeps four nulls.
/// </summary>
[Fact]
public void TheMachinesReadingsBecomeTheFourCpuAndMemoryColumnsAndAbsenceStaysNull()
{
List<FlFrameRecord> records = SessionFixtures.Stream(600, FlMeasured.OutputRes | FlMeasured.PresentArgs);
SessionRow unelevated = SessionAggregator.Aggregate(SessionFixtures.Skeleton(),
SessionFixtures.Hooked(records) with { Sensors = SessionFixtures.SensorsWithSystem(5) }).Row;
unelevated.AvgCpuLoad.Should().BeApproximately(22.5, 1e-9, "21..24 over the four ticks that had an interval; the first tick has none and is not a zero");
unelevated.AvgRamMb.Should().Be(16000);
unelevated.AvgCpuTemp.Should().BeNull("no unprivileged API reads a CPU's thermal sensor");
unelevated.MaxCpuTemp.Should().BeNull();
unelevated.AvgGpuLoad.Should().Be(50, "the GPU half is untouched");
SessionRow elevated = SessionAggregator.Aggregate(SessionFixtures.Skeleton(),
SessionFixtures.Hooked(records) with { Sensors = SessionFixtures.SensorsWithSystem(5, cpuTemp: 60) }).Row;
elevated.AvgCpuTemp.Should().Be(62);
elevated.MaxCpuTemp.Should().Be(64);
SessionRow before = SessionAggregator.Aggregate(SessionFixtures.Skeleton(),
SessionFixtures.Hooked(records) with { Sensors = SessionFixtures.Sensors(5) }).Row;
(before.AvgCpuLoad, before.AvgCpuTemp, before.MaxCpuTemp, before.AvgRamMb).Should().Be((null, null, null, null));
}
[Fact]
public void AGapExcludesTheIntervalIntoTheRecordFromTheStatistics()
{
@@ -98,6 +98,21 @@ public sealed class SessionFinalizerTests
built.Sensors.Should().AllSatisfy(s => s.Hz.Should().Be(1));
}
[Fact]
public void TheMachinesReadingsBecomeTheCpuAndMemorySeriesTheSchemaAlwaysAllowed()
{
(SessionFinalizer finalizer, _) = Make();
FinalizedSession built = finalizer.Build(new FinalizeInput { Skeleton = SessionFixtures.Skeleton(tier: CaptureTier.NotHooked), Sensors = SessionFixtures.SensorsWithSystem(3) });
built.Sensors.Select(s => s.Series).Should().Equal(["t_ms", "gpu_temp", "gpu_load", "vram_adapter", "cpu_load", "ram_mb"], "no tick carried a CPU temperature, so there is no cpu_temp series - absent, not a row of -1");
RawSeriesCodec.Floats(built.Sensors[4].Data).Should().Equal(SessionFinalizer.SensorMissing, 21f, 22f);
RawSeriesCodec.Floats(built.Sensors[5].Data).Should().Equal(16000f, 16000f, 16000f);
FinalizedSession hot = finalizer.Build(new FinalizeInput { Skeleton = SessionFixtures.Skeleton(tier: CaptureTier.NotHooked), Sensors = SessionFixtures.SensorsWithSystem(3, cpuTemp: 70) });
hot.Sensors.Select(s => s.Series).Should().Contain("cpu_temp");
}
[Fact]
public async Task TooShortIsDiscardedAndNothingIsWritten()
{
@@ -73,6 +73,10 @@ internal static class SessionFixtures
QpcFrequency = QpcFrequency,
};
/// <summary>The same ticks with the machine's reading on each: CPU busy climbing from 20 %, memory flat, a CPU temperature only when asked for.</summary>
public static List<TelemetrySample> SensorsWithSystem(int seconds, double? cpuTemp = null) =>
[.. Sensors(seconds).Select((s, i) => s with { System = new SystemReading(CpuLoadPct: i == 0 ? null : 20 + i, RamUsedMb: 16000, CpuTempC: cpuTemp is { } t ? t + i : null) })];
public static List<TelemetrySample> Sensors(int seconds, double? temp = 60, double? load = 50)
{
var list = new List<TelemetrySample>(seconds);
@@ -68,7 +68,7 @@ public sealed class PartialSessionFileTests : IDisposable
w.AppendNote(_t0, "started Launch");
w.AppendRecords(0, [Record(0), Record(1), Record(2)]);
w.AppendGaps([2]);
w.AppendSensors([Sample(1_100_000, 61.5, 3000), Sample(1_200_000, null, 3001)]);
w.AppendSensors([Sample(1_100_000, 61.5, 3000) with { System = new SystemReading(CpuLoadPct: 42.5, RamUsedMb: 12000, CpuTempC: null) }, Sample(1_200_000, null, 3001)]);
w.AppendTouches([1_050_000, 1_150_000]);
w.AppendTick(new PartialTick(3, 2, 0, 1, 1, _t0.AddSeconds(1).ToUnixTimeMilliseconds(), state));
w.AppendRecords(3, [Record(3), Record(4)]);
@@ -96,6 +96,8 @@ public sealed class PartialSessionFileTests : IDisposable
p.Sensors[0].Sample.TempCoreC.Should().Be(61.5);
p.Sensors[0].Sample.PcieGen.Should().Be(4);
p.Sensors[1].Sample.TempCoreC.Should().BeNull("null stays null across the file: N/A is never 0");
p.Sensors[0].System.Should().Be(new SystemReading(42.5, 12000, null), "the machine's reading rides the same chunk, a missing CPU temperature stays missing");
p.Sensors[1].System.IsEmpty.Should().BeTrue("a sample with no system reading reads back with none - which is every .partial written before 2026-09-21");
p.Sensors[1].Sample.VramAdapterMb.Should().Be(3001);
p.Sensors[1].Sample.LoadPct.Should().BeNull();
p.TouchQpc.Should().Equal(1_050_000, 1_150_000);
@@ -0,0 +1,164 @@
using FluentAssertions;
using FrameLedger.Application.Telemetry;
using FrameLedger.Infrastructure.Telemetry;
using LibreHardwareMonitor.Hardware;
using NSubstitute;
namespace FrameLedger.Infrastructure.Tests.Telemetry;
/// <summary>
/// The machine beside the GPU (2026-09-21): busy time is an interval, so the first read has none; kernel time includes
/// idle, as <c>GetSystemTimes</c> reports it; a field nobody measured is null and never zero; a sensor that throws costs
/// its own field and nothing else.
/// </summary>
public sealed class SystemTelemetrySourceTests
{
private sealed class FakeCounters : ISystemCounters
{
public Queue<SystemTimes?> Times { get; } = new();
public ulong? MemoryInUse { get; set; } = 8UL * 1024 * 1024 * 1024;
public bool TryReadTimes(out SystemTimes times)
{
SystemTimes? next = Times.Count > 0 ? Times.Dequeue() : null;
times = next ?? default;
return next is not null;
}
public bool TryReadMemoryInUseBytes(out ulong inUse)
{
inUse = MemoryInUse ?? 0;
return MemoryInUse is not null;
}
}
private sealed class FakeTemperature(Func<double?> read) : ICpuTemperatureReader
{
public bool Disposed { get; private set; }
public double? Read() => read();
public void Dispose() => Disposed = true;
}
[Fact]
public void TheFirstReadHasNoIntervalAndTheSecondIsBusyOverElapsed()
{
var counters = new FakeCounters();
counters.Times.Enqueue(new SystemTimes(Idle: 1000, Kernel: 1500, User: 500));
// +1000 elapsed across kernel+user (kernel INCLUDES idle), of which +750 idle: 25% busy.
counters.Times.Enqueue(new SystemTimes(Idle: 1750, Kernel: 2300, User: 700));
using var source = new SystemTelemetrySource(counters, temperature: null);
source.TryRead(out SystemReading first).Should().BeTrue("memory answered even though load has no interval yet");
first.CpuLoadPct.Should().BeNull("a first read has nothing to subtract from: null, never 0");
first.RamUsedMb.Should().Be(8192);
first.CpuTempC.Should().BeNull();
source.CpuTemperatureAvailable.Should().BeFalse();
source.TryRead(out SystemReading second).Should().BeTrue();
second.CpuLoadPct.Should().BeApproximately(25, 1e-9);
}
[Fact]
public void CountersThatDidNotAdvanceOrWentBackwardsAreNoReading()
{
var t = new SystemTimes(10, 20, 30);
SystemTelemetrySource.Load(t, t).Should().BeNull("two reads inside one clock tick");
SystemTelemetrySource.Load(t, new SystemTimes(Idle: 110, Kernel: 30, User: 40)).Should().BeNull("idle cannot exceed the total it is part of");
SystemTelemetrySource.Load(new SystemTimes(0, 0, 0), new SystemTimes(Idle: 0, Kernel: 50, User: 50)).Should().Be(100);
SystemTelemetrySource.Load(new SystemTimes(0, 0, 0), new SystemTimes(Idle: 100, Kernel: 100, User: 0)).Should().Be(0);
}
[Fact]
public void NothingAnsweringIsNoReadingAtAll()
{
var counters = new FakeCounters { MemoryInUse = null };
using var source = new SystemTelemetrySource(counters, temperature: null);
source.TryRead(out SystemReading reading).Should().BeFalse();
reading.IsEmpty.Should().BeTrue();
}
[Fact]
public void AThrowingTemperatureSensorCostsItsOwnFieldOnlyAndTheReaderIsDisposedWithTheSource()
{
var counters = new FakeCounters();
int calls = 0;
using var temperature = new FakeTemperature(() => ++calls == 1 ? throw new InvalidOperationException("ring0 went away") : 71.5);
var source = new SystemTelemetrySource(counters, temperature);
source.CpuTemperatureAvailable.Should().BeTrue();
source.TryRead(out SystemReading thrown).Should().BeTrue();
thrown.CpuTempC.Should().BeNull();
thrown.RamUsedMb.Should().NotBeNull();
source.TryRead(out SystemReading read).Should().BeTrue();
read.CpuTempC.Should().Be(71.5);
source.Dispose();
temperature.Disposed.Should().BeTrue();
source.TryRead(out _).Should().BeFalse("a disposed source reads nothing");
}
[Fact]
public async Task TheRealCountersAnswerOnThisMachine()
{
using SystemTelemetrySource source = SystemTelemetrySource.Create();
source.TryRead(out SystemReading first).Should().BeTrue();
first.RamUsedMb.Should().BeGreaterThan(256, "this process alone is running on more than that");
await Task.Delay(150, TestContext.Current.CancellationToken);
source.TryRead(out SystemReading second).Should().BeTrue();
second.CpuLoadPct.Should().NotBeNull().And.BeInRange(0, 100);
}
private static ISensor Sensor(string name, float? value, SensorType type = SensorType.Temperature)
{
ISensor s = Substitute.For<ISensor>();
s.SensorType.Returns(type);
s.Name.Returns(name);
s.Value.Returns(value);
return s;
}
private static IHardware Hardware(HardwareType type, params ISensor[] sensors)
{
IHardware h = Substitute.For<IHardware>();
h.HardwareType.Returns(type);
h.Sensors.Returns(sensors);
h.SubHardware.Returns([]);
return h;
}
[Fact]
public void ThePackageSensorIsTheCpuTemperatureAndTheHottestCoreIsTheFallback()
{
IHardware intel = Hardware(HardwareType.Cpu, Sensor("CPU Core #1", 60f), Sensor("CPU Core #2", 66f), Sensor("CPU Package", 70f), Sensor("CPU Core #1 Distance to TjMax", 40f), Sensor("CPU Total", 12f, SensorType.Load));
IHardware amd = Hardware(HardwareType.Cpu, Sensor("Core (Tctl/Tdie)", 64.5f), Sensor("CCD1 (Tdie)", 58f));
IHardware coresOnly = Hardware(HardwareType.Cpu, Sensor("CPU Core #1", 55f), Sensor("CPU Core #2", 59f), Sensor("CPU Core #3", null));
IHardware gpu = Hardware(HardwareType.GpuNvidia, Sensor("GPU Core", 80f));
LhmCpuTemperatureReader.Pick([intel]).Should().Be(70);
LhmCpuTemperatureReader.Pick([amd]).Should().Be(64.5);
LhmCpuTemperatureReader.Pick([coresOnly]).Should().Be(59, "no package sensor: the hottest core is the hottest the part got");
LhmCpuTemperatureReader.Pick([gpu]).Should().BeNull("a GPU's temperature is not the CPU's");
LhmCpuTemperatureReader.Pick([]).Should().BeNull();
}
[Fact]
public void TheReaderOpensUpdatesAndClosesItsComputer()
{
ILhmComputer computer = Substitute.For<ILhmComputer>();
IHardware cpu = Hardware(HardwareType.Cpu, Sensor("CPU Package", 68f));
computer.Hardware.Returns([cpu]);
var reader = new LhmCpuTemperatureReader(computer);
reader.Read().Should().Be(68);
reader.Dispose();
reader.Read().Should().BeNull();
computer.Received(1).Open();
computer.Received(1).Update();
computer.Received(1).Close();
}
}
@@ -41,6 +41,61 @@ public sealed class TelemetryPollerTests
poller.Drain(drained).Should().Be(0);
}
private sealed class FakeSystem(SystemReading? reading) : ISystemTelemetrySource
{
public bool Disposed { get; private set; }
public bool CpuTemperatureAvailable => reading?.CpuTempC is not null;
public bool TryRead(out SystemReading read)
{
read = reading ?? default;
return reading is not null;
}
public void Dispose() => Disposed = true;
}
[Fact]
public void TheMachinesReadingRidesTheSameTickAndATickOnlyItAnsweredIsStillQueued()
{
var clock = new ManualTimeProvider { Ticks = 7 };
using var layer = new FakeLayer(TelemetryLayer.Lhm);
layer.Publish(layer.Sample(_t0, load: 50));
using var system = new FakeSystem(new SystemReading(CpuLoadPct: 37.5, RamUsedMb: 9000, CpuTempC: null));
var poller = new TelemetryPoller(layer, new TelemetryPollerOptions(), clock, ownsSource: true, system);
poller.PollOnce();
layer.Publish(null);
poller.PollOnce();
var drained = new List<TelemetrySample>();
poller.Drain(drained).Should().Be(2);
drained[0].Sample.LoadPct.Should().Be(50);
drained[0].System.CpuLoadPct.Should().Be(37.5);
drained[1].Sample.Layer.Should().Be(TelemetryLayer.None, "the GPU layers said nothing on this tick; the placeholder names no layer and no field");
drained[1].Sample.PresentFields.Should().Be(GpuCapabilities.None);
drained[1].System.RamUsedMb.Should().Be(9000);
poller.CpuTemperatureAvailable.Should().BeFalse();
poller.Dispose();
system.Disposed.Should().BeTrue("the poller owns the system source with the layers");
}
[Fact]
public void WithNoSystemSourceEverySampleCarriesAnEmptyReading()
{
using var layer = new FakeLayer(TelemetryLayer.Lhm);
layer.Publish(layer.Sample(_t0, load: 50));
using var poller = new TelemetryPoller(layer, new TelemetryPollerOptions(), new ManualTimeProvider());
poller.PollOnce();
var drained = new List<TelemetrySample>();
poller.Drain(drained);
drained.Should().ContainSingle().Which.System.IsEmpty.Should().BeTrue();
}
[Fact]
public void ALayerWithNothingToSayQueuesNothing()
{