@codyswann/lisa 8.1.1 → 8.2.0
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/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.json +138 -11
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/scripts/queue-contract-resolution.mjs +583 -0
- package/plugins/lisa/.codex-plugin/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa/.codex-plugin/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-agy/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-agy/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-agy/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-agy/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-agy/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-agy/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa-agy/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa-agy/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa-agy/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-agy/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-copilot/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa-copilot/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa-copilot/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-cursor/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa-cursor/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa-cursor/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-cursor/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/scripts/ready-queue-order.mjs +99 -25
- package/plugins/lisa-devin/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/lisa-devin/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/lisa-devin/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/lisa-devin/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/lisa-devin/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/lisa-devin/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/lisa-devin/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/lisa-devin/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/lisa-devin/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/lisa-devin/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/scripts/ready-queue-order.mjs +99 -25
- package/plugins/src/base/scripts/stale-blocker-comment.mjs +185 -0
- package/plugins/src/base/scripts/stale-blocker-confirm.mjs +130 -0
- package/plugins/src/base/scripts/stale-blocker-edges.mjs +466 -0
- package/plugins/src/base/scripts/stale-blocker-pending.mjs +257 -0
- package/plugins/src/base/scripts/stale-blocker-restore.mjs +180 -0
- package/plugins/src/base/scripts/stale-blocker-summary.mjs +222 -0
- package/plugins/src/base/scripts/stale-blocker-sweep.mjs +394 -0
- package/plugins/src/base/scripts/stale-blocker-verify.mjs +193 -0
- package/plugins/src/base/skills/lisa-atlassian-access/SKILL.md +1 -0
- package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +2 -7
- package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +2 -0
- package/plugins/src/base/skills/lisa-linear-access/SKILL.md +44 -0
- package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +2 -0
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +127 -2
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-queue.mjs +90 -20
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links-results.mjs +254 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-stale-links.mjs +243 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +60 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/queue-github.mjs +68 -8
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +49 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-github.mjs +196 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/stale-links-state.mjs +173 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Comments owed for stale-link removals that are already confirmed
|
|
4
|
+
* (CodySwannGT/lisa#5065).
|
|
5
|
+
*
|
|
6
|
+
* Once a removal reads back as done, its link is gone and no later plan will
|
|
7
|
+
* see it again. If posting the comment then fails, or the writer is stopped
|
|
8
|
+
* before it posts, the operator would never learn why the link went. So each
|
|
9
|
+
* confirmed removal is recorded here as pending until its comment is posted,
|
|
10
|
+
* and pending comments are retried on their own, separately from any new
|
|
11
|
+
* plan. The record is plain JSON so any agent can keep it in its state
|
|
12
|
+
* directory; the functions here are pure and do no I/O.
|
|
13
|
+
*
|
|
14
|
+
* The same directory keeps a second record: the items whose planned
|
|
15
|
+
* removals did NOT happen. Their links are still there, so every cycle plans
|
|
16
|
+
* them again; without the record, items that keep failing and sort first
|
|
17
|
+
* would spend the per-cycle cap every time and starve later items. The
|
|
18
|
+
* planner puts a recorded item after every other candidate
|
|
19
|
+
* (`planStaleLinkSweep({failures})`), and a removal that later succeeds
|
|
20
|
+
* clears its record, so it returns to the normal order.
|
|
21
|
+
* @module stale-blocker-pending
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One comment still owed.
|
|
26
|
+
* @typedef {object} PendingComment
|
|
27
|
+
* @property {string} ref - The item
|
|
28
|
+
* @property {string[]} removed - Its confirmed removals
|
|
29
|
+
* @property {string} comment - The comment to post
|
|
30
|
+
* @property {object | null} commentAdf - The same as ADF for Jira, else null
|
|
31
|
+
* @property {string} since - When the removal was confirmed (ISO time)
|
|
32
|
+
* @property {number} attempts - Failed posts so far
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param {{ ref: string, removed: readonly string[] }} entry
|
|
37
|
+
* @returns {string} Identity of a pending comment
|
|
38
|
+
*/
|
|
39
|
+
const keyOf = entry =>
|
|
40
|
+
`${entry.ref}|${[...(entry.removed ?? [])].sort().join(",")}`;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Record the comment owed for one verified result. A result with nothing
|
|
44
|
+
* confirmed owes nothing; recording the same removals twice keeps one entry.
|
|
45
|
+
* @param {readonly PendingComment[]} pending
|
|
46
|
+
* @param {Pick<import("./stale-blocker-verify.mjs").StaleLinkResult, "ref" | "confirmed" | "comment"> & { commentAdf?: object | null }} result - A verify result
|
|
47
|
+
* @param {string} now - ISO time
|
|
48
|
+
* @returns {PendingComment[]}
|
|
49
|
+
*/
|
|
50
|
+
export function addPending(pending, result, now) {
|
|
51
|
+
const list = Array.isArray(pending) ? [...pending] : [];
|
|
52
|
+
if (!result?.comment || result.confirmed.length === 0) return list;
|
|
53
|
+
const entry = {
|
|
54
|
+
ref: result.ref,
|
|
55
|
+
removed: [...result.confirmed],
|
|
56
|
+
comment: result.comment,
|
|
57
|
+
commentAdf: result.commentAdf ?? null,
|
|
58
|
+
since: now,
|
|
59
|
+
attempts: 0,
|
|
60
|
+
};
|
|
61
|
+
return list.some(one => keyOf(one) === keyOf(entry))
|
|
62
|
+
? list
|
|
63
|
+
: [...list, entry];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Drop the ONE comment that just posted: an item can owe more than one (a
|
|
68
|
+
* post failed, then a later cycle confirmed other removals), and each is
|
|
69
|
+
* identified by its item and its removed set, as {@link addPending} keys it.
|
|
70
|
+
* @param {readonly PendingComment[]} pending
|
|
71
|
+
* @param {string} ref
|
|
72
|
+
* @param {readonly string[]} removed - The posted comment's `removed`
|
|
73
|
+
* @returns {PendingComment[]}
|
|
74
|
+
*/
|
|
75
|
+
export const settlePending = (pending, ref, removed) => {
|
|
76
|
+
const key = keyOf({ ref, removed });
|
|
77
|
+
return (Array.isArray(pending) ? pending : []).filter(
|
|
78
|
+
one => keyOf(one) !== key
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Count one more failed post for that one comment.
|
|
84
|
+
* @param {readonly PendingComment[]} pending
|
|
85
|
+
* @param {string} ref
|
|
86
|
+
* @param {readonly string[]} removed - The comment's `removed`
|
|
87
|
+
* @returns {PendingComment[]}
|
|
88
|
+
*/
|
|
89
|
+
export const failedPending = (pending, ref, removed) => {
|
|
90
|
+
const key = keyOf({ ref, removed });
|
|
91
|
+
return (Array.isArray(pending) ? pending : []).map(one =>
|
|
92
|
+
keyOf(one) === key
|
|
93
|
+
? { ...one, attempts: Number(one.attempts ?? 0) + 1 }
|
|
94
|
+
: one
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Items whose planned removals did not happen, by ref.
|
|
100
|
+
* @typedef {Record<string, { attempts: number, since: string, stillPresent: string[] }>} RemovalFailures
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Update the failure record from one verified result: a planned removal
|
|
105
|
+
* still on the item counts one more failure; none left clears the record.
|
|
106
|
+
* @param {RemovalFailures | undefined} failures
|
|
107
|
+
* @param {{ ref: string, stillPresent: readonly string[] }} result
|
|
108
|
+
* @param {string} now - ISO time
|
|
109
|
+
* @returns {RemovalFailures}
|
|
110
|
+
*/
|
|
111
|
+
export function recordRemovalResult(failures, result, now) {
|
|
112
|
+
const current =
|
|
113
|
+
failures && typeof failures === "object" && !Array.isArray(failures)
|
|
114
|
+
? failures
|
|
115
|
+
: {};
|
|
116
|
+
const { [result.ref]: previous, ...rest } = current;
|
|
117
|
+
if (result.stillPresent.length === 0) return rest;
|
|
118
|
+
return {
|
|
119
|
+
...rest,
|
|
120
|
+
[result.ref]: {
|
|
121
|
+
attempts: Number(previous?.attempts ?? 0) + 1,
|
|
122
|
+
since: previous?.since ?? now,
|
|
123
|
+
stillPresent: [...result.stillPresent],
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Confirmed plan entries whose writes are about to run, by item ref. A
|
|
130
|
+
* confirm records its entry here BEFORE any delete, and only a verify that
|
|
131
|
+
* read the item back settles it. So a read-back that fails after the
|
|
132
|
+
* deletes ran (or a writer stopped in between) leaves the removals
|
|
133
|
+
* recoverable: the entry is verified again on the next cycle instead of its
|
|
134
|
+
* links vanishing with no comment and no restore check.
|
|
135
|
+
* @typedef {Record<string, { plan: object, since: string, attempts: number }>} InFlight
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param {unknown} value
|
|
140
|
+
* @returns {Record<string, any>}
|
|
141
|
+
*/
|
|
142
|
+
const recordOf = value =>
|
|
143
|
+
value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Record one confirmed plan entry as in flight. An item that still has an
|
|
147
|
+
* unsettled entry is refused, never overwritten: that entry may hold links
|
|
148
|
+
* already removed whose read-back failed, and it is their only recovery
|
|
149
|
+
* record. Verify it first (`stale-links-pending` lists it as unverified).
|
|
150
|
+
* @param {InFlight | undefined} inflight
|
|
151
|
+
* @param {{ ref: string }} plan - The confirmed plan entry
|
|
152
|
+
* @param {string} now - ISO time
|
|
153
|
+
* @returns {InFlight}
|
|
154
|
+
*/
|
|
155
|
+
export function recordInFlight(inflight, plan, now) {
|
|
156
|
+
const current = recordOf(inflight);
|
|
157
|
+
if (Object.hasOwn(current, plan.ref)) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
`${plan.ref} still has an earlier stale-link plan whose read-back has not succeeded; verify that one first (stale-links-pending lists it under unverified), then plan again.`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return { ...current, [plan.ref]: { plan, since: now, attempts: 0 } };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Settle an item's in-flight entry after a verify read it back.
|
|
167
|
+
* @param {InFlight | undefined} inflight
|
|
168
|
+
* @param {string} ref
|
|
169
|
+
* @returns {InFlight}
|
|
170
|
+
*/
|
|
171
|
+
export function settleInFlight(inflight, ref) {
|
|
172
|
+
const { [ref]: _settled, ...rest } = recordOf(inflight);
|
|
173
|
+
return rest;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Count one more failed verify for an item's in-flight entry.
|
|
178
|
+
* @param {InFlight | undefined} inflight
|
|
179
|
+
* @param {string} ref
|
|
180
|
+
* @returns {InFlight}
|
|
181
|
+
*/
|
|
182
|
+
export function failedInFlight(inflight, ref) {
|
|
183
|
+
const current = recordOf(inflight);
|
|
184
|
+
if (!Object.hasOwn(current, ref)) return current;
|
|
185
|
+
return {
|
|
186
|
+
...current,
|
|
187
|
+
[ref]: {
|
|
188
|
+
...current[ref],
|
|
189
|
+
attempts: Number(current[ref].attempts ?? 0) + 1,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Links owed back to an item, by ref: removed links whose blocker reopened
|
|
196
|
+
* before the delete. Each stays owed until a read-back shows it present
|
|
197
|
+
* again, and the queue holds its item from dispatch meanwhile, because the
|
|
198
|
+
* item would otherwise look unblocked while its blocker is open.
|
|
199
|
+
* Only the links are kept: the actions that put them back are computed from
|
|
200
|
+
* a fresh read each time (`restoreActions`), so a re-added `Blocked by` line
|
|
201
|
+
* never overwrites a body edited since.
|
|
202
|
+
* @typedef {Record<string, { links: { blockerRef: string, source: string, actionId: string, linkType?: string }[], since: string, attempts: number }>} OwedRestores
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Record the restores one verify result owes (merging with any already owed
|
|
207
|
+
* for the item).
|
|
208
|
+
* @param {OwedRestores | undefined} owed
|
|
209
|
+
* @param {{ ref: string, restored: readonly { blockerRef: string }[] }} result
|
|
210
|
+
* @param {readonly { blockerRef: string, source: string, actionId: string, linkType?: string }[]} links - The plan's links
|
|
211
|
+
* @param {string} now - ISO time
|
|
212
|
+
* @returns {OwedRestores}
|
|
213
|
+
*/
|
|
214
|
+
export function recordRestores(owed, result, links, now) {
|
|
215
|
+
const current = recordOf(owed);
|
|
216
|
+
if ((result.restored ?? []).length === 0) return current;
|
|
217
|
+
const back = new Set(result.restored.map(one => one.blockerRef));
|
|
218
|
+
const previous = current[result.ref];
|
|
219
|
+
const merged = [
|
|
220
|
+
...(previous?.links ?? []).filter(link => !back.has(link.blockerRef)),
|
|
221
|
+
...links.filter(link => back.has(link.blockerRef)),
|
|
222
|
+
];
|
|
223
|
+
return {
|
|
224
|
+
...current,
|
|
225
|
+
[result.ref]: {
|
|
226
|
+
links: merged,
|
|
227
|
+
since: previous?.since ?? now,
|
|
228
|
+
attempts: Number(previous?.attempts ?? 0),
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Settle the owed restores a read-back shows done: each owed link whose
|
|
235
|
+
* blocker is linked again is dropped; the item's entry goes once none is
|
|
236
|
+
* left, and otherwise counts one more failed try.
|
|
237
|
+
* @param {OwedRestores | undefined} owed
|
|
238
|
+
* @param {string} ref
|
|
239
|
+
* @param {ReadonlySet<string>} present - Blocker refs linked on the item now
|
|
240
|
+
* @returns {OwedRestores}
|
|
241
|
+
*/
|
|
242
|
+
export function settleRestores(owed, ref, present) {
|
|
243
|
+
const current = recordOf(owed);
|
|
244
|
+
const entry = current[ref];
|
|
245
|
+
if (!entry) return current;
|
|
246
|
+
const { [ref]: _entry, ...rest } = current;
|
|
247
|
+
const left = entry.links.filter(link => !present.has(link.blockerRef));
|
|
248
|
+
if (left.length === 0) return rest;
|
|
249
|
+
return {
|
|
250
|
+
...rest,
|
|
251
|
+
[ref]: {
|
|
252
|
+
...entry,
|
|
253
|
+
links: left,
|
|
254
|
+
attempts: Number(entry.attempts ?? 0) + 1,
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Put back a link whose blocker reopened between the confirm and the delete
|
|
4
|
+
* (CodySwannGT/lisa#5065).
|
|
5
|
+
*
|
|
6
|
+
* No tracker offers a conditional delete ("remove this link only while its
|
|
7
|
+
* blocker is still finished"), so the confirm re-read leaves a window of
|
|
8
|
+
* seconds in which a person can reopen the blocker. After the delete, the
|
|
9
|
+
* writer reads each removed blocker again. A blocker that is no longer safe
|
|
10
|
+
* to delete (reopened, moved back to an intermediate done rung, or unreadable)
|
|
11
|
+
* gets its link recreated, no marker, and a line in the report; only the
|
|
12
|
+
* removals whose blocker is still finished are confirmed.
|
|
13
|
+
*
|
|
14
|
+
* Pure: it judges and returns the vendor actions, and the writer performs
|
|
15
|
+
* them through the access layers.
|
|
16
|
+
* @module stale-blocker-restore
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
blockerResolution,
|
|
21
|
+
githubBlockerEdges,
|
|
22
|
+
isRemovable,
|
|
23
|
+
jiraBlockerEdges,
|
|
24
|
+
linearBlockerEdges,
|
|
25
|
+
} from "./stale-blocker-edges.mjs";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {unknown} value
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
const text = value => (typeof value === "string" ? value : "");
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The verdict for one removed blocker as read NOW. A blocker with no read is
|
|
35
|
+
* inaccessible, which is never safe to delete.
|
|
36
|
+
* @param {string} tracker
|
|
37
|
+
* @param {{ ref: string, project: string, repo: string }} item
|
|
38
|
+
* @param {string} ref - The blocker
|
|
39
|
+
* @param {Record<string, any> | null | undefined} raw - The blocker as read now
|
|
40
|
+
* @param {{ doneRoles: readonly string[], landedRoles?: readonly string[] }} roles
|
|
41
|
+
* @returns {string} Verdict
|
|
42
|
+
*/
|
|
43
|
+
export function verdictNow(tracker, item, ref, raw, roles) {
|
|
44
|
+
const [edge] =
|
|
45
|
+
tracker === "github"
|
|
46
|
+
? githubBlockerEdges({
|
|
47
|
+
repo: item.repo,
|
|
48
|
+
body: `Blocked by ${ref}`,
|
|
49
|
+
bodyBlockers: raw ? { [ref]: raw } : {},
|
|
50
|
+
})
|
|
51
|
+
: tracker === "jira"
|
|
52
|
+
? jiraBlockerEdges({
|
|
53
|
+
fields: {
|
|
54
|
+
issuelinks: [
|
|
55
|
+
{
|
|
56
|
+
id: "now",
|
|
57
|
+
type: { inward: "is blocked by" },
|
|
58
|
+
inwardIssue: raw ?? { key: ref },
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
: linearBlockerEdges({
|
|
64
|
+
inverseRelations: [
|
|
65
|
+
{ id: "now", type: "blocks", issue: raw ?? { identifier: ref } },
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
return blockerResolution(
|
|
69
|
+
edge,
|
|
70
|
+
roles.doneRoles,
|
|
71
|
+
item.project,
|
|
72
|
+
roles.landedRoles
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The `Blocked by` line that names these refs again, short where local. It
|
|
78
|
+
* goes FIRST: the top of a body is always outside any code fence, while the
|
|
79
|
+
* end may sit inside an unclosed one, where the line would be literal text
|
|
80
|
+
* and the relationship would not come back. The existing body is kept as is.
|
|
81
|
+
* @param {string} body - The body as read back
|
|
82
|
+
* @param {readonly string[]} refs - Canonical refs
|
|
83
|
+
* @param {string} repo - The item's own repo
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
86
|
+
function bodyWithRefs(body, refs, repo) {
|
|
87
|
+
const own = `${repo}#`;
|
|
88
|
+
const line = `Blocked by ${refs
|
|
89
|
+
.map(ref => (ref.startsWith(own) ? `#${ref.slice(own.length)}` : ref))
|
|
90
|
+
.join(", ")}`;
|
|
91
|
+
return body.trim() === "" ? line : `${line}\n\n${body}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The vendor actions that recreate these links.
|
|
96
|
+
* @param {string} tracker
|
|
97
|
+
* @param {{ ref: string, repo: string, body: string }} item - As read back
|
|
98
|
+
* @param {readonly { blockerRef: string, source: string, actionId: string, linkType?: string }[]} links
|
|
99
|
+
* @returns {object[]}
|
|
100
|
+
*/
|
|
101
|
+
export function restoreActions(tracker, item, links) {
|
|
102
|
+
if (tracker === "jira") {
|
|
103
|
+
return links.map(link => ({
|
|
104
|
+
op: "link",
|
|
105
|
+
from: link.blockerRef,
|
|
106
|
+
to: item.ref,
|
|
107
|
+
type: link.linkType || "Blocks",
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
if (tracker === "linear") {
|
|
111
|
+
return links.map(link => ({
|
|
112
|
+
op: "create-relation",
|
|
113
|
+
issue: link.blockerRef,
|
|
114
|
+
relatedIssue: item.ref,
|
|
115
|
+
type: "blocks",
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
const number = item.ref.split("#")[1];
|
|
119
|
+
const native = links
|
|
120
|
+
.filter(link => link.source === "github-native")
|
|
121
|
+
.map(link => ({
|
|
122
|
+
op: "add-dependency",
|
|
123
|
+
endpoint: `repos/${item.repo}/issues/${number}/dependencies/blocked_by`,
|
|
124
|
+
issueId: link.actionId,
|
|
125
|
+
}));
|
|
126
|
+
const bodyRefs = links
|
|
127
|
+
.filter(link => link.source === "github-body")
|
|
128
|
+
.map(link => link.blockerRef);
|
|
129
|
+
return bodyRefs.length === 0
|
|
130
|
+
? native
|
|
131
|
+
: [
|
|
132
|
+
...native,
|
|
133
|
+
{ op: "body", body: bodyWithRefs(item.body, bodyRefs, item.repo) },
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Split the removals the read-back shows gone into those whose blocker is
|
|
139
|
+
* still finished (confirmed) and those to put back.
|
|
140
|
+
* @param {{
|
|
141
|
+
* tracker: "github" | "jira" | "linear",
|
|
142
|
+
* item: { ref: string, project: string, repo: string, body: string },
|
|
143
|
+
* gone: readonly string[],
|
|
144
|
+
* links: readonly { blockerRef: string, source: string, actionId: string, linkType?: string }[],
|
|
145
|
+
* blockersNow: Record<string, Record<string, any> | null>,
|
|
146
|
+
* doneRoles: readonly string[],
|
|
147
|
+
* landedRoles?: readonly string[],
|
|
148
|
+
* }} input - `blockersNow` holds each removed blocker as read after the delete
|
|
149
|
+
* @returns {{ confirmed: string[], restored: { blockerRef: string, verdict: string }[], restore: object[] }}
|
|
150
|
+
*/
|
|
151
|
+
export function splitReopened(input) {
|
|
152
|
+
const verdicts = new Map(
|
|
153
|
+
input.gone.map(ref => [
|
|
154
|
+
ref,
|
|
155
|
+
verdictNow(
|
|
156
|
+
input.tracker,
|
|
157
|
+
input.item,
|
|
158
|
+
ref,
|
|
159
|
+
input.blockersNow?.[ref] ?? null,
|
|
160
|
+
input
|
|
161
|
+
),
|
|
162
|
+
])
|
|
163
|
+
);
|
|
164
|
+
const reopened = input.gone.filter(
|
|
165
|
+
ref => !isRemovable(text(verdicts.get(ref)))
|
|
166
|
+
);
|
|
167
|
+
const back = new Set(reopened);
|
|
168
|
+
return {
|
|
169
|
+
confirmed: input.gone.filter(ref => !back.has(ref)),
|
|
170
|
+
restored: reopened.map(ref => ({
|
|
171
|
+
blockerRef: ref,
|
|
172
|
+
verdict: text(verdicts.get(ref)),
|
|
173
|
+
})),
|
|
174
|
+
restore: restoreActions(
|
|
175
|
+
input.tracker,
|
|
176
|
+
input.item,
|
|
177
|
+
input.links.filter(link => back.has(link.blockerRef))
|
|
178
|
+
),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Counts and the one-line cycle summary for the stale-link sweep
|
|
4
|
+
* (CodySwannGT/lisa#5065), split from `stale-blocker-sweep.mjs` to keep each
|
|
5
|
+
* file within its line budget. The summary is what the session manager's
|
|
6
|
+
* cycle status line says: how many stale links it cleared and how many real
|
|
7
|
+
* blockers remain, in words an operator can act on.
|
|
8
|
+
* @module stale-blocker-summary
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* What one sweep found.
|
|
13
|
+
* @typedef {object} StaleLinkReport
|
|
14
|
+
* @property {number} scanned - Items read
|
|
15
|
+
* @property {number} skippedBlockedRole - Items left to the Blocked sweep
|
|
16
|
+
* @property {string[]} unknownStatus - Items left alone because their own status was not read
|
|
17
|
+
* @property {number} cleared - Links planned for removal
|
|
18
|
+
* @property {number} itemsCleared - Items with a planned removal
|
|
19
|
+
* @property {string[]} claimable - Ready items nothing holds any more
|
|
20
|
+
* @property {string[]} deferred - Items left for the next cycle
|
|
21
|
+
* @property {number} realBlockers - Open blockers in the same project
|
|
22
|
+
* @property {number} itemsWithRealBlockers - Items with one
|
|
23
|
+
* @property {number} crossProject - Links to another project, left alone
|
|
24
|
+
* @property {{ ref: string, blocker: string }[]} inaccessible - Blockers that could not be read
|
|
25
|
+
* @property {{ ref: string, blocker: string }[]} keptByPerson - Links a person put back
|
|
26
|
+
* @property {number} [landed] - Links kept to work merged but not yet in production (they hold nothing)
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {readonly object[]} list
|
|
31
|
+
* @returns {number}
|
|
32
|
+
*/
|
|
33
|
+
const size = list => list.length;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Pairs of item and blocker refs, for the report.
|
|
37
|
+
* @param {string} ref
|
|
38
|
+
* @param {readonly { blockerRef: string }[]} edges
|
|
39
|
+
* @returns {{ ref: string, blocker: string }[]}
|
|
40
|
+
*/
|
|
41
|
+
const pairs = (ref, edges) =>
|
|
42
|
+
edges.map(edge => ({ ref, blocker: edge.blockerRef }));
|
|
43
|
+
|
|
44
|
+
/** How an item whose own blocker list could not be read is reported. */
|
|
45
|
+
export const UNREAD_LIST = "its blocker list";
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Tally the sweep over every judged item.
|
|
49
|
+
* @param {readonly { item: { ref: string, statusKnown?: boolean, relationsRead?: boolean }, inBlocked: boolean, sorted: Record<string, object[]> }[]} judged
|
|
50
|
+
* @param {readonly { removed: string[], becomesClaimable: boolean, ref: string }[]} plans
|
|
51
|
+
* @param {readonly string[]} deferred
|
|
52
|
+
* @returns {StaleLinkReport}
|
|
53
|
+
*/
|
|
54
|
+
export function tallySweep(judged, plans, deferred) {
|
|
55
|
+
const known = judged.filter(entry => entry.item.statusKnown !== false);
|
|
56
|
+
const open = known.filter(entry => !entry.inBlocked);
|
|
57
|
+
return {
|
|
58
|
+
scanned: judged.length,
|
|
59
|
+
skippedBlockedRole: known.length - open.length,
|
|
60
|
+
unknownStatus: judged
|
|
61
|
+
.filter(entry => entry.item.statusKnown === false)
|
|
62
|
+
.map(entry => entry.item.ref),
|
|
63
|
+
cleared: plans.reduce((sum, plan) => sum + plan.removed.length, 0),
|
|
64
|
+
itemsCleared: plans.length,
|
|
65
|
+
claimable: plans
|
|
66
|
+
.filter(plan => plan.becomesClaimable)
|
|
67
|
+
.map(plan => plan.ref),
|
|
68
|
+
deferred: [...deferred],
|
|
69
|
+
realBlockers: open.reduce((sum, e) => sum + size(e.sorted.real), 0),
|
|
70
|
+
itemsWithRealBlockers: open.filter(e => size(e.sorted.real) > 0).length,
|
|
71
|
+
crossProject: open.reduce((sum, e) => sum + size(e.sorted.crossProject), 0),
|
|
72
|
+
inaccessible: [
|
|
73
|
+
...open
|
|
74
|
+
.filter(e => e.item.relationsRead === false)
|
|
75
|
+
.map(e => ({ ref: e.item.ref, blocker: UNREAD_LIST })),
|
|
76
|
+
...open.flatMap(e => pairs(e.item.ref, e.sorted.inaccessible)),
|
|
77
|
+
],
|
|
78
|
+
keptByPerson: open.flatMap(e => pairs(e.item.ref, e.sorted.keptByPerson)),
|
|
79
|
+
landed: open.reduce((sum, e) => sum + size(e.sorted.landed ?? []), 0),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {number} count
|
|
85
|
+
* @param {string} one
|
|
86
|
+
* @param {string} many
|
|
87
|
+
* @returns {string}
|
|
88
|
+
*/
|
|
89
|
+
const plural = (count, one, many) => `${count} ${count === 1 ? one : many}`;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The parts every summary line shares: what is left for the next cycle, the
|
|
93
|
+
* real blockers, and the blockers that could not be opened.
|
|
94
|
+
* @param {StaleLinkReport} report
|
|
95
|
+
* @returns {string[]}
|
|
96
|
+
*/
|
|
97
|
+
function tail(report) {
|
|
98
|
+
const parts = [];
|
|
99
|
+
if (report.deferred.length > 0) {
|
|
100
|
+
parts.push(
|
|
101
|
+
`${plural(report.deferred.length, "item", "items")} left for the next cycle`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
parts.push(
|
|
105
|
+
`${plural(report.realBlockers, "real blocker remains", "real blockers remain")} on ${plural(report.itemsWithRealBlockers, "item", "items")}`
|
|
106
|
+
);
|
|
107
|
+
if (report.inaccessible.length > 0) {
|
|
108
|
+
const list = report.inaccessible
|
|
109
|
+
.map(pair => `${pair.blocker} (on ${pair.ref})`)
|
|
110
|
+
.join(", ");
|
|
111
|
+
parts.push(`could not open ${list}`);
|
|
112
|
+
}
|
|
113
|
+
const landed = report.landed ?? 0;
|
|
114
|
+
if (landed > 0) {
|
|
115
|
+
parts.push(
|
|
116
|
+
`kept ${plural(landed, "link", "links")} to work merged but not yet in production (not holding anything)`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const unknown = report.unknownStatus ?? [];
|
|
120
|
+
if (unknown.length > 0) {
|
|
121
|
+
parts.push(
|
|
122
|
+
`left ${unknown.join(", ")} alone because ${unknown.length === 1 ? "its" : "their"} status could not be read`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return parts;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* One plain line describing the PLAN. Nothing has been written yet, so it
|
|
130
|
+
* says "planned" and "would become ready", never "cleared".
|
|
131
|
+
* @param {StaleLinkReport} report
|
|
132
|
+
* @returns {string}
|
|
133
|
+
*/
|
|
134
|
+
export function summarizeStaleLinkSweep(report) {
|
|
135
|
+
const parts = [
|
|
136
|
+
`planned removal of ${plural(report.cleared, "stale blocker link", "stale blocker links")} on ${plural(report.itemsCleared, "item", "items")}`,
|
|
137
|
+
];
|
|
138
|
+
if (report.claimable.length > 0) {
|
|
139
|
+
parts.push(`${report.claimable.length} would become ready to start`);
|
|
140
|
+
}
|
|
141
|
+
return `stale links (plan): ${[...parts, ...tail(report)].join("; ")}.`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* One plain line for the cycle summary, built from what the read-backs
|
|
146
|
+
* confirmed. Planned removals that did not happen and items deferred to the
|
|
147
|
+
* next cycle are counted separately, never as cleared.
|
|
148
|
+
* @param {StaleLinkReport} report - The plan's report
|
|
149
|
+
* @param {readonly { ref?: string, confirmed: string[], stillPresent: string[], becameReady: boolean, restored?: readonly object[], blockersBefore?: { real: number, inaccessible: string[] }, blockersAfter?: { real: number, inaccessible: string[] } }[]} results - One per item acted on
|
|
150
|
+
* @param {{ planned?: number }} [counts] - Planned removals, when they differ
|
|
151
|
+
* from the report (a plan entry confirmed down to fewer links)
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
export function summarizeVerifiedSweep(report, results, counts = {}) {
|
|
155
|
+
const cleared = results.reduce((sum, r) => sum + r.confirmed.length, 0);
|
|
156
|
+
const items = results.filter(r => r.confirmed.length > 0).length;
|
|
157
|
+
const ready = results.filter(r => r.becameReady).length;
|
|
158
|
+
const putBack = results.reduce(
|
|
159
|
+
(sum, r) => sum + (r.restored?.length ?? 0),
|
|
160
|
+
0
|
|
161
|
+
);
|
|
162
|
+
const planned = counts.planned ?? report.cleared;
|
|
163
|
+
const notDone = Math.max(0, planned - cleared - putBack);
|
|
164
|
+
const parts = [
|
|
165
|
+
`cleared ${plural(cleared, "stale blocker link", "stale blocker links")} on ${plural(items, "item", "items")}`,
|
|
166
|
+
];
|
|
167
|
+
if (ready > 0) parts.push(`${ready} now ready to start`);
|
|
168
|
+
if (putBack > 0) {
|
|
169
|
+
parts.push(
|
|
170
|
+
// Verify only records these as owed; nothing has put them back yet
|
|
171
|
+
// (`stale-links-restored` confirms that, and the item is held until
|
|
172
|
+
// then), so the line never claims a restore that may not have run.
|
|
173
|
+
`${plural(putBack, "link", "links")} awaiting restoration (blocker reopened)`
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
if (notDone > 0) {
|
|
177
|
+
parts.push(
|
|
178
|
+
`${plural(notDone, "planned removal", "planned removals")} not done (retried next cycle)`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return `stale links: ${[...parts, ...tail(refreshed(report, results))].join("; ")}.`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* The plan's report with each acted-on item's blocker totals replaced by its
|
|
186
|
+
* read-back's (`blockersBefore` -> `blockersAfter`): a blocker that finished,
|
|
187
|
+
* or reopened, since the plan is counted as it is now. Items with no newer
|
|
188
|
+
* observation keep their planning-time contribution.
|
|
189
|
+
* @param {StaleLinkReport} report
|
|
190
|
+
* @param {readonly { ref?: string, blockersBefore?: { real: number, inaccessible: string[] }, blockersAfter?: { real: number, inaccessible: string[] } }[]} results
|
|
191
|
+
* @returns {StaleLinkReport}
|
|
192
|
+
*/
|
|
193
|
+
function refreshed(report, results) {
|
|
194
|
+
const seen = results.filter(
|
|
195
|
+
r => r.ref && r.blockersBefore && r.blockersAfter
|
|
196
|
+
);
|
|
197
|
+
if (seen.length === 0) return report;
|
|
198
|
+
const acted = new Set(seen.map(r => r.ref));
|
|
199
|
+
const sum = (pick, list) => list.reduce((total, r) => total + pick(r), 0);
|
|
200
|
+
const holds = side => r => (r[side].real > 0 ? 1 : 0);
|
|
201
|
+
return {
|
|
202
|
+
...report,
|
|
203
|
+
realBlockers: Math.max(
|
|
204
|
+
0,
|
|
205
|
+
report.realBlockers -
|
|
206
|
+
sum(r => r.blockersBefore.real, seen) +
|
|
207
|
+
sum(r => r.blockersAfter.real, seen)
|
|
208
|
+
),
|
|
209
|
+
itemsWithRealBlockers: Math.max(
|
|
210
|
+
0,
|
|
211
|
+
report.itemsWithRealBlockers -
|
|
212
|
+
sum(holds("blockersBefore"), seen) +
|
|
213
|
+
sum(holds("blockersAfter"), seen)
|
|
214
|
+
),
|
|
215
|
+
inaccessible: [
|
|
216
|
+
...report.inaccessible.filter(pair => !acted.has(pair.ref)),
|
|
217
|
+
...seen.flatMap(r =>
|
|
218
|
+
r.blockersAfter.inaccessible.map(blocker => ({ ref: r.ref, blocker }))
|
|
219
|
+
),
|
|
220
|
+
],
|
|
221
|
+
};
|
|
222
|
+
}
|