feat(cardwired): internal applications list for smart mode - #162
Conversation
|
Warning Review limit reached
Next review available in: 13 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe daemon now stores application metadata and GPU policies in SQLite. The analyzer discovers application identities from desktop entries, process data, and Steam environments. D-Bus methods expose policy reads and validated updates. ChangesApplication policy analysis
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DaemonManager
participant CardwireDatabase
participant SmartPolicyInterface
participant CardwireAnalyzer
DaemonManager->>CardwireDatabase: Build database and load policy cache
DaemonManager->>SmartPolicyInterface: Pass database handle
DaemonManager->>CardwireAnalyzer: Pass policy cache and metadata sender
SmartPolicyInterface->>CardwireDatabase: Read or update application policies
CardwireAnalyzer->>CardwireDatabase: Persist newly discovered applications
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
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 `@crates/cardwire-daemon/src/analyzer/models.rs`:
- Around line 303-308: Update the GpuPolicy::Forced branch in the policy match
to stop returning hardcoded GPU ID 1. Until the policy model and schema carry a
target GPU ID, reject Forced by returning None; otherwise persist and return the
stored target ID while preserving the existing Blocked and Allowed behavior.
In `@crates/cardwire-daemon/src/analyzer/static_analysis.rs`:
- Around line 108-129: Update the Exec argument loop in the static analyzer to
scan all parts for a steam://rungameid/ URI before applying the wrapper-binary
stop condition. Ensure commands such as “steam steam://rungameid/<id>” extract
and insert the Steam app metadata, while retaining the existing wrapper handling
when no URI is present.
In `@crates/cardwire-daemon/src/file/sql.rs`:
- Around line 85-105: Make queued policy inserts report their SQLite outcome:
update the channel and worker around spawn_blocking in sql.rs to return success
or failure for each request, then in analyzer/models.rs update the cache only
after success and remove or retry the pending entry on failure. Apply changes at
crates/cardwire-daemon/src/file/sql.rs lines 85-105 and
crates/cardwire-daemon/src/analyzer/models.rs lines 336-354, preserving the
existing insert behavior and ensuring failed writes do not permanently block
applications.
In `@crates/cardwire-daemon/src/interface/smart.rs`:
- Around line 153-172: Update set_app_policies to serialize the entire policy
update using a dedicated policy-update lock: acquire it before the blocking
database update and hold it through the cache replacement. Add or reuse a
separate mutex field on the owning type, without using the cache RwLock as the
transaction lock, so database and cache updates remain ordered consistently.
- Around line 157-170: Ensure the persistence flow in discover_app acknowledges
completion of the queued SQLite insert before exposing the app in db_cache, so
update_policy cannot run against an unpersisted entry. Add an acknowledgement
path and await it before cache publication, or retry update_policy after
persistence completes; preserve the existing zero-row failure behavior once
persistence has finished.
🪄 Autofix
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: eda21409-eead-400e-9fc6-0d371abb4421
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (14)
.gitignoreCargo.tomlcrates/cardwire-daemon/Cargo.tomlcrates/cardwire-daemon/src/analyzer/README.mdcrates/cardwire-daemon/src/analyzer/dynamic_analysis.rscrates/cardwire-daemon/src/analyzer/helpers.rscrates/cardwire-daemon/src/analyzer/mod.rscrates/cardwire-daemon/src/analyzer/models.rscrates/cardwire-daemon/src/analyzer/static_analysis.rscrates/cardwire-daemon/src/file/mod.rscrates/cardwire-daemon/src/file/sql.rscrates/cardwire-daemon/src/file/state.rscrates/cardwire-daemon/src/interface/smart.rscrates/cardwire-daemon/src/models.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@crates/cardwire-daemon/src/analyzer/models.rs`:
- Around line 338-362: Update discover_app to maintain a separate in-flight
lookup-name guard alongside db_cache, allowing only one database persistence
request for each unknown application at a time. Check and register the name
before sending through db_tx, skip duplicate discoveries while pending, and
remove the pending entry after every reply, send failure, or other exit path;
keep committed GpuPolicy values in db_cache.
🪄 Autofix
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: 50c4ad3f-4bff-4e36-901f-bb47071098b3
📒 Files selected for processing (4)
crates/cardwire-daemon/src/analyzer/models.rscrates/cardwire-daemon/src/analyzer/static_analysis.rscrates/cardwire-daemon/src/file/sql.rscrates/cardwire-daemon/src/interface/smart.rs
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
Checklist: