Merge pull request 'claude-code: a login not handed gives way to a newer lease of its own account (H-A-140)' (#714) from fix/licence-file-the-cli-accepts into main

This commit was merged in pull request #714.
This commit is contained in:
2026-11-20 13:49:50 +00:00
2 changed files with 44 additions and 13 deletions
+15 -2
View File
@@ -630,9 +630,19 @@ func Apply(p Paths, c Current, sealed SealedBox, write WriteManaged) (map[string
// asks claude_code_grant for it on this node's report; its successor then comes as a newer generation.
// This return skips the binding's generation below on purpose: later binding events pull again until
// the manager adopts the login.
// The latest login wins (design 39 §6): a lease of the same account that succeeds the login (H-A-139) —
// the manager adopted a later login to that account from another node — replaces it, said as "login
// superseded"; a login to another account than the lease's licence is always kept (H-A-140, hq
// design/47-H1-answers-59 b75d1386).
superseded := false
if LoginNotHanded(local, readHanded(p)) {
log.Printf("login kept: the login in the credentials file was not handed to the manager yet (licence %s)", c.Licence)
return map[string]any{"applied": false, "licence": c.Licence, "reason": LoginKept}, nil
id := ReadIdentity(p.account())
if id == nil || id.EmailAddress == "" || id.EmailAddress != c.Licence || !Succeeds(local, g) {
log.Printf("login kept: the login in the credentials file was not handed to the manager yet (licence %s)", c.Licence)
return map[string]any{"applied": false, "licence": c.Licence, "reason": LoginKept}, nil
}
superseded = true
log.Printf("login superseded: a later login to the account of licence %s was adopted by the manager (generation %d)", c.Licence, c.Generation)
}
// A login handed to the manager is replaced only by a grant of a newer lineage (its refresh token's
// expiry later than the login's, or the same lineage with a later access expiry, as the manager's refresh yields it): a lease older than the login is never
@@ -643,6 +653,9 @@ func Apply(p Paths, c Current, sealed SealedBox, write WriteManaged) (map[string
return map[string]any{"applied": false, "licence": c.Licence, "reason": LoginKept}, nil
}
d := DecideApply(GrantOf(local), g, switched || HoldsLogin(local))
if d.Apply && superseded {
out["reason"] = "login superseded"
}
if d.Apply {
next := WithGrant(local, g)
if switched {