Skip to content

feat: node operator identity tracking#17

Merged
eduardoworrel merged 3 commits into
mainfrom
feat/auth-middleware
Feb 26, 2026
Merged

feat: node operator identity tracking#17
eduardoworrel merged 3 commits into
mainfrom
feat/auth-middleware

Conversation

@eduardoworrel

@eduardoworrel eduardoworrel commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Track node operator identity through the entire task pipeline from WebSocket connection to metrics
  • Pass operator={userId} in upstream WS URI so server can attribute inference work to node operators
  • Fix race condition in PostProcessingQueue: store metrics in Redis BEFORE publishing result to result_queue
  • Add OperatorId to NodeContribution in TaskMetrics

Files changed

  • TaskSockets.cs — read operator query param from WS connection
  • WebSocketNodesQueue.cs — store operator_id alongside nodeId in channel
  • DistributeQueue.cs — store operator_id in taskRequest.PrivateArgs
  • TaskMetrics.cs — add OperatorId to NodeContribution
  • TaskMetricsBuilder.cs — include operator_id in built metrics
  • PostProcessingQueue.cs — fix race condition (metrics before result)

Test plan

  • Node connects via gateway WS with operator param
  • operator_id flows through pipeline: WS → Redis → metrics → HTTP response
  • operator_id appears in PostgreSQL inference_node_contributions
  • Race condition fix verified: metrics available when core-api reads them

🤖 Generated with Claude Code

eduardoworrel and others added 3 commits February 25, 2026 21:20
Add env-var-driven auth middleware that defaults to none (backward compatible).
- AUTH_HTTP_MODE=api-key-env validates X-API-Key header on /api/ routes
- AUTH_WS_MODE=api-key-env validates ?token= query param before WS accept
- docker-compose.yml includes commented example env vars

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When X-Verbose: true header is sent, response wraps result with
pipeline metrics: queue_wait_ms, preprocessing_ms, inference_ms,
postprocessing_ms, total_ms, and per-node contribution data.

Timestamps propagate through PrivateArgs across all 3 services
(core-api, core-background, core-websocket) via Redis.
Without the header, responses are unchanged (backward compatible).

Tested all 5 endpoints: translation, text-generation, TTS, STT,
image-text-to-text.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pass the authenticated operator user_id from WebSocket connection
through the entire task pipeline so metrics can attribute inference work
to the node operator. Also fix race condition where metrics were stored
in Redis after result publication, causing core-api to read stale data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eduardoworrel eduardoworrel merged commit 93046d2 into main Feb 26, 2026
4 of 5 checks 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.

1 participant