@runeditrun/rer 0.2.38 → 0.2.40

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.
@@ -0,0 +1,26 @@
1
+ // `rer check` on a seed's CONTRACT.md: the Status table parses, and every
2
+ // evidence path it cites is in the checkout. A seed without CONTRACT.md has
3
+ // nothing to check here.
4
+ import { lstat, readFile } from 'node:fs/promises';
5
+ import { isAbsolute, join, normalize, sep } from 'node:path';
6
+ import { ContractError, parseContract } from '../foundation/runtime/seed-contract.mjs';
7
+
8
+ const file = 'CONTRACT.md';
9
+
10
+ export async function contractStatusClauses(root) {
11
+ let text;
12
+ try { text = await readFile(join(root, file), 'utf8'); } catch (error) { if (error.code === 'ENOENT') return []; throw error; }
13
+ let contract;
14
+ try { contract = parseContract(text, { file }); } catch (error) {
15
+ if (!(error instanceof ContractError)) throw error;
16
+ return error.problems.map(problem => ({ id: 'CONTRACT.status', ok: false, message: `${file}:${problem.line}: ${problem.message}` }));
17
+ }
18
+ const clauses = [{ id: 'CONTRACT.status', ok: true }];
19
+ for (const clause of contract.clauses) for (const path of clause.evidence) {
20
+ const inside = !isAbsolute(path) && !normalize(path).split(sep).includes('..');
21
+ let exists = false;
22
+ if (inside) try { await lstat(join(root, path)); exists = true; } catch {}
23
+ clauses.push({ id: `CONTRACT.evidence.${clause.id}`, ok: exists, ...(!exists ? { message: `${file}:${clause.row}: ${clause.id} is ${clause.status} with evidence ${path}, which ${inside ? 'is not in this checkout' : 'is outside this repository'}.` } : {}) });
24
+ }
25
+ return clauses;
26
+ }
@@ -17,6 +17,7 @@ import { localOnlyBinding, ownerWorkerName } from '../modules/deploy-kit/owner.m
17
17
  import { refuseLocalModels } from '../modules/deploy-kit/local-only.mjs';
18
18
  import { migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
19
19
  import { shared } from './shared.mjs';
20
+ import { settingKinds } from './deploy-settings.mjs';
20
21
  import { deployGuide, neededForRealDeploy, reportNeeded } from './deploy-needs.mjs';
21
22
  import { keepHookSecrets } from './deploy-secrets.mjs';
22
23
  import { withoutLocalSettings, refuseLocalEnvOutput } from './local-env.mjs';
@@ -82,10 +83,11 @@ export async function deployCommand(context) {
82
83
  await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed: context.setupSeed, adapter, declarationPath: path, options });
83
84
  const sourceSha = options.dryRun ? undefined : committedSource(root, options);
84
85
  const { env, supplied, generated, reused, rotated } = await deployEnvironment({ root, options, declaration, setupManifest, settings, localOnlyKeys });
85
- const { createRedaction, credentialValues } = await shared('redaction.mjs');
86
+ const { createRedaction } = await shared('redaction.mjs');
86
87
  const redaction = createRedaction();
88
+ const kinds = await settingKinds({ declaration, setupManifest });
87
89
  const addSecret = value => { redaction.addSecrets([value]); store.addSecrets?.([value]); };
88
- for (const value of [...credentialValues(env), env.CLOUDFLARE_ACCOUNT_ID, ...(declaration.secrets ?? []).map(item => env[item.environment])].filter(Boolean)) addSecret(value);
90
+ for (const value of [...kinds.privateValues(env), env.CLOUDFLARE_ACCOUNT_ID, ...(declaration.secrets ?? []).map(item => env[item.environment])].filter(Boolean)) addSecret(value);
89
91
  const environment = options.environment ?? 'production';
90
92
  // The hook uploads every value it is given: a generated secret it gets is the one the Worker keeps.
91
93
  if (!options.dryRun) await keepHookSecrets({ root, environment, declaration, setupManifest, env, generated, reused, rotated, again: deployAgain(options), report: line => store.report(line) });
@@ -53,16 +53,28 @@ export async function deployEnvironment({ root, options, declaration, setupManif
53
53
  }
54
54
 
55
55
  // Hooks and their child builds read process.env. Install the private file for
56
- // this command only, and restore even keys changed by a failing hook.
57
- export async function withDeployEnvironment(root, options, run) {
56
+ // this command only, and restore even keys changed by a failing hook. Output
57
+ // redaction follows what the deploy declaration says each value is: declared
58
+ // secrets and credentials stay redacted, declared non-secret settings print in
59
+ // full, and an undeclared --env-file value stays redacted with a note on how to
60
+ // declare it.
61
+ export async function withDeployEnvironment(project, options, out, run) {
58
62
  const saved = { ...process.env };
59
- const { env } = await deployEnvironment({ root, options, declaration: {} });
60
- const { createRedaction, credentialValues } = await shared('redaction.mjs');
63
+ const { env } = await deployEnvironment({ root: project.root, options, declaration: {} });
64
+ const { createRedaction } = await shared('redaction.mjs');
65
+ const { declaredSettings, settingKinds, undeclaredNotice } = await import('./deploy-settings.mjs');
66
+ const declared = await declaredSettings(project), kinds = await settingKinds(declared);
61
67
  const redaction = createRedaction();
62
68
  // Provider names are public enum values. Masking "resend" would also hide
63
69
  // RESEND_API_KEY in the preflight's instruction for the missing credential.
64
70
  const publicProvider = (key, value) => key === 'MAIL_PROVIDER' && /^(resend|sendgrid|cloudflare|rer|later)$/.test(value);
65
- redaction.addSecrets([...credentialValues(env), ...Object.entries(env).filter(([key, value]) => saved[key] !== value && !publicProvider(key, value)).map(([, value]) => value)]);
71
+ const supplied = Object.entries(env).filter(([key, value]) => saved[key] !== value);
72
+ redaction.addSecrets([...kinds.privateValues(env), ...supplied.filter(([key, value]) => !kinds.shown(key, value) && !publicProvider(key, value)).map(([, value]) => value)]);
73
+ const undeclared = declared.declaration ? kinds.undeclared(supplied.map(([key]) => key)) : [];
74
+ if (undeclared.length) {
75
+ const message = undeclaredNotice(undeclared, declared.path);
76
+ if (options.json) out.event('warning', { code: 'undeclared_env_setting', names: undeclared, message }); else out.progress(`${message}\n`);
77
+ }
66
78
  Object.assign(process.env, env);
67
79
  try { return await run(redaction); }
68
80
  catch (error) { if (typeof error?.message === 'string') error.message = redaction.redact(error.message); throw error; }
@@ -0,0 +1,45 @@
1
+ import { shared } from './shared.mjs';
2
+
3
+ // What a deployment's declaration says each value is. A value prints in full only
4
+ // when the declaration names it a non-secret setting: a declared var, the origin
5
+ // variable and its setting, a setup field that is not a secret, or a name in
6
+ // "publicSettings". Anything the declaration calls a secret, any credential-named
7
+ // key and any other --env-file value stays redacted.
8
+ const PRIVATE_KEYS = ['CLOUDFLARE_ACCOUNT_ID'];
9
+
10
+ export async function settingKinds({ declaration = {}, setupManifest } = {}) {
11
+ const { credentialName, credentialUrl, credentialValues } = await shared('redaction.mjs');
12
+ const secrets = Array.isArray(declaration.secrets) ? declaration.secrets : [];
13
+ const names = list => (Array.isArray(list) ? list : []).filter(name => typeof name === 'string');
14
+ const fields = Array.isArray(setupManifest?.fields) ? setupManifest.fields : [];
15
+ const secret = new Set([...PRIVATE_KEYS, ...secrets.flatMap(item => [item?.binding, item?.environment]), ...fields.filter(field => field?.kind === 'secret').map(field => field.name)].filter(Boolean));
16
+ const open = new Set([...Object.keys(declaration.vars ?? {}), declaration.originVar, declaration.publicOriginSetting, ...names(declaration.publicSettings), ...fields.filter(field => field?.kind !== 'secret').map(field => field?.name)].filter(name => name && !secret.has(name)));
17
+ // A declared setting is exempt from the key-name heuristic (AUTH_ORIGIN is a
18
+ // name, not a credential), never when its value carries credentials itself.
19
+ const shown = (key, value) => open.has(key) && typeof value === 'string' && !credentialUrl(value);
20
+ return {
21
+ shown,
22
+ // The values to keep out of output, from every key that is not shown.
23
+ privateValues: env => Object.entries(env).flatMap(([key, value]) => typeof value !== 'string' || shown(key, value) ? [] : secret.has(key) ? (value ? [value] : []) : credentialValues({ [key]: value })),
24
+ // Keys the deploy hides by default and the person may declare.
25
+ undeclared: keys => keys.filter(key => !open.has(key) && !secret.has(key) && !credentialName(key)),
26
+ };
27
+ }
28
+
29
+ // The declaration and setup manifest the deploy will read, loaded early so the
30
+ // redaction knows each value's kind. A project that cannot yield them yet
31
+ // declares nothing, so every --env-file value stays redacted and the deploy
32
+ // itself reports the real error.
33
+ export async function declaredSettings(project) {
34
+ let declaration, path, setupManifest = project.setupManifest;
35
+ if (!project.adapter) return {};
36
+ try { ({ path, value: declaration } = await (await import('./deploy-command.mjs')).declarationFor(project.root, project.adapter)); } catch { return {}; }
37
+ if (!setupManifest && project.adapter.setup) {
38
+ try { setupManifest = (await (await shared('setup-manifest.mjs')).loadInstallerSeed(project.root, project.adapter)).manifest; } catch { /* the lifecycle reports an invalid manifest */ }
39
+ }
40
+ return { declaration, path, setupManifest };
41
+ }
42
+
43
+ export function undeclaredNotice(names, path) {
44
+ return `Undeclared --env-file settings stay out of rer's output: ${names.join(', ')}. To print one, declare it as a non-secret setting: add its name to "publicSettings" in ${path}.`;
45
+ }
package/cli/deploy.mjs CHANGED
@@ -2,6 +2,7 @@ import { requireProductionAuth } from './production-auth.mjs';
2
2
  import { readFile } from 'node:fs/promises';
3
3
  import { deployDiagnostic, migrationFailure, providerFailure, assetFailure } from '../modules/deploy-kit/diagnostics.mjs';
4
4
  import { shared } from './shared.mjs';
5
+ import { settingKinds } from './deploy-settings.mjs';
5
6
  import { contained } from './project.mjs';
6
7
  import { missing, invalid, refuse, RerError } from './errors.mjs';
7
8
  import { ownerPlan, ownerWorkerName, localOnlyBinding } from '../modules/deploy-kit/owner.mjs';
@@ -60,9 +61,9 @@ export function ownerDeploy(declarationPath, lifecycle) {
60
61
  const kept = keptSecrets(declaration, setupManifest);
61
62
  if (cloudflareCredentials.some(name => !env[name]?.trim())) throw missing(missingCredentialsMessage(declaration, env));
62
63
  const { main } = await import('../modules/deploy-kit/owner-cli.mjs');
63
- const { createRedaction, credentialValues } = await shared('redaction.mjs');
64
+ const { createRedaction } = await shared('redaction.mjs');
64
65
  const redaction = createRedaction();
65
- redaction.addSecrets([...credentialValues(env), env.CLOUDFLARE_ACCOUNT_ID, ...(declaration.secrets ?? []).map(item => env[item.environment]).filter(Boolean)]);
66
+ redaction.addSecrets([...(await settingKinds({ declaration, setupManifest })).privateValues(env), env.CLOUDFLARE_ACCOUNT_ID, ...(declaration.secrets ?? []).map(item => env[item.environment]).filter(Boolean)]);
66
67
  const claim = setupManifest?.steps?.find(item => item.type === 'owner-claim');
67
68
  const declared = binding => (Array.isArray(declaration.secrets) ? declaration.secrets : []).find(item => item?.binding === binding);
68
69
  const owner = (command, extra = [], values = env, more = {}) => main([command, '--declaration', declarationPath, '--environment', environment, ...extra], values, { cwd: root, localOnlyKeys, ...more });
package/cli/export.mjs CHANGED
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
6
6
 
7
7
  // Copy whole maintained source/tooling directories. Python publication scans
8
8
  // load sibling modules and data dynamically; they belong in the inventory too.
9
- export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
9
+ export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/delivery-producer/migrations.mjs', 'modules/delivery-producer/mail.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs', 'foundation/runtime/seed-contract.mjs'];
10
10
  export async function inventory(base, roots = sourceRoots) {
11
11
  const files = [];
12
12
  async function walk(path) {
package/cli/inspect.mjs CHANGED
@@ -22,6 +22,7 @@ import { savedOrigin } from './door-mode.mjs';
22
22
  import { probePnpm } from './pnpm-probe.mjs';
23
23
  import { deliveryDeclarationClauses } from './delivery-declarations.mjs';
24
24
  import { checkoutPlaceholderMarks } from './placeholder-mark.mjs';
25
+ import { contractStatusClauses } from './contract-status.mjs';
25
26
 
26
27
  // cliVersion: the rer version of the code answering (absent for a vendored copy
27
28
  // too old to record one). defaults: what a server start applies when the person
@@ -129,6 +130,7 @@ export async function check(project, explicitProfile) {
129
130
  add('SC-08.portability', typeof adapter?.portability?.export === 'function' && typeof adapter?.portability?.import === 'function', 'Adopt the reviewed mainline complete local portability API; archive support remains unavailable until then.');
130
131
  if (adapter?.devIdentity) for (const [id, ok, message] of await devIdentityClauses(project.root, adapter)) add(id, ok, message);
131
132
  for (const [id, ok, message] of await authCopyClauses(project.root)) add(id, ok, message);
133
+ clauses.push(...await contractStatusClauses(project.root));
132
134
  placeholderMarks = await checkoutPlaceholderMarks(project.root, project.descriptor.project);
133
135
  }
134
136
  for(const issue of await localAiDiagnostics(project,process.env))add('AI.'+issue.feature,false,issue.code+': '+issue.message);
package/cli/lifecycle.mjs CHANGED
@@ -23,7 +23,7 @@ export async function runCommand(project, options, out) {
23
23
  const { validateDeployOptions } = await import('./deploy-command.mjs');
24
24
  validateDeployOptions(options);
25
25
  const { withDeployEnvironment } = await import('./deploy-inputs.mjs');
26
- return withDeployEnvironment(project.root, options, redaction => runLifecycle(project, options, out, redaction));
26
+ return withDeployEnvironment(project, options, out, redaction => runLifecycle(project, options, out, redaction));
27
27
  }
28
28
  return runLifecycle(project, options, out);
29
29
  }
package/cli/signin.mjs CHANGED
@@ -3,6 +3,7 @@ import { deployEnvironment, deployAgain } from './deploy-inputs.mjs';
3
3
  import { deploymentRecord } from './deployment-record.mjs';
4
4
  import { invalid, missing, refuse, RerError } from './errors.mjs';
5
5
  import { shared } from './shared.mjs';
6
+ import { settingKinds } from './deploy-settings.mjs';
6
7
  import { main as owner } from '../modules/deploy-kit/owner-cli.mjs';
7
8
  import { deployDiagnostic, providerRefusal } from '../modules/deploy-kit/diagnostics.mjs';
8
9
 
@@ -18,9 +19,9 @@ export async function signinCommand(project, options, out, { fetch } = {}) {
18
19
  const state = await deploymentRecord(root, { ...options, verb: 'signin' });
19
20
  const { env } = await deployEnvironment({ root, options, declaration, localOnlyKeys: project.adapter.localOnlyKeys ?? [] });
20
21
  if (['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'].some(name => !env[name]?.trim())) throw missing('rer signin uses the Cloudflare credentials that deployed this environment: set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment or an --env-file, then run it again.');
21
- const { createRedaction, credentialValues } = await shared('redaction.mjs');
22
+ const { createRedaction } = await shared('redaction.mjs');
22
23
  const redaction = createRedaction();
23
- redaction.addSecrets([...credentialValues(env), env.CLOUDFLARE_ACCOUNT_ID]);
24
+ redaction.addSecrets([...(await settingKinds({ declaration, setupManifest: project.setupManifest })).privateValues(env), env.CLOUDFLARE_ACCOUNT_ID]);
24
25
  let result;
25
26
  try { result = await owner(['signin', '--declaration', path, '--environment', environment, ...(state ? ['--state', state] : [])], env, { cwd: root, localOnlyKeys: project.adapter.localOnlyKeys ?? [], ...(fetch ? { fetch } : {}) }); }
26
27
  catch (error) { throw failure(error, { environment, again, adapter: project.adapter, redact: redaction.redact }); }
@@ -7,7 +7,9 @@
7
7
  // entry's CSS imports compile to. The optional site config is a Vite config
8
8
  // naming the plugins the site pages need (a docs virtual module, a CSS
9
9
  // toolchain); the app's own Vite config is never loaded, because its Worker
10
- // plugins do not run in Node. It reads no installation data.
10
+ // plugins do not run in Node. It reads no installation data. A seed with a
11
+ // CONTRACT.md gets it parsed as sitePages({ contract }), for its /contract
12
+ // page; one that does not parse stops the build, naming its lines.
11
13
  // Usage: node site-render.mjs ROOT ENTRY OUTPUT [CONFIG]
12
14
  import { cp, lstat, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
13
15
  import { createRequire } from 'node:module';
@@ -15,6 +17,7 @@ import { dirname, join, resolve, sep } from 'node:path';
15
17
  import { pathToFileURL } from 'node:url';
16
18
  import { buildClients, writeSiteAsset } from './site-client.mjs';
17
19
  import { redactSiteOutput, siteBuildDiagnostic } from './site-diagnostics.mjs';
20
+ import { ContractError, parseContract } from '../foundation/runtime/seed-contract.mjs';
18
21
 
19
22
  redactSiteOutput();
20
23
 
@@ -30,6 +33,13 @@ try { vite = await import(pathToFileURL(createRequire(join(root, 'package.json')
30
33
  catch { fail('The run site renders with the checkout\'s own Vite. Run rer install first.'); }
31
34
  process.env.NODE_ENV ??= 'production';
32
35
 
36
+ let contract;
37
+ try { contract = parseContract(await readFile(join(root, 'CONTRACT.md'), 'utf8')); }
38
+ catch (error) {
39
+ if (error instanceof ContractError) fail(`The run site's /contract page is built from CONTRACT.md, which does not parse:\n${error.message}`);
40
+ if (error.code !== 'ENOENT') throw error;
41
+ }
42
+
33
43
  // The Node bundle sits beside the output, inside the checkout, so its external
34
44
  // imports resolve from the checkout's node_modules. It never enters the site.
35
45
  const server = `${output}.render`;
@@ -52,7 +62,7 @@ try {
52
62
  if (typeof module.sitePages !== 'function') fail(`${entry} must export sitePages(), returning { pages: [{ path, html }], assets: [public paths] }.`);
53
63
  const clientBuild = await buildClients(vite, root, output, clientJSON ? JSON.parse(clientJSON) : {}), clients = clientBuild.clients;
54
64
  styles = [...new Set([...styles,...clientBuild.styles])];
55
- const build = await module.sitePages({ styles, clients });
65
+ const build = await module.sitePages({ styles, clients, ...(contract ? { contract } : {}) });
56
66
  if (!Array.isArray(build?.pages) || !Array.isArray(build.assets)) fail('sitePages() returns { pages, assets }.');
57
67
 
58
68
  const written = new Set();
@@ -0,0 +1,280 @@
1
+ // A seed's CONTRACT.md as data: the product target, the clauses it defines,
2
+ // and its Status table. `rer check` validates it and the run site's /contract
3
+ // page is built from it, so both read the contract through this one parser.
4
+ // The shape it accepts is documented in SEED-COMMAND-CONTRACT.md ("Contract
5
+ // status"). It throws a ContractError listing every problem, each with the
6
+ // CONTRACT.md line it is on; it never guesses a missing value.
7
+ // Plain JavaScript (types in seed-contract.d.mts) so the rer CLI runs it under
8
+ // Node and the seed's Vite site build imports it from src/base.
9
+
10
+ export const kinds = Object.freeze(['published', 'target', 'push-further'])
11
+ export const statuses = Object.freeze(['done', 'partial', 'missing'])
12
+ export const statusHeader = Object.freeze(['Clause', 'Title', 'Kind', 'Status', 'Evidence', 'Gap'])
13
+ const summaryHeader = ['Clauses', 'Done', 'Partial', 'Missing', 'Total']
14
+
15
+ // The one clause-ID rule, shared with the release catalogue: uppercase words
16
+ // and a two- or three-digit number joined by hyphens (HOME-001, PAN-01), or the
17
+ // legacy hyphenless form of up to four capitals and a number (E1, A7).
18
+ export const clauseIdSource = '(?:[A-Z][A-Z0-9]*(?:-[A-Z][A-Z0-9]*)*-[0-9]{2,3}|[A-Z]{1,4}[0-9]{1,3})'
19
+ const id = clauseIdSource
20
+ const clauseId = new RegExp(`^${id}$`)
21
+ const dash = '\\s+[—–-]\\s+'
22
+ // The three ways a contract defines a clause: a bold bullet, a bold paragraph
23
+ // or a heading, each "ID — Title." at the start of its line.
24
+ const definitions = [
25
+ new RegExp(`^-\\s+\\*\\*(${id})${dash}(.+?)\\*\\*`),
26
+ new RegExp(`^\\*\\*(${id})${dash}(.+?)\\*\\*`),
27
+ new RegExp(`^#{2,6}\\s+(${id})${dash}(.+?)\\s*#*\\s*$`),
28
+ ]
29
+ const heading = /^(#{1,6})\s+(.+?)\s*#*\s*$/
30
+ const judged = /^Judged from the code and tests at commit `([0-9a-f]{7,40})` \(([^)]+)\)[.;:]/
31
+ const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
32
+
33
+ export class ContractError extends Error {
34
+ constructor(file, problems) {
35
+ super(problems.map(problem => `${file}:${problem.line}: ${problem.message}`).join('\n'))
36
+ this.name = 'ContractError'
37
+ this.file = file
38
+ this.problems = problems
39
+ }
40
+ }
41
+
42
+ /** Markdown inline text as plain text: links keep their label; emphasis and code marks go. */
43
+ export function plainText(value) {
44
+ return value.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/\*\*|__|`/g, '').replace(/(^|\W)[*_](\S[^*_]*?)[*_](?=\W|$)/g, '$1$2').trim()
45
+ }
46
+
47
+ const cleanTitle = value => plainText(value).replace(/[.:]$/, '').trim()
48
+
49
+ function cells(line) {
50
+ const body = line.trim().replace(/^\|/, '').replace(/(?<!\\)\|$/, '')
51
+ return body.split(/(?<!\\)\|/).map(cell => cell.trim().replace(/\\\|/g, '|'))
52
+ }
53
+ const isTableLine = line => line.trimStart().startsWith('|')
54
+ const isDivider = line => /^\|?(\s*:?-{3,}:?\s*\|)+\s*:?-{0,}:?\s*$/.test(line.trim())
55
+
56
+ function isoDate(text) {
57
+ let year, month, day
58
+ const written = /^(\d{1,2}) ([A-Z][a-z]+) (\d{4})$/.exec(text), iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text)
59
+ if (written && months.includes(written[2])) [day, month, year] = [Number(written[1]), months.indexOf(written[2]) + 1, Number(written[3])]
60
+ else if (iso) [year, month, day] = iso.slice(1).map(Number)
61
+ else return undefined
62
+ const date = new Date(Date.UTC(year, month - 1, day))
63
+ if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day) return undefined
64
+ return date.toISOString().slice(0, 10)
65
+ }
66
+
67
+ // Every heading outside fenced code, with the 1-based line it is on.
68
+ function outline(lines) {
69
+ const headings = []
70
+ let fence
71
+ lines.forEach((line, index) => {
72
+ const marker = /^\s*(```|~~~)/.exec(line)?.[1]
73
+ if (marker) { fence = fence === marker ? undefined : fence ?? marker; return }
74
+ if (fence) return
75
+ const match = heading.exec(line)
76
+ if (match) headings.push({ level: match[1].length, text: plainText(match[2]), line: index + 1 })
77
+ })
78
+ return headings
79
+ }
80
+
81
+ // The section a heading opens: its line through the line before the next
82
+ // heading at its level or above.
83
+ function sectionEnd(headings, start, lineCount) {
84
+ const next = headings.find(other => other.line > start.line && other.level <= start.level)
85
+ return next ? next.line - 1 : lineCount
86
+ }
87
+
88
+ function readTarget(lines, headings, problems) {
89
+ const section = headings.find(entry => entry.level === 2 && /^Product target\b/i.test(entry.text))
90
+ if (!section) { problems.push({ line: 1, message: 'CONTRACT.md has no "## Product target" section with its Category, Incumbents and First buyer table.' }); return undefined }
91
+ const end = sectionEnd(headings, section, lines.length), found = {}
92
+ for (let line = section.line + 1; line <= end; line++) {
93
+ const text = lines[line - 1]
94
+ if (!isTableLine(text) || isDivider(text)) continue
95
+ const [label = '', value = ''] = cells(text), name = plainText(label).toLowerCase()
96
+ const key = name === 'category' ? 'category' : name.startsWith('incumbents') ? 'incumbents' : name === 'first buyer' ? 'firstBuyer' : /\balso beat\b/.test(name) ? 'alsoBeats' : undefined
97
+ if (key && !found[key]) found[key] = { value: plainText(value), line }
98
+ }
99
+ for (const [key, label] of [['category', 'Category'], ['incumbents', 'Incumbents a buyer switches from'], ['firstBuyer', 'First buyer']])
100
+ if (!found[key]?.value) problems.push({ line: found[key]?.line ?? section.line, message: `The Product target table needs a non-empty "${label}" row.` })
101
+ if (!found.category?.value || !found.incumbents?.value || !found.firstBuyer?.value) return undefined
102
+ const incumbents = found.incumbents.value.split(/\s*,\s*|\s+(?:and|or)\s+/).map(name => name.trim()).filter(Boolean)
103
+ return { category: found.category.value, incumbents, replaces: found.incumbents.value, alsoBeats: found.alsoBeats?.value || null, firstBuyer: found.firstBuyer.value }
104
+ }
105
+
106
+ /** An area's anchor: "Archive, trash and deletion" -> "archive-trash-and-deletion". */
107
+ export function areaSlug(name) {
108
+ return name.normalize('NFKD').replace(/[\u0300-\u036f]/g, '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
109
+ }
110
+ // Target and push-further areas sit under (or are) a heading starting
111
+ // "Target clauses" or "Push further"; every other area is published.
112
+ const targetSection = /^(?:Target clauses|Push further)\b/i
113
+ function areaGroup(headings, area) {
114
+ let level = area.level + 1
115
+ for (const entry of headings.filter(other => other.line <= area.line).reverse()) {
116
+ if (entry.level >= level) continue
117
+ if (targetSection.test(entry.text)) return 'target'
118
+ level = entry.level
119
+ }
120
+ return 'published'
121
+ }
122
+
123
+ // Clause definitions everywhere except the Status section and retired-ID
124
+ // sections. The area is the nearest heading above that is not a clause.
125
+ // A clause's own "*Status:* partial." line, kept beside its text, is recorded
126
+ // so a row that disagrees with it is refused.
127
+ function readDefinitions(lines, headings, skipped, problems) {
128
+ const defined = new Map(), areas = new Map(), slugs = new Map()
129
+ let fence, current
130
+ lines.forEach((text, index) => {
131
+ const line = index + 1
132
+ const marker = /^\s*(```|~~~)/.exec(text)?.[1]
133
+ if (marker) { fence = fence === marker ? undefined : fence ?? marker; return }
134
+ if (fence || skipped.some(([start, end]) => line >= start && line <= end)) { current = undefined; return }
135
+ const match = definitions.map(pattern => pattern.exec(text)).find(Boolean)
136
+ if (!match) {
137
+ if (heading.test(text)) current = undefined
138
+ const stated = /^\*{1,2}Status:\*{1,2}\s*(done|partial|missing)\b/.exec(text)
139
+ if (stated && current && !current.stated) current.stated = { status: stated[1], line }
140
+ return
141
+ }
142
+ const area = headings.filter(entry => entry.line < line && !definitions[2].test(lines[entry.line - 1])).at(-1)
143
+ const [, clause, title] = match
144
+ if (defined.has(clause)) { problems.push({ line, message: `${clause} is defined twice (first at line ${defined.get(clause).line}).` }); return }
145
+ if (!area) { problems.push({ line, message: `${clause} is defined above every section heading, so it has no area.` }); return }
146
+ current = { id: clause, title: cleanTitle(title), area: area.text, line }
147
+ defined.set(clause, current)
148
+ const group = areaGroup(headings, area), known = areas.get(area.text)
149
+ if (known && known.group !== group) problems.push({ line: area.line, message: `Area "${area.text}" is a ${group} area here but a ${known.group} area at line ${known.line}; give one of them its own name.` })
150
+ if (known) return
151
+ const slug = areaSlug(area.text)
152
+ if (!slug) problems.push({ line: area.line, message: `Area "${area.text}" has no letters or digits to make its #area- link from.` })
153
+ else if (slugs.has(slug)) problems.push({ line: area.line, message: `Area "${area.text}" has the same link (#area-${slug}) as "${slugs.get(slug).text}" at line ${slugs.get(slug).line}; rename one.` })
154
+ else slugs.set(slug, area)
155
+ areas.set(area.text, { name: area.text, slug, group, line: area.line })
156
+ })
157
+ return { defined, areas }
158
+ }
159
+
160
+ function readSummary(lines, start, problems) {
161
+ const rows = []
162
+ for (let line = start + 2; line <= lines.length && isTableLine(lines[line - 1]); line++) {
163
+ const [label, ...numbers] = cells(lines[line - 1])
164
+ const values = numbers.map(value => /^\d+$/.test(value) ? Number(value) : NaN)
165
+ if (values.length !== 4 || values.some(Number.isNaN)) { problems.push({ line, message: 'A summary row is a label and four whole numbers: Done, Partial, Missing, Total.' }); continue }
166
+ rows.push({ line, label: plainText(label), done: values[0], partial: values[1], missing: values[2], total: values[3] })
167
+ }
168
+ return rows
169
+ }
170
+
171
+ // Which kinds a summary row counts: "All", or kinds joined by "and".
172
+ function summaryKinds(label) {
173
+ const name = label.toLowerCase()
174
+ if (name === 'all' || name === 'total') return kinds
175
+ const parts = name.split(/\s*,\s*|\s+and\s+/).map(part => part === 'push further' ? 'push-further' : part)
176
+ return parts.every(part => kinds.includes(part)) ? parts : undefined
177
+ }
178
+
179
+ function checkSummaries(summaries, sentences, clauses, problems) {
180
+ const count = selected => {
181
+ const rows = clauses.filter(clause => selected.includes(clause.kind))
182
+ return { done: rows.filter(row => row.status === 'done').length, partial: rows.filter(row => row.status === 'partial').length, missing: rows.filter(row => row.status === 'missing').length, total: rows.length }
183
+ }
184
+ for (const row of summaries) {
185
+ const selected = summaryKinds(row.label)
186
+ if (!selected) { problems.push({ line: row.line, message: `Summary row "${row.label}" names no kind: use All, Published, Target, Push further, or kinds joined by "and".` }); continue }
187
+ const actual = count(selected)
188
+ const wrong = ['done', 'partial', 'missing', 'total'].filter(key => row[key] !== actual[key])
189
+ if (wrong.length) problems.push({ line: row.line, message: `Summary row "${row.label}" says ${wrong.map(key => `${row[key]} ${key}`).join(', ')}; the Status table has ${wrong.map(key => `${actual[key]} ${key}`).join(', ')}.` })
190
+ }
191
+ const all = count(kinds)
192
+ for (const sentence of sentences) {
193
+ const wrong = ['total', 'done', 'partial', 'missing'].filter(key => sentence[key] !== undefined && sentence[key] !== all[key])
194
+ if (wrong.length) problems.push({ line: sentence.line, message: `The summary says ${wrong.map(key => `${sentence[key]} ${key === 'total' ? 'clauses' : key}`).join(', ')}; the Status table has ${wrong.map(key => `${all[key]} ${key === 'total' ? 'clauses' : key}`).join(', ')}.` })
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Parse CONTRACT.md text. `file` names it in error messages.
200
+ * @returns {import('./seed-contract.d.mts').SeedContract}
201
+ */
202
+ export function parseContract(text, { file = 'CONTRACT.md' } = {}) {
203
+ if (typeof text !== 'string') throw new TypeError('parseContract takes the CONTRACT.md text.')
204
+ const lines = text.replace(/\r\n?/g, '\n').split('\n'), headings = outline(lines), problems = []
205
+ const statusHeading = headings.filter(entry => entry.level === 2 && entry.text === 'Status')
206
+ if (statusHeading.length !== 1) throw new ContractError(file, [statusHeading.length ? { line: statusHeading[1].line, message: 'CONTRACT.md has more than one "## Status" section.' } : { line: lines.length, message: 'CONTRACT.md has no "## Status" section.' }])
207
+ const status = statusHeading[0], statusEnd = sectionEnd(headings, status, lines.length)
208
+ const skipped = [[status.line, statusEnd], ...headings.filter(entry => /^Retired\b/i.test(entry.text)).map(entry => [entry.line, sectionEnd(headings, entry, lines.length)])]
209
+ const target = readTarget(lines, headings, problems)
210
+ const { defined, areas: areaHeadings } = readDefinitions(lines, headings, skipped, problems)
211
+
212
+ // The judged-at line opens the section.
213
+ let commit, date
214
+ const first = lines.slice(status.line, statusEnd).findIndex(line => line.trim()) + status.line + 1
215
+ const opening = first > status.line ? judged.exec(lines[first - 1].trim()) : null
216
+ if (!opening) problems.push({ line: first > status.line ? first : status.line, message: 'The Status section opens with "Judged from the code and tests at commit `<sha>` (<date>)."' })
217
+ else {
218
+ commit = opening[1]
219
+ date = isoDate(opening[2])
220
+ if (!date) problems.push({ line: first, message: `"${opening[2]}" is not a date: write it as 16 October 2026 or 2026-10-16.` })
221
+ }
222
+
223
+ // The section's tables: optional summaries, then exactly one clause table.
224
+ const summaries = [], sentences = [], clauses = [], rows = new Map()
225
+ let tableLine, wrongHeader
226
+ for (let line = status.line + 1; line <= statusEnd; line++) {
227
+ const textLine = lines[line - 1]
228
+ const sentence = /\b(\d+) clauses?:\s*(\d+) done,\s*(\d+) partial(?:,| and)\s*(\d+) missing\b/i.exec(textLine)
229
+ if (sentence) sentences.push({ line, total: Number(sentence[1]), done: Number(sentence[2]), partial: Number(sentence[3]), missing: Number(sentence[4]) })
230
+ if (!isTableLine(textLine)) continue
231
+ const header = cells(textLine)
232
+ let end = line
233
+ while (end + 1 <= statusEnd && isTableLine(lines[end])) end++
234
+ if (!isDivider(lines[line] ?? '')) problems.push({ line: line + 1, message: 'A table header is followed by its |---| divider line.' })
235
+ if (header.join('|') === summaryHeader.join('|')) summaries.push(...readSummary(lines, line, problems))
236
+ else if (tableLine) problems.push({ line, message: `The Status section has one clause table (at line ${tableLine}); this is a second table.` })
237
+ else if (header.join('|') !== statusHeader.join('|')) { wrongHeader = true; problems.push({ line, message: `The Status table header is | ${statusHeader.join(' | ')} |, not | ${header.join(' | ')} |.` }) }
238
+ else {
239
+ tableLine = line
240
+ if (end < line + 2) problems.push({ line, message: 'The Status table has no rows: it holds one row per clause the contract defines.' })
241
+ for (let rowLine = line + 2; rowLine <= end; rowLine++) {
242
+ const row = cells(lines[rowLine - 1])
243
+ if (row.length !== statusHeader.length) { problems.push({ line: rowLine, message: `A Status row has ${statusHeader.length} cells (${statusHeader.join(', ')}); this one has ${row.length}.` }); continue }
244
+ const [clauseCell, titleCell, kind, state, evidenceCell, gapCell] = row, clause = plainText(clauseCell), title = cleanTitle(titleCell)
245
+ if (!clauseId.test(clause)) { problems.push({ line: rowLine, message: `"${clauseCell}" is not a clause ID such as HOME-001.` }); continue }
246
+ if (rows.has(clause)) { problems.push({ line: rowLine, message: `${clause} has a second Status row (the first is at line ${rows.get(clause)}).` }); continue }
247
+ rows.set(clause, rowLine)
248
+ const definition = defined.get(clause)
249
+ if (!definition) problems.push({ line: rowLine, message: `${clause} has a Status row but CONTRACT.md defines no such clause.` })
250
+ else if (title && title !== definition.title) problems.push({ line: rowLine, message: `${clause} is titled "${title}" here but "${definition.title}" where it is defined (line ${definition.line}).` })
251
+ if (definition?.stated && statuses.includes(state) && definition.stated.status !== state) problems.push({ line: rowLine, message: `${clause} is ${state} here but its own Status line says ${definition.stated.status} (line ${definition.stated.line}).` })
252
+ if (!kinds.includes(kind)) problems.push({ line: rowLine, message: `${clause} kind "${kind}" is not one of ${kinds.join(', ')}.` })
253
+ if (!statuses.includes(state)) problems.push({ line: rowLine, message: `${clause} status "${state}" is not one of ${statuses.join(', ')}.` })
254
+ if (!title) problems.push({ line: rowLine, message: `${clause} has no title.` })
255
+ const evidence = [...evidenceCell.matchAll(/`([^`]+)`/g)].map(match => match[1].trim()).filter(Boolean), gap = plainText(gapCell)
256
+ if (state === 'done' && !evidence.length) problems.push({ line: rowLine, message: `${clause} is done, so its Evidence names the repository path that proves it, in backticks.` })
257
+ if (state === 'partial' && !evidence.length) problems.push({ line: rowLine, message: `${clause} is partial, so its Evidence names the repository path that backs it, in backticks.` })
258
+ if ((state === 'partial' || state === 'missing') && !gap) problems.push({ line: rowLine, message: `${clause} is ${state}, so its Gap says what is missing.` })
259
+ if (definition && kinds.includes(kind) && statuses.includes(state)) clauses.push({ id: clause, title, kind, status: state, evidence, gap, area: definition.area, line: definition.line, row: rowLine })
260
+ }
261
+ }
262
+ line = end
263
+ }
264
+ if (!tableLine) { if (!wrongHeader) problems.push({ line: status.line, message: `The Status section has no | ${statusHeader.join(' | ')} | table.` }) }
265
+ else for (const definition of defined.values()) if (!rows.has(definition.id)) problems.push({ line: definition.line, message: `${definition.id} is defined here but has no Status row.` })
266
+ if (!problems.length) checkSummaries(summaries, sentences, clauses, problems)
267
+ if (problems.length) throw new ContractError(file, problems.sort((a, b) => a.line - b.line))
268
+
269
+ const tally = rows => {
270
+ const counts = { done: 0, partial: 0, missing: 0, total: rows.length }
271
+ for (const row of rows) counts[row.status]++
272
+ return counts
273
+ }
274
+ const areas = [...areaHeadings.values()].map(({ name, slug, group }) => {
275
+ const own = clauses.filter(clause => clause.area === name).sort((a, b) => a.line - b.line)
276
+ return { name, slug, group, clauses: own.map(clause => clause.id), ...tally(own) }
277
+ }).filter(area => area.total)
278
+ const counts = tally(clauses)
279
+ return { commit, date, target, areas, clauses, counts }
280
+ }
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.40
4
+
5
+ - **The /contract clause table keeps clause IDs whole.** A clause ID or kind never breaks across lines. The ID column is sized from the longest clause ID in the contract, so a long ID like `DEPENDENCY-001` fits on one line. Titles wrap only between words, and only evidence paths and gap text may break inside a word. The kind now sits under the clause ID instead of in a column of its own.
6
+ - **The /contract page is denser and easier to scan.** Rows are tighter. The split by kind fits on one line on a desktop and shows one count per line on a phone. On a phone, clause cards use the full width. When the sticky "Progress by area" card holds more than fits, a shadow at its edge shows there is more to scroll.
7
+ - These changes are to `contract-page.ts` and `contract-style.ts`, which a seed carries in `src/base` from Base. A seed's site entry needs no change.
8
+
9
+ ## 0.2.39
10
+
11
+ - **A seed's CONTRACT.md is parsed and checked.** `rer check` and `rer build --site` now parse a seed's CONTRACT.md with one parser: its clauses, the `## Status` table (judged-at line, header, one row per defined clause, kind, status, evidence and gap), the summary counts and the Product target. Clause IDs follow one rule, shared with the release catalogue: `AREA-NN(N)`, or the legacy `A1` form. `rer check` reports each problem as a failing `CONTRACT.status` clause naming the line, and reports each cited evidence path missing from the checkout as `CONTRACT.evidence.<ID>`.
12
+ - **The run site has a /contract page.** `rer build --site` renders the parsed contract at `/contract`: progress by status, a split by kind, the Product target, progress by area, and every clause with status filters and search. The Run, home and 404 headers link Contract only when the page exists. Base's template and default seed render it. An existing seed's site entry needs three lines to do the same (gr-base-199's report shows them): import `contractPageHtml`, take `{ contract }` in `sitePages`, and add the `/contract` page.
13
+ - **Release note: a non-canonical or malformed CONTRACT.md now fails `rer check` and `rer build --site`.** Each problem's line is named, and a failed site build leaves the previous site as it was. Seeds without a CONTRACT.md are unaffected. A seed whose site entry has not been updated still has its CONTRACT.md parsed, but gets no `/contract` page.
14
+ - **`rer deploy` redacts by what a value is.** Declared non-secret settings now print in full, so the final line can name the address: "Sign in by email at https://<host>". These are `vars`, `originVar`, `publicOriginSetting`, setup fields that are not secrets, and names in the new optional deploy-declaration key `publicSettings`. Declared secrets, generated secrets, `CLOUDFLARE_ACCOUNT_ID`, credential-named keys and values that carry credentials stay redacted everywhere: stdout, stderr, `--json` and logs. A secret also listed in `publicSettings` stays redacted. Undeclared `--env-file` values stay redacted too, and the output names them and says to add them to `publicSettings`.
15
+ - **Release note: `publicSettings` is a new optional deploy-declaration key.** It takes a list of upper-case setting names that a hook reads but that are not bindings, such as hosts, origins, names or regions. An invalid list is refused.
16
+
3
17
  ## 0.2.38
4
18
 
5
19
  - **Local settings never reach a deployment.** `rer build`, the build `rer deploy` runs, and every custom deploy hook now run with the checkout's local settings files (`.dev.vars`, `.env`) moved aside, and Wrangler's `.env` and `process.env` loading is switched off. A hard kill puts the files back on the next run. If build output still holds a `.dev.vars*`, `.env*` or `*.env` file, it is refused, naming the file, before anything is uploaded. This applies to `rer build`, `rer deploy`, the deploy kit, the container image build and the delivery package. Before, a seed whose build copied `.dev.vars` into `dist/client` uploaded it as a public Worker asset, and the demo container image copied `dist/server/.dev.vars`. No live deployment was affected. The Vite plugin that drops these files from every build now lives in onboarding (`@runeditrun/rer/local-variables-output` in package mode), and the seed template uses it too.
@@ -22,7 +22,7 @@ import { publicOrigin } from './public-origin.mjs';
22
22
  const segment = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
23
23
  const STATE_KIND = 'rer-deploy-owner-state';
24
24
  export const KINDS = ['d1','r2','kv','queues'];
25
- const DECLARATION_KEYS = ['version','project','compatibilityDate','compatibilityFlags','d1','r2','kv','queues','durableObjects','secrets','crons','vars','originVar','publicOriginSetting','services','workersDev','platforms','container','deployGuide'];
25
+ const DECLARATION_KEYS = ['version','project','compatibilityDate','compatibilityFlags','d1','r2','kv','queues','durableObjects','secrets','crons','vars','originVar','publicOriginSetting','publicSettings','services','workersDev','platforms','container','deployGuide'];
26
26
  const ENTRY_KEYS = {d1:['binding'],r2:['binding','locationHint'],kv:['binding'],queues:['binding','consumer','deadLetterQueue'],durableObjects:['binding','className','storage'],secrets:['binding','environment','verifyStandIn','optional'],services:['binding','project','entrypoint','allowedHosts','grant']};
27
27
 
28
28
  export function refuse(code, kind, name) { const error = new Error(code); error.resource = `${kind}:${name}`; return error; }
@@ -114,6 +114,7 @@ export function localOnlyBinding(declaration, localOnlyKeys = []) {
114
114
  /** A seed declares bindings, never names. Migrations come from the packaged artifact. */
115
115
  export function ownerPlan(target, declaration, artifact, { localOnlyKeys = [], env = {} } = {}) {
116
116
  assert(declaration?.version === 1 && typeof declaration === 'object' && Object.keys(declaration).every(key => DECLARATION_KEYS.includes(key)), 'invalid-owner-declaration');
117
+ assert(declaration.publicSettings === undefined || Array.isArray(declaration.publicSettings) && new Set(declaration.publicSettings).size === declaration.publicSettings.length && declaration.publicSettings.every(name => typeof name === 'string' && /^[A-Z][A-Z0-9_]*$/.test(name)), 'invalid-public-settings');
117
118
  if (declaration.platforms !== undefined) assert(Array.isArray(declaration.platforms) && declaration.platforms.length > 0 && new Set(declaration.platforms).size === declaration.platforms.length && declaration.platforms.every(item => ['workers','container'].includes(item)), 'invalid-platforms');
118
119
  if (declaration.container !== undefined) {
119
120
  const config=declaration.container;
@@ -1,6 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { mkdirSync, writeFileSync } from 'node:fs';
3
3
  import { resolve, dirname } from 'node:path';
4
+ import { clauseIdSource } from '../../foundation/runtime/seed-contract.mjs';
4
5
 
5
6
  export const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
6
7
  export const json = value => JSON.stringify(value, null, 2) + '\n';
@@ -14,7 +15,7 @@ function clauses(text) {
14
15
  if (body) result.push({ id: current.id, title: current.title, text: body });
15
16
  current = null;
16
17
  };
17
- const clauseLine = /^- \*\*([A-Z][A-Z0-9-]*-\d{3})\s+[—–-]\s+(.+?)\.?\*\*[ \t]*(.*)$/;
18
+ const clauseLine = new RegExp(`^- \\*\\*(${clauseIdSource})\\s+[—–-]\\s+(.+?)\\.?\\*\\*[ \\t]*(.*)$`);
18
19
  for (const line of text.split(/\r\n|\n|\r/)) {
19
20
  const match = clauseLine.exec(line);
20
21
  if (match) {
@@ -79,11 +79,15 @@ font files the app already serves; anything else is refused.
79
79
  | `--rer-font-body`, `--rer-font-heading` | font stack (optional) | text; headings and product name |
80
80
  | `--rer-radius` | `px` or `rem` length (optional) | cards, inputs, buttons |
81
81
  | `--rer-logo` | `url("/path")` to an svg, png or webp the app serves (optional) | mark beside the product name |
82
+ | `--rer-done`, `--rer-partial`, `--rer-missing` | colour (optional; Base has defaults) | status fills on the run site's `/contract` |
83
+ | `--rer-done-ink`, `--rer-partial-ink`, `--rer-missing-ink` | colour (optional) | status words and counts on `/contract` |
84
+ | `--rer-on-done`, `--rer-on-partial`, `--rer-on-missing` | colour (optional) | labels printed on each status fill |
82
85
 
83
86
  Contrast is checked against the declared colours before the installer starts:
84
87
  text on page and surface, muted text on page and surface, links on surface and
85
- accent text on accent need 4.5:1; focus on page and surface and borders on
86
- surface need 3:1. A failing pair is named with its ratio. Every `url()` must
88
+ accent text on accent need 4.5:1, as do each declared status ink on page and
89
+ surface and each `--rer-on-*` label on its declared fill; focus on page and
90
+ surface and borders on surface need 3:1. A failing pair is named with its ratio. Every `url()` must
87
91
  name a same-origin file under the served directory.
88
92
 
89
93
  The app must serve the file at `/rer-theme.css` with its fonts and logo; a
@@ -12,6 +12,10 @@ export const themeTokens = Object.freeze({
12
12
  '--rer-page': 'colour', '--rer-surface': 'colour', '--rer-text': 'colour', '--rer-muted': 'colour',
13
13
  '--rer-border': 'colour', '--rer-focus': 'colour', '--rer-accent': 'colour', '--rer-accent-text': 'colour',
14
14
  '--rer-link': 'colour', '--rer-font-body': 'stack', '--rer-font-heading': 'stack', '--rer-radius': 'radius', '--rer-logo': 'logo',
15
+ // The run site's /contract statuses: fills, text inks and the labels printed on fills. Base has defaults for each.
16
+ '--rer-done': 'colour', '--rer-partial': 'colour', '--rer-missing': 'colour',
17
+ '--rer-done-ink': 'colour', '--rer-partial-ink': 'colour', '--rer-missing-ink': 'colour',
18
+ '--rer-on-done': 'colour', '--rer-on-partial': 'colour', '--rer-on-missing': 'colour',
15
19
  });
16
20
  const required = ['--rer-page', '--rer-surface', '--rer-text', '--rer-muted', '--rer-border', '--rer-focus'];
17
21
 
@@ -20,6 +24,7 @@ const pairs = [
20
24
  ['--rer-text', '--rer-page', 4.5], ['--rer-text', '--rer-surface', 4.5], ['--rer-muted', '--rer-surface', 4.5], ['--rer-muted', '--rer-page', 4.5],
21
25
  ['--rer-link', '--rer-surface', 4.5], ['--rer-accent-text', '--rer-accent', 4.5],
22
26
  ['--rer-focus', '--rer-page', 3], ['--rer-focus', '--rer-surface', 3], ['--rer-border', '--rer-surface', 3],
27
+ ...['done', 'partial', 'missing'].flatMap(status => [[`--rer-${status}-ink`, '--rer-page', 4.5], [`--rer-${status}-ink`, '--rer-surface', 4.5], [`--rer-on-${status}`, `--rer-${status}`, 4.5]]),
23
28
  ];
24
29
 
25
30
  const faceDescriptors = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.38",
3
+ "version": "0.2.40",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",