memleaf 0.2.62__tar.gz → 0.2.63__tar.gz

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. {memleaf-0.2.62 → memleaf-0.2.63}/CHANGELOG.md +7 -0
  2. {memleaf-0.2.62/src/memleaf.egg-info → memleaf-0.2.63}/PKG-INFO +4 -3
  3. {memleaf-0.2.62 → memleaf-0.2.63}/README.en.md +3 -2
  4. {memleaf-0.2.62 → memleaf-0.2.63}/README.md +3 -2
  5. {memleaf-0.2.62 → memleaf-0.2.63}/docs/semantic-extraction-protocol.md +2 -4
  6. {memleaf-0.2.62 → memleaf-0.2.63}/pyproject.toml +1 -1
  7. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/__init__.py +1 -1
  8. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/plugin.yaml +1 -1
  9. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/semantic_maintenance.py +2 -2
  10. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/semantic_protocol.py +7 -8
  11. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/single_pass_plan.py +2 -2
  12. {memleaf-0.2.62 → memleaf-0.2.63/src/memleaf.egg-info}/PKG-INFO +4 -3
  13. {memleaf-0.2.62 → memleaf-0.2.63}/LICENSE +0 -0
  14. {memleaf-0.2.62 → memleaf-0.2.63}/MANIFEST.in +0 -0
  15. {memleaf-0.2.62 → memleaf-0.2.63}/docs/capture-budget-design.md +0 -0
  16. {memleaf-0.2.62 → memleaf-0.2.63}/docs/config-migrations.md +0 -0
  17. {memleaf-0.2.62 → memleaf-0.2.63}/docs/core-refactor.md +0 -0
  18. {memleaf-0.2.62 → memleaf-0.2.63}/docs/evidence-retention.md +0 -0
  19. {memleaf-0.2.62 → memleaf-0.2.63}/docs/extraction-latency.md +0 -0
  20. {memleaf-0.2.62 → memleaf-0.2.63}/docs/gate-evidence-boundary.md +0 -0
  21. {memleaf-0.2.62 → memleaf-0.2.63}/docs/general-processing.md +0 -0
  22. {memleaf-0.2.62 → memleaf-0.2.63}/docs/hermes-mcp-runtime.md +0 -0
  23. {memleaf-0.2.62 → memleaf-0.2.63}/docs/processing-quality-acceptance.md +0 -0
  24. {memleaf-0.2.62 → memleaf-0.2.63}/docs/v0.2.26-processing-status.md +0 -0
  25. {memleaf-0.2.62 → memleaf-0.2.63}/examples/README.md +0 -0
  26. {memleaf-0.2.62 → memleaf-0.2.63}/examples/basic_usage.py +0 -0
  27. {memleaf-0.2.62 → memleaf-0.2.63}/examples/mcp_stdio.ndjson +0 -0
  28. {memleaf-0.2.62 → memleaf-0.2.63}/install.ps1 +0 -0
  29. {memleaf-0.2.62 → memleaf-0.2.63}/install.sh +0 -0
  30. {memleaf-0.2.62 → memleaf-0.2.63}/setup.cfg +0 -0
  31. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/__main__.py +0 -0
  32. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/adapters/__init__.py +0 -0
  33. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/adapters/antigravity.py +0 -0
  34. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/adapters/base.py +0 -0
  35. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/adapters/codex.py +0 -0
  36. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/adapters/hermes.py +0 -0
  37. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/admission.py +0 -0
  38. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/batch_review.py +0 -0
  39. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/budget.py +0 -0
  40. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/capture.py +0 -0
  41. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/cli.py +0 -0
  42. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/compaction.py +0 -0
  43. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/config.py +0 -0
  44. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/create_coordinator.py +0 -0
  45. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/credentials.py +0 -0
  46. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/evidence_budget.py +0 -0
  47. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/evidence_policy.py +0 -0
  48. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/evidence_structure.py +0 -0
  49. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/evidence_syntax.py +0 -0
  50. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/extraction_budget.py +0 -0
  51. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/extraction_capability.py +0 -0
  52. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/extraction_work_state.py +0 -0
  53. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/frontmatter.py +0 -0
  54. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/README.md +0 -0
  55. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/__init__.py +0 -0
  56. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/_mcp_client.py +0 -0
  57. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/_provider.py +0 -0
  58. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/_shared.py +0 -0
  59. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_provider/evidence_budget.py +0 -0
  60. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/hermes_runtime.py +0 -0
  61. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/host_events.py +0 -0
  62. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/host_runtime.py +0 -0
  63. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/inbox.py +0 -0
  64. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/index.py +0 -0
  65. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/inspection.py +0 -0
  66. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/installer.py +0 -0
  67. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/__init__.py +0 -0
  68. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/base.py +0 -0
  69. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/claude_compatible.py +0 -0
  70. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/gemini.py +0 -0
  71. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/openai_compatible.py +0 -0
  72. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/router.py +0 -0
  73. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/llm/thinking.py +0 -0
  74. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/locking.py +0 -0
  75. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/mcp_server.py +0 -0
  76. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/memory_commit.py +0 -0
  77. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/memory_planner.py +0 -0
  78. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/memory_writer.py +0 -0
  79. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/model_capabilities.py +0 -0
  80. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/model_discovery.py +0 -0
  81. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/model_execution.py +0 -0
  82. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/models.py +0 -0
  83. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/native_index.py +0 -0
  84. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/native_registration.py +0 -0
  85. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/parallel_model.py +0 -0
  86. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/planning_context.py +0 -0
  87. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/process_common.py +0 -0
  88. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/process_jobs.py +0 -0
  89. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/process_journal.py +0 -0
  90. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/process_owner.py +0 -0
  91. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/processing.py +0 -0
  92. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/prompts.py +0 -0
  93. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/provenance.py +0 -0
  94. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/recording_policy.py +0 -0
  95. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/redaction.py +0 -0
  96. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/retention.py +0 -0
  97. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/retrieval.py +0 -0
  98. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/retrieval_gate.py +0 -0
  99. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/scope_maintenance.py +0 -0
  100. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/scope_state.py +0 -0
  101. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/service.py +0 -0
  102. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/single_pass_memory_planner.py +0 -0
  103. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/source_policy.py +0 -0
  104. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/state_layout.py +0 -0
  105. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/subprocess_flags.py +0 -0
  106. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/summary_batch.py +0 -0
  107. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/target_reconciliation.py +0 -0
  108. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/turn_audit.py +0 -0
  109. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/turn_plan.py +0 -0
  110. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/update_coordinator.py +0 -0
  111. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/update_review.py +0 -0
  112. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/validation.py +0 -0
  113. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf/vault.py +0 -0
  114. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf.egg-info/SOURCES.txt +0 -0
  115. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf.egg-info/dependency_links.txt +0 -0
  116. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf.egg-info/entry_points.txt +0 -0
  117. {memleaf-0.2.62 → memleaf-0.2.63}/src/memleaf.egg-info/top_level.txt +0 -0
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to memleaf are documented here.
4
4
 
5
+ ## 0.2.63 — 2026-09-16
6
+
7
+ - Unify the retention decision across first-pass extraction, topic selection, candidate repair and `semantic_maintenance`. The model now judges future reuse, information gain, direct usability and forgetting cost, keeping only the smallest core with clear material value; the contract contains no mail, report, customer or project-specific exclusion rule.
8
+ - Keep maintenance complementary to extraction: it applies the same value judgment to incoming candidates, continues maintaining candidates that qualify, discards those without clear value and defers only unresolved meaning. The `0.2.62` date/ownership degradation and update-target grouping remain intact.
9
+
10
+ Verification covers prompt consistency and compactness assertions, Python 3.11 compilation/imports, package metadata consistency, a package wheel containing the Hermes provider resource, and `git diff --check`. Real-provider replay remains runtime acceptance after installation.
11
+
5
12
  ## 0.2.62 — 2026-09-16
6
13
 
7
14
  - Record conclusions, not process. The contract now opens with one precedence rule -- 只记结论: what the user chose, agreed to, or what happened; options, plans and drafts offered by the assistant are process even when they look like reusable knowledge. It replaces a genuine conflict between two earlier sentences: `reusable`/通用经验 invited storing the assistant's own outline, while the assistant-proposal clause forbade it, so the model decided by coin flip. The contradictory sentence about assistant suggestions never being a task basis is gone with it. Measured on the reproduced turn, the assistant's four-section outline was written in one of two runs before the change and in none of four runs after it.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memleaf
3
- Version: 0.2.62
3
+ Version: 0.2.63
4
4
  Summary: A local-first Markdown memory core for AI agents
5
5
  Author: memleaf contributors
6
6
  License-Expression: MIT
@@ -23,8 +23,9 @@ Dynamic: license-file
23
23
 
24
24
  [English](README.en.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
25
25
 
26
- > **版本:0.2.62。**
27
- > 自动提炼只记结论:用户选定的、答应的、已发生的事;助手给出的选项、方案和草稿属于过程,即使它们看起来像可复用的经验也不写成记忆。同一件事只写一次,避免同一条内容同时落成事实和待办。提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),B3 仅作为兼容读取格式保留。
26
+ > **版本:0.2.63。**
27
+ > 自动提炼和复核共用同一条“未来记忆价值”标准:模型综合未来复用、信息增量、再次读取时的直接可用性和忘记成本,只保留对未来理解、判断或行动有实质影响的最小核心;没有明确价值的信息不提炼,不按具体业务场景硬编码排除。
28
+ > 提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),首轮、主题选择、候选修复和 `semantic_maintenance` 使用同一套保留价值判断;同一件事只写一次。
28
29
  > Core 不再因为归属、日期、任务依据或跨项目而丢弃整条候选:归属缺失会归一到证据里唯一被点名的项目、否则落 `global`;日期只接受能在本候选证据里找到出处、且能锚定成 ISO 的写法(`明天`、`周五`、`月底` 都会被解析),无法解析时只丢掉日期字段,记忆照常写入;未获授权的改归属沿用目标原归属。
29
30
  > 待办 `due_date` 只表示待办动作本身明确声明的截止日;属于待办主题或预期结果的日期不会被误作截止日。项目归属由模型按语义判断,不要求项目名在证据里逐字出现。复核阶段会保留首轮已选定的更新目标,避免“状态变更”被降级成新增记忆。Markdown 仍是唯一事实源。
30
31
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
@@ -4,8 +4,9 @@
4
4
 
5
5
  [中文](README.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
6
6
 
7
- > **Version: 0.2.62.**
8
- > Automatic extraction now records conclusions only: what the user chose, agreed to, or what happened. Options, plans and drafts offered by the assistant are process, even when they look like reusable knowledge. One topic is written once, so the same content no longer lands as both a fact and a todo. A single Chinese semantic contract is now sent; the older English B3 prompt has been deleted and B3 remains only as a compatibility read format.
7
+ > **Version: 0.2.63.**
8
+ > Automatic extraction and review share one future-value standard: the model weighs likely reuse, information gain, direct usability when read again, and the cost of forgetting. It keeps only the smallest core that can materially help future understanding, decisions, or actions; information without clear value is not extracted, and no business-specific exclusion rule is hard-coded.
9
+ > A single Chinese semantic contract is sent for extraction, topic selection, candidate repair, and `semantic_maintenance`; the older English B3 prompt has been deleted and B3 remains only as a compatibility read format. One topic is written once.
9
10
  > Core no longer discards a whole candidate over ownership, dates, task basis or cross-project wording. A missing owner normalizes to the single project named by that candidate's own evidence, otherwise `global`. A deadline is accepted only when it appears in the candidate's own evidence and can be anchored to ISO (`明天`, `周五`, `月底` all resolve); when it cannot, only the date field is dropped and the memory is still written. An unauthorized ownership change keeps the target's existing scope.
10
11
  > A todo's `due_date` means only the explicit deadline of the todo action; dates describing its subject or desired outcome are not deadlines. Project ownership remains the model's semantic judgement and needs no literal name match. The review stage now keeps the update target chosen by the first pass, so a state change is no longer downgraded into a new memory. Markdown remains the sole source of truth.
11
12
  > **The current release supports Hermes and Codex.** Antigravity is not detected, installed, or configured.
@@ -4,8 +4,9 @@
4
4
 
5
5
  [English](README.en.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
6
6
 
7
- > **版本:0.2.62。**
8
- > 自动提炼只记结论:用户选定的、答应的、已发生的事;助手给出的选项、方案和草稿属于过程,即使它们看起来像可复用的经验也不写成记忆。同一件事只写一次,避免同一条内容同时落成事实和待办。提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),B3 仅作为兼容读取格式保留。
7
+ > **版本:0.2.63。**
8
+ > 自动提炼和复核共用同一条“未来记忆价值”标准:模型综合未来复用、信息增量、再次读取时的直接可用性和忘记成本,只保留对未来理解、判断或行动有实质影响的最小核心;没有明确价值的信息不提炼,不按具体业务场景硬编码排除。
9
+ > 提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),首轮、主题选择、候选修复和 `semantic_maintenance` 使用同一套保留价值判断;同一件事只写一次。
9
10
  > Core 不再因为归属、日期、任务依据或跨项目而丢弃整条候选:归属缺失会归一到证据里唯一被点名的项目、否则落 `global`;日期只接受能在本候选证据里找到出处、且能锚定成 ISO 的写法(`明天`、`周五`、`月底` 都会被解析),无法解析时只丢掉日期字段,记忆照常写入;未获授权的改归属沿用目标原归属。
10
11
  > 待办 `due_date` 只表示待办动作本身明确声明的截止日;属于待办主题或预期结果的日期不会被误作截止日。项目归属由模型按语义判断,不要求项目名在证据里逐字出现。复核阶段会保留首轮已选定的更新目标,避免“状态变更”被降级成新增记忆。Markdown 仍是唯一事实源。
11
12
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
@@ -13,11 +13,9 @@
13
13
 
14
14
  ## 提炼判据
15
15
 
16
- 契约只说我们要什么,不列禁止项:
16
+ 契约引导模型先判断信息是否有长期记忆价值,而不按具体业务场景列禁止项:综合未来复用、信息增量、再次读取时的直接可用性和忘记成本。只有对未来理解、判断或行动可能产生实质影响的信息才保留;没有明确价值就列入 `no_memory`,并只写产生该价值的最小核心。同一件事只写一次。
17
17
 
18
- - **只记结论**:用户选定的、答应的、已发生的事。助手给出的选项、方案、草稿属于过程——即使它看起来像可复用的通用经验,也仍然是过程。来源优先于"像不像经验"。
19
- - **同一件事只写一次**:同一条内容不会同时落成事实和待办。
20
- - `retention` 与类型独立:`reusable` 表示今后仍需使用的业务状态、约定或可复用结论;`session` 表示仅说明本轮如何查询、执行和恢复的过程,Core 会把它转成 `no_memory`。
18
+ 首轮提炼、主题选择、候选修复和 `semantic_maintenance` 共用这条判断标准。`retention` 与类型独立:`reusable` 表示符合上述标准,`session` 表示不符合,Core 会把 `session` 转成 `no_memory`。维护阶段将符合标准的 incoming 继续维护,不符合的丢弃,语义无法确定的延后;它负责维护已有候选,不重新发明主题。
21
19
 
22
20
  ## 降级而不是丢弃
23
21
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "memleaf"
7
- version = "0.2.62"
7
+ version = "0.2.63"
8
8
  description = "A local-first Markdown memory core for AI agents"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -1,6 +1,6 @@
1
1
  """Local-first Markdown memory core for AI agents."""
2
2
 
3
- __version__ = "0.2.62"
3
+ __version__ = "0.2.63"
4
4
 
5
5
  from .config import DEFAULT_CONFIG, default_config, load_config, save_config
6
6
  from .frontmatter import FrontmatterError, dump_frontmatter, dump_yaml, load_yaml, parse_frontmatter
@@ -1,5 +1,5 @@
1
1
  name: memleaf
2
- version: 0.2.62
2
+ version: 0.2.63
3
3
  description: "Hermes-native external MemoryProvider for local-first Markdown memory shared with the memleaf MCP server."
4
4
  hooks:
5
5
  - prefetch
@@ -2,10 +2,10 @@
2
2
  from __future__ import annotations
3
3
  import json
4
4
  from typing import Any, Mapping
5
- from .semantic_protocol import expand_fragments, _invalid
5
+ from .semantic_protocol import RETENTION_GUIDANCE, expand_fragments, _invalid
6
6
  from .validation import parse_strict_json
7
7
 
8
- MAINTENANCE_SYSTEM = '''维护长期记忆,而不是再次摘录对话。groups 按项目和类型隔离,incoming 是本轮增量,existing 是可更新的 catalog ID。
8
+ MAINTENANCE_SYSTEM = RETENTION_GUIDANCE + "\n" + '''维护长期记忆,而不是再次摘录对话。按上述标准复核 incoming:符合标准的继续维护,没有明确价值的放 discard,无法判断的放 deferred。groups 按项目和类型隔离,incoming 是本轮增量,existing 是可更新的 catalog ID。
9
9
  同一事项的需求、进展、回复、附件位置和约定日期合并维护;后续状态替换旧状态,重复信息不新建。不同的独立事项保持分开。正文概括核心,不逐条转录文档或保存助手的临时建议。类型由输入确定,本阶段只维护同类型的状态。
10
10
  返回 JSON {"memories":[{"from":[incoming ID],"target":"已有memory_id或null","title":"主题","body":"合并后的当前内容","type":"fact或todo等"}],"discard":[incoming ID],"deferred":[incoming ID]}。
11
11
  每条仅合并同组 incoming;同一事项已有记忆时 target 必须选该组 existing 中的ID,保留其有效内容并更新变化;独立新事项 target=null。已有target保留原type;新任务没有同事项todo目标时新建todo,不借用fact ID。同一target只输出一次。无需修改的已有记忆可原样返回。todo 提供 status(active/completed/cancelled)和 due_date(原文日期,无则null);不能把任务变成一般事实而丢失动作。每个 incoming 由 from、discard 或 deferred 覆盖。无需处理原始片段ID、复制证据或生成记忆ID。'''
@@ -107,16 +107,15 @@ def source_fragments(b3_prompt: str) -> dict[str, Any]:
107
107
  'scope_context': data['scope_background'], 'scope_registry': data['scope_registry']}
108
108
 
109
109
 
110
- RETENTION_GUIDANCE = """retention 独立于 fact/todo 类型:reusable 表示今后仍需使用的业务状态、约定、稳定环境或可复用结论;session 表示仅说明本轮如何查询、执行和恢复的过程及瞬时结果。一次操作成功或失败不自动建立稳定结论;若已明确形成持续问题、后续任务或通用经验,保留其成立的核心含义。session 由 Core 转为 no_memory,不写入长期记忆。"""
110
+ RETENTION_GUIDANCE = """先判断这段信息是否有长期记忆价值:综合未来复用概率、信息增量、再次读取时是否可直接使用和忘记成本。只有对未来理解、判断或行动可能产生实质影响的信息才保留;没有明确价值就放 no_memory。只保留产生该价值的最小核心。"""
111
111
 
112
112
 
113
- FRAGMENT_SYSTEM = f'''只记结论:用户选定的、答应的、已发生的事。助手给的选项、方案、草稿是过程,哪怕它看起来像通用经验,也仍然是过程。
114
- 根据底层长期有效的业务含义提炼记忆,不继承原文的标题、紧急程度、列表分类或建议处理方式。
113
+ FRAGMENT_SYSTEM = f'''根据对话语义判断每段信息是否值得形成长期记忆,不继承原文的标题、紧急程度、列表分类或建议处理方式。
115
114
  {RETENTION_GUIDANCE}
116
115
  返回 JSON:{{"memories":[],"no_memory":[],"deferred":[]}}。
117
- 每条 memory:{{"retention":"reusable 或 session","title":"简短主题","body":"脱离本轮对话仍有价值的核心内容","scope":"project:主体名 或 global","evidence":[片段ID]}}。type 默认 fact,表示业务事实或状态;可选类型 preference、project、todo、event、identity、other,event 仅用于事件本身而非其携带的业务事实。一条一个独立主题与归属,同一件事只写一次。scope 写这条事实归属的那个主体的名字,形如 project:鑫元基金——客户、项目、系统、产品都算,证据里出现了谁就写谁;只有整条确实没有主体时才写 global。同一段的独立主题分别提炼。
116
+ 每条 memory:{{"retention":"reusable 或 session","title":"简短主题","body":"脱离本轮对话仍有价值的核心内容","scope":"project:主体名 或 global","evidence":[片段ID]}}。type 默认 fact,表示业务事实或状态;可选类型 preference、project、todo、event、identity、other,event 仅用于事件本身而非其携带的业务事实。一条一个独立主题与归属,同一件事只写一次。scope 表示事实所属主体,按语义判断,不要求名称与证据逐字一致;项目、客户、系统、产品等主体均可作为归属,没有明确主体才写 global。同一段的独立主题分别提炼。
118
117
  新 todo 额外提供 task_basis:[用户角色片段ID],其内容须明确建立用户自己承担的未完成动作。todo 提供 status(active/completed/cancelled)及 due_date(该任务约定日期,无则 null),completed_at 可选。日期保留原文写法,由 Core 解析相对日期。
119
- no_memory 填仅服务本轮交互、没有后续使用价值的片段ID;deferred 填语义尚无法确定的片段ID。每个片段须被 memory 引用或列入其中一个数组。同片段允许支持多条 memory。若为 catalog 中同一事项的补充、状态变化或重复,target 填已有真实 ID 并给出合并后的当前内容;新事项才省略 target。无需输出写入决策、生成ID或复制原文。'''
118
+ no_memory 填不符合上述长期记忆价值标准的片段ID;deferred 填语义尚无法确定的片段ID。每个片段须被 memory 引用或列入其中一个数组。同片段允许支持多条 memory。若为 catalog 中同一事项的补充、状态变化或重复,target 填已有真实 ID 并给出合并后的当前内容;新事项才省略 target。无需输出写入决策、生成ID或复制原文。'''
120
119
 
121
120
 
122
121
  def expand_fragments(raw: str, fragments: list[dict[str, Any]]) -> str:
@@ -227,11 +226,11 @@ def _independent_project_subjects(text: str, scope_registry: Mapping[str, Any] |
227
226
 
228
227
 
229
228
 
230
- TOPIC_SYSTEM = RETENTION_GUIDANCE + "\n" + '''根据底层长期有效的业务含义识别值得保留的独立主题,不继承原文标题、紧急程度、列表分类或建议处理方式。
229
+ TOPIC_SYSTEM = RETENTION_GUIDANCE + "\n" + '''根据对话语义识别值得保留的独立主题,不继承原文标题、紧急程度、列表分类或建议处理方式。
231
230
  这一阶段只选择有后续价值的主题及其证据,不写记忆正文,不分类,不处理日期,不决定数据库操作。
232
231
  返回 JSON {"topics":[{"retention":"reusable 或 session","scope":"project:项目名 或 global","evidence":[片段ID]}],"no_memory":[片段ID],"deferred":[片段ID]}。
233
- 每个独立主题单独列出,scope 表示主题真正所属的项目,系统/工具名不自动成为归属。其他合法 scope:domain:名称、portfolio:名称、unscoped。
234
- no_memory 表示仅服务本轮交互的操作过程或瞬时信息,没有长期业务含义;deferred 表示语义无法确定。覆盖所有片段,每个被一个或多个主题引用或列入一个数组。'''
232
+ 每个独立主题单独列出,scope 表示主题真正所属的主体,按语义判断,不要求名称与证据逐字一致;没有明确主体才写 global。其他合法 scope:domain:名称、portfolio:名称、unscoped。
233
+ no_memory 表示不符合上述长期记忆价值标准;deferred 表示语义无法确定。覆盖所有片段,每个被一个或多个主题引用或列入一个数组。'''
235
234
 
236
235
 
237
236
  def compile_topics(raw: str, fragments: list[dict[str, Any]], protocol_version: str, *, contexts=None):
@@ -1496,7 +1496,7 @@ def run_single_pass_stage(
1496
1496
  if row.get("detail") == "scope_drift" else "A field contains an unsupported date or task attribution; retain supported core facts."}
1497
1497
  for row in deferrals if row.get("candidate_id") in failed_ids]}
1498
1498
  repair_prompt = "MEMORY_REPAIR\n" + json.dumps(payload, ensure_ascii=False, separators=(",", ":"))
1499
- repair_system = FRAGMENT_SYSTEM + "\nCore 已拒绝这些候选。请根据证据保留核心事实,纠正违规日期或归属;不要丢弃已成立的核心内容。"
1499
+ repair_system = FRAGMENT_SYSTEM + "\nCore 已拒绝这些候选。请按上述长期记忆价值标准复核,保留符合标准的最小核心,纠正违规日期或归属;不要凭空增加内容。"
1500
1500
  if inline_system:
1501
1501
  repair_prompt, repair_system = repair_system + "\n\n" + repair_prompt, ""
1502
1502
  repair_details, repair_targets = [], []
@@ -1691,7 +1691,7 @@ def run_single_pass_stage(
1691
1691
  if any(c["unit_id"] == f["unit_id"] for c in row["evidence"])]}
1692
1692
  for row in affected if problems[row["candidate_id"]]["detail"] not in {"semantic_review", "maintenance_uncertain"}
1693
1693
  ]
1694
- review_system = FRAGMENT_SYSTEM + "\n请按完整证据独立提炼;主题清单和 no_memory_candidates 均是待复核的候选。修正 issues,保留成立的核心事实。"
1694
+ review_system = FRAGMENT_SYSTEM + "\n请按完整证据独立复核每条信息是否符合上述长期记忆价值标准;主题清单和 no_memory_candidates 均只是待复核候选。修正 issues,只提炼符合标准的最小核心,其余放入 no_memory。"
1695
1695
  maintenance_context = None
1696
1696
  if "memories" in value:
1697
1697
  from .semantic_maintenance import maintenance_input, MAINTENANCE_SYSTEM
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memleaf
3
- Version: 0.2.62
3
+ Version: 0.2.63
4
4
  Summary: A local-first Markdown memory core for AI agents
5
5
  Author: memleaf contributors
6
6
  License-Expression: MIT
@@ -23,8 +23,9 @@ Dynamic: license-file
23
23
 
24
24
  [English](README.en.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
25
25
 
26
- > **版本:0.2.62。**
27
- > 自动提炼只记结论:用户选定的、答应的、已发生的事;助手给出的选项、方案和草稿属于过程,即使它们看起来像可复用的经验也不写成记忆。同一件事只写一次,避免同一条内容同时落成事实和待办。提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),B3 仅作为兼容读取格式保留。
26
+ > **版本:0.2.63。**
27
+ > 自动提炼和复核共用同一条“未来记忆价值”标准:模型综合未来复用、信息增量、再次读取时的直接可用性和忘记成本,只保留对未来理解、判断或行动有实质影响的最小核心;没有明确价值的信息不提炼,不按具体业务场景硬编码排除。
28
+ > 提炼契约现在只有一份中文语义契约(旧版英文 B3 提示词已删除),首轮、主题选择、候选修复和 `semantic_maintenance` 使用同一套保留价值判断;同一件事只写一次。
28
29
  > Core 不再因为归属、日期、任务依据或跨项目而丢弃整条候选:归属缺失会归一到证据里唯一被点名的项目、否则落 `global`;日期只接受能在本候选证据里找到出处、且能锚定成 ISO 的写法(`明天`、`周五`、`月底` 都会被解析),无法解析时只丢掉日期字段,记忆照常写入;未获授权的改归属沿用目标原归属。
29
30
  > 待办 `due_date` 只表示待办动作本身明确声明的截止日;属于待办主题或预期结果的日期不会被误作截止日。项目归属由模型按语义判断,不要求项目名在证据里逐字出现。复核阶段会保留首轮已选定的更新目标,避免“状态变更”被降级成新增记忆。Markdown 仍是唯一事实源。
30
31
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes