@runeditrun/rer 0.2.84 → 0.2.86

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.
Files changed (236) hide show
  1. package/README.md +156 -50
  2. package/cli/README.md +78 -2
  3. package/cli/agent-door.mjs +149 -0
  4. package/cli/agent-fixtures.mjs +16 -0
  5. package/cli/agent-mail.mjs +54 -0
  6. package/cli/agent-network.mjs +64 -0
  7. package/cli/agent-reviewers.mjs +110 -0
  8. package/cli/agent-secrets.mjs +23 -0
  9. package/cli/agent-sponsors.mjs +43 -0
  10. package/cli/agent-surface.mjs +34 -0
  11. package/cli/agent-webhooks.mjs +19 -0
  12. package/cli/authoring.mjs +2 -1
  13. package/cli/bounded.mjs +1 -1
  14. package/cli/business/archive-task.mjs +32 -0
  15. package/cli/business/carry.mjs +151 -0
  16. package/cli/business/catchup-task.mjs +42 -0
  17. package/cli/business/choices.mjs +97 -0
  18. package/cli/business/command.mjs +29 -6
  19. package/cli/business/connect.mjs +20 -8
  20. package/cli/business/detector.mjs +4 -1
  21. package/cli/business/device.mjs +13 -0
  22. package/cli/business/export-inputs.mjs +69 -0
  23. package/cli/business/export-task.mjs +17 -0
  24. package/cli/business/invocation.mjs +8 -1
  25. package/cli/business/keychain.mjs +8 -1
  26. package/cli/business/lease.mjs +11 -1
  27. package/cli/business/local-commands.mjs +80 -30
  28. package/cli/business/outbound.mjs +9 -4
  29. package/cli/business/parsers-config.mjs +8 -7
  30. package/cli/business/parsers-syntax.mjs +7 -3
  31. package/cli/business/permissions.mjs +2 -0
  32. package/cli/business/questions.mjs +89 -6
  33. package/cli/business/setup-command.mjs +49 -0
  34. package/cli/business/setup-company.json +15 -0
  35. package/cli/business/setup-demo.mjs +95 -0
  36. package/cli/business/state.mjs +44 -10
  37. package/cli/business/supervisor.mjs +97 -32
  38. package/cli/business/vendor-door.mjs +230 -0
  39. package/cli/business/vendors/README.md +29 -3
  40. package/cli/business/vendors/common.mjs +8 -6
  41. package/cli/business/vendors/index.mjs +22 -11
  42. package/cli/business/vendors/sorry.mjs +106 -0
  43. package/cli/container-transfer.mjs +2 -2
  44. package/cli/contract.mjs +7 -7
  45. package/cli/demo-deploy-error.mjs +14 -0
  46. package/cli/demo-native.mjs +6 -2
  47. package/cli/deploy-command.mjs +6 -4
  48. package/cli/deploy-config.mjs +1 -1
  49. package/cli/deploy-owner-input.mjs +3 -1
  50. package/cli/deploy-variables.mjs +58 -0
  51. package/cli/deploy.mjs +9 -7
  52. package/cli/door-clauses.mjs +157 -0
  53. package/cli/errors.mjs +1 -1
  54. package/cli/export.mjs +16 -4
  55. package/cli/hosted-output.mjs +17 -7
  56. package/cli/human-error.mjs +20 -0
  57. package/cli/inspect.mjs +4 -0
  58. package/cli/jsonc.mjs +8 -4
  59. package/cli/lifecycle.mjs +26 -6
  60. package/cli/main.mjs +2 -1
  61. package/cli/managed-data-schema.mjs +127 -0
  62. package/cli/managed-data-zip.mjs +116 -0
  63. package/cli/managed-data.mjs +110 -0
  64. package/cli/managed-server.mjs +25 -14
  65. package/cli/native-owner-entry.mjs +86 -0
  66. package/cli/output.mjs +3 -2
  67. package/cli/parse.mjs +2 -2
  68. package/cli/portability-empty.mjs +65 -0
  69. package/cli/portability-migrations.mjs +33 -9
  70. package/cli/portability-policy.mjs +5 -2
  71. package/cli/portability-worker.mjs +15 -6
  72. package/cli/portability.mjs +30 -8
  73. package/cli/production-auth.mjs +1 -1
  74. package/cli/production-mail.mjs +8 -2
  75. package/cli/ready-summary.mjs +9 -0
  76. package/cli/run-transfers.mjs +37 -0
  77. package/cli/runtime-front-door.mjs +4 -4
  78. package/cli/server-proxy.mjs +4 -3
  79. package/cli/server-registry.mjs +13 -8
  80. package/cli/site.mjs +6 -1
  81. package/cli/transfers.mjs +17 -4
  82. package/edition-authoring/archive-source.mjs +59 -0
  83. package/edition-authoring/base-copies.mjs +147 -25
  84. package/edition-authoring/cli.mjs +1 -1
  85. package/edition-authoring/edition-migrations.mjs +7 -3
  86. package/edition-authoring/module-closure.mjs +2 -16
  87. package/edition-authoring/workflow-copies.mjs +1 -1
  88. package/edition-authoring/workflow-scripts.mjs +12 -3
  89. package/foundation/runtime/contract-docs.mjs +218 -34
  90. package/foundation/runtime/contract-prose-patterns.mjs +14 -0
  91. package/foundation/runtime/contract-prose.mjs +88 -0
  92. package/foundation/runtime/run-data.d.mts +1 -0
  93. package/foundation/runtime/run-data.mjs +2 -0
  94. package/global/CHANGELOG.md +126 -0
  95. package/global/README.md +156 -50
  96. package/global/cli/command.mjs +8 -2
  97. package/global/cli/install.mjs +4 -5
  98. package/global/cli/path-link.mjs +3 -2
  99. package/global/cli/repo-command.mjs +3 -7
  100. package/global/door/command.mjs +3 -1
  101. package/global/launch/dev.mjs +12 -2
  102. package/global/launch/facts.mjs +2 -2
  103. package/global/launch/render.mjs +16 -9
  104. package/global/launch/state.mjs +4 -4
  105. package/global/main.mjs +13 -8
  106. package/install.sh +17 -6
  107. package/modules/agent-door/CLAUSES.md +215 -0
  108. package/modules/agent-door/conformance/audit.mjs +66 -0
  109. package/modules/agent-door/conformance/authority.d.mts +2 -0
  110. package/modules/agent-door/conformance/authority.mjs +17 -0
  111. package/modules/agent-door/conformance/crypto.mjs +36 -0
  112. package/modules/agent-door/conformance/discovery.mjs +61 -0
  113. package/modules/agent-door/conformance/index.mjs +41 -0
  114. package/modules/agent-door/conformance/invocation.mjs +32 -0
  115. package/modules/agent-door/conformance/journey.mjs +112 -0
  116. package/modules/agent-door/conformance/narrowing.d.mts +1 -0
  117. package/modules/agent-door/conformance/narrowing.mjs +21 -0
  118. package/modules/agent-door/conformance/negative.mjs +47 -0
  119. package/modules/agent-door/conformance/network-modules.mjs +86 -0
  120. package/modules/agent-door/conformance/network-runtime.mjs +46 -0
  121. package/modules/agent-door/conformance/policy-phases.mjs +75 -0
  122. package/modules/agent-door/conformance/protocol.mjs +145 -0
  123. package/modules/agent-door/conformance/replay.mjs +38 -0
  124. package/modules/agent-door/conformance/schema.mjs +71 -0
  125. package/modules/agent-door/conformance/security.mjs +33 -0
  126. package/modules/agent-door/conformance/sponsors.mjs +68 -0
  127. package/modules/agent-door/conformance/surface.mjs +89 -0
  128. package/modules/agent-door/conformance/target.mjs +18 -0
  129. package/modules/agent-door/conformance/tool-name.d.mts +1 -0
  130. package/modules/agent-door/conformance/tool-name.mjs +7 -0
  131. package/modules/agent-door/conformance/webhooks.mjs +30 -0
  132. package/modules/container/README.md +6 -1
  133. package/modules/container/adapters/d1-limits.mjs +286 -0
  134. package/modules/container/adapters/d1-sqlite.mjs +95 -0
  135. package/modules/container/adapters/d1-workerd-preload.mjs +19 -0
  136. package/modules/container/adapters/d1-workerd-setup.mjs +26 -0
  137. package/modules/container/adapters/d1-workerd.mjs +5 -0
  138. package/modules/container/adapters/sqlite-worker.mjs +5 -3
  139. package/modules/container/build.mjs +1 -0
  140. package/modules/container/image-variables.mjs +14 -3
  141. package/modules/container/transfer.mjs +14 -4
  142. package/modules/container/worker-engine.mjs +3 -3
  143. package/modules/demo-host/README.md +6 -0
  144. package/modules/demo-host/build.mjs +1 -0
  145. package/modules/demo-host/native/prepare.mjs +2 -1
  146. package/modules/demo-host/native/sql.mjs +7 -2
  147. package/modules/demo-host/ownership.mjs +39 -0
  148. package/modules/demo-host/plan.mjs +2 -1
  149. package/modules/demo-host/remove.mjs +6 -1
  150. package/modules/deploy-kit/README.md +22 -2
  151. package/modules/deploy-kit/d1-import-diagnostics.mjs +56 -0
  152. package/modules/deploy-kit/d1-import.mjs +17 -5
  153. package/modules/deploy-kit/diagnostics.mjs +29 -3
  154. package/modules/deploy-kit/owner-cli.mjs +20 -7
  155. package/modules/deploy-kit/provider-transport.mjs +19 -4
  156. package/modules/deploy-kit/provider.mjs +57 -22
  157. package/modules/deploy-kit/readiness-window.mjs +1 -1
  158. package/modules/deploy-kit/site.mjs +8 -3
  159. package/modules/deploy-kit/worker.mjs +4 -4
  160. package/modules/import-kit/schema/importer-verification-receipt.schema.json +171 -0
  161. package/modules/import-kit/schema/importers.schema.json +107 -0
  162. package/modules/import-kit/src/d1/README.md +23 -4
  163. package/modules/import-kit/src/d1/atomic-prefix.ts +2 -2
  164. package/modules/import-kit/src/d1/budget.ts +15 -7
  165. package/modules/import-kit/src/d1/column-layout.ts +5 -0
  166. package/modules/import-kit/src/d1/creation.ts +15 -8
  167. package/modules/import-kit/src/d1/database.ts +3 -3
  168. package/modules/import-kit/src/d1/erasure-pages.ts +2 -1
  169. package/modules/import-kit/src/d1/erasure.ts +2 -2
  170. package/modules/import-kit/src/d1/jobs.ts +10 -6
  171. package/modules/import-kit/src/d1/plans.ts +14 -8
  172. package/modules/import-kit/src/d1/retirement.ts +2 -2
  173. package/modules/import-kit/src/d1/sets.ts +1 -3
  174. package/modules/import-kit/src/d1/staged-creation.ts +3 -3
  175. package/modules/import-kit/src/door/ADOPTING.md +20 -0
  176. package/modules/import-kit/src/door/README.md +2 -1
  177. package/modules/import-kit/src/door/admission.ts +5 -3
  178. package/modules/import-kit/src/door/archive.ts +5 -2
  179. package/modules/import-kit/src/door/authority.ts +1 -0
  180. package/modules/import-kit/src/door/grants.ts +1 -1
  181. package/modules/import-kit/src/door/handler.ts +14 -8
  182. package/modules/import-kit/src/door/index.ts +1 -1
  183. package/modules/import-kit/src/door/jobs.ts +40 -0
  184. package/modules/import-kit/src/door/limits.ts +1 -1
  185. package/modules/import-kit/src/door/operator.ts +3 -3
  186. package/modules/import-kit/src/door/planning.ts +10 -6
  187. package/modules/import-kit/src/door/protocol.ts +2 -2
  188. package/modules/import-kit/src/door/raw.ts +25 -0
  189. package/modules/import-kit/src/door/refusals.ts +2 -1
  190. package/modules/import-kit/src/door/types.ts +26 -6
  191. package/modules/import-kit/src/receipt/encoding.ts +37 -0
  192. package/modules/import-kit/src/receipt/index.ts +69 -0
  193. package/modules/import-kit/src/receipt/policy.ts +24 -0
  194. package/modules/import-kit/src/receipt/types.ts +64 -0
  195. package/modules/import-kit/src/receipt/uri.ts +45 -0
  196. package/modules/import-kit/src/receipt/validation.ts +87 -0
  197. package/modules/import-kit/src/status/encoding.ts +13 -0
  198. package/modules/import-kit/src/status/evidence.ts +218 -0
  199. package/modules/import-kit/src/status/index.ts +56 -0
  200. package/modules/import-kit/src/status/schema.ts +208 -0
  201. package/modules/import-kit/src/status/types.ts +86 -0
  202. package/modules/operator-auth/accounts/delegated.mjs +48 -0
  203. package/modules/operator-auth/index.d.mts +7 -0
  204. package/modules/operator-auth/service.mjs +2 -0
  205. package/modules/portability/README.md +138 -9
  206. package/modules/portability/backfills.mjs +9 -8
  207. package/modules/portability/bridge.mjs +32 -5
  208. package/modules/portability/catalogue.mjs +12 -5
  209. package/modules/portability/copies.mjs +8 -1
  210. package/modules/portability/derived.mjs +33 -0
  211. package/modules/portability/files.mjs +4 -3
  212. package/modules/portability/http-errors.mjs +1 -1
  213. package/modules/portability/http.mjs +3 -3
  214. package/modules/portability/import.mjs +29 -13
  215. package/modules/portability/index.d.mts +4 -3
  216. package/modules/portability/index.mjs +1 -1
  217. package/modules/portability/ledgers.mjs +3 -2
  218. package/modules/portability/legacy-safety.mjs +11 -2
  219. package/modules/portability/migration-history.mjs +2 -2
  220. package/modules/portability/progress.mjs +1 -0
  221. package/modules/portability/restore-empty.mjs +12 -0
  222. package/modules/release/github-verify.mjs +11 -2
  223. package/onboarding/adapter.mjs +35 -6
  224. package/onboarding/app-fetch.mjs +6 -4
  225. package/onboarding/development-runtime.mjs +19 -0
  226. package/onboarding/local/operation.mjs +45 -27
  227. package/onboarding/loopback-fetch.mjs +16 -0
  228. package/onboarding/operator-installer.mjs +2 -4
  229. package/onboarding/process-diagnostics.mjs +6 -2
  230. package/onboarding/production-runtime.mjs +4 -2
  231. package/onboarding/readiness.mjs +1 -0
  232. package/package.json +4 -2
  233. package/scripts/publish-check/copy_identities.py +3 -1
  234. package/scripts/publish-check/github_refs.py +32 -13
  235. package/scripts/publish-check/public_hygiene.py +1 -1
  236. package/cli/business/opt-ins.mjs +0 -33
@@ -1,13 +1,17 @@
1
+ import { humanError } from '../../cli/human-error.mjs';
1
2
  // What `rer dev` prints while it launches: a progress line at least every 30
2
3
  // seconds (a `progress` event with --json), then the dispatcher's ready lines.
4
+ import { readySummary } from '../../cli/ready-summary.mjs';
5
+ import { launchSummary } from '../../cli/run-transfers.mjs';
6
+
3
7
  const elapsed = ms => { const s = Math.round(ms / 1000); return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${s % 60}s`; };
4
8
  const quiet = 20000;
5
9
 
6
10
  // `keyless` (a start by the front door, whose log this is): the ready lines
7
11
  // leave out the dev-key link, so the door's files never hold a key.
8
- export function printer({ json, stopHint, keyless = false }) {
12
+ export function printer({ json, stopHint, keyless = false, root }) {
9
13
  const started = Date.now();
10
- let current = 'preparing', last = Date.now();
14
+ let current = 'preparing', last = Date.now(), phaseStarted = last, currentPhase;
11
15
  const event = (name, fields) => process.stdout.write(JSON.stringify({ version: 1, verb: 'dev', event: name, ...fields }) + '\n');
12
16
  const line = text => process.stderr.write(`rer dev: ${text}\n`);
13
17
  const progress = (phase, message) => {
@@ -16,20 +20,23 @@ export function printer({ json, stopHint, keyless = false }) {
16
20
  else line(message);
17
21
  };
18
22
  return {
19
- phase({ phase, message }) { if (phase !== 'note') current = message; progress(phase, message); },
23
+ phase({ phase, message }) { if (phase !== 'note') { if (phase !== currentPhase) phaseStarted = Date.now(); currentPhase = phase; current = message; } progress(phase, message); },
20
24
  attaching(startedAt) { progress('attach', `attaching to the launch already preparing this checkout (started ${elapsed(Date.now() - startedAt)} ago)`); },
21
- heartbeat() { if (Date.now() - last >= quiet) progress('waiting', `still ${current} (${elapsed(Date.now() - started)}). Allow up to 10 minutes; if this command is stopped, run rer dev again to reattach.`); },
25
+ heartbeat() { if (Date.now() - last >= quiet) progress('waiting', `still ${current} (${elapsed(Date.now() - phaseStarted)}). Allow up to 10 minutes; if this command is stopped, run rer dev again to reattach.`); },
22
26
  // The dispatcher's ready event, as its own human ready lines.
23
- ready(ready, { log, pid }) {
27
+ async ready(ready, { log, pid }) {
24
28
  if (keyless) { const { openUrl, ...rest } = ready; ready = rest; }
25
29
  if (json) { event('server', { pid, log }); process.stdout.write(JSON.stringify(ready) + '\n'); return; }
26
- const out = [`RER_READY ${ready.url}`];
30
+ const out = root
31
+ ? [...readySummary(ready), ...await launchSummary(root), '', 'Details for tools and troubleshooting:', `RER_READY ${ready.url}`]
32
+ : [`Your app is ready, open it: ${ready.openUrl ?? ready.url}`, `RER_READY ${ready.url}`];
27
33
  if (ready.openUrl) {
28
34
  if (ready.signedInAs) out.push(`RER_SIGNED_IN ${ready.signedInAs}`);
29
- out.push(`RER_OPEN ${ready.openUrl}`, 'Open that link on this computer. Its fragment holds this checkout\'s dev key, which the page keeps only as a cookie; never share the link.');
35
+ out.push(`RER_OPEN ${ready.openUrl}`);
30
36
  }
31
37
  // A seed with a run site: its static homepage, /run and docs, served locally.
32
- if (ready.siteUrl) out.push(`RER_SITE ${ready.siteUrl}`);
38
+ // The checkout summary above already labels it for people.
39
+ if (ready.siteUrl) out.push(...(root ? [] : [`Site: ${ready.siteUrl}`]), `RER_SITE ${ready.siteUrl}`);
33
40
  out.push(`The server keeps running in the background${pid ? ` (PID ${pid})` : ''}. Stop it with: ${stopHint}`);
34
41
  if (log) out.push(`Server log (private): ${log}`);
35
42
  process.stdout.write(out.join('\n') + '\n');
@@ -39,7 +46,7 @@ export function printer({ json, stopHint, keyless = false }) {
39
46
  if (failure.event) process.stdout.write(JSON.stringify(failure.event) + '\n');
40
47
  else event('error', { code: 'launch_refused', message: failure.message, exitCode: failure.exitCode });
41
48
  event('result', { ok: false, exitCode: failure.exitCode });
42
- } else process.stderr.write(failure.message + '\n');
49
+ } else process.stderr.write(humanError(failure, { retry: /Correct the cause, then run (.+) again\./.exec(failure.message)?.[1] }) + '\n');
43
50
  },
44
51
  };
45
52
  }
@@ -131,8 +131,8 @@ const stepRecord = name => ({
131
131
  });
132
132
  export const installState = stepRecord('install'), setupState = stepRecord('setup');
133
133
 
134
- // The ports other checkouts were set up on by this launcher. A stopped
135
- // checkout keeps its saved origin, so a fresh launch must not take its port.
134
+ // Saved setup ports are held only while their launch worker or server lives.
135
+ // A stopped checkout keeps its settings without reserving a port indefinitely.
136
136
  export async function savedPorts(checkout, env = process.env) {
137
137
  const launches = join(serversDirectory(env), 'launches'), own = launchPath(checkout, env);
138
138
  let entries = [];
@@ -140,8 +140,8 @@ export async function savedPorts(checkout, env = process.env) {
140
140
  const ports = [];
141
141
  for (const entry of entries) {
142
142
  if (!entry.isDirectory() || join(launches, entry.name) === own) continue;
143
- const port = (await setupState.read(join(launches, entry.name)))?.port;
144
- if (Number.isInteger(port)) ports.push(port);
143
+ const directory = join(launches, entry.name), port = (await setupState.read(directory))?.port;
144
+ if (Number.isInteger(port) && (await liveWorker(directory) || await live(await serverRecord.read(directory)))) ports.push(port);
145
145
  }
146
146
  return ports;
147
147
  }
package/global/main.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { humanError } from '../cli/human-error.mjs';
1
2
  import { checkoutBootstrap, checkoutVerbs } from '../cli/contract.mjs';
2
3
  import { dispatcher, locate, pinnedPackage, unsupportedMessage } from './checkout.mjs';
3
4
  import { delegate } from './delegate.mjs';
@@ -28,8 +29,8 @@ else its vendored scripts/rer.mjs.
28
29
  them off PATH): where a project's docs say pnpm run X, run rer run X.
29
30
  rer list [DIR] The checkouts in DIR (default: here), newest first, with whether rer dev can
30
31
  launch them, whether they are set up, and their running URL. --json for data.
31
- rer business ... Pair a Business device, store local vendor keys, inspect tasks and disconnect.
32
- rer business --help lists the commands and current protocol limitations.
32
+ rer business ... Set up your business once and share its name, logo and brand colour
33
+ with apps that support Business. Start with rer business connect.
33
34
  rer companion ... Pair this computer with a Run Edit Run app and run its change requests here
34
35
  with your own Codex or Claude. rer companion --help lists the commands.
35
36
  rer door ... The opt-in front door: every checkout at http://NAME.localhost:PORT, started
@@ -37,6 +38,7 @@ else its vendored scripts/rer.mjs.
37
38
  rer cli status This rer: version, contents digest, install channel, launcher and other rer
38
39
  commands on PATH. --json for data.
39
40
  rer cli install Install this package for the current user (~/.local/bin/rer).
41
+ rer cli path Optional: make rer available in future terminals; shows the shell step.
40
42
  rer cli uninstall Remove the launcher and the install root; ~/.rer is untouched.
41
43
  rer update Move to the latest published rer (--version X for an exact one), the way it
42
44
  was installed: npx and install.sh installs switch atomically, npm installs run npm.
@@ -69,7 +71,7 @@ export async function main(argv) {
69
71
  if (!verb || verb === '--help' || verb === '-h' || verb === 'help') { process.stdout.write(help); return 0; }
70
72
  if (verb === 'cli') return (await import('./cli/command.mjs')).cliCommand(argv.slice(1));
71
73
  if (verb === 'list') return (await import('./list.mjs')).listCommand(argv.slice(1));
72
- if (verb === 'door') return (await import('./door/command.mjs')).doorCommand(argv.slice(1));
74
+ if (verb === 'door' && argv[1] !== 'clauses') return (await import('./door/command.mjs')).doorCommand(argv.slice(1));
73
75
  if (verb === 'run') return (await import('./run.mjs')).runScript(argv.slice(1));
74
76
  if (repositoryCommands[verb] && argv.includes('--help')) {
75
77
  const { help } = await import('../cli/parse.mjs');
@@ -80,7 +82,7 @@ export async function main(argv) {
80
82
  const repository = repoArguments(argv);
81
83
  if (repository) return await (await import('./cli/repo-command.mjs')).repoCommand(repository);
82
84
  } catch (error) {
83
- process.stderr.write(error.message + '\n');
85
+ process.stderr.write((argv.includes('--json') ? error.message : humanError(error)) + '\n');
84
86
  return typeof error.exitCode === 'number' ? error.exitCode : 1;
85
87
  }
86
88
  const target = locate(argv);
@@ -95,7 +97,7 @@ export async function main(argv) {
95
97
  if ((mode !== 'bundled' || pinnedPackage(target.root)) && verb === 'doctor' && !argv.includes('--help')) {
96
98
  const { parse } = await import('../cli/parse.mjs');
97
99
  try { parse(target.args, target.root); }
98
- catch (error) { process.stderr.write(error.message + '\n'); return error.exitCode ?? 2; }
100
+ catch (error) { process.stderr.write((argv.includes('--json') ? error.message : humanError(error)) + '\n'); return error.exitCode ?? 2; }
99
101
  const code = await (await import('./browser-runtime.mjs')).browserPreflight(target.root, target.args);
100
102
  if (code !== undefined) return code;
101
103
  }
@@ -107,11 +109,11 @@ export async function main(argv) {
107
109
  // here, before provisioning the checkout's package manager.
108
110
  const publicArgs = verb === 'dev' ? target.args.filter(arg => arg !== '--door-start') : target.args;
109
111
  try { parse(publicArgs, target.root); }
110
- catch (error) { process.stderr.write(error.message + '\n'); return error.exitCode ?? 2; }
112
+ catch (error) { process.stderr.write((argv.includes('--json') ? error.message : humanError(error)) + '\n'); return error.exitCode ?? 2; }
111
113
  const { ensureProjectPnpm } = await import('../cli/project-pnpm.mjs');
112
114
  const { RerError } = await import('../cli/errors.mjs');
113
115
  try { await ensureProjectPnpm(target.root, { report: text => process.stderr.write(text + '\n') }); }
114
- catch (error) { if (!(error instanceof RerError)) throw error; process.stderr.write(error.message + '\n'); return error.exitCode; }
116
+ catch (error) { if (!(error instanceof RerError)) throw error; process.stderr.write((argv.includes('--json') ? error.message : humanError(error)) + '\n'); return error.exitCode; }
115
117
  }
116
118
  }
117
119
  if (verb === 'queue') {
@@ -135,7 +137,7 @@ export async function main(argv) {
135
137
  if (!(failure instanceof LaunchFailure)) throw failure;
136
138
  // A --json caller gets the failed step as data, as the checkout's own verbs report it.
137
139
  if (failure.event && target.args.includes('--json')) for (const event of [{ ...failure.event, verb }, { version: 1, verb, event: 'result', ok: false, exitCode: failure.exitCode }]) process.stdout.write(JSON.stringify(event) + '\n');
138
- else process.stderr.write(failure.message + '\n');
140
+ else process.stderr.write(humanError(failure, { retry: `rer ${verb} --cwd '${target.root.replaceAll("'", "'\\''")}'` }) + '\n');
139
141
  return failure.exitCode;
140
142
  }
141
143
  }
@@ -145,6 +147,9 @@ export async function main(argv) {
145
147
  const code = await (await import('./browser-runtime.mjs')).browserPreflight(target.root, target.args);
146
148
  if (code !== undefined) return code;
147
149
  }
150
+ if (first && ['setup', 'dev'].includes(verb) && !argv.some(arg => ['--help', '-h', '--stop', '--demo'].includes(arg))) {
151
+ await (await import('../cli/business/carry.mjs')).refreshCheckout(target.root);
152
+ }
148
153
  if (verb === 'dev' && mode && mode !== 'package' && !argv.includes('--help')) return (await import('./launch/dev.mjs')).launchDev(target);
149
154
  // Every other server start or queued job on a vendored pin gets the person
150
155
  // defaults too (a pinned package applies its own).
package/install.sh CHANGED
@@ -12,7 +12,7 @@
12
12
  # package's own `rer cli install`: the same layout as
13
13
  # `npx -y @runeditrun/rer cli install`. A failure leaves any previous install
14
14
  # selected and working. It never edits shell profiles: when ~/.local/bin is not
15
- # on PATH for new terminals, its last line is the one to run that adds it.
15
+ # on PATH, the absolute launcher works now; shell setup is optional after launch.
16
16
  #
17
17
  # Needs curl and tar. If Node 22 or later is absent, installs the pinned official
18
18
  # Node release in rer's own data directory. macOS/Linux x64/arm64; Windows: WSL2.
@@ -20,6 +20,13 @@
20
20
  # Everything runs from main, so a partly downloaded script does nothing.
21
21
  main() {
22
22
  set -eu
23
+ # BEGIN COLD RUN BUDGET (generated from foundation/runtime/run-data.mjs)
24
+ cold_run_budget='Allow roughly 500 MB–1 GB of downloads and 1–3 GB of disk space for a first run, including Node, rer, the app and its dependencies. The app and your computer can need more; later runs reuse downloads.'
25
+ # END COLD RUN BUDGET
26
+ printf '%s\n' "$cold_run_budget"
27
+ RER_BUDGET_SHOWN=1
28
+ RER_TRANSFER_NODE_BYTES=0
29
+ export RER_BUDGET_SHOWN RER_TRANSFER_NODE_BYTES
23
30
  if [ "${1:-}" = -- ]; then shift; fi
24
31
  package='@runeditrun/rer'
25
32
 
@@ -139,15 +146,15 @@ if (!ended || pax) stop('the archive is truncated.');
139
146
  if (process.argv[4] !== '' && Number(process.argv[4]) !== count) stop('the archive holds ' + count + ' entries; the registry says ' + process.argv[4] + '.');
140
147
  if (process.argv[5] !== '' && Number(process.argv[5]) !== total) stop('the archive unpacks to ' + total + ' bytes; the registry says ' + process.argv[5] + '.');
141
148
  NODE
149
+ RER_TRANSFER_RER_BYTES=$(wc -c < "$work/rer.tgz" | tr -d ' ')
150
+ export RER_TRANSFER_RER_BYTES
142
151
  mkdir "$work/stage"
143
152
  tar -xzf "$work/rer.tgz" -C "$work/stage" || fail "could not unpack rer $version; nothing was installed."
144
- # A supplied command replaces the app next step. Business connect runs the
145
- # launcher directly, so it also needs no PATH advice.
153
+ # A supplied command replaces the app next step. Shell setup is offered only
154
+ # after the app is ready, through the optional rer cli path command.
146
155
  no_next=
147
- no_path=
148
156
  if [ "$#" -gt 0 ]; then no_next=1; fi
149
- if [ "${1:-}" = business ] && [ "${2:-}" = connect ]; then no_path=1; fi
150
- RER_INSTALL_CHANNEL=script RER_INSTALL_NO_NEXT=$no_next RER_INSTALL_NO_PATH=$no_path "$node_binary" "$work/stage/package/global/rer.mjs" cli install </dev/null \
157
+ RER_INSTALL_CHANNEL=script RER_INSTALL_NO_NEXT=$no_next "$node_binary" "$work/stage/package/global/rer.mjs" cli install </dev/null \
151
158
  || fail "rer cli install failed; any previous install is still selected."
152
159
  if [ "$#" -eq 0 ]; then return; fi
153
160
  # The command can tell the person how to run rer again from their own shell,
@@ -174,6 +181,8 @@ install_node() {
174
181
  || fail "could not download Node $node_version checksums from nodejs.org."
175
182
  curl -fL --proto '=https' "$release/$archive" -o "$work/$archive" \
176
183
  || fail "could not download Node $node_version from nodejs.org."
184
+ RER_TRANSFER_NODE_BYTES=$(wc -c < "$work/$archive" | tr -d ' ')
185
+ export RER_TRANSFER_NODE_BYTES
177
186
  expected=$(awk -v file="$archive" '$2 == file { print $1 }' "$work/SHASUMS256.txt")
178
187
  [ "${#expected}" -eq 64 ] || fail "nodejs.org gives no unique SHA-256 for $archive."
179
188
  case "$expected" in *[!0-9a-f]*) fail "nodejs.org gives an invalid SHA-256 for $archive." ;; esac
@@ -203,6 +212,8 @@ try {
203
212
  fs.renameSync(temporary, path.join(root, 'node'));
204
213
  } finally { try { fs.unlinkSync(temporary); } catch (error) { if (error.code !== 'ENOENT') throw error; } }
205
214
  NODE
215
+ RER_TRANSFER_NODE_DISK=$(du -sk "$node_home" | awk '{printf "%.0f", $1 * 1024}')
216
+ export RER_TRANSFER_NODE_DISK
206
217
  node_binary="$node_home/bin/node"
207
218
  PATH="$PATH:$node_home/bin"
208
219
  export PATH
@@ -0,0 +1,215 @@
1
+ # Base-delivered agent clauses
2
+
3
+ This is the canonical acceptance text for BASE-AGENT-001 through BASE-AGENT-013.
4
+ `rer door clauses --write` synchronizes these clauses into a seed's CONTRACT.md.
5
+ The seed owns its SURFACE- and AGENT- clauses and its judgments: adding these
6
+ requirements proves no implementation. New Status rows start missing; later
7
+ syncs retain the seed's status, evidence and gap, including a newer judgment.
8
+ MCP method names below use spaced slashes; wire names omit those spaces.
9
+
10
+ ## Target clauses
11
+
12
+ ### Agent surface (Base-delivered)
13
+
14
+ #### BASE-AGENT-001 — One MCP door per seed
15
+
16
+ *Tier:* Agent surface
17
+
18
+ **Requirement.** Every seed, hosted or self-hosted, serves one remote MCP endpoint at `/mcp` over Streamable HTTP. It speaks the current revision (2026-07-28) and accepts 2025-11-25 clients through the twelve-month deprecation window. It implements `server / discover`, tools, resources and prompts. Lists are deterministic and carry `ttlMs` and `cacheScope: "private"`. Roots, Sampling and Logging are not served.
19
+
20
+ **Acceptance.**
21
+ 1. `server / discover` returns the supported versions, capabilities, `serverInfo` and instructions.
22
+ 2. A 2026-07-28 request works with no handshake, and a 2025-11-25 client completes `initialize` and lists the same tools.
23
+ 3. An unsupported version returns `UnsupportedProtocolVersion`.
24
+ 4. Two `tools / list` calls return the same order, with cache fields.
25
+ 5. A foreign Origin returns 403, and a header and body method mismatch returns `HeaderMismatch`.
26
+ 6. An oversized body returns 413 with no effect.
27
+
28
+ #### BASE-AGENT-002 — The seed's jobs are tools, through the UI's own actions
29
+
30
+ *Tier:* Agent surface
31
+
32
+ **Requirement.** Each Core job a person does in the product is a tool. Where one is not, the Agent surface says why: it runs on a device, it is a person's interactive screen, it belongs to a connector or the import door, or it is an installation fact. Risk is never the reason: a risky job is a tool with its class (BASE-AGENT-006). Tools are named `<seed>.<area>.<verb>` and declare input and output schemas and truthful annotations. Each calls the same server action as the UI, so validation and authorization are written once, and the seed's embedded agents use the same registry. A business refusal returns `isError` with the seed's stable error code.
33
+
34
+ **Acceptance.**
35
+ 1. The Core clause ids in each tool's `_meta`, with the not-a-tool reasons that `server / discover` serves, cover every Core clause in the contract, and no reason is risk; the harness and `rer check` fail on a gap.
36
+ 2. Each tool's fixture result validates against its `outputSchema`.
37
+ 3. Read tools declare `readOnlyHint`; tools that can carry destructive declare `destructiveHint`, and tools that can carry external declare `openWorldHint`.
38
+ 4. A refusal returns the same error code the UI gets for the same action.
39
+ 5. The UI action and its tool, on the same fixture, give the same record state and the same audit event type.
40
+ 6. The seed's embedded agents appear in the audit as calls to the same tools.
41
+
42
+ #### BASE-AGENT-003 — Records are resources
43
+
44
+ *Tier:* Agent surface
45
+
46
+ **Requirement.** Each primary record type has a URI template, and tools return `resource_link`s to the records they touch. A read returns exactly the fields the caller's role sees in the UI. File bytes count against any byte budget on the grant. A record the caller cannot open reads as not found, identical to a missing id. Text from customers, imports or files carries an untrusted marker in `_meta`.
47
+
48
+ **Acceptance.**
49
+ 1. `resources / templates / list` names every record type in the Agent surface.
50
+ 2. Reads as two roles return exactly what the UI shows each.
51
+ 3. An out-of-scope id and a missing id give identical responses.
52
+ 4. A write's `resource_link` reads back the new state.
53
+ 5. Bytes over budget return `budget_exhausted` and no partial content.
54
+ 6. Customer-sourced text carries the untrusted marker.
55
+
56
+ #### BASE-AGENT-004 — Business identity and short-lived, audience-bound tokens
57
+
58
+ *Tier:* Agent surface
59
+
60
+ **Requirement.** The door is an OAuth 2.1 resource server. Its RFC 9728 metadata names the authorization servers this installation trusts. That is the paired Business when Business provisioned it, verified with the owner-claim trust the installation already holds for its import door; otherwise it is the seed's own sign-in. Access tokens are RFC 9068 JWTs with `aud` set to the seed's canonical MCP URI, `sub` the sponsoring person, `act` the agent (RFC 8693) with its specialist, scopes per tool family, and a lifetime of 15 minutes or less (5 by default). The policy scopes rules on the sponsor, agent and specialist the token names. The consent behind the tokens can last longer and is revocable. Tokens travel only in the Authorization header, and there is no passthrough.
61
+
62
+ **Acceptance.**
63
+ 1. An unauthenticated call returns 401 with `resource_metadata`, and the metadata names the trusted servers and scopes.
64
+ 2. A Business token for this seed works, and the same token sent to a sibling seed returns 401.
65
+ 3. An expired token returns 401, and a token with a lifetime over 15 minutes is refused.
66
+ 4. A read-only token calling a write tool returns 403 `insufficient_scope` with every needed scope in one challenge.
67
+ 5. A token in a query string is refused and not logged.
68
+ 6. Revoking consent in the seed or in Business refuses the next call within 60 seconds.
69
+ 7. After unpairing, Business tokens are refused and the seed's own sign-in still works.
70
+
71
+ #### BASE-AGENT-005 — An agent acts as a person in a role, never more
72
+
73
+ *Tier:* Agent surface
74
+
75
+ **Requirement.** Every call is authorized as the sponsoring person's current role and access (BASE-ACCESS-004), intersected with the grant's resources, actions and budget. A grant only narrows. No call widens the calling agent's own authority. A call that would widen its own grant or its sponsor's role, or change the company policy or Pause, is refused with `self_escalation`, whatever the policy says; narrowing its own grant is allowed. Other access and security changes are ordinary actions in the access and security classes. An agent never acts after its sponsor is suspended. Anything an agent reads (records, files, emails, imports, other seeds' results) is data and cannot change its scope, its targets or a call's class.
76
+
77
+ **Acceptance.**
78
+ 1. For each role fixture, every tool's allow or deny through MCP equals the UI's for the same action.
79
+ 2. A one-folder, read-only grant holds, and widening through arguments is refused.
80
+ 3. Downgrading the sponsor changes the next call's result, and suspending the sponsor returns 401.
81
+ 4. Calls that widen the agent's own grant or its sponsor's role, or change the policy or Pause, return `self_escalation` and change nothing, even under a policy with every class autonomous; dropping a scope from its own grant runs.
82
+ 5. An injection fixture yields no out-of-grant call and no change of class: record text asking for a wider action, or claiming that a recipient is internal.
83
+
84
+ #### BASE-AGENT-006 — Every action declares its risk class
85
+
86
+ *Tier:* Agent surface
87
+
88
+ **Requirement.** Classes come from the fleet list in RISK-POLICY.md: standard, external, money, commitment, accounts, gated, access, security, destructive, sensitive and live. In the registry, each tool declares the classes it can carry and a server-side classifier that decides them per call from the arguments, current records and, for gated, the provider's answer. The classifier also supplies each class's facts: the measure (items, recipients, amount and currency, people or records), the counterparty (internal, known, new or public), the direction for access, the provider and step for gated, and the data kind for sensitive. A classifier never reads a flag, label or claim supplied by the agent or by record text. A seed cannot add a class; it proposes one for the fleet list.
89
+
90
+ **Acceptance.**
91
+ 1. Every tool in `tools / list` carries its possible classes in `_meta`, equal to the Agent surface table.
92
+ 2. For each tool, fixture calls cover every class it can carry, and the computed classes and facts equal the fixture's expected values.
93
+ 3. An argument or record text asserting a class or a confirmation (`internal: true`, `confirmExternal: true`) leaves the computed classes unchanged.
94
+ 4. Money calls carry amount and currency, external calls their counterparty and recipient count, access calls their direction, and destructive calls their item count.
95
+ 5. No tool in `tools / list` declares a class outside the fleet list, and `rer check` fails on one.
96
+ 6. A refused call's audit row still records its computed classes.
97
+
98
+ #### BASE-AGENT-007 — The company's policy decides, at one chokepoint
99
+
100
+ *Tier:* Agent surface
101
+
102
+ **Requirement.** Every agent door calls one decision function: MCP, the integration API with agent tokens, and the seed's embedded agents. It evaluates the call's classes against the company's policy, as above. The seed ships no dispositions and fills no gap with one: agent access opens only under a complete policy that setup has asked for (RISK-POLICY.md), and before then every agent call returns `policy_unset` with the setup link and changes nothing. *Autonomous* runs the call. *Review* runs it and adds it to the review feed. *Approval* saves a pending action with server-computed facts and returns `input_required`, with a URL-mode elicitation to the seed's approval page and a pending handle. Each person the rule names approves the exact saved revision in a signed-in browser, and changed inputs need a new approval. The retried call returns the result and a receipt. A rejection returns `approval_rejected`, and a lapse past the wait the rule sets returns `approval_expired`. *Blocked* returns `policy_blocked`, naming the class, rule and revision.
103
+
104
+ **Acceptance.**
105
+ 1. The Base harness runs each tool under each disposition for every class it can carry, and sees it run, run and enter the review feed, wait with no effect, or be refused.
106
+ 2. Before setup is complete, the setup page lists every class the seed's tools carry with examples and no answer pre-selected, an agent call returns `policy_unset` with the setup link and changes nothing, and an incomplete revision cannot be confirmed; a `*` rule completes it, and a tool an upgrade adds with an unanswered class appears in `tools / list` once that class is answered, while the other tools keep running.
107
+ 3. Under "money autonomous up to $500, approval up to $10,000, blocked above", calls of $400, $600 and $20,000 run, wait and are refused; a per-day cap sends the call that crosses it to the next rule.
108
+ 4. A call carrying two classes takes the stricter disposition.
109
+ 5. An approval shows server-computed facts and an expiry, returns the URL elicitation and a handle, and completes once after the named approver approves; a changed input needs a new approval, and a rejection or lapse leaves no effect.
110
+ 6. The same call through MCP, the integration API and an embedded agent gets the same decision.
111
+ 7. A policy change applies to the next call within 60 seconds, and the audit cites the new revision.
112
+ 8. A policy document with a bad signature or another Business's id is rejected, and the door keeps the last valid revision.
113
+
114
+ #### BASE-AGENT-008 — Truthful attribution
115
+
116
+ *Tier:* Agent surface
117
+
118
+ **Requirement.** Every agent act is recorded and shown as `"<agent> for <person>"`, and mail and messages an agent sends outside name it that way as their sender. An approval, a review mark, a confirmation (a warning dialog, a typed-field confirmation, a delivery confirmation), a decision or a signature attributed to a person comes only from that person's signed-in session. When an agent does the equivalent act, the record names the agent, and the act carries its own class; a binding decision or a signature is commitment. Agent doors ignore arguments that stand for a person's confirmation. No tool solves a bot check, or enters a person's own password or 2FA code at an outside service. A provider step that demands a person goes to a person, whatever the policy says; the gated class marks such steps before they run.
119
+
120
+ **Acceptance.**
121
+ 1. An agent call carrying a person-confirmation flag is classified and decided exactly as without it.
122
+ 2. Approving, marking reviewed or answering a policy question with an agent or device token returns 403 and changes nothing.
123
+ 3. A form-mode elicitation "accept" never completes an approval.
124
+ 4. Where an agent's decision, signature or field confirmation runs without a person, it reads `"<agent> for <person>"` in the record, the activity view, exports and any certificate, never as the person's own act.
125
+ 5. After a person approves an agent's prepared action, the record shows the person as approver and the agent as preparer.
126
+ 6. Activity and exports at 1440 and 390 show `"<agent> for <person>"` for every agent act.
127
+ 7. Mail an agent sends to an outside address names `"<agent> for <person>"` as its sender.
128
+
129
+ #### BASE-AGENT-009 — Every agent action is audited with its class and decision
130
+
131
+ *Tier:* Agent surface
132
+
133
+ **Requirement.** Extending BASE-OPS-005, each call that reads private data or changes anything records the agent client, name and specialist, and the run or task id (`traceparent` when sent); the sponsoring person, the grant, the tool and the targets; the classes and their facts, and the policy revision and rule; the decision (autonomous, review, approval, blocked, unset or self_escalation) and the outcome (done, refused, pending or failed); the approval or review id and person, and the idempotency key. For a period, the seed's Agents page shows actions by class and decision with the notable ones, the review feed (Mark reviewed, Flag, and Undo where reversible), pending approvals, steps waiting for a person and setup questions. Business shows the same across seeds.
134
+
135
+ **Acceptance.**
136
+ 1. One write leaves a complete audit row.
137
+ 2. Refused, pending, unset and self-escalation calls are audited.
138
+ 3. The Agents page's counts by class and decision equal the audit rows on a fixture week.
139
+ 4. The review feed lists exactly the calls decided as review; Mark reviewed records the person, and Undo restores a reversible one.
140
+ 5. Filtering by agent or class lists only those rows, and export includes every field.
141
+ 6. Removing the agent keeps its rows and its name.
142
+ 7. The Agents page works at 1440 and 390 with no serious or critical axe findings.
143
+
144
+ #### BASE-AGENT-010 — Agents can follow changes
145
+
146
+ *Tier:* Agent surface
147
+
148
+ **Requirement.** The seed emits a typed event for every record change and for every approval, review and policy decision. Each event carries a stable id, a type, the record URI, the actor (a person, or an agent acting for a person) and a time. Events never carry secrets or more than the subscriber may read. Agents can read events three ways: `subscriptions / listen`, an `events.list` tool with a cursor, and signed webhooks from Base `integrations` using the same ids. Every channel delivers at least once and filters by access at delivery.
149
+
150
+ **Acceptance.**
151
+ 1. A subscribed record changed in the UI produces a notification within 10 seconds.
152
+ 2. `events.list` returns the same event id the webhook carries.
153
+ 3. Replaying from a cursor returns the same ids in order.
154
+ 4. After access is revoked, no channel delivers events about that record.
155
+ 5. A failed webhook is visible and replays without duplicate effects.
156
+ 6. `approval.pending`, `approval.decided`, `review.flagged` and `policy.adopted` carry the class and decision and nothing the subscriber may not read.
157
+
158
+ #### BASE-AGENT-011 — Limits are policy, and Pause stops everything
159
+
160
+ *Tier:* Agent surface
161
+
162
+ **Requirement.** Business limits are rules in the company's policy: per-call and per-day thresholds on any class's measure, such as money moved, outside recipients or items destroyed; spend caps on provider cost (models, SMS, email) per seed, specialist or agent, which setup asks with the classes; "no cap" is an answer. Tools with provider cost declare an estimate before they run, and an exhausted cap returns `budget_exhausted` before any partial effect. The seed's capacity limits (request rate, body and byte sizes) protect the installation: they bound rate and size, never daily business volume, are documented and are not policy. A grant carries budgets only when the person granting it sets them. A **Pause agents** control in the seed, and Pause all agents in Business when paired, refuses every agent token within 60 seconds until a person resumes; browser sessions and devices keep working.
163
+
164
+ **Acceptance.**
165
+ 1. A rate overrun returns 429 with `Retry-After`.
166
+ 2. A per-day cap of three outside recipients sends the fourth to the rule that applies past the cap.
167
+ 3. An exhausted spend cap returns `budget_exhausted` with no partial effect and shows the spend.
168
+ 4. Under the answer "no cap", a spending call runs and its spend shows in usage; a call that spends nothing is unaffected by any cap.
169
+ 5. The usage view shows calls, decisions by class, money moved and provider spend per agent.
170
+ 6. Pause and Pause all agents each stop the next call within 60 seconds, and resume restores access.
171
+ 7. An agent token cannot resume.
172
+
173
+ #### BASE-AGENT-012 — Writes are idempotent and conflict-safe
174
+
175
+ *Tier:* Agent surface
176
+
177
+ **Requirement.** Every mutating tool requires an idempotency key and takes an optional expected revision. The same key with the same arguments returns the first outcome for at least 24 hours; the same key with different arguments returns `idempotency_conflict`; a stale revision returns `revision_conflict` with the current revision. Long work returns a job handle and a status tool, with no dependence on the Tasks extension.
178
+
179
+ **Acceptance.**
180
+ 1. Two calls with one key give one effect and equal results.
181
+ 2. A retry with a new JSON-RPC id and the same key, after a dropped stream, returns the recorded outcome.
182
+ 3. The same key with different arguments returns a conflict and no effect.
183
+ 4. A stale revision returns a conflict naming the current revision.
184
+ 5. A job handle used by another person's token reads as not found.
185
+
186
+ #### BASE-AGENT-013 — Manifest, docs and the conformance journey
187
+
188
+ *Tier:* Agent surface
189
+
190
+ **Requirement.** `server / discover` instructions and an on-site `/docs/agents` page are generated from the action registry. The page lists tools by job, with each tool's classes, the test that adds each computed class, its scopes, resource templates, event types, capacity limits and error codes, and the specialist role. `prompts / list` carries the specialist's jobs. Base ships the conformance journey, a harness that `rer verify` runs against `rer dev` and seeds run in CI. It is an MCP client; a signed-in test person takes a person's steps (setup answers, approvals, review marks, resume) through the URLs the door returns, and the same browser leg runs the UI-parity actions and the page checks at 1440 and 390. It runs every acceptance point of BASE-AGENT-001 to 012 and of the seed's SURFACE clauses under two company policies: *all autonomous* (`*`), and *held* (standard review, every other class the seed declares approval, which the test person grants), plus the single-class variants a point names. A point that names no disposition passes under both.
191
+
192
+ **Acceptance.**
193
+ 1. The docs list exactly the names in `tools / list` and `resources / templates / list`.
194
+ 2. Each tool's classes, and the test behind each computed one, are documented.
195
+ 3. The harness fails on any of: a tool without a schema; an effect under approval or blocked, or before setup is complete; a computed class that differs from its fixture; a flag that changes a class or completes a person's step; a role-parity mismatch; a wrong-audience token being accepted; a duplicate effect on retry.
196
+ 4. Every acceptance point runs under both policies, every decision matches the policy in force, and under all autonomous no call waits for a person or is refused by policy.
197
+ 5. A stranger agent given only the seed URL completes the specialist journey through MCP.
198
+
199
+ ## Status
200
+
201
+ | Clause | Title | Kind | Status | Evidence | Gap |
202
+ | --- | --- | --- | --- | --- | --- |
203
+ | `BASE-AGENT-001` | One MCP door per seed | target | missing | | Not yet judged through this seed's own doors. |
204
+ | `BASE-AGENT-002` | The seed's jobs are tools, through the UI's own actions | target | missing | | Not yet judged through this seed's own doors. |
205
+ | `BASE-AGENT-003` | Records are resources | target | missing | | Not yet judged through this seed's own doors. |
206
+ | `BASE-AGENT-004` | Business identity and short-lived, audience-bound tokens | target | missing | | Not yet judged through this seed's own doors. |
207
+ | `BASE-AGENT-005` | An agent acts as a person in a role, never more | target | missing | | Not yet judged through this seed's own doors. |
208
+ | `BASE-AGENT-006` | Every action declares its risk class | target | missing | | Not yet judged through this seed's own doors. |
209
+ | `BASE-AGENT-007` | The company's policy decides, at one chokepoint | target | missing | | Not yet judged through this seed's own doors. |
210
+ | `BASE-AGENT-008` | Truthful attribution | target | missing | | Not yet judged through this seed's own doors. |
211
+ | `BASE-AGENT-009` | Every agent action is audited with its class and decision | target | missing | | Not yet judged through this seed's own doors. |
212
+ | `BASE-AGENT-010` | Agents can follow changes | target | missing | | Not yet judged through this seed's own doors. |
213
+ | `BASE-AGENT-011` | Limits are policy, and Pause stops everything | target | missing | | Not yet judged through this seed's own doors. |
214
+ | `BASE-AGENT-012` | Writes are idempotent and conflict-safe | target | missing | | Not yet judged through this seed's own doors. |
215
+ | `BASE-AGENT-013` | Manifest, docs and the conformance journey | target | missing | | Not yet judged through this seed's own doors. |
@@ -0,0 +1,66 @@
1
+ import { isDeepStrictEqual } from 'node:util';
2
+ import { classIds } from './protocol.mjs';
3
+ import { AGENT_CLASSES } from './surface.mjs';
4
+ import { targetIdentity } from './target.mjs';
5
+
6
+ export async function auditRows(c) {
7
+ const rows = []; let cursor = null, differs = 0;
8
+ for (let page = 0; page < 100; page++) {
9
+ const result = await c.personJson(`/agents/api/audit?agent=${encodeURIComponent(c.agentId)}${cursor ? `&after=${encodeURIComponent(cursor)}` : ''}`);
10
+ if (!Array.isArray(result.rows) || !Number.isInteger(result.differs_from_policy)) throw new Error('Audit API must return rows and differs_from_policy');
11
+ rows.push(...result.rows); differs += result.differs_from_policy;
12
+ if (result.cursor == null || result.cursor === cursor) return { rows, differs };
13
+ cursor = result.cursor;
14
+ }
15
+ throw new Error('Audit pagination exceeded 100 pages');
16
+ }
17
+ export async function auditPhase(c) {
18
+ const { rows, differs } = await auditRows(c), expected = [...c.calls];
19
+ c.add('BASE-AGENT-009.1.count', rows.length === expected.length, `Expected exactly ${expected.length} audit rows for tool calls, resource reads and approval executions, found ${rows.length}.`);
20
+ c.add('BASE-AGENT-009.1.unique', new Set(rows.map(row => row.id)).size === rows.length, 'Every tool call, resource read and approval execution must have its own audit ID.');
21
+ for (const [index, call] of expected.entries()) {
22
+ const row = rows[index], decision = call.decision;
23
+ c.add(`BASE-AGENT-009.1.call.${index}`, Boolean(row) && row.tool === call.name && row.consent === c.consent && row.agent?.id === c.agentId && row.agent?.specialist === c.surface.specialist && row.sponsor?.id === c.sponsor.id && typeof row.label === 'string' && row.label.includes(' for ') && Number.isFinite(Date.parse(row.at)) && row.door === (call.kind === 'embedded' ? 'embedded' : 'mcp'), `${call.name} lacks its complete ordered audit row.`);
24
+ if (!row) continue;
25
+ if (call.code === 'native_proof_required') c.add(`BASE-AGENT-004.native-proof.audit.${index}`, row.outcome === 'refused' && row.code === call.code, `${call.name} native proof challenge must retain its refused audit outcome.`);
26
+ c.add(`BASE-AGENT-009.1.resource.${index}`, call.kind === 'resources/read' ? row.resource === call.args.uri : row.resource === null || targetIdentity(row.resource), `${call.name} audit resource must identify the requested URI or the seed-resolved native kind and id.`);
27
+ c.add(`BASE-AGENT-009.2.link.${index}`, call.kind === 'approval/execute' ? row.id !== decision?.id && row.decision_id === decision?.id : row.decision_id === null, `${call.name} must ${call.kind === 'approval/execute' ? 'link its own execution row to the pending decision' : 'have its own call row without an approval execution link'}.`);
28
+ const validClasses = Array.isArray(row.classes) && new Set(classIds(row.classes)).size === row.classes.length && row.classes.every(item => AGENT_CLASSES.includes(item.class) && item.facts && typeof item.facts === 'object');
29
+ c.add(`BASE-AGENT-006.6.audit.${index}`, validClasses && (decision ? isDeepStrictEqual(classIds(row.classes), classIds(decision.classes)) && decision.classes.every(item => row.classes.some(actual => actual.class === item.class && isDeepStrictEqual(actual.facts, item.facts))) : call.kind === 'resources/read' || row.classes.length === 0), `${call.name} audit classes/facts differ from its computed decision.`);
30
+ if (decision) c.add(`BASE-AGENT-009.2.decision.${index}`, (call.kind === 'approval/execute' || row.id === decision.id) && row.decision === decision.disposition && row.revision === decision.revision && isDeepStrictEqual(row.rules, decision.classes.map(({ class: cls, rule, do: disposition }) => ({ class: cls, rule, do: disposition }))), `${call.name} audit decision or revision differs from the response.`);
31
+ else if (call.kind === 'resources/read') c.add(`BASE-AGENT-009.2.resource-rules.${index}`, Array.isArray(row.rules) && isDeepStrictEqual(classIds(row.rules), classIds(row.classes)) && row.rules.every(rule => typeof rule.rule === 'string' && ['autonomous', 'review', 'approval', 'blocked', 'unset'].includes(rule.do)), 'Resource audit classes must each carry the applied policy rule and disposition.');
32
+ if (decision?.disposition === 'review') c.add(`BASE-AGENT-009.4.review.${index}`, Boolean(row.review?.id), `${call.name} was decided review without a review row.`);
33
+ if (call.pending) c.add(`BASE-AGENT-009.2.pending.${index}`, row.outcome === 'pending' && Boolean(call.approval?.id) && row.approval?.id === call.approval.id, `${call.name} must retain its original pending audit outcome and approval handle after the approval executes.`);
34
+ if (call.kind === 'approval/execute') c.add(`BASE-AGENT-008.5.execution.${index}`, row.approval?.id === call.approvalId && row.approval.by?.includes(c.sponsor.id) && row.outcome === 'done', `${call.name} approved execution lacks its completed row and named sponsor approval.`);
35
+ if (call.result?._meta?.['com.runeditrun/receipt']) c.add(`BASE-AGENT-008.5.audit.${index}`, Boolean(row.approval?.id) && row.approval.by?.includes(row.sponsor.id), `${call.name} approval receipt lacks the signed-in sponsor as approver.`);
36
+ }
37
+ c.add('BASE-AGENT-007.7.differs-from-policy', differs === 0, `Audit evidence has ${differs} decisions that differ from the policy in force.`);
38
+ // Audit is read before the events tool: its own call is audited as well, but
39
+ // cannot occur in a snapshot taken before it was made.
40
+ const events = []; let after;
41
+ for (let page = 0; page < 100; page++) {
42
+ const result = await c.tool(`${c.surface.seed}.events.list`, { ...(after ? { after } : {}), limit: 200 });
43
+ const content = result.result?.structuredContent;
44
+ if (!Array.isArray(content?.events)) throw new Error('events.list did not return {events,cursor}');
45
+ events.push(...content.events);
46
+ if (content.events.length < 200 || content.cursor === after) break;
47
+ after = content.cursor;
48
+ }
49
+ c.add('BASE-AGENT-010.2.events', events.length > 0 && new Set(events.map(event => event.id)).size === events.length && events.every(event => typeof event.id === 'string' && typeof event.type === 'string' && typeof event.uri === 'string' && event.actor && Number.isFinite(Date.parse(event.at))), 'Events must have stable unique ids, type, URI, actor and time.');
50
+ for (const type of ['policy.adopted', 'approval.pending', 'approval.decided']) {
51
+ const applicable = type === 'policy.adopted' || rows.some(row => row.approval);
52
+ if (applicable) c.add(`BASE-AGENT-010.6.${type}`, events.some(event => event.type === type), `Missing ${type} event.`);
53
+ }
54
+ const writeTools = new Set(rows.filter(row => row.tool !== 'resources/read' && ['done', 'replayed'].includes(row.outcome) && c.surface.tools.find(tool => tool.name === row.tool)?.readOnly === false).map(row => row.tool));
55
+ c.add('BASE-AGENT-010.1.effects', !writeTools.size || [...events, ...c.effectEvents ?? []].some(event => event.actor?.kind === 'agent' && !['policy.decision', 'approval.pending', 'approval.decided'].includes(event.type)), 'Completed writes must produce record-change events attributed to the agent while their native resources are readable.');
56
+ if (events.length > 1) {
57
+ const cursor = events[0].id;
58
+ const replay1 = await c.tool(`${c.surface.seed}.events.list`, { after: cursor, limit: 200 });
59
+ const replay2 = await c.tool(`${c.surface.seed}.events.list`, { after: cursor, limit: 200 });
60
+ const ids = result => result.result?.structuredContent?.events?.map(event => event.id) ?? [];
61
+ const first = ids(replay1), second = ids(replay2);
62
+ c.add('BASE-AGENT-010.3.cursor', first.length > 0 && isDeepStrictEqual(first, second.slice(0, first.length)) && first[0] === events[1].id, 'Replaying one cursor must return the same retained event ids in order.');
63
+ }
64
+ const final = await auditRows(c);
65
+ c.add('BASE-AGENT-009.1.events-audited', final.rows.length === c.calls.length && final.differs === 0, `events.list audit calls mismatch: ${final.rows.length} audit rows for ${c.calls.length} calls.`);
66
+ }
@@ -0,0 +1,2 @@
1
+ export function recordOnlySchema(schema: unknown, depth?: number): boolean
2
+ export function recordOnlyAuthority(tool: unknown): boolean
@@ -0,0 +1,17 @@
1
+ // A no-subject security tool may change a record, but its declared input must
2
+ // have no place to carry an authority subject, role or grant. Fail closed on
3
+ // open objects, opaque schemas, references and unbounded schema composition.
4
+ const subject = /(?:^|_)(?:person|people|user|member|owner|sponsor|agent|role|scope|grant|credential|permission|authorit(?:y|ies)|principal|privilege|entitlement|capabilit(?:y|ies)|authorization|identity|consent|token)(?:s|id|ids)?(?:_|$)/;
5
+ const field = name => name.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase().replace(/[^a-z0-9]+/g, '_');
6
+ export function recordOnlySchema(schema, depth = 0) {
7
+ if (!schema || typeof schema !== 'object' || Array.isArray(schema) || depth > 32
8
+ || Object.keys(schema).some(key => ['$ref', '$dynamicRef', 'allOf', 'anyOf', 'oneOf', 'not', 'if', 'then', 'else', 'patternProperties', 'dependentSchemas', 'unevaluatedProperties'].includes(key))) return false;
9
+ if (schema.type === 'object') return schema.additionalProperties === false && schema.properties !== null && typeof schema.properties === 'object' && !Array.isArray(schema.properties)
10
+ && Object.entries(schema.properties).every(([name, value]) => !subject.test(field(name)) && recordOnlySchema(value, depth + 1));
11
+ if (schema.type === 'array') return recordOnlySchema(schema.items, depth + 1);
12
+ return ['string', 'boolean', 'number', 'integer', 'null'].includes(schema.type);
13
+ }
14
+ export const recordOnlyAuthority = tool => tool?.authority === 'none' && tool.readOnly === false
15
+ && Array.isArray(tool.classes) && tool.classes.includes('security') && !tool.classes.includes('access')
16
+ && tool.effect?.kind === 'record' && typeof tool.effect.justification === 'string' && tool.effect.justification.trim().length > 0
17
+ && recordOnlySchema(tool.inputSchema);
@@ -0,0 +1,36 @@
1
+ import { createHash, randomUUID, webcrypto } from 'node:crypto';
2
+
3
+ export const CATALOGUE = 'rer-agent-classes/1';
4
+ export function canonical(value) {
5
+ if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
6
+ if (value && typeof value === 'object') return `{${Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => `${JSON.stringify(key)}:${canonical(item)}`).join(',')}}`;
7
+ return JSON.stringify(value);
8
+ }
9
+ export async function signJws(privateKey, kid, typ, payload) {
10
+ const input = [Buffer.from(JSON.stringify({ alg: 'ES256', typ, kid })).toString('base64url'), Buffer.from(JSON.stringify(payload)).toString('base64url')].join('.');
11
+ const signature = await webcrypto.subtle.sign({ name: 'ECDSA', hash: 'SHA-256' }, privateKey, new TextEncoder().encode(input));
12
+ return `${input}.${Buffer.from(signature).toString('base64url')}`;
13
+ }
14
+ export function seconds(now) {
15
+ const value = typeof now === 'function' ? now() : now ?? Date.now();
16
+ return Math.floor((value instanceof Date ? value.getTime() : typeof value === 'string' ? Date.parse(value) : value) / 1000);
17
+ }
18
+ export async function accessToken(context, overrides = {}) {
19
+ const iat = seconds(context.now);
20
+ return signJws(context.signer.privateKey, context.signer.kid, 'at+jwt', {
21
+ iss: context.signer.issuer, aud: `${context.origin}/mcp`, sub: context.person.sub, email: context.person.email.toLowerCase(),
22
+ act: { sub: context.agentId, name: 'Agent door conformance', specialist: context.surface.specialist }, client_id: 'rer-agent-conformance',
23
+ scope: [...new Set([...context.surface.tools.map(tool => tool.scope), ...(context.resourceScopes ?? []), 'events:read'])].join(' '), business: context.business,
24
+ consent: context.consent, jti: randomUUID(), iat, exp: iat + 300, ...overrides,
25
+ });
26
+ }
27
+ export const autonomousPolicy = () => ({ schema: 'rer-agent-policy/1', catalogue: CATALOGUE, rules: [{ id: 'all', class: '*', do: 'autonomous' }], spend: { none: true } });
28
+ export const heldPolicy = () => ({ schema: 'rer-agent-policy/1', catalogue: CATALOGUE, rules: [{ id: 'all', class: '*', do: 'approval', approver: ['sponsor'], wait: 'PT1H' }, { id: 'standard', class: 'standard', do: 'review' }], reviewers: ['sponsor'], spend: { none: true } });
29
+ export async function policyEnvelope(context, document, { paused = false, revoked, revision = context.revision + 1, seq = context.seq + 1, ...overrides } = {}) {
30
+ const iat = seconds(context.now);
31
+ const revision_signature = document === null ? null : await signJws(context.signer.privateKey, context.signer.kid, 'rer-agent-policy-revision+jwt', {
32
+ business: context.business, revision, document_sha256: createHash('sha256').update(canonical(document)).digest('hex'),
33
+ });
34
+ const payload = { v: 1, iss: context.signer.issuer, aud: context.origin, sub: context.signer.installationId, business: context.business, seq, revision, paused, catalogue: CATALOGUE, document, revision_signature, iat, exp: iat + 300, ...(revoked === undefined ? {} : { revoked }), ...overrides };
35
+ return { payload, policy: await signJws(context.signer.privateKey, context.signer.kid, 'rer-agent-policy+jwt', payload) };
36
+ }