math-skill 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.en-US.md +45 -14
  2. package/README.md +45 -14
  3. package/SKILL.en.md +122 -0
  4. package/SKILL.md +122 -0
  5. package/agents/math-critic.en.md +32 -18
  6. package/agents/math-critic.md +33 -18
  7. package/commands/ask.en.md +2 -2
  8. package/commands/ask.md +2 -2
  9. package/design-patterns/compression/low-rank-kv-cache.en.md +1 -0
  10. package/design-patterns/loss/orthogonality-loss.en.md +7 -7
  11. package/design-patterns/loss/orthogonality-loss.md +7 -7
  12. package/knowledge-base/algebraic-geometry/grassmannian-plucker.en.md +71 -0
  13. package/knowledge-base/algebraic-geometry/grassmannian-plucker.md +71 -0
  14. package/knowledge-base/algebraic-geometry/index.en.md +47 -0
  15. package/knowledge-base/algebraic-geometry/index.md +47 -0
  16. package/knowledge-base/algebraic-geometry/sheaf-cohomology.en.md +72 -0
  17. package/knowledge-base/algebraic-geometry/sheaf-cohomology.md +72 -0
  18. package/knowledge-base/cryptography/attack-game-framework.en.md +56 -0
  19. package/knowledge-base/cryptography/attack-game-framework.md +56 -0
  20. package/knowledge-base/cryptography/cca-cpa-ae-hierarchy.en.md +57 -0
  21. package/knowledge-base/cryptography/cca-cpa-ae-hierarchy.md +57 -0
  22. package/knowledge-base/cryptography/index.en.md +54 -0
  23. package/knowledge-base/cryptography/index.md +54 -0
  24. package/knowledge-base/cryptography/prf-prg-owf.en.md +62 -0
  25. package/knowledge-base/cryptography/prf-prg-owf.md +62 -0
  26. package/knowledge-base/cryptography/reduction-proof-template.en.md +60 -0
  27. package/knowledge-base/cryptography/reduction-proof-template.md +60 -0
  28. package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +2 -2
  29. package/knowledge-base/matrix-analysis/low-rank-approximation.md +2 -2
  30. package/knowledge-base/matrix-analysis/projection.en.md +11 -12
  31. package/knowledge-base/matrix-analysis/projection.md +11 -12
  32. package/knowledge-base/overview.en.md +8 -4
  33. package/knowledge-base/overview.md +8 -4
  34. package/knowledge-base/probability/kl-divergence.en.md +6 -6
  35. package/knowledge-base/probability/kl-divergence.md +6 -6
  36. package/package.json +4 -2
  37. package/references/agentic-workflow.en.md +2 -2
  38. package/references/agentic-workflow.md +2 -2
  39. package/references/books/abstract-algebra.en.md +18 -29
  40. package/references/books/abstract-algebra.md +18 -29
  41. package/references/books/algebraic-geometry-rising-sea.en.md +1 -1
  42. package/references/books/algebraic-geometry-rising-sea.md +2 -2
  43. package/references/books/applied-cryptography.en.md +112 -0
  44. package/references/books/applied-cryptography.md +18 -19
  45. package/references/books/differential-geometry.md +1 -1
  46. package/references/books/foundations-of-cryptography.en.md +112 -0
  47. package/references/books/foundations-of-cryptography.md +20 -20
  48. package/references/books/introduction-to-modern-cryptography.en.md +130 -0
  49. package/references/books/introduction-to-modern-cryptography.md +21 -21
  50. package/references/books/micro-lie-theory.en.md +1 -1
  51. package/references/books/micro-lie-theory.md +1 -1
  52. package/references/books/smooth-manifolds.en.md +1 -1
  53. package/references/books/smooth-manifolds.md +1 -1
  54. package/references/gpu-friendly-math.en.md +8 -8
  55. package/references/gpu-friendly-math.md +8 -8
  56. package/references/inspiration.en.md +8 -84
  57. package/references/inspiration.md +8 -84
  58. package/references/musings.en.md +87 -0
  59. package/references/musings.md +87 -0
  60. package/references/skill-index.en.md +32 -22
  61. package/references/skill-index.md +29 -19
  62. package/skills/math-research-activator/SKILL.en.md +4 -193
  63. package/skills/math-research-activator/SKILL.md +4 -214
@@ -1,199 +1,10 @@
1
1
  ---
2
2
  name: math-research-activator
3
3
  description: |
4
- Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol analysis. Does NOT trigger for pure engineering tasks (debug, refactoring, hyperparameter tuning).
4
+ Route AI architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol reviews to the minimum necessary mathematical lenses, anchors, and design checks. Also use for mathematics questions tied to AI research. Do not use for implementation-only debugging, refactoring, tuning, or general code review.
5
+ 中文:为 AI 架构/算子设计、理论分析、数学迁移,以及密码学定义、构造、归约和协议审查,选择最少必要的数学透镜、锚点与检查;纯实现工程任务不触发。
5
6
  ---
6
7
 
8
+ # Compatibility Entry
7
9
 
8
- > **Language Routing & Mixed-Input Rules**: Judge primary language by sentence structure/verbs/mood particles. AI/math/engineering terms don't count. Code/paths/formulas excluded. When CN/EN ratio is close, follow last turn; default to Chinese if no context. Explicit request overrides. Chinese `SKILL.md`, English → this file. Full rules: `../../references/skill-index.en.md`.
9
-
10
- # Math Research OS
11
-
12
- > "The thinking system does not hand out theorems, the knowledge system does not indulge in loose inspiration, and the design layer does not fake profundity."
13
-
14
- This system is a mathematical staff office for AI architecture innovation and cryptographic research — not an arsenal, but one that tells you: **what kind of battle this is, which arms to deploy, how to deploy them, and where things could go wrong.**
15
-
16
- ## Core Principle
17
-
18
- > Math Skill does not store mathematics. It activates, routes, and translates mathematics for AI research.
19
-
20
- - **knowledge-base/** is not a closed encyclopedia but a set of mathematical activation anchors
21
- - When existing cards cannot cover a problem, the agent must NOT stop or force-fit; instead, generate a "temporary knowledge card" based on lenses, reference layers, and the agent's own mathematical knowledge, then continue with design translation
22
- - **design-patterns/** is a collection of math→AI translation prototypes, not a complete model repository; when no matching pattern exists, generate a temporary design candidate from the mathematical structure and label it as a temporary design pattern
23
-
24
- ## Three-Layer Orthogonal Architecture
25
-
26
- | Layer | Responsibility | Directory | Core Question |
27
- |-------|---------------|-----------|--------------|
28
- | **Thinking Lenses** | Diagnose problem structure, recommend mathematical perspectives | `../../lenses/*.en.md` | Which perspective should we view this problem through? |
29
- | **Activation Anchors** | Activate high-frequency math structures; trigger Knowledge Gap Protocol when insufficient | `../../knowledge-base/*/*.en.md` | What math structures does this perspective require? |
30
- | **Design Translation** | Translate mathematics into AI modules/losses/operators | `../../design-patterns/*/*.en.md` | How does this mathematics become model architecture? |
31
-
32
- Auxiliary layers:
33
- - `../../references/books/*.en.md`: Distilled notes from 7 textbooks; full context when deeper understanding is needed
34
- - `../../references/books/applied-cryptography.md`, `../../references/books/foundations-of-cryptography.md`, `../../references/books/introduction-to-modern-cryptography.md`: 3 English-language cryptography distillations; see `../../references/skill-index.en.md`
35
- - `../../references/gpu-friendly-math.en.md`: GPU Eight-Dimension Acceptance Gate (single source of truth)
36
- - `../../agents/math-critic.en.md`: Math-engineering dual critic
37
-
38
- ## Automatic Trigger Conditions
39
-
40
- **All of Gate 1 + Gate 2 + Gate 3 must be satisfied simultaneously for intervention:**
41
-
42
- ### Gate 0 · Exclusion Gate (Highest Priority)
43
- The following tasks **never** trigger the system regardless of workspace contents: code review, debugging, refactoring, hyperparameter tuning, build/deployment, purely factual queries, general software engineering.
44
-
45
- ### Gate 1 · Environment Signal
46
- The workspace contains architecture-level core code (attention/transformer/MoE, `*.cu`/kernel) or research notes, **or** cryptography-related code / protocol descriptions / security proof drafts. Routine files like `model.py` or `trainer.py` alone **do not** constitute an environment signal.
47
-
48
- ### Gate 2 · Task Signal
49
- The user's task involves **designing/improving** a new architecture/operator, **analyzing** theoretical properties, **transferring** mathematical structures into AI design, **analyzing cryptographic constructions/security definitions/reduction proofs/protocols**, or **querying math knowledge relevant to AI research** (e.g., "how is tangent space used in optimization?"). Pure encyclopedic math or cryptography fact queries do not auto-trigger, but can be accessed via `/ask`.
50
-
51
- ### Gate 3 · Intent Match
52
- The user's intent matches one of scenarios A/B/C/D. Pure engineering tasks matching scenario E → no intervention.
53
-
54
- > **`/ask` entry**: Manual invocation skips Gate 1 and Gate 2, executing only Gate 0 (exclusion) + Gate 3 (intent match), allowing direct access to any scenario including knowledge queries.
55
-
56
- ## Domain Router (new in v3.2.0)
57
-
58
- > AI research and cryptography **share** mathematical foundations but each has **exclusive** specialty layers. After intent diagnosis and before lens invocation, Domain Router determines the problem's domain and decides which anchors/books/design patterns to load, avoiding cross-domain pollution and token waste.
59
-
60
- ### Three-Layer Domain Classification
61
-
62
- | Layer | Signal Keyword Examples | Loaded Content | Exclusive/Shared |
63
- |-------|------------------------|----------------|-------------------|
64
- | **AI Research Layer** | attention, loss, routing, representation, compression, MoE, transformer, KV-cache, LoRA, SSM, diffusion, RL | `../../knowledge-base/` (7 domains, 31 anchors) + `../../design-patterns/` (5 types, 22 patterns) + 7 AI books | AI-exclusive |
65
- | **Cryptography Layer** | encryption, signature, MAC, PRF/PRG/PRP, OWF, CCA, CPA, AE, zero-knowledge, reduction proof, attack game, DL/CDH/DDH, RSA, ECC, lattice crypto | 3 crypto books + shared math anchors (on demand) + temporary knowledge cards | Crypto-exclusive |
66
- | **Shared Math Layer** | probability, information theory, entropy, group, ring, field, matrix, spectrum, optimization, convexity, perturbation, complexity | Corresponding anchors in `../../knowledge-base/` + `../../lenses/` lenses | Shared |
67
-
68
- ### Routing Rules
69
-
70
- 1. **Judge domain first**: Determine primary domain (AI / Crypto / pure math query) from user keywords.
71
- 2. **No redundant loading of shared math**: If the domain is cryptography, load shared math anchors (e.g., `../../knowledge-base/probability/entropy.md`, `../../knowledge-base/matrix-analysis/spectral-decomposition.md`) on demand; do **NOT** load AI-exclusive `../../design-patterns/`.
72
- - **"On demand" criterion**: Load if and only if the problem's mathematical structure maps to that shared anchor's core definition/formulas — i.e., the problem statement explicitly mentions the anchor's core concept (e.g., "spectrum," "entropy," "convex," "perturbation"), or a lens/critic explicitly routes to it. **The domain tag does not decide whether shared anchors load; the problem structure does.**
73
- 3. **Explicit annotation on cross-domain**: If the problem is genuinely AI×crypto intersection (e.g., "use PRF for model watermarking," "reduction proof for adversarial examples"), Domain Router explicitly lists both domains' loaded items and annotates intersection points.
74
- - **Intersection annotation template** (4-tuple, feeds critic dim 19 checkpoint 6):
75
- 1. **Crypto primitive + security property** (e.g., "PRF + pseudorandomness")
76
- 2. **AI module + functional requirement** (e.g., "watermark + unique traceability")
77
- 3. **Transfer direction** (crypto→AI / AI→crypto)
78
- 4. **Assumption achievability after transfer** (Is the original assumption still achievable in the AI scenario? E.g., "Is the PRF assumption satisfiable in ML deployment?")
79
- 4. **No pollution when not cross-domain**: Pure AI problems do not load cryptography books; pure crypto problems do not load AI design patterns. Avoids token waste and conceptual confusion.
80
- 5. **Domain-tagged gap protocol**: Temporary knowledge cards generated by Knowledge Gap Protocol are tagged with domain (AI/Crypto/Shared) for subsequent upgrade to corresponding formal cards.
81
-
82
- ### Domain Router Decision Flow
83
-
84
- ```
85
- User question
86
-
87
- [Gate 0-3 triggered?]
88
- ↓ yes
89
- Domain Router: keyword-based primary domain judgment
90
- ├─ AI research → load knowledge-base + design-patterns + AI books
91
- ├─ Cryptography → load crypto books + shared math anchors (on demand)
92
- ├─ Pure math → only load lenses + corresponding knowledge-base anchors
93
- └─ AI×Crypto → dual-domain load + intersection annotation
94
-
95
- [Scenario A/B/C/D routing]
96
-
97
- [Lenses → anchors/books → design translation (AI only) / reduction template (crypto only) → critic]
98
- ```
99
-
100
- ## Main Workflow
101
-
102
- ### Step 1: Diagnose Intent
103
- 1. Determine which scenario (A/B/C/D/E) the user's intent belongs to
104
- 2. **Domain Router judgment**: problem domain (AI / Crypto / pure math / intersection)
105
- 3. Extract the core tension of the problem: what to preserve? what to suppress? what are the constraints? what is the engineering bottleneck?
106
- 4. Output a problem-type classification + domain tag
107
-
108
- ### Step 2: Route Invocation
109
-
110
- ```
111
- Scenario A (Analysis): Select 1–3 lenses → output perspective diagnosis → critic review
112
- Scenario B (Design): Select 1–3 lenses → invoke relevant activation anchors; if no coverage, enter Knowledge Gap Protocol → generate formal/temporary design patterns → critic review
113
- · AI domain: design patterns from design-patterns/; output attention/loss/routing/representation/compression
114
- · Crypto domain: design patterns from cryptography books' construction paradigms (SPN/Feistel/Merkle-Damgård/KEM-DEM/Fiat-Shamir); output encryption/MAC/signature/protocols
115
- Scenario C (Query): Prefer loading relevant activation anchors or crypto books; if no coverage, generate temporary knowledge card → output per knowledge activation protocol
116
- Scenario D (Verification): Load relevant anchors or temporary knowledge cards → critic reviews conditions and boundaries
117
- · AI domain: pass GPU Eight-Dimension Acceptance Gate
118
- · Crypto domain: pass reduction tightness + assumption dependency + implementation pitfall checks (GPU gate not required)
119
- Scenario E (Engineering): No intervention
120
- ```
121
-
122
- ### Step 3: Output Format
123
-
124
- **Token-economy rule**: The following is the maximum structure, not the default full template. Trim to the user's question; for simple knowledge queries, provide only the needed definition / formula / risk. Expand design and GPU/reduction sections only when relevant, and do not restate loaded cards verbatim. **After Domain Router determines the domain, only expand the domain-specific subsection.**
125
-
126
- **Scenario A/B Output**:
127
- 1. **[Diagnosis]** Problem type + core tension
128
- 2. **[Lens]** Recommend 1–3 mathematical perspectives (annotate why each is/is not suitable)
129
- 3. **[Knowledge]** (Scenario B only) Activated mathematical structures (reference activation anchors or temporary knowledge cards)
130
- 4. **[Design]** (Scenario B only) Candidate AI module drafts (reference design patterns or temporary design drafts)
131
- 5. **[GPU]** Run candidates through the Eight-Dimension Gate (friendly/retrofittable/unfriendly)
132
- 6. **[Conclusion]** Retain candidates that pass both acceptance gates + next-step recommendations
133
-
134
- **Scenario C Output** (Knowledge Activation Protocol, trimmed as needed):
135
- 1. Minimal definition
136
- 2. Core formulas
137
- 3. Applicable problems
138
- 4. AI design translation (only when the question involves AI / operators)
139
- 5. Engineering feasibility (only when implementation / GPU matters)
140
- 6. Risks and failure conditions
141
- 7. Further references (only when traceability is requested or the conclusion depends on book references)
142
-
143
- **Scenario D Output** (short conclusion first + conditions/boundaries):
144
- 1. Conditions under which it holds
145
- 2. Conditions under which it fails
146
- 3. What it can guarantee at most
147
- 4. What it cannot guarantee
148
- 5. Engineering feasibility (only when implementation / GPU matters)
149
-
150
- **A conclusion must always be provided — never output analysis alone without convergence.**
151
-
152
- ## GPU Eight-Dimension Acceptance Gate
153
-
154
- Formal terminology (single authoritative source: `../../references/gpu-friendly-math.en.md`):
155
- **Tensorization / GEMM-mappability / Complexity / Memory & KV-Cache / Low-Precision Stability / Parallelism & Communication / Sparse Structure / Operator Fusion**
156
-
157
- **Quantitative assessment requirements**: For each candidate design, the GPU assessment should not only provide [v]/[~]/[x] labels but also answer:
158
- 1. FLOPs of core operations and ratio vs. baseline
159
- 2. Peak memory (bytes), whether large matrices are materialized
160
- 3. Numerical stability strategy under bf16/fp8
161
- 4. Number of fusible kernels and expected speedup
162
-
163
- See the quantitative checklist in `../../references/gpu-friendly-math.en.md`.
164
-
165
- ## Depth-of-Consultation Protocol
166
-
167
- - **Light**: Read knowledge cards (`../../knowledge-base/*/*.en.md`); self-contained and immediately usable
168
- - **Medium**: Read distilled book notes (`../../references/books/*.en.md`) for more complete context; for cryptography, also consult the 3 English-language `.md` files listed in `../../references/skill-index.en.md`
169
- - **Deep**: When `math_book/<PDF>` is available locally, the agent automatically runs `pdftotext` + grep to locate the original page
170
-
171
- ## Knowledge Gap Protocol
172
-
173
- When the mathematical tools required by the user's problem are not in the existing `knowledge-base/`, do NOT force-fit existing cards. Execute the following procedure:
174
-
175
- 1. **Gap Identification**: Explicitly state that no fully corresponding knowledge card exists. Classify the gap as: new domain, new theorem family, new structure, new application scenario, or combinatorial extension of existing cards.
176
-
177
- 2. **Lens Fallback**: Select 1–3 most relevant thinking lenses to determine the problem's mathematical structure. E.g., local-to-global, categorical, spectral, projection, causal, perturbation.
178
-
179
- 3. **Candidate Knowledge Localization**: Provide mathematical keywords, theorem families, concept clusters, and reference book directions to look up. Existing card coverage is not required, but explain why these concepts are relevant.
180
-
181
- 4. **Temporary Knowledge Card**: Generate a temporary knowledge summary in the same format as formal cards:
182
- - Minimal definition
183
- - Core structure
184
- - Applicable problems
185
- - AI design translation
186
- - GPU feasibility
187
- - Risks and failure conditions
188
- - **Source & Confidence** (required):
189
- - Knowledge source: label as "Agent inference / Lens derivation / Reference book extrapolation / Requires external verification"
190
- - Confidence: High (theorem-backed) / Medium (reasonable inference, not rigorously proven) / Low (exploratory hypothesis)
191
- - Unverified claims: list key conclusions requiring subsequent verification
192
-
193
- 5. **Design Translation**: If the user's goal is mechanism design, translate the temporary knowledge into candidate AI modules, losses, routing, attention, representation, or compression schemes.
194
-
195
- 6. **Upgrade Recommendation**: If this gap recurs frequently, recommend adding a formal knowledge card or design pattern.
196
-
197
- ## Workflow Example
198
-
199
- Full workflow example: `../../references/skill-index.en.md`.
10
+ This is the Claude/plugin-style compatibility entry. Read and follow `../../SKILL.en.md` completely; the root file is the single authoritative English body and all resource paths resolve from the repository root. Do not also load `SKILL.md`.
@@ -1,220 +1,10 @@
1
1
  ---
2
2
  name: math-research-activator
3
3
  description: |
4
- 数学研究操作系统:自动诊断用户意图,路由到思想透镜、激活锚点或设计翻译层。触发于设计/改进模型架构/算子/注意力、分析理论性质、迁移数学结构到 AI 设计,以及密码学安全定义、构造、归约证明与协议分析。不触发于纯工程任务(debug、重构、调参)。
5
- English: Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, activation anchors, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol analysis. Does NOT trigger for pure engineering tasks.
4
+ 数学研究路由器:为 AI 架构/算子设计、理论性质分析、数学结构迁移,以及密码学定义、构造、归约与协议审查,选择必要的数学透镜、知识锚点和设计检查。也用于与 AI 研究有关的数学查询。纯实现型 debug、重构、调参和一般代码审查不触发。
5
+ English: Route AI architecture/operator design, theoretical analysis, math-to-AI transfer, and cryptographic definitions, constructions, reductions, or protocol reviews to the minimum necessary mathematical lenses, anchors, and design checks. Do not use for implementation-only debugging, refactoring, tuning, or general code review.
6
6
  ---
7
7
 
8
- > **语言路由与混合输入规则**:看句式/动词/语气词主框架判定主语言。AI/数学/工程术语不计入。代码/路径/公式不计入。中英接近时沿用上一轮,无上下文默认中文。显式要求优先。中文→本文件,英文→`SKILL.en.md`。完整规则见 `../../references/skill-index.md`。
8
+ # 兼容入口
9
9
 
10
- # 数学研究操作系统 / Math Research OS
11
-
12
- > "思想系统不负责给定理,知识系统不负责乱启发,设计层不负责装深刻。"
13
-
14
- 本系统是面向 AI 架构创新与密码学研究的数学参谋部——不是武器库,而是告诉你:**这场仗是什么仗、该用什么兵种、怎么部署、哪里会翻车。**
15
-
16
- ## 核心原则
17
-
18
- > Math Skill 不存储数学,它激活数学、路由数学,并把数学翻译成 AI 研究设计。
19
-
20
- - **knowledge-base/** 不是封闭百科,而是数学激活锚点集合(activation anchors)
21
- - 当现有卡片不能覆盖问题时,Agent 不得停止或强行套用,而应基于透镜、参考层和自身数学知识生成"临时知识卡",继续完成设计翻译
22
- - **design-patterns/** 是 math→AI 翻译原型集合,不是完整模型仓库;无对应模式时根据数学结构临时生成候选设计,并标记为 temporary design pattern
23
-
24
- ## 三层正交架构
25
-
26
- | 层 | 职责 | 目录 | 核心问题 |
27
- |----|------|------|---------|
28
- | **思想透镜** | 诊断问题结构,推荐数学视角 | `../../lenses/*.md` | 这个问题该用什么视角看? |
29
- | **激活锚点** | 激活高频数学结构,并在不足时触发 Knowledge Gap Protocol | `../../knowledge-base/*/*.md` | 这个视角需要激活哪些数学结构? |
30
- | **设计翻译** | 把数学变成 AI 模块/loss/算子 | `../../design-patterns/*/*.md` | 这些数学怎么变成模型结构? |
31
-
32
- 辅助层:
33
- - `../../references/books/*.md`:10 本书的蒸馏稿,需要深入时的完整上下文;其中 3 本密码学书稿见 `../../references/skill-index.md`
34
- - `../../references/gpu-friendly-math.md`:GPU 八维验收门(唯一权威)
35
- - `../../agents/math-critic.md`:数学-工程双重批判器
36
-
37
- ## 意图诊断(5 场景)
38
-
39
- | 场景 | 诊断信号 | 调用路径 |
40
- |------|---------|---------|
41
- | **A. 问题分析** | "这个设计合理吗?""逻辑链有没有漏洞?" | 透镜 → critic |
42
- | **B. 机制设计** | "设计新 attention""把 X 迁移到 Y" | 透镜 → 激活锚点 → 设计 → critic |
43
- | **C. 知识查询** | "流形上的切空间是什么?""投影定理怎么用?" | 激活锚点 |
44
- | **D. 验证审查** | "这个公式成立吗?""loss 能保证什么?" | 激活锚点 → 相关设计模式(若引用具体 AI 构造)→ critic |
45
- | **E. 纯工程** | debug、重构、调参、代码审查 | **不调用数学系统** |
46
-
47
- ## 透镜库(15 个数学视角)
48
-
49
- 15 个透镜覆盖:公理化、对偶、对称性、谱分解、几何、投影与分解、变分、局部到整体、拓扑、范畴化、扰动、因果、博弈、概率统计、算法。目录:`../../lenses/*.md`。完整目录表见 `../../references/skill-index.md`。
50
-
51
- ## 激活锚点(按数学领域组织)
52
-
53
- 7 个领域:矩阵分析、最优化、微分几何、李理论、拓扑、概率与信息、信息几何。目录:`../../knowledge-base/*/*.md`。完整目录表见 `../../references/skill-index.md`。
54
-
55
- ## 设计模式库(按 AI 组件组织)
56
-
57
- 5 个组件类型:注意力、损失函数、路由、表示、压缩。目录:`../../design-patterns/*/*.md`。完整目录表见 `../../references/skill-index.md`。
58
-
59
- ## 自动触发条件
60
-
61
- **必须同时满足 Gate 1 + Gate 2 + Gate 3 才介入:**
62
-
63
- ### Gate 0 · 排除门(最高优先级)
64
- 以下任务**无论工作区含什么**都不触发:代码审查、debug、重构、调参、构建部署、纯事实查询、通用软件工程。
65
-
66
- ### Gate 1 · 环境信号
67
- 工作区含架构核心代码(attention/transformer/MoE、`*.cu`/kernel)或研究笔记,**或**密码学相关代码/协议描述/安全证明草稿。仅 `model.py`、`trainer.py` 等常规文件**不构成**环境信号。
68
-
69
- ### Gate 2 · 任务信号
70
- 用户任务涉及**设计/改进**新架构/算子、**分析**理论性质、**迁移**数学结构到 AI 设计、**分析密码学构造/安全定义/归约证明/协议**,或**查询与 AI 研究相关的数学知识**(如"切空间在优化中怎么用")。纯百科式数学或密码学事实查询不自动触发,但可通过 `/ask` 手动进入。
71
-
72
- ### Gate 3 · 意图匹配
73
- 用户意图匹配场景 A/B/C/D 之一。纯工程任务匹配场景 E → 不介入。
74
-
75
- > **`/ask` 入口**:手动调用时跳过 Gate 1 和 Gate 2,仅执行 Gate 0(排除门)+ Gate 3(意图匹配),可直接进入任意场景包括知识查询。
76
-
77
- ## Domain Router(v3.2.0 新增)
78
-
79
- > AI 研究与密码学**共享**数学根基,但**独有**各自的专业层。Domain Router 在意图诊断后、调用透镜前,先判定问题归属,决定加载哪些锚点/书稿/设计模式,避免跨域污染与 token 浪费。
80
-
81
- ### 三层归属判定
82
-
83
- | 层 | 信号词示例 | 加载内容 | 独有/共用 |
84
- |----|-----------|---------|----------|
85
- | **AI 研究层** | attention、loss、routing、representation、compression、MoE、transformer、KV-cache、LoRA、SSM、扩散、RL | `../../knowledge-base/`(7 领域 31 锚点)+ `../../design-patterns/`(5 类 22 模式)+ AI 方向 7 本书 | AI 独有 |
86
- | **密码学层** | 加密、签名、MAC、PRF/PRG/PRP、OWF、CCA、CPA、AE、零知识、归约证明、攻击游戏、DL/CDH/DDH、RSA、ECC、格密码 | 3 本密码学书稿 + 共用数学锚点(按需)+ 临时知识卡 | 密码独有 |
87
- | **共用数学层** | 概率、信息论、熵、群、环、域、矩阵、谱、优化、凸性、扰动、复杂度 | `../../knowledge-base/` 中的对应锚点 + `../../lenses/` 透镜 | 共用 |
88
-
89
- ### 路由规则
90
-
91
- 1. **先判 domain**:从用户关键词判定主 domain(AI / 密码 / 纯数学查询)。
92
- 2. **共用数学不重复加载**:若 domain 是密码学,共用数学锚点(如 `../../knowledge-base/probability/entropy.md`、`../../knowledge-base/matrix-analysis/spectral-decomposition.md`)按需加载,**不**加载 AI 专属的 `../../design-patterns/`。
93
- - **"按需"判定条件**:当且仅当问题的数学结构映射到该共用锚点的核心定义/公式时加载。即问题陈述中显式出现该锚点对应的核心概念(如"谱""熵""凸""扰动"),或透镜路由/critic 明确指向该锚点。**domain 标签不决定共用锚点加载与否,问题结构决定。**
94
- 3. **跨域时显式标注**:若问题确实是 AI×密码交叉(如"用 PRF 做模型水印""对抗样本的归约证明"),Domain Router 显式列出两个 domain 的加载项,并标注交叉点。
95
- - **交叉点标注模板**(四元组,供 critic 第 19 维第 6 检查点审查):
96
- 1. **密码学原语 + 安全性质**(如"PRF + 伪随机性")
97
- 2. **AI 模块 + 功能需求**(如"水印 + 唯一可追踪性")
98
- 3. **迁移方向**(密码→AI / AI→密码)
99
- 4. **迁移后假设可达性**(原假设在 AI 场景是否仍可达成?如"PRF 的 PRF 假设在 ML 部署中是否可满足")
100
- 4. **不跨域时不污染**:纯 AI 问题不加载密码学书稿;纯密码学问题不加载 AI 设计模式。避免 token 浪费与概念混淆。
101
- 5. **缺口协议分 domain**:Knowledge Gap Protocol 生成的临时知识卡标注 domain(AI/密码/共用),便于后续升级到对应正式卡片。
102
-
103
- ### Domain Router 判定流程图
104
-
105
- ```
106
- 用户问题
107
-
108
- [Gate 0-3 触发?]
109
- ↓ 是
110
- Domain Router: 关键词判定主 domain
111
- ├─ AI 研究 → 加载 knowledge-base + design-patterns + AI 书稿
112
- ├─ 密码学 → 加载密码学书稿 + 共用数学锚点(按需)
113
- ├─ 纯数学 → 只加载 lenses + 对应 knowledge-base 锚点
114
- └─ AI×密码 → 双 domain 加载 + 交叉点标注
115
-
116
- [场景 A/B/C/D 路由]
117
-
118
- [透镜 → 锚点/书稿 → 设计翻译(仅 AI)/ 归约模板(仅密码)→ critic]
119
- ```
120
-
121
- ## 主流程
122
-
123
- ### 第一步:诊断意图
124
- 1. 判断用户意图属于场景 A/B/C/D/E 哪个
125
- 2. **Domain Router 判定**:问题归属(AI / 密码 / 纯数学 / 交叉)
126
- 3. 提取问题核心张力:想保留什么?想抑制什么?约束是什么?工程瓶颈是什么?
127
- 4. 输出问题类型分类 + domain 标注
128
-
129
- ### 第二步:路由调用
130
-
131
- ```
132
- 场景 A(分析):选 1-3 个透镜 → 输出视角诊断 → critic 审查
133
- 场景 B(设计):选 1-3 个透镜 → 调用相关激活锚点;若无覆盖则进入 Knowledge Gap Protocol → 生成正式/临时设计模式 → critic 审查
134
- · AI domain:设计模式来自 design-patterns/,产出 attention/loss/routing/representation/compression
135
- · 密码 domain:设计模式来自密码学书稿的构造范式(SPN/Feistel/Merkle-Damgård/KEM-DEM/Fiat-Shamir),产出加密/MAC/签名/协议
136
- 场景 C(查询):优先加载相关激活锚点或密码学书稿;若无覆盖则生成临时知识卡 → 按知识激活协议输出
137
- 场景 D(验证):加载相关锚点或临时知识卡 → critic 审查条件与边界
138
- · AI domain:过 GPU 八维验收门
139
- · 密码 domain:过归约紧度 + 假设依赖 + 实现陷阱检查(不必过 GPU 门)
140
- 场景 E(工程):不介入
141
- ```
142
-
143
- ### 第三步:输出格式
144
-
145
- **Token 经济原则**:以下是最长结构,不是默认全文模板。按用户问题裁剪;简单知识查询只给必要定义/公式/风险,设计与 GPU/归约内容只在与问题有关时展开;避免复述已加载卡片全文;**Domain Router 已判定 domain 后,只展开该 domain 的专属小节**。
146
-
147
- **场景 A/B 输出**:
148
- 1. **[诊断]** 问题类型 + 核心张力
149
- 2. **[透镜]** 推荐 1-3 个数学视角(标注为什么适合/不适合)
150
- 3. **[知识]**(仅场景 B)激活的数学结构(引用激活锚点或临时知识卡)
151
- 4. **[设计]**(仅场景 B)候选 AI 模块草案(引用设计模式或临时设计草案)
152
- 5. **[GPU]** 候选过八维门(友好/可改造/不友好)
153
- 6. **[结论]** 保留通过双验收门的候选 + 下一步建议
154
-
155
- **场景 C 输出**(知识激活协议,按需裁剪):
156
- 1. 最小定义
157
- 2. 核心公式
158
- 3. 适用问题
159
- 4. AI 设计翻译(仅当问题与 AI/算子相关)
160
- 5. 工程可行性(仅当涉及实现/GPU)
161
- 6. 风险与失效条件
162
- 7. 深入参考(仅当用户要追溯或结论依赖外部书稿)
163
-
164
- **场景 D 输出**(优先短结论 + 条件边界):
165
- 1. 成立条件
166
- 2. 不成立条件
167
- 3. 最多能保证什么
168
- 4. 不能保证什么
169
- 5. 工程可行性(仅当涉及实现/GPU)
170
-
171
- **必须给出结论,不得只输出分析而不收敛。**
172
-
173
- ## GPU 八维验收门
174
-
175
- 正式术语(唯一权威来源:`../../references/gpu-friendly-math.md`):
176
- **张量化 / GEMM 可映射 / 复杂度 / 显存与 KV-Cache / 低精度稳定 / 并行与通信 / 稀疏结构 / 算子融合**
177
-
178
- **量化评估要求**:对每个候选设计,GPU 评估不应只给 [v]/[~]/[x] 标签,还需回答:
179
- 1. 核心操作的 FLOPs 和与 baseline 的比值
180
- 2. 峰值显存 (bytes),是否物化大矩阵
181
- 3. bf16/fp8 下的数值稳定性策略
182
- 4. 可融合的 kernel 数和预期加速
183
-
184
- 详见 `../../references/gpu-friendly-math.md` 的量化检查清单。
185
-
186
- ## 深度查阅协议
187
-
188
- - **轻度**:读知识卡片(`../../knowledge-base/*/*.md`),自足可用
189
- - **中度**:读书蒸馏稿(`../../references/books/*.md`),获取更完整上下文;密码学问题优先查阅 `../../references/skill-index.md` 列出的 3 本专门书稿
190
- - **深度**:本机有 `math_book/<PDF>` 时,Agent 自动 `pdftotext` + grep 定位原文页
191
-
192
- ## 知识缺口协议 / Knowledge Gap Protocol
193
-
194
- 当用户问题需要的数学工具不在现有 `knowledge-base/` 中时,不得强行套用已有卡片。执行以下流程:
195
-
196
- 1. **缺口识别**:明确指出现有知识库中没有完全对应的知识卡片。判断缺口属于:新领域、新定理族、新结构、新应用场景,还是已有卡片的组合扩展。
197
-
198
- 2. **透镜回退**:选择 1-3 个最相关思想透镜,用它们确定问题的数学结构。例如:局部到整体、范畴化、谱分解、投影、因果、扰动等。
199
-
200
- 3. **候选知识定位**:给出应查找的数学关键词、定理族、概念簇、参考书方向。不要求已有知识卡覆盖,但必须说明为什么这些知识相关。
201
-
202
- 4. **临时知识卡**:生成一个"临时知识摘要",格式同正式知识卡:
203
- - 最小定义
204
- - 核心结构
205
- - 适用问题
206
- - AI 设计翻译
207
- - GPU 可行性
208
- - 风险与失效条件
209
- - **来源与置信度**(必填):
210
- - 知识来源:标注为"Agent 推断 / 透镜推导 / 参考书外推 / 需外部验证"
211
- - 置信度:高(有定理支撑)/ 中(合理推断但未严格证明)/ 低(探索性假说)
212
- - 未核验声明:列出需要后续验证的关键结论
213
-
214
- 5. **设计翻译**:若用户目标是机制设计,则将临时知识转译为候选 AI 模块、loss、routing、attention、representation 或 compression 方案。
215
-
216
- 6. **升级建议**:如果该缺口高频出现,建议新增正式 knowledge card 或 design pattern。
217
-
218
- ## 工作流范例
219
-
220
- 完整工作流范例见 `../../references/skill-index.md`。
10
+ 这是 Claude/plugin 风格的兼容入口。完整读取并遵循 `../../SKILL.md`;该根文件是唯一权威正文,所有资源路径均相对仓库根解析。不要同时读取 `SKILL.en.md`。