Skip to content

Record the BankRelations BQ: a typed relation to a bank employee or unit checked on the write side, with its dates and status (roadmap 1.12) - #128

Merged
KsiProgramming merged 6 commits into
mainfrom
plan/1.12-party-bank-relations-bq
Nov 8, 2026
Merged

KsiProgramming merged 6 commits into
mainfrom
plan/1.12-party-bank-relations-bq

Conversation

@KsiProgramming

Copy link
Copy Markdown
Owner

Roadmap phase

Phase: 1.12 BankRelations BQ
Planning package: specs/2026-11-08-party-bank-relations-bq/

Closes #37

Summary

Records the party's relationship with the bank: the last Behavior Qualifier of Party Reference Data Directory. As ADR 0024 decided, BankRelations is a singleton entity of the entry aggregate, so it uses the entry's stream, version (ETag / If-Match) and inline view.

What is recorded (ADR 0035, the core slice chosen in the planning interview):

  • BankRelationType as a closed list: RelationshipManager and AccountOfficer (a bank employee), ServicingBranch and ServicingBusinessUnit (a unit of the bank). BIAN gives free text with one example.
  • BusinessUnitEmployeeReference.PartyReference: another registered entry of this directory, a person for an employee's role and an organisation for a unit's. It is checked on the write side, the same guarantee as the Associations (ADR 0033) and the Reference corporate references (ADR 0034).
  • BankRelationReference: RelationshipStartDate and RelationshipEndDate (stored as UTC, the end not before the start) and RelationshipLifecycleStatus.StatusDescription (Active, Suspended or Ended).
  • Every other BIAN part (InvolvementReference, RelationshipType, RelationshipValidityPeriod, RelationshipIdentification, the other Datetime and Status parts) is refused with 400 party.bank-relations-field-not-supported, naming each path.

Command side. UpdateBankRelations is a partial update, as in 1.9–1.21: an omitted value keeps its value, and a blank value or empty object clears it. The handler loads the entry. When the Update sets the employee or unit, or changes the type it must fit, the handler also loads that entry through IPartyDirectory, never through a view. The pure Decide then checks the rules on the resulting BankRelations:

  • a reference without a type is 400 party.bank-relations-invalid, and so is an end before the start;
  • then 422 party.self-reference, party.referenced-party-not-registered and party.referenced-party-type-mismatch, which reuse the ADR 0034 codes.

The new event is BankRelationsUpdated (stored as party_bank_relations_updated), carrying the full resulting BankRelations. The response is built from the acknowledgement.

Query side. RetrieveBankRelations reads the new nullable BankRelations section of the inline PartyReferenceDataDirectoryEntryView (ETag, 304). Streams and views written before 1.12 still load, fold and rebuild.

HTTP. PUT …/BankRelations/{bankrelationsid}/Update and GET …/Retrieve in RimBank.Api/Party/PartyReferenceDataDirectory/BankRelations/, with a demo block in RimBank.Host.http.

Small refactor. PartyReferenceDates.TryReadUtcInstant reads a date or a date-time as UTC, and AssociationValidityPeriod now uses it too, with no change in behaviour.

Docs. New ADR 0035. ADR 0024 is amended with the "BankRelations requests (1.12)" paragraph, the events table and the error codes table. Tech-stack §3.4 now shows the BankRelations/ tree, and roadmap 1.12 is 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). On HTTP, every new error path is tested; there is no MCP tool for BankRelations yet (roadmap 1.17)
  • Every new BIAN operation exposed over HTTP is also exposed as an MCP tool, with a parity test. N/A: the MCP tools for Update and every BQ are roadmap 1.17, as for 1.9–1.21. Until then, HTTP and MCP do not match for these two operations
  • GitHub Actions CI green (build, test, format, CodeQL)
  • An ADR in docs/adr/ for any significant or BIAN-interpretation decision (ADR 0035, ADR 0024 amended)
  • The roadmap checkbox ticked in the same PR

Validation

Local runs on the 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,953 passed, 0 failed (exit 0).
  • dotnet format RimBank.slnx --verify-no-changes: exit 0.

What the new tests cover (validation.md):

  • Core (Shouldly, FsCheck), 84 tests:
    • BankRelationTypesTests (types, statuses, and which party type each type references);
    • BankRelationsChangesTests (refused paths first, each invalid path named, an empty BankRelationReference clears);
    • BankRelationsDecisionTests (every error code; set, keep and clear; a new type is checked against the kept reference);
    • BankRelationsPartialUpdateProperties (the partial-update laws);
    • UpdateBankRelationsHandlerTests (check order; a kept reference is not reloaded; an association id given as the employee is "not registered");
    • RetrieveBankRelationsHandlerTests;
    • BankRelationsViewProjectionTests (Given events → Then view, including a pre-1.12 stream and view).
  • PostgreSQL (Testcontainers), BankRelationsRoundTripTests, 8 tests: inline read-your-write, the stable event name with enums stored by name, a type mismatch refused on the write side, a stale version gives 409, idempotent replay appends once, and RebuildViewAsync restores the view.
  • HTTP (Alba):
    • UpdateBankRelationsEndpointTests and RetrieveBankRelationsEndpointTests: 200 with ETag and 304; 400 for an invalid identifier, invalid values and refused parts; 404 for the party and for the BankRelations id; 409; 428; a missing Idempotency-Key; and 422 for a self-reference, an unregistered party, an association id and a type mismatch. Every error is application/problem+json;
    • BankRelationsLogPrivacyTests: no submitted value is logged on success, refusal, 422, 409 or Retrieve.
  • Conformance: PartyReferenceDataDirectoryConformanceTests now lists BankRelations/Update (PUT, command) and BankRelations/Retrieve (GET, query), and is green.

Not run yet: the manual .http demo against the Aspire host (validation.md, "Manual / demo checks"). The "BankRelations BQ (roadmap 1.12, ADR 0035)" block in src/RimBank.Host/RimBank.Host.http is ready for it. Its output will be added here once it has run.

Review focus

  • The four relation types and their party-type rule (ADR 0035). BIAN gives no list. Are RelationshipManager, AccountOfficer, ServicingBranch and ServicingBusinessUnit the right closed set?
  • Reusing the ADR 0034 error codes for the 422s, instead of adding BankRelations-specific ones. The detail starts with the BIAN path.
  • Lifecycle status read from StatusDescription, with no rule linking it to the dates (Ended does not need an end date).
  • One relationship per party. BIAN's body is one object, and ADR 0024 makes this BQ a singleton. Several bank contacts per party would need its own aggregate and a later ADR.
  • Accepted drift. If the referenced entry later changes its own party type, it is not checked again, for the same reason as in ADR 0034.

🤖 Generated with Claude Code

KsiProgramming and others added 6 commits November 8, 2026 20:38
…employee or unit reference, dates and status

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cked employee or unit, dates and status (roadmap 1.12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… section of the entry view (roadmap 1.12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… trips and a view rebuild (roadmap 1.12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Problem Details, conformance and a log-privacy test (roadmap 1.12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1.12

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) area:read-models Views, projections and queries (read side) area:api HTTP adapters: Minimal APIs, Problem Details, OpenAPI area:persistence Marten and PostgreSQL adapters, event store context:party Party / Party Reference Data Directory labels Nov 8, 2026
@KsiProgramming KsiProgramming self-assigned this Nov 8, 2026
@KsiProgramming
KsiProgramming merged commit f74af5b into main Nov 8, 2026
0 of 3 checks passed
@KsiProgramming
KsiProgramming deleted the plan/1.12-party-bank-relations-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: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.12 BankRelations BQ

1 participant