Skip to content

Wire Maxine AFX packaging, native path, and rate-specific models (stubbed) - #336

Merged
tonythethompson merged 12 commits into
mainfrom
cursor/nvidia-afx-wiring-753d
Oct 1, 2026
Merged

tonythethompson merged 12 commits into
mainfrom
cursor/nvidia-afx-wiring-753d

Conversation

@tonythethompson

@tonythethompson tonythethompson commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Continues #335 with as-far-as-honest AFX wiring: packaging gates, Maxine-aligned native path, rate-specific models, and settings→stage options. NvidiaAfxIntegration.IsStubbed() stays true. DeepFilterNet remains the live enhancement backend. No Ready claims without Trackdub-hosted redistributables + verified GPU native run.

What works

  • NvidiaAfxRuntimePackageGates rejects placeholder URL/zero-hash/size packages; bundled manifest still non-downloadable
  • License field NvidiaAfxLicenseAccepted + NvidiaAfxRuntimeInstaller (stub/license/gate refusals)
  • Local runtime override via NvidiaAfxRuntimeDirectory / TRACKDUB_NVIDIA_AFX_RUNTIME_ROOT
  • Maxine 3.x layout: NVAudioEffects.dll + features/nvafx*/ (legacy models/*.nvam fallback)
  • Rate-specific models via ModelsBySampleRate / ResolveRequiredModels(sampleRate) (16k + 48k)
  • Feature bin DLL presence gate when a features/ tree is present
  • Native P/Invoke + SetDllImportResolver; managed preload of features/*/bin/*.dll (no SetDllDirectory)
  • Probe prefers 48 kHz when supported; readiness requires models for every supported rate
  • AEC far-end: FarEndReferenceAudioPath on options + dual-input session Process (selector not in Maxine 3.x public docs; stays discoverable-only)
  • Settings → stage: SpeechAudioEnhancementStageHandler uses SpeechAudioEnhancementOptions.FromStudioSettings
  • Docs: docs/reference/nvidia-afx-wiring.md

Still blocked

  • Real Maxine redistributable ZIP URLs + verified SHA-256/size (NVIDIA ships via developer installer, not a public CDN)
  • Flipping IsStubbed() / swapping DI stub readiness for real probe
  • Verified NVAudioEffects.dll create/load/run on Turing+ GPU
  • Desktop UI for AFX license / runtime directory (contracts ready)

Test plan

  • dotnet test tests/Trackdub.Composition.Tests --filter FullyQualifiedName~NvidiaAfx -m:1 (32 passed)
  • dotnet test tests/Trackdub.Infrastructure.Tests --filter FullyQualifiedName~NvidiaAfx -m:1 (23 passed)
  • dotnet test tests/Trackdub.Application.Tests --filter FullyQualifiedName~SpeechAudioEnhancement -m:1 (14 passed)

Base: main (merged docs-rag corpus commit).

Open in Web Open in Cursor 

Review in cubic

Summary by CodeRabbit

  • New Features
    • Speech enhancement requests can now use studio settings and optional far-end reference audio.
    • Added NVIDIA AFX profile and runtime status documentation, including its current availability and setup requirements.
  • Documentation
    • Added NVIDIA AFX entries to the reference navigation and documentation index.
  • Notes
    • NVIDIA AFX remains stubbed and unavailable; DeepFilterNet3 remains the shipping speech-enhancement backend.

cursoragent and others added 3 commits September 30, 2026 23:24
Register AFX for discovery while keeping honest not-ready behavior:
stub readiness in DI, refuse downloads, and fall through to DeepFilterNet
until native packaging is wired. Lock the stub contract with tests and docs.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Check EnableNvidiaAfx and IsStubbed before GetReadiness so a replaced
readiness implementation cannot break DeepFilterNet fallback.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Scaffold honest redistributable gates, Maxine-aligned NvAFX_Run/AEC
far-end, and settings→enhancement stage options without flipping
IsStubbed() or claiming Ready.

Co-authored-by: Anthony Thompson <github@trackdub.com>
@cursor

cursor Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • queue - adds this PR to the back of the merge queue
  • fast - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8245b010-eaaf-402a-a0f8-0cbf49da7161

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR successfully wires NVIDIA AFX packaging gates and native path integration. The implementation demonstrates solid engineering:

Key Strengths:

  • P/Invoke bindings correctly match Maxine AFX SDK signatures with proper IntPtr[] marshalling for pointer-to-pointer parameters
  • Package validation gates properly reject placeholder URLs, zero hashes, and incomplete metadata
  • Far-end reference audio path for AEC properly implemented with dual-input processing
  • Thread-safe native library loading with proper locking
  • Comprehensive test coverage (42 tests passing)

Technical Implementation:

  • NvAFX_Run signature correctly updated to use IntPtr[] for planar channel buffers
  • Proper GCHandle pinning for memory safety during native calls
  • Secure download verification with SHA-256 and size checks
  • Atomic extraction with staging directories
  • Graceful fallback to DeepFilterNet when AFX unavailable

The code is production-ready with IsStubbed() staying true as documented. No merge-blocking defects identified.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@tonythethompson
tonythethompson marked this pull request as ready for review September 30, 2026 23:38
Keep readiness short-circuit tests from stubs and the AEC far-end
fallback coverage from wiring.

Co-authored-by: Anthony Thompson <github@trackdub.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. Cursor Bugbot was not present after the first poll, so that automated-review signal was skipped. No applicable approval policy required human review, and this automation had no prior approval to keep or dismiss.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Wire gated NVIDIA AFX runtime and native audio paths while retaining stub

✨ Enhancement 🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add license and package gates so placeholder AFX runtimes cannot be installed or reported ready.
• Connect studio settings and AEC far-end audio to Maxine-aligned enhancement paths.
• Keep AFX stubbed and DeepFilterNet active until redistributables and GPU execution are verified.
Diagram

graph TD
  Settings["Studio settings"] --> Stage["Enhancement stage"] --> Wrapper["AFX wrapper"] --> Readiness{"Stub or ready?"} -->|Ready| Session["Native AFX session"]
  Readiness -->|Stubbed or unavailable| Fallback["DeepFilterNet fallback"]
  Installer["Runtime installer"] --> Gates["Package gates"]
  subgraph Legend
    direction LR
    _component["Component"] ~~~ _decision{"Decision"}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Local-runtime-only probing
  • ➕ Avoids maintaining an installer before redistributables exist.
  • ➖ Leaves no gated path for future verified, hosted packages.

Recommendation: Retain the gated installer and explicit stub flag: they prepare a future distribution path without presenting placeholder packages or unverified native execution as shipping functionality. A local-only approach is simpler now but would defer the packaging contract.

Files changed (26) +1027 / -87

Enhancement (9) +522 / -50
SpeechAudioEnhancementStageHandler.csPass settings and far-end options into enhancement +36/-2

Pass settings and far-end options into enhancement

• Resolves options from a request override, studio settings, or defaults, then applies an optional request-level far-end path.

src/Trackdub.Application/Transcripts/SpeechAudioEnhancementStageHandler.cs

NvidiaAfxRuntimeInstaller.csAdd license- and package-gated installer +92/-0

Add license- and package-gated installer

• Introduces installation results and checks stub status, license acceptance, manifest metadata, and architecture before invoking the downloader.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeInstaller.cs

NvidiaAfxRuntimeReadinessService.csRecognize local AFX runtime roots +25/-5

Recognize local AFX runtime roots

• Adds settings/environment runtime resolution and native-library checks to the concrete readiness path. Stubbed readiness still returns not ready immediately.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeReadinessService.cs

NvidiaAfxSession.csPrepare frame-aware and dual-input native processing +170/-37

Prepare frame-aware and dual-input native processing

• Queries input/output frame sizes, processes pinned planar buffers, and supplies near- and far-end inputs for AEC.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs

NvidiaAfxSpeechAudioEnhancementService.csPass AEC reference audio to native session +35/-5

Pass AEC reference audio to native session

• Falls back when an AEC reference path is absent; otherwise reads and resamples far-end audio for the native session once AFX is enabled and ready.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs

ISpeechAudioEnhancementService.csExtend enhancement options for AEC and settings +22/-1

Extend enhancement options for AEC and settings

• Adds a far-end reference path and maps studio AFX settings into options, normalizing intensity to the supported range.

src/Trackdub.Contracts/ISpeechAudioEnhancementService.cs

IStudioSettingsService.csAdd AFX license and runtime settings +10/-0

Add AFX license and runtime settings

• Adds persisted settings fields for license acceptance and an optional local runtime directory.

src/Trackdub.Contracts/IStudioSettingsService.cs

NvidiaAfxRuntimePackageGates.csValidate AFX package metadata +84/-0

Validate AFX package metadata

• Rejects missing or placeholder HTTPS URLs, hashes, sizes, versions, and license URLs; also checks whether a manifest contains any downloadable package.

src/Trackdub.Infrastructure/Components/NvidiaAfx/NvidiaAfxRuntimePackageGates.cs

NvidiaAfxRuntimePathResolver.csResolve local or installed AFX runtime +48/-0

Resolve local or installed AFX runtime

• Prefers an existing settings directory, then an environment override, then the component-store install, and checks for the native DLL.

src/Trackdub.Infrastructure/Components/NvidiaAfx/NvidiaAfxRuntimePathResolver.cs

Bug fix (3) +30 / -9
NvidiaAfxNative.csAlign native Run binding with Maxine buffers +21/-6

Align native Run binding with Maxine buffers

• Changes NvAFX_Run to pointer arrays for planar buffers and adds input/output frame parameter names.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxNative.cs

NvidiaAfxProfileCatalog.csCorrect telephony upscale profile metadata +4/-3

Correct telephony upscale profile metadata

• Uses the Maxine 8-to-16 kHz chained selector, 8 kHz input rate, and corresponding model paths.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxProfileCatalog.cs

NvidiaAfxRuntimeDownloader.csReject non-downloadable AFX packages +5/-0

Reject non-downloadable AFX packages

• Applies package validation before creating an install directory or downloading, in addition to the existing stub refusal.

src/Trackdub.Infrastructure/Components/NvidiaAfx/NvidiaAfxRuntimeDownloader.cs

Tests (6) +375 / -0
SpeechAudioEnhancementOptionsPlumbingTests.csTest settings-to-stage option plumbing +136/-0

Test settings-to-stage option plumbing

• Covers AFX settings mapping, intensity clamping, and far-end path forwarding to the enhancement service.

tests/Trackdub.Application.Tests/SpeechAudioEnhancementOptionsPlumbingTests.cs

NvidiaAfxProfileCatalogTests.csTest AEC and telephony profile definitions +20/-0

Test AEC and telephony profile definitions

• Asserts AEC reference requirements and the corrected telephony selector and sample rate.

tests/Trackdub.Composition.Tests/NvidiaAfxProfileCatalogTests.cs

NvidiaAfxRuntimeInstallerTests.csTest installer stub refusal +81/-0

Test installer stub refusal

• Confirms installation fails with the stub reason even when license acceptance and plausible package metadata are supplied.

tests/Trackdub.Composition.Tests/NvidiaAfxRuntimeInstallerTests.cs

NvidiaAfxSpeechAudioEnhancementServiceTests.csTest AEC fallback without reference path +24/-0

Test AEC fallback without reference path

• Confirms an AEC request lacking far-end audio uses the fallback backend.

tests/Trackdub.Composition.Tests/NvidiaAfxSpeechAudioEnhancementServiceTests.cs

NvidiaAfxRuntimePackageGatesTests.csTest package metadata gates +62/-0

Test package metadata gates

• Covers placeholder rejection, plausible package acceptance, and the bundled manifest remaining non-downloadable.

tests/Trackdub.Infrastructure.Tests/Components/NvidiaAfx/NvidiaAfxRuntimePackageGatesTests.cs

NvidiaAfxRuntimePathResolverTests.csTest AFX runtime path resolution +52/-0

Test AFX runtime path resolution

• Checks preference for a configured directory and detection of a missing native DLL.

tests/Trackdub.Infrastructure.Tests/Components/NvidiaAfx/NvidiaAfxRuntimePathResolverTests.cs

Documentation (6) +66 / -22
docs.jsonList AFX wiring reference +1/-0

List AFX wiring reference

• Adds the wiring-status page to documentation navigation.

docs/docs.json

index.mdLink AFX wiring status +1/-0

Link AFX wiring status

• Adds an index link distinguishing the new wiring from the existing stub contract.

docs/index.md

nvidia-afx-stubs.mdClarify remaining AFX stub gates +19/-19

Clarify remaining AFX stub gates

• Updates the stub contract to identify wired capabilities and the packaging, readiness, and GPU-validation work still blocking Ready.

docs/reference/nvidia-afx-stubs.md

nvidia-afx-wiring.mdDocument wired and blocked AFX paths +33/-0

Document wired and blocked AFX paths

• Describes packaging, native, AEC, and settings plumbing alongside the remaining distribution, GPU-validation, and UI blockers.

docs/reference/nvidia-afx-wiring.md

NvidiaAfxIntegration.csClarify stub reason and license links +11/-2

Clarify stub reason and license links

• Explains why AFX remains stubbed and exposes license and developer-resource URLs without changing IsStubbed().

src/Trackdub.Contracts/NvidiaAfxIntegration.cs

NvidiaAfxProfile.csCorrect telephony selector description +1/-1

Correct telephony selector description

• Names the Maxine chained selector used by the telephony upscale profile.

src/Trackdub.Contracts/NvidiaAfxProfile.cs

Other (2) +34 / -6
CompositionRoot.csRegister gated AFX installer dependencies +23/-2

Register gated AFX installer dependencies

• Registers the downloader, installer, and HTTP client while retaining stub readiness and the fallback enhancement service.

src/Trackdub.Composition/CompositionRoot.cs

nvidiaafx-runtime.manifest.jsonAnnotate placeholder runtime manifest +11/-4

Annotate placeholder runtime manifest

• Adds license and developer-resource metadata and replaces telephony model paths while keeping all packages non-downloadable.

src/Trackdub.Composition/nvidiaafx-runtime.manifest.json

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bba189ce66

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeReadinessService.cs Outdated
@qodo-code-review

qodo-code-review Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Telephony upscale writes audio at wrong rate ✓ Resolved
Description
NvidiaAfxSpeechAudioEnhancementService sets outputSampleRate to the 8 kHz input rate even though
the telephony superres8kto16k_denoiser16k effect outputs 16 kHz, and uses that value for the WAV
header, DurationSeconds, and SampleRate. When AFX runs the telephony profile, the output samples
are labeled 8 kHz, making playback run at half speed with doubled duration and incorrect artifact
metadata.
Code

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[R67-71]

+            int outputSampleRate = targetSampleRate;
            await WaveAudioWriter.WriteMonoPcm16Async(
                request.DestinationPath,
                enhanced,
-                targetSampleRate,
+                outputSampleRate,
Relevance

●●● Strong

Rate-changing output mislabeled with input rate deterministically corrupts playback and artifact
metadata.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The catalog selects an 8-to-16 kHz chained effect, and Process returns full output frames for
rate-changing effects, but the service passes the 8 kHz input rate to the WAV writer and uses it in
the result. NVIDIA's separate input and output sample-rate parameters and differing Super Resolution
buffer sizes further establish that the output rate need not equal the input rate.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxProfileCatalog.cs[57-60]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[180-209]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxProfileCatalog.cs[54-64]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[35-45]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[65-80]
🌐 The SDK exposes separate input and output sample rates, and Super Resolution produces more output samples than input samples.

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The AFX service writes and reports the telephony upscale effect's 16 kHz output at its 8 kHz input rate, giving the WAV header, duration, and result metadata the wrong sample rate.

## Fix Focus Areas
- src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[110-138]
- src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[65-80]

## Recommended Fix
In `NvidiaAfxSession.Create`, query `NvidiaAfxNativeParameters.OutputSampleRate` (or calculate `inputRate * NumOutputSamplesPerFrame / NumInputSamplesPerFrame`) and expose the loaded effect's output rate as a property. Use that property in the service for WAV writing, `DurationSeconds`, and `SampleRate`, and add a rate-changing profile test.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Short references cut off speech ✓ Resolved
Description
NvidiaAfxSession.Process reduces sampleCount to the shorter of the near-end and far-end arrays,
then uses that count to copy and trim the output. When AEC is enabled with a shorter or empty
reference WAV, the corresponding near-end speech is silently omitted from the enhanced artifact,
leaving downstream stages with a shorter track and no error.
Code

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[R163-167]

+        int sampleCount = nearEnd.Length;
+        if (farEnd is not null)
        {
-            int remaining = input.Length - offset;
-            int currentFrameSamples = Math.Min(stride, remaining);
-            float[] frameIn = new float[stride];
-            float[] frameOut = new float[stride];
-            Array.Copy(input, offset, frameIn, 0, currentFrameSamples);
-            EnsureSuccess(
-                NvidiaAfxNative.NvAFX_Run(
-                    _handle.DangerousGetHandle(),
-                    frameIn,
-                    frameOut,
-                    _samplesPerFrame,
-                    _channels),
-                _selector,
-                "Run");
-            Array.Copy(frameOut, 0, output, offset, currentFrameSamples);
+            sampleCount = Math.Min(sampleCount, farEnd.Length);
+        }
Relevance

●●● Strong

Short references silently truncate primary audio, a concrete correctness defect requiring
aligned-length handling.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The service reads the near-end audio and a far-end reference from a caller-provided path separately,
so their lengths need not match, then passes both arrays to Process. There, the minimum-length
calculation controls both alignedInput and the final trim; the service writes that reduced result
as the completed enhanced artifact.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[51-71]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[163-181]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[200-209]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[200-206]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
AEC truncates near-end speech whenever the far-end reference is shorter, including when it is empty.

## Fix Focus Areas
- src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[163-178]

## Recommended Fix
Keep `sampleCount = nearEnd.Length`. When filling `farAligned`, copy only `Math.Min(farEnd.Length, sampleCount)` samples and leave the remainder zero-padded; alternatively, reject mismatched durations before processing. Add tests covering a shorter and an empty reference.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Settings errors stop live enhancement ✓ Resolved
Description
ResolveOptionsAsync now loads studio settings for every stage request without explicit options,
and settings-file access errors escape that call. If the file is inaccessible, the handler fails the
stage before the live DeepFilterNet service runs, and the transcript pipeline propagates the
failure.
Code

src/Trackdub.Application/Transcripts/SpeechAudioEnhancementStageHandler.cs[R132-133]

+            StudioSettings settings = await studioSettingsService.LoadAsync(cancellationToken).ConfigureAwait(false);
+            options = SpeechAudioEnhancementOptions.FromStudioSettings(settings);
Relevance

●●● Strong

Recent precedent accepts handling filesystem errors to preserve pipeline fallback behavior.

PR-#210

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both production invocation paths omit explicit options, so they reach the new load. The settings
implementation does not catch file-access errors; the handler marks other exceptions as failures and
rethrows them.

src/Trackdub.Application/Transcripts/Stages/SpeechEnhancementGenerationStage.cs[43-48]
src/Trackdub.Application/Transcripts/ProjectWorkflow.cs[504-509]
src/Trackdub.Infrastructure/Settings/JsonStudioSettingsService.cs[26-45]
src/Trackdub.Application/Transcripts/SpeechAudioEnhancementStageHandler.cs[101-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Settings-file access errors now stop the live speech-enhancement stage before DeepFilterNet runs.
## Fix Focus Areas
- src/Trackdub.Application/Transcripts/SpeechAudioEnhancementStageHandler.cs[125-145]
## Recommended Fix
Handle non-cancellation settings-load failures by logging the error and using default enhancement options; preserve cancellation behavior and add a stage test for an inaccessible settings file.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View medium (2)
4. Far-end fallback test misses its gate ✓ Resolved
Description
EnhanceAsync_FallsBack_WhenAecProfileMissingFarEnd claims its fake readiness gets past the stub
check, but IsStubbed() still returns true. The service returns through that earlier check for
this test, so its assertions pass without exercising the new missing-reference condition.
Code

tests/Trackdub.Composition.Tests/NvidiaAfxSpeechAudioEnhancementServiceTests.cs[R65-69]

+    public async Task EnhanceAsync_FallsBack_WhenAecProfileMissingFarEnd()
+    {
+        var fallback = new FakeSpeechAudioEnhancementService();
+        // Force past stub short-circuit by using a fake readiness + only testing far-end gate
+        // after IsStubbed flips; while stubbed the stub gate wins first, which is also correct.
Relevance

●●● Strong

Recent precedent accepts aligning test comments and semantics with behavior, especially when
assertions miss the intended path.

PR-#210

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3659200 requires test names, comments, and assertions to reflect the behavior they exercise.
The new test claims to get past the stub check, while the service checks the hard-coded stub flag
before evaluating the far-end condition.

Rule 3659200: Keep XML docs and tests aligned with current behavior (rename/reword when semantics change)
tests/Trackdub.Composition.Tests/NvidiaAfxSpeechAudioEnhancementServiceTests.cs[64-85]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[18-27]
src/Trackdub.Contracts/NvidiaAfxIntegration.cs[28-30]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new test passes through the stub fallback rather than testing the missing far-end reference condition.

## Fix Focus Areas
- tests/Trackdub.Composition.Tests/NvidiaAfxSpeechAudioEnhancementServiceTests.cs[64-85]
- src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs[18-27]

## Recommended Fix
Use a testable stub-state seam to reach the far-end check, then assert that a missing reference causes fallback. Until that is possible, rename and reword the test so it does not claim to cover that gate.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Native writes can overrun the output frame buffer ✓ Resolved
Description
When num_output_samples_per_frame cannot be queried, numOutputSamples falls back to the legacy
parameter or to numInputSamples, so outFrame is sized to the input frame. For the upsampling
chained effect, NvAFX_Run then writes more samples than that pinned buffer holds, corrupting
native memory.
Code

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[R120-124]

+            uint numOutputSamples = QueryU32OrDefault(
+                safeHandle,
+                NvidiaAfxNativeParameters.NumOutputSamplesPerFrame,
+                fallbackParameter: NvidiaAfxNativeParameters.SamplesPerFrameLegacy,
+                defaultValue: numInputSamples);
Relevance

●●● Strong

Native buffer overrun is a direct reliability defect; no rejection precedent supports retaining
unsafe sizing.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
RunFrame pins outFrame (length outputFrame) and passes only its raw pointer to native code, so
the native side has no length for the output buffer.

src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[182-184]
src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[226-253]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The output frame size silently falls back to the input frame size. Rate-changing effects then write past the end of the pinned output buffer.

## Fix Focus Areas
- src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs[115-130]

## Recommended Fix
For chained or rate-changing profiles, throw if `num_output_samples_per_frame` cannot be queried. Also check that the output/input frame ratio matches the expected rate ratio before running.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Compliance rules (platform): 4 rules
✅ Web pages:
  +8 more
✅ Cross-repo context — repo relationships
  Explored: repo: trackdubllc/Trackdub-gated (sha: 49391dd4) — View relationship
✅ REVIEW.md
Review mode: 🧠 Deep: This is a broad, behavior-changing native integration spanning packaging, licensing, DI, audio/AEC processing, settings plumbing, and multiple independent code paths with substantial potential for subtle defects.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread tests/Trackdub.Composition.Tests/NvidiaAfxSpeechAudioEnhancementServiceTests.cs Outdated
Comment thread src/Trackdub.Application/Transcripts/SpeechAudioEnhancementStageHandler.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSpeechAudioEnhancementService.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo Fixer

No findings are within the configured fix scope. To change which findings are fixed, adjust the setting on your Qodo configuration page.

Use telephony output sample rate, zero-pad short AEC far-end, require
native create/load before Ready, harden settings-load and frame-size
fallbacks, and cover the gates with tests. Keep IsStubbed() true.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Base automatically changed from cursor/nvidia-afx-stubs-9c86 to main September 30, 2026 23:58
Resolve conflicts after #335 squash-merge onto main by keeping wiring
and review fixes. IsStubbed remains true.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Copilot AI balanced review requested due to automatic review settings October 1, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Native buffer sizing, rate-changing output trimming, headless settings propagation, and post-stub test coverage need correction.

Review effort: Balanced
Findings: 1 High severity · 3 Medium severity · 1 Low severity

Open (5)
What changed in this PR

Adds gated NVIDIA AFX runtime scaffolding while preserving stubbed readiness and DeepFilterNet fallback.

Changes:

  • Adds package, license, runtime-path, and native readiness gates.
  • Aligns native AFX/AEC processing and telephony output handling.
  • Plumbs studio settings and far-end audio into enhancement stages.
File Description
tests/​Trackdub.Infrastructure.Tests/​Components/​NvidiaAfx/​NvidiaAfxRuntimePathResolverTests.cs Tests runtime path resolution.
tests/​Trackdub.Infrastructure.Tests/​Components/​NvidiaAfx/​NvidiaAfxRuntimePackageGatesTests.cs Tests package metadata gates.
tests/​Trackdub.Composition.Tests/​NvidiaAfxSpeechAudioEnhancementServiceTests.cs Tests AEC fallback behavior.
tests/​Trackdub.Composition.Tests/​NvidiaAfxSessionHelpersTests.cs Tests frame and far-end helpers.
tests/​Trackdub.Composition.Tests/​NvidiaAfxRuntimeInstallerTests.cs Tests stubbed installer refusal.
tests/​Trackdub.Composition.Tests/​NvidiaAfxProfileCatalogTests.cs Tests AEC and telephony profiles.
tests/​Trackdub.Composition.Tests/​NvidiaAfxInstalledRuntimeEvaluatorTests.cs Tests native readiness evaluation.
tests/​Trackdub.Application.Tests/​SpeechAudioEnhancementOptionsPlumbingTests.cs Tests settings-to-stage mapping.
src/​Trackdub.Infrastructure/​Components/​NvidiaAfx/​NvidiaAfxRuntimePathResolver.cs Resolves configured or installed runtimes.
src/​Trackdub.Infrastructure/​Components/​NvidiaAfx/​NvidiaAfxRuntimePackageGates.cs Validates package metadata.
src/​Trackdub.Infrastructure/​Components/​NvidiaAfx/​NvidiaAfxRuntimeDownloader.cs Applies gates before download.
src/​Trackdub.Contracts/​NvidiaAfxProfile.cs Corrects telephony selector documentation.
src/​Trackdub.Contracts/​NvidiaAfxIntegration.cs Expands stub status and resource metadata.
src/​Trackdub.Contracts/​IStudioSettingsService.cs Adds AFX license and runtime settings.
src/​Trackdub.Contracts/​ISpeechAudioEnhancementService.cs Adds far-end and settings mapping options.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxSpeechAudioEnhancementService.cs Adds AEC input and output-rate handling.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxSession.cs Implements dual-input native frame processing.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxRuntimeReadinessService.cs Adds installed-runtime native probing.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxRuntimeInstaller.cs Adds gated installer orchestration.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxProfileCatalog.cs Updates telephony and output-rate metadata.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxNative.cs Aligns Maxine P/Invoke declarations.
src/​Trackdub.Composition/​NvidiaAfx/​NvidiaAfxEffectProbe.cs Adds create/load readiness probe.
src/​Trackdub.Composition/​nvidiaafx-runtime.manifest.json Updates placeholder package metadata.
src/​Trackdub.Composition/​CompositionRoot.cs Registers installer and HTTP client.
src/​Trackdub.Application/​Transcripts/​SpeechAudioEnhancementStageHandler.cs Resolves settings and far-end overrides.
docs/​reference/​nvidia-afx-wiring.md Documents wiring and remaining blockers.
docs/​reference/​nvidia-afx-stubs.md Updates the stub contract.
docs/​index.md Links the wiring reference.
docs/​docs.json Adds reference navigation entry.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Outdated
Comment thread src/Trackdub.Infrastructure/Components/NvidiaAfx/NvidiaAfxRuntimePackageGates.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeInstaller.cs Outdated
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeInstaller.cs Fixed
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxRuntimeInstaller.cs Fixed
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Fixed
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs Fixed
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs
Require exact RunFrame channel counts, preserve headless AFX settings,
trim rate-changing padded output, reject non-hex SHA-256, add installer
stub-seam tests, EnsureSuccess on non-chained output-rate set, and narrow
installer catch filters. IsStubbed remains true.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxSession.cs
cursoragent and others added 2 commits October 1, 2026 00:41
Resolve NVAudioEffects.dll and features/nvafx*/models by architecture,
switch profiles to feature+stem model requirements, keep legacy models/
fallback, and leave IsStubbed true until Windows+NVIDIA proof.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Bind 16k/48k model stems per sample rate, require feature bin DLLs
when a features/ tree is present, and resolve NVAudioEffects via
DllImport resolver so CreateEffect can load Maxine feature packages.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxNative.cs Fixed
Comment thread src/Trackdub.Composition/NvidiaAfx/NvidiaAfxNative.cs Fixed
@cursor cursor Bot changed the title Wire Nvidia AFX packaging gates and native path (still stubbed) Wire Maxine AFX packaging, native path, and rate-specific models (stubbed) Oct 1, 2026
Preload features/*/bin/*.dll via NativeLibrary.Load before NVAudioEffects,
keep SetDllImportResolver, and tidy layout resolvers with Select/FirstOrDefault.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Keep Maxine wiring changes; pick up latest main for CI stability.

Co-authored-by: Anthony Thompson <github@trackdub.com>
Address CodeQL style finding on EnumerateFeatureNativeLibraryPaths.

Co-authored-by: Anthony Thompson <github@trackdub.com>
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.

3 participants