# Offline Host State Contract

This file defines the host-local state layout for offline deployments.

## Host Root

```text
~/nexuscrm-deployment/offline/envs/
```

## Shared Nginx State

```text
~/nexuscrm-deployment/offline/envs/nginx/conf.d/<env>.conf
```

For blue-green environments, the rendered nginx conf is the routing authority.

## Environment Shared State

```text
~/nexuscrm-deployment/offline/envs/<env>/shared/deploy/
  deploy.lock
  last-successful-deploy
  last-known-good-target
  history/
```

## Runtime Target State

For blue-green:

```text
~/nexuscrm-deployment/offline/envs/<env>/<slot>/
  env/runtime.env
  run/
  logs/
  .runtime/
  artifacts/deploys/<deploy-id>/
```

For single-slot:

```text
~/nexuscrm-deployment/offline/envs/<env>/
  env/runtime.env
  run/
  logs/
  .runtime/
  artifacts/deploys/<deploy-id>/
```

## Rules

1. live nginx conf is authoritative for blue-green routing state
2. deploy scripts must infer the active slot from nginx root and backend port mapping
3. deploy artifacts must be written into the target-local artifact directory
4. blue-green service authority must use only slot-specific unit names such as `nexuscrm-staging-blue-backend.service`
5. single-slot service authority must use the environment-level unit name such as `nexuscrm-staging-backend.service`
6. legacy unit names that are not part of the configured topology are contract violations
