@rt-tools/agent-kit 0.38.0 → 0.39.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/assets/checks/check-turn-map.mjs +4 -4
- package/assets/checks/decision-table.json +91 -24
- package/assets/checks/flow-data.mjs +22 -23
- package/assets/checks/flow-forecast.mjs +12 -8
- package/assets/checks/flow-guard.mjs +365 -163
- package/assets/checks/flow-step.mjs +188 -58
- package/assets/checks/flow-verdict.mjs +124 -9
- package/assets/checks/record-count.mjs +27 -0
- package/assets/checks/task-flow-script.mjs +33 -7
- package/assets/checks/work-result.mjs +92 -11
- package/assets/commands/night.md +3 -3
- package/assets/defaults/turn-map.md +4 -2
- package/assets/docs/GLOSSARY.md +1 -1
- package/assets/hooks/ask-judge.md +4 -2
- package/assets/hooks/facts.sh +66 -0
- package/assets/hooks/git-guard-delivery-epic.sh +2 -2
- package/assets/hooks/git-guard-delivery-rerun.sh +17 -5
- package/assets/hooks/git-guard-push-ahead.sh +24 -2
- package/assets/hooks/git-guard-push-marks.sh +209 -12
- package/assets/hooks/git-guard-push-tests.sh +29 -2
- package/assets/hooks/pre-push.sh +26 -2
- package/assets/hooks/push-ahead-call-guard.sh +447 -0
- package/assets/hooks/push-set.sh +31 -8
- package/assets/hooks/turn-exit-guard.sh +1 -1
- package/assets/hooks/turn-judge.md +16 -6
- package/assets/patterns/doc-style-human.md +36 -76
- package/assets/pitfalls/doc-style-human.md +112 -0
- package/assets/pitfalls/epic-flow.md +92 -0
- package/assets/pitfalls/mockups.needs-mockups.md +87 -0
- package/assets/pitfalls/observability.needs-app.md +186 -0
- package/assets/pitfalls/platform-access.md +94 -0
- package/assets/pitfalls/queue-audit.github.md +78 -0
- package/assets/pitfalls/task-flow-archive.md +2 -1
- package/assets/pitfalls/task-flow-close.2.md +2 -1
- package/assets/pitfalls/task-flow-owner.md +29 -0
- package/assets/pitfalls/task-flow-resume.md +2 -2
- package/assets/pitfalls/task-flow-start.md +1 -1
- package/assets/pitfalls/turn-conduct.md +1 -1
- package/assets/rules/autonomous-work.md +1 -1
- package/assets/rules/epic-flow.md +24 -63
- package/assets/rules/mockups.needs-mockups.md +25 -64
- package/assets/rules/observability.needs-app.md +43 -172
- package/assets/rules/platform-access.md +28 -75
- package/assets/rules/queue-audit.github.md +25 -52
- package/assets/rules/task-flow-owner.md +6 -6
- package/assets/rules/turn-conduct.md +22 -19
- package/assets/task-flow/flow.js +10 -14
- package/assets/task-flow/flow.md +7 -8
- package/assets/task-flow/measure/ci.mjs +184 -0
- package/assets/task-flow/measure/owner.mjs +13 -6
- package/assets/task-flow/measure/session.mjs +92 -15
- package/assets/task-flow/source/git.mjs +179 -11
- package/assets/task-flow/source/host.mjs +105 -0
- package/assets/task-flow/source/owner.mjs +33 -13
- package/assets/task-flow/source/session.mjs +47 -10
- package/lib/agent-checks.d.ts.map +1 -1
- package/lib/agent-checks.js +14 -2
- package/lib/agent-checks.js.map +1 -1
- package/package.json +1 -1
|
@@ -43,15 +43,17 @@ import { evaluateCondition } from './flow-condition.mjs';
|
|
|
43
43
|
import { runForecast } from './flow-forecast.mjs';
|
|
44
44
|
import { judgeCall } from './flow-guard.mjs';
|
|
45
45
|
import { callOf, guardContext } from './flow-guard-run.mjs';
|
|
46
|
-
import { isWriteCommand,
|
|
46
|
+
import { isWriteCommand, retiredLines } from './flow-data.mjs';
|
|
47
47
|
import { FlowModelError, buildModel } from './flow-model.mjs';
|
|
48
48
|
import { overridePath, removedLines } from './flow-override.mjs';
|
|
49
49
|
import { planProblems, readRecord, runPlanRed } from './flow-plan.mjs';
|
|
50
50
|
import { runStepCommand } from './flow-step.mjs';
|
|
51
51
|
import { FlowSyntaxError } from './flow-syntax.mjs';
|
|
52
|
-
import { currentStep, holdReason, menuCause,
|
|
52
|
+
import { currentStep, decide, holdReason, menuCause, stageStep } from './flow-verdict.mjs';
|
|
53
53
|
|
|
54
54
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
55
|
+
// The history source puts a taken-apart folder back; it lies next to the laid-out engine, one level up in the package.
|
|
56
|
+
const history = await import(pathToFileURL([join(HERE, 'task-flow/source/git.mjs'), join(HERE, '../task-flow/source/git.mjs')].find((path) => existsSync(path))).href);
|
|
55
57
|
|
|
56
58
|
/** Where the description lies: next to the laid-out engine, or in the package. */
|
|
57
59
|
export function flowPath(given) {
|
|
@@ -130,7 +132,7 @@ export async function openReaders(model, base, given = {}) {
|
|
|
130
132
|
const source = await openSources(model, base, given);
|
|
131
133
|
const modules = {};
|
|
132
134
|
for (const m of model.measures) modules[m.entry] = await import(pathToFileURL(join(base, m.file)).href);
|
|
133
|
-
const data = { words: model.words, expect: model.expect, rules: {
|
|
135
|
+
const data = { words: model.words, expect: model.expect, rules: { isWriteCommand } };
|
|
134
136
|
const caps = new Map(model.measures.map((m) => [m.entry, m.caps]));
|
|
135
137
|
return (name) => {
|
|
136
138
|
const [, entry, cap] = name.split('.');
|
|
@@ -214,16 +216,38 @@ async function runVerdict(model, base) {
|
|
|
214
216
|
return cache.get(name);
|
|
215
217
|
};
|
|
216
218
|
const result = measureStates(model, measured);
|
|
217
|
-
const
|
|
218
|
-
if (
|
|
219
|
+
const decided = decide(model, measured, result);
|
|
220
|
+
if (decided) return decided;
|
|
219
221
|
const root = spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).stdout?.trim();
|
|
220
222
|
const branch = spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { encoding: 'utf8' }).stdout?.trim();
|
|
221
223
|
const progress = join(root ?? '.', GUARD_SETTINGS.tasksDir, branch ?? '', 'progress.md');
|
|
222
|
-
const
|
|
224
|
+
const folder = `${GUARD_SETTINGS.tasksDir}/${branch}`;
|
|
225
|
+
// A folder a live step run put back is not the folder of the branch: its progress is an older one.
|
|
226
|
+
const text = existsSync(progress) && !history.liveRun(folder) ? readFileSync(progress, 'utf8') : null;
|
|
227
|
+
let step = currentStep(text);
|
|
228
|
+
// No current step: the first one of the plan not done or without a matched mark, from the history
|
|
229
|
+
// when the folder is taken apart.
|
|
230
|
+
if (!step && branch && model.states[result.index - 1]?.key === 'stage') {
|
|
231
|
+
const source = await openSources(model, base);
|
|
232
|
+
step = stageStep(source('git'), source('marks'), folder, branch, text);
|
|
233
|
+
}
|
|
223
234
|
const task = branch?.match(/^[A-Z]+-(\d+)-/)?.[1] ?? null;
|
|
224
235
|
return { block: holdReason(model, result, step, { cause: menuCause(measured), task }) };
|
|
225
236
|
}
|
|
226
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Cleans the folder a broken step run put back, at a start of the engine, by `cleanBroken` of the
|
|
240
|
+
* history source: `{ verdict, folder }` or null. A folder kept because it was edited after the run is
|
|
241
|
+
* named on stderr, so nobody reads its older progress for the branch's own.
|
|
242
|
+
*/
|
|
243
|
+
export function cleanBrokenRun() {
|
|
244
|
+
const broken = history.cleanBroken();
|
|
245
|
+
if (broken?.verdict === 'kept' && broken.folder) {
|
|
246
|
+
console.error(`task-flow-script: ${broken.folder} is left by a broken step run and was edited after it — not removed; take it away by hand once read`);
|
|
247
|
+
}
|
|
248
|
+
return broken;
|
|
249
|
+
}
|
|
250
|
+
|
|
227
251
|
const COMMANDS = ['states', 'measure', 'step', 'plan-check', 'plan-red', 'guard', 'verdict', 'forecast'];
|
|
228
252
|
/** The commands the hooks call: they judge by the package description when the override breaks. */
|
|
229
253
|
const HOOK_COMMANDS = ['guard', 'verdict'];
|
|
@@ -240,6 +264,8 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
240
264
|
console.error(USAGE);
|
|
241
265
|
process.exit(2);
|
|
242
266
|
}
|
|
267
|
+
// A folder a broken step run put back is cleaned before any command; a live run keeps it.
|
|
268
|
+
cleanBrokenRun();
|
|
243
269
|
try {
|
|
244
270
|
const path = flowPath(given);
|
|
245
271
|
const override = overridePath(overrideGiven, given);
|
|
@@ -278,7 +304,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
|
278
304
|
process.exit(runPlanRed(sources, model, readRecord(process.env.RT_FLOW_TRANSCRIPT)));
|
|
279
305
|
} else {
|
|
280
306
|
const result = measureStates(model, await openReaders(model, dirname(path)));
|
|
281
|
-
console.log(json ? JSON.stringify(measureJson(model, result)) : [...measureLines(model, result), ...removedLines(model)].join('\n'));
|
|
307
|
+
console.log(json ? JSON.stringify(measureJson(model, result)) : [...measureLines(model, result), ...removedLines(model), ...retiredLines(model)].join('\n'));
|
|
282
308
|
}
|
|
283
309
|
} catch (error) {
|
|
284
310
|
if (error instanceof FlowSyntaxError) {
|
|
@@ -4,8 +4,11 @@
|
|
|
4
4
|
* functions the hook at the end of a turn and the reading of merges use: the events of the records,
|
|
5
5
|
* the merges, the editions, the verdicts.
|
|
6
6
|
*
|
|
7
|
-
* node work-result.mjs --observations <dir> --until YYYY-MM-DD [--days N] [--no-package]
|
|
8
|
-
* node work-result.mjs --epics --own <dir> [--observations <dir>]... --until YYYY-MM-DD [--days N]
|
|
7
|
+
* node work-result.mjs --observations <dir> [--until YYYY-MM-DD] [--days N] [--no-package]
|
|
8
|
+
* node work-result.mjs --epics --own <dir> [--observations <dir>]... [--until YYYY-MM-DD] [--days N]
|
|
9
|
+
*
|
|
10
|
+
* With no `--until` the period ends today, the day of the moment of the run as the observations
|
|
11
|
+
* write it (UTC).
|
|
9
12
|
*
|
|
10
13
|
* Prints one JSON object: `{ result, lines }`. `result` holds the numbers, never a null among the
|
|
11
14
|
* lines of the result; `lines` holds the text the report prints.
|
|
@@ -98,6 +101,8 @@ export function dayResult(observations, events, day, firstCounted = firstCounted
|
|
|
98
101
|
...dayMerges(observations, day),
|
|
99
102
|
};
|
|
100
103
|
if (!kept.recorded) return { ...kept, beforeCounter: firstCounted === null || day < firstCounted };
|
|
104
|
+
// A dead end belongs to the day of its last refusal, and to the check whose refusals made it.
|
|
105
|
+
const ends = deadEndsOf(events).filter((d) => String(d.to).startsWith(day));
|
|
101
106
|
return {
|
|
102
107
|
...kept,
|
|
103
108
|
beforeCounter: false,
|
|
@@ -112,7 +117,8 @@ export function dayResult(observations, events, day, firstCounted = firstCounted
|
|
|
112
117
|
interrupts: of.filter((e) => e.ev === 'interrupt').length,
|
|
113
118
|
ownerWords: of.filter((e) => e.ev === 'word').length,
|
|
114
119
|
corrections: of.filter((e) => e.ev === 'word' && e.corr).length,
|
|
115
|
-
deadEnds:
|
|
120
|
+
deadEnds: ends.length,
|
|
121
|
+
deadEndsByCheck: Object.fromEntries(byCountThenName(Object.entries(count(ends, (d) => d.check || 'unnamed')))),
|
|
116
122
|
};
|
|
117
123
|
}
|
|
118
124
|
|
|
@@ -138,13 +144,18 @@ export function periodEpics(observations, days, { publishes = true } = {}) {
|
|
|
138
144
|
}));
|
|
139
145
|
}
|
|
140
146
|
|
|
141
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* The result of a period: a result per day, the epics of the period, the verdict on milestone G of
|
|
149
|
+
* the epic and the sums the lines print.
|
|
150
|
+
*/
|
|
142
151
|
export function resultOf(observations, days, { publishes = true } = {}) {
|
|
143
152
|
const events = eventsOf(observations);
|
|
144
153
|
const firstCounted = firstCountedDay(observations);
|
|
154
|
+
const dayResults = days.map((day) => dayResult(observations, events, day, firstCounted));
|
|
145
155
|
return {
|
|
146
|
-
days:
|
|
156
|
+
days: dayResults,
|
|
147
157
|
epics: periodEpics(observations, days, { publishes }),
|
|
158
|
+
milestone: epicMilestoneOf(dayResults),
|
|
148
159
|
};
|
|
149
160
|
}
|
|
150
161
|
|
|
@@ -152,6 +163,57 @@ const hours = (minutes) => (minutes / 60).toFixed(1);
|
|
|
152
163
|
|
|
153
164
|
/** Milestone G: fewer than this many refusals per hundred calls; exactly this many is not reached. */
|
|
154
165
|
const MILESTONE_G_LIMIT = 5;
|
|
166
|
+
/** Milestone G of the epic: a day is judged only with at least this many calls. */
|
|
167
|
+
const MILESTONE_G_CALLS = 1500;
|
|
168
|
+
/** Milestone G of the epic: this many days in a row, each holding it. */
|
|
169
|
+
const MILESTONE_G_DAYS = 3;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* What keeps one day from holding milestone G of the epic, in the words of the report; an empty list
|
|
173
|
+
* when the day holds it. A day with no session record holds nothing: no number of it is counted.
|
|
174
|
+
*/
|
|
175
|
+
export function milestoneMissesOf(d) {
|
|
176
|
+
if (!d.recorded) return ['записи сессий нет'];
|
|
177
|
+
const misses = [];
|
|
178
|
+
if (d.calls < MILESTONE_G_CALLS) misses.push(`вызовов ${d.calls} < ${MILESTONE_G_CALLS}`);
|
|
179
|
+
if (d.refusalsPer100 >= MILESTONE_G_LIMIT) misses.push(`отказов ${d.refusalsPer100.toFixed(2)} на сто ≥ ${MILESTONE_G_LIMIT}`);
|
|
180
|
+
if (d.deadEnds > 0) misses.push(`тупиков ${d.deadEnds} > 0`);
|
|
181
|
+
return misses;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A working day of milestone G: a session record and at least MILESTONE_G_CALLS calls. */
|
|
185
|
+
const workingDay = (d) => Boolean(d.recorded) && d.calls >= MILESTONE_G_CALLS;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Milestone G of the epic over the days of a period, oldest first: reached when MILESTONE_G_DAYS
|
|
189
|
+
* working days in a row each hold it. A day that is not a working day is skipped: it neither counts
|
|
190
|
+
* nor breaks the run, by the owner's choice of 22.11.2026. `run` names the first such days; `misses`
|
|
191
|
+
* names every day that does not hold it and by what, the skipped ones marked.
|
|
192
|
+
*/
|
|
193
|
+
export function epicMilestoneOf(days) {
|
|
194
|
+
const misses = days
|
|
195
|
+
.map((d) => ({ day: d.day, why: milestoneMissesOf(d), skipped: !workingDay(d) }))
|
|
196
|
+
.filter((m) => m.why.length > 0);
|
|
197
|
+
let run = [];
|
|
198
|
+
for (const d of days.filter(workingDay)) {
|
|
199
|
+
run = milestoneMissesOf(d).length > 0 ? [] : [...run, d.day];
|
|
200
|
+
if (run.length === MILESTONE_G_DAYS) return { reached: true, run, misses };
|
|
201
|
+
}
|
|
202
|
+
return { reached: false, run: [], held: run.length, misses };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The lines of the verdict on milestone G of the epic. */
|
|
206
|
+
export function epicMilestoneLines(milestone, dayCount) {
|
|
207
|
+
const rule = `${MILESTONE_G_DAYS} рабочих дня подряд: от ${MILESTONE_G_CALLS} вызовов, отказов меньше ${MILESTONE_G_LIMIT} на сто, ни одного тупика`;
|
|
208
|
+
if (milestone.reached) return [` Веха G эпика: достигнута — ${milestone.run.join(', ')} (${rule})`];
|
|
209
|
+
const lines = [` Веха G эпика: не достигнута (нужно ${rule})`];
|
|
210
|
+
for (const m of milestone.misses) lines.push(` ${m.day}: ${m.why.join(', ')}${m.skipped ? ' — не рабочий день, пропущен' : ''}`);
|
|
211
|
+
// With no working day that breaks it, the run is only short: say how long the last one is.
|
|
212
|
+
if (milestone.misses.every((m) => m.skipped)) {
|
|
213
|
+
lines.push(` рабочих дней подряд держат веху: ${milestone.held ?? 0} из ${MILESTONE_G_DAYS} (в отрезке ${dayCount} дн.)`);
|
|
214
|
+
}
|
|
215
|
+
return lines;
|
|
216
|
+
}
|
|
155
217
|
|
|
156
218
|
/** The milestone G words of a day. A day with no call is not judged. */
|
|
157
219
|
export function milestoneOf(d) {
|
|
@@ -208,7 +270,16 @@ export function linesOf(result) {
|
|
|
208
270
|
lines.push(gateLine(result.days));
|
|
209
271
|
lines.push(` Цель не достигнута: ${sum('goalNotMet')}`);
|
|
210
272
|
for (const [task, n] of byCountThenName(Object.entries(verdicts))) lines.push(` ${task}: ${n}`);
|
|
211
|
-
|
|
273
|
+
// Beside the verdict of the epic, a reached day the epic skips says so, or the two lines disagree.
|
|
274
|
+
const epic = result.days.length >= MILESTONE_G_DAYS;
|
|
275
|
+
for (const d of result.days) {
|
|
276
|
+
const skipped = epic && d.calls > 0 && !workingDay(d) && milestoneMissesOf(d).length === 1 ? ' (не рабочий день для вехи эпика)' : '';
|
|
277
|
+
lines.push(result.days.length === 1 ? ` ${milestoneOf(d)}` : ` ${d.day} ${milestoneOf(d)}${skipped}`);
|
|
278
|
+
}
|
|
279
|
+
// The epic milestone asks for days in a row: a shorter period has nothing to judge it by.
|
|
280
|
+
if (result.days.length >= MILESTONE_G_DAYS) {
|
|
281
|
+
lines.push(...epicMilestoneLines(result.milestone ?? epicMilestoneOf(result.days), result.days.length));
|
|
282
|
+
}
|
|
212
283
|
lines.push(' Повторы ошибок: считается в приёмнике');
|
|
213
284
|
return lines;
|
|
214
285
|
}
|
|
@@ -229,6 +300,12 @@ export function gateLine(days) {
|
|
|
229
300
|
return ` проверка правил: отказов ${total}${parts.length ? ` (${parts.join(', ')})` : ''}, правил без отказа ${delivered}`;
|
|
230
301
|
}
|
|
231
302
|
|
|
303
|
+
/** The dead ends of a day by check: the name and the number of series, most first; «нет» for none. */
|
|
304
|
+
export const deadEndWords = (byCheck) => {
|
|
305
|
+
const parts = Object.entries(byCheck ?? {}).map(([name, n]) => `${name} ${n}`);
|
|
306
|
+
return parts.length ? parts.join(', ') : 'нет';
|
|
307
|
+
};
|
|
308
|
+
|
|
232
309
|
/** The lines counted from the session record, over the days that have one. */
|
|
233
310
|
function recordLines(days, sum) {
|
|
234
311
|
const lines = [` Простой: ${hours(sum('idleMinutes', days))} ч`, ' Отказов на сто вызовов:'];
|
|
@@ -236,6 +313,8 @@ function recordLines(days, sum) {
|
|
|
236
313
|
lines.push(` ${d.day}: ${d.refusalsPer100.toFixed(2)} (${d.refusals} из ${d.calls})`);
|
|
237
314
|
for (const [name, c] of Object.entries(d.byCheck)) lines.push(` ${name}: ${c.per100.toFixed(2)}`);
|
|
238
315
|
}
|
|
316
|
+
lines.push(' Тупики по проверкам:');
|
|
317
|
+
for (const d of days) lines.push(` ${d.day}: ${deadEndWords(d.deadEndsByCheck)}`);
|
|
239
318
|
const pairs = {};
|
|
240
319
|
for (const d of days) for (const [pair, n] of Object.entries(d.pairs)) pairs[pair] = (pairs[pair] ?? 0) + n;
|
|
241
320
|
const pairList = byCountThenName(Object.entries(pairs));
|
|
@@ -259,19 +338,21 @@ export function sendingEpics(own, others, days, { publishes = true } = {}) {
|
|
|
259
338
|
}));
|
|
260
339
|
}
|
|
261
340
|
|
|
262
|
-
|
|
341
|
+
/** The last day of the period: `--until`, or the day of the moment when it is not given. */
|
|
342
|
+
export const untilOf = (argv, now) => option(argv, '--until') ?? now.toISOString().slice(0, 10);
|
|
343
|
+
|
|
344
|
+
function main(argv, now = new Date()) {
|
|
345
|
+
const until = untilOf(argv, now);
|
|
263
346
|
if (argv.includes('--epics')) {
|
|
264
347
|
const own = option(argv, '--own');
|
|
265
|
-
|
|
266
|
-
if (!own || !until) return 1;
|
|
348
|
+
if (!own) return 1;
|
|
267
349
|
const days = daysOf(until, Number(option(argv, '--days') ?? '1'));
|
|
268
350
|
const others = options(argv, '--observations').filter((dir) => dir !== own).flatMap((dir) => readObservations(dir));
|
|
269
351
|
console.log(JSON.stringify({ epics: sendingEpics(readObservations(own), others, days, { publishes: !argv.includes('--no-package') }) }));
|
|
270
352
|
return 0;
|
|
271
353
|
}
|
|
272
354
|
const dir = option(argv, '--observations');
|
|
273
|
-
|
|
274
|
-
if (!dir || !until) return 1;
|
|
355
|
+
if (!dir) return 1;
|
|
275
356
|
const days = daysOf(until, Number(option(argv, '--days') ?? '1'));
|
|
276
357
|
const result = resultOf(readObservations(dir), days, { publishes: !argv.includes('--no-package') });
|
|
277
358
|
console.log(JSON.stringify({ result, lines: linesOf(result) }));
|
package/assets/commands/night.md
CHANGED
|
@@ -113,9 +113,9 @@ Then the work goes by the rule and the pattern, and the last reply gives the lis
|
|
|
113
113
|
that lies in the file.
|
|
114
114
|
|
|
115
115
|
Where a turn-exit guard is laid out, it holds a working turn until the scenario is over or the
|
|
116
|
-
owner
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
owner presses Esc. The boundary is neither, and a question does not end the turn either. So the
|
|
117
|
+
list is appended along the way and lies in the file at any minute. The night ends with the end of
|
|
118
|
+
the scenario, or with the owner's Esc in the morning.
|
|
119
119
|
|
|
120
120
|
## What this command does not do
|
|
121
121
|
|
|
@@ -31,14 +31,16 @@ merge go on without the executor and do not get faster from being watched.
|
|
|
31
31
|
## What a turn ends with
|
|
32
32
|
|
|
33
33
|
- **the end of the scenario** — the engine measured it; under an epic the table of its tasks is shown
|
|
34
|
-
- **
|
|
34
|
+
- **the owner interrupted the turn** — they pressed Esc; a turn a background notice wakes after it
|
|
35
|
+
ends too, until they write again. No typed word stops the work
|
|
35
36
|
|
|
36
37
|
The exit guard holds every other turn and names the one next move. The task flow description adds
|
|
37
38
|
release cases that are not the executor's choice: no write to the tree, a branch outside the
|
|
38
39
|
scenario, a role session, a silent host, a menu that did not reach the owner twice.
|
|
39
40
|
|
|
40
41
|
A question, a guard's refusal, a handover and handed-in work do not end a turn. A step that
|
|
41
|
-
another guard refuses twice goes to the owner as one menu: «отложить RT-N»,
|
|
42
|
+
another guard refuses twice goes to the owner as one menu: «отложить RT-N», «подскажу путь»; the
|
|
43
|
+
way goes into its free field. The menu waits for the answer inside the turn.
|
|
42
44
|
|
|
43
45
|
Where the tree has set the compaction threshold below the stop threshold, a filled window does
|
|
44
46
|
not end the turn: the context is compacted, the handover arrives as the entry, and the work goes
|
package/assets/docs/GLOSSARY.md
CHANGED
|
@@ -66,7 +66,7 @@ sections through the override; they merge here by heading, and a package edit do
|
|
|
66
66
|
- **Audit** — a check that edits nothing and names discrepancies: of the layout against the package, of specs against the code, of the work queue against the branches
|
|
67
67
|
- **Measurement** — a number taken from the running application. A look at the screen is not a measurement
|
|
68
68
|
- **Flow script** — the engine of the task flow. It measures the work state of a branch by the task flow description, runs the check of a plan step and writes its mark, and gives the verdict at the end of a turn. The description is data; the script edits no file of the work
|
|
69
|
-
- **Exit check** — the guard at the end of a turn that asks the flow script for a verdict. It holds a turn whose scenario is not over and names the one next move. Only the end of the scenario, the owner's
|
|
69
|
+
- **Exit check** — the guard at the end of a turn that asks the flow script for a verdict. It holds a turn whose scenario is not over and names the one next move. Only the end of the scenario, the owner's Esc and the release cases of the description let a turn end
|
|
70
70
|
|
|
71
71
|
## Russian names
|
|
72
72
|
|
|
@@ -36,8 +36,10 @@ after any refusal of another check. Avoid both.
|
|
|
36
36
|
could be done. A refusal elsewhere is never a reason to hold the question.
|
|
37
37
|
- The question is the menu named by a refusal of the exit check. Another check
|
|
38
38
|
refused the step twice. The options are exactly two: «отложить RT-N» with the task number and
|
|
39
|
-
|
|
40
|
-
progress does not hold it.
|
|
39
|
+
«подскажу путь», and the question says the way goes into its free field. The owner's answer to
|
|
40
|
+
it is their word, so a next step named in the progress does not hold it.
|
|
41
|
+
- The owner answered that menu with a bare «подскажу путь» and no text, and the question is one
|
|
42
|
+
question with a free field that asks for the way. It is part of the same menu.
|
|
41
43
|
|
|
42
44
|
## Hold the question — answer `{"ok": false, "reason": "BLOCKED by ask-judge: …"}` — only when
|
|
43
45
|
|
package/assets/hooks/facts.sh
CHANGED
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
# the facts the neighbours judge a named move by, as JSON: the
|
|
32
32
|
# exam, the window, the rules the gate wants for the move, the
|
|
33
33
|
# rule of the course of work and the entry from a handover
|
|
34
|
+
# rt_node_pinned_dir [root] the bin directory of the node `.nvmrc` pins, installed by nvm
|
|
35
|
+
# rt_node_pin_mismatch [root] one line when no installed node serves the pin and the node
|
|
36
|
+
# of PATH does not either; empty otherwise
|
|
34
37
|
#
|
|
35
38
|
# FAIL-OPEN: a fact that cannot be read is empty. The guard decides by an empty fact as it did when
|
|
36
39
|
# its own call failed.
|
|
@@ -306,3 +309,66 @@ rt_move_rules() {
|
|
|
306
309
|
esac
|
|
307
310
|
) | tr '\n' ' '
|
|
308
311
|
}
|
|
312
|
+
|
|
313
|
+
# The version `.nvmrc` of the tree pins, without the `v`: a full version, a major or a major and a
|
|
314
|
+
# minor. The first line that is not a comment counts, spaces and tabs aside. An alias — `lts/*`,
|
|
315
|
+
# `node` — and a tree with no `.nvmrc` give nothing.
|
|
316
|
+
rt_node_pin() {
|
|
317
|
+
local pin
|
|
318
|
+
# A byte order mark ahead of the version is dropped with the rest of the blank.
|
|
319
|
+
pin="$({ LC_ALL=C sed -e "s/^$(printf '\357\273\277')//" -e 's/#.*//' -e 's/[[:space:]]//g' "${1:-.}/.nvmrc" | grep -m 1 .; } 2>/dev/null)"
|
|
320
|
+
pin="${pin#v}"
|
|
321
|
+
case "$pin" in '' | *[!0-9.]* | .* | *..* | *.) return 0 ;; esac
|
|
322
|
+
printf '%s' "$pin"
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
# Whether version $1 is not lower than version $2, part by part as numbers: 22.01 equals 22.1.
|
|
326
|
+
rt_node_at_least() {
|
|
327
|
+
awk -v a="$1" -v b="$2" 'BEGIN { n = split(a, x, "."); m = split(b, y, "."); if (m > n) n = m
|
|
328
|
+
for (i = 1; i <= n; i++) { if (x[i] + 0 > y[i] + 0) exit 0; if (x[i] + 0 < y[i] + 0) exit 1 } exit 0 }'
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
# Whether node $1 serves pin $2: the pinned version itself; for a major or a major and a minor, any
|
|
332
|
+
# version under it; for a full version, a newer one of the same major too.
|
|
333
|
+
rt_node_serves() {
|
|
334
|
+
local have="$1" pin="$2"
|
|
335
|
+
case "$have" in "$pin" | "$pin".*) return 0 ;; esac
|
|
336
|
+
case "$pin" in *.*.*) [ "${have%%.*}" = "${pin%%.*}" ] && rt_node_at_least "$have" "$pin" ;; *) return 1 ;; esac
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
# The bin directory of the pinned node under nvm. A full version takes its own directory, and with
|
|
340
|
+
# none — the highest installed one of the same major above it; a major or a major and a minor takes
|
|
341
|
+
# the highest installed version under it. An install with no executable node is passed over. The
|
|
342
|
+
# steps of a set run on it: the node the hook inherits may be another one, and a tree that demands
|
|
343
|
+
# its node refuses that.
|
|
344
|
+
rt_node_pinned_dir() {
|
|
345
|
+
local pin base found version
|
|
346
|
+
pin="$(rt_node_pin "${1:-.}")"
|
|
347
|
+
[ -n "$pin" ] || return 0
|
|
348
|
+
base="${NVM_DIR:-$HOME/.nvm}/versions/node"
|
|
349
|
+
[ -x "$base/v$pin/bin/node" ] && printf '%s' "$base/v$pin/bin" && return 0
|
|
350
|
+
for found in "$base"/v*/bin/node; do
|
|
351
|
+
[ -x "$found" ] || continue
|
|
352
|
+
version="${found%/bin/node}"
|
|
353
|
+
printf '%s\n' "${version##*/v}"
|
|
354
|
+
done | grep -E '^[0-9]+(\.[0-9]+)*$' | sort -t. -k1,1nr -k2,2nr -k3,3nr | while IFS= read -r version; do
|
|
355
|
+
rt_node_serves "$version" "$pin" && printf '%s' "$base/v$version/bin" && break
|
|
356
|
+
done || true
|
|
357
|
+
return 0
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
# One line when no installed node serves the pin and the node of PATH does not serve it either: no
|
|
361
|
+
# step of a set runs then, and the line names the command that installs it. A node of PATH that
|
|
362
|
+
# serves the pin runs the steps as before.
|
|
363
|
+
rt_node_pin_mismatch() {
|
|
364
|
+
local root="${1:-.}" pin have shown
|
|
365
|
+
pin="$(rt_node_pin "$root")"
|
|
366
|
+
[ -n "$pin" ] || return 0
|
|
367
|
+
[ -n "$(rt_node_pinned_dir "$root")" ] && return 0
|
|
368
|
+
have="$(node --version 2>/dev/null)"
|
|
369
|
+
have="${have#v}"
|
|
370
|
+
[ -n "$have" ] && rt_node_serves "$have" "$pin" && return 0
|
|
371
|
+
shown="${have:+v$have}"
|
|
372
|
+
printf 'node v%s is pinned in .nvmrc and not installed; PATH gives %s — nvm install %s' \
|
|
373
|
+
"$pin" "${shown:-no node}" "$pin"
|
|
374
|
+
}
|
|
@@ -79,7 +79,7 @@ rt_epic_base() {
|
|
|
79
79
|
if rt_epic_is_merged "$_epic"; then
|
|
80
80
|
return 0
|
|
81
81
|
fi
|
|
82
|
-
unmet epic_branch none "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has. Take it from the fresh main branch, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh}\` (the Bash call with run_in_background) and push it after their end: the push is refused until they have a green mark."
|
|
82
|
+
unmet epic_branch none "the task belongs to the epic #${_epic}, and no branch of that epic is in the remote. The branch of the epic is taken before the first of its tasks and sent at once — a branch that exists only on one machine is a base nobody else has. Take it from the fresh main branch, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh} > \"\${TMPDIR:-/tmp}/push-ahead-\$(basename \"\$PWD\").log\" 2>&1\` (the Bash call with run_in_background, nothing after it; the verdict is the code of the notice and the last \`push ahead:\` line of the log) and push it after their end: the push is refused until they have a green mark."
|
|
83
83
|
return 0
|
|
84
84
|
;;
|
|
85
85
|
*' '*)
|
|
@@ -109,7 +109,7 @@ rt_epic_base() {
|
|
|
109
109
|
&& ! git merge-base --is-ancestor "origin/${main_branch}" "origin/${_epic_branch}" 2>/dev/null \
|
|
110
110
|
&& ! git merge-base --is-ancestor "origin/${main_branch}" "$_base_ref" 2>/dev/null; then
|
|
111
111
|
_behind="$(git rev-list --count "origin/${_epic_branch}..origin/${main_branch}" 2>/dev/null)"
|
|
112
|
-
unmet epic_has_main_tip no "the branch of the epic «${_epic_branch}» does not carry the tip of «${main_branch}» — it has moved ahead by ${_behind:-several} commits. The main branch is merged into the branch of the epic, not bypassed by taking the base from the main one: git checkout ${_epic_branch}, git merge origin/${main_branch}, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh}\` (the Bash call with run_in_background), and send the branch after their end: the push is refused until they have a green mark."
|
|
112
|
+
unmet epic_has_main_tip no "the branch of the epic «${_epic_branch}» does not carry the tip of «${main_branch}» — it has moved ahead by ${_behind:-several} commits. The main branch is merged into the branch of the epic, not bypassed by taking the base from the main one: git checkout ${_epic_branch}, git merge origin/${main_branch}, run the heavy steps by \`${ahead_cmd:-bash git-guard-push-ahead.sh} > \"\${TMPDIR:-/tmp}/push-ahead-\$(basename \"\$PWD\").log\" 2>&1\` (the Bash call with run_in_background, nothing after it; the verdict is the code of the notice and the last \`push ahead:\` line of the log), and send the branch after their end: the push is refused until they have a green mark."
|
|
113
113
|
fi
|
|
114
114
|
|
|
115
115
|
return 0
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
# closed. The engine puts a taken-apart task folder back from the history for the run.
|
|
10
10
|
#
|
|
11
11
|
# FAIL-OPEN: no node, no engine, a branch with no plan or a plan with no checks — nothing is judged.
|
|
12
|
+
#
|
|
13
|
+
# Requires: hooks/facts.sh
|
|
12
14
|
|
|
13
15
|
rt_delivery_rerun() {
|
|
14
16
|
command -v node >/dev/null 2>&1 || return 0
|
|
@@ -19,14 +21,24 @@ rt_delivery_rerun() {
|
|
|
19
21
|
[ -n "$engine" ] || return 0
|
|
20
22
|
local dir="${root:-${CLAUDE_PROJECT_DIR:-.}}" pinned run_path="$PATH"
|
|
21
23
|
# The checks run on the node the tree pins in .nvmrc, as they ran when measured: the session may
|
|
22
|
-
# carry another default, and a tree with an engines field refuses it.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[ -
|
|
24
|
+
# carry another default, and a tree with an engines field refuses it. The same function names the
|
|
25
|
+
# directory for the push set.
|
|
26
|
+
# shellcheck disable=SC1091
|
|
27
|
+
command -v rt_node_pinned_dir >/dev/null 2>&1 || { [ -f "$rt_hooks_dir/facts.sh" ] && . "$rt_hooks_dir/facts.sh" 2>/dev/null; }
|
|
28
|
+
command -v rt_node_pinned_dir >/dev/null 2>&1 && pinned="$(rt_node_pinned_dir "$dir")"
|
|
29
|
+
[ -n "$pinned" ] && run_path="$pinned:$PATH"
|
|
26
30
|
out="$(cd "$dir" && PATH="$run_path" node "$engine" step --done --pr 2>&1)"
|
|
27
31
|
code=$?
|
|
28
32
|
[ "$code" -eq 0 ] && return 0
|
|
33
|
+
# The move names the steps by their numbers: a line of a step begins with it and does not end matched.
|
|
34
|
+
local steps move
|
|
35
|
+
steps="$(printf '%s\n' "$out" | awk '/^[0-9]+\.[0-9]+ / && !/· совпало$/ { printf "%s`node tools/task-flow-script.mjs step %s`", (n++ ? ", " : ""), $1 }')"
|
|
36
|
+
move="Fix what each step measures and run $steps again: it marks the step done when the check matches."
|
|
37
|
+
# No unmatched step: a live run holds the folder, or a check changed a tracked file — the lines say which.
|
|
38
|
+
[ -n "$steps" ] || move="The lines above name the cause: do what they say, then open the PR again."
|
|
39
|
+
printf '%s' "$out" | grep -q 'git revert --no-edit' &&
|
|
40
|
+
move="$move The task folder is taken apart: the command puts it back for the run, and a fix that lies in the folder takes the move the engine named above."
|
|
29
41
|
unmet steps_remeasured no "the done steps of the plan were measured once more before the PR, and not every one matched:
|
|
30
42
|
$(printf '%s\n' "$out" | sed 's/^/ /')
|
|
31
|
-
|
|
43
|
+
$move"
|
|
32
44
|
}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
# Exit codes: 0 — the set is green; 1 — a check is red; 3 — the run did not start (no profile, no
|
|
15
15
|
# repository, edits outside the index). Not 2: to a hook that code means "refuse", and this command
|
|
16
16
|
# refuses nothing.
|
|
17
|
+
#
|
|
18
|
+
# Requires: hooks/git-guard-push-marks.sh, hooks/facts.sh
|
|
17
19
|
not_started=3
|
|
18
20
|
|
|
19
21
|
rt_hooks_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
@@ -51,6 +53,21 @@ command -v rt_push_note_not_run >/dev/null 2>&1 || rt_push_note_not_run() { retu
|
|
|
51
53
|
command -v rt_run_note >/dev/null 2>&1 || rt_run_note() { return 0; }
|
|
52
54
|
command -v rt_tree_sign >/dev/null 2>&1 || rt_tree_sign() { return 0; }
|
|
53
55
|
|
|
56
|
+
# The steps and their choice run on the node the tree pins, as at the push: the shell that starts
|
|
57
|
+
# the run may carry another one. A pinned node that is not installed, with another node in PATH,
|
|
58
|
+
# starts no step.
|
|
59
|
+
# shellcheck disable=SC1091
|
|
60
|
+
command -v rt_node_pinned_dir >/dev/null 2>&1 || { [ -f "$rt_hooks_dir/facts.sh" ] && . "$rt_hooks_dir/facts.sh" 2>/dev/null; }
|
|
61
|
+
if command -v rt_node_pinned_dir >/dev/null 2>&1; then
|
|
62
|
+
node_line="$(rt_node_pin_mismatch "$root")"
|
|
63
|
+
if [ -n "$node_line" ]; then
|
|
64
|
+
printf 'push ahead: %s\n' "$node_line" >&2
|
|
65
|
+
exit "$not_started"
|
|
66
|
+
fi
|
|
67
|
+
node_dir="$(rt_node_pinned_dir "$root")"
|
|
68
|
+
[ -n "$node_dir" ] && PATH="$node_dir:$PATH"
|
|
69
|
+
fi
|
|
70
|
+
|
|
54
71
|
# A mark vouches for the tree of the head, and the checks run over the working copy: with edits
|
|
55
72
|
# outside the index the run would write marks for content that does not leave.
|
|
56
73
|
rt_push_mark_clean || {
|
|
@@ -60,13 +77,18 @@ rt_push_mark_clean || {
|
|
|
60
77
|
|
|
61
78
|
base="$(rt_push_base "${RT_MAIN_BRANCH:-main}")"
|
|
62
79
|
skip_code="${RT_SKIP_CODE:-7}"
|
|
80
|
+
# The steps run against a ref pinned at the commit of the base, and the push takes that ref while the
|
|
81
|
+
# record fits its head: a branch merged, removed, moved or put next to this one during the set
|
|
82
|
+
# changes nothing for the push.
|
|
83
|
+
command -v rt_push_base_pin >/dev/null 2>&1 && base="$(rt_push_base_pin "$base")"
|
|
84
|
+
command -v rt_push_base_label >/dev/null 2>&1 || rt_push_base_label() { printf '%s' "${1:-none}"; }
|
|
63
85
|
|
|
64
86
|
if command -v rt_push_adds_nothing >/dev/null 2>&1 && rt_push_adds_nothing "$base"; then
|
|
65
|
-
printf 'push ahead: the head adds no commit to %s — there is nothing to run, the push passes\n' "$base"
|
|
87
|
+
printf 'push ahead: the head adds no commit to %s — there is nothing to run, the push passes\n' "$(rt_push_base_label "$base")"
|
|
66
88
|
exit 0
|
|
67
89
|
fi
|
|
68
90
|
|
|
69
|
-
printf 'push ahead: base %s, tree %s\n' "$
|
|
91
|
+
printf 'push ahead: base %s, tree %s\n' "$(rt_push_base_label "$base")" "$(git rev-parse --short 'HEAD^{tree}')"
|
|
70
92
|
sign="$(rt_tree_sign .)"
|
|
71
93
|
# Whether the change touched the subject of each step, for the run lines; a step the selection
|
|
72
94
|
# drops leaves a line of its own.
|