Skip to content

fix(efficacy): keep a token a trial refreshed when the credential link is remade - #84

Merged
braboj merged 3 commits into
mainfrom
fix/credential-refresh
Oct 30, 2026
Merged

braboj merged 3 commits into
mainfrom
fix/credential-refresh

Conversation

@braboj

@braboj braboj commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Stops runs stalling every 8 hours on an expired login. When a trial's CLI refreshes the token, the harness now keeps the new token instead of discarding it.

Before and after

trial CLI refreshes ─► saves a new file ─► link to the account's file broken
before: next re-link deletes it ─► next trial gets the rotated-out token ─► blocked
after:  newer home file copied over the account's, in place ─► re-link ─► live token

What changed where

File Change
tests/efficacy/harness.py expires_at(); refresh_credentials writes back a newer home file; account= for tests
tests/efficacy/harness.py credential_rotation_checks(): 4 checks on a fake account file
docs/architecture/06-runtime-view.md The credential-file bullet says why the write-back exists

Checks

The running round 5c keeps its old code; a watcher outside the harness covers it until the run restarts.

Closes #83

🤖 Generated with Claude Code

https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX

braboj and others added 3 commits October 30, 2026 07:18
…k is remade

A trial's CLI saves a refreshed token as a new file, which breaks the
scratch home's hard link to the account's credentials. The next re-link
discarded that file and handed the next trial the rotated-out refresh
token, so the trial failed at its first call and the run waited for a
login. refresh_credentials now writes a home file that expires later back
over the account's file, in place, before remaking the link.

Closes #83

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX
The expiry comparison and the copy back were separate steps, so a second
run could write a newer token between them and the first then overwrote
it with its older one, in the account's file and every home linked to it.
The compare, the write and the re-link now hold a lock file beside the
account's credentials; a lock older than a minute, left by a dead run, is
broken. Two self-test checks: the race, paused between the reads and the
write, and a stale lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX
…hat writes them

The lock holds off a second run, not the CLI, which saves its token by
replacing the account's file. A save landing between the expiry comparison
and copyfile() had its newer token overwritten, since copyfile() opened
the replacement. write_back() now reads the account's expiry through the
handle it then writes, and after writing checks the path still names that
file; where a save replaced it, it compares again against the save rather
than overwriting it. A self-test check races a replacement against the
write-back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DpT5xPB8YTAMW2Msp4aPTX
@braboj
braboj merged commit 64eecd7 into main Oct 30, 2026
2 checks passed
@braboj
braboj deleted the fix/credential-refresh branch October 30, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runs stall when the OAuth session expires mid-run

1 participant