claude-code: a login is succeeded by its own refresh, not only by a newer lineage

The manager's refresh keeps the licence's refresh-token expiry, so a grant of the
same lineage with a later access expiry replaces the login; a grant with no
mark, an older lineage or no later access expiry is the older lease and is kept.

Builds: ADR 0206, ADR 0209, design 39 §3 §6, design 14, H-A-138 (hq design/47-H1-answers-59 175ed320), H-A-139 (hq design/47-H1-answers-59 e359911e)
This commit is contained in:
2026-11-20 14:25:47 +01:00
parent a8a0cfeb8f
commit 0934292f47
3 changed files with 41 additions and 17 deletions
+4 -4
View File
@@ -638,11 +638,11 @@ func Apply(p Paths, c Current, sealed SealedBox, write WriteManaged) (map[string
return map[string]any{"applied": false, "licence": c.Licence, "reason": LoginKept}, nil
}
// 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, as the manager marks it): a lease older than the login is never
// 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
// written, so the manager's failed refresh is a finding on the manager, never a lost login here
// (H-A-138, hq design/47-H1-answers-59 175ed320).
if HoldsLogin(local) && !NewerLineage(local, g) {
log.Printf("login kept: the grant offered for licence %s is not of a newer lineage than the login in the credentials file", c.Licence)
// (H-A-138, hq design/47-H1-answers-59 175ed320; H-A-139, e359911e).
if HoldsLogin(local) && !Succeeds(local, g) {
log.Printf("login kept: the grant offered for licence %s does not succeed the login in the credentials file", c.Licence)
return map[string]any{"applied": false, "licence": c.Licence, "reason": LoginKept}, nil
}
d := DecideApply(GrantOf(local), g, switched || HoldsLogin(local))