feat: add remy-backed RemediationProvider skeleton [IDE-2052]#1328
feat: add remy-backed RemediationProvider skeleton [IDE-2052]#1328bastiandoetsch wants to merge 2 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
/describe |
PR Reviewer Guide 🔍
|
|
PR Description updated to latest commit (9bac438) |
|
/describe |
|
PR Description updated to latest commit (9bac438) |
|
/describe |
|
PR Description updated to latest commit (2d61f9d) |
|
Addressing bot findings: Destructive Workspace Mutation + Data Loss Risk: Both criticals are valid for this PR viewed in isolation. The worktree isolation that prevents live workspace mutation is introduced in the next PR in this stack (#1329 feat/IDE-2052-pr4), which clones ContentRoot into a detached git worktree before invoking remy. The |
99f2243 to
a2330ca
Compare
2d61f9d to
37e017b
Compare
|
/describe |
|
PR Description updated to latest commit (37e017b) |
a2330ca to
c50ae83
Compare
37e017b to
8a2b7fa
Compare
Concrete RemediationProvider that shells out to `snyk remy <contentRoot>` against an isolated git worktree. The worktree is caller-supplied; the provider mutates it in place and returns the changes as a WorkspaceEdit built from a before/after git diff. Key design points: - remyRunner seam allows unit testing without a real CLI - context propagated to all git subprocess calls for cancellation - ContentRoot validated as an absolute path before use - product guard: Remy actions offered for Snyk Code only - feature is nil-gated in production (remediation_agent_enabled=false) Interface doc updated with the worktree isolation contract.
Track lastWasInsertion on diffState to reliably detect whether the immediately preceding diff line was a '+' insertion when the '\ No newline at end of file' marker appears. The old code unconditionally decremented currentLine, which was wrong for insertions (applyInsertion never advances the cursor). A first fix attempt used Range.Start.Line == s.currentLine as a proxy but that has a false-positive in multi-hunk diffs where a later hunk header resets currentLine to a value coincidentally matching a prior insertion line. With lastWasInsertion: if the preceding line was '+', strip the synthetic trailing '\n' from the last TextEdit. If '-', compensate with currentLine-- as before. Reset the flag on every non-insertion diff line (hunk header, deletion, context).
8a2b7fa to
6a7850b
Compare
c50ae83 to
0ea7ea9
Compare
User description
Summary
remyProviderstruct backed bygafRunner(invokes GAF"fix"workflow)NewRemyProvider(engine, runner)—runneris the test seamFileChangeNotifierinterface withInvalidateFile(path)InvalidateFileintotextDocument/didChangeandtextDocument/didSaveLSP handlers viadeps.RemediationNotifierremyProviderconstruction behindremediation_agent_enabledconfig keyPR Stack — Merge Order
flowchart LR main(["main"]) PR1["#1326 PR-1\nfindingId + kind"] PR2["#1327 PR-2\nCA provider"] PR3["#? PR-3 ← YOU ARE HERE\nremy initial"] PR4["#? PR-4\nworktree impl"] PR5["#? PR-5\nunit tests"] PR6["#? PR-6\ninteg+smoke tests"] main --> PR1 --> PR2 --> PR3 --> PR4 --> PR5 --> PR6 style PR3 fill:#ffd700,color:#000Depends on: #1327
Test plan
make testpassesPR Type
Enhancement
Description
Introduce Remy-backed RemediationProvider.
Integrate provider into CodeActionService.
Enable via configuration flag
remediation_agent_enabled.Convert git diffs to WorkspaceEdits.
Diagram Walkthrough
flowchart LR A[Configuration: remediation_agent_enabled] --> B(RemyProvider); B --> C(CodeActionService); B -- Uses --> D{Remy CLI}; D -- Mutates --> E[Git Worktree]; E -- Generates --> F(Git Diff); F --> B;File Walkthrough
init.go
Integrate Remy RemediationProvider into DI.application/di/init.go
remediationpackage.RemyProviderconditionally based on theremediation_agent_enabledconfiguration.RemediationProviderinto theCodeActionService.remediationAgentEnabledKeyconstant.provider.go
Define RemediationProvider interface.domain/snyk/remediation/provider.go
RemediationProviderinterface for autonomous fixing.responsibilities regarding worktree mutation.
remy.go
Implement Remy RemediationProvider logic.domain/snyk/snyk/remediation/remy.go
RemediationProviderinterface using thesnyk remyCLI.remyRunner(defaulting to subprocessexecution).
types.WorkspaceEditby parsing git diffs between pre- andpost-mutation states.
subprocess execution.