diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index ad96bea..57bdc19 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -51,6 +51,9 @@ jobs: - name: Install site dependencies (install scripts disabled by .npmrc) working-directory: site run: npm ci + - name: Website examples (reference checker) + working-directory: site + run: npm run check:examples - name: Build working-directory: site diff --git a/CHANGELOG.md b/CHANGELOG.md index cd5e500..aefb682 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ API versions (`v1alpha1`, ...) are versioned separately, see [GOVERNANCE.md](GOV ### Added +- Website: `npm run check:examples` runs every YAML example marked with an `awp-check` comment through the reference checker (valid, or rejected with an expected code and no error of another family); unknown options and profiles and a run without any marked example fail. Part of `npm test` and the pages workflow; the Quickstart manifest is marked. - AEP-0026 (interactive execution: kind `AgentSession`, `sessions` opt-in with `maxAutonomy`, three autonomy levels) and AEP-0027 (agent engine: `agents[].engine`, repository configuration off by default) as Draft concepts with open questions; numbers to be confirmed. From runtime feedback G62, G63, G65, G73, G81, G82. - AEP-0023 (step isolation) as Draft for `v1alpha3`: structured network destinations (`allowTo` with `host` or `cidr` and `ports`, replacing `allowHosts`), enforce or reject, internal destinations only through a `cidr` entry under `security`, platform ceilings that reject and never adjust (with a change to spec 5.7), credentials and approvals outside the execution environment, a minimum isolation class; hardening as informative implementer guidance. From runtime feedback G10, G47, G49 to G51, G61, G64, G67 to G69. - `docs/runtime-feedback.md`: gaps G41 to G87 (event triggers, the concept review, models, interactive sessions and a coding agent engine), with the AEP each belongs to, the evidence from the runtime, and a rule for what goes into AWP (section 10). diff --git a/site/README.md b/site/README.md index 6fb1300..a286e2e 100644 --- a/site/README.md +++ b/site/README.md @@ -6,17 +6,23 @@ Static site for https://agenticworkflowprotocol.org, built with Astro Starlight. cd site npm ci # install scripts are disabled by .npmrc (ignore-scripts=true) npm run build # sync -> astro build -> dist/ (+ Pagefind index, sitemap, CNAME) -npm test # offline link check, size budget, axe-core accessibility check +npm test # marked examples, offline link check, size budget, axe-core accessibility check npm run dev # local development server ``` +- **Checked examples.** A YAML block directly after an `awp-check` comment is run through the + reference checker by `npm run check:examples` (no build needed; uses the root `npm ci`). + `` means valid under all profiles; `profiles=core,governance` narrows the + profiles, and `expect=` requires a rejection with that diagnostic code. In `.mdx` pages use + `{/* awp-check ... */}`. Mark every complete manifest; fragments and proposals stay unmarked. + - **Content.** The specification, glossary, CLI formats, changelog and community files are rendered from the repository files by `scripts/sync-content.mjs` into git-ignored paths; they are not copied into Git. Example manifests on the site are imported from `spec/v1alpha1/examples/`. Hand-written pages are in `src/content/docs/`, the introduction page is `src/content/docs/index.mdx`; `scripts/build-llms.mjs` writes `llms.txt` and `llms-full.txt` into `dist/` at build time. - **No external requests.** System fonts, no CDN, no analytics; search is a static Pagefind index. `check:links` and `check:a11y` fail if any page references or requests an external resource. -- **Node.** Astro 5.18.2 and Starlight 0.37.7 are pinned because Astro 6 and later require Node 22. +- **Node.** Astro 7.3.3 and Starlight 0.42.6 are pinned and need Node 22.12 or later. The a11y check needs a system Chromium or Chrome (`CHROME_PATH`); no browser is downloaded. - **Languages.** English only. Add a `de` locale in `astro.config.mjs` and a `src/content/docs/de/` tree. - **Deploy.** Cloudflare Pages builds and serves the site from `main`. `.github/workflows/pages.yml` diff --git a/site/package.json b/site/package.json index 073698e..c7392cb 100644 --- a/site/package.json +++ b/site/package.json @@ -16,7 +16,8 @@ "check:links": "node scripts/check-links.mjs", "check:budget": "node scripts/check-budget.mjs", "check:a11y": "node scripts/check-a11y.mjs", - "test": "npm run check:links && npm run check:budget && npm run check:a11y" + "check:examples": "node scripts/check-examples.mjs", + "test": "npm run check:examples && npm run check:links && npm run check:budget && npm run check:a11y" }, "dependencies": { "@astrojs/markdown-remark": "7.3.2", diff --git a/site/scripts/check-examples.mjs b/site/scripts/check-examples.mjs new file mode 100644 index 0000000..bcd0a2d --- /dev/null +++ b/site/scripts/check-examples.mjs @@ -0,0 +1,96 @@ +// Runs the YAML examples of the website through the reference checker, so that a page never shows a +// manifest the specification no longer accepts. Only marked code blocks are checked: a marker on its +// own line directly before a ```yaml fence, as an HTML comment in .md and as a JSX comment in .mdx. +// +// must be valid (all profiles) +// must be valid under these profiles +// must be rejected with this diagnostic code +// +// Unmarked blocks are fragments or proposals and are never checked. +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import { join, relative, resolve, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { validateText } from '../../conformance/awp-check.mjs'; +import { KNOWN_PROFILES } from '../../conformance/semantic.mjs'; + +const siteRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..'); +const docsDir = join(siteRoot, 'src/content/docs'); +const MARKER = /^\s*(?:|\*\/\})\s*$/; +const YAML_FENCE = /^\s*```ya?ml\b/; +const FENCE_END = /^\s*```\s*$/; + +const walk = (dir) => readdirSync(dir).flatMap((name) => { + const path = join(dir, name); + return statSync(path).isDirectory() ? walk(path) : [path]; +}); + +const OPTIONS = ['profiles', 'expect']; + +/** Parses `profiles=a,b expect=code` after the marker keyword; unknown options or profiles are problems. */ +function parseOptions(text) { + const options = {}; + const problems = []; + for (const [, key, value] of text.matchAll(/(\w+)=(\S+)/g)) { + if (!OPTIONS.includes(key)) problems.push(`unknown awp-check option "${key}"`); + options[key] = value; + } + const profiles = options.profiles?.split(','); + // A misspelt profile would silently drop its rules, so it is an error like in the CLI. + for (const profile of profiles ?? []) if (!KNOWN_PROFILES.includes(profile)) problems.push(`unknown profile "${profile}"`); + return { options: { profiles, expect: options.expect }, problems }; +} + +/** The family of a diagnostic code: `security` for `security.image-not-pinned`. */ +const familyOf = (code) => code.split('.')[0]; + +/** Returns the marked YAML blocks of one page, and a problem for every marker without a YAML block. */ +function markedBlocks(lines) { + const blocks = []; + const problems = []; + lines.forEach((line, index) => { + const marker = line.match(MARKER); + if (!marker) return; + const start = index + 1; + const end = lines.findIndex((l, i) => i > start && FENCE_END.test(l)); + if (!YAML_FENCE.test(lines[start] ?? '') || end === -1) { + problems.push({ line: index + 1, message: 'awp-check marker is not followed by a complete yaml code block' }); + return; + } + const parsed = parseOptions(marker[1]); + for (const message of parsed.problems) problems.push({ line: index + 1, message }); + blocks.push({ line: start + 1, text: lines.slice(start + 1, end).join('\n'), ...parsed.options }); + }); + return { blocks, problems }; +} + +/** Checks one block and returns an error message, or null if the checker agrees with the marker. */ +function checkBlock(block, location) { + const errors = validateText(block.text, location, { profiles: block.profiles }).diagnostics + .filter((d) => d.severity === 'error'); + if (block.expect) { + // As in the conformance runner: the expected code must occur, and no error of another family. + const hit = errors.some((d) => d.code === block.expect); + const stray = errors.filter((d) => familyOf(d.code) !== familyOf(block.expect)); + return hit && stray.length === 0 ? null : `${location}: expected only ${block.expect}, got ${errors.map((d) => d.code).join(', ') || 'valid'}`; + } + return errors.length === 0 ? null : `${location}: ${errors.map((d) => `${d.code} ${d.path}`).join('; ')}`; +} + +const pages = walk(docsDir).filter((f) => /\.mdx?$/.test(f)); +const failures = []; +let checked = 0; +for (const page of pages) { + const name = relative(siteRoot, page); + const { blocks, problems } = markedBlocks(readFileSync(page, 'utf8').split('\n')); + for (const problem of problems) failures.push(`${name}:${problem.line}: ${problem.message}`); + for (const block of blocks) { + checked++; + const failure = checkBlock(block, `${name}:${block.line}`); + if (failure) failures.push(failure); + } +} +// A run that checks nothing means the markers were lost, not that every example is valid. +if (checked === 0) failures.push('no marked examples found; mark at least the Quickstart manifest'); +for (const failure of failures) console.error(failure); +console.log(`check-examples: ${checked} marked examples, ${failures.length} failed`); +process.exit(failures.length ? 1 : 0); diff --git a/site/src/content/docs/getting-started/quickstart.md b/site/src/content/docs/getting-started/quickstart.md index b13e515..0a7ad96 100644 --- a/site/src/content/docs/getting-started/quickstart.md +++ b/site/src/content/docs/getting-started/quickstart.md @@ -26,6 +26,7 @@ npm ci --ignore-scripts Create `hello.workflow.yaml`. It declares an owner, a budget, one agent, one step and a default-deny permission model. + ```yaml title="hello.workflow.yaml" apiVersion: awp.agenticworkflowprotocol.org/v1alpha1 kind: Workflow