Skip to content

Keep Codex refresh readable on the bound auth inode - #1871

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1542-preserve-refresh-json
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1542-preserve-refresh-json

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep Codex refresh readable on the bound auth inode

  • Goal: Keep refreshed auth JSON readable if the switcher stops immediately after the write.
  • Problem: A shorter refresh overwrites the start of the auth file and leaves old bytes until a separate truncate.
  • Context: Closes Preserve a complete Codex auth file if refresh is interrupted #1542. A running reviewer can hold a bind mount of the original auth inode.

Acceptance

  • Keep the bound inode. A completed refresh write must leave valid JSON even when interrupted before any subsequent cleanup.
  • Exercise that boundary with synthetic credentials and confirm the already-open file reads the refreshed tokens and retains the same inode.

Notes

The change touches only the refresh function and extends the existing binding test. No token selection or refresh exchange behavior changes.

Base

main @ 691a906

Validation

Recorded for 83dc6d9db9e2

  • 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, 83dc6d9, approve

Architecture-Review: unchanged; refresh preserves the existing auth inode, credential identity and token exchange.
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 83dc6d9db9e27f0db0ea1d3b3472ce4a9823dbef, 21.0s: 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.

# the completed write is readable without a second, interruptible truncate.
payload = (json.dumps(auth, indent=2) + "\n").encode("utf-8")
with auth_file.open("r+b", buffering=0) as fh:
payload = payload.ljust(os.fstat(fh.fileno()).st_size, b" ")

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: Auth file never shrinks after a refresh, so it keeps its largest size

Because ljust(st_size) pads every refresh to the current file size, auth.json stays at the largest size it has ever had, and trailing spaces build up. This is safe: json.loads in identity() and the other readers, and Codex's serde_json, all accept trailing whitespace, and the padding overwrites the old token bytes, so nothing stale is left behind. The size is also capped by the largest payload written. Still, a future reader that compares raw bytes or checks the length would see unexpected padding. A short note in the comment saying the size is intentionally monotonic would make this clear. Optionally, the test could also cover a refresh whose payload is longer than the existing file, so the extend path is exercised too.

@eowca
eowca marked this pull request as ready for review November 26, 2026 12:22
@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 26bf82a at 12:28 UTC

6 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 12:22 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1879
  • ✅ Merged 12:28 · 26bf82a · 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 26bf82a into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1542-preserve-refresh-json branch November 26, 2026 12:29
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.

Preserve a complete Codex auth file if refresh is interrupted

1 participant