From 54f4f258f8530abc2d0d516d0495fdda8c8fbd91 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Sun, 1 Nov 2026 03:40:12 -0800 Subject: [PATCH 1/2] fix(leases): accept scoped native Windows worktree paths Signed-off-by: Lihua <1017343802@qq.com> --- .github/workflows/python-tests.yml | 1 + .../work_items/task_lease_workspace.ts | 15 +++++++++------ .../control_plane_ts/task_lease_workspace.test.ts | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index a550ecc6d1..4df4621a23 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -1025,6 +1025,7 @@ jobs: tests/control_plane_ts/quota_void_commit.test.ts tests/control_plane_ts/shadow_entry_delivery.test.ts tests/control_plane_ts/sqlite_backup.test.ts + tests/control_plane_ts/task_lease_workspace.test.ts - name: Install the frontend dependencies for a source rebuild working-directory: apps/presentation/dashboard diff --git a/loopx/control_plane/work_items/task_lease_workspace.ts b/loopx/control_plane/work_items/task_lease_workspace.ts index 17331884d3..cb4b605ca0 100644 --- a/loopx/control_plane/work_items/task_lease_workspace.ts +++ b/loopx/control_plane/work_items/task_lease_workspace.ts @@ -120,17 +120,20 @@ export async function observeLeaseWorktree(path: string, overlaps: (path: string while (pending.length > 0) { const parent = pending.pop()!; for await (const entry of await opendir(resolve(root, parent))) { - const relative = parent ? `${parent}/${entry.name}` : entry.name; - if (!overlaps(relative) && !overlaps(`${relative}/**`)) continue; - const full = resolve(root, relative); + const scopePath = parent ? `${parent}/${entry.name}` : entry.name; + if (!overlaps(scopePath) && !overlaps(`${scopePath}/**`)) continue; + const full = resolve(root, scopePath); try { const info = await lstat(full); if (info.isSymbolicLink()) { await requireInternalFileLink(root, full, overlaps); - } else if (!(await realpath(full)).startsWith(`${root}/`)) { - throw new LeaseWorktreeObservationError("worktree scope contains a redirected path"); + } else { + const location = relative(root, await realpath(full)); + if (!location || location === ".." || location.startsWith(`..${sep}`) || isAbsolute(location)) { + throw new LeaseWorktreeObservationError("worktree scope contains a redirected path"); + } } - if (info.isDirectory()) pending.push(relative); + if (info.isDirectory()) pending.push(scopePath); } catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; } diff --git a/tests/control_plane_ts/task_lease_workspace.test.ts b/tests/control_plane_ts/task_lease_workspace.test.ts index 63e2186c86..c08905499a 100644 --- a/tests/control_plane_ts/task_lease_workspace.test.ts +++ b/tests/control_plane_ts/task_lease_workspace.test.ts @@ -27,6 +27,9 @@ test("observed Git origins use the Todo repository identity contract", { git("-C", main, "-c", "user.name=Fixture", "-c", "user.email=fixture@example.com", "commit", "--allow-empty", "-m", "fixture"); git("-C", main, "worktree", "add", "-b", "fixture", worktree); + await mkdir(join(worktree, "docs")); + await writeFile(join(worktree, "docs/guide.md"), "public fixture\n"); + const overlaps = (path: string) => evaluateTaskLeaseWriteScopesOverlap({left: ["docs/**"], right: [path]}).overlap === true; for (const [origin, expected] of [ ["https://GITHUB.com:443/example/project.git", repo], ["ssh://git@github.com:22/example/project.git", repo], @@ -37,7 +40,7 @@ test("observed Git origins use the Todo repository identity contract", { ]) { await t.test(origin, async () => { git("-C", main, "config", "remote.origin.url", origin); - const observed = await observeLeaseWorktree(worktree, () => false); + const observed = await observeLeaseWorktree(worktree, overlaps); assert.equal(observed.repository, expected); const input = request(); const decision = evaluateTaskLeaseAcquireDecision({...input, other_leases: [], @@ -56,7 +59,7 @@ test("observed Git origins use the Todo repository identity contract", { ]) { await t.test(`reject ${origin}`, async () => { git("-C", main, "config", "remote.origin.url", origin); - await assert.rejects(observeLeaseWorktree(worktree, () => false)); + await assert.rejects(observeLeaseWorktree(worktree, overlaps)); }); } }); From 94253740d1fe82c4d04d9fe291674f3921bd0184 Mon Sep 17 00:00:00 2001 From: Lihua <1017343802@qq.com> Date: Sun, 1 Nov 2026 04:06:08 -0800 Subject: [PATCH 2/2] test(ci): register scoped worktree coverage in the Windows manifest Signed-off-by: Lihua <1017343802@qq.com> --- scripts/ci/test_windows_lane_coverage.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ci/test_windows_lane_coverage.py b/scripts/ci/test_windows_lane_coverage.py index 4b384b5de4..cb456d0208 100644 --- a/scripts/ci/test_windows_lane_coverage.py +++ b/scripts/ci/test_windows_lane_coverage.py @@ -63,6 +63,7 @@ "tests/control_plane_ts/quota_void_commit.test.ts", # #6356 "tests/control_plane_ts/shadow_entry_delivery.test.ts", # #6356 "tests/control_plane_ts/sqlite_backup.test.ts", # #6258 + "tests/control_plane_ts/task_lease_workspace.test.ts", # #7805 )