Skip to content

Add classic acceleration mode#113

Open
nexiumbiz-debug wants to merge 3 commits into
Gnarus-G:mainfrom
nexiumbiz-debug:classic-accel-mode
Open

Add classic acceleration mode#113
nexiumbiz-debug wants to merge 3 commits into
Gnarus-G:mainfrom
nexiumbiz-debug:classic-accel-mode

Conversation

@nexiumbiz-debug

@nexiumbiz-debug nexiumbiz-debug commented May 9, 2026

Copy link
Copy Markdown

Summary

  • Add a new classic acceleration mode with a configurable EXPONENT parameter.
  • Wire the mode through the driver, Rust CLI/TUI parameter model, NixOS module, and docs.
  • Keep existing mode IDs stable by appending classic after no_accel; exponent 2 matches the existing linear formula path.

Fixes #111.

Verification

  • Passed: git diff --check.
  • Not run locally: cargo fmt --all, cargo test --all, and make test; this Windows Codex environment has no cargo, gcc, make, or installed WSL distro available.

Note

This PR was prepared with AI assistance from the nexiumbiz-debug account. If this solves the requested feature and sponsorship/donation coordination is needed, please handle that privately with the account owner rather than in the public issue thread.

Summary by CodeRabbit

  • New Features
    • Added a "Classic" acceleration mode with a configurable exponent and full support in the CLI, TUI, and kernel interface.
  • Documentation
    • README and NixOS docs updated with Classic mode usage and example configuration (including exponent).
  • Tests
    • Added sensitivity tests validating Classic mode behavior.

Review Change Stack

@vercel

vercel Bot commented May 9, 2026

Copy link
Copy Markdown

@nexiumbiz-debug is attempting to deploy a commit to the gnarusg's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@nexiumbiz-debug has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 53 minutes and 42 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35749ee7-a67b-494b-ba2a-f87ab08bb7f9

📥 Commits

Reviewing files that changed from the base of the PR and between 6066a1d and 43774ae.

📒 Files selected for processing (1)
  • driver/tests/accel.test.c
📝 Walkthrough

Walkthrough

This PR introduces a new "Classic" acceleration mode supporting power-law sensitivity curves with configurable exponent. The feature spans kernel driver implementation, Rust parameter system, CLI/TUI interfaces, NixOS configuration, and comprehensive testing and documentation.

Changes

Classic Acceleration Mode

Layer / File(s) Summary
Parameter Definitions
crates/core/src/params.rs, driver/accel/mode.h
AccelMode enum gains Classic variant. Four new parameters added: ClassicAccel, OffsetClassic, ClassicOutputCap, ClassicExponent, with validation requiring positive exponent and non-negative offset.
Kernel Implementation
driver/accel/classic.h, driver/accel.h
New classic.h header defines classic_curve_args struct, classic_power() helper (fast path for exponent==2), classic_base_fn() for sensitivity computation, and __classic_sens_fun() core function with edge-case handling and optional output capping. accel.h includes classic header, adds union member and dispatch, and adjusts tag type.
Kernel Parameter Wiring
driver/accel_k.h, driver/params.h
collect_args() populates classic union member from kernel parameters. Module parameter EXPONENT registered with build-time conditional default; classic header included where needed.
Rust Core System
crates/core/src/sens_fns.rs, crates/core/src/persist.rs, crates/core/src/context.rs
convert_to_accel_args extended to handle AccelMode::Classic. SysFsStore::set_all_classic() method added for parameter persistence. TUI context snapshot populated with classic parameters.
User Interface
cli/src/main.rs, tui/src/app.rs
CLI Set/Get commands support Classic mode parameter management (imports ALL_CLASSIC_PARAMS and new match arms). TUI adds Classic screen with dynamic graph Y-axis scaling using ClassicOutputCap.
NixOS Configuration
module.nix
Mode option extended to accept "classic" value mapped to integer 4. New exponent option added with positive-float validation and emitted to modprobe parameters (formatted to fixed-point).
Tests & Documentation
driver/tests/accel.test.c, README.md, README_NIXOS.md
Unit test validates classic sensitivity behavior and exponent scaling effects. README documents the Classic formula and marks Classic in the curves checklist. README_NIXOS Quick Start example adds exponent = 2.5.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A classic curve blooms bright,
With exponent's gentle might,
From kernel core to TUI light,
Parameters tuned just right,
The rabbit hops in flight ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add classic acceleration mode' directly and clearly describes the main change—introducing a new acceleration mode called 'classic'.
Linked Issues check ✅ Passed The PR implements classic-style acceleration (issue #111) with a configurable exponent parameter, matching the request for a formula raising linear acceleration to an exponent >2.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the classic acceleration mode: kernel driver support, Rust parameter model/CLI/TUI integration, NixOS module updates, and documentation additions.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
module.nix (1)

45-45: 💤 Low value

Update comment to reflect Classic mode parameter.

Line 45 adds the EXPONENT parameter under the # Linear mode parameters comment (line 41), but EXPONENT is actually a Classic mode parameter. Consider adding a # Classic mode parameters comment above line 45 to improve clarity.

📝 Proposed documentation improvement
  # Linear mode parameters
  ACCEL = cfg.parameters.acceleration;
  OFFSET = cfg.parameters.offset;
  OUTPUT_CAP = cfg.parameters.outputCap;
+
+ # Classic mode parameters
  EXPONENT = cfg.parameters.exponent;
🤖 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 `@module.nix` at line 45, The EXPONENT parameter is currently placed under the
"# Linear mode parameters" heading but belongs to Classic mode; update the file
by inserting a "# Classic mode parameters" comment immediately above the
EXPONENT declaration (or move EXPONENT out from under the "# Linear mode
parameters" block), ensuring the EXPONENT symbol is documented under the Classic
mode section so headings accurately reflect parameter grouping.
🤖 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 `@driver/accel/classic.h`:
- Around line 40-42: The current guard in the function that returns FIXEDPT_ONE
when input_speed <= args.offset or args.exponent <= 0 misses the explicit case
of input_speed == 0 which can lead to division by zero in classic_base_fn;
update the validation in the same function to explicitly check for input_speed
== 0 (or alternatively enforce/validate args.offset is non-negative) and return
FIXEDPT_ONE (or an appropriate safe value) when input_speed is zero to prevent
the division by zero in classic_base_fn.

In `@driver/accel/mode.h`:
- Around line 4-10: The enum declaration uses C++ typed-enum syntax which is
invalid in C; remove the ": unsigned char" part and declare a plain enum
accel_mode with the same enumerators (linear, natural, synchronous, no_accel,
classic) so the code compiles under C (gnu11); if a specific storage size is
required, replace usage sites to cast to/from uint8_t or add explicit storage
variables rather than relying on a typed enum.

---

Nitpick comments:
In `@module.nix`:
- Line 45: The EXPONENT parameter is currently placed under the "# Linear mode
parameters" heading but belongs to Classic mode; update the file by inserting a
"# Classic mode parameters" comment immediately above the EXPONENT declaration
(or move EXPONENT out from under the "# Linear mode parameters" block), ensuring
the EXPONENT symbol is documented under the Classic mode section so headings
accurately reflect parameter grouping.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6a67f19f-4bf7-4bf2-a5e3-12db5126d5af

📥 Commits

Reviewing files that changed from the base of the PR and between c7c1369 and 3968e7d.

📒 Files selected for processing (15)
  • README.md
  • README_NIXOS.md
  • cli/src/main.rs
  • crates/core/src/context.rs
  • crates/core/src/params.rs
  • crates/core/src/persist.rs
  • crates/core/src/sens_fns.rs
  • driver/accel.h
  • driver/accel/classic.h
  • driver/accel/mode.h
  • driver/accel_k.h
  • driver/params.h
  • driver/tests/accel.test.c
  • module.nix
  • tui/src/app.rs

Comment thread driver/accel/classic.h Outdated
Comment thread driver/accel/mode.h Outdated
@nexiumbiz-debug

Copy link
Copy Markdown
Author

Thanks for the review. I pushed commit 6066a1d to address the two actionable items here: the classic sensitivity path now explicitly returns early for zero input speed before the division path, and the driver mode enum is back to a plain C enum while the C-facing tag field stays an unsigned char to preserve the existing Rust/C layout. I also added the zero-speed regression assertion and moved EXPONENT under the classic-mode parameter block in the Nix module. I couldn't run the kernel driver build locally in this Windows environment, but git diff --check is clean.

@nexiumbiz-debug

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 9, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (1)
driver/tests/accel.test.c (1)

109-138: ⚡ Quick win

Consider testing multiple speed values for robustness.

The test validates the core behaviors (exponent=2 equivalence, zero-speed edge case, exponent effect) but uses only a single speed value (4) for the exponent comparisons. Testing multiple speeds would strengthen confidence in the power-law curve.

🧪 Optional: Add multi-speed validation
 static int test_classic_sensitivity(void) {
   struct linear_curve_args linear_args = (struct linear_curve_args){
       .accel = fpt_rconst(0.3),
       .offset = fpt_fromint(1),
       .output_cap = 0,
   };
   struct classic_curve_args classic_args = (struct classic_curve_args){
       .accel = fpt_rconst(0.3),
       .offset = fpt_fromint(1),
       .output_cap = 0,
       .exponent = fpt_fromint(2),
   };

-  fpt speed = fpt_fromint(4);
-  fpt linear_sens = __linear_sens_fun(speed, linear_args);
-  fpt classic_sens = __classic_sens_fun(speed, classic_args);
-
-  assert(linear_sens == classic_sens);
+  // Test exponent=2 equivalence at multiple speeds
+  for (int s = 1; s <= 5; s++) {
+    fpt speed = fpt_fromint(s);
+    fpt linear_sens = __linear_sens_fun(speed, linear_args);
+    fpt classic_sens = __classic_sens_fun(speed, classic_args);
+    assert(linear_sens == classic_sens);
+  }

   classic_args.offset = -FIXEDPT_ONE;
   assert(__classic_sens_fun(0, classic_args) == FIXEDPT_ONE);
   classic_args.offset = fpt_fromint(1);

   classic_args.exponent = fpt_fromint(3);
-  fpt steeper_classic_sens = __classic_sens_fun(speed, classic_args);
-
-  assert(steeper_classic_sens > classic_sens);
+  // Verify exponent effect holds across speeds
+  for (int s = 1; s <= 5; s++) {
+    fpt speed = fpt_fromint(s);
+    classic_args.exponent = fpt_fromint(2);
+    fpt baseline_sens = __classic_sens_fun(speed, classic_args);
+    classic_args.exponent = fpt_fromint(3);
+    fpt steeper_sens = __classic_sens_fun(speed, classic_args);
+    assert(steeper_sens > baseline_sens);
+  }

   return 0;
 }
🤖 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 `@driver/tests/accel.test.c` around lines 109 - 138, The test only checks
sensitivity at speed=4; update test_classic_sensitivity to validate behavior
across multiple speeds by iterating a small set of representative speeds (e.g.,
0, 1, 2, 4, 8 or similar) and for each speed assert that
__linear_sens_fun(speed, linear_args) == __classic_sens_fun(speed, classic_args)
when exponent==2, and that increasing classic_args.exponent (e.g., from 2 to 3)
yields a strictly larger __classic_sens_fun(speed, classic_args) for each
nonzero speed; retain the separate zero-speed/offset edge-case check using
__classic_sens_fun(0, classic_args) == FIXEDPT_ONE.
🤖 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.

Nitpick comments:
In `@driver/tests/accel.test.c`:
- Around line 109-138: The test only checks sensitivity at speed=4; update
test_classic_sensitivity to validate behavior across multiple speeds by
iterating a small set of representative speeds (e.g., 0, 1, 2, 4, 8 or similar)
and for each speed assert that __linear_sens_fun(speed, linear_args) ==
__classic_sens_fun(speed, classic_args) when exponent==2, and that increasing
classic_args.exponent (e.g., from 2 to 3) yields a strictly larger
__classic_sens_fun(speed, classic_args) for each nonzero speed; retain the
separate zero-speed/offset edge-case check using __classic_sens_fun(0,
classic_args) == FIXEDPT_ONE.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0478bb8-a8e1-4ddc-9171-73398d21e404

📥 Commits

Reviewing files that changed from the base of the PR and between 3968e7d and 6066a1d.

📒 Files selected for processing (5)
  • driver/accel.h
  • driver/accel/classic.h
  • driver/accel/mode.h
  • driver/tests/accel.test.c
  • module.nix
🚧 Files skipped from review as they are similar to previous changes (3)
  • driver/accel/classic.h
  • driver/accel.h
  • module.nix

@nexiumbiz-debug

Copy link
Copy Markdown
Author

Small follow-up in 43774ae: broadened the classic sensitivity test across multiple representative speeds and kept the zero-speed edge-case assertion separate. Local validation: git diff --check is clean. I still cannot run make test from this Windows shell because make/WSL/C toolchain are not installed here; the PR's CodeRabbit check is passing on the updated head, with Vercel still awaiting team authorization.

Copy link
Copy Markdown

Hey, just checking in on this one. CodeRabbit is passing now and the only visible check still failing is Vercel asking for team authorization, so I think the implementation is ready for a maintainer look whenever you have a moment.

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.

Add "Classic" Style Accel

2 participants