Skip to content

publish provider concurrency on-chain so gateways skip / wait - #17

Merged
ffaerber merged 1 commit into
mainfrom
claude/long-running-inference-comms-VDpVA
Jun 1, 2026
Merged

publish provider concurrency on-chain so gateways skip / wait#17
ffaerber merged 1 commit into
mainfrom
claude/long-running-inference-comms-VDpVA

Conversation

@ffaerber

@ffaerber ffaerber commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

When every provider for a model is mid-job, gateways had no way to tell:
the selector saw only active + heartbeat + price, picked one anyway,
and the request died on the 30s ack timeout.

  • ProviderRegistry.Provider gains maxConcurrentJobs (uint32, 0 = unset)
    and setMaxConcurrentJobs() mutator + event. openJobs was already
    on-chain; combined the two tell selectors when a provider is full.
  • Provider node syncs T4T_MAX_CONCURRENT_JOBS to chain on startup if
    it differs from the published value.
  • Selector reads openJobs + maxConcurrentJobs per candidate, filters
    out the full ones, and returns the rest of the pool so callers can
    fall over or wait.
  • Gateway wraps selectProvider → postJob in a wait-and-retry loop
    bounded by T4T_PROVIDER_WAIT_SECONDS (default 120s, poll every 5s).
    Surfaces a waiting_for_capacity SSE event so clients see the wait.
  • Tests: registry mutator + initial-zero invariant; selector capacity
    filter, fallback-to-cheapest-not-busy, zero-as-unlimited, no-match
    fail-fast.

When every provider for a model is mid-job, gateways had no way to tell:
the selector saw only `active` + heartbeat + price, picked one anyway,
and the request died on the 30s ack timeout.

- `ProviderRegistry.Provider` gains `maxConcurrentJobs` (uint32, 0 = unset)
  and `setMaxConcurrentJobs()` mutator + event. `openJobs` was already
  on-chain; combined the two tell selectors when a provider is full.
- Provider node syncs `T4T_MAX_CONCURRENT_JOBS` to chain on startup if
  it differs from the published value.
- Selector reads `openJobs` + `maxConcurrentJobs` per candidate, filters
  out the full ones, and returns the rest of the pool so callers can
  fall over or wait.
- Gateway wraps `selectProvider → postJob` in a wait-and-retry loop
  bounded by `T4T_PROVIDER_WAIT_SECONDS` (default 120s, poll every 5s).
  Surfaces a `waiting_for_capacity` SSE event so clients see the wait.
- Tests: registry mutator + initial-zero invariant; selector capacity
  filter, fallback-to-cheapest-not-busy, zero-as-unlimited, no-match
  fail-fast.
@ffaerber
ffaerber merged commit 3eb3b1c into main Jun 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants