kenaz 0.3.9 → 0.3.11

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 (117) hide show
  1. package/core/.claude/commands/Ansuz.md +12 -16
  2. package/core/.claude/hooks/memory-guard.js +13 -0
  3. package/core/.claude/skills/code_reviewer/SKILL.md +0 -1
  4. package/core/.claude/skills/code_reviewer/patterns.yaml +0 -8
  5. package/core/.claude/skills/dev_agent/SKILL.md +3 -6
  6. package/core/.claude/skills/heimdall/SKILL.md +5 -6
  7. package/core/.claude/skills/huginn/SKILL.md +11 -38
  8. package/core/.collaboration/core/task-api.js +2 -218
  9. package/core/.collaboration/core/task-api.test.js +1 -138
  10. package/core/.formation/bifrost/launch.js +2 -2
  11. package/core/.formation/bifrost/launch.test.js +2 -2
  12. package/core/.formation/bifrost/shared/ansuz-boot-policy.js +3 -3
  13. package/core/.formation/bifrost/shared/codex-injection.js +3 -17
  14. package/core/.formation/bifrost/shared/consolidate.js +1 -51
  15. package/core/.formation/bifrost/sync.js +4 -5
  16. package/core/.formation/tools/__tests__/subagent-bifrost-guard.test.js +1 -1
  17. package/core/.formation/tools/dispatch.js +2 -2
  18. package/core/.formation/tools/kenaz-stats.js +259 -0
  19. package/core/.formation/tools/kenaz-stats.test.js +180 -0
  20. package/core/.formation/tools/mcp-allowlist.test.js +5 -3
  21. package/core/.formation/tools/post-complete/bounded-http.js +1 -40
  22. package/core/.formation/tools/post-complete/bounded-http.test.js +2 -89
  23. package/core/.formation/tools/post-complete/cognitive.js +2 -119
  24. package/core/.formation/tools/post-complete/testing.js +3 -21
  25. package/core/.formation/tools/post-complete.js +2 -428
  26. package/core/.formation/tools/post-complete.test.js +0 -135
  27. package/core/.formation/tools/prompt.js +14 -0
  28. package/core/.formation/tools/route-audit.test.js +8 -20
  29. package/core/.rule/INDEX.yaml +3 -3
  30. package/core/.rule/general/ddx-synapse-stack.yaml +11 -11
  31. package/core/.rule/general/specialist-identity-contract.yaml +5 -5
  32. package/core/.rule/general/synapse-code-intelligence.yaml +25 -111
  33. package/core/.rule/general/worktree-isolation.yaml +2 -2
  34. package/core/.rule/pipeline/task-execution.yaml +6 -9
  35. package/core/.specialist/Amelia/README.md +5 -5
  36. package/core/.specialist/Amelia/capability.yaml +10 -18
  37. package/core/.specialist/Amelia/knowledge.yaml +15 -66
  38. package/core/.specialist/Amelia/workflow.yaml +12 -21
  39. package/core/.specialist/Ansuz/RULES.md +6 -0
  40. package/core/.specialist/Ansuz/capability.yaml +12 -87
  41. package/core/.specialist/Ansuz/concepts/autonomous_agenda.yaml +1 -1
  42. package/core/.specialist/Ansuz/concepts/autonomy_contract.yaml +2 -3
  43. package/core/.specialist/Ansuz/concepts/capability_pointers.yaml +1 -3
  44. package/core/.specialist/Ansuz/concepts/cognitive_fluency_contract.yaml +8 -21
  45. package/core/.specialist/Ansuz/concepts/cognitive_systems_overview.yaml +0 -4
  46. package/core/.specialist/Ansuz/concepts/cognitive_systems_turn_context.yaml +1 -1
  47. package/core/.specialist/Ansuz/concepts/completion_tracking.yaml +0 -1
  48. package/core/.specialist/Ansuz/concepts/deep_knowledge_pointers.yaml +0 -3
  49. package/core/.specialist/Ansuz/concepts/evolvable_guardrails.yaml +3 -3
  50. package/core/.specialist/Ansuz/concepts/fatigue_handoff.yaml +1 -7
  51. package/core/.specialist/Ansuz/concepts/guardrails_immutable.yaml +3 -4
  52. package/core/.specialist/Ansuz/concepts/identity.yaml +1 -2
  53. package/core/.specialist/Ansuz/concepts/phase9_verification.yaml +0 -1
  54. package/core/.specialist/Ansuz/concepts/phase_protocol.yaml +3 -4
  55. package/core/.specialist/Ansuz/core.yaml +3 -6
  56. package/core/.specialist/Ansuz/elixir.yaml +6 -6
  57. package/core/.specialist/Ansuz/exo_cortex_tools.yaml +5 -9
  58. package/core/.specialist/Ansuz/guards/blind_spot_guards.yaml +2 -2
  59. package/core/.specialist/Ansuz/guards/lesson_guards.yaml +6 -19
  60. package/core/.specialist/Ansuz/identity_contract.yaml +4 -4
  61. package/core/.specialist/Ansuz/knowledge.yaml +13 -40
  62. package/core/.specialist/Ansuz/modules/ddx.yaml +2 -2
  63. package/core/.specialist/Ansuz/modules/prophecy.yaml +19 -19
  64. package/core/.specialist/Ansuz/modules/pulse_empty.yaml +6 -17
  65. package/core/.specialist/Ansuz/tools/ansuz-handoff-snapshot.js +3 -102
  66. package/core/.specialist/Ansuz/tools/ansuz-sdk-runner.js +2 -44
  67. package/core/.specialist/Ansuz/workflow.yaml +32 -76
  68. package/core/.specialist/Forseti/core.yaml +2 -7
  69. package/core/.specialist/Forseti/rule.yaml +1 -1
  70. package/core/.specialist/Heimdall/SKILL.md +2 -3
  71. package/core/.specialist/Heimdall/capability.yaml +22 -45
  72. package/core/.specialist/Heimdall/core.yaml +24 -126
  73. package/core/.specialist/Heimdall/principles.yaml +8 -11
  74. package/core/.specialist/Heimdall/rule.yaml +2 -2
  75. package/core/.specialist/Huginn/capability.yaml +31 -52
  76. package/core/.specialist/Huginn/core.yaml +43 -123
  77. package/core/.specialist/Huginn/principles.yaml +5 -5
  78. package/core/.specialist/Huginn/rule.yaml +3 -9
  79. package/core/.specialist/REFLECTION_TO_CONTROL.md +3 -4
  80. package/core/.specialist/shared/guard_schema.json +1 -1
  81. package/core/.specialist/shared/principles.yaml +6 -6
  82. package/core/.specialist/tools/__tests__/task-2409-lessons.test.js +95 -0
  83. package/core/.specialist/tools/ansuz-boot-fast.js +1 -0
  84. package/core/.specialist/tools/lessons.js +234 -0
  85. package/core/.specialist/tools/phase-gate.js +10 -230
  86. package/core/.specialist/tools/phase-gate.test.js +2 -2
  87. package/core/.specialist/tools/prompt-files.test.js +1 -1
  88. package/core/.specialist/tools/session.js +2 -89
  89. package/core/.system/memory/README.md +3 -0
  90. package/core/CLAUDE.md +6 -7
  91. package/core/KENAZ_CORE_VERSION +1 -1
  92. package/core/dev/plans/CLI_FIRST_INSTALL_FLOW.md +26 -0
  93. package/core/plugins/kenaz/INVENTORY.md +1 -1
  94. package/core/plugins/kenaz/commands/Ansuz.md +12 -16
  95. package/core/plugins/kenaz/scripts/kenaz.test.js +2 -1
  96. package/core/plugins/kenaz/scripts/ygg.js +2 -0
  97. package/core/plugins/kenaz/skills/code_reviewer/SKILL.md +0 -1
  98. package/core/plugins/kenaz/skills/code_reviewer/patterns.yaml +0 -8
  99. package/core/plugins/kenaz/skills/dev_agent/SKILL.md +3 -6
  100. package/lib/cli.js +13 -3
  101. package/package.json +6 -6
  102. package/core/.claude/hooks/handoff-snapshot-on-decision.js +0 -188
  103. package/core/.claude/skills/synapse_maintain/SKILL.md +0 -84
  104. package/core/.formation/tools/alaya-gate.js +0 -198
  105. package/core/.formation/tools/post-complete/health.js +0 -464
  106. package/core/.formation/tools/post-complete/task2038.test.js +0 -246
  107. package/core/.formation/tools/post-complete/task2341.test.js +0 -74
  108. package/core/.rule/general/cortex-tools.yaml +0 -181
  109. package/core/.rule/general/memory-language.yaml +0 -67
  110. package/core/.rule/general/memory-source-priority.yaml +0 -207
  111. package/core/.rule/general/synapse-cognitive-fusion.yaml +0 -301
  112. package/core/.specialist/Ansuz/concepts/cognitive_systems_hippocampus.yaml +0 -14
  113. package/core/.specialist/Ansuz/concepts/write_verification.yaml +0 -26
  114. package/core/.specialist/Ansuz/modules/recall.yaml +0 -45
  115. package/core/.specialist/tools/MEMORY_RECALL_TRIGGERS.md +0 -156
  116. package/core/.specialist/tools/context-injection.js +0 -395
  117. package/core/dev/scripts/probe/hippocampus-concurrency.js +0 -247
@@ -1,207 +0,0 @@
1
- # .rule/general/memory-source-priority.yaml
2
- # Memory Source Priority and Recall Trigger Rules (TASK_1077)
3
- #
4
- # Formalizes the deterministic priority ordering and mandatory trigger points
5
- # for specialist memory recall. Prevents the "last-source-wins" silent failure
6
- # mode where overlapping claims from different memory layers are resolved by
7
- # load order rather than evidence quality.
8
- #
9
- # Priority: This rule applies to all specialists (Ansuz, Amelia, Huginn)
10
- # that use the memory stack (Synapse + Hippocampus + Handoff).
11
- # Conflicts: This rule supersedes ad-hoc recall decisions in phase files.
12
- # Phase files may define WHEN to recall; this file defines
13
- # HOW to arbitrate when sources disagree.
14
-
15
- _meta:
16
- category: "general"
17
- priority: 1
18
- applies_to:
19
- - "ai_agent"
20
- - "ansuz"
21
- - "amelia"
22
- - "huginn"
23
- last_updated: "2026-04-11"
24
- created_by: "TASK_1077 — Memory source priority and trigger map"
25
- contract_file: ".kenaz/specialist/memory_source_priority.yaml"
26
- trigger_map: ".specialist/tools/MEMORY_RECALL_TRIGGERS.md"
27
-
28
- rules:
29
-
30
- # =============================================================================
31
- # MSP-001: Priority Ordering is Mandatory
32
- # =============================================================================
33
- - id: "MSP-001"
34
- title: "Memory source priority ordering must be applied at every conflict"
35
- description: |
36
- When two or more recalled items address the same topic (symbol, file, or
37
- decision), the agent MUST resolve the conflict using the priority order
38
- defined in `.kenaz/specialist/memory_source_priority.yaml`.
39
-
40
- Priority order (high → low):
41
- 100 user_session_context (current conversation — beats all)
42
- 90 verified_decision_rune (shipped architectural commitments)
43
- 80 session_handoff (uncommitted work from prior session)
44
- 70 self_model_lesson (identity-layer learning)
45
- 60 risk_or_fix_rune (active risk warnings and fixes)
46
- 50 sigil (architectural patterns, general)
47
- 40 insight_or_pattern_rune (observations)
48
- 30 episode (raw narrative)
49
- 20 summary_or_ash_rune (distilled principles)
50
- 10 lesson_guard (advisory checklist, already surfaced by phase-gate)
51
-
52
- Silent "last source wins" is a violation of this rule.
53
- severity: "must"
54
- rationale: |
55
- Without explicit ordering, the agent silently prefers whichever source
56
- happened to load last. This produces non-deterministic decisions that
57
- cannot be reviewed or debugged. Deterministic ordering makes
58
- disagreements visible and auditable.
59
- test: |
60
- Given two recalled items on the same topic, can the agent name the winning
61
- source, its priority_rank, and the conflict_mode applied?
62
- YES → compliant. NO → violation.
63
-
64
- # =============================================================================
65
- # MSP-002: Conflict Mode Must Be Honoured
66
- # =============================================================================
67
- - id: "MSP-002"
68
- title: "strict vs advisory conflict modes must be applied as specified"
69
- description: |
70
- Each source type has a conflict_mode in memory_source_priority.yaml:
71
- - strict: highest-priority item wins; competing view hidden from agent
72
- but logged with conflict_with: <winner_id>
73
- - advisory: highest-priority item wins; competing view surfaced to agent
74
- labelled as "competing view (rank: N)"
75
-
76
- Agents must NOT:
77
- - apply advisory mode to a strict-mode source
78
- - apply strict mode when the source specifies advisory
79
- - silently ignore either the winner or the loser
80
-
81
- Overriding a strict-mode winner requires an explicit user statement in the
82
- current session (user_session_context, rank 100).
83
- severity: "must"
84
- rationale: |
85
- Strict mode exists precisely for risk/fix runes: an agent that surfaces a
86
- risk warning as a "competing view" invites rationalizing it away. Advisory
87
- mode exists for cases where nuance matters more than uniformity.
88
- test: |
89
- When a risk_or_fix_rune (strict) conflicts with an episode (advisory),
90
- does the agent follow the rune without showing the episode as an option?
91
- YES (unless user overrides) → compliant.
92
-
93
- # =============================================================================
94
- # MSP-003: Required Recall Triggers Must Fire
95
- # =============================================================================
96
- - id: "MSP-003"
97
- title: "Required recall triggers must execute at their specified phase boundary"
98
- description: |
99
- The following triggers are non-optional; skipping them requires an explicit
100
- documented reason (analogous to CANARY_CHECK — "SKIP — reason"):
101
-
102
- Phase 0 (Boot):
103
- - cortex_recall(type=ash, limit=5) → load ash runes
104
- - synapse_sigils(projectPath) → load sigils
105
- - Read ansuz_self_model.json → load self_model_lesson
106
-
107
- Phase 1 (Requirements):
108
- - synapse_recall(query=task_title+scope_keywords) → check rune history
109
-
110
- Before editing a non-trivial symbol (> 5 lines, non-config):
111
- - synapse_recall(symbol_name) → check risk/fix runes; kenaz_lsp_references(symbol_name) → check blast radius
112
-
113
- Phase 3 (Decomposition):
114
- - kenaz_lsp_references on the key scope symbols → check blast radius; synapse_recall(scope keywords) → check risk runes
115
-
116
- Phase 9 (Verification):
117
- - synapse_recall on touched symbols → check risk runes post-edit
118
-
119
- Phase-gate blocked exit:
120
- - lesson_guards auto-surfaced by phase-gate.js (agent does NOT need to call manually)
121
-
122
- Optional (conditional):
123
- - session_handoff: load only if a per-session slot exists under
124
- .kenaz/specialist/handoffs/ (latest generated_at wins; resolved via
125
- handoff-resolver readLatestHandoff — the legacy singular
126
- ansuz_session_handoff.json is retired read-only fallback, M3/TASK_1760)
127
- AND its generated_at is within ttl_hours: 72
128
- - episode: load at Phase 0 if hippocampus_episode_recall returns ≥ 1 result;
129
- at Phase 1 if relevant task_id appears in Phase 0 summary
130
- severity: "must"
131
- rationale: |
132
- FAIL-009 records cases where the pre-edit impact check was skipped under time pressure
133
- and caused regressions. Required triggers exist because their decision-point
134
- value is unconditional — the question is not "might this matter?" but "this
135
- always matters."
136
- test: |
137
- Did the agent fire cortex_recall(ash) and synapse_sigils during Phase 0?
138
- Did it call synapse_recall (and check kenaz_lsp_references) before modifying a non-trivial symbol?
139
- YES → compliant. NO → violation (must state SKIP reason if consciously skipping).
140
-
141
- # =============================================================================
142
- # MSP-004: TTL Violations Must Be Caught at Load Time
143
- # =============================================================================
144
- - id: "MSP-004"
145
- title: "Expired memory items must not be used as primary evidence"
146
- description: |
147
- Each source type has a TTL (time-to-live):
148
- user_session_context: 24h
149
- verified_decision_rune: 180 days
150
- session_handoff: 72h
151
- self_model_lesson: 365 days
152
- risk_or_fix_rune: 90 days
153
- sigil: 180 days
154
- insight_or_pattern_rune: 90 days
155
- episode: 30 days
156
- summary_or_ash_rune: 45 days
157
- lesson_guard: 180 days
158
-
159
- An item past its TTL:
160
- - MAY be shown to the agent as background context
161
- - MUST NOT be treated as primary evidence for a current decision
162
- - MUST be labelled as "expired (N days old)" when shown
163
-
164
- TTL expiration does NOT mean the information is wrong — it means
165
- the information has not been refreshed and may be stale relative
166
- to current code. The agent should re-verify before acting on it.
167
- severity: "should"
168
- rationale: |
169
- A 90-day-old risk rune may have been resolved by a later fix. A 72h+
170
- handoff describes a session context that is no longer the active cycle.
171
- TTLs prevent stale guidance from silently overriding fresh evidence.
172
- test: |
173
- Does the agent check freshness_seconds against source TTL before
174
- treating a recalled item as primary evidence?
175
- YES → compliant. Stale item used without staleness label → violation.
176
-
177
- # =============================================================================
178
- # MSP-005: Conflict Audit Trail Must Exist
179
- # =============================================================================
180
- - id: "MSP-005"
181
- title: "Conflict arbitration outcomes must be traceable"
182
- description: |
183
- When a conflict is resolved (winner selected over loser), the losing
184
- item must be recorded in a way that can be audited later:
185
- - In strict mode: log conflict_with: <winner_source_id> to the event log
186
- - In advisory mode: surface the competing view in agent output so the
187
- user can observe that a conflict existed and how it was resolved
188
-
189
- Silent conflict resolution — where the agent picks a winner and shows
190
- nothing about the loser — is a violation of this rule, even in strict mode
191
- (the log entry must still exist).
192
-
193
- Instrumentation: .specialist/tools/memory-action-log.js (TASK_1072)
194
- exposes `recordConflict()` for this purpose. If unavailable, a plain
195
- in-response note is sufficient — the key is that the conflict is visible.
196
- severity: "should"
197
- rationale: |
198
- Without an audit trail, post-hoc review cannot determine whether a bad
199
- decision was caused by wrong priority ordering, wrong source data, or
200
- correct reasoning from correct data. The audit trail makes the arbitration
201
- falsifiable.
202
- test: |
203
- After a conflict resolution event, can a reviewer identify:
204
- (a) which sources conflicted?
205
- (b) which won and why (priority_rank + conflict_mode)?
206
- (c) what happened to the loser?
207
- ALL YES → compliant. Any NO → violation.
@@ -1,301 +0,0 @@
1
- # .rule/general/synapse-cognitive-fusion.yaml
2
- # Synapse 認知融合洞察 — Agent 在工作過程中主動識別 Rune/Sigil 融合時機
3
- # 優先級:此規則凌駕於 CLAUDE.md 和 .claude/skills/ 中的定義
4
- # 前置依賴:SYN-001(可用性偵測)、SYN-007(認知層基本規則)
5
-
6
- _meta:
7
- category: "general"
8
- priority: 1
9
- applies_to:
10
- - "ai_agent"
11
- last_updated: "2026-03-15"
12
- depends_on: ["SYN-001", "SYN-007"]
13
-
14
- rules:
15
- # =============================================================================
16
- # SYN-008: 認知融合洞察(Cognitive Fusion Awareness)
17
- # =============================================================================
18
- - id: "SYN-008"
19
- title: "認知融合洞察"
20
- description: |
21
- 所有 Agent 在工作過程中必須保持「認知雷達」開啟。
22
- 不是做完才想「要不要寫 rune」,而是工作中持續偵測融合時機。
23
- 原則:稀缺但不遲鈍 — 不為寫而寫,但發現值得的瞬間不能錯過。
24
- severity: "should"
25
-
26
- # ─────────────────────────────────────────────────
27
- # 認知雷達:6 種融合信號
28
- # ─────────────────────────────────────────────────
29
- # 工作中遇到這些信號時,暫停 0.5 秒評估是否值得融合。
30
- # 不是 checklist — 是持續運行的背景偵測。
31
-
32
- cognitive_radar:
33
- signals:
34
- - id: "surprise"
35
- name: "意外發現"
36
- description: "代碼行為與預期不符、隱藏的 side-effect、非直覺的設計"
37
- examples:
38
- - "這個函數看起來是 pure,但內部修改了全域狀態"
39
- - "刪除這個「無用」的 import 會導致 side-effect 消失"
40
- - "這個 timeout 不是 bug,是故意的 race condition workaround"
41
- action: "→ inscribe type=risk 或 type=insight"
42
-
43
- - id: "pain_point"
44
- name: "反覆踩坑"
45
- description: "同一個區域、同一種錯誤模式,已經或即將被多次觸發"
46
- examples:
47
- - "第二次在這個模組遇到序列化問題"
48
- - "這個 API 的錯誤處理每次都被忘記"
49
- - "這個 config 的預設值在 dev/prod 不同,每次部署都出問題"
50
- action: "→ inscribe type=fix 或 type=pattern(標記反覆出錯的模式)"
51
-
52
- - id: "design_fork"
53
- name: "設計分歧點"
54
- description: "面對 2+ 方案做出了非顯然的選擇,且理由不在代碼中"
55
- examples:
56
- - "選了 polling 而非 WebSocket — 因為後端不支援長連接"
57
- - "用了 SQLite WAL 而非 default journal — 因為需要併發讀"
58
- - "不用 ORM 直接寫 SQL — 因為 KuzuDB 的 Cypher 沒有 ORM"
59
- action: "→ inscribe type=decision(記錄選擇和理由)"
60
-
61
- - id: "cross_boundary"
62
- name: "跨模組洞察"
63
- description: "發現 3+ 個 symbol 共同構成一個未命名的概念或流程"
64
- examples:
65
- - "scanner → indexer → graph_builder 構成 'synapse indexing pipeline'"
66
- - "auth_middleware → session_store → token_refresh 構成 'auth flow'"
67
- - "dispatch → prompt_assembly → log_writer 構成 'formation execution'"
68
- action: "→ forge Sigil(建立概念節點,連接相關 symbols)"
69
-
70
- - id: "hidden_constraint"
71
- name: "隱藏約束"
72
- description: "代碼中存在未文檔化的約束、順序依賴、或環境假設"
73
- examples:
74
- - "必須先 init embedding engine 才能 search — 否則 silent failure"
75
- - "這個函數只能在主線程呼叫 — 沒有 assert 但會 deadlock"
76
- - "Windows 上路徑必須用 \\ 但這個函數假設了 /"
77
- action: "→ inscribe type=risk(標記危險區域)"
78
-
79
- - id: "evolution_trace"
80
- name: "演化軌跡"
81
- description: "一段代碼經歷了顯著的設計演化,當前狀態需要歷史 context 才能理解"
82
- examples:
83
- - "這個 fallback 邏輯是因為 v1 API 還有 client 在用"
84
- - "雙 session 架構是從單 session 演化來的 — 解決 reindex blocking"
85
- - "這個 cache 層是後加的 — 原本直接查 DB,因為 P99 > 2s"
86
- action: "→ inscribe type=insight(記錄演化脈絡)"
87
-
88
- activation: |
89
- 認知雷達不是每個 tool call 後都跑一次。
90
- 它在以下自然工作節點自動活化:
91
- - 讀完一段陌生代碼後(「這裡怎麼這樣寫?」→ surprise / hidden_constraint)
92
- - 定位到 bug 根因後(「原來是這個原因」→ pain_point / surprise)
93
- - 做出技術選擇後(「選 A 不選 B 因為...」→ design_fork)
94
- - 完成跨模組理解後(「原來這三個模組一起構成了...」→ cross_boundary)
95
- - 讀到歷史 commit 或 comment 後(「所以當初是因為...」→ evolution_trace)
96
-
97
- red_flags: |
98
- 如果你發現自己在想以下任何一句話 — 立刻停下,這是跳過認知融合的前兆:
99
- - 「這次沒什麼特別的發現」— 真的嗎?還是你根本沒啟動雷達?
100
- - 「都是標準工作,不需要記錄」— FAIL-010 的 5 個 non-obvious pattern 也是「標準工作」中發現的
101
- - 「太忙了,先做下一個任務」— 多任務並行時認知融合最容易被犧牲,但此時發現往往最有價值
102
- - 「等一下再補」— 你不會回來的。上下文一旦切換,洞察就消失了
103
- - 「這個之前應該有人寫過了」— 查了嗎?沒查就是猜測,猜測不是理由
104
- - 「只改了幾行,不值得記」— 改動大小 ≠ 洞察價值。一行 fix 可能藏著最關鍵的 risk rune
105
-
106
- anti_rationalization:
107
- - excuse: "沒什麼值得記錄的"
108
- reality: "FAIL-010 中 Ansuz 跨 3 個任務發現 5 個 non-obvious pattern,一個都沒記。「沒什麼」是最危險的自我欺騙"
109
- - excuse: "這是標準操作,大家都知道"
110
- reality: "下一個 agent 不是你,它沒有你此刻的上下文。標準操作中的例外才是最需要記的"
111
- - excuse: "多任務並行,沒時間做 checkpoint"
112
- reality: "並行正是 FAIL-010 的根因。越忙越要做 — checkpoint 是 hard gate,不是軟性建議"
113
- - excuse: "完成任務比較重要,認知融合是附加的"
114
- reality: "認知融合是任務完成的一部分。沒有 rune 的任務 = 一次性消耗,不產生複利"
115
-
116
- # =============================================================================
117
- # SYN-009: 融合適性分析(Fusion Fitness Analysis)
118
- # =============================================================================
119
- - id: "SYN-009"
120
- title: "融合適性分析"
121
- description: |
122
- 偵測到信號後,快速評估這段知識是否值得注入 Synapse 認知層。
123
- 不是所有發現都值得寫 — 過度注入會污染認知層,降低 recall 品質。
124
- severity: "should"
125
-
126
- # ─── 三維評分 ───
127
- fitness_dimensions:
128
- future_utility:
129
- question: "未來 agent 在這個 symbol 附近工作時,需要知道這件事嗎?"
130
- high: "不知道會踩坑、會做錯決策、會重複排查"
131
- low: "知道了也不影響工作結果"
132
- weight: 0.5
133
-
134
- non_obviousness:
135
- question: "這個知識能從代碼本身直接讀出來嗎?"
136
- high: "看代碼看不出來,需要額外 context(歷史、環境、業務)"
137
- low: "代碼自解釋,docstring 已說明,命名就能看懂"
138
- weight: 0.3
139
-
140
- stability:
141
- question: "這個知識的保質期有多長?"
142
- high: "架構級決策、持久的設計約束、反覆出現的模式"
143
- low: "臨時 workaround、即將重構的代碼、版本特定的 hack"
144
- weight: 0.2
145
-
146
- # ─── 決策門檻 ───
147
- decision_gate:
148
- inscribe_threshold: |
149
- 三維加權 ≥ 0.6 → inscribe
150
- 任一維度 = high 且其他不是 low → inscribe
151
- 全部 low → 跳過
152
- forge_threshold: |
153
- cross_boundary 信號 + 涉及 3+ symbol + future_utility=high → forge
154
- 只有 2 個 symbol → 考慮只 inscribe,不建 sigil
155
-
156
- # ─── 快速判斷捷徑 ───
157
- shortcuts:
158
- always_inscribe:
159
- - "bug 根因是 non-obvious 的(不看代碼會再踩)"
160
- - "函數有未文檔化的 precondition 或 side-effect"
161
- - "做了會影響其他模組的架構決策"
162
- never_inscribe:
163
- - "docstring 或 comment 已經說明的事"
164
- - "標準 library 用法(不是專案特有的)"
165
- - "純 style/formatting 的觀察"
166
- - "confidence < 0.6 的推測(等驗證後再寫)"
167
-
168
- # =============================================================================
169
- # SYN-010: Sigil 湧現偵測(Sigil Emergence Detection)
170
- # =============================================================================
171
- - id: "SYN-010"
172
- title: "Sigil 湧現偵測"
173
- description: |
174
- Sigil 是跨 symbol 的語義概念節點 — 比 Rune 更稀缺、更有價值。
175
- Sigil 不是設計出來的,而是從工作中「湧現」的。
176
- 當你發現散落的 symbol 之間有未命名的概念連結時,就是 forge 的時機。
177
- severity: "should"
178
-
179
- # ─── 湧現條件 ───
180
- emergence_conditions:
181
- must_all:
182
- - "涉及 3+ 個 symbol(跨越至少 2 個檔案)"
183
- - "這些 symbol 共同構成一個可命名的概念或流程"
184
- - "概念名稱不是已有的 class/module 名(否則用 MEMBER_OF 關係就夠了)"
185
- - "未來 agent 用這個概念名搜尋時,應該能找到所有相關 symbol"
186
-
187
- # ─── 湧現場景 ───
188
- emergence_scenarios:
189
- pipeline_discovery: |
190
- 工作中發現 A → B → C → D 的資料流或控制流,
191
- 但這四個 symbol 分散在不同檔案,沒有統一的 entry point。
192
- → forge Sigil: name="xxx_pipeline", members=[A, B, C, D]
193
- pattern_crystallization: |
194
- 在不同模組中發現相同的設計模式被反覆使用(如 retry-with-backoff),
195
- 但沒有共用的 base class 或 utility。
196
- → forge Sigil: name="retry_pattern", members=[impl_1, impl_2, impl_3]
197
- concept_naming: |
198
- 多個 rune 指向同一個抽象概念(如「auth 相關的所有安全檢查」),
199
- 但沒有一個統一的名字。
200
- → forge Sigil: name="auth_security_checks", abstract="All security validations in the auth flow"
201
- failure_cluster: |
202
- 多個 fix rune 集中在相關的 symbol 群,暗示一個脆弱區域。
203
- → forge Sigil: name="xxx_fragile_zone", members=[affected symbols]
204
-
205
- # ─── Sigil 品質標準 ───
206
- quality_criteria:
207
- name: "簡潔英文、snake_case、概念性(不是技術細節)"
208
- abstract: "一句話說明這個概念是什麼、為什麼重要"
209
- members: "至少 3 個 symbol,每個都和概念有真關聯(不湊數)"
210
-
211
- # ─── 與 recall 的閉環 ───
212
- recall_integration: |
213
- forge 完 Sigil 後,未來 agent 用 synapse_recall 搜尋概念名,
214
- 就能一次拉出所有相關 symbol + rune。
215
- 這是認知層的核心價值:把散落的知識凝結成可搜尋的概念。
216
-
217
- # =============================================================================
218
- # SYN-012: Acted-On 回溯鏈(Recall → Inscribe Linkage)
219
- # =============================================================================
220
- - id: "SYN-012"
221
- title: "Acted-On 回溯鏈"
222
- description: |
223
- synapse_inscribe 時必須回溯本 session 先前 recall 過的 rune,
224
- 將相關的 rune_id 傳入 related_rune_ids 參數。這閉合了
225
- recall → acted_on → confidence_boost 的學習迴路。
226
- 沒有 related_rune_ids 的 inscribe = 斷鏈,metaplasticity
227
- confidence 更新無法運作。
228
- severity: "must"
229
-
230
- why: |
231
- TASK_1245 simulation 發現 90 天內 6333 次 recall 只有 22 次
232
- acted_on(0.35%)。根因:agent inscribe 時從不傳 related_rune_ids,
233
- 導致 rune_usage_log 中 acted_on 永遠為 0。confidence 更新規則
234
- 無法觸發(需要 acted_on_rate > 0.5)。
235
-
236
- protocol:
237
- when: "每次呼叫 synapse_inscribe 時"
238
- how: |
239
- 1. 回顧本 session 中你已經 recall 過的 rune(synapse_recall 結果)
240
- 2. 從中選出與當前 inscribe 直接相關的 rune_id(你讀了它、它影響了你的決策或行動)
241
- 3. 傳入 related_rune_ids=[rune_id_1, rune_id_2, ...]
242
- examples:
243
- recall_then_fix: |
244
- synapse_recall("connection timeout") → 返回 rune_abc123(risk rune)
245
- 你讀了它,避開了已知的 timeout 地雷,然後 inscribe 了新的 fix rune
246
- → synapse_inscribe(... related_rune_ids=["rune_abc123"])
247
- recall_symbol_then_inscribe: |
248
- synapse_recall("parseConfig") → 返回 rune_def456(decision rune)
249
- 你修改了 parseConfig 並留下新的 decision rune
250
- → synapse_inscribe(... related_rune_ids=["rune_def456"])
251
- no_prior_recall: |
252
- 本 session 沒有做過任何 recall → related_rune_ids=[] 或省略
253
- 這是合理的 — 不要為了填而填
254
-
255
- rules:
256
- - "✅ 每次 inscribe 前回顧:本 session recall 過哪些 rune?哪些影響了這次 inscribe?"
257
- - "✅ 只傳真正相關的 rune_id — 你讀了它且它影響了你的行動"
258
- - "❌ 不要為了填 related_rune_ids 而額外 recall — 自然工作流中已經 recall 的才算"
259
- - "❌ 不要把所有 recall 過的 rune 都塞進去 — 只選直接相關的"
260
-
261
- # =============================================================================
262
- # SYN-011: 認知層應用(Cognitive Layer Application)
263
- # =============================================================================
264
- - id: "SYN-011"
265
- title: "認知層應用"
266
- description: |
267
- 不只是寫入 — 更重要的是在工作中主動應用已有的認知。
268
- 每個 agent 開始觸碰 symbol 前,都應該先查詢認知層。
269
- severity: "should"
270
-
271
- # ─── 應用時機 ───
272
- application_triggers:
273
- pre_modify: |
274
- 準備修改任何 symbol 前:
275
- 1. synapse_recall 查詢該 symbol / 該模組的已知 rune
276
- 2. 如有 risk rune → 小心處理,避免踩已知地雷
277
- 3. 如有 decision rune → 理解當初為什麼這樣設計,避免破壞意圖
278
- 4. 如有 fix rune → 確認你的修改不會 reintroduce 已修過的 bug
279
- pre_design: |
280
- 設計新功能或架構時:
281
- 1. synapse_sigils 瀏覽概念地圖 → 理解系統高層結構
282
- 2. synapse_recall 搜尋相關概念 → 找已有的 pattern 和 decision
283
- 3. 基於已有認知做設計,而非從零開始
284
- during_debug: |
285
- Debug 過程中:
286
- 1. 定位到可疑 symbol 後,先 synapse_recall 查 fix/risk rune
287
- 2. 如果有「上次也是這裡出問題」的 rune → 直接讀根因,跳過重複排查
288
- 3. 節省的不只是時間,更是避免走入錯誤的假設
289
-
290
- # ─── 認知循環 ───
291
- cognitive_loop: |
292
- 工作中的認知不是線性的,而是一個循環:
293
-
294
- recall(帶著已知開始)
295
- → 工作(偵測信號)
296
- → 評估(融合適性分析)
297
- → inscribe/forge(注入新知識)
298
- → 下次 recall 時可用
299
-
300
- 每一輪工作都在豐富認知層,讓下一輪工作更有效。
301
- Agent 不是工具,是有記憶的協作者。
@@ -1,14 +0,0 @@
1
- id: cognitive_systems_hippocampus
2
- priority: P1
3
- always_load: false
4
- triggers:
5
- - "episodes"
6
- - "memory"
7
- - "consolidation"
8
- size_kb: 0.44
9
- evolution_status: operational
10
- ---
11
- hippocampus_consolidation:
12
- what: "Spaced repetition for episodes — consolidation_scores ranks episodes by review urgency (recency × access × richness). Cool tier (>30 days) and Archive tier (>90 days) compress old episodes."
13
- tools: "hippocampus_consolidation_scores, hippocampus_consolidate, hippocampus_due_episodes"
14
- auto: "Auto-consolidation runs on Dashboard startup and on hippocampus_consolidation_scores/consolidate calls."
@@ -1,26 +0,0 @@
1
- id: write_verification
2
- priority: P0
3
- always_load: true
4
- triggers:
5
- always: true
6
- size_kb: 1.23
7
- evolution_status: immutable
8
- ---
9
- write_verification_protocol:
10
- trigger: "After every synapse_inscribe call"
11
- description: "Verify the rune was actually written — eliminates silent write failures (TASK_946)"
12
- steps:
13
- - "1. Extract first 8 words of inscribed content (strip punctuation for FTS5 safety)"
14
- - "2. Call synapse_recall(query=<8_words>, limit=1, projectPath=PROJECT_PATH)"
15
- - "3. If result_count > 0 → write confirmed, continue normally (silent)"
16
- - |
17
- 4. If result_count = 0:
18
- a. Distinguish failure type:
19
- - Connection refused / timeout → Synapse unavailable → log warning only, do NOT push ambient_signal
20
- - Empty results with successful response → genuine write failure → proceed to step b
21
- b. Push to ambient_signals: {signal_type: 'write_failure', summary: 'inscribe failed: {symbol_stable_id} — recall returned 0 results', detected_at: ISO, symbols: [symbol_stable_id]}
22
- c. Notify user: "⚠️ Memory write could not be verified for {symbol_stable_id}"
23
- notes:
24
- - "MEM-LANG-001: verify query must be in English — same rule as inscribe content"
25
- - "Max verify query length: 8 words, no special characters"
26
- - "This protocol applies to ALL synapse_inscribe calls — no exceptions"
@@ -1,45 +0,0 @@
1
- name: recall
2
- description: "Ansuz episodic memory recall protocol — when and how to use hippocampus"
3
- auto_inject: "Phase 1 enter(強制注入,確保 Ansuz 帶著歷史認知進入需求分析)"
4
-
5
- # ═══════════════════════════════════════
6
- # 三層回憶機制(Phase 0 Tiered Recall)
7
- # Redesigned: TASK_685 — cold-start fix
8
- # ═══════════════════════════════════════
9
- tiers:
10
- tier_1_ash:
11
- tool: "synapse_recall"
12
- params: "type=ash, limit=5, projectPath=當前專案絕對路徑"
13
- when: "Phase 0 無條件執行 — 不依賴 query 關鍵字"
14
- purpose: "載入 Ash 哲學/架構 Rune(系統設計原則、跨 session 洞見)。冷啟動也保證命中,解決新 session 遺漏高價值 rune 的問題"
15
- gate_signal: "ash_loaded=true(Phase 0 exit 必要條件)"
16
-
17
- tier_2_sigils:
18
- tool: "synapse_sigils"
19
- params: "projectPath=當前專案絕對路徑"
20
- when: "Phase 0 無條件執行"
21
- purpose: "載入全域架構 Sigil 概念圖(跨 symbol 的系統級概念)。Ansuz 必須在後續工作中主動應用,不只是存儲"
22
-
23
- tier_3_contextual:
24
- tool: "hippocampus_episode_recall"
25
- params: "projectPath=當前專案絕對路徑, limit=3(不帶 query — FTS5 非語義搜尋,無 query 時按時間倒序,命中率最高)"
26
- when: "情境觸發 — 需要歷史 episode 脈絡時才呼叫"
27
- trigger_conditions:
28
- - "Phase 0:想了解近期 session 的結論與教訓"
29
- - "Phase 1:需求與歷史 episode 相關,需要當時的決策細節"
30
- - "Phase 9:驗證失敗,需要比對歷史同類問題的修復過程"
31
- - "任何時候:Ash/Sigil 觸發了疑問,需要追蹤完整的 episode 細節"
32
- skip_when: "純任務繼續(無需歷史 context)→ 可跳過"
33
-
34
- # ═══════════════════════════════════════
35
- # Phase 1 回憶協議
36
- # ═══════════════════════════════════════
37
- phase_1_protocol:
38
- step_1: "讀 Phase 0 已載入的 Ash rune(ash_loaded=true 確認)— 有無相關 lesson/pattern?"
39
- step_2: "執行 synapse_recall(query=需求關鍵字) — 查 rune/sigil 歷史知識(Phase 1 必做)"
40
- step_3: |
41
- 如果 Phase 0 的 episode 摘要中有與本次需求相關的 task_id:
42
- → hippocampus_episode_recall(task_id=that_episode_task_id)
43
- → 讀完整 entries,提取相關 decision/risk
44
- step_4: "將回憶結果整合進需求分析(避免重蹈歷史坑)"
45
- rule: "synapse_recall 是必做的;hippocampus 細節召回是條件觸發的"