taskplane 0.21.2 → 0.21.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1069,9 +1069,37 @@ export async function pollUntilTaskComplete(
1069
1069
  }
1070
1070
  }
1071
1071
 
1072
- // Grace period expired without .DONE task failed (TP-070: async)
1072
+ // Grace period expired last resort: check the lane BRANCH for .DONE.
1073
+ // The worker may have committed .DONE before the session exited, but
1074
+ // the worktree filesystem doesn't reflect it (stale checkout, race).
1075
+ // This handles the common case where the worker completes all work,
1076
+ // commits .DONE, and then the session exits before the poll detects it.
1077
+ {
1078
+ const relDonePath = donePath.startsWith(lane.worktreePath)
1079
+ ? donePath.slice(lane.worktreePath.length).replace(/^[\\/]+/, "").replace(/\\/g, "/")
1080
+ : null;
1081
+ if (relDonePath) {
1082
+ const gitResult = runGit(
1083
+ ["show", `${lane.branch}:${relDonePath}`],
1084
+ lane.worktreePath,
1085
+ );
1086
+ if (gitResult.ok) {
1087
+ execLog(laneId, task.taskId, ".DONE found on lane branch (not in worktree) — task succeeded", {
1088
+ session: sessionName,
1089
+ branch: lane.branch,
1090
+ });
1091
+ return {
1092
+ status: "succeeded",
1093
+ exitReason: ".DONE committed to lane branch (found via git show after grace period)",
1094
+ doneFileFound: true,
1095
+ };
1096
+ }
1097
+ }
1098
+ }
1099
+
1100
+ // Truly failed — no .DONE on filesystem or branch
1073
1101
  const logTail = await readLaneLogTailAsync(laneLogPath);
1074
- execLog(laneId, task.taskId, "grace period expired without .DONE — task failed", {
1102
+ execLog(laneId, task.taskId, "grace period expired, no .DONE on filesystem or branch — task failed", {
1075
1103
  session: sessionName,
1076
1104
  logPath: laneLogPath,
1077
1105
  });
@@ -1259,6 +1287,23 @@ export async function executeLane(
1259
1287
  // The task-runner writes .DONE via writeFileSync but never commits it.
1260
1288
  if (pollResult.status === "succeeded") {
1261
1289
  commitTaskArtifacts(lane, task, laneId);
1290
+
1291
+ // Reset worktree to clean state for the next task on this lane.
1292
+ // Without this, the next worker sees the previous task's modified
1293
+ // files and can get confused about which task it's working on.
1294
+ if (lane.tasks.indexOf(task) < lane.tasks.length - 1) {
1295
+ execLog(laneId, task.taskId, "resetting worktree for next task");
1296
+ const resetResult = runGit(["checkout", "--", "."], lane.worktreePath);
1297
+ const cleanResult = runGit(["clean", "-fd"], lane.worktreePath);
1298
+ if (!resetResult.ok || !cleanResult.ok) {
1299
+ execLog(laneId, task.taskId, "worktree reset warning", {
1300
+ resetOk: resetResult.ok,
1301
+ cleanOk: cleanResult.ok,
1302
+ resetErr: resetResult.stderr,
1303
+ cleanErr: cleanResult.stderr,
1304
+ });
1305
+ }
1306
+ }
1262
1307
  }
1263
1308
 
1264
1309
  // If task failed or was paused, skip remaining tasks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskplane",
3
- "version": "0.21.2",
3
+ "version": "0.21.4",
4
4
  "description": "AI agent orchestration for pi — parallel task execution with checkpoint discipline",
5
5
  "keywords": [
6
6
  "pi-package",