Skip to content

Commit a37b238

Browse files
committed
feat: Update RAG API URL in docker-compose files and enhance file permission handling in RAG services
1 parent 1a4247e commit a37b238

6 files changed

Lines changed: 54 additions & 9 deletions

File tree

deployment/docker-compose.prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ services:
134134
SPRING_SESSION_STORE_TYPE: redis
135135
SPRING_REDIS_HOST: redis
136136
SPRING_REDIS_PORT: 6379
137-
RAG_API_URL: http://localhost:8001
137+
RAG_API_URL: http://rag-pipeline:8001
138138
RAG_ENABLED: "true"
139139
LOGGING_FILE_NAME: /app/logs/codecrow-pipeline-agent.log
140140
ports:

deployment/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ services:
135135
SPRING_SESSION_STORE_TYPE: redis
136136
SPRING_REDIS_HOST: redis
137137
SPRING_REDIS_PORT: 6379
138-
RAG_API_URL: http://localhost:8001
138+
RAG_API_URL: http://rag-pipeline:8001
139139
RAG_ENABLED: "true"
140140
#JAVA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5006"
141141
LOGGING_FILE_NAME: /app/logs/codecrow-pipeline-agent.log

java-ecosystem/libs/core/src/main/java/org/rostilos/codecrow/core/persistence/repository/analysis/RagIndexStatusRepository.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ public interface RagIndexStatusRepository extends JpaRepository<RagIndexStatus,
2323
List<RagIndexStatus> findByWorkspaceAndStatus(@Param("workspace") String workspace,
2424
@Param("status") RagIndexingStatus status);
2525

26+
/**
27+
* Check if project has a usable RAG index.
28+
* Returns true when status is INDEXED (normal) or UPDATING (incremental update in progress,
29+
* base index still valid) or FAILED but was previously indexed (lastIndexedAt not null).
30+
*/
2631
@Query("SELECT CASE WHEN COUNT(r) > 0 THEN true ELSE false END FROM RagIndexStatus r " +
27-
"WHERE r.project.id = :projectId AND r.status = 'INDEXED'")
28-
boolean isProjectIndexed(@Param("projectId") Long projectId);
32+
"WHERE r.project.id = :projectId " +
33+
"AND (r.status IN ('INDEXED', 'UPDATING') " +
34+
" OR (r.status = 'FAILED' AND r.lastIndexedAt IS NOT NULL))")
35+
boolean
36+
isProjectIndexed(@Param("projectId") Long projectId);
2937

3038
void deleteByProjectId(Long projectId);
3139
}

java-ecosystem/libs/rag-engine/src/main/java/org/rostilos/codecrow/ragengine/service/IncrementalRagUpdateService.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.io.IOException;
1515
import java.nio.file.Files;
1616
import java.nio.file.Path;
17+
import java.nio.file.attribute.PosixFilePermission;
18+
import java.nio.file.attribute.PosixFilePermissions;
1719
import java.util.*;
1820
import java.util.concurrent.*;
1921

@@ -104,7 +106,9 @@ public Map<String, Object> performIncrementalUpdate(
104106
addedOrModifiedFiles.addAll(addedFiles);
105107
addedOrModifiedFiles.addAll(modifiedFiles);
106108

107-
Path tempDir = Files.createTempDirectory("codecrow-rag-incremental-");
109+
Path tempDir = Files.createTempDirectory("codecrow-rag-incremental-",
110+
PosixFilePermissions.asFileAttribute(
111+
PosixFilePermissions.fromString("rwxrwxrwx")));
108112
try {
109113
int fetchedFiles = fetchFilesToTempDir(
110114
vcsConnection,
@@ -155,8 +159,16 @@ private int fetchFilesToTempDir(
155159
String content = vcsClient.getFileContent(workspaceSlug, repoSlug, filePath, branch);
156160
if (content != null) {
157161
Path targetPath = tempDir.resolve(filePath);
158-
Files.createDirectories(targetPath.getParent());
162+
Path parentDir = targetPath.getParent();
163+
Files.createDirectories(parentDir);
164+
// Ensure all intermediate dirs are world-readable
165+
// (shared /tmp volume between containers)
166+
for (Path dir = parentDir; dir != null && dir.startsWith(tempDir); dir = dir.getParent()) {
167+
dir.toFile().setReadable(true, false);
168+
dir.toFile().setExecutable(true, false);
169+
}
159170
Files.writeString(targetPath, content);
171+
targetPath.toFile().setReadable(true, false);
160172
return true;
161173
}
162174
return false;

java-ecosystem/libs/rag-engine/src/main/java/org/rostilos/codecrow/ragengine/service/RagIndexingService.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.io.*;
99
import java.nio.file.Files;
1010
import java.nio.file.Path;
11+
import java.nio.file.attribute.PosixFilePermissions;
1112
import java.util.List;
1213
import java.util.Map;
1314
import java.util.zip.ZipEntry;
@@ -40,7 +41,9 @@ public Map<String, Object> indexFromArchive(
4041
if (excludePatterns != null && !excludePatterns.isEmpty()) {
4142
log.info("Using {} custom exclude patterns", excludePatterns.size());
4243
}
43-
Path tempDir = Files.createTempDirectory("codecrow-rag-");
44+
Path tempDir = Files.createTempDirectory("codecrow-rag-",
45+
PosixFilePermissions.asFileAttribute(
46+
PosixFilePermissions.fromString("rwxrwxrwx")));
4447
try {
4548
extractArchive(archiveData, tempDir);
4649

@@ -78,7 +81,9 @@ public Map<String, Object> indexFromArchiveFile(
7881
if (excludePatterns != null && !excludePatterns.isEmpty()) {
7982
log.info("Using {} custom exclude patterns", excludePatterns.size());
8083
}
81-
Path tempDir = Files.createTempDirectory("codecrow-rag-");
84+
Path tempDir = Files.createTempDirectory("codecrow-rag-",
85+
PosixFilePermissions.asFileAttribute(
86+
PosixFilePermissions.fromString("rwxrwxrwx")));
8287
try {
8388
extractArchiveFile(archiveFile, tempDir);
8489

@@ -173,8 +178,10 @@ private void extractArchive(byte[] archiveData, Path targetDir) throws IOExcepti
173178

174179
if (entry.isDirectory()) {
175180
Files.createDirectories(entryPath);
181+
setWorldReadable(entryPath);
176182
} else {
177183
Files.createDirectories(entryPath.getParent());
184+
setWorldReadable(entryPath.getParent());
178185

179186
try (FileOutputStream fos = new FileOutputStream(entryPath.toFile())) {
180187
byte[] buffer = new byte[8192];
@@ -183,6 +190,7 @@ private void extractArchive(byte[] archiveData, Path targetDir) throws IOExcepti
183190
fos.write(buffer, 0, len);
184191
}
185192
}
193+
entryPath.toFile().setReadable(true, false);
186194
}
187195
zis.closeEntry();
188196
}
@@ -206,8 +214,10 @@ private void extractArchiveFile(Path archiveFile, Path targetDir) throws IOExcep
206214

207215
if (entry.isDirectory()) {
208216
Files.createDirectories(entryPath);
217+
setWorldReadable(entryPath);
209218
} else {
210219
Files.createDirectories(entryPath.getParent());
220+
setWorldReadable(entryPath.getParent());
211221

212222
try (FileOutputStream fos = new FileOutputStream(entryPath.toFile())) {
213223
byte[] buffer = new byte[8192];
@@ -216,6 +226,7 @@ private void extractArchiveFile(Path archiveFile, Path targetDir) throws IOExcep
216226
fos.write(buffer, 0, len);
217227
}
218228
}
229+
entryPath.toFile().setReadable(true, false);
219230
}
220231
zis.closeEntry();
221232
}
@@ -224,6 +235,17 @@ private void extractArchiveFile(Path archiveFile, Path targetDir) throws IOExcep
224235
log.info("Extracted archive file {} to: {}", archiveFile, targetDir);
225236
}
226237

238+
/**
239+
* Set a path to be world-readable and world-executable (for directories).
240+
* Required because the shared /tmp volume is accessed by multiple containers
241+
* running as different users.
242+
*/
243+
private static void setWorldReadable(Path path) {
244+
File f = path.toFile();
245+
f.setReadable(true, false);
246+
f.setExecutable(true, false);
247+
}
248+
227249
private void deleteDirectory(File dir) {
228250
if (dir.exists()) {
229251
File[] files = dir.listFiles();

java-ecosystem/libs/rag-engine/src/main/java/org/rostilos/codecrow/ragengine/service/RagOperationsServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,10 @@ public void triggerIncrementalUpdate(
224224
analysisJobService.completeJob(job, null);
225225

226226
} catch (Exception e) {
227-
ragIndexTrackingService.markIndexingFailed(project, e.getMessage());
227+
// Use markIncrementalUpdateFailed (keeps status INDEXED, increments failure counter)
228+
// NOT markIndexingFailed which would set status to FAILED and permanently block
229+
// all future incremental updates even though the base index is still valid.
230+
ragIndexTrackingService.markIncrementalUpdateFailed(project, e.getMessage());
228231
log.error("RAG incremental update failed", e);
229232
if (job != null) {
230233
analysisJobService.error(job, "rag_error", "RAG incremental update failed: " + e.getMessage());

0 commit comments

Comments
 (0)