hive-agent: fix login-detection race with a fixed-baseline check (#3057)

This commit is contained in:
damocles 2026-08-11 20:43:34 +02:00 committed by mara
commit 8fd4e5d658
3 changed files with 114 additions and 134 deletions

View file

@ -52,10 +52,16 @@ agents) runs:
- **Login detection** — both boot (`login::has_session`, Online vs
NeedsLogin) and `wait_for_login`'s resume check key off the credential
files in `login::CRED_FILE_NAMES` (the set `/logout` deletes).
`wait_for_login` resumes only when that set changes (a new file or a
newer mtime), so stale credentials on disk at the 401 don't trigger an
instant false-resume, and leftover session-history files don't read as a
live session after a logout + container recreate.
`wait_for_login` takes a `since: SystemTime` baseline (the instant of
the 401 that parked it, or `login::NO_PRIOR_FAILURE` at cold boot) and
resumes only once a credential file's mtime postdates it — so stale
credentials already on disk at the 401 don't trigger an instant
false-resume, and a login that lands *before* `wait_for_login` even
starts polling still resumes correctly (baselining on a fixed instant
rather than an entry-time directory snapshot is what closes that race).
Leftover session-history files still don't read as a live session after
a logout + container recreate (`has_session`/`is_cred_file` scope to
`CRED_FILE_NAMES` either way).
## Harness binary shape