Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Align trial-start proofs with retry burst
rcourtmand38dcb00da13
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.mdindex 344fecce88..2a6534c669 100644--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md@@ -579,6 +579,17 @@ actual remaining backoff through `Retry-After` and`details.retry_after_seconds` rather than a coarse full-window guess. Sharedtrial-start presentation must treat that backoff as canonical and surface itconsistently instead of flattening every `429` into generic copy.+That proof must stay aligned in browser and shell coverage too:+`tests/integration/tests/07-trial-signup-return.spec.ts` and+`tests/integration/scripts/trial-signup-contract.sh` must treat duplicate+starts inside the allowed burst as the same hosted-signup redirect contract and+only require `trial_rate_limited` plus backoff metadata once the limiter+actually engages, rather than assuming the second attempt is already denied.+That proof split is also intentional: the browser spec may attach to a reused+local instance whose retry bucket is already exhausted and therefore must+accept an immediate canonical `429` backoff response, while the snapshot-clean+shell probe remains the fresh-state contract that proves an initial hosted+redirect and the later transition into `trial_rate_limited`.Hosted tenant organization seeding and hosted handoff role mapping now belongto the same cloud-paid truth too. `internal/cloudcp/stripe/provisioner.go`must seed tenant org members from the shared account-role-to-organization-rolediff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex a606cd7856..480a7ad3c8 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -451,6 +451,14 @@ browser helper must treat `PLAYWRIGHT_BASE_URL` as the browser truth and leave`PULSE_BASE_URL` available for backend-oriented health checks and setuptraffic, so split browser/backend proof can target fresh frontend code withoutrewiring the API-side contract.+That same integration-README ownership includes the local commercial trial+probe guidance. The snapshot-clean trial instructions for+`tests/integration/scripts/trial-signup-contract.sh` must describe duplicate+local `/api/license/trial/start` requests as staying on the hosted-signup+redirect contract until the configured retry burst is exhausted; they may only+teach `429 trial_rate_limited` plus `Retry-After` backoff once the limiter+actually engages, rather than claiming the second duplicate attempt is always+rate limited.Playwright-driven public/commercial specs that support scenario-specificendpoint overrides such as `PULSE_CLOUD_BASE_URL` or`PULSE_COMMERCIAL_BASE_URL` must layer those values through that same shareddiff --git a/scripts/tests/test-hot-dev-bg.sh b/scripts/tests/test-hot-dev-bg.shindex fb3c564f50..6e303abaf3 100755--- a/scripts/tests/test-hot-dev-bg.sh+++ b/scripts/tests/test-hot-dev-bg.sh@@ -706,6 +706,26 @@ test_integration_readme_uses_managed_backend_restart_wrapper() {assert_not_contains "integration readme no longer documents raw backend restart script" "${output}" "./scripts/hot-dev-bg.sh backend-restart"}+test_integration_readme_documents_trial_retry_burst_contract() {+ local output+ output="$(+ awk '+ /^### Snapshot-Clean Proxmox LXC Trial SAT$/ { capture=1 }+ capture { print }+ /^### Run Theme Visual Regression Suite$/ {+ exit+ }+ ' "${INTEGRATION_README}"+ )"++ assert_contains "integration readme documents hosted-signup retry burst" "${output}" "retry-burst"+ assert_contains "integration readme documents retry contract wording" "${output}" "contract:"+ assert_contains "integration readme keeps hosted-signup wording" "${output}" "hosted-signup"+ assert_contains "integration readme documents retry burst exhaustion" "${output}" "retry burst is exhausted"+ assert_contains "integration readme documents retry-after backoff" "${output}" "Retry-After"+ assert_contains "integration readme references hosted trial probe script" "${output}" "tests/integration/scripts/trial-signup-contract.sh"+}+test_integration_quick_start_distinguishes_embedded_frontend_from_hot_dev() {local outputoutput="$(sed -n '82,102p' "${ROOT_DIR}/tests/integration/QUICK_START.md")"@@ -1099,6 +1119,7 @@ main() {test_hot_dev_bg_script_advertises_managed_entrypointtest_hot_dev_bg_usage_prefers_managed_wrapperstest_integration_readme_uses_managed_backend_restart_wrapper+ test_integration_readme_documents_trial_retry_burst_contracttest_integration_quick_start_distinguishes_embedded_frontend_from_hot_devtest_acceptance_doc_distinguishes_embedded_frontend_from_hot_devtest_playwright_defaults_prefer_managed_hot_dev_runtimediff --git a/tests/integration/README.md b/tests/integration/README.mdindex 683513d8d4..16a9422dcd 100644--- a/tests/integration/README.md+++ b/tests/integration/README.md@@ -28,10 +28,10 @@ End-to-end Playwright tests that validate critical user flows against a running- Logged-out login page (full page + form card)- Authenticated Settings → Authentication page- `tests/07-trial-signup-return.spec.ts` — trial workflow contract:- - Start hosted Pro trial initiation via API- - Verify response points to hosted `/start-pro-trial`+ - Start hosted Pro trial initiation via API and verify the reused-instance contract+ - Verify the response either points to hosted `/start-pro-trial` or returns canonical `Retry-After` backoff when the local retry bucket is already exhausted- Verify local entitlements remain unchanged until activation- - Verify duplicate initiation is rate limited+ - Verify duplicate initiation stays on the hosted-signup retry-burst contract- `tests/08-cloud-hosting.spec.ts` — hosted cloud signup contract:- Public `/cloud/signup` form creates a real Stripe sandbox checkout session- Checkout completes and returns to hosted signup completion page@@ -181,6 +181,9 @@ For hosted trial initiation validation against a fresh LXC each run:- Runbook: `docs/operations/TRIAL_E2E_LXC_SNAPSHOT_RUNBOOK.md`- Probe script: `tests/integration/scripts/trial-signup-contract.sh`+ - Confirms repeated local trial starts stay on the hosted-signup retry-burst+ contract: duplicate attempts keep returning hosted-signup redirects until+ the retry burst is exhausted, then return `Retry-After` backoff metadata- Full sandbox orchestration (multi-tenant + trial + cloud, with per-scenario snapshot reset):- `tests/integration/scripts/run-lxc-sandbox-evals.sh`- Includes hosted trial initiation validation and cloud subscription cancellation lifecycle verificationdiff --git a/tests/integration/evals/scenarios.json b/tests/integration/evals/scenarios.jsonindex 9dd5b2c775..66cbfe163b 100644--- a/tests/integration/evals/scenarios.json+++ b/tests/integration/evals/scenarios.json@@ -26,7 +26,7 @@{"id": "trial-signup","name": "Pro Trial Signup Return",- "description": "Ensures self-hosted Pulse initiates hosted trial signup, preserves local entitlements until activation, and rate-limits duplicate initiation attempts.",+ "description": "Ensures self-hosted Pulse initiates hosted trial signup, preserves local entitlements until activation, and enforces the hosted-signup retry-burst contract for duplicate initiation attempts.","deterministic": {"command": ["npx",diff --git a/tests/integration/evals/tasks/trial-signup.md b/tests/integration/evals/tasks/trial-signup.mdindex 860cecef0f..65351b9afb 100644--- a/tests/integration/evals/tasks/trial-signup.md+++ b/tests/integration/evals/tasks/trial-signup.md@@ -1,7 +1,7 @@# Scenario: Pro Trial Signup## Goal-Prove the self-hosted Pulse instance initiates the hosted trial flow correctly, does not mint local entitlement before activation, and rate-limits duplicate initiation attempts.+Prove the self-hosted Pulse instance initiates the hosted trial flow correctly, does not mint local entitlement before activation, and enforces the hosted-signup retry-burst contract for duplicate initiation attempts.## Environment- Base URL: `{{base_url}}`@@ -10,10 +10,13 @@ Prove the self-hosted Pulse instance initiates the hosted trial flow correctly,## Required checks1. Verify pre-trial entitlements show `trial_eligible=true`.-2. Start trial via `POST /api/license/trial/start` and confirm HTTP `409` with code `trial_signup_required`.-3. Verify the response includes a hosted `action_url` that targets `/start-pro-trial`.-4. Verify post-initiation entitlements remain unactivated locally (`trial_eligible=true`, `subscription_state=expired`).-5. Verify a second immediate trial start attempt is rate limited with HTTP `429`.+2. Start trial via `POST /api/license/trial/start`.+3. If the first response is HTTP `409`, confirm code `trial_signup_required` and a hosted `action_url` that targets `/start-pro-trial`.+4. If the first response is HTTP `429`, confirm code `trial_rate_limited` and that `Retry-After` matches `details.retry_after_seconds`.+5. Verify post-initiation entitlements remain unactivated locally (`trial_eligible=true`, `subscription_state=expired`).+6. Retry `POST /api/license/trial/start` immediately:+ - If the first response was `409`, accept either another `409 trial_signup_required` while the retry burst is still open or `429 trial_rate_limited` once the limiter engages.+ - If the first response was already `429`, confirm the retry remains `429 trial_rate_limited` with matching backoff metadata.## Output contractWrite JSON to `{{result_json}}` with this shape:diff --git a/tests/integration/scripts/trial-signup-contract.sh b/tests/integration/scripts/trial-signup-contract.shindex c426c71867..6df22d1271 100755--- a/tests/integration/scripts/trial-signup-contract.sh+++ b/tests/integration/scripts/trial-signup-contract.sh@@ -8,6 +8,7 @@ PULSE_BASE_URL="${PULSE_BASE_URL:-http://127.0.0.1:7655}"PULSE_E2E_USERNAME="${PULSE_E2E_USERNAME:-admin}"PULSE_E2E_PASSWORD="${PULSE_E2E_PASSWORD:-admin}"WAIT_TIMEOUT_SECONDS="${WAIT_TIMEOUT_SECONDS:-60}"+MAX_DUPLICATE_TRIAL_ATTEMPTS="${MAX_DUPLICATE_TRIAL_ATTEMPTS:-10}"if ! command -v curl >/dev/null 2>&1; thenecho "ERROR: curl is required"@@ -26,6 +27,7 @@ login_body="${tmp_dir}/login.json"entitlements_body="${tmp_dir}/entitlements.json"start_body="${tmp_dir}/trial_start.json"second_start_body="${tmp_dir}/trial_start_second.json"+second_start_headers="${tmp_dir}/trial_start_second.headers"wait_for_http() {local url="$1"@@ -127,18 +129,63 @@ if [ "${post_sub_state}" != "expired" ]; thenexit 1fi-echo "[6/6] Verify duplicate initiation is rate limited"-second_start_code="$(- curl -sS -o "${second_start_body}" -w '%{http_code}' \- -X POST \- -b "${cookies_file}" \- -H "X-CSRF-Token: ${csrf_token}" \- "${PULSE_BASE_URL}/api/license/trial/start"-)"-assert_code "429" "${second_start_code}" "POST /api/license/trial/start (second attempt)"-second_code_name="$(jq -r '.code // empty' "${second_start_body}")"-if [ "${second_code_name}" != "trial_rate_limited" ]; then- echo "ERROR: expected code=trial_rate_limited on second attempt, got ${second_code_name:-<empty>}"+echo "[6/6] Verify duplicate initiation stays on the retry-burst contract until the limiter engages"+rate_limited_attempt=""+second_start_code=""+second_code_name=""+retry_after_header=""+retry_after_seconds=""++for attempt in $(seq 2 "${MAX_DUPLICATE_TRIAL_ATTEMPTS}"); do+ second_start_code="$(+ curl -sS -D "${second_start_headers}" -o "${second_start_body}" -w '%{http_code}' \+ -X POST \+ -b "${cookies_file}" \+ -H "X-CSRF-Token: ${csrf_token}" \+ "${PULSE_BASE_URL}/api/license/trial/start"+ )"+ second_code_name="$(jq -r '.code // empty' "${second_start_body}")"++ if [ "${second_start_code}" = "409" ]; then+ if [ "${second_code_name}" != "trial_signup_required" ]; then+ echo "ERROR: expected code=trial_signup_required within retry burst, got ${second_code_name:-<empty>}"+ exit 1+ fi+ action_url="$(jq -r '.details.action_url // empty' "${second_start_body}")"+ if [ -z "${action_url}" ]; then+ echo "ERROR: expected action_url while retry burst still allows hosted signup"+ exit 1+ fi+ continue+ fi++ if [ "${second_start_code}" = "429" ]; then+ if [ "${second_code_name}" != "trial_rate_limited" ]; then+ echo "ERROR: expected code=trial_rate_limited once retry burst is exceeded, got ${second_code_name:-<empty>}"+ exit 1+ fi+ retry_after_header="$(+ awk 'tolower($1)=="retry-after:" {print $2}' "${second_start_headers}" | tr -d '\r' | tail -n1+ )"+ retry_after_seconds="$(jq -r '.details.retry_after_seconds // empty' "${second_start_body}")"+ if [ -z "${retry_after_header}" ]; then+ echo "ERROR: expected Retry-After header once retry burst is exceeded"+ exit 1+ fi+ if [ "${retry_after_seconds}" != "${retry_after_header}" ]; then+ echo "ERROR: expected details.retry_after_seconds=${retry_after_header}, got ${retry_after_seconds:-<empty>}"+ exit 1+ fi+ rate_limited_attempt="${attempt}"+ break+ fi++ echo "ERROR: expected HTTP 409 within retry burst or HTTP 429 once the limiter engages, got ${second_start_code}"+ exit 1+done++if [ -z "${rate_limited_attempt}" ]; then+ echo "ERROR: duplicate trial initiation never hit the retry limiter within ${MAX_DUPLICATE_TRIAL_ATTEMPTS} attempts"exit 1fi@@ -147,4 +194,5 @@ echo " login_code=${login_code}"echo " entitlements_before_code=${entitlements_code}"echo " trial_start_code=${start_code} (code=${start_code_name})"echo " post_trial_entitlements_code=${post_entitlements_code}"-echo " second_trial_start_code=${second_start_code} (code=${second_code_name})"+echo " retry_limiter_attempt=${rate_limited_attempt}"+echo " final_trial_start_code=${second_start_code} (code=${second_code_name}, retry_after=${retry_after_header})"diff --git a/tests/integration/tests/07-trial-signup-return.spec.ts b/tests/integration/tests/07-trial-signup-return.spec.tsindex c11f5e7a6b..cae8f7350c 100644--- a/tests/integration/tests/07-trial-signup-return.spec.ts+++ b/tests/integration/tests/07-trial-signup-return.spec.ts@@ -15,6 +15,25 @@ type TrialStartPayload = {details?: Record<string, string>;};+function expectTrialRateLimited(payload: TrialStartPayload, retryAfterHeader?: string | null) {+ expect(payload.code).toBe('trial_rate_limited');+ const retryAfterSeconds = Number.parseInt(payload.details?.retry_after_seconds || '', 10);+ expect(retryAfterSeconds).toBeGreaterThan(0);+ if (retryAfterHeader) {+ expect(String(retryAfterSeconds)).toBe(retryAfterHeader);+ }+}++function expectHostedTrialRedirect(payload: TrialStartPayload) {+ expect(payload.code).toBe('trial_signup_required');++ const actionUrl = payload.details?.action_url ?? '';+ expect(actionUrl).toContain('/start-pro-trial');+ const parsedActionUrl = new URL(actionUrl);+ expect(parsedActionUrl.searchParams.get('org_id')).toBe('default');+ expect(parsedActionUrl.searchParams.get('return_url')).toContain('/auth/trial-activate');+}+test.describe.serial('Trial signup return flow', () => {test('initiates hosted trial signup and preserves local entitlements until activation', async ({ page }, testInfo) => {test.skip(testInfo.project.name.startsWith('mobile-'), 'Desktop-only trial workflow coverage');@@ -38,16 +57,17 @@ test.describe.serial('Trial signup return flow', () => {const startRes = await apiRequest(page, '/api/license/trial/start', {method: 'POST',});- expect(startRes.status(), `trial start failed: HTTP ${startRes.status()}`).toBe(409);+ expect(+ [409, 429],+ `trial start failed: expected 409 or 429, got HTTP ${startRes.status()}`,+ ).toContain(startRes.status());const startPayload = (await startRes.json()) as TrialStartPayload;- expect(startPayload.code).toBe('trial_signup_required');-- const actionUrl = startPayload.details?.action_url ?? '';- expect(actionUrl).toContain('/start-pro-trial');- const parsedActionUrl = new URL(actionUrl);- expect(parsedActionUrl.searchParams.get('org_id')).toBe('default');- expect(parsedActionUrl.searchParams.get('return_url')).toContain('/auth/trial-activate');+ if (startRes.status() === 409) {+ expectHostedTrialRedirect(startPayload);+ } else {+ expectTrialRateLimited(startPayload, startRes.headers()['retry-after'] ?? null);+ }// Verify entitlements remain unchanged until the hosted flow returns.const postRes = await apiRequest(page, '/api/license/entitlements');@@ -62,15 +82,22 @@ test.describe.serial('Trial signup return flow', () => {// Verify UI still reflects the unactivated local state.await page.goto('/settings');await page.getByRole('button', { name: /pulse pro/i }).first().click();- await expect(page.getByRole('heading', { name: 'Current License' })).toBeVisible();+ await expect(page.getByRole('heading', { name: 'Pulse Pro' }).first()).toBeVisible();await expect(page.getByText(/No Pro license is active/i)).toBeVisible();- // Verify duplicate initiation is rate limited.+ // Verify duplicate initiation stays on the owned retry-burst contract.const secondRes = await apiRequest(page, '/api/license/trial/start', {method: 'POST',});- expect(secondRes.status()).toBe(429);const secondPayload = (await secondRes.json()) as TrialStartPayload;- expect(secondPayload.code).toBe('trial_rate_limited');+ if (startRes.status() === 429) {+ expect(secondRes.status()).toBe(429);+ expectTrialRateLimited(secondPayload, secondRes.headers()['retry-after'] ?? null);+ } else if (secondRes.status() === 409) {+ expectHostedTrialRedirect(secondPayload);+ } else {+ expect(secondRes.status()).toBe(429);+ expectTrialRateLimited(secondPayload, secondRes.headers()['retry-after'] ?? null);+ }});});