Skip to content

Update docs for 0.11.0 and include new changes - #119

Merged
luytan merged 10 commits into
mainfrom
update-doc
Jul 29, 2026
Merged

Update docs for 0.11.0 and include new changes#119
luytan merged 10 commits into
mainfrom
update-doc

Conversation

@luytan

@luytan luytan commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the changes and if applicable, a related issue.

If this PR introduce a new feature, explain your motivations

Fixes # (issue)

TODO

  • Copy-Paste this line

Checklist:

  • My code follows the style guidelines of this project (cargo fmt)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the mdBook documentation
  • My changes generate no new warnings (clippy/clang)
  • New and existing unit tests pass locally with my changes (either use nix flake check or wait for the ci)

Summary by CodeRabbit

  • Documentation
    • Added NVIDIA-specific troubleshooting for nvidia-powerd failures after switching GPU modes.
    • Expanded and reworked installation/requirements/usage docs with clearer distro guidance, systemd/Wayland expectations, and updated BPF LSM verification steps.
    • Updated Smart Mode and configuration instructions (including corrected auto-apply GPU state commands).
    • Enhanced the introduction and refreshed development docs (Smart Mode, eBPF overview, DBus structure, and Switcheroo compatibility), with new pages and links.
  • Documentation (Site Rendering)
    • Improved Mermaid rendering with automatic light/dark theme support.
  • Chores
    • Enabled Mermaid mdBook preprocessing and added Mermaid support to the dev shell and CI.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8a229b69-067b-4d85-bfff-0f7fea4256b7

📥 Commits

Reviewing files that changed from the base of the PR and between 967deee and 19911f0.

📒 Files selected for processing (3)
  • docs/development/bpf.md
  • docs/development/dbus.md
  • docs/development/switcheroo.md

📝 Walkthrough

Walkthrough

Cardwire’s documentation now covers its product model, supported environments, installation paths, Smart Mode behavior, development architecture, Mermaid rendering, and NVIDIA troubleshooting.

Changes

Documentation and Mermaid guidance

Layer / File(s) Summary
Product overview
docs/introduction.md
The introduction describes GPU modes, eBPF/LSM-based GPU access blocking, comparisons with other managers, and the early-development warning.
System requirements and installation
docs/getting-started/requirements.md, docs/getting-started/installation.md
Requirements and installation instructions cover supported distributions, systemd, Wayland, BPF LSM verification, package installation, and source builds.
Usage and configuration
docs/getting-started/usage.md
Smart Mode documentation reflects Switcheroo DBus shim behavior, updated approval variables, and corrected auto-apply GPU state commands.
Development architecture
docs/development/bpf.md, docs/development/dbus.md, docs/development/smart.md, docs/development/switcheroo.md, docs/SUMMARY.md
Development pages describe eBPF hooks and maps, D-Bus interfaces, Smart Mode flow, and the Switcheroo compatibility shim.
Mermaid rendering
book.toml, docs/lib/mermaid/mermaid-init.js, flake.nix, .github/workflows/cicd.yml
mdBook Mermaid preprocessing, theme-aware initialization, development-shell support, and CI installation are configured.
NVIDIA troubleshooting
docs/diagnostics/troubleshooting.md
A troubleshooting entry explains restarting nvidia-powerd.service after an integrated-mode switch failure.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Process
  participant eBPF
  participant UserspaceAnalyzer
  participant CardwireDaemon
  Process->>eBPF: Emit exec event
  eBPF->>UserspaceAnalyzer: Publish process event
  UserspaceAnalyzer->>CardwireDaemon: Update allowed PID state
  CardwireDaemon->>Process: Permit or block GPU access
  Process->>eBPF: Emit exit event
  eBPF->>CardwireDaemon: Publish cleanup event
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is just the unfilled template and lacks a real summary, issue reference, motivation, and checklist completion. Replace the template text with a concrete change summary, add any related issue and motivation, and complete the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: a docs update for version 0.11.0 with additional related changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch update-doc

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (1)
docs/getting-started/installation.md (1)

139-141: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Scope this fallback to supported systemd distributions.

The requirements document states that non-systemd distros are unsupported, but this section tells “other distros” to build and install Cardwire without that restriction. A non-systemd user could follow these steps into an unsupported setup; explicitly require systemd here or rename the section accordingly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/getting-started/installation.md` around lines 139 - 141, Update the
“Other distros” installation guidance to explicitly limit this fallback to
distributions using systemd, matching the documented support requirements.
Either rename the section to identify supported systemd distributions or add an
equivalent systemd prerequisite to the existing clone, make, and BPF LSM
instructions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/diagnostics/troubleshooting.md`:
- Around line 46-54: Update the “nvidia-powerd failure after switching modes”
troubleshooting guidance to scope the restart remedy to systems supporting
NVIDIA Dynamic Boost and where the nvidia-powerd.service unit exists. Clarify
that users on unsupported systems should not run the restart command, while
preserving the existing command for applicable systems.

In `@docs/getting-started/installation.md`:
- Around line 103-117: Update the BPF LSM link in the Ubuntu/Debian installation
instructions to use the generated anchor for the “Enabling BPF LSM (with GRUB)”
heading, `#enabling-bpf-lsm-with-grub`, while leaving the surrounding
installation steps unchanged.

In `@docs/getting-started/requirements.md`:
- Around line 49-53: Update the BPF verification guidance in “Verify BPF is in
the boot cmdline” to distinguish kernel configuration from runtime state:
describe CONFIG_BPF_LSM and CONFIG_LSM outputs as showing built-in/default LSM
support and order only, and identify /proc/cmdline as the source of truth for
whether bpf is active. Preserve the existing GRUB example that appends bpf.

In `@docs/getting-started/usage.md`:
- Line 59: Update the Smart mode description to hyphenate “real-time” when
describing the analyzer, without changing the surrounding wording.

---

Outside diff comments:
In `@docs/getting-started/installation.md`:
- Around line 139-141: Update the “Other distros” installation guidance to
explicitly limit this fallback to distributions using systemd, matching the
documented support requirements. Either rename the section to identify supported
systemd distributions or add an equivalent systemd prerequisite to the existing
clone, make, and BPF LSM instructions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 81a27fc8-1b0d-4b45-be8c-e467479dd481

📥 Commits

Reviewing files that changed from the base of the PR and between fca0bc4 and 2f03087.

📒 Files selected for processing (5)
  • docs/diagnostics/troubleshooting.md
  • docs/getting-started/installation.md
  • docs/getting-started/requirements.md
  • docs/getting-started/usage.md
  • docs/introduction.md

Comment thread docs/diagnostics/troubleshooting.md
Comment thread docs/getting-started/installation.md
Comment thread docs/getting-started/requirements.md
Comment thread docs/getting-started/usage.md Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/development/bpf.md`:
- Around line 11-12: Add a blank line immediately after each affected Markdown
heading, including the “LSM Hooks” heading and the heading at the referenced
second section, to satisfy MD022 while preserving the existing section content.
- Around line 39-41: Update docs/development/bpf.md lines 39-41 to retain the
dirent-length filtering explanation and explicitly state that blocked GPUs are
omitted from directory listings rather than causing an error. Update
docs/development/smart.md lines 51-61 by separating the getdents64 listing
behavior from file_open access behavior, documenting the former as hiding
entries and the latter with its correct -ENOENT result.
- Around line 29-35: Unify the Smart-mode state machine by defining one
canonical mapping for environment flags, analyzer outcomes, cw_allowed_pid
values, and GPU visibility, then apply it consistently at
docs/development/bpf.md:29-35, docs/development/smart.md:21-23,
docs/development/smart.md:55-61, and docs/development/switcheroo.md:41-53.
Update the cw_allowed_pid documentation, analyzer and environment-variable
semantics, Mermaid branches, and CARDWIRE_FORCE_DGPU/CARDWIRE_ALLOW behavior to
match that single mapping.

In `@docs/development/dbus.md`:
- Around line 7-8: Update the SwitcherooControl note link in dbus.md to
reference switcheroo.md, matching the added documentation file and SUMMARY.md
entry.

In `@docs/development/switcheroo.md`:
- Around line 15-16: Add blank lines after every affected subsection heading in
docs/development/switcheroo.md, including HasDualGpu and the referenced
sections, and ensure the file ends with exactly one trailing newline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7478fb06-35cd-4ce0-b165-b45cc39edf8a

📥 Commits

Reviewing files that changed from the base of the PR and between 2f03087 and 8df62a2.

⛔ Files ignored due to path filters (1)
  • docs/lib/mermaid/mermaid.min.js is excluded by !**/*.min.js
📒 Files selected for processing (8)
  • book.toml
  • docs/SUMMARY.md
  • docs/development/bpf.md
  • docs/development/dbus.md
  • docs/development/smart.md
  • docs/development/switcheroo.md
  • docs/lib/mermaid/mermaid-init.js
  • flake.nix

Comment thread docs/development/bpf.md
Comment thread docs/development/bpf.md
Comment on lines +29 to +35
- **`cw_mode`**: Stores the current Cardwire mode (0=Integrated, 1=Hybrid, 2=Manual, 3=Smart).
- **`cw_blocked_ino`**: A hash map containing the inodes of blocked DRM devices (`/dev/dri/cardX`, `/dev/dri/renderDX`). The value indicates the GPU ID (0 for iGPU, 1 for dGPU).
- **`cw_exp_blk_ino`**: Contains inodes of blocked NVIDIA-specific files when `experimental_nvidia_block` is enabled.
- **`cw_allowed_pid`**: Used in Smart mode. Contains the PIDs of applications that have been analyzed and allowed to use the dGPU. The stored value (`__u8`) is used to identify if PID is meant for iGPU(0) or dGPU(1)
- **`cw_allowed_comm`**: A whitelist of process names (like `udev` or `pacman`) that bypass blocking entirely.
- **`cw_daemon_pid`**: Cardwire's own PID so it doesn't block itself.
- **`cw_exec_events`**, **`cw_close_events`**, **`cw_report_events`**: Ring buffers used to send process and block events back to userspace.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Unify the Smart-mode state machine across the development guides.

The environment flags, allowed-PID values, and GPU visibility states currently describe incompatible mappings. Define one canonical table and apply it at every affected site.

  • docs/development/bpf.md#L29-L35: document the canonical cw_allowed_pid value mapping.
  • docs/development/smart.md#L21-L23: align analyzer and environment-variable semantics.
  • docs/development/smart.md#L55-L61: align the Mermaid branches with that mapping.
  • docs/development/switcheroo.md#L41-L53: align CARDWIRE_FORCE_DGPU and CARDWIRE_ALLOW behavior.
📍 Affects 3 files
  • docs/development/bpf.md#L29-L35 (this comment)
  • docs/development/smart.md#L21-L23
  • docs/development/smart.md#L55-L61
  • docs/development/switcheroo.md#L41-L53
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/development/bpf.md` around lines 29 - 35, Unify the Smart-mode state
machine by defining one canonical mapping for environment flags, analyzer
outcomes, cw_allowed_pid values, and GPU visibility, then apply it consistently
at docs/development/bpf.md:29-35, docs/development/smart.md:21-23,
docs/development/smart.md:55-61, and docs/development/switcheroo.md:41-53.
Update the cw_allowed_pid documentation, analyzer and environment-variable
semantics, Mermaid branches, and CARDWIRE_FORCE_DGPU/CARDWIRE_ALLOW behavior to
match that single mapping.

Comment thread docs/development/bpf.md Outdated
Comment on lines +39 to +41
Across all blocking modes (Integrated, Manual, Smart), Cardwire uses the `getdents64` syscall hooks to manipulate the contents of directories (like `/dev/dri/`) on the fly.

**BLOCKED_NVIDIA_FILES**

- For the list of blocked NVIDIA files

**SETTINGS**

- For experimental_nvidia_block

## Block list

### PCI files

Files that get blocked when a gpu's PCI address is blocked:

- config
- current_link_speed
- current_link_width
- max_link_speed
- max_link_width

### NVIDIA files

These files are only blocked when the `experimental_nvidia_block` setting is enabled

- libGLX_nvidia.so.0
- nvidia_icd.json
- nvidia_icd.x86_64.json
- nvidiactl

/dev/nvidia? using the minor

Example:

```bash
/dev/nvidia0
```

Will be blocked using the major `195` and the minor `0`

### DRM

DRM node (card + renderD) are blocked using their major + minor ID

Example:

```bash
/dev/dri/card1
/dev/dri/renderD128
```

Will be blocked using the major `226` and the minor `1` || `128`
When an application calls `getdents64` to list available GPUs, the eBPF program `patch_dirent_if_found` loops through the directory entries in memory. If it spots an inode belonging to a blocked GPU, it overwrites the previous entry's length field, effectively "jumping over" the blocked device. To the application, the blocked GPU simply does not exist.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Separate directory hiding from file-access errors.

The prose and diagram disagree on whether getdents64 removes entries by rewriting dirent lengths or returns -ENOENT. Document each hook’s actual behavior independently.

  • docs/development/bpf.md#L39-L41: retain the dirent-filtering behavior and state its observable result.
  • docs/development/smart.md#L51-L61: split the getdents64 listing path from file_open and show the correct result for each.
📍 Affects 2 files
  • docs/development/bpf.md#L39-L41 (this comment)
  • docs/development/smart.md#L51-L61
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/development/bpf.md` around lines 39 - 41, Update docs/development/bpf.md
lines 39-41 to retain the dirent-length filtering explanation and explicitly
state that blocked GPUs are omitted from directory listings rather than causing
an error. Update docs/development/smart.md lines 51-61 by separating the
getdents64 listing behavior from file_open access behavior, documenting the
former as hiding entries and the latter with its correct -ENOENT result.

Comment thread docs/development/dbus.md Outdated
Comment on lines +15 to +16
### `HasDualGpu`
Indicates whether the system has exactly two GPUs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Complete the markdown formatting incantations.

MD022 flags missing blank lines after the subsection headings, and MD047 reports that the file lacks its final newline. Add the required spacing and exactly one trailing newline.

Also applies to: 20-21, 25-26, 41-42, 50-51, 53-53

🧰 Tools
🪛 markdownlint-cli2 (0.23.1)

[warning] 15-15: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/development/switcheroo.md` around lines 15 - 16, Add blank lines after
every affected subsection heading in docs/development/switcheroo.md, including
HasDualGpu and the referenced sections, and ensure the file ends with exactly
one trailing newline.

Source: Linters/SAST tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

⚠️ Outside diff range comments (1)
docs/getting-started/usage.md (1)

71-71: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Name the actual fallback condition, young scribe.

The daemon gates this XDG/Flatpak detection on !switcheroo_support; it does not check whether “switcheroo/cardwire” is absent. Please change the parenthetical to “Only on systems that do not support Switcheroo,” so the guidance matches crates/cardwire-daemon/src/analyzer/models.rs:183-216.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/getting-started/usage.md` at line 71, Update the parenthetical
description for Flatpak apps with XDG PrefersNonDefaultGpu=true to state “Only
on systems that do not support Switcheroo,” matching the daemon’s
!switcheroo_support condition. Keep the surrounding guidance unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/cicd.yml:
- Line 149: Update the mdbook-mermaid installation step to pin the version
tested with mdbook 0.5.2 and pass Cargo’s --locked option, replacing the
unconstrained install command while preserving the existing workflow setup.

---

Outside diff comments:
In `@docs/getting-started/usage.md`:
- Line 71: Update the parenthetical description for Flatpak apps with XDG
PrefersNonDefaultGpu=true to state “Only on systems that do not support
Switcheroo,” matching the daemon’s !switcheroo_support condition. Keep the
surrounding guidance unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cbf88bb1-178c-4505-87ee-6f170129ea87

📥 Commits

Reviewing files that changed from the base of the PR and between 8df62a2 and 967deee.

📒 Files selected for processing (3)
  • .github/workflows/cicd.yml
  • docs/getting-started/installation.md
  • docs/getting-started/usage.md
💤 Files with no reviewable changes (1)
  • docs/getting-started/installation.md

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf -y | sh
rustup update
cargo install --version ${MDBOOK_VERSION} mdbook
cargo install mdbook-mermaid

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin mdbook-mermaid for reproducible builds.

The workflow pins mdbook but installs an unconstrained Mermaid preprocessor, so future releases can change CI behavior without any repository change. Pin the version tested with mdbook 0.5.2 and use --locked; the upstream project publishes versioned releases and supports Cargo installation. (github.com)

🪄 Proposed fix
-          cargo install mdbook-mermaid
+          cargo install --version <tested-version> --locked mdbook-mermaid
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/cicd.yml at line 149, Update the mdbook-mermaid
installation step to pin the version tested with mdbook 0.5.2 and pass Cargo’s
--locked option, replacing the unconstrained install command while preserving
the existing workflow setup.

@luytan
luytan merged commit 7317953 into main Jul 29, 2026
6 of 8 checks passed
@luytan
luytan deleted the update-doc branch July 29, 2026 16:55
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