fix(worker): harden CLI injection, stuck-Running, chain wedge, and Fail guard
1. ArgumentList (fix injection): ClaudeArgsBuilder.Build() now returns IReadOnlyList<string>; ClaudeProcess populates ProcessStartInfo.ArgumentList instead of Arguments, so values like system prompts are never shell-split. DailyPrepPrompt, RefinePrompt, and WeekReportService migrated similarly. All IClaudeProcess fakes updated. 2. ContinueAsync exception guard: wrap RunOnceAsync in try/catch matching the RunAsync pattern so an unexpected exception never leaves the task stuck in Running status. 3. Planning chain cascade: OnChildFinishedAsync now calls CancelAsync on the immediate blocked successor when a child fails or is cancelled, triggering a recursive cascade that clears the entire remaining chain instead of leaving it wedged. 4. FailAsync guard: restrict valid source states to Running and Queued; WaitingForReview -> Failed is now rejected, preventing an invalid transition that could corrupt the review workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
763732a9b3
commit
33bdff8a6e
@@ -87,12 +87,8 @@ public sealed class PlanningChainCoordinator
|
||||
public async Task<string?> OnChildFinishedAsync(
|
||||
string childTaskId, TaskStatus finalStatus, CancellationToken ct = default)
|
||||
{
|
||||
if (finalStatus != TaskStatus.Done) return null;
|
||||
|
||||
await using var ctx = await _dbFactory.CreateDbContextAsync(ct);
|
||||
// The successor is whichever sibling explicitly blocks on this child.
|
||||
// No status check — UnblockAsync flips legacy Waiting to Queued and is a no-op
|
||||
// for already-Queued rows in the new layout.
|
||||
var nextId = await ctx.Tasks
|
||||
.AsNoTracking()
|
||||
.Where(t => t.BlockedByTaskId == childTaskId)
|
||||
@@ -101,7 +97,16 @@ public sealed class PlanningChainCoordinator
|
||||
.FirstOrDefaultAsync(ct);
|
||||
if (nextId is null) return null;
|
||||
|
||||
await _state().UnblockAsync(nextId, ct);
|
||||
return nextId;
|
||||
if (finalStatus == TaskStatus.Done)
|
||||
{
|
||||
await _state().UnblockAsync(nextId, ct);
|
||||
return nextId;
|
||||
}
|
||||
|
||||
// Child failed or was cancelled: cancel the immediate successor so the chain
|
||||
// is not left wedged. CancelAsync triggers OnChildTerminalAsync → OnChildFinishedAsync
|
||||
// for that successor, cascading cancellation through the rest of the chain.
|
||||
await _state().CancelAsync(nextId, DateTime.UtcNow, ct);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user