memleaf 0.2.86__tar.gz → 0.2.87__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 (183) hide show
  1. {memleaf-0.2.86 → memleaf-0.2.87}/CHANGELOG.md +33 -0
  2. {memleaf-0.2.86/src/memleaf.egg-info → memleaf-0.2.87}/PKG-INFO +6 -6
  3. {memleaf-0.2.86 → memleaf-0.2.87}/README.en.md +4 -4
  4. {memleaf-0.2.86 → memleaf-0.2.87}/README.md +5 -5
  5. {memleaf-0.2.86 → memleaf-0.2.87}/examples/incremental_acceptance.json +9 -10
  6. {memleaf-0.2.86 → memleaf-0.2.87}/pyproject.toml +1 -1
  7. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/__init__.py +1 -1
  8. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/acceptance.py +1 -1
  9. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/compaction.py +1 -1
  10. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/extraction_budget.py +3 -0
  11. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/extraction_work_state.py +2 -2
  12. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/README.md +7 -0
  13. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/_provider.py +3 -3
  14. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/plugin.yaml +1 -1
  15. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/host_retention.py +17 -1
  16. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_commit.py +31 -4
  17. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_execution.py +51 -27
  18. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_failed_recovery.py +3 -1
  19. memleaf-0.2.87/src/memleaf/incremental_merge.py +70 -0
  20. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_partial.py +2 -1
  21. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_prompts.py +9 -6
  22. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_protocol.py +24 -5
  23. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_recovery.py +2 -0
  24. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_run_state.py +53 -4
  25. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_semantics.py +57 -15
  26. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/mcp_server.py +39 -18
  27. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/memory_writer.py +15 -0
  28. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/process_common.py +0 -1
  29. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/processing_route.py +19 -2
  30. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/prompts.py +1 -1
  31. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/semantic_maintenance.py +1 -1
  32. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/service.py +1 -2
  33. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/single_pass_plan.py +1 -1
  34. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/source_policy.py +7 -0
  35. {memleaf-0.2.86 → memleaf-0.2.87/src/memleaf.egg-info}/PKG-INFO +6 -6
  36. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf.egg-info/SOURCES.txt +1 -0
  37. {memleaf-0.2.86 → memleaf-0.2.87}/LICENSE +0 -0
  38. {memleaf-0.2.86 → memleaf-0.2.87}/MANIFEST.in +0 -0
  39. {memleaf-0.2.86 → memleaf-0.2.87}/docs/acceptance-evidence-guide.md +0 -0
  40. {memleaf-0.2.86 → memleaf-0.2.87}/docs/automatic-processing-route.md +0 -0
  41. {memleaf-0.2.86 → memleaf-0.2.87}/docs/body-compaction.md +0 -0
  42. {memleaf-0.2.86 → memleaf-0.2.87}/docs/candidate-reconciliation.md +0 -0
  43. {memleaf-0.2.86 → memleaf-0.2.87}/docs/capture-budget-design.md +0 -0
  44. {memleaf-0.2.86 → memleaf-0.2.87}/docs/config-migrations.md +0 -0
  45. {memleaf-0.2.86 → memleaf-0.2.87}/docs/core-refactor.md +0 -0
  46. {memleaf-0.2.86 → memleaf-0.2.87}/docs/development-closeout.md +0 -0
  47. {memleaf-0.2.86 → memleaf-0.2.87}/docs/evidence-retention.md +0 -0
  48. {memleaf-0.2.86 → memleaf-0.2.87}/docs/explicit-memory-update.md +0 -0
  49. {memleaf-0.2.86 → memleaf-0.2.87}/docs/extraction-latency.md +0 -0
  50. {memleaf-0.2.86 → memleaf-0.2.87}/docs/failed-run-recovery.md +0 -0
  51. {memleaf-0.2.86 → memleaf-0.2.87}/docs/gate-evidence-boundary.md +0 -0
  52. {memleaf-0.2.86 → memleaf-0.2.87}/docs/general-processing.md +0 -0
  53. {memleaf-0.2.86 → memleaf-0.2.87}/docs/hermes-mcp-runtime.md +0 -0
  54. {memleaf-0.2.86 → memleaf-0.2.87}/docs/hermes-provider-compatibility.md +0 -0
  55. {memleaf-0.2.86 → memleaf-0.2.87}/docs/hermes-source-comparison-context.md +0 -0
  56. {memleaf-0.2.86 → memleaf-0.2.87}/docs/host-acceptance-runbook.md +0 -0
  57. {memleaf-0.2.86 → memleaf-0.2.87}/docs/immutable-release-assets.md +0 -0
  58. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-commit-contract.md +0 -0
  59. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-execution.md +0 -0
  60. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-native-comparison.md +0 -0
  61. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-partial-recovery.md +0 -0
  62. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-planner-preview.md +0 -0
  63. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-runtime-contract.md +0 -0
  64. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-scope-registration.md +0 -0
  65. {memleaf-0.2.86 → memleaf-0.2.87}/docs/incremental-selected-retention.md +0 -0
  66. {memleaf-0.2.86 → memleaf-0.2.87}/docs/installed-artifact-verification.md +0 -0
  67. {memleaf-0.2.86 → memleaf-0.2.87}/docs/memory-lifecycle-tools.md +0 -0
  68. {memleaf-0.2.86 → memleaf-0.2.87}/docs/memory-state-contract.md +0 -0
  69. {memleaf-0.2.86 → memleaf-0.2.87}/docs/migration-preflight.md +0 -0
  70. {memleaf-0.2.86 → memleaf-0.2.87}/docs/processing-quality-acceptance.md +0 -0
  71. {memleaf-0.2.86 → memleaf-0.2.87}/docs/public-query-integrity.md +0 -0
  72. {memleaf-0.2.86 → memleaf-0.2.87}/docs/query-performance.md +0 -0
  73. {memleaf-0.2.86 → memleaf-0.2.87}/docs/remember-incremental-route.md +0 -0
  74. {memleaf-0.2.86 → memleaf-0.2.87}/docs/runtime-state-retention.md +0 -0
  75. {memleaf-0.2.86 → memleaf-0.2.87}/docs/semantic-extraction-protocol.md +0 -0
  76. {memleaf-0.2.86 → memleaf-0.2.87}/docs/source-work-contract.md +0 -0
  77. {memleaf-0.2.86 → memleaf-0.2.87}/docs/v0.2.26-processing-status.md +0 -0
  78. {memleaf-0.2.86 → memleaf-0.2.87}/examples/README.md +0 -0
  79. {memleaf-0.2.86 → memleaf-0.2.87}/examples/basic_usage.py +0 -0
  80. {memleaf-0.2.86 → memleaf-0.2.87}/examples/mcp_stdio.ndjson +0 -0
  81. {memleaf-0.2.86 → memleaf-0.2.87}/examples/query_benchmark.py +0 -0
  82. {memleaf-0.2.86 → memleaf-0.2.87}/install.ps1 +0 -0
  83. {memleaf-0.2.86 → memleaf-0.2.87}/install.sh +0 -0
  84. {memleaf-0.2.86 → memleaf-0.2.87}/setup.cfg +0 -0
  85. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/__main__.py +0 -0
  86. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/adapters/__init__.py +0 -0
  87. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/adapters/antigravity.py +0 -0
  88. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/adapters/base.py +0 -0
  89. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/adapters/codex.py +0 -0
  90. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/adapters/hermes.py +0 -0
  91. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/admission.py +0 -0
  92. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/batch_review.py +0 -0
  93. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/budget.py +0 -0
  94. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/capture.py +0 -0
  95. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/cli.py +0 -0
  96. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/config.py +0 -0
  97. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/create_coordinator.py +0 -0
  98. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/credentials.py +0 -0
  99. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/evidence_budget.py +0 -0
  100. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/evidence_policy.py +0 -0
  101. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/evidence_structure.py +0 -0
  102. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/evidence_syntax.py +0 -0
  103. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/explicit_text_source.py +0 -0
  104. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/extraction_capability.py +0 -0
  105. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/frontmatter.py +0 -0
  106. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/__init__.py +0 -0
  107. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/_mcp_client.py +0 -0
  108. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/_shared.py +0 -0
  109. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/evidence_budget.py +0 -0
  110. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_provider/provider_compatibility.py +0 -0
  111. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/hermes_runtime.py +0 -0
  112. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/host_events.py +0 -0
  113. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/host_runtime.py +0 -0
  114. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/host_turn_identity.py +0 -0
  115. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/inbox.py +0 -0
  116. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_dates.py +0 -0
  117. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_explicit.py +0 -0
  118. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_journal.py +0 -0
  119. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_native.py +0 -0
  120. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_preview.py +0 -0
  121. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_runtime.py +0 -0
  122. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_scopes.py +0 -0
  123. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/incremental_selection.py +0 -0
  124. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/index.py +0 -0
  125. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/inspection.py +0 -0
  126. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/installer.py +0 -0
  127. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/legacy_update_journal.py +0 -0
  128. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/__init__.py +0 -0
  129. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/base.py +0 -0
  130. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/claude_compatible.py +0 -0
  131. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/gemini.py +0 -0
  132. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/openai_compatible.py +0 -0
  133. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/router.py +0 -0
  134. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/llm/thinking.py +0 -0
  135. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/locking.py +0 -0
  136. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/memory_commit.py +0 -0
  137. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/memory_planner.py +0 -0
  138. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/memory_retraction.py +0 -0
  139. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/memory_update.py +0 -0
  140. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/migration.py +0 -0
  141. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/model_capabilities.py +0 -0
  142. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/model_discovery.py +0 -0
  143. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/model_execution.py +0 -0
  144. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/models.py +0 -0
  145. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/native_index.py +0 -0
  146. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/native_registration.py +0 -0
  147. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/parallel_model.py +0 -0
  148. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/planning_candidates.py +0 -0
  149. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/planning_context.py +0 -0
  150. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/process_jobs.py +0 -0
  151. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/process_journal.py +0 -0
  152. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/process_owner.py +0 -0
  153. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/processing.py +0 -0
  154. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/provenance.py +0 -0
  155. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/provider_compatibility.py +0 -0
  156. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/query_clock.py +0 -0
  157. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/query_progress.py +0 -0
  158. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/query_scan.py +0 -0
  159. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/receipt_codec.py +0 -0
  160. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/recording_policy.py +0 -0
  161. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/redaction.py +0 -0
  162. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/remember_route.py +0 -0
  163. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/retention.py +0 -0
  164. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/retrieval.py +0 -0
  165. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/retrieval_gate.py +0 -0
  166. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/runtime_retention.py +0 -0
  167. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/scope_maintenance.py +0 -0
  168. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/scope_state.py +0 -0
  169. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/semantic_protocol.py +0 -0
  170. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/single_pass_memory_planner.py +0 -0
  171. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/state_layout.py +0 -0
  172. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/subprocess_flags.py +0 -0
  173. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/summary_batch.py +0 -0
  174. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/target_reconciliation.py +0 -0
  175. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/turn_audit.py +0 -0
  176. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/turn_plan.py +0 -0
  177. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/update_coordinator.py +0 -0
  178. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/update_review.py +0 -0
  179. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/validation.py +0 -0
  180. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf/vault.py +0 -0
  181. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf.egg-info/dependency_links.txt +0 -0
  182. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf.egg-info/entry_points.txt +0 -0
  183. {memleaf-0.2.86 → memleaf-0.2.87}/src/memleaf.egg-info/top_level.txt +0 -0
@@ -4,6 +4,39 @@ All notable changes to memleaf are documented here.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.2.87 — 2026-10-04
8
+
9
+ ### Shared source-bound maintenance with bounded model cost
10
+
11
+ - Allow up to five actual requests per incremental work item, stopping on
12
+ success. Extraction, format retries, review and recovery share the durable
13
+ allowance; older work retains its smaller creation-time limit.
14
+ - Bind conversational lifecycle updates to the captured host turn. MCP
15
+ `update_memory` no longer accepts model-supplied source times or directly
16
+ commits rewritten facts when host-bound. Preserve the trusted Python API.
17
+ - Retire `waiting_on` from extraction and model/read/list projections; maintain
18
+ dependencies in the current body. Legacy stored data remains readable.
19
+ - Merge confirmed duplicate memories through the existing processing requests.
20
+ Preserve combined facts, provenance and history; reject incompatible targets.
21
+ Commit the survivor before retracting duplicates, with dependency revisions
22
+ checked at the final writer boundary and recoverable frozen operations.
23
+ - Maintain shared facts across related project and task records using the
24
+ existing source-bound review. Independent lifecycles remain separate.
25
+ - Retract withdrawn facts/preferences through validity, retaining their history;
26
+ explicit replacement preferences remain valid. Task cancellation is not a
27
+ substitute for preference withdrawal.
28
+ - Reuse successful, verified full-turn host retention to settle automatic work
29
+ without another model request. Partial selected retention does not claim
30
+ complete automatic coverage. Record actual API token usage without extra
31
+ requests or counting cached replay usage again.
32
+ - Count known provenance overlaps once; mark counts for truncated histories as
33
+ upper bounds when their unseen overlap cannot be reconstructed.
34
+ - Validation: 483 affected regression and installation/acceptance checks passed;
35
+ nine isolated real DeepSeek scenarios and the installed Hermes background
36
+ callback with current source passed. Saved faulty time arguments were rejected
37
+ in an isolated zero-call replay. No production memory migration or historical
38
+ failed-run retry was performed.
39
+
7
40
  ## 0.2.86 — 2026-10-04
8
41
 
9
42
  ### Source-bound Hermes retention and general extraction compatibility
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memleaf
3
- Version: 0.2.86
3
+ Version: 0.2.87
4
4
  Summary: A local-first Markdown memory core for AI agents
5
5
  Author: memleaf contributors
6
6
  License-Expression: MIT
@@ -23,10 +23,10 @@ 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.86。**
26
+ > **版本:0.2.87。**
27
27
  > 自动提炼和复核共用同一条“未来记忆价值”标准:模型综合未来复用、信息增量、再次读取时的直接可用性和忘记成本,只保留对未来理解、判断或行动有实质影响的最小核心;没有明确价值的信息不提炼,不按具体业务场景硬编码排除。
28
- > 提炼先比较旧事项中的编号、目标、进展、责任和期限;补全未知信息也应维护原事项,另建独立待办不能替代项目事实更新。Core 不按标题强行合并。
29
- > 新请求兼容等价的字段表示;未知执行人保持 `null`,新增或变更负责人、等待方和期限需要真实来源。行动及相关字段经过有界语义复核,提炼与复核共用每份工作的最多两次模型请求额度;复核失败不写入。来源时间用于解析相对日期,不补造事实日期。
28
+ > 提炼先比较旧事项中的编号、目标、进展、责任和期限;补全未知信息也应维护原事项,另建独立待办不能替代项目事实更新。确认重复的记忆在现有处理请求中合并,保留历史与来源;项目和独立任务保持各自生命周期,Core 不按标题强行合并。
29
+ > 新请求兼容等价的字段表示;未知执行人保持 `null`,新增或变更负责人和期限需要真实来源;等待条件在正文维护,不再提炼 `waiting_on`。行动及相关字段经过有界语义复核,提炼与复核共用每份工作的最多五次模型请求额度,成功即停止;复核失败不写入。来源时间用于解析相对日期,不补造事实日期。
30
30
  > 待办 `due_date` 只表示待办动作本身明确声明的截止日;属于待办主题或预期结果的日期不会被误作截止日。项目归属由模型按语义判断,不要求项目名在证据里逐字出现。复核阶段会保留首轮已选定的更新目标,避免“状态变更”被降级成新增记忆。Markdown 仍是唯一事实源。
31
31
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
32
32
 
@@ -285,7 +285,7 @@ python -m memleaf.mcp_server --vault "$HOME/.memleaf"
285
285
  | `process_status` | 只读查询异步处理 job 状态 |
286
286
  | `recover_failed_run` | 预览并显式恢复终态传输失败,保留原请求预算 |
287
287
  | `remember` | 用户明确要求时创建或更新记忆 |
288
- | `update_memory` | 携带当前 revision 办结、取消或重新激活任务,保留正文与历史 |
288
+ | `update_memory` | 携带当前 revision 维护任务或撤回事实/偏好;宿主绑定的调用排队处理真实消息 |
289
289
  | `forget_memory` | 用户明确要求遗忘时,携带 `confirm_delete=true` 按精确 ID 永久删除 |
290
290
  | `forget_about` | 携带 `confirm_delete=true` 遗忘明确主题;有歧义时只返回候选 |
291
291
  | `rebuild_index` | 重建可重建的本地派生索引 |
@@ -361,7 +361,7 @@ python -m memleaf.mcp_server --vault /path/to/your/vault \
361
361
 
362
362
  捕获、索引、目录检索和读取可离线运行;`process()`、`remember()` 和 `compact()` 需要可用的模型能力。
363
363
 
364
- 包含行动或责任、期限变更的增量候选通常会追加一次语义复核;每份增量工作最多两次请求,格式修复也计入同一额度。
364
+ 包含行动或责任、期限变更的增量候选通常会追加一次语义复核;每份增量工作最多五次请求,格式修复与恢复也计入同一持久化额度,成功即停止。
365
365
 
366
366
  `llm.mode` 支持:
367
367
 
@@ -4,10 +4,10 @@
4
4
 
5
5
  [中文](README.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
6
6
 
7
- > **Version: 0.2.86.**
7
+ > **Version: 0.2.87.**
8
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
- > Extraction compares existing identifiers, objectives, progress, responsibility and deadlines first. Filling an unknown also maintains the original item; a separate task does not replace updating shared project facts. Core does not merge matching titles.
10
- > New requests accept equivalent field representations. Unknown executors remain `null`; new or changed responsibility, dependencies and deadlines require actual source evidence. Proposed actions and related fields undergo bounded semantic verification within the existing two-request limit per work item; failed verification blocks writes. Source time resolves relative dates without inventing factual dates.
9
+ > Extraction compares existing identifiers, objectives, progress, responsibility and deadlines first. Filling an unknown also maintains the original item; a separate task does not replace updating shared project facts. Confirmed duplicates can be merged in the existing processing requests with their sources and history preserved. Independent project and task lifecycles remain separate; Core does not merge matching titles.
10
+ > New requests accept equivalent field representations. Unknown executors remain `null`; new or changed responsibility and deadlines require actual source evidence. Dependencies belong in the body; `waiting_on` is no longer extracted. Proposed actions and related fields undergo bounded semantic verification within a shared five-request limit per work item, stopping on success; failed verification blocks writes. Source time resolves relative dates without inventing factual dates.
11
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.
12
12
  > **The current release supports Hermes and Codex.** Antigravity is not detected, installed, or configured.
13
13
 
@@ -266,7 +266,7 @@ The server exposes the following tools:
266
266
  | `process_status` | Read the status of a background processing job |
267
267
  | `recover_failed_run` | Preview and explicitly recover terminal transport failures within the original request budget |
268
268
  | `remember` | Create or update memory after an explicit request |
269
- | `update_memory` | Complete, cancel or reopen a task using its current revision; retain body and history |
269
+ | `update_memory` | Maintain tasks or retract facts/preferences using their current revision; host-bound calls queue actual source messages |
270
270
  | `forget_memory` | Permanently delete an exact ID after explicit user forgetting, with `confirm_delete=true` |
271
271
  | `forget_about` | Forget an unambiguous topic with `confirm_delete=true`; return candidates when ambiguous |
272
272
  | `rebuild_index` | Rebuild local derived indexes |
@@ -4,10 +4,10 @@
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.86。**
7
+ > **版本:0.2.87。**
8
8
  > 自动提炼和复核共用同一条“未来记忆价值”标准:模型综合未来复用、信息增量、再次读取时的直接可用性和忘记成本,只保留对未来理解、判断或行动有实质影响的最小核心;没有明确价值的信息不提炼,不按具体业务场景硬编码排除。
9
- > 提炼先比较旧事项中的编号、目标、进展、责任和期限;补全未知信息也应维护原事项,另建独立待办不能替代项目事实更新。Core 不按标题强行合并。
10
- > 新请求兼容等价的字段表示;未知执行人保持 `null`,新增或变更负责人、等待方和期限需要真实来源。行动及相关字段经过有界语义复核,提炼与复核共用每份工作的最多两次模型请求额度;复核失败不写入。来源时间用于解析相对日期,不补造事实日期。
9
+ > 提炼先比较旧事项中的编号、目标、进展、责任和期限;补全未知信息也应维护原事项,另建独立待办不能替代项目事实更新。确认重复的记忆在现有处理请求中合并,保留历史与来源;项目和独立任务保持各自生命周期,Core 不按标题强行合并。
10
+ > 新请求兼容等价的字段表示;未知执行人保持 `null`,新增或变更负责人和期限需要真实来源;等待条件在正文维护,不再提炼 `waiting_on`。行动及相关字段经过有界语义复核,提炼与复核共用每份工作的最多五次模型请求额度,成功即停止;复核失败不写入。来源时间用于解析相对日期,不补造事实日期。
11
11
  > 待办 `due_date` 只表示待办动作本身明确声明的截止日;属于待办主题或预期结果的日期不会被误作截止日。项目归属由模型按语义判断,不要求项目名在证据里逐字出现。复核阶段会保留首轮已选定的更新目标,避免“状态变更”被降级成新增记忆。Markdown 仍是唯一事实源。
12
12
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
13
13
 
@@ -266,7 +266,7 @@ python -m memleaf.mcp_server --vault "$HOME/.memleaf"
266
266
  | `process_status` | 只读查询异步处理 job 状态 |
267
267
  | `recover_failed_run` | 预览并显式恢复终态传输失败,保留原请求预算 |
268
268
  | `remember` | 用户明确要求时创建或更新记忆 |
269
- | `update_memory` | 携带当前 revision 办结、取消或重新激活任务,保留正文与历史 |
269
+ | `update_memory` | 携带当前 revision 维护任务或撤回事实/偏好;宿主绑定的调用排队处理真实消息 |
270
270
  | `forget_memory` | 用户明确要求遗忘时,携带 `confirm_delete=true` 按精确 ID 永久删除 |
271
271
  | `forget_about` | 携带 `confirm_delete=true` 遗忘明确主题;有歧义时只返回候选 |
272
272
  | `rebuild_index` | 重建可重建的本地派生索引 |
@@ -342,7 +342,7 @@ python -m memleaf.mcp_server --vault /path/to/your/vault \
342
342
 
343
343
  捕获、索引、目录检索和读取可离线运行;`process()`、`remember()` 和 `compact()` 需要可用的模型能力。
344
344
 
345
- 包含行动或责任、期限变更的增量候选通常会追加一次语义复核;每份增量工作最多两次请求,格式修复也计入同一额度。
345
+ 包含行动或责任、期限变更的增量候选通常会追加一次语义复核;每份增量工作最多五次请求,格式修复与恢复也计入同一持久化额度,成功即停止。
346
346
 
347
347
  `llm.mode` 支持:
348
348
 
@@ -31,7 +31,7 @@
31
31
  "expected": {
32
32
  "execution_status": "completed",
33
33
  "coverage_status": "complete",
34
- "max_calls": 1,
34
+ "max_calls": 2,
35
35
  "count": 1,
36
36
  "required": [
37
37
  {
@@ -215,14 +215,13 @@
215
215
  "expected": {
216
216
  "execution_status": "completed",
217
217
  "coverage_status": "complete",
218
- "max_calls": 1,
218
+ "max_calls": 2,
219
219
  "count": 1,
220
220
  "required": [
221
221
  {
222
222
  "memory_id": "mem-report",
223
223
  "status": "active",
224
224
  "assignee": "林工",
225
- "waiting_on": "客户验收",
226
225
  "due_date": "2026-09-25"
227
226
  }
228
227
  ]
@@ -330,7 +329,7 @@
330
329
  "expected": {
331
330
  "execution_status": "completed",
332
331
  "coverage_status": "complete",
333
- "max_calls": 1,
332
+ "max_calls": 2,
334
333
  "required": [
335
334
  {
336
335
  "memory_id": "mem-report",
@@ -421,7 +420,7 @@
421
420
  "expected": {
422
421
  "execution_status": "completed",
423
422
  "coverage_status": "complete",
424
- "max_calls": 1,
423
+ "max_calls": 2,
425
424
  "count": 2,
426
425
  "required": [
427
426
  {
@@ -471,7 +470,7 @@
471
470
  "expected": {
472
471
  "execution_status": "completed",
473
472
  "coverage_status": "complete",
474
- "max_calls": 1,
473
+ "max_calls": 2,
475
474
  "count": 1,
476
475
  "required": [
477
476
  {
@@ -524,7 +523,7 @@
524
523
  "expected": {
525
524
  "execution_status": "completed",
526
525
  "coverage_status": "complete",
527
- "max_calls": 1,
526
+ "max_calls": 2,
528
527
  "count": 1,
529
528
  "required": [
530
529
  {
@@ -564,7 +563,7 @@
564
563
  "expected": {
565
564
  "execution_status": "completed",
566
565
  "coverage_status": "complete",
567
- "max_calls": 1,
566
+ "max_calls": 2,
568
567
  "count": 1,
569
568
  "required": [
570
569
  {
@@ -665,7 +664,7 @@
665
664
  "expected": {
666
665
  "execution_status": "completed",
667
666
  "coverage_status": "complete",
668
- "max_calls": 1,
667
+ "max_calls": 2,
669
668
  "count": 2,
670
669
  "required": [
671
670
  {
@@ -732,7 +731,7 @@
732
731
  "expected": {
733
732
  "execution_status": "completed",
734
733
  "coverage_status": "complete",
735
- "max_calls": 1,
734
+ "max_calls": 2,
736
735
  "count": 1,
737
736
  "required": [
738
737
  {
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "memleaf"
7
- version = "0.2.86"
7
+ version = "0.2.87"
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.86"
3
+ __version__ = "0.2.87"
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
@@ -327,7 +327,7 @@ def _checks(expected: dict, records: list[dict], observations: list[dict], calls
327
327
  else: # forbidden
328
328
  good = all(not any(matches(r, forbidden) for r in records) for forbidden in value)
329
329
  results.append({"check": key, "passed": good})
330
- results.append({"check": "per_work_request_cap", "passed": result.get("reserved_requests", 0) <= 2})
330
+ results.append({"check": "per_work_request_cap", "passed": result.get("reserved_requests", 0) <= result["request_limit"]})
331
331
  return results
332
332
 
333
333
 
@@ -427,7 +427,7 @@ class Compactor:
427
427
  value = _content_mapping(candidate.memory)
428
428
  value["memory_id"] = candidate.memory.memory_id
429
429
  value["validity"] = candidate.memory.validity
430
- for key in ("assignee", "waiting_on", "due_text"):
430
+ for key in ("assignee", "due_text"):
431
431
  if key in candidate.memory.extra:
432
432
  value[key] = deepcopy(candidate.memory.extra[key])
433
433
  return value
@@ -14,6 +14,8 @@ from .llm import ModelError
14
14
 
15
15
 
16
16
  MAX_MODEL_REQUESTS = 3
17
+ # Incremental drafting, format repair and review share one durable allowance.
18
+ MAX_INCREMENTAL_REQUESTS = 5
17
19
  TARGET_TOTAL_SECONDS = 10.0
18
20
 
19
21
 
@@ -205,6 +207,7 @@ def budget_single_pass_backend(
205
207
 
206
208
  __all__ = [
207
209
  "MAX_MODEL_REQUESTS",
210
+ "MAX_INCREMENTAL_REQUESTS",
208
211
  "TARGET_TOTAL_SECONDS",
209
212
  "ExtractionTiming",
210
213
  "aggregate_extraction_metrics",
@@ -17,7 +17,7 @@ from pathlib import Path
17
17
  from typing import Any, Mapping
18
18
 
19
19
  from .locking import atomic_write_json, read_json
20
- from .extraction_budget import MAX_MODEL_REQUESTS
20
+ from .extraction_budget import MAX_MODEL_REQUESTS, MAX_INCREMENTAL_REQUESTS
21
21
  from .validation import parse_strict_json
22
22
 
23
23
 
@@ -307,7 +307,7 @@ def reserve_model_request(
307
307
  raise ExtractionWorkStateError("invalid extraction work id")
308
308
  if not _valid_identifier(turn_id, maximum=800):
309
309
  raise ExtractionWorkStateError("invalid extraction turn id")
310
- if type(request_limit) is not int or not 1 <= request_limit <= MAX_MODEL_REQUESTS:
310
+ if type(request_limit) is not int or not 1 <= request_limit <= max(MAX_MODEL_REQUESTS, MAX_INCREMENTAL_REQUESTS):
311
311
  raise ExtractionWorkStateError("invalid extraction request limit")
312
312
  if type(legacy_source_unchanged) is not bool:
313
313
  raise ExtractionWorkStateError("invalid legacy source compatibility flag")
@@ -17,6 +17,13 @@ A queued response is not a saved memory. The installer excludes standalone MCP
17
17
  supports `remember` for other clients, plus `forget` and maintenance operations.
18
18
  This is a Soft Gate, not a guarantee that every answer has performed retrieval.
19
19
 
20
+ The bound native route also handles conversational corrections, completion,
21
+ cancellation, reopening and withdrawal. A successful full-turn retention receipt
22
+ settles automatic extraction without another model request. Partial selections
23
+ remain separate. MCP lifecycle updates do not accept model-supplied source times;
24
+ trusted Python callers keep their explicit metadata API. Restart Hermes after
25
+ upgrading to load the current Provider.
26
+
20
27
  Hermes discovers this directory when it is installed as:
21
28
 
22
29
  ```text
@@ -1403,7 +1403,7 @@ class MemleafMemoryProvider(MemoryProvider):
1403
1403
  "file writes to simulate success, and do not infer automatic success merely because "
1404
1404
  "active or history files exist. Automatic recall is a directory of "
1405
1405
  "scope identifiers, hierarchy, and aliases only; it never contains "
1406
- "memory IDs, titles, or bodies. For explicit retention use memleaf_remember with the current retrieval_id; it retains verified user messages after the complete turn is captured. Pending means not yet saved. Do not submit assistant-written facts through legacy MCP remember. "
1406
+ "memory IDs, titles, or bodies. For explicit retention or corrections, task completion/cancellation/reopening, and withdrawing a fact/preference, use memleaf_remember with the current retrieval_id. It processes the actual complete turn and preserves audit history. Do not perform a conversational lifecycle edit through an unbound MCP update or infer message time from a deadline. Pending means not yet saved. Do not submit assistant-written facts through legacy MCP remember. "
1407
1407
  "Use deliberate remember/forget tools "
1408
1408
  "only when the user explicitly asks for that operation. Automatic "
1409
1409
  "capture and processing use only visible user and assistant text; "
@@ -2060,7 +2060,7 @@ class MemleafMemoryProvider(MemoryProvider):
2060
2060
  if not tool_name.startswith(prefix):
2061
2061
  return None
2062
2062
  name = tool_name[len(prefix):]
2063
- if name not in {"search", "read", "list_todos", "scope_catalog", "remember"}:
2063
+ if name not in {"search", "read", "list_todos", "scope_catalog", "remember", "update_memory"}:
2064
2064
  return None
2065
2065
  turn_id = _host_turn_id(turn_context)
2066
2066
  session = turn_context.get("session_id") if isinstance(turn_context, Mapping) else None
@@ -2102,7 +2102,7 @@ class MemleafMemoryProvider(MemoryProvider):
2102
2102
  # gated by the initialized host identity and write policy.
2103
2103
  if not self._write_enabled:
2104
2104
  return []
2105
- return [{"name": "memleaf_remember", "description": "Use only for an explicit user request to remember. Bind the actual complete user turn; never submit rewritten facts or scopes. Returns pending until the turn is captured and processed.",
2105
+ return [{"name": "memleaf_remember", "description": "Use for an explicit user request to remember or maintain existing memory: corrections, task completion/cancellation/reopening, or withdrawal of a fact/preference. Bind the actual complete user turn; never submit rewritten facts, dates or scopes. Returns pending until the turn is captured and processed.",
2106
2106
  "parameters": {"type": "object", "properties": {"retrieval_id": {"type": "string"}},
2107
2107
  "required": ["retrieval_id"], "additionalProperties": False}}]
2108
2108
 
@@ -1,5 +1,5 @@
1
1
  name: memleaf
2
- version: 0.2.86
2
+ version: 0.2.87
3
3
  description: "Hermes-native external MemoryProvider for local-first Markdown memory shared with the memleaf MCP server."
4
4
  hooks:
5
5
  - prefetch
@@ -138,7 +138,10 @@ def remember_turn(service, *, phase, retrieval_id=None, source=None, session_id=
138
138
  turn, _ = _window(service, source, session_id, turn_key(turn_id))
139
139
  users = [event for event in turn.events if event.role == "user"]
140
140
  request = "\n\n".join(event.content for event in users)
141
- refs = [event.event_key for event in users]
141
+ # One host completion evaluates the entire captured turn. The actual
142
+ # user request still bounds explicit retention; the assistant remains
143
+ # a visible source, never authority for new user obligations.
144
+ refs = [event.event_key for event in turn.events]
142
145
  selection, request = bind_selection(intent, refs, request)
143
146
  run = load_run(processed, explicit_run_id(source, session_id, selection))
144
147
  if run is not None and run["status"] in {"completed", "completed_with_unresolved", "blocked", "failed", "cancelled"}:
@@ -165,3 +168,16 @@ def complete_for_captured_turn(service, turn, *, model=None, router=None):
165
168
  _, row = bound
166
169
  return remember_turn(service, phase="complete", source=turn.source, session_id=turn.session_id,
167
170
  turn_id=row["turn_id"], model=model, router=router)
171
+
172
+
173
+ def covers_complete_turn(service, turn, result):
174
+ """Only a verified immutable full-source commit may replace automatic work."""
175
+ from .incremental_journal import load_work
176
+ from .turn_plan import input_digest
177
+ with service.vault.lock():
178
+ processed = _read_processed(service.vault.processed_state_path)
179
+ work = load_work(processed, result.get('commit_work_id', ''))
180
+ if (work is None or not work.get('host_retention_origin') or not work['receipt_settled']
181
+ or work['source_digest'] != input_digest(turn)):
182
+ return False
183
+ return {e['event_key'] for e in work['evidence'] if e['use'] == 'new'} == set(turn.event_keys)
@@ -105,7 +105,7 @@ def _freeze_operation(proposal: dict[str, Any], snapshot: Any, now: str, active:
105
105
  else:
106
106
  value.update(memory_id=before.memory_id, created=before.created, updated=now)
107
107
  after = Memory.from_mapping(value)
108
- if before is not None and dedup_digest(before.to_dict()) == dedup_digest(after.to_dict()):
108
+ if before is not None and not op.get("merge_from") and dedup_digest(before.to_dict()) == dedup_digest(after.to_dict()):
109
109
  op.update(action="NO_CHANGE", expected_revision=revision_digest(before))
110
110
  return op
111
111
  if before is None:
@@ -118,8 +118,14 @@ def _freeze_operation(proposal: dict[str, Any], snapshot: Any, now: str, active:
118
118
  return op
119
119
  from .incremental_dates import source_basis
120
120
  provenance = [source_basis(e) for e in state["evidence"] if e["ref"] in op["evidence"]]
121
- after.sources, source_meta = merge_sources(before.sources if before else [], provenance,
122
- extra=before.extra if before else {})
121
+ old_sources, old_meta = (before.sources, before.extra) if before else ([], {})
122
+ if op.get("merge_from"):
123
+ from .source_policy import merge_memory_provenance
124
+ peers = [Memory.from_mapping(t["memory"]) for t in state["targets"].values()
125
+ if t["memory"]["memory_id"] in op["merge_from"]]
126
+ old_sources, old_meta = merge_memory_provenance([before, *peers])
127
+ op["merge_revisions"] = {m.memory_id: revision_digest(m) for m in peers}
128
+ after.sources, source_meta = merge_sources(old_sources, provenance, extra=old_meta)
123
129
  after.extra.update(source_meta)
124
130
  after.extra["incremental_operation_id"] = op["operation_id"]
125
131
  if any(t["memory"]["memory_id"] == op["memory_id"] and t.get("basis_status") == "external_change_detected"
@@ -162,8 +168,17 @@ def _source_valid(service, processed, work):
162
168
 
163
169
 
164
170
  def _settle_source(service, processed, work, *, source_valid):
171
+ whole_host_turn = False
172
+ if source_valid and work.get("host_retention_origin") is not None:
173
+ # A scoped selection alone cannot prove whole-turn coverage. Only a
174
+ # verified host intent, evaluated against every current source event,
175
+ # may settle the automatic route as well.
176
+ turn, _ = _window(service, work["source"], work["session_id"], work["turn_key"])
177
+ selected = work.get("binding", {}).get("arguments", {}).get("selection", {})
178
+ whole_host_turn = (set(selected.get("source_refs", [])) == set(turn.event_keys)
179
+ == {e["event_key"] for e in work["evidence"] if e["use"] == "new"})
165
180
  if (work.get("request_kind", "automatic") == "explicit_remember"
166
- and not any(e.get("explicit_input") for e in work["evidence"])):
181
+ and not whole_host_turn and not any(e.get("explicit_input") for e in work["evidence"])):
167
182
  # This authorization only selected some material. Its own work receipt
168
183
  # settles it; it never consumes the automatic turn or changes cleanup.
169
184
  return
@@ -232,6 +247,18 @@ def _resume_unlocked(service, processed, work):
232
247
  if not guard_matches(current_guard, work["scope_guard"], applied_additions(work)):
233
248
  raise ValueError("scope_registry_changed")
234
249
  if op["action"] in {"CREATE", "UPDATE"}:
250
+ if op.get("merged_into"):
251
+ survivor = next((item for item in work["operations"]
252
+ if item.get("memory_id") == op["merged_into"]), None)
253
+ current, _ = service._revision_target_unlocked(op["merged_into"])
254
+ if (survivor is None or survivor["state"] not in {"applied", "settled"}
255
+ or current is None or revision_digest(current.memory) != survivor.get("replacement_revision")):
256
+ raise ValueError("merge_survivor_not_committed")
257
+ op["merge_revisions"] = {op["merged_into"]: survivor["replacement_revision"]}
258
+ for identity, expected in op.get("merge_revisions", {}).items():
259
+ current, _ = service._revision_target_unlocked(identity)
260
+ if current is None or revision_digest(current.memory) != expected:
261
+ raise ValueError("merge_target_changed")
235
262
  # Pin the configuration already authorized above through
236
263
  # the shared writer's history/head boundary as well.
237
264
  guarded_op = {**op, "scope_guard": current_guard} if work.get("scope_guard") is not None else op