# WorkerEmployment

## Description

WorkerEmployment is the **effective-dated employment relationship** between a `Worker` and a legal entity — the `organization` module's `Company`. It answers "employed by whom, as what, from when to when" and carries the attributes that change over an employment's life: employment type (an EmploymentType catalog entry referenced by `employmentTypeId`), work regime (a WorkRegime catalog entry referenced by `workRegimeId`), hire date, and termination date.

Following the effective-dating standard (ADR-013), a WorkerEmployment is a **generation series**: changing an attribute (e.g. converting a contractor to full-time) closes the current generation (`effectiveEnd` = day before the change) and inserts a new generation, rather than overwriting. Multiple generations sharing one `versionOf` describe one continuous employment; a Worker may also hold multiple distinct employments (re-hire after termination, or concurrent employment across Companies — the seam that makes future multi-legal-entity support possible, ADR-018).

This is the Oracle "Work Relationship" tier (issue #7): the layer between the immutable person (Worker) and the concrete post (Assignment).

## Domain Model Definitions

### Model type

Standard

### Command Definitions

Command docs are out of scope for this design phase (ADR-011). Anticipated commands:

- createWorkerEmployment — open an employment relationship for a Worker at a Company (initial generation)
- updateWorkerEmployment — record an attribute change as a new effective-dated generation (closes prior generation)
- terminateWorkerEmployment — set the termination date and close the current generation

### Query Definitions

- getWorkerEmployment — retrieve a single employment generation by id
- listWorkerEmploymentsByWorker — all employment generations for a Worker (history), paginated
- listActiveWorkerEmployments — current generations (`effectiveEnd IS NULL`, not terminated) as of today, paginated
### Models

- WorkerEmployment

### Invariants

- Effective-dated per ADR-013: each record carries `effectiveStart`, nullable `effectiveEnd`, and `versionOf`; generations sharing a `versionOf` must not overlap in their effective ranges
- The current generation of an employment has `effectiveEnd IS NULL`; a change never overwrites a generation — it closes the prior one and inserts a new one
- Every WorkerEmployment references exactly one Worker and exactly one organization Company (legal entity)
- `employmentTypeId` references an EmploymentType catalog entry belonging to the same Company; adding a new employment type is catalog data, not a code change or fixed enum
- `workRegimeId` references a WorkRegime catalog entry belonging to the same Company; there is no fixed enum, so ordinary work and any custom regime can be expressed and the consuming app owns the catalog
- A future-dated generation (`effectiveStart` in the future) is a scheduled change and must not be treated as the current employment until its start date
- Termination is expressed by a termination date on the closing generation; a terminated employment has no open (`effectiveEnd IS NULL`) generation beyond the termination date

### Relationships

- **Belongs to Worker**: `workerId` references the person employed
- **Belongs to EmploymentType**: `employmentTypeId` references the employment type catalog entry
- **Belongs to WorkRegime**: `workRegimeId` references the work regime catalog entry
- **References Company** (organization, cross-module): `companyId` references the employing legal entity (LegalEntity); root scope seam for future multi-entity support (ADR-018)
- **Has many Assignment**: an employment is assigned to one or more Positions over time (Assignment generations reference this employment)
- **Drives eligibility**: work-rules EligibilityRule and WorkRule resolution read the employmentTypeId / workRegimeId from the employment generation effective on the calculated date
