Skip to content

ci(cloud-brain): deploy the shared brain with the site, and test it in CI (CB5) - #55

Merged
shaal merged 6 commits into
mainfrom
ship/cb5-deploy
Oct 1, 2026
Merged

shaal merged 6 commits into
mainfrom
ship/cb5-deploy

Conversation

@shaal

@shaal shaal commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

deploy.yml builds the Rust Worker with its pinned toolchain (a composite
action: the Rust beta, worker-build 0.8.7 and its Emscripten, cached) and
deploys it as vectorvroom-brain (vectorvroom-brain-pr- for a PR). The
page gets the Worker's origin in cloud/config.json only when /health says
ok, brain on, limits bound and the page's protocol, and /v1/stats answers
the site with CORS; otherwise Shared stays hidden and the run fails after
Pages is published.

wrangler.jsonc sets limits.cpu_ms (30 s) for the Workers Paid plan (D2):
a cold start rebuilds the index in about a second. cloud-brain.yml runs the
native tests, the Emscripten build, the Worker under wrangler dev and the
page against it. The runbook covers the breaker, limits, rollback, the
CF-Connecting-IP check, training, forget, fuzzing and preview cleanup.

Summary by CodeRabbit

  • New Features
    • Added an experimental shared cloud brain service, with production and pull-request preview deployments.
    • The site can connect to the brain when deployment succeeds; otherwise, it continues without a configured brain endpoint.
  • Documentation
    • Added an operations guide covering service availability, verification, rollback, limits, and troubleshooting.
  • Reliability
    • Added automated checks for the brain service and its compatibility with the site.

Confidence

Verbatim from /ship's Phase 2 confidence gate — per-axis score (0–25), the
evidence used, and the self-critique. Treat anything below 20 as a known soft
spot to verify before relying on it.

Requirements Fit: 24/25

  • Evidence:
    • deploy.yml deploys vectorvroom-brain (from main) and vectorvroom-brain-pr-<n> with a cached toolchain, and writes the endpoint into cloud/config.json; cloud-brain.yml CI; the runbook; D2 Paid through limits.cpu_ms (the account accepted it).
    • CB4's notes: CF-Connecting-IP refused at the edge (403), /health limits:true, fuzzing in the runbook.
  • To honestly score 25 I would need to: complete the first production health check (runs at merge).
  • Self-critique: the main-only steps run for the first time on the merge push.

Functional Robustness: 23/25

  • Evidence:
    • Two review rounds: production only from main and after its tests; the build never sees the credentials; the health check is tied to the commit built; the fallback keeps the running brain only when the page's cloud code is unchanged since its commit, else Shared is hidden; the breaker is a Worker secret.
  • To honestly score 25 I would need to: exact per-address limits (Cloudflare's binding is approximate by design).
  • Self-critique: previews are not deleted automatically; a re-run may not bring Shared back over immutable caching (documented).

Verification Evidence: 24/25

  • Evidence:
    • 5 preview deploys with health checks passing; a headless Chromium session on the deployed preview (consent, "Shared brain online", a crash map at 25 s, a brain at 35 s, the Worker's stats rose).
    • The breaker tried on the deployed Worker; a forged CF-Connecting-IP refused (403); a burst refused (429).
    • CI green on Ubuntu; locally the Worker suite 20/20 and the browser suite pass; the fallback's commit guard tried against the live preview.
  • To honestly score 25 I would need to: see the main run's test gate and the production health check pass.
  • Self-critique: three CI-only timing flakes were fixed in tests; others may exist.

System Safety & Integration: 24/25

  • Evidence:
    • Pages always publishes; Shared is hidden if no brain answers; the multiplayer steps are unchanged; no data can be touched from non-main runs; rollback and the breaker are documented.
  • To honestly score 25 I would need to: protect main with required checks (the owner's settings).
  • Self-critique: every site deploy now spends about 1 to 4.5 minutes on the brain build.

Total: 95/100. Gate (≥95 AND no axis <15): PASS

…n CI (CB5)

deploy.yml builds the Rust Worker with its pinned toolchain (a composite
action: the Rust beta, worker-build 0.8.7 and its Emscripten, cached) and
deploys it as vectorvroom-brain (vectorvroom-brain-pr-<n> for a PR). The
page gets the Worker's origin in cloud/config.json only when /health says
ok, brain on, limits bound and the page's protocol, and /v1/stats answers
the site with CORS; otherwise Shared stays hidden and the run fails after
Pages is published.

wrangler.jsonc sets limits.cpu_ms (30 s) for the Workers Paid plan (D2):
a cold start rebuilds the index in about a second. cloud-brain.yml runs the
native tests, the Emscripten build, the Worker under wrangler dev and the
page against it. The runbook covers the breaker, limits, rollback, the
CF-Connecting-IP check, training, forget, fuzzing and preview cleanup.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b78edae6-8b68-483f-b61c-c8265d49f16f

📥 Commits

Reviewing files that changed from the base of the PR and between d95c7ab and 678bc60.

📒 Files selected for processing (7)
  • .github/actions/cloud-brain-toolchain/action.yml
  • .github/workflows/cloud-brain.yml
  • .github/workflows/deploy.yml
  • cloud-brain/README.md
  • cloud-brain/wrangler.jsonc
  • docs/operations/cloud-brain-operations.md
  • scripts/cloud-brain-health.mjs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds cached Cloud Brain toolchain setup and CI, production and preview Worker deployment with health checks, endpoint configuration, and operational documentation.

Changes

Cloud Brain deployment

Layer / File(s) Summary
Toolchain and CI setup
.github/actions/cloud-brain-toolchain/action.yml, .github/workflows/cloud-brain.yml
Adds a composite action that caches build inputs and installs pinned Rust targets and worker-build. The CI workflow uses the action to build and test Cloud Brain and upload test results.
Worker deployment and endpoint checks
.github/workflows/deploy.yml, cloud-brain/wrangler.jsonc, scripts/cloud-brain-health.mjs, cloud-brain/README.md, docs/operations/cloud-brain-operations.md
Sets the Worker CPU limit and deploys production or PR-specific Workers. Health checks validate /health and /v1/stats; deployment writes the HTTPS endpoint to site configuration or writes a null endpoint. The workflow reports deployment status, and the README and runbook describe the deployment and operations.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DeployWorkflow
  participant CloudBrainWorker
  participant HealthCheck
  participant StaticSite
  DeployWorkflow->>CloudBrainWorker: Deploy named Worker and capture URL
  DeployWorkflow->>HealthCheck: Check the Worker URL
  HealthCheck->>CloudBrainWorker: Request /health and /v1/stats
  HealthCheck-->>DeployWorkflow: Return check result
  DeployWorkflow->>StaticSite: Write HTTPS brain URL or null endpoint
Loading

Merge Risk: ⚪ Minimal · up to 678bc

The shared Brain endpoint is published only after deployment and health checks succeed. No concrete merge-blocking issue is established; merge after normal build and CI checks pass.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 678bc

The endpoint checks protect newly published pages, but do not undo a Worker deployment that fails validation. Preview Workers also share production rate-limit budgets for the same source addresses. These create meaningful release-containment and environment-isolation risks, although preview data is separated and no new credential compromise was established.

Retained concerns

  • Medium · security · inferred: The health gate controls publication of the next client configuration, not the already-deployed public Worker. A validation failure, cancellation, or Pages publication failure has no automatic disablement or rollback path. A Worker rejected for missing limiter bindings can therefore remain reachable with the inherited fail-open limiter behavior. After a successful release, replacing the stable production origin can also affect existing clients before the new version passes validation. Manual recovery exists, but is outside the workflow transaction.
  • Medium · reliability · observed: The new automated PR Workers reuse production rate-limit namespace IDs and address keys. Preview traffic consequently consumes production abuse-control budgets for matching source addresses, so preview activity can throttle production users sharing that address. Separate Worker names and Durable Objects isolate data, but not these controls. This is bounded same-address contention, not evidence of arbitrary global denial of service or new access to production data.
Security review details

Security Blast Radius

  • inferred — Runtime effects span the production shared-brain service and each deployed preview. Preview data separation does not isolate same-address limiter budgets. Deployment commands inherit the configured account token; maximum credential exposure depends on its external permissions, not the PR-specific Worker name.

Security Findings and Attack Paths

  • inferred — A failed publication gate does not make the deployed Worker unreachable. Non-browser clients can supply an allowed Origin, so hiding Shared is not backend access revocation. Preview health requests also consume the shared read limiter without requiring an Origin, permitting same-address preview activity to affect production's limiter budget. No exploit, data disclosure, or account-wide compromise was demonstrated.

Trust Boundaries and Controls

  • observed — The new Cloud Brain shell step supplies deployment credentials to npm installation, Wrangler build/deploy, and the health checker. The inspected parent already deployed PR-controlled multiplayer configuration using the same token fallback, so the added execution path alone does not establish a new PR-to-secret trust bypass. Actual token scope and same-repository PR approval policy were not available.

Resilience and Maintainability Implications

  • observed — Manual emergency disablement preserves Durable Object data, but a normal deployment turns the service back on because the normal configuration omits the disable variable. Preview deletion and schema-aware rollback likewise depend on operators rather than automatic reconciliation.

Hardening Proposals

  • proposed — Bind release serialization to the resolved Worker identity, validate candidate versions before production activation where supported, and define explicit failure compensation. Separate preview rate-limit namespaces from production and give preview cleanup an automatic owner.
  • proposed — Document and verify deployment-token scope and PR trust policy, use separately constrained preview authority where possible, and keep build and health-check execution outside the credential-bearing deployment step. Preserve emergency disablement until an explicit authorized recovery decision.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (6 skipped: 6 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main changes: deploying the shared Cloud Brain with the site and testing it in CI.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (6 skipped: 6 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

shaal added 5 commits October 1, 2026 09:06
…aker that needs no build

From review: production deploys only from main, after the native and
Worker tests (a migration cannot be rolled back); a run that cannot deploy
keeps the running production brain if it still answers; the build never
sees the Cloudflare credentials; /health reports the commit built, so the
health check waits for the new version, and it also sends a recall as the
page does. The breaker is a DISABLE_BRAIN secret (tried on the preview).
Cache keys per job; the CI skips docs-only changes and cancels superseded
runs. Browser stage 7 waits out A's send backoff (A and B share one
address in CI).
…e back to a seed (sessions run every second)
@shaal
shaal merged commit f798016 into main Oct 1, 2026
8 of 10 checks passed
@shaal
shaal deleted the ship/cb5-deploy branch October 1, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant