Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Record no identity when setup finishes without an account

shukieshah4dbe4e204ab2
diff --git a/cli/beacon/cmd/endpoint_onboarding.go b/cli/beacon/cmd/endpoint_onboarding.go
index db90098d..40916fc2 100644
--- a/cli/beacon/cmd/endpoint_onboarding.go
+++ b/cli/beacon/cmd/endpoint_onboarding.go
@@ -219,8 +219,15 @@ func runAccountOnboarding(cmd *cobra.Command, profile *onboarding.Profile, desti
if !result.Completed {
return onboardingOutcome{}, onboarding.ErrWizardCancelled
}
- if result.SignedInEmail != "" {
+ switch {
+ case result.SignedInEmail != "":
status = account.Status{SignedIn: true, User: account.User{Email: result.SignedInEmail}}
+ case result.WithoutAccount:
+ // The user finished without signing in. Any identity still in status came
+ // from a session on disk that was not usable -- an expired one keeps its
+ // user -- and recording it would name someone who did not authorize this
+ // run, under an outcome that says they did.
+ status = account.Status{}
}
privacyMode := ""
@@ -245,13 +252,18 @@ func runAccountOnboarding(cmd *cobra.Command, profile *onboarding.Profile, desti
recordedDestination = ""
}
- outcome := onboardingOutcome{Connect: connectAfterInstall}
+ decided := onboardingOutcome{Connect: connectAfterInstall}
email := status.User.Email
- outcome.Persist = func() error {
+ // A run that never signed in is recorded as skipped, not authenticated.
+ outcome := onboarding.OutcomeAuthenticated
+ if result.WithoutAccount {
+ outcome = onboarding.OutcomeSkipped
+ }
+ decided.Persist = func() error {
if profile.Onboarding.CompletedAt == "" {
profile.Onboarding = onboarding.Onboarding{
CompletedAt: onboardingClock().UTC().Format(time.RFC3339),
- Outcome: onboarding.OutcomeAuthenticated,
+ Outcome: outcome,
Email: email,
BeaconVersion: version.GetVersion(),
Destination: recordedDestination,
@@ -280,7 +292,7 @@ func runAccountOnboarding(cmd *cobra.Command, profile *onboarding.Profile, desti
case result.Destination == onboarding.DestinationLocal:
fmt.Fprintln(cmd.OutOrStdout(), "Local-only telemetry selected. Open it with `beacon traces`.")
}
- return outcome, nil
+ return decided, nil
}
// recordDestinationAsymptote stores the managed answer after explicit
diff --git a/cli/beacon/cmd/endpoint_onboarding_test.go b/cli/beacon/cmd/endpoint_onboarding_test.go
index 9886f9a2..1ab8633e 100644
--- a/cli/beacon/cmd/endpoint_onboarding_test.go
+++ b/cli/beacon/cmd/endpoint_onboarding_test.go
@@ -942,3 +942,45 @@ func TestOnboardingPersistsNothingUntilTheInstallSucceeds(t *testing.T) {
t.Fatal("a machine whose install failed must be asked again on the next install")
}
}
+
+// Finishing setup without an account must not record a leftover identity as the
+// person who onboarded, nor claim the run was authenticated.
+//
+// account.Inspect returns the stored user even when the session is expired, so
+// Email is populated while SignedIn is false.
+func TestSkippingTheAccountRecordsNoIdentity(t *testing.T) {
+ h := newOnboardingHarness(t)
+ h.askable = true
+ h.accountStatus = account.Status{
+ SignedIn: true,
+ Expired: true,
+ User: account.User{ID: "usr_old", Email: "[email protected]"},
+ }
+ onboardingRunWizard = func(_ io.Reader, _ io.Writer, _ onboarding.WizardOptions) (onboarding.WizardResult, error) {
+ return onboarding.WizardResult{
+ Completed: true,
+ WithoutAccount: true,
+ Destination: onboarding.DestinationLocal,
+ }, nil
+ }
+
+ if _, err := runOnboarding(t, h.cmd); err != nil {
+ t.Fatalf("runOnboarding returned error: %v", err)
+ }
+ if len(h.saved) != 1 {
+ t.Fatalf("saved = %+v, want one profile", h.saved)
+ }
+ got := h.saved[0].Onboarding
+ if got.Email != "" {
+ t.Fatalf("recorded an identity the user did not sign in as: %q", got.Email)
+ }
+ if got.Outcome == onboarding.OutcomeAuthenticated {
+ t.Fatalf("a run with no account must not be recorded as authenticated: %q", got.Outcome)
+ }
+ if got.Outcome != onboarding.OutcomeSkipped {
+ t.Fatalf("outcome = %q, want skipped", got.Outcome)
+ }
+ if got.Destination != onboarding.DestinationLocal {
+ t.Fatalf("destination = %q, want local", got.Destination)
+ }
+}
diff --git a/cli/beacon/internal/onboarding/wizard.go b/cli/beacon/internal/onboarding/wizard.go
index 26729606..c7217e54 100644
--- a/cli/beacon/internal/onboarding/wizard.go
+++ b/cli/beacon/internal/onboarding/wizard.go
@@ -466,6 +466,11 @@ func (m wizardModel) recover() (tea.Model, tea.Cmd) {
m.result.WithoutAccount = true
m.result.Destination = DestinationLocal
m.result.PrivacyMode = ""
+ // Drop any leftover identity. Email is populated from whatever session was
+ // on disk, including an expired one that cannot be used, so leaving it set
+ // would show an account on the confirm screen next to "not signed in".
+ m.options.Email = ""
+ m.options.SignedIn = false
m.screen = confirmScreen
return m, nil
default:
diff --git a/cli/beacon/internal/onboarding/wizard_test.go b/cli/beacon/internal/onboarding/wizard_test.go
index a5fff01e..2304cb33 100644
--- a/cli/beacon/internal/onboarding/wizard_test.go
+++ b/cli/beacon/internal/onboarding/wizard_test.go
@@ -574,3 +574,38 @@ func TestStaleSignInDoesNotPoisonRetry(t *testing.T) {
t.Fatalf("the current attempt's failure was dropped: screen = %v", model.screen)
}
}
+
+// An expired session still carries a user, so Email is populated while SignedIn is
+// false. Finishing without an account must not then show that stale identity.
+func TestFinishingWithoutAnAccountDropsALeftoverIdentity(t *testing.T) {
+ model := signInWizard(t, neverReturns)
+ model.options.Email = "[email protected]" // from an expired session
+ model.options.OfferManaged = true
+ model.screen = signInScreen
+
+ model, _ = advanceWizard(t, model, "enter")
+ t.Cleanup(func() { model.stopSignIn() })
+ next, _ := model.Update(signInDoneMsg{attempt: 1, err: errors.New("connection refused")})
+ model = next.(wizardModel)
+
+ for i, choice := range model.recoveryChoices() {
+ if choice.id == "local" {
+ model.selected = i
+ }
+ }
+ model, _ = advanceWizard(t, model, "enter")
+
+ if model.options.Email != "" {
+ t.Fatalf("a leftover identity survived the skip: %q", model.options.Email)
+ }
+ view := strings.Join(strings.Fields(model.View()), " ")
+ if strings.Contains(view, "[email protected]") {
+ t.Fatalf("confirm screen shows an account the user did not sign in as:\n%s", view)
+ }
+ if strings.Contains(view, "Account:") {
+ t.Fatalf("confirm screen shows an account line with no account:\n%s", view)
+ }
+ if !strings.Contains(view, "not signed in") {
+ t.Fatalf("confirm screen should say there is no account:\n%s", view)
+ }
+}