hebbrix 2.10.0__tar.gz → 2.12.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 (53) hide show
  1. {hebbrix-2.10.0 → hebbrix-2.12.0}/CHANGELOG.md +10 -0
  2. {hebbrix-2.10.0/hebbrix.egg-info → hebbrix-2.12.0}/PKG-INFO +11 -5
  3. {hebbrix-2.10.0 → hebbrix-2.12.0}/README.md +10 -4
  4. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/__init__.py +5 -1
  5. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/answers.py +77 -21
  6. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/client.py +1 -1
  7. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/models.py +33 -1
  8. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/sync_client.py +1 -1
  9. {hebbrix-2.10.0 → hebbrix-2.12.0/hebbrix.egg-info}/PKG-INFO +11 -5
  10. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix.egg-info/SOURCES.txt +1 -0
  11. {hebbrix-2.10.0 → hebbrix-2.12.0}/pyproject.toml +1 -1
  12. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_answer_decision.py +7 -0
  13. hebbrix-2.12.0/tests/test_answer_values.py +280 -0
  14. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_customer_developer_experience.py +1 -1
  15. {hebbrix-2.10.0 → hebbrix-2.12.0}/LICENSE +0 -0
  16. {hebbrix-2.10.0 → hebbrix-2.12.0}/MANIFEST.in +0 -0
  17. {hebbrix-2.10.0 → hebbrix-2.12.0}/contracts/openapi-routes.json +0 -0
  18. {hebbrix-2.10.0 → hebbrix-2.12.0}/docs/native-experience-operations.md +0 -0
  19. {hebbrix-2.10.0 → hebbrix-2.12.0}/examples/native_reflection_worker.py +0 -0
  20. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/_advice.py +0 -0
  21. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/chat.py +0 -0
  22. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/exceptions.py +0 -0
  23. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/execution.py +0 -0
  24. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/experience.py +0 -0
  25. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/openai_reflection.py +0 -0
  26. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/reflection_worker.py +0 -0
  27. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/resources.py +0 -0
  28. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix/workflow.py +0 -0
  29. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix.egg-info/dependency_links.txt +0 -0
  30. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix.egg-info/entry_points.txt +0 -0
  31. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix.egg-info/requires.txt +0 -0
  32. {hebbrix-2.10.0 → hebbrix-2.12.0}/hebbrix.egg-info/top_level.txt +0 -0
  33. {hebbrix-2.10.0 → hebbrix-2.12.0}/setup.cfg +0 -0
  34. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_advanced_resources.py +0 -0
  35. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_advisor_integrity.py +0 -0
  36. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_answer_context.py +0 -0
  37. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_chat_answer_options.py +0 -0
  38. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_compact_search_default.py +0 -0
  39. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_evidence_loop_resource.py +0 -0
  40. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_evidence_safety_boundary.py +0 -0
  41. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_execution_permission.py +0 -0
  42. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_experience_request.py +0 -0
  43. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_experience_workflow.py +0 -0
  44. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_followup_helpers.py +0 -0
  45. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_memories_resource.py +0 -0
  46. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_openai_reflection.py +0 -0
  47. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_openapi_parity.py +0 -0
  48. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_outcome_advice_resource.py +0 -0
  49. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_procedural_resource.py +0 -0
  50. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_reflection_worker_cli.py +0 -0
  51. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_release_version.py +0 -0
  52. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_sync_client.py +0 -0
  53. {hebbrix-2.10.0 → hebbrix-2.12.0}/tests/test_workflow_route_contract.py +0 -0
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.12.0 — 2026-11-18 (values and value conflicts)
4
+
5
+ - Types: search rows (`MemoryRow`) gain `values` (server 1.4.45) and `value_conflicts` (server 1.4.46), and now also type `applies_to` and `entity_match`. `values` lists the codes a memory gives as values: a field's value (`customs_form='EXP-7'`) or a code a rule requires ("need customs form EXP-7"); a value never scopes a memory away from the task. `value_conflicts` lists `{"value", "query_value"}` objects (new type `ValueConflict`), set when the query or task names a different value of the same kind than one the memory requires. Both are optional: rows from older servers omit them, and unknown keys are kept as before.
6
+ - Behaviour change: `answer_context` renders `applies_to` as what the memory is about (`about: Acme, order 5531`) instead of `names …`, so a rule's required code no longer reads as a name; it renders `values` as `requires or gives: EXP-7` (a code listed in both appears once, as a value), and states each value conflict on its own line before the memory's text: `Conflicts with the task: task says EXP-9, memory requires EXP-7.` A row without `values` or `value_conflicts` renders exactly as in 2.11.0 apart from `about:` replacing `names`.
7
+
8
+ ## 2.11.0 — 2026-11-13 (service failures, answer finality)
9
+
10
+ - `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`.
11
+ - 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`.
12
+
3
13
  ## 2.10.0 — 2026-11-12 (applicable rules, consistent abstention flags)
4
14
 
5
15
  - 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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hebbrix
3
- Version: 2.10.0
3
+ Version: 2.12.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.10.0**. Start with memory storage and search, or
68
+ The current stable package is **2.12.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.10.0
75
+ pip install hebbrix==2.12.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -132,7 +132,8 @@ if not decision:
132
132
  # decision.context holds the rows, never to answer from.
133
133
  return my_reply_for(decision.action)
134
134
  # The user's standing profile plus the rows you may answer from, each with its
135
- # date, memory type, subject and support.
135
+ # date, memory type, subject, what it is about, the values it requires or
136
+ # gives, any conflict with the task, and its support.
136
137
  return await my_llm(question, context=answer_context(response, decision))
137
138
  ```
138
139
 
@@ -142,7 +143,12 @@ short" reach your model even when they did not rank for this message. It lists
142
143
  each fact with its category, confidence and date, the topics to avoid, the
143
144
  profile's `scope`, and says so when the profile is still being updated
144
145
  (`projection.status: "pending"`) or could not be read, so a missing preference
145
- is not taken as absent. When the decision is not to answer it returns the
146
+ is not taken as absent. Each row says what the memory is about (`applies_to`:
147
+ `about: Acme, order 5531`) and the codes it requires or gives (`values`:
148
+ `requires or gives: EXP-7`). When the task names a different value of the same
149
+ kind than one the memory requires (`value_conflicts`), a line before the
150
+ memory's text says so: `Conflicts with the task: task says EXP-9, memory
151
+ requires EXP-7.` When the decision is not to answer it returns the
146
152
  profile alone. `usable_memories(response)` returns just the rows. Pass
147
153
  `history=True` for a question about the past, when superseded and historical
148
154
  versions should count (it never overrides `unverified`, `no_relevant_memory`,
@@ -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.10.0**. Start with memory storage and search, or
5
+ The current stable package is **2.12.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.10.0
12
+ pip install hebbrix==2.12.0
13
13
  ```
14
14
 
15
15
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -69,7 +69,8 @@ if not decision:
69
69
  # decision.context holds the rows, never to answer from.
70
70
  return my_reply_for(decision.action)
71
71
  # The user's standing profile plus the rows you may answer from, each with its
72
- # date, memory type, subject and support.
72
+ # date, memory type, subject, what it is about, the values it requires or
73
+ # gives, any conflict with the task, and its support.
73
74
  return await my_llm(question, context=answer_context(response, decision))
74
75
  ```
75
76
 
@@ -79,7 +80,12 @@ short" reach your model even when they did not rank for this message. It lists
79
80
  each fact with its category, confidence and date, the topics to avoid, the
80
81
  profile's `scope`, and says so when the profile is still being updated
81
82
  (`projection.status: "pending"`) or could not be read, so a missing preference
82
- is not taken as absent. When the decision is not to answer it returns the
83
+ is not taken as absent. Each row says what the memory is about (`applies_to`:
84
+ `about: Acme, order 5531`) and the codes it requires or gives (`values`:
85
+ `requires or gives: EXP-7`). When the task names a different value of the same
86
+ kind than one the memory requires (`value_conflicts`), a line before the
87
+ memory's text says so: `Conflicts with the task: task says EXP-9, memory
88
+ requires EXP-7.` When the decision is not to answer it returns the
83
89
  profile alone. `usable_memories(response)` returns just the rows. Pass
84
90
  `history=True` for a question about the past, when superseded and historical
85
91
  versions should count (it never overrides `unverified`, `no_relevant_memory`,
@@ -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.10.0"
8
+ __version__ = "2.12.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,
@@ -37,6 +38,7 @@ from hebbrix.models import (
37
38
  RevisionStatus,
38
39
  ScopeIndexing,
39
40
  SearchSafetyEnvelope,
41
+ ValueConflict,
40
42
  )
41
43
  from hebbrix.sync_client import SyncMemoryClient
42
44
 
@@ -57,11 +59,13 @@ __all__ = [
57
59
  "SearchSafetyEnvelope",
58
60
  "ActionAdviceReceipt",
59
61
  "AnswerDecision",
62
+ "AnswerFinality",
60
63
  "AnswerStatus",
61
64
  "MemoryRow",
62
65
  "MemoryStatus",
63
66
  "RevisionStatus",
64
67
  "ScopeIndexing",
68
+ "ValueConflict",
65
69
  "answer_context",
66
70
  "should_answer",
67
71
  "usable_memories",
@@ -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"):
@@ -199,7 +203,10 @@ def should_answer(
199
203
  if response.get("confidence_reason") == AUTHORIZATION_NOT_VERIFIABLE:
200
204
  return declined(AUTHORIZATION_NOT_VERIFIABLE, VERIFY_AUTHORIZATION)
201
205
  grounding = response.get("grounding")
202
- if isinstance(grounding, Mapping) and grounding.get("answerability") == CONTEXT_ONLY:
206
+ if (
207
+ isinstance(grounding, Mapping)
208
+ and grounding.get("answerability") == CONTEXT_ONLY
209
+ ):
203
210
  return declined(CONTEXT_ONLY, USE_AS_CONTEXT)
204
211
  if require_ready and not _ready(response):
205
212
  return declined(INDEX_NOT_READY, "retry")
@@ -330,6 +337,56 @@ def _profile_lines(profile: Any) -> List[str]:
330
337
  return lines
331
338
 
332
339
 
340
+ def _strings(value: Any) -> List[str]:
341
+ """The non-empty strings of a list field; [] when an older API omits it."""
342
+
343
+ if not isinstance(value, list):
344
+ return []
345
+ return [item for item in value if isinstance(item, str) and item]
346
+
347
+
348
+ def _code(value: Any) -> Optional[str]:
349
+ if isinstance(value, str):
350
+ return value.strip() or None
351
+ if isinstance(value, (int, float)) and not isinstance(value, bool):
352
+ return str(value)
353
+ return None
354
+
355
+
356
+ def _conflict_lines(row: Mapping[str, Any]) -> List[str]:
357
+ """One plain line per ``value_conflicts`` entry: the task names a different
358
+ value of the same kind than one the memory requires. A side the server did
359
+ not send is not a reason to drop the warning."""
360
+
361
+ conflicts = row.get("value_conflicts")
362
+ lines: List[str] = []
363
+ for conflict in conflicts if isinstance(conflicts, list) else []:
364
+ if not isinstance(conflict, Mapping):
365
+ continue
366
+ required = _code(conflict.get("value"))
367
+ asked = _code(conflict.get("query_value"))
368
+ if not required and not asked:
369
+ continue
370
+ line = (
371
+ f"Conflicts with the task: task says {asked or 'a different value'}, "
372
+ f"memory requires {required or 'a different value'}."
373
+ )
374
+ if line not in lines:
375
+ lines.append(line)
376
+ return lines
377
+
378
+
379
+ def _memory_lines(index: int, row: Mapping[str, Any]) -> List[str]:
380
+ """A numbered memory: its details, any conflict with the task, its text."""
381
+
382
+ details = _memory_details(row)
383
+ return [
384
+ f"[{index}]" + (f" ({'; '.join(details)})" if details else ""),
385
+ *_conflict_lines(row),
386
+ str(row.get("content") or ""),
387
+ ]
388
+
389
+
333
390
  def _memory_details(row: Mapping[str, Any]) -> List[str]:
334
391
  metadata = row.get("metadata") if isinstance(row.get("metadata"), Mapping) else {}
335
392
  details = []
@@ -344,14 +401,15 @@ def _memory_details(row: Mapping[str, Any]) -> List[str]:
344
401
  details.append(f"valid until {_day(row.get('valid_until'))}")
345
402
  if row.get("subject"):
346
403
  details.append(f"about {row['subject']}")
347
- applies_to = row.get("applies_to")
348
- names = (
349
- [n for n in applies_to if isinstance(n, str) and n]
350
- if isinstance(applies_to, list)
351
- else []
352
- )
353
- if names:
354
- details.append("names " + ", ".join(names))
404
+ values = _strings(row.get("values"))
405
+ # A code the memory gives as a value says what it requires or gives, not
406
+ # what it is about: shown once, as a value.
407
+ given = {value.casefold() for value in values}
408
+ about = [n for n in _strings(row.get("applies_to")) if n.casefold() not in given]
409
+ if about:
410
+ details.append("about: " + ", ".join(about))
411
+ if values:
412
+ details.append("requires or gives: " + ", ".join(values))
355
413
  if row.get("revision_status"):
356
414
  details.append(str(row["revision_status"]))
357
415
  grounding = row.get("grounding")
@@ -389,9 +447,13 @@ def answer_context(
389
447
  it is still being projected from recent writes; an unavailable profile is
390
448
  said to be unavailable, never left out as if empty. The memories section
391
449
  lists only ``decision.memories``, numbered for citation, each with its
392
- memory type, date, whom it is about, the names it states, its revision
393
- status and its support. When the decision is not to answer, only the
394
- profile is returned: standing preferences still shape a reply such as
450
+ memory type, date, whose fact it is, what it is about (``applies_to``:
451
+ "about: Acme, order 5531"), the values it requires or gives (``values``:
452
+ "requires or gives: EXP-7"), its revision status and its support. Each
453
+ ``value_conflicts`` entry is stated on its own line before the memory's
454
+ text ("Conflicts with the task: task says EXP-9, memory requires EXP-7.").
455
+ When the decision is not to answer, only the profile is returned:
456
+ standing preferences still shape a reply such as
395
457
  "I don't know that yet". For a Reason suggestion or plan (``context_only``)
396
458
  the memories that should shape it are listed as context, marked as neither
397
459
  established facts nor permission to act. Returns "" when there is nothing to
@@ -399,9 +461,7 @@ def answer_context(
399
461
  """
400
462
 
401
463
  if decision is None:
402
- decision = should_answer(
403
- response, history=history, require_ready=require_ready
404
- )
464
+ decision = should_answer(response, history=history, require_ready=require_ready)
405
465
  sections = []
406
466
  profile = _profile_lines(
407
467
  response.get("profile") if isinstance(response, Mapping) else None
@@ -416,9 +476,7 @@ def answer_context(
416
476
  )
417
477
  lines = [heading]
418
478
  for index, row in enumerate(decision.memories, start=1):
419
- details = _memory_details(row)
420
- lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
421
- lines.append(str(row.get("content") or ""))
479
+ lines.extend(_memory_lines(index, row))
422
480
  sections.append("\n".join(lines))
423
481
  elif decision.reason == CONTEXT_ONLY and decision.context:
424
482
  lines = [
@@ -426,8 +484,6 @@ def answer_context(
426
484
  "facts, and never permission to act):"
427
485
  ]
428
486
  for index, row in enumerate(decision.context, start=1):
429
- details = _memory_details(row)
430
- lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
431
- lines.append(str(row.get("content") or ""))
487
+ lines.extend(_memory_lines(index, row))
432
488
  sections.append("\n".join(lines))
433
489
  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.10.0",
96
+ "User-Agent": "hebbrix-python/2.12.0",
97
97
  }
98
98
 
99
99
  if self.api_key:
@@ -44,9 +44,24 @@ 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
 
54
+ class ValueConflict(TypedDict, total=False):
55
+ """A value a memory requires where the query or task names a different
56
+ value of the same kind (server 1.4.46): the rule requires customs form
57
+ ``EXP-7`` and the task says ``EXP-9``."""
58
+
59
+ # The value the memory requires.
60
+ value: str
61
+ # The value of the same kind the query or task names instead.
62
+ query_value: str
63
+
64
+
50
65
  class MemoryRow(TypedDict, total=False):
51
66
  """One search row or Reason source, with its standing among the versions of
52
67
  what it states. Decide what to do with a response in code:
@@ -71,6 +86,19 @@ class MemoryRow(TypedDict, total=False):
71
86
  stated_at: Optional[str]
72
87
  replaced_values: Optional[List[str]]
73
88
  currency_basis: Optional[Literal["revision", "later_memory"]]
89
+ # What the memory is about: the names and record identifiers it names
90
+ # (customers, people, orders, tickets, campaigns).
91
+ applies_to: List[str]
92
+ # match, partial, mismatch, unscoped, or not_applicable when the query
93
+ # names no entity.
94
+ entity_match: Optional[str]
95
+ # Codes the memory gives as values (server 1.4.45): a field's value
96
+ # (customs_form='EXP-7') or a code a rule requires ("need customs form
97
+ # EXP-7"). A value never scopes a memory away from the task.
98
+ values: List[str]
99
+ # Each value the memory requires where the query or task names a different
100
+ # value of the same kind (server 1.4.46).
101
+ value_conflicts: List[ValueConflict]
74
102
 
75
103
 
76
104
  class ScopeIndexing(TypedDict, total=False):
@@ -113,6 +141,9 @@ class SearchSafetyEnvelope(TypedDict, total=False):
113
141
  abstain_recommended: bool
114
142
  # What this response lets a caller do, in one value.
115
143
  answer_status: AnswerStatus
144
+ # final, provisional or none: act on a final answer only when a decision
145
+ # must cover the whole scope (agents, side effects).
146
+ answer_finality: AnswerFinality
116
147
  indexing: Optional[ScopeIndexing]
117
148
  confidence_reason: Optional[str]
118
149
  # /v1/search/reason: decision_abstained is true exactly when answer is null.
@@ -130,7 +161,8 @@ class SearchSafetyEnvelope(TypedDict, total=False):
130
161
  degraded: bool
131
162
  sdk_safety_reason: str
132
163
  proof_context: Dict[str, Any]
133
- # Entities the query names; each row carries applies_to/entity_match.
164
+ # Entities the query names; each row carries applies_to/entity_match,
165
+ # and values/value_conflicts on servers that send them.
134
166
  query_entities: List[str]
135
167
  # Standing profile facts and preferences (search include_profile=True).
136
168
  profile: Dict[str, Any]
@@ -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.10.0",
1147
+ "User-Agent": "hebbrix-python/2.12.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.10.0
3
+ Version: 2.12.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.10.0**. Start with memory storage and search, or
68
+ The current stable package is **2.12.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.10.0
75
+ pip install hebbrix==2.12.0
76
76
  ```
77
77
 
78
78
  Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
@@ -132,7 +132,8 @@ if not decision:
132
132
  # decision.context holds the rows, never to answer from.
133
133
  return my_reply_for(decision.action)
134
134
  # The user's standing profile plus the rows you may answer from, each with its
135
- # date, memory type, subject and support.
135
+ # date, memory type, subject, what it is about, the values it requires or
136
+ # gives, any conflict with the task, and its support.
136
137
  return await my_llm(question, context=answer_context(response, decision))
137
138
  ```
138
139
 
@@ -142,7 +143,12 @@ short" reach your model even when they did not rank for this message. It lists
142
143
  each fact with its category, confidence and date, the topics to avoid, the
143
144
  profile's `scope`, and says so when the profile is still being updated
144
145
  (`projection.status: "pending"`) or could not be read, so a missing preference
145
- is not taken as absent. When the decision is not to answer it returns the
146
+ is not taken as absent. Each row says what the memory is about (`applies_to`:
147
+ `about: Acme, order 5531`) and the codes it requires or gives (`values`:
148
+ `requires or gives: EXP-7`). When the task names a different value of the same
149
+ kind than one the memory requires (`value_conflicts`), a line before the
150
+ memory's text says so: `Conflicts with the task: task says EXP-9, memory
151
+ requires EXP-7.` When the decision is not to answer it returns the
146
152
  profile alone. `usable_memories(response)` returns just the rows. Pass
147
153
  `history=True` for a question about the past, when superseded and historical
148
154
  versions should count (it never overrides `unverified`, `no_relevant_memory`,
@@ -30,6 +30,7 @@ tests/test_advanced_resources.py
30
30
  tests/test_advisor_integrity.py
31
31
  tests/test_answer_context.py
32
32
  tests/test_answer_decision.py
33
+ tests/test_answer_values.py
33
34
  tests/test_chat_answer_options.py
34
35
  tests/test_compact_search_default.py
35
36
  tests/test_customer_developer_experience.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hebbrix"
7
- version = "2.10.0"
7
+ version = "2.12.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"
@@ -510,3 +510,10 @@ def test_a_rule_never_answers_an_authorization_question():
510
510
  decision = should_answer(page)
511
511
  assert not decision
512
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"
@@ -0,0 +1,280 @@
1
+ """Search rows' values and value conflicts reach your model as what they are.
2
+
3
+ SDK 2.11.0 rendered ``applies_to`` as "names ...", so a rule's required code
4
+ read as a name ("names EXP-7"), and it never showed ``values`` (server 1.4.45)
5
+ or ``value_conflicts`` (server 1.4.46). ``applies_to`` is what a memory is
6
+ about; ``values`` is what it requires or gives; a value conflict means the task
7
+ names a different value of the same kind than one the memory requires.
8
+ """
9
+
10
+ from unittest.mock import AsyncMock, Mock
11
+
12
+ import pytest
13
+
14
+ import hebbrix
15
+ from hebbrix import MemoryRow, ValueConflict, answer_context, should_answer
16
+ from hebbrix.resources import SearchResource
17
+ from hebbrix.sync_client import SyncSearchResource
18
+
19
+ HEADING = "Memories to answer from (current, supported for this message):"
20
+
21
+
22
+ def row(memory_id, content, **fields):
23
+ return {
24
+ "memory_id": memory_id,
25
+ "id": memory_id,
26
+ "content": content,
27
+ "score": 0.9,
28
+ "low_confidence": False,
29
+ "is_current": True,
30
+ "revision_status": "current",
31
+ **fields,
32
+ }
33
+
34
+
35
+ def search(rows, **fields):
36
+ return {
37
+ "query": "q",
38
+ "results": rows,
39
+ "total": len(rows),
40
+ "no_match": False,
41
+ "abstain_recommended": False,
42
+ "answer_status": "answerable",
43
+ "query_confidence": 0.9,
44
+ "grounding": {"status": "supported"},
45
+ "evidence_ids": [r["memory_id"] for r in rows],
46
+ "safety_contract_version": "search-safety-v1",
47
+ **fields,
48
+ }
49
+
50
+
51
+ def rule(**fields):
52
+ return row(
53
+ "r1",
54
+ "Orders for Acme need customs form EXP-7.",
55
+ stated_at="2026-11-02T09:00:00Z",
56
+ metadata={"memory_type": "rule"},
57
+ grounding={"status": "supported", "support_basis": "verified_span"},
58
+ **fields,
59
+ )
60
+
61
+
62
+ def lines(rows, **fields):
63
+ return answer_context(search(rows, **fields)).splitlines()
64
+
65
+
66
+ # Presence: the fields reach the caller untouched.
67
+
68
+
69
+ @pytest.mark.asyncio
70
+ async def test_both_clients_keep_values_and_conflicts_on_each_row():
71
+ conflict = {"value": "EXP-7", "query_value": "EXP-9", "kind": "customs_form"}
72
+ envelope = search(
73
+ [
74
+ rule(
75
+ applies_to=["Acme"],
76
+ entity_match="match",
77
+ values=["EXP-7"],
78
+ value_conflicts=[conflict],
79
+ )
80
+ ]
81
+ )
82
+ sync, asynchronous = Mock(), Mock()
83
+ sync.post.return_value = dict(envelope)
84
+ asynchronous.post = AsyncMock(return_value=dict(envelope))
85
+ first = SyncSearchResource(sync).search_with_proof("q", user_id="u")
86
+ second = await SearchResource(asynchronous).search_with_proof("q", user_id="u")
87
+ for response in (first, second):
88
+ (kept,) = response["results"]
89
+ assert kept["applies_to"] == ["Acme"] and kept["entity_match"] == "match"
90
+ assert kept["values"] == ["EXP-7"]
91
+ # An unknown key on a conflict is kept, not stripped.
92
+ assert kept["value_conflicts"] == [conflict]
93
+ assert "sdk_safety_reason" not in response
94
+
95
+
96
+ def test_row_types_name_the_entity_and_value_fields_and_require_none():
97
+ fields = MemoryRow.__annotations__
98
+ for name in ("applies_to", "entity_match", "values", "value_conflicts"):
99
+ assert name in fields
100
+ assert MemoryRow.__total__ is False
101
+ assert set(ValueConflict.__annotations__) == {"value", "query_value"}
102
+ assert ValueConflict.__total__ is False
103
+ assert "ValueConflict" in hebbrix.__all__
104
+
105
+
106
+ # Rendering.
107
+
108
+
109
+ def test_applies_to_reads_as_what_the_memory_is_about():
110
+ text = lines([rule(applies_to=["Acme", "order 5531"])])
111
+ assert text == [
112
+ HEADING,
113
+ "[1] (rule; stated 2026-11-02; about: Acme, order 5531; current; "
114
+ "support verified_span)",
115
+ "Orders for Acme need customs form EXP-7.",
116
+ ]
117
+ assert not any("names" in line for line in text)
118
+
119
+
120
+ def test_a_required_code_reads_as_a_value_not_a_name():
121
+ text = lines([rule(applies_to=["Acme"], values=["EXP-7"])])
122
+ assert text == [
123
+ HEADING,
124
+ "[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7; "
125
+ "current; support verified_span)",
126
+ "Orders for Acme need customs form EXP-7.",
127
+ ]
128
+
129
+
130
+ def test_a_code_listed_in_applies_to_and_values_reads_once_as_a_value():
131
+ text = lines([rule(applies_to=["Acme", "exp-7"], values=["EXP-7", "MGR-2"])])
132
+ assert text[1] == (
133
+ "[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7, "
134
+ "MGR-2; current; support verified_span)"
135
+ )
136
+
137
+
138
+ def test_values_without_applies_to_still_render():
139
+ text = lines([rule(values=["EXP-7"])])
140
+ assert text[1] == (
141
+ "[1] (rule; stated 2026-11-02; requires or gives: EXP-7; current; "
142
+ "support verified_span)"
143
+ )
144
+
145
+
146
+ def test_a_value_conflict_is_stated_before_the_memory_text():
147
+ conflicted = rule(
148
+ applies_to=["Acme"],
149
+ values=["EXP-7"],
150
+ value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}],
151
+ )
152
+ assert lines([conflicted]) == [
153
+ HEADING,
154
+ "[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7; "
155
+ "current; support verified_span)",
156
+ "Conflicts with the task: task says EXP-9, memory requires EXP-7.",
157
+ "Orders for Acme need customs form EXP-7.",
158
+ ]
159
+
160
+
161
+ def test_each_conflict_gets_one_line_and_repeats_collapse():
162
+ conflicted = rule(
163
+ values=["EXP-7", "MGR-2"],
164
+ value_conflicts=[
165
+ {"value": "EXP-7", "query_value": "EXP-9"},
166
+ {"value": "MGR-2", "query_value": "MGR-5"},
167
+ {"value": "EXP-7", "query_value": "EXP-9"},
168
+ ],
169
+ )
170
+ text = lines([conflicted])
171
+ assert text[2:] == [
172
+ "Conflicts with the task: task says EXP-9, memory requires EXP-7.",
173
+ "Conflicts with the task: task says MGR-5, memory requires MGR-2.",
174
+ "Orders for Acme need customs form EXP-7.",
175
+ ]
176
+
177
+
178
+ def test_conflicts_are_listed_under_their_own_memory():
179
+ plain = row("m2", "Acme ships from Rotterdam.", applies_to=["Acme"])
180
+ conflicted = rule(value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}])
181
+ text = lines([plain, conflicted])
182
+ assert text == [
183
+ HEADING,
184
+ "[1] (about: Acme; current)",
185
+ "Acme ships from Rotterdam.",
186
+ "[2] (rule; stated 2026-11-02; current; support verified_span)",
187
+ "Conflicts with the task: task says EXP-9, memory requires EXP-7.",
188
+ "Orders for Acme need customs form EXP-7.",
189
+ ]
190
+
191
+
192
+ def test_a_conflict_missing_one_side_still_warns():
193
+ text = lines(
194
+ [
195
+ rule(
196
+ value_conflicts=[
197
+ {"value": "EXP-7"},
198
+ {"query_value": "EXP-9", "value": None},
199
+ {"value": 7, "query_value": 9},
200
+ ]
201
+ )
202
+ ]
203
+ )
204
+ assert text[2:5] == [
205
+ "Conflicts with the task: task says a different value, memory requires "
206
+ "EXP-7.",
207
+ "Conflicts with the task: task says EXP-9, memory requires a different "
208
+ "value.",
209
+ "Conflicts with the task: task says 9, memory requires 7.",
210
+ ]
211
+
212
+
213
+ def test_a_suggestion_renders_values_and_conflicts_as_context():
214
+ page = {
215
+ "answer": None,
216
+ "sources": [
217
+ {
218
+ "memory_id": "r1",
219
+ "content": "Orders for Acme need customs form EXP-7.",
220
+ "applies_to": ["Acme"],
221
+ "values": ["EXP-7"],
222
+ "value_conflicts": [{"value": "EXP-7", "query_value": "EXP-9"}],
223
+ }
224
+ ],
225
+ "decision_abstained": True,
226
+ "answer_status": "unverified",
227
+ "grounding": {"status": "supported", "answerability": "context_only"},
228
+ }
229
+ assert answer_context(page).splitlines()[1:] == [
230
+ "[1] (about: Acme; requires or gives: EXP-7)",
231
+ "Conflicts with the task: task says EXP-9, memory requires EXP-7.",
232
+ "Orders for Acme need customs form EXP-7.",
233
+ ]
234
+
235
+
236
+ # Absence and malformed input: older servers and unknown shapes.
237
+
238
+
239
+ def test_rows_without_the_new_fields_render_as_before():
240
+ old = rule(applies_to=[])
241
+ assert lines([old]) == [
242
+ HEADING,
243
+ "[1] (rule; stated 2026-11-02; current; support verified_span)",
244
+ "Orders for Acme need customs form EXP-7.",
245
+ ]
246
+ assert lines([old]) == lines([rule()])
247
+
248
+
249
+ @pytest.mark.parametrize(
250
+ "fields",
251
+ [
252
+ {"values": None, "value_conflicts": None, "applies_to": None},
253
+ {"values": "EXP-7", "value_conflicts": {"value": "EXP-7"}},
254
+ {"values": [None, "", 7, {"v": 1}], "applies_to": [None, "", 3]},
255
+ {"value_conflicts": [None, "EXP-7", [], {}, {"unknown": "EXP-9"}]},
256
+ {"value_conflicts": [{"value": " ", "query_value": True}]},
257
+ ],
258
+ )
259
+ def test_malformed_fields_add_nothing(fields):
260
+ assert lines([rule(**fields)]) == lines([rule()])
261
+
262
+
263
+ def test_values_and_conflicts_do_not_change_the_decision():
264
+ plain = search([rule(applies_to=["Acme"])])
265
+ annotated = search(
266
+ [
267
+ rule(
268
+ applies_to=["Acme"],
269
+ values=["EXP-7"],
270
+ value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}],
271
+ )
272
+ ]
273
+ )
274
+ before, after = should_answer(plain), should_answer(annotated)
275
+ assert (before.answer, before.reason, before.action) == (
276
+ after.answer,
277
+ after.reason,
278
+ after.action,
279
+ )
280
+ assert [r["memory_id"] for r in after.memories] == ["r1"]
@@ -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.10.0" in readme
165
+ assert "pip install hebbrix==2.12.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