@codyswann/lisa 8.2.5 → 8.2.7
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/all/copy-overwrite/scripts/check-threshold-ratchet.mjs +280 -46
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +3 -3
- package/all/copy-overwrite/scripts/threshold-ratchet-compare.mjs +433 -21
- package/all/copy-overwrite/scripts/threshold-ratchet-families.mjs +77 -4
- package/dist/core/lisa-owned-hash-ledger.json +56 -2
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/upstream-evidence-manifest.json +25 -14
- package/package.json +4 -4
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/hooks/threshold-ratchet-compare.mjs +433 -21
- package/plugins/lisa/hooks/threshold-ratchet-families.mjs +77 -4
- package/plugins/lisa/hooks/threshold-ratchet.mjs +280 -46
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/hooks/threshold-ratchet-compare.mjs +433 -21
- package/plugins/lisa-copilot/hooks/threshold-ratchet-families.mjs +77 -4
- package/plugins/lisa-copilot/hooks/threshold-ratchet.mjs +280 -46
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/threshold-ratchet-compare.mjs +433 -21
- package/plugins/lisa-cursor/hooks/threshold-ratchet-families.mjs +77 -4
- package/plugins/lisa-cursor/hooks/threshold-ratchet.mjs +280 -46
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/threshold-ratchet-compare.mjs +433 -21
- package/plugins/lisa-devin/hooks/threshold-ratchet-families.mjs +77 -4
- package/plugins/lisa-devin/hooks/threshold-ratchet.mjs +280 -46
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/hooks/threshold-ratchet-compare.mjs +433 -21
- package/plugins/src/base/hooks/threshold-ratchet-families.mjs +77 -4
- package/plugins/src/base/hooks/threshold-ratchet.mjs +280 -46
- package/rails/copy-overwrite/scripts/check-threshold-ratchet.mjs +280 -46
- package/rails/copy-overwrite/scripts/threshold-ratchet-compare.mjs +433 -21
- package/rails/copy-overwrite/scripts/threshold-ratchet-families.mjs +77 -4
- package/typescript/copy-contents/.husky/pre-commit +3 -2
- package/typescript/copy-overwrite/scripts/check-threshold-ratchet.mjs +280 -46
- package/typescript/copy-overwrite/scripts/threshold-ratchet-compare.mjs +433 -21
- package/typescript/copy-overwrite/scripts/threshold-ratchet-families.mjs +77 -4
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
10
|
ALLOW_STATE,
|
|
11
|
+
HUMAN_GATE_ACCESS_ONLY,
|
|
12
|
+
HUMAN_GATE_STRICT,
|
|
13
|
+
allowEntryExpiry,
|
|
11
14
|
classifyAllowEntry,
|
|
12
15
|
describeAllowScope,
|
|
13
16
|
extractAllowEntries,
|
|
@@ -23,8 +26,13 @@ import {
|
|
|
23
26
|
globRoot,
|
|
24
27
|
isDeclaredDirection,
|
|
25
28
|
parseJson,
|
|
29
|
+
reasonInWords,
|
|
26
30
|
} from "./threshold-ratchet-families.mjs";
|
|
27
31
|
|
|
32
|
+
/** The one config the allow list and the `humanGate.mode` are read from. */
|
|
33
|
+
const ROOT_CONFIG = ".lisa.config.json";
|
|
34
|
+
/** Finding type: the change adds a `thresholdRatchet.allow` entry. */
|
|
35
|
+
const TYPE_ALLOW_ADDED = "allow-added";
|
|
28
36
|
/** Finding type: a numeric bound or boolean gate moved the weakening way. */
|
|
29
37
|
const TYPE_WEAKENED = "weakened";
|
|
30
38
|
/** Finding type: a gate-shrinking exemption was added (Tier 3). */
|
|
@@ -41,6 +49,8 @@ const KIND_ALLOW_LIST = "allow-list";
|
|
|
41
49
|
* @property {number|string} [base] Baseline value
|
|
42
50
|
* @property {number|string} [current] Current value
|
|
43
51
|
* @property {string} message Operator-readable explanation
|
|
52
|
+
* @property {{ file: string, key: string, reason?: unknown, until?: unknown }} [entry]
|
|
53
|
+
* The allow entry an `allow-added` finding is about, as the change wrote it
|
|
44
54
|
*/
|
|
45
55
|
|
|
46
56
|
/**
|
|
@@ -251,8 +261,12 @@ function compareK6(relPath, base, current) {
|
|
|
251
261
|
}
|
|
252
262
|
|
|
253
263
|
/**
|
|
254
|
-
* Compare .lisa.config.json allow lists: report added exception
|
|
255
|
-
*
|
|
264
|
+
* Compare .lisa.config.json allow lists: report every added exception entry.
|
|
265
|
+
*
|
|
266
|
+
* The finding says only what was added, and carries the entry. Whether an
|
|
267
|
+
* added entry is accepted or refused is {@link settleAddedExceptions}' call,
|
|
268
|
+
* because that depends on the rest of the change and on the repository's
|
|
269
|
+
* `humanGate.mode`, neither of which this comparison can see.
|
|
256
270
|
* @param {string} relPath Repo-relative path
|
|
257
271
|
* @param {unknown} base Parsed baseline config
|
|
258
272
|
* @param {unknown} current Parsed current config
|
|
@@ -268,14 +282,239 @@ function compareAllowList(relPath, base, current) {
|
|
|
268
282
|
findings.push({
|
|
269
283
|
file: relPath,
|
|
270
284
|
key: `thresholdRatchet.allow ${entry.file}#${entry.key}`,
|
|
271
|
-
type:
|
|
272
|
-
message: `${relPath}: new threshold exception — ${describeAllowScope(entry)}
|
|
285
|
+
type: TYPE_ALLOW_ADDED,
|
|
286
|
+
message: `${relPath}: new threshold exception — ${describeAllowScope(entry)}.`,
|
|
287
|
+
entry,
|
|
273
288
|
});
|
|
274
289
|
}
|
|
275
290
|
}
|
|
276
291
|
return findings;
|
|
277
292
|
}
|
|
278
293
|
|
|
294
|
+
/**
|
|
295
|
+
* What an added allow entry still lacks before it can be recorded.
|
|
296
|
+
*
|
|
297
|
+
* An entry needs a reason, so whoever meets it later knows what resolves it,
|
|
298
|
+
* and a day it ends, because an exemption that cannot end is a permanent
|
|
299
|
+
* reduction in what the ratchet covers (#3856). A day already past is refused
|
|
300
|
+
* too: such an entry would be dead on arrival and exempt nothing.
|
|
301
|
+
* @param {{ reason?: unknown, until?: unknown }} entry The entry as written
|
|
302
|
+
* @param {number} now Clock reading
|
|
303
|
+
* @returns {string[]} One clause per gap; empty when the entry is sound
|
|
304
|
+
*/
|
|
305
|
+
function addedExceptionGaps(entry, now) {
|
|
306
|
+
const gaps = [];
|
|
307
|
+
if (reasonInWords(entry.reason) === "") {
|
|
308
|
+
gaps.push("it needs a reason saying what resolves it");
|
|
309
|
+
}
|
|
310
|
+
const expiresAt = allowEntryExpiry(entry.until);
|
|
311
|
+
if (expiresAt === undefined) {
|
|
312
|
+
gaps.push(
|
|
313
|
+
'it needs an "until": "YYYY-MM-DD" day naming when it is reviewed'
|
|
314
|
+
);
|
|
315
|
+
} else if (now >= expiresAt) {
|
|
316
|
+
gaps.push(`its "until" day ${String(entry.until).trim()} has passed`);
|
|
317
|
+
}
|
|
318
|
+
return gaps;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* How many threshold names a hint lists before it stops.
|
|
323
|
+
*/
|
|
324
|
+
const HINT_LIMIT = 5;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The rule an allow entry is matched by, said once for every hint that needs it.
|
|
328
|
+
*/
|
|
329
|
+
const COVER_RULE =
|
|
330
|
+
'An entry covers a threshold only when its "file" is that threshold\'s file (the same path, or the name of a file of that name in a sub-folder) and its "key" is that threshold\'s key or "*".';
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Warn that an entry refused for arriving with a threshold change would not
|
|
334
|
+
* cover that change even once merged.
|
|
335
|
+
*
|
|
336
|
+
* The refusal tells the reader to merge the entry first and then make the
|
|
337
|
+
* threshold change. With a key that names none of the thresholds the change
|
|
338
|
+
* loosens, following that to the letter ends in a second refusal with no
|
|
339
|
+
* explanation, so the mismatch is said here, where the entry is still being
|
|
340
|
+
* written.
|
|
341
|
+
* @param {{ file: string, key: string }} entry The added entry
|
|
342
|
+
* @param {Finding[]} others The other findings in the change
|
|
343
|
+
* @returns {string} A sentence to append, or nothing when the entry covers one
|
|
344
|
+
*/
|
|
345
|
+
function keyMismatchNote(entry, others) {
|
|
346
|
+
if (others.some(finding => entryCovers(entry, finding))) return "";
|
|
347
|
+
const names = [...new Set(others.map(f => `${f.file} → ${f.key}`))];
|
|
348
|
+
const listed = names.slice(0, HINT_LIMIT).join("; ");
|
|
349
|
+
const more = names.length > HINT_LIMIT ? "; and more" : "";
|
|
350
|
+
return ` As written it would not cover what this change loosens either: it names ${entry.file} → ${entry.key}, and the thresholds changed here are ${listed}${more}. ${COVER_RULE}`;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* The threshold names the ratchet finds in a file as the change has it.
|
|
355
|
+
*
|
|
356
|
+
* Taken from the comparison itself — every finding it reports when the file
|
|
357
|
+
* is emptied — so the names cannot differ from what an entry is matched
|
|
358
|
+
* against. `*` is left out: it is how an unreadable file reports itself, not
|
|
359
|
+
* a name anybody would write.
|
|
360
|
+
* @param {string} file Repo-relative path
|
|
361
|
+
* @param {string} text The file's text
|
|
362
|
+
* @returns {string[]} Names, in the order the comparison reports them
|
|
363
|
+
*/
|
|
364
|
+
function thresholdNamesIn(file, text) {
|
|
365
|
+
return [
|
|
366
|
+
...new Set(compareFile(file, text, "{}").map(finding => finding.key)),
|
|
367
|
+
].filter(name => name !== "*");
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Point out a sound, entry-only exception whose key names no threshold the
|
|
372
|
+
* ratchet finds in its file today.
|
|
373
|
+
*
|
|
374
|
+
* An entry is matched by its file and its exact key, and nothing at record
|
|
375
|
+
* time says which threshold it is meant for. A key that is nearly right — the
|
|
376
|
+
* name in the config file instead of the name the ratchet gives the threshold
|
|
377
|
+
* — is recorded, merged, and then covers nothing, and the operator learns of
|
|
378
|
+
* it one merge later. So when the named file can be read, the notice says
|
|
379
|
+
* what the ratchet finds in it.
|
|
380
|
+
*
|
|
381
|
+
* It states an observation and never a prediction. An entry can be right and
|
|
382
|
+
* still name nothing today: a threshold that is added later, a mutation
|
|
383
|
+
* exclusion that does not exist yet, or a file of the same name in a
|
|
384
|
+
* sub-folder, which an entry with a bare file name also matches. Saying such
|
|
385
|
+
* an entry "will cover nothing" would be false.
|
|
386
|
+
*
|
|
387
|
+
* It can never change the verdict. The file name comes from the entry, so a
|
|
388
|
+
* path that leaves the repository is not read, and any failure while reading
|
|
389
|
+
* or comparing — a file too deep to walk, say — yields no note rather than an
|
|
390
|
+
* error from code whose only job is a hint.
|
|
391
|
+
* @param {{ file: string, key: string }} entry The entry being recorded
|
|
392
|
+
* @param {(file: string) => string | null | undefined} readFile Reads a
|
|
393
|
+
* repository file as the change has it
|
|
394
|
+
* @returns {string} A sentence to append to the notice, or nothing
|
|
395
|
+
*/
|
|
396
|
+
function unmatchedKeyNote(entry, readFile) {
|
|
397
|
+
const leavesRepository =
|
|
398
|
+
entry.file.startsWith("/") || entry.file.split(/[\\/]/u).includes("..");
|
|
399
|
+
if (entry.key === "*" || leavesRepository || !familyFor(entry.file)) {
|
|
400
|
+
return "";
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const text = readFile(entry.file);
|
|
404
|
+
if (typeof text !== "string") return "";
|
|
405
|
+
const names = thresholdNamesIn(entry.file, text);
|
|
406
|
+
if (names.length === 0 || names.includes(entry.key)) return "";
|
|
407
|
+
const listed = names
|
|
408
|
+
.slice(0, HINT_LIMIT)
|
|
409
|
+
.map(name => `"${name}"`)
|
|
410
|
+
.join(", ");
|
|
411
|
+
const more = names.length > HINT_LIMIT ? ", and more" : "";
|
|
412
|
+
return ` Check the key: the ratchet finds no threshold named "${entry.key}" in ${entry.file} at the repository root today. The names it finds there are ${listed}${more}. If the entry is meant for one of them, its key must be that name exactly. A threshold added later, a new exclusion, or a file of the same name in a sub-folder is still matched by the entry as written.`;
|
|
413
|
+
} catch {
|
|
414
|
+
return "";
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Decide one added allow entry under the default policy.
|
|
420
|
+
* @param {Finding} finding The `allow-added` finding
|
|
421
|
+
* @param {Finding[]} others Every other ratchet finding in the change
|
|
422
|
+
* @param {number} now Clock reading
|
|
423
|
+
* @param {(file: string) => string | null | undefined} readFile Reads a
|
|
424
|
+
* repository file as the change has it
|
|
425
|
+
* @returns {{ accepted: boolean, message: string }} The verdict and its text:
|
|
426
|
+
* a notice when accepted, the refusal otherwise
|
|
427
|
+
*/
|
|
428
|
+
function judgeAddedException(finding, others, now, readFile) {
|
|
429
|
+
const entry = finding.entry ?? {};
|
|
430
|
+
const said = finding.message.replace(/\.$/u, "");
|
|
431
|
+
if (finding.file !== ROOT_CONFIG) {
|
|
432
|
+
return {
|
|
433
|
+
accepted: false,
|
|
434
|
+
message: `${said} — is written in ${finding.file}, and the ratchet reads exceptions from the repository's root ${ROOT_CONFIG} only, so it would never exempt anything. Record it in the root ${ROOT_CONFIG} instead.`,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
const gaps = addedExceptionGaps(entry, now);
|
|
438
|
+
if (gaps.length > 0) {
|
|
439
|
+
return {
|
|
440
|
+
accepted: false,
|
|
441
|
+
message: `${said} — cannot be recorded yet: ${gaps.join(", and ")}. Complete the entry and try again.`,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
if (others.length > 0) {
|
|
445
|
+
return {
|
|
446
|
+
accepted: false,
|
|
447
|
+
message: `${said} — arrives together with another threshold change, and an exception exempts nothing until it is merged. Merge this entry in a change of its own first, then make the threshold change.${keyMismatchNote(entry, others)}`,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
accepted: true,
|
|
452
|
+
message: `new exception recorded — ${describeAllowScope(entry)}. Reason on record: "${reasonInWords(entry.reason)}". It ends after ${String(entry.until).trim()}. It exempts nothing until this change is merged, so make the threshold change in a later change.${unmatchedKeyNote(entry, readFile)}`,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Settle the allow entries a change adds: which are recorded, which refused.
|
|
458
|
+
*
|
|
459
|
+
* The fence this keeps is that a change cannot grant itself an exception. The
|
|
460
|
+
* allow list is honoured from the baseline only, so an entry exempts nothing
|
|
461
|
+
* until it is merged — and that ordering does not depend on refusing the
|
|
462
|
+
* change that records the entry. Refusing it anyway left the exception route
|
|
463
|
+
* unusable: the refusal told the reader to land the entry in a change of its
|
|
464
|
+
* own, which was the change being refused (#5099).
|
|
465
|
+
*
|
|
466
|
+
* Under the default `access-only` policy an agent records a risk acceptance
|
|
467
|
+
* and a person can reverse it (#4687), so an added entry is ACCEPTED when it
|
|
468
|
+
* is sound — a reason and a day it ends that has not passed — and the change
|
|
469
|
+
* holds no other ratchet finding. An entry that arrives with any other
|
|
470
|
+
* finding is refused whether or not it would cover that finding: accepting it
|
|
471
|
+
* would be the self-grant, one step removed.
|
|
472
|
+
*
|
|
473
|
+
* Under `strict` an exception stays a person's decision, and nothing here can
|
|
474
|
+
* see that a person approved, so every added entry is refused as it always
|
|
475
|
+
* was.
|
|
476
|
+
* @param {Finding[]} findings Every finding from the change, promotion-carried
|
|
477
|
+
* entries already taken out
|
|
478
|
+
* @param {string} mode The repository's `humanGate.mode`, from the baseline
|
|
479
|
+
* @param {number} [now] Clock reading, injected so the check is deterministic
|
|
480
|
+
* @param {(file: string) => string | null | undefined} [readFile] Reads a
|
|
481
|
+
* repository file as the change has it, so a recorded entry can be checked
|
|
482
|
+
* against the thresholds its file holds; reads nothing by default
|
|
483
|
+
* @returns {{
|
|
484
|
+
* accepted: Array<{ finding: Finding, message: string }>,
|
|
485
|
+
* refused: Finding[],
|
|
486
|
+
* rest: Finding[],
|
|
487
|
+
* }} Entries recorded (with the notice to print), entries refused (with the
|
|
488
|
+
* refusal as their message), and every finding that is not an added entry
|
|
489
|
+
*/
|
|
490
|
+
export function settleAddedExceptions(
|
|
491
|
+
findings,
|
|
492
|
+
mode,
|
|
493
|
+
now = Date.now(),
|
|
494
|
+
readFile = () => null
|
|
495
|
+
) {
|
|
496
|
+
const added = findings.filter(f => f.type === TYPE_ALLOW_ADDED);
|
|
497
|
+
const rest = findings.filter(f => f.type !== TYPE_ALLOW_ADDED);
|
|
498
|
+
if (mode !== HUMAN_GATE_ACCESS_ONLY) {
|
|
499
|
+
return {
|
|
500
|
+
accepted: [],
|
|
501
|
+
refused: added.map(finding => ({
|
|
502
|
+
...finding,
|
|
503
|
+
message: `${finding.message} Exceptions are a human decision: land this entry in its own human-approved change first, then make the threshold change. It needs a reason saying what resolves it and an "until": "YYYY-MM-DD" naming the day it is reviewed, because an exemption that cannot end is a permanent reduction in what the ratchet covers.`,
|
|
504
|
+
})),
|
|
505
|
+
rest,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
const accepted = [];
|
|
509
|
+
const refused = [];
|
|
510
|
+
for (const finding of added) {
|
|
511
|
+
const verdict = judgeAddedException(finding, rest, now, readFile);
|
|
512
|
+
if (verdict.accepted) accepted.push({ finding, message: verdict.message });
|
|
513
|
+
else refused.push({ ...finding, message: verdict.message });
|
|
514
|
+
}
|
|
515
|
+
return { accepted, refused, rest };
|
|
516
|
+
}
|
|
517
|
+
|
|
279
518
|
/**
|
|
280
519
|
* Say a part's folder the way an operator would.
|
|
281
520
|
* @param {string} scope The part's folder; `.` is the whole repository
|
|
@@ -438,7 +677,7 @@ export function compareDeclaredThresholds(
|
|
|
438
677
|
type: verdict.type,
|
|
439
678
|
base: held.value,
|
|
440
679
|
...(verdict.current === undefined ? {} : { current: verdict.current }),
|
|
441
|
-
message: `${relPath}: the ${held.direction} "${held.name}" of the ${held.gate} gate, for ${folderInWords(held.scope)}, ${verdict.told}
|
|
680
|
+
message: `${relPath}: the ${held.direction} "${held.name}" of the ${held.gate} gate, for ${folderInWords(held.scope)}, ${verdict.told} To loosen it on purpose, an exception under thresholdRatchet.allow with "file": "${relPath}" and "key": "${held.key}" has to be merged first.`,
|
|
442
681
|
});
|
|
443
682
|
}
|
|
444
683
|
return findings;
|
|
@@ -511,6 +750,58 @@ function compareLighthouse(relPath, base, current) {
|
|
|
511
750
|
return findings;
|
|
512
751
|
}
|
|
513
752
|
|
|
753
|
+
/**
|
|
754
|
+
* Whether a config's text literally declares `humanGate.mode: "strict"`.
|
|
755
|
+
* @param {string | null | undefined} text The config's text
|
|
756
|
+
* @returns {boolean} True only for a readable object whose mode, trimmed and
|
|
757
|
+
* lower-cased, is the word `strict`
|
|
758
|
+
*/
|
|
759
|
+
function declaresStrict(text) {
|
|
760
|
+
const mode = parseJson(text)?.humanGate?.mode;
|
|
761
|
+
return (
|
|
762
|
+
typeof mode === "string" && mode.trim().toLowerCase() === HUMAN_GATE_STRICT
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Report a root config whose `humanGate.mode` stops being `strict`.
|
|
768
|
+
*
|
|
769
|
+
* Under `strict` a threshold exception is a person's decision, and
|
|
770
|
+
* {@link settleAddedExceptions} refuses every added entry on that ground. The
|
|
771
|
+
* mode is read from the baseline, so a change cannot relax it for itself —
|
|
772
|
+
* but a change that ONLY relaxes it would, once merged, let the next change
|
|
773
|
+
* record an exception with no person involved. A strict repository could be
|
|
774
|
+
* walked down in three ordinary steps without this check ever objecting. So
|
|
775
|
+
* leaving `strict` is itself a loosening, and is reported like one.
|
|
776
|
+
* @param {string} relPath Repo-relative path
|
|
777
|
+
* @param {string} baselineText The config's text at the baseline
|
|
778
|
+
* @param {string | null | undefined} currentText Its text now; nothing when
|
|
779
|
+
* the file was deleted
|
|
780
|
+
* @returns {Finding[]} One finding when the mode left `strict`, else none
|
|
781
|
+
*/
|
|
782
|
+
function compareHumanGateMode(relPath, baselineText, currentText) {
|
|
783
|
+
if (relPath !== ROOT_CONFIG) return [];
|
|
784
|
+
// Both sides are judged by whether the file literally DECLARES strict, not
|
|
785
|
+
// by the fail-safe reading used when exceptions are settled. A baseline
|
|
786
|
+
// that reads as strict only because nobody can read it — a misspelt mode, a
|
|
787
|
+
// block that is not an object, a file that does not parse — never said
|
|
788
|
+
// strict, and refusing the change that corrects it would wedge the
|
|
789
|
+
// repository on its own damage with no way through. The current side is
|
|
790
|
+
// held to the same literal reading, so respelling "strict" into something
|
|
791
|
+
// unreadable is reported here rather than slipping past as "still strict".
|
|
792
|
+
if (!declaresStrict(baselineText) || declaresStrict(currentText)) return [];
|
|
793
|
+
return [
|
|
794
|
+
{
|
|
795
|
+
file: relPath,
|
|
796
|
+
key: "humanGate.mode",
|
|
797
|
+
type: TYPE_WEAKENED,
|
|
798
|
+
base: HUMAN_GATE_STRICT,
|
|
799
|
+
current: HUMAN_GATE_ACCESS_ONLY,
|
|
800
|
+
message: `${relPath}: humanGate.mode stops being "strict". Under strict a threshold exception is a person's decision; with this change merged, the next one could be recorded with no person involved. This check cannot see that a person approved it.`,
|
|
801
|
+
},
|
|
802
|
+
];
|
|
803
|
+
}
|
|
804
|
+
|
|
514
805
|
/**
|
|
515
806
|
* Compare one watched file's baseline and current contents and report every
|
|
516
807
|
* weakening. Pure: no filesystem or git access.
|
|
@@ -527,12 +818,15 @@ export function compareFile(relPath, baselineText, currentText) {
|
|
|
527
818
|
// Deleting an allow list grants nothing, so that half stays silent. The
|
|
528
819
|
// thresholds the file declared are another matter: they go with it.
|
|
529
820
|
if (family.kind === KIND_ALLOW_LIST) {
|
|
530
|
-
return
|
|
531
|
-
relPath,
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
821
|
+
return [
|
|
822
|
+
...compareHumanGateMode(relPath, baselineText, currentText),
|
|
823
|
+
...compareDeclaredThresholds(
|
|
824
|
+
relPath,
|
|
825
|
+
parseJson(baselineText),
|
|
826
|
+
undefined,
|
|
827
|
+
true
|
|
828
|
+
),
|
|
829
|
+
];
|
|
536
830
|
}
|
|
537
831
|
return [
|
|
538
832
|
{
|
|
@@ -572,12 +866,15 @@ export function compareFile(relPath, baselineText, currentText) {
|
|
|
572
866
|
// block every change touching the file without making anything safer.
|
|
573
867
|
if (base === undefined) {
|
|
574
868
|
return family.kind === KIND_ALLOW_LIST
|
|
575
|
-
?
|
|
869
|
+
? compareHumanGateMode(relPath, baselineText, currentText)
|
|
576
870
|
: [unparseableBaseline(relPath)];
|
|
577
871
|
}
|
|
578
872
|
if (current === undefined) {
|
|
579
873
|
return family.kind === KIND_ALLOW_LIST
|
|
580
|
-
?
|
|
874
|
+
? [
|
|
875
|
+
...compareHumanGateMode(relPath, baselineText, currentText),
|
|
876
|
+
...unreadableDeclaration(relPath, base),
|
|
877
|
+
]
|
|
581
878
|
: [unparseable(relPath)];
|
|
582
879
|
}
|
|
583
880
|
switch (family.kind) {
|
|
@@ -595,6 +892,7 @@ export function compareFile(relPath, baselineText, currentText) {
|
|
|
595
892
|
return compareLighthouse(relPath, base, current);
|
|
596
893
|
case KIND_ALLOW_LIST:
|
|
597
894
|
return [
|
|
895
|
+
...compareHumanGateMode(relPath, baselineText, currentText),
|
|
598
896
|
...compareAllowList(relPath, base, current),
|
|
599
897
|
...compareDeclaredThresholds(relPath, base, current),
|
|
600
898
|
];
|
|
@@ -641,6 +939,102 @@ export function describeAllowList(allowEntries, now = Date.now()) {
|
|
|
641
939
|
return lines;
|
|
642
940
|
}
|
|
643
941
|
|
|
942
|
+
/**
|
|
943
|
+
* One allow entry as a comparable string: its scope, reason and end.
|
|
944
|
+
* @param {{ file: string, key: string, reason?: unknown, until?: unknown }} entry An allow entry
|
|
945
|
+
* @returns {string} A string equal for two entries that say the same thing
|
|
946
|
+
*/
|
|
947
|
+
function entryIdentity(entry) {
|
|
948
|
+
return JSON.stringify([
|
|
949
|
+
entry.file,
|
|
950
|
+
entry.key,
|
|
951
|
+
entry.reason ?? null,
|
|
952
|
+
entry.until ?? null,
|
|
953
|
+
]);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Split the allow entries on HEAD into those a protected branch already holds
|
|
958
|
+
* and those that exist only on this branch.
|
|
959
|
+
*
|
|
960
|
+
* At commit and at edit the baseline is HEAD, and HEAD is whatever this branch
|
|
961
|
+
* last committed. Once an entry-only change can be committed (#5099), reading
|
|
962
|
+
* the allow list from HEAD alone would let commit one record an exception and
|
|
963
|
+
* commit two use it, with nothing merged — the self-grant, split in two. So in
|
|
964
|
+
* those modes an entry counts only when it is also on a protected branch as
|
|
965
|
+
* the remote last reported it: the same "exempts nothing until it is merged"
|
|
966
|
+
* rule the pull-request check applies by comparing against the base.
|
|
967
|
+
*
|
|
968
|
+
* An entry is the same entry only when its scope, reason and end all match. A
|
|
969
|
+
* local edit to a merged entry — a later `until`, say — is not the merged one.
|
|
970
|
+
* @param {Array<{ file: string, key: string, reason?: unknown, until?: unknown }>} entries
|
|
971
|
+
* The allow list at HEAD
|
|
972
|
+
* @param {Array<Array<{ file: string, key: string, reason?: unknown, until?: unknown }>>} mergedLists
|
|
973
|
+
* The allow list of each protected branch that could be read
|
|
974
|
+
* @returns {{ merged: object[], unmerged: object[] }} Entries a protected
|
|
975
|
+
* branch holds, and entries only this branch holds
|
|
976
|
+
*/
|
|
977
|
+
export function splitMergedEntries(entries, mergedLists) {
|
|
978
|
+
const known = new Set(mergedLists.flat().map(entryIdentity));
|
|
979
|
+
return {
|
|
980
|
+
merged: entries.filter(entry => known.has(entryIdentity(entry))),
|
|
981
|
+
unmerged: entries.filter(entry => !known.has(entryIdentity(entry))),
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* Say which refused findings an unmerged entry would have covered, so the
|
|
987
|
+
* reader is not left wondering why a recorded exception did nothing.
|
|
988
|
+
* @param {Finding[]} blocked Findings still refused
|
|
989
|
+
* @param {Array<{ file: string, key: string }>} unmerged Entries only this
|
|
990
|
+
* branch holds
|
|
991
|
+
* @param {string[]} refs The protected branches that were consulted; empty
|
|
992
|
+
* when the remote's default branch could not be named
|
|
993
|
+
* @returns {string[]} One line per unmerged entry that covers a refused finding
|
|
994
|
+
*/
|
|
995
|
+
export function describeUnmergedCover(blocked, unmerged, refs) {
|
|
996
|
+
const why =
|
|
997
|
+
refs.length === 0
|
|
998
|
+
? `is recorded on this branch, and which branch of the remote named origin is its default could not be determined, so nothing shows the entry is merged and it exempts nothing yet. Run "git fetch origin" and then "git remote set-head origin --auto", and try again.`
|
|
999
|
+
: `is recorded on this branch but is not on ${refs.join(" or ")}, so it exempts nothing yet. Merge the change that records it first; if it is already merged, run "git fetch" and try again. Only the remote named origin is consulted, and "git remote set-head origin --auto" refreshes which of its branches is the default.`;
|
|
1000
|
+
return unmerged
|
|
1001
|
+
.filter(entry => blocked.some(finding => entryCovers(entry, finding)))
|
|
1002
|
+
.map(entry => `${describeAllowScope(entry)} ${why}`);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* Explain a refusal that an exception on record looks meant for and misses.
|
|
1007
|
+
*
|
|
1008
|
+
* An entry is matched by its file and its exact key. One written with a key
|
|
1009
|
+
* that is nearly the threshold's — the name in the config file rather than
|
|
1010
|
+
* the name the ratchet gives it, say — is recorded without complaint, because
|
|
1011
|
+
* nothing at that moment says which threshold it is for. The first sign is
|
|
1012
|
+
* the refusal of the threshold change, which without this line reads as if
|
|
1013
|
+
* the exception had been ignored.
|
|
1014
|
+
* @param {Finding[]} blocked Findings still refused
|
|
1015
|
+
* @param {Array<{ file: string, key: string }>} entries Every allow entry on
|
|
1016
|
+
* record for this run, merged or not
|
|
1017
|
+
* @returns {string[]} One line per refused finding that an entry for the same
|
|
1018
|
+
* file names with a different key
|
|
1019
|
+
*/
|
|
1020
|
+
export function describeNearMisses(blocked, entries) {
|
|
1021
|
+
const lines = [];
|
|
1022
|
+
for (const finding of blocked) {
|
|
1023
|
+
if (finding.type === TYPE_ALLOW_ADDED) continue;
|
|
1024
|
+
const near = entries.filter(
|
|
1025
|
+
entry =>
|
|
1026
|
+
!entryCovers(entry, finding) &&
|
|
1027
|
+
entryCovers({ file: entry.file, key: "*" }, finding)
|
|
1028
|
+
);
|
|
1029
|
+
if (near.length === 0) continue;
|
|
1030
|
+
const keys = [...new Set(near.map(entry => `"${entry.key}"`))].join(", ");
|
|
1031
|
+
lines.push(
|
|
1032
|
+
`${finding.file}: an exception on record for this file names ${keys}, which is not this threshold's key "${finding.key}", so it does not cover it. ${COVER_RULE}`
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
return lines;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
644
1038
|
/**
|
|
645
1039
|
* Drop findings covered by a LIVE baseline-side allow entry.
|
|
646
1040
|
*
|
|
@@ -682,7 +1076,7 @@ export function applyAllowList(findings, allowEntries, now = Date.now()) {
|
|
|
682
1076
|
const expired = [];
|
|
683
1077
|
for (const finding of findings) {
|
|
684
1078
|
const covering =
|
|
685
|
-
finding.type ===
|
|
1079
|
+
finding.type === TYPE_ALLOW_ADDED
|
|
686
1080
|
? []
|
|
687
1081
|
: classified.filter(c => entryCovers(c.entry, finding));
|
|
688
1082
|
const live = covering.find(c => c.state !== ALLOW_STATE.EXPIRED);
|
|
@@ -708,11 +1102,33 @@ export function applyAllowList(findings, allowEntries, now = Date.now()) {
|
|
|
708
1102
|
|
|
709
1103
|
/**
|
|
710
1104
|
* Render the operator-facing block message.
|
|
1105
|
+
*
|
|
1106
|
+
* The closing paragraph names the way to an exception, and it must name one
|
|
1107
|
+
* the check accepts. Under the default policy that is an entry merged in a
|
|
1108
|
+
* change of its own; under `strict` it stays a person's separate change.
|
|
711
1109
|
* @param {Finding[]} findings Blocked findings
|
|
1110
|
+
* @param {string} [mode] The repository's `humanGate.mode`
|
|
712
1111
|
* @returns {string} Multi-line report explaining what weakened and the
|
|
713
|
-
*
|
|
1112
|
+
* exception path
|
|
714
1113
|
*/
|
|
715
|
-
export function formatReport(findings) {
|
|
1114
|
+
export function formatReport(findings, mode = HUMAN_GATE_ACCESS_ONLY) {
|
|
1115
|
+
const wayOut =
|
|
1116
|
+
mode === HUMAN_GATE_ACCESS_ONLY
|
|
1117
|
+
? [
|
|
1118
|
+
"gate. If the regression is justified, record an exception in",
|
|
1119
|
+
".lisa.config.json under thresholdRatchet.allow — with a reason saying",
|
|
1120
|
+
'what resolves it, and an "until": "YYYY-MM-DD" naming the day it is',
|
|
1121
|
+
"reviewed — and merge it in a change of its own first; this check honors",
|
|
1122
|
+
"an exception only after it is merged, and only until its until date",
|
|
1123
|
+
"passes.",
|
|
1124
|
+
]
|
|
1125
|
+
: [
|
|
1126
|
+
"gate. If a human decides an exception is genuinely correct, they record it",
|
|
1127
|
+
"in .lisa.config.json under thresholdRatchet.allow — with a reason saying",
|
|
1128
|
+
'what resolves it, and an "until": "YYYY-MM-DD" naming the day it is',
|
|
1129
|
+
"reviewed — in a separate human-approved change; this check honors an",
|
|
1130
|
+
"exception only after it is merged, and only until its until date passes.",
|
|
1131
|
+
];
|
|
716
1132
|
return [
|
|
717
1133
|
"⛔ Quality gate weakened — blocked by the threshold ratchet.",
|
|
718
1134
|
"",
|
|
@@ -720,10 +1136,6 @@ export function formatReport(findings) {
|
|
|
720
1136
|
"",
|
|
721
1137
|
"Quality thresholds are a one-way ratchet: they may tighten but never",
|
|
722
1138
|
"loosen. Fix the code so it meets the current gate instead of lowering the",
|
|
723
|
-
|
|
724
|
-
"in .lisa.config.json under thresholdRatchet.allow — with a reason saying",
|
|
725
|
-
'what resolves it, and an "until": "YYYY-MM-DD" naming the day it is',
|
|
726
|
-
"reviewed — in a separate human-approved change; this check honors an",
|
|
727
|
-
"exception only after it is merged, and only until its until date passes.",
|
|
1139
|
+
...wayOut,
|
|
728
1140
|
].join("\n");
|
|
729
1141
|
}
|
|
@@ -572,6 +572,80 @@ export function extractAllowEntries(config) {
|
|
|
572
572
|
);
|
|
573
573
|
}
|
|
574
574
|
|
|
575
|
+
/** The `humanGate.mode` under which an agent records a risk acceptance. */
|
|
576
|
+
export const HUMAN_GATE_ACCESS_ONLY = "access-only";
|
|
577
|
+
/** The `humanGate.mode` under which a threshold exception stays a person's. */
|
|
578
|
+
export const HUMAN_GATE_STRICT = "strict";
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* The `humanGate.mode` a config declares, as the ratchet reads it.
|
|
582
|
+
*
|
|
583
|
+
* Same rule as `resolveHumanGateMode` in `scripts/human-gate-act.mjs`, written
|
|
584
|
+
* out here because this module ships inside a plugin payload and into host
|
|
585
|
+
* `scripts/` folders, and neither has that script beside it: only an absent
|
|
586
|
+
* mode is the default, `access-only`; a declared value is compared trimmed and
|
|
587
|
+
* lower-cased; and a value that is not a known mode fails safe, to `strict`,
|
|
588
|
+
* so a typo never loosens the gate.
|
|
589
|
+
*
|
|
590
|
+
* The caller passes the BASELINE config, the side the allow list is read from.
|
|
591
|
+
* A change therefore cannot relax the mode and add an exception in one step,
|
|
592
|
+
* and a personal `.lisa.config.local.json` — which no baseline holds — cannot
|
|
593
|
+
* relax it at all.
|
|
594
|
+
* @param {unknown} config Parsed `.lisa.config.json`, or nothing when the
|
|
595
|
+
* baseline has none
|
|
596
|
+
* @returns {"access-only" | "strict"} The mode in force
|
|
597
|
+
*/
|
|
598
|
+
export function humanGateModeOf(config) {
|
|
599
|
+
if (!config || typeof config !== "object") return HUMAN_GATE_ACCESS_ONLY;
|
|
600
|
+
const block = config.humanGate;
|
|
601
|
+
if (block === undefined) return HUMAN_GATE_ACCESS_ONLY;
|
|
602
|
+
// A block that is present and is not an object declared something nobody
|
|
603
|
+
// can read. The other resolvers of this key fail safe on it, and so does
|
|
604
|
+
// this one: a malformed block must not read as "nothing declared".
|
|
605
|
+
if (block === null || typeof block !== "object" || Array.isArray(block)) {
|
|
606
|
+
return HUMAN_GATE_STRICT;
|
|
607
|
+
}
|
|
608
|
+
const declared = block.mode;
|
|
609
|
+
if (declared === undefined) return HUMAN_GATE_ACCESS_ONLY;
|
|
610
|
+
const mode =
|
|
611
|
+
typeof declared === "string" ? declared.trim().toLowerCase() : declared;
|
|
612
|
+
return mode === HUMAN_GATE_ACCESS_ONLY
|
|
613
|
+
? HUMAN_GATE_ACCESS_ONLY
|
|
614
|
+
: HUMAN_GATE_STRICT;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* The `humanGate.mode` of a `.lisa.config.json` given as text.
|
|
619
|
+
*
|
|
620
|
+
* Absent and unreadable are opposite cases and must not be conflated. A
|
|
621
|
+
* repository with no config at the baseline declared nothing, so the default
|
|
622
|
+
* applies. A config that is there and does not parse declared something
|
|
623
|
+
* nobody can read, and that fails safe like any other unreadable declaration.
|
|
624
|
+
* @param {string | null | undefined} text The file's text, or nothing when the
|
|
625
|
+
* baseline has no such file
|
|
626
|
+
* @returns {"access-only" | "strict"} The mode in force
|
|
627
|
+
*/
|
|
628
|
+
export function humanGateModeOfText(text) {
|
|
629
|
+
if (text === null || text === undefined) return HUMAN_GATE_ACCESS_ONLY;
|
|
630
|
+
const config = parseJson(text);
|
|
631
|
+
const readable =
|
|
632
|
+
config !== null && typeof config === "object" && !Array.isArray(config);
|
|
633
|
+
return readable ? humanGateModeOf(config) : HUMAN_GATE_STRICT;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* An allow entry's reason as one line of text.
|
|
638
|
+
*
|
|
639
|
+
* A reason is written by whoever records the entry and is printed into the
|
|
640
|
+
* check's own output. Left raw, a line break inside it starts a new line that
|
|
641
|
+
* reads as the check speaking, so every run of whitespace becomes one space.
|
|
642
|
+
* @param {unknown} reason The entry's `reason`
|
|
643
|
+
* @returns {string} The reason on one line; empty when there is none
|
|
644
|
+
*/
|
|
645
|
+
export function reasonInWords(reason) {
|
|
646
|
+
return typeof reason === "string" ? reason.replace(/\s+/gu, " ").trim() : "";
|
|
647
|
+
}
|
|
648
|
+
|
|
575
649
|
/**
|
|
576
650
|
* The three states an allow entry's expiry condition can be in.
|
|
577
651
|
*
|
|
@@ -667,10 +741,9 @@ export function describeAllowScope(entry) {
|
|
|
667
741
|
*/
|
|
668
742
|
export function classifyAllowEntry(entry, now) {
|
|
669
743
|
const scope = describeAllowScope(entry);
|
|
744
|
+
const reason = reasonInWords(entry.reason);
|
|
670
745
|
const because =
|
|
671
|
-
|
|
672
|
-
? ` Reason on record: ${entry.reason.trim()}`
|
|
673
|
-
: " No reason is recorded.";
|
|
746
|
+
reason === "" ? " No reason is recorded." : ` Reason on record: ${reason}`;
|
|
674
747
|
const expiresAt = allowEntryExpiry(entry.until);
|
|
675
748
|
if (expiresAt === undefined) {
|
|
676
749
|
const summary = `names no condition anything can evaluate (until = ${JSON.stringify(entry.until ?? null)})`;
|
|
@@ -688,7 +761,7 @@ export function classifyAllowEntry(entry, now) {
|
|
|
688
761
|
state: ALLOW_STATE.EXPIRED,
|
|
689
762
|
scope,
|
|
690
763
|
summary,
|
|
691
|
-
detail: `${scope} ${summary} and no longer exempts anything. Delete it, or record a fresh
|
|
764
|
+
detail: `${scope} ${summary} and no longer exempts anything. Delete it, or record a fresh entry naming the new condition.${because}`,
|
|
692
765
|
};
|
|
693
766
|
}
|
|
694
767
|
const summary = `is live until ${day}`;
|