Repository navigation
feat(devnet): bind dev-installed providers to their coordinator and add seed data - #1330
Conversation
… data An installer served by any coordinator other than production now writes that coordinator's [coordinator] url into provider.toml and keeps the file's other lines. Before this, a Mac installed from the dev coordinator connected to production, because the provider default is production and install.sh never wrote the URL. The production installer leaves the file unchanged. Add coordinator/cmd/devnet-seed, which fills an empty dev database with fake accounts, API keys, provider sessions, usage, ledger entries and balances through the store package. It refuses a database whose users table has rows, before any migration runs. Fix the dev runbook and deploy comments: bootstrap creates only 10 secrets, the console runs on Vercel, the R2 CDN URL is not templated into install.sh, and vm-startup.sh now sets EIGENINFERENCE_IPAPI_KEY like refresh-env.sh. Add a DevNet checklist of the steps that need a person. Refs DBLM-552. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Deployment failed for project d-inference with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
Threat model review — advisoryReviewed head Review not completed for this head. Previous findings are superseded, not confirmed resolved. LOW: Installer now persists the serving coordinator URL, extending Host-header-injection impact (T-040)coordinator/api/install.sh:28 · T-040 Previously, a coordinator URL injected into the installer through Host or X-Forwarded-Proto (T-040) affected only the one-shot download. With this PR the installer's bind_provider_coordinator writes COORD_URL into ~/.config/darkbloom/provider.toml as `[coordinator] url`, after validating only that it is a syntactically valid https://host\[:port\] (or localhost http). The provider's start, login, update and LaunchAgent all use that URL. If the coordinator derives COORD_URL from request headers (baseURL unset) and a cache or proxy serves the poisoned installer, the victim's provider stays bound to the attacker's host. Later `darkbloom login` tokens and provider traffic then go to that host, and updates are fetched from it. A malicious installer could already run arbitrary code, but the persistent rebinding is new. Fix: require baseURL to be configured in production so install.sh never reflects request headers. Optionally allowlist the hosts the installer may write, and have the provider warn when its coordinator differs from the production default. Raised by: anthropic/claude-sonnet-5.5 Models: budgeted Sonnet / selective Opus / selective Sol 6.1. Findings require human validation; this review never requests changes or blocks merging. Coverage: 26/120 source units; cross-file integration pending. 0 selected depth batch(es) pending. All threat definitions indexed; relevant full definitions selected. Unchanged callers are not scanned. Cost this run: $0.4236 reported, $0.0000 reserved with unknown cost; 5 paid request(s), 2 reused batch(es), 100485 provider cache-hit tokens. Saved findings and earlier report · Historical findings are not confirmed resolved. |
The served COORD_URL is written into provider.toml, so accept only a bare host[:port] (letters, digits, dots, hyphens) and refuse paths, quotes and other characters that could change the TOML. Plain http:// (ws://) is accepted only for localhost and 127.0.0.1, so a remote coordinator cannot be bound over a cleartext channel. Addresses the threat-model review finding on #1330. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Deployment failed for project eigen-homepages-darkbloom with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Deployment failed for project d-inference-console-ui-dev with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Deployment failed for project d-inference-landing with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
Disposition for the threat-model review finding (MEDIUM, installer persists an unvalidated coordinator URL):
|
The installer now persists the substituted coordinator URL, so a Host-derived URL would rebind later provider traffic. Record this, the host validation, and that production and dev both configure the base URL. Addresses the LOW threat-model review findings on #1330. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Disposition for the two LOW threat-model findings on a3367bd (Host-header-derived URL persisted into
|
The installer now always binds the provider to the coordinator that served it. The production installer removes any url line under [coordinator] and keeps every other line, so the provider falls back to its built-in production default; it does not create the file when it is missing, and it leaves a file without that url byte-for-byte unchanged. Before this, a Mac bound to dev stayed on dev after the production installer ran. Other coordinators keep the existing behaviour. Update the installer, Go and Swift tests, and the docs that described the old limitation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng test runner requireEmptyDatabase no longer reuses one bool for "table exists" and "has rows". The coordinator-binding Python test runs the installer hook through one helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve CHANGELOG.md (keep both sides), docs/developer/test.md (master header) and the installer binding test, which follows master's move of the templating tests to coordinator/tests/api/releases/contracts/install_test.go. devnet-seed opens PostgreSQL through store/postgres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tests/cmd Master keeps every coordinator test under coordinator/tests/ in an external package. Follow payout-audit: cmd/devnet-seed is a thin main that calls devnetseed.Run, and the package exports ParseOptions, Seed and Run. The tests move to coordinator/tests/cmd/devnet-seed (package devnetseed_test) unchanged in their assertions and use store/memory for the in-memory store. Docs: point docs/developer/test.md at the moved tests, and remove the dated VM status from the DevNet checklist in docs/operations/dev-environment.md; the procedure stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs-impact requires a canonical owner entry for the new coordinator/internal/command/devnetseed package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port onto master dccc9ee. Conflicts: CHANGELOG.md keeps master's "provider service replacement" section and this PR's "DevNet" section; the three doc stamps take master's later dates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Deployment failed for project darkbloom-status with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
Summary
This PR prepares the DevNet: a dev coordinator plus Macs that stay bound to it, so the team can test database migrations and account erasure before production. Linear: DBLM-552.
https://api.dev.darkbloom.xyzdownloaded the dev release, but the provider then connected to production: the provider default iswss://api.darkbloom.dev/ws/providerandinstall.shnever wrote a URL. Nowbind_provider_coordinatorinscripts/install.shalways binds the provider to the serving coordinator, and keeps every other line of~/.config/darkbloom/provider.toml:url = "wss://<host>/ws/provider"under[coordinator](ws://only forhttp://localhost/http://127.0.0.1), and creates the file if it is missing. The host must be a barehost[:port]; anything else stops the install.https://api.darkbloom.dev): removes anyurlline under[coordinator], so the provider uses its built-in production default. It does not create the file, and a file without that line stays byte-for-byte unchanged. Running the production installer therefore moves a dev Mac back to production.coordinator/cmd/devnet-seedfills an empty database with fake data (seed-<n>@example.invalid,did:privy:seed-<n>, serialsSEED00000001, model IDsdevnet-seed/*) through the samestoremethods the coordinator uses. It refuses to run whenusershas any row, and it checks this before any migration runs. The default scale is small; the runbook gives flags for production-like volume.install.sh, and adds a DevNet checklist of the steps that need a person. The comment inbootstrap.shsaid the console runs on Cloud Run; it runs on Vercel.vm-startup.shnow setsEIGENINFERENCE_IPAPI_KEY, asrefresh-env.shalready did (the env lines of the two files now match).Paths that read the bound URL
I checked every CLI path.
start(and the LaunchAgent plist it writes),login,update,doctor,enroll,modelsand the watchdog all readconfig.coordinator.urlfromprovider.toml. No Swift code change was needed.ServiceDrainfalls back to the production URL when no daemon state exists, but it uses that URL only to take a local update lock, not to make a network call.Before / After
flowchart LR subgraph Before direction TB B1(["curl api.dev…/install.sh | bash"]):::user --> B2["install.sh<br/>downloads dev release"]:::code B2 --> B3[("provider.toml<br/>(no coordinator url)")]:::data B3 --> B4["darkbloom start / login / update<br/>default url"]:::code B4 --> B5{{"wss://api.darkbloom.dev<br/>PRODUCTION"}}:::bad end subgraph After direction TB A1(["curl api.dev…/install.sh | bash"]):::user --> A2["install.sh<br/>downloads dev release"]:::code A2 --> A3["bind_provider_coordinator<br/>COORD_URL ≠ production: write url"]:::new A3 --> A4[("provider.toml<br/>[coordinator] url = wss://api.dev…")]:::data A4 --> A5["darkbloom start / login / update<br/>LaunchAgent, watchdog"]:::code A5 --> A6{{"wss://api.dev.darkbloom.xyz<br/>DEV"}}:::good P1(["prod install.sh"]):::user --> P2["bind_provider_coordinator<br/>COORD_URL = production:<br/>remove [coordinator] url"]:::new P2 --> P3[("provider.toml<br/>other lines kept")]:::data P3 --> P4{{"wss://api.darkbloom.dev<br/>built-in default"}}:::good end classDef user fill:#dbeafe,stroke:#1d4ed8,color:#0b1b3a classDef code fill:#f3f4f6,stroke:#4b5563,color:#111827 classDef new fill:#dcfce7,stroke:#15803d,color:#052e16 classDef data fill:#fef9c3,stroke:#a16207,color:#422006 classDef bad fill:#fee2e2,stroke:#b91c1c,color:#450a0a classDef good fill:#dcfce7,stroke:#15803d,color:#052e16flowchart LR subgraph Before direction TB S1(["empty dev database"]):::data --> S2["no seed tool:<br/>data only from real use"]:::bad end subgraph After direction TB T1(["devnet-seed --accounts N ..."]):::user --> T2{"users table<br/>has rows?"}:::new T2 -- "yes" --> T3["refuse<br/>(before migrations)"]:::bad T2 -- "no" --> T4["store.NewPostgres<br/>(migrations)"]:::code T4 --> T5["CreateUser, CreateAPIKey"]:::code T5 --> T6["UpsertProvider +<br/>Open/Touch/CloseProviderSession"]:::code T6 --> T7["Credit deposit, Debit charge,<br/>RecordUsage, CreditProviderAccount"]:::code T7 --> T8[("users, api_keys, providers,<br/>provider_sessions, usage,<br/>ledger_entries, balances")]:::data end classDef user fill:#dbeafe,stroke:#1d4ed8,color:#0b1b3a classDef code fill:#f3f4f6,stroke:#4b5563,color:#111827 classDef new fill:#dcfce7,stroke:#15803d,color:#052e16 classDef data fill:#fef9c3,stroke:#a16207,color:#422006 classDef bad fill:#fee2e2,stroke:#b91c1c,color:#450a0aLegend: blue = person, grey = existing code, green = new code or good outcome, yellow = stored data, red = wrong or refused outcome.
Test plan
python3 scripts/test-install-coordinator-binding.py: 11 tests pass. Production: creates no file, removes only the[coordinator]url (other sections, including[coordinator.extra]and[provider]url keys, kept), leaves a file without that url byte-identical, and dev-then-production restores the original file. Other coordinators: missing file, url replacement, section without url, file without the section, url keys in other tables left alone, localhosthttp://→ws://, and bad URLs (remotehttp://, paths, quotes,user@) failing without a write../scripts/test-install-atomic.sh(now also runs the test above): passes.go test ./coordinator/api -run 'TestServedInstallerBindsProviderToServingCoordinator|TestInstallScriptTemplating|TestEmbeddedInstaller': passes. The new test runs the installer exactly as a dev and a prod coordinator serve it: dev creates or extends the file; production creates no file and removes the dev url from an existing one.DATABASE_URL=<disposable postgres:17> go test ./coordinator/cmd/devnet-seed: 4 tests pass. Row counts for users, api_keys, providers, provider_sessions, usage, provider_earnings, balances and ledger_entries; balance totals; a second run is refused; a database with users is refused before migrations.swift test --filter "InstallerCoordinatorBindingTests|RuntimeSnapshotConfigTests"(withDEVELOPER_DIRset to Xcode,--build-system native): 8 tests pass. The new suite runs the real installer step and reads the result throughloadRuntimeSnapshot,loadUpdateConfigandWatchdog.settings, checks that a fully serialized config keeps every other setting, and checks that dev then production returns the config to its original values with the production default URL.golangci-lint run ./coordinator/cmd/... ./coordinator/api/...(v2.1.6, as CI): 0 issues.gofmt -l: clean../scripts/test-install-atomic.sh: passes.scripts/sync-install-embed.sh check,make docs-impact-check BASE=origin/master,make docs-check,git diff --check: pass.coordinator/cmd/payout-auditTestPostgresAuditAndApprovedRefundfailed locally against Postgres 17. This PR does not change that package orcoordinator/store.Components touched
cmd/devnet-seed, installer embed, testscripts/install.sh,deploy/gcp/*,deploy/provider-fleet/update-fleet.shProtocol / interface changes
[coordinator] urlconfig key.scripts/install.shandcoordinator/api/install.share identical (sync-install-embed.sh check).release-swift.ymlandLatestProviderVersionare not changed. No version bump.Documentation impact
docs/operations/dev-environment.md(steps 1, 2, 9, new step 10, DevNet checklist),docs/provider/installation.md,docs/provider/cli-reference.md,docs/operations/provider-release.md,docs/developer/test.md,CHANGELOG.md(Unreleased — DevNet).Limitations
darkbloom start.darkbloom restartreuses the existing LaunchAgent arguments.devnet-seedrefuses as soon as anyone has signed in to the database, so run it on a fresh dev database. It does not seed billing sessions, withdrawals or Global Payouts rows.EIGENINFERENCE_STRIPE_GLOBAL_PAYOUTS_*variables. This is listed in the checklist and not changed here.🤖 Generated with Claude Code
Refactor Pass
A dedicated refactor subagent reviewed the diff against the
AGENTS.mdstructure, clean-code and refactor rules. Outcome: one cleanup commit, 813c561.cmd/devnet-seed/main.go: inrequireEmptyDatabase, one bool served two checks. It is now two bools,usersTableExistsandhasUsers. The queries, their order and the error text are unchanged.scripts/test-install-coordinator-binding.py: the--bind-coordinator-testcall was copied in two places. Both now use one helper,run_binding(coordinator, config). All 11 tests and their assertions are unchanged.scripts/install.shand its copy incoordinator/api/install.sh),seed.go, the deploy scripts and the docs are unchanged.scripts/sync-install-embed.sh checkreports that the two installer copies match.Validation on the final tree: the Python binding tests (11 OK),
go vet,gofmt -l,golangci-lintv2.1.6 (0 issues),go test -count=1 ./cmd/devnet-seed(4 PASS, including the two Postgres tests on localpostgres:16),make docs-impact-check, andmake docs-check(330 OK) all pass.Needs a port before merge: master c5552d3 moved
coordinator/api/install_sh_test.gotocoordinator/tests/api/, andTestCoordinatorTestsAreIsolatedrejects test files outside that directory. Both of this PR's Go test files would fail that check.cmd/devnet-seed/main_test.gois apackage maintest of unexported functions, so it needs to be rewritten as well as moved. There are also conflicts inCHANGELOG.md,tests/api/releases/contracts/install_test.goanddocs/developer/test.md.For the author: the DevNet checklist in
docs/operations/dev-environment.mdhas point-in-time status ("timed out on 2026-10-03", "Agents cannot do them") that may belong in this PR body instead.Port to master, c4c9556, 83bed15 and 7337d9b (follow-up): merged master. The devnet-seed logic moved into the production package
coordinator/internal/command/devnetseed/(Run,ParseOptions,Seed), following master'scmd/payout-audit→internal/command/payoutauditlayout.cmd/devnet-seed/main.gois now only the entry point. The tests moved tocoordinator/tests/cmd/devnet-seed/with the same assertions. The installer test lives intests/api/releases/contracts/install_test.go, next to the helpers it uses. The dated session status in the dev-environment checklist is removed. Build, vet, lint (0), the layout guard,test-coordinator-tests.py(20), the tests/api, releases and cmd tests, the devnet-seed tests on Postgres 16 with-race,sync-install-embed.sh checkand the installer-binding tests (11) pass. Not repeated on the merged tree: the SwiftInstallerCoordinatorBindingTests. Master changed no provider-swift files this test touches.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.