包文件→ .shtukbase/packages/norms-core/checks/floor.ts
checks/floor.ts
26 行, 1.0 KB.
文件按包中的原样显示:代码及其注释不做翻译。
- // NS-R04 (the waiver part). A waiver from a rule with `floor: true` can only be refused: a requested or allowed
- // waiver from a floor rule is a finding.
- import { type Head, address, main, records, status, values } from './pagelib.ts';
- const DONE = ['refused', 'closed'];
- export const RULE = { id: 'ns-r04', title: 'No open waivers of floor norms' };
- export function check(): string[] {
- const rules = new Map<string, Head>();
- for (const [addr, head] of records('norms/rules')) {
- rules.set(addr, head);
- for (const rid of values(head.ruleId)) rules.set(rid, head);
- }
- const out: string[] = [];
- for (const [addr, head] of records('norms/waivers')) {
- if (DONE.includes(status(head))) continue;
- for (const ref of values(head.rule)) {
- const rule = rules.get(address(ref)) ?? rules.get(ref);
- 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`);
- }
- }
- return out;
- }
- if (import.meta.main) main({ RULE, check });