Every synced entity type builds its cluster envelopes in one place, for live sync and for backfill #331

Closed
opened 2026-11-05 20:48:50 -05:00 by claude · 1 comment
Owner

Part of epic #59.

  • Kind: feature
  • Area: dns
  • Priority: medium
  • Milestone: Post-release fixes
  • Agent: coder
  • Depends on: #330
  • Decisions: Q-CL-4 (plaintext only inside the cluster channel, re-encrypted per node) (#260)

Why

A backfill must send exactly what live sync sends, secrets included, and must apply the same filters (local-list entries only, global rewrites only).

What changes

New IClusterConfigSyncSource in Server.Core, one source per entity type plus tombstones in Ninlil.Dns.Server.ClusterSync, and the live subscribers refactored to use the same builder. See the work package detail below (59-2.

Acceptance

  • The nine tests listed in design 59-2 pass in src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests. BuildEnvelope_ForEachEntityType_MatchesTheLiveSubscribersEnvelope proves the wire is unchanged.
  • dotnet test Ninlil.slnx -p:NinlilSkipAngularBuild=true passes.
  • Every item in Before you finish that applies is done.

Source

ClusterConfigSyncSubscriberBase.cs:74-143, UserClusterSyncEventSubscriber.cs:77-191, RewriteClusterSyncEventSubscriber.cs:57-68, FilterListEntryClusterConfigSyncApplier.cs:11-16, b14-design.md §2.10.

Work package detail

  • Goal: every synced entity type can list and build its envelopes. The live subscribers use the same builder.
  • Interface (new, Ninlil.Dns.Server.Core/ClusterSync/IClusterConfigSyncSource.cs):
    public interface IClusterConfigSyncSource
    {
        string EntityType { get; }          // equals the applier's EntityType; "Tombstone" for the tombstone source
        int BackfillStage { get; }          // 0 roles and filter lists, 1 users and entries, 2 the rest, 3 tombstones
        IAsyncEnumerable<ClusterConfigSyncEnvelope> ReadBackfillAsync(CancellationToken stoppingToken);
    }
    
  • Files (Ninlil.Dns.Server.ClusterSync):
    • Shared/ClusterConfigSyncSourceBase<TEntity>: id snapshot through ListIdsAsync(predicate), then GetByIdAsync per id, and BuildEnvelope(entity, ownNodeId) using the stamping rule at ClusterConfigSyncSubscriberBase.cs:121-130.
    • One source per type in Filtering/, AccessControl/, Rewrites/, Forwarding/ and Identity/:
      • Entries: only lists with Source == Local, a snapshot per local list.
      • Rewrites: predicate ClientId == null && ClientGroupId == null.
      • Users and roles: build the payload exactly as their subscribers do today.
    • Shared/TombstoneClusterConfigSyncSource.cs: one deletion envelope per tombstone whose EntityType is a registered applier's type, stamped with the tombstone's time and origin.
    • Refactor ClusterConfigSyncSubscriberBase and the user and role subscribers so they build through the source's builder.
    • Register the sources in ServiceCollectionClusterSyncExtension.
  • Constraints:
    • The envelope bytes for a live change must stay identical (regression test).
    • A user whose secret fails to decrypt is skipped with a Warning naming the user id (OD-4).
    • Update the summaries (subscriber base, user subscriber) and follow the comment standard.
  • Acceptance (fail first, src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests):
    • ReadBackfillAsync_ForFilterLists_YieldsOneEnvelopePerList
    • ReadBackfillAsync_ForFilterListEntries_YieldsOnlyEntriesOfLocalLists
    • ReadBackfillAsync_ForRewrites_SkipsClientAndGroupScopedRewrites
    • ReadBackfillAsync_ForUsers_SendsDecryptedSecretsAndNoCiphertext
    • ReadBackfillAsync_ForAUserWhoseSecretCannotBeDecrypted_SkipsThatUserAndContinues
    • ReadBackfillAsync_ForARowWithoutAnOriginatingNode_StampsThisNodesId
    • ReadBackfillAsync_ForARowDeletedAfterTheSnapshot_SkipsIt
    • ReadBackfillAsync_ForTombstones_YieldsADeletionEnvelopeWithTheTombstonesTimestamp
    • BuildEnvelope_ForEachEntityType_MatchesTheLiveSubscribersEnvelope
    • The existing subscriber tests stay green.
  • Non-goals: settings, sending, triggering.
  • Gate:
    • dotnet test src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests
    • dotnet test src/dotnet/tests/Ninlil.Web.Tests
    • Server.Core changed, so also dotnet test Ninlil.slnx -p:NinlilSkipAngularBuild=true.
Part of epic #59. - **Kind:** feature - **Area:** dns - **Priority:** medium - **Milestone:** Post-release fixes - **Agent:** coder - **Depends on:** #330 - **Decisions:** Q-CL-4 (plaintext only inside the cluster channel, re-encrypted per node) (#260) ### Why A backfill must send exactly what live sync sends, secrets included, and must apply the same filters (local-list entries only, global rewrites only). ### What changes New `IClusterConfigSyncSource` in Server.Core, one source per entity type plus tombstones in `Ninlil.Dns.Server.ClusterSync`, and the live subscribers refactored to use the same builder. See the work package detail below (59-2. ### Acceptance - [ ] The nine tests listed in design 59-2 pass in `src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests`. `BuildEnvelope_ForEachEntityType_MatchesTheLiveSubscribersEnvelope` proves the wire is unchanged. - [ ] `dotnet test Ninlil.slnx -p:NinlilSkipAngularBuild=true` passes. - [ ] Every item in [Before you finish](https://git.lantea.one/lantea-one/ninlil/src/branch/main/AGENTS.md#before-you-finish) that applies is done. ### Source `ClusterConfigSyncSubscriberBase.cs:74-143`, `UserClusterSyncEventSubscriber.cs:77-191`, `RewriteClusterSyncEventSubscriber.cs:57-68`, `FilterListEntryClusterConfigSyncApplier.cs:11-16`, `b14-design.md` §2.10. ### Work package detail - **Goal:** every synced entity type can list and build its envelopes. The live subscribers use the same builder. - **Interface** (new, `Ninlil.Dns.Server.Core/ClusterSync/IClusterConfigSyncSource.cs`): ```csharp public interface IClusterConfigSyncSource { string EntityType { get; } // equals the applier's EntityType; "Tombstone" for the tombstone source int BackfillStage { get; } // 0 roles and filter lists, 1 users and entries, 2 the rest, 3 tombstones IAsyncEnumerable<ClusterConfigSyncEnvelope> ReadBackfillAsync(CancellationToken stoppingToken); } ``` - **Files** (`Ninlil.Dns.Server.ClusterSync`): - `Shared/ClusterConfigSyncSourceBase<TEntity>`: id snapshot through `ListIdsAsync(predicate)`, then `GetByIdAsync` per id, and `BuildEnvelope(entity, ownNodeId)` using the stamping rule at `ClusterConfigSyncSubscriberBase.cs:121-130`. - One source per type in `Filtering/`, `AccessControl/`, `Rewrites/`, `Forwarding/` and `Identity/`: - Entries: only lists with `Source == Local`, a snapshot per local list. - Rewrites: predicate `ClientId == null && ClientGroupId == null`. - Users and roles: build the payload exactly as their subscribers do today. - `Shared/TombstoneClusterConfigSyncSource.cs`: one deletion envelope per tombstone whose `EntityType` is a registered applier's type, stamped with the tombstone's time and origin. - Refactor `ClusterConfigSyncSubscriberBase` and the user and role subscribers so they build through the source's builder. - Register the sources in `ServiceCollectionClusterSyncExtension`. - **Constraints:** - The envelope bytes for a live change must stay identical (regression test). - A user whose secret fails to decrypt is skipped with a Warning naming the user id (OD-4). - Update the summaries (subscriber base, user subscriber) and follow the comment standard. - **Acceptance (fail first, `src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests`):** - `ReadBackfillAsync_ForFilterLists_YieldsOneEnvelopePerList` - `ReadBackfillAsync_ForFilterListEntries_YieldsOnlyEntriesOfLocalLists` - `ReadBackfillAsync_ForRewrites_SkipsClientAndGroupScopedRewrites` - `ReadBackfillAsync_ForUsers_SendsDecryptedSecretsAndNoCiphertext` - `ReadBackfillAsync_ForAUserWhoseSecretCannotBeDecrypted_SkipsThatUserAndContinues` - `ReadBackfillAsync_ForARowWithoutAnOriginatingNode_StampsThisNodesId` - `ReadBackfillAsync_ForARowDeletedAfterTheSnapshot_SkipsIt` - `ReadBackfillAsync_ForTombstones_YieldsADeletionEnvelopeWithTheTombstonesTimestamp` - `BuildEnvelope_ForEachEntityType_MatchesTheLiveSubscribersEnvelope` - The existing subscriber tests stay green. - **Non-goals:** settings, sending, triggering. - **Gate:** - `dotnet test src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests` - `dotnet test src/dotnet/tests/Ninlil.Web.Tests` - Server.Core changed, so also `dotnet test Ninlil.slnx -p:NinlilSkipAngularBuild=true`.
Author
Owner

Done on feature/59-cluster-join-backfill (d446fb9c, d1103ba4); verified (whole solution green with Docker; live wire output pinned and unchanged). Closes when the epic merges into develop.

Done on `feature/59-cluster-join-backfill` (d446fb9c, d1103ba4); verified (whole solution green with Docker; live wire output pinned and unchanged). Closes when the epic merges into develop.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#331
No description provided.