code

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code: Executable Documentation Governance

代码:可执行文档治理

λο.τ :: Vibecode → ExecutableDocumentation
     where τ ∈ {compiles, validates, runs, passes}

compound :: Knowledge → Response → Knowledge
compound K τ = K ∪ crystallize(assess(τ))
λο.τ :: Vibecode → ExecutableDocumentation
     where τ ∈ {compiles, validates, runs, passes}

compound :: Knowledge → Response → Knowledge
compound K τ = K ∪ crystallize(assess(τ))

Metaschema

元Schema

This skill is homoiconic: it enforces the same patterns it describes. The structure mirrors the content; the DAG below governs both skill loading and project governance.
┌─────────────────────────────────────────────────────────────────────┐
│                     PROGRESSIVE LOADING DAG                         │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│  L0: SKILL.md (this file)                                          │
│      │  • Core laws, routing, quick patterns                       │
│      │  • Compound engineering integration                         │
│      │  • Always loaded (~500 lines)                               │
│      │                                                             │
│      ├──► L1: references/laws.md                                   │
│      │        • Seven Laws complete specification                  │
│      │        • Load when: implementing governance                 │
│      │                                                             │
│      ├──► L1: references/executable-doc.md                         │
│      │        • Tier hierarchy, conversion methodology             │
│      │        • Load when: converting docs to code                 │
│      │                                                             │
│      ├──► L1: references/patterns.md                               │
│      │        • TODO management, type documentation                │
│      │        • Load when: establishing patterns                   │
│      │                                                             │
│      ├──► L1: references/compound-engineering.md                   │
│      │        • K' = K ∪ crystallize(assess(τ))                   │
│      │        • Load when: crystallizing learnings                 │
│      │                                                             │
│      ├──► L1: references/abductive-learning.md                     │
│      │        • OHPT protocol for debugging                        │
│      │        • Load when: systematic debugging needed             │
│      │                                                             │
│      ├──► L2: scripts/preflight.py                                 │
│      │        • Execute directly for validation                    │
│      │        • Load when: customizing checks                      │
│      │                                                             │
│      ├──► L2: scripts/validate-skill.py                            │
│      │        • Self-validation (homoiconic)                       │
│      │        • Load when: validating this or other skills         │
│      │                                                             │
│      ├──► L2: hooks/*                                              │
│      │        • Hookify rules for governance + compound learning   │
│      │        • Install via: scripts/install-hooks.sh              │
│      │                                                             │
│      └──► L3: templates/*                                          │
│               • CI/CD configs                                      │
│               • Copy when: initializing projects                   │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘
本技能具备**同态(homoiconic)**特性:它强制执行的模式与自身描述的模式完全一致。结构与内容相互映射;下方的有向无环图(DAG)同时管控技能加载与项目治理。
┌─────────────────────────────────────────────────────────────────────┐
│                     渐进式加载DAG                                  │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│  L0: SKILL.md(本文件)                                             │
│      │  • 核心法则、路由、快速模式                                  │
│      │  • 复合工程集成                                              │
│      │  • 始终加载(约500行)                                        │
│      │                                                             │
│      ├──► L1: references/laws.md                                   │
│      │        • 七大法则完整规范                                    │
│      │        • 加载时机:实施治理机制时                            │
│      │                                                             │
│      ├──► L1: references/executable-doc.md                         │
│      │        • 层级体系、转换方法论                                │
│      │        • 加载时机:将文档转换为代码时                        │
│      │                                                             │
│      ├──► L1: references/patterns.md                               │
│      │        • TODO管理、类型文档                                  │
│      │        • 加载时机:建立模式时                                │
│      │                                                             │
│      ├──► L1: references/compound-engineering.md                   │
│      │        • K' = K ∪ crystallize(assess(τ))                   │
│      │        • 加载时机:固化学习成果时                            │
│      │                                                             │
│      ├──► L1: references/abductive-learning.md                     │
│      │        • 用于调试的OHPT协议                                  │
│      │        • 加载时机:需要系统化调试时                          │
│      │                                                             │
│      ├──► L2: scripts/preflight.py                                 │
│      │        • 直接执行以完成验证                                  │
│      │        • 加载时机:自定义检查规则时                          │
│      │                                                             │
│      ├──► L2: scripts/validate-skill.py                            │
│      │        • 自验证(同态特性)                                  │
│      │        • 加载时机:验证本技能或其他技能时                    │
│      │                                                             │
│      ├──► L2: hooks/*                                              │
│      │        • 用于治理与复合学习的Hookify规则                    │
│      │        • 安装方式:scripts/install-hooks.sh                  │
│      │                                                             │
│      └──► L3: templates/*                                          │
│               • CI/CD配置文件                                      │
│               • 复制时机:初始化项目时                              │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

The Seven Laws

七大法则

haskell
-- Core invariants (see references/laws.md for complete spec)
LAW_1:fFeatures. deployed(f)e2e_verified(f)
LAW_2:eExecutions. observable(e)traceable(e)
LAW_3:rCriticalRules. script_enforced(r)
LAW_4:prPRs. merged(pr)human_reviewed(pr)
LAW_5:dAuthoritativeDoc. dCodebase
LAW_6: compiles(d)validates(d)current(d)
LAW_7:planPlans. expressed_as_todos(plan)in_code(plan)
haskell
-- 核心不变量(完整规范请参考references/laws.md)
LAW_1:fFeatures. deployed(f)e2e_verified(f)
LAW_2:eExecutions. observable(e)traceable(e)
LAW_3:rCriticalRules. script_enforced(r)
LAW_4:prPRs. merged(pr)human_reviewed(pr)
LAW_5:dAuthoritativeDoc. dCodebase
LAW_6: compiles(d)validates(d)current(d)
LAW_7:planPlans. expressed_as_todos(plan)in_code(plan)

Routing

路由机制

python
def route(task: Task) -> Pipeline:
    """Route task to appropriate governance level."""
    
    if task.type == "simple_change":
        return R1_SINGLE  # Preflight only
    
    if task.type == "feature":
        return R2_COMPOSE  # Preflight → E2E → Log review
    
    if task.type in ["architecture", "governance", "release"]:
        return R3_FULL  # Full Seven Laws verification
    
    return R0_DIRECT  # No governance (rare)
LevelPipelineVerification
R0DirectNone
R1
preflight
Types, schemas, linting
R2
preflight → e2e → logs
+ Runtime behavior
R3
full_governance
All Seven Laws
python
def route(task: Task) -> Pipeline:
    """将任务路由至对应的治理层级。"""
    
    if task.type == "simple_change":
        return R1_SINGLE  # 仅执行预检
    
    if task.type == "feature":
        return R2_COMPOSE  # 预检 → E2E测试 → 日志审核
    
    if task.type in ["architecture", "governance", "release"]:
        return R3_FULL  # 完整七大法则验证
    
    return R0_DIRECT  # 无治理(罕见情况)
层级流水线验证内容
R0直接执行
R1
preflight
类型、Schema、代码规范检查
R2
preflight → e2e → logs
+ 运行时行为验证
R3
full_governance
所有七大法则

Quick Start

快速开始

1. Initialize Project Governance

1. 初始化项目治理机制

bash
undefined
bash
undefined

Copy governance templates to project

将治理模板复制到项目中

cp templates/ci.yml ./.github/workflows/
cp templates/ci.yml ./.github/workflows/

Run preflight to verify setup

运行预检以验证设置

python scripts/preflight.py --init
python scripts/preflight.py --init

Install governance hooks (optional)

安装治理钩子(可选)

bash scripts/install-hooks.sh
undefined
bash scripts/install-hooks.sh
undefined

2. Establish Executable Documentation

2. 建立可执行文档

python
undefined
python
undefined

BAD: External documentation (will drift)

错误示例:外部文档(会出现偏差)

docs/api.md: "User endpoint returns JSON with name and email"

docs/api.md: "用户接口返回包含name和email的JSON"

GOOD: Type as documentation (compiles = current)

正确示例:用类型作为文档(编译通过即代表文档是最新的)

@dataclass class UserResponse: """User endpoint response. If this compiles, docs are current.""" name: str email: EmailStr created_at: datetime
undefined
@dataclass class UserResponse: """用户接口响应。如果该类编译通过,说明文档是最新的。""" name: str email: EmailStr created_at: datetime
undefined

3. Plan with TODOs

3. 使用TODO进行规划

python
undefined
python
undefined

Instead of external implementation plan, use in-code TODOs:

不要使用外部实现计划,而是使用代码内的TODO:

TODO(auth-1,required): Implement password hashing

TODO(auth-1,required): 实现密码哈希

Context: Security requirement SR-101

背景:安全需求SR-101

Acceptance: bcrypt cost factor 12, no plaintext storage

验收标准:bcrypt成本因子为12,不存储明文密码

TODO(auth-2): Add rate limiting

TODO(auth-2): 添加速率限制

Context: Prevent brute force per SR-102

背景:根据SR-102防止暴力破解

Approach: Redis sliding window, 5 attempts/minute

实现方案:Redis滑动窗口,每分钟5次尝试

async def login(credentials: LoginCredentials) -> AuthResult: # Implementation replaces TODOs as work completes pass
undefined
async def login(credentials: LoginCredentials) -> AuthResult: # 实现完成后替换TODO pass
undefined

4. Validate Before Merge

4. 合并前验证

bash
undefined
bash
undefined

Run preflight (automatically runs in CI)

运行预检(CI中会自动执行)

python scripts/preflight.py
python scripts/preflight.py

Check remaining TODOs

检查剩余的必填TODO

grep -rn "TODO(.required" --include=".py" --include="*.ts" src/
grep -rn "TODO(.required" --include=".py" --include="*.ts" src/

Generate architecture diagram (from code, not hand-drawn)

从代码生成架构图(而非手绘)

npx madge --image docs/deps.svg src/
undefined
npx madge --image docs/deps.svg src/
undefined

Executable Documentation Hierarchy

可执行文档层级

TierFormTrustVerification
T1Type signatures0.95Compiler
T2Schema definitions0.95Validator
T3API specs (generated)0.95Generator
T4Database migrations0.95Migration runner
T5Linter rules0.90Linter
T6Test assertions0.70Test runner
T7TODOs in code0.60Grep/lint
T8Inline comments0.50Localized drift
T9External docs0.10Will drift
Governing Principle:
IF    types check       (T1)
AND   schemas validate  (T2)
AND   specs generate    (T3)
AND   migrations run    (T4)
AND   linters pass      (T5)
AND   todos resolved    (T7)
THEN  documentation IS current
层级形式可信度验证方式
T1类型签名0.95编译器
T2Schema定义0.95验证器
T3API规范(生成)0.95生成器
T4数据库迁移脚本0.95迁移执行器
T5代码规范规则0.90代码检查工具
T6测试断言0.70测试执行器
T7代码中的TODO0.60Grep/代码检查
T8行内注释0.50局部偏差
T9外部文档0.10会出现偏差
治理原则:
如果    类型检查通过       (T1)
且      Schema验证通过  (T2)
且      规范生成完成    (T3)
且      迁移脚本执行通过    (T4)
且      代码检查通过      (T5)
且      必填TODO已解决    (T7)
那么  文档是最新的

Conversion Methodology

转换方法论

When documentation is needed, convert to code-based form:
python
def document_in_code(need: str) -> CodeDoc:
    """Convert documentation need to executable form."""
    
    # Priority order: higher tier = more trustworthy
    if can_express_as_type(need):
        return TypeDefinition(need)  # T1
    
    if can_express_as_schema(need):
        return SchemaDefinition(need)  # T2
    
    if can_express_as_linter_rule(need):
        return LinterRule(need)  # T5
    
    if can_express_as_test(need):
        return TestCase(need)  # T6, with tautology caveat
    
    if can_express_as_todo(need):
        return TODO(need)  # T7
    
    # Last resort: inline comment (T8)
    # NEVER external doc (T9)
    return InlineComment(need)
For complete conversion patterns, load:
references/executable-doc.md
当需要文档时,将其转换为基于代码的形式:
python
def document_in_code(need: str) -> CodeDoc:
    """将文档需求转换为可执行形式。"""
    
    # 优先级顺序:层级越高,可信度越高
    if can_express_as_type(need):
        return TypeDefinition(need)  # T1
    
    if can_express_as_schema(need):
        return SchemaDefinition(need)  # T2
    
    if can_express_as_linter_rule(need):
        return LinterRule(need)  # T5
    
    if can_express_as_test(need):
        return TestCase(need)  # T6,注意同义反复问题
    
    if can_express_as_todo(need):
        return TODO(need)  # T7
    
    # 最后选择:行内注释(T8)
    # 绝对不要使用外部文档(T9)
    return InlineComment(need)
完整转换模式请参考:
references/executable-doc.md

Preflight Script

预检脚本

Core validation that runs before every commit:
bash
#!/bin/bash
每次提交前运行的核心验证脚本:
bash
#!/bin/bash

Minimal preflight example — run python scripts/preflight.py for full version

极简预检示例 — 完整版本请运行python scripts/preflight.py

set -e
echo "=== PREFLIGHT: Executable Documentation Verification ==="
set -e
echo "=== 预检:可执行文档验证 ==="

T1: Types compile

T1:类型编译通过

npm run typecheck || { echo "❌ Types invalid"; exit 1; }
npm run typecheck || { echo "❌ 类型无效"; exit 1; }

T2: Schemas validate

T2:Schema验证通过

npm run validate:schemas || { echo "❌ Schemas invalid"; exit 1; }
npm run validate:schemas || { echo "❌ Schema无效"; exit 1; }

T5: Linting passes

T5:代码规范检查通过

npm run lint || { echo "❌ Linting failed"; exit 1; }
npm run lint || { echo "❌ 代码规范检查失败"; exit 1; }

T7: Required TODOs resolved

T7:必填TODO已解决

grep -rn "TODO(.*required" src/ && { echo "❌ Required TODOs remain"; exit 1; }
echo "✅ Preflight passed"

**For complete preflight implementation, run:** `python scripts/preflight.py`
grep -rn "TODO(.*required" src/ && { echo "❌ 仍有必填TODO未解决"; exit 1; }
echo "✅ 预检通过"

**完整预检实现请运行:** `python scripts/preflight.py`

TODO Categories

TODO分类

python
undefined
python
undefined

Standard categories for TODO-based planning:

基于TODO规划的标准分类:

TODO(feature-id): Standard task

TODO(feature-id): 标准任务

TODO(feature-id,required): Must complete before merge (blocks CI)

TODO(feature-id,required): 合并前必须完成(会阻塞CI)

TODO(feature-id,blocked:other): Waiting on dependency

TODO(feature-id,blocked:other): 等待依赖项完成

TODO(tech-debt): Known improvement needed

TODO(tech-debt): 已知需要改进的技术债务

TODO(security): Security-related (high priority)

TODO(security): 安全相关任务(高优先级)

FIXME: Known bug requiring fix

FIXME: 需要修复的已知bug

HACK: Temporary solution needing proper implementation

HACK: 需要优化的临时解决方案


**Lifecycle:**
PLAN → Write TODOs at implementation points DEVELOP → Implement, remove TODO when done VERIFY → grep for remaining TODOs COMPLETE → Zero required TODOs = feature complete

**For TODO management, use:** `grep -rn "TODO(.*required" --include="*.py" --include="*.ts" src/`

**生命周期:**
规划 → 在实现点编写TODO 开发 → 实现功能,完成后移除TODO 验证 → 搜索剩余的TODO 完成 → 无必填TODO即代表功能完成

**TODO管理命令:** `grep -rn "TODO(.*required" --include="*.py" --include="*.ts" src/`

Unit Test Skepticism (LAW_3 Caveat)

单元测试质疑(法则3注意事项)

python
undefined
python
undefined

WARNING: AI writes tautological tests

警告:AI会编写同义反复的测试

Test documents what code DOES, not what code SHOULD DO

测试验证的是代码当前的行为,而非代码应该实现的需求

REQUIREMENT: "Users can log in with valid credentials"

需求:"用户可以使用有效凭据登录"

AI IMPLEMENTATION (buggy):

AI实现(存在bug):

def authenticate(user, password): return True # BUG: Always succeeds
def authenticate(user, password): return True # Bug:始终返回成功

AI TEST (tautological):

AI测试(同义反复):

def test_authenticate(): assert authenticate("user", "pass") == True # ✓ PASSES! # Test verifies implementation, not requirement

**Mitigation:**
- E2E tests verify actual behavior (LAW_1)
- Human review verifies intent (LAW_4)
- Unit tests provide regression protection only
- Trust hierarchy: `E2E (0.9) > Review (0.75) > Unit (0.3)`
def test_authenticate(): assert authenticate("user", "pass") == True # ✓ 测试通过! # 测试验证的是实现,而非需求

**缓解方案:**
- E2E测试验证实际行为(法则1)
- 人工审核验证需求意图(法则4)
- 单元测试仅用于回归保护
- 可信度层级:`E2E (0.9) > 人工审核 (0.75) > 单元测试 (0.3)`

Diagram Generation

图表生成

Generate diagrams from code, never hand-draw:
bash
undefined
从代码生成图表,绝对不要手绘:
bash
undefined

Dependency graph from imports

从导入关系生成依赖图

npx madge --image docs/deps.svg src/
npx madge --image docs/deps.svg src/

Type relationships

类型关系图

npx ts-diagram src/ > docs/types.mmd
npx ts-diagram src/ > docs/types.mmd

Database schema from migrations

从迁移脚本生成数据库Schema

pg_dump --schema-only | sqlt-graph > docs/schema.svg
pg_dump --schema-only | sqlt-graph > docs/schema.svg

OpenAPI from annotations (generated = current)

从注解生成OpenAPI(生成即代表最新)

npm run generate:openapi

**Use standard tools:** `npx madge`, `npx ts-diagram`, `pg_dump | sqlt-graph`
npm run generate:openapi

**使用标准工具:** `npx madge`, `npx ts-diagram`, `pg_dump | sqlt-graph`

Self-Validation (Homoiconicity)

自验证(同态特性)

This skill validates itself using the same rules it prescribes:
python
undefined
本技能使用自身规定的规则进行自验证:
python
undefined

scripts/validate-skill.py validates:

scripts/validate-skill.py验证以下内容:

1. SKILL.md under 500 lines ✓

1. SKILL.md不超过500行 ✓

2. References progressively loaded ✓

2. 参考文档渐进式加载 ✓

3. Scripts executable ✓

3. 脚本可执行 ✓

4. No external docs (only code-based) ✓

4. 无外部文档(仅使用基于代码的形式) ✓

5. DAG structure maintained ✓

5. DAG结构保持完整 ✓


Run: `python scripts/validate-skill.py code/`

运行命令:`python scripts/validate-skill.py code/`

Compound Engineering

复合工程

The self-improvement loop that makes knowledge recursive:
haskell
compound :: KnowledgeResponseKnowledge
compound K τ = Kcrystallize(assess(τ))

-- K grows monotonically; never loses valid knowledge
-- Crystallization compresses: raw experience → reusable pattern
使知识具备递归性的自我改进循环:
haskell
compound :: KnowledgeResponseKnowledge
compound K τ = Kcrystallize(assess(τ))

-- K单调增长;永远不会丢失有效知识
-- 固化过程将原始经验压缩为可复用模式

The Compound Loop

复合循环

Plan(K) → Execute → Assess → Compound(K→K')
   ↑                              |
   └────────── K' ────────────────┘
Each iteration makes the next easier, not harder.
规划(K) → 执行 → 评估 → 复合(K→K')
   ↑                              |
   └────────── K' ────────────────┘
每次迭代都会让下一次工作更简单,而非更复杂。

Trigger Detection

触发检测

Compound when resolution patterns detected:
PatternExampleAction
Confirmation"that worked", "correct"Extract solution
Insight"I see now", "the key is"Extract principle
Prevention"next time", "to avoid"Extract guard
Connection"this relates to", "like"Extract vertex
当检测到解决模式时触发复合过程:
模式示例操作
确认"这个有效", "正确"提取解决方案
洞察"我现在明白了", "关键是"提取原则
预防"下次", "避免"提取防护规则
关联"这与...相关", "类似"提取关联顶点

Learning Crystallization

学习成果固化

yaml
undefined
yaml
undefined

Required schema for compounded learnings

复合学习成果的必填Schema

date: YYYY-MM-DD trigger: "what initiated learning" domain: "coding|debugging|architecture|..." observation: "what was observed" hypothesis: "best explanation" root_cause: "fundamental cause (not surface)" solution: "what worked" why_works: "mechanistic explanation" prevention: "how to avoid in future" vertices:
  • "[[shared concept 1]]"
  • "[[shared concept 2]]" confidence: 0.85

**Validation before adding to K:**
- [ ] Has >=2 shared vertices with existing K
- [ ] Root cause is fundamental (not surface symptom)
- [ ] Solution is generalizable (not one-off)
- [ ] Prevention is actionable

**For complete compound engineering spec, load:** `references/compound-engineering.md`
date: YYYY-MM-DD trigger: "触发学习的事件" domain: "coding|debugging|architecture|..." observation: "观察到的内容" hypothesis: "最佳解释" root_cause: "根本原因(而非表面症状)" solution: "有效的解决方案" why_works: "机制性解释" prevention: "未来如何避免" vertices:
  • "[[共享概念1]]"
  • "[[共享概念2]]" confidence: 0.85

**添加至K前的验证项:**
- [ ] 与现有K至少有2个共享顶点
- [ ] 根本原因是本质问题(而非表面症状)
- [ ] 解决方案具备通用性(而非一次性方案)
- [ ] 预防措施可执行

**完整复合工程规范请参考:** `references/compound-engineering.md`

Abductive Learning (OHPT Protocol)

溯因学习(OHPT协议)

Inference to the best explanation for systematic debugging:
O (Observation) → H (Hypothesis) → P (Prediction) → T (Test)
PhaseQuestionOutput
OWhat was observed?Symptom description
HWhat explains O?Candidate causes (ranked by parsimony)
PIf H true, what else?Testable predictions
TDoes P hold?Evidence confirming/refuting H
用于系统化调试的最佳解释推理:
O(观察)→ H(假设)→ P(预测)→ T(测试)
阶段问题输出
O观察到了什么?症状描述
H什么可以解释O?候选原因(按简洁性排序)
P如果H成立,还会发生什么?可测试的预测
TP是否成立?确认/反驳H的证据

Quick Template

快速模板

python
"""
O: [What was observed - be specific]
H: [Best explanation - testable, parsimonious]
P: [If H true, then... - observable consequences]
T: [Test result - confirms/refutes H]
"""
For complete OHPT protocol, load:
references/abductive-learning.md
python
"""
O: [观察到的具体内容]
H: [最佳解释 - 可测试、简洁]
P: [如果H成立,则会... - 可观察的结果]
T: [测试结果 - 确认/反驳H]
"""
完整OHPT协议请参考:
references/abductive-learning.md

Hookify Integration

Hookify集成

Governance enforcement through hookify rules:
HookEventPurpose
law1-e2e-deploy
bashVerify E2E before deploy
law2-observability
fileWarn on debug logging
law5-external-docs
fileBlock external documentation
law6-compile-current
bashCheck types before merge
law7-required-todos
bashVerify TODOs resolved
stop-checklist
stopSeven Laws completion check
tautological-tests
fileDetect test anti-patterns
compound-learning
stopPrompt crystallization
abductive-hypothesis
fileRequire OHPT in tests
knowledge-monotonicity
filePrevent knowledge deletion
vertex-sharing
fileRequire vertex connections
inference-chain
fileComplete reasoning chains
pattern-crystallization
bashExtract on commits
Install hooks:
bash scripts/install-hooks.sh
通过Hookify规则实现治理机制:
钩子事件目的
law1-e2e-deploy
bash部署前验证E2E测试
law2-observability
file对调试日志发出警告
law5-external-docs
file阻止外部文档
law6-compile-current
bash合并前检查类型
law7-required-todos
bash验证TODO已解决
stop-checklist
stop七大法则完成检查
tautological-tests
file检测测试反模式
compound-learning
stop触发学习成果固化
abductive-hypothesis
file测试中要求使用OHPT
knowledge-monotonicity
file防止知识删除
vertex-sharing
file要求关联顶点
inference-chain
file完整推理链
pattern-crystallization
bash提交时提取模式
安装钩子:
bash scripts/install-hooks.sh

Integration Points

集成点

SkillIntegration
graph
Topology validation (η ≥ 4)
critique
Multi-lens code review
hierarchical-reasoning
S→T→O decomposition
component
Generate CI/CD configs
skill-optimiser
Validate this skill
learn
Compound engineering loop
ultrawork
Parallel governance checks
技能集成方式
graph
拓扑验证(η ≥ 4)
critique
多维度代码审核
hierarchical-reasoning
S→T→O分解
component
生成CI/CD配置
skill-optimiser
验证本技能
learn
复合工程循环
ultrawork
并行治理检查

File Structure

文件结构

code/
├── SKILL.md                    # This file (L0)
├── references/
│   ├── laws.md                 # Seven Laws complete spec (L1)
│   ├── executable-doc.md       # Tier system, conversion (L1)
│   ├── patterns.md             # TODO, types, diagrams (L1)
│   ├── compound-engineering.md # K' = K ∪ crystallize(assess(τ)) (L1)
│   └── abductive-learning.md   # OHPT debugging protocol (L1)
├── scripts/
│   ├── preflight.py            # Validation orchestration (L2)
│   ├── validate-skill.py       # Self-validation (L2)
│   └── install-hooks.sh        # Install governance hooks (L2)
├── templates/
│   └── ci.yml                  # GitHub Actions template (L3)
└── hooks/                      # Hookify governance + compound rules
    ├── hookify.law1-e2e-deploy.local.md
    ├── hookify.law2-observability.local.md
    ├── hookify.law5-external-docs.local.md
    ├── hookify.law6-compile-current.local.md
    ├── hookify.law7-required-todos.local.md
    ├── hookify.stop-checklist.local.md
    ├── hookify.tautological-tests.local.md
    ├── hookify.compound-learning.local.md      # Crystallize before stop
    ├── hookify.abductive-hypothesis.local.md   # OHPT in tests
    ├── hookify.knowledge-monotonicity.local.md # K never shrinks
    ├── hookify.vertex-sharing.local.md         # Require connections
    ├── hookify.inference-chain.local.md        # Complete reasoning
    └── hookify.pattern-crystallization.local.md # Extract on commit
code/
├── SKILL.md                    # 本文件(L0)
├── references/
│   ├── laws.md                 # 七大法则完整规范(L1)
│   ├── executable-doc.md       # 层级体系、转换方法(L1)
│   ├── patterns.md             # TODO、类型、图表(L1)
│   ├── compound-engineering.md # K' = K ∪ crystallize(assess(τ))(L1)
│   └── abductive-learning.md   # OHPT调试协议(L1)
├── scripts/
│   ├── preflight.py            # 验证编排(L2)
│   ├── validate-skill.py       # 自验证(L2)
│   └── install-hooks.sh        # 安装治理钩子(L2)
├── templates/
│   └── ci.yml                  # GitHub Actions模板(L3)
└── hooks/                      # Hookify治理与复合学习规则
    ├── hookify.law1-e2e-deploy.local.md
    ├── hookify.law2-observability.local.md
    ├── hookify.law5-external-docs.local.md
    ├── hookify.law6-compile-current.local.md
    ├── hookify.law7-required-todos.local.md
    ├── hookify.stop-checklist.local.md
    ├── hookify.tautological-tests.local.md
    ├── hookify.compound-learning.local.md      # 停止前固化学习成果
    ├── hookify.abductive-hypothesis.local.md   # 测试中使用OHPT
    ├── hookify.knowledge-monotonicity.local.md # K永不缩减
    ├── hookify.vertex-sharing.local.md         # 要求关联顶点
    ├── hookify.inference-chain.local.md        # 完整推理链
    └── hookify.pattern-crystallization.local.md # 提交时提取模式

Holarchic Structure

层级结构

Every component is a complete holon:
SKILL (this file)
  ├── Contains: Complete governance framework
  ├── Validates: Itself via scripts/validate-skill.py
  └── Holons:
        ├── preflight.py
        │   ├── Contains: Complete validation pipeline
        │   ├── Validates: Project code
        │   └── Holons: Individual check functions
        ├── hooks/*
        │   ├── Contains: Seven Laws enforcement rules
        │   ├── Validates: Via hookify plugin
        │   └── Holons: Individual law-specific rules
        └── templates/*
            ├── Contains: Complete project setup
            ├── Validates: Via instantiation
            └── Holons: Individual config files
Scale invariance:
λο.τ
applies at every level—skill, script, function, line.

┌─────────────────────────────────────────────────────────────────┐
│  SEVEN LAWS          │  TRUST HIERARCHY    │  VERIFICATION     │
├──────────────────────┼─────────────────────┼───────────────────┤
│  1. E2E verified     │  Types (0.95)       │  Compiles         │
│  2. Observable       │  Schemas (0.95)     │  Validates        │
│  3. Script enforced  │  E2E (0.90)         │  Passes           │
│  4. Human reviewed   │  Review (0.75)      │  Approved         │
│  5. Code is doc      │  Unit (0.30)        │  (Low trust)      │
│  6. Compile=current  │  External (0.10)    │  (Will drift)     │
│  7. TODOs are plans  │                     │                   │
└──────────────────────┴─────────────────────┴───────────────────┘
每个组件都是一个完整的子系统:
SKILL(本文件)
  ├── 包含:完整治理框架
  ├── 验证:通过scripts/validate-skill.py自验证
  └── 子系统:
        ├── preflight.py
        │   ├── 包含:完整验证流水线
        │   ├── 验证:项目代码
        │   └── 子系统:单个检查函数
        ├── hooks/*
        │   ├── 包含:七大法则强制执行规则
        │   ├── 验证:通过Hookify插件
        │   └── 子系统:单个法则相关规则
        └── templates/*
            ├── 包含:完整项目初始化配置
            ├── 验证:通过实例化
            └── 子系统:单个配置文件
尺度不变性:
λο.τ
适用于每个层级——技能、脚本、函数、代码行。

┌─────────────────────────────────────────────────────────────────┐
│  七大法则          │  可信度层级    │  验证方式     │
├──────────────────────┼─────────────────────┼───────────────────┤
│  1. E2E验证通过     │  类型(0.95)       │  编译通过         │
│  2. 可观察性       │  Schema(0.95)     │  验证通过        │
│  3. 脚本强制执行  │  E2E(0.90)         │  测试通过           │
│  4. 人工审核通过   │  审核(0.75)      │  已批准         │
│  5. 代码即文档      │  单元测试(0.30)        │  (可信度低)      │
│  6. 编译通过即最新  │  外部文档(0.10)    │  (会出现偏差)     │
│  7. TODO即规划      │                     │                   │
└──────────────────────┴─────────────────────┴───────────────────┘