Skip to content

Acquire account locks before starting account updates - #1790

Merged
mergify[bot] merged 2 commits into
mainfrom
lean178/1665-home-lock-transaction
Nov 26, 2026
Merged

mergify[bot] merged 2 commits into
mainfrom
lean178/1665-home-lock-transaction

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Acquire account locks before starting account updates

Context and goal

  • Context: Account selection, monitoring, and Codex home synchronization share two existing locks.
  • Problem: A suspended holder can block commands indefinitely. Timing out after a credential refresh or partial home sync leaves account files changed.
  • Goal: Bound acquisition and take the required locks before any account-file writes.

Supersedes #1773. Closes #1665.

Acceptance

  • Acquiring an occupied lock fails with a retry message and leaves account data untouched.
  • Monitor checks acquire the home lock once for the whole sync batch.
  • Codex retry selects and prepares accounts under the home lock before credential refresh or state publication.
  • One held-lock regression covers both locks and the early-write paths.

Validation

Recorded for 8dae2be84589

  • 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, d2a19fe, request_changes

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

Architecture-Review: unchanged; account operations keep their existing locks and acquire them before mutable work.
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 d2a19fe54e35435d16403efaf80acba502e1c21b, 59.5s: request_changes (0 critical, 2 important, 1 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: d569624a0f2d9939c420a8a6326eacdc76e760ddb928818503aa15d960415418

Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread tests/test_ai_accounts.py
lambda: helper.check(quiet=True),
lambda: helper.cmd_add("codex", "new"),
lambda: helper.cmd_pinned_exec("codex", helper.identity("codex", "b"), ["unused"]),
lambda: helper.exhausted("codex", helper.identity("codex", "main"), "model", retry_env={}),

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: Exercise the Codex retry through cmd_run

Calling exhausted directly verifies its lock acquisition, but the regression would still pass if cmd_run reacquired the home lock after selection. The existing successful replay test uses Claude. Add a Codex replay from main to an extra home and assert that the second child receives the selected home and identity with only one home-lock acquisition across selection and replay.

Architecture-Review: unchanged; launch uses the same account locks and each provider is prepared once.
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 8dae2be845895d2c2d884775aec3d04153f0bbf0, 23.9s: approve (0 critical, 0 important, 1 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: 207bf9f1d6ee2a42191cc4f033b3caa66c2800e341a537b8e10a81415087d8f7

Comment thread tests/test_ai_accounts.py
for operation in operations:
with pytest.raises(helper.AccountLockTimeout, match=r"\.codex-sync\.lock is busy"):
operation()
assert elapsed == 360

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: Check the timeout for each lock acquisition

The 360-second total can pass even if one operation exceeds its deadline and another returns early. Capture the fake clock before each operation, including the separate .lock check, and assert that each timeout occurs within the acquisition bound. This also avoids recalculating the total when adding a case.

@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 40fab65 at 10:46 UTC

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

So far

  • ✅ Entered the queue Thu 26 Nov, 10:41 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1817
  • ✅ Merged 10:46 · 40fab65 · 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 40fab65 into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1665-home-lock-transaction branch November 26, 2026 10:46
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