@rt-tools/agent-kit 0.24.0 → 0.27.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/agents/business-analyst.md +51 -50
- package/assets/agents/cargo-writer.md +54 -0
- package/assets/agents/conscience.md +37 -35
- package/assets/agents/project-manager.md +49 -48
- package/assets/agents/prose-editor.md +31 -29
- package/assets/agents/qa-engineer.md +50 -48
- package/assets/agents/rules-reviewer.md +63 -58
- package/assets/agents/skill-curator.md +83 -78
- package/assets/agents/spec-critic.md +34 -29
- package/assets/agents/spec-writer.md +35 -32
- package/assets/agents/strict-teacher.md +39 -37
- package/assets/checks/archive-age.mjs +48 -28
- package/assets/checks/archive-prune.mjs +16 -14
- package/assets/checks/board-epic-link.github.mjs +29 -0
- package/assets/checks/board-epics.github.mjs +286 -49
- package/assets/checks/board-folders.mjs +61 -0
- package/assets/checks/board-gh.github.mjs +35 -26
- package/assets/checks/board-long-work.github.mjs +29 -25
- package/assets/checks/board-paths.github.mjs +21 -16
- package/assets/checks/board-pull-state.github.mjs +168 -0
- package/assets/checks/board-runs.github.mjs +45 -43
- package/assets/checks/board-task-dirs.github.mjs +98 -0
- package/assets/checks/board-titles.github.mjs +19 -17
- package/assets/checks/board.github.mjs +133 -194
- package/assets/checks/check-archive-age.mjs +23 -19
- package/assets/checks/check-board.github.mjs +131 -263
- package/assets/checks/check-descriptions.mjs +30 -29
- package/assets/checks/check-doc-paths.mjs +91 -88
- package/assets/checks/check-dupes.mjs +84 -80
- package/assets/checks/check-file-size.mjs +74 -71
- package/assets/checks/check-glossary.mjs +47 -37
- package/assets/checks/check-hook-scope.mjs +30 -27
- package/assets/checks/check-lib-layers.mjs +22 -21
- package/assets/checks/check-profile-drift.mjs +48 -43
- package/assets/checks/check-prose-style.mjs +138 -39
- package/assets/checks/check-push-gate.mjs +53 -50
- package/assets/checks/check-reuse.mjs +50 -40
- package/assets/checks/check-schema-drift.mjs +104 -84
- package/assets/checks/check-specs.mjs +155 -134
- package/assets/checks/check-state-next.mjs +66 -52
- package/assets/checks/check-states.mjs +32 -30
- package/assets/checks/check-styles.mjs +52 -51
- package/assets/checks/check-turn-map.mjs +54 -46
- package/assets/checks/epic-table.github.mjs +268 -0
- package/assets/checks/lib-boundaries.mjs +32 -30
- package/assets/checks/lib-common.mjs +30 -29
- package/assets/checks/lib-domains.mjs +34 -34
- package/assets/checks/lib-manifests.mjs +17 -15
- package/assets/checks/lib-reexports.mjs +18 -18
- package/assets/checks/rt-kit-checks.config.mjs +187 -142
- package/assets/checks/signals.mjs +43 -39
- package/assets/checks/spec-anchors.mjs +114 -87
- package/assets/checks/spec-common.mjs +128 -84
- package/assets/checks/spec-contract.mjs +30 -30
- package/assets/checks/spec-proposed.mjs +27 -24
- package/assets/checks/spec-scenarios.mjs +51 -28
- package/assets/checks/specs-for.mjs +214 -0
- package/assets/checks/task-new.github.mjs +315 -61
- package/assets/commands/feedback.md +65 -59
- package/assets/commands/next-session.md +64 -57
- package/assets/commands/night.md +115 -0
- package/assets/commands/skill-curator.md +83 -79
- package/assets/defaults/gate-map.sh +108 -97
- package/assets/defaults/project.sh +232 -185
- package/assets/defaults/shell.sh +73 -68
- package/assets/defaults/turn-map.md +47 -44
- package/assets/docs/GLOSSARY.md +142 -65
- package/assets/hooks/browser-device-id.sh +16 -12
- package/assets/hooks/browser-guard-device-id.sh +34 -28
- package/assets/hooks/browser-guard-no-asking.sh +5 -4
- package/assets/hooks/browser-guard-no-listing.sh +12 -11
- package/assets/hooks/browser-guard-no-other-drivers.sh +48 -42
- package/assets/hooks/browser-guard-require-select.sh +34 -23
- package/assets/hooks/claim-guard.sh +62 -56
- package/assets/hooks/commit-msg.sh +14 -10
- package/assets/hooks/conscience-guard.sh +91 -45
- package/assets/hooks/constitution-index.sh +16 -16
- package/assets/hooks/deny-tail.sh +28 -26
- package/assets/hooks/dev-server-guard.sh +50 -43
- package/assets/hooks/dispatch.sh +60 -46
- package/assets/hooks/docs-guard.sh +100 -91
- package/assets/hooks/epic-over.sh +49 -0
- package/assets/hooks/epic-stop-guard.sh +108 -0
- package/assets/hooks/exam-guard.sh +105 -93
- package/assets/hooks/git-guard-delivery-conflict.sh +41 -36
- package/assets/hooks/git-guard-delivery-draft.sh +48 -38
- package/assets/hooks/git-guard-delivery-epic.sh +167 -0
- package/assets/hooks/git-guard-delivery-folder.sh +50 -43
- package/assets/hooks/git-guard-delivery-signature.sh +119 -53
- package/assets/hooks/git-guard-delivery.sh +223 -183
- package/assets/hooks/git-guard-main.sh +38 -34
- package/assets/hooks/git-guard-push-tests.sh +99 -87
- package/assets/hooks/glossary-load.sh +23 -22
- package/assets/hooks/grill-gate-ask.sh +12 -11
- package/assets/hooks/grill-gate.sh +94 -87
- package/assets/hooks/guard-note.sh +20 -19
- package/assets/hooks/handoff-entry-guard.sh +45 -25
- package/assets/hooks/handoff-write.sh +74 -67
- package/assets/hooks/hook-input.sh +67 -58
- package/assets/hooks/lint-after-edit.sh +95 -61
- package/assets/hooks/observe.sh +28 -26
- package/assets/hooks/override-write-guard.sh +23 -21
- package/assets/hooks/postmortem-guard.sh +42 -39
- package/assets/hooks/profile-check.sh +22 -20
- package/assets/hooks/proposal-guard.sh +57 -49
- package/assets/hooks/prose-style-guard.sh +49 -24
- package/assets/hooks/qa-dataid-guard.sh +83 -58
- package/assets/hooks/rerun-guard.sh +31 -30
- package/assets/hooks/reuse-first-guard.sh +108 -87
- package/assets/hooks/roles.sh +14 -14
- package/assets/hooks/rule-article.sh +39 -34
- package/assets/hooks/rule-source-guard.sh +47 -42
- package/assets/hooks/skill-gate-layers.sh +63 -57
- package/assets/hooks/skill-gate-rearm.sh +15 -8
- package/assets/hooks/skill-gate.sh +89 -81
- package/assets/hooks/skill-loaded.sh +10 -6
- package/assets/hooks/sql-guard-parse.sh +71 -66
- package/assets/hooks/sql-guard-request.sh +51 -46
- package/assets/hooks/sql-guard-target.sh +60 -51
- package/assets/hooks/sql-guard-write.sh +87 -79
- package/assets/hooks/sql-guard.sh +52 -47
- package/assets/hooks/stand-login-guard.sh +43 -37
- package/assets/hooks/task-context-load.sh +60 -55
- package/assets/hooks/task-flow-context.sh +87 -69
- package/assets/hooks/task-flow-draft-guard.sh +55 -48
- package/assets/hooks/task-flow-guard.sh +67 -64
- package/assets/hooks/turn-entry-load.sh +39 -32
- package/assets/hooks/turn-exit-guard.sh +260 -204
- package/assets/hooks/turn-exit-patterns.sh +63 -0
- package/assets/hooks/utf8.sh +14 -11
- package/assets/hooks/waiting-turn-guard.sh +104 -94
- package/assets/hooks/window-fill-guard.sh +70 -62
- package/assets/hooks/work-start-guard.sh +52 -49
- package/assets/hooks/write-targets.sh +99 -44
- package/assets/laws/autonomous-work.md +29 -27
- package/assets/laws/code-structure.md +31 -30
- package/assets/laws/delivery.md +170 -137
- package/assets/laws/entity-editing.md +52 -50
- package/assets/laws/entity-models.md +14 -13
- package/assets/laws/frontend-application.md +39 -38
- package/assets/laws/lib-imports.md +27 -27
- package/assets/laws/lists.md +31 -29
- package/assets/laws/navigation.md +37 -37
- package/assets/laws/observability.md +41 -40
- package/assets/laws/project-documentation.md +106 -99
- package/assets/laws/reuse-first.md +31 -29
- package/assets/laws/shared-code.md +27 -27
- package/assets/laws/verifiability.md +131 -124
- package/assets/laws/work-conduct.md +250 -244
- package/assets/patterns/admin-lists-screen.md +72 -69
- package/assets/patterns/admin-nav-item.md +51 -46
- package/assets/patterns/angular-patterns-state.md +32 -31
- package/assets/patterns/api-layer-pair.md +33 -31
- package/assets/patterns/autonomous-work-run.md +50 -49
- package/assets/patterns/browser-verification-measure.md +124 -88
- package/assets/patterns/browser-verification-stand.md +169 -157
- package/assets/patterns/component-structure-new.md +51 -42
- package/assets/patterns/dependencies-upgrade.md +55 -39
- package/assets/patterns/doc-style-human.md +55 -37
- package/assets/patterns/doc-style-sweep.md +82 -79
- package/assets/patterns/doc-style-trace.md +87 -81
- package/assets/patterns/doc-style-write.md +130 -122
- package/assets/patterns/entity-aside.md +77 -63
- package/assets/patterns/entity-models-new.md +37 -37
- package/assets/patterns/entity-store.md +33 -33
- package/assets/patterns/git-workflow-commit.azure.md +94 -87
- package/assets/patterns/git-workflow-commit.github.md +160 -142
- package/assets/patterns/git-workflow-commit.gitlab.md +96 -90
- package/assets/patterns/git-workflow-docker.md +165 -147
- package/assets/patterns/git-workflow-freshness.md +45 -45
- package/assets/patterns/git-workflow-merge.md +102 -94
- package/assets/patterns/git-workflow-migration.md +54 -52
- package/assets/patterns/git-workflow-pr-ready.md +57 -56
- package/assets/patterns/git-workflow-pr.azure.md +127 -122
- package/assets/patterns/git-workflow-pr.github.md +186 -177
- package/assets/patterns/git-workflow-pr.gitlab.md +139 -132
- package/assets/patterns/git-workflow-restart.md +35 -31
- package/assets/patterns/git-workflow-secrets.md +80 -73
- package/assets/patterns/git-workflow-stack.md +136 -107
- package/assets/patterns/lib-layers-move.md +62 -53
- package/assets/patterns/lib-layers-new.md +59 -45
- package/assets/patterns/observability-record.md +72 -67
- package/assets/patterns/platform-access-di.md +31 -29
- package/assets/patterns/reuse-first-extend.md +66 -61
- package/assets/patterns/shared-code-new.md +39 -38
- package/assets/patterns/spec-driven-domain.md +161 -151
- package/assets/patterns/spec-driven-rule.md +179 -168
- package/assets/patterns/spec-driven-sweep.md +41 -39
- package/assets/patterns/status-report-table.github.md +48 -36
- package/assets/patterns/styling-bem-component.md +42 -42
- package/assets/patterns/styling-bem-layout.md +39 -34
- package/assets/patterns/styling-bem-sheet.md +59 -58
- package/assets/patterns/task-flow-archive.md +222 -215
- package/assets/patterns/task-flow-close.md +234 -203
- package/assets/patterns/task-flow-handoff.md +154 -145
- package/assets/patterns/task-flow-resume.md +138 -133
- package/assets/patterns/task-flow-start.md +228 -202
- package/assets/patterns/testing-e2e.md +102 -101
- package/assets/patterns/testing-unit.md +77 -70
- package/assets/patterns/ts-procedure.md +32 -29
- package/assets/patterns/turn-entry-map.md +50 -48
- package/assets/pitfalls/agent-kit.md +172 -142
- package/assets/pitfalls/doc-style.md +96 -91
- package/assets/pitfalls/git-workflow.azure.md +49 -46
- package/assets/pitfalls/git-workflow.github.md +270 -234
- package/assets/pitfalls/git-workflow.gitlab.md +49 -45
- package/assets/pitfalls/spec-driven.md +73 -71
- package/assets/pitfalls/styling-bem.md +46 -40
- package/assets/pitfalls/task-flow.md +262 -246
- package/assets/pitfalls/testing.md +99 -92
- package/assets/pitfalls/turn-conduct.md +96 -81
- package/assets/rules/angular-patterns.md +81 -80
- package/assets/rules/api-layer.md +77 -74
- package/assets/rules/autonomous-work.md +87 -74
- package/assets/rules/browser-verification.md +223 -214
- package/assets/rules/component-structure.md +72 -69
- package/assets/rules/dependencies.md +74 -67
- package/assets/rules/deploy-flow.azure.md +118 -108
- package/assets/rules/deploy-flow.github.md +145 -135
- package/assets/rules/deploy-flow.gitlab.md +120 -110
- package/assets/rules/doc-style.md +201 -173
- package/assets/rules/entity-conventions.needs-admin.md +81 -79
- package/assets/rules/entity-models.md +73 -70
- package/assets/rules/git-workflow.azure.md +224 -228
- package/assets/rules/git-workflow.github.md +268 -239
- package/assets/rules/git-workflow.gitlab.md +218 -217
- package/assets/rules/lib-layers.md +85 -86
- package/assets/rules/lists.md +101 -97
- package/assets/rules/navigation.md +78 -78
- package/assets/rules/observability.needs-app.md +165 -153
- package/assets/rules/platform-access.md +76 -75
- package/assets/rules/reuse-first.md +153 -143
- package/assets/rules/shared-code.md +82 -79
- package/assets/rules/spec-driven.md +279 -260
- package/assets/rules/status-report.md +62 -58
- package/assets/rules/styling-bem.md +81 -77
- package/assets/rules/task-flow.md +303 -270
- package/assets/rules/testing.md +224 -209
- package/assets/rules/turn-conduct.md +262 -258
- package/assets/rules/turn-entry.md +92 -87
- package/assets/rules/typescript-conventions.md +94 -88
- package/assets/samples/specs/_template/spec.md +47 -47
- package/assets/samples/tasks/_template/grill.md +20 -20
- package/assets/samples/tasks/_template/plan.md +32 -30
- package/assets/samples/tasks/_template/progress.md +16 -16
- package/assets/skills/agent-kit-extend.md +129 -113
- package/assets/skills/agent-kit.md +259 -233
- package/assets/skills/write-a-skill.md +76 -71
- package/assets/templates/findings.md +19 -19
- package/assets/templates/gate-map.sh +16 -14
- package/assets/templates/implementation.md +28 -27
- package/assets/templates/pattern.md +17 -17
- package/assets/templates/pitfalls.md +6 -6
- package/assets/templates/postmortem.md +24 -23
- package/assets/templates/project.sh +24 -24
- package/assets/templates/proposal.md +62 -60
- package/assets/templates/rule.md +38 -38
- package/assets/workflows/feature.js +46 -46
- package/assets/workflows/plan.js +54 -54
- package/bin/agent-kit.d.ts.map +1 -1
- package/bin/agent-kit.js +8 -1
- package/bin/agent-kit.js.map +1 -1
- package/lib/cargo-prose.d.ts +41 -0
- package/lib/cargo-prose.d.ts.map +1 -0
- package/lib/cargo-prose.js +88 -0
- package/lib/cargo-prose.js.map +1 -0
- package/lib/cargo.d.ts +12 -1
- package/lib/cargo.d.ts.map +1 -1
- package/lib/cargo.js +8 -2
- package/lib/cargo.js.map +1 -1
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.d.ts.map +1 -1
- package/lib/catalog.js +4 -3
- package/lib/catalog.js.map +1 -1
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +5 -2
- package/lib/commands.js.map +1 -1
- package/lib/companion.js +3 -2
- package/lib/companion.js.map +1 -1
- package/lib/enroll.d.ts +7 -1
- package/lib/enroll.d.ts.map +1 -1
- package/lib/enroll.js +12 -3
- package/lib/enroll.js.map +1 -1
- package/lib/fate.d.ts +29 -0
- package/lib/fate.d.ts.map +1 -0
- package/lib/fate.js +147 -0
- package/lib/fate.js.map +1 -0
- package/lib/override-marks.d.ts +7 -0
- package/lib/override-marks.d.ts.map +1 -1
- package/lib/override-marks.js +14 -0
- package/lib/override-marks.js.map +1 -1
- package/lib/plan.d.ts +11 -0
- package/lib/plan.d.ts.map +1 -1
- package/lib/plan.js +10 -1
- package/lib/plan.js.map +1 -1
- package/lib/ship.d.ts +29 -9
- package/lib/ship.d.ts.map +1 -1
- package/lib/ship.js +44 -2
- package/lib/ship.js.map +1 -1
- package/lib/shipment.d.ts.map +1 -1
- package/lib/shipment.fixture.d.ts +8 -1
- package/lib/shipment.fixture.d.ts.map +1 -1
- package/lib/shipment.fixture.js +9 -0
- package/lib/shipment.fixture.js.map +1 -1
- package/lib/shipment.js +38 -5
- package/lib/shipment.js.map +1 -1
- package/lib/sync.d.ts.map +1 -1
- package/lib/sync.js +45 -11
- package/lib/sync.js.map +1 -1
- package/package.json +1 -1
- package/rt-tools-agent-kit-0.27.0.tgz +0 -0
- package/rt-tools-agent-kit-0.24.0.tgz +0 -0
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* The link between a task and an epic. Lives in a file of its own: the work queue audit stands at
|
|
3
|
+
* the length limit even without it, and these two checks are read separately.
|
|
4
4
|
*/
|
|
5
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { declaredEpicOf } from './board-epic-link.mjs';
|
|
9
|
+
import { ghJson, numberFromTitle, OfflineError, OWNER, REPO, TASK_KEY } from './board.mjs';
|
|
9
10
|
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* The label of an epic card. Not named — the link is not judged: there would be nothing left to
|
|
14
|
+
* tell an epic card from an ordinary task by.
|
|
14
15
|
*/
|
|
16
|
+
// Чтение объявления переехало в свой модуль, а звали его отсюда: имя оставлено на прежнем месте,
|
|
17
|
+
// чтобы соседям не пришлось знать о переезде.
|
|
18
|
+
export { declaredEpicOf };
|
|
19
|
+
|
|
15
20
|
const EPIC_LABEL = CONFIG.board?.epicLabel ?? '';
|
|
16
21
|
|
|
22
|
+
/** The labels of the cargo of the trees: those records are not tasks and are not judged as such. */
|
|
23
|
+
const CARGO_LABELS = CONFIG.board?.cargoLabels ?? [];
|
|
24
|
+
|
|
17
25
|
/**
|
|
18
|
-
*
|
|
26
|
+
* The rows of the epic makeup — those standing in the table with the task column.
|
|
19
27
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
28
|
+
* The epic plan holds other tables too: the sources of findings, the makeup of families, the count
|
|
29
|
+
* of items. Numbers taken from the whole text, and even from all the tables, would make an epic
|
|
30
|
+
* task out of everything it mentioned — the previous epic its findings grew from, a review, a task
|
|
31
|
+
* of a neighbouring tree.
|
|
23
32
|
*/
|
|
24
|
-
function planRows(plan) {
|
|
33
|
+
export function planRows(plan) {
|
|
25
34
|
const rows = [];
|
|
26
35
|
let inside = false;
|
|
27
36
|
for (const line of plan.split('\n')) {
|
|
@@ -31,9 +40,11 @@ function planRows(plan) {
|
|
|
31
40
|
continue;
|
|
32
41
|
}
|
|
33
42
|
if (!inside) {
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
43
|
+
// The column has two names, English and the owner's: a tree translates its plans one at
|
|
44
|
+
// a time, and one name would take the untranslated epics out of the check silently. A
|
|
45
|
+
// word boundary is no good here either: `\b` knows only Latin letters and never matches
|
|
46
|
+
// Cyrillic — the check would stay silent on any plan.
|
|
47
|
+
inside = /\|[^|]*(?:Task|Задача)/.test(line);
|
|
37
48
|
continue;
|
|
38
49
|
}
|
|
39
50
|
rows.push(line);
|
|
@@ -42,27 +53,61 @@ function planRows(plan) {
|
|
|
42
53
|
}
|
|
43
54
|
|
|
44
55
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
* The plan of an epic named by its own card, and the reason there is none.
|
|
57
|
+
*
|
|
58
|
+
* The plan is the document that carries the makeup, not the first path in the body. A card names
|
|
59
|
+
* its decision next to its plan, and the decision has no table of tasks: read as the plan, it made
|
|
60
|
+
* the makeup empty and every open task of the epic read as not belonging to it — fourteen false
|
|
61
|
+
* lines at once, and the true ones drowned among them.
|
|
62
|
+
*
|
|
63
|
+
* A path counts as a spelling with a directory: a bare file name occurs in the body in prose and
|
|
64
|
+
* would lead the reader to the very first mention.
|
|
65
|
+
*/
|
|
66
|
+
export function planPathOf(body) {
|
|
67
|
+
const named = [...String(body ?? '').matchAll(/(?:^|[\s(`])([\w.-]+(?:\/[\w.-]+)+\.md)/g)].map((match) => match[1]);
|
|
68
|
+
if (named.length === 0) {
|
|
69
|
+
return { path: null, why: 'the epic card names no path to the plan — there is nowhere to read what the epic holds' };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const onDisk = named.filter((path) => existsSync(join(ROOT, path)));
|
|
73
|
+
if (onDisk.length === 0) {
|
|
74
|
+
return { path: null, why: `the epic plan «${named[0]}» is not on disk — the card points into emptiness` };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const carrying = onDisk.find((path) => planRows(readFileSync(join(ROOT, path), 'utf8')) !== '') ?? null;
|
|
78
|
+
if (carrying === null) {
|
|
79
|
+
return {
|
|
80
|
+
path: null,
|
|
81
|
+
why: `none of the documents the card names carries the makeup of the epic — «${onDisk.join('», «')}». The makeup is a table with a task column`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { path: carrying, why: '' };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The link between a task and an epic, read in both directions.
|
|
90
|
+
*
|
|
91
|
+
* A task created under an epic names it in its body, and the epic plan names the task from its own
|
|
92
|
+
* side. A one-sided binding looks whole exactly as a two-sided one does: the reader comes now from
|
|
93
|
+
* the epic plan, now from its card, and the second side exists only for one of them. It held by
|
|
94
|
+
* imitation — while a body was written from the sample of a neighbouring task of the same epic, the
|
|
95
|
+
* line travelled with the shape, and a task created in the middle of work out of a finding was not
|
|
96
|
+
* written from a sample.
|
|
97
|
+
*
|
|
98
|
+
* The path to the plan is taken from the body of the epic card: it has to name it anyway, and a
|
|
99
|
+
* directory setting would create a second source of truth. A path counts as a spelling with a
|
|
100
|
+
* directory — a bare file name in the body occurs in prose and would lead the check to the very
|
|
101
|
+
* first mention. A plan absent from disk is a discrepancy of its own: the card points into
|
|
102
|
+
* emptiness.
|
|
103
|
+
*
|
|
104
|
+
* Only what is open is judged, as in the rest of the audit: a closed task of an epic is history,
|
|
105
|
+
* and there is nothing to close a line about it with.
|
|
61
106
|
*/
|
|
62
107
|
export function checkEpicLinks(open, report) {
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
108
|
+
// The label is not named — there is nothing to tell an epic card from an ordinary task by, and
|
|
109
|
+
// the check stays silent. Silent exactly so, not "there are no epics": a tree without epics and
|
|
110
|
+
// a tree that has not named the label are indistinguishable here.
|
|
66
111
|
if (!EPIC_LABEL) {
|
|
67
112
|
return;
|
|
68
113
|
}
|
|
@@ -70,24 +115,20 @@ export function checkEpicLinks(open, report) {
|
|
|
70
115
|
const byNumber = new Map(open.map((issue) => [issue.number, issue]));
|
|
71
116
|
const epics = open.filter((issue) => (issue.labels ?? []).some((label) => label.name === EPIC_LABEL));
|
|
72
117
|
const listedBy = new Map();
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
118
|
+
// Epics whose makeup could not be read. Their tasks are not judged from the other side: an
|
|
119
|
+
// unread plan has already been reported by a line of its own, and four lines "the task is not in
|
|
120
|
+
// the plan" beside it speak of the same miss again, naming other tasks as guilty.
|
|
76
121
|
const unreadable = new Set();
|
|
77
122
|
|
|
78
123
|
for (const epic of epics) {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
report(`#${epic.number}:
|
|
82
|
-
unreadable.add(epic.number);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (!existsSync(join(ROOT, planPath))) {
|
|
86
|
-
report(`#${epic.number}: замысла эпика «${planPath}» нет на диске — карточка ссылается в пустоту`);
|
|
124
|
+
const found = planPathOf(epic.body);
|
|
125
|
+
if (found.path === null) {
|
|
126
|
+
report(`#${epic.number}: ${found.why}`);
|
|
87
127
|
unreadable.add(epic.number);
|
|
88
128
|
continue;
|
|
89
129
|
}
|
|
90
130
|
|
|
131
|
+
const planPath = found.path;
|
|
91
132
|
const plan = readFileSync(join(ROOT, planPath), 'utf8');
|
|
92
133
|
const mentions = planRows(plan).matchAll(new RegExp(`(?:#|${TASK_KEY}-)(\\d+)`, 'g'));
|
|
93
134
|
const numbers = new Set([...mentions].map((match) => Number(match[1])));
|
|
@@ -97,27 +138,223 @@ export function checkEpicLinks(open, report) {
|
|
|
97
138
|
}
|
|
98
139
|
listedBy.set(number, epic.number);
|
|
99
140
|
const body = String(byNumber.get(number).body ?? '');
|
|
100
|
-
if (!
|
|
141
|
+
if (!declaredEpicOf(body, epic.number)) {
|
|
101
142
|
report(
|
|
102
|
-
`#${number}:
|
|
143
|
+
`#${number}: the plan of the epic #${epic.number} names the task, and its body does not name the epic. Add the line «Задача эпика #${epic.number}, замысел — ${planPath}»`
|
|
103
144
|
);
|
|
104
145
|
}
|
|
105
146
|
}
|
|
106
147
|
}
|
|
107
148
|
|
|
108
|
-
//
|
|
109
|
-
//
|
|
149
|
+
// The other side: the body named the epic, and the epic plan does not know this task. It reads
|
|
150
|
+
// as a task under an epic, but "take the next one" will never hand it out.
|
|
110
151
|
const epicNumbers = new Set(epics.map((issue) => issue.number));
|
|
111
152
|
for (const issue of open) {
|
|
112
153
|
if (epicNumbers.has(issue.number)) {
|
|
113
154
|
continue;
|
|
114
155
|
}
|
|
115
|
-
const named = String(issue.body ?? '')
|
|
156
|
+
const named = declaredEpicOf(String(issue.body ?? ''));
|
|
116
157
|
if (named === undefined || !epicNumbers.has(Number(named)) || unreadable.has(Number(named))) {
|
|
117
158
|
continue;
|
|
118
159
|
}
|
|
119
160
|
if (listedBy.get(issue.number) !== Number(named)) {
|
|
120
|
-
report(`#${issue.number}:
|
|
161
|
+
report(`#${issue.number}: the body names the epic #${named}, and its plan does not carry the task — «take the next one» will not give it out`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
checkTasksOutsideEpics(open, epicNumbers, report);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The word by which a task declares itself as work outside an epic. It is written by the creating
|
|
170
|
+
* command from the word of the owner, and the audit reads exactly that shape: work outside an epic
|
|
171
|
+
* is lawful, and only the owner names it as such.
|
|
172
|
+
*/
|
|
173
|
+
const OUTSIDE_EPIC = /работа\s+вне\s+эпика/i;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A task belonging to no epic and carrying no word of the owner about work outside one.
|
|
177
|
+
*
|
|
178
|
+
* The delivery guard refuses such a task at the creating command, and only there: a card made
|
|
179
|
+
* through the web goes past every guard, and one created before this order came in has neither
|
|
180
|
+
* line. By the queue it reads as ordinary work, and that nothing stands behind it shows nowhere —
|
|
181
|
+
* the audit is the only reader that comes for exactly this.
|
|
182
|
+
*
|
|
183
|
+
* The cargo of the trees is not judged: those records are not tasks at all — they have no title
|
|
184
|
+
* with a number, no executor and no place on the board, and never will.
|
|
185
|
+
*/
|
|
186
|
+
function checkTasksOutsideEpics(open, epicNumbers, report) {
|
|
187
|
+
for (const issue of open) {
|
|
188
|
+
if (epicNumbers.has(issue.number)) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if ((issue.labels ?? []).some((label) => CARGO_LABELS.includes(label.name))) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const body = String(issue.body ?? '');
|
|
195
|
+
if (declaredEpicOf(body) !== undefined || OUTSIDE_EPIC.test(body)) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
report(
|
|
199
|
+
`#${issue.number}: the task names no epic, and no word of the owner about work outside one. Add the line «Задача эпика #<номер>, замысел — <путь>» or «Работа вне эпика — <слово владельца>»`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The tasks of an epic linked to its card as sub-issues.
|
|
206
|
+
*
|
|
207
|
+
* The plan of the epic holds the makeup, and the body of a task names the epic — but both are
|
|
208
|
+
* text, and the board reads neither. On the board a task of an epic looks exactly like a task
|
|
209
|
+
* outside one: the epic card shows no list of its tasks, no count of the done ones, and whoever
|
|
210
|
+
* looks at the board assembles both by hand from the list of open cards.
|
|
211
|
+
*
|
|
212
|
+
* A sub-issue is the hosting's own link between two cards, and it fills all three at once: the
|
|
213
|
+
* epic card gets the list, the task card gets the line about its parent, and the board card gets
|
|
214
|
+
* the "done of total" bar.
|
|
215
|
+
*
|
|
216
|
+
* The list of the epic's tasks is taken from its plan, as everywhere in this audit — the plan is
|
|
217
|
+
* the makeup. Closed tasks are judged too, unlike the rest of the audit: the bar counts them, and
|
|
218
|
+
* an epic whose closed tasks are not linked shows a share lower than the true one.
|
|
219
|
+
*
|
|
220
|
+
* Arguments: the open cards, the reporting function, the call options of the hosting client.
|
|
221
|
+
*/
|
|
222
|
+
export function checkEpicSubIssues(open, report, options) {
|
|
223
|
+
if (!EPIC_LABEL || !OWNER || !REPO) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const epics = open.filter((issue) => (issue.labels ?? []).some((label) => label.name === EPIC_LABEL));
|
|
228
|
+
for (const epic of epics) {
|
|
229
|
+
const found = planPathOf(epic.body);
|
|
230
|
+
if (found.path === null) {
|
|
231
|
+
// The unread plan has already been reported by a line of its own in the link check.
|
|
232
|
+
continue;
|
|
121
233
|
}
|
|
234
|
+
|
|
235
|
+
const rows = planRows(readFileSync(join(ROOT, found.path), 'utf8'));
|
|
236
|
+
const named = new Set([...rows.matchAll(new RegExp(`(?:#|${TASK_KEY}-)(\\d+)`, 'g'))].map((match) => Number(match[1])));
|
|
237
|
+
named.delete(epic.number);
|
|
238
|
+
if (named.size === 0) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
let linked;
|
|
243
|
+
try {
|
|
244
|
+
linked = new Set(ghJson(['api', `repos/${OWNER}/${REPO}/issues/${epic.number}/sub_issues`, '--jq', '[.[].number]'], options));
|
|
245
|
+
} catch (error) {
|
|
246
|
+
if (error instanceof OfflineError) {
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
// The hosting has no such link at all, or the call is refused: this is not a
|
|
250
|
+
// discrepancy of the tree, and a line about it would repeat every run.
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const missing = [...named].filter((number) => !linked.has(number)).sort((left, right) => left - right);
|
|
255
|
+
if (missing.length > 0) {
|
|
256
|
+
report(
|
|
257
|
+
`#${epic.number}: the plan names tasks that are not sub-issues of the epic card — ${missing.map((number) => `#${number}`).join(', ')}. On the board the epic then shows neither its makeup nor how much of it is done`
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The base of an open request about a task of an epic.
|
|
265
|
+
*
|
|
266
|
+
* The delivery guard judges this at the opening, and only there: a request opened by a person from
|
|
267
|
+
* the hosting page goes past it, and one opened before this order came in carries the base it was
|
|
268
|
+
* opened with. In the list of requests the base is not shown at all — the reader sees the title and
|
|
269
|
+
* the branch, and a request going into the main branch past its epic looks like every other.
|
|
270
|
+
*
|
|
271
|
+
* The branch of the epic is recognised by its number in the name, not by a list of refs: the audit
|
|
272
|
+
* reads the queue and does not go to the tree, and a base carrying the number of the epic is its
|
|
273
|
+
* branch — a task and its epic never share a number.
|
|
274
|
+
*/
|
|
275
|
+
export function checkEpicPullBase(open, pulls, report) {
|
|
276
|
+
if (!EPIC_LABEL) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const epicOf = new Map();
|
|
281
|
+
for (const issue of open) {
|
|
282
|
+
const named = declaredEpicOf(String(issue.body ?? ''));
|
|
283
|
+
if (named !== undefined) {
|
|
284
|
+
epicOf.set(issue.number, Number(named));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
for (const pull of pulls) {
|
|
289
|
+
const number = numberFromTitle(pull.title);
|
|
290
|
+
if (number === null || !epicOf.has(number)) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const epic = epicOf.get(number);
|
|
294
|
+
const base = String(pull.baseRefName ?? '');
|
|
295
|
+
if (base.startsWith(`${TASK_KEY}-${epic}-`)) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
report(
|
|
299
|
+
`PR #${pull.number}: the task #${number} belongs to the epic #${epic}, and the base of the request is «${base}». A request past the epic takes the task out of it: the epic is handed in without it`
|
|
300
|
+
);
|
|
122
301
|
}
|
|
123
302
|
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Two states of an epic that nothing sees.
|
|
306
|
+
*
|
|
307
|
+
* **An epic without a branch.** Its branch is taken before the first of its tasks, and one that was
|
|
308
|
+
* not taken leaves every task standing on the main branch: the epic is then merged piece by piece,
|
|
309
|
+
* and there is nothing left to hand in whole. The card says nothing about a branch, and the list of
|
|
310
|
+
* requests shows none while no request is open from it.
|
|
311
|
+
*
|
|
312
|
+
* **An epic whose tasks are over.** Its request into the main branch opens when the last folder is
|
|
313
|
+
* taken apart, and until it opens the work of the whole epic lies outside the main branch while
|
|
314
|
+
* looking finished: every task is closed, the board is empty, and only the epic card stays open.
|
|
315
|
+
*
|
|
316
|
+
* Both are read by the same two things: the open tasks of the epic and the open requests. The
|
|
317
|
+
* branch of the epic is recognised by its number in the name — the audit reads the queue and does
|
|
318
|
+
* not go to the tree.
|
|
319
|
+
*/
|
|
320
|
+
export function checkEpicState(open, pulls, report) {
|
|
321
|
+
if (!EPIC_LABEL) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const epics = open.filter((issue) => (issue.labels ?? []).some((label) => label.name === EPIC_LABEL));
|
|
326
|
+
if (epics.length === 0) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const claimed = new Map();
|
|
331
|
+
for (const issue of open) {
|
|
332
|
+
const named = declaredEpicOf(String(issue.body ?? ''));
|
|
333
|
+
if (named !== undefined) {
|
|
334
|
+
claimed.set(issue.number, Number(named));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
for (const epic of epics) {
|
|
339
|
+
const prefix = `${TASK_KEY}-${epic.number}-`;
|
|
340
|
+
const fromEpic = pulls.filter((pull) => String(pull.headRefName ?? '').startsWith(prefix));
|
|
341
|
+
const intoEpic = pulls.filter((pull) => String(pull.baseRefName ?? '').startsWith(prefix));
|
|
342
|
+
const tasksLeft = [...claimed.entries()].filter(([, number]) => number === epic.number);
|
|
343
|
+
|
|
344
|
+
// A branch of the epic shows in a request either way: one from it, or one into it. Neither
|
|
345
|
+
// — and there is nothing in the queue to say the branch exists at all.
|
|
346
|
+
if (fromEpic.length === 0 && intoEpic.length === 0) {
|
|
347
|
+
report(
|
|
348
|
+
`#${epic.number}: the epic has no branch in the requests — neither one from it nor one into it. The branch of an epic is taken before its first task, and without it every task stands on the main branch`
|
|
349
|
+
);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (tasksLeft.length === 0 && fromEpic.length === 0) {
|
|
354
|
+
report(
|
|
355
|
+
`#${epic.number}: the tasks of the epic are over, and no request from its branch is open. Until it opens, the work of the whole epic lies outside the main branch while looking finished`
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Task branches that have not carried their folder in by a single commit — a part of the work queue
|
|
4
|
+
* audit.
|
|
5
|
+
*
|
|
6
|
+
* Moved into a file of its own because the audit itself has grown to the length limit: it has many
|
|
7
|
+
* subjects, and this one stands apart — it is the only one that reads the local repository and does
|
|
8
|
+
* without the network and without the hosting.
|
|
9
|
+
*/
|
|
10
|
+
import { execFileSync } from 'node:child_process';
|
|
11
|
+
|
|
12
|
+
import { TASK_KEY } from './board.mjs';
|
|
13
|
+
import { CONFIG, ROOT } from './rt-kit-checks.config.mjs';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The plan guard asks the folder from the disk, so an uncommitted one lets edits through for the
|
|
17
|
+
* whole of the work, and the refusal comes at the very end: the turn exit guard takes the sign of
|
|
18
|
+
* handed-over work from the branch history, and there is no folder there. At that minute there is
|
|
19
|
+
* nothing left to fix with — the folder was taken apart by one's own hands, and one assembled anew
|
|
20
|
+
* gives two extra commits in a ready PR.
|
|
21
|
+
*
|
|
22
|
+
* The branch history is judged, not its tip: the folder is taken apart by the last commit before
|
|
23
|
+
* the PR is opened, and the tip of finished work lawfully carries no folder.
|
|
24
|
+
*
|
|
25
|
+
* Read from the local repository, without the network: branches of other machines are not visible
|
|
26
|
+
* from here, and this check says nothing about them.
|
|
27
|
+
*/
|
|
28
|
+
export function checkBranchFolders(report, mainBranch) {
|
|
29
|
+
const git = (args) => execFileSync('git', args, { cwd: ROOT, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
30
|
+
|
|
31
|
+
let branches;
|
|
32
|
+
try {
|
|
33
|
+
branches = git(['branch', '--format=%(refname:short)', '--list', `${TASK_KEY}-*`]).split('\n');
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A branch without a task number is lawful and lives locally — for a trial and a grill; it is
|
|
39
|
+
// due no folder, and demanding one would mean refusing work that will not go into the main
|
|
40
|
+
// branch.
|
|
41
|
+
const numbered = new RegExp(`^${TASK_KEY}-\\d+-`);
|
|
42
|
+
|
|
43
|
+
for (const branch of branches.map((one) => one.trim()).filter((one) => numbered.test(one))) {
|
|
44
|
+
try {
|
|
45
|
+
// The branch contribution is empty — nothing to judge: a folder is put in by the very
|
|
46
|
+
// first commit, not by creating it.
|
|
47
|
+
if (!git(['log', '--format=%h', '-1', `${mainBranch}..${branch}`]).trim()) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (git(['log', '--format=%h', '-1', branch, '--', `${CONFIG.tasksDir}/${branch}`]).trim()) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
} catch {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
report(
|
|
57
|
+
`${branch}: the task folder never travelled into the branch — commit ${CONFIG.tasksDir}/${branch}/, ` +
|
|
58
|
+
`otherwise the refusal arrives at the exit of a turn, when there is nothing left to fix`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The call to the hosting client: how it is found, what it is signed with and what counts as a
|
|
4
|
+
* temporary refusal.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Separated from the work with the work queue because the subject here is another one — not a task
|
|
7
|
+
* and not a column, but the call itself: where to get the executable, which token to sign it with,
|
|
8
|
+
* what to read as "there is no network" and what to repeat. Together with the queue this outgrew
|
|
9
|
+
* the file length limit.
|
|
8
10
|
*/
|
|
9
11
|
import { execFileSync } from 'node:child_process';
|
|
10
12
|
import { existsSync, readFileSync } from 'node:fs';
|
|
@@ -16,8 +18,8 @@ const BOARD = CONFIG.board ?? {};
|
|
|
16
18
|
const BOT_TOKEN_FILE = BOARD.tokenPath ? BOARD.tokenPath.replace(/^~/, homedir()) : '';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
|
-
* `gh`
|
|
20
|
-
*
|
|
21
|
+
* The owner's `gh` is substituted by a password manager wrapper, and a call by name goes into it.
|
|
22
|
+
* So the real executable is tried first, and only then the name from PATH.
|
|
21
23
|
*/
|
|
22
24
|
function ghBinary() {
|
|
23
25
|
if (process.env.GH_BIN) {
|
|
@@ -28,9 +30,14 @@ function ghBinary() {
|
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
33
|
+
* The machine account token lies outside the repository and does not get into the output. Its
|
|
34
|
+
* absence is not a refusal: a tree that has not named a token in `board.tokenPath` works with the
|
|
35
|
+
* queue under the account the hosting client is signed in as.
|
|
36
|
+
*
|
|
37
|
+
* The token is supplied by reading a task, moving a column and listing one's own PRs in dispute.
|
|
38
|
+
* Reading a PR goes without it deliberately: the review fields need rights to the organisation
|
|
39
|
+
* accounts, which the machine account was not given, and a request with the token is refused
|
|
40
|
+
* entirely. Whose eyes the answer was taken by is told by the `viewer` field in it.
|
|
34
41
|
*/
|
|
35
42
|
export function botToken() {
|
|
36
43
|
if (!existsSync(BOT_TOKEN_FILE)) {
|
|
@@ -43,9 +50,9 @@ export function botToken() {
|
|
|
43
50
|
export class OfflineError extends Error {}
|
|
44
51
|
|
|
45
52
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
53
|
+
* A network refusal differs from a refusal on the merits only by its text: `gh` answers
|
|
54
|
+
* both with a non-zero code. What lands here is what leaves nothing to check by — not
|
|
55
|
+
* what was checked and turned out wrong.
|
|
49
56
|
*/
|
|
50
57
|
function isOffline(stderr) {
|
|
51
58
|
return /dial tcp|no such host|network is unreachable|timeout|TLS handshake|connection refused|Bad credentials|authentication|not logged/i.test(
|
|
@@ -54,25 +61,26 @@ function isOffline(stderr) {
|
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
/**
|
|
57
|
-
*
|
|
64
|
+
* A refusal that passes by itself: the hosting answered but could not.
|
|
58
65
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
66
|
+
* It differs from a refusal on the merits in that a repeat lifts it: the five-hundred codes, the
|
|
67
|
+
* gateway and its timeout. A refusal by right, by a non-existent record and by an unknown column do
|
|
68
|
+
* not land here — they will not pass on the third try either, and would make one wait.
|
|
62
69
|
*/
|
|
63
70
|
function isUnavailable(stderr) {
|
|
64
71
|
return /HTTP 50[0234]\b|Bad Gateway|Service Unavailable|Gateway Time-?out|Server Error/i.test(stderr);
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
/**
|
|
74
|
+
/** How many times to try a call refused by the hosting being unavailable. */
|
|
68
75
|
const TRIES = 3;
|
|
69
76
|
|
|
70
77
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
78
|
+
* The pause before the next attempt, twice as long as the previous one. Synchronous: the hosting
|
|
79
|
+
* call here is synchronous too, and moving it into a promise would mean moving everyone who calls
|
|
80
|
+
* it along with it.
|
|
73
81
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
82
|
+
* The number is taken from the environment for the sake of the tests: they need no pause of their
|
|
83
|
+
* own, and are not obliged to wait three seconds for every scenario.
|
|
76
84
|
*/
|
|
77
85
|
const PAUSE_MS = Number(process.env.RT_GH_RETRY_MS ?? 1000) || 0;
|
|
78
86
|
|
|
@@ -95,17 +103,18 @@ export function gh(args, { token } = {}) {
|
|
|
95
103
|
} catch (error) {
|
|
96
104
|
const stderr = String(error.stderr ?? error.message ?? '');
|
|
97
105
|
if (error.code === 'ENOENT' || isOffline(stderr)) {
|
|
98
|
-
throw new OfflineError(stderr.trim() || 'gh
|
|
106
|
+
throw new OfflineError(stderr.trim() || 'gh is unavailable');
|
|
99
107
|
}
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
108
|
+
// The rule demands moving the column by the same motion as the work, and the hosting
|
|
109
|
+
// answered with unavailability for an hour straight: without a repeat the executor
|
|
110
|
+
// either turns the call by hand or leaves the column behind — and the audit finds that
|
|
111
|
+
// only after the PR is opened.
|
|
103
112
|
if (isUnavailable(stderr) && attempt < TRIES) {
|
|
104
113
|
pause(waited);
|
|
105
114
|
waited *= 2;
|
|
106
115
|
continue;
|
|
107
116
|
}
|
|
108
|
-
const failure = new Error(stderr.trim() || `gh ${args[0]}
|
|
117
|
+
const failure = new Error(stderr.trim() || `gh ${args[0]} finished with an error`);
|
|
109
118
|
failure.stderr = stderr;
|
|
110
119
|
throw failure;
|
|
111
120
|
}
|