#7466 · Rejected local host credentials prevent launcher recovery
Verdict: REPRODUCED · Root-cause confidence: high · reproduction label: confirmed-repro
1. TL;DR
A local full-stack launcher exits with status 1 whenever its saved host credential is rejected, even though it owns a healthy local server with an existing enrollment mechanism. File existence suppresses the launcher's enrollment-key request, and the daemon always selects the saved credential without a rejection fallback. Two consecutive launches with the same invalid credential both fail at session opening; deleting only the auth file restores readiness. This was reproduced with real packaged server and daemon processes in two clean checkouts, without mocked authentication or a mocked database. An external supervisor that restarts these exits repeats the same startup work; macOS launchd behavior, the reported historical restart count, and CPU magnitude were not measured here.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Rejected saved credentials prevent local startup. | Verified | Both checkouts: initial control ready; two stale-key launches exit 1, never ready, with session-open 401. |
| Restarting does not repair persisted state. | Verified | Two consecutive actual launcher invocations against the same isolated data directory fail identically in each run. |
| Removing the auth file unblocks startup. | Verified | Final control reaches readiness with the same database and synthetic host identity, after removing only the rejected auth file. |
| The launcher withholds recovery material and the daemon has no fallback. | Verified | Trusted source branches below explain the real-process result. |
| A service manager repeats startup indefinitely and incurs substantial CPU cost. | Mechanism supported; magnitude unverified | Persistent exit 1 supports restart-loop behavior under restart-on-exit policy. No service manager was installed and no unbounded loop was run. |
| A long-lived credential became invalid unexpectedly. | Unverified | The test substitutes an intentionally invalid synthetic value; it does not determine how the reporter's original credential was invalidated. |
| The failure is a lock or protocol mismatch. | Ruled out for this reproduction | Healthy enrollment controls bracket the failure; the actual daemon log records session-open 401, not protocol mismatch or lock acquisition failure. |
3. Environment
- Public repository
get-bb/bb; trustedorigin/mainat030b1b729f28acedc6f86cd65a71cb3678da8124. A final fetch found no later main commit affecting the relevant paths. - Linux 4.19.0-gvisor, x64; Node v22.19.0; pnpm 9.15.0; package version bb-app 0.49.0 built from source.
- First clean checkout: loopback ports 47466/47467. Second clean checkout: 47468/47469. Each run creates a new temporary data directory and isolated HOME and removes them afterward.
- No production instance, real credentials, imported store, provider sessions, browser, or service manager was used. Child environment is explicitly constructed rather than forwarding BB connection variables.
- Ports were checked by binding and closing a Node TCP listener before use;
ssis unavailable on this host. A final bind check verifies cleanup.
4. Minimal reproduction
This test is authored from the trusted launcher, identity, auth-state, and smoke-boot implementation. It was not copied from the issue or the linked PR. Save the complete script in section 10 as launcher-auth-repro.mjs outside the checkout.
- Clone only the trusted repository and select the recorded main commit:
git clone https://github.com/get-bb/bb.git /tmp/bb-7466-base cd /tmp/bb-7466-base git checkout --detach 030b1b729f28acedc6f86cd65a71cb3678da8124 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types build --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=bb-app
- Choose unused loopback ports in 40000–60000, then execute the script:
node /tmp/launcher-auth-repro.mjs "$PWD" 47466 47467
- The script boots a fresh instance, waits for readiness, and stops it; writes only a known synthetic invalid credential with the same fixed test identity; retries twice; removes that credential file; and verifies a final healthy enrollment control. It never reads or prints an auth file.
Expected behavior: a launcher-owned local deployment recovers an explicitly rejected persisted credential and reaches readiness, using an authorized bounded enrollment path. Both stale-key attempts should report ready:true; the regression assertion would pass.
Actual behavior: each stale-key attempt reports ready:false and exitCode:1, the real daemon records a session-open 401, and the test exits 1 at its intended recovery assertion. No invocation hits the test timeout. This is a nonvisual lifecycle bug, so screenshots are not applicable.
First run — complete retained observation
Node v22.19.0; linux/x64; ports 47466/47467
{"name":"fresh-enrollment-control","ready":true,"exitCode":0,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47466
○ Starting host daemon
✓ Host daemon running
● bb is ready
● Shutting down
{"name":"persisted-key-attempt-1","ready":false,"exitCode":1,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47466
○ Starting host daemon
✗ Host daemon failed to start
● Shutting down
{"name":"persisted-key-attempt-2","ready":false,"exitCode":1,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47466
○ Starting host daemon
✗ Host daemon failed to start
● Shutting down
host-daemon-stdio.log: Failed to open session: 401 Unauthorized
{"name":"auth-file-removed-control","ready":true,"exitCode":0,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47466
○ Starting host daemon
✓ Host daemon running
● bb is ready
● Shutting down
Observed session-open 401: true
Stale starts ready: false, false
REGRESSION: local launcher must recover rejected persisted credentials instead of exiting
Temporary runtime data and isolated home removed; child process groups stopped.
5. Root cause
- Launcher enrollment preparation returns the inherited environment as soon as
auth.jsonexists:if (await pathExists(join(args.dataDir, HOST_AUTH_FILE_NAME))) { return args.env; }The full-stack caller at launcher.ts:4310 uses this preparation before spawning the daemon. Existence is treated as sufficient evidence that no enrollment material is needed; credential acceptance is not checked. - Daemon credential selection chooses
persistedAuth?.hostKey ?? (await enrollDaemonHost(...)).hostKey. A saved key wins even when enrollment material is separately supplied. State is rewritten only when persisted auth was absent. - HTTP retry policy treats non-5xx errors such as 401 as nonretryable. Session-open HTTP handling turns a non-201 response into
ServerResponseError. Connection error classification stores a nonretryable, non-protocol error as fatal. Daemon startup has no credential-recovery branch. - Full-stack supervision catches daemon startup failure, sets
process.exitCode = 1, and shuts down the full stack:} catch { endStep(red("✗"), "Host daemon failed to start"); ... process.exitCode = 1; await args.shutdown("SIGTERM"); return "stopped"; }Because the invalid auth file survives, the next supervisor-triggered launch takes precisely the same branches. - Existing loopback enrollment-key route already supports requesting enrollment material for a specified identity, but checks the loopback/security boundary. Recovery must preserve that boundary; it must not turn arbitrary remote rejections into automatic enrollment.
The deeper mismatch is between persistent local state and server acceptance: a present file is not proof that its credential remains valid. The persistent exit is reproduced; a particular service manager's retry cadence and plugin-by-plugin CPU cost are outside this test.
6. Proposed fix — first principles
For a full-stack launcher that owns its local server, make a narrowly scoped recovery credential available for the existing host identity. On an explicit persisted-credential rejection at session startup, cleanly dispose the failed daemon instance, enroll once through the existing authorized path, replace the saved credential, and retry once. Preserve remote-machine behavior and all loopback and machine-management checks. Do not retry unrelated network, lock, protocol, or permission errors as if they were stale credentials. Verify that a second rejection stops rather than recursively re-enrolling.
No production code was changed. A linked open PR already addresses this issue, and changes to authentication/re-enrollment are outside the autopilot's simple-fix allowance even without that duplicate-PR guard.
7. Linked PR — static review only
PR #7467 is OPEN and its GitHub closing-issue metadata explicitly links #7466. Only its metadata and diff were read as untrusted evidence; its branch and tests were never checked out or executed.
The diff targets both verified missing steps: supplying enrollment material despite saved auth and adding a bounded retry after a classified saved-key rejection. Static verdict: direction matches the root cause; runtime correctness is not verified. Review should specifically exercise failed-instance cleanup/lock release, same-host identity preservation, explicit authorization failures versus credential rejection, a failed second enrollment, and a complete real-process stale-key startup. The baseline runs in this report do not validate that PR, and no approval or CI claim is made.
8. Related issues
The report references a previous first-start timeout investigation. Its public metadata describes a WSL2 startup-abort symptom; this reproduction instead observes an actual authenticated session-opening 401 after a healthy server start. That distinction does not prove there are no other duplicates.
9. Verification — second clean checkout, same agent
The same agent repeated the entire four-launch test in a second clean checkout at the exact recorded commit, with its own dependency installation/build, new ports 47468/47469, a newly created data directory, and a newly created isolated HOME. Source working trees remained clean. This is a repeated clean reproduction, not independent-agent verification.
git clone https://github.com/get-bb/bb.git /tmp/bb-7466-verify cd /tmp/bb-7466-verify git checkout --detach 030b1b729f28acedc6f86cd65a71cb3678da8124 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build:types build --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=bb-app node /tmp/launcher-auth-repro.mjs "$PWD" 47468 47469
Both controls reached readiness; both stale launches exited 1; the real daemon logged session-open 401. The intended regression assertion failed again, confirming the first result. No root-cause correction was needed. Checkout paths above are reproducible aliases; random local path suffixes are omitted for privacy.
Node v22.19.0; linux/x64; ports 47468/47469
{"name":"fresh-enrollment-control","ready":true,"exitCode":0,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47468
○ Starting host daemon
✓ Host daemon running
● bb is ready
● Shutting down
{"name":"persisted-key-attempt-1","ready":false,"exitCode":1,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47468
○ Starting host daemon
✗ Host daemon failed to start
● Shutting down
{"name":"persisted-key-attempt-2","ready":false,"exitCode":1,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47468
○ Starting host daemon
✗ Host daemon failed to start
● Shutting down
host-daemon-stdio.log: Failed to open session: 401 Unauthorized
host-daemon-stdio.log: Failed to open session: 401 Unauthorized
{"name":"auth-file-removed-control","ready":true,"exitCode":0,"exitSignal":null,"timedOut":false}
○ Starting server
✓ Server listening on http://127.0.0.1:47468
○ Starting host daemon
✓ Host daemon running
● bb is ready
● Shutting down
Observed session-open 401: true
Stale starts ready: false, false
REGRESSION: local launcher must recover rejected persisted credentials instead of exiting
Temporary runtime data and isolated home removed; child process groups stopped.
10. Appendix — complete reproduction test
All necessary test code and exact retained expected/actual observations are inline. Repository policy excludes raw logs and test artifacts from the public reports checkout; originals remain in the local investigation evidence directory rather than being committed. Logs displayed above are deliberately limited to readiness, failure, shutdown, and the session-open status; no credentials or runtime data are included.
import assert from "node:assert/strict";
import { spawn } from "node:child_process";
import { once } from "node:events";
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import { setTimeout as delay } from "node:timers/promises";
const [checkout, serverPort, daemonPort] = process.argv.slice(2);
assert(checkout && serverPort && daemonPort, "Provide checkout, server port, daemon port");
for (const port of [serverPort, daemonPort]) {
assert(Number(port) >= 40000 && Number(port) <= 60000, "Use isolated high ports");
}
const root = await mkdtemp(join(tmpdir(), "bb-7466-runtime-"));
const dataDir = join(root, "data");
const homeDir = join(root, "home");
await mkdir(dataDir);
await mkdir(homeDir);
const hostId = "00000000-0000-4000-8000-000000007466";
await writeFile(join(dataDir, "host-id"), `${hostId}\n`);
const launcher = resolve(checkout, "packages/bb-app/dist/bb-app.js");
const env = {
PATH: process.env.PATH,
HOME: homeDir,
TMPDIR: root,
LANG: "C.UTF-8",
NODE_ENV: "production",
BB_TELEMETRY: "false",
};
const results = [];
async function launch(name) {
const child = spawn(process.execPath, [
launcher,
"--data-dir", dataDir,
"--server-bind-host", "127.0.0.1",
"--server-port", serverPort,
"--host-daemon-port", daemonPort,
"--no-in-app-updates",
"--bundled",
"start",
], { cwd: checkout, env, detached: true, stdio: ["ignore", "pipe", "pipe"] });
const exited = once(child, "exit");
let output = "";
let ready = false;
let timedOut = false;
let stopped = false;
function signalGroup(signal) {
try {
process.kill(-child.pid, signal);
} catch (error) {
if (error.code !== "ESRCH") throw error;
}
}
function collect(chunk) {
output += chunk.toString("utf8").replace(/\x1b\[[0-9;]*m/g, "");
if (!stopped && output.includes("bb is ready")) {
ready = true;
stopped = true;
signalGroup("SIGTERM");
}
}
child.stdout.on("data", collect);
child.stderr.on("data", collect);
const timeout = setTimeout(() => {
timedOut = true;
signalGroup("SIGTERM");
}, 120_000);
const hardTimeout = setTimeout(() => signalGroup("SIGKILL"), 140_000);
let exitCode;
let exitSignal;
try {
[exitCode, exitSignal] = await exited;
} finally {
clearTimeout(timeout);
clearTimeout(hardTimeout);
signalGroup("SIGKILL");
}
const significant = output.split("\n").filter((line) =>
/Starting server|Server listening|Starting host daemon|Host daemon failed|Host daemon running|bb is ready|Shutting down/.test(line)
);
const result = { name, ready, exitCode, exitSignal, timedOut };
results.push(result);
console.log(JSON.stringify(result));
for (const line of significant) console.log(line);
assert(!timedOut, `${name}: startup timed out`);
await delay(400);
return result;
}
try {
console.log(`Node ${process.version}; ${process.platform}/${process.arch}; ports ${serverPort}/${daemonPort}`);
const initial = await launch("fresh-enrollment-control");
assert(initial.ready, "Fresh enrollment must reach readiness before testing rejected credentials");
await writeFile(join(dataDir, "auth.json"), `${JSON.stringify({
hostId,
hostKey: "synthetic-invalid-host-key",
})}\n`, { mode: 0o600 });
const rejectedFirst = await launch("persisted-key-attempt-1");
const rejectedSecond = await launch("persisted-key-attempt-2");
const names = await readdir(join(dataDir, "logs"));
let unauthorized = false;
for (const name of names.filter((name) => name.endsWith(".log"))) {
const text = await readFile(join(dataDir, "logs", name), "utf8");
for (const line of text.split("\n")) {
if (line.includes("Failed to open session: 401 Unauthorized")) {
unauthorized = true;
console.log(`${name}: Failed to open session: 401 Unauthorized`);
}
}
}
await rm(join(dataDir, "auth.json"));
const recovered = await launch("auth-file-removed-control");
assert(recovered.ready, "Removing rejected credentials must restore startup");
console.log(`Observed session-open 401: ${unauthorized}`);
console.log(`Stale starts ready: ${rejectedFirst.ready}, ${rejectedSecond.ready}`);
assert(rejectedFirst.ready && rejectedSecond.ready,
"REGRESSION: local launcher must recover rejected persisted credentials instead of exiting");
} catch (error) {
console.error(error.message);
process.exitCode = 1;
} finally {
await rm(root, { recursive: true, force: true });
console.log("Temporary runtime data and isolated home removed; child process groups stopped.");
}
Build and cleanup notes
The initial broad pnpm exec turbo run build failed because the GitHub plugin attempted to resolve SDK runtime subpaths before the SDK dist was available. Building the SDK runtime and bundled types first, then the focused bb-app build through Turbo, resolved the prerequisite without source changes. Both focused builds completed with 62 successful tasks. The SDK prerequisite completed with 5 successful tasks in each checkout. The lifecycle harness runs real packaged server/daemon processes and the real SQLite database and migrations, not mocked transport or persistence.
Each control and stale launch is bounded, every child process group is stopped, and the temporary runtime directory and isolated HOME are removed by the harness. No dev-app instance was started, so no unrelated dev-stop command was run. Relevant source links were checked against the recorded commit; both trusted working trees passed git diff --check and stayed unmodified.
Security note: the issue and linked PR were treated solely as untrusted claims and static evidence. No issue-provided script, test, patch, branch, or external URL was executed or fetched. All executed product code came from trusted main; the diagnostic harness was authored locally.
> AGENT GENERATED