@futurelastic/colab-handbook 1.14.0-rc.13 → 1.14.0-rc.14
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/package.json +1 -1
- package/tools/lib/disposition.js +27 -10
package/package.json
CHANGED
package/tools/lib/disposition.js
CHANGED
|
@@ -69,7 +69,19 @@ const HUMAN = 'human';
|
|
|
69
69
|
* GitHub's close reason takes. Frozen and closed: a kind outside this list is not a disposition
|
|
70
70
|
* with an unknown authority, it is not a disposition.
|
|
71
71
|
*/
|
|
72
|
-
const KINDS = Object.freeze(['done', 'split', 'routed-out', 'hold', 'needs-
|
|
72
|
+
const KINDS = Object.freeze(['done', 'split', 'routed-out', 'hold', 'needs-owner', 'not planned', 'leave']);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* #609 — names this module still READS but never writes. `needs-owner` replaced `needs-boss`
|
|
76
|
+
* ("Boss" named one deployment's human; the standard is for any owner). During the switch a
|
|
77
|
+
* reader must accept both, or an issue marked under the old name reads as unrecognised — "not
|
|
78
|
+
* cleared" — to a tool that only knows the new one. Each legacy name classifies exactly like the
|
|
79
|
+
* kind it maps to. Kept out of KINDS / TOKENS / TOKEN_BY_KIND on purpose: those are what a writer
|
|
80
|
+
* may emit, and `formatMarker` refuses a legacy kind. Drop an entry once the old name has had no
|
|
81
|
+
* open use for its window (a separate issue, filed then).
|
|
82
|
+
*/
|
|
83
|
+
const LEGACY_KINDS = Object.freeze({ 'needs-boss': 'needs-owner' });
|
|
84
|
+
const LEGACY_TOKENS = Object.freeze({ 'needs-boss': 'needs-owner' });
|
|
73
85
|
|
|
74
86
|
/**
|
|
75
87
|
* The same seven by MARKER TOKEN. No token is a prefix or a decorated variant of another — the
|
|
@@ -82,13 +94,14 @@ const TOKEN_BY_KIND = Object.freeze({
|
|
|
82
94
|
split: 'split',
|
|
83
95
|
'routed-out': 'routed-out',
|
|
84
96
|
hold: 'hold',
|
|
85
|
-
'needs-
|
|
97
|
+
'needs-owner': 'needs-owner',
|
|
86
98
|
'not planned': 'not-planned',
|
|
87
99
|
leave: 'leave',
|
|
88
100
|
});
|
|
89
|
-
const KIND_BY_TOKEN = Object.freeze(
|
|
90
|
-
Object.fromEntries(Object.entries(TOKEN_BY_KIND).map(([kind, token]) => [token, kind]))
|
|
91
|
-
)
|
|
101
|
+
const KIND_BY_TOKEN = Object.freeze({
|
|
102
|
+
...Object.fromEntries(Object.entries(TOKEN_BY_KIND).map(([kind, token]) => [token, kind])),
|
|
103
|
+
...LEGACY_TOKENS, // read-only: a legacy token parses to the current kind (#609)
|
|
104
|
+
});
|
|
92
105
|
const TOKENS = Object.freeze(Object.values(TOKEN_BY_KIND));
|
|
93
106
|
|
|
94
107
|
/**
|
|
@@ -149,7 +162,10 @@ function parseMarker(text) {
|
|
|
149
162
|
if (typeof text !== 'string' || text === '') return null;
|
|
150
163
|
const tokens = [...text.matchAll(new RegExp(MARKER_PATTERN, 'g'))].map((m) => m[1]);
|
|
151
164
|
if (tokens.length === 0) return null;
|
|
152
|
-
|
|
165
|
+
// Distinct by the KIND a token reads as, so a legacy token and its current spelling (#609) are
|
|
166
|
+
// one proposal, not two; an unrecognised token stays distinct by its own spelling.
|
|
167
|
+
const distinct = [...new Set(tokens.map((t) => (
|
|
168
|
+
Object.prototype.hasOwnProperty.call(LEGACY_TOKENS, t) ? TOKEN_BY_KIND[LEGACY_TOKENS[t]] : t)))];
|
|
153
169
|
if (distinct.length > 1) {
|
|
154
170
|
return { token: null, kind: null, recognised: false, why: `${distinct.length} markers proposing different dispositions` };
|
|
155
171
|
}
|
|
@@ -251,9 +267,10 @@ function verdict(kind, authority, applicable, why, blockers, extra) {
|
|
|
251
267
|
*/
|
|
252
268
|
function classify(facts) {
|
|
253
269
|
const f = facts && typeof facts === 'object' ? facts : {};
|
|
254
|
-
const
|
|
270
|
+
const named = f.kind !== undefined && f.kind !== null
|
|
255
271
|
? f.kind
|
|
256
272
|
: (f.token !== undefined && f.token !== null ? KIND_BY_TOKEN[f.token] : undefined);
|
|
273
|
+
const kind = Object.prototype.hasOwnProperty.call(LEGACY_KINDS, named) ? LEGACY_KINDS[named] : named;
|
|
257
274
|
|
|
258
275
|
if (!KINDS.includes(kind)) {
|
|
259
276
|
return verdict(null, HUMAN, false, 'not a recognised disposition — not cleared, never a default', []);
|
|
@@ -331,11 +348,11 @@ function classify(facts) {
|
|
|
331
348
|
: verdict(kind, AGENT, true, 'the park names what it is waiting on — the agent applies', []);
|
|
332
349
|
}
|
|
333
350
|
|
|
334
|
-
case 'needs-
|
|
351
|
+
case 'needs-owner':
|
|
335
352
|
// Record-first: the pass writes the question down with the apply lever pre-filled and moves
|
|
336
353
|
// on. It does not stop and wait, and it never applies this itself.
|
|
337
354
|
return verdict(kind, HUMAN, true,
|
|
338
|
-
'never applied by an agent — the agent records the question,
|
|
355
|
+
'never applied by an agent — the agent records the question, the owner answers, the issue returns to intake', []);
|
|
339
356
|
|
|
340
357
|
case 'not planned': {
|
|
341
358
|
const sup = f.supersededBy && typeof f.supersededBy === 'object' ? f.supersededBy : {};
|
|
@@ -375,7 +392,7 @@ function classify(facts) {
|
|
|
375
392
|
|
|
376
393
|
module.exports = {
|
|
377
394
|
AGENT, HUMAN,
|
|
378
|
-
KINDS, TOKENS, TOKEN_BY_KIND, KIND_BY_TOKEN,
|
|
395
|
+
KINDS, TOKENS, TOKEN_BY_KIND, KIND_BY_TOKEN, LEGACY_KINDS, LEGACY_TOKENS,
|
|
379
396
|
ASSERTS_AN_OUTCOME, SKIP_FENCE_CLASSES, EVIDENCE_FIELDS, HOLD_STALE_DAYS, MARKER_PATTERN,
|
|
380
397
|
parseMarker, formatMarker, evidenceShape, axisPermits, classify,
|
|
381
398
|
};
|