@co-engram/core 0.1.2 → 0.1.3

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 (227) hide show
  1. package/dist/bootstrap/classify.d.ts +67 -0
  2. package/dist/bootstrap/classify.d.ts.map +1 -0
  3. package/dist/bootstrap/classify.js +119 -0
  4. package/dist/bootstrap/classify.js.map +1 -0
  5. package/dist/bootstrap/index.d.ts +89 -0
  6. package/dist/bootstrap/index.d.ts.map +1 -0
  7. package/dist/bootstrap/index.js +158 -0
  8. package/dist/bootstrap/index.js.map +1 -0
  9. package/dist/concepts/dictionary.d.ts +260 -0
  10. package/dist/concepts/dictionary.d.ts.map +1 -0
  11. package/dist/concepts/dictionary.js +253 -0
  12. package/dist/concepts/dictionary.js.map +1 -0
  13. package/dist/concepts/index.d.ts +11 -0
  14. package/dist/concepts/index.d.ts.map +1 -0
  15. package/dist/concepts/index.js +10 -0
  16. package/dist/concepts/index.js.map +1 -0
  17. package/dist/concepts/types.d.ts +65 -0
  18. package/dist/concepts/types.d.ts.map +1 -0
  19. package/dist/concepts/types.js +15 -0
  20. package/dist/concepts/types.js.map +1 -0
  21. package/dist/config/defaults.d.ts +32 -3
  22. package/dist/config/defaults.d.ts.map +1 -1
  23. package/dist/config/defaults.js +52 -2
  24. package/dist/config/defaults.js.map +1 -1
  25. package/dist/config/index.d.ts +18 -1
  26. package/dist/config/index.d.ts.map +1 -1
  27. package/dist/config/index.js +75 -3
  28. package/dist/config/index.js.map +1 -1
  29. package/dist/config/loader.d.ts +10 -0
  30. package/dist/config/loader.d.ts.map +1 -0
  31. package/dist/config/loader.js +10 -0
  32. package/dist/config/loader.js.map +1 -0
  33. package/dist/config/types.d.ts +97 -1
  34. package/dist/config/types.d.ts.map +1 -1
  35. package/dist/contradiction/auto-degrade.d.ts +11 -2
  36. package/dist/contradiction/auto-degrade.d.ts.map +1 -1
  37. package/dist/contradiction/auto-degrade.js +22 -0
  38. package/dist/contradiction/auto-degrade.js.map +1 -1
  39. package/dist/contradiction/resolver.d.ts.map +1 -1
  40. package/dist/contradiction/resolver.js +7 -1
  41. package/dist/contradiction/resolver.js.map +1 -1
  42. package/dist/dreaming/index.d.ts +1 -0
  43. package/dist/dreaming/index.d.ts.map +1 -1
  44. package/dist/dreaming/index.js +1 -0
  45. package/dist/dreaming/index.js.map +1 -1
  46. package/dist/dreaming/llm-pattern-abstraction.d.ts +31 -0
  47. package/dist/dreaming/llm-pattern-abstraction.d.ts.map +1 -0
  48. package/dist/dreaming/llm-pattern-abstraction.js +70 -0
  49. package/dist/dreaming/llm-pattern-abstraction.js.map +1 -0
  50. package/dist/dreaming/rem.d.ts.map +1 -1
  51. package/dist/dreaming/rem.js +1 -0
  52. package/dist/dreaming/rem.js.map +1 -1
  53. package/dist/dreaming/scheduler.d.ts +13 -0
  54. package/dist/dreaming/scheduler.d.ts.map +1 -1
  55. package/dist/dreaming/scheduler.js +14 -2
  56. package/dist/dreaming/scheduler.js.map +1 -1
  57. package/dist/evolution/triggered.d.ts.map +1 -1
  58. package/dist/evolution/triggered.js +1 -0
  59. package/dist/evolution/triggered.js.map +1 -1
  60. package/dist/generative/hypothesis.d.ts.map +1 -1
  61. package/dist/generative/hypothesis.js +1 -0
  62. package/dist/generative/hypothesis.js.map +1 -1
  63. package/dist/i18n/en.d.ts.map +1 -1
  64. package/dist/i18n/en.js +1262 -32
  65. package/dist/i18n/en.js.map +1 -1
  66. package/dist/i18n/index.d.ts +34 -1
  67. package/dist/i18n/index.d.ts.map +1 -1
  68. package/dist/i18n/index.js +36 -7
  69. package/dist/i18n/index.js.map +1 -1
  70. package/dist/i18n/zh.d.ts +698 -32
  71. package/dist/i18n/zh.d.ts.map +1 -1
  72. package/dist/i18n/zh.js +1267 -33
  73. package/dist/i18n/zh.js.map +1 -1
  74. package/dist/index/graph-builder.js +3 -3
  75. package/dist/index/graph-builder.js.map +1 -1
  76. package/dist/index.d.ts +3 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +3 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/learning/loop.d.ts +9 -0
  81. package/dist/learning/loop.d.ts.map +1 -1
  82. package/dist/learning/loop.js +42 -1
  83. package/dist/learning/loop.js.map +1 -1
  84. package/dist/maintenance/types.d.ts +11 -0
  85. package/dist/maintenance/types.d.ts.map +1 -1
  86. package/dist/maintenance/types.js.map +1 -1
  87. package/dist/merge/synapse-merger.js +6 -0
  88. package/dist/merge/synapse-merger.js.map +1 -1
  89. package/dist/merge-driver.cjs +64 -5
  90. package/dist/observability/audit-log.d.ts +7 -1
  91. package/dist/observability/audit-log.d.ts.map +1 -1
  92. package/dist/observability/audit-log.js.map +1 -1
  93. package/dist/observability/necessity-evaluator.d.ts +29 -0
  94. package/dist/observability/necessity-evaluator.d.ts.map +1 -1
  95. package/dist/observability/necessity-evaluator.js +240 -13
  96. package/dist/observability/necessity-evaluator.js.map +1 -1
  97. package/dist/observability/proposal-engine.d.ts.map +1 -1
  98. package/dist/observability/proposal-engine.js +12 -0
  99. package/dist/observability/proposal-engine.js.map +1 -1
  100. package/dist/observability/runtime-description-check.d.ts +55 -0
  101. package/dist/observability/runtime-description-check.d.ts.map +1 -0
  102. package/dist/observability/runtime-description-check.js +63 -0
  103. package/dist/observability/runtime-description-check.js.map +1 -0
  104. package/dist/prompt-signals/cache.d.ts +73 -0
  105. package/dist/prompt-signals/cache.d.ts.map +1 -1
  106. package/dist/prompt-signals/cache.js +102 -0
  107. package/dist/prompt-signals/cache.js.map +1 -1
  108. package/dist/prompt-signals/event-bus.d.ts +82 -0
  109. package/dist/prompt-signals/event-bus.d.ts.map +1 -0
  110. package/dist/prompt-signals/event-bus.js +105 -0
  111. package/dist/prompt-signals/event-bus.js.map +1 -0
  112. package/dist/prompt-signals/index.d.ts +2 -1
  113. package/dist/prompt-signals/index.d.ts.map +1 -1
  114. package/dist/prompt-signals/index.js +2 -1
  115. package/dist/prompt-signals/index.js.map +1 -1
  116. package/dist/reinforcement/ltp.d.ts +15 -1
  117. package/dist/reinforcement/ltp.d.ts.map +1 -1
  118. package/dist/reinforcement/ltp.js +24 -5
  119. package/dist/reinforcement/ltp.js.map +1 -1
  120. package/dist/reinforcement/related.d.ts +31 -2
  121. package/dist/reinforcement/related.d.ts.map +1 -1
  122. package/dist/reinforcement/related.js +39 -3
  123. package/dist/reinforcement/related.js.map +1 -1
  124. package/dist/retrieval/filter.d.ts.map +1 -1
  125. package/dist/retrieval/filter.js +7 -0
  126. package/dist/retrieval/filter.js.map +1 -1
  127. package/dist/retrieval/fts.d.ts +6 -5
  128. package/dist/retrieval/fts.d.ts.map +1 -1
  129. package/dist/retrieval/fts.js +74 -22
  130. package/dist/retrieval/fts.js.map +1 -1
  131. package/dist/status/index.d.ts +7 -0
  132. package/dist/status/index.d.ts.map +1 -0
  133. package/dist/status/index.js +7 -0
  134. package/dist/status/index.js.map +1 -0
  135. package/dist/status/status.d.ts +132 -0
  136. package/dist/status/status.d.ts.map +1 -0
  137. package/dist/status/status.js +437 -0
  138. package/dist/status/status.js.map +1 -0
  139. package/dist/storage/engram-store.d.ts.map +1 -1
  140. package/dist/storage/engram-store.js +17 -2
  141. package/dist/storage/engram-store.js.map +1 -1
  142. package/dist/storage/git.d.ts +168 -0
  143. package/dist/storage/git.d.ts.map +1 -1
  144. package/dist/storage/git.js +616 -33
  145. package/dist/storage/git.js.map +1 -1
  146. package/dist/storage/index.d.ts +1 -0
  147. package/dist/storage/index.d.ts.map +1 -1
  148. package/dist/storage/index.js +1 -0
  149. package/dist/storage/index.js.map +1 -1
  150. package/dist/storage/infra-doctor.d.ts +42 -0
  151. package/dist/storage/infra-doctor.d.ts.map +1 -0
  152. package/dist/storage/infra-doctor.js +92 -0
  153. package/dist/storage/infra-doctor.js.map +1 -0
  154. package/dist/storage/obsidian-links.d.ts +73 -0
  155. package/dist/storage/obsidian-links.d.ts.map +1 -0
  156. package/dist/storage/obsidian-links.js +177 -0
  157. package/dist/storage/obsidian-links.js.map +1 -0
  158. package/dist/storage/path.d.ts +24 -0
  159. package/dist/storage/path.d.ts.map +1 -1
  160. package/dist/storage/path.js +53 -0
  161. package/dist/storage/path.js.map +1 -1
  162. package/dist/storage/repository.d.ts +37 -1
  163. package/dist/storage/repository.d.ts.map +1 -1
  164. package/dist/storage/repository.js +235 -17
  165. package/dist/storage/repository.js.map +1 -1
  166. package/dist/storage/synapse-store.d.ts +7 -1
  167. package/dist/storage/synapse-store.d.ts.map +1 -1
  168. package/dist/storage/synapse-store.js +8 -0
  169. package/dist/storage/synapse-store.js.map +1 -1
  170. package/dist/tools/audit-query-tool.d.ts +53 -0
  171. package/dist/tools/audit-query-tool.d.ts.map +1 -0
  172. package/dist/tools/audit-query-tool.js +123 -0
  173. package/dist/tools/audit-query-tool.js.map +1 -0
  174. package/dist/tools/doctor-tools.d.ts +5 -0
  175. package/dist/tools/doctor-tools.d.ts.map +1 -1
  176. package/dist/tools/doctor-tools.js +11 -3
  177. package/dist/tools/doctor-tools.js.map +1 -1
  178. package/dist/tools/engram-tools.d.ts +13 -0
  179. package/dist/tools/engram-tools.d.ts.map +1 -1
  180. package/dist/tools/engram-tools.js +72 -8
  181. package/dist/tools/engram-tools.js.map +1 -1
  182. package/dist/tools/index.d.ts +3 -0
  183. package/dist/tools/index.d.ts.map +1 -1
  184. package/dist/tools/index.js +3 -0
  185. package/dist/tools/index.js.map +1 -1
  186. package/dist/tools/llm-descriptions.d.ts +28 -28
  187. package/dist/tools/llm-descriptions.d.ts.map +1 -1
  188. package/dist/tools/llm-descriptions.js +56 -489
  189. package/dist/tools/llm-descriptions.js.map +1 -1
  190. package/dist/tools/normalization.d.ts +43 -0
  191. package/dist/tools/normalization.d.ts.map +1 -0
  192. package/dist/tools/normalization.js +68 -0
  193. package/dist/tools/normalization.js.map +1 -0
  194. package/dist/tools/registry.d.ts.map +1 -1
  195. package/dist/tools/registry.js +6 -0
  196. package/dist/tools/registry.js.map +1 -1
  197. package/dist/tools/schemas.d.ts +67 -11
  198. package/dist/tools/schemas.d.ts.map +1 -1
  199. package/dist/tools/schemas.js +61 -6
  200. package/dist/tools/schemas.js.map +1 -1
  201. package/dist/tools/skill-tools.js +1 -1
  202. package/dist/tools/skill-tools.js.map +1 -1
  203. package/dist/tools/synapse-tools.d.ts.map +1 -1
  204. package/dist/tools/synapse-tools.js +1 -0
  205. package/dist/tools/synapse-tools.js.map +1 -1
  206. package/dist/tools/sync-tools.d.ts +102 -0
  207. package/dist/tools/sync-tools.d.ts.map +1 -0
  208. package/dist/tools/sync-tools.js +309 -0
  209. package/dist/tools/sync-tools.js.map +1 -0
  210. package/dist/tools/synthesize-tools.d.ts +79 -0
  211. package/dist/tools/synthesize-tools.d.ts.map +1 -0
  212. package/dist/tools/synthesize-tools.js +297 -0
  213. package/dist/tools/synthesize-tools.js.map +1 -0
  214. package/dist/tools/tool-profile.d.ts +68 -0
  215. package/dist/tools/tool-profile.d.ts.map +1 -0
  216. package/dist/tools/tool-profile.js +174 -0
  217. package/dist/tools/tool-profile.js.map +1 -0
  218. package/dist/tools/tool.d.ts +17 -0
  219. package/dist/tools/tool.d.ts.map +1 -1
  220. package/dist/tools/tool.js.map +1 -1
  221. package/dist/types/disclosure.d.ts +7 -0
  222. package/dist/types/disclosure.d.ts.map +1 -1
  223. package/dist/types/repository-types.d.ts +17 -1
  224. package/dist/types/repository-types.d.ts.map +1 -1
  225. package/dist/types/synapse.d.ts +19 -1
  226. package/dist/types/synapse.d.ts.map +1 -1
  227. package/package.json +9 -9
@@ -0,0 +1,260 @@
1
+ /**
2
+ * CONCEPT_DICTIONARY —— 概念字典单一真相源
3
+ *
4
+ * 所有用户可见 surface(viewer help tab、mcp instructions、prompt-builder、工具描述)
5
+ * 引用此处的概念解释,而不是各自维护一份(否则会出现概念漂移,见 fix-2 的
6
+ * help-contract 抓到的 synapse/proposal 漂移)。
7
+ *
8
+ * 默认值必须与源码一致:
9
+ * - ReinforcementConfig.DEFAULT_CONFIG(ltpGain=0.02 等)
10
+ * - DEFAULT_EFFECTIVENESS_WINDOWS(observation=6h 等)
11
+ * - DEFAULT_VERIFICATION_CONFIG(minEvidenceForPlausible=1 等)
12
+ * - DEFAULT_WEIGHTS(alpha=0.5 等)
13
+ *
14
+ * 修改默认值时,改源码同时改这里 —— fix-3 的运行时 FORBIDDEN_TERMS 校验 + fix-5 的
15
+ * 默认值审计会捕获不一致。
16
+ *
17
+ * @module @co-engram/core/concepts
18
+ */
19
+ import type { ConceptEntry, ConceptId, ScoreBand } from "./types.js";
20
+ /**
21
+ * 概念字典本体
22
+ *
23
+ * `satisfies Readonly<Record<ConceptId, ConceptEntry>>` 强制每个 ConceptId 都有 entry,
24
+ * 添加新 id 但忘了填字典会编译失败。
25
+ */
26
+ export declare const CONCEPT_DICTIONARY: {
27
+ readonly engram: {
28
+ readonly id: "engram";
29
+ readonly zh: "记忆印迹";
30
+ readonly en: "engram";
31
+ readonly userExplanation: {
32
+ readonly zh: "一条被持久化的团队记忆。每条记忆有标题、内容、领域标签,以及随使用强度变化的『重要性』分数。一条记忆可以被多次检索、强化或反驳,状态会随使用反馈演化。";
33
+ readonly en: "A persistent team memory entry with a title, content, domain tags, and an \"importance\" score that evolves with use. Each memory can be retrieved, reinforced, or refuted multiple times — its state evolves with feedback.";
34
+ };
35
+ readonly internalRule: {
36
+ readonly zh: "存储为 markdown + frontmatter,文件路径默认 {domainTags}/{slug}.md。5 种 kind:observation / fact / pattern / procedure / hypothesis。";
37
+ readonly en: "Stored as markdown + frontmatter, default path {domainTags}/{slug}.md. 5 kinds: observation / fact / pattern / procedure / hypothesis.";
38
+ };
39
+ readonly refs: readonly ["synapse", "importance", "kind", "domain_tag"];
40
+ };
41
+ readonly synapse: {
42
+ readonly id: "synapse";
43
+ readonly zh: "记忆突触";
44
+ readonly en: "synapse";
45
+ readonly userExplanation: {
46
+ readonly zh: "两条记忆印迹之间的有类型连接(类似大脑里神经元之间的突触)。常见类型:extends(扩展)、derives_from(派生/证据)、contradicts(矛盾)、related_to(关联)。突触让记忆从孤立条目变成知识图谱。";
47
+ readonly en: "A typed connection between two engrams (like synapses between neurons). Common kinds: extends, derives_from (evidence), contradicts, related_to. Synapses turn isolated entries into a knowledge graph.";
48
+ };
49
+ readonly internalRule: {
50
+ readonly zh: "kind=\"contradicts\" 时,自动给双方 engram 写 contradicted audit 事件(可被 engram_audit_query 查到),触发矛盾解决流程。";
51
+ readonly en: "When kind=\"contradicts\", automatically writes contradicted audit events to both engrams (queryable via engram_audit_query), triggering the contradiction resolution flow.";
52
+ };
53
+ readonly refs: readonly ["engram", "verification_status"];
54
+ };
55
+ readonly ltp: {
56
+ readonly id: "ltp";
57
+ readonly zh: "长时程增强(LTP)";
58
+ readonly en: "Long-Term Potentiation (LTP)";
59
+ readonly userExplanation: {
60
+ readonly zh: "记忆被有效使用时,重要性上升的机制。每次『有效检索』(用户真的用到这条记忆解决了任务)给这条记忆的重要性 +0.02(默认)。这是大脑里『一起激活的神经元连接增强』(Hebbian)的简化模型。";
61
+ readonly en: "The mechanism by which a memory's importance rises on effective use. Each \"effective retrieval\" (the user actually applied the memory to solve a task) adds +0.02 (default) to its importance. This is a simplified model of Hebbian learning (\"neurons that fire together wire together\").";
62
+ };
63
+ readonly internalRule: {
64
+ readonly zh: "每次 effective=1 检索,importance += ltpGain(默认 0.02)。10 次有效检索约能把 0.5 提升到 0.7。";
65
+ readonly en: "Per effective=1 retrieval, importance += ltpGain (default 0.02). ~10 effective retrievals raise 0.5 to ~0.7.";
66
+ };
67
+ readonly refs: readonly ["importance", "observation_window", "hebbian"];
68
+ };
69
+ readonly ltd: {
70
+ readonly id: "ltd";
71
+ readonly zh: "长时程削弱(LTD)";
72
+ readonly en: "Long-Term Depression (LTD)";
73
+ readonly userExplanation: {
74
+ readonly zh: "记忆被错误使用时,重要性下降的机制。每次『失败使用』(用户反馈说这条记忆错了/过时)给重要性 -0.03(默认)。失败惩罚略大于成功增益,符合『失败比成功更显著』的神经科学规律。";
75
+ readonly en: "The mechanism by which a memory's importance falls on failed use. Each \"failed use\" (user reports the memory was wrong or stale) subtracts 0.03 (default) from importance. The penalty slightly exceeds the LTP gain, matching the neuroscience finding that failures weigh more than successes.";
76
+ };
77
+ readonly internalRule: {
78
+ readonly zh: "每次 failedUse,importance -= ltdPenalty(默认 0.03);累积失败超过 failureThreshold(默认 3)次后,按 failureEscalation(默认 1.5)倍率额外惩罚。";
79
+ readonly en: "Per failedUse, importance -= ltdPenalty (default 0.03); once cumulative failures exceed failureThreshold (default 3), an extra failureEscalation (default 1.5) multiplier applies.";
80
+ };
81
+ readonly refs: readonly ["ltp", "importance", "observation_window"];
82
+ };
83
+ readonly hebbian: {
84
+ readonly id: "hebbian";
85
+ readonly zh: "Hebbian 原则";
86
+ readonly en: "Hebbian principle";
87
+ readonly userExplanation: {
88
+ readonly zh: "『一起激活的神经元连接增强』。在 co-engram 里:强化一条记忆时,与它直接相连(通过突触)的邻居记忆也会得到一部分增益(默认一半,即 0.5 倍),让相关知识一起被记住。";
89
+ readonly en: "\"Neurons that fire together wire together.\" In co-engram: when a memory is reinforced, its direct neighbors (via synapses) also gain a fraction of the boost (default half, i.e. 0.5x) — so related knowledge gets remembered together.";
90
+ };
91
+ readonly internalRule: {
92
+ readonly zh: "邻居强化系数 = hebbianRatio(默认 0.5)。直接邻居得到 ltpGain × hebbianRatio 的 importance 增益。";
93
+ readonly en: "Neighbor reinforcement ratio = hebbianRatio (default 0.5). Direct neighbors gain ltpGain × hebbianRatio importance.";
94
+ };
95
+ readonly refs: readonly ["ltp", "synapse", "importance"];
96
+ };
97
+ readonly rpe: {
98
+ readonly id: "rpe";
99
+ readonly zh: "奖励预测误差(RPE)";
100
+ readonly en: "Reward Prediction Error (RPE)";
101
+ readonly userExplanation: {
102
+ readonly zh: "实际价值超出预期的程度。在大脑里,阳性 RPE(比预期好)会触发多巴胺释放,加强相关记忆。co-engram 借用这个概念驱动『候选审批』—— 系统观察到的、超出阈值的新模式会被提名为候选记忆,等用户确认后转为正式记忆。";
103
+ readonly en: "The gap between actual and expected value. In the brain, positive RPE (better than expected) triggers dopamine release and strengthens associated memories. co-engram borrows this for proposal capture — observed patterns exceeding a threshold are nominated as candidate memories awaiting user approval.";
104
+ };
105
+ readonly internalRule: {
106
+ readonly zh: "necessity-evaluator 通过 LLM 或规则评估『这条消息是否值得捕获』,必要度超阈值才进入 proposal 队列。";
107
+ readonly en: "The necessity-evaluator (LLM or rule-based) assesses \"is this message worth capturing\"; only those above the threshold enter the proposal queue.";
108
+ };
109
+ readonly refs: readonly ["engram", "importance"];
110
+ };
111
+ readonly verification_status: {
112
+ readonly id: "verification_status";
113
+ readonly zh: "验证状态";
114
+ readonly en: "verification status";
115
+ readonly userExplanation: {
116
+ readonly zh: "记忆可信度的 5 档状态:未验证 → 似合理 → 较可能 → 已验证 → 已反驳。状态随使用反馈(强化 / 失败 / 跨情境证据)演化。已反驳状态会阻止这条记忆再次被检索命中。";
117
+ readonly en: "5-level memory credibility: unverified → plausible → probable → verified → refuted. Evolves with use feedback (reinforcement / failure / cross-context evidence). Refuted memories are excluded from retrieval.";
118
+ };
119
+ readonly internalRule: {
120
+ readonly zh: "升级条件(默认):似合理需 ≥1 evidence;较可能需 ≥2 evidence 且 ≥2 个不同 domainTags;已验证需 ≥3 evidence、≥2 domains 且创建满 7 天。降级由 LTD/失败驱动。";
121
+ readonly en: "Default upgrade thresholds: plausible ≥1 evidence; probable ≥2 evidence AND ≥2 distinct domainTags; verified ≥3 evidence, ≥2 domains, AND 7 days since creation. Downgrade driven by LTD/failures.";
122
+ };
123
+ readonly refs: readonly ["observation_window", "provenance", "synapse"];
124
+ };
125
+ readonly observation_window: {
126
+ readonly id: "observation_window";
127
+ readonly zh: "观察窗口";
128
+ readonly en: "observation window";
129
+ readonly userExplanation: {
130
+ readonly zh: "记忆被检索命中后开启的一段观察期。窗口期内:用户若回来强化这条记忆 → 记为『有效检索』,触发 LTP;用户若反馈失败 → 记为『失败使用』,触发 LTD;窗口过期 → 关闭,本次命中不计入有效性。窗口长度按 kind 不同:观察类 6 小时、事实/模式/流程类 1-2 天、假设类 7 天。";
131
+ readonly en: "An observation period opened when a memory is retrieved. During the window: if the user returns to reinforce the memory → counted as \"effective retrieval\" (triggers LTP); if the user reports a failure → counted as \"failed use\" (triggers LTD); if the window expires → closed, this hit does not count. Length depends on kind: observation 6h, fact/pattern/procedure 1-2d, hypothesis 7d.";
132
+ };
133
+ readonly internalRule: {
134
+ readonly zh: "默认窗口长度:observation=6h,fact=24h,pattern=48h,procedure=48h,hypothesis=7d。多 kind engram 取最长。";
135
+ readonly en: "Default window lengths: observation=6h, fact=24h, pattern=48h, procedure=48h, hypothesis=7d. Multi-kind engrams use the maximum.";
136
+ };
137
+ readonly refs: readonly ["ltp", "ltd", "kind"];
138
+ };
139
+ readonly importance: {
140
+ readonly id: "importance";
141
+ readonly zh: "重要性";
142
+ readonly en: "importance";
143
+ readonly userExplanation: {
144
+ readonly zh: "记忆的优先级分数,取值 [0,1]。检索结果按相关性 + 时效性 + 重要性三因子加权打分排序。重要性会随 LTP 上升、LTD 下降,所以常用且有效的记忆会自然浮上来。";
145
+ readonly en: "Memory priority score in [0,1]. Retrieval results are ranked by a weighted three-factor score: relevance + recency + importance. Importance rises with LTP and falls with LTD, so frequently-effective memories naturally surface.";
146
+ };
147
+ readonly internalRule: {
148
+ readonly zh: "三因子权重(默认):relevance α=0.5,recency β=0.3,importance γ=0.2。effectiveImportance = importance × (1 + reinforcementScore),截断到 [0,1]。";
149
+ readonly en: "Default three-factor weights: relevance α=0.5, recency β=0.3, importance γ=0.2. effectiveImportance = importance × (1 + reinforcementScore), clamped to [0,1].";
150
+ };
151
+ readonly refs: readonly ["ltp", "ltd", "decay"];
152
+ };
153
+ readonly decay: {
154
+ readonly id: "decay";
155
+ readonly zh: "艾宾浩斯衰退";
156
+ readonly en: "Ebbinghaus decay";
157
+ readonly userExplanation: {
158
+ readonly zh: "记忆随时间淡化。检索打分里 recency 因子按艾宾浩斯遗忘曲线衰退:每过一个半衰期,recency 减半。半衰期由 decayHalfLifeDays 配置(若为 null 表示永不衰退,如永久性事实)。";
159
+ readonly en: "Memories fade over time. The \"recency\" retrieval factor follows the Ebbinghaus forgetting curve: each half-life halves the recency. The half-life is set by decayHalfLifeDays (null = never decays, e.g. permanent facts).";
160
+ };
161
+ readonly internalRule: {
162
+ readonly zh: "recency = 0.5^(ageDays / decayHalfLifeDays)。ageDays ≤ 0 或 decayHalfLifeDays ≤ 0 时 recency = 1(不衰退)。";
163
+ readonly en: "recency = 0.5^(ageDays / decayHalfLifeDays). When ageDays ≤ 0 or decayHalfLifeDays ≤ 0, recency = 1 (no decay).";
164
+ };
165
+ readonly refs: readonly ["importance"];
166
+ };
167
+ readonly provenance: {
168
+ readonly id: "provenance";
169
+ readonly zh: "溯源";
170
+ readonly en: "provenance";
171
+ readonly userExplanation: {
172
+ readonly zh: "每条记忆的来源信息:谁创建、何时创建、sourceType(firsthand / secondhand / inferred)。验收高可信结论前,应通过溯源信息判断原始证据是否可靠。";
173
+ readonly en: "Each memory carries its origin: who created it, when, and sourceType (firsthand / secondhand / inferred). Before relying on a high-confidence conclusion, check provenance to judge if the underlying evidence is trustworthy.";
174
+ };
175
+ readonly refs: readonly ["engram", "verification_status"];
176
+ };
177
+ readonly domain_tag: {
178
+ readonly id: "domain_tag";
179
+ readonly zh: "领域标签";
180
+ readonly en: "domain tag";
181
+ readonly userExplanation: {
182
+ readonly zh: "记忆的主题分类(如 testing、android、backend)。用于检索过滤、跨情境证据聚合(verification 升级条件需要 ≥2 个不同 domainTags)、目录组织。一条记忆可有多个领域标签。";
183
+ readonly en: "Memory topic (e.g. testing, android, backend). Used for retrieval filtering, cross-context evidence aggregation (verification upgrade requires ≥2 distinct domainTags), and directory layout. A memory can have multiple domain tags.";
184
+ };
185
+ readonly refs: readonly ["engram", "context_tag", "verification_status"];
186
+ };
187
+ readonly context_tag: {
188
+ readonly id: "context_tag";
189
+ readonly zh: "情境标签";
190
+ readonly en: "context tag";
191
+ readonly userExplanation: {
192
+ readonly zh: "比领域标签更细粒度的使用情境(如 session-id、子项目名)。用于跨情境证据聚合 —— 同样的结论在不同情境被独立验证,可信度才更高。";
193
+ readonly en: "Finer-grained use context than domain tags (e.g. session-id, sub-project). Used for cross-context evidence aggregation — the same conclusion independently verified across different contexts yields higher credibility.";
194
+ };
195
+ readonly refs: readonly ["domain_tag", "verification_status"];
196
+ };
197
+ readonly kind: {
198
+ readonly id: "kind";
199
+ readonly zh: "类别";
200
+ readonly en: "kind";
201
+ readonly userExplanation: {
202
+ readonly zh: "记忆的 5 种基础类别:观察(单次所见)、事实(多次验证)、模式(跨情境抽象)、流程(陈述性步骤)、假设(AI 推断、待验证)。类别决定观察窗口长度、检索权重等行为。";
203
+ readonly en: "5 base kinds: observation (single sighting), fact (verified multiple times), pattern (cross-context abstraction), procedure (declarative steps), hypothesis (AI-inferred, to be verified). The kind drives observation-window length, retrieval weights, and other behaviors.";
204
+ };
205
+ readonly internalRule: {
206
+ readonly zh: "observation 窗口 6h;fact 24h;pattern/procedure 48h;hypothesis 7d。多 kind 取 max。";
207
+ readonly en: "observation window 6h; fact 24h; pattern/procedure 48h; hypothesis 7d. Multi-kind uses max.";
208
+ };
209
+ readonly refs: readonly ["engram", "observation_window", "domain_tag"];
210
+ };
211
+ };
212
+ /**
213
+ * 取概念条目(便于从 id 安全访问)
214
+ *
215
+ * 直接 `CONCEPT_DICTIONARY[id]` 也行;此函数主要给宿主代码显式标注返回类型。
216
+ */
217
+ export declare function getConcept(id: ConceptId): ConceptEntry;
218
+ /**
219
+ * 把 [0,1] 浮点分数格式化为人类可读的『高/中/低(数值)』
220
+ *
221
+ * 用于所有用户可见的数值字段(importance / reinforcementScore / lastRetrievalScore /
222
+ * FTS score / effectiveness),防止浮点精度泄露(如 0.018000000000000002、
223
+ * 0.7719155626908514 直接 dump 给用户)。
224
+ *
225
+ * 阈值:≥0.7 高;≥0.3 中;<0.3 低。2 位小数保留可读精度。
226
+ *
227
+ * JSON-RPC 协议层(raw)与文本呈现层(band+display)并存,见 Task 1.3。
228
+ */
229
+ export declare function formatScore(score: number, lang: "zh" | "en"): string;
230
+ /**
231
+ * 工具返回结果里的结构化分数字段
232
+ *
233
+ * `raw` 是 2 位小数(rounded),保证 JSON 序列化不会泄露浮点噪声
234
+ * (如 0.018000000000000002 / 0.7719155626908514)。
235
+ *
236
+ * `band` 是语言中立的等级枚举,host adapter / viewer 用 translatePrompt
237
+ * 或本地 i18n 字典把它本地化为『高』/『high』等。
238
+ *
239
+ * 设计原因:不在 core 层硬编码中文,保持 host-agnostic(元2 dual-host 契约)。
240
+ */
241
+ export interface ScoreField {
242
+ /** 2 位小数(rounded),JSON-safe */
243
+ readonly raw: number;
244
+ /** 语言中立等级:high (≥0.7) / medium (≥0.3) / low (<0.3) */
245
+ readonly band: ScoreBand;
246
+ }
247
+ /**
248
+ * 把裸浮点封装为 ScoreField
249
+ *
250
+ * 同时做两件事:
251
+ * 1. round 到 2 位小数,杀掉浮点噪声(0.018000000000000002 → 0.02)
252
+ * 2. 计算 band(high/medium/low),供 host adapter 渲染
253
+ *
254
+ * 单独抽出是因为多个工具(engram_get / engram_reinforce / engram_recompute_importance /
255
+ * engram_search)都要做同样的处理,集中一处避免漂移。
256
+ */
257
+ export declare function formatScoreField(raw: number): ScoreField;
258
+ /** 重导出类型,方便 `import { CONCEPT_DICTIONARY, type ConceptEntry } from "..."` */
259
+ export type { ConceptEntry, ConceptId, ScoreBand } from "./types.js";
260
+ //# sourceMappingURL=dictionary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/concepts/dictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsM+B,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,YAAY,CAEtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAQpE;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAKxD;AAED,6EAA6E;AAC7E,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,253 @@
1
+ /**
2
+ * CONCEPT_DICTIONARY —— 概念字典单一真相源
3
+ *
4
+ * 所有用户可见 surface(viewer help tab、mcp instructions、prompt-builder、工具描述)
5
+ * 引用此处的概念解释,而不是各自维护一份(否则会出现概念漂移,见 fix-2 的
6
+ * help-contract 抓到的 synapse/proposal 漂移)。
7
+ *
8
+ * 默认值必须与源码一致:
9
+ * - ReinforcementConfig.DEFAULT_CONFIG(ltpGain=0.02 等)
10
+ * - DEFAULT_EFFECTIVENESS_WINDOWS(observation=6h 等)
11
+ * - DEFAULT_VERIFICATION_CONFIG(minEvidenceForPlausible=1 等)
12
+ * - DEFAULT_WEIGHTS(alpha=0.5 等)
13
+ *
14
+ * 修改默认值时,改源码同时改这里 —— fix-3 的运行时 FORBIDDEN_TERMS 校验 + fix-5 的
15
+ * 默认值审计会捕获不一致。
16
+ *
17
+ * @module @co-engram/core/concepts
18
+ */
19
+ /**
20
+ * 概念字典本体
21
+ *
22
+ * `satisfies Readonly<Record<ConceptId, ConceptEntry>>` 强制每个 ConceptId 都有 entry,
23
+ * 添加新 id 但忘了填字典会编译失败。
24
+ */
25
+ export const CONCEPT_DICTIONARY = {
26
+ engram: {
27
+ id: "engram",
28
+ zh: "记忆印迹",
29
+ en: "engram",
30
+ userExplanation: {
31
+ zh: "一条被持久化的团队记忆。每条记忆有标题、内容、领域标签,以及随使用强度变化的『重要性』分数。一条记忆可以被多次检索、强化或反驳,状态会随使用反馈演化。",
32
+ en: 'A persistent team memory entry with a title, content, domain tags, and an "importance" score that evolves with use. Each memory can be retrieved, reinforced, or refuted multiple times — its state evolves with feedback.',
33
+ },
34
+ internalRule: {
35
+ zh: "存储为 markdown + frontmatter,文件路径默认 {domainTags}/{slug}.md。5 种 kind:observation / fact / pattern / procedure / hypothesis。",
36
+ en: "Stored as markdown + frontmatter, default path {domainTags}/{slug}.md. 5 kinds: observation / fact / pattern / procedure / hypothesis.",
37
+ },
38
+ refs: ["synapse", "importance", "kind", "domain_tag"],
39
+ },
40
+ synapse: {
41
+ id: "synapse",
42
+ zh: "记忆突触",
43
+ en: "synapse",
44
+ userExplanation: {
45
+ zh: "两条记忆印迹之间的有类型连接(类似大脑里神经元之间的突触)。常见类型:extends(扩展)、derives_from(派生/证据)、contradicts(矛盾)、related_to(关联)。突触让记忆从孤立条目变成知识图谱。",
46
+ en: "A typed connection between two engrams (like synapses between neurons). Common kinds: extends, derives_from (evidence), contradicts, related_to. Synapses turn isolated entries into a knowledge graph.",
47
+ },
48
+ internalRule: {
49
+ zh: 'kind="contradicts" 时,自动给双方 engram 写 contradicted audit 事件(可被 engram_audit_query 查到),触发矛盾解决流程。',
50
+ en: 'When kind="contradicts", automatically writes contradicted audit events to both engrams (queryable via engram_audit_query), triggering the contradiction resolution flow.',
51
+ },
52
+ refs: ["engram", "verification_status"],
53
+ },
54
+ ltp: {
55
+ id: "ltp",
56
+ zh: "长时程增强(LTP)",
57
+ en: "Long-Term Potentiation (LTP)",
58
+ userExplanation: {
59
+ zh: "记忆被有效使用时,重要性上升的机制。每次『有效检索』(用户真的用到这条记忆解决了任务)给这条记忆的重要性 +0.02(默认)。这是大脑里『一起激活的神经元连接增强』(Hebbian)的简化模型。",
60
+ en: 'The mechanism by which a memory\'s importance rises on effective use. Each "effective retrieval" (the user actually applied the memory to solve a task) adds +0.02 (default) to its importance. This is a simplified model of Hebbian learning ("neurons that fire together wire together").',
61
+ },
62
+ internalRule: {
63
+ zh: "每次 effective=1 检索,importance += ltpGain(默认 0.02)。10 次有效检索约能把 0.5 提升到 0.7。",
64
+ en: "Per effective=1 retrieval, importance += ltpGain (default 0.02). ~10 effective retrievals raise 0.5 to ~0.7.",
65
+ },
66
+ refs: ["importance", "observation_window", "hebbian"],
67
+ },
68
+ ltd: {
69
+ id: "ltd",
70
+ zh: "长时程削弱(LTD)",
71
+ en: "Long-Term Depression (LTD)",
72
+ userExplanation: {
73
+ zh: "记忆被错误使用时,重要性下降的机制。每次『失败使用』(用户反馈说这条记忆错了/过时)给重要性 -0.03(默认)。失败惩罚略大于成功增益,符合『失败比成功更显著』的神经科学规律。",
74
+ en: 'The mechanism by which a memory\'s importance falls on failed use. Each "failed use" (user reports the memory was wrong or stale) subtracts 0.03 (default) from importance. The penalty slightly exceeds the LTP gain, matching the neuroscience finding that failures weigh more than successes.',
75
+ },
76
+ internalRule: {
77
+ zh: "每次 failedUse,importance -= ltdPenalty(默认 0.03);累积失败超过 failureThreshold(默认 3)次后,按 failureEscalation(默认 1.5)倍率额外惩罚。",
78
+ en: "Per failedUse, importance -= ltdPenalty (default 0.03); once cumulative failures exceed failureThreshold (default 3), an extra failureEscalation (default 1.5) multiplier applies.",
79
+ },
80
+ refs: ["ltp", "importance", "observation_window"],
81
+ },
82
+ hebbian: {
83
+ id: "hebbian",
84
+ zh: "Hebbian 原则",
85
+ en: "Hebbian principle",
86
+ userExplanation: {
87
+ zh: "『一起激活的神经元连接增强』。在 co-engram 里:强化一条记忆时,与它直接相连(通过突触)的邻居记忆也会得到一部分增益(默认一半,即 0.5 倍),让相关知识一起被记住。",
88
+ en: '"Neurons that fire together wire together." In co-engram: when a memory is reinforced, its direct neighbors (via synapses) also gain a fraction of the boost (default half, i.e. 0.5x) — so related knowledge gets remembered together.',
89
+ },
90
+ internalRule: {
91
+ zh: "邻居强化系数 = hebbianRatio(默认 0.5)。直接邻居得到 ltpGain × hebbianRatio 的 importance 增益。",
92
+ en: "Neighbor reinforcement ratio = hebbianRatio (default 0.5). Direct neighbors gain ltpGain × hebbianRatio importance.",
93
+ },
94
+ refs: ["ltp", "synapse", "importance"],
95
+ },
96
+ rpe: {
97
+ id: "rpe",
98
+ zh: "奖励预测误差(RPE)",
99
+ en: "Reward Prediction Error (RPE)",
100
+ userExplanation: {
101
+ zh: "实际价值超出预期的程度。在大脑里,阳性 RPE(比预期好)会触发多巴胺释放,加强相关记忆。co-engram 借用这个概念驱动『候选审批』—— 系统观察到的、超出阈值的新模式会被提名为候选记忆,等用户确认后转为正式记忆。",
102
+ en: "The gap between actual and expected value. In the brain, positive RPE (better than expected) triggers dopamine release and strengthens associated memories. co-engram borrows this for proposal capture — observed patterns exceeding a threshold are nominated as candidate memories awaiting user approval.",
103
+ },
104
+ internalRule: {
105
+ zh: 'necessity-evaluator 通过 LLM 或规则评估『这条消息是否值得捕获』,必要度超阈值才进入 proposal 队列。',
106
+ en: 'The necessity-evaluator (LLM or rule-based) assesses "is this message worth capturing"; only those above the threshold enter the proposal queue.',
107
+ },
108
+ refs: ["engram", "importance"],
109
+ },
110
+ verification_status: {
111
+ id: "verification_status",
112
+ zh: "验证状态",
113
+ en: "verification status",
114
+ userExplanation: {
115
+ zh: "记忆可信度的 5 档状态:未验证 → 似合理 → 较可能 → 已验证 → 已反驳。状态随使用反馈(强化 / 失败 / 跨情境证据)演化。已反驳状态会阻止这条记忆再次被检索命中。",
116
+ en: "5-level memory credibility: unverified → plausible → probable → verified → refuted. Evolves with use feedback (reinforcement / failure / cross-context evidence). Refuted memories are excluded from retrieval.",
117
+ },
118
+ internalRule: {
119
+ zh: "升级条件(默认):似合理需 ≥1 evidence;较可能需 ≥2 evidence 且 ≥2 个不同 domainTags;已验证需 ≥3 evidence、≥2 domains 且创建满 7 天。降级由 LTD/失败驱动。",
120
+ en: "Default upgrade thresholds: plausible ≥1 evidence; probable ≥2 evidence AND ≥2 distinct domainTags; verified ≥3 evidence, ≥2 domains, AND 7 days since creation. Downgrade driven by LTD/failures.",
121
+ },
122
+ refs: ["observation_window", "provenance", "synapse"],
123
+ },
124
+ observation_window: {
125
+ id: "observation_window",
126
+ zh: "观察窗口",
127
+ en: "observation window",
128
+ userExplanation: {
129
+ zh: "记忆被检索命中后开启的一段观察期。窗口期内:用户若回来强化这条记忆 → 记为『有效检索』,触发 LTP;用户若反馈失败 → 记为『失败使用』,触发 LTD;窗口过期 → 关闭,本次命中不计入有效性。窗口长度按 kind 不同:观察类 6 小时、事实/模式/流程类 1-2 天、假设类 7 天。",
130
+ en: 'An observation period opened when a memory is retrieved. During the window: if the user returns to reinforce the memory → counted as "effective retrieval" (triggers LTP); if the user reports a failure → counted as "failed use" (triggers LTD); if the window expires → closed, this hit does not count. Length depends on kind: observation 6h, fact/pattern/procedure 1-2d, hypothesis 7d.',
131
+ },
132
+ internalRule: {
133
+ zh: "默认窗口长度:observation=6h,fact=24h,pattern=48h,procedure=48h,hypothesis=7d。多 kind engram 取最长。",
134
+ en: "Default window lengths: observation=6h, fact=24h, pattern=48h, procedure=48h, hypothesis=7d. Multi-kind engrams use the maximum.",
135
+ },
136
+ refs: ["ltp", "ltd", "kind"],
137
+ },
138
+ importance: {
139
+ id: "importance",
140
+ zh: "重要性",
141
+ en: "importance",
142
+ userExplanation: {
143
+ zh: "记忆的优先级分数,取值 [0,1]。检索结果按相关性 + 时效性 + 重要性三因子加权打分排序。重要性会随 LTP 上升、LTD 下降,所以常用且有效的记忆会自然浮上来。",
144
+ en: "Memory priority score in [0,1]. Retrieval results are ranked by a weighted three-factor score: relevance + recency + importance. Importance rises with LTP and falls with LTD, so frequently-effective memories naturally surface.",
145
+ },
146
+ internalRule: {
147
+ zh: "三因子权重(默认):relevance α=0.5,recency β=0.3,importance γ=0.2。effectiveImportance = importance × (1 + reinforcementScore),截断到 [0,1]。",
148
+ en: "Default three-factor weights: relevance α=0.5, recency β=0.3, importance γ=0.2. effectiveImportance = importance × (1 + reinforcementScore), clamped to [0,1].",
149
+ },
150
+ refs: ["ltp", "ltd", "decay"],
151
+ },
152
+ decay: {
153
+ id: "decay",
154
+ zh: "艾宾浩斯衰退",
155
+ en: "Ebbinghaus decay",
156
+ userExplanation: {
157
+ zh: "记忆随时间淡化。检索打分里 recency 因子按艾宾浩斯遗忘曲线衰退:每过一个半衰期,recency 减半。半衰期由 decayHalfLifeDays 配置(若为 null 表示永不衰退,如永久性事实)。",
158
+ en: 'Memories fade over time. The "recency" retrieval factor follows the Ebbinghaus forgetting curve: each half-life halves the recency. The half-life is set by decayHalfLifeDays (null = never decays, e.g. permanent facts).',
159
+ },
160
+ internalRule: {
161
+ zh: "recency = 0.5^(ageDays / decayHalfLifeDays)。ageDays ≤ 0 或 decayHalfLifeDays ≤ 0 时 recency = 1(不衰退)。",
162
+ en: "recency = 0.5^(ageDays / decayHalfLifeDays). When ageDays ≤ 0 or decayHalfLifeDays ≤ 0, recency = 1 (no decay).",
163
+ },
164
+ refs: ["importance"],
165
+ },
166
+ provenance: {
167
+ id: "provenance",
168
+ zh: "溯源",
169
+ en: "provenance",
170
+ userExplanation: {
171
+ zh: "每条记忆的来源信息:谁创建、何时创建、sourceType(firsthand / secondhand / inferred)。验收高可信结论前,应通过溯源信息判断原始证据是否可靠。",
172
+ en: "Each memory carries its origin: who created it, when, and sourceType (firsthand / secondhand / inferred). Before relying on a high-confidence conclusion, check provenance to judge if the underlying evidence is trustworthy.",
173
+ },
174
+ refs: ["engram", "verification_status"],
175
+ },
176
+ domain_tag: {
177
+ id: "domain_tag",
178
+ zh: "领域标签",
179
+ en: "domain tag",
180
+ userExplanation: {
181
+ zh: "记忆的主题分类(如 testing、android、backend)。用于检索过滤、跨情境证据聚合(verification 升级条件需要 ≥2 个不同 domainTags)、目录组织。一条记忆可有多个领域标签。",
182
+ en: "Memory topic (e.g. testing, android, backend). Used for retrieval filtering, cross-context evidence aggregation (verification upgrade requires ≥2 distinct domainTags), and directory layout. A memory can have multiple domain tags.",
183
+ },
184
+ refs: ["engram", "context_tag", "verification_status"],
185
+ },
186
+ context_tag: {
187
+ id: "context_tag",
188
+ zh: "情境标签",
189
+ en: "context tag",
190
+ userExplanation: {
191
+ zh: "比领域标签更细粒度的使用情境(如 session-id、子项目名)。用于跨情境证据聚合 —— 同样的结论在不同情境被独立验证,可信度才更高。",
192
+ en: "Finer-grained use context than domain tags (e.g. session-id, sub-project). Used for cross-context evidence aggregation — the same conclusion independently verified across different contexts yields higher credibility.",
193
+ },
194
+ refs: ["domain_tag", "verification_status"],
195
+ },
196
+ kind: {
197
+ id: "kind",
198
+ zh: "类别",
199
+ en: "kind",
200
+ userExplanation: {
201
+ zh: "记忆的 5 种基础类别:观察(单次所见)、事实(多次验证)、模式(跨情境抽象)、流程(陈述性步骤)、假设(AI 推断、待验证)。类别决定观察窗口长度、检索权重等行为。",
202
+ en: "5 base kinds: observation (single sighting), fact (verified multiple times), pattern (cross-context abstraction), procedure (declarative steps), hypothesis (AI-inferred, to be verified). The kind drives observation-window length, retrieval weights, and other behaviors.",
203
+ },
204
+ internalRule: {
205
+ zh: "observation 窗口 6h;fact 24h;pattern/procedure 48h;hypothesis 7d。多 kind 取 max。",
206
+ en: "observation window 6h; fact 24h; pattern/procedure 48h; hypothesis 7d. Multi-kind uses max.",
207
+ },
208
+ refs: ["engram", "observation_window", "domain_tag"],
209
+ },
210
+ };
211
+ /**
212
+ * 取概念条目(便于从 id 安全访问)
213
+ *
214
+ * 直接 `CONCEPT_DICTIONARY[id]` 也行;此函数主要给宿主代码显式标注返回类型。
215
+ */
216
+ export function getConcept(id) {
217
+ return CONCEPT_DICTIONARY[id];
218
+ }
219
+ /**
220
+ * 把 [0,1] 浮点分数格式化为人类可读的『高/中/低(数值)』
221
+ *
222
+ * 用于所有用户可见的数值字段(importance / reinforcementScore / lastRetrievalScore /
223
+ * FTS score / effectiveness),防止浮点精度泄露(如 0.018000000000000002、
224
+ * 0.7719155626908514 直接 dump 给用户)。
225
+ *
226
+ * 阈值:≥0.7 高;≥0.3 中;<0.3 低。2 位小数保留可读精度。
227
+ *
228
+ * JSON-RPC 协议层(raw)与文本呈现层(band+display)并存,见 Task 1.3。
229
+ */
230
+ export function formatScore(score, lang) {
231
+ const band = score >= 0.7 ? "high" : score >= 0.3 ? "medium" : "low";
232
+ const labels = {
233
+ zh: { high: "高", medium: "中", low: "低" },
234
+ en: { high: "high", medium: "medium", low: "low" },
235
+ };
236
+ return `${labels[lang][band]}(${score.toFixed(2)})`;
237
+ }
238
+ /**
239
+ * 把裸浮点封装为 ScoreField
240
+ *
241
+ * 同时做两件事:
242
+ * 1. round 到 2 位小数,杀掉浮点噪声(0.018000000000000002 → 0.02)
243
+ * 2. 计算 band(high/medium/low),供 host adapter 渲染
244
+ *
245
+ * 单独抽出是因为多个工具(engram_get / engram_reinforce / engram_recompute_importance /
246
+ * engram_search)都要做同样的处理,集中一处避免漂移。
247
+ */
248
+ export function formatScoreField(raw) {
249
+ const rounded = Math.round(raw * 100) / 100;
250
+ const band = rounded >= 0.7 ? "high" : rounded >= 0.3 ? "medium" : "low";
251
+ return { raw: rounded, band };
252
+ }
253
+ //# sourceMappingURL=dictionary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../../src/concepts/dictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM,EAAE;QACN,E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AAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * 概念字典 —— co-engram 神经科学概念的单一真相源
3
+ *
4
+ * 详见 {@link dictionary.ts} 的 docstring。
5
+ *
6
+ * @module @co-engram/core/concepts
7
+ */
8
+ export * from "./types.js";
9
+ export { CONCEPT_DICTIONARY, getConcept, formatScore, formatScoreField, } from "./dictionary.js";
10
+ export type { ScoreField } from "./dictionary.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/concepts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 概念字典 —— co-engram 神经科学概念的单一真相源
3
+ *
4
+ * 详见 {@link dictionary.ts} 的 docstring。
5
+ *
6
+ * @module @co-engram/core/concepts
7
+ */
8
+ export * from "./types.js";
9
+ export { CONCEPT_DICTIONARY, getConcept, formatScore, formatScoreField, } from "./dictionary.js";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/concepts/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,WAAW,EACX,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * 概念字典类型定义
3
+ *
4
+ * co-engram 引入大量神经科学概念(engram / synapse / LTP / LTD / Hebbian / RPE /
5
+ * verification state machine / observation window / multi-dim importance 等)。
6
+ * 元3「神经科学墙」的核心症状是:这些概念对挑剔用户完全不可见,规则藏在源码里。
7
+ *
8
+ * CONCEPT_DICTIONARY 是这些概念的单一真相源,所有面向用户的 surface
9
+ * (viewer help tab / mcp instructions / prompt-builder / 工具描述)都必须引用它,
10
+ * 不允许在别处重新定义。
11
+ *
12
+ * @module @co-engram/core/concepts
13
+ */
14
+ /**
15
+ * 概念 ID(全部小写下划线,稳定标识)
16
+ *
17
+ * 添加新概念时:
18
+ * 1. 在此 union 加 id
19
+ * 2. 在 dictionary.ts 填 ConceptEntry(必填 zh / en / userExplanation)
20
+ * 3. 若有内部规则,补 internalRule(人类可读描述,引用真实默认值)
21
+ * 4. 通过 `satisfies Readonly<Record<ConceptId, ConceptEntry>>` 让编译器强制全覆盖
22
+ */
23
+ export type ConceptId = "engram" | "synapse" | "ltp" | "ltd" | "hebbian" | "rpe" | "verification_status" | "observation_window" | "importance" | "decay" | "provenance" | "domain_tag" | "context_tag" | "kind";
24
+ /**
25
+ * 概念字典条目
26
+ *
27
+ * 设计原则:
28
+ * - zh / en 是内部术语(可保留专业用词,允许"LTP"、"Hebbian"等缩写)
29
+ * - userExplanation 是面向挑剔用户的解释(避免术语堆砌,讲清楚是什么、为什么有用)
30
+ * - internalRule 引用真实源码默认值(不写"约 0.02",写"0.02"),便于用户验证
31
+ * - refs 把相关概念串起来,viewer help tab 可据此渲染图
32
+ */
33
+ export interface ConceptEntry {
34
+ /** 稳定 id(等于 CONCEPT_DICTIONARY 里的 key) */
35
+ readonly id: ConceptId;
36
+ /** 内部中文术语(可保留专业缩写) */
37
+ readonly zh: string;
38
+ /** 内部英文术语 */
39
+ readonly en: string;
40
+ /** 用户层解释 */
41
+ readonly userExplanation: {
42
+ /** 中文用户解释(挑剔用户能懂,不堆砌术语) */
43
+ readonly zh: string;
44
+ /** 英文用户解释 */
45
+ readonly en: string;
46
+ };
47
+ /** 内部规则(引用真实默认值,如"每次 effective 检索 importance += 0.02") */
48
+ readonly internalRule?: {
49
+ /** 中文规则描述 */
50
+ readonly zh: string;
51
+ /** 英文规则描述 */
52
+ readonly en: string;
53
+ };
54
+ /** 相关概念 id 列表(用于 viewer help 渲染关系图) */
55
+ readonly refs?: readonly ConceptId[];
56
+ }
57
+ /**
58
+ * 重要性 / 强化分数的可读分级
59
+ *
60
+ * 用于把 [0,1] 区间的浮点(importance / reinforcementScore / lastRetrievalScore /
61
+ * FTS score)映射为"高/中/低"用户可读形式,防止浮点精度泄露
62
+ * (如 0.018000000000000002 直接 dump 给用户)。
63
+ */
64
+ export type ScoreBand = "high" | "medium" | "low";
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/concepts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,SAAS,GACT,KAAK,GACL,KAAK,GACL,SAAS,GACT,KAAK,GACL,qBAAqB,GACrB,oBAAoB,GACpB,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,MAAM,CAAC;AAEX;;;;;;;;GAQG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,YAAY;IACZ,QAAQ,CAAC,eAAe,EAAE;QACxB,2BAA2B;QAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,aAAa;QACb,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,CAAC,EAAE;QACtB,aAAa;QACb,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,aAAa;QACb,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,uCAAuC;IACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC"}