# Local Manifest Publisher (dev profile)

This document describes how to boot the current `sf-manifest-publisher` binary locally and which
environment variables control its bootstrap configuration.

## Environment variables

`sf-manifest-publisher` reads the following environment variables:

- `SF_MANIFEST_PUBLISHER_LISTEN_ADDR`
  - Type: `host:port`
  - Default: `127.0.0.1:50563`
  - Meaning: where the gRPC server listens for:
    - `ManifestPublisherInternalService`
    - `ManifestPublisherSnapshotInternalService`

- `SF_MANIFEST_PUBLISHER_PUBLISHER_EPOCH`
  - Type: `u64`
  - Default: `1`
  - Meaning: fenced publisher epoch for diagnostics/fencing; MUST be > 0.

- `SF_MANIFEST_PUBLISHER_OBJECT_STORE_BACKEND`
  - Type: `string`
  - Default: `in_memory`
  - Meaning: object-store backend for durable manifest/pointer writes.
  - Values:
    - `in_memory` (intended for local smoke tests only)
    - `s3`

- `SF_MANIFEST_PUBLISHER_S3_BUCKET`
  - Type: `string`
  - Default: empty
  - Meaning: S3 bucket name for `s3` backend.

- `SF_MANIFEST_PUBLISHER_S3_REGION`
  - Type: `string`
  - Default: empty
  - Meaning: AWS region for `s3` backend.

- `SF_MANIFEST_PUBLISHER_S3_ENDPOINT_URL`
  - Type: `string` (optional)
  - Default: unset
  - Meaning: custom endpoint URL (for example MinIO).

- `SF_MANIFEST_PUBLISHER_S3_ACCESS_KEY_ID`
  - Type: `string`
  - Default: empty
  - Meaning: access key for `s3` backend.

- `SF_MANIFEST_PUBLISHER_S3_SECRET_ACCESS_KEY`
  - Type: `string`
  - Default: empty
  - Meaning: secret key for `s3` backend.

- `SF_MANIFEST_PUBLISHER_S3_SESSION_TOKEN`
  - Type: `string` (optional)
  - Default: unset
  - Meaning: AWS session token for `s3` backend when using temporary credentials.

- `SF_MANIFEST_PUBLISHER_S3_PATH_STYLE`
  - Type: `bool`
  - Default: `false`
  - Meaning: force S3 path-style addressing (useful for some non-AWS endpoints).

- `SF_MANIFEST_PUBLISHER_MAX_PENDING_REQUESTS_PER_COLLECTION`
  - Type: `usize`
  - Default: `4096`
  - Meaning: per-collection pending request cap enforced at the gRPC boundary.
  - Notes:
    - When the cap is reached, the publisher fails closed with retryable `SF_RATE_LIMITED`.

- `SF_MANIFEST_PUBLISHER_MAX_CONCURRENT_COLLECTIONS`
  - Type: `usize`
  - Default: `32`
  - Meaning: global concurrency cap (limits simultaneous collection publishes).

- `SF_MANIFEST_PUBLISHER_CATALOG_CONTROL_ENDPOINT`
  - Type: `string` (optional)
  - Default: unset
  - Meaning: when set, enables best-effort post-commit CCS head advancement intents via
    internal gRPC (`CatalogControlInternalService`).

- `SF_MANIFEST_PUBLISHER_HEAD_ADVANCE_QUEUE_CAPACITY`
  - Type: `usize`
  - Default: `1024`
  - Meaning: bounded queue capacity for the best-effort CCS head-advance dispatcher.

## Boot locally

From the repository root:

```bash
cd rust
cargo run -p sf-manifest-publisher
```

Or override the listen address:

```bash
cd rust
SF_MANIFEST_PUBLISHER_LISTEN_ADDR=127.0.0.1:50563 cargo run -p sf-manifest-publisher
```

## Example wiring (Visibility Barrier -> Manifest Publisher)

In one terminal, boot Manifest Publisher:

```bash
cd rust
SF_MANIFEST_PUBLISHER_LISTEN_ADDR=127.0.0.1:50563 cargo run -p sf-manifest-publisher
```

In another terminal, boot Visibility Barrier and point it at the publisher:

```bash
cd rust
SF_VISIBILITY_BARRIER_LISTEN_ADDR=127.0.0.1:50562 \
SF_VISIBILITY_BARRIER_MANIFEST_PUBLISHER_ENDPOINT=http://127.0.0.1:50563 \
cargo run -p sf-visibility-barrier
```

Notes:
- In the current bootstrap profile the publisher defaults to an in-memory object store backend, which is
  suitable for local smoke tests but not durable across restarts.
