memleaf 0.2.51__tar.gz → 0.2.53__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 (114) hide show
  1. {memleaf-0.2.51 → memleaf-0.2.53}/CHANGELOG.md +15 -0
  2. {memleaf-0.2.51/src/memleaf.egg-info → memleaf-0.2.53}/PKG-INFO +2 -2
  3. {memleaf-0.2.51 → memleaf-0.2.53}/README.en.md +1 -1
  4. {memleaf-0.2.51 → memleaf-0.2.53}/README.md +1 -1
  5. {memleaf-0.2.51 → memleaf-0.2.53}/pyproject.toml +1 -1
  6. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/__init__.py +1 -1
  7. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/plugin.yaml +1 -1
  8. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/model_execution.py +9 -0
  9. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/planning_context.py +22 -2
  10. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/single_pass_memory_planner.py +37 -4
  11. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/single_pass_plan.py +2 -1
  12. {memleaf-0.2.51 → memleaf-0.2.53/src/memleaf.egg-info}/PKG-INFO +2 -2
  13. {memleaf-0.2.51 → memleaf-0.2.53}/LICENSE +0 -0
  14. {memleaf-0.2.51 → memleaf-0.2.53}/MANIFEST.in +0 -0
  15. {memleaf-0.2.51 → memleaf-0.2.53}/docs/capture-budget-design.md +0 -0
  16. {memleaf-0.2.51 → memleaf-0.2.53}/docs/config-migrations.md +0 -0
  17. {memleaf-0.2.51 → memleaf-0.2.53}/docs/core-refactor.md +0 -0
  18. {memleaf-0.2.51 → memleaf-0.2.53}/docs/evidence-retention.md +0 -0
  19. {memleaf-0.2.51 → memleaf-0.2.53}/docs/extraction-latency.md +0 -0
  20. {memleaf-0.2.51 → memleaf-0.2.53}/docs/gate-evidence-boundary.md +0 -0
  21. {memleaf-0.2.51 → memleaf-0.2.53}/docs/general-processing.md +0 -0
  22. {memleaf-0.2.51 → memleaf-0.2.53}/docs/hermes-mcp-runtime.md +0 -0
  23. {memleaf-0.2.51 → memleaf-0.2.53}/docs/processing-quality-acceptance.md +0 -0
  24. {memleaf-0.2.51 → memleaf-0.2.53}/docs/v0.2.26-processing-status.md +0 -0
  25. {memleaf-0.2.51 → memleaf-0.2.53}/examples/README.md +0 -0
  26. {memleaf-0.2.51 → memleaf-0.2.53}/examples/basic_usage.py +0 -0
  27. {memleaf-0.2.51 → memleaf-0.2.53}/examples/mcp_stdio.ndjson +0 -0
  28. {memleaf-0.2.51 → memleaf-0.2.53}/install.ps1 +0 -0
  29. {memleaf-0.2.51 → memleaf-0.2.53}/install.sh +0 -0
  30. {memleaf-0.2.51 → memleaf-0.2.53}/setup.cfg +0 -0
  31. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/__main__.py +0 -0
  32. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/adapters/__init__.py +0 -0
  33. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/adapters/antigravity.py +0 -0
  34. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/adapters/base.py +0 -0
  35. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/adapters/codex.py +0 -0
  36. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/adapters/hermes.py +0 -0
  37. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/admission.py +0 -0
  38. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/batch_review.py +0 -0
  39. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/budget.py +0 -0
  40. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/capture.py +0 -0
  41. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/cli.py +0 -0
  42. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/compaction.py +0 -0
  43. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/config.py +0 -0
  44. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/create_coordinator.py +0 -0
  45. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/credentials.py +0 -0
  46. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/evidence_budget.py +0 -0
  47. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/evidence_policy.py +0 -0
  48. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/evidence_structure.py +0 -0
  49. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/evidence_syntax.py +0 -0
  50. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/extraction_budget.py +0 -0
  51. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/extraction_capability.py +0 -0
  52. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/extraction_work_state.py +0 -0
  53. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/frontmatter.py +0 -0
  54. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/README.md +0 -0
  55. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/__init__.py +0 -0
  56. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/_mcp_client.py +0 -0
  57. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/_provider.py +0 -0
  58. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/_shared.py +0 -0
  59. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_provider/evidence_budget.py +0 -0
  60. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/hermes_runtime.py +0 -0
  61. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/host_events.py +0 -0
  62. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/host_runtime.py +0 -0
  63. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/inbox.py +0 -0
  64. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/index.py +0 -0
  65. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/inspection.py +0 -0
  66. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/installer.py +0 -0
  67. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/__init__.py +0 -0
  68. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/base.py +0 -0
  69. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/claude_compatible.py +0 -0
  70. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/gemini.py +0 -0
  71. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/openai_compatible.py +0 -0
  72. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/router.py +0 -0
  73. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/llm/thinking.py +0 -0
  74. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/locking.py +0 -0
  75. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/mcp_server.py +0 -0
  76. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/memory_commit.py +0 -0
  77. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/memory_planner.py +0 -0
  78. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/memory_writer.py +0 -0
  79. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/model_capabilities.py +0 -0
  80. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/model_discovery.py +0 -0
  81. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/models.py +0 -0
  82. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/native_index.py +0 -0
  83. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/native_registration.py +0 -0
  84. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/parallel_model.py +0 -0
  85. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/process_common.py +0 -0
  86. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/process_jobs.py +0 -0
  87. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/process_journal.py +0 -0
  88. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/process_owner.py +0 -0
  89. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/processing.py +0 -0
  90. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/prompts.py +0 -0
  91. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/provenance.py +0 -0
  92. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/recording_policy.py +0 -0
  93. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/redaction.py +0 -0
  94. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/retention.py +0 -0
  95. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/retrieval.py +0 -0
  96. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/retrieval_gate.py +0 -0
  97. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/scope_maintenance.py +0 -0
  98. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/scope_state.py +0 -0
  99. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/service.py +0 -0
  100. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/source_policy.py +0 -0
  101. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/state_layout.py +0 -0
  102. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/subprocess_flags.py +0 -0
  103. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/summary_batch.py +0 -0
  104. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/target_reconciliation.py +0 -0
  105. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/turn_audit.py +0 -0
  106. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/turn_plan.py +0 -0
  107. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/update_coordinator.py +0 -0
  108. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/update_review.py +0 -0
  109. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/validation.py +0 -0
  110. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf/vault.py +0 -0
  111. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf.egg-info/SOURCES.txt +0 -0
  112. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf.egg-info/dependency_links.txt +0 -0
  113. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf.egg-info/entry_points.txt +0 -0
  114. {memleaf-0.2.51 → memleaf-0.2.53}/src/memleaf.egg-info/top_level.txt +0 -0
@@ -2,6 +2,21 @@
2
2
 
3
3
  All notable changes to memleaf are documented here.
4
4
 
5
+ ## 0.2.53 — 2026-09-13
6
+
7
+ - Keep the memory when only the project name is unproven. A real turn was lost in full because of one word: the user wrote "在弄个记账的小玩意儿,就扔家里那台 N100 上跑,没打算上云", the model named the project `project:记账小玩意儿` -- the user's phrase with 的 removed -- and Core refuses a project scope whose name is not in the candidate's own evidence. That refusal discarded the whole candidate, so the N100 deployment and the no-cloud decision went with the unproven name, leaving three evidence units unresolved and nothing written. The memory was grounded; only the affiliation was not. The claim is now dropped and the memory kept with `global`, which asserts no ownership and loses no source-backed content. The refusal itself is unchanged: Core still never records a project it cannot ground.
8
+ - Name the project from the evidence verbatim, and prefer the shortest term that appears. The same turn showed the model composing a name by editing the user's words, which is the failure mode the grounding rule catches. The contract now says so directly, with the worked example: the thing described as "记账的小玩意儿" is `project:记账`, not `project:记账小玩意儿` and not `project:记账的小玩意儿`. Measured against the live model on the exact captured turn, the composed name is gone and both the with-assistant and user-only variants yield `project:记账`.
9
+ - Make the B3 outcome counters actually surface. `b3_normalization_count` and `b3_candidate_deferred_count` were emitted but were not in the metric allowlist, so they were discarded without a word -- which made the "visible rather than silent" claim in the 0.2.49 and 0.2.50 notes untrue. Both are now recorded, together with `b3_ungrounded_scope_dropped_count` for the fallback above.
10
+
11
+ Verification for this release used the real model on the captured turn. 118 tests pass with no model call, pinning the grounding rule that caused the loss (a verbatim name passes, the edited name does not), the fallback (a project scope becomes `global`, non-project scopes survive, an empty input still yields a legal scope), and the grounding decision itself. Against the live route, replaying the exact captured turn with and without the assistant's reply now yields `project:记账` in both cases, where before the fix the with-assistant variant yielded the ungrounded composed name. The deferred candidates of that already-processed turn are replayed from the journal rather than re-attempted, so the memory lost by the old code is not recovered by upgrading; the fix applies to turns processed from now on.
12
+
13
+ ## 0.2.52 — 2026-09-13
14
+
15
+ - Stop an assistant message from originating a durable claim. A three-sentence acceptance run recorded a project requirement the user never asked for: the user wrote only "我写日志习惯用中文,英文的扫两眼就跳过去了", the assistant replied with its own elaboration ("记账工具的日志……都写成中文;异常堆栈上头再包一层人话"), and the planner stored that elaboration as a project fact. The design allows an assistant reply as a source for *organising what the user already said*, so the rule is now explicit about what that excludes: an assistant message may organise, restate or report what the user's own evidence establishes, may never be the only support for a durable claim, and contributes nothing where it states a decision, requirement, rule, plan, recommendation or added detail of its own -- however definite it sounds. Consequences the assistant derived from a user preference are the assistant's, not the user's, and are not recorded as requirements or project state.
16
+ - Fix a regression the scope vocabulary introduced, before it could reach a project-scoped Vault. The scoped fallback runs when a turn matches no existing memory and the session scope is specific, and it declared itself ambiguous when the scope held more than one record -- ``len(records) > 1``. A populated scope therefore always reported ambiguity, which cleared ``lookup_complete`` and deferred every CREATE in that turn. It stayed dormant while sessions were ``global``-only, because ``_has_specific_scope`` is false for ``global`` and the fallback never ran; the first session that carried ``project:记账`` activated it, and turn three of the acceptance run deferred with ``lookup_incomplete`` and wrote nothing with zero rows withheld from the catalog. Ambiguity now means what it should: this turn names more than one specific scope, so the fallback cannot tell which one owns it.
17
+
18
+ Verification for this release used the real model and a real Vault. 110 tests pass with no model call, covering the assistant-source rule and the allowance it must preserve, and the scope fallback across a populated scope, two named projects, global-only and an empty scope. Against the live route, the assistant-source rule was checked on three cases: the reproduced defect (the user's preference is now recorded alone, the assistant's elaboration is marked ``assistant_restatement`` and nothing is written from it), an assistant reply that organises user-stated progress, and a requirement the user explicitly accepts -- the two controls still work. The ambiguity fix was checked against the deferred production turn, which now reports ``lookup_complete: true`` with all 21 in-scope records projected. The assistant-source rule is published in the prompt and enforced by the planner's judgement, not by a Core-side structural check, so a model that ignores it can still record such a claim; no measurement of that rate was made.
19
+
5
20
  ## 0.2.51 — 2026-09-13
6
21
 
7
22
  - Publish the scope vocabulary in the B3 single-pass contract. The compact contract described `scopes` only as `nonempty string[]` and never named `project:<name>`, so a planner handed an empty `scope_registry` had exactly one value it could be sure was legal. A first message that plainly establishes a project -- "最近在弄个记账的小玩意儿,就扔家里那台 N100 上跑" -- was filed under `global`, producing the internally inconsistent `type=project` beside `scopes=["global"]`. The legacy summarize contract always carried this paragraph; B3 lost it, the same way it had lost the todo-field and date rules repaired in 0.2.48 and 0.2.50.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memleaf
3
- Version: 0.2.51
3
+ Version: 0.2.53
4
4
  Summary: A local-first Markdown memory core for AI agents
5
5
  Author: memleaf contributors
6
6
  License-Expression: MIT
@@ -23,7 +23,7 @@ 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.51。**
26
+ > **版本:0.2.53。**
27
27
  > 记忆只从用户与 Agent 的可见对话提炼。Agent 已在回复中整理的事实、项目进展和明确待办可作为来源;邮件、附件、网页和终端等工具原文不进入记忆提炼。模型负责保留原话中的不确定性,现有记忆仅用于比较、去重和更新。Markdown 仍是唯一事实源。
28
28
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
29
29
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  [中文](README.md) · [PyPI](https://pypi.org/project/memleaf/) · [GitHub](https://github.com/miffyblueboo/memleaf)
6
6
 
7
- > **Version: 0.2.51.**
7
+ > **Version: 0.2.53.**
8
8
  > Automatic extraction now uses only the current turn's visible user input and final assistant reply. Raw tool output, attachments, web/file/terminal payloads and legacy tool-evidence bodies are not new source evidence; existing or retrieved memory remains comparison context rather than source authority. Background processing is persisted as a local job and can be checked through the read-only `process_status` MCP tool; failed work remains retryable and fail closed. The release also tightens source/date grounding, target reconciliation, duplicate/no-op handling and semantic review before writes. Markdown remains the sole source of truth with no SQLite runtime dependency. Acceptance covers deterministic regression suites and synthetic inputs; it does not claim real-mail or customer-business acceptance.
9
9
  > **The current release supports Hermes and Codex.** Antigravity is not detected, installed, or configured.
10
10
 
@@ -4,7 +4,7 @@
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.51。**
7
+ > **版本:0.2.53。**
8
8
  > 记忆只从用户与 Agent 的可见对话提炼。Agent 已在回复中整理的事实、项目进展和明确待办可作为来源;邮件、附件、网页和终端等工具原文不进入记忆提炼。模型负责保留原话中的不确定性,现有记忆仅用于比较、去重和更新。Markdown 仍是唯一事实源。
9
9
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
10
10
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "memleaf"
7
- version = "0.2.51"
7
+ version = "0.2.53"
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.51"
3
+ __version__ = "0.2.53"
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.51
2
+ version: 0.2.53
3
3
  description: "Hermes-native external MemoryProvider for local-first Markdown memory shared with the memleaf MCP server."
4
4
  hooks:
5
5
  - prefetch
@@ -51,6 +51,12 @@ _COVERAGE_DIAGNOSTIC_FIELDS = frozenset({"explanation"})
51
51
  _METRIC_EVENT_FIELDS = frozenset({
52
52
  "repair_attempted_count", "repair_rejected_semantic_drift_count",
53
53
  "parse_accepted_count", "decision_case_normalization_count",
54
+ # Normalization, deferral and scope fallback are all outcomes a turn can
55
+ # reach without failing, so they must actually surface in the metrics. The
56
+ # first two were emitted but silently dropped here, which made the
57
+ # "visible rather than silent" claim in their release notes untrue.
58
+ "b3_normalization_count", "b3_candidate_deferred_count",
59
+ "b3_ungrounded_scope_dropped_count",
54
60
  })
55
61
  _THINKING_OBSERVATION_SOURCES = frozenset({
56
62
  "request_parameter", "reasoning_tokens", "reasoning_content", "unavailable",
@@ -82,6 +88,9 @@ def _metric_bucket() -> dict[str, Any]:
82
88
  "repair_rejected_semantic_drift_count": 0,
83
89
  "parse_accepted_count": 0,
84
90
  "decision_case_normalization_count": 0,
91
+ "b3_normalization_count": 0,
92
+ "b3_candidate_deferred_count": 0,
93
+ "b3_ungrounded_scope_dropped_count": 0,
85
94
  "_first_started": None,
86
95
  "_last_finished": None,
87
96
  }
@@ -393,7 +393,21 @@ class PlanningContext:
393
393
 
394
394
 
395
395
  def _scope_records_unlocked(self, scope: Any) -> tuple[list[Any], bool]:
396
- """Read and rank active records once for a scoped fallback."""
396
+ """Read and rank active records once for a scoped fallback.
397
+
398
+ ``ambiguous`` answers a question about *scope identity*: does this turn
399
+ name more than one specific scope, so that the fallback cannot tell
400
+ which one owns it? It deliberately does not count how many memories the
401
+ scope holds. A scope carrying many memories is ordinary, and a session
402
+ naming one project owns its turns unambiguously.
403
+
404
+ Counting records instead made the fallback declare itself ambiguous
405
+ whenever a scope was populated, which marked the lookup unprovable and
406
+ deferred every CREATE in a project-scoped session -- while a
407
+ ``global``-only session, where the fallback never runs, was unaffected.
408
+ The catalog ceiling is what bounds how much context is safe to supply;
409
+ ambiguity is not.
410
+ """
397
411
 
398
412
  active_records = self.service._read_memories_unlocked("knowledge")
399
413
  scoped = filter_by_scope(
@@ -415,7 +429,13 @@ class PlanningContext:
415
429
  ),
416
430
  reverse=True,
417
431
  )
418
- return records, len(records) > 1
432
+ requested = [scope] if isinstance(scope, str) else list(scope or [])
433
+ specific = {
434
+ value
435
+ for value in requested
436
+ if isinstance(value, str) and value not in {"", "global", "unscoped"}
437
+ }
438
+ return records, len(specific) > 1
419
439
 
420
440
 
421
441
  @classmethod
@@ -34,6 +34,25 @@ from .validation import ModelOutputError, parse_summarize_output
34
34
  from .llm import ModelUnavailable
35
35
 
36
36
 
37
+ def _drop_ungrounded_project_scopes(scopes: Iterable[Any]) -> list[str]:
38
+ """Return the scopes that assert no unproven project ownership.
39
+
40
+ A project scope is a claimed affiliation and Core refuses one the evidence
41
+ does not name. The memory carrying it is usually grounded in full; only the
42
+ affiliation is unproven, so the claim is dropped rather than the memory.
43
+ Measured on a real turn, discarding the candidate instead lost
44
+ "在弄个记账的小玩意儿,跑在 N100,不上云" entirely because the model had
45
+ named the project "记账小玩意儿" while the user wrote "记账的小玩意儿".
46
+ """
47
+
48
+ kept = [
49
+ scope
50
+ for scope in scopes
51
+ if not (isinstance(scope, str) and scope.startswith("project:"))
52
+ ]
53
+ return kept or ["global"]
54
+
55
+
37
56
  class SinglePassMemoryPlanner(MemoryPlanner):
38
57
  """One semantic model call for an ordinary automatic turn."""
39
58
 
@@ -430,10 +449,24 @@ class SinglePassMemoryPlanner(MemoryPlanner):
430
449
  validation_scope_registry,
431
450
  authorized_project_scopes,
432
451
  ):
433
- raise ModelOutputError(
434
- "B3 project scope is not grounded by claimed source",
435
- validation_detail="scope_not_grounded",
436
- )
452
+ # The memory itself is grounded; only the ownership claim is
453
+ # not. Discarding the whole candidate over an unproven project
454
+ # name loses source-backed content the user stated, so the
455
+ # claim is dropped and the memory is kept unscoped instead.
456
+ # Nothing is fabricated either way: no ownership is asserted.
457
+ kept = _drop_ungrounded_project_scopes(scopes)
458
+ dropped = kept != list(scopes)
459
+ scopes = kept
460
+ scope_source = self._derived_scope_source(scopes, scope_background, scope)
461
+ candidate["scopes"] = scopes
462
+ candidate["scope_source"] = scope_source
463
+ if dropped:
464
+ event = getattr(self.model, "_record_metric_event", None)
465
+ if callable(event):
466
+ event(
467
+ {"stage": "single_pass", "operation": "single_pass_primary"},
468
+ "b3_ungrounded_scope_dropped_count",
469
+ )
437
470
  if (
438
471
  decision == "UPDATE"
439
472
  and target_memory is not None
@@ -121,6 +121,7 @@ SINGLE_PASS_SYSTEM = f"""You are memleaf's single-pass memory planner.
121
121
 
122
122
  SOURCE
123
123
  Only current_evidence may establish new facts or changes. local_memory_catalog and native_memory_catalog are comparison context; native memory is never an UPDATE/NO_CHANGE target. Never invent source facts, ownership, dates, status, obligations, numbers, relationships or IDs.
124
+ An assistant message is evidence of what you reported, never of what the user wants. It may organise, restate or report what the user's own evidence establishes, but it may never be the only support for a durable claim. When it states something the user's message does not establish -- your own decision, requirement, rule, plan, recommendation or added detail -- record nothing from that statement, however definite it sounds. Consequences you derived from a user preference are yours, not the user's: never record them as a requirement or as project state. Only something the user stated or accepted becomes memory.
124
125
 
125
126
  TASK
126
127
  Extract every independently useful long-term memory. Keep independently retrievable/updateable topics separate and preserve entity, condition, polarity, uncertainty, ownership, state and meaning-critical numbers/codes. CREATE only when no supplied local memory represents the durable information; UPDATE only when current evidence proves a change to one supplied local memory; NO_CHANGE only when it adds no semantic change; DEFERRED for a durable candidate that cannot safely reach a terminal decision. Project ownership and platform/system names are separate judgments. Do not turn every negation into no_memory and do not use NO_CHANGE to hide ambiguity.
@@ -128,7 +129,7 @@ Extract every independently useful long-term memory. Keep independently retrieva
128
129
  SCOPES
129
130
  Legal values: global | domain:<name> | portfolio:<name> | project:<name> | unscoped. scopes is a nonempty array; at most one project:<name> per memory; unscoped must be the only value, and Core then records insufficient_context.
130
131
  When a candidate concerns one distinct project the user is working on -- a type=project memory, or the work, decisions, state or deadlines that belong to that project -- scope it to that project as project:<name>, using the name the evidence itself uses. The project does not need to be registered first; scope_registry only lists what already exists.
131
- Ground the name in this candidate's own cited evidence, or in a project scope explicitly supplied for this turn. A product, platform, system, vendor, notification source, comparison or implementation context is not ownership by name alone.
132
+ Ground the name in this candidate's own cited evidence, or in a project scope explicitly supplied for this turn. Never edit, translate or combine the evidence's words into a name that does not appear there, and choose the shortest term that does appear and names the project: the thing described as "记账的小玩意儿" is project:记账, not project:记账小玩意儿 and not project:记账的小玩意儿. An ungrounded name is rejected and its memory is deferred instead of written. A product, platform, system, vendor, notification source, comparison or implementation context is not ownership by name alone.
132
133
  Use global only for a fact that no single project owns: a standing personal preference, a machine-wide or tool-wide rule, or an environment fact. Never invent, translate or borrow a project name.
133
134
 
134
135
  DATES
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memleaf
3
- Version: 0.2.51
3
+ Version: 0.2.53
4
4
  Summary: A local-first Markdown memory core for AI agents
5
5
  Author: memleaf contributors
6
6
  License-Expression: MIT
@@ -23,7 +23,7 @@ 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.51。**
26
+ > **版本:0.2.53。**
27
27
  > 记忆只从用户与 Agent 的可见对话提炼。Agent 已在回复中整理的事实、项目进展和明确待办可作为来源;邮件、附件、网页和终端等工具原文不进入记忆提炼。模型负责保留原话中的不确定性,现有记忆仅用于比较、去重和更新。Markdown 仍是唯一事实源。
28
28
  > **当前版本支持 Hermes 和 Codex。** Antigravity(反重力)不检测、不安装、不配置。
29
29
 
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