cross-engine-operator
在下游构造跨引擎一致的算子,确保各语言版本的 Pine 引擎行为一致。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
在下游构造跨引擎一致的算子,确保各语言版本的 Pine 引擎行为一致。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
构造一个新语言的 pine-foo 引擎实现,遵循「先对齐再重构」策略确保行为一致性。
将新 pine-foo 引擎接入 fixtures 测试和 cross-validate 脚本,确保与已有实现行为一致。
定时自动维护 llmdoc 项目文档的 Skill。支持两种模式:聚合仓库模式(遍历子模块)和 单仓库模式(直接在当前仓库操作)。每天北京时间 5:00(UTC 21:00)由 GitHub Actions schedule 触发,也支持 workflow_dispatch 手动触发。收集指定时间范围内(默认过去 24 小时) 合并到目标分支的提交记录和 PR 内容,分析代码变更是否涉及功能新增、接口变更或架构调整, 如果需要则自动更新 llmdoc/ 下的对应文档并推送到目标分支。不改变外部行为的变更 (bug 修复、重构、依赖升级等)会被跳过。更新完成后输出结构化 JSON 结果并通过飞书通知。
分析 Bug 类型 Issue, 定位根因, 并对简单 Bug 自动创建修复 PR。
根据 Issue 的讨论和方案, 实现功能或修复 Bug, 并创建 PR。
定期巡查仓库,监控 CI 状态、扫描未处理 Issue,自动分发到对应 skill 处理。
| name | cross-engine-operator |
| description | 在下游构造跨引擎一致的算子,确保各语言版本的 Pine 引擎行为一致。 |
指导如何开发一个新算子,使其在所有语言版本的 Pine 引擎中行为一致。
在写任何代码之前,先定义算子的行为规范:
创建 fixtures/operators/<operator_name>.json:
{
"operator": "my_new_operator",
"cases": [
{
"name": "basic case — describe what this tests",
"params": {
"param1": "value1",
"param2": 42
},
"metadata": {
"common_input": ["field_a"],
"item_input": ["field_b", "field_c"],
"common_output": ["field_a"],
"item_output": ["field_b", "field_c", "new_field"]
},
"input": {
"common": { "field_a": "hello" },
"items": [
{ "field_b": 1, "field_c": "x" },
{ "field_b": 2, "field_c": "y" }
]
},
"expected": {
"common": { "field_a": "hello" },
"items": [
{ "field_b": 1, "field_c": "x", "new_field": "computed" },
{ "field_b": 2, "field_c": "y", "new_field": "computed" }
]
}
}
]
}
关键原则:
83 不写 83.0)算子参数的 schema 定义(用于 codegen 和 config 校验):
Operator: my_new_operator
Params:
- param1: string, required
- param2: int, optional, default=10
- fail_on_error: bool, optional, default=false
如果算子与其他算子组合时有特殊行为,创建 fixtures/pipelines/<scenario>.json:
{
"config": {
"operators": {
"step1": { "operator": "transform_set", "params": {...} },
"step2": { "operator": "my_new_operator", "params": {...} }
},
"pipeline": ["step1", "step2"]
},
"cases": [...]
}
Go 是参考实现,其行为定义了 fixture 的 expected 输出。
pine-go/operators/my_new_operator.go
实现要点:
Operator 接口:Init(params), Process(frame), Schema() OperatorSchemaregistry.go 中注册pine-java/src/main/java/page/liam/pine/operators/MyNewOperator.java
实现要点:
Operator 接口:init(Map params), process(Frame frame), schema()AllOperators.ensureRegistered() 中注册FixtureTest 确认 operator fixture 通过同 Java 的策略:实现接口 → 注册 → 跑 fixture → 对齐 Go 输出。
每个引擎独立跑 fixture:
# Go
cd pine-go && go test ./... -run TestFixtures
# Java
cd pine-java && mvn test -Dtest=FixtureTest
跑完整 cross-validate 确认所有引擎输出一致:
bash scripts/cross-validate.sh
新算子会被自动覆盖到以下段落:
如果新增了 operator fixture,它会在各引擎的内部 fixture test 中被执行,但 cross-validate.sh 通过 pipeline fixture 间接验证。
# 构造一个只含新算子的最小 pipeline
cat > /tmp/test_config.json << 'EOF'
{
"operators": {
"op1": { "operator": "my_new_operator", "params": {...} }
},
"pipeline": ["op1"]
}
EOF
cat > /tmp/test_req.json << 'EOF'
{ "common": {...}, "items": [...] }
EOF
# 对比
diff <(pineapple-run -config /tmp/test_config.json -request /tmp/test_req.json) \
<(java -cp ... page.liam.pine.RunCli -config /tmp/test_config.json -request /tmp/test_req.json)
| 场景 | 陷阱 | 对齐方式 |
|---|---|---|
| JSON 整数 | Go: float64, Java: Integer/Long | 输出时保持原类型 |
| 除法 | Go: int/int=int, Java: int/int=int | 明确语义 |
| NaN/Infinity | Go: JSON 输出 null | 所有语言: 替换为 null |
| 浮点精度 | IEEE 754 | 避免精度敏感计算 |
| 场景 | 陷阱 | 对齐方式 |
|---|---|---|
| Map 序列化 | Go 按 key 字母排序 | 所有引擎必须对齐 |
| 稳定排序 | Go sort.SliceStable | 确保所有语言用 stable sort |
| Shuffle | 需要确定性种子 | 算子不做 shuffle 或用固定种子 |
| 场景 | 陷阱 | 对齐方式 |
|---|---|---|
| HTML chars | Go 默认转义 <>& | 所有引擎需要实现 GoFormat |
| Unicode | U+2028/U+2029 转义 | 同上 |
| nil vs "" | Go nil string → JSON null | 区分空字符串和 null |
| 场景 | 陷阱 | 对齐方式 |
|---|---|---|
| 空 list | Go nil slice → null vs [] | 统一为 null 或 [] |
| 空 map | 同上 | 统一 |
| 字段缺失 | Go omitempty | 明确哪些字段省略 |
新算子必须在所有引擎中注册相同的 schema:
my_new_operator)验证:cross-validate Section 1 (codegen schema parity)。
算子执行错误的处理也需要跨引擎一致:
// 当 fail_on_error=true 时
- 输入无效 → Engine 返回 error (HTTP 500, CLI exit 1)
- error message 格式: operator "op_name": <具体错误>
// 当 fail_on_error=false 时 (默认)
- 输入无效 → skip 当前算子,warnings 中记录
- warnings 格式: operator "op_name": <具体错误>
如果新算子有 fail_on_error 参数,需要在 fixtures/errors/ 中添加对应的错误 fixture。
fixtures/operators/<name>.json 覆盖 golden path + edge casescross-validate.sh 绿色