Files
yidaima/RuoYi-Vue/docs/superpowers/plans/2026-07-10-model-gateway-prompt-identity.md

2.1 KiB

Model Gateway And Prompt Identity Plan

Goal: Put every existing AI call behind a provider-neutral model gateway and make queued AI tasks execute with an immutable Prompt/model identity.

Architecture: AiGenerateServiceImpl keeps the current domain-specific user Prompt builders, but delegates invocation to AiModelInvoker. The invoker resolves a versioned PromptRelease, routes through ModelGatewayRouter, and honors a task-scoped pinned identity supplied by AiGenerationTaskWorker. DeepSeekModelGateway is the first provider adapter and supports an explicit model override.

Task 1: Contracts

  • Define Prompt release, registry, invocation plan, model request/result, gateway descriptor, and stream contracts.
  • Define a task execution context that safely restores nested/thread-local state.
  • Reject unknown Prompt releases, providers, model mismatches, and fingerprint drift.

Task 2: Legacy-Compatible Implementations

  • Publish built-in Prompt releases for every current generation type.
  • Wrap IDeepSeekClient with DeepSeekModelGateway and route explicit model IDs.
  • Add AiModelInvoker and retain a legacy fallback for existing direct unit fixtures.

Task 3: Task Traceability

  • Persist Prompt code, version, and fingerprint beside provider/model on AI tasks.
  • Include Prompt/model identity in task idempotency hashes and API status responses.
  • Execute queued work inside the pinned identity context.

Task 4: Migration And Verification

  • Update base SQL, workbench SQL, task upgrade SQL, and add an existing-schema upgrade.
  • Add contract, gateway, context, task persistence, mapper, and SQL tests.
  • Run focused and broad backend regressions, frontend tests/build, and git diff --check.

Boundaries

  • User Prompt builders remain in AiGenerateServiceImpl during P2-B1 and are identified by an immutable builder contract string.
  • Database-editable Prompt templates, publish/rollback APIs, and the RuoYi Prompt administration UI are P2-B2.
  • Requirement planning into ProjectSpec Draft/Patch and Stage Handler checkpoints remain later P2 work.