# Template Comparison Methodology (标准模版对比)

## When to use
When a client has a standard template and wants to know how their signed contracts deviate from it.
This is an ADD-ON to the portfolio audit workflow — produces an extra column in the Excel summary.

## Setup
1. Locate template file(s) in the client's 参考文件/ directory
2. Read template with python-docx (if .docx) or OCR (if .pdf)
3. Map template articles to a checklist

## Comparison Dimensions

### 1. Missing clauses (模版有但合同缺失)
Check each template article against the actual contract. Flag:
- Entire articles/sections missing
- Sub-clauses within a section that were dropped
- Protective language removed (e.g., "且不承担违约责任")
- Quantitative requirements removed (e.g., time limits, penalty caps)

Risk levels:
- 🔴 高：directly impacts party's core rights (押金退还、法定解除权、发票保护)
- ⚠️ 中：reduces protection but workarounds exist
- Low: cosmetic or minor scope differences

### 2. Added clauses (合同有但模版没有)
Note whether additions are:
- ✅ Favorable to the client
- ❌ Unfavorable (e.g., additional burden of proof requirements)
- Neutral

### 3. Substantive differences (实质性差异)
Side-by-side of same clause with different wording/numbers:
- Notice periods (e.g., 1 month → 3 months)
- Penalty rates (e.g., 0.1‰ vs 0.1% — **watch for OCR errors on ‰**)
- Scope qualifiers added/removed (e.g., "严重影响" vs "影响")
- Rights downgraded (e.g., "征得同意" → "通知")
- Obligation standards changed (e.g., "按现状交付" → "装修保持原状")

## Key articles to always check (rental contracts)

| Template Article | What to check |
|-----------------|---------------|
| 发票条款 | 甲方不开票→乙方可延付不违约？税务损失由谁担？ |
| 押金退还 | 仅"期满"还是"期满/解除/终止"均可退？ |
| 单方解除 | 有无"除法定或本合同约定外"限定？ |
| 甲方违约赔偿 | 是否含退押金+退预付款+装修损失+诉讼费律师费？ |
| 不可抗力范围 | 是否含"政府政策变更"+"行业治理"？还是仅限特定事件？ |
| 无法办证解除 | "房屋本身原因+政策原因"还是仅"政策原因"？ |
| 续租/优先权时限 | 通知期多长？模版通常1个月 |
| 看房权 | "征得同意"还是"通知"？ |
| 迁离标准 | "按现状"还是"保持原状"（暗示恢复义务）？ |
| 甲方备案义务 | 有无时限？不配合有无违约后果？ |
| 竞业限制范围 | "大楼"还是"大楼、商圈等"？ |
| 补充条款 | 是否利用了模版预留的补充条款空间？ |

## Output format for L column (与标准模版差异)

For contracts with MAJOR deviations:
```
⚠️ 与标准模版存在多处重大偏离：
1. 【条款名】模版要求XX；本合同YY
2. 【条款名】模版要求XX；本合同YY
...
✅ [any positive deviation noted]
```

For contracts largely matching template:
```
✅ 与标准模版高度一致，仅以下小偏差：
1. 【条款名】差异描述
...
其余主要条款均与模版一致
```

For contracts SAME-SOURCE as template but with substantive deviations (本合同就是 07 模版填空而成、骨架同源，但个别关键条款被改动/删除 —— 人民中路即此类，最易被误判为"独立友好范本"):
```
✅ 本合同与 07 标准模版同源（系模版填空而成，条款体系/编号/措辞逐条对应），但有以下实质偏离：
1. 🔴【条款名】模版为XX；本合同被改为YY（对乙方不利/缺失关键保护）
2. 🔴【条款名】模版有XX条款；本合同整条删除
...
其余条款与模版一致（含0.1‰逾期、含疫情/行业治理、优先权等模版标配——属同源固有，非本合同特有优势）
```
> ⚠️ **此档对治的典型错误（人民中路实证）**：把模版本身就有的标配条款（0.1‰、含疫情、优先权）当成"本合同特别友好"列为优势，却漏掉真正被改动/删除的实质偏离（抵押"不得→可"、办学许可证免责款被删）。判别口诀：**先认"是不是模版填空而成"——是 → 用本档，差异只写"被改/被删"的地方，绝不把模版标配当本合同优势。**

For non-comparable documents:
```
补充协议，非模版对比范围
```
or
```
物业服务协议，无对应标准模版
```

## Implementation pattern

Use `delegate_task` with two parallel subagents:
1. **Structural comparison subagent**: reads template + actual contracts, produces clause-by-clause diff
2. **Thematic extraction subagent**: extracts specific clause categories the client cares about (e.g., termination, modification, penalties)

Pass to each subagent:
- Template full text
- All contract .md files with their table entry numbers
- Clear focus instructions

After delegation, verify outputs exist and are coherent before incorporating into Excel.

## Thematic risk additions to K column

When the client asks for specific risk categories (e.g., 合同变更与提前解除):
- APPEND to existing K column content with a clear sub-header: `【合同变更与提前解除】`
- Include: notice period, penalty formula, deposit handling, practical implications
- Flag favorable precedents (e.g., a previously successful partial surrender with zero penalty)
- In section 四, add a comprehensive summary with cost estimates for all scenarios

## OCR artifact awareness
- ‰ (千分号) frequently OCR'd as % — flag for manual verification on originals
- Table cells may have garbled column alignment
- Stamps/seals over text cause character corruption
- Article numbering may be inconsistent in OCR output
