feat(corps): 企业配置增加环境属性与生产安全保护机制
- Schema 扩展: CorpConfigSchema 增加 env ('prod' | 'test' | 'demo') 与 isTest 字段,未知企业保守兜底为 prod
- 智能初判与归一化: inferCorpEnvFromName 依据名称初判环境,normalizeCorpConfig 确保配置持久化时环境对齐
- CLI 视图升级: corps list 与 search 增加「环境」列 (🏭 正式 / 🧪 测试 / 🎪 演示),支持 --test/--prod/--env 筛选
- 环境打标与迁移: 新增 hose-use corps tag 命令,支持单个企业标记与 --migrate-all 批量显式升级持久化
- 生产安全阻断: workflow test 等敏感调试在正式生产环境 (prod) 阻断执行,需显式附加 --force 确认生产风险
- 上下文与探针增强: context、probe、corps current 全面输出企业环境属性
- 测试与文档补全: 覆盖 489 项全量测试并通过 tsc 类型检查
This commit is contained in:
1 parent
908286c1df
commit
af1e11c018
15 files changed
+775
-28
No files matched your search
@@ -5,7 +5,10 @@ import * as services from "../../domains/platform/services.js";
|
||||
import type { CliParsedArgs, CliRuntime } from "../types.js";
|
||||
import type { WorkflowTestReport } from "../../domains/platform/types.js";
|
||||
|
||||
const runtime = { selectedCorp: { id: "mock-corp" }, jsonMode: true } as CliRuntime;
|
||||
const runtime = {
|
||||
selectedCorp: { id: "mock-corp", name: "Mock测试企业", env: "test", isTest: true } as any,
|
||||
jsonMode: true,
|
||||
} as CliRuntime;
|
||||
const args = (options: Record<string, string | boolean> = {}): CliParsedArgs => ({ area: "workflow", action: "test", args: ["pipe"], options: { flow: "ID01-record", ...options }, raw: ["workflow", "test", "pipe", "--flow=ID01-record"] });
|
||||
const completed: WorkflowTestReport = { jobId: "job", pipelineId: "pipe", status: "COMPLETED", outcome: "completed", timedOut: false, diagnosticsComplete: true, diagnosticsErrors: [], runType: "DEBUG", targetEntityId: "record", executionTree: [], failedExecutions: [], conditionDiagnoses: [] };
|
||||
|
||||
@@ -94,4 +97,20 @@ describe("workflow debug mutation and result contract", () => {
|
||||
expect(result.stdout).toContain("FAILED");
|
||||
});
|
||||
}
|
||||
|
||||
it("blocks workflow test without --force when selected corp is production environment", async () => {
|
||||
const { run } = setup();
|
||||
const prodRuntime = {
|
||||
selectedCorp: { id: "prod-corp", name: "生产正式企业", env: "prod", isTest: false },
|
||||
jsonMode: false,
|
||||
} as any;
|
||||
const blocked = await handleWorkflowTest(args({ yes: true }), prodRuntime);
|
||||
expect(blocked.exitCode).toBe(1);
|
||||
expect(blocked.stderr).toContain("生产环境安全阻断");
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
|
||||
const allowed = await handleWorkflowTest(args({ yes: true, force: true }), prodRuntime);
|
||||
expect(allowed.exitCode).toBe(0);
|
||||
expect(run).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user