feat(KB-130): allow dependent tasks to start from in-review dep branches

- Relax scheduler dep gate to treat in-review tasks as satisfied
- Add resolveBaseBranch() to detect in-review deps with unmerged worktrees
- Executor creates worktrees from dep branch instead of HEAD when baseBranch is set
- Extend file-overlap tracking to include in-review tasks with worktrees
- Add baseBranch field to Task type and store update logic
- Add scheduler and executor tests for in-review dependency handling
This commit is contained in:
Dustin Byrne
2026-03-27 02:15:20 -04:00
parent dd746ba904
commit 69dca3e11f
7 changed files with 507 additions and 27 deletions

View File

@@ -72,19 +72,21 @@ export class WorktreePool {
* Prepare a recycled worktree for a new task.
*
* Resets the working tree to a clean state, then creates (or force-resets)
* the task's branch based on `main`. This ensures the new task starts
* from the latest main with a clean working directory, while preserving
* untracked build caches (node_modules, target/, dist/).
* the task's branch based on the given start point (or `main` by default).
* This ensures the new task starts from the correct base with a clean
* working directory, while preserving untracked build caches
* (node_modules, target/, dist/).
*
* Steps performed:
* 1. `git checkout -- .` — discard tracked file modifications
* 2. `git clean -fd` — remove untracked files (but not .gitignore'd caches)
* 3. `git checkout -B <branchName> main` — create/reset branch from main
* 3. `git checkout -B <branchName> <startPoint>` — create/reset branch from start point
*
* @param worktreePath — Absolute path to the recycled worktree
* @param branchName — Branch name for the new task (e.g., `kb/kb-042`)
* @param startPoint — Git ref to branch from (e.g., `kb/kb-041`). Defaults to `main`.
*/
prepareForTask(worktreePath: string, branchName: string): void {
prepareForTask(worktreePath: string, branchName: string, startPoint?: string): void {
// Clean tracked modifications
try {
execSync("git checkout -- .", { cwd: worktreePath, stdio: "pipe" });
@@ -95,8 +97,9 @@ export class WorktreePool {
// Remove untracked files (but not .gitignore'd build caches)
execSync("git clean -fd", { cwd: worktreePath, stdio: "pipe" });
// Create or force-reset the branch from main
execSync(`git checkout -B "${branchName}" main`, {
// Create or force-reset the branch from the start point (or main)
const base = startPoint || "main";
execSync(`git checkout -B "${branchName}" ${base}`, {
cwd: worktreePath,
stdio: "pipe",
});