feat: add tenant-scoped rule and permission management

This commit is contained in:
wren
2026-05-21 22:03:08 +08:00
parent a2c2bf1969
commit 1f1bccf3b3
193 changed files with 64463 additions and 1771 deletions
@@ -0,0 +1,197 @@
metadata:
type_id: contract.evaluation.delegation
name: 委托评估合同
version: '0.1'
last_updated: '2026-04-14'
parent: contract
classification_keywords:
- 委托评估
- 评估合同
- 房地产评估
description: '最小规则集,用于端到端验证印章 / 签名 / 齐缝章识别流水线。
'
extract:
- group: 默认分组
fields:
- name: 甲方名称
type: string
required_from: draft
desc: 委托估价方(甲方)全称
deep_retry: false
- name: 乙方名称
type: string
required_from: draft
desc: 受托估价方(乙方、评估机构)全称
deep_retry: false
visual_elements:
seals:
- id: 乙方评估机构章
name: 乙方合同专用章 / 公章
required: true
required_from: executed
allowed_types:
- 合同专用章
- 公章
signatures:
- id: 甲乙方代理人签名
name: 甲方 / 乙方法定代表人或代理人手写签名
required: true
required_from: executed
cross_page_seals:
- id: 齐缝章
name: 页间齐缝章
required: true
required_from: executed
rules:
- group: 印章合规
rules:
- rule_id: EVAL-SEAL-001
name: 合同存在合同专用章或公章
risk: high
score: 10
applies_in:
- executed
stages:
- id: '1'
check: visual
element: seal
expect: type_in
allowed_types:
- 合同专用章
- 公章
logic: '1'
messages:
pass: 检测到合同专用章或公章
fail: 未检测到合同专用章或公章
type: deterministic
- rule_id: EVAL-SEAL-002
name: 乙方评估机构章文字匹配
risk: medium
score: 10
applies_in:
- executed
stages:
- id: '1'
check: visual
element: seal
expect: text_match
expected_text: 广东博亿美房地产资产评估有限公司 合同专用章 4453020060917
logic: '1'
messages:
pass: 乙方合同专用章文字命中
fail: 乙方合同专用章文字未命中
type: deterministic
- rule_id: EVAL-CROSS-001
name: 存在齐缝章
risk: high
score: 10
applies_in:
- executed
stages:
- id: '1'
check: visual
element: cross_page_seal
expect: present
min_count: 1
logic: '1'
messages:
pass: 检测到齐缝章
fail: 未检测到齐缝章
type: deterministic
- rule_id: EVAL-CROSS-002
name: 齐缝章两侧对齐且完整
risk: medium
score: 10
applies_in:
- executed
stages:
- id: '1'
check: visual
element: cross_page_seal
expect: complete
logic: '1'
messages:
pass: 齐缝章两半对齐且完整
fail: 齐缝章仅检测到单侧,无法判定完整性
type: deterministic
- group: 签字合规
rules:
- rule_id: EVAL-SIGN-001
name: 合同尾页存在手写签名
risk: high
score: 10
applies_in:
- executed
stages:
- id: '1'
check: visual
element: signature
expect: present
min_count: 2
logic: '1'
messages:
pass: 合同存在甲乙双方的手写签名(≥2
fail: 合同缺少甲方或乙方的手写签名
type: deterministic
- group: 我方权益保护
rules:
- rule_id: EVAL-OUR-001
name: 我方缔约地位及不利条款审查
risk: high
score: 10
stages:
- id: '1'
check: ai
field: ctx
prompt: |-
请基于合同全文判断我方(中国烟草相关公司/专卖局)在本合同中的缔约地位,并审查是否存在强势条款或不利于我方的条款。
合同全文字段来源:ctx。该字段由后端负责注入和匹配。
合同全文:{{ctx}}
评查步骤:
1. 识别合同中是否存在中国烟草相关主体,包括但不限于“中国烟草”“烟草公司”“烟草专卖局”“中烟”“卷烟厂”“烟草工业”“烟草商业”等名称或其分支机构。
2. 判断该主体是我方,并识别我方在合同中的地位:甲方、乙方、发包人、承包人、委托方、受托方、出租方、承租方、出借人、借款人、赠与方、受赠方或其他。
3. 从合同全文审查是否存在明显偏向对方、加重我方责任、限制我方权利、降低对方责任、增加我方付款/赔偿/解除限制/验收风险/知识产权风险/保密风险/争议解决不利风险的条款。
4. 若无法识别我方主体或我方地位,应返回无法判断,并说明原因,不得臆测。
强势或不利条款示例:
- 对方可单方变更、解除、延期履行,而我方缺少对应权利。
- 我方承担高额违约金、无限责任、连带责任或无上限赔偿,对方责任明显较轻。
- 付款条件、验收、交付、质量、质保、知识产权、保密、争议解决、管辖地等安排明显不利于我方。
- 排除或限制我方依法解除、抗辩、追偿、索赔、验收异议或审计监督权利。
请以JSON格式回答:{"passed": true/false, "our_party": "我方主体名称或无法判断", "our_position": "甲方/乙方/发包人/承包人/委托方/受托方/出租方/承租方/出借人/借款人/赠与方/受赠方/其他/无法判断", "has_strong_terms": true/false, "has_unfavorable_terms": true/false, "risk_terms": ["风险条款摘要"], "reason": "判断理由", "suggestion": "修改建议"}
schema:
type: object
required:
- passed
- our_party
- our_position
- has_strong_terms
- has_unfavorable_terms
- reason
properties:
passed:
type: boolean
our_party:
type: string
our_position:
type: string
has_strong_terms:
type: boolean
has_unfavorable_terms:
type: boolean
risk_terms:
type: array
reason:
type: string
suggestion:
type: string
pass_when: passed == True
logic: '1'
messages:
pass: 未发现明显强势条款或不利于我方的条款
fail: 存在强势条款、不利于我方的条款或无法判断我方缔约地位
type: ai_rule