Connect all accounts in guided Equipo setup
Default to six Claude and two Codex accounts, preserve existing homes on rerun, refuse duplicate identities, and bind every connected account. Exercise observed account changes for both providers using private copies. Verified targeted tests, nine guard mutations, and a passing make ci run.
17 files changed,
+691
−69
docs/live-gate.md+11 −4docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+4 −0docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-2.md+92 −0internal/directlive/account_change.go+23 −8internal/directlive/driver.go+2 −4internal/directlive/driver_test.go+46 −15internal/directlive/generation.go+0 −5internal/directlive/testdata/fake-cli.py+1 −1internal/equipo/copy.go+5 −2internal/runner/provider/direct_live_config.go+14 −3internal/runner/provider/direct_live_config_test.go+49 −0internal/tryequipo/account_set.go+89 −0internal/tryequipo/accounts.go+9 −0internal/tryequipo/config.go+13 −5internal/tryequipo/multiple_accounts_test.go+325 −0internal/tryequipo/run.go+7 −21scripts/runner-reference-allowlist.json+1 −1
CI failed — run details
Intent
diff --git a/docs/live-gate.md b/docs/live-gate.md| index d969e114..414cd424 100644 |
| --- a/docs/live-gate.md |
| +++ b/docs/live-gate.md |
| @@ -14,8 +14,10 @@ default browser opener cannot reach your browser. Provider login output is |
| hidden so sign-in links, tokens and credential contents stay out of the terminal |
| and logs. |
| -Type `SIGN IN` when you are ready. Use two different Claude accounts and one |
| -Codex account. Confirm each observed identity. The guide creates private homes |
| +Type `SIGN IN` when you are ready. Choose the total accounts to connect for |
| +each provider. The defaults are six Claude accounts and two Codex accounts, |
| +with at least two of each required. Confirm each observed identity. The guide |
| +refuses duplicate accounts within a provider and creates private homes |
| under `~/.local/share/equipo/accounts/`; it refuses interactive and ZeroSub |
| homes. Confirmed homes are checked again on every run. If an account changes, |
| setup stops rather than accepting the replacement. |
| @@ -39,8 +41,8 @@ The guide creates a disposable Git repository and sentinels. The live driver |
| checks each provider's policies, approvals, recovery and isolation. It reads |
| the Codex tool catalog from captured CLI events and tries every exposed tool |
| against the protected paths. The account-change check uses private copies of |
| -the two Claude homes, leaving their credential sources untouched. Missing |
| -observations or failed denials block certification. Human approval questions |
| +two connected accounts for each provider, leaving their credential sources |
| +untouched. Missing observations or failed denials block certification. Human approval questions |
| arrive through the terminal and expire after 60 seconds. |
| V1 does not refresh tokens. A manifest candidate records `certified_refresh: |
| @@ -48,6 +50,11 @@ null` and a reason. Egress permits only the provider's inference host. An expire |
| login makes the connection unavailable with **Sign in again**. Work cannot |
| silently retry on another account. |
| +To add accounts, run the script again and increase the totals. Every connected |
| +account is written to the bindings file. Finished sign-ins are checked and reused; |
| +only new or expired accounts need sign-in. Existing homes and binding IDs stay |
| +the same, and totals cannot drop existing accounts. |
| + |
| If the run stops, run the same script again. Confirmed accounts and setup values |
| are retained under `~/.local/share/equipo/try/`. Each certification attempt gets |
| a fresh evidence directory and log; incomplete evidence is never reused as a |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 95b5f202..42c7246d 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -5109,6 +5109,10 @@ records to satisfy a gate. Release remains blocked while any row is pending. |
| | `ready` | Manifest candidate: %s<br>After reviewing and importing the evidence bundle and candidate manifest, the controller releases with:<br>%s<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| | `live` | Type RUN LIVE GATE to authorize the displayed limits and disposable exercises | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| | `signin` | Type SIGN IN to start official sign-ins in dedicated homes | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `claude-accounts` | Total Claude accounts to connect | Guided live gate | COPY REVIEW REQUIRED | |
| +| `codex-accounts` | Total Codex accounts to connect | Guided live gate | COPY REVIEW REQUIRED | |
| +| `account-minimum` | Enter a whole number of at least %d. Keep all existing accounts connected.<br> | Guided live gate | COPY REVIEW REQUIRED | |
| +| `duplicate-account` | This account is already connected in another home. Run the guide again and sign in to a different account.<br> | Guided live gate | COPY REVIEW REQUIRED | |
| | `instance` | Instance ID from Equipo | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| | `person` | Your Equipo person ID | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| | `claude-model` | Exact Claude model | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-2.md b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-2.md| new file mode 100644 |
| index 00000000..46170210 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-2.md |
| @@ -0,0 +1,92 @@ |
| +# Try Equipo follow-up controller report |
| + |
| +The guide asks for total account counts, defaulting to six Claude accounts and |
| +two Codex accounts. It requires at least two of each and keeps existing accounts |
| +connected. Each account gets its own private home and confirmed identity. All |
| +connected accounts enter the bindings file; coordinator selection is unchanged. |
| + |
| +Saved counts become the next run's defaults. Existing home paths, identity |
| +markers and binding IDs survive reruns, including upgrades from the original |
| +three-home setup. Finished sign-ins are probed without another sign-in. A new |
| +home that resolves to an already connected account is refused before its |
| +identity is saved. On rerun, that unconfirmed home can sign in to another account. |
| + |
| +Certification now selects two connected accounts per provider. Both adapters |
| +observe the second account, then must refuse its login when the expected |
| +identity is the first account. The source homes remain untouched. Marker |
| +modification has its own separate observation and cannot substitute for a second |
| +account. The input format adds `account_changes`, keyed by provider. The previous |
| +Claude-only `account_change` input remains readable; ambiguous inputs are refused. |
| + |
| +No real sign-ins, provider sessions, other agents, copy-review server, enrolment, |
| +release or deployment were run. README prose is unchanged. The live gate still |
| +requires real evidence before release. |
| + |
| +## Verification |
| + |
| +The new setup tests first failed to compile because `connectAccounts` and |
| +`writeBindings` did not exist. The first driver test exposed an incorrect |
| +observation path in the test; that path was corrected before guard checks. |
| + |
| +Targeted setup and configuration checks passed: |
| + |
| +`CGO_ENABLED=0 go test ./internal/tryequipo ./internal/runner/provider -run 'TestConnectAll|TestAccount|TestDuplicateAccount|TestLiveConfig|TestUpgradeOriginal|TestDirectLive' -count=1` |
| + |
| +The fake Engineering driver passed with second-account evidence for both |
| +providers: |
| + |
| +`CGO_ENABLED=0 go test ./internal/directlive -run '^TestDirectDriverFakeCLI/Engineering$' -count=1` |
| + |
| +Each guard below was deliberately broken with a compile-valid mutation, tested, |
| +and restored. Every command uses `CGO_ENABLED=0` and `-count=1`. |
| + |
| +| Broken guard | Test command | Result | |
| +| --- | --- | --- | |
| +| Default to two Claude accounts | `go test ./internal/tryequipo -run '^TestConnectAllAccountsAndAddOnRerun$'` | Failed: only four accounts connected | |
| +| Allow fewer than two accounts | `go test ./internal/tryequipo -run '^TestAccountCountMinimumAndNoRemoval$'` | Failed: sign-in began before valid counts | |
| +| Allow dropping existing accounts | `go test ./internal/tryequipo -run '^TestUpgradeOriginalThreeHomes$'` | Failed: existing sixth account removed | |
| +| Accept duplicate identities | `go test ./internal/tryequipo -run '^TestDuplicateAccountRefusedAndRetryable$'` | Failed for both providers | |
| +| Repeat finished sign-ins | `go test ./internal/tryequipo -run '^TestConnectAllAccountsAndAddOnRerun$'` | Failed: finished sign-ins repeated | |
| +| Write only two bindings | `go test ./internal/tryequipo -run '^TestConnectAllAccountsAndAddOnRerun$'` | Failed: not every account was bound | |
| +| Omit the second Codex account | `go test ./internal/tryequipo -run '^TestLiveConfigAccountChangeBothProviders$'` | Failed: missing account-change configuration | |
| +| Accept the primary account as the second account | `go test ./internal/runner/provider -run '^TestDirectLiveAccountChanges$'` | Failed for both providers | |
| +| Skip Codex account change | `go test ./internal/directlive -run '^TestDirectDriverFakeCLI/Engineering$'` | Failed: Codex account-change evidence was not certified | |
| + |
| +The tests use temporary directories managed by Go and do not require `TMPDIR`. |
| +The fake sign-in programs inherit only the provider login environment. They |
| +record login counts and emit synthetic login output to verify it stays hidden. |
| +The driver checks that both primary and secondary credential sources stay intact. |
| + |
| +Full affected-package checks passed: |
| + |
| +`CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive ./internal/runner/provider -count=1` |
| + |
| +Results: setup 7.693s, certification 156.581s, provider 9.689s. The added binding |
| +write on rerun and the exact copy-inventory check also passed: |
| + |
| +`CGO_ENABLED=0 go test ./internal/tryequipo ./internal/plan3test -run 'TestConnectAllAccountsAndAddOnRerun|TestPlan3ReleaseBoundaries/inventory' -count=1` |
| + |
| +Targeted `go vet`, the reference inventory and unchanged size budgets passed. |
| +The single background `make ci` run passed with exit 0. Its full test step ran |
| +27 packages without cached results or failures in 5m4.889s. Build, vet, |
| +formatting, staticcheck, govulncheck, gitleaks, size budgets, adapter checks, |
| +namespace checks, migrations and performance all passed. Cold boot had a 102ms |
| +median against 500ms; every measured GET stayed below its 150ms budget. |
| +No reachable vulnerabilities or leaked secrets were reported. Network access |
| +remained enabled and Go caches used their defaults. |
| + |
| +## New strings |
| + |
| +All four entries are individually marked `COPY REVIEW PENDING` in |
| +`internal/equipo/copy.go` and listed in the Plan 3 copy inventory. The guide's |
| +account-count, rerun and certification paragraphs were updated in |
| +`docs/live-gate.md`. No copy-review server was started, as instructed. |
| + |
| +| Key | Text | |
| +| --- | --- | |
| +| `claude-accounts` | Total Claude accounts to connect | |
| +| `codex-accounts` | Total Codex accounts to connect | |
| +| `account-minimum` | Enter a whole number of at least %d. Keep all existing accounts connected. | |
| +| `duplicate-account` | This account is already connected in another home. Run the guide again and sign in to a different account. | |
| + |
| +The last two strings end with a newline. |
diff --git a/internal/directlive/account_change.go b/internal/directlive/account_change.go| index a9673781..c3a469fc 100644 |
| --- a/internal/directlive/account_change.go |
| +++ b/internal/directlive/account_change.go |
| @@ -9,6 +9,7 @@ import ( |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| + "amadan.net/oficina/equipo/internal/runner/provider/codex" |
| ) |
| // The trial uses the two confirmed accounts through private runtime copies. |
| @@ -20,14 +21,17 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| err = fmt.Errorf("%s: %w", stage, err) |
| } |
| }() |
| - other := x.d.cfg.AccountChange |
| - if other == nil { |
| + other, exists := x.d.cfg.AccountChanges[x.launch.Binding.Provider] |
| + if !exists && x.launch.Binding.Provider == "claude" && x.d.cfg.AccountChange != nil { |
| + other, exists = *x.d.cfg.AccountChange, true |
| + } |
| + if !exists { |
| return x.check("changed-identity-stops-step", false, map[string]bool{"second_account_observed": false}) |
| } |
| - if other.Provider != "claude" || other.AccountID == x.launch.Binding.AccountID { |
| + if other.Provider != x.launch.Binding.Provider || other.AccountID == x.launch.Binding.AccountID { |
| return provider.ErrIdentity |
| } |
| - b := *other |
| + b := other |
| b.RuntimeRoot = filepath.Join(x.d.policyPaths.ScratchRoot, "homes") |
| second, err := provider.OpenAccount(ctx, b) |
| if err != nil { |
| @@ -50,7 +54,7 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| return err |
| } |
| defer os.RemoveAll(in.Scratch) |
| - in, err = claude.PolicyInputs(second.Binding(), in, role, x.evidence.Model) |
| + in, err = accountChangeInputs(second.Binding(), in, role, x.evidence.Model) |
| if err != nil { |
| return err |
| } |
| @@ -72,7 +76,11 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| defer os.RemoveAll(trial) |
| // Only provider-produced, sanitized runtime metadata and login bytes enter |
| // this disposable source. They are never written to the evidence bundle. |
| - for _, name := range []string{".credentials.json", ".claude.json"} { |
| + files := []string{"auth.json"} |
| + if b.Provider == "claude" { |
| + files = []string{".credentials.json", ".claude.json"} |
| + } |
| + for _, name := range files { |
| raw, e := os.ReadFile(filepath.Join(second.Binding().Home, name)) |
| if e != nil { |
| return e |
| @@ -84,7 +92,7 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| if err = os.WriteFile(filepath.Join(trial, provider.IdentityFile), marshal(x.launch.Binding.Expected), 0600); err != nil { |
| return err |
| } |
| - first := provider.Binding{ID: x.launch.Binding.ID, Provider: "claude", AccountID: x.launch.Binding.AccountID, Expected: x.launch.Binding.Expected, Home: trial, RuntimeRoot: b.RuntimeRoot} |
| + first := provider.Binding{ID: x.launch.Binding.ID, Provider: b.Provider, AccountID: x.launch.Binding.AccountID, Expected: x.launch.Binding.Expected, Home: trial, RuntimeRoot: b.RuntimeRoot} |
| stage = "trial-open" |
| lease, err := provider.OpenAccount(ctx, first) |
| if err != nil { |
| @@ -98,7 +106,7 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| defer os.RemoveAll(in.Scratch) |
| stage = "trial-inputs" |
| in.Tools = profile.MCPTools() |
| - in, err = claude.PolicyInputs(lease.Binding(), in, role, x.evidence.Model) |
| + in, err = accountChangeInputs(lease.Binding(), in, role, x.evidence.Model) |
| if err != nil { |
| return err |
| } |
| @@ -112,3 +120,10 @@ func (x *exercise) accountChange(ctx context.Context) (err error) { |
| stopped := errors.Is(rejected, provider.ErrIdentity) && changed.AccountID == other.AccountID && lease.BeginTurn(ctx) != nil |
| return x.check("changed-identity-stops-step", stopped, map[string]any{"selected": first.AccountID, "observed": changed.AccountID, "second_account": observed.AccountID, "rejected_before_dispatch": stopped}) |
| } |
| + |
| +func accountChangeInputs(b provider.Binding, in provider.PolicyInputs, role, model string) (provider.PolicyInputs, error) { |
| + if b.Provider == "claude" { |
| + return claude.PolicyInputs(b, in, role, model) |
| + } |
| + return codex.PolicyInputs(b, in, model) |
| +} |
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go| index 1008df54..1a265c39 100644 |
| --- a/internal/directlive/driver.go |
| +++ b/internal/directlive/driver.go |
| @@ -343,10 +343,8 @@ func (d *driver) exercise(ctx context.Context, b provider.DirectLiveBinding, rol |
| return e, err |
| } |
| phase = "account-change" |
| - if binding.Provider == "claude" { |
| - if err = x.accountChange(ctx); err != nil { |
| - return e, err |
| - } |
| + if err = x.accountChange(ctx); err != nil { |
| + return e, err |
| } |
| if err = x.changedIdentity(ctx); err != nil { |
| return e, err |
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go| index 0872fab6..85c3ed50 100644 |
| --- a/internal/directlive/driver_test.go |
| +++ b/internal/directlive/driver_test.go |
| @@ -83,21 +83,33 @@ func TestDirectDriverFakeWorker(t *testing.T) { |
| c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: provider.Binding{ID: name, Home: home, AccountID: id.AccountID, Provider: name, Expected: id}, Model: "fixture-model", AuthHost: "", ClaudeTOFUConfirmed: name == "claude"}) |
| c.Sentinels[name] = filepath.Join(home, "sentinel") |
| } |
| - second := c.Bindings[0].Binding |
| - second.ID = "claude-second" |
| - second.AccountID = "second@example.invalid" |
| - second.Expected.AccountID = second.AccountID |
| - second.Expected.HomeID = "second-home" |
| - second.Home = filepath.Join(root, "claude-second") |
| - if err := os.Mkdir(second.Home, 0700); err != nil { |
| - t.Fatal(err) |
| - } |
| - for file, raw := range map[string][]byte{provider.IdentityFile: marshal(second.Expected), ".credentials.json": []byte(`{"fixture":true}`), ".claude.json": []byte(`{"oauthAccount":{"emailAddress":"second@example.invalid"}}`)} { |
| - if err := os.WriteFile(filepath.Join(second.Home, file), raw, 0600); err != nil { |
| + changes := map[string]provider.Binding{} |
| + for _, primary := range c.Bindings { |
| + second := primary.Binding |
| + second.ID += "-second" |
| + second.AccountID = "second@example.invalid" |
| + second.Expected.AccountID = second.AccountID |
| + second.Expected.HomeID = second.ID |
| + second.Home = filepath.Join(root, second.ID) |
| + if err := os.Mkdir(second.Home, 0700); err != nil { |
| t.Fatal(err) |
| } |
| + files := map[string][]byte{provider.IdentityFile: marshal(second.Expected)} |
| + if second.Provider == "claude" { |
| + files[".credentials.json"] = []byte(`{"fixture":true}`) |
| + files[".claude.json"] = []byte(`{"oauthAccount":{"emailAddress":"second@example.invalid"}}`) |
| + } else { |
| + files["auth.json"] = []byte(`{"email":"second@example.invalid"}`) |
| + } |
| + for file, raw := range files { |
| + if err := os.WriteFile(filepath.Join(second.Home, file), raw, 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + changes[second.Provider] = second |
| } |
| - c.AccountChange = &second |
| + c.AccountChanges = changes |
| + |
| for _, name := range []string{"repo", "other", "state"} { |
| c.Sentinels[name] = filepath.Join(root, name, "sentinel") |
| } |
| @@ -128,13 +140,20 @@ func TestDirectDriverFakeWorker(t *testing.T) { |
| t.Fatal(err) |
| } |
| original := map[string]string{} |
| - for _, b := range c.Bindings { |
| - entries, err := os.ReadDir(b.Binding.Home) |
| + sources := []provider.Binding{} |
| + for _, entry := range c.Bindings { |
| + sources = append(sources, entry.Binding) |
| + } |
| + for _, other := range changes { |
| + sources = append(sources, other) |
| + } |
| + for _, b := range sources { |
| + entries, err := os.ReadDir(b.Home) |
| if err != nil { |
| t.Fatal(err) |
| } |
| for _, entry := range entries { |
| - path := filepath.Join(b.Binding.Home, entry.Name()) |
| + path := filepath.Join(b.Home, entry.Name()) |
| raw, err := os.ReadFile(path) |
| if err != nil { |
| t.Fatal(err) |
| @@ -226,6 +245,18 @@ func TestDirectDriverFakeWorker(t *testing.T) { |
| t.Fatalf("%s did not exercise %s: %+v", name, check, e.Checks[check]) |
| } |
| } |
| + rawChange, err := os.ReadFile(filepath.Join(c.EvidenceDir, filepath.Dir(name), e.Checks["changed-identity-stops-step"].Artifact)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var change struct { |
| + Selected, Observed string |
| + SecondAccount string `json:"second_account"` |
| + Rejected bool `json:"rejected_before_dispatch"` |
| + } |
| + if json.Unmarshal(rawChange, &change) != nil || change.Selected != "fixture@example.invalid" || change.Observed != "second@example.invalid" || change.SecondAccount != change.Observed || !change.Rejected { |
| + t.Fatalf("%s did not observe and refuse the second account: %s", e.Provider, rawChange) |
| + } |
| if e.ValidateGroup(filepath.Dir(filepath.Join(c.EvidenceDir, name)), "Calibration") == nil { |
| t.Fatal("fake CLI certified production") |
| } |
diff --git a/internal/directlive/generation.go b/internal/directlive/generation.go| index a94162e3..6a55f626 100644 |
| --- a/internal/directlive/generation.go |
| +++ b/internal/directlive/generation.go |
| @@ -51,11 +51,6 @@ func (x *exercise) changedIdentity(ctx context.Context) error { |
| if rejected == nil { |
| _ = x.launcher.Interrupt(ctx, x.session) |
| } |
| - if x.evidence.Provider == "codex" { |
| - if err := x.check("changed-identity-stops-step", stopped, map[string]bool{"rejected_before_dispatch": stopped}); err != nil { |
| - return err |
| - } |
| - } |
| return x.check("identity-marker-tamper-denied", stopped, map[string]any{"expected": x.launch.Binding.Expected, "rejected_before_dispatch": stopped}) |
| }) |
| } |
diff --git a/internal/directlive/testdata/fake-cli.py b/internal/directlive/testdata/fake-cli.py| index 1f05f1ca..66050c76 100644 |
| --- a/internal/directlive/testdata/fake-cli.py |
| +++ b/internal/directlive/testdata/fake-cli.py |
| @@ -50,7 +50,7 @@ for line in sys.stdin: |
| if method=='initialize': |
| result=next(f['result'] for f in recorded['frames'] if f.get('id')==1) |
| emit(next(f for f in recorded['frames'] if f.get('method')=='remoteControl/status/changed')) |
| - elif method=='account/read':result={'account':{'type':'chatgpt','email':'fixture@example.invalid','planType':'pro'},'requiresOpenaiAuth':True} |
| + elif method=='account/read':result={'account':{'type':'chatgpt','email':json.load(open('/home/runner/auth.json')).get('email','fixture@example.invalid'),'planType':'pro'},'requiresOpenaiAuth':True} |
| elif method=='config/read': |
| result=recorded_config(config) |
| elif method in ['thread/start','thread/resume']: |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 64c4552b..cfcbe9d6 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -1108,11 +1108,14 @@ func RunnerSetupCopy(key string) string { return copyText(key) } |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): onboarding.first_instructions |
| var copyOnboardingFirstInstructions = pageCopy["onboarding.first_instructions"] |
| -// TryText contains the guided live gate's pending copy. The controller requested |
| -// this inventory without a copy-review server. |
| +// TryText returns pending guide copy, listed for the controller without a review server. |
| func TryText(key string) string { return tryCopy[key] } |
| var tryCopy = map[string]string{ |
| + "claude-accounts": "Total Claude accounts to connect", // COPY REVIEW PENDING: try.claude-accounts |
| + "codex-accounts": "Total Codex accounts to connect", // COPY REVIEW PENDING: try.codex-accounts |
| + "account-minimum": "Enter a whole number of at least %d. Keep all existing accounts connected.\n", // COPY REVIEW PENDING: try.account-minimum |
| + "duplicate-account": "This account is already connected in another home. Run the guide again and sign in to a different account.\n", // COPY REVIEW PENDING: try.duplicate-account |
| // COPY REVIEW PENDING: try.prerequisite |
| "prerequisite": "Missing prerequisite: %s\n", |
| // COPY REVIEW PENDING: try.prompt |
diff --git a/internal/runner/provider/direct_live_config.go b/internal/runner/provider/direct_live_config.go| index 2a0c04b7..0c86fcb4 100644 |
| --- a/internal/runner/provider/direct_live_config.go |
| +++ b/internal/runner/provider/direct_live_config.go |
| @@ -12,6 +12,7 @@ import ( |
| // DirectLiveConfig is an explicit, operator-owned input to certification. It is |
| // never populated by discovering logins or by reading interactive CLI config. |
| type DirectLiveConfig struct { |
| + AccountChanges map[string]Binding `json:"account_changes,omitempty"` |
| AccountChange *Binding `json:"account_change,omitempty"` |
| RunID string `json:"run_id"` |
| Repository string `json:"repository"` |
| @@ -108,13 +109,23 @@ func (c DirectLiveConfig) Validate(enabled string) error { |
| return ErrPolicy |
| } |
| } |
| + changes := map[string]Binding{} |
| + for family, b := range c.AccountChanges { |
| + changes[family] = b |
| + } |
| if c.AccountChange != nil { |
| - b := *c.AccountChange |
| - if b.Provider != "claude" || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != "2.1.312" { |
| + if _, exists := changes["claude"]; exists { |
| + return ErrIdentity |
| + } |
| + changes["claude"] = *c.AccountChange |
| + } |
| + for family, b := range changes { |
| + version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[family] |
| + if version == "" || b.Provider != family || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != version { |
| return ErrIdentity |
| } |
| for _, primary := range c.Bindings { |
| - if primary.Binding.Provider == "claude" && (primary.Binding.AccountID == b.AccountID || primary.Binding.Expected.HomeID == b.Expected.HomeID) { |
| + if primary.Binding.Provider == family && (primary.Binding.AccountID == b.AccountID || primary.Binding.Expected.HomeID == b.Expected.HomeID) { |
| return ErrIdentity |
| } |
| } |
diff --git a/internal/runner/provider/direct_live_config_test.go b/internal/runner/provider/direct_live_config_test.go| index 2909c667..89419f2b 100644 |
| --- a/internal/runner/provider/direct_live_config_test.go |
| +++ b/internal/runner/provider/direct_live_config_test.go |
| @@ -92,3 +92,52 @@ func TestDirectLiveGateRequiresExplicitInputs(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +func TestDirectLiveAccountChanges(t *testing.T) { |
| + for _, family := range []string{"claude", "codex"} { |
| + t.Run(family, func(t *testing.T) { |
| + for _, scenario := range []string{"valid", "same_account", "same_home_id", "same_home", "wrong_family", "wrong_version", "unknown_family", "ambiguous_legacy"} { |
| + t.Run(scenario, func(t *testing.T) { |
| + c := liveConfigFixture(t) |
| + var primary Binding |
| + for _, entry := range c.Bindings { |
| + if entry.Binding.Provider == family { |
| + primary = entry.Binding |
| + } |
| + } |
| + second := primary |
| + second.ID += "-second" |
| + second.AccountID += "-second" |
| + second.Expected.AccountID = second.AccountID |
| + second.Expected.HomeID += "-second" |
| + second.Home = filepath.Join(filepath.Dir(primary.Home), family+"-second") |
| + if err := os.Mkdir(second.Home, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + key := family |
| + switch scenario { |
| + case "same_account": |
| + second.AccountID = primary.AccountID |
| + second.Expected.AccountID = primary.AccountID |
| + case "same_home_id": |
| + second.Expected.HomeID = primary.Expected.HomeID |
| + case "same_home": |
| + second.Home = primary.Home |
| + case "wrong_family": |
| + second.Provider = "other" |
| + case "wrong_version": |
| + second.Expected.ProviderVersion = "0.0.0" |
| + case "unknown_family": |
| + key = "other" |
| + case "ambiguous_legacy": |
| + c.AccountChange = &second |
| + } |
| + c.AccountChanges = map[string]Binding{key: second} |
| + if err := c.Validate("1"); (err == nil) != (scenario == "valid") { |
| + t.Fatalf("%s: %v", scenario, err) |
| + } |
| + }) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/tryequipo/account_set.go b/internal/tryequipo/account_set.go| new file mode 100644 |
| index 00000000..a4d9a0fa |
| --- /dev/null |
| +++ b/internal/tryequipo/account_set.go |
| @@ -0,0 +1,89 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "strconv" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + runnersetup "amadan.net/oficina/equipo/internal/runner/setup" |
| +) |
| + |
| +// Keep the original three binding IDs so existing setups retain their accounts. |
| +func accountKey(family string, index int) string { |
| + if family == "claude" && index <= 2 { |
| + return "claude-" + string(rune('a'+index-1)) |
| + } |
| + if family == "codex" && index == 1 { |
| + return "codex" |
| + } |
| + return family + "-" + strconv.Itoa(index) |
| +} |
| + |
| +func (w *Wizard) connectAccounts(ctx context.Context, paths map[string]string) ([]provider.Binding, error) { |
| + counts := map[string]int{} |
| + for _, family := range []string{"claude", "codex"} { |
| + minimum := 2 |
| + for key := range w.State.Homes { |
| + for index := 1; index <= len(w.State.Homes)+1; index++ { |
| + if key == accountKey(family, index) { |
| + minimum = max(minimum, index) |
| + break |
| + } |
| + } |
| + } |
| + def := max(minimum, map[string]int{"claude": 6, "codex": 2}[family]) |
| + key := family + "-accounts" |
| + if saved, err := strconv.Atoi(w.State.Values[key]); err == nil { |
| + def = max(minimum, saved) |
| + } |
| + answer, err := w.ask(key, strconv.Itoa(def)) |
| + if err != nil { |
| + return nil, err |
| + } |
| + count, err := strconv.Atoi(answer) |
| + if err != nil || count < minimum { |
| + fmt.Fprintf(w.Output, equipo.TryText("account-minimum"), minimum) |
| + return nil, provider.ErrPolicy |
| + } |
| + counts[family] = count |
| + } |
| + for family, count := range counts { |
| + w.State.Values[family+"-accounts"] = strconv.Itoa(count) |
| + } |
| + if err := w.save(); err != nil { |
| + return nil, err |
| + } |
| + var bindings []provider.Binding |
| + for _, family := range []string{"claude", "codex"} { |
| + for index := 1; index <= counts[family]; index++ { |
| + key := accountKey(family, index) |
| + w.phase = key |
| + b, err := w.account(ctx, key, family, paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"]) |
| + if err != nil { |
| + return nil, err |
| + } |
| + bindings = append(bindings, b) |
| + } |
| + } |
| + return bindings, nil |
| +} |
| + |
| +func (w *Wizard) duplicateAccount(key, family, account string) bool { |
| + for other, h := range w.State.Homes { |
| + if other != key && (other == family || strings.HasPrefix(other, family+"-")) && h.Identity.AccountID == account { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +func (w *Wizard) writeBindings(path string, bindings []provider.Binding) error { |
| + var rows []runnersetup.AccountBinding |
| + for _, b := range bindings { |
| + rows = append(rows, runnersetup.AccountBinding{ID: b.ID, LocalID: b.ID, Label: b.ID, PersonID: w.State.Values["person"], Provider: b.Provider, Family: map[string]string{"claude": "claude", "codex": "gpt"}[b.Provider], Model: w.State.Values[b.Provider+"-model"], AccountID: b.AccountID, ProviderHome: b.Home, ExpectedIdentity: b.Expected, Kind: "subscription"}) |
| + } |
| + return w.ownedJSON(path, rows) |
| +} |
diff --git a/internal/tryequipo/accounts.go b/internal/tryequipo/accounts.go| index e0c0f04d..30f14454 100644 |
| --- a/internal/tryequipo/accounts.go |
| +++ b/internal/tryequipo/accounts.go |
| @@ -54,6 +54,11 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi |
| }) |
| b := provider.Binding{ID: key, Home: h.Path, Provider: family} |
| id, err := probe.Probe(ctx, b) |
| + // A refused duplicate is unconfirmed. Let its next invocation sign in to |
| + // another account without disturbing any confirmed home's credentials. |
| + if err == nil && h.Identity.AccountID == "" && w.duplicateAccount(key, family, id.AccountID) { |
| + err = provider.ErrIdentity |
| + } |
| if err != nil { |
| fmt.Fprintf(w.Output, equipo.TryText("login"), key) |
| args := []string{"auth", "login"} |
| @@ -78,6 +83,10 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi |
| if strings.ContainsAny(id.AccountID, "\r\n\x1b") { |
| return b, provider.ErrIdentity |
| } |
| + if w.duplicateAccount(key, family, id.AccountID) { |
| + fmt.Fprint(w.Output, equipo.TryText("duplicate-account")) |
| + return b, provider.ErrIdentity |
| + } |
| if h.Identity.AccountID != "" { |
| if id.AccountID != h.Identity.AccountID || id.ProviderVersion != h.Identity.ProviderVersion { |
| return b, provider.ErrIdentity |
diff --git a/internal/tryequipo/config.go b/internal/tryequipo/config.go| index a8a54a86..76985fe1 100644 |
| --- a/internal/tryequipo/config.go |
| +++ b/internal/tryequipo/config.go |
| @@ -48,12 +48,20 @@ func (w *Wizard) config(ctx context.Context, root string, paths map[string]strin |
| if _, err = command(ctx, paths["EQUIPO_GIT_PATH"], []string{"-c", "core.hooksPath=/dev/null", "init", c.Repository}, root, []string{"PATH=/usr/bin:/bin", "HOME=" + root, "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null"}, nil); err != nil { |
| return c, err |
| } |
| - for _, b := range []provider.Binding{bindings[0], bindings[2]} { |
| - c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: b, Model: w.State.Values[b.Provider+"-model"], ClaudeTOFUConfirmed: b.Provider == "claude"}) |
| - c.Sentinels[b.Provider] = filepath.Join(b.Home, "equipo-try-sentinel") |
| + c.AccountChanges = map[string]provider.Binding{} |
| + for _, b := range bindings { |
| + if _, exists := c.Sentinels[b.Provider]; !exists { |
| + c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: b, Model: w.State.Values[b.Provider+"-model"], ClaudeTOFUConfirmed: b.Provider == "claude"}) |
| + c.Sentinels[b.Provider] = filepath.Join(b.Home, "equipo-try-sentinel") |
| + } else if _, exists := c.AccountChanges[b.Provider]; !exists { |
| + c.AccountChanges[b.Provider] = b |
| + c.Sentinels[b.Provider+"-other"] = filepath.Join(b.Home, "equipo-try-sentinel") |
| + } |
| + } |
| + if len(c.AccountChanges) != 2 { |
| + return c, provider.ErrIdentity |
| } |
| - c.AccountChange = &bindings[1] |
| - c.Sentinels["claude-other"] = filepath.Join(bindings[1].Home, "equipo-try-sentinel") |
| + |
| c.Sentinels["repo"] = filepath.Join(c.Repository, "sentinel") |
| c.Sentinels["state"] = filepath.Join(root, "state/sentinel") |
| c.Sentinels["other"] = filepath.Join(root, "other/sentinel") |
diff --git a/internal/tryequipo/multiple_accounts_test.go b/internal/tryequipo/multiple_accounts_test.go| new file mode 100644 |
| index 00000000..c50c806c |
| --- /dev/null |
| +++ b/internal/tryequipo/multiple_accounts_test.go |
| @@ -0,0 +1,325 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + runnersetup "amadan.net/oficina/equipo/internal/runner/setup" |
| +) |
| + |
| +func multiAccountWizard(t *testing.T, input string) (*Wizard, map[string]string, string) { |
| + t.Helper() |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + accounts := filepath.Join(root, "accounts") |
| + if err := os.Mkdir(accounts, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + log := filepath.Join(root, "signins") |
| + script := fmt.Sprintf(`#!/usr/bin/python3 |
| +import json,os,sys |
| +family=os.path.basename(sys.argv[0]) |
| +home=os.environ['CLAUDE_CONFIG_DIR' if family=='claude' else 'CODEX_HOME'] |
| +assert home==os.environ['HOME'] |
| +assert 'OPENAI_API_KEY' not in os.environ and 'ANTHROPIC_API_KEY' not in os.environ |
| +credential=home+('/.credentials.json' if family=='claude' else '/auth.json') |
| +if sys.argv[1:]==['--version']: print('2.1.312 (Claude Code)' if family=='claude' else 'codex-cli 0.165.0') |
| +elif '--help' in sys.argv: pass |
| +elif sys.argv[1:]==(['auth','login'] if family=='claude' else ['login']): |
| + with open(%q,'a') as f: f.write(home+'\n') |
| + identity=open(home+'/next-identity').read() if os.path.exists(home+'/next-identity') else os.path.basename(home)+'@example.invalid' |
| + with open(credential,'w') as f: json.dump({'email':identity},f) |
| + os.chmod(credential,0o600) |
| + print('secret-login-output') |
| +elif sys.argv[1:]==['auth','status','--json']: |
| + if not os.path.exists(credential): sys.exit(1) |
| + print(json.dumps({'loggedIn':True,'authMethod':'claude.ai','email':json.load(open(credential))['email']})) |
| +elif sys.argv[1]=='app-server': |
| + for line in sys.stdin: |
| + q=json.loads(line) |
| + if 'id' not in q: continue |
| + if q['method']=='initialize': r={'userAgent':'equipo/0.165.0 fixture','codexHome':home} |
| + elif q['method']=='account/read': |
| + assert q['params']=={'refreshToken':False} |
| + r={'account':{'type':'chatgpt','email':json.load(open(credential))['email']} if os.path.exists(credential) else None} |
| + else: sys.exit(2) |
| + print(json.dumps({'id':q['id'],'result':r}),flush=True) |
| +else: sys.exit(2) |
| +`, log) |
| + paths := map[string]string{} |
| + for _, family := range []string{"claude", "codex"} { |
| + binary := filepath.Join(root, family) |
| + if err := os.WriteFile(binary, []byte(script), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"] = binary |
| + } |
| + w := &Wizard{Root: root, Accounts: accounts, Input: strings.NewReader(input), Output: &bytes.Buffer{}} |
| + w.init() |
| + return w, paths, log |
| +} |
| + |
| +func TestConnectAllAccountsAndAddOnRerun(t *testing.T) { |
| + w, paths, log := multiAccountWizard(t, "\n\n"+strings.Repeat("yes\n", 8)) |
| + bindings, err := w.connectAccounts(context.Background(), paths) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(bindings) != 8 { |
| + t.Fatalf("got %d accounts, want six Claude and two Codex", len(bindings)) |
| + } |
| + counts := map[string]int{} |
| + homes := map[string]bool{} |
| + for _, b := range bindings { |
| + counts[b.Provider]++ |
| + if homes[b.Home] { |
| + t.Fatal("reused home") |
| + } |
| + homes[b.Home] = true |
| + for _, path := range []string{b.Home, filepath.Join(b.Home, provider.IdentityFile)} { |
| + info, err := os.Stat(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want := os.FileMode(0600) |
| + if info.IsDir() { |
| + want = 0700 |
| + } |
| + if info.Mode().Perm() != want { |
| + t.Fatal("non-private home or identity", path) |
| + } |
| + } |
| + } |
| + if counts["claude"] != 6 || counts["codex"] != 2 { |
| + t.Fatal(counts) |
| + } |
| + w.State.Values["person"] = "person" |
| + w.State.Values["claude-model"] = "claude-model" |
| + w.State.Values["codex-model"] = "codex-model" |
| + path := filepath.Join(w.Root, "bindings.json") |
| + if err := w.writeBindings(path, bindings); err != nil { |
| + t.Fatal(err) |
| + } |
| + var rows []runnersetup.AccountBinding |
| + raw, err := os.ReadFile(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := json.Unmarshal(raw, &rows); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(rows) != 8 { |
| + t.Fatal("not every connected account was bound", len(rows)) |
| + } |
| + for i, row := range rows { |
| + b := bindings[i] |
| + if row.ID != b.ID || row.AccountID != b.AccountID || row.ProviderHome != b.Home || row.ExpectedIdentity != b.Expected || row.PersonID != "person" || row.Model != b.Provider+"-model" { |
| + t.Fatal(row) |
| + } |
| + } |
| + // Read state from disk as a new invocation would. Only the added account signs in. |
| + w.State = State{} |
| + if err := w.load(); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.reader.Reset(strings.NewReader("7\n2\nyes\n")) |
| + added, err := w.connectAccounts(context.Background(), paths) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(added) != 9 { |
| + t.Fatal(len(added)) |
| + } |
| + if err := w.writeBindings(path, added); err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err = os.ReadFile(path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := json.Unmarshal(raw, &rows); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(rows) != 9 { |
| + t.Fatal("added account has no binding", len(rows)) |
| + } |
| + info, err := os.Stat(path) |
| + if err != nil || info.Mode().Perm() != 0600 { |
| + t.Fatal("bindings file is not private", err) |
| + } |
| + for _, old := range bindings { |
| + found := false |
| + for _, b := range added { |
| + if b.ID == old.ID { |
| + found = true |
| + if b != old { |
| + t.Fatal("existing binding changed") |
| + } |
| + } |
| + } |
| + if !found { |
| + t.Fatal("existing binding dropped") |
| + } |
| + } |
| + w.reader.Reset(strings.NewReader("\n\n")) |
| + resumed, err := w.connectAccounts(context.Background(), paths) |
| + if err != nil || len(resumed) != 9 { |
| + t.Fatal(len(resumed), err) |
| + } |
| + raw, err = os.ReadFile(log) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(strings.Fields(string(raw))) != 9 { |
| + t.Fatal("finished sign-ins repeated", string(raw)) |
| + } |
| + if strings.Contains(w.Output.(*bytes.Buffer).String(), "secret-login-output") { |
| + t.Fatal("sign-in output leaked") |
| + } |
| +} |
| + |
| +func TestAccountCountMinimumAndNoRemoval(t *testing.T) { |
| + for _, input := range []string{"1\n2\n", "2\n1\n", "0\n", "-1\n", "many\n"} { |
| + t.Run(strings.TrimSpace(input), func(t *testing.T) { |
| + w, paths, log := multiAccountWizard(t, input) |
| + if _, err := w.connectAccounts(context.Background(), paths); err == nil { |
| + t.Fatal("invalid count accepted") |
| + } |
| + if _, err := os.Stat(log); !os.IsNotExist(err) { |
| + t.Fatal("sign-in before valid counts") |
| + } |
| + }) |
| + } |
| + w, paths, _ := multiAccountWizard(t, "2\n2\n"+strings.Repeat("yes\n", 4)) |
| + if _, err := w.connectAccounts(context.Background(), paths); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.reader.Reset(strings.NewReader("1\n2\n")) |
| + if _, err := w.connectAccounts(context.Background(), paths); err == nil { |
| + t.Fatal("existing account removed") |
| + } |
| +} |
| + |
| +func TestDuplicateAccountRefusedAndRetryable(t *testing.T) { |
| + for _, family := range []string{"claude", "codex"} { |
| + t.Run(family, func(t *testing.T) { |
| + w, paths, _ := multiAccountWizard(t, "yes\nyes\n") |
| + binary := paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"] |
| + first, err := w.account(context.Background(), family+"-a", family, binary) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + home, err := provider.NewLoginHome(w.Accounts) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + w.State.Homes[family+"-b"] = Home{Path: home} |
| + if err := os.WriteFile(filepath.Join(home, "next-identity"), []byte(first.AccountID), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := w.account(context.Background(), family+"-b", family, binary); err == nil { |
| + t.Fatal("duplicate account accepted") |
| + } |
| + if w.State.Homes[family+"-b"].Identity.AccountID != "" { |
| + t.Fatal("duplicate identity saved") |
| + } |
| + if err := os.WriteFile(filepath.Join(home, "next-identity"), []byte("different@example.invalid"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := w.account(context.Background(), family+"-b", family, binary); err != nil { |
| + t.Fatal("duplicate cannot be corrected on rerun", err) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestLiveConfigAccountChangeBothProviders(t *testing.T) { |
| + w, paths, _ := multiAccountWizard(t, "\n\n"+strings.Repeat("yes\n", 8)) |
| + bindings, err := w.connectAccounts(context.Background(), paths) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + paths["EQUIPO_GIT_PATH"], err = exec.LookPath("git") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + paths["EQUIPO_ORIGIN"] = "https://equipo.example.invalid" |
| + w.State.Values["claude-model"] = "fixture" |
| + w.State.Values["codex-model"] = "fixture" |
| + w.reader.Reset(strings.NewReader(strings.Repeat("\n", 10))) |
| + funding, err := w.funding() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + config, err := w.config(context.Background(), filepath.Join(w.Root, "run"), paths, bindings, funding) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := json.Marshal(config) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var wire struct { |
| + AccountChanges map[string]provider.Binding `json:"account_changes"` |
| + } |
| + if err := json.Unmarshal(raw, &wire); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(config.Bindings) != 2 || len(wire.AccountChanges) != 2 { |
| + t.Fatal("missing provider account-change case", string(raw)) |
| + } |
| + for _, primary := range config.Bindings { |
| + other := wire.AccountChanges[primary.Binding.Provider] |
| + if other.Provider != primary.Binding.Provider || other.Home == primary.Binding.Home || other.AccountID == primary.Binding.AccountID { |
| + t.Fatal("invalid second account", other) |
| + } |
| + } |
| +} |
| + |
| +func TestUpgradeOriginalThreeHomes(t *testing.T) { |
| + w, paths, log := multiAccountWizard(t, strings.Repeat("yes\n", 3)) |
| + for _, spec := range [][2]string{{"claude-a", "claude"}, {"claude-b", "claude"}, {"codex", "codex"}} { |
| + if _, err := w.account(context.Background(), spec[0], spec[1], paths["EQUIPO_"+strings.ToUpper(spec[1])+"_PATH"]); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + old := map[string]Home{} |
| + for k, v := range w.State.Homes { |
| + old[k] = v |
| + } |
| + w.State = State{} |
| + if err := w.load(); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.reader.Reset(strings.NewReader("\n\n" + strings.Repeat("yes\n", 5))) |
| + bindings, err := w.connectAccounts(context.Background(), paths) |
| + if err != nil || len(bindings) != 8 { |
| + t.Fatal(len(bindings), err) |
| + } |
| + for k, h := range old { |
| + if w.State.Homes[k] != h { |
| + t.Fatal("original home replaced", k) |
| + } |
| + } |
| + raw, err := os.ReadFile(log) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(strings.Fields(string(raw))) != 8 { |
| + t.Fatal("original sign-ins repeated") |
| + } |
| + w.reader.Reset(strings.NewReader("5\n2\n")) |
| + if _, err := w.connectAccounts(context.Background(), paths); err == nil { |
| + t.Fatal("existing sixth account removed") |
| + } |
| +} |
diff --git a/internal/tryequipo/run.go b/internal/tryequipo/run.go| index 3a277628..03d1da3b 100644 |
| --- a/internal/tryequipo/run.go |
| +++ b/internal/tryequipo/run.go |
| @@ -13,7 +13,6 @@ import ( |
| "amadan.net/oficina/equipo/internal/directlive" |
| "amadan.net/oficina/equipo/internal/equipo" |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| - runnersetup "amadan.net/oficina/equipo/internal/runner/setup" |
| "golang.org/x/sys/unix" |
| ) |
| @@ -54,22 +53,12 @@ func (w *Wizard) Run(ctx context.Context) (err error) { |
| if answer != "SIGN IN" { |
| return provider.ErrPolicy |
| } |
| - var bindings []provider.Binding |
| - for _, spec := range [][2]string{{"claude-a", "claude"}, {"claude-b", "claude"}, {"codex", "codex"}} { |
| - w.phase = spec[0] |
| - variable := "EQUIPO_CLAUDE_PATH" |
| - if spec[1] == "codex" { |
| - variable = "EQUIPO_CODEX_PATH" |
| - } |
| - b, e := w.account(ctx, spec[0], spec[1], paths[variable]) |
| - if e != nil { |
| - return e |
| - } |
| - bindings = append(bindings, b) |
| - } |
| - if bindings[0].AccountID == bindings[1].AccountID { |
| - return provider.ErrIdentity |
| + w.phase = "configuration" |
| + bindings, err := w.connectAccounts(ctx, paths) |
| + if err != nil { |
| + return err |
| } |
| + |
| w.phase = "configuration" |
| for _, key := range []string{"instance", "person", "claude-model", "codex-model", "forge"} { |
| variable := map[string]string{"instance": "EQUIPO_INSTANCE_ID", "person": "EQUIPO_PERSON_ID", "claude-model": "EQUIPO_CLAUDE_MODEL", "codex-model": "EQUIPO_CODEX_MODEL", "forge": "EQUIPO_AMADAN_CREDENTIAL_PATH"}[key] |
| @@ -108,13 +97,10 @@ func (w *Wizard) Run(ctx context.Context) (err error) { |
| paths[key] = path |
| } |
| paths["EQUIPO_ACCOUNT_BINDINGS_PATH"] = filepath.Join(runnerRoot, "bindings.json") |
| - var rows []runnersetup.AccountBinding |
| - for _, b := range bindings { |
| - rows = append(rows, runnersetup.AccountBinding{ID: b.ID, LocalID: b.ID, Label: b.ID, PersonID: w.State.Values["person"], Provider: b.Provider, Family: map[string]string{"claude": "claude", "codex": "gpt"}[b.Provider], Model: w.State.Values[b.Provider+"-model"], AccountID: b.AccountID, ProviderHome: b.Home, ExpectedIdentity: b.Expected, Kind: "subscription"}) |
| - } |
| - if err = w.ownedJSON(paths["EQUIPO_ACCOUNT_BINDINGS_PATH"], rows); err != nil { |
| + if err = w.writeBindings(paths["EQUIPO_ACCOUNT_BINDINGS_PATH"], bindings); err != nil { |
| return err |
| } |
| + |
| if err = w.build(ctx, paths); err != nil { |
| return err |
| } |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 8ec9178a..6dfc52b3 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -7113,7 +7113,7 @@ |
| }, |
| { |
| "path": "internal/directlive/account_change.go", |
| - "line_sha256": "d98752042a7729fc653b914c31d5e9dd3b0466c882e5d3e42dfcef4df47a0b98", |
| + "line_sha256": "7098c8a9f822c562179662689bca38b5d13b41747415aebe1d2e401d4005c94c", |
| "match": "trial", |
| "count": 1, |
| "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |