Skip to content

Bound waits on the ai-accounts state and home locks - #1773

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1665-bounded-waits
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1665-bounded-waits

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bound waits on the ai-accounts state and home locks

Context and goal

  • Context: The optional account helper takes separate state and Codex-home locks when selecting accounts or syncing local files.
  • Problem: A suspended holder can block any subsequent writer indefinitely.
  • Goal: Stop acquisition after the existing 60-second lock wait budget and report which lock is occupied.

Closes #1665

Acceptance

  • Bound acquisition for both existing lock files and preserve their order and scope.
  • Give a clear retry message and avoid account updates when acquisition times out.
  • Exercise both with an actual held lock and fake time.

Validation

Recorded for 3ffc219e232d (not current head) (unverified, run loopzero check)

  • 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

Review

  • primary, codex, 012ea03, request_changes

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

  • delta, codex, 1d70d50, request_changes

Superseded by #1790. #1665 remains tracked by the replacement.

eowca and others added 2 commits November 26, 2026 10:04
Architecture-Review: unchanged; existing account locks keep their order and scope, with bounded acquisition on contention.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; retain main account fixture changes and the held-lock regression.
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 codex on 012ea0370c1a5232b2fac877b6ec2f258359ace8, 45.4s: request_changes (0 critical, 4 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 8765985a44ba3cec46df6c5f29ca96b8127636f5f078302f57fd6068b4d76984

Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread scripts/ai-accounts/ai-accounts Resolved
Architecture-Review: unchanged; retain the existing wait and failure interfaces while covering their boundary cases.
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 delta review by codex on 1d70d501f01740efdb9f39996397de3eef44f772, 241.1s: request_changes (0 critical, 2 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 426e8632600c4d8a9a12691ffab8a13641abe5510460b2890b1849a06e38008f

if candidates:
chosen = min(candidates)[1]
if prepare is not None:
prepare(chosen)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important: A retry can refresh standby credentials before the home lock times out

When cmd_run retries from main to an idle Codex account with a nearly expired token, candidate selection calls model_availability before prepare(chosen). Its check_codex probe can rotate the refresh token and rewrite the standby account’s auth.json. If .codex-sync.lock is held, preparation then times out after the credential update. The new test stubs model_availability, which hides this path. Make candidate probing read-only until the required home lock has been acquired, and cover a refresh-eligible standby with a held lock.

codex_names = accounts("codex")
for name in codex_names:
if name != "main":
sync_codex_home(codex_home(name))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important: A monitor timeout can leave earlier Codex homes modified

check acquires and releases .codex-sync.lock separately for each extra home. With two extra homes, the first sync can move files into ~/.codex and create links before another process takes the lock and stalls the second sync. The command then reports a timeout after changing account files. Acquire the existing home lock once for the sync batch under the state lock, and reuse the per-home sync logic while holding it.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Parking this draft at 1d70d501f01740efdb9f39996397de3eef44f772. The primary and delta rounds are complete, and two delta findings still block delivery.

  • Hold the existing Codex-home lock across the monitor's entire sync batch so contention cannot leave earlier homes modified.
  • Acquire the required home lock before any retry candidate probe that can refresh standby credentials, or keep that probe read-only until the lock is held. Cover a refresh-eligible standby under contention.

Both changes need review coverage on the resulting source head. #1665 stays open. The focused account tests passed on this draft, and the draft has not been queued.

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.

Bound waits on the ai-accounts state and home locks

1 participant