@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,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
|
};
|
|
@@ -49,7 +49,7 @@ omit the plugin rules tree; do not assume a runtime-specific rules directory.
|
|
|
49
49
|
- **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.
|
|
50
50
|
- **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.
|
|
51
51
|
- **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.
|
|
52
|
-
- **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.
|
|
52
|
+
- **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.
|
|
53
53
|
|
|
54
54
|
## UI Evidence Checklist (when work is UI-visible)
|
|
55
55
|
|
|
@@ -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`
|
|
@@ -260,7 +260,7 @@ Each marker must satisfy ALL of:
|
|
|
260
260
|
|
|
261
261
|
FAIL when the Validation Journey is present but declares zero binding `[EVIDENCE: ...]` markers, when any binding marker is untyped or uses a type outside the taxonomy, or when any binding name is empty, duplicated, or not kebab-case. A behavior-changing work unit SHOULD declare both a success marker and an error/edge marker; a journey with only one binding marker passes but the remediation should recommend adding the error/edge case.
|
|
262
262
|
|
|
263
|
-
Parse claiming markers by the exact `[EVIDENCE:` prefix. A cross-work-item pointer in the canonical form `[EVIDENCE-REF: <work-item-ref> | <artifact-type>: <kebab-case-name>]` is non-claiming. The Lisa 2.223.0 form `[EVIDENCE-REF: <tracker-ref>: <artifact-type>: <kebab-case-name>]` is also accepted as a legacy non-claiming alias; parse it from the right so the final two fields are type/name and a tracker URL may contain `:`. Exclude both forms from the manifest, S14's minimum-marker count, local marker type/name validation, and duplicate-name checks. Independently validate every `EVIDENCE-REF`: the native work-item reference must be non-empty and unambiguous, the artifact type must use the fixed taxonomy, and the name must be non-empty kebab-case. A malformed reference FAILs S14 as an invalid pointer but never becomes a local evidence obligation. A valid canonical or legacy reference may point to a sibling's artifact, but it never satisfies S14 for this item. Therefore a runtime-changing leaf whose journey contains only `EVIDENCE-REF` entries FAILs S14 for zero local claiming markers, not because a valid legacy reference is malformed. Quoting or code-formatting another item's `[EVIDENCE: ...]` marker does not make it a reference; writers must convert it to the canonical pipe form. Linear returns stored Markdown with brackets escaped (`\[EVIDENCE: cli-output: name\]`, `\[EVIDENCE-REF: ...\]`): decode one Markdown escape layer outside code fences, indented code and inline code spans before matching, as `localMarkers` in `completion-proof-shape.mjs` does, so an escaped and an unescaped marker are the same declaration and a malformed one still FAILs. A marker inside an inline code span on a single line (any backtick-run length) is an example, like one in a fence: it never counts toward S14 and is never refused as malformed.
|
|
263
|
+
Parse claiming markers by the exact `[EVIDENCE:` prefix. A cross-work-item pointer in the canonical form `[EVIDENCE-REF: <work-item-ref> | <artifact-type>: <kebab-case-name>]` is non-claiming. The Lisa 2.223.0 form `[EVIDENCE-REF: <tracker-ref>: <artifact-type>: <kebab-case-name>]` is also accepted as a legacy non-claiming alias; parse it from the right so the final two fields are type/name and a tracker URL may contain `:`. Exclude both forms from the manifest, S14's minimum-marker count, local marker type/name validation, and duplicate-name checks. Independently validate every `EVIDENCE-REF`: the native work-item reference must be non-empty and unambiguous, the artifact type must use the fixed taxonomy, and the name must be non-empty kebab-case. A malformed reference FAILs S14 as an invalid pointer but never becomes a local evidence obligation. A valid canonical or legacy reference may point to a sibling's artifact, but it never satisfies S14 for this item. Therefore a runtime-changing leaf whose journey contains only `EVIDENCE-REF` entries FAILs S14 for zero local claiming markers, not because a valid legacy reference is malformed. Quoting or code-formatting another item's `[EVIDENCE: ...]` marker does not make it a reference; writers must convert it to the canonical pipe form. Linear returns stored Markdown with brackets escaped (`\[EVIDENCE: cli-output: name\]`, `\[EVIDENCE-REF: ...\]`): decode one Markdown escape layer outside code fences, indented code and inline code spans before matching, as `localMarkers` in `completion-proof-shape.mjs` does, so an escaped and an unescaped marker are the same declaration and a malformed one still FAILs. A marker inside an inline code span on a single line (any backtick-run length) is an example, like one in a fence: it never counts toward S14 and is never refused as malformed. 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.
|
|
264
264
|
|
|
265
265
|
This gate depends on S11. It is `N/A` for containers — a **Project** (the Epic equivalent), or any item with open child work (coordination containers, not work units) — and for leaf units with `runtime_behavior_change = false` (doc-only / config-only / type-only / test-only). If S11 fails because the Validation Journey is absent, S14 also FAILs (there is no manifest to bind) with remediation pointing back to `lisa-linear-add-journey`. It is likewise `N/A` with a repair note when `runtime_behavior_change` is **underivable** under S8 — reading an absent declaration as `false` is exactly the silent assumption that made this gate unauditable on a live Issue.
|
|
266
266
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lisa-session-manager
|
|
3
|
-
description: "Runs the local session manager for a project: a long-lived Claude Code session in tmux that dispatches Ready work items to fresh background worker sessions (`/lisa:implement <REF> managedBy=<manager>`), relays worker questions and operator answers over the project's own Telegram bot when one is configured (Telegram is optional; without it questions stay pending in the ledger), reconciles stalled and
|
|
3
|
+
description: "Runs the local session manager for a project: a long-lived Claude Code session in tmux that dispatches Ready work items to fresh background worker sessions (`/lisa:implement <REF> managedBy=<manager>`), relays worker questions and operator answers over the project's own Telegram bot when one is configured (Telegram is optional; without it questions stay pending in the ledger), reconciles stalled, blocked and orphaned items, re-judges human holds, and records one automation run outcome per cycle. Tracker-neutral (GitHub, Jira, Linear); lifecycle states always come from config. Requires Claude Code (background sessions, channels, cross-session messaging). Set it up with lisa-setup-session-manager."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Session manager
|
|
@@ -456,7 +456,7 @@ shows them.
|
|
|
456
456
|
not valid JSON): report its message
|
|
457
457
|
to the operator and leave the item; it never means the reply was a credential.
|
|
458
458
|
|
|
459
|
-
**In Progress (ledger-driven).** Run `classify`. Items not in the ledger are
|
|
459
|
+
**In Progress (ledger-driven).** Run `classify`. Items not in the ledger are handled by "Orphans and holds" below, never here.
|
|
460
460
|
|
|
461
461
|
| Classification | Action |
|
|
462
462
|
|---|---|
|
|
@@ -473,6 +473,69 @@ covers a plain Bash call (lisa#4522). So `blocked-on-prompt` detection is the gu
|
|
|
473
473
|
`resume` passes the same permission flags as `spawn`, so a relayed answer or nudge never drops
|
|
474
474
|
the bypass.
|
|
475
475
|
|
|
476
|
+
**Orphans and holds** (CodySwannGT/lisa#4722). Items get left in the `claimed` role (or the
|
|
477
|
+
`review` role) by an earlier manager session, a worker that died or was stopped, or a completion
|
|
478
|
+
step that never ran, and nothing else revisits them. Holds an agent may decide sit in the queue
|
|
479
|
+
just as long. Sweep both every cycle, after `classify` and before Dispatch:
|
|
480
|
+
|
|
481
|
+
1. **List** the items in the `claimed` role and, only when `resolve-lifecycle-role.mjs` resolves
|
|
482
|
+
the optional `review` role, the `review` role; plus the open items carrying the human-needed
|
|
483
|
+
label or a `[lisa-human-gate]` body marker, in any role. Page every list to completion (GitHub:
|
|
484
|
+
`gh`, with `--limit 10000`; Jira / Linear: `lisa-atlassian-access` or `lisa-linear-access`).
|
|
485
|
+
Write `{"complete":true,"items":[{ref,role,labels,body,comments,assignees,updatedAt}],"holds":[{ref,role,labels,body,comments,assignees,updatedAt}]}`
|
|
486
|
+
to `.lisa/session-manager/orphan-input.json`: refs canonical as dispatch uses them, comments
|
|
487
|
+
as `{id,author,body,createdAt}` with the author's stable id and the comment's own posting
|
|
488
|
+
time (a refusal comment with no `createdAt` never ages out of its 24-hour park), assignees as `{login,id}` objects on GitHub (the REST
|
|
489
|
+
`.assignees[].id`) and as the account or user id on Jira and Linear, and each hold's `role` as
|
|
490
|
+
the lifecycle role it is in (`ready`, `claimed`, `review`, `blocked`, `done`), so a lift never
|
|
491
|
+
moves an item that is in a lane back to the `ready` role. On Jira and Linear a hold with no
|
|
492
|
+
known role is lifted but never moved. Set `complete` to `true`
|
|
493
|
+
only when every list reached its last page; the CLI refuses anything else. Run
|
|
494
|
+
`node "$SM/session-manager.mjs" orphan-plan --input .lisa/session-manager/orphan-input.json --project-root "$ROOT"`.
|
|
495
|
+
For each ref in `lookup`, find its pull request in the item's repo dir
|
|
496
|
+
(`gh pr list --state all --search <ref>`); when several match, prefer the merged one, then an
|
|
497
|
+
open one, then a closed one. Set that item's `pr` to `null` or
|
|
498
|
+
`{"url":…,"state":"open"|"merged"|"closed"}`, and run it again. The live refs, "me", the
|
|
499
|
+
operators and the trusted authors come from the ledger and config, never from the input. It
|
|
500
|
+
skips refs the ledger shows running or asking (their holds too, so an item waiting on a
|
|
501
|
+
person's answer is never on the operator's list twice), items assigned to anyone but "me" or an
|
|
502
|
+
operator, and items updated within `--stale-hours` (default 6) or with no `updatedAt`, which
|
|
503
|
+
protects a person running `/lisa:implement` by hand. A live or foreign hold is skipped the
|
|
504
|
+
same way; a fresh or undated one is not lifted this cycle, but its human reasons still reach
|
|
505
|
+
the operator's list, so a new comment never makes the list change.
|
|
506
|
+
2. **Act** per bucket. **Before every write** in this sweep (a finish, a return, a re-dispatch
|
|
507
|
+
claim, a parked comment, a hold lift), re-read the item with `lisa-tracker-read`. Skip it for
|
|
508
|
+
this cycle, with one transcript line and no write, when its role is no longer the one the plan
|
|
509
|
+
saw, it gained an assignee who is neither "me" nor an operator, or its `updatedAt` is newer than
|
|
510
|
+
the snapshot the plan used, apart from this sweep's own earlier write on that item. The plan is
|
|
511
|
+
a snapshot; someone may have moved the item since. Every write goes through `lisa-tracker-write`
|
|
512
|
+
and is read back with `lisa-tracker-read`; every comment is the planner's, which starts with
|
|
513
|
+
`[lisa-session-manager]`.
|
|
514
|
+
- `doneReady`: the pull request merged. In the item's repo dir run
|
|
515
|
+
`node scripts/lisa-work-item.mjs finish --ref <ref> --pr-url <prUrl>`. If it refuses, post
|
|
516
|
+
one comment that starts `[lisa-session-manager] Cannot complete:` and says, in plain words,
|
|
517
|
+
why the item cannot complete yet. Later cycles see that comment and park the item, then retry
|
|
518
|
+
finishing once it is more than 24 hours old.
|
|
519
|
+
- `return`: move it to the `ready` role with the entry's `comment`.
|
|
520
|
+
- `redispatch`: an open pull request and no worker. Claim it (`reused`) and `spawn` it exactly
|
|
521
|
+
as Dispatch steps 2.3 and 2.4, ahead of new items, while `capacity` says `can_spawn`. A
|
|
522
|
+
spawn that reaches `stall.maxAttempts` follows the `exhausted` row above.
|
|
523
|
+
- `parked`: post the entry's `comment` only when `reasonOnItem` is false. An item in the
|
|
524
|
+
`review` role with an open pull request is parked, never re-dispatched: it is waiting on
|
|
525
|
+
review or merge.
|
|
526
|
+
- `holds.lift`: post each of its `comments` (each ends with its `Decision:` line; `decision` is null for a lift an earlier cycle
|
|
527
|
+
already posted, which only re-lanes the item); a partial
|
|
528
|
+
lift is also in `holds.keep` with the reasons still left for a person. Then remove
|
|
529
|
+
the human-needed label and move it to the `ready` role as its `actions` say.
|
|
530
|
+
- `holds.keep`: when `holds.digest.changed` is true, send `holds.digest.text` to the operator
|
|
531
|
+
once (Telegram when configured, else the cycle summary; nothing when the text is empty), then
|
|
532
|
+
record it with `ledger control --hold-digest <fingerprint>` (`none` when `fingerprint` is
|
|
533
|
+
null). An unchanged list is never re-sent.
|
|
534
|
+
- `deferred`: the next cycle takes them.
|
|
535
|
+
|
|
536
|
+
A failure anywhere in this sweep is one transcript line: it never holds dispatch and never makes
|
|
537
|
+
the cycle `recovery-required`.
|
|
538
|
+
|
|
476
539
|
**Blocked.** List the items in the `blocked` role (paged to completion, same access paths as the
|
|
477
540
|
queue below). For each:
|
|
478
541
|
|
|
@@ -650,7 +713,7 @@ session `start` creates), every cycle ends in **exactly one** of the six outcome
|
|
|
650
713
|
| This cycle | Run outcome |
|
|
651
714
|
|---|---|
|
|
652
715
|
| No dispatch, no state change, no question relayed or newly pending. The summary still states the denominator: "swept N ready, 0 dispatchable; R running/C cap". | `nothing-needed` |
|
|
653
|
-
| At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
|
|
716
|
+
| At least one of: a worker spawned and seen live in `status`; a Blocked→Ready release written and read back; an orphan finished, returned or re-dispatched, or a hold lifted, written and read back; an answer delivered and its marker removed (`SendMessage` acknowledged, or `resume` returned a session id), or recorded on the item and read back before its marker was removed; a stalled or `blocked-on-prompt` item retried. | `change-proved` |
|
|
654
717
|
| An item was marked human-needed ("Mark and move on": marker and question comment written and read back), in any of the four cases, including an `exhausted` item moved to the `blocked` role, or a marked item whose question comment was re-posted after `item-answer` reported `no-question-comment`; or a worker `FAILED` moved the item to the `blocked` role with its reason comment, both read back. The summary names each ref and where to answer it. | `candidate-proposed` |
|
|
655
718
|
| No item was newly marked, but a pending question was re-sent on Telegram (`requestion`) and awaits the operator, and nothing else changed. | `approval-requested` |
|
|
656
719
|
| The tracker, a configured Telegram or `claude` was unreachable; Telegram is configured but was unavailable or unpaired (a question stayed pending with no Telegram message id); a human-needed mark could not be written or read back, or no marker is configured; an answer for a finished worker, an `exhausted` item or a `decision` no worker has picked up could not be posted on the item or read back (its question stays pending); a worker `FAILED`'s move to the `blocked` role could not be written or read back; a spawn failed after the claim (the item went back to Ready); a worker classified `setup-gap` (the item went back to Ready); the capacity probe failed. | `recovery-required` |
|
|
@@ -668,7 +731,9 @@ other candidates. The planning-miss candidate a mark routes (step 6 of "Mark and
|
|
|
668
731
|
one: it runs in the background, and whatever it does — a learning PR, a drop note, a failure —
|
|
669
732
|
never moves the cycle's outcome. The same holds for the overruled-escalation sweep in Reconcile,
|
|
670
733
|
including its `[lisa-escalation-overruled]` marker comment: it is never a state change for the run
|
|
671
|
-
outcome.
|
|
734
|
+
outcome. In the "Orphans and holds" sweep, a completion, return, re-dispatch or hold lift
|
|
735
|
+
written and read back counts as `change-proved`; a failure in that sweep is one transcript line and
|
|
736
|
+
never `recovery-required`, and a parked comment or the operator's hold list is never a state change. When several rows apply, the most urgent wins: `recovery-required`, then
|
|
672
737
|
`candidate-proposed`, then `approval-requested`, then `change-proved`.
|
|
673
738
|
A missing channel is never a reason for `recovery-required`: with `notify` `none`, a cycle ends
|
|
674
739
|
`nothing-needed`, `change-proved` or `candidate-proposed` on its work alone.
|
|
@@ -9,6 +9,9 @@ the project: edit the prose to match how you run it. The loop follows the
|
|
|
9
9
|
|
|
10
10
|
Keeps Ready work moving on this machine: each Ready item gets its own fresh coding session, and the
|
|
11
11
|
operator answers that session's questions, from their phone when the project has a Telegram bot.
|
|
12
|
+
Each cycle it also sweeps items left claimed with no live worker (finishing, returning or
|
|
13
|
+
re-dispatching them) and re-judges human holds: it lifts the ones an agent may decide and sends the
|
|
14
|
+
operator one list of the rest, only when that list changes.
|
|
12
15
|
|
|
13
16
|
## Sources of truth
|
|
14
17
|
|
|
@@ -57,6 +57,21 @@ function pausedFlag(value) {
|
|
|
57
57
|
return value === "true";
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Parse `--hold-digest <fingerprint>`: the sha256 `orphan-plan` reported.
|
|
62
|
+
* @param {string} value - Flag value
|
|
63
|
+
* @returns {string} Fingerprint
|
|
64
|
+
*/
|
|
65
|
+
function holdDigestFlag(value) {
|
|
66
|
+
if (!/^[0-9a-f]{64}$/u.test(value)) {
|
|
67
|
+
throw new CliError(
|
|
68
|
+
"--hold-digest must be a sha256 fingerprint or none.",
|
|
69
|
+
2
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
|
|
60
75
|
/**
|
|
61
76
|
* Parse a flag where `none` clears the value.
|
|
62
77
|
* @param {string | undefined} value - Flag value
|
|
@@ -173,6 +188,7 @@ const LEDGER_ACTIONS = {
|
|
|
173
188
|
intFlag(value, "--max-workers")
|
|
174
189
|
),
|
|
175
190
|
me: clearable(ctx.values.me, value => value),
|
|
191
|
+
holdDigest: clearable(ctx.values["hold-digest"], holdDigestFlag),
|
|
176
192
|
}).filter(([, value]) => value !== undefined)
|
|
177
193
|
)
|
|
178
194
|
),
|