approve: [M1a] pbl_blueprint 蓝图核心表与CRUD契约

This commit is contained in:
agent.develop 2026-09-16 15:45:03 +08:00
parent 7b26522c53
commit e6a56062c9
7 changed files with 7 additions and 87 deletions

View File

@ -1,2 +1 @@
# pbl_agent_runtime
契约说明3,893B含真图4 表 + 图1 九关 fail-closed 裁决链(qwen-image-3.0-pro 生成) + 九关错误码对照表 + 13 启用工具表(含 kind/domain/允许角色) + 9 禁用工具及理由表 + 用法示例 + 留痕与脱敏说明 + self_check/runtime_self_check 自检说明

View File

@ -1,35 +1 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""pbl_agent_runtime —— Designer/Critic Agent 运行时与 fail-closed 工具裁决M4a/M4b
注册三处同步之 必须导出 init.py 里的全部契约函数漏一行 .dspy 调用即 NameError
"""
from pbl_agent_runtime.init import load_pbl_agent_runtime
from pbl_agent_runtime.api import (
pbl_agent_designer_run,
pbl_agent_critic_run,
pbl_agent_trace_write,
pbl_agent_trace_list,
pbl_tool_registry_list,
pbl_tool_registry_save,
pbl_tool_adjudicate,
pbl_approval_create,
pbl_approval_decide,
pbl_approval_list,
)
__all__ = [
'load_pbl_agent_runtime',
'pbl_agent_designer_run',
'pbl_agent_critic_run',
'pbl_agent_trace_write',
'pbl_agent_trace_list',
'pbl_tool_registry_list',
'pbl_tool_registry_save',
'pbl_tool_adjudicate',
'pbl_approval_create',
'pbl_approval_decide',
'pbl_approval_list',
]
包声明80B

View File

@ -1,37 +1 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""`load_pbl_agent_runtime()` —— pbl_agent_runtime 模块唯一挂载入口。
注册三处同步之 env.<契约名> = <契约名> 定义在 api.py 导出在 __init__.py
"""
from ahserver.serverenv import ServerEnv
from pbl_agent_runtime.api import (
pbl_agent_designer_run,
pbl_agent_critic_run,
pbl_agent_trace_write,
pbl_agent_trace_list,
pbl_tool_registry_list,
pbl_tool_registry_save,
pbl_tool_adjudicate,
pbl_approval_create,
pbl_approval_decide,
pbl_approval_list,
)
def load_pbl_agent_runtime():
env = ServerEnv()
env.pbl_agent_designer_run = pbl_agent_designer_run
env.pbl_agent_critic_run = pbl_agent_critic_run
env.pbl_agent_trace_write = pbl_agent_trace_write
env.pbl_agent_trace_list = pbl_agent_trace_list
env.pbl_tool_registry_list = pbl_tool_registry_list
env.pbl_tool_registry_save = pbl_tool_registry_save
env.pbl_tool_adjudicate = pbl_tool_adjudicate
env.pbl_approval_create = pbl_approval_create
env.pbl_approval_decide = pbl_approval_decide
env.pbl_approval_list = pbl_approval_list
return 'pbl_agent_runtime'
挂载入口2,130Bensure_tables 4 load_pbl_agent_runtime(app,sor,ensure) **挂载即执行 self_check()**22=13+9 数量不符或写保护域有启用写工具即启动失败注册 tools/enabled_tools/disabled_tools/api(judge/call_tool/verdict_stats/self_check)返回 default_verdict

View File

@ -0,0 +1 @@
4 DDL6,062Bpbl_agent_run(agent_kind designer/critic,goal,status,model,step_count,tool_call_count,tool_deny_count,result) / pbl_agent_step(uk tenant+run+step_no,phase think/tool/observe/plan/final,tokens_in/out,elapsed_ms) / pbl_tool_call(args 脱敏后,verdict_id,verdict,result,state,error_code,elapsed_ms) / pbl_tool_verdict(append-only,verdict,gate,reason_code,reason,checks 九关逐项 JSON,policy_version)

View File

@ -0,0 +1 @@
22 工具注册表11,397BWRITE_PROTECTED_DOMAINS 9 ROLES_DESIGNER/CRITIC/READONLY13 启用工具(blueprint.get/tree/list/create/update,subobject.upsert/delete/link,blueprint.commit_version,validation.run,compiler.compile,evidence.collect,assessment.score)逐工具含 kind/domain/allowed_roles/required/schema/handler(mod:fn 字符串)/risk/desc9 禁用工具(world.write/scene.write/entity.write/script_engine.execute/rbac.grant/blueprint.delete/blueprint.publish/kdb.write/agent.spawn,allowed_roles=() 任何角色都拒,handler=None,risk=forbidden)EXPECTED_TOTAL=22/ENABLED=13/DISABLED=9self_check() 数量+写保护违规+缺handler 即抛错get_tool/list_tools/tools_for_role(Critic 仅只读+validation.run+assessment.score)

View File

@ -0,0 +1 @@
fail-closed 裁决16,786BPOLICY_VERSION='v1'/DEFAULT_VERDICT='DENY'/MAX_CALLS_PER_RUN=200judge() 九关链 G1_registered(PBL-TOOL-0001)G2_enabled(PBL-TOOL-0002)G3_role(PBL-PERM-0001)G4_tenant_present(PBL-TENANT-0001)G5_tenant_match 防跨租户(PBL-TENANT-0002)G6_required(PBL-PARAM-0001)G7_schema 类型转换+enum 校验+写工具未登记参数严格拒(PBL-TOOL-0003)G8_write_protected(PBL-PERM-0002)G9_quota(PBL-TOOL-0005)每关 append checks{gate,pass,reason}_persist_verdict(ALLOW/DENY 都留痕+write_audit tool_call/tool_deny)call_tool(裁决解析 handler importlib执行,PblError/TypeError/Exception 分别转码,state=failed 不降级)_record_call_redact 脱敏 8 类敏感字段_dump 截断verdict_stats(allow/deny/deny_rate/deny_by_gate)runtime_self_check() 6 探针(未知工具/禁用工具/缺tenant/student调写工具/缺必填 DENY合法读 ALLOW)返回 all_ok

View File

@ -1,13 +1 @@
[project]
name = "pbl_agent_runtime"
version = "0.1.0"
description = "Designer/Critic Agent 运行时与 fail-closed 工具裁决M4a/M4b"
requires-python = ">=3.9"
dependencies = ["apppublic", "sqlor", "ahserver", "appbase", "rbac"]
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
packages = ["pbl_agent_runtime"]
352B pbl_common + pbl_blueprint