Skip to content

fix(ops): never abandon an admitted credential, service or login write on cancellation - #91

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

barelyworkingcode merged 3 commits into
mainfrom
fix/87-sibling-ops-commit-race

Conversation

@barelyworkingcode

Copy link
Copy Markdown
Owner

Closes #87

This is the #85 fix applied to the sibling ops. These methods 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:

  • CredentialOps.Mint and Revoke
  • ServiceOps.Register, Create, Update and SaveConfigFile
  • LoginOps.MintBootstrap and RevokePasskey

The worst case: a cancelled Mint stored a credential whose plaintext the caller never received. All eight now use runCommitted (Queue.DoCommitted). CredentialOps and ServiceOps gain the helper; CredentialOps.runQueued, now unused, is removed. Calls that already pass context.Background() are unchanged.

Tests (red first, cmd/relay/ops_commit_race_test.go, -race): one row per method. Each queues the step, cancels the caller, then releases, and asserts the committed result and the stored state. Mint and MintBootstrap pin that the returned secret is the stored one.

Break-and-restore on Mint. Review: round 1 had one minor finding (dead runQueued), fixed; round 2 clean. Full go test ./... passed locally with Relay stopped. Follow-ups: #88 (cancel before start, and a disconnected client), #90 (shared queue helper).

🤖 Generated with Claude Code

barelyworkingcode and others added 3 commits September 26, 2026 00:23
…ller cancellation

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

Refs #87

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

Mint, Revoke, the service writes and the login mint/revoke ran through
runQueued and returned ctx.Err() while the closure could still commit.
A cancelled credential mint stored a credential whose plaintext the
caller never received. They now use runCommitted.

Refs #87

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

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

Copy link
Copy Markdown
Owner Author

Merged by the coordinator under the owner's delegation (credentials): CI test and race green on c5204d9, review round 2 clean.

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.

CredentialOps, ServiceOps and LoginOps have the same queued-closure cancellation race as #85

1 participant