feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
-- CreateTable
|
2026-05-24 10:44:06 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS `ModelRoute` (
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
`id` VARCHAR(191) NOT NULL,
|
|
|
|
|
`tier` VARCHAR(32) NOT NULL,
|
|
|
|
|
`taskType` VARCHAR(32) NOT NULL DEFAULT '*',
|
|
|
|
|
`preferredProvider` VARCHAR(32) NOT NULL,
|
|
|
|
|
`preferredModel` VARCHAR(100) NOT NULL,
|
|
|
|
|
`fallbackProvider` VARCHAR(32) NOT NULL,
|
|
|
|
|
`fallbackModel` VARCHAR(100) NOT NULL,
|
|
|
|
|
`maxRetries` INTEGER NOT NULL DEFAULT 2,
|
|
|
|
|
`isActive` BOOLEAN NOT NULL DEFAULT true,
|
|
|
|
|
`createdBy` VARCHAR(100) NULL,
|
|
|
|
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
|
|
|
`updatedAt` DATETIME(3) NOT NULL,
|
|
|
|
|
|
|
|
|
|
UNIQUE INDEX `ModelRoute_tier_taskType_key`(`tier`, `taskType`),
|
|
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- CreateTable
|
2026-05-24 10:44:06 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS `ProviderConfig` (
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
`id` VARCHAR(191) NOT NULL,
|
|
|
|
|
`name` VARCHAR(32) NOT NULL,
|
|
|
|
|
`enabled` BOOLEAN NOT NULL DEFAULT true,
|
|
|
|
|
`baseUrl` VARCHAR(255) NULL,
|
|
|
|
|
`updatedBy` VARCHAR(100) NULL,
|
|
|
|
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
|
|
|
`updatedAt` DATETIME(3) NOT NULL,
|
|
|
|
|
|
|
|
|
|
UNIQUE INDEX `ProviderConfig_name_key`(`name`),
|
|
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- CreateTable
|
2026-05-24 10:44:06 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS `FallbackEvent` (
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
`id` VARCHAR(191) NOT NULL,
|
|
|
|
|
`tier` VARCHAR(32) NOT NULL,
|
|
|
|
|
`taskType` VARCHAR(32) NOT NULL,
|
|
|
|
|
`fromProvider` VARCHAR(32) NOT NULL,
|
|
|
|
|
`fromModel` VARCHAR(100) NOT NULL,
|
|
|
|
|
`toProvider` VARCHAR(32) NOT NULL,
|
|
|
|
|
`toModel` VARCHAR(100) NOT NULL,
|
|
|
|
|
`errorMessage` VARCHAR(500) NULL,
|
|
|
|
|
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
|
|
|
|
|
|
|
|
PRIMARY KEY (`id`)
|
|
|
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
|
|
2026-05-24 10:44:06 +08:00
|
|
|
-- Seed default routes (skip if already exist)
|
|
|
|
|
INSERT IGNORE INTO `ModelRoute` (`id`, `tier`, `taskType`, `preferredProvider`, `preferredModel`, `fallbackProvider`, `fallbackModel`, `maxRetries`) VALUES
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
('route-cheap-default', 'cheap', '*', 'deepseek', 'deepseek-v4-flash', 'deepseek', 'deepseek-v4-flash', 2),
|
|
|
|
|
('route-primary-default', 'primary', '*', 'minimax', 'minimax-m2.7', 'deepseek', 'deepseek-v4-pro', 3),
|
|
|
|
|
('route-strong-default', 'strong', '*', 'deepseek', 'deepseek-v4-pro', 'deepseek', 'deepseek-v4-pro', 3);
|
|
|
|
|
|
2026-05-24 10:44:06 +08:00
|
|
|
-- Seed provider configs (skip if already exist)
|
|
|
|
|
INSERT IGNORE INTO `ProviderConfig` (`id`, `name`, `enabled`) VALUES
|
feat: M1-01~03 — AI Gateway deepening, Vector module, Task Queue deepening
M1-01 AI Gateway:
- DB-driven ModelRoute/ProviderConfig/FallbackEvent tables
- ModelRouter rewrite with loadFromDb() hot-reload
- Fallback event recording + AIUsageRecorded event publishing
- Admin AAPI: routes CRUD, provider enable/disable, fallback events log
M1-02 Vector & Retrieval:
- VectorService with Qdrant client (upsert/delete/search/rerank)
- Admin AAPI: collection status, vector count, reindex trigger
M1-03 Task Queue:
- 16 task types with default retry/timeout configs
- Task stats dashboard, worker status panel, batch retry endpoint
M0 audit fixes:
- ApiMetric retention policy (30-day cleanup)
- Content Safety integration in Files module
- Queue registration centralized (domain-events)
- SECRET_MASTER_KEY production validation
E2E tests:
- M0: 28 smoke tests covering all 14 M0 issues
- M1: 16 tests covering M1-01/02/03
- Mock infrastructure: prisma, ioredis, jose, bullmq, qdrant
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 10:18:07 +08:00
|
|
|
('prov-deepseek', 'deepseek', true),
|
|
|
|
|
('prov-minimax', 'minimax', true),
|
|
|
|
|
('prov-siliconflow', 'siliconflow', true),
|
|
|
|
|
('prov-mock', 'mock', false);
|