This repository was archived by the owner on May 13, 2026. It is now read-only.
feat(setup): canonical bootstrap endpoint + legacy migration - #903
Merged
Conversation
shiba4life
enabled auto-merge
May 6, 2026 01:07
shiba4life
force-pushed
the
kanban/973ff-bootstrap-collapse
branch
from
May 6, 2026 01:10
11336c1 to
1cb751c
Compare
Adds POST /api/setup/bootstrap as the additive foundation for collapsing the three first-launch paths (CLI wizard, web UI onboarding, silent auto-init in get_database_status) into one server-side handler. Why: - CLI wizard wrote plaintext identity; master key was never minted in its process. - Auto-init in get_database_status silently provisioned a "ghost node" whenever a stale node_config.json existed. - Recovery-phrase restore went through a separate code path with its own rollback logic. This PR is the additive first step (one of five per the task plan): the new endpoint + boot-time migration land alongside the existing paths so we can validate them before flipping clients over. Endpoint behavior (D1-D5 from the task): - 410 Gone once .onboarding_complete exists (one-shot, no tokens) - Single body shape, recovery_phrase optional => fresh-mint OR restore - Atomic-on-failure: identity tree, credentials, anthropic key, and config files all roll back if any step after identity persistence fails - ENC: blob in Sled when os-keychain is on, plaintext for dev builds - 409 Conflict on cloud-mismatch, 503 not used in this PR (deferred) Boot-time legacy migration (StartupCtx::boot): - Re-encrypts plaintext identity under the keychain master key when os-keychain is enabled - Synthesizes the missing .onboarding_complete marker when an identity exists but the file is absent - Idempotent; conservative (no marker for never-set-up nodes) Loopback bind invariant: - bind_address_for() pulled out of folddb_server main; tests assert 127.0.0.1 for the default port and a range of arbitrary ports. The bootstrap auth model rests on this — if the daemon ever binds 0.0.0.0, per-request caller auth must land alongside the change. Out of scope (will land as separate kanban tasks): - Renaming load_or_generate -> provision and adding NodeManagerError::NotProvisioned - Stripping auto-init from get_database_status - Porting the React onboarding wizard to a single POST - Porting the CLI wizard to a REST client - Removing dead helpers in src/bin/folddb/commands/setup.rs Cross-module test races: - Three test modules (auth, startup, setup) set FOLDDB_HOME concurrently and were racing each other through three separate per-module mutexes. Adds src/utils/test_lock.rs::folddb_home_env_lock so all three share the same lock. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
shiba4life
force-pushed
the
kanban/973ff-bootstrap-collapse
branch
from
May 6, 2026 01:14
1cb751c to
a014c92
Compare
This was referenced May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Additive first step toward collapsing the three first-launch paths
(CLI wizard, web UI onboarding, silent auto-init in
get_database_status)into one canonical server-side handler. This PR introduces the new
endpoint and a boot-time migration; the existing paths keep working
alongside so we can validate before flipping clients over.
Tracks kanban task
973ff. Subsequent PRs (filed as separate tasks)rename
load_or_generate→provision, strip the auto-init branch,and port the CLI + React clients.
What's in here
POST /api/setup/bootstrap(src/server/routes/setup.rs) — singlehandler for fresh-mint and recovery-phrase restore. Self-disables on
.onboarding_complete(410 Gone). Atomic-on-failure: identity tree,credentials, anthropic key, and config files all roll back if any
post-identity step fails.
StartupCtx::boot) — re-encryptsplaintext identities (legacy CLI installs) under the keychain master
key, synthesizes a missing
.onboarding_completemarker when anidentity already exists. Idempotent; conservative (no marker for
never-set-up nodes).
bin/folddb_server.rs) — bind helperextracted, two tests assert 127.0.0.1 for default and arbitrary
ports. The bootstrap auth model rests on this: no token, just one-shot
marker file + loopback isolation.
src/utils/test_lock.rs) — threetest modules were racing each other on the env var via three private
mutexes. Now they share one.
Out of scope (filed as follow-up kanban tasks)
identity::load_or_generate→identity::provisionand gate to bootstrap-onlyNodeManagerError::NotProvisioned→ HTTP 503 conversionget_database_statusfolddb setupCLI wizard to a REST clientsave_identity_card_via_local_nodeonce the CLI port landsTest plan
cargo check --workspacecargo clippy --workspace --all-targets -- -D warnings -A dead_code(
-A dead_codesuppresses the pre-existingapple_import.rs:772warning that fires on macOS only — known issue, unrelated)
cargo test --lib— 934 passcargo test --bins— 11 passcd src/server/static-react && npm test— 676 pass, 6 skippedbirthday 400, marker_path resolves from FOLDDB_HOME, three
migration regression tests (synthesize marker, idempotent, no-op
on empty pool, re-encrypt under master key with
os-keychain)end-to-end — those clients are unchanged in this PR; will be
exercised more thoroughly when their respective port PRs land
🤖 Generated with Claude Code