looply-cli 0.5.48 → 0.5.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.src-hash +1 -1
- package/dist/additive-union.d.ts +31 -0
- package/dist/additive-union.d.ts.map +1 -0
- package/dist/additive-union.js +129 -0
- package/dist/additive-union.js.map +1 -0
- package/dist/branch-delivery-wiring.d.ts +7 -3
- package/dist/branch-delivery-wiring.d.ts.map +1 -1
- package/dist/branch-delivery-wiring.js +9 -2
- package/dist/branch-delivery-wiring.js.map +1 -1
- package/dist/branch-delivery.d.ts +31 -2
- package/dist/branch-delivery.d.ts.map +1 -1
- package/dist/branch-delivery.js +142 -7
- package/dist/branch-delivery.js.map +1 -1
- package/dist/branch-replay.d.ts +9 -1
- package/dist/branch-replay.d.ts.map +1 -1
- package/dist/branch-replay.js +58 -6
- package/dist/branch-replay.js.map +1 -1
- package/dist/daemon-cmd.d.ts.map +1 -1
- package/dist/daemon-cmd.js +10 -1
- package/dist/daemon-cmd.js.map +1 -1
- package/dist/deliver-cmd.d.ts +1 -0
- package/dist/deliver-cmd.d.ts.map +1 -1
- package/dist/deliver-cmd.js +2 -0
- package/dist/deliver-cmd.js.map +1 -1
- package/dist/fresh-gates.d.ts +105 -0
- package/dist/fresh-gates.d.ts.map +1 -0
- package/dist/fresh-gates.js +200 -0
- package/dist/fresh-gates.js.map +1 -0
- package/dist/outcome-audit.d.ts +4 -2
- package/dist/outcome-audit.d.ts.map +1 -1
- package/dist/outcome-audit.js +6 -3
- package/dist/outcome-audit.js.map +1 -1
- package/dist/setup-check-wiring.d.ts +18 -0
- package/dist/setup-check-wiring.d.ts.map +1 -1
- package/dist/setup-check-wiring.js +63 -1
- package/dist/setup-check-wiring.js.map +1 -1
- package/dist/ticket-words.d.ts.map +1 -1
- package/dist/ticket-words.js +4 -0
- package/dist/ticket-words.js.map +1 -1
- package/package.json +2 -2
package/dist/branch-delivery.js
CHANGED
|
@@ -130,12 +130,12 @@ rebuild = {}) {
|
|
|
130
130
|
.filter((ids) => /^[0-9a-f]{40}$/.test(ids[0] ?? ''))
|
|
131
131
|
.map(([sha, ...parents]) => ({ sha: sha, parents }));
|
|
132
132
|
},
|
|
133
|
-
async replay(base, commits) {
|
|
133
|
+
async replay(base, commits, opts) {
|
|
134
134
|
try {
|
|
135
135
|
return await (0, branch_replay_1.replayOnto)(exec, (dir) => {
|
|
136
136
|
const inner = (rebuild.execAt ?? git_driver_1.nodeGitExec)(dir);
|
|
137
137
|
return (args) => inner(['-c', 'credential.interactive=never', ...args]);
|
|
138
|
-
}, base, commits, rebuild.scratchRoot);
|
|
138
|
+
}, base, commits, rebuild.scratchRoot, opts);
|
|
139
139
|
}
|
|
140
140
|
catch (e) {
|
|
141
141
|
return { ok: false, because: e.message.slice(0, 300) };
|
|
@@ -577,6 +577,7 @@ async function deliverOnce(deps, input) {
|
|
|
577
577
|
...((input.maintenance && !input.maintenance.autoMerge) || input.noAutoMerge === true ? { noAutoMerge: true } : {}),
|
|
578
578
|
...(input.checks ? { checks: { ...input.checks } } : {}),
|
|
579
579
|
...(input.clientRef ? { clientRef: input.clientRef } : {}),
|
|
580
|
+
...(input.late === true ? { late: true } : {}),
|
|
580
581
|
...(input.parts ? { parts: input.parts.map((p) => ({ ...p })) } : {}),
|
|
581
582
|
state: 'not-pushed',
|
|
582
583
|
note: null,
|
|
@@ -999,6 +1000,78 @@ function decideChecks(required, checks) {
|
|
|
999
1000
|
const waiting = checks.filter((c) => c.state === 'pending').map((c) => c.name);
|
|
1000
1001
|
return waiting.length > 0 ? { kind: 'pending', waiting } : { kind: 'green' };
|
|
1001
1002
|
}
|
|
1003
|
+
/**
|
|
1004
|
+
* THE PROJECT'S CHECKS ON WHAT WILL ACTUALLY LAND (`fresh-gates.ts`): the pull request's head when it is already on top of
|
|
1005
|
+
* the base as it is now, else its own commits replayed onto that base (never merged, never pushed — only checked). Kept
|
|
1006
|
+
* on the entry per head and base, so a pass that changes neither never runs them again.
|
|
1007
|
+
*
|
|
1008
|
+
* passed → merge; review → held for a person, saying why; later → asked again on a later pass.
|
|
1009
|
+
*/
|
|
1010
|
+
async function landedChecks(deps, e, pull, at) {
|
|
1011
|
+
const where = `the current ${(0, delivery_rules_1.shortBranch)(pull.base)}`;
|
|
1012
|
+
if (deps.freshGates === undefined)
|
|
1013
|
+
return { kind: 'review', entry: e, why: `Looply cannot run its checks again on ${where} here` };
|
|
1014
|
+
const head = pull.headSha || e.sha;
|
|
1015
|
+
await deps.git.freshBase(pull.base).catch(() => pull.base);
|
|
1016
|
+
const base = await deps.git.remoteSha((0, delivery_rules_1.shortBranch)(pull.base)).catch(() => null);
|
|
1017
|
+
if (base === null)
|
|
1018
|
+
return { kind: 'later', because: `${(0, delivery_rules_1.shortBranch)(pull.base)} on origin could not be read` };
|
|
1019
|
+
const kept = e.freshGates;
|
|
1020
|
+
let answer;
|
|
1021
|
+
// A kept answer for the same head and base; an "unknown" (a full disk, the network) only for an hour.
|
|
1022
|
+
const keptFresh = kept && kept.head === head && kept.base === base && (kept.verdict !== 'unknown' || now(deps) - Date.parse(kept.at) < UNKNOWN_KEPT_MS);
|
|
1023
|
+
if (kept && keptFresh) {
|
|
1024
|
+
answer =
|
|
1025
|
+
kept.verdict === 'passed'
|
|
1026
|
+
? { verdict: 'passed', checks: kept.checks ?? {} }
|
|
1027
|
+
: kept.verdict === 'failed'
|
|
1028
|
+
? { verdict: 'failed', step: kept.step ?? 'a check', checks: kept.checks ?? {} }
|
|
1029
|
+
: { verdict: 'unknown', because: kept.because ?? 'it could not be judged' };
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
/**
|
|
1033
|
+
* What lands, made only when the checks actually start (in the background, `backgroundFreshGates`): the head when it
|
|
1034
|
+
* already sits on the base, else its commits replayed onto it. Asked by HEAD AND BASE, never by the replayed commit,
|
|
1035
|
+
* whose committer date — and so its sha — differs every time it is made.
|
|
1036
|
+
*/
|
|
1037
|
+
const landing = async () => {
|
|
1038
|
+
if (await deps.git.isAncestor(base, head).catch(() => false))
|
|
1039
|
+
return head;
|
|
1040
|
+
const range = await deps.git.commitsBetween(base, head).catch(() => null);
|
|
1041
|
+
if (range === null || range.length === 0 || range.some((c) => c.parents.length !== 1))
|
|
1042
|
+
return null;
|
|
1043
|
+
const replayed = await deps.git.replay(base, range.map((c) => c.sha)).catch(() => null);
|
|
1044
|
+
return replayed !== null && replayed.ok ? replayed.sha : null;
|
|
1045
|
+
};
|
|
1046
|
+
answer = await deps.freshGates(head, base, landing).catch((err) => ({ verdict: 'unknown', because: err.message }));
|
|
1047
|
+
if (answer.verdict === 'later')
|
|
1048
|
+
return { kind: 'later', because: answer.because };
|
|
1049
|
+
}
|
|
1050
|
+
const entry = {
|
|
1051
|
+
...e,
|
|
1052
|
+
freshGates: {
|
|
1053
|
+
head,
|
|
1054
|
+
base,
|
|
1055
|
+
verdict: answer.verdict,
|
|
1056
|
+
step: answer.verdict === 'failed' ? answer.step : null,
|
|
1057
|
+
because: answer.verdict === 'unknown' ? answer.because.slice(0, 300) : null,
|
|
1058
|
+
checks: answer.verdict === 'unknown' ? null : { ...answer.checks },
|
|
1059
|
+
at,
|
|
1060
|
+
},
|
|
1061
|
+
};
|
|
1062
|
+
if (answer.verdict === 'passed')
|
|
1063
|
+
return { kind: 'passed', entry, checks: { ...answer.checks } };
|
|
1064
|
+
return {
|
|
1065
|
+
kind: 'review',
|
|
1066
|
+
entry,
|
|
1067
|
+
why: answer.verdict === 'failed'
|
|
1068
|
+
? `Looply's checks, run again on ${where}, failed ("${answer.step}"). They ran with the dependencies installed without their install scripts, which a step like Prisma generate or a native module may need, so this may not be the change's fault`
|
|
1069
|
+
: `Looply's checks could not be run again on ${where} (${answer.because.slice(0, 160)})`,
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
/** How long a kept "could not be judged" answer stands before the checks are tried again. */
|
|
1073
|
+
const UNKNOWN_KEPT_MS = 60 * 60_000;
|
|
1074
|
+
const now = (deps) => deps.now();
|
|
1002
1075
|
/** The last merge wait said per goal (`goalStillWanted`): each reason is logged once, not every pass. */
|
|
1003
1076
|
const mergeWaitSaid = new Map();
|
|
1004
1077
|
/**
|
|
@@ -1412,10 +1485,18 @@ async function advanceOne(deps, e) {
|
|
|
1412
1485
|
* commit are the check instead — every one of them passed, or it goes to a person as before.
|
|
1413
1486
|
*/
|
|
1414
1487
|
let noCiNote = null;
|
|
1488
|
+
let rerun = false;
|
|
1489
|
+
// The head is the commit Looply delivered (or rebuilt): nobody else pushed to it.
|
|
1490
|
+
const ownHead = pull.headSha === '' || pull.headSha === e.sha;
|
|
1415
1491
|
if (verdict.kind === 'none' && !approved) {
|
|
1416
1492
|
// The gates ran on the delivered commit: a head that moved, or a `-solo` rebuild, is not what they judged.
|
|
1417
|
-
const sameCommit =
|
|
1418
|
-
|
|
1493
|
+
const sameCommit = ownHead && !e.rebuiltFrom;
|
|
1494
|
+
/**
|
|
1495
|
+
* Late (the outcome auditor's) or LOOPLY'S OWN rebuild: Looply's checks run AGAIN on what lands
|
|
1496
|
+
* (`fresh-gates.ts`), not the run's. A head somebody else pushed is theirs: it goes to a person, as before.
|
|
1497
|
+
*/
|
|
1498
|
+
rerun = deps.freshGates !== undefined && OWN_GATES_STAND_IN.includes(mode) && ownHead && (e.late === true || e.rebuiltFrom != null);
|
|
1499
|
+
const gatesHold = OWN_GATES_STAND_IN.includes(mode) && (rerun || (gatesPassed(e.checks) && sameCommit));
|
|
1419
1500
|
if (age < exports.NO_CHECKS_GRACE_MS) {
|
|
1420
1501
|
/**
|
|
1421
1502
|
* SAY WHAT WILL HAPPEN, NOT "WAITING FOR CI". Under ship to test with Looply's own checks
|
|
@@ -1435,6 +1516,43 @@ async function advanceOne(deps, e) {
|
|
|
1435
1516
|
}
|
|
1436
1517
|
noCiNote = `merged on Looply's own checks (${Object.keys(e.checks ?? {}).join(', ')} passed); the repository reports no CI`;
|
|
1437
1518
|
}
|
|
1519
|
+
/**
|
|
1520
|
+
* 🔴 LATE OR REBUILT: THE CHECKS RUN AGAIN ON WHAT LANDS. A change the outcome auditor delivered hours after its run,
|
|
1521
|
+
* or one rebuilt on the current base, merges on Looply's own word only once the project's checks pass on the change
|
|
1522
|
+
* on top of the base as it is now. Failed or unknown: delivered for review, the ticket saying why in one line.
|
|
1523
|
+
*/
|
|
1524
|
+
const late = e.late === true && ownHead && !approved && verdict.kind !== 'pending';
|
|
1525
|
+
const landed = rerun || late;
|
|
1526
|
+
if (landed) {
|
|
1527
|
+
const f = await landedChecks(deps, e, pull, at);
|
|
1528
|
+
if (f.kind === 'later') {
|
|
1529
|
+
/**
|
|
1530
|
+
* NEVER A SILENT WAIT: the ticket is told it waits for the checks (once), and after a day of waiting (a run of
|
|
1531
|
+
* the repository always in flight, the budget always spent) it goes to a person, saying why.
|
|
1532
|
+
*/
|
|
1533
|
+
const since = e.freshWaitSince ? Date.parse(e.freshWaitSince) : NaN;
|
|
1534
|
+
if (!Number.isNaN(since) && now - since > exports.CHECKS_PATIENCE_MS) {
|
|
1535
|
+
const note = `not merged: Looply's checks could not be run again on the current ${(0, delivery_rules_1.shortBranch)(pull.base)} within a day (${f.because}); a person merges it`;
|
|
1536
|
+
deps.log(`deliver : ${e.goalId}: ${note}`);
|
|
1537
|
+
await save(deps, { ...e, state: 'pr-open', freshWaitSince: null, note, updatedAt: at });
|
|
1538
|
+
}
|
|
1539
|
+
else if (Number.isNaN(since)) {
|
|
1540
|
+
await save(deps, { ...e, freshWaitSince: at, note: `merging once Looply's checks pass again on the current ${(0, delivery_rules_1.shortBranch)(pull.base)} (${f.because})`, updatedAt: at });
|
|
1541
|
+
}
|
|
1542
|
+
return;
|
|
1543
|
+
}
|
|
1544
|
+
if (f.kind === 'review') {
|
|
1545
|
+
const note = `not merged: ${f.why}; a person merges it`;
|
|
1546
|
+
if (e.state !== 'pr-open' || e.note !== note) {
|
|
1547
|
+
deps.log(`deliver : ${e.goalId}: ${note}`);
|
|
1548
|
+
await save(deps, { ...f.entry, freshWaitSince: null, state: 'pr-open', note, updatedAt: at });
|
|
1549
|
+
}
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
e = { ...f.entry, freshWaitSince: null };
|
|
1553
|
+
if (noCiNote !== null)
|
|
1554
|
+
noCiNote = `merged on Looply's own checks, run again on the current ${(0, delivery_rules_1.shortBranch)(pull.base)} (${Object.keys(f.checks).join(', ')} passed); the repository reports no CI`;
|
|
1555
|
+
}
|
|
1438
1556
|
if (verdict.kind === 'pending') {
|
|
1439
1557
|
if (age > exports.CHECKS_PATIENCE_MS) {
|
|
1440
1558
|
await save(deps, { ...e, state: 'pr-open', note: `not merged: still waiting for ${verdict.waiting.join(', ')} after a day; a person merges`, updatedAt: at });
|
|
@@ -1466,6 +1584,15 @@ async function advanceOne(deps, e) {
|
|
|
1466
1584
|
return;
|
|
1467
1585
|
}
|
|
1468
1586
|
}
|
|
1587
|
+
// 🔴 Checked on what lands: the base must still be the one the checks ran on. Moved since → checked again first.
|
|
1588
|
+
if (landed && e.freshGates) {
|
|
1589
|
+
await deps.git.freshBase(pull.base).catch(() => pull.base);
|
|
1590
|
+
const baseNow = await deps.git.remoteSha((0, delivery_rules_1.shortBranch)(pull.base)).catch(() => null);
|
|
1591
|
+
if (baseNow !== e.freshGates.base) {
|
|
1592
|
+
deps.log(`deliver : ${e.goalId}: ${(0, delivery_rules_1.shortBranch)(pull.base)} moved since its checks ran again; checked again before merging`);
|
|
1593
|
+
return;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1469
1596
|
const merged = await api.merge(pull.number, pull.headSha, pullTitle(e.goalText));
|
|
1470
1597
|
if (!merged.merged) {
|
|
1471
1598
|
await save(deps, { ...e, state: 'checks-failed', failedHead: pull.headSha || e.sha, note: `checks allow it but GitHub would not merge: ${merged.message}`, updatedAt: at });
|
|
@@ -1614,9 +1741,14 @@ async function rebuildOnBase(deps, api, e, pull, at, mode) {
|
|
|
1614
1741
|
const commits = range.filter((c) => mine.has(c.sha));
|
|
1615
1742
|
if (commits.some((c) => c.parents.length !== 1))
|
|
1616
1743
|
return held("its own commits include a merge, which Looply never replays");
|
|
1617
|
-
|
|
1744
|
+
// 🔴 A conflict that is only ADDITIONS on both sides to a JSON object (two goals each adding a script to package.json)
|
|
1745
|
+
// is united (`additive-union.ts`); any other conflict still refuses, naming its files, and waits for a person.
|
|
1746
|
+
const replayed = await deps.git.replay(ref, commits.map((c) => c.sha), { unionAdditive: true });
|
|
1618
1747
|
if (!replayed.ok)
|
|
1619
1748
|
return held(replayed.because);
|
|
1749
|
+
const unitedNote = replayed.unioned !== undefined && replayed.unioned.length > 0
|
|
1750
|
+
? ` The only conflict, in ${replayed.unioned.join(', ')}, was additions on both sides; Looply kept both.`
|
|
1751
|
+
: '';
|
|
1620
1752
|
const original = { branch: e.rebuiltFrom?.branch ?? e.branch, sha: e.rebuiltFrom?.sha ?? e.sha };
|
|
1621
1753
|
const named = await soloBranch(deps, { goalId: e.goalId, claims, from: original.branch, replayed, ref, branches, onOrigin, at });
|
|
1622
1754
|
if (!named.ok)
|
|
@@ -1661,7 +1793,7 @@ async function rebuildOnBase(deps, api, e, pull, at, mode) {
|
|
|
1661
1793
|
}
|
|
1662
1794
|
}
|
|
1663
1795
|
await api
|
|
1664
|
-
.closePull(pull.number, `Rebuilt on the current ${base} as ${fresh.url}, because this pull request conflicted with ${base}. Same changes, each commit applied as it was; nothing was resolved by guesswork
|
|
1796
|
+
.closePull(pull.number, `Rebuilt on the current ${base} as ${fresh.url}, because this pull request conflicted with ${base}. Same changes, each commit applied as it was; nothing was resolved by guesswork.${unitedNote}`)
|
|
1665
1797
|
.catch((err) => deps.log(`deliver : ${e.goalId}: could not close ${e.pullRequestUrl ?? `#${pull.number}`} (${err.message})`));
|
|
1666
1798
|
deps.log(`deliver : ${e.goalId}: ${e.pullRequestUrl ?? `#${pull.number}`} conflicted with ${base}; rebuilt as ${fresh.url}`);
|
|
1667
1799
|
const without = others.filter((f) => !unmerged.includes(f)).map((f) => ({ goalId: f.goalId ?? null, branch: f.branch, commits: f.commits.length }));
|
|
@@ -1678,6 +1810,9 @@ async function rebuildOnBase(deps, api, e, pull, at, mode) {
|
|
|
1678
1810
|
mode,
|
|
1679
1811
|
state: 'waiting-checks',
|
|
1680
1812
|
rebuiltFrom: { branch: original.branch, sha: original.sha, without },
|
|
1813
|
+
// A new commit: no wait or answer of the checks on the old one carries over.
|
|
1814
|
+
freshWaitSince: null,
|
|
1815
|
+
freshGates: null,
|
|
1681
1816
|
// 🔴 Nobody approved this commit: an earlier "Approve and ship" does not carry over to it.
|
|
1682
1817
|
approvedAt: null,
|
|
1683
1818
|
voidedApproval: e.approvedAt ?? e.voidedApproval ?? null,
|
|
@@ -1687,7 +1822,7 @@ async function rebuildOnBase(deps, api, e, pull, at, mode) {
|
|
|
1687
1822
|
// The age clock is the original pull request's: a rebuild is not a newer piece of work.
|
|
1688
1823
|
openedAt: e.openedAt,
|
|
1689
1824
|
waitingSince: at,
|
|
1690
|
-
note: `it conflicted with ${base}, so Looply rebuilt it on the current ${base} as ${fresh.url} (replaces ${e.pullRequestUrl ?? `#${pull.number}`}); merging once the checks allow`.slice(0, 600),
|
|
1825
|
+
note: `it conflicted with ${base}, so Looply rebuilt it on the current ${base} as ${fresh.url} (replaces ${e.pullRequestUrl ?? `#${pull.number}`})${replayed.unioned?.length ? `, keeping both sides' additions to ${replayed.unioned.join(', ')}` : ''}; merging once the checks allow`.slice(0, 600),
|
|
1691
1826
|
updatedAt: at,
|
|
1692
1827
|
});
|
|
1693
1828
|
}
|