MCPcopy Create free account
hub / github.com/SethGammon/Citadel / main

Function main

scripts/live-github-steward-proof.js:283–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

281}
282
283async function main() {
284 const args = parseArgs(process.argv.slice(2));
285 if (args.help) {
286 console.log(usage());
287 return;
288 }
289
290 const owner = gh(['api', 'user', '--jq', '.login']);
291 const workDir = path.join(os.tmpdir(), args.repoName);
292 fs.rmSync(workDir, { recursive: true, force: true });
293 fs.mkdirSync(workDir, { recursive: true });
294
295 console.log(`workDir=${workDir}`);
296 setupInitialRepo(workDir, args);
297 const repoUrl = createGitHubRepo(workDir, owner, args.repoName, args.visibility);
298 console.log(`repo=${repoUrl}`);
299 protectMain(owner, args.repoName);
300 console.log('protected main with strict ci status checks');
301
302 const createdPrs = [];
303 for (let number = 1; number <= args.firstReady; number += 1) {
304 const pr = createAgentPr(workDir, owner, args.repoName, number);
305 createdPrs.push(pr);
306 console.log(`created PR ${number}: ${pr.prUrl}`);
307 }
308
309 const transcript = [];
310 for (let cycle = 1; cycle <= args.maxCycles; cycle += 1) {
311 if (cycle === 3) {
312 for (let number = args.firstReady + 1; number <= args.totalPrs; number += 1) {
313 const pr = createAgentPr(workDir, owner, args.repoName, number);
314 createdPrs.push(pr);
315 console.log(`created PR ${number}: ${pr.prUrl}`);
316 }
317 }
318
319 let result;
320 try {
321 result = runStewardCycle(workDir, cycle);
322 } catch (error) {
323 transcript.push({ cycle, error: error.message });
324 throw error;
325 }
326 const entry = {
327 cycle,
328 outcome: result.outcome,
329 statuses: result.queue.map((item) => ({ id: item.id, status: item.status, reason: item.reason || null })),
330 };
331 transcript.push(entry);
332 console.log(`cycle ${cycle}: ${result.outcome.action}${result.outcome.item ? ` ${result.outcome.item}` : ''}`);
333
334 const landed = result.queue.filter((item) => item.status === 'landed').length;
335 if (result.queue.length === args.totalPrs && landed === args.totalPrs) {
336 console.log(`all ${args.totalPrs} PRs landed at cycle ${cycle}`);
337 break;
338 }
339 await sleep(args.pollMs);
340 }

Callers 1

Calls 11

ghFunction · 0.85
setupInitialRepoFunction · 0.85
createGitHubRepoFunction · 0.85
protectMainFunction · 0.85
createAgentPrFunction · 0.85
runStewardCycleFunction · 0.85
collectProofFunction · 0.85
parseArgsFunction · 0.70
usageFunction · 0.70
sleepFunction · 0.70
assertFunction · 0.70

Tested by

no test coverage detected