Skip to content

Commit 7129ec2

Browse files
cliffhallclaude
andcommitted
fix(sdk-watch): lapse scope ownership with the rows; never settle an unknown install
Copilot on #5285, round 3: - The record of sweep-applied scopes kept a scope whose label a maintainer had removed, since an absent label never entered removeLabels. If they reapplied it, a later catch-up removed their label. Ownership now lapses whenever the rows stop calling for a scope. - A copy with no installed version is not behind, so a group whose lockfile stopped resolving a copy was treated as settled and its issue rewritten as done. A group now settles only when every copy has a known installed version. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent af567a9 commit 7129ec2

2 files changed

Lines changed: 62 additions & 5 deletions

File tree

‎scripts/sdk-watch.mjs‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,11 +393,10 @@ export function refreshPlan(issue, state) {
393393
const removeLabels = before.filter(
394394
(l) => !after.includes(l) && had.has(l) && owned.includes(l),
395395
);
396+
// Ownership lapses once the rows stop calling for a scope, whether or not
397+
// the label was still there to remove: a maintainer may reapply it later.
396398
const applied = [
397-
...new Set([
398-
...owned.filter((l) => !removeLabels.includes(l)),
399-
...addLabels,
400-
]),
399+
...new Set([...owned.filter((l) => after.includes(l)), ...addLabels]),
401400
].sort();
402401
const body = buildIssueBody(state, applied);
403402
// Labels follow the rows, so an unchanged body means unchanged labels.
@@ -718,7 +717,10 @@ export function main({
718717
}
719718
const state = markRows(group, rows, latest);
720719
if (!state) continue;
721-
(state.rows.some((r) => r.behind) ? states : settled).push(state);
720+
if (state.rows.some((r) => r.behind)) states.push(state);
721+
// A copy with no installed version is not known to have caught up, so
722+
// its group is not settled: its issue is left as it is.
723+
else if (state.rows.every((r) => r.installed !== null)) settled.push(state);
722724
}
723725

724726
const emit = (filed) => {

‎scripts/sdk-watch.test.mjs‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,61 @@ test("a scope label someone applied first survives successive refreshes", () =>
820820
assert.equal(refreshPlan(apply(plan4), done), null);
821821
});
822822

823+
test("ownership lapses with the rows, even when the label was already gone", () => {
824+
const latest = { mcp: "1.30.0" };
825+
const time = row("mcp", "src/time", ">=1.29.0,<2", "1.29.0");
826+
const git = (installed) => row("mcp", "src/git", ">=1.29.0,<2", installed);
827+
const both = groupState(group("python-sdk"), [time, git("1.29.0")], latest);
828+
// The sweep applied both; a maintainer has since removed server-git.
829+
const issue = {
830+
body: buildIssueBody(both),
831+
labels: [{ name: "server-time" }],
832+
};
833+
const caughtUp = groupState(
834+
group("python-sdk"),
835+
[time, git("1.30.0")],
836+
latest,
837+
);
838+
const plan = refreshPlan(issue, caughtUp);
839+
assert.deepEqual(plan.removeLabels, []);
840+
assert.deepEqual(appliedScopes(plan.body), ["server-time"]);
841+
842+
// The maintainer reapplies server-git and git falls behind again: the
843+
// label is theirs now, so git catching up a second time leaves it.
844+
const again = refreshPlan(
845+
{
846+
body: plan.body,
847+
labels: [{ name: "server-time" }, { name: "server-git" }],
848+
},
849+
both,
850+
);
851+
assert.deepEqual([again.addLabels, again.removeLabels], [[], []]);
852+
assert.deepEqual(appliedScopes(again.body), ["server-time"]);
853+
const last = refreshPlan(
854+
{
855+
body: again.body,
856+
labels: [{ name: "server-time" }, { name: "server-git" }],
857+
},
858+
caughtUp,
859+
);
860+
assert.deepEqual(last.removeLabels, []);
861+
});
862+
863+
test("a copy with no installed version does not settle its group", (t) => {
864+
const [filed] = filedIssues({
865+
files: files({ "src/time/uv.lock": UV("2.3.0") }),
866+
});
867+
// The lockfile no longer resolves either copy: nothing is behind, but
868+
// nothing is known to have caught up either.
869+
const lockless = files({
870+
"src/time/uv.lock": UV("2.3.0"),
871+
"package-lock.json": JSON.stringify({ packages: {} }),
872+
});
873+
const none = fakeWorld({ issues: [filed], files: lockless });
874+
run(none, { output: outputFile(t) });
875+
assert.equal(writes(none.calls).length, 0);
876+
});
877+
823878
test("an open issue whose installs changed is refreshed in place, once", (t) => {
824879
const noPy = files({ "src/time/uv.lock": UV("2.3.0") });
825880
const [filed] = filedIssues({ files: noPy });

0 commit comments

Comments
 (0)