looply-cli 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.src-hash +1 -1
- package/dist/checkout-carry.d.ts +2 -0
- package/dist/checkout-carry.d.ts.map +1 -1
- package/dist/checkout-carry.js +25 -2
- package/dist/checkout-carry.js.map +1 -1
- package/dist/goal-adaptive.d.ts +12 -0
- package/dist/goal-adaptive.d.ts.map +1 -1
- package/dist/goal-adaptive.js +19 -4
- package/dist/goal-adaptive.js.map +1 -1
- package/dist/goal-compile.d.ts +7 -0
- package/dist/goal-compile.d.ts.map +1 -1
- package/dist/goal-compile.js +3 -0
- package/dist/goal-compile.js.map +1 -1
- package/dist/goal-execution-evidence.d.ts +28 -2
- package/dist/goal-execution-evidence.d.ts.map +1 -1
- package/dist/goal-execution-evidence.js +30 -5
- package/dist/goal-execution-evidence.js.map +1 -1
- package/dist/goal-reproof.d.ts +42 -0
- package/dist/goal-reproof.d.ts.map +1 -0
- package/dist/goal-reproof.js +35 -0
- package/dist/goal-reproof.js.map +1 -0
- package/dist/plan-recovery.d.ts +70 -0
- package/dist/plan-recovery.d.ts.map +1 -0
- package/dist/plan-recovery.js +131 -0
- package/dist/plan-recovery.js.map +1 -0
- package/dist/run-cmd.d.ts.map +1 -1
- package/dist/run-cmd.js +64 -9
- package/dist/run-cmd.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STATEMENT_CONTEXT = exports.DIRECT_STEP_PREFIX = void 0;
|
|
4
|
+
exports.refusalContext = refusalContext;
|
|
5
|
+
exports.directFixStep = directFixStep;
|
|
6
|
+
exports.directFixOutcome = directFixOutcome;
|
|
7
|
+
exports.withoutRefuted = withoutRefuted;
|
|
8
|
+
exports.compileWithRecovery = compileWithRecovery;
|
|
9
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
|
+
const goal_compile_1 = require("./goal-compile");
|
|
11
|
+
/** The longest direct-step title: the verify pass and the phone both show it. */
|
|
12
|
+
const DIRECT_TITLE_MAX = 240;
|
|
13
|
+
exports.DIRECT_STEP_PREFIX = 'Do what this ticket asks, as written';
|
|
14
|
+
/** The context for a re-plan after refusals: each refused step, and why. */
|
|
15
|
+
function refusalContext(refused) {
|
|
16
|
+
const lines = refused.map((r) => `- ${JSON.stringify(r.step.title)}: ${r.verdict.ok ? 'admitted' : r.verdict.because}`);
|
|
17
|
+
return [
|
|
18
|
+
'These steps cited code that is not there at the current tree:',
|
|
19
|
+
...lines,
|
|
20
|
+
'The repository has moved since you looked, or the citation was wrong. Open those files again at the',
|
|
21
|
+
'current tree and plan against what is there now. Cite a line only after reading it.',
|
|
22
|
+
].join('\n');
|
|
23
|
+
}
|
|
24
|
+
/** The context for a re-plan after an empty plan: read the ticket as an instruction. */
|
|
25
|
+
exports.STATEMENT_CONTEXT = [
|
|
26
|
+
'It came back with no steps. This goal is a ticket a person wrote, and people often word a',
|
|
27
|
+
'ticket as a remark, a complaint or a question ("X is only done manually", "Y is not tracking",',
|
|
28
|
+
'"shouldn\'t Z happen automatically?"). Read it as an instruction: make the code behave the way',
|
|
29
|
+
'the ticket implies it should. Return no steps only if the repository already does that, and',
|
|
30
|
+
'then cite the code that shows it.',
|
|
31
|
+
].join('\n');
|
|
32
|
+
/** The person's own first line, which is the ticket's title when AutoRyn sent it. */
|
|
33
|
+
function firstLine(text) {
|
|
34
|
+
return (text.split(/\r?\n/).find((l) => l.trim() !== '') ?? '').trim();
|
|
35
|
+
}
|
|
36
|
+
/** The one step a ticket gets when structured planning produced nothing usable. */
|
|
37
|
+
function directFixStep(goalText) {
|
|
38
|
+
const head = firstLine(goalText);
|
|
39
|
+
const title = head === '' ? exports.DIRECT_STEP_PREFIX : `${exports.DIRECT_STEP_PREFIX}: ${head}`;
|
|
40
|
+
return {
|
|
41
|
+
title: title.length > DIRECT_TITLE_MAX ? `${title.slice(0, DIRECT_TITLE_MAX - 1)}…` : title,
|
|
42
|
+
tag: 'goal',
|
|
43
|
+
evidence: [],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** A compile answer made of the direct step alone, for a caller that needs a `CompileOutcome`. */
|
|
47
|
+
function directFixOutcome(goalText) {
|
|
48
|
+
const step = directFixStep(goalText);
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
steps: [step],
|
|
52
|
+
dropped: 0,
|
|
53
|
+
malformed: 0,
|
|
54
|
+
transcript: '',
|
|
55
|
+
requestDigest: (0, node_crypto_1.createHash)('sha256').update(`direct:${goalText}`, 'utf8').digest('hex'),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** A refused step with the citations that failed taken off it. */
|
|
59
|
+
function withoutRefuted(r) {
|
|
60
|
+
const refuted = r.verdict.ok ? [] : r.verdict.refuted;
|
|
61
|
+
return { ...r.step, evidence: r.step.evidence.filter((e) => !refuted.includes(e)) };
|
|
62
|
+
}
|
|
63
|
+
function dedupe(steps, max) {
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
const out = [];
|
|
66
|
+
for (const s of steps) {
|
|
67
|
+
const k = (0, goal_compile_1.stepKey)(s.title);
|
|
68
|
+
if (seen.has(k))
|
|
69
|
+
continue;
|
|
70
|
+
seen.add(k);
|
|
71
|
+
out.push(s);
|
|
72
|
+
}
|
|
73
|
+
return out.slice(0, max);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Compile, check, and recover. `maxSteps` bounds what is queued, whatever the
|
|
77
|
+
* recovery added, so a re-plan never makes a plan bigger than the cap it was asked under.
|
|
78
|
+
*/
|
|
79
|
+
async function compileWithRecovery(input, deps, maxSteps) {
|
|
80
|
+
const notes = [];
|
|
81
|
+
const say = (line) => {
|
|
82
|
+
notes.push(line);
|
|
83
|
+
deps.log?.(line);
|
|
84
|
+
};
|
|
85
|
+
const first = await deps.compile(input);
|
|
86
|
+
// A failed or unreadable answer is not a plan to recover: it spends nothing and is asked again.
|
|
87
|
+
if (!first.ok || (first.steps.length === 0 && first.malformed > 0))
|
|
88
|
+
return { compiled: first, checked: null, notes };
|
|
89
|
+
const firstChecked = await deps.check(first.steps);
|
|
90
|
+
let answer = first;
|
|
91
|
+
let queued = [...firstChecked.admitted];
|
|
92
|
+
if (firstChecked.refused.length > 0) {
|
|
93
|
+
say(`${firstChecked.refused.length} step(s) cited code that is not at the tree — planning again against the current tree`);
|
|
94
|
+
const again = await deps.compile({ ...input, retryContext: refusalContext(firstChecked.refused) });
|
|
95
|
+
if (again.ok && again.steps.length > 0) {
|
|
96
|
+
const checkedAgain = await deps.check(again.steps);
|
|
97
|
+
answer = again;
|
|
98
|
+
queued = [...queued, ...checkedAgain.admitted, ...checkedAgain.refused.map(withoutRefuted)];
|
|
99
|
+
if (checkedAgain.refused.length > 0) {
|
|
100
|
+
say(`${checkedAgain.refused.length} re-planned step(s) still cite code that is not there — kept without those citations; the verify pass checks them`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
queued = [...queued, ...firstChecked.refused.map(withoutRefuted)];
|
|
105
|
+
say('the re-plan gave nothing usable — keeping the refused steps without their citations; the verify pass checks them');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (queued.length === 0) {
|
|
109
|
+
say('the plan came back empty — asking again with the ticket read as an instruction');
|
|
110
|
+
const again = await deps.compile({ ...input, retryContext: exports.STATEMENT_CONTEXT });
|
|
111
|
+
if (again.ok && again.steps.length > 0) {
|
|
112
|
+
const checkedAgain = await deps.check(again.steps);
|
|
113
|
+
answer = again;
|
|
114
|
+
queued = [...checkedAgain.admitted, ...checkedAgain.refused.map(withoutRefuted)];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (queued.length === 0) {
|
|
118
|
+
say('still no plan — queuing one direct step: do what the ticket asks, with its full text');
|
|
119
|
+
const direct = directFixOutcome(input.goalText);
|
|
120
|
+
answer = { ...direct, requestDigest: answer.ok ? answer.requestDigest : direct.requestDigest };
|
|
121
|
+
queued = direct.ok ? direct.steps : [];
|
|
122
|
+
}
|
|
123
|
+
const steps = dedupe(queued, maxSteps);
|
|
124
|
+
const compiled = answer.ok ? { ...answer, steps } : answer;
|
|
125
|
+
return {
|
|
126
|
+
compiled,
|
|
127
|
+
checked: { admitted: steps, refused: firstChecked.refused, treeSha: firstChecked.treeSha },
|
|
128
|
+
notes,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=plan-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-recovery.js","sourceRoot":"","sources":["../src/plan-recovery.ts"],"names":[],"mappings":";;;AAgEA,wCAQC;AAiBD,sCAQC;AAGD,4CAUC;AAGD,wCAGC;AAkBD,kDAsDC;AA5LD,6CAAyC;AAEzC,iDAAoG;AAwDpG,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEhB,QAAA,kBAAkB,GAAG,sCAAsC,CAAC;AAEzE,4EAA4E;AAC5E,SAAgB,cAAc,CAAC,OAA+B;IAC5D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACxH,OAAO;QACL,+DAA+D;QAC/D,GAAG,KAAK;QACR,qGAAqG;QACrG,qFAAqF;KACtF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,wFAAwF;AAC3E,QAAA,iBAAiB,GAAG;IAC/B,2FAA2F;IAC3F,gGAAgG;IAChG,gGAAgG;IAChG,6FAA6F;IAC7F,mCAAmC;CACpC,CAA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E,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,OAAO;QACL,QAAQ;QACR,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE;QAC1F,KAAK;KACN,CAAC;AACJ,CAAC"}
|
package/dist/run-cmd.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-cmd.d.ts","sourceRoot":"","sources":["../src/run-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,OAAO,EAGL,KAAK,cAAc,EAKnB,KAAK,IAAI,EAaT,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA+B/E,OAAO,EAGL,KAAK,aAAa,EAIlB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAoBxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"run-cmd.d.ts","sourceRoot":"","sources":["../src/run-cmd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOvD,OAAO,EAGL,KAAK,cAAc,EAKnB,KAAK,IAAI,EAaT,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAA6B,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AA+B/E,OAAO,EAGL,KAAK,aAAa,EAIlB,KAAK,UAAU,EAChB,MAAM,gBAAgB,CAAC;AAoBxB,OAAO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GAAG,EAAE,YAAY;AACjB;;;;;;;;GAQG;AACH,UAAU,CAAC,EAAE,yBAAyB;AACtC;;;;;;GAMG;AACH,QAAQ,CAAC,EAAE,2BAA2B;AACtC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;AACtB;;;;;;;;GAQG;AACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;AACzB;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,EAAE,aAAa;AACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;AACpB;;;;;;;;;;;;GAYG;AACH,IAAI,CAAC,EAAE,cAAc,GACpB,MAAM,CA4FR;AAED;;;;;;;;;;;GAWG;AACH;;;;;;GAMG;AACH,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChF,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;CACnF;AAiID;;;GAGG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAi6HnE"}
|
package/dist/run-cmd.js
CHANGED
|
@@ -61,7 +61,9 @@ const programme_mode_1 = require("./programme-mode");
|
|
|
61
61
|
const partial_asker_1 = require("./partial-asker");
|
|
62
62
|
const goal_ownership_1 = require("./goal-ownership");
|
|
63
63
|
const goal_compile_1 = require("./goal-compile");
|
|
64
|
+
const plan_recovery_1 = require("./plan-recovery");
|
|
64
65
|
const goal_execution_evidence_1 = require("./goal-execution-evidence");
|
|
66
|
+
const goal_reproof_1 = require("./goal-reproof");
|
|
65
67
|
const round_records_1 = require("./round-records");
|
|
66
68
|
const goal_gap_1 = require("./goal-gap");
|
|
67
69
|
const goal_adaptive_1 = require("./goal-adaptive");
|
|
@@ -2853,7 +2855,10 @@ async function runLoop(opts) {
|
|
|
2853
2855
|
if (verdict.compile && scope !== null && binding.kind === 'bound') {
|
|
2854
2856
|
compiledThisRun = true;
|
|
2855
2857
|
log(`compile : ${binding.goal.text}`);
|
|
2856
|
-
|
|
2858
|
+
// Read before the compile: the compiler is told not to change anything, and every check of its
|
|
2859
|
+
// answer (the first and any re-plan) is made against the same committed tree.
|
|
2860
|
+
const compiledAt = await git.headTreeSha().catch(() => null);
|
|
2861
|
+
const recovered = await (0, plan_recovery_1.compileWithRecovery)({
|
|
2857
2862
|
goalId: binding.goal.id,
|
|
2858
2863
|
goalVersion: binding.goal.version,
|
|
2859
2864
|
goalText: binding.goal.text,
|
|
@@ -2885,10 +2890,16 @@ async function runLoop(opts) {
|
|
|
2885
2890
|
// acceptance map `produceClaims` holds `provenBy` against.
|
|
2886
2891
|
checks: config.gates.map((g) => g.name),
|
|
2887
2892
|
}),
|
|
2888
|
-
}, {
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2893
|
+
}, {
|
|
2894
|
+
compile: (i) => (0, goal_compile_1.compileGoal)(i, { invoke: planAgent }),
|
|
2895
|
+
// M3-2: checked at the committed tree before any step becomes an item; the compile recorded either way.
|
|
2896
|
+
check: (steps) => (0, compile_check_1.checkCompiledPlan)(steps, compileReaders, compiledAt),
|
|
2897
|
+
log: (line) => log(`compile : ${line}`),
|
|
2898
|
+
}, goal_compile_1.COMPILE_MAX_STEPS);
|
|
2899
|
+
// A step whose citation did not hold is re-planned, an empty plan is asked again as an instruction,
|
|
2900
|
+
// and only then does a ticket get one direct step (`plan-recovery.ts`) — never a hand-back.
|
|
2901
|
+
const compiled = recovered.compiled;
|
|
2902
|
+
const checked = recovered.checked;
|
|
2892
2903
|
for (const r of checked?.refused ?? [])
|
|
2893
2904
|
log(`compile : ${(0, compile_check_1.describeRefusal)(r)}`);
|
|
2894
2905
|
await recordCompile(binding.goal.id, binding.goal.version, compiledAt, compiled, checked);
|
|
@@ -3181,7 +3192,17 @@ async function runLoop(opts) {
|
|
|
3181
3192
|
.filter((i) => !(0, goal_compile_1.isPlanMarker)(i)),
|
|
3182
3193
|
}, {
|
|
3183
3194
|
evaluate: (i) => (0, goal_gap_1.evaluateGoalGap)(i, { invoke: planAgent }),
|
|
3184
|
-
|
|
3195
|
+
// The same recovery as the first plan: re-plan refused steps, read an empty answer as
|
|
3196
|
+
// an instruction, and fall back to one direct step before this revision is empty.
|
|
3197
|
+
compile: async (i, maxSteps) => {
|
|
3198
|
+
const at = await git.headTreeSha().catch(() => null);
|
|
3199
|
+
const recovered = await (0, plan_recovery_1.compileWithRecovery)(i, {
|
|
3200
|
+
compile: (j) => (0, goal_compile_1.compileGoal)(j, { invoke: planAgent, maxSteps }),
|
|
3201
|
+
check: (steps) => (0, compile_check_1.checkCompiledPlan)(steps, compileReaders, at),
|
|
3202
|
+
log: (line) => log(`goal : ${line}`),
|
|
3203
|
+
}, maxSteps);
|
|
3204
|
+
return recovered.compiled;
|
|
3205
|
+
},
|
|
3185
3206
|
changedPaths: () => git.changedPaths(),
|
|
3186
3207
|
headSha: () => git.headSha(),
|
|
3187
3208
|
/**
|
|
@@ -3199,14 +3220,33 @@ async function runLoop(opts) {
|
|
|
3199
3220
|
// retryable and says what actually happened.
|
|
3200
3221
|
if (!read.ok)
|
|
3201
3222
|
return { ok: false, reason: read.because, unknown: true };
|
|
3202
|
-
const
|
|
3223
|
+
const key2Input = {
|
|
3203
3224
|
scope: askedScope,
|
|
3204
3225
|
items: owned,
|
|
3205
3226
|
rounds: read.rounds,
|
|
3206
3227
|
// F27: a carried commit is confirmed as the round the lane carried.
|
|
3207
3228
|
currentHead: judged.kind === 'carried' ? judged.of : head,
|
|
3208
3229
|
requiredSteps: (0, gate_1.requiredSteps)(config.gates),
|
|
3209
|
-
}
|
|
3230
|
+
};
|
|
3231
|
+
let confirmed = (0, goal_execution_evidence_1.confirmGoalExecutionEvidence)(key2Input);
|
|
3232
|
+
/**
|
|
3233
|
+
* THE CODE MOVED ON: CHECK WHAT IS HERE NOW, DON'T HAND IT BACK (`goal-reproof.ts`).
|
|
3234
|
+
* Another ticket's run cut on top of this goal's commits is the common case in a
|
|
3235
|
+
* person's own checkout; the gates run again at HEAD, and KEY 2 is asked again.
|
|
3236
|
+
*/
|
|
3237
|
+
if (!confirmed.ok && confirmed.moved === true && judged.kind !== 'carried') {
|
|
3238
|
+
log('goal : the code moved on since this plan was delivered — running the gates again at the current tree');
|
|
3239
|
+
const again = await (0, goal_reproof_1.reproveAtHead)(head, (0, goal_execution_evidence_1.committedShasOf)(key2Input), {
|
|
3240
|
+
changedPaths: () => git.changedPaths(),
|
|
3241
|
+
isAncestor: (a, of) => git.isAncestor(a, of),
|
|
3242
|
+
changedPathsBetween: (from, to) => git.changedPathsBetween(from, to),
|
|
3243
|
+
runGates: async (paths) => (await (0, gate_1.runGate)({ steps: config.gates, changedPaths: paths, runner: (0, untrusted_gate_1.makeUntrustedGateRunner)(cwd) })).steps,
|
|
3244
|
+
});
|
|
3245
|
+
confirmed = again.ok
|
|
3246
|
+
? (0, goal_execution_evidence_1.confirmGoalExecutionEvidence)({ ...key2Input, rechecked: { contains: again.contains, steps: again.steps } })
|
|
3247
|
+
: { ok: false, because: `${goal_execution_evidence_1.CODE_MOVED_ON}, and it could not be checked again: ${again.because}` };
|
|
3248
|
+
log(`goal : ${confirmed.ok ? 'the gates pass at the current tree, and this plan’s work is in it' : confirmed.because}`);
|
|
3249
|
+
}
|
|
3210
3250
|
/**
|
|
3211
3251
|
* 🔴 WHAT KEY 2 SAW, KEPT FOR THE FOURTH KEY.
|
|
3212
3252
|
*
|
|
@@ -3222,7 +3262,7 @@ async function runLoop(opts) {
|
|
|
3222
3262
|
deliveringSha = confirmed.round.sha ?? null;
|
|
3223
3263
|
key2Saw = {
|
|
3224
3264
|
delivered: new Set(confirmed.delivered),
|
|
3225
|
-
checks: new Map((confirmed.round.gate?.steps ?? []).map((st) => [
|
|
3265
|
+
checks: new Map((confirmed.reproved ?? confirmed.round.gate?.steps ?? []).map((st) => [
|
|
3226
3266
|
st.step,
|
|
3227
3267
|
// A `when:` filter that matched nothing is SKIPPED, which
|
|
3228
3268
|
// is a different answer from passing — and the whole
|
|
@@ -3378,6 +3418,9 @@ async function runLoop(opts) {
|
|
|
3378
3418
|
const left = scope === null ? null : (0, core_1.workLeft)(runQueue.list());
|
|
3379
3419
|
if (left === 'finished')
|
|
3380
3420
|
return `this goal's work is done — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}`;
|
|
3421
|
+
if (left === 'stalled' && compiledThisRun && !runQueue.list().some((i) => i.state === 'draft')) {
|
|
3422
|
+
return `nothing in the first plan is ready to work on — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}; the next Start checks this goal against the code`;
|
|
3423
|
+
}
|
|
3381
3424
|
if (left === 'stalled')
|
|
3382
3425
|
return `nothing here can move without you — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}`;
|
|
3383
3426
|
return `nothing to do — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}`;
|
|
@@ -3508,7 +3551,19 @@ async function runLoop(opts) {
|
|
|
3508
3551
|
throw new RunRefused(`this goal's work is done — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}`, 'run_refused');
|
|
3509
3552
|
}
|
|
3510
3553
|
if (left === 'stalled') {
|
|
3554
|
+
/**
|
|
3555
|
+
* NOT A PERSON'S YET, WHEN THIS START ONLY JUST MADE THE PLAN.
|
|
3556
|
+
*
|
|
3557
|
+
* The verify pass can set a fresh plan's steps aside (stale, duplicate, blocked) and leave
|
|
3558
|
+
* nothing to pick. Nobody has asked the goal check yet: the next Start does — it measures
|
|
3559
|
+
* the goal against the code and re-plans what is missing (TAB-B-45 ended here). Retryable.
|
|
3560
|
+
* Items that wait on a person's decision (an `unclear` draft) still say so.
|
|
3561
|
+
*/
|
|
3562
|
+
const firstPlanOnly = compiledThisRun && !runQueue.list().some((i) => i.state === 'draft');
|
|
3563
|
+
const stalledBecause = (0, queue_summary_1.describeNoReady)(runQueue.list());
|
|
3511
3564
|
await releaseHold();
|
|
3565
|
+
if (firstPlanOnly)
|
|
3566
|
+
throw new Error(`nothing in the first plan is ready to work on — ${stalledBecause}; the next Start checks this goal against the code`);
|
|
3512
3567
|
throw new RunRefused(`nothing here can move without you — ${(0, queue_summary_1.describeNoReady)(runQueue.list())}`, 'human_required');
|
|
3513
3568
|
}
|
|
3514
3569
|
await releaseHold();
|