@codyswann/lisa 4.110.1 → 4.111.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/all/copy-overwrite/scripts/lib/completion-proof-conformance.mjs +24 -1
- package/all/copy-overwrite/scripts/lib/completion-proof-markdown.mjs +91 -3
- package/all/copy-overwrite/scripts/lib/completion-proof-shape.mjs +189 -19
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +4 -3
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +38 -0
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +82 -13
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- 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/human-gate-lift.mjs +148 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa/.codex-plugin/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- package/plugins/lisa/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa-agy/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa-agy/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa-agy/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- 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/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa-copilot/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa-copilot/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa-copilot/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa-cursor/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa-cursor/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/lisa-devin/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/lisa-devin/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/lisa-devin/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
- 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-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-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/skills/lisa-linear-validate-issue/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-session-manager/SKILL.md +69 -4
- package/plugins/src/base/skills/lisa-session-manager/references/runbook-template.md +3 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-cycle.mjs +16 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-orphans.mjs +162 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/cli-usage.mjs +40 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/ledger.mjs +15 -3
- package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-buckets.mjs +233 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-holds.mjs +252 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/orphan-sweep.mjs +335 -0
- package/plugins/src/base/skills/lisa-session-manager/scripts/session-manager.mjs +12 -1
- package/plugins/src/base/skills/lisa-tracker-evidence/SKILL.md +1 -1
- package/plugins/src/base/skills/lisa-tracker-evidence/references/completion-authorization.md +10 -1
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hold half of the session manager's "Orphans and holds" sweep
|
|
3
|
+
* (CodySwannGT/lisa#4722). Pure: no I/O, no clock, no config reads.
|
|
4
|
+
*
|
|
5
|
+
* Items behind a human gate (the human-needed label or a `[lisa-human-gate]`
|
|
6
|
+
* body marker) used to wait until someone noticed, even when the hold was a
|
|
7
|
+
* decision an agent is allowed to make. Each cycle the manager re-judges every
|
|
8
|
+
* hold with the shared `planHumanGateLift`, so the lift rule lives in one
|
|
9
|
+
* place: a hold it may lift is lifted with a `Decision:` line saying why; a
|
|
10
|
+
* hold only a person can act on goes into ONE consolidated operator list, the
|
|
11
|
+
* digest, sent only when its fingerprint changes.
|
|
12
|
+
* @module session-manager/orphan-holds
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
|
|
16
|
+
import { planHumanGateLift } from "../../../scripts/human-gate-lift.mjs";
|
|
17
|
+
import {
|
|
18
|
+
classifyHumanGateReason,
|
|
19
|
+
humanGateVerdict,
|
|
20
|
+
} from "../../../scripts/intake-blocker-reprobe.mjs";
|
|
21
|
+
import { findCredentialShape } from "./human-needed.mjs";
|
|
22
|
+
|
|
23
|
+
/** What the digest says for a hold carrying only the label. */
|
|
24
|
+
export const NO_STATED_REASON = "no stated reason";
|
|
25
|
+
|
|
26
|
+
/** Longest reason a digest line carries, so the list fits a phone screen. */
|
|
27
|
+
const REASON_LIMIT = 90;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A hold slug in words: `stripe-api-key` reads as `stripe api key`.
|
|
31
|
+
* @param {string} reason - Normalized hold reason
|
|
32
|
+
* @returns {string} Plain words
|
|
33
|
+
*/
|
|
34
|
+
const words = reason => reason.replaceAll(/[-_]+/gu, " ").trim();
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* One kept reason in plain language: the act a person must perform when the
|
|
38
|
+
* reason names one, the slug in words otherwise.
|
|
39
|
+
* @param {string} reason - Hold reason; empty for a label-only hold
|
|
40
|
+
* @param {unknown} humanOnly - Project-declared human-only classes
|
|
41
|
+
* @returns {string} Plain-language reason
|
|
42
|
+
*/
|
|
43
|
+
function describeKept(reason, humanOnly) {
|
|
44
|
+
if (reason === "") return NO_STATED_REASON;
|
|
45
|
+
if (findCredentialShape(reason) !== null) return "a reason that was withheld";
|
|
46
|
+
const verdict = classifyHumanGateReason(reason, { humanOnly });
|
|
47
|
+
const named = words(reason);
|
|
48
|
+
return verdict.valid && verdict.label
|
|
49
|
+
? `${named} (a person must ${verdict.label})`
|
|
50
|
+
: named;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Cap a digest reason at {@link REASON_LIMIT} characters.
|
|
55
|
+
* @param {string} text - Reason
|
|
56
|
+
* @returns {string} Bounded reason
|
|
57
|
+
*/
|
|
58
|
+
function bounded(text) {
|
|
59
|
+
return text.length > REASON_LIMIT
|
|
60
|
+
? `${text.slice(0, REASON_LIMIT - 1)}…`
|
|
61
|
+
: text;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The Decision line a lift carries: why an agent may decide the hold.
|
|
66
|
+
* @param {string[]} lifted - The reasons lifted
|
|
67
|
+
* @returns {string} One `Decision:` line
|
|
68
|
+
*/
|
|
69
|
+
function decisionLine(lifted) {
|
|
70
|
+
const named = lifted.map(reason => `"${words(reason)}"`).join(", ");
|
|
71
|
+
return (
|
|
72
|
+
`Decision: ${named} is a choice an agent may make under the project's ` +
|
|
73
|
+
"hold policy, since it names nothing only a person can do, so the hold " +
|
|
74
|
+
"is lifted and whoever builds the item makes and records that choice."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The resolved value(s) of a hold's role: one label or state, or every
|
|
80
|
+
* env-keyed `done` value. Empty when the role is missing or unconfigured.
|
|
81
|
+
* @param {{role?: unknown}} item - Hold
|
|
82
|
+
* @param {Record<string, string | string[]> | undefined} roleLabels - Role
|
|
83
|
+
* to value(s)
|
|
84
|
+
* @returns {string[]} Lane values
|
|
85
|
+
*/
|
|
86
|
+
function laneValues(item, roleLabels) {
|
|
87
|
+
const known = roleLabels ?? {};
|
|
88
|
+
const role = typeof item.role === "string" ? item.role : "";
|
|
89
|
+
const value = Object.hasOwn(known, role) ? known[role] : [];
|
|
90
|
+
return (Array.isArray(value) ? value : [value]).filter(
|
|
91
|
+
entry => typeof entry === "string" && entry !== ""
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The item's labels plus its role's resolved value(s). On Jira and Linear a
|
|
97
|
+
* role is a workflow state, not a label, so without it the lane check would
|
|
98
|
+
* see an item in the `claimed` role as in no lane and move it back to the
|
|
99
|
+
* `ready` role.
|
|
100
|
+
* @param {{role?: unknown, labels?: unknown}} item - Hold
|
|
101
|
+
* @param {Record<string, string | string[]> | undefined} roleLabels - Role
|
|
102
|
+
* to value(s)
|
|
103
|
+
* @returns {unknown[]} Labels the lane check reads
|
|
104
|
+
*/
|
|
105
|
+
function withRoleLabel(item, roleLabels) {
|
|
106
|
+
const labels = Array.isArray(item.labels) ? item.labels : [];
|
|
107
|
+
return [...labels, ...laneValues(item, roleLabels)];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* The lift's label writes, failing closed where roles are states: with no
|
|
112
|
+
* known lane for the hold, the lift lifts the hold but never re-lanes it,
|
|
113
|
+
* because "no state we recognize" is not proof the item is in no lane.
|
|
114
|
+
* @param {{role?: unknown}} item - Hold
|
|
115
|
+
* @param {object} policy - Resolved hold policy
|
|
116
|
+
* @param {{removeHumanNeededLabel: boolean, addReadyLabel: string|null}} actions - Planned writes
|
|
117
|
+
* @returns {{removeHumanNeededLabel: boolean, addReadyLabel: string|null}} Writes to apply
|
|
118
|
+
*/
|
|
119
|
+
function laneSafeActions(item, policy, actions) {
|
|
120
|
+
if (!policy.rolesAreStates) return actions;
|
|
121
|
+
if (laneValues(item, policy.roleLabels).length > 0) return actions;
|
|
122
|
+
return { ...actions, addReadyLabel: null };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* The lift planner's input for one hold.
|
|
127
|
+
* @param {{labels?: unknown, body?: unknown, comments?: unknown}} item - Hold
|
|
128
|
+
* @param {object} policy - Resolved hold policy
|
|
129
|
+
* @returns {object} planHumanGateLift input
|
|
130
|
+
*/
|
|
131
|
+
function liftInput(item, policy) {
|
|
132
|
+
return {
|
|
133
|
+
labels: withRoleLabel(item, policy.roleLabels),
|
|
134
|
+
body: item.body,
|
|
135
|
+
comments: item.comments,
|
|
136
|
+
trustedHumanActorIds: policy.trustedHumanActorIds,
|
|
137
|
+
humanNeededLabel: policy.humanNeededLabel,
|
|
138
|
+
humanOnly: policy.humanOnly,
|
|
139
|
+
readyLabel: policy.readyLabel,
|
|
140
|
+
lifecycleLabels: policy.lifecycleLabels,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether a lift still writes anything once the lane check has run.
|
|
146
|
+
* @param {string[]} comments - Lift comments
|
|
147
|
+
* @param {{removeHumanNeededLabel: boolean, addReadyLabel: string|null}} actions - Lane-safe writes
|
|
148
|
+
* @returns {boolean} True when there is a comment or a label write
|
|
149
|
+
*/
|
|
150
|
+
const writesSomething = (comments, actions) =>
|
|
151
|
+
comments.length > 0 ||
|
|
152
|
+
actions.removeHumanNeededLabel ||
|
|
153
|
+
actions.addReadyLabel !== null;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The verdict for a lift or partial lift. Classified after the lane check:
|
|
157
|
+
* where roles are states, a lift whose only write was re-laning has nothing
|
|
158
|
+
* left to do, and listing it would spend the cap every cycle.
|
|
159
|
+
* @param {{ref: string}} item - Hold
|
|
160
|
+
* @param {object} policy - Resolved hold policy
|
|
161
|
+
* @param {{lifted: string[], kept: string[], comments: string[], actions: object}} plan - Lift plan
|
|
162
|
+
* @returns {{kind: "lift"|"skip", entry: object, keep?: object}} Verdict
|
|
163
|
+
*/
|
|
164
|
+
function liftVerdict(item, policy, plan) {
|
|
165
|
+
// A re-lane-only lift (an earlier cycle posted the lift) decides nothing.
|
|
166
|
+
const decision = plan.lifted.length > 0 ? decisionLine(plan.lifted) : null;
|
|
167
|
+
const kept = plan.kept.map(reason => describeKept(reason, policy.humanOnly));
|
|
168
|
+
const keep =
|
|
169
|
+
kept.length > 0
|
|
170
|
+
? { keep: { ref: item.ref, reason: bounded(kept.join("; ")) } }
|
|
171
|
+
: {};
|
|
172
|
+
const comments = plan.comments.map(body =>
|
|
173
|
+
decision === null ? body : `${body}\n${decision}`
|
|
174
|
+
);
|
|
175
|
+
const actions = laneSafeActions(item, policy, plan.actions);
|
|
176
|
+
if (!writesSomething(comments, actions)) {
|
|
177
|
+
return {
|
|
178
|
+
...keep,
|
|
179
|
+
kind: "skip",
|
|
180
|
+
entry: { ref: item.ref, reason: "nothing-to-write" },
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
...keep,
|
|
185
|
+
kind: "lift",
|
|
186
|
+
entry: {
|
|
187
|
+
ref: item.ref,
|
|
188
|
+
reason: `the hold names only a decision an agent may make (${plan.lifted.map(words).join(", ")})`,
|
|
189
|
+
comments,
|
|
190
|
+
actions,
|
|
191
|
+
decision,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Judge one hold: lift it, keep it for a person, or skip it.
|
|
198
|
+
* @param {{ref: string, labels?: unknown, body?: unknown, comments?: unknown}} item - Hold
|
|
199
|
+
* @param {object} policy - Resolved hold policy
|
|
200
|
+
* @returns {{kind: "lift"|"keep"|"skip", entry: object,
|
|
201
|
+
* keep?: {ref: string, reason: string}}} Verdict; a partial lift also
|
|
202
|
+
* carries `keep`, the reasons still left for a person
|
|
203
|
+
*/
|
|
204
|
+
export function judgeHold(item, policy) {
|
|
205
|
+
const input = liftInput(item, policy);
|
|
206
|
+
const plan = planHumanGateLift(input);
|
|
207
|
+
if (plan.reason === "lift" || plan.reason === "partial-lift") {
|
|
208
|
+
return liftVerdict(item, policy, plan);
|
|
209
|
+
}
|
|
210
|
+
if (plan.reason === "already-lifted") {
|
|
211
|
+
return { kind: "skip", entry: { ref: item.ref, reason: "already-lifted" } };
|
|
212
|
+
}
|
|
213
|
+
const verdict = humanGateVerdict(input);
|
|
214
|
+
if (!verdict.held) {
|
|
215
|
+
return { kind: "skip", entry: { ref: item.ref, reason: "released" } };
|
|
216
|
+
}
|
|
217
|
+
const reason = bounded(
|
|
218
|
+
verdict.outstanding
|
|
219
|
+
.map(kept => describeKept(kept, policy.humanOnly))
|
|
220
|
+
.join("; ")
|
|
221
|
+
);
|
|
222
|
+
return { kind: "keep", entry: { ref: item.ref, reason } };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The one consolidated operator list of truly-human holds, and its
|
|
227
|
+
* fingerprint. The fingerprint is the sha256 of the sorted `ref\treason`
|
|
228
|
+
* lines, so the order holds arrive in never changes it.
|
|
229
|
+
* @param {{ref: string, reason: string}[]} keep - Kept holds
|
|
230
|
+
* @param {string | null | undefined} previous - Fingerprint last sent
|
|
231
|
+
* @returns {{fingerprint: string | null, text: string, changed: boolean}}
|
|
232
|
+
* Digest; an empty list has a null fingerprint and empty text
|
|
233
|
+
*/
|
|
234
|
+
export function holdDigest(keep, previous) {
|
|
235
|
+
const rows = [...keep].sort((a, b) =>
|
|
236
|
+
a.ref < b.ref ? -1 : Number(a.ref > b.ref)
|
|
237
|
+
);
|
|
238
|
+
const fingerprint =
|
|
239
|
+
rows.length === 0
|
|
240
|
+
? null
|
|
241
|
+
: createHash("sha256")
|
|
242
|
+
.update(rows.map(row => `${row.ref}\t${row.reason}`).join("\n"))
|
|
243
|
+
.digest("hex");
|
|
244
|
+
const text =
|
|
245
|
+
rows.length === 0
|
|
246
|
+
? ""
|
|
247
|
+
: [
|
|
248
|
+
`Waiting on you (${rows.length}): only a person can do these.`,
|
|
249
|
+
...rows.map(row => `${row.ref}: ${row.reason}`),
|
|
250
|
+
].join("\n");
|
|
251
|
+
return { fingerprint, text, changed: fingerprint !== (previous ?? null) };
|
|
252
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan the session manager's "Orphans and holds" sweep (CodySwannGT/lisa#4722).
|
|
3
|
+
* Pure: no I/O, no config reads; the clock arrives as `now`.
|
|
4
|
+
*
|
|
5
|
+
* Reconcile used to look only at the manager's own ledger, so items left in
|
|
6
|
+
* the `claimed` (or `review`) role by an earlier manager session, a worker
|
|
7
|
+
* that died or was stopped, or a completion step that never ran were never
|
|
8
|
+
* revisited. On a live project most claimed items had no live worker, some
|
|
9
|
+
* for days. This planner buckets each such orphan:
|
|
10
|
+
*
|
|
11
|
+
* - `doneReady`: its pull request merged; only completion is missing.
|
|
12
|
+
* - `return`: no open or merged pull request; back to the `ready` role.
|
|
13
|
+
* - `redispatch`: an open pull request and no owner; spawn a fresh attempt.
|
|
14
|
+
* - `parked`: held for a person; leave it, but make sure it says why.
|
|
15
|
+
* - `lookup`: the pull request is not known yet; the manager finds it first.
|
|
16
|
+
*
|
|
17
|
+
* It never touches an item the ledger shows live, one assigned to someone
|
|
18
|
+
* other than "me" or an operator, or one updated within `staleHours`, which
|
|
19
|
+
* protects a person running `/lisa:implement` by hand outside the manager.
|
|
20
|
+
* The hold half lives in orphan-holds.mjs. Writes per cycle are capped at
|
|
21
|
+
* `max`, shared across orphans and hold lifts, and the rest are `deferred`.
|
|
22
|
+
* @module session-manager/orphan-sweep
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
entryMatches,
|
|
26
|
+
idComparableValues,
|
|
27
|
+
parseIdEntries,
|
|
28
|
+
} from "../../../scripts/operator-id-kinds.mjs";
|
|
29
|
+
import { holdDigest, judgeHold } from "./orphan-holds.mjs";
|
|
30
|
+
import { FINISH_RETRY_HOURS, classifyOrphan } from "./orphan-buckets.mjs";
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
FINISH_REFUSED_PREFIX,
|
|
34
|
+
FINISH_RETRY_HOURS,
|
|
35
|
+
SWEEP_COMMENT_PREFIX,
|
|
36
|
+
} from "./orphan-buckets.mjs";
|
|
37
|
+
|
|
38
|
+
/** At most this many writes per cycle unless the caller says otherwise. */
|
|
39
|
+
export const DEFAULT_ORPHAN_MAX = 10;
|
|
40
|
+
|
|
41
|
+
/** An item updated more recently than this many hours is left alone. */
|
|
42
|
+
export const DEFAULT_STALE_HOURS = 6;
|
|
43
|
+
|
|
44
|
+
/** The order buckets spend the cap in. */
|
|
45
|
+
const CAPPED_BUCKETS = ["doneReady", "return", "redispatch", "parked"];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A trimmed id string, or null. Numeric ids become strings.
|
|
49
|
+
* @param {unknown} value - Raw id
|
|
50
|
+
* @returns {string | null} Comparable id
|
|
51
|
+
*/
|
|
52
|
+
function idOrNull(value) {
|
|
53
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim();
|
|
54
|
+
return Number.isSafeInteger(value) ? String(value) : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The fields one assignee is compared on, the way `queue` compares them: a
|
|
59
|
+
* plain string is the tracker's normalized id (GitHub login, Jira accountId,
|
|
60
|
+
* Linear user id); a `{login, id}` object adds the kind-keyed fields.
|
|
61
|
+
* @param {unknown} assignee - One assignee as the tracker gave it
|
|
62
|
+
* @returns {{plain: string|null, login: string|null, id: string|null}} Fields
|
|
63
|
+
*/
|
|
64
|
+
function assigneeFields(assignee) {
|
|
65
|
+
if (assignee !== null && typeof assignee === "object") {
|
|
66
|
+
const login = idOrNull(assignee.login);
|
|
67
|
+
const id = idOrNull(assignee.id ?? assignee.accountId);
|
|
68
|
+
return { plain: login ?? id, login, id };
|
|
69
|
+
}
|
|
70
|
+
return { plain: idOrNull(assignee), login: null, id: null };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether any assignee is neither "me" nor an operator.
|
|
75
|
+
* @param {unknown} assignees - The item's assignees
|
|
76
|
+
* @param {{me: string|null, operators: object[]}} who - Identities
|
|
77
|
+
* @returns {boolean} True when someone else holds the item
|
|
78
|
+
*/
|
|
79
|
+
function heldBySomeoneElse(assignees, who) {
|
|
80
|
+
return (Array.isArray(assignees) ? assignees : []).some(assignee => {
|
|
81
|
+
const fields = assigneeFields(assignee);
|
|
82
|
+
if (fields.plain === null) return false;
|
|
83
|
+
if (who.me !== null && fields.plain === who.me) return false;
|
|
84
|
+
return !who.operators.some(entry => entryMatches(entry, fields));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Resolve and check the options.
|
|
90
|
+
* @param {object} opts - Caller options
|
|
91
|
+
* @returns {object} Resolved policy
|
|
92
|
+
*/
|
|
93
|
+
function resolveOptions(opts = {}) {
|
|
94
|
+
const now = new Date(opts.now ?? Number.NaN).getTime();
|
|
95
|
+
if (!Number.isFinite(now)) throw new Error("now must be a valid time");
|
|
96
|
+
const max = opts.max ?? DEFAULT_ORPHAN_MAX;
|
|
97
|
+
if (!Number.isInteger(max) || max < 0) {
|
|
98
|
+
throw new Error("max must be a non-negative integer");
|
|
99
|
+
}
|
|
100
|
+
const staleHours = opts.staleHours ?? DEFAULT_STALE_HOURS;
|
|
101
|
+
if (typeof staleHours !== "number" || !(staleHours >= 0)) {
|
|
102
|
+
throw new Error("staleHours must be a non-negative number");
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
now,
|
|
106
|
+
max,
|
|
107
|
+
staleMs: staleHours * 3_600_000,
|
|
108
|
+
live: new Set(Array.isArray(opts.liveRefs) ? opts.liveRefs : []),
|
|
109
|
+
who: {
|
|
110
|
+
me: idOrNull(opts.me),
|
|
111
|
+
operators: parseIdEntries(opts.operatorIds),
|
|
112
|
+
},
|
|
113
|
+
trustedHumanActorIds: idComparableValues(opts.trustedAuthorIds),
|
|
114
|
+
humanNeededLabel: opts.humanNeededLabel,
|
|
115
|
+
humanOnly: opts.humanOnly,
|
|
116
|
+
readyLabel: opts.readyLabel,
|
|
117
|
+
lifecycleLabels: opts.lifecycleLabels,
|
|
118
|
+
roleLabels: opts.roleLabels ?? {},
|
|
119
|
+
rolesAreStates: opts.rolesAreStates === true,
|
|
120
|
+
finishRetryMs: FINISH_RETRY_HOURS * 3_600_000,
|
|
121
|
+
previousDigest: opts.previousDigest ?? null,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Why an orphan candidate is left alone, or null when the sweep may act.
|
|
127
|
+
* @param {object} item - Candidate with a ref
|
|
128
|
+
* @param {object} policy - Resolved policy
|
|
129
|
+
* @returns {string | null} Skip reason
|
|
130
|
+
*/
|
|
131
|
+
function skipReason(item, policy) {
|
|
132
|
+
if (policy.live.has(item.ref)) return "live";
|
|
133
|
+
if (heldBySomeoneElse(item.assignees, policy.who)) return "foreign";
|
|
134
|
+
const updated = new Date(item.updatedAt ?? Number.NaN).getTime();
|
|
135
|
+
if (!Number.isFinite(updated)) return "undated";
|
|
136
|
+
return policy.now - updated < policy.staleMs ? "fresh" : null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The canonical ref of a raw entry, or empty.
|
|
141
|
+
* @param {unknown} raw - Raw entry
|
|
142
|
+
* @returns {string} Trimmed ref
|
|
143
|
+
*/
|
|
144
|
+
const refOf = raw => (typeof raw?.ref === "string" ? raw.ref.trim() : "");
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sort orphan candidates into skips and buckets, uncapped.
|
|
148
|
+
* @param {unknown} items - Raw candidates
|
|
149
|
+
* @param {object} policy - Resolved policy
|
|
150
|
+
* @returns {{skipped: object[], buckets: Record<string, object[]>}} Sorted
|
|
151
|
+
*/
|
|
152
|
+
function sortOrphans(items, policy) {
|
|
153
|
+
const skipped = [];
|
|
154
|
+
const buckets = {
|
|
155
|
+
lookup: [],
|
|
156
|
+
doneReady: [],
|
|
157
|
+
return: [],
|
|
158
|
+
redispatch: [],
|
|
159
|
+
parked: [],
|
|
160
|
+
};
|
|
161
|
+
for (const raw of Array.isArray(items) ? items : []) {
|
|
162
|
+
const ref = refOf(raw);
|
|
163
|
+
const reason = ref === "" ? "no ref" : skipReason({ ...raw, ref }, policy);
|
|
164
|
+
if (reason !== null) {
|
|
165
|
+
skipped.push({ ref: ref === "" ? null : ref, reason });
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const { bucket, entry } = classifyOrphan({ ...raw, ref }, policy);
|
|
169
|
+
buckets[bucket].push(entry);
|
|
170
|
+
}
|
|
171
|
+
return { skipped, buckets };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Guards that only hold back a lift: the hold is still listed for a person. */
|
|
175
|
+
const LIFT_ONLY_GUARDS = new Set(["fresh", "undated"]);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Judge every hold, once per ref.
|
|
179
|
+
*
|
|
180
|
+
* A live or foreign hold is skipped outright: not ours to judge. A fresh or
|
|
181
|
+
* undated one is still judged, but only its kept reasons are used; its lift
|
|
182
|
+
* waits. Otherwise any comment, the sweep's own partial-lift comment
|
|
183
|
+
* included, would bump `updatedAt`, drop the hold from the operator's list
|
|
184
|
+
* for `staleHours`, and churn the digest.
|
|
185
|
+
* @param {unknown} holds - Raw hold candidates
|
|
186
|
+
* @param {object} policy - Resolved policy
|
|
187
|
+
* @returns {{lift: object[], keep: object[], skipped: object[]}} Judged
|
|
188
|
+
*/
|
|
189
|
+
function sortHolds(holds, policy) {
|
|
190
|
+
const judged = { lift: [], keep: [], skipped: [] };
|
|
191
|
+
const seen = new Set();
|
|
192
|
+
for (const raw of Array.isArray(holds) ? holds : []) {
|
|
193
|
+
const ref = refOf(raw);
|
|
194
|
+
if (ref === "" || seen.has(ref)) continue;
|
|
195
|
+
seen.add(ref);
|
|
196
|
+
const guard = skipReason({ ...raw, ref }, policy);
|
|
197
|
+
if (guard !== null && !LIFT_ONLY_GUARDS.has(guard)) {
|
|
198
|
+
judged.skipped.push({ ref, reason: guard });
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const { kind, entry, keep } = judgeHold({ ...raw, ref }, policy);
|
|
202
|
+
if (kind === "lift" && guard !== null) {
|
|
203
|
+
judged.skipped.push({ ref, reason: guard });
|
|
204
|
+
} else {
|
|
205
|
+
judged[kind === "skip" ? "skipped" : kind].push(entry);
|
|
206
|
+
}
|
|
207
|
+
if (keep) judged.keep.push(keep);
|
|
208
|
+
}
|
|
209
|
+
return judged;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Whether an entry spends the cap: a parked item already explaining its hold
|
|
214
|
+
* needs no write, so it never does.
|
|
215
|
+
* @param {string} bucket - Bucket name
|
|
216
|
+
* @param {object} entry - Bucket entry
|
|
217
|
+
* @returns {boolean} True when it costs a write
|
|
218
|
+
*/
|
|
219
|
+
const costs = (bucket, entry) =>
|
|
220
|
+
bucket !== "parked" || entry.reasonOnItem === false;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Spend the cap across buckets in order, deferring the overflow.
|
|
224
|
+
* @param {[string, object[]][]} queue - Buckets in spending order
|
|
225
|
+
* @param {number} max - Cap
|
|
226
|
+
* @returns {{kept: Record<string, object[]>, deferred: object[]}} Capped
|
|
227
|
+
*/
|
|
228
|
+
function spendCap(queue, max) {
|
|
229
|
+
let spent = 0;
|
|
230
|
+
const kept = {};
|
|
231
|
+
const deferred = [];
|
|
232
|
+
for (const [bucket, entries] of queue) {
|
|
233
|
+
kept[bucket] = [];
|
|
234
|
+
for (const entry of entries) {
|
|
235
|
+
if (costs(bucket, entry) && spent >= max) {
|
|
236
|
+
deferred.push({ ref: entry.ref, bucket });
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (costs(bucket, entry)) spent += 1;
|
|
240
|
+
kept[bucket].push(entry);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return { kept, deferred };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* One orphan the sweep acts on, or asks a PR lookup for.
|
|
248
|
+
* @typedef {object} OrphanEntry
|
|
249
|
+
* @property {string} ref - Canonical item ref
|
|
250
|
+
* @property {string} reason - Plain-English reason for the bucket
|
|
251
|
+
* @property {string} [prUrl] - The pull request (`doneReady`, `redispatch`)
|
|
252
|
+
* @property {string} [comment] - The comment to post (`return`, and `parked`
|
|
253
|
+
* when `reasonOnItem` is false); starts with `[lisa-session-manager]`
|
|
254
|
+
* @property {boolean} [reasonOnItem] - `parked` only: the item already says
|
|
255
|
+
* why it is held
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* One hold the sweep lifts.
|
|
260
|
+
* @typedef {object} HoldLift
|
|
261
|
+
* @property {string} ref - Canonical item ref
|
|
262
|
+
* @property {string} reason - Plain-English reason
|
|
263
|
+
* @property {string[]} comments - Lift comments, each ending with `decision`
|
|
264
|
+
* when there is one
|
|
265
|
+
* @property {{removeHumanNeededLabel: boolean, addReadyLabel: string|null}}
|
|
266
|
+
* actions - Label writes after the comments
|
|
267
|
+
* @property {string|null} decision - The `Decision:` line; null for a lift
|
|
268
|
+
* that only re-lanes an item an earlier cycle already lifted
|
|
269
|
+
*/
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The plan `planOrphanSweep` returns; it writes nothing.
|
|
273
|
+
* @typedef {object} OrphanSweepPlan
|
|
274
|
+
* @property {OrphanEntry[]} doneReady - Merged PR; finish completion
|
|
275
|
+
* @property {OrphanEntry[]} return - Back to the `ready` role
|
|
276
|
+
* @property {OrphanEntry[]} redispatch - Open PR; spawn a fresh attempt
|
|
277
|
+
* @property {OrphanEntry[]} parked - Held for a person; leave it
|
|
278
|
+
* @property {OrphanEntry[]} lookup - Find the PR, then plan again
|
|
279
|
+
* @property {{ref: string|null, reason: string}[]} skipped - Left alone
|
|
280
|
+
* @property {{lift: HoldLift[], keep: {ref: string, reason: string}[],
|
|
281
|
+
* digest: {fingerprint: string|null, text: string, changed: boolean}}}
|
|
282
|
+
* holds - Lifts, truly-human holds and the operator's list
|
|
283
|
+
* @property {{ref: string, bucket: string}[]} deferred - Over the cap
|
|
284
|
+
*/
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Plan this cycle's orphan and hold sweep.
|
|
288
|
+
* @param {{items?: unknown, holds?: unknown}} input - Items in the `claimed`
|
|
289
|
+
* (and configured `review`) role as `{ref, role, labels, body, comments,
|
|
290
|
+
* assignees, updatedAt, pr}` (`pr` undefined when not looked up, null when
|
|
291
|
+
* none was found, else `{url, state}`), and held items as
|
|
292
|
+
* `{ref, role?, labels, body, comments, assignees, updatedAt}`
|
|
293
|
+
* @param {{liveRefs?: string[], me?: string|null, operatorIds?: unknown,
|
|
294
|
+
* now: string|number|Date, staleHours?: number, max?: number,
|
|
295
|
+
* trustedAuthorIds?: unknown, humanNeededLabel?: string, humanOnly?: unknown,
|
|
296
|
+
* readyLabel?: string, lifecycleLabels?: string[],
|
|
297
|
+
* roleLabels?: Record<string, string | string[]>,
|
|
298
|
+
* rolesAreStates?: boolean,
|
|
299
|
+
* previousDigest?: string|null}} opts - Ledger-derived live refs,
|
|
300
|
+
* identities, the clock, the cap and the hold policy
|
|
301
|
+
* @returns {OrphanSweepPlan} Plan; it writes nothing
|
|
302
|
+
*/
|
|
303
|
+
export function planOrphanSweep(input = {}, opts = {}) {
|
|
304
|
+
const policy = resolveOptions(opts);
|
|
305
|
+
const orphans = sortOrphans(input.items, policy);
|
|
306
|
+
const holds = sortHolds(input.holds, policy);
|
|
307
|
+
const lookup = orphans.buckets.lookup;
|
|
308
|
+
const capped = spendCap(
|
|
309
|
+
[
|
|
310
|
+
...CAPPED_BUCKETS.map(bucket => [bucket, orphans.buckets[bucket]]),
|
|
311
|
+
["lift", holds.lift],
|
|
312
|
+
],
|
|
313
|
+
policy.max
|
|
314
|
+
);
|
|
315
|
+
return {
|
|
316
|
+
doneReady: capped.kept.doneReady,
|
|
317
|
+
return: capped.kept.return,
|
|
318
|
+
redispatch: capped.kept.redispatch,
|
|
319
|
+
parked: capped.kept.parked,
|
|
320
|
+
lookup: lookup.slice(0, policy.max),
|
|
321
|
+
skipped: [...orphans.skipped, ...holds.skipped],
|
|
322
|
+
holds: {
|
|
323
|
+
lift: capped.kept.lift,
|
|
324
|
+
keep: holds.keep,
|
|
325
|
+
digest: holdDigest(holds.keep, policy.previousDigest),
|
|
326
|
+
},
|
|
327
|
+
deferred: [
|
|
328
|
+
...capped.deferred,
|
|
329
|
+
...lookup.slice(policy.max).map(entry => ({
|
|
330
|
+
ref: entry.ref,
|
|
331
|
+
bucket: "lookup",
|
|
332
|
+
})),
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
}
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
} from "./cli-cycle.mjs";
|
|
49
49
|
import { answer, itemAnswer, markPlan } from "./cli-human.mjs";
|
|
50
50
|
import { cycle } from "./cyclers.mjs";
|
|
51
|
+
import { orphanPlan } from "./cli-orphans.mjs";
|
|
51
52
|
import { overruledPlan } from "./cli-overruled.mjs";
|
|
52
53
|
import { repoDir, start, status, stop, validate } from "./cli-manager.mjs";
|
|
53
54
|
import { queue } from "./cli-queue.mjs";
|
|
@@ -129,6 +130,11 @@ const COMMANDS = {
|
|
|
129
130
|
options: { input: text, max: text },
|
|
130
131
|
positionals: 0,
|
|
131
132
|
},
|
|
133
|
+
"orphan-plan": {
|
|
134
|
+
run: orphanPlan,
|
|
135
|
+
options: { input: text, max: text, "stale-hours": text },
|
|
136
|
+
positionals: 0,
|
|
137
|
+
},
|
|
132
138
|
answer: { run: answer, options: {}, positionals: 1 },
|
|
133
139
|
"item-answer": { run: itemAnswer, options: {}, positionals: 1 },
|
|
134
140
|
"channel-answer": { run: channelAnswer, options: {}, positionals: 1 },
|
|
@@ -171,7 +177,12 @@ const LEDGER_SPECS = {
|
|
|
171
177
|
"validation-cleared": { options: {}, positionals: 1 },
|
|
172
178
|
"clear-setup-gap": { options: {}, positionals: 1 },
|
|
173
179
|
control: {
|
|
174
|
-
options: {
|
|
180
|
+
options: {
|
|
181
|
+
paused: text,
|
|
182
|
+
"max-workers": text,
|
|
183
|
+
me: text,
|
|
184
|
+
"hold-digest": text,
|
|
185
|
+
},
|
|
175
186
|
positionals: 0,
|
|
176
187
|
},
|
|
177
188
|
};
|
|
@@ -47,7 +47,7 @@ omit the plugin rules tree; do not assume a runtime-specific rules directory.
|
|
|
47
47
|
- **The "Not established" section is required.** Before posting, confirm `evidence/comment.md` (and `comment.txt` where the vendor uses it) contains a `## Not established` heading and that the verdict carries `not_established_reviewed: true`. The heading is **never omitted and never blank**: with nothing outstanding it still renders `None outstanding — reviewed`; otherwise it lists, in plain operator language, each thing the verification did not prove — boundaries not exercised, environments not tested, behavior consciously out of scope. A comment with no such heading, a heading with nothing under it, or a verdict whose `not_established_reviewed` flag is absent is **refused**: stop and report the missing Not-established review instead of posting. (The list may be empty; the flag may never be omitted.) Definition and exemplars live in the `claim-evidence-mapping` rule; this generalizes `lisa-improve-harness`'s required, never-empty `Known limits` field.
|
|
48
48
|
- **Artifact identity is required, with values (S14 extension).** Before posting, confirm the comment body carries a `## Artifact identity` heading populated with **values, not placeholders**: the `repository`, the `head_sha` the verification observed, the `environment`, and for each committed or uploaded artifact its `sha256` digest and `captured_at`. Then check both identity failures. **`artifact_mismatch`** — an evidence entry whose recorded `artifact_head_sha` differs from the verdict's `artifact.head_sha`: refuse the post and report the offending evidence id together with **both SHAs** (the one the artifact was captured at and the one the verdict claims), e.g. `EV-2 captured at 4f1c9ab but artifact.head_sha is 9de0c31`. **`evidence_digest_mismatch`** — recompute the `sha256` of each committed evidence file on read, or of the fetched bytes when its locator is an uploaded URL; if the bytes no longer match the recorded digest (or the file is absent), stop and report the evidence id by name. Never summarize either as "verification failed" — name the field, the ids, and both SHAs so a non-engineer can read it at the gate. **Advisory-first:** until `verification.gate.enforceBoundaries` is `true` in `.lisa.config.json`, an identity failure is reported to the operator but does not block the post; once ratcheted on it refuses the post exactly like a missing artifact. Definition: the `claim-evidence-mapping` rule.
|
|
49
49
|
- **Merge-race reconciliation (at completion, not at post).** The evidence's pinned `head_sha` is reconciled against the merged head using the ancestry + deploy-run definition of "what shipped" that `lisa-drive-pr-to-merge` already owns — cite that skill, never re-implement or restate its checks here. Pre-merge evidence counts for the merge commit only when its head is a parent of the merge, ancestry alone never justifies reporting shipped, and on a mismatch verification re-runs against the merged head before completion is declared.
|
|
50
|
-
- **Evidence references are not manifest entries.** Extract obligations using the exact `[EVIDENCE:` prefix (and the legacy local `[SCREENSHOT:` form). Exclude both the canonical `[EVIDENCE-REF: <work-item-ref> | <artifact-type>: <kebab-case-name>]` and the Lisa 2.223.0 legacy alias `[EVIDENCE-REF: <tracker-ref>: <artifact-type>: <kebab-case-name>]` from artifact lookup, missing-artifact reporting, and duplicate-name checks: either belongs to another work item and cannot satisfy this item's S14 gate. A runtime-changing leaf with references but no local claiming marker must be rejected before dispatch. Linear returns stored Markdown with brackets escaped (`\[EVIDENCE: cli-output: name\]`): decode one Markdown escape layer outside code before matching, as `localMarkers` in `completion-proof-shape.mjs` does, so escaped and unescaped markers bind the same manifest. A marker inside an inline code span on a single line (any backtick-run length), like one in fenced or indented code, is an example: it is neither a manifest entry nor a malformed declaration.
|
|
50
|
+
- **Evidence references are not manifest entries.** Extract obligations using the exact `[EVIDENCE:` prefix (and the legacy local `[SCREENSHOT:` form). Exclude both the canonical `[EVIDENCE-REF: <work-item-ref> | <artifact-type>: <kebab-case-name>]` and the Lisa 2.223.0 legacy alias `[EVIDENCE-REF: <tracker-ref>: <artifact-type>: <kebab-case-name>]` from artifact lookup, missing-artifact reporting, and duplicate-name checks: either belongs to another work item and cannot satisfy this item's S14 gate. A runtime-changing leaf with references but no local claiming marker must be rejected before dispatch. Linear returns stored Markdown with brackets escaped (`\[EVIDENCE: cli-output: name\]`): decode one Markdown escape layer outside code before matching, as `localMarkers` in `completion-proof-shape.mjs` does, so escaped and unescaped markers bind the same manifest. A marker inside an inline code span on a single line (any backtick-run length), like one in fenced or indented code, is an example: it is neither a manifest entry nor a malformed declaration. Indented code means four or more columns past the content column of the list item that holds the line (or past the margin outside a list), after a blank line or heading: a marker on a list item's continuation line, at any indentation that still continues the item's paragraph, is claiming.
|
|
51
51
|
|
|
52
52
|
## UI Evidence Checklist (when work is UI-visible)
|
|
53
53
|
|
package/plugins/lisa-cursor/skills/lisa-tracker-evidence/references/completion-authorization.md
CHANGED
|
@@ -125,7 +125,16 @@ complete slurped output of a paginated listing. The immutable proof record
|
|
|
125
125
|
remains limited to 2 MiB. Page and row limits are additional bounds: a listing
|
|
126
126
|
with at most 100 pages or 10,000 comments can still exceed its byte ceiling and
|
|
127
127
|
must fail closed without a lifecycle write. Visible local evidence markers
|
|
128
|
-
claim attachments; fenced or indented examples and HTML comments do not.
|
|
128
|
+
claim attachments; fenced or indented examples and HTML comments do not. A
|
|
129
|
+
marker on a list item's continuation line is visible: indentation is measured
|
|
130
|
+
from the content column of the list item that holds it, so only a line four or
|
|
131
|
+
more columns past that, outside a paragraph, is an indented example. The
|
|
132
|
+
conformance check reads `## Acceptance Criteria` in any case, with any internal
|
|
133
|
+
spacing and optional closing `#`s. When no such heading exists but a visible
|
|
134
|
+
line names the criteria some other way (`### Acceptance Criteria`, a bold
|
|
135
|
+
`**Acceptance Criteria**`, `## Acceptance Criteria:`, or the name underlined
|
|
136
|
+
with `---` or `===`), the check refuses and
|
|
137
|
+
asks for the heading to be renamed rather than reading zero scenarios.
|
|
129
138
|
|
|
130
139
|
An ordinary pending result from `finish` or the applying sweep exits zero
|
|
131
140
|
because it preserves the nonterminal state. A refused `publish-completion-proof`
|