Skip to content

Address code-review findings (Rust + JS + PS) toward 10/10 - #11

Merged
zerox80 merged 2 commits into
mainfrom
fix/review-2026-07-01
Jul 1, 2026
Merged

Address code-review findings (Rust + JS + PS) toward 10/10#11
zerox80 merged 2 commits into
mainfrom
fix/review-2026-07-01

Conversation

@zerox80

@zerox80 zerox80 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Comprehensive follow-up to the manual code review. All CI gates stay green:

  • \cargo fmt --check\ clean
  • \cargo clippy --all-targets -- -D warnings\ clean
  • \cargo test --all\ -> 33 passed, 0 failed

  • ode --test\ -> 5 passed, 0 failed (golden-vector parity intact)
  • PowerShell parser OK on all edited scripts

Summary by area

Rust backend

  • atomic.rs (High): the stale-lock takeover used a non-atomic \stale-check -> remove_file -> create_new\ pattern that could rob a slow-but-living writer of its lock. Replaced with PID-liveness-gated atomic rename-to-tombstone: we only take over when we can confirm the holder PID is no longer active (OpenProcess + GetExitCodeProcess with ERROR_INVALID_PARAMETER detection), and use an atomic rename (vs. remove+create) so two contenders can't both succeed. Documented the residual behaviour.
  • common.rs: removed speculative Win11 build 26200 ('25H2'), added 22000 RTM.
  • inventory.rs: clamp implausible ageYears (<0, >30y, NaN/Inf) to None instead of producing absurd displays and skewing buckets.
  • merge.rs / assignments.rs: extracted \effective_display()\ to dedupe the \user_display vempty -> fall back to user\ logic across three sites; dropped redundant \�ios/\win11\ clones.
  • overview.rs (Medium): collapsed nine separate scans into a single-pass accumulation of status tallies, dept map, needs_upgrade total, and RAM buckets; \current\ semantics documented.
  • commands.rs: avoid full \Vec\ clone in the AD-fallback path (\ allback_users_from_devices\ takes &).
  • config.rs: \control_dir_for\ no longer falls back to a relative empty path for single-segment \data_dir\ inputs; relies on the absolute-path gate downstream.
  • upgrade.rs: documented the inclusive \minRamGB\ boundary (covered by golden vectors).

Frontend

  • (Critical) Counter drift: the dashboard 'Upgrade' tag used \o.status.upgrade\ while the nav badge and inventory segment used \o.upgradeNeeded; unified to \o.upgradeNeeded\ everywhere.
  • (High) Row styling: rows now use \ViewModel.isUpgradeCandidate\ so stale-with-reason devices in the Upgrade filter are visually promoted instead of dimmed.
  • view-model.js (Medium): locale-aware collation (\de, numeric:true) — umlaut surnames and hostnames \WS-AB-2\ vs \WS-AB-10\ sort correctly; sort-key cache replaces repeated \ oLowerCase\ per comparison; unused \sortValue\ removed.
  • app-panels.js: search input debounced 150ms (matching the AD modal); refresh button guarded against double-clicks; Escape closes only the topmost layer (modal before drawer).
  • app.js: drawer foot moved out of \drawer-body\ so it stops scrolling with the body; _TAURI_\ read at call time; \Number(x) || default\ pattern replaced with \Number.isFinite\ checks; dead \�isibleCount==null\ branch removed.
  • shared.js / mock.js: \DEFAULT_THRESHOLDS\ deduped into \shared.js; \cpuClockMhz\ now derives from realistic per-PC clock values (was always 0 — the CPU-clock threshold was a no-op in preview); mock \set_assignment\ returns \device\ activating the optimistic UI path; \upgrade_reasons\ snake-case fallback removed.
  • dev-server.js: \X-Content-Type-Options: nosniff, \X-Frame-Options: DENY, \Referrer-Policy: no-referrer.
  • index.html: the static 'AD verbunden' label flacked on first paint → 'AD wird geladen'.

PowerShell

  • Get-AdUsers.ps1 (High): force UTF-8 (no BOM) stdout so umlauts survive the Rust/serde_json parse; dispose \SearchResultCollection; drop dead
    ull-check on the env-var cast.
  • Invoke-Inventory.ps1: prefer \Win32_ComputerSystem.DNSHostName\ over the 15-char NetBIOS \Name; \slotsTotal\ sums across all \Win32_PhysicalMemoryArray\ instances (multi-socket); added \MSFT_PhysicalDisk\ fallback via
    oot\Microsoft\Windows\Storage\ before falling back to the unreliable model-string regex; clamp implausible ageYears; documented \LastLoggedOnUser\ reliability and \win11\ (TPM/SecureBoot) preflight semantics; logs written as UTF-8 without BOM.
  • Remove-StaleInventory.ps1 (High): per-file try/catch so a single locked file no longer aborts the cleanup sweep; \schemaVersion\ validated as positive int in range.

Verification

\
cd app/src-tauri && cargo fmt --all -- --check && cargo test --all && cargo clippy --all-targets -- -D warnings
cd app && node --check src/shared.js && node --check src/view-model.js && node --check src/app.js && node --check src/app-panels.js && node --check src/mock.js && node --check dev-server.js && node --test tests/upgrade-parity.test.js tests/view-model.test.js
\
All green.

Rust backend:
- atomic.rs: replace non-atomic stale-lock takeover (stale-check + remove_file
  + create_new) with PID-liveness-gated atomic rename-to-tombstone, so a slow
  but still-living writer is no longer robbed of its lock.
- common.rs: drop speculative Win11 build 26200 ('25H2'), add 22000 RTM.
- inventory.rs: clamp implausible ageYears (<0, >30y, NaN/Inf) to None instead
  of producing absurd 'Gerät alt (-5 Jahre)' displays.
- merge.rs/assignments.rs: extract effective_display() helper to dedupe the
  'user_display vempty -> fall back to user' logic across three call sites.
- merge.rs: drop redundant .clone() of bios/win11 via as_ref().
- overview.rs: single-pass accumulation of status tallies, dept map, and RAM
  buckets (previously nine separate scans).
- commands.rs: avoid full Vec clone in the AD-fallback path.
- config.rs: control_dir_for no longer falls back to a relative Path::new('')
  for single-segment data_dir inputs.
- upgrade.rs: document inclusive minRamGB boundary.

Frontend:
- Fix counter drift: dashboard 'Upgrade' tag now uses o.upgradeNeeded (the same
  definition the inventory segment and nav badge use) instead of o.status.upgrade.
- Row highlight uses ViewModel.isUpgradeCandidate instead of status==='upgrade',
  so stale-with-reason devices in the Upgrade filter are visually promoted
  rather than dimmed.
- view-model.js: locale-aware collation (numeric:true, de) — umlaut surnames and
  hostnames like 'WS-AB-2' vs 'WS-AB-10' now sort correctly; drop unused sortValue.
- Search input debounced (150ms, mirroring the AD modal); refresh button guarded
  against double-clicks; Escape closes the topmost layer (modal before drawer).
- Drawer foot moved out of drawer-body (previously nested inside, scrolling with
  the body instead of staying sticky).
- Dedupe DEFAULT_THRESHOLDS into shared.js; mock.js cpuClockMhz now derives from
  realistic per-PC clock values; mock set_assignment returns device, activating
  the optimistic UI path.
- __TAURI__ now read at call time, not snapshotted once at load.
- dev-server.js adds X-Content-Type-Options/X-Frame-Options/Referrer-Policy.

PowerShell:
- Get-AdUsers.ps1: force UTF-8 output (no BOM) so umlauts survive the
  Rust/serde_json parse; dispose SearchResultCollection; drop dead null check.
- Invoke-Inventory.ps1: prefer DNSHostName over NetBIOS short name; sum slotsTotal
  across all Win32_PhysicalMemoryArray instances; add MSFT_PhysicalDisk fallback via
  root\Microsoft\Windows\Storage before relying on the unreliable model-string
  regex; clamp implausible ageYears; document LastLoggedOnUser and win11 TPM/
  SecureBoot preflight semantics; write logs as UTF-8 without BOM.
- Remove-StaleInventory.ps1: per-file try/catch so a single locked file no longer
  aborts the cleanup sweep; reject non-integer or out-of-range schemaVersion.

All CI gates remain green: cargo fmt --check, cargo clippy -D warnings (33 tests),
node --check, and the shared golden-vector parity tests.
@zerox80
zerox80 force-pushed the fix/review-2026-07-01 branch from 0772237 to 2d76eaa Compare July 1, 2026 20:23
@zerox80
zerox80 merged commit 2925544 into main Jul 1, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant