ShtukbaseStandard
файл пакета→ .shtukbase/packages/norms-core/checks/floor.ts

checks/floor.ts

26 строк, 1.0 КБ.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. // NS-R04 (the waiver part). A waiver from a rule with `floor: true` can only be refused: a requested or allowed
  2. // waiver from a floor rule is a finding.
  3. import { type Head, address, main, records, status, values } from './pagelib.ts';
  4. const DONE = ['refused', 'closed'];
  5. export const RULE = { id: 'ns-r04', title: 'No open waivers of floor norms' };
  6. export function check(): string[] {
  7. const rules = new Map<string, Head>();
  8. for (const [addr, head] of records('norms/rules')) {
  9. rules.set(addr, head);
  10. for (const rid of values(head.ruleId)) rules.set(rid, head);
  11. }
  12. const out: string[] = [];
  13. for (const [addr, head] of records('norms/waivers')) {
  14. if (DONE.includes(status(head))) continue;
  15. for (const ref of values(head.rule)) {
  16. const rule = rules.get(address(ref)) ?? rules.get(ref);
  17. if (rule !== undefined && rule.floor === true) out.push(`${addr}: a waiver of the floor norm ${ref} — the floor is not weakened, a waiver can only be rejected`);
  18. }
  19. }
  20. return out;
  21. }
  22. if (import.meta.main) main({ RULE, check });