hebbrix 2.9.0__tar.gz → 2.11.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.9.0 → hebbrix-2.11.0}/CHANGELOG.md +10 -0
  2. {hebbrix-2.9.0/hebbrix.egg-info → hebbrix-2.11.0}/PKG-INFO +8 -4
  3. {hebbrix-2.9.0 → hebbrix-2.11.0}/README.md +7 -3
  4. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/__init__.py +3 -1
  5. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/answers.py +51 -10
  6. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/client.py +1 -1
  7. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/models.py +7 -0
  8. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/sync_client.py +1 -1
  9. {hebbrix-2.9.0 → hebbrix-2.11.0/hebbrix.egg-info}/PKG-INFO +8 -4
  10. {hebbrix-2.9.0 → hebbrix-2.11.0}/pyproject.toml +1 -1
  11. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_answer_decision.py +93 -0
  12. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_customer_developer_experience.py +1 -1
  13. {hebbrix-2.9.0 → hebbrix-2.11.0}/LICENSE +0 -0
  14. {hebbrix-2.9.0 → hebbrix-2.11.0}/MANIFEST.in +0 -0
  15. {hebbrix-2.9.0 → hebbrix-2.11.0}/contracts/openapi-routes.json +0 -0
  16. {hebbrix-2.9.0 → hebbrix-2.11.0}/docs/native-experience-operations.md +0 -0
  17. {hebbrix-2.9.0 → hebbrix-2.11.0}/examples/native_reflection_worker.py +0 -0
  18. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/_advice.py +0 -0
  19. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/chat.py +0 -0
  20. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/exceptions.py +0 -0
  21. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/execution.py +0 -0
  22. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/experience.py +0 -0
  23. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/openai_reflection.py +0 -0
  24. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/reflection_worker.py +0 -0
  25. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/resources.py +0 -0
  26. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix/workflow.py +0 -0
  27. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix.egg-info/SOURCES.txt +0 -0
  28. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix.egg-info/dependency_links.txt +0 -0
  29. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix.egg-info/entry_points.txt +0 -0
  30. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix.egg-info/requires.txt +0 -0
  31. {hebbrix-2.9.0 → hebbrix-2.11.0}/hebbrix.egg-info/top_level.txt +0 -0
  32. {hebbrix-2.9.0 → hebbrix-2.11.0}/setup.cfg +0 -0
  33. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_advanced_resources.py +0 -0
  34. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_advisor_integrity.py +0 -0
  35. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_answer_context.py +0 -0
  36. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_chat_answer_options.py +0 -0
  37. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_compact_search_default.py +0 -0
  38. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_evidence_loop_resource.py +0 -0
  39. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_evidence_safety_boundary.py +0 -0
  40. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_execution_permission.py +0 -0
  41. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_experience_request.py +0 -0
  42. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_experience_workflow.py +0 -0
  43. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_followup_helpers.py +0 -0
  44. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_memories_resource.py +0 -0
  45. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_openai_reflection.py +0 -0
  46. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_openapi_parity.py +0 -0
  47. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_outcome_advice_resource.py +0 -0
  48. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_procedural_resource.py +0 -0
  49. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_reflection_worker_cli.py +0 -0
  50. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_release_version.py +0 -0
  51. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_sync_client.py +0 -0
  52. {hebbrix-2.9.0 → hebbrix-2.11.0}/tests/test_workflow_route_contract.py +0 -0
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.11.0 — 2026-11-13 (service failures, answer finality)
4
+
5
+ - `answer_status` `"unavailable"` (server 1.4.30): a service the evidence depends on failed for this request and nothing answers. `should_answer` declines it with action `retry`; never tell the user the fact is absent. Earlier versions declined it as `malformed_response`.
6
+ - Types: search and Reason responses gain `answer_finality` (`final`, `provisional`, `none`): whether an answerable response covers the whole scope (index ready) or only the evidence indexed so far. An agent acting on an answer, or any action with side effects, waits for `final`.
7
+
8
+ ## 2.10.0 — 2026-11-12 (applicable rules, consistent abstention flags)
9
+
10
+ - An `unverified` search response whose rows include `evidence_role: "applicable_rule"` (server 1.4.27) returns reason `applicable_rule` and action `use_as_context`, those rules first in `decision.context`: policy that speaks to the asked case but that the API has not verified decides it. Let your model apply it, or call `reason`. A rule is never an authorization; `authorization_not_verifiable` still comes first.
11
+ - `history=True` no longer overrides an explicit abstention flag on an `answerable` response: a response marked `answerable` that also sets `no_match`, `abstain_recommended` or `decision_abstained` contradicts itself and is declined in every mode, with that flag as the reason. History mode still answers a `superseded` response from its earlier versions (its flags concern the present), never one with `no_match`.
12
+
3
13
  ## 2.9.0 — 2026-11-11 (high-stakes readiness, history and suggestions)
4
14
 
5
15
  - `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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hebbrix
3
- Version: 2.9.0
3
+ Version: 2.11.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.9.0**. Start with memory storage and search, or
68
+ The current stable package is **2.11.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.9.0
75
+ pip install hebbrix==2.11.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -150,7 +150,11 @@ versions should count (it never overrides `unverified`, `no_relevant_memory`,
150
150
  the answer is then also held, with action `retry`, until `indexing.status` is
151
151
  `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
152
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
153
+ model suggests, and are never a fact or a permission. An `unverified` search
154
+ whose rows include `evidence_role: "applicable_rule"` returns reason
155
+ `applicable_rule` and action `use_as_context`: the rule speaks to the asked
156
+ case but the API has not verified it decides it; let your model apply it, or
157
+ call `reason()`. `reason()` takes
154
158
  `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
155
159
  to a group the store cannot place the user in: use the rule, and check the
156
160
  permission in your own system.
@@ -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.9.0**. Start with memory storage and search, or
5
+ The current stable package is **2.11.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.9.0
12
+ pip install hebbrix==2.11.0
13
13
  ```
14
14
 
15
15
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -87,7 +87,11 @@ versions should count (it never overrides `unverified`, `no_relevant_memory`,
87
87
  the answer is then also held, with action `retry`, until `indexing.status` is
88
88
  `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
89
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
90
+ model suggests, and are never a fact or a permission. An `unverified` search
91
+ whose rows include `evidence_role: "applicable_rule"` returns reason
92
+ `applicable_rule` and action `use_as_context`: the rule speaks to the asked
93
+ case but the API has not verified it decides it; let your model apply it, or
94
+ call `reason()`. `reason()` takes
91
95
  `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
92
96
  to a group the store cannot place the user in: use the rule, and check the
93
97
  permission in your own system.
@@ -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.9.0"
8
+ __version__ = "2.11.0"
9
9
  __author__ = "Hebbrix Team"
10
10
  __license__ = "MIT"
11
11
 
@@ -29,6 +29,7 @@ from hebbrix.exceptions import (
29
29
  )
30
30
  from hebbrix.models import (
31
31
  ActionAdviceReceipt,
32
+ AnswerFinality,
32
33
  AnswerStatus,
33
34
  EvidenceClaim,
34
35
  GroundingReceipt,
@@ -57,6 +58,7 @@ __all__ = [
57
58
  "SearchSafetyEnvelope",
58
59
  "ActionAdviceReceipt",
59
60
  "AnswerDecision",
61
+ "AnswerFinality",
60
62
  "AnswerStatus",
61
63
  "MemoryRow",
62
64
  "MemoryStatus",
@@ -32,6 +32,7 @@ ANSWER_STATUSES = (
32
32
  "unverified",
33
33
  "indexing",
34
34
  "no_relevant_memory",
35
+ "unavailable",
35
36
  )
36
37
  REVISION_STATUSES = ("current", "superseded", "conflicting", "historical")
37
38
 
@@ -43,6 +44,9 @@ ACTIONS = {
43
44
  "unverified": "abstain",
44
45
  "indexing": "retry",
45
46
  "no_relevant_memory": "say_unknown",
47
+ # A service the evidence depends on failed for this request: retry, and
48
+ # never tell the user the fact is absent.
49
+ "unavailable": "retry",
46
50
  }
47
51
  # A permission question answered by a rule that restricts the act to a group no
48
52
  # memory ties the asker to (``confidence_reason`` "authorization_not_verifiable"):
@@ -127,6 +131,12 @@ def _ready(response: Mapping[str, Any]) -> bool:
127
131
  )
128
132
 
129
133
 
134
+ _ABSTENTION_FLAGS = ("no_match", "abstain_recommended", "decision_abstained")
135
+ # A row's evidence_role for a current rule that speaks to the asked case but is
136
+ # not verified to decide it (see ``should_answer``).
137
+ APPLICABLE_RULE = "applicable_rule"
138
+
139
+
130
140
  def should_answer(
131
141
  response: Optional[Mapping[str, Any]],
132
142
  *,
@@ -151,14 +161,28 @@ def should_answer(
151
161
  recognises ("Where did I live before?"). It overrides one thing: a
152
162
  superseded or historical row then counts as evidence, so a response the
153
163
  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
164
+ versions (a superseded response's ``abstain_recommended`` or
165
+ ``decision_abstained`` concerns the present, so it does not bar this). It
166
+ never overrides ``unverified``, ``no_relevant_memory``, ``indexing``,
167
+ ``conflicting``, ``authorization_not_verifiable`` or ``no_match``.
168
+
169
+ A response marked ``answerable`` that also sets ``no_match``,
170
+ ``abstain_recommended`` or ``decision_abstained`` contradicts itself; the
171
+ server never sends one, and this helper declines it, with that flag as
172
+ the reason, in every mode. Keep each
156
173
  row's ``revision_status`` and ``stated_at`` in what you pass to the model, so
157
174
  it can tell the versions apart.
158
175
 
159
176
  A Reason result for a suggestion or plan (``context_only``) returns action
160
177
  ``use_as_context``: give ``decision.context`` to your model to shape what it
161
178
  suggests, never as an established fact or a permission to act.
179
+
180
+ An ``unverified`` search response whose rows include an
181
+ ``evidence_role: applicable_rule`` row returns reason ``applicable_rule``
182
+ and action ``use_as_context``, with those rules first in
183
+ ``decision.context``: policy that speaks to the asked case but that the
184
+ API has not verified decides it. Let your model apply it (and say so), or
185
+ ask ``reason``, which applies stored rules to the case and cites them.
162
186
  """
163
187
 
164
188
  if not isinstance(response, Mapping) or "answer_status" not in response:
@@ -179,20 +203,39 @@ def should_answer(
179
203
  if response.get("confidence_reason") == AUTHORIZATION_NOT_VERIFIABLE:
180
204
  return declined(AUTHORIZATION_NOT_VERIFIABLE, VERIFY_AUTHORIZATION)
181
205
  grounding = response.get("grounding")
182
- if isinstance(grounding, Mapping) and grounding.get("answerability") == CONTEXT_ONLY:
206
+ if (
207
+ isinstance(grounding, Mapping)
208
+ and grounding.get("answerability") == CONTEXT_ONLY
209
+ ):
183
210
  return declined(CONTEXT_ONLY, USE_AS_CONTEXT)
184
211
  if require_ready and not _ready(response):
185
212
  return declined(INDEX_NOT_READY, "retry")
186
- if history and status in ("answerable", "superseded"):
213
+ flags = [flag for flag in _ABSTENTION_FLAGS if response.get(flag) is True]
214
+ if status == "answerable" and flags:
215
+ # The server never marks a response answerable while it recommends
216
+ # abstaining. An envelope that does contradicts itself, and a
217
+ # contradiction is not an answer, in history mode or not.
218
+ return declined(flags[0], "abstain")
219
+ if history and status in ("answerable", "superseded") and "no_match" not in flags:
220
+ # A superseded response recommends abstaining for the present: every
221
+ # relevant record states a value that no longer holds. That is what a
222
+ # question about the past reads, so those flags do not bar it here.
187
223
  usable = [row for row in rows if _is_history(row, search_row=search_rows)]
188
224
  if usable:
189
225
  others = [row for row in rows if row not in usable]
190
226
  return AnswerDecision(True, "history", "answer", usable, others, cited)
227
+ if status == "unverified":
228
+ rules = [row for row in rows if row.get("evidence_role") == APPLICABLE_RULE]
229
+ if rules:
230
+ # A rule that speaks to the asked case, not verified to decide
231
+ # it: policy for your model to apply, never an established answer
232
+ # or a permission (authorization questions were declined above).
233
+ others = [row for row in rows if row not in rules]
234
+ return AnswerDecision(
235
+ False, APPLICABLE_RULE, USE_AS_CONTEXT, [], [*rules, *others], cited
236
+ )
191
237
  if status != "answerable":
192
238
  return declined(status, ACTIONS[status])
193
- for flag in ("no_match", "abstain_recommended", "decision_abstained"):
194
- if response.get(flag) is True:
195
- return declined(flag, "abstain")
196
239
  usable = [row for row in rows if _is_evidence(row, search_row=search_rows)]
197
240
  if not usable:
198
241
  return declined("no_usable_memories", "abstain")
@@ -363,9 +406,7 @@ def answer_context(
363
406
  """
364
407
 
365
408
  if decision is None:
366
- decision = should_answer(
367
- response, history=history, require_ready=require_ready
368
- )
409
+ decision = should_answer(response, history=history, require_ready=require_ready)
369
410
  sections = []
370
411
  profile = _profile_lines(
371
412
  response.get("profile") if isinstance(response, Mapping) else None
@@ -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.9.0",
96
+ "User-Agent": "hebbrix-python/2.11.0",
97
97
  }
98
98
 
99
99
  if self.api_key:
@@ -44,6 +44,10 @@ AnswerStatus = Literal[
44
44
  "indexing",
45
45
  "no_relevant_memory",
46
46
  ]
47
+ # Whether an answerable response covers its whole scope: final (every
48
+ # memory accepted for the scope was indexed), provisional (answerable from what
49
+ # is indexed now; a pending memory may change it) or none (nothing to act on).
50
+ AnswerFinality = Literal["final", "provisional", "none"]
47
51
  RevisionStatus = Literal["current", "superseded", "conflicting", "historical"]
48
52
 
49
53
 
@@ -113,6 +117,9 @@ class SearchSafetyEnvelope(TypedDict, total=False):
113
117
  abstain_recommended: bool
114
118
  # What this response lets a caller do, in one value.
115
119
  answer_status: AnswerStatus
120
+ # final, provisional or none: act on a final answer only when a decision
121
+ # must cover the whole scope (agents, side effects).
122
+ answer_finality: AnswerFinality
116
123
  indexing: Optional[ScopeIndexing]
117
124
  confidence_reason: Optional[str]
118
125
  # /v1/search/reason: decision_abstained is true exactly when answer is null.
@@ -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.9.0",
1147
+ "User-Agent": "hebbrix-python/2.11.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.9.0
3
+ Version: 2.11.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.9.0**. Start with memory storage and search, or
68
+ The current stable package is **2.11.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.9.0
75
+ pip install hebbrix==2.11.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -150,7 +150,11 @@ versions should count (it never overrides `unverified`, `no_relevant_memory`,
150
150
  the answer is then also held, with action `retry`, until `indexing.status` is
151
151
  `ready` and `indexing.answer_risk` is `none`. A Reason suggestion or plan
152
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
153
+ model suggests, and are never a fact or a permission. An `unverified` search
154
+ whose rows include `evidence_role: "applicable_rule"` returns reason
155
+ `applicable_rule` and action `use_as_context`: the rule speaks to the asked
156
+ case but the API has not verified it decides it; let your model apply it, or
157
+ call `reason()`. `reason()` takes
154
158
  `deadline_ms`; a `timed_out` response is an abstention. `verify_authorization` means the returned rule limits the action
155
159
  to a group the store cannot place the user in: use the rule, and check the
156
160
  permission in your own system.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hebbrix"
7
- version = "2.9.0"
7
+ version = "2.11.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"
@@ -424,3 +424,96 @@ def test_a_suggestion_is_context_to_shape_never_an_answer():
424
424
  assert decision.action == "use_as_context"
425
425
  assert decision.memories == []
426
426
  assert ids(decision.context) == ["camera"]
427
+
428
+
429
+ @pytest.mark.parametrize("flag", ["abstain_recommended", "decision_abstained", "no_match"])
430
+ def test_an_answerable_status_beside_an_abstention_flag_fails_closed_in_every_mode(flag):
431
+ # A contradictory envelope (the server never sends one): answerable, an
432
+ # explicit abstention flag, and only an earlier, unestablished row.
433
+ page = search(
434
+ [
435
+ row(
436
+ "synthetic-history",
437
+ revision_status="historical",
438
+ is_current=False,
439
+ low_confidence=True,
440
+ )
441
+ ],
442
+ indexing={"status": "ready", "answer_risk": "none"},
443
+ **{flag: True},
444
+ )
445
+ for options in ({}, {"history": True}, {"history": True, "require_ready": True}):
446
+ decision = should_answer(page, **options)
447
+ assert not decision
448
+ assert decision.reason == flag
449
+ assert decision.action == "abstain"
450
+ assert decision.memories == []
451
+ assert usable_memories(page, **options) == []
452
+
453
+
454
+ def test_a_superseded_reason_result_still_answers_a_history_question():
455
+ # Reason marks a result superseded only when it abstains for the present
456
+ # (decision_abstained), so that flag is what a question about the past reads.
457
+ page = reason(
458
+ [source("old", is_current=False, revision_status="superseded")],
459
+ answer=None,
460
+ decision_abstained=True,
461
+ answer_status="superseded",
462
+ )
463
+ assert not should_answer(page)
464
+ decision = should_answer(page, history=True)
465
+ assert decision
466
+ assert decision.reason == "history"
467
+ assert ids(decision.memories) == ["old"]
468
+
469
+
470
+ def test_history_never_answers_a_response_that_matched_nothing():
471
+ page = search(
472
+ [row("old", is_current=False, revision_status="superseded", low_confidence=True)],
473
+ answer_status="superseded",
474
+ abstain_recommended=True,
475
+ no_match=True,
476
+ )
477
+ decision = should_answer(page, history=True)
478
+ assert not decision
479
+ assert decision.reason == "superseded"
480
+
481
+
482
+ def test_an_applicable_rule_is_policy_context_never_an_answer():
483
+ rows = [
484
+ row("case", low_confidence=True, evidence_role="related"),
485
+ row("rule", low_confidence=True, evidence_role="applicable_rule"),
486
+ ]
487
+ page = search(
488
+ rows,
489
+ answer_status="unverified",
490
+ abstain_recommended=True,
491
+ confidence_reason="soft_claim_candidate",
492
+ )
493
+ decision = should_answer(page)
494
+ assert not decision
495
+ assert decision.reason == "applicable_rule"
496
+ assert decision.action == "use_as_context"
497
+ assert decision.memories == []
498
+ assert ids(decision.context) == ["rule", "case"]
499
+ assert usable_memories(page) == []
500
+
501
+
502
+ def test_a_rule_never_answers_an_authorization_question():
503
+ rows = [row("rule", low_confidence=True, evidence_role="applicable_rule")]
504
+ page = search(
505
+ rows,
506
+ answer_status="unverified",
507
+ abstain_recommended=True,
508
+ confidence_reason="authorization_not_verifiable",
509
+ )
510
+ decision = should_answer(page)
511
+ assert not decision
512
+ assert decision.reason == "authorization_not_verifiable"
513
+
514
+
515
+ def test_a_failed_service_is_retried_never_reported_absent():
516
+ decision = should_answer(search([], answer_status="unavailable"))
517
+ assert decision.answer is False
518
+ assert decision.reason == "unavailable"
519
+ assert decision.action == "retry"
@@ -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.9.0" in readme
165
+ assert "pip install hebbrix==2.11.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