{ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://zeekerwatchman/schemas/ir.json", "title": "IR (Intermediate Representation) Schema", "description": "3-stage pipeline output: feature analysis rules with trigger/action semantics", "type": "object", "required": ["feature", "feature_id", "rules"], "properties": { "feature": { "type": "string", "description": "功能名称,从 PRD 中提取" }, "feature_id": { "type": "string", "description": "功能缩写,用于生成 rule_id 前缀,如 PRD, AUTH, ORDER", "pattern": "^[A-Z]{2,8}$" }, "rule_count": { "type": "integer", "description": "规则总数" }, "generated_at": { "type": "string", "format": "date-time" }, "rules": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/IRRule" } } }, "definitions": { "IRRule": { "type": "object", "required": ["rule_id", "description", "priority"], "properties": { "rule_id": { "type": "string", "description": "唯一标识。格式: IR-{feature_id}-{section}-{seq},如 IR-PRD-4.2.1-001", "pattern": "^IR-[A-Z]{2,8}-[0-9.]+-[0-9]{3}$", "examples": ["IR-PRD-4.2.1-001", "IR-AUTH-2.1-001"] }, "description": { "type": "string", "description": "完整的中文自然语言描述,包含前置条件、触发条件和所有动作", "minLength": 10 }, "priority": { "type": "string", "enum": ["P0", "P1", "P2"], "description": "P0=核心安全规则, P1=重要规则, P2=边界情况" }, "sources": { "type": "array", "items": { "$ref": "#/definitions/Source" }, "description": "规则的数据来源锚点" }, "precondition": { "type": "object", "description": "规则生效的前置状态条件。可以是空对象", "properties": { "switch": { "type": "string" }, "app_type": { "type": "string", "description": "如: 系统限制, SDK限制, 其他应用" }, "app_state": { "type": "string", "description": "如: 前台, 后台" } } }, "trigger": { "type": "object", "required": ["operator", "conditions"], "properties": { "operator": { "type": "string", "enum": ["AND", "OR"], "description": "多个条件的组合方式" }, "conditions": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/TriggerCondition" } } } }, "actions": { "type": "array", "minItems": 1, "items": { "$ref": "#/definitions/Action" } } } }, "TriggerCondition": { "type": "object", "required": ["signal", "operator", "value"], "properties": { "signal": { "type": "string", "description": "触发信号名,如 车速, 档位, 文件格式", "examples": ["车速", "文件大小", "应用请求启动"] }, "operator": { "type": "string", "enum": [">=", ">", "<=", "<", "==", "!=", "in", "not_in", "exists"], "description": "比较运算符" }, "value": { "description": "比较值,可以是数字、字符串或数组" }, "unit": { "type": "string", "description": "数值单位,如 km/h, 秒, MB", "examples": ["km/h", "秒", "MB"] } } }, "Action": { "type": "object", "required": ["type", "description"], "properties": { "type": { "type": "string", "enum": ["system", "user_interaction"], "description": "system=系统自动行为, user_interaction=用户可见交互" }, "description": { "type": "string", "description": "动作描述" }, "content": { "type": "string", "description": "用户可见内容(仅 user_interaction 类型需要),如 Toast 文案" } } }, "Source": { "type": "object", "required": ["type"], "properties": { "type": { "type": "string", "enum": ["para", "table", "image", "logic_tree"], "description": "来源类型" }, "section": { "type": "string", "description": "章节号" }, "row": { "type": "integer", "description": "表格行号" }, "text_snippet": { "type": "string", "description": "前200字关键文字" }, "image_id": { "type": "string", "description": "图片 rId" } } } } }