# Public onboarding invitation origin

Local source and contract verification, 2026-10-08. No Dev registration, real mailbox delivery, account mutation, push, GitHub mutation, or deployment occurred.

## Result and ownership

The public onboarding response now exposes the invitation's persisted agency allocation origin. Initial resolve and pending-2FA resume use the same nullable DTO mapping. The field is navigation context, never authorization; no grants, database schema, Keycloak, authentication policy, current-agency availability calculation, or tracking milestones changed.

- Worktree: `_worktrees/userservice-1156-invite-origin`
- Branch: `fix/1156-public-onboarding-invite-origin`
- Refreshed base: `803970c97fec74ce2141f5ce8a59fd29cbe1c9f9`
- Validated head: `40ac9a18f2fb4444eb25e19bd0fceaa07055a8e9`
- Working tree: clean after commit
- Parent: ORISO-Admin#1026; delivery child: ORISO-Admin#1156
- Root owns independent review, integration, PR publication, and backend-first delivery coordination.

## Changed paths

```text
src/main/java/de/caritas/cob/userservice/api/adapters/web/controller/TenantAdminOnboardingController.java
src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/AgencyAdminOnboardingWizardIT.java
src/test/java/de/caritas/cob/userservice/api/service/accountinvite/AccountInviteServiceTest.java
```

Production change: eight additive lines declaring nullable `agencyIdAllocationMode` and mapping the persisted enum directly to its wire string. Tests reuse existing public seams.

## Sanitized contract trace

The first four rows use real public HTTP resolve and registration/resume services against the isolated testing-profile H2 database. Existing external AgencyService/Keycloak boundaries use the established test fixtures. The resend column uses the existing public service seam with mocked repository and mail boundaries; it is not evidence of a received mail or a subsequent HTTP resolve of that replacement.

| Case | Persisted origin | Initial resolve origin | Pending-2FA resolve origin | agencyExists initial / resume | Purpose initial / resume | Resend replacement origin | Result |
|---|---|---|---|---|---|---|---|
| New auto-reserved centre | AUTO | AUTO | AUTO | false / true | INVITE / INVITE | AUTO | PASS |
| New manually reserved centre | MANUAL | MANUAL | MANUAL | false / true | INVITE / INVITE | MANUAL | PASS |
| Joining an existing centre | EXISTING | EXISTING | EXISTING | true / true | INVITE / INVITE | EXISTING | PASS |
| Legacy unknown origin | null | null | null | not separately asserted / not separately asserted | INVITE on resume; initial purpose not separately asserted | null | PASS |
| Existing-account setup retains purpose | MANUAL | MANUAL | Not registered in this case | not separately asserted / not exercised | EXISTING_ACCOUNT_SETUP / not exercised | Separate selected-history setup regression passes | PASS |

The first two rows demonstrate why `agencyExists` cannot replace persisted origin: registration/resume changes the availability result while origin stays AUTO or MANUAL. The setup-purpose row keeps purpose distinct from allocation mode, so consumers can exclude setup links from new-centre continuation.

No raw Spring logs, recipient identifiers, passwords, invitation tokens, OTPs, or setup material are included in this trace.

## RED and GREEN evidence

1. RED: existing persisted-centre HTTP resolve returned status 200 but omitted `$.agencyIdAllocationMode`; the new assertion failed with `No value at JSON path`. One test, one assertion failure, zero test errors.
2. Minimal GREEN: same HTTP case passed after the DTO addition. One test, zero failures/errors/skips; Maven BUILD SUCCESS.
3. The first consolidated attempt stopped before tests at the format gate. A scoped apply pattern had matched no files; two formatting differences were corrected. Whole-project `spotless:check` then passed across 1823 Java files, with zero changes needed. No gate was suppressed.
4. Final GREEN and package: 51 tests, zero failures/errors/skips. HTTP wizard 17; controller contract 28; selected resend/setup service 6. Jar packaging and Spring Boot repackaging passed. Total final invocation 11:51 minutes.

The final invocation reused the unchanged OpenAPI models generated successfully in the earlier attempt. The plugin's `codegen.skip` property was verified in its local plugin descriptor. Production and test compilation, formatting, selected tests, and packaging all still ran. Fresh CI must run its normal generation/build process; this is local evidence.

**For developers — exact local gate command:**

```bash
JAVA_HOME=$(/usr/libexec/java_home -v 21) ./mvnw -B -Dcodegen.skip=true '-Dtest=AgencyAdminOnboardingWizardIT,TenantAdminOnboardingControllerTest,AccountInviteServiceTest#resendInvite_Should_PreserveTheAgencyOriginOnTheReplacementInvite+resendInvite_Should_SupersedeOldInviteAndCreateNewEmailSentInvite+genericHistoryResendDelegatesOnlyTheScopedSelectedSetupRow' -Dskip.unit-tests=false -Dskip.integration-tests=true package
JAVA_HOME=$(/usr/libexec/java_home -v 21) ./mvnw -B spotless:check
```

Read exact totals from the three final Surefire XML reports. Raw build logs remain local and must not be attached publicly. The broader repository test suite and live Dev acceptance were not run by this worker.

## Commit scope

```text
40ac9a18f fix: expose persisted agency origin in onboarding resolve
 .../TenantAdminOnboardingController.java           |  8 ++
 .../controller/AgencyAdminOnboardingWizardIT.java  | 93 +++++++++++++++++++++-
 .../accountinvite/AccountInviteServiceTest.java    | 39 +++++++++
 3 files changed, 138 insertions(+), 2 deletions(-)
```

Commit attribution is truthful: plain English with `Refs OpenResilienceInitiative/ORISO-Admin#1156`; no stale Claude authorship footer. Current dev targeting takes precedence over the legacy pre-dev reference.
