diff --git a/docs/assets/readme/render.mjs b/docs/assets/readme/render.mjs index 357be95b..29702131 100644 --- a/docs/assets/readme/render.mjs +++ b/docs/assets/readme/render.mjs @@ -4,7 +4,7 @@ import { chromium } from 'playwright'; import { mkdirSync, readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import path from 'node:path'; -import { where } from './where-chock-sits.mjs'; +import { where, SITE_PALETTE } from './where-chock-sits.mjs'; import { where as sessionPath } from './session-path.mjs'; const HERE = path.dirname(fileURLToPath(import.meta.url)); @@ -218,11 +218,11 @@ ${grid(3, 16, [['commit', 'A git hook or CI gate that exits non-zero.'], ['in-ag ${grid(3, 16, [[A.grades.enforced, 'matrix cells graded “enforced”: no agent reaches it'], [`${D.asi.refused_at_commit.length} of ${D.asi.with_policy}`, 'OWASP Agentic risks with a slice refused at commit'], [D.asi.fully_covered, 'OWASP Agentic risks fully covered: every mapping is partial']].map(([n, l]) => stat(n, l)))}`); const FIGURE = JSON.parse(readFileSync(path.join(HERE, 'where-chock-sits.json'), 'utf8')); -const WHERE = where(page, FIGURE), SESSION_PATH = sessionPath(page, FIGURE); +const WHERE = where(page, FIGURE), WHERE_SITE = where(page, FIGURE, SITE_PALETTE), SESSION_PATH = sessionPath(page, FIGURE); const ALL_NEW = { layers: LAYERS, quickstart: QUICKSTART, matrix: MATRIX, catalog: CATALOG, family: FAMILY, honest: HONEST }; // README v2 panels go under v2/; the titled refusal, roles and contribute PNGs at the old paths stay frozen until RW-7b. -const V2 = { 'v2/refusal': REFUSAL, 'v2/roles': ROLES, 'v2/contribute': CONTRIBUTE, 'v2/where-chock-sits': WHERE, 'v2/session-path': SESSION_PATH }; +const V2 = { 'v2/refusal': REFUSAL, 'v2/roles': ROLES, 'v2/contribute': CONTRIBUTE, 'v2/where-chock-sits': WHERE, 'v2/where-chock-sits-site': WHERE_SITE, 'v2/session-path': SESSION_PATH }; // 1280x640 social preview banners: the same specs as the covers, laid out for the fixed canvas. const social = ({ repo, title, sub, chips, right }) => `
diff --git a/docs/assets/readme/v2/where-chock-sits-site.png b/docs/assets/readme/v2/where-chock-sits-site.png new file mode 100644 index 00000000..80a1c524 Binary files /dev/null and b/docs/assets/readme/v2/where-chock-sits-site.png differ diff --git a/docs/assets/readme/where-chock-sits.mjs b/docs/assets/readme/where-chock-sits.mjs index 13b8b13d..f412e7c4 100644 --- a/docs/assets/readme/where-chock-sits.mjs +++ b/docs/assets/readme/where-chock-sits.mjs @@ -69,23 +69,35 @@ export const crowded = (L) => { return bad; }; -export const where = (page, W) => { +// A palette is a small object of named colours; the layout never reads it, so every palette gives the same shapes. +export const DEFAULT_PALETTE = { + paper: '#FBF7EE', ink: '#2B2A35', soft: '#5C5A6B', line: '#6B6877', accent: '#C2410C', grey: '#8D8A99', + chip: '#fff', hollow: '#7C7989', + fill: { you: '#EFE9F9', prompt: '#EFE9F9', session: '#EFE9F9', context: '#DDEFE0', loop: '#DCEAF9', model: '#E8E1F6', subagents: '#F6E2EC', gate: '#F6E2EC', tools: '#ECE6D8', external: '#E9E4F3', commit: '#DDF0EE', push: '#DDF0EE', ci: '#DDF0EE', main: '#DDF0EE' }, +}; +// The chock-site palette: the tokens in chock-site static/css/site.css (--bg, --text, --body, --line-2, --accent, --muted, --footer-bg). +export const SITE_PALETTE = { + paper: '#0B1B33', ink: '#FFFFFF', soft: '#C7D2E3', line: '#607198', accent: '#38BDF8', grey: '#94A3B8', + chip: '#081326', hollow: '#94A3B8', + fill: { you: '#1B2F55', prompt: '#1B2F55', session: '#1B2F55', context: '#113A44', loop: '#16365E', model: '#2A2856', subagents: '#3A2647', gate: '#3A2647', tools: '#24324F', external: '#2A2856', commit: '#0E3B42', push: '#0E3B42', ci: '#0E3B42', main: '#0E3B42' }, +}; + +export const where = (page, W, palette = DEFAULT_PALETTE) => { const L = layout(W), bad = crowded(L), H = W.harness; if (bad.length) throw new Error(`figure shapes too close: ${JSON.stringify(bad)}`); const esc = (s) => s.replace(/&/g, '&').replace(/ `
${inner}
`; const diamond = (x, y, acts, s = 10) => abs(x - s / 2, y - s / 2, s, s, `transform:rotate(45deg);box-sizing:border-box;border:2px solid ${acts ? ACCENT : GREY};background:${acts ? ACCENT : PAPER}`, ''); const frame = (x, y, w, h, title, inside = false) => abs(x, y, w, h, `border:2px dashed ${LINE};border-radius:18px;box-sizing:border-box`, inside ? `
${esc(title)}
` : `
${esc(title)}
`); const card = (c) => abs(c.x, c.y, c.w, c.h, `box-sizing:border-box;background:${FILL[c.id]};border:1.5px solid ${LINE};border-radius:12px;padding:10px 8px`, `
${esc(c.name)}
${esc(c.line)}
`); - const badge = (b) => abs(b.x, b.y, b.w, b.h, `box-sizing:border-box;display:flex;align-items:center;gap:4px;padding:0 5px;border-radius:999px;background:#fff;white-space:nowrap;font-size:12px;line-height:14px;font-weight:600;color:${b.p.acts ? ACCENT : '#7C7989'}`, `${diamond(5, 5, b.p.acts)}${esc(b.p.label)}`); + const badge = (b) => abs(b.x, b.y, b.w, b.h, `box-sizing:border-box;display:flex;align-items:center;gap:4px;padding:0 5px;border-radius:999px;background:${CHIP};white-space:nowrap;font-size:12px;line-height:14px;font-weight:600;color:${b.p.acts ? ACCENT : HOLLOW}`, `${diamond(5, 5, b.p.acts)}${esc(b.p.label)}`); const arrow = ``; const paths = L.segs.map((s) => ``).join(''); const layerTitles = H.layers.map((t, i) => abs(PAD + 6, L.layerTitleY[i], 120, 14, `font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:${SOFT}`, esc(t))).join(''); const labels = L.labels.map((l) => abs(l.x, l.y, l.w, 14, `font-size:12px;line-height:14px;font-weight:600;color:${SOFT};white-space:nowrap`, esc(l.text))).join(''); const keyRow = (acts, text, y) => `
${diamond(7, 7, acts, 12)}${esc(text)}
`; - const stop = `padding:4px 6px;border:1.5px solid ${LINE};border-radius:999px;background:#fff;font-size:12.5px;font-weight:600;color:${INK};white-space:nowrap`; + const stop = `padding:4px 6px;border:1.5px solid ${LINE};border-radius:999px;background:${CHIP};font-size:12.5px;font-weight:600;color:${INK};white-space:nowrap`; const own = `${esc(W.own.label)}${esc(W.own.command)}`; const stops = W.stops.map((s) => `${esc(s)}`).join('') + own; const base = L.Ht + 20, total = base + 196; diff --git a/tests/test_readme_picture.py b/tests/test_readme_picture.py index 29ec2141..bb756353 100644 --- a/tests/test_readme_picture.py +++ b/tests/test_readme_picture.py @@ -3,7 +3,11 @@ from __future__ import annotations import json +import shutil +import struct +import subprocess +import pytest from readme_figure_support import FIGURE, OTHER_POINTS, ROOT, crowded, engine_acts PNG = "docs/assets/readme/v2/where-chock-sits.png" @@ -81,6 +85,37 @@ def test_architecture_doc_shows_the_harness_then_the_session_path_and_lists_ever assert f"**{point['name']}**" in doc and point["line"] in doc, point["id"] +def test_site_palette_render_has_the_same_layout_as_the_default() -> None: + node = shutil.which("node") + if not node: + pytest.skip("node is not installed") + script = ( + "import {where, DEFAULT_PALETTE, SITE_PALETTE} from './docs/assets/readme/where-chock-sits.mjs';" + "import {readFileSync} from 'node:fs';" + "const W = JSON.parse(readFileSync('docs/assets/readme/where-chock-sits.json', 'utf8'));" + "const strip = (h) => h.replace(/#[0-9a-fA-F]{3,8}\\b/g, '#');" + "const a = where((b) => b, W), b = where((b) => b, W, SITE_PALETTE);" + "console.log(JSON.stringify({same: strip(a) === strip(b), differs: a !== b," + " keys: Object.keys(DEFAULT_PALETTE.fill).join() === Object.keys(SITE_PALETTE.fill).join()}));" + ) + done = subprocess.run( + [node, "--input-type=module", "-e", script], cwd=ROOT, capture_output=True, text=True, check=False + ) + assert done.returncode == 0, done.stderr + assert json.loads(done.stdout) == {"same": True, "differs": True, "keys": True} + + +def test_both_figure_pngs_exist_with_the_same_size() -> None: + sizes = [] + for name in ("where-chock-sits", "where-chock-sits-site"): + png = ROOT / "docs" / "assets" / "readme" / "v2" / f"{name}.png" + assert png.stat().st_size > 10_000, name + sizes.append(struct.unpack(">II", png.read_bytes()[16:24])) + assert sizes[0] == sizes[1] + render = (ROOT / "docs" / "assets" / "readme" / "render.mjs").read_text(encoding="utf-8") + assert "'v2/where-chock-sits-site': WHERE_SITE" in render + + def test_renderer_registers_both_figures() -> None: render = (ROOT / "docs" / "assets" / "readme" / "render.mjs").read_text(encoding="utf-8") assert "'v2/where-chock-sits': WHERE" in render and "'v2/session-path': SESSION_PATH" in render