File contents BKN 回填
公约:../_shared/contract.md
做什么
把 bkn-bind 和 bkn-map 的结果合并,写回 .bkn 文件,完成资源绑定闭环。
输入
binding_decision_list:对象级绑定结果
property_mapping_draft:属性级映射结果
relation_binding_result:bkn-relation-bind 的输出(关系类型 + 中间视图)
relation_mapping_draft:bkn-map 的关系类映射结果
network_dir:网络目录(.bkn 文件位于 {network_dir}/bkn/)
流程
属性回灌门禁 (P1-2):
读取 {network_dir}/pipeline_state.yaml(文件不存在时视为 map_completed 缺失)
map_completed == true → 继续
map_completed == skipped (bind_mode == deferred 场景)→ 记录 map_status: skipped (deferred),继续
map_completed 不存在或为 false :
用户明确要求跳过 → 在 pipeline_state.yaml 中追加 skipped_steps: [bkn-map],输出警告后继续
否则,阻断并回交 pipeline 调度 ,输出:
"bkn-backfill 需要 bkn-map 先执行完成(map_completed 未就绪)。请 pipeline 调度 bkn-map 后再调用本 skill。"
合并绑定变更 + 属性变更 + 映射状态为统一差异清单
存储位置过滤 :
跳过 存储位置: local 的对象(本地对象无需资源绑定,不参与回填)
在输出摘要中单独列出被跳过的 local 对象
对象类回填 (仅 platform 对象):
Data Source 绑定值替换(名称/技术名 → 稳定 resource_id)
Mapped Field 更新为资源真实属性名
数据视图中不存在的属性:默认标注 Mapped Field 为 -(保留属性定义,便于后续补绑);用户可指定删除该行
不改动 Description 或其他业务语义字段
级联修正 (关键改进):
构建 rename_map:{object_id: {old_property_name → new_property_name}}
来源 1:bkn-map 的 property_regen_summary.rename 动作(draft 属性名 → 视图字段名)
来源 2:用户手动指定的属性重命名
扫描 {network_dir}/bkn/relation_types/*.bkn 的 Mapping Rules,将 Source Property / Target Property 中引用了已重命名属性的值替换
扫描 {network_dir}/bkn/action_types/*.bkn 的 Parameter Binding / Pre-conditions,将 Binding 列中引用了已重命名属性的值替换
级联修正只改引用名,不改语义
关系类回填 (新增):
仅处理 relation_binding_result 中 status: confirmed 的关系
direct 类型 :
回填 Endpoint 表的 Type 列为 direct
回填 Mapping Rules 表(Source Property → Target Property)
indirect 类型 :
回填 Endpoint 表的 Type 列为 indirect
回填 Backing Resource 表(Type = resource, ID = backing_resource_id)
回填 Source Mapping 表(Source Property → Resource Property)
回填 Target Mapping 表(Resource Property → Target Property)
pending 关系 :
仅回填 Endpoint 表(Type 列保留占位符或留空)
Backing Resource / Source/Target Mapping 段不生成
跳过 relation_mapping_quality: blocked 的关系(在输出中标记)
推送前关系映射完整性预检 (执行 ../_shared/prepush-validation.md):
检查所有 relation_types 的 Source/Target Property 是否存在于对应对象的 Data Properties
检查所有 action_types 的 Parameter Binding 属性是否存在于绑定对象的 Data Properties
检查 Concept Group 成员和 Network Overview 一致性
检查 indirect 类型关系的 Backing Resource ID 是否非空
检查 indirect 类型关系的 Source/Target Mapping 属性是否存在于对应资源 schema
local 对象跳过属性存在性检查,但仍参与对象存在性检查
pending 关系仅 warning,不阻断
预检失败 → 阻断写入,列出全部错误 ,提示修复后重试
执行写入(写入 {network_dir}/bkn/ 下对应的 .bkn 文件)
回读校验(文件存在、关键字段已替换、级联引用一致、关系类结构完整)
输出精简摘要,提示用户检查
输出
backfill_plan:
binding_replacements: [{object, old_value, new_resource_id}]
property_changes: [{object, property, action, layer}]
cascade_renames: [{file, table, old_ref, new_ref}]
# 新增:关系类回填计划
relation_replacements:
- 关系ID: ""
关系名称: ""
关系类型: direct | indirect
actions:
- action: "" # fill_endpoint_type / fill_mapping_view / fill_source_mapping / fill_target_mapping
target_section: "" # Endpoint / Backing Resource / Source Mapping / Target Mapping
old_value: ""
new_value: ""
skipped_local_objects: [对象名]
skipped_pending_relations: [关系名] # pending 关系,跳过回填
map_gate: {map_completed: true|false|skipped, user_skipped_map: true|false, blocked_for_map: true|false}
prepush_validation: {status, errors} # 写入前预检结果
backfill_status: success | partial | failed
verification:
files_checked: 0
fields_replaced: 0
cascade_refs_fixed: 0
relations_filled: 0 # 新增:已回填的关系数量
pending_relations: 0 # 新增:pending 关系数量
issues: []
约束
只写 Data Source、Mapped Field 和级联引用,不改业务语义字段
级联修正仅限属性名引用,不修改关系方向或动作语义
写入前必须执行 ../_shared/prepush-validation.md 预检,失败则阻断写入
执行回填前必须确认 map_completed == true 或 skipped,否则阻断并回交 pipeline 调度
写入后必须回读校验,包括级联引用一致性
回填失败时保留差异清单,可重试
1 --- 2 name: bkn-backfill 3 description: 将绑定/映射结果写回 .bkn 文件。 4 --- 5 6 # BKN 回填 7 8 公约:`../_shared/contract.md` 9 10 ## 做什么 11 12 把 `bkn-bind` 和 `bkn-map` 的结果合并,写回 `.bkn` 文件,完成资源绑定闭环。 13 14 ## 输入 15 16 - `binding_decision_list`:对象级绑定结果 17 - `property_mapping_draft`:属性级映射结果 18 - `relation_binding_result`:`bkn-relation-bind` 的输出(关系类型 + 中间视图) 19 - `relation_mapping_draft`:`bkn-map` 的关系类映射结果 20 - `network_dir`:网络目录(`.bkn` 文件位于 `{network_dir}/bkn/`) 21 22 ## 流程 23 24 1. **属性回灌门禁**(P1-2): 25 - 读取 `{network_dir}/pipeline_state.yaml`(文件不存在时视为 `map_completed` 缺失) 26 - **`map_completed == true`** → 继续 27 - **`map_completed == skipped`**(`bind_mode == deferred` 场景)→ 记录 `map_status: skipped (deferred)`,继续 28 - **`map_completed` 不存在或为 false**: 29 - 用户明确要求跳过 → 在 `pipeline_state.yaml` 中追加 `skipped_steps: [bkn-map]`,输出警告后继续 30 - 否则,**阻断并回交 pipeline 调度**,输出: 31 `"bkn-backfill 需要 bkn-map 先执行完成(map_completed 未就绪)。请 pipeline 调度 bkn-map 后再调用本 skill。"` 32 2. 合并绑定变更 + 属性变更 + 映射状态为统一差异清单 33 3. **存储位置过滤**: 34 - 跳过 `存储位置: local` 的对象(本地对象无需资源绑定,不参与回填) 35 - 在输出摘要中单独列出被跳过的 local 对象 36 4. **对象类回填**(仅 platform 对象): 37 - Data Source 绑定值替换(名称/技术名 → 稳定 `resource_id`) 38 - Mapped Field 更新为资源真实属性名 39 - 数据视图中不存在的属性:默认标注 Mapped Field 为 `-`(保留属性定义,便于后续补绑);用户可指定删除该行 40 - 不改动 Description 或其他业务语义字段 41 5. **级联修正**(关键改进): 42 - 构建 `rename_map`:`{object_id: {old_property_name → new_property_name}}` 43 - 来源 1:`bkn-map` 的 `property_regen_summary.rename` 动作(draft 属性名 → 视图字段名) 44 - 来源 2:用户手动指定的属性重命名 45 - 扫描 `{network_dir}/bkn/relation_types/*.bkn` 的 Mapping Rules,将 Source Property / Target Property 中引用了已重命名属性的值替换 46 - 扫描 `{network_dir}/bkn/action_types/*.bkn` 的 Parameter Binding / Pre-conditions,将 Binding 列中引用了已重命名属性的值替换 47 - 级联修正只改引用名,不改语义 48 6. **关系类回填**(新增): 49 - 仅处理 `relation_binding_result` 中 `status: confirmed` 的关系 50 - **direct 类型**: 51 - 回填 Endpoint 表的 Type 列为 `direct` 52 - 回填 Mapping Rules 表(Source Property → Target Property) 53 - **indirect 类型**: 54 - 回填 Endpoint 表的 Type 列为 `indirect` 55 - 回填 Backing Resource 表(Type = resource, ID = backing_resource_id) 56 - 回填 Source Mapping 表(Source Property → Resource Property) 57 - 回填 Target Mapping 表(Resource Property → Target Property) 58 - **pending 关系**: 59 - 仅回填 Endpoint 表(Type 列保留占位符或留空) 60 - Backing Resource / Source/Target Mapping 段不生成 61 - 跳过 `relation_mapping_quality: blocked` 的关系(在输出中标记) 62 7. **推送前关系映射完整性预检**(执行 `../_shared/prepush-validation.md`): 63 - 检查所有 `relation_types` 的 Source/Target Property 是否存在于对应对象的 Data Properties 64 - 检查所有 `action_types` 的 Parameter Binding 属性是否存在于绑定对象的 Data Properties 65 - 检查 Concept Group 成员和 Network Overview 一致性 66 - 检查 indirect 类型关系的 Backing Resource ID 是否非空 67 - 检查 indirect 类型关系的 Source/Target Mapping 属性是否存在于对应资源 schema 68 - `local` 对象跳过属性存在性检查,但仍参与对象存在性检查 69 - `pending` 关系仅 warning,不阻断 70 - **预检失败 → 阻断写入,列出全部错误**,提示修复后重试 71 8. 执行写入(写入 `{network_dir}/bkn/` 下对应的 `.bkn` 文件) 72 9. 回读校验(文件存在、关键字段已替换、级联引用一致、关系类结构完整) 73 10. 输出精简摘要,提示用户检查 74 75 ## 输出 76 77 ```yaml 78 backfill_plan: 79 binding_replacements: [{object, old_value, new_resource_id}] 80 property_changes: [{object, property, action, layer}] 81 cascade_renames: [{file, table, old_ref, new_ref}] 82 # 新增:关系类回填计划 83 relation_replacements: 84 - 关系ID: "" 85 关系名称: "" 86 关系类型: direct | indirect 87 actions: 88 - action: "" # fill_endpoint_type / fill_mapping_view / fill_source_mapping / fill_target_mapping 89 target_section: "" # Endpoint / Backing Resource / Source Mapping / Target Mapping 90 old_value: "" 91 new_value: "" 92 skipped_local_objects: [对象名] 93 skipped_pending_relations: [关系名] # pending 关系,跳过回填 94 map_gate: {map_completed: true|false|skipped, user_skipped_map: true|false, blocked_for_map: true|false} 95 prepush_validation: {status, errors} # 写入前预检结果 96 backfill_status: success | partial | failed 97 verification: 98 files_checked: 0 99 fields_replaced: 0 100 cascade_refs_fixed: 0 101 relations_filled: 0 # 新增:已回填的关系数量 102 pending_relations: 0 # 新增:pending 关系数量 103 issues: [] 104 ``` 105 106 ## 约束 107 108 - 只写 Data Source、Mapped Field 和级联引用,不改业务语义字段 109 - 级联修正仅限属性名引用,不修改关系方向或动作语义 110 - **写入前必须执行 `../_shared/prepush-validation.md` 预检,失败则阻断写入** 111 - **执行回填前必须确认 `map_completed == true` 或 `skipped`,否则阻断并回交 pipeline 调度** 112 - 写入后必须回读校验,包括级联引用一致性 113 - 回填失败时保留差异清单,可重试
openbkn-ai/bkn-engineering/tree/main/skills/bkn-creator/internal/bkn-backfill commit 1f50c0bb47
Frequently asked questions How do I install the Bkn Backfill skill? Run npx skillmds@latest add openbkn-ai/bkn-backfill in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
What does the Bkn Backfill skill do? 将绑定/映射结果写回 .bkn 文件。 It is listed under Coding & Dev Tools on SkillMD.
Is Bkn Backfill safe to use? This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
Which AI agents work with Bkn Backfill? This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Is Bkn Backfill free to use? Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Who published Bkn Backfill? openbkn-ai (@openbkn-ai) published this skill. Their other Agent Skills are listed on their SkillMD profile.