@futurelastic/colab-handbook 0.0.0-bootstrap.0 → 1.12.0-rc.8
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/LICENSE +21 -0
- package/README.md +309 -3
- package/README.vi.md +279 -0
- package/audit/audit.mjs +3035 -0
- package/package.json +26 -5
- package/templates/README.md +257 -0
- package/templates/adr-README.md +57 -0
- package/templates/branch-name.yml +51 -0
- package/templates/ci-laravel.yml +540 -0
- package/templates/ci-node.yml +291 -0
- package/templates/ci-python.yml +281 -0
- package/templates/deploy-xserver.yml +531 -0
- package/templates/dist-refs.yml +177 -0
- package/templates/docs-lint.mjs +993 -0
- package/templates/docs-lint.yml +55 -0
- package/templates/gotchas-d-README.md +41 -0
- package/templates/identity-vocabulary.example +58 -0
- package/templates/npx-launcher.mjs +213 -0
- package/templates/pre-commit-dispatch +88 -0
- package/templates/pre-commit-identity +267 -0
- package/templates/pre-push-guard +117 -0
- package/templates/release-auto.yml +470 -0
- package/templates/release-tag.yml +245 -0
- package/templates/repo-CLAUDE-block.md +21 -0
- package/tools/colab +13746 -0
- package/tools/lib/adopt.js +882 -0
- package/tools/lib/axis-authority.js +96 -0
- package/tools/lib/base-ci-verdict.js +93 -0
- package/tools/lib/blocked-by.js +262 -0
- package/tools/lib/branch-name.js +137 -0
- package/tools/lib/checklist.js +143 -0
- package/tools/lib/ci-cure.js +512 -0
- package/tools/lib/ci-grant.js +307 -0
- package/tools/lib/ci-verdict.js +113 -0
- package/tools/lib/claim-comments.js +212 -0
- package/tools/lib/claim-identity.js +195 -0
- package/tools/lib/codeowners.js +208 -0
- package/tools/lib/consumer-evidence.js +74 -0
- package/tools/lib/container-close.js +141 -0
- package/tools/lib/cure-diff.js +267 -0
- package/tools/lib/decision-record.js +335 -0
- package/tools/lib/dirty-owner.js +150 -0
- package/tools/lib/disposition.js +378 -0
- package/tools/lib/docs-only.js +156 -0
- package/tools/lib/exposure-shape.js +207 -0
- package/tools/lib/gate.js +80 -0
- package/tools/lib/git.js +1059 -0
- package/tools/lib/group-labels.js +120 -0
- package/tools/lib/hermetic.js +193 -0
- package/tools/lib/identity.js +187 -0
- package/tools/lib/install-check.js +259 -0
- package/tools/lib/instruction-file.js +302 -0
- package/tools/lib/journal.js +430 -0
- package/tools/lib/labels.js +653 -0
- package/tools/lib/landed.js +230 -0
- package/tools/lib/local-adopt.js +133 -0
- package/tools/lib/lockfile-drift.js +119 -0
- package/tools/lib/machine-trailer.js +83 -0
- package/tools/lib/machine.js +238 -0
- package/tools/lib/migration-grant.js +641 -0
- package/tools/lib/migration-paths.js +135 -0
- package/tools/lib/notify.js +188 -0
- package/tools/lib/npm-publish-guard.js +242 -0
- package/tools/lib/orphan-worktree.js +127 -0
- package/tools/lib/owner-branch.js +182 -0
- package/tools/lib/place.js +782 -0
- package/tools/lib/ports.js +167 -0
- package/tools/lib/procs.js +185 -0
- package/tools/lib/readiness.js +240 -0
- package/tools/lib/records.js +185 -0
- package/tools/lib/refs-brake.js +95 -0
- package/tools/lib/release-cut.js +822 -0
- package/tools/lib/release-finalize.js +481 -0
- package/tools/lib/release-policy.js +358 -0
- package/tools/lib/release-tag.js +225 -0
- package/tools/lib/ship-batch.js +277 -0
- package/tools/lib/ship-roles.js +71 -0
- package/tools/lib/ship-target-sync.js +181 -0
- package/tools/lib/shipguard.js +317 -0
- package/tools/lib/shipped-branch.js +56 -0
- package/tools/lib/solo.js +213 -0
- package/tools/lib/squash.js +515 -0
- package/tools/lib/stale-base.js +70 -0
- package/tools/lib/stamp.js +703 -0
- package/tools/lib/state.js +262 -0
- package/tools/lib/teardown.js +83 -0
- package/tools/lib/trust-humans.js +104 -0
- package/tools/lib/util.js +98 -0
- package/tools/lib/wake.js +188 -0
- package/tools/lib/workflow-triggers.js +273 -0
- package/tools/lib/writes-authority.js +237 -0
- package/tools/lib/yaml.js +101 -0
- package/bin/cli.js +0 -3
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* The cure rule's DIFF signals (#297) — what the branch's diff against trunk touches of "the
|
|
4
|
+
* instrument grading it": the CI workflow files (condition 4) and any `package.json`'s `scripts`
|
|
5
|
+
* block (condition 5). The verdict itself stays in the PURE tools/lib/ci-cure.js; this module is the
|
|
6
|
+
* git read behind it, injected the same way tools/lib/docs-only.js takes its `git`, so the subtle
|
|
7
|
+
* parts (renames, deleted manifests, unparseable JSON) are tested against real repositories rather
|
|
8
|
+
* than left as tools/colab's untestable residue.
|
|
9
|
+
*
|
|
10
|
+
* WHY `package.json` IS PART OF THE INSTRUMENT. The Node CI template does not hardcode what it
|
|
11
|
+
* measures: its "Detect optional scripts" step asks `package.json` whether `typecheck`/`lint`/`test`
|
|
12
|
+
* exist and SKIPS each step whose script is absent — and the job still concludes `success`. So a
|
|
13
|
+
* branch that deletes `scripts.test` stops the failing suite from running at all without touching
|
|
14
|
+
* `.github/workflows/**`, and condition 4 alone would call it a cure.
|
|
15
|
+
*
|
|
16
|
+
* ANY `package.json`, AT ANY DEPTH — not just the root. The template's
|
|
17
|
+
* `defaults.run.working-directory` is an adopter-edited point, workspace runners read nested
|
|
18
|
+
* `scripts`, and parsing an adopter's own YAML to find the one manifest that matters would be
|
|
19
|
+
* brittle in the fail-open direction. The cost is a false refusal on an unrelated nested manifest's
|
|
20
|
+
* scripts change during a red trunk, which falls through to the human ci-grant: the safe direction.
|
|
21
|
+
*
|
|
22
|
+
* `--no-renames`, deliberately. With rename detection on (git's default for `diff`), a rename lists
|
|
23
|
+
* only its NEW path, so moving `.github/workflows/ci.yml` to `ci.yml.off` — or `package.json` to
|
|
24
|
+
* `package.json.bak` — used to read as touching neither. Without it a rename is a delete plus an add,
|
|
25
|
+
* and the deleted side is seen.
|
|
26
|
+
*
|
|
27
|
+
* THE PYTHON DEPENDENCY MANIFESTS ARE PART OF THE INSTRUMENT TOO (#377) — condition 6. The Python
|
|
28
|
+
* template's "Detect optional tooling" step does not ask a manifest a question the way the Node one
|
|
29
|
+
* does; it asks the INSTALLED ENVIRONMENT (`python -m pytest --version`), and runs ruff/mypy/pytest
|
|
30
|
+
* only when that succeeds. What is installed is decided by exactly the files the template reads:
|
|
31
|
+
* `pip install -e .` from `pyproject.toml` (whose build backend reads `setup.py`/`setup.cfg`), else
|
|
32
|
+
* `pip install -r requirements.txt`, then `pip install -r requirements-dev.txt`. Drop `pytest` from
|
|
33
|
+
* any of them and the Test step skips while the job concludes `success`. So the signal is WHOLE-FILE,
|
|
34
|
+
* not a block: in Python the dependency list IS the switch, and the switch is transitive (pytest can
|
|
35
|
+
* arrive through `pytest-cov`), which no block-level parse could measure. Which files count:
|
|
36
|
+
*
|
|
37
|
+
* - basename `pyproject.toml`, `setup.py`, `setup.cfg` — what `pip install -e .` reads;
|
|
38
|
+
* - a `.txt`/`.in` whose basename contains `requirements`, or that sits under a `requirements/`
|
|
39
|
+
* directory — the template's two names and the conventional layouts around them;
|
|
40
|
+
* - any file one of those pulls in: a requirements file's `-r`/`-c` include, or a
|
|
41
|
+
* `[tool.setuptools.dynamic]` `file =` in a pyproject — resolved against BOTH sides' trees, so
|
|
42
|
+
* editing `deps/test.txt` counts when an unchanged `requirements-dev.txt` includes it.
|
|
43
|
+
*
|
|
44
|
+
* Any depth, for the same reason as `package.json`. A content change of any kind counts — a
|
|
45
|
+
* version pin included, which is the accepted false refusal: a "pin the broken upstream" cure falls
|
|
46
|
+
* through to the human ci-grant. Narrowing to "a requirement NAME disappeared" is deliberately
|
|
47
|
+
* unmade: a version change can drop a transitive tool, and that is unmeasurable here. Lockfiles
|
|
48
|
+
* (`poetry.lock`, `uv.lock`, `Pipfile.lock`) are NOT read by the template and do not count; an
|
|
49
|
+
* adopter whose CI installs from one has edited the template and owns extending this list.
|
|
50
|
+
*
|
|
51
|
+
* FAIL CLOSED. Every unmeasurable input is `null`, never `false`: a failed diff read, a manifest
|
|
52
|
+
* blob that could not be read, a manifest that does not parse, a manifest that is a symlink or a
|
|
53
|
+
* submodule. ci-cure.js's `cureVerdict` refuses on `null`.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
const { parseRaw } = require('./docs-only');
|
|
57
|
+
|
|
58
|
+
/** Stands for "no such file on this side of the diff" (an all-zero sha in `--raw`). */
|
|
59
|
+
const ABSENT = Symbol('absent');
|
|
60
|
+
|
|
61
|
+
const ZERO_SHA = /^0+$/;
|
|
62
|
+
/** Modes a manifest may carry and still be read as a plain file. `000000` = absent on that side. */
|
|
63
|
+
const FILE_MODES = new Set(['100644', '100755', '000000']);
|
|
64
|
+
|
|
65
|
+
const PY_BASENAMES = new Set(['pyproject.toml', 'setup.py', 'setup.cfg']);
|
|
66
|
+
|
|
67
|
+
/** A Python dependency manifest by NAME alone (#377) — include-referenced files are added by
|
|
68
|
+
* `pythonIncludedPaths`, which needs the trees. */
|
|
69
|
+
function isPythonManifest(p) {
|
|
70
|
+
const base = p.slice(p.lastIndexOf('/') + 1);
|
|
71
|
+
if (PY_BASENAMES.has(base)) return true;
|
|
72
|
+
if (!/\.(txt|in)$/i.test(base)) return false;
|
|
73
|
+
return /requirements/i.test(base) || /(^|\/)requirements\//i.test(p);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Normalise `a/./b/../c` to `a/c`; null when it climbs out of the repo root. */
|
|
77
|
+
function joinRel(dir, rel) {
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const seg of `${dir ? `${dir}/` : ''}${rel}`.split('/')) {
|
|
80
|
+
if (!seg || seg === '.') continue;
|
|
81
|
+
if (seg === '..') { if (!out.length) return null; out.pop(); } else out.push(seg);
|
|
82
|
+
}
|
|
83
|
+
return out.join('/');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* PURE. The repo-relative paths one Python manifest pulls in. A requirements file: every
|
|
88
|
+
* `-r`/`--requirement`/`-c`/`--constraint` target (pip resolves it against the including file's
|
|
89
|
+
* directory). A `pyproject.toml`: every string in a `file =` under `[tool.setuptools.dynamic]`.
|
|
90
|
+
* URLs and paths escaping the repo are skipped — nothing in this repo can change them.
|
|
91
|
+
*/
|
|
92
|
+
function pythonIncludes(filePath, text) {
|
|
93
|
+
const dir = filePath.includes('/') ? filePath.slice(0, filePath.lastIndexOf('/')) : '';
|
|
94
|
+
const base = filePath.slice(filePath.lastIndexOf('/') + 1);
|
|
95
|
+
const found = [];
|
|
96
|
+
const add = (rel) => {
|
|
97
|
+
const r = String(rel).trim();
|
|
98
|
+
if (!r || /^[a-z][a-z0-9+.-]*:\/\//i.test(r)) return;
|
|
99
|
+
const j = joinRel(dir, r);
|
|
100
|
+
if (j) found.push(j);
|
|
101
|
+
};
|
|
102
|
+
const lines = String(text).replace(/\\\r?\n/g, ' ').split(/\r?\n/);
|
|
103
|
+
if (base === 'pyproject.toml') {
|
|
104
|
+
let inDynamic = false;
|
|
105
|
+
for (const line of lines) {
|
|
106
|
+
const sec = /^\s*\[([^\]]+)\]\s*(#.*)?$/.exec(line);
|
|
107
|
+
if (sec) { inDynamic = sec[1].trim() === 'tool.setuptools.dynamic'; continue; }
|
|
108
|
+
if (!inDynamic) continue;
|
|
109
|
+
const m = /\bfile\s*=\s*(\[[^\]]*\]|"[^"]*"|'[^']*')/.exec(line);
|
|
110
|
+
if (m) for (const q of m[1].match(/"[^"]*"|'[^']*'/g) || []) add(q.slice(1, -1));
|
|
111
|
+
}
|
|
112
|
+
return found;
|
|
113
|
+
}
|
|
114
|
+
if (!/\.(txt|in)$/i.test(base)) return found;
|
|
115
|
+
for (const raw of lines) {
|
|
116
|
+
const line = raw.replace(/(^|\s)#.*$/, '').trim();
|
|
117
|
+
const m = /^(?:-r|-c|--requirement|--constraint)(?:\s*=\s*|\s+|(?=[^\s-]))(\S+)/.exec(line);
|
|
118
|
+
if (m) add(m[1]);
|
|
119
|
+
}
|
|
120
|
+
return found;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The include closure of one tree, as a Set of paths — or null when the tree or a manifest blob in
|
|
125
|
+
* it could not be read. Starts from every name-matched manifest in the tree and follows includes
|
|
126
|
+
* to a fixpoint (an include of an include counts).
|
|
127
|
+
*/
|
|
128
|
+
function pythonIncludedPaths(git, repo, rev) {
|
|
129
|
+
const ls = git.git(['ls-tree', '-r', '-z', '--full-tree', rev], repo);
|
|
130
|
+
if (!ls.ok) return null;
|
|
131
|
+
const blobs = new Map();
|
|
132
|
+
for (const rec of String(ls.stdout).split('\0')) {
|
|
133
|
+
const m = /^(\d+) (\w+) ([0-9a-f]+)\t(.+)$/s.exec(rec);
|
|
134
|
+
if (m && m[2] === 'blob') blobs.set(m[4], m[3]);
|
|
135
|
+
}
|
|
136
|
+
const included = new Set();
|
|
137
|
+
const queue = [...blobs.keys()].filter(isPythonManifest);
|
|
138
|
+
const seen = new Set(queue);
|
|
139
|
+
while (queue.length) {
|
|
140
|
+
const p = queue.shift();
|
|
141
|
+
const r = git.git(['cat-file', 'blob', blobs.get(p)], repo);
|
|
142
|
+
if (!r.ok) return null;
|
|
143
|
+
for (const inc of pythonIncludes(p, r.stdout)) {
|
|
144
|
+
included.add(inc);
|
|
145
|
+
if (!seen.has(inc) && blobs.has(inc)) { seen.add(inc); queue.push(inc); }
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return included;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function isManifest(p) {
|
|
152
|
+
return p === 'package.json' || p.endsWith('/package.json');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Key-order-independent JSON, so reordering `scripts` keys is not a change but editing a command is. */
|
|
156
|
+
function canonical(v) {
|
|
157
|
+
if (Array.isArray(v)) return `[${v.map(canonical).join(',')}]`;
|
|
158
|
+
if (v && typeof v === 'object') {
|
|
159
|
+
return `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canonical(v[k])}`).join(',')}}`;
|
|
160
|
+
}
|
|
161
|
+
return JSON.stringify(v);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** The `scripts` value as the Node template reads it (`scripts || {}`), canonicalised — or null when
|
|
165
|
+
* the text is not a JSON object. */
|
|
166
|
+
function scriptsOf(text) {
|
|
167
|
+
let obj;
|
|
168
|
+
try { obj = JSON.parse(String(text).replace(/^/, '')); } catch (_) { return null; }
|
|
169
|
+
if (!obj || typeof obj !== 'object' || Array.isArray(obj)) return null;
|
|
170
|
+
return canonical(obj.scripts || {});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* PURE. Whether the `scripts` block differs between two versions of one `package.json`. Each side is
|
|
175
|
+
* its text, or `ABSENT` when the file does not exist on that side. Returns `true`/`false`, or `null`
|
|
176
|
+
* when either present side does not parse as a JSON object.
|
|
177
|
+
*
|
|
178
|
+
* A file that exists on only one side DIFFERS, whatever it holds: deleting the root manifest flips
|
|
179
|
+
* the template's `hashFiles('package.json') != ''` guard and skips every Node step, build included.
|
|
180
|
+
*/
|
|
181
|
+
function scriptsBlockDiffers(baseText, headText) {
|
|
182
|
+
if (baseText === ABSENT && headText === ABSENT) return false;
|
|
183
|
+
if (baseText === ABSENT || headText === ABSENT) return true;
|
|
184
|
+
const a = scriptsOf(baseText);
|
|
185
|
+
const b = scriptsOf(headText);
|
|
186
|
+
if (a === null || b === null) return null;
|
|
187
|
+
return a !== b;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** One side's text for a raw-diff entry: `ABSENT`, the blob text, or null on a failed read. */
|
|
191
|
+
function sideText(git, repo, sha) {
|
|
192
|
+
if (!sha || ZERO_SHA.test(sha)) return ABSENT;
|
|
193
|
+
const r = git.git(['cat-file', 'blob', sha], repo);
|
|
194
|
+
return r.ok ? r.stdout : null;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The diff signals for one branch against trunk, over the merge-base range (`trunk...branch` — the
|
|
199
|
+
* same tree a squash lands). Returns `{ ok, reason, workflowsTouched, manifestScriptsTouched,
|
|
200
|
+
* manifestPaths, pythonManifestTouched, pythonManifestPaths }` (the last two: condition 6, #377): `ok:false` with both flags `null` when the diff itself could not be read;
|
|
201
|
+
* `manifestScriptsTouched` `true`/`false`/`null` (unmeasurable), with `manifestPaths` listing every
|
|
202
|
+
* manifest whose scripts changed. Never throws.
|
|
203
|
+
*/
|
|
204
|
+
function cureDiffSignals(git, repo, trunk, branch) {
|
|
205
|
+
const raw = git.git(['diff', '-z', '--no-renames', '--raw', '--no-abbrev', `${trunk}...${branch}`], repo);
|
|
206
|
+
if (!raw.ok) {
|
|
207
|
+
return { ok: false, reason: `git diff ${trunk}...${branch} failed: ${(raw.stderr || '').split('\n')[0] || raw.code}`,
|
|
208
|
+
workflowsTouched: null, manifestScriptsTouched: null, manifestPaths: [],
|
|
209
|
+
pythonManifestTouched: null, pythonManifestPaths: [] };
|
|
210
|
+
}
|
|
211
|
+
const entries = parseRaw(raw.stdout);
|
|
212
|
+
const workflowsTouched = entries.some((e) => e.path.startsWith('.github/workflows/'));
|
|
213
|
+
|
|
214
|
+
const touched = [];
|
|
215
|
+
const unmeasured = [];
|
|
216
|
+
for (const e of entries) {
|
|
217
|
+
if (!isManifest(e.path)) continue;
|
|
218
|
+
if (!FILE_MODES.has(e.oldMode) || !FILE_MODES.has(e.newMode)) { unmeasured.push(e.path); continue; }
|
|
219
|
+
if (e.oldSha && e.oldSha === e.newSha) continue; // mode-only change: same content
|
|
220
|
+
const differs = scriptsBlockDiffers(sideText(git, repo, e.oldSha), sideText(git, repo, e.newSha));
|
|
221
|
+
if (differs === true) touched.push(e.path);
|
|
222
|
+
else if (differs === null) unmeasured.push(e.path);
|
|
223
|
+
}
|
|
224
|
+
let manifestScriptsTouched = false;
|
|
225
|
+
if (touched.length) manifestScriptsTouched = true;
|
|
226
|
+
else if (unmeasured.length) manifestScriptsTouched = null;
|
|
227
|
+
|
|
228
|
+
const py = pythonSignal(git, repo, trunk, branch, entries);
|
|
229
|
+
const reasons = [];
|
|
230
|
+
if (unmeasured.length && !touched.length) reasons.push(`could not read the scripts of: ${unmeasured.join(', ')}`);
|
|
231
|
+
if (py.touched === null) reasons.push(py.reason);
|
|
232
|
+
return {
|
|
233
|
+
ok: true,
|
|
234
|
+
reason: reasons.join('; '),
|
|
235
|
+
workflowsTouched, manifestScriptsTouched, manifestPaths: touched,
|
|
236
|
+
pythonManifestTouched: py.touched, pythonManifestPaths: py.paths,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Condition 6's signal (#377): which Python dependency manifests the diff changes. A changed entry
|
|
242
|
+
* counts when its path is a manifest by name, or is included by one on EITHER side (the base side
|
|
243
|
+
* sees an include the branch deleted along with its target). Content-identical mode-only changes do
|
|
244
|
+
* not count; a manifest that is a symlink or a submodule counts as touched — pip follows the link,
|
|
245
|
+
* and the gate cannot vouch for what it points at, so there is nothing to call unmeasured about it.
|
|
246
|
+
* The include closure is read only when some changed path is not already a manifest by name, so
|
|
247
|
+
* a diff touching nothing else pays no tree reads. Returns `{touched: true|false|null, paths, reason}`.
|
|
248
|
+
*/
|
|
249
|
+
function pythonSignal(git, repo, trunk, branch, entries) {
|
|
250
|
+
const changed = entries.filter((e) => !(e.oldSha && e.oldSha === e.newSha));
|
|
251
|
+
const paths = changed.filter((e) => isPythonManifest(e.path)).map((e) => e.path);
|
|
252
|
+
const rest = changed.filter((e) => !isPythonManifest(e.path));
|
|
253
|
+
if (rest.length) {
|
|
254
|
+
const mb = git.git(['merge-base', trunk, branch], repo);
|
|
255
|
+
const base = mb.ok ? pythonIncludedPaths(git, repo, mb.stdout.trim()) : null;
|
|
256
|
+
const head = base ? pythonIncludedPaths(git, repo, branch) : null;
|
|
257
|
+
if (!base || !head) {
|
|
258
|
+
return paths.length
|
|
259
|
+
? { touched: true, paths, reason: '' }
|
|
260
|
+
: { touched: null, paths: [], reason: 'could not read the Python manifests\' includes (-r/-c, setuptools dynamic file)' };
|
|
261
|
+
}
|
|
262
|
+
for (const e of rest) if (base.has(e.path) || head.has(e.path)) paths.push(e.path);
|
|
263
|
+
}
|
|
264
|
+
return { touched: paths.length > 0, paths, reason: '' };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
module.exports = { cureDiffSignals, scriptsBlockDiffers, isPythonManifest, pythonIncludes, ABSENT };
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* The decision-record marker (#121) — makes recording an answer to a blocking question a
|
|
4
|
+
* POSITIVE, machine-readable act, never just the absence of `needs-decision`
|
|
5
|
+
* (tools/lib/labels.js, NEEDS_DECISION_LABEL).
|
|
6
|
+
*
|
|
7
|
+
* WHY THIS MODULE EXISTS. #122 consolidated the design-approval gate into the wider
|
|
8
|
+
* `needs-decision` (CONVENTIONS.md §5, *Decision gate*) — a human must answer a blocking
|
|
9
|
+
* question before an issue can start. #121 answers a narrower but sharper question: what
|
|
10
|
+
* does ANSWERING look like, mechanically? "Clear the label" was the obvious answer and the
|
|
11
|
+
* wrong one — #127 measured it failing LIVE: a ruling was posted as ordinary prose in a
|
|
12
|
+
* comment, the gate label was removed, and a later triage pass, reading the issue fresh, saw
|
|
13
|
+
* no machine-readable record of a decision and RE-GATED it. The ruling had been sitting in a
|
|
14
|
+
* comment the whole time. A cleared label is indistinguishable from a label never applied.
|
|
15
|
+
*
|
|
16
|
+
* So the fix makes the ANSWER the artifact a consumer reads, not the absence of a gate — the
|
|
17
|
+
* same principle CONVENTIONS.md already applies to a design conclusion's three units ("prose
|
|
18
|
+
* does not block, so prose is not the record"), extended from the QUESTION side to the
|
|
19
|
+
* ANSWER side.
|
|
20
|
+
*
|
|
21
|
+
* TWO MARKERS, TWO DIFFERENT JOBS — read together, never one alone (identical shape to
|
|
22
|
+
* tools/lib/migration-grant.js, which this module is modelled on):
|
|
23
|
+
* - a LABEL (`decision-recorded`, tools/lib/labels.js) — makes a recorded decision a cheap
|
|
24
|
+
* `gh issue list --label` query, and — the load-bearing half — applying a label on GitHub
|
|
25
|
+
* requires triage/write permission, so a drive-by comment on this public repo cannot
|
|
26
|
+
* manufacture a decision merely by posting well-formed text.
|
|
27
|
+
* - a COMMENT (this module's DECISION_MARK/REOPEN_MARK) — carries what a label cannot: WHO
|
|
28
|
+
* ruled (never the typist — mirrors `Filed-by:`, CONVENTIONS.md §5 *Provenance*), WHAT
|
|
29
|
+
* `<!-- decision:options -->` block (if any) it answers, and WHEN. The comment is the
|
|
30
|
+
* authority; the label is the gate.
|
|
31
|
+
*
|
|
32
|
+
* Both are required for a decision to read as live (evaluateIssue, below) — a label with no
|
|
33
|
+
* live comment is exactly the state a rolled-back/failed write leaves, and must refuse, not
|
|
34
|
+
* "recorded".
|
|
35
|
+
*
|
|
36
|
+
* PURE BY CONSTRUCTION, same posture as migration-grant.js / readiness.js / landed.js /
|
|
37
|
+
* shipguard.js: signals in, verdict out. No git, no network, no `gh`.
|
|
38
|
+
*
|
|
39
|
+
* WHO IS ALLOWED TO WRITE THE COMMENT is a DIFFERENT question from who is allowed to APPLY
|
|
40
|
+
* the label, and this module answers only the second by requiring TRUSTED_ASSOCIATIONS on
|
|
41
|
+
* read — the same hole migration-grant.js closes, for the same public-repo reason. Unlike
|
|
42
|
+
* `colab migration-grant` / `colab ci-grant` / `colab promote`, `colab decision --record` is
|
|
43
|
+
* deliberately NOT gated on COLAB_HUMAN=1: those three AUTHORIZE a write to production or
|
|
44
|
+
* trunk that did not exist before the command ran; this one TRANSCRIBES a call a human
|
|
45
|
+
* already made elsewhere (the ordinary case is `Filed-by: boss` — an agent recording Boss's
|
|
46
|
+
* ruling, not inventing one). The safety property is carried by requiring `ruledBy` (no
|
|
47
|
+
* default) plus TRUSTED_ASSOCIATIONS on read, not by gating who may type the command. If that
|
|
48
|
+
* is judged too weak in review, requiring COLAB_HUMAN=1 here too is the safe direction and
|
|
49
|
+
* costs one line in tools/colab — flagged, not decided, by this module.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/** The two comment markers. STABLE WIRE FORMAT — do not reword casually; `tools/colab` and any
|
|
53
|
+
* vendored reader parse these verbatim, the same posture as GRANT_MARK/REVOKE_MARK. */
|
|
54
|
+
const DECISION_MARK = '⚖ Decision recorded';
|
|
55
|
+
const REOPEN_MARK = '↩ Decision reopened';
|
|
56
|
+
|
|
57
|
+
// Deliberately DIFFERENT leading glyph (not just different trailing text) — mirrors
|
|
58
|
+
// migration-grant.js's GRANT_RE/REVOKE_RE split, and for the identical reason: a reopen mark
|
|
59
|
+
// that merely suffixed the decision mark would make every reopen parse as a fresh decision,
|
|
60
|
+
// silently reopening exactly the door it was posted to close.
|
|
61
|
+
const DECISION_RE = /^⚖ Decision recorded — ruled-by `([^`]*)` · answers `([^`]*)` · host `([^`]*)` · (\S+)/;
|
|
62
|
+
const REOPEN_RE = /^↩ Decision reopened — ruled-by `([^`]*)` · host `([^`]*)` · (\S+)/;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The exact decision-comment body. Keep in lockstep with DECISION_RE.
|
|
66
|
+
* `ruledBy` names the human whose call it is — never the typist (mirrors `Filed-by:`).
|
|
67
|
+
* `answers` is the `<!-- decision:options -->` block reference this decision resolves
|
|
68
|
+
* (a comment URL/id), or `-` when there was no options block to answer.
|
|
69
|
+
* `body`, if given, is the ruling prose appended below the marker line — chosen option, why,
|
|
70
|
+
* what was rejected (CONVENTIONS.md §5, design conclusions' Unit 1).
|
|
71
|
+
*/
|
|
72
|
+
function decisionCommentBody(ruledBy, answers, host, iso, body) {
|
|
73
|
+
const head = `${DECISION_MARK} — ruled-by \`${ruledBy}\` · answers \`${answers || '-'}\` · host \`${host}\` · ${iso}`;
|
|
74
|
+
return body ? `${head}\n\n${body}` : head;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The exact reopen-comment body. Keep in lockstep with REOPEN_RE. Reopening is NOT scoped to
|
|
78
|
+
* the same `ruledBy` — see liveDecisions doc below for why. */
|
|
79
|
+
function reopenCommentBody(ruledBy, host, iso, reason) {
|
|
80
|
+
const head = `${REOPEN_MARK} — ruled-by \`${ruledBy}\` · host \`${host}\` · ${iso}`
|
|
81
|
+
+ ' — every decision on this issue up to this point is superseded.';
|
|
82
|
+
return reason ? `${head}\n\n${reason}` : head;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Every DECISION_MARK comment not cancelled by a LATER REOPEN_MARK — whoever posted the
|
|
87
|
+
* reopen. Deliberately NOT author-scoped, same reasoning as migration-grant's liveGrants: a
|
|
88
|
+
* decision is not a race between identities the way a claim is, it is a standing record a
|
|
89
|
+
* human is meant to be able to reopen from any trusted account, on any machine.
|
|
90
|
+
*
|
|
91
|
+
* Sort is by `createdAt` (GitHub's own timestamp, authoritative — never comment array order).
|
|
92
|
+
* A decision AFTER the latest reopen is live again: decide, reopen, decide is "currently
|
|
93
|
+
* decided," not "permanently reopened."
|
|
94
|
+
*
|
|
95
|
+
* Returns [{ruledBy, answers, host, at, login, authorAssociation}], oldest-first — a caller
|
|
96
|
+
* wanting the current verdict takes the LAST entry; the full list serves `colab decision
|
|
97
|
+
* --list`, which shows history, not just the verdict.
|
|
98
|
+
*/
|
|
99
|
+
function liveDecisions(comments) {
|
|
100
|
+
const list = Array.isArray(comments) ? comments : [];
|
|
101
|
+
const sorted = [...list].sort((a, b) => (a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : 0));
|
|
102
|
+
|
|
103
|
+
let lastReopenAt = null;
|
|
104
|
+
for (const c of sorted) {
|
|
105
|
+
const body = String(c.body || '').trim();
|
|
106
|
+
if (REOPEN_RE.test(body)) {
|
|
107
|
+
if (lastReopenAt === null || c.createdAt > lastReopenAt) lastReopenAt = c.createdAt;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const live = [];
|
|
112
|
+
for (const c of sorted) {
|
|
113
|
+
const body = String(c.body || '').trim();
|
|
114
|
+
const m = body.match(DECISION_RE);
|
|
115
|
+
if (!m) continue;
|
|
116
|
+
const at = c.createdAt;
|
|
117
|
+
const cancelled = lastReopenAt !== null && lastReopenAt > at;
|
|
118
|
+
if (cancelled) continue;
|
|
119
|
+
live.push({
|
|
120
|
+
ruledBy: m[1],
|
|
121
|
+
answers: m[2],
|
|
122
|
+
host: m[3],
|
|
123
|
+
at,
|
|
124
|
+
login: (c.author && c.author.login) || '',
|
|
125
|
+
authorAssociation: c.authorAssociation || '',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return live;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Association values GitHub reports (`authorAssociation`) trustworthy enough to write a
|
|
132
|
+
* record a scheduled driver will rely on. Same set, same reasoning, as
|
|
133
|
+
* migration-grant.js's TRUSTED_ASSOCIATIONS — re-exported from there rather than duplicated,
|
|
134
|
+
* so the two never drift about who counts as trusted. */
|
|
135
|
+
const { TRUSTED_ASSOCIATIONS } = require('./migration-grant.js');
|
|
136
|
+
const { authorIsHuman } = require('./trust-humans.js');
|
|
137
|
+
|
|
138
|
+
/** The live decisions a reader may act on (#407). `trust` is trust-humans.js parseTrustHumans()
|
|
139
|
+
* of trunk's project.yml, or absent — absent/undeclared keeps the association check exactly as
|
|
140
|
+
* before; declared, a ruling counts only when its author's login is listed in trust-humans. A
|
|
141
|
+
* ruling is a human's by definition, so the human list — not the association class — decides. */
|
|
142
|
+
function trustedDecisions(comments, trust) {
|
|
143
|
+
return liveDecisions(comments).filter((d) => authorIsHuman(d, trust).ok);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** True when `comments` carries at least one live (non-reopened) DECISION_MARK from a
|
|
147
|
+
* trusted association (or, with `trust` declared, a listed human — #407). Does not check labels
|
|
148
|
+
* — pure comment-side signal, for a caller that wants "was this actually answered" independent
|
|
149
|
+
* of whatever label state it finds. */
|
|
150
|
+
function hasRecordedDecision(comments, trust) {
|
|
151
|
+
return trustedDecisions(comments, trust).length > 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The `<!-- decision:options -->` block references every live decision on this issue claims
|
|
155
|
+
* to answer, most-recent-last, `'-'` entries filtered out. Lets a caller cross-check a
|
|
156
|
+
* decision against the options block it names, when one exists (CONVENTIONS.md §5,
|
|
157
|
+
* *Decision options*, which #126 finally wrote — until then this comment cited
|
|
158
|
+
* code-triage/SKILL.md, which has never contained the convention: the format was
|
|
159
|
+
* implemented here and specified nowhere). */
|
|
160
|
+
function answeredOptionRefs(comments, trust) {
|
|
161
|
+
return trustedDecisions(comments, trust)
|
|
162
|
+
.filter((d) => d.answers && d.answers !== '-')
|
|
163
|
+
.map((d) => d.answers);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The question-side marker (CONVENTIONS.md §5, *Decision options*, #126). Only its PRESENCE
|
|
167
|
+
* and its comment's createdAt matter here — the block's content is parsed by consumers. */
|
|
168
|
+
const OPTIONS_RE = /<!--\s*decision:options\b/;
|
|
169
|
+
|
|
170
|
+
/** The design-approval ask (CONVENTIONS.md §5, *Decision options*, #379): the second
|
|
171
|
+
* machine-readable question shape, beside the options block. A design issue whose finished
|
|
172
|
+
* artifact awaits approval carries `Mockup: <url of the frozen image>` in its BODY, anchored at
|
|
173
|
+
* the start of a line — never a comment, so a reader finds it with one field and no timeline.
|
|
174
|
+
* A set reviewed together carries one line in each member's body; the review comment keeps the
|
|
175
|
+
* full gallery. Leading whitespace disqualifies the line on purpose: an indented `Mockup:` is
|
|
176
|
+
* quoted or nested text, not the filer's declaration. */
|
|
177
|
+
const MOCKUP_RE = /^Mockup:[ \t]*(\S+)[ \t]*$/gm;
|
|
178
|
+
|
|
179
|
+
/** Every `Mockup:` URL declared in an issue body, in order. Empty when none (or no body). */
|
|
180
|
+
function mockupUrls(body) {
|
|
181
|
+
if (typeof body !== 'string' || body === '') return [];
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const m of body.replace(/\r\n/g, '\n').matchAll(MOCKUP_RE)) out.push(m[1]);
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const ASK_SHAPES = Object.freeze({ OPTIONS: 'options', MOCKUP: 'mockup' });
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Which machine-readable shape the question on a `needs-decision` issue takes (#379):
|
|
191
|
+
* - `options` — a `<!-- decision:options` block, in the body or any comment (#126);
|
|
192
|
+
* - `mockup` — at least one `Mockup:` line in the body (design approval);
|
|
193
|
+
* - `null` — neither: a question no consumer can render. Triage and sweep report that as
|
|
194
|
+
* a finding for its filer (CONVENTIONS.md §5) — it is never a new gate, and it
|
|
195
|
+
* never changes whether the issue is pending.
|
|
196
|
+
* Both present reads as `options`: a pick-one block is the more specific ask.
|
|
197
|
+
*/
|
|
198
|
+
function askShape({ body = '', comments = [] } = {}) {
|
|
199
|
+
const hasOptions = OPTIONS_RE.test(typeof body === 'string' ? body : '') ||
|
|
200
|
+
(Array.isArray(comments) ? comments : []).some((c) => c && OPTIONS_RE.test(c.body || ''));
|
|
201
|
+
const mockups = mockupUrls(body);
|
|
202
|
+
const shape = hasOptions ? ASK_SHAPES.OPTIONS : (mockups.length ? ASK_SHAPES.MOCKUP : null);
|
|
203
|
+
return { shape, options: hasOptions, mockups };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const PAIR_VERDICTS = Object.freeze({
|
|
207
|
+
OPEN_QUESTION: 'open-question',
|
|
208
|
+
INTERRUPTED_WRITE: 'interrupted-write',
|
|
209
|
+
UNDETERMINED: 'undetermined',
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
function toMs(iso) {
|
|
213
|
+
const t = Date.parse(iso);
|
|
214
|
+
return Number.isFinite(t) ? t : null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function newestMs(isoList) {
|
|
218
|
+
let best = null;
|
|
219
|
+
for (const iso of isoList) {
|
|
220
|
+
const t = toMs(iso);
|
|
221
|
+
if (t !== null && (best === null || t > best)) best = t;
|
|
222
|
+
}
|
|
223
|
+
return best;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The both-labels pair, resolved (#357). An issue carrying `needs-decision` AND a recorded
|
|
228
|
+
* decision (`decision-recorded` label, or a live ⚖ record) is AMBIGUOUS by construction — two
|
|
229
|
+
* different histories produce the identical label set:
|
|
230
|
+
*
|
|
231
|
+
* - an INTERRUPTED WRITE: `colab decision --record` posted the ⚖ comment (step 1), then its
|
|
232
|
+
* label swap failed (step 2), leaving the gate label behind. The question is answered.
|
|
233
|
+
* - a SECOND QUESTION asked by hand: someone added `needs-decision` again to an issue that
|
|
234
|
+
* was already decided, instead of `colab decision --reopen`. The question is OPEN — and a
|
|
235
|
+
* reader that resolved the pair as "interrupted write, label is stale" hid it from the
|
|
236
|
+
* human who had to answer it (measured: ~9 h invisible in an adopter's decision inbox).
|
|
237
|
+
*
|
|
238
|
+
* Time tells them apart. The ask is the newest `needs-decision` `labeled` event, or the newest
|
|
239
|
+
* `<!-- decision:options -->` comment, whichever is later; the answer is the newest live,
|
|
240
|
+
* trusted ⚖ record. Ask newer than answer ⇒ OPEN question. Ask not newer ⇒ interrupted write.
|
|
241
|
+
* Anything this function cannot prove ⇒ UNDETERMINED, which every caller surfaces as PENDING —
|
|
242
|
+
* showing a settled question once more costs a glance; hiding an open one costs a human's
|
|
243
|
+
* ruling (the fail-toward-visible posture of *Readiness*).
|
|
244
|
+
*
|
|
245
|
+
* `labelEvents` — the created-at ISO timestamps of every `labeled` event for `needs-decision`
|
|
246
|
+
* on this issue (the issue events API), or `null` when they were not read. `null` is NEVER
|
|
247
|
+
* "no events": an unread timeline can still be decided by a newer options block, and otherwise
|
|
248
|
+
* stays UNDETERMINED. An empty array read successfully is also undetermined — a label that is
|
|
249
|
+
* present but has no `labeled` event is something this function cannot explain.
|
|
250
|
+
*
|
|
251
|
+
* Returns null when the pair is not present (nothing to resolve).
|
|
252
|
+
*/
|
|
253
|
+
function pairVerdict({ labels, comments, labelEvents = null, trust } = {}) {
|
|
254
|
+
const labelNames = new Set(
|
|
255
|
+
(labels || []).map((l) => (l && typeof l === 'object' ? l.name : l)),
|
|
256
|
+
);
|
|
257
|
+
const decisions = trustedDecisions(comments, trust);
|
|
258
|
+
const gated = labelNames.has('needs-decision');
|
|
259
|
+
const recordedLabel = labelNames.has('decision-recorded');
|
|
260
|
+
if (!gated || (!recordedLabel && decisions.length === 0)) return null;
|
|
261
|
+
|
|
262
|
+
const optionsAts = (Array.isArray(comments) ? comments : [])
|
|
263
|
+
.filter((c) => OPTIONS_RE.test(String(c.body || '')))
|
|
264
|
+
.map((c) => c.createdAt);
|
|
265
|
+
const optionsMs = newestMs(optionsAts);
|
|
266
|
+
const labeledMs = Array.isArray(labelEvents) ? newestMs(labelEvents) : null;
|
|
267
|
+
const askMs = [optionsMs, labeledMs].filter((t) => t !== null).reduce((a, b) => (b > a ? b : a), null);
|
|
268
|
+
const askAt = askMs === null ? null : new Date(askMs).toISOString();
|
|
269
|
+
|
|
270
|
+
// The label with NO live record behind it can never be an interrupted --record: record posts
|
|
271
|
+
// the comment FIRST, so every interrupted write leaves a live ⚖ record. What is left is a gate
|
|
272
|
+
// on an issue whose decision was never (or is no longer) recorded — an open question.
|
|
273
|
+
if (decisions.length === 0) {
|
|
274
|
+
return { verdict: PAIR_VERDICTS.OPEN_QUESTION, askAt, decidedAt: null, why: 'needs-decision is applied and no live ⚖ record stands behind decision-recorded' };
|
|
275
|
+
}
|
|
276
|
+
const decidedAt = decisions[decisions.length - 1].at;
|
|
277
|
+
const decidedMs = toMs(decidedAt);
|
|
278
|
+
|
|
279
|
+
if (askMs !== null && decidedMs !== null && askMs > decidedMs) {
|
|
280
|
+
return { verdict: PAIR_VERDICTS.OPEN_QUESTION, askAt, decidedAt, why: 'the newest ask is newer than the newest ⚖ record — a second question' };
|
|
281
|
+
}
|
|
282
|
+
// Only a successfully-read, non-empty label timeline can prove the ask predates the record.
|
|
283
|
+
if (Array.isArray(labelEvents) && labeledMs !== null && decidedMs !== null) {
|
|
284
|
+
return { verdict: PAIR_VERDICTS.INTERRUPTED_WRITE, askAt, decidedAt, why: 'every needs-decision label event predates the ⚖ record — its label swap did not finish' };
|
|
285
|
+
}
|
|
286
|
+
return { verdict: PAIR_VERDICTS.UNDETERMINED, askAt, decidedAt, why: labelEvents === null ? 'the label timeline was not read' : 'no needs-decision label event could be read' };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* One issue's readiness verdict — the function `code-triage` (or any reader deciding whether
|
|
291
|
+
* to apply/keep `needs-decision`) calls. `labels` is the issue's label list (bare strings or
|
|
292
|
+
* `{name}` objects, same tolerant shape as tools/lib/labels.js); `comments` is what
|
|
293
|
+
* `gh issue view --json comments` returns, or `[]`/`null` when unavailable — never treat a
|
|
294
|
+
* failed read as "no decision"; that is the caller's job to distinguish, this function only
|
|
295
|
+
* reports what it was given. `labelEvents` is optional — see pairVerdict.
|
|
296
|
+
*
|
|
297
|
+
* Returns `{ recorded, gated, contradiction, pair, pending, decisions }`:
|
|
298
|
+
* - `recorded` — a live, trusted DECISION_MARK exists (comment-side truth).
|
|
299
|
+
* - `gated` — `needs-decision` label is present.
|
|
300
|
+
* - `contradiction` — BOTH true at once. Kept for existing readers; it is NOT a verdict. Until
|
|
301
|
+
* #357 this doc said to resolve it toward "decided" — that reading hid a
|
|
302
|
+
* second question asked on a decided issue. Read `pair`/`pending`.
|
|
303
|
+
* - `pair` — pairVerdict()'s result, or null when the pair is absent.
|
|
304
|
+
* - `pending` — whether a human still owes an answer: gated, unless the pair resolves
|
|
305
|
+
* to an interrupted write. UNDETERMINED is pending, by design.
|
|
306
|
+
* - `decisions` — the full liveDecisions() list, for a caller that wants to show detail.
|
|
307
|
+
* - `ask` — askShape()'s result when the caller passed `body`, else null (#379).
|
|
308
|
+
* - `unshapedAsk` — true when a pending question takes neither shape: a finding for its
|
|
309
|
+
* filer, never a gate. null when `body` was not passed (unknown, not false).
|
|
310
|
+
*/
|
|
311
|
+
function evaluateIssue({ labels, comments, labelEvents = null, body, trust } = {}) {
|
|
312
|
+
const labelNames = new Set(
|
|
313
|
+
(labels || []).map((l) => (l && typeof l === 'object' ? l.name : l)),
|
|
314
|
+
);
|
|
315
|
+
const decisions = trustedDecisions(comments, trust);
|
|
316
|
+
const recorded = decisions.length > 0;
|
|
317
|
+
const gated = labelNames.has('needs-decision');
|
|
318
|
+
const pair = pairVerdict({ labels, comments, labelEvents, trust });
|
|
319
|
+
const pending = gated && !(pair && pair.verdict === PAIR_VERDICTS.INTERRUPTED_WRITE);
|
|
320
|
+
// #379: only judged when the caller passed the body — an unread body is "unknown", never
|
|
321
|
+
// "unshaped", so a caller that never fetched it is not handed a false finding.
|
|
322
|
+
const ask = body === undefined ? null : askShape({ body, comments });
|
|
323
|
+
const unshapedAsk = ask === null ? null : (pending && ask.shape === null);
|
|
324
|
+
return { recorded, gated, contradiction: recorded && gated, pair, pending, decisions, ask, unshapedAsk };
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
module.exports = {
|
|
328
|
+
DECISION_MARK, REOPEN_MARK, DECISION_RE, REOPEN_RE,
|
|
329
|
+
decisionCommentBody, reopenCommentBody,
|
|
330
|
+
liveDecisions, TRUSTED_ASSOCIATIONS, trustedDecisions,
|
|
331
|
+
hasRecordedDecision, answeredOptionRefs,
|
|
332
|
+
OPTIONS_RE, PAIR_VERDICTS, pairVerdict,
|
|
333
|
+
MOCKUP_RE, mockupUrls, ASK_SHAPES, askShape,
|
|
334
|
+
evaluateIssue,
|
|
335
|
+
};
|