Skip to content

Add the Associations BQ as its own PartyAssociation aggregate: POST …/Associations/Register, PUT …/{id}/Update and GET …/Retrieve, owner and associate checked on the write side (roadmap 1.11) - #126

Merged
KsiProgramming merged 6 commits into
mainfrom
plan/1.11-party-associations-bq
Nov 8, 2026

Conversation

@KsiProgramming

Copy link
Copy Markdown
Owner

Roadmap phase

Phase: 1.11 Associations BQ
Planning package: specs/2026-11-08-party-associations-bq/

Closes #36

Summary

The directory can now record how one party relates to another (a parent company, a spouse, a power of attorney…), as the Associations Behavior Qualifier. As decided in ADR 0024, an association is its own aggregate, PartyAssociation, with its own stream, version and inline view, so busy parties do not become a concurrency hotspot.

What an association records (ADR 0033, new)

  • The associate: AssociateReference.PartyReference, the entry id of another registered party.
  • AssociateType: the 7 BIAN enum values plus PartyIsThePowerOfAttorneyForParty and PartyReceivesBenefitsFromAParty, which BIAN's description lists. They are read in any case and answered in BIAN spelling, and a record reads "this party type the associate".
  • AssociationValidFromToDate: optional ISO 8601 bounds kept in UTC, From ≤ To, never compared with today. A known ToDateTime is how an association ends.
  • The other BIAN fields (employee, obligations, beneficiary, proxy, product references, InvolvementReference) are refused with party.association-field-not-supported.

Commands (write side)

  • RegisterPartyAssociation: POST /PartyReferenceDataDirectory/{id}/Associations/Register. The handler loads the owner's and the associate's entry streams through IPartyDirectory, never a view (mission principle 5). The checks run in order: owner exists (404 party.party-not-found), not itself (422 party.self-association), associate registered (422 party.associate-not-registered).
  • UpdatePartyAssociation: PUT …/Associations/{associationsid}/Update, a partial update of the type and the period, with If-Match on the association's own version (ADR 0027). The owner and the associate never change: another associate is 422 party.associate-cannot-change.
  • Both acknowledge from the decided state (PartyAssociationAcknowledged).

Query (read side)

  • RetrievePartyAssociation: GET …/Associations/{associationsid}/Retrieve, served from the inline PartyAssociationView, with ETag and 304. Only the owning entry finds it (404 party.association-not-found otherwise).

Plumbing

  • IPartyDirectory / IPartyDirectoryEnquiry cover both stream types. The Marten loaders keep only their own event type, so an association id sent as an associate is a clean 422, not a cast failure.
  • Stable stored event names party_association_registered and party_association_updated, and a second AddInlineView.

Docs: new ADR 0033; ADR 0024 amended (Associations requests paragraph, events, error codes); tech-stack §3.4 tree; demo requests in RimBank.Host.http; roadmap 1.11 ticked.

Definition of done

  • Working code that follows tech-stack.md (naming, dependency rules, business-only names in core)
  • Commands and queries kept separate as described in tech-stack.md §8: commands go through decisions and return acknowledgements, queries read only from read models
  • Unit tests for domain and application logic, including a projection test (Given events → Then view) for every new or changed read model, plus integration tests (Testcontainers) for any adapter touched
  • Every new or changed read model can be rebuilt from the context's own event store
  • Contexts stay loosely coupled as described in tech-stack.md §8.4: no shared or cross-context read models, and no cross-context references except .Subscriptions → .PublishedLanguage
  • Architecture tests green
  • Every new error path returns RFC 9457 Problem Details (on both HTTP and MCP). HTTP only for now: the MCP tools for these operations come in 1.17, as for every BQ so far
  • Every new BIAN operation exposed over HTTP is also exposed as an MCP tool, with a parity test. N/A in this phase: the roadmap schedules the Associations MCP tools and their parity test in 1.16/1.17
  • GitHub Actions CI green (build, test, format, CodeQL)
  • An ADR in docs/adr/ for any significant or BIAN-interpretation decision (ADR 0033 new, ADR 0024 amended)
  • The roadmap checkbox ticked in the same PR

Validation

Run locally on this branch:

  • dotnet restore RimBank.slnx --locked-mode: OK, no lock file change.
  • dotnet build RimBank.slnx -c Release: 0 warnings, 0 errors.
  • dotnet test --solution RimBank.slnx -c Release --no-build: 1,799 passed, 0 failed (incl. Testcontainers and Alba).
  • dotnet format RimBank.slnx --verify-no-changes: exit 0.

From validation.md:

  • Core (RimBank.Core.Tests, Associations/): typed-id contract, PartyRelationshipTypesTests, AssociationValidityPeriodTests, PartyAssociationInputTests, PartyAssociationDecisionTests (every error code), FsCheck PartyAssociationLawsProperties (decider laws, owner and associate never change, an empty Update keeps the state), PartyAssociationViewProjectionTests (Given events → Then view), and handler tests with the in-memory ports.
  • Testcontainers (PartyAssociationRoundTripTests): both stream types in one store, inline read-your-write, stale version → party.version-conflict, idempotent Register (one stream), an association id is never an entry, and RebuildViewAsync restores the view.
  • Alba: Register/Update/Retrieve endpoint tests covering 200 + ETag, 304, and Problem Details for 400 (shared.invalid-identifier, party.association-invalid, party.association-field-not-supported, missing Idempotency-Key, shared.if-match-invalid), 404, 409, 422 and 428.
  • Conformance: PartyReferenceDataDirectoryConformanceTests now lists the three Associations operations.
  • The manual .http demo was optional (not chosen in the interview) and was not run.

Review focus

  • The two relationship types from BIAN's description (ADR 0033), beyond the 7 enum values.
  • The direction convention "owner type associate", and that the inverse is not recorded automatically.
  • No uniqueness of owner/associate/type, and no "active" flag (the period is never compared with today).
  • party.association-already-registered (409): a new code that only a replayed decision can meet. It is added so the decider is complete.
  • One request model (PartyAssociationRequest) for Register and Update, because BIAN's two bodies are the same.
  • Open questions: none.

🤖 Generated with Claude Code

KsiProgramming and others added 6 commits November 8, 2026 18:55
Requirements, plan and validation for Register, Update and Retrieve of party
associations: the associate, the relationship type and the validity period,
with owner and associate checked on the write side (ADR 0024).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…od and decisions (roadmap 1.11)

The Associations BQ as its own aggregate (ADR 0024): PartyAssociationId, the
nine BIAN relationship types, the ISO 8601 validity period, the Register and
Update input readers that refuse unrecorded fields first, and the pure
Register/Update decisions with their decider laws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ociation view (roadmap 1.11)

RegisterPartyAssociation loads the owner's and the associate's entry streams
through IPartyDirectory (never a view), UpdatePartyAssociation checks the
owner and the expected version, and RetrievePartyAssociation reads the new
PartyAssociationView. Both ports gain the association streams and views,
with in-memory adapters and the Marten members.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… view (roadmap 1.11)

Stable stored names for PartyAssociationRegistered and PartyAssociationUpdated,
the inline PartyAssociationView next to the entry view, and Testcontainers
round trips: read-your-write, stale version, idempotent Register, an
association id is never an entry, and a rebuild restores the view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nformance (roadmap 1.11)

POST /PartyReferenceDataDirectory/{id}/Associations/Register, PUT
…/Associations/{associationsid}/Update (If-Match) and GET …/Retrieve (ETag,
304), one BIAN request model for both commands, the three operations in the
conformance list, and the demo requests in RimBank.Host.http.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ee and roadmap tick

ADR 0033 records what a party association records (associate, nine
relationship types, validity period), the refused BIAN fields and the new
error codes; ADR 0024 gains the Associations requests paragraph; the plan
gains an As-built section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KsiProgramming KsiProgramming added stage:1 Roadmap Stage 1: Party Reference Data Directory (first vertical slice) type:feature New business or platform behaviour area:domain Aggregates, decisions, events and invariants (write side) context:party Party / Party Reference Data Directory labels Nov 8, 2026
@KsiProgramming KsiProgramming self-assigned this Nov 8, 2026
@KsiProgramming KsiProgramming added area:api HTTP adapters: Minimal APIs, Problem Details, OpenAPI area:persistence Marten and PostgreSQL adapters, event store area:read-models Views, projections and queries (read side) area:bian-conformance Conformance with the BIAN v14 OpenAPI and AsyncAPI specs labels Nov 8, 2026
@KsiProgramming
KsiProgramming merged commit 5ef34c3 into main Nov 8, 2026
0 of 3 checks passed
@KsiProgramming
KsiProgramming deleted the plan/1.11-party-associations-bq branch November 10, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:api HTTP adapters: Minimal APIs, Problem Details, OpenAPI area:bian-conformance Conformance with the BIAN v14 OpenAPI and AsyncAPI specs area:domain Aggregates, decisions, events and invariants (write side) area:persistence Marten and PostgreSQL adapters, event store area:read-models Views, projections and queries (read side) context:party Party / Party Reference Data Directory stage:1 Roadmap Stage 1: Party Reference Data Directory (first vertical slice) type:feature New business or platform behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.11 Associations BQ

1 participant