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

무엇을 변경했습니까

  • 프로젝트 신뢰 읽기에서 writer lock 획득을 제거했습니다.
  • trust.json 쓰기는 기존 proper-lockfile 직렬화를 유지하면서 동일 디렉터리 임시 파일과 atomic rename으로 게시합니다.
  • 실제 writer lock이 유지되는 동안 저장된 신뢰 결정을 읽는 회귀 테스트를 추가했습니다.

왜 변경했습니까

여러 Senpi/OMO 프로세스가 동시에 실행될 때 읽기 전용 프로젝트 신뢰 조회가 writer lock과 경합하여 Lock file is already being held로 프로세스를 종료시킬 수 있었습니다. 완성된 이전 snapshot은 안전하게 읽을 수 있으므로 reader가 writer lock을 기다릴 이유가 없습니다.

어떻게 구현했습니까

reader는 마지막 게시 snapshot을 직접 읽고 기존 strict parser로 검증합니다. writer는 lock 안에서 read-modify-write를 수행하고 완전한 JSON을 임시 파일에 쓴 뒤 rename합니다. malformed snapshot과 신뢰 기본값의 fail-closed 의미는 바꾸지 않았습니다.

어떻게 검증했습니까

  • 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
  • 실제 proper-lockfile writer가 trust.json.lock을 점유한 동안 source CLI --list-models exit 0
  • Senpi CLI smoke PASS (8/8), 실제 auth 파일 unchanged

제외 범위

credential/settings lock 정책과 trust decision 자체는 변경하지 않았습니다. 별도 mock-loop 전체 self-test의 tool-protocol leak 시나리오 18개는 이 경로와 무관한 기존 실패로 남겼습니다.

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

Copy link
Copy Markdown
Author

검토를 요청드립니다.

  • RED: 실제 proper-lockfile writer가 trust.json.lock을 점유한 동안 기존 ProjectTrustStore.get()ELOCKED 발생
  • GREEN: lock-free snapshot read 후 동일 시나리오에서 저장된 decision 반환
  • focused tests 3/3 PASS
  • bun run check PASS
  • source CLI --list-models가 live writer lock 중 exit 0
  • CLI smoke 8/8 PASS, real auth unchanged
  • 독립 코드 리뷰 APPROVE

변경은 reader lock 제거와 writer의 same-directory temp+rename 게시로 제한하며 trust decision 및 malformed fail-closed 계약은 유지합니다.

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