…E-2052]
Follow-up fixes to the remediation code-action path, surfaced by review of
the fixFolder work:
- Restrict remediation quick-fixes to products the agent can handle. The
filter previously let fixable Open Source issues through and offered a
RemediationAgentQuickFix the LLM agent cannot apply; replace the negated
IaC bypass with an explicit product switch (Code when it has an AI fix,
IaC) and drop everything else.
- Propagate the codeAction/resolve request context to the provider. The
deferred edit ran with context.Background(), so cancelling a resolve left
the remediation running; the deferred-edit type now carries a context that
is threaded through to Remediate, and a nil deferred edit is guarded in
both the resolve and the AI-fix command paths.
- Make the code-action cache concurrency-safe. actionsCache was an
unsynchronised map read by codeAction/resolve and written by
textDocument/codeAction; add a mutex covering every access, take it only to
read and (via defer) delete the entry, and run the slow edit without the
lock held so the entry survives a concurrent retry and is always cleaned up,
even on panic.
- FixFolder now rejects a worktree with uncommitted tracked changes
(git status --porcelain --untracked-files=no) so it cannot silently fold
pre-existing edits into its result, while ignoring untracked artifacts.
- Advertise snyk.remediationAgent.fixFolder only when the remediation agent
is enabled, via an exported RemediationAgentEnabledKey shared with the DI
gate. Correct the filtered-issue debug count and remove the unused
NoopProvider.
User description
Summary
Follow-up fixes to the remediation code-action flow, surfaced by review of the fixFolder work (PR #1331). All are correctness/robustness fixes; ~217 lines of production change, the rest tests (outside-in TDD throughout).
RemediationAgentQuickFixthe agent can't apply. Replaced the negated IaC bypass with an explicit productswitch(Code when it has an AI fix; IaC) — OSS/Secrets/Unknown excluded.codeAction/resolvecontext to the provider. The deferred edit ran withcontext.Background(), so cancelling a resolve didn't stop the remediation. The deferred-edit type now carries acontext.Contextthreaded toRemediate; nil deferred edits are guarded in both the resolve and AI-fix paths.actionsCachewas an unsynchronised map read bycodeAction/resolveand written bytextDocument/codeAction. Added a mutex covering every access; the entry is read and (viadefer) deleted under the lock, with the slow edit run lock-free — so a concurrent retry still finds the entry and the entry is always cleaned up, even on panic.FixFolderrejects a dirty worktree (git status --porcelain --untracked-files=no) so it can't silently fold pre-existing tracked changes into its result, while ignoring untracked artifacts.snyk.remediationAgent.fixFoldercommand advertisement on the feature flag (exportedRemediationAgentEnabledKeyshared with the DI gate). Fixed the filtered-issue debug count; removed the unusedNoopProvider.PR Stack — Merge Order
flowchart LR main(["main"]) PR0["#1330\nremy unit tests"] PR1["#1331\nfixFolder + remy integ/smoke + cross-platform"] PR2["← YOU ARE HERE\nremediation code-action follow-up fixes"] main --> PR0 --> PR1 --> PR2 style PR2 fill:#ffd700,color:#000Depends on: #1331
Note on size
780 changed lines, but 217 are production and ~563 are tests (TDD acceptance/unit + a
-raceregression test for the cache). Kept as one cohesive bug-fix set rather than fragmenting the review.Test plan
PR Type
Enhancement, Bug fix
Description
Improve remediation code action robustness and concurrency.
Enhance context propagation to remediation providers.
Add product filtering for remediation actions.
Strengthen FixFolder command preconditions and error handling.
Diagram Walkthrough
flowchart LR subgraph LSP Client Client["Client"] end subgraph Snyk LS Server A[textDocument/codeAction] --> B(CodeActionService.GetCodeActions); B --> C{IssuesProvider}; B --> D[remediationCodeActions]; D -- Filters --> E(Product Check); B --> F(cacheCodeAction); F -- Mutex --> G[(actionsCache)]; H[codeAction/resolve] --> I(CodeActionService.ResolveCodeAction); I -- Read/Unlock --> G; I -- Pass Context --> J(DeferredEdit); I -- Mutex --> G; K[FixFolder Command] --> L(Remediator.FixFolder); L -- Git Checks --> M{Worktree Status}; N[Initialize Server] --> O{ExecuteCommandProvider}; O -- Conditionally adds --> P[RemediationAgentFixFolderCommand]; end Client -- Request --> A; Client -- Request --> H; Client -- Execute --> K;File Walkthrough
8 files
Make code action cache concurrency-safe and improve remediation logicExport RemediationAgentEnabledKey and use it for feature flagPass context to ResolveCodeAction handlerConditionally advertise FixFolder command and use exported keyPass context to deferred edits and handle nil deferred editsUpdate deferred edit signature to accept context.ContextUpdate OSS quickfix edit callback to accept context.ContextUpdate CodeAction interface for context in deferred edits11 files
Add tests for cache concurrency and context propagation in codeactionsExport cache length for testingAdd race detector tests for code action cacheTest remediation agent context propagation and OSS issue handlingUse exported RemediationAgentEnabledKey in testUse exported RemediationAgentEnabledKey in smoke testTest conditional command advertisement and remediation agent featuresAdd test for nil deferred edit in code fix commandUpdate mock deferred edit to accept context.ContextAdd tests for FixFolder dirty worktree guardUpdate deferred edit calls in OSS tests1 files
Guard FixFolder against dirty worktrees2 files