Skip to content

Age GitHub App tokens with suspend-aware elapsed time - #1373

Merged
mergify[bot] merged 6 commits into
mainfrom
lean178/1157-token-cache-replacement
Nov 26, 2026
Merged

mergify[bot] merged 6 commits into
mainfrom
lean178/1157-token-cache-replacement

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Age GitHub App tokens with suspend-aware elapsed time

Context and goal

  • Goal: The GitHub App token cache refreshes based on elapsed time that includes suspend.
  • Problem: A backward host clock correction can leave an expired installation token looking fresh in the process cache.
  • Context: The cache uses the existing 3,000-second refresh interval before the credential expires at one hour.

Closes #1157

Acceptance

  • At 3,620 seconds of elapsed time, a wall-clock reading only 2,620 seconds ahead of mint time triggers refresh.
  • Ordinary cache hits reuse fresh credentials. Suspends that cross the existing cache lifetime refresh the token, including a suspend during minting or retry.

Notes

  • Supersedes Age GitHub App tokens with suspend-aware elapsed time #1209. Carries the approved production diff, merges main and folds the same fake-clock rollback into the existing cache test. Owner Decisions cleared this expiry behavior on Age GitHub App tokens with suspend-aware elapsed time #1209.
    The cache stores installation credentials and may outlive clock adjustments. Keep the existing identity selection, expiry margin and helper behavior. Hosts without a suspend-aware clock skip cache reuse.

  • The rollback replay reused token 1 on the pre-fix code and minted token 2 after the fix. Existing cache-hit and suspend replays also passed.

Base

main @ a4fa169

Validation

Recorded for 279dbbd8f69e

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 279dbbd, approve

eowca and others added 6 commits November 26, 2026 01:08
Architecture-Review: unchanged; GitHub identities and credential sources stay the same while cache expiry uses elapsed boot time.
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 279dbbd8f69e1f1130c15e683af984375271fa4f, 24.7s: approve (0 critical, 0 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/github.py
return ""
_app_token_cache = (result.stdout.strip(), minted)
token = result.stdout.strip()
if minted is None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: No test covers the path where the host has no suspend-aware clock

The task says hosts without a suspend-aware clock skip cache reuse. In the code, _app_token_clock() returns None when CLOCK_BOOTTIME is missing or clock_gettime raises OSError. app_token() then returns the token for that call only, and _cached_app_token() never reports a cache hit. None of the changed tests exercise this. Each one either patches _app_token_clock to return a number or sets CLOCK_BOOTTIME. If someone later changes the None handling (for example, back to caching with a wall-clock fallback), no test would fail. Suggested fix: add a short test that runs monkeypatch.delattr(github.time, "CLOCK_BOOTTIME", raising=False) and checks that two app_token() calls run the helper twice and leave _app_token_cache empty. A second case could patch clock_gettime to raise OSError and check the same thing.

@eowca
eowca marked this pull request as ready for review November 26, 2026 02:19
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 2217d67 at 02:37 UTC

7 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:31 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1400
  • ✅ Merged 02:37 · 2217d67 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 2217d67 into main Nov 26, 2026
16 checks passed
@eowca
eowca deleted the lean178/1157-token-cache-replacement branch November 26, 2026 02:38
@mergify mergify Bot removed the queued label Nov 26, 2026
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.

Stop reusing expired GitHub App tokens after a clock rollback

1 participant