hebbrix 2.8.0__tar.gz → 2.9.0__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 (52) hide show
  1. {hebbrix-2.8.0 → hebbrix-2.9.0}/CHANGELOG.md +7 -0
  2. {hebbrix-2.8.0/hebbrix.egg-info → hebbrix-2.9.0}/PKG-INFO +10 -5
  3. {hebbrix-2.8.0 → hebbrix-2.9.0}/README.md +9 -4
  4. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/__init__.py +1 -1
  5. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/answers.py +92 -11
  6. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/client.py +1 -1
  7. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/sync_client.py +1 -1
  8. {hebbrix-2.8.0 → hebbrix-2.9.0/hebbrix.egg-info}/PKG-INFO +10 -5
  9. {hebbrix-2.8.0 → hebbrix-2.9.0}/pyproject.toml +1 -1
  10. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_answer_context.py +38 -0
  11. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_answer_decision.py +41 -0
  12. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_customer_developer_experience.py +1 -1
  13. {hebbrix-2.8.0 → hebbrix-2.9.0}/LICENSE +0 -0
  14. {hebbrix-2.8.0 → hebbrix-2.9.0}/MANIFEST.in +0 -0
  15. {hebbrix-2.8.0 → hebbrix-2.9.0}/contracts/openapi-routes.json +0 -0
  16. {hebbrix-2.8.0 → hebbrix-2.9.0}/docs/native-experience-operations.md +0 -0
  17. {hebbrix-2.8.0 → hebbrix-2.9.0}/examples/native_reflection_worker.py +0 -0
  18. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/_advice.py +0 -0
  19. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/chat.py +0 -0
  20. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/exceptions.py +0 -0
  21. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/execution.py +0 -0
  22. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/experience.py +0 -0
  23. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/models.py +0 -0
  24. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/openai_reflection.py +0 -0
  25. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/reflection_worker.py +0 -0
  26. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/resources.py +0 -0
  27. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix/workflow.py +0 -0
  28. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix.egg-info/SOURCES.txt +0 -0
  29. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix.egg-info/dependency_links.txt +0 -0
  30. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix.egg-info/entry_points.txt +0 -0
  31. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix.egg-info/requires.txt +0 -0
  32. {hebbrix-2.8.0 → hebbrix-2.9.0}/hebbrix.egg-info/top_level.txt +0 -0
  33. {hebbrix-2.8.0 → hebbrix-2.9.0}/setup.cfg +0 -0
  34. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_advanced_resources.py +0 -0
  35. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_advisor_integrity.py +0 -0
  36. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_chat_answer_options.py +0 -0
  37. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_compact_search_default.py +0 -0
  38. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_evidence_loop_resource.py +0 -0
  39. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_evidence_safety_boundary.py +0 -0
  40. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_execution_permission.py +0 -0
  41. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_experience_request.py +0 -0
  42. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_experience_workflow.py +0 -0
  43. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_followup_helpers.py +0 -0
  44. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_memories_resource.py +0 -0
  45. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_openai_reflection.py +0 -0
  46. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_openapi_parity.py +0 -0
  47. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_outcome_advice_resource.py +0 -0
  48. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_procedural_resource.py +0 -0
  49. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_reflection_worker_cli.py +0 -0
  50. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_release_version.py +0 -0
  51. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_sync_client.py +0 -0
  52. {hebbrix-2.8.0 → hebbrix-2.9.0}/tests/test_workflow_route_contract.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.9.0 — 2026-11-11 (high-stakes readiness, history and suggestions)
4
+
5
+ - `should_answer(response, require_ready=True)` (also on `usable_memories` and `answer_context`): for high-stakes flows, holds the answer with action `retry` and reason `index_not_ready` until `indexing.status` is `ready` and `indexing.answer_risk` is `none`. A response that does not report its indexing is not ready.
6
+ - Behaviour change: `history=True` now applies only when the server answered or marked the response `superseded`; it no longer overrides `unverified`, `no_relevant_memory` or `indexing`.
7
+ - A Reason result for a suggestion or plan (`grounding.answerability: "context_only"`) returns action `use_as_context` with its memories in `context`; `answer_context` lists them as context that is neither an established fact nor permission to act.
8
+ - `answer_context` says when recent writes could not be reflected in the profile (`projection.status: "failed"`, server 1.4.25).
9
+
3
10
  ## 2.8.0 — 2026-11-11 (answer decisions and answer context)
4
11
 
5
12
  - New `hebbrix.should_answer(response)`: decides in code whether a `search_with_proof()` or `reason()` response may be answered from, returning an `AnswerDecision` with `action` (`answer`, `say_unknown`, `abstain`, `verify_authorization`, `ask_user`, `retry` or `say_no_longer_current`), `reason`, the usable `memories` and the `context` rows never to answer from. `history=True` counts superseded and historical versions for questions about the past.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hebbrix
3
- Version: 2.8.0
3
+ Version: 2.9.0
4
4
  Summary: Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs
5
5
  Author-email: Hebbrix Team <support@hebbrix.com>
6
6
  Maintainer-email: Hebbrix Team <support@hebbrix.com>
@@ -65,14 +65,14 @@ Dynamic: license-file
65
65
 
66
66
  Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
67
67
 
68
- The current stable package is **2.8.0**. Start with memory storage and search, or
68
+ The current stable package is **2.9.0**. Start with memory storage and search, or
69
69
  the three-call outcome-learning workflow below. Advanced evidence and execution
70
70
  permission transports are opt-in; installing the SDK never permits an action.
71
71
 
72
72
  ## Install
73
73
 
74
74
  ```bash
75
- pip install hebbrix==2.8.0
75
+ pip install hebbrix==2.9.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -145,8 +145,13 @@ profile's `scope`, and says so when the profile is still being updated
145
145
  is not taken as absent. When the decision is not to answer it returns the
146
146
  profile alone. `usable_memories(response)` returns just the rows. Pass
147
147
  `history=True` for a question about the past, when superseded and historical
148
- versions should count. `reason()` takes `deadline_ms`; a `timed_out` response is
149
- an abstention. `verify_authorization` means the returned rule limits the action
148
+ versions should count (it never overrides `unverified`, `no_relevant_memory`,
149
+ `indexing` or `conflicting`). Pass `require_ready=True` for a high-stakes flow:
150
+ the answer is then also held, with action `retry`, until `indexing.status` is
151
+ `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
152
+ (`context_only`) returns action `use_as_context`: its memories shape what your
153
+ model suggests, and are never a fact or a permission. `reason()` takes
154
+ `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
150
155
  to a group the store cannot place the user in: use the rule, and check the
151
156
  permission in your own system.
152
157
 
@@ -2,14 +2,14 @@
2
2
 
3
3
  Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
4
4
 
5
- The current stable package is **2.8.0**. Start with memory storage and search, or
5
+ The current stable package is **2.9.0**. Start with memory storage and search, or
6
6
  the three-call outcome-learning workflow below. Advanced evidence and execution
7
7
  permission transports are opt-in; installing the SDK never permits an action.
8
8
 
9
9
  ## Install
10
10
 
11
11
  ```bash
12
- pip install hebbrix==2.8.0
12
+ pip install hebbrix==2.9.0
13
13
  ```
14
14
 
15
15
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -82,8 +82,13 @@ profile's `scope`, and says so when the profile is still being updated
82
82
  is not taken as absent. When the decision is not to answer it returns the
83
83
  profile alone. `usable_memories(response)` returns just the rows. Pass
84
84
  `history=True` for a question about the past, when superseded and historical
85
- versions should count. `reason()` takes `deadline_ms`; a `timed_out` response is
86
- an abstention. `verify_authorization` means the returned rule limits the action
85
+ versions should count (it never overrides `unverified`, `no_relevant_memory`,
86
+ `indexing` or `conflicting`). Pass `require_ready=True` for a high-stakes flow:
87
+ the answer is then also held, with action `retry`, until `indexing.status` is
88
+ `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
89
+ (`context_only`) returns action `use_as_context`: its memories shape what your
90
+ model suggests, and are never a fact or a permission. `reason()` takes
91
+ `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
87
92
  to a group the store cannot place the user in: use the rule, and check the
88
93
  permission in your own system.
89
94
 
@@ -5,7 +5,7 @@ production OpenAPI and ``GET /v1/users/me/capabilities``. The experimental
5
5
  World Model is intentionally absent from this release.
6
6
  """
7
7
 
8
- __version__ = "2.8.0"
8
+ __version__ = "2.9.0"
9
9
  __author__ = "Hebbrix Team"
10
10
  __license__ = "MIT"
11
11
 
@@ -49,6 +49,15 @@ ACTIONS = {
49
49
  # the rule is in ``context``; check the asker's role in your own system.
50
50
  AUTHORIZATION_NOT_VERIFIABLE = "authorization_not_verifiable"
51
51
  VERIFY_AUTHORIZATION = "verify_authorization"
52
+ # A Reason request for a suggestion or plan ("Can you suggest accessories for my
53
+ # camera?") has no stored answer: its sources are the memories that should shape
54
+ # what your model composes (``grounding.answerability`` "context_only"). They are
55
+ # context, never a verified fact or a permission.
56
+ CONTEXT_ONLY = "context_only"
57
+ USE_AS_CONTEXT = "use_as_context"
58
+ # ``require_ready``: the scope's index is not complete, or the server says the
59
+ # answer may still change (``indexing.answer_risk``).
60
+ INDEX_NOT_READY = "index_not_ready"
52
61
  # Set by the SDK on a response whose rows it kept although it is degraded: not a
53
62
  # malformed envelope, so it is not a reason to fail closed on its own.
54
63
  _PRESERVED = "degraded_evidence_preserved"
@@ -105,17 +114,51 @@ def _is_history(row: Mapping[str, Any], *, search_row: bool) -> bool:
105
114
  )
106
115
 
107
116
 
117
+ def _ready(response: Mapping[str, Any]) -> bool:
118
+ """Whether the response says its scope is fully indexed with nothing that
119
+ could change the answer. A response that does not say is not ready."""
120
+
121
+ indexing = response.get("indexing")
122
+ if not isinstance(indexing, Mapping):
123
+ return False
124
+ return indexing.get("status") == "ready" and indexing.get("answer_risk") in (
125
+ None,
126
+ "none",
127
+ )
128
+
129
+
108
130
  def should_answer(
109
- response: Optional[Mapping[str, Any]], *, history: bool = False
131
+ response: Optional[Mapping[str, Any]],
132
+ *,
133
+ history: bool = False,
134
+ require_ready: bool = False,
110
135
  ) -> AnswerDecision:
111
136
  """Whether you may answer from ``response`` (a ``search_with_proof`` or
112
137
  ``reason`` result), the rows to answer from, and what to do when you may not.
113
138
 
139
+ Every server signal is enforced: ``answer_status``, ``no_match``,
140
+ ``abstain_recommended``, ``decision_abstained``, ``confidence_reason`` and
141
+ each row's ``low_confidence`` and ``revision_status``.
142
+
143
+ ``require_ready=True`` is for high-stakes flows (money, health, actions):
144
+ the answer is also held, with action ``retry``, until ``indexing.status`` is
145
+ ``ready`` and ``indexing.answer_risk`` is ``none``. Without it an answer
146
+ from a scope still indexing is allowed when the server allows it
147
+ (``answer_risk`` ``may_change``), and a count, total or list is always held
148
+ while indexing (``answer_status`` ``indexing``).
149
+
114
150
  ``history=True`` is for a question about the past that your application
115
- recognises ("Where did I live before?"): superseded and historical rows then
116
- count, whatever the response says of the present. Keep each row's
117
- ``revision_status`` and ``stated_at`` in what you pass to the model, so it can
118
- tell the versions apart. Conflicting rows never count.
151
+ recognises ("Where did I live before?"). It overrides one thing: a
152
+ superseded or historical row then counts as evidence, so a response the
153
+ server answered or marked ``superseded`` can be answered from its earlier
154
+ versions. It never overrides ``unverified``, ``no_relevant_memory``,
155
+ ``indexing``, ``conflicting`` or ``authorization_not_verifiable``. Keep each
156
+ row's ``revision_status`` and ``stated_at`` in what you pass to the model, so
157
+ it can tell the versions apart.
158
+
159
+ A Reason result for a suggestion or plan (``context_only``) returns action
160
+ ``use_as_context``: give ``decision.context`` to your model to shape what it
161
+ suggests, never as an established fact or a permission to act.
119
162
  """
120
163
 
121
164
  if not isinstance(response, Mapping) or "answer_status" not in response:
@@ -135,7 +178,12 @@ def should_answer(
135
178
  return declined(status, ACTIONS[status])
136
179
  if response.get("confidence_reason") == AUTHORIZATION_NOT_VERIFIABLE:
137
180
  return declined(AUTHORIZATION_NOT_VERIFIABLE, VERIFY_AUTHORIZATION)
138
- if history:
181
+ grounding = response.get("grounding")
182
+ if isinstance(grounding, Mapping) and grounding.get("answerability") == CONTEXT_ONLY:
183
+ return declined(CONTEXT_ONLY, USE_AS_CONTEXT)
184
+ if require_ready and not _ready(response):
185
+ return declined(INDEX_NOT_READY, "retry")
186
+ if history and status in ("answerable", "superseded"):
139
187
  usable = [row for row in rows if _is_history(row, search_row=search_rows)]
140
188
  if usable:
141
189
  others = [row for row in rows if row not in usable]
@@ -153,12 +201,17 @@ def should_answer(
153
201
 
154
202
 
155
203
  def usable_memories(
156
- response: Optional[Mapping[str, Any]], *, history: bool = False
204
+ response: Optional[Mapping[str, Any]],
205
+ *,
206
+ history: bool = False,
207
+ require_ready: bool = False,
157
208
  ) -> List[Dict[str, Any]]:
158
209
  """The rows of ``response`` safe to pass to a model as evidence; empty when
159
210
  ``should_answer`` says not to answer."""
160
211
 
161
- return should_answer(response, history=history).memories
212
+ return should_answer(
213
+ response, history=history, require_ready=require_ready
214
+ ).memories
162
215
 
163
216
 
164
217
  def _day(value: Any) -> Optional[str]:
@@ -189,7 +242,8 @@ def _profile_lines(profile: Any) -> List[str]:
189
242
  projection = profile.get("projection")
190
243
  projection = projection if isinstance(projection, Mapping) else {}
191
244
  pending = projection.get("status") == "pending"
192
- if not facts and not avoid and not pending:
245
+ failed = projection.get("status") == "failed"
246
+ if not facts and not avoid and not pending and not failed:
193
247
  return []
194
248
  scope = profile.get("scope")
195
249
  scope = (
@@ -226,6 +280,17 @@ def _profile_lines(profile: Any) -> List[str]:
226
280
  f"- still being updated: {writes} not yet reflected; a fact here may be "
227
281
  "missing or about to change."
228
282
  )
283
+ elif failed:
284
+ count = projection.get("failed_writes")
285
+ writes = (
286
+ f"{count} recent writes"
287
+ if isinstance(count, int) and count > 0
288
+ else "recent writes"
289
+ )
290
+ lines.append(
291
+ f"- incomplete: {writes} could not be reflected; a fact from them may be "
292
+ "missing."
293
+ )
229
294
  return lines
230
295
 
231
296
 
@@ -276,6 +341,7 @@ def answer_context(
276
341
  decision: Optional[AnswerDecision] = None,
277
342
  *,
278
343
  history: bool = False,
344
+ require_ready: bool = False,
279
345
  ) -> str:
280
346
  """The text to give your own model with the user's message: the end user's
281
347
  standing profile and the memories ``should_answer`` lets you answer from.
@@ -290,11 +356,16 @@ def answer_context(
290
356
  memory type, date, whom it is about, the names it states, its revision
291
357
  status and its support. When the decision is not to answer, only the
292
358
  profile is returned: standing preferences still shape a reply such as
293
- "I don't know that yet". Returns "" when there is nothing to add.
359
+ "I don't know that yet". For a Reason suggestion or plan (``context_only``)
360
+ the memories that should shape it are listed as context, marked as neither
361
+ established facts nor permission to act. Returns "" when there is nothing to
362
+ add.
294
363
  """
295
364
 
296
365
  if decision is None:
297
- decision = should_answer(response, history=history)
366
+ decision = should_answer(
367
+ response, history=history, require_ready=require_ready
368
+ )
298
369
  sections = []
299
370
  profile = _profile_lines(
300
371
  response.get("profile") if isinstance(response, Mapping) else None
@@ -313,4 +384,14 @@ def answer_context(
313
384
  lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
314
385
  lines.append(str(row.get("content") or ""))
315
386
  sections.append("\n".join(lines))
387
+ elif decision.reason == CONTEXT_ONLY and decision.context:
388
+ lines = [
389
+ "Memories that should shape the suggestion (context: not established "
390
+ "facts, and never permission to act):"
391
+ ]
392
+ for index, row in enumerate(decision.context, start=1):
393
+ details = _memory_details(row)
394
+ lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
395
+ lines.append(str(row.get("content") or ""))
396
+ sections.append("\n".join(lines))
316
397
  return "\n\n".join(sections)
@@ -93,7 +93,7 @@ class MemoryClient:
93
93
  """Get request headers."""
94
94
  headers = {
95
95
  "Content-Type": "application/json",
96
- "User-Agent": "hebbrix-python/2.8.0",
96
+ "User-Agent": "hebbrix-python/2.9.0",
97
97
  }
98
98
 
99
99
  if self.api_key:
@@ -1144,7 +1144,7 @@ class SyncMemoryClient:
1144
1144
  self.source = source or os.getenv("HEBBRIX_SOURCE")
1145
1145
  headers = {
1146
1146
  "Content-Type": "application/json",
1147
- "User-Agent": "hebbrix-python/2.8.0",
1147
+ "User-Agent": "hebbrix-python/2.9.0",
1148
1148
  }
1149
1149
  if api_key:
1150
1150
  headers["Authorization"] = f"Bearer {api_key}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hebbrix
3
- Version: 2.8.0
3
+ Version: 2.9.0
4
4
  Summary: Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs
5
5
  Author-email: Hebbrix Team <support@hebbrix.com>
6
6
  Maintainer-email: Hebbrix Team <support@hebbrix.com>
@@ -65,14 +65,14 @@ Dynamic: license-file
65
65
 
66
66
  Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
67
67
 
68
- The current stable package is **2.8.0**. Start with memory storage and search, or
68
+ The current stable package is **2.9.0**. Start with memory storage and search, or
69
69
  the three-call outcome-learning workflow below. Advanced evidence and execution
70
70
  permission transports are opt-in; installing the SDK never permits an action.
71
71
 
72
72
  ## Install
73
73
 
74
74
  ```bash
75
- pip install hebbrix==2.8.0
75
+ pip install hebbrix==2.9.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -145,8 +145,13 @@ profile's `scope`, and says so when the profile is still being updated
145
145
  is not taken as absent. When the decision is not to answer it returns the
146
146
  profile alone. `usable_memories(response)` returns just the rows. Pass
147
147
  `history=True` for a question about the past, when superseded and historical
148
- versions should count. `reason()` takes `deadline_ms`; a `timed_out` response is
149
- an abstention. `verify_authorization` means the returned rule limits the action
148
+ versions should count (it never overrides `unverified`, `no_relevant_memory`,
149
+ `indexing` or `conflicting`). Pass `require_ready=True` for a high-stakes flow:
150
+ the answer is then also held, with action `retry`, until `indexing.status` is
151
+ `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
152
+ (`context_only`) returns action `use_as_context`: its memories shape what your
153
+ model suggests, and are never a fact or a permission. `reason()` takes
154
+ `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
150
155
  to a group the store cannot place the user in: use the rule, and check the
151
156
  permission in your own system.
152
157
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hebbrix"
7
- version = "2.8.0"
7
+ version = "2.9.0"
8
8
  description = "Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -119,6 +119,29 @@ def test_a_profile_still_being_projected_says_so():
119
119
  )
120
120
 
121
121
 
122
+ def test_a_profile_whose_writes_failed_to_project_says_it_is_incomplete():
123
+ failed = {
124
+ **PROFILE,
125
+ "facts": [],
126
+ "avoid_topics": [],
127
+ "projection": {
128
+ "status": "failed",
129
+ "pending_writes": 0,
130
+ "failed_writes": 2,
131
+ "capped": False,
132
+ "failure": {"reason": "profile_extraction_failed", "retryable": True},
133
+ "retry_after_seconds": None,
134
+ },
135
+ }
136
+ context = answer_context(search([], failed, answer_status="no_relevant_memory"))
137
+ assert context == (
138
+ "Standing profile of this user (applies to every reply; collection_id c-1; "
139
+ "end_user_id user-42; as of 2026-11-08; projection failed):\n"
140
+ "- incomplete: 2 recent writes could not be reflected; a fact from them may "
141
+ "be missing."
142
+ )
143
+
144
+
122
145
  def test_an_unavailable_profile_is_not_presented_as_empty():
123
146
  context = answer_context(
124
147
  search([ALLERGY], {"status": "unavailable", "facts": [], "count": 0})
@@ -170,3 +193,18 @@ def test_reason_sources_render_too():
170
193
  "[1] (fact; saved 2026-11-02; current)",
171
194
  "The user is allergic to peanuts.",
172
195
  ]
196
+
197
+
198
+ def test_a_suggestion_lists_its_context_as_neither_fact_nor_permission():
199
+ from hebbrix import answer_context
200
+
201
+ page = {
202
+ "answer": None,
203
+ "sources": [{"memory_id": "m1", "content": "The user owns a Fuji X-T5."}],
204
+ "decision_abstained": True,
205
+ "answer_status": "unverified",
206
+ "grounding": {"status": "supported", "answerability": "context_only"},
207
+ }
208
+ text = answer_context(page)
209
+ assert "The user owns a Fuji X-T5." in text
210
+ assert "not established facts" in text and "never permission" in text
@@ -383,3 +383,44 @@ def test_an_unverified_permission_is_its_own_action_with_the_rule_as_context():
383
383
  def test_the_authorization_reason_is_the_apis():
384
384
  text = SCHEMAS["SearchResponse"]["properties"]["confidence_reason"]["description"]
385
385
  assert "authorization_not_verifiable" in text
386
+
387
+
388
+ def test_history_never_overrides_an_unverified_response():
389
+ # The server could not establish any row: earlier versions among them are
390
+ # not evidence for the past either.
391
+ rows = [row("old", is_current=False, revision_status="historical", low_confidence=True)]
392
+ page = search(rows, answer_status="unverified", abstain_recommended=True)
393
+ decision = should_answer(page, history=True)
394
+ assert not decision
395
+ assert decision.action == "abstain"
396
+ assert ids(decision.context) == ["old"]
397
+
398
+
399
+ def test_a_high_stakes_answer_waits_for_a_ready_index():
400
+ ready = {"status": "ready", "answer_risk": "none"}
401
+ assert should_answer(search(indexing=ready), require_ready=True)
402
+ for indexing in (
403
+ {"status": "incomplete", "answer_risk": "may_change"},
404
+ {"status": "ready", "answer_risk": "may_change"},
405
+ None,
406
+ ):
407
+ decision = should_answer(search(indexing=indexing), require_ready=True)
408
+ assert not decision
409
+ assert decision.action == "retry"
410
+ assert decision.reason == "index_not_ready"
411
+ # Without it, a response the server lets answer while indexing answers.
412
+ assert should_answer(search(indexing={"status": "incomplete", "answer_risk": "may_change"}))
413
+
414
+
415
+ def test_a_suggestion_is_context_to_shape_never_an_answer():
416
+ page = reason(
417
+ [source("camera")],
418
+ answer=None,
419
+ decision_abstained=True,
420
+ grounding={"status": "supported", "answerability": "context_only"},
421
+ )
422
+ decision = should_answer(page)
423
+ assert not decision
424
+ assert decision.action == "use_as_context"
425
+ assert decision.memories == []
426
+ assert ids(decision.context) == ["camera"]
@@ -162,6 +162,6 @@ def test_package_docs_metadata_uses_canonical_host():
162
162
  assert 'Documentation = "https://hebbrix.com/docs"' in text
163
163
  assert "docs.hebbrix.com" not in text
164
164
  readme = (root / "README.md").read_text()
165
- assert "pip install hebbrix==2.8.0" in readme
165
+ assert "pip install hebbrix==2.9.0" in readme
166
166
  assert "three calls" in readme
167
167
  assert "schema `" not in readme
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