# AppointmentHistory

## Description

AppointmentHistory is the **appointment journal** — an append-only record of every appointment event that changes a Worker's organizational placement: hire, transfer, promotion, secondment, concurrent posting, return, and termination. This is the first-class Japanese-enterprise concept that COMPANY and TeamSpirit Enterprise own and that pure SMB attendance tools lack (issues #7, #13, #16).

Each entry records both the **effective date** (when the appointment takes effect) and the **issue date** (when it was ordered), which lets future-dated appointments be issued and queried ahead of time. Where `Assignment` holds the effective-dated *world state* (who occupies which post now), AppointmentHistory holds the immutable *event log* of the appointments that produced those states — together they reconstruct "the org chart as of any date" and provide the audit trail that replaces the deprecated `audit` module (ADR-013).

## Domain Model Definitions

### Model type

AppendOnly

### Command Definitions

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

- recordAppointment — append an appointment (order) event; may create or change an Assignment on its effective date

### Query Definitions

- getAppointment — retrieve a single appointment event by id
- listAppointmentsByWorker — a Worker's appointment history in chronological order, paginated
- listUpcomingAppointments — future-dated appointments not yet effective (`effectiveDate` in the future), paginated
### Models

- AppointmentHistory

### Invariants

- Append-only: entries are never modified or deleted; a correction is a new compensating entry, preserving the full appointment trail
- Every entry references the Worker and the Assignment it created or changed, and references an `appointmentTypeId` (an AppointmentType catalog entry — HIRE / TRANSFER / PROMOTION / SECONDMENT / CONCURRENT / RETURN / TERMINATION as company-scoped data)
- Every entry carries an `effectiveDate` (when it takes effect) and an `issuedAt` (appointment issue date); `issuedAt` may precede `effectiveDate` (future-dated appointment)
- `appointmentTypeId` references catalog data by id; the AppointmentType's `action` drove the Assignment side effect this entry recorded
- An entry describing a move records both the from-Position and to-Position (from-Position is absent for a CREATE_PRIMARY_ASSIGNMENT such as HIRE; to-Position is absent for an END_ASSIGNMENT such as TERMINATION)

### Relationships

- **Belongs to Worker**: `workerId` references the person appointed
- **References Assignment**: `assignmentId` references the Assignment generation this appointment created or changed
- **References AppointmentType**: `appointmentTypeId` references the AppointmentType catalog entry (its `action` decides the Assignment side effect)
- **References Position (from/to)**: captures the origin and destination posts of a move for org-chart reconstruction
- **Audit source**: together with effective-dated generations and the approval decision log, provides the "who/when/what" trail in lieu of the deprecated audit module (ADR-013)
