feat: remy worktree isolation, per-root mutex, parseDiffHunks fix [IDE-2052]#1329
feat: remy worktree isolation, per-root mutex, parseDiffHunks fix [IDE-2052]#1329bastiandoetsch wants to merge 4 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 Description updated to latest commit (8c0d6a5) |
PR Reviewer Guide 🔍
|
|
/describe |
8c0d6a5 to
c1286ff
Compare
|
/describe |
|
PR Description updated to latest commit (c1286ff) |
1 similar comment
|
PR Description updated to latest commit (c1286ff) |
|
/describe |
|
PR Description updated to latest commit (4ab7fd6) |
|
/describe |
|
PR Description updated to latest commit (4ab7fd6) |
|
Addressing bot finding — Global Lock Contention: The Rationale: The lock-split alternative (snapshot paths, unlock, stat, relock) introduces a TOCTOU race where a concurrent
Keeping the simple design. No code change. |
2d61f9d to
37e017b
Compare
|
/describe |
4ab7fd6 to
131f83f
Compare
|
PR Description updated to latest commit (131f83f) |
37e017b to
8a2b7fa
Compare
131f83f to
51106db
Compare
…on [IDE-2052] - Invoke GAF "fix" workflow in an isolated git worktree (git worktree add --detach) so the real workspace is never mutated during fix generation - Resolve git root via rev-parse for monorepo subdir workspace folders - Partition WorkspaceEdit by req.FilePath; cache remainder per ContentRoot for subsequent code action resolutions without re-invoking remy - Serialize concurrent Remediate calls via per-root mutex with double-checked locking, preventing duplicate LLM invocations - Fix tryServeFromCache data race: hold cacheMu for the full read-validate-consume cycle (cacheValid iterates entry.changes while InvalidateFile deletes from the same map under cacheMu) - Evict empty cache entries in InvalidateFile; use exec.CommandContext with a 30 s cleanup timeout for worktree removal - Fix parseDiffHunks: use inHunk flag instead of "---"/"+++" prefix check (the old check silently dropped deletions of "--" lines, e.g. SQL comments) - Add FileChangeNotifier interface; wire InvalidateFile into both textDocument/didChange and textDocument/didSave LSP handlers - Gate provider behind remediation_agent_enabled config key; wire FileChangeNotifier through di.Dependencies
… complexity [IDE-2052] Extract runRemyInWorktree, buildWorkspaceEdits, populateCache, editsToEdit from Remediate to bring cyclomatic complexity under the gocyclo threshold of 15. Apply spelling fix in codeaction.go. No behavioral change.
8a2b7fa to
6a7850b
Compare
51106db to
24aa3d9
Compare
User description
Summary
workflow.Engine; changes discovered via git diffcacheValidlock precondition documented;cacheValidcalled insidecacheMutryServeFromCache: atomic read-validate-consume undercacheMu(no lock-split)PR Stack — Merge Order
```mermaid
flowchart LR
main(["main"])
PR1["#1326 PR-1\nfindingId + code action kind"]
PR2["#1327 PR-2\nremy provider + multi-product"]
PR3["#1328 PR-3\nNo-newline fix + goimports"]
PR4["#1329 PR-4 ← YOU ARE HERE\nGAF runner + worktree + cache + tests"]
PR5["#1330 PR-5\nunit tests for remy"]
FNDID["#1331 PR-6\nintegration + smoke tests"]
main --> PR1 --> PR2 --> PR3 --> PR4 --> PR5 --> FNDID
style PR4 fill:#ffd700,color:#000
```
Depends on: #1328
Deferred to later PRs
Test plan
go test ./domain/snyk/remediation/...— 83.2% coveragemake test— all packages passmake lint— 0 issuesPR Type
Enhancement, Bug fix
Description
Introduce Remy remediation agent with detached git worktree isolation.
Integrate Go Application Framework runner and implement file caching.
Add per-root mutexes for concurrent remediation calls.
Fix logic in
parseDiffHunksfor accurate diff processing.Diagram Walkthrough
File Walkthrough
init.go
Integrate remediation notifier into DIapplication/di/init.go
remediationNotifierto theDependenciesstruct.remediationNotifierwhen the remediation agent isenabled.
FileChangeNotifierinterface into the dependency injectionsystem.
server.go
LSP handlers trigger file change invalidationapplication/server/server.go
onFileChangecallback (RemediationNotifier.InvalidateFile)to LSP handlers.
textDocument/didChangeandtextDocument/didSavehandlers now invokeonFileChange.provider.go
Define FileChangeNotifier interfacedomain/snyk/remediation/provider.go
FileChangeNotifierinterface with theInvalidateFilemethod.
invalidate them.
remy.go
Core Remy provider logic with GAF, cache, and concurrencydomain/snyk/remediation/remy.go
git worktree add --detach.workflow.
re-computation.
Remediatecallsfor the same root.
parseDiffHunksby using aninHunkflag to correctly handle difflines.
FileChangeNotifierinterface.resolveGitRootto handle monorepos.export_for_test.go
Export diff parsing helper for testsdomain/snyk/remediation/export_for_test.go
workspaceEditFromContentfor testing purposes.remy_provider_test.go
Unit tests for remediation providerdomain/snyk/remediation/remy_provider_test.go
remyProvider.eviction.