Skip to content

Add signing operation coordination infrastructure - #1066

Merged
dtivel merged 5 commits into
mainfrom
dtivel/signing-operation-coordinator
Sep 25, 2026
Merged

dtivel merged 5 commits into
mainfrom
dtivel/signing-operation-coordinator

Conversation

@dtivel

@dtivel dtivel commented Sep 6, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1049.

Summary

  • Add canonical signing-source identities for physical files and recursively nested container entries.
  • Add invocation-scoped coordination so duplicate source claims share one owner operation, result, or failure.
  • Retain immutable snapshots for successful operations and support atomic materialization into multiple layouts.
  • Make the coordinator IAsyncDisposable: disposal rejects new work, waits for every in-flight operation, then deletes the snapshots. Concurrent and repeated DisposeAsync calls share one disposal and see the same outcome, including any cleanup failure.
  • Add protection against an operation awaiting itself.
  • Add tests for identity semantics, concurrency, shared failures, reentrancy, materialization, and disposal and cleanup.

Behavior

This infrastructure is dormant: nothing registers it with dependency injection or calls it from dispatch, signing formats, containers, or the CLI. A later PR in the ClickOnce implementation sequence will activate it.

Testing

  • dotnet build .\sign.sln
  • dotnet test .\sign.sln --no-build

1,060 tests passed and 1 test was skipped.

I also compared the latest NuGet.org release (0.9.1-beta.26431.1) against a Release build of this branch. The standard signing matrix and extra scenarios aimed at this PR behaved the same on both, including signatures, timestamps, which files changed, and temp-file cleanup.

@dtivel
dtivel requested a review from a team as a code owner September 6, 2026 14:49
@dtivel
dtivel changed the base branch from main to dtivel/clickonce-safe-staging September 6, 2026 14:49
@dtivel
dtivel requested review from kartheekp-ms and a lite review from Copilot September 6, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It adds substantial new concurrency coordination and snapshot-lifetime logic that warrants careful human review despite strong unit test coverage.

Review tier: Lite
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity test/​Sign.Core.Test/​TestInfrastructure/​TestDirectory.cs — CreateFile takes a parameter named relativePath but currently does not enforce that it is actually…
Low severity src/​Sign.Core/​SigningOperationCoordinator.cs — The artifact-unavailable detection mixes || and && without parentheses, which is easy to misread…
What changed in this PR

This PR introduces new internal coordination infrastructure in Sign.Core to canonicalize signing-source identities and to deduplicate concurrent signing operations by sharing a single owner operation/result (plus snapshot-based materialization). It also adds focused unit tests to validate identity semantics, concurrency behavior, snapshot materialization, and disposal/cleanup.

Changes:

  • Added SigningSourceIdentity to provide canonical identities for physical paths and recursively nested container entries.
  • Added SigningOperationCoordinator + SigningOperationResult to coordinate same-identity operations and materialize immutable snapshot outputs safely.
  • Added new unit-test coverage (including concurrency and disposal scenarios) and a small temp-directory test helper.
File Description
test/​Sign.Core.Test/​TestInfrastructure/​TestDirectory.cs Adds a disposable temp directory helper for coordinator/identity tests.
test/​Sign.Core.Test/​SigningSourceIdentityTests.cs Adds unit tests for physical path canonicalization and container entry normalization.
test/​Sign.Core.Test/​SigningOperationCoordinatorTests.cs Adds extensive coverage for coordination, shared failures, self-await prevention, snapshot materialization, and cleanup.
src/​Sign.Core/​SigningSourceIdentity.cs Implements canonical, comparable identities for physical files and nested container entries.
src/​Sign.Core/​SigningOperationResult.cs Implements snapshot-based materialization plus snapshot lifetime management and cleanup behavior.
src/​Sign.Core/​SigningOperationCoordinator.cs Implements invocation-scoped deduplication/coordination for same-identity signing operations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dtivel
dtivel force-pushed the dtivel/signing-operation-coordinator branch 3 times, most recently from a259f23 to bff564d Compare September 21, 2026 17:54
Base automatically changed from dtivel/clickonce-safe-staging to main September 21, 2026 18:11
@dtivel
dtivel force-pushed the dtivel/signing-operation-coordinator branch from bff564d to 50744a8 Compare September 21, 2026 18:11
kartheekp-ms
kartheekp-ms previously approved these changes Sep 21, 2026
Comment thread src/Sign.Core/SigningSourceIdentity.cs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Hold the snapshot lifetime lease through the complete owner operation to prevent premature disposal.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
Resolved since last review (2)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review effort: Lite
Findings: None

Resolved since last review (1)

kartheekp-ms
kartheekp-ms previously approved these changes Sep 24, 2026
dtivel and others added 4 commits September 24, 2026 10:41
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: be91288d-5106-4c59-a1fa-c5353dccb828
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: be91288d-5106-4c59-a1fa-c5353dccb828
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: be91288d-5106-4c59-a1fa-c5353dccb828
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: be91288d-5106-4c59-a1fa-c5353dccb828
@dtivel
dtivel force-pushed the dtivel/signing-operation-coordinator branch from 784e94f to e3e9c32 Compare September 24, 2026 17:42
Implement IAsyncDisposable with a single shared disposal task so
concurrent and repeated DisposeAsync calls await the same in-flight
operations and observe the same outcome, including snapshot cleanup
failures. Remove the snapshot leases, move SigningOperationFile to its
own file, and replace the ConcurrentDictionary with a Dictionary that
is only accessed under the coordinator lock.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: be91288d-5106-4c59-a1fa-c5353dccb828
@dtivel

dtivel commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator Author

@kartheekp-ms I pushed 28827e2 with a few simplifications. The main change is to disposal.

  • Disposal: the coordinator now implements IAsyncDisposable. Disposal rejects new work, waits for in-flight operations to finish, then deletes the snapshots. Concurrent or repeated DisposeAsync calls share one disposal, so every caller gets the same result, including any cleanup failure.
  • Leases removed: waiting for operations during disposal makes the leases added in 784e94f unnecessary.
  • Dictionary instead of ConcurrentDictionary: the dictionary is only accessed under the lock, so it doesn't need to be concurrent. Your earlier suggestion still holds: the caller whose candidate is inserted starts the operation. It now uses TryGetValue and Add instead of GetOrAdd.
  • SigningOperationFile is moved to its own file.
  • Documentation: the contract comment now says that operation delegates must not dispose the coordinator.
  • Tests: new tests cover concurrent disposal, disposal waiting for in-flight work, and a cleanup failure that every caller observes.

Nothing calls this code in production yet, so there's no behavior change.

@dtivel
dtivel requested a review from kartheekp-ms September 25, 2026 18:52
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.

3 participants