Skip to content

FAC-135.6 feat: sentiment vLLM-primary dispatch + admin config endpoint #369

@y4nder

Description

@y4nder

Summary

Expose the self-hosted vLLM classifier as the primary sentiment dispatch target with OpenAI as a per-item fallback, runtime-rotatable via a SuperAdmin admin endpoint. The vLLM deployment runs on Thunder Compute with a URL that cycles every few days as cloud credits refresh; operators now rotate the URL and model through SystemConfig without redeploying the worker.

Context

The current sentiment path calls OpenAI for every chunk at per-token cost. A self-hosted vLLM classifier (fine-tuned Gemma) is available but its URL rotates with Thunder Compute's credit cycle. The worker needs a runtime-configurable URL and the API needs a guarded admin surface to change it. This ticket covers the API-side contract, config persistence, and admin endpoint; the worker-side strategy and fallback logic live in sentiment.worker.temp.faculytics.

Scope

API (api.faculytics)

  • batchAnalysisJobSchema + sentiment-worker.dto.ts extended with optional vllmConfig (https-only URL) and optional servedBy on each result item
  • SENTIMENT_VLLM_CONFIG SystemConfig row seeded (enabled=false default)
  • New SentimentConfigService with single-read update returning { previous, next } for TOCTOU-free audit capture
  • New AdminSentimentConfigController at GET/PUT /admin/sentiment/vllm-config
    • @UseJwtGuard(SUPER_ADMIN)
    • https-only URL, cross-field validation (rejects enabled=true + empty URL/model)
    • Production rollout gate via ALLOW_SENTIMENT_VLLM_ENABLED_IN_PROD
    • Manual AuditService.Emit with before/after payload — no @Audited decorator (avoids double-audit through the interceptor)
  • New audit action ADMIN_SENTIMENT_VLLM_CONFIG_UPDATE
  • SystemConfig registered in AnalysisModule.forFeature; SentimentConfigService wired into PipelineOrchestratorService
  • Orchestrator snapshots config once per dispatch and attaches vllmConfig to every chunk envelope only when enabled=true + URL non-empty

Tests

  • Cross-boundary contract test covering the sentiment-worker envelope with vllmConfig present/absent
  • Processor spec coverage for servedBy round-trip through rawResult JSONB
  • SentimentConfigService spec covering read/update, { previous, next } shape, and production rollout gate
  • AdminSentimentConfigController spec covering guard wiring, validation rejections, and audit emission
  • Pipeline orchestrator chunking spec extended to assert vllmConfig attachment behavior

Out of scope

  • Worker-side vLLM strategy + OpenAI per-item fallback (separate repo / PR)
  • Admin SPA card for editing the config (separate admin.faculytics PR)
  • Logprob-derived soft probabilities — empirical probe showed top-1 P≈1.0 across test samples; logprobs are preserved raw in rawResult for future calibration only
  • errorClass taxonomy on servedBy failures

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions