package file→ .shtukbase/packages/norms-core/checks/review.ts
checks/review.ts
24 lines, 1.1 KB.
- // NS-R05. A norm with `shelfLife.class: fast` has reviewBy; a live norm past its reviewBy is due for review.
- import { day, main, records, status, today } from './pagelib.ts';
- import { pystr } from '../../collections/checks/lib/pages.ts';
- const DEAD = ['rejected', 'retired', 'replaced'];
- export const RULE = { id: 'ns-r05', title: 'The review date of a norm has not passed' };
- export function check(): string[] {
- const out: string[] = [];
- for (const folder of ['norms/rules', 'norms/principles', 'norms/defaults']) {
- for (const [addr, head] of records(folder)) {
- if (DEAD.includes(status(head))) continue;
- const life = head.shelfLife;
- const fast = !!life && typeof life === 'object' && !Array.isArray(life) && (life.class ? pystr(life.class) : '').trim() === 'fast';
- const when = day(head.reviewBy);
- if (fast && when === null) out.push(`${addr}: a fast norm (shelfLife.class: fast) without reviewBy`);
- if (when !== null && when < today()) out.push(`${addr}: the review date ${when} has passed — review the norm and set a new date`);
- }
- }
- return out;
- }
- if (import.meta.main) main({ RULE, check });