Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions loopx/control_plane/work_items/task_lease_workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/test_windows_lane_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand Down
7 changes: 5 additions & 2 deletions tests/control_plane_ts/task_lease_workspace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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: [],
Expand All @@ -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));
});
}
});
Expand Down
Loading