feat(ssa): Complete T-test end-to-end testing with 9 bug fixes - Phase 1 core 85% complete. R service: missing value auto-filter. Backend: error handling, variable matching, dynamic filename. Frontend: module activation, session isolation, error propagation. Full flow verified.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
42
backend/src/modules/ssa/validators/planSchema.ts
Normal file
42
backend/src/modules/ssa/validators/planSchema.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* SSA 计划验证 Schema (Zod)
|
||||
*/
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
// 护栏配置 Schema
|
||||
export const guardrailConfigSchema = z.object({
|
||||
name: z.string(),
|
||||
check_code: z.string().optional(),
|
||||
threshold: z.string().optional(),
|
||||
action_type: z.enum(['Block', 'Warn', 'Switch']).default('Warn'),
|
||||
action_target: z.string().optional(),
|
||||
status: z.enum(['pending', 'passed', 'failed', 'switched']).default('pending')
|
||||
});
|
||||
|
||||
// 分析计划 Schema
|
||||
export const analysisPlanSchema = z.object({
|
||||
tool_code: z.string().regex(/^ST_[A-Z_]+$/, 'tool_code must match ST_XXX pattern'),
|
||||
tool_name: z.string().min(1),
|
||||
reasoning: z.string(),
|
||||
params: z.record(z.any()),
|
||||
guardrails: z.array(guardrailConfigSchema).optional(),
|
||||
confidence: z.number().min(0).max(1).optional()
|
||||
});
|
||||
|
||||
// 执行请求 Schema
|
||||
export const executeRequestSchema = z.object({
|
||||
plan: analysisPlanSchema,
|
||||
confirm: z.boolean().default(true)
|
||||
});
|
||||
|
||||
// 咨询消息 Schema
|
||||
export const consultMessageSchema = z.object({
|
||||
message: z.string().min(1, 'Message cannot be empty')
|
||||
});
|
||||
|
||||
// 类型导出
|
||||
export type GuardrailConfig = z.infer<typeof guardrailConfigSchema>;
|
||||
export type AnalysisPlan = z.infer<typeof analysisPlanSchema>;
|
||||
export type ExecuteRequest = z.infer<typeof executeRequestSchema>;
|
||||
export type ConsultMessage = z.infer<typeof consultMessageSchema>;
|
||||
Reference in New Issue
Block a user