diff --git a/tests/restart-chaos/README.md b/tests/restart-chaos/README.md index a40d71aa69c..20fe2ccdd08 100644 --- a/tests/restart-chaos/README.md +++ b/tests/restart-chaos/README.md @@ -641,6 +641,112 @@ every grade, every failed run with its error code, message and last error events probes, and the duplicates: two runs of one task executing at once, two Runner processes for one run, repeated identical agent comments and repeated subtask titles. The wave fails unless every task passed. +## Hosted mode (`--hosted-base-url`, `--hosted-allow`) + +```sh +set -a; source ~/.secrets; set +a +H=.staging.paperclip.app +# Read-only: watch one release of the instance (GET /api/health every 2 s) and report its shape. No writes. +node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/hosted.ts --hosted-base-url https://$H --hosted-allow $H --hosted-observe-only +# Smoke: 2 tasks, no release wait, 1-minute settle, then cleanup. +node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/hosted.ts --hosted-base-url https://$H --hosted-allow $H \ + --hosted-releases 0 --hosted-tasks 2 --hosted-turn-minutes 3 --hosted-label rc-hosted-smoke1 +# A run across 3 real releases at 5 concurrent (default), then the same at 15. +node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/hosted.ts --hosted-base-url https://$H --hosted-allow $H --hosted-releases 3 --hosted-label rc-hosted-r3c5 +node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/hosted.ts --hosted-base-url https://$H --hosted-allow $H --hosted-releases 3 --hosted-concurrency 15 --hosted-label rc-hosted-r3c15 +# Remove everything one run created (also run automatically at the end of every run unless --hosted-keep). +node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/hosted.ts --hosted-base-url https://$H --hosted-allow $H --hosted-cleanup-only --hosted-label rc-hosted-r3c5 +``` + +Hosted mode runs the release-swap proof against a real hosted instance that takes automatic releases, instead of +servers the harness starts. It starts no server and injects no fault: each release the instance's own continuous +deploy rolls out is a swap. + +**Target guard** (`hosted-guard.ts`). The harness refuses to start unless `--hosted-base-url` is a bare `https://` +origin and `--hosted-allow` names the same host. The host must be one stack under `.staging.paperclip.app` or +`.test.paperclip.app`. `paperclip.staging.paperclip.app`, production hosts, the fleet admin and Cloud hosts are +refused even when allowed explicitly. Every request is checked against that one origin before it is sent. + +**Sign-in.** The harness uses a board token for the host: `PAPERCLIP_HOSTED_TOKEN`, or +`credentials["https://"].token` in `~/.paperclip/auth.json` (the CLI's store). It never prints the token. +Hosted stacks sit behind the Cloud tenant gateway, which answers every request without a session, including +`/api/health` and the CLI's `POST /api/cli-auth/challenges`, with `401 tenant_session_required`. So +`paperclipai auth login --api-base https://` cannot start there. A person who can sign in to the instance must +create the challenge from a signed-in browser tab, approve it, and store the token. Without a token, hosted mode +stops before any request. + +**Setup** (`hosted-setup.ts`). Company creation is managed by Cloud, so the run works inside the signed-in user's +company (`--hosted-company ` when there are several). Everything it creates carries the run label +(`--hosted-label`, default `rc-hosted-`): one project `Restart chaos