# GetWorkerByUser

## Overview

Resolves the Worker linked to a given user-management User id, letting downstream attendance commands and queries translate a logged-in User's identity into their HR identity (Worker) before performing HR operations.

## Business Rules

- Returns the Worker whose `userId` matches the given User id; since a User has at most one Worker (1:1), at most one Worker is returned
- Returns NOT_FOUND (rather than an empty/null Worker silently) when the User exists but has never been registered as a Worker — this is the "User without a Worker" case (e.g. an external partner with login-only access)
- Does not validate that the User itself exists in user-management beyond the join; a non-existent User id also resolves to no Worker found

## Process Flow

```mermaid
flowchart TD
    A[Caller requests Worker by userId] --> B{Worker with matching userId exists?}
    B -- No --> C[Reject: WORKER_NOT_FOUND]
    B -- Yes --> D[Return the linked Worker]
```

## External Dependencies

- [workforce::Worker](../model/Worker.md) model — entity being queried
- user-management::User model (cross-module) — the login identity a Worker is resolved from

## Error Scenarios

- **WORKER_NOT_FOUND**: the specified Worker does not exist

## Test Cases

- returns the Worker linked to a User with a registered Worker
- returns NOT_FOUND for a User that has never been registered as a Worker
- returns NOT_FOUND for a non-existent userId
