fix: filter epic sync issues by label (#3089)

github-coordination sync listed every repo issue and pushed the epic label onto all of them (#3084). Scope the listing to issues carrying the policy's epic label plus issues whose body still holds the coordination marker (label-drift recovery), deduped by number, and reject an empty labels.epic in loadPolicy. Tests cover the filtered path and the recovery path with exact gh argv. Independent exact-head review passed with no P0/P1; CI 44/44 at the head.
This commit is contained in:
Wu Shuwen
2026-09-12 01:46:04 +01:00
committed by GitHub
parent c9148d0bb2
commit 3033436dcc
5 changed files with 116 additions and 4 deletions
+81
View File
@@ -243,6 +243,87 @@ async function runTests() {
passed++;
else failed++;
if (
await test('sync filters the issue list to the configured epic label', async () => {
const rootDir = createTempDir('github-coordination-sync-');
const dbPath = path.join(rootDir, 'state.db');
try {
const epicIssue = {
number: 12,
title: 'Ship GitHub-native coordination',
body: '# Ship GitHub-native coordination',
url: 'https://github.com/affaan-m/ECC/issues/12',
state: 'OPEN',
labels: [{ name: 'epic' }],
author: { login: 'maintainer' },
updatedAt: '2026-06-01T12:00:00Z'
};
const shim = writeGhShim(rootDir, {
'issue list --repo affaan-m/ECC --state all --limit 100 --label epic --json number,title,body,url,state,labels,author,updatedAt,assignees': [epicIssue],
'issue list --repo affaan-m/ECC --state all --limit 100 --search in:body "ecc-coordination:start" --json number,title,body,url,state,labels,author,updatedAt,assignees': []
});
const result = run(['sync', '--repo', 'affaan-m/ECC', '--db', dbPath, '--dry-run', '--json'], {
cwd: rootDir,
env: {
ECC_GH_SHIM: shim.shimPath,
ECC_GH_SHIM_LOG: shim.logPath
}
});
assert.strictEqual(result.status, 0, result.stderr);
const payload = parseJson(result.stdout);
assert.strictEqual(payload.count, 1);
assert.strictEqual(payload.items[0].issueNumber, 12);
} finally {
cleanup(rootDir);
}
})
)
passed++;
else failed++;
if (
await test('sync recovers coordinated issues whose epic label drifted', async () => {
const rootDir = createTempDir('github-coordination-sync-drift-');
const dbPath = path.join(rootDir, 'state.db');
try {
const driftedIssue = {
number: 13,
title: 'Recover label drift',
body: '<!-- ecc-coordination:start -->\n```json\n{}\n```\n<!-- ecc-coordination:end -->',
url: 'https://github.com/affaan-m/ECC/issues/13',
state: 'OPEN',
labels: [{ name: 'coordination:synced' }],
author: { login: 'maintainer' },
updatedAt: '2026-06-01T12:00:00Z'
};
const shim = writeGhShim(rootDir, {
'issue list --repo affaan-m/ECC --state all --limit 100 --label epic --json number,title,body,url,state,labels,author,updatedAt,assignees': [],
'issue list --repo affaan-m/ECC --state all --limit 100 --search in:body "ecc-coordination:start" --json number,title,body,url,state,labels,author,updatedAt,assignees': [driftedIssue]
});
const result = run(['sync', '--repo', 'affaan-m/ECC', '--db', dbPath, '--dry-run', '--json'], {
cwd: rootDir,
env: {
ECC_GH_SHIM: shim.shimPath,
ECC_GH_SHIM_LOG: shim.logPath
}
});
assert.strictEqual(result.status, 0, result.stderr);
const payload = parseJson(result.stdout);
assert.strictEqual(payload.count, 1);
assert.strictEqual(payload.items[0].issueNumber, 13);
assert.ok(payload.items[0].labels.includes('epic'));
} finally {
cleanup(rootDir);
}
})
)
passed++;
else failed++;
process.stdout.write(`\nResults: Passed: ${passed}, Failed: ${failed}\n`);
process.exit(failed > 0 ? 1 : 0);
}