code
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode: 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: ∀f ∈ Features. deployed(f) ⟹ e2e_verified(f)
LAW_2: ∀e ∈ Executions. observable(e) ∧ traceable(e)
LAW_3: ∀r ∈ CriticalRules. script_enforced(r)
LAW_4: ∀pr ∈ PRs. merged(pr) ⟹ human_reviewed(pr)
LAW_5: ∀d ∈ AuthoritativeDoc. d ⊂ Codebase
LAW_6: compiles(d) ∨ validates(d) ⟹ current(d)
LAW_7: ∀plan ∈ Plans. expressed_as_todos(plan) ∧ in_code(plan)haskell
-- 核心不变量(完整规范请参考references/laws.md)
LAW_1: ∀f ∈ Features. deployed(f) ⟹ e2e_verified(f)
LAW_2: ∀e ∈ Executions. observable(e) ∧ traceable(e)
LAW_3: ∀r ∈ CriticalRules. script_enforced(r)
LAW_4: ∀pr ∈ PRs. merged(pr) ⟹ human_reviewed(pr)
LAW_5: ∀d ∈ AuthoritativeDoc. d ⊂ Codebase
LAW_6: compiles(d) ∨ validates(d) ⟹ current(d)
LAW_7: ∀plan ∈ Plans. 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)| Level | Pipeline | Verification |
|---|---|---|
| R0 | Direct | None |
| R1 | | Types, schemas, linting |
| R2 | | + Runtime behavior |
| R3 | | 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 | | 类型、Schema、代码规范检查 |
| R2 | | + 运行时行为验证 |
| R3 | | 所有七大法则 |
Quick Start
快速开始
1. Initialize Project Governance
1. 初始化项目治理机制
bash
undefinedbash
undefinedCopy 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
undefinedbash scripts/install-hooks.sh
undefined2. Establish Executable Documentation
2. 建立可执行文档
python
undefinedpython
undefinedBAD: 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
undefined3. Plan with TODOs
3. 使用TODO进行规划
python
undefinedpython
undefinedInstead 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
undefinedasync def login(credentials: LoginCredentials) -> AuthResult:
# 实现完成后替换TODO
pass
undefined4. Validate Before Merge
4. 合并前验证
bash
undefinedbash
undefinedRun 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/
undefinednpx madge --image docs/deps.svg src/
undefinedExecutable Documentation Hierarchy
可执行文档层级
| Tier | Form | Trust | Verification |
|---|---|---|---|
| T1 | Type signatures | 0.95 | Compiler |
| T2 | Schema definitions | 0.95 | Validator |
| T3 | API specs (generated) | 0.95 | Generator |
| T4 | Database migrations | 0.95 | Migration runner |
| T5 | Linter rules | 0.90 | Linter |
| T6 | Test assertions | 0.70 | Test runner |
| T7 | TODOs in code | 0.60 | Grep/lint |
| T8 | Inline comments | 0.50 | Localized drift |
| T9 | External docs | 0.10 | Will 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 | 编译器 |
| T2 | Schema定义 | 0.95 | 验证器 |
| T3 | API规范(生成) | 0.95 | 生成器 |
| T4 | 数据库迁移脚本 | 0.95 | 迁移执行器 |
| T5 | 代码规范规则 | 0.90 | 代码检查工具 |
| T6 | 测试断言 | 0.70 | 测试执行器 |
| T7 | 代码中的TODO | 0.60 | Grep/代码检查 |
| 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.mdPreflight Script
预检脚本
Core validation that runs before every commit:
bash
#!/bin/bash每次提交前运行的核心验证脚本:
bash
#!/bin/bashMinimal 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
undefinedpython
undefinedStandard 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
undefinedpython
undefinedWARNING: 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
undefinedDependency 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
undefinedscripts/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 :: Knowledge → Response → Knowledge
compound K τ = K ∪ crystallize(assess(τ))
-- K grows monotonically; never loses valid knowledge
-- Crystallization compresses: raw experience → reusable pattern使知识具备递归性的自我改进循环:
haskell
compound :: Knowledge → Response → Knowledge
compound K τ = K ∪ crystallize(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:
| Pattern | Example | Action |
|---|---|---|
| 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
undefinedyaml
undefinedRequired 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)| Phase | Question | Output |
|---|---|---|
| O | What was observed? | Symptom description |
| H | What explains O? | Candidate causes (ranked by parsimony) |
| P | If H true, what else? | Testable predictions |
| T | Does P hold? | Evidence confirming/refuting H |
用于系统化调试的最佳解释推理:
O(观察)→ H(假设)→ P(预测)→ T(测试)| 阶段 | 问题 | 输出 |
|---|---|---|
| O | 观察到了什么? | 症状描述 |
| H | 什么可以解释O? | 候选原因(按简洁性排序) |
| P | 如果H成立,还会发生什么? | 可测试的预测 |
| T | P是否成立? | 确认/反驳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.mdpython
"""
O: [观察到的具体内容]
H: [最佳解释 - 可测试、简洁]
P: [如果H成立,则会... - 可观察的结果]
T: [测试结果 - 确认/反驳H]
"""完整OHPT协议请参考:
references/abductive-learning.mdHookify Integration
Hookify集成
Governance enforcement through hookify rules:
| Hook | Event | Purpose |
|---|---|---|
| bash | Verify E2E before deploy |
| file | Warn on debug logging |
| file | Block external documentation |
| bash | Check types before merge |
| bash | Verify TODOs resolved |
| stop | Seven Laws completion check |
| file | Detect test anti-patterns |
| stop | Prompt crystallization |
| file | Require OHPT in tests |
| file | Prevent knowledge deletion |
| file | Require vertex connections |
| file | Complete reasoning chains |
| bash | Extract on commits |
Install hooks:
bash scripts/install-hooks.sh通过Hookify规则实现治理机制:
| 钩子 | 事件 | 目的 |
|---|---|---|
| bash | 部署前验证E2E测试 |
| file | 对调试日志发出警告 |
| file | 阻止外部文档 |
| bash | 合并前检查类型 |
| bash | 验证TODO已解决 |
| stop | 七大法则完成检查 |
| file | 检测测试反模式 |
| stop | 触发学习成果固化 |
| file | 测试中要求使用OHPT |
| file | 防止知识删除 |
| file | 要求关联顶点 |
| file | 完整推理链 |
| bash | 提交时提取模式 |
安装钩子:
bash scripts/install-hooks.shIntegration Points
集成点
| Skill | Integration |
|---|---|
| Topology validation (η ≥ 4) |
| Multi-lens code review |
| S→T→O decomposition |
| Generate CI/CD configs |
| Validate this skill |
| Compound engineering loop |
| Parallel governance checks |
| 技能 | 集成方式 |
|---|---|
| 拓扑验证(η ≥ 4) |
| 多维度代码审核 |
| S→T→O分解 |
| 生成CI/CD配置 |
| 验证本技能 |
| 复合工程循环 |
| 并行治理检查 |
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 commitcode/
├── 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 filesScale 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即规划 │ │ │
└──────────────────────┴─────────────────────┴───────────────────┘