# Tyr 0.30 Latchflo managed-mode example.
version: 1

server:
  port: 8787

upstreams:
  openai:
    baseUrl: http://mock-provider:9000

timeouts:
  responseHeadersMs: 30000
  streamIdleMs: 30000
  clientStallMs: 30000

shutdown:
  drainTimeoutMs: 30000

priority:
  trustHeader: false

telemetry:
  metrics:
    enabled: true
  audit:
    enabled: true

pools:
  - name: openai-primary
    modelPrefixes: [gpt, o1, o3, o4]
    estimatorModel: gpt-4o
    # Managed pools must begin closed. Latchflo's first odd revision opens them.
    maxConcurrent: 0
    maxQueue: 0
    limitsRevision: 0
    admissionMode: enforce
    defaultOutputReservation: 4096
    # Optional. Without it a lower grant waits for running requests to finish.
    # With it, requests that a lower grant leaves above the new limits are
    # stopped after the grace period. That includes the zero-capacity revision
    # Tyr applies when a grant expires. Local policy: Latchflo does not send
    # it. Keep the grace period shorter than the gap between grant revisions,
    # because a newer revision restarts it.
    # stop:
    #   takeBackGraceMs: 5000
    # Latchflo owns the physical pool grant. Configure the fixed class keys at
    # zero while the managed pool starts closed; the first class-aware grant
    # atomically supplies physical limits, protected floors, and hard ceilings.
    admissionClasses:
      defaultClass: standard
      classes:
        standard:
          protectedConcurrent: 0
          maxConcurrent: 0
          # Local policy remains fixed while Latchflo changes numeric grants.
          borrowedAdmissionSlot:
            releaseMechanism: deadline_abandonment
            deadlineMs: 30000
        premium:
          protectedConcurrent: 0
          maxConcurrent: 0
      rules:
        - admissionClass: premium
          roles: [tier.premium]

# Latchflo 0.13+ supplies the complete routable fleet in desired state. The
# shared Tyr-to-Tyr secret stays local; it is never distributed by Latchflo.
routing:
  capacityAware:
    instanceId: tyr-a
    sharedSecretEnv: TYR_ROUTING_SECRET
    pollIntervalMs: 100
    staleAfterMs: 1000
    probeTimeoutMs: 250
    forwardTimeoutMs: 30000
    peers: []

controlPlane:
  type: latchflo
  url: http://latchflo-control-plane:8080
  instanceId: tyr-a
  pools: [openai-primary]
  bootstrapTokenEnv: LATCHFLO_AGENT_BOOTSTRAP_TOKEN
  agentTokenFile: /var/lib/tyr/latchflo-agent.token
  # Startup retries use bounded exponential backoff with equal jitter.
  retryIntervalMs: 1000
  retryMaxIntervalMs: 30000
  requestTimeoutMs: 5000
  metadata:
    region: us-west
    zone: us-west-2a
    version: 0.36.1
    endpoint: http://tyr-a:8787
    labels:
      environment: demo
