mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-19 17:52:01 +00:00
2d5e50fa88
配方语言(agentlab-recipe/2,新 recipe_types、recipe) - 封闭、不含正则、保存时静态校验:常量只能从表里的候选文字里选,占位符只能映射成空值,单位从固定词表里取 - 交叉表和列表两种版式;分段各自定位、不依赖先后顺序;合计按标签语义区间核对,关系恒等式、口径不同的声明都写在配方里 - 固定的解析器集合(parsers/2):全角、各类横线、千分位、月日写法宽容归一,规范写法存库、原文另记 执行器(新 xlsx_cells、recipe_engine) - 两遍读取逐行对账,每个非空格都要有去向(格子账);交叉表逆透视成长表,按统计期补年份并断言覆盖整期 - 合计行改作核对并另存一张表,不和明细混在一列;区域外文字、隐藏行列、合并单元格、空行之后的文字都单独报出 - STRICT 加主键写临时库;按锚点段记溯源,供后续证据下钻用;大表流式读取,扫描在 sheetData 处停止 校验与说明(新 recipe_checks、recipe_notes) - SQL 核对分通过、不一致、无法核对三种结果,失败分结构、数据质量、需确认三类;结构类直接拒收 - 数据质量类可以写理由接受,接受不改库、只改状态和说明 - 表的说明按核对结果生成、不含数字,经过数字检查;没核对过的不写「已核对」 起草(新 recipe_suggest、recipe_ai) - 先用规则起草:建议卡片加待确认问题(关系要不要登记、占位符表示什么) - 规则起草不完整时才提示 AI 兜底:界面先展示要发出的全部文字,用户同意才发;只发结构,数字、隐藏行列、遮罩列不发,公式先脱敏;同意绑定模型和服务方;AI 只写配方,有限次修订,记 token 和费用;截断单独识别 - 无论规则还是 AI 起草,都必须人工确认才能启用 导入流程(新 recipe_imports、recipe_confirm、recipe_diff、api/table_imports) - 暂存 → 起草 → 回答问题或改配方 → 试运行 → 勾确认项、写接受理由 → 确认并启用;接入期 1 的构建、导入记录、快照和运行固定版本 - 上传新一期按已确认的配方重放,不调用模型,出回执和差异卡,手动启用 - 改配方报破坏性变更(breaking:*)、单位变化、工作表改名的兜底,都要逐项勾选确认 前端导入向导(新 pages/import) - 原始网格(行列号、去向着色)、建议卡片、配方面板(表单,不露正则)、试运行回执、确认清单、差异卡、AI 起草的同意对话框
86 lines
4.0 KiB
JSON
86 lines
4.0 KiB
JSON
{
|
|
"recipe_format": "agentlab-recipe/2",
|
|
"mode": "replace",
|
|
"other_visible_sheets": "confirm",
|
|
"sheets": [
|
|
{
|
|
"id": "s1",
|
|
"match": {"name": "客流汇总", "fallback": "only_visible_sheet"},
|
|
"hidden": {"rows": "reject_if_any", "cols": "reject_if_any"},
|
|
"context": [
|
|
{"id": "统计期", "kind": "period", "parser": "cn_date_range", "prefer_prefix": "统计时间范围", "cross_check": "filename"}
|
|
],
|
|
"blocks": [
|
|
{
|
|
"id": "交叉表",
|
|
"layout": "crosstab",
|
|
"axis": {
|
|
"find": {"parser": "month_day_or_date", "min": 2},
|
|
"name": "日期",
|
|
"type": "DATE",
|
|
"year_from": "统计期",
|
|
"checks": ["contiguous", "covers_context"]
|
|
},
|
|
"label_offset": -1,
|
|
"values": {
|
|
"type": "INTEGER",
|
|
"placeholders": [{"text": "·", "meaning": "无数据"}],
|
|
"blank": "reject",
|
|
"text_number": "reject",
|
|
"formula": "reject"
|
|
},
|
|
"segments": [
|
|
{
|
|
"id": "日客流",
|
|
"role": "measures",
|
|
"table": "日客流",
|
|
"locate": {"by": "labels"},
|
|
"labels": {"expect": ["全日客流(人次)", "分区甲(人次)", "分区乙(人次)"]},
|
|
"measures": {"全日客流(人次)": "全日客流", "分区甲(人次)": "分区甲", "分区乙(人次)": "分区乙"}
|
|
},
|
|
{
|
|
"id": "日间",
|
|
"role": "dimension",
|
|
"table": "时段客流",
|
|
"locate": {"by": "section_title", "title": "日间时段客流(人次)"},
|
|
"labels": {"expect": ["7-8", "8-9", "9-10", "10-11", "11-12", "12-13", "13-14", "14-15", "15-16", "16-17", "17-18"]},
|
|
"dim": {"name": "时段", "parser": "hour_range", "derive": {"起始小时": "start", "结束小时": "end"}},
|
|
"value": "客流",
|
|
"const": {"时段类别": {"pick": "日间"}}
|
|
},
|
|
{
|
|
"id": "夜间",
|
|
"role": "dimension",
|
|
"table": "时段客流",
|
|
"locate": {"by": "section_title", "title": "夜间时段客流(人次)"},
|
|
"labels": {"expect": ["18-19", "19-20", "20-21", "21-22", "22-23", "23-24"]},
|
|
"dim": {"name": "时段", "parser": "hour_range", "derive": {"起始小时": "start", "结束小时": "end"}},
|
|
"value": "客流",
|
|
"const": {"时段类别": {"pick": "夜间"}},
|
|
"stop_parser": "hour_range_total"
|
|
},
|
|
{
|
|
"id": "夜间合计",
|
|
"role": "derived",
|
|
"locate": {"by": "after", "segment": "夜间"},
|
|
"labels_parser": "hour_range_total",
|
|
"labels": {"expect": ["18-22 时合计", "22-24 时合计", "18-24 时合计"]},
|
|
"verify": {"kind": "label_range_sum", "against_table": "时段客流", "value": "客流"},
|
|
"keep_as": {"table": "时段客流_表内合计", "dim": "合计项", "derive": {"起始小时": "start", "结束小时": "end"}, "value": "客流"}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"tables": [
|
|
{"name": "日客流", "grain": ["日期"], "kind": "data", "units": {"全日客流": "人次", "分区甲": "人次", "分区乙": "人次"}, "note": ""},
|
|
{"name": "时段客流", "grain": ["日期", "时段"], "kind": "data", "units": {"客流": "人次"}, "note": ""},
|
|
{"name": "时段客流_表内合计", "grain": ["日期", "合计项"], "kind": "reported_total", "units": {"客流": "人次"}, "note": ""}
|
|
],
|
|
"relations": [
|
|
{"id": "R1", "kind": "sum_eq", "table": "日客流", "total": "全日客流", "parts": ["分区甲", "分区乙"], "claims": "F1"},
|
|
{"id": "R2", "kind": "not_comparable", "a": {"table": "时段客流", "value": "客流"}, "b": {"table": "日客流", "value": "全日客流"}, "by": "日期", "claims": "F2"}
|
|
]
|
|
}
|