ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/content/checks/c01_approval.ts

checks/c01_approval.ts

28 líneas, 1.8 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // CNT-R01. Approved and published drafts (and approved ideas) were approved by a person: approvedBy is filled and is
  2. // not an agent (an /agents/ path, an agent page name or title, a harness or model name); a draft has approvedOn, and
  3. // publishedOn is not before it.
  4. import { FOLDERS, agentNames, phase, records, report, text } from '../lib/content.ts';
  5. const out: string[] = [];
  6. const agents = agentNames();
  7. const isAgent = (who: string) => {
  8. const w = who.toLowerCase().replace(/\.md$/, '');
  9. return w.startsWith('/agents/') || w.startsWith('agents/') || agents.has(w) || [...agents].some((a) => a.length > 3 && w.includes(a) && a.startsWith('/agents/'));
  10. };
  11. const scope: string[] = [];
  12. for (const [folder, states] of [[FOLDERS.drafts, ['approved', 'published']], [FOLDERS.ideas, ['approved', 'drafted']]] as const) {
  13. for (const r of records(folder)) {
  14. const st = phase(r.fm.status);
  15. if (!(states as readonly string[]).includes(st)) continue;
  16. scope.push(r.id);
  17. const who = text(r.fm.approvedBy);
  18. if (!who) out.push(`${r.id}: state ${st}, but approvedBy is empty → a person approves and writes their name [no-approver]`);
  19. else if (isAgent(who)) out.push(`${r.id}: approved by "${who}", which is an agent, and only a person approves → return status: ${folder === FOLDERS.drafts ? 'review' : 'new'} and clear approvedBy [agent-approver]`);
  20. if (folder !== FOLDERS.drafts) continue;
  21. const on = text(r.fm.approvedOn);
  22. if (!on) out.push(`${r.id}: no approval day approvedOn → write YYYY-MM-DD [no-date]`);
  23. const pub = text(r.fm.publishedOn);
  24. if (st === 'published' && on && pub && pub < on) out.push(`${r.id}: published ${pub}, before the approval ${on} → fix the dates [published-before-approved]`);
  25. }
  26. }
  27. report(out, `approved drafts and ideas (${scope.length})`);