fix(coding-agent): avoid project trust read contention - #1394
Open
JeremyDev87 wants to merge 1 commit into
Open
Conversation
프로젝트 신뢰 읽기가 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 락 오류를 방지하고 발생해도 작업이 중단되지 않게 수정
Author
|
Requesting review.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
trust.jsonwrites keep the existing proper-lockfile serialization but publish through a same-directory temp file and an atomic rename.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.tsPASS (3/3)bun run checkPASS--list-modelsexits 0 while a real proper-lockfile writer holdstrust.json.lockOut 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 publishedtrust.jsonsnapshot without acquiring the lock, while writes keep proper-lockfile serialization and publish via temp file plus atomic rename.changes.mdwith the change details and expected merge conflict zones.Written for commit f20ffa9. Summary will update on new commits.