mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-09-24 23:10:56 +08:00
5.1 KiB
5.1 KiB
ModalityRuntimeContract Schema
状态:current planning source
更新时间:2026-04-29
目标:定义 Lime 多模态底层运行合同的机器可检查结构,确保@命令、按钮和 Scene 只能绑定到底层 contract,而不是反过来决定运行事实源。
1. Schema 事实源
当前机器可检查事实源:
- Registry:
src/lib/governance/modalityRuntimeContracts.json - Capability Matrix:
src/lib/governance/modalityCapabilityMatrix.json - Check:
scripts/check-modality-runtime-contracts.mjs - npm 入口:
npm run governance:modality-contracts
本文件解释字段语义;JSON registry 是校验输入。
2. 核心原则
contract_key代表底层多模态运行能力,例如image_generation、browser_control、pdf_extract。contract_key不代表上层入口,不能写成@配图、@浏览器或/scene-key。bound_entries在 Phase 0/1 可以为空;进入 Phase 7 后按 contract 逐条把@、按钮和 Scene 绑定进来。- 每个 contract 必须能解释 identity、capability、profile、executor、truth source、artifact、viewer、evidence。
required_capabilities必须全部出现在 capability-matrix.md。routing_slot必须出现在 capability matrix 的model_roles。- contract 不允许引用不存在的 artifact kind、viewer surface、permission key 或 evidence event。
3. 顶层结构
{
"version": 1,
"status": "current",
"owner": "docs/roadmap/warp/contract-schema.md",
"contracts": []
}
4. Contract 字段
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
contract_key |
string | 是 | 底层能力主键,不能是入口名 |
lifecycle |
string | 是 | current / compat / deprecated / dead |
modality |
string | 是 | text / image / audio / video / browser / document / code / mixed |
runtime_identity |
string[] | 是 | 运行关联键,例如 session_id、thread_id、turn_id |
input_context_kinds |
string[] | 是 | 输入上下文类型 |
required_capabilities |
string[] | 是 | 模型/工具/执行能力需求 |
permission_profile_keys |
string[] | 是 | 权限面需求 |
routing_slot |
string | 是 | 模型角色槽位 |
executor_binding |
object | 是 | 执行器描述 |
truth_source |
string[] | 是 | 唯一事实源 |
artifact_kinds |
string[] | 是 | 输出 artifact kind |
viewer_surface |
string[] | 是 | viewer / workspace 消费面 |
evidence_events |
string[] | 是 | evidence pack 必须导出的事件 |
limecore_policy_refs |
string[] | 是 | LimeCore 只作为目录/策略/offer/audit 事实源 |
fallback_policy |
string[] | 是 | 降级或阻断策略 |
detour_policy |
object | 是 | 允许/禁止的偏航工具 |
owner_surface |
string | 是 | current owner |
bound_entries |
object[] | 是 | 上层入口绑定;Phase 0/1 默认允许为空 |
5. Executor binding
{
"executor_kind": "skill",
"binding_key": "image_generate",
"current_path": "Agent turn -> Skill(image_generate) -> image task artifact",
"supports_progress": true,
"supports_cancel": true,
"supports_resume": false,
"supports_artifact": true,
"failure_mapping": ["permission_denied", "capability_gap", "executor_error"]
}
固定约束:
local_cli只能作为 typed adapter。- 不支持 progress / cancel / resume / artifact 的 executor 必须显式写
false。 - executor 失败必须映射到可解释原因,不能只返回普通文本。
6. Entry binding
Phase 7 才允许大量补 entry binding。
结构:
{
"entry_key": "at_image_generate",
"entry_kind": "command",
"display_name": "@配图",
"launch_metadata_path": "harness.image_skill_launch",
"entry_source": "at_image_command",
"default_input_mapping": ["user_text", "selected_assets"],
"entry_visibility_policy": ["skill_catalog_visible", "profile_allows_image_generation"]
}
固定约束:
- Entry binding 必须引用已存在的
contract_key。 - Entry binding 不得拥有
truth_source、artifact_kinds、viewer_surface。 - Entry binding 只补 launch metadata、
entry_source和 input mapping。 launch_metadata_path必须指向harness.*,避免入口直接绕到 task / artifact 层。
7. 首批 contract
首批 registry 先覆盖底层能力;image_generation 已作为第一条 vertical slice 进入 Phase 7 entry binding:
image_generationbrowser_controlpdf_extractvoice_generationweb_research
这些 contract 用于验证 schema 和治理守卫;后续 vertical slice 继续按“先底层、后 entry binding”的顺序推进。
8. 校验入口
npm run governance:modality-contracts
通过标准:
- 所有必填字段存在。
- 所有数组字段非空,除
bound_entries可为空。 contract_key唯一且不是入口名。- 枚举字段使用已知值。
- executor binding 声明能力与 failure mapping。
- entry binding 不携带底层事实源字段。
- entry binding 必须声明
entry_source,且launch_metadata_path必须留在harness.*。