Skip to content

fix(coding-agent): avoid project trust read contention - #1394

Open
JeremyDev87 wants to merge 1 commit into
code-yeongyu:mainfrom
JeremyDev87:fix/project-trust-lock-contention
Open

fix(coding-agent): avoid project trust read contention#1394
JeremyDev87 wants to merge 1 commit into
code-yeongyu:mainfrom
JeremyDev87:fix/project-trust-lock-contention

Conversation

@JeremyDev87

@JeremyDev87 JeremyDev87 commented Sep 5, 2026

Copy link
Copy Markdown

What changed

  • Removed writer-lock acquisition from project trust reads.
  • trust.json writes keep the existing proper-lockfile serialization but publish through a same-directory temp file and an atomic rename.
  • Added a regression test that reads the stored trust decision while a real writer lock is held.

Why

When several Senpi/OMO processes run concurrently, a read-only project trust lookup could contend with the writer lock and kill the process with Lock file is already being held. A completed previous snapshot is safe to read, so there is no reason for a reader to wait on the writer lock.

How

The reader reads the last published snapshot directly and validates it with the existing strict parser. The writer performs read-modify-write inside the lock, writes complete JSON to a temp file, and renames it. The fail-closed semantics for malformed snapshots and for the trust default are unchanged.

Verification

  • npm --prefix packages/coding-agent test -- test/suite/regressions/project-trust-lock-contention.test.ts test/trust-manager.test.ts PASS (3/3)
  • bun run check PASS
  • The source CLI --list-models exits 0 while a real proper-lockfile writer holds trust.json.lock
  • Senpi CLI smoke PASS (8/8), real auth files unchanged

Out of scope

Credential/settings lock policy and the trust decision itself are unchanged. The 18 tool-protocol leak scenarios in the full mock-loop self-test are pre-existing failures unrelated to this path and were left as-is.

Closes #1393


Summary by cubic

Fixes project trust reads retrying the writer lock synchronously and throwing ELOCKED, which could kill concurrent processes. Reads now use the last atomically published trust.json snapshot without acquiring the lock, while writes keep proper-lockfile serialization and publish via temp file plus atomic rename.

  • Adds a regression test that reads trust while a real writer holds the lock.
  • Updates changes.md with the change details and expected merge conflict zones.

Written for commit f20ffa9. Summary will update on new commits.

Review in cubic

프로젝트 신뢰 읽기가 writer lock을 기다리지 않고 마지막 원자적 snapshot을 사용하게 합니다.
쓰기는 기존 lock 직렬화를 유지하며 임시 파일 rename으로 완전한 snapshot만 게시합니다.

Closes code-yeongyu#1393

Co-Authored-By: Claude GPT-5.6 Sol <noreply@anthropic.com>
Ultraworked-With: gpt-5.6-sol
User-Request: OMO 락 오류를 방지하고 발생해도 작업이 중단되지 않게 수정
@JeremyDev87

JeremyDev87 commented Sep 5, 2026

Copy link
Copy Markdown
Author

Requesting review.

  • RED: with a real proper-lockfile writer holding trust.json.lock, the existing ProjectTrustStore.get() raises ELOCKED
  • GREEN: after the lock-free snapshot read, the same scenario returns the stored decision
  • Focused tests 3/3 PASS
  • bun run check PASS
  • The source CLI --list-models exits 0 while the live writer lock is held
  • CLI smoke 8/8 PASS, real auth unchanged
  • Independent code review: APPROVE

The change is limited to removing the reader lock and publishing writes via a same-directory temp file plus rename; the trust decision and malformed-input fail-closed contracts are unchanged.

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.

fix: project trust reads fail on concurrent writer lock

1 participant