@su-sws/synthetic-web-team 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/packages/cli/bin/sws.mjs +11 -2
- package/packages/cli/src/checks.mjs +59 -12
- package/packages/cli/src/divergences.mjs +68 -0
- package/packages/cli/src/history.mjs +1 -0
- package/packages/cli/src/report.mjs +23 -7
- package/packages/wizard/src/emit.mjs +3 -1
- package/skills/sws-compliance-check/SKILL.md +7 -1
- package/skills/sws-diverge/SKILL.md +18 -2
- package/standards/recipes/astro-static/acceptance.yml +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-sws/synthetic-web-team",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Stanford Web Services standards and agent team: policy, patterns, recipes, fragments, prior art, 31 skills, the two-part install wizard, and the advisory compliance CLI.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"sync-skills": "node scripts/sync-skills.mjs",
|
|
12
|
-
"validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-install.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs && node scripts/validate-hooks.mjs && node scripts/validate-acknowledged.mjs && node scripts/validate-layouts.mjs",
|
|
12
|
+
"validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-install.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs && node scripts/validate-hooks.mjs && node scripts/validate-acknowledged.mjs && node scripts/validate-layouts.mjs && node scripts/validate-divergences.mjs && node scripts/validate-frameworks.mjs",
|
|
13
13
|
"check": "npm run validate && npm run sync-skills -- --check",
|
|
14
14
|
"pack:all": "mkdir -p .pack && npm pack --pack-destination ./.pack && npm pack -w @su-sws/synthetic-web-team-mcp --pack-destination ./.pack"
|
|
15
15
|
},
|
package/packages/cli/bin/sws.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import * as gh from '../src/github.mjs';
|
|
|
25
25
|
import { preflight, summarise } from '../src/preflight.mjs';
|
|
26
26
|
import { findStandards as locateStandards } from '../src/standards.mjs';
|
|
27
27
|
import { loadAcknowledged, applyAcknowledgements, sha256 } from '../src/acknowledged.mjs';
|
|
28
|
+
import { loadDivergences, applyDivergences } from '../src/divergences.mjs';
|
|
28
29
|
// Sibling directory inside the same published package (@su-sws/synthetic-web-team), so this
|
|
29
30
|
// relative path resolves in the repository and in a tarball alike. One reader
|
|
30
31
|
// of the install record means the CLI and the wizard cannot disagree about what
|
|
@@ -255,10 +256,13 @@ async function run() {
|
|
|
255
256
|
// criterion still reports, at weight 0, so a check is never silently dropped.
|
|
256
257
|
const byId = new Map((acceptance.criteria || []).map((c) => [c.id, c]));
|
|
257
258
|
const ack = loadAcknowledged(root);
|
|
259
|
+
const divergences = loadDivergences(root);
|
|
258
260
|
const now = new Date();
|
|
259
261
|
|
|
260
262
|
// An acknowledgement covers what it names, not the whole check: see
|
|
261
263
|
// src/acknowledged.mjs. Entries a blocking check cannot honour are reported.
|
|
264
|
+
// Then a divergence that names a check still failing explains it, for checks
|
|
265
|
+
// that are preferences rather than requirements: see src/divergences.mjs.
|
|
262
266
|
const findings = raw.map((f) => {
|
|
263
267
|
const c = byId.get(f.id) || {};
|
|
264
268
|
const blocking = Boolean(f.blocking || c.severity === 'block');
|
|
@@ -267,13 +271,18 @@ async function run() {
|
|
|
267
271
|
if (a?.ignored.length) {
|
|
268
272
|
console.error(` warning: ${a.ignored.length} acknowledgement(s) for ${f.id} ignored; the report says why.`);
|
|
269
273
|
}
|
|
274
|
+
const afterAck = { ...f, state: a?.state ?? f.state, detail: a?.detail ?? f.detail };
|
|
275
|
+
const d = applyDivergences(afterAck, divergences, { blocking, policy: c.policy ?? null });
|
|
276
|
+
if (d?.ignored.length) {
|
|
277
|
+
console.error(` warning: ${d.ignored.length} divergence(s) naming ${f.id} ignored; the report says why.`);
|
|
278
|
+
}
|
|
270
279
|
// The value hashes were for matching entries, just above. Nothing below
|
|
271
280
|
// this line, no report, comment or artifact, gets to see them.
|
|
272
281
|
const locations = (a?.locations ?? f.locations)?.map(({ sha256: _hash, ...l }) => l);
|
|
273
282
|
return {
|
|
274
283
|
...f,
|
|
275
|
-
state:
|
|
276
|
-
detail:
|
|
284
|
+
state: d?.state ?? afterAck.state,
|
|
285
|
+
detail: d?.detail ?? afterAck.detail,
|
|
277
286
|
...(locations ? { locations } : {}),
|
|
278
287
|
weight: c.weight ?? 0,
|
|
279
288
|
severity: c.severity ?? 'warn',
|
|
@@ -99,6 +99,26 @@ export function projectFiles(root) {
|
|
|
99
99
|
return files.sort((a, b) => depth(a) - depth(b) || a.localeCompare(b));
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// The framework the project is built with: 'next', 'astro', or null for a
|
|
103
|
+
// static site with neither. A check written for one framework never runs on
|
|
104
|
+
// another, because its advice is wrong there: Astro sets response headers in
|
|
105
|
+
// host config, Next in headers(); Astro's canonical URLs come from `site`,
|
|
106
|
+
// Next's from metadataBase. Next wins if a project somehow has both.
|
|
107
|
+
export function framework(root) {
|
|
108
|
+
const d = deps(root);
|
|
109
|
+
if (nextConfig(root) || d.next) return 'next';
|
|
110
|
+
if (['astro.config.mjs', 'astro.config.js', 'astro.config.ts'].some((f) => existsSync(join(root, f))) || d.astro) {
|
|
111
|
+
return 'astro';
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Source without its comments, so a check reading config never counts a
|
|
117
|
+
// commented-out line: `// key: 'Content-Security-Policy'` is not a CSP. Line
|
|
118
|
+
// comments are only taken where `//` cannot be part of a URL in a string.
|
|
119
|
+
const withoutJsComments = (s) => s.replace(/\/\*[\s\S]*?\*\//g, '').replace(/(^|[^:'"`\\])\/\/.*$/gm, '$1');
|
|
120
|
+
const withoutTomlComments = (s) => s.replace(/^\s*#.*$/gm, '');
|
|
121
|
+
|
|
102
122
|
// --------------------------------------------------------------------------
|
|
103
123
|
// footer: reads the contract, never hardcodes the link set
|
|
104
124
|
// --------------------------------------------------------------------------
|
|
@@ -456,16 +476,23 @@ export function seo({ root, html, dist }) {
|
|
|
456
476
|
? bad('seo.meta-description', `${noDesc.length} page(s) without one: ${noDesc.slice(0, 3).join(', ')}`)
|
|
457
477
|
: ok('seo.meta-description', 'all pages have a meta description'));
|
|
458
478
|
|
|
479
|
+
// The fix depends on the framework: Astro derives canonical URLs and the
|
|
480
|
+
// sitemap from `site`; Next from the metadata API and app/sitemap.ts.
|
|
481
|
+
const isNext = framework(root) === 'next';
|
|
459
482
|
out.push(noCanon.length
|
|
460
483
|
? bad('seo.canonical', `${noCanon.length} page(s) without a canonical link`,
|
|
461
|
-
|
|
484
|
+
isNext
|
|
485
|
+
? "Set `alternates.canonical` in each page's metadata, with `metadataBase` in the root layout so it resolves absolutely."
|
|
486
|
+
: 'Requires `site` set in the framework config. Missing `site` also silently breaks the sitemap.')
|
|
462
487
|
: ok('seo.canonical', 'canonical links present'));
|
|
463
488
|
|
|
464
489
|
const sitemap = ['sitemap-index.xml', 'sitemap.xml'].find((f) => existsSync(join(dist, f)));
|
|
465
490
|
out.push(sitemap
|
|
466
491
|
? ok('seo.sitemap', `${sitemap} emitted`)
|
|
467
492
|
: bad('seo.sitemap', 'no sitemap in the build output',
|
|
468
|
-
|
|
493
|
+
isNext
|
|
494
|
+
? 'Add app/sitemap.ts, which Next serves at /sitemap.xml.'
|
|
495
|
+
: 'Add @astrojs/sitemap and set `site` in the config.'));
|
|
469
496
|
|
|
470
497
|
const robotsPath = join(dist, 'robots.txt');
|
|
471
498
|
if (!existsSync(robotsPath)) {
|
|
@@ -1339,14 +1366,34 @@ const DEFAULT_HEADER_SET = [
|
|
|
1339
1366
|
['X-Frame-Options', 'frame options'],
|
|
1340
1367
|
];
|
|
1341
1368
|
|
|
1369
|
+
// Where a CSP comes from, if anywhere: the Next config's headers(), the Netlify
|
|
1370
|
+
// plugin that adds a per-request nonce, or host config. Bodies are read
|
|
1371
|
+
// without comments, so a commented-out policy is not one.
|
|
1372
|
+
function cspSource(root, nextBody, host) {
|
|
1373
|
+
if (nextBody && /Content-Security-Policy/i.test(nextBody)) return 'headers() in the Next config';
|
|
1374
|
+
if (deps(root)['@netlify/plugin-csp-nonce']
|
|
1375
|
+
|| (host?.kind === 'netlify' && /@netlify\/plugin-csp-nonce/.test(host.body))) return '@netlify/plugin-csp-nonce';
|
|
1376
|
+
if (host && /Content-Security-Policy/i.test(host.body)) return host.file;
|
|
1377
|
+
return null;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1342
1380
|
export function security({ root }) {
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1381
|
+
const found = nextConfig(root);
|
|
1382
|
+
const cfg = found && { ...found, body: withoutJsComments(found.body) };
|
|
1383
|
+
const rawHost = hostConfig(root);
|
|
1384
|
+
const host = rawHost && {
|
|
1385
|
+
...rawHost, body: rawHost.kind === 'netlify' ? withoutTomlComments(rawHost.body) : rawHost.body,
|
|
1386
|
+
};
|
|
1345
1387
|
const out = [];
|
|
1346
1388
|
|
|
1347
|
-
//
|
|
1348
|
-
//
|
|
1349
|
-
|
|
1389
|
+
// Headers in host config: how Astro and a static build send them, because
|
|
1390
|
+
// Astro middleware misses prerendered routes. Never on a Next project, which
|
|
1391
|
+
// sets them in headers() for every route, static files included, and
|
|
1392
|
+
// security.headers-set checks that instead.
|
|
1393
|
+
out.push(framework(root) === 'next'
|
|
1394
|
+
? na('astro.headers-in-host-config',
|
|
1395
|
+
'a Next project: response headers come from headers() in the Next config (see security.headers-set)')
|
|
1396
|
+
: host
|
|
1350
1397
|
? (() => {
|
|
1351
1398
|
const missing = DEFAULT_HEADER_SET.filter(([h]) => !new RegExp(h, 'i').test(host.body)).map(([, l]) => l);
|
|
1352
1399
|
return missing.length
|
|
@@ -1377,15 +1424,15 @@ export function security({ root }) {
|
|
|
1377
1424
|
// header that breaks pages at CONTENT-EDIT time rather than at deploy time.
|
|
1378
1425
|
// MinWeb requires no response headers at all. The default header set below
|
|
1379
1426
|
// is what we actually ask for, because none of it can break a page.
|
|
1427
|
+
const csp = cspSource(root, hasHeaders ? b : null, host);
|
|
1428
|
+
out.push(csp
|
|
1429
|
+
? ok('security.csp-present', `CSP set by ${csp}; record it in .sws/manifest.yml`)
|
|
1430
|
+
: ok('security.csp-present', 'no CSP, which is compliant: CSP is optional'));
|
|
1380
1431
|
if (!hasHeaders) {
|
|
1381
|
-
out.push(ok('security.csp-present', 'no CSP, which is compliant: CSP is optional'));
|
|
1382
1432
|
out.push(bad('security.headers-set', 'no headers() function in the Next config',
|
|
1383
1433
|
'Add headers() returning the default set: HSTS, nosniff, Referrer-Policy, ' +
|
|
1384
1434
|
'Permissions-Policy, and X-Frame-Options: SAMEORIGIN. See standards/hosting/capabilities.yml.'));
|
|
1385
1435
|
} else {
|
|
1386
|
-
out.push(/Content-Security-Policy/i.test(b)
|
|
1387
|
-
? ok('security.csp-present', 'CSP configured in headers(); record it in .sws/manifest.yml')
|
|
1388
|
-
: ok('security.csp-present', 'no CSP, which is compliant: CSP is optional'));
|
|
1389
1436
|
|
|
1390
1437
|
const want = [
|
|
1391
1438
|
['Strict-Transport-Security', 'HSTS'],
|
|
@@ -1422,7 +1469,7 @@ export function security({ root }) {
|
|
|
1422
1469
|
|
|
1423
1470
|
export function next({ root, html }) {
|
|
1424
1471
|
const cfg = nextConfig(root);
|
|
1425
|
-
const isNext =
|
|
1472
|
+
const isNext = framework(root) === 'next';
|
|
1426
1473
|
if (!isNext) {
|
|
1427
1474
|
return ['next.postcss-configured', 'next.no-vite-tailwind', 'next.no-tailwind-config', 'next.metadata-base']
|
|
1428
1475
|
.map((id) => na(id, 'not a Next project'));
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Divergences that cover checks.
|
|
2
|
+
//
|
|
3
|
+
// A divergence in .sws/manifest.yml records a deliberate departure from the
|
|
4
|
+
// recipe. Naming the checks it explains, in `checks:`, moves those findings out
|
|
5
|
+
// of the nag and into a "Divergences" section of the report, with the reason
|
|
6
|
+
// beside them. Without that, a choice made on purpose and written down still
|
|
7
|
+
// read as "Should fix" on every run, and the only way to quiet it was an
|
|
8
|
+
// accepted risk with a review date, which says "fix later" about something that
|
|
9
|
+
// will never change.
|
|
10
|
+
//
|
|
11
|
+
// A divergence covers a preference, never a requirement. Checks whose criterion
|
|
12
|
+
// carries a policy (accessibility, brand, MinWeb, MinSec, MinPriv) are what the
|
|
13
|
+
// sws-diverge skill calls "what never bends": a person can still decline one,
|
|
14
|
+
// in .sws/acknowledged.yml, where it stays an accepted risk with a review date.
|
|
15
|
+
// So an entry naming one is ignored, and the report says so.
|
|
16
|
+
|
|
17
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
import YAML from 'yaml';
|
|
20
|
+
|
|
21
|
+
/** Policies a divergence may cover: SWS's own conventions, and unclassified criteria. */
|
|
22
|
+
const PREFERENCE = new Set(['patterns', null, undefined]);
|
|
23
|
+
|
|
24
|
+
/** The manifest's divergences that name at least one check, with `checks` as an array. */
|
|
25
|
+
export function loadDivergences(root) {
|
|
26
|
+
const p = join(root, '.sws', 'manifest.yml');
|
|
27
|
+
if (!existsSync(p)) return [];
|
|
28
|
+
let m;
|
|
29
|
+
try { m = YAML.parse(readFileSync(p, 'utf8')) || {}; } catch { return []; }
|
|
30
|
+
const divs = Array.isArray(m.divergences) ? m.divergences : [];
|
|
31
|
+
return divs
|
|
32
|
+
.map((d) => ({ ...d, checks: [].concat(d?.checks ?? []).filter((c) => typeof c === 'string') }))
|
|
33
|
+
.filter((d) => d.checks.length);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Applies the divergences that name a failing finding.
|
|
38
|
+
*
|
|
39
|
+
* Returns null when none names it or the finding is not a failure. Otherwise
|
|
40
|
+
* `{ state, detail, ignored }`: `diverged` with the reason when an entry covers
|
|
41
|
+
* it, or the finding's own state with a note when every entry naming it was
|
|
42
|
+
* ignored because the check is a requirement.
|
|
43
|
+
*/
|
|
44
|
+
export function applyDivergences(finding, divergences, { blocking, policy }) {
|
|
45
|
+
if (finding.state !== 'fail') return null;
|
|
46
|
+
const entries = divergences.filter((d) => d.checks.includes(finding.id));
|
|
47
|
+
if (!entries.length) return null;
|
|
48
|
+
|
|
49
|
+
if (blocking || !PREFERENCE.has(policy)) {
|
|
50
|
+
const why = blocking ? 'it is the blocking check' : `it is a ${policy} requirement`;
|
|
51
|
+
return {
|
|
52
|
+
state: finding.state,
|
|
53
|
+
detail: `${finding.detail} (divergence ignored: ${why}, so a divergence cannot cover it; ` +
|
|
54
|
+
'accept the risk in .sws/acknowledged.yml instead)',
|
|
55
|
+
ignored: entries,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const reasons = [...new Set(entries.map((d) => d.reason).filter(Boolean))];
|
|
60
|
+
const what = [...new Set(entries.map((d) => d.changed).filter(Boolean))];
|
|
61
|
+
const note = reasons.length === 1 ? `: ${String(reasons[0]).trim().replace(/\s+/g, ' ')}` : '';
|
|
62
|
+
const label = what.length === 1 ? String(what[0]).trim().replace(/\s+/g, ' ') : 'recorded in .sws/manifest.yml';
|
|
63
|
+
return {
|
|
64
|
+
state: 'diverged',
|
|
65
|
+
detail: `${finding.detail} (divergence: ${label}${note})`,
|
|
66
|
+
ignored: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -132,6 +132,7 @@ export function entryFor({ score, findings, sha, ref, runId }) {
|
|
|
132
132
|
fail: findings.filter((f) => f.state === 'fail').length,
|
|
133
133
|
unknown: findings.filter((f) => f.state === 'unknown').length,
|
|
134
134
|
acknowledged: findings.filter((f) => f.state === 'acknowledged').length,
|
|
135
|
+
diverged: findings.filter((f) => f.state === 'diverged').length,
|
|
135
136
|
},
|
|
136
137
|
};
|
|
137
138
|
}
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
// would mean the score never recovers, and people would stop
|
|
12
12
|
// documenting risk acceptance, which is the behaviour we most
|
|
13
13
|
// want.
|
|
14
|
+
// diverged earns its weight, and the score is annotated, for the same
|
|
15
|
+
// reason: a deliberate choice written down is the behaviour the
|
|
16
|
+
// contract asks for. Only preferences can be diverged from.
|
|
14
17
|
// not_applicable excluded from the total entirely.
|
|
15
18
|
|
|
16
19
|
// Grouping is by what the reader can DO, not by policy chapter. Note every
|
|
@@ -23,22 +26,34 @@ const GROUPS = [
|
|
|
23
26
|
['Consider', (f) => f.state === 'fail'],
|
|
24
27
|
['Could not check', (f) => f.state === 'unknown'],
|
|
25
28
|
['Accepted risks', (f) => f.state === 'acknowledged'],
|
|
29
|
+
['Divergences', (f) => f.state === 'diverged'],
|
|
26
30
|
];
|
|
27
31
|
|
|
28
32
|
export function score(findings) {
|
|
29
|
-
let earned = 0, possible = 0, ack = 0;
|
|
33
|
+
let earned = 0, possible = 0, ack = 0, div = 0;
|
|
30
34
|
for (const f of findings) {
|
|
31
35
|
if (f.state === 'not_applicable' || !f.weight) continue;
|
|
32
36
|
possible += f.weight;
|
|
33
37
|
if (f.state === 'pass') earned += f.weight;
|
|
34
38
|
else if (f.state === 'acknowledged') { earned += f.weight; ack++; }
|
|
39
|
+
else if (f.state === 'diverged') { earned += f.weight; div++; }
|
|
35
40
|
}
|
|
36
41
|
return {
|
|
37
42
|
value: possible ? Math.round((earned / possible) * 100) : 100,
|
|
38
|
-
earned, possible, acknowledged: ack,
|
|
43
|
+
earned, possible, acknowledged: ack, diverged: div,
|
|
39
44
|
};
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
const plural = (n, word) => `${n} ${word}${n > 1 ? 's' : ''}`;
|
|
48
|
+
|
|
49
|
+
/** What the score includes besides passes, e.g. "1 accepted risk, 2 divergences", or ''. */
|
|
50
|
+
export function includes(sc) {
|
|
51
|
+
return [
|
|
52
|
+
sc.acknowledged ? plural(sc.acknowledged, 'accepted risk') : '',
|
|
53
|
+
sc.diverged ? plural(sc.diverged, 'divergence') : '',
|
|
54
|
+
].filter(Boolean).join(', ');
|
|
55
|
+
}
|
|
56
|
+
|
|
42
57
|
export function group(findings) {
|
|
43
58
|
const seen = new Set();
|
|
44
59
|
const out = [];
|
|
@@ -56,7 +71,7 @@ const C = {
|
|
|
56
71
|
};
|
|
57
72
|
const paint = (s, c) => (process.stdout.isTTY ? `${C[c]}${s}${C.reset}` : s);
|
|
58
73
|
|
|
59
|
-
const ICON = { pass: '+', fail: '!', unknown: '?', acknowledged: '~', not_applicable: '.' };
|
|
74
|
+
const ICON = { pass: '+', fail: '!', unknown: '?', acknowledged: '~', diverged: '=', not_applicable: '.' };
|
|
60
75
|
|
|
61
76
|
export function renderTerminal({ findings, sc, recipe, blocking }) {
|
|
62
77
|
const L = [];
|
|
@@ -67,7 +82,7 @@ export function renderTerminal({ findings, sc, recipe, blocking }) {
|
|
|
67
82
|
const bar = '#'.repeat(Math.round(sc.value / 5)).padEnd(20, '.');
|
|
68
83
|
const colour = sc.value >= 90 ? 'green' : sc.value >= 70 ? 'yellow' : 'red';
|
|
69
84
|
L.push(` ${paint(bar, colour)} ${paint(String(sc.value), 'bold')}/100` +
|
|
70
|
-
(sc
|
|
85
|
+
(includes(sc) ? paint(` (includes ${includes(sc)})`, 'dim') : ''));
|
|
71
86
|
L.push('');
|
|
72
87
|
|
|
73
88
|
for (const [name, items] of group(findings)) {
|
|
@@ -111,7 +126,7 @@ export function renderMarkdown({ findings, sc, recipe, blocking }) {
|
|
|
111
126
|
L.push(`## Stanford compliance report`);
|
|
112
127
|
L.push('');
|
|
113
128
|
L.push(`**Score ${sc.value}/100**` +
|
|
114
|
-
(sc
|
|
129
|
+
(includes(sc) ? ` (includes ${includes(sc)})` : '') +
|
|
115
130
|
` · recipe \`${recipe}\``);
|
|
116
131
|
L.push('');
|
|
117
132
|
if (blocking.length) {
|
|
@@ -137,7 +152,7 @@ export function renderMarkdown({ findings, sc, recipe, blocking }) {
|
|
|
137
152
|
export function renderJson({ findings, sc, recipe, blocking }) {
|
|
138
153
|
return JSON.stringify({
|
|
139
154
|
recipe, score: sc, blocking: blocking.map((b) => b.id),
|
|
140
|
-
counts: ['pass', 'fail', 'unknown', 'acknowledged', 'not_applicable']
|
|
155
|
+
counts: ['pass', 'fail', 'unknown', 'acknowledged', 'diverged', 'not_applicable']
|
|
141
156
|
.reduce((a, s) => ({ ...a, [s]: findings.filter((f) => f.state === s).length }), {}),
|
|
142
157
|
findings,
|
|
143
158
|
}, null, 2);
|
|
@@ -175,7 +190,7 @@ export function renderPrComment({ findings, sc, recipe, blocking }, { trend, run
|
|
|
175
190
|
const unknowns = findings.filter((f) => f.state === 'unknown');
|
|
176
191
|
L.push(`\`${recipe}\` · ${findings.filter((f) => f.state === 'pass').length} passing · ` +
|
|
177
192
|
`${fails.length} to fix · ${unknowns.length} unchecked` +
|
|
178
|
-
(sc
|
|
193
|
+
(includes(sc) ? ` · ${includes(sc).replace(', ', ' · ')}` : ''));
|
|
179
194
|
L.push('');
|
|
180
195
|
|
|
181
196
|
if (blocking.length) {
|
|
@@ -295,6 +310,7 @@ export function renderHtml({ findings, sc, recipe, blocking }, { trend, spark, s
|
|
|
295
310
|
tr.fail td:first-child{border-left:3px solid var(--cardinal)}
|
|
296
311
|
tr.unknown td:first-child{border-left:3px solid #b9b6b0}
|
|
297
312
|
tr.acknowledged td:first-child{border-left:3px solid #7a9a01}
|
|
313
|
+
tr.diverged td:first-child{border-left:3px solid #006cb8}
|
|
298
314
|
footer{margin-top:2.5rem;padding-top:1rem;border-top:1px solid var(--line);
|
|
299
315
|
color:#5f5e5b;font-size:.85rem}
|
|
300
316
|
</style></head><body>
|
|
@@ -357,7 +357,9 @@ content:
|
|
|
357
357
|
prior_art: []
|
|
358
358
|
|
|
359
359
|
# Deliberate departures from the recipe. Each needs a reason. Silent divergence
|
|
360
|
-
# is the only kind that is a problem. See the sws-diverge skill.
|
|
360
|
+
# is the only kind that is a problem. See the sws-diverge skill. Name the checks a
|
|
361
|
+
# divergence explains in \`checks:\`, and the report lists them as divergences
|
|
362
|
+
# rather than findings to fix. Preferences only: a requirement cannot be diverged.
|
|
361
363
|
divergences: []
|
|
362
364
|
`;
|
|
363
365
|
}
|
|
@@ -42,7 +42,13 @@ correct for that project. Read it rather than inventing criteria.
|
|
|
42
42
|
|
|
43
43
|
## Result states, and one that matters more than it looks
|
|
44
44
|
|
|
45
|
-
`pass` · `fail` · `unknown` · `acknowledged` · `not_applicable`
|
|
45
|
+
`pass` · `fail` · `unknown` · `acknowledged` · `diverged` · `not_applicable`
|
|
46
|
+
|
|
47
|
+
`acknowledged` is an accepted risk from `.sws/acknowledged.yml`, with a review
|
|
48
|
+
date. `diverged` is a deliberate choice: a divergence in `.sws/manifest.yml` whose
|
|
49
|
+
`checks:` names the check. Only checks that are SWS preferences (policy
|
|
50
|
+
`patterns`, or none) can be diverged; a requirement stays a failure or an
|
|
51
|
+
accepted risk.
|
|
46
52
|
|
|
47
53
|
**`unknown` is never a pass and never scores.** Any check that can fail to
|
|
48
54
|
execute must report it: axe needs a real browser, the footer check needs built
|
|
@@ -51,8 +51,24 @@ divergences:
|
|
|
51
51
|
by: sheamck@stanford.edu
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
The record is what lets the next person understand the project
|
|
55
|
-
|
|
54
|
+
The record is what lets the next person understand the project. When the choice
|
|
55
|
+
makes a check fail, name the check in `checks:`, and the report moves the finding
|
|
56
|
+
from the nag to a "Divergences" section, with the reason beside it:
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
- from: next-ssr
|
|
60
|
+
changed: Font Awesome Pro icons, not Heroicons
|
|
61
|
+
reason: Licensed and managed by the web team, with the token in CI (ADR 0013)
|
|
62
|
+
cost_accepted: A licence to renew, and a token every install needs
|
|
63
|
+
checks: [security.no-fontawesome-pro]
|
|
64
|
+
date: 2026-11-09
|
|
65
|
+
by: sheamck@stanford.edu
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`checks:` covers preferences only: criteria with `policy: patterns` or no
|
|
69
|
+
policy. A divergence naming a requirement (accessibility, brand, MinWeb, MinSec,
|
|
70
|
+
MinPriv) or the blocking check is ignored, and the report says so. Those are
|
|
71
|
+
below, under what never bends.
|
|
56
72
|
|
|
57
73
|
**5. Say when a swap is genuinely unsupported.** Not everything is a preference.
|
|
58
74
|
Tailwind 3 with Decanter 8 does not work, because Decanter 8 requires Tailwind 4.
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
# same way: a harness where axe silently failed to load still printed
|
|
25
25
|
# "0 violations", which is a report that lies.
|
|
26
26
|
|
|
27
|
-
# Result states: pass | fail | unknown | acknowledged | not_applicable
|
|
27
|
+
# Result states: pass | fail | unknown | acknowledged | diverged | not_applicable
|
|
28
28
|
|
|
29
29
|
recipe: astro-static
|
|
30
30
|
version: 1
|