Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: auto-cleanup pipeline artifacts when pipeline completes all stages

Adam Eivy2f7249385190
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index a8fc194f64..f29d1e0614 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -7,6 +7,7 @@
- Pipeline stage 2+ tasks stuck in queue forever — follow-up tasks were missing `id` and `status: 'pending'` fields when created with `raw: true`, making them invisible to the task evaluator
- Pipeline tasks not marked completed after agent finishes — `app-improve-*` task IDs were misidentified as user tasks (expected `sys-` prefix), causing `updateTask` to look in the wrong file
- Pipeline stage 2 tasks blocked by app cooldown — pipeline continuations now bypass the 30-minute app review cooldown
+- Pipeline artifacts (e.g., REVIEW.md) not cleaned up after final stage — automated cleanup now deletes `fileNotExists` precondition files when pipeline completes
- Self-update failing with "exit code null" at npm-install step — PM2 watch restarted the server during `git checkout` (which changes `server/` files), breaking the stdout pipe to the update script. SIGPIPE killed the script before `|| true` could handle it, leaving the update incomplete. Added `trap '' PIPE` to ignore SIGPIPE so the script runs to completion.
- Improved update error messages to show signal name (e.g., "killed by SIGPIPE") instead of opaque "exit code null"
diff --git a/server/services/subAgentSpawner.js b/server/services/subAgentSpawner.js
index 01fa2be44f..70bfa7b0f8 100644
--- a/server/services/subAgentSpawner.js
+++ b/server/services/subAgentSpawner.js
@@ -8,7 +8,7 @@
import { spawn, execSync } from 'child_process';
import { join } from 'path';
-import { writeFile, mkdir, readFile, readdir, rm, stat } from 'fs/promises'; // mkdir kept for non-recursive use
+import { writeFile, mkdir, readFile, readdir, rm, stat, unlink } from 'fs/promises'; // mkdir kept for non-recursive use
import { existsSync } from 'fs';
import { homedir } from 'os';
import { v4 as uuidv4 } from 'uuid';
@@ -1877,6 +1877,16 @@ async function handlePipelineProgression(task, agentId, success) {
await updateTask(task.id, {
metadata: { ...task.metadata, pipeline: { ...pipeline, status: 'completed', stageResults: updatedResults } }
}, task.taskType);
+ // Clean up pipeline artifacts (e.g., REVIEW.md left by stage 1)
+ if (task.metadata.repoPath) {
+ for (const stage of stages) {
+ const file = stage.precondition?.fileNotExists;
+ if (file) {
+ const filePath = join(task.metadata.repoPath, file);
+ await unlink(filePath).catch(() => {});
+ }
+ }
+ }
emitLog('info', `✅ Pipeline ${pipeline.id} completed all ${stages.length} stages`, { pipelineId: pipeline.id });
return;
}