archivo del paquete→ .shtukbase/packages/owner/checks/provisional.ts
checks/provisional.ts
29 líneas, 1.5 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // AUT-R01. A decision or a question marked `provisional: true` has `provisionalBasis` (why this answer) and
- // `waitsFor` (what answer it waits for). When `waitsFor` leads to a question that is already answered, the mark is
- // due to be removed or the decision redone.
- // The shared part is norms-core's (this package requires it), side by side in .shtukbase/packages/.
- import { type Head, address, main, records, status, values } from '../../norms-core/checks/pagelib.ts';
- const QUESTIONS = 'knowledge/questions';
- export const RULE = { id: 'aut-r01', title: 'A provisional decision with a basis and what it waits for' };
- export function check(): string[] {
- const questions = new Map<string, Head>();
- for (const [addr, head] of records(QUESTIONS)) questions.set(addr, head);
- const out: string[] = [];
- for (const folder of ['knowledge/decisions', QUESTIONS]) {
- for (const [addr, head] of records(folder)) {
- if (head.provisional !== true) continue;
- const miss = ['provisionalBasis', 'waitsFor'].filter((f) => !values(head[f]).length);
- if (miss.length) out.push(`${addr}: provisional, but ${miss.join(', ')} not filled`);
- for (const ref of values(head.waitsFor)) {
- const q = questions.get(address(ref));
- if (q !== undefined && status(q) === 'answered') out.push(`${addr}: the answer to ${address(ref)} has come — remove provisional or rework the decision`);
- }
- }
- }
- return out;
- }
- if (import.meta.main) main({ RULE, check });