Skip to content

fix(projects): never abandon an admitted ProjectOps write on caller cancellation - #89

Merged
barelyworkingcode merged 3 commits into
mainfrom
fix/85-project-ops-commit-race
Sep 26, 2026
Merged

barelyworkingcode merged 3 commits into
mainfrom
fix/85-project-ops-commit-race

Conversation

@barelyworkingcode

Copy link
Copy Markdown
Owner

Closes #85

ProjectOps.Create, Update, RotateToken and NarrowForEnrolment read their queued closure's results after it returns, but ran through runQueued (Queue.Do). That returns ctx.Err() on cancellation while the closure may still commit. The effect was a data race on the result variables and a failure reported for a write that happened. Worst of all, a cancelled RotateToken could store a new token the caller never received. All four now use runCommitted (Queue.DoCommitted).

Tests (red first, cmd/relay/project_ops_commit_race_test.go, -race): for each of the four methods, the store write is blocked after the step is queued, the caller is cancelled, and the write is released. The method must then return the committed result, and the store must agree. RotateToken pins that the caller either gets the stored token or storage is unchanged.

Break-and-restore on RotateToken. Review round 1 was clean. Full go test ./... passed locally with Relay stopped. The same bug in sibling ops is #87.

🤖 Generated with Claude Code

barelyworkingcode and others added 3 commits September 26, 2026 00:06
…ancellation

Checkpoint before the fix; --no-verify because the tests are red by design.

Refs #85

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ancellation

Create, Update, RotateToken and NarrowForEnrolment read their queued
closure's results after return, but ran through runQueued, which
returns ctx.Err() while the closure may still commit. A cancelled
RotateToken could store a new token the caller never received. They
now use runCommitted.

Refs #85

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@barelyworkingcode
barelyworkingcode merged commit 299bdde into main Sep 26, 2026
2 checks passed
@barelyworkingcode
barelyworkingcode deleted the fix/85-project-ops-commit-race branch September 26, 2026 07:22
@barelyworkingcode

Copy link
Copy Markdown
Owner Author

Merged by the coordinator under the owner's delegation (tokens): CI test and race green on 70c3325, review round 1 clean; reviewer questions answered in the contract.

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.

ProjectOps.Create/Update race their queued closure when the caller's context is cancelled

1 participant