hebbrix 2.11.0__tar.gz → 2.12.1__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.
- {hebbrix-2.11.0 → hebbrix-2.12.1}/CHANGELOG.md +10 -0
- {hebbrix-2.11.0/hebbrix.egg-info → hebbrix-2.12.1}/PKG-INFO +11 -5
- {hebbrix-2.11.0 → hebbrix-2.12.1}/README.md +10 -4
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/__init__.py +3 -1
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/answers.py +74 -17
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/client.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/models.py +26 -1
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/resources.py +33 -8
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/sync_client.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.1/hebbrix.egg-info}/PKG-INFO +11 -5
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix.egg-info/SOURCES.txt +2 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/pyproject.toml +1 -1
- hebbrix-2.12.1/tests/test_answer_values.py +280 -0
- hebbrix-2.12.1/tests/test_closest_match_envelope.py +521 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_customer_developer_experience.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.1}/LICENSE +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/MANIFEST.in +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/contracts/openapi-routes.json +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/docs/native-experience-operations.md +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/examples/native_reflection_worker.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/_advice.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/chat.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/exceptions.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/execution.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/experience.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/openai_reflection.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/reflection_worker.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix/workflow.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix.egg-info/dependency_links.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix.egg-info/entry_points.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix.egg-info/requires.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/hebbrix.egg-info/top_level.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/setup.cfg +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_advanced_resources.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_advisor_integrity.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_answer_context.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_answer_decision.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_chat_answer_options.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_compact_search_default.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_evidence_loop_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_evidence_safety_boundary.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_execution_permission.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_experience_request.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_experience_workflow.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_followup_helpers.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_memories_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_openai_reflection.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_openapi_parity.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_outcome_advice_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_procedural_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_reflection_worker_cli.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_release_version.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_sync_client.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.1}/tests/test_workflow_route_contract.py +0 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.12.1 — 2026-12-05 (closest matches beside no_match)
|
|
4
|
+
|
|
5
|
+
- Fix: `search_with_proof()` no longer discards a response that matched nothing but returns the closest memories about the same subject (server 1.4.53 and later: `no_match: true`, `answer_status: "no_relevant_memory"`, `confidence_reason: "closest_match_not_an_answer"`, each row `low_confidence: true` with `low_confidence_reason: "closest_match_not_an_answer"`). 2.12.0 rejected it (`rows_not_bound_to_evidence_ids`), dropped the rows, and `should_answer` returned `malformed_response` / `abstain`. The rows are now kept with their labels, and `should_answer` returns reason `no_relevant_memory`, action `say_unknown`, those rows in `decision.context` and never in `memories`. `reason()` applies the same rule to its `sources`.
|
|
6
|
+
- The envelope rule, precisely: a row with `low_confidence: true` is a candidate and may be absent from `evidence_ids`; every other row (including one that does not state `low_confidence`) is evidence and must still be bound to `evidence_ids`. `no_match: true` may carry rows only when every row is a candidate and `evidence_ids` is empty; `no_match: true` beside an evidence row, or a non-empty `evidence_ids`, still fails closed as before. Because `search()` returns `search_with_proof()`'s rows, it now returns those closest matches too (it returned none before), each flagged `low_confidence: true`: filter on `low_confidence` to keep only answers, as the API documents. Nothing else in the validator or in `should_answer` changed.
|
|
7
|
+
|
|
8
|
+
## 2.12.0 — 2026-11-18 (values and value conflicts)
|
|
9
|
+
|
|
10
|
+
- 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.
|
|
11
|
+
- 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`.
|
|
12
|
+
|
|
3
13
|
## 2.11.0 — 2026-11-13 (service failures, answer finality)
|
|
4
14
|
|
|
5
15
|
- `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`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hebbrix
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.12.1
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
8
|
+
__version__ = "2.12.1"
|
|
9
9
|
__author__ = "Hebbrix Team"
|
|
10
10
|
__license__ = "MIT"
|
|
11
11
|
|
|
@@ -38,6 +38,7 @@ from hebbrix.models import (
|
|
|
38
38
|
RevisionStatus,
|
|
39
39
|
ScopeIndexing,
|
|
40
40
|
SearchSafetyEnvelope,
|
|
41
|
+
ValueConflict,
|
|
41
42
|
)
|
|
42
43
|
from hebbrix.sync_client import SyncMemoryClient
|
|
43
44
|
|
|
@@ -64,6 +65,7 @@ __all__ = [
|
|
|
64
65
|
"MemoryStatus",
|
|
65
66
|
"RevisionStatus",
|
|
66
67
|
"ScopeIndexing",
|
|
68
|
+
"ValueConflict",
|
|
67
69
|
"answer_context",
|
|
68
70
|
"should_answer",
|
|
69
71
|
"usable_memories",
|
|
@@ -177,6 +177,12 @@ def should_answer(
|
|
|
177
177
|
``use_as_context``: give ``decision.context`` to your model to shape what it
|
|
178
178
|
suggests, never as an established fact or a permission to act.
|
|
179
179
|
|
|
180
|
+
A response that matched nothing (``no_match``) may carry the closest
|
|
181
|
+
memories about the same subject, each ``low_confidence: true``
|
|
182
|
+
(``confidence_reason`` ``closest_match_not_an_answer``). It returns reason
|
|
183
|
+
``no_relevant_memory`` and action ``say_unknown``, those rows in
|
|
184
|
+
``decision.context``: what is closest, never an answer.
|
|
185
|
+
|
|
180
186
|
An ``unverified`` search response whose rows include an
|
|
181
187
|
``evidence_role: applicable_rule`` row returns reason ``applicable_rule``
|
|
182
188
|
and action ``use_as_context``, with those rules first in
|
|
@@ -337,6 +343,56 @@ def _profile_lines(profile: Any) -> List[str]:
|
|
|
337
343
|
return lines
|
|
338
344
|
|
|
339
345
|
|
|
346
|
+
def _strings(value: Any) -> List[str]:
|
|
347
|
+
"""The non-empty strings of a list field; [] when an older API omits it."""
|
|
348
|
+
|
|
349
|
+
if not isinstance(value, list):
|
|
350
|
+
return []
|
|
351
|
+
return [item for item in value if isinstance(item, str) and item]
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _code(value: Any) -> Optional[str]:
|
|
355
|
+
if isinstance(value, str):
|
|
356
|
+
return value.strip() or None
|
|
357
|
+
if isinstance(value, (int, float)) and not isinstance(value, bool):
|
|
358
|
+
return str(value)
|
|
359
|
+
return None
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def _conflict_lines(row: Mapping[str, Any]) -> List[str]:
|
|
363
|
+
"""One plain line per ``value_conflicts`` entry: the task names a different
|
|
364
|
+
value of the same kind than one the memory requires. A side the server did
|
|
365
|
+
not send is not a reason to drop the warning."""
|
|
366
|
+
|
|
367
|
+
conflicts = row.get("value_conflicts")
|
|
368
|
+
lines: List[str] = []
|
|
369
|
+
for conflict in conflicts if isinstance(conflicts, list) else []:
|
|
370
|
+
if not isinstance(conflict, Mapping):
|
|
371
|
+
continue
|
|
372
|
+
required = _code(conflict.get("value"))
|
|
373
|
+
asked = _code(conflict.get("query_value"))
|
|
374
|
+
if not required and not asked:
|
|
375
|
+
continue
|
|
376
|
+
line = (
|
|
377
|
+
f"Conflicts with the task: task says {asked or 'a different value'}, "
|
|
378
|
+
f"memory requires {required or 'a different value'}."
|
|
379
|
+
)
|
|
380
|
+
if line not in lines:
|
|
381
|
+
lines.append(line)
|
|
382
|
+
return lines
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
def _memory_lines(index: int, row: Mapping[str, Any]) -> List[str]:
|
|
386
|
+
"""A numbered memory: its details, any conflict with the task, its text."""
|
|
387
|
+
|
|
388
|
+
details = _memory_details(row)
|
|
389
|
+
return [
|
|
390
|
+
f"[{index}]" + (f" ({'; '.join(details)})" if details else ""),
|
|
391
|
+
*_conflict_lines(row),
|
|
392
|
+
str(row.get("content") or ""),
|
|
393
|
+
]
|
|
394
|
+
|
|
395
|
+
|
|
340
396
|
def _memory_details(row: Mapping[str, Any]) -> List[str]:
|
|
341
397
|
metadata = row.get("metadata") if isinstance(row.get("metadata"), Mapping) else {}
|
|
342
398
|
details = []
|
|
@@ -351,14 +407,15 @@ def _memory_details(row: Mapping[str, Any]) -> List[str]:
|
|
|
351
407
|
details.append(f"valid until {_day(row.get('valid_until'))}")
|
|
352
408
|
if row.get("subject"):
|
|
353
409
|
details.append(f"about {row['subject']}")
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
410
|
+
values = _strings(row.get("values"))
|
|
411
|
+
# A code the memory gives as a value says what it requires or gives, not
|
|
412
|
+
# what it is about: shown once, as a value.
|
|
413
|
+
given = {value.casefold() for value in values}
|
|
414
|
+
about = [n for n in _strings(row.get("applies_to")) if n.casefold() not in given]
|
|
415
|
+
if about:
|
|
416
|
+
details.append("about: " + ", ".join(about))
|
|
417
|
+
if values:
|
|
418
|
+
details.append("requires or gives: " + ", ".join(values))
|
|
362
419
|
if row.get("revision_status"):
|
|
363
420
|
details.append(str(row["revision_status"]))
|
|
364
421
|
grounding = row.get("grounding")
|
|
@@ -396,9 +453,13 @@ def answer_context(
|
|
|
396
453
|
it is still being projected from recent writes; an unavailable profile is
|
|
397
454
|
said to be unavailable, never left out as if empty. The memories section
|
|
398
455
|
lists only ``decision.memories``, numbered for citation, each with its
|
|
399
|
-
memory type, date,
|
|
400
|
-
|
|
401
|
-
|
|
456
|
+
memory type, date, whose fact it is, what it is about (``applies_to``:
|
|
457
|
+
"about: Acme, order 5531"), the values it requires or gives (``values``:
|
|
458
|
+
"requires or gives: EXP-7"), its revision status and its support. Each
|
|
459
|
+
``value_conflicts`` entry is stated on its own line before the memory's
|
|
460
|
+
text ("Conflicts with the task: task says EXP-9, memory requires EXP-7.").
|
|
461
|
+
When the decision is not to answer, only the profile is returned:
|
|
462
|
+
standing preferences still shape a reply such as
|
|
402
463
|
"I don't know that yet". For a Reason suggestion or plan (``context_only``)
|
|
403
464
|
the memories that should shape it are listed as context, marked as neither
|
|
404
465
|
established facts nor permission to act. Returns "" when there is nothing to
|
|
@@ -421,9 +482,7 @@ def answer_context(
|
|
|
421
482
|
)
|
|
422
483
|
lines = [heading]
|
|
423
484
|
for index, row in enumerate(decision.memories, start=1):
|
|
424
|
-
|
|
425
|
-
lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
|
|
426
|
-
lines.append(str(row.get("content") or ""))
|
|
485
|
+
lines.extend(_memory_lines(index, row))
|
|
427
486
|
sections.append("\n".join(lines))
|
|
428
487
|
elif decision.reason == CONTEXT_ONLY and decision.context:
|
|
429
488
|
lines = [
|
|
@@ -431,8 +490,6 @@ def answer_context(
|
|
|
431
490
|
"facts, and never permission to act):"
|
|
432
491
|
]
|
|
433
492
|
for index, row in enumerate(decision.context, start=1):
|
|
434
|
-
|
|
435
|
-
lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
|
|
436
|
-
lines.append(str(row.get("content") or ""))
|
|
493
|
+
lines.extend(_memory_lines(index, row))
|
|
437
494
|
sections.append("\n".join(lines))
|
|
438
495
|
return "\n\n".join(sections)
|
|
@@ -51,6 +51,17 @@ AnswerFinality = Literal["final", "provisional", "none"]
|
|
|
51
51
|
RevisionStatus = Literal["current", "superseded", "conflicting", "historical"]
|
|
52
52
|
|
|
53
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
|
+
|
|
54
65
|
class MemoryRow(TypedDict, total=False):
|
|
55
66
|
"""One search row or Reason source, with its standing among the versions of
|
|
56
67
|
what it states. Decide what to do with a response in code:
|
|
@@ -75,6 +86,19 @@ class MemoryRow(TypedDict, total=False):
|
|
|
75
86
|
stated_at: Optional[str]
|
|
76
87
|
replaced_values: Optional[List[str]]
|
|
77
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]
|
|
78
102
|
|
|
79
103
|
|
|
80
104
|
class ScopeIndexing(TypedDict, total=False):
|
|
@@ -137,7 +161,8 @@ class SearchSafetyEnvelope(TypedDict, total=False):
|
|
|
137
161
|
degraded: bool
|
|
138
162
|
sdk_safety_reason: str
|
|
139
163
|
proof_context: Dict[str, Any]
|
|
140
|
-
# 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.
|
|
141
166
|
query_entities: List[str]
|
|
142
167
|
# Standing profile facts and preferences (search include_profile=True).
|
|
143
168
|
profile: Dict[str, Any]
|
|
@@ -94,10 +94,28 @@ _SEARCH_SAFETY_FIELDS = frozenset(
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def _is_candidate_row(row: Any) -> bool:
|
|
98
|
+
"""A row the server flags ``low_confidence: true``: a retrieval candidate
|
|
99
|
+
returned as context (a closest match beside ``no_match``, or a candidate on
|
|
100
|
+
an answerable page), never evidence. Only the boolean ``true`` says so; a
|
|
101
|
+
row that does not say it is a candidate is treated as evidence."""
|
|
102
|
+
|
|
103
|
+
return isinstance(row, dict) and row.get("low_confidence") is True
|
|
104
|
+
|
|
105
|
+
|
|
97
106
|
def _canonical_search_envelope(
|
|
98
107
|
response: Dict[str, Any], *, rows_key: str = "results"
|
|
99
108
|
) -> Dict[str, Any]:
|
|
100
|
-
"""Validate API-owned evidence metadata and fail closed on contract drift.
|
|
109
|
+
"""Validate API-owned evidence metadata and fail closed on contract drift.
|
|
110
|
+
|
|
111
|
+
Every evidence row (``low_confidence`` not ``true``) must be bound to
|
|
112
|
+
``evidence_ids``. A candidate row (``low_confidence: true``) may be absent
|
|
113
|
+
from them: servers list candidates on answerable pages but not the closest
|
|
114
|
+
matches they return beside ``no_match``. ``no_match: true`` may carry rows
|
|
115
|
+
only when every row is a candidate and ``evidence_ids`` is empty; those
|
|
116
|
+
rows are kept as context. Any evidence beside ``no_match`` is a
|
|
117
|
+
contradiction and fails closed.
|
|
118
|
+
"""
|
|
101
119
|
|
|
102
120
|
data = dict(response) if isinstance(response, dict) else {}
|
|
103
121
|
raw_rows = data.get(rows_key)
|
|
@@ -141,26 +159,33 @@ def _canonical_search_envelope(
|
|
|
141
159
|
elif not rows and data.get("no_match") is False:
|
|
142
160
|
reason = "no_evidence_rows"
|
|
143
161
|
else:
|
|
144
|
-
|
|
162
|
+
# Candidate rows need no binding; every other row is evidence.
|
|
163
|
+
evidence_row_ids = {
|
|
145
164
|
str(row.get("memory_id") or row.get("id"))
|
|
146
165
|
for row in rows
|
|
147
|
-
if isinstance(row, dict)
|
|
166
|
+
if isinstance(row, dict)
|
|
167
|
+
and (row.get("memory_id") or row.get("id"))
|
|
168
|
+
and not _is_candidate_row(row)
|
|
148
169
|
}
|
|
149
170
|
evidence_ids = {str(value) for value in data.get("evidence_ids", []) if value}
|
|
150
|
-
if not
|
|
171
|
+
if not evidence_row_ids.issubset(evidence_ids):
|
|
151
172
|
reason = "rows_not_bound_to_evidence_ids"
|
|
152
|
-
elif data.get("no_match") and (
|
|
173
|
+
elif data.get("no_match") and (evidence_row_ids or evidence_ids):
|
|
153
174
|
reason = "no_match_contains_evidence"
|
|
154
175
|
|
|
155
176
|
# Degradation and abstention are confidence signals, not proof that the
|
|
156
177
|
# API returned no evidence. Erasing valid, evidence-bound rows here made
|
|
157
178
|
# the SDK disagree with the REST response and converted a safe fallback
|
|
158
179
|
# into a false negative. Fail closed only when the envelope is malformed
|
|
159
|
-
# or the server explicitly reports no match.
|
|
180
|
+
# or the server explicitly reports no match. An explicit no match keeps
|
|
181
|
+
# its candidate rows (the closest memories about the same subject, every
|
|
182
|
+
# one ``low_confidence: true``) as context: nothing answers, and these are
|
|
183
|
+
# what is closest. A malformed envelope keeps nothing.
|
|
160
184
|
if reason or data.get("no_match") is True:
|
|
161
|
-
|
|
185
|
+
context_rows = [] if reason else [row for row in rows if _is_candidate_row(row)]
|
|
186
|
+
data[rows_key] = context_rows
|
|
162
187
|
if rows_key == "results":
|
|
163
|
-
data["total"] =
|
|
188
|
+
data["total"] = len(context_rows)
|
|
164
189
|
data["no_match"] = True
|
|
165
190
|
data["abstain_recommended"] = True
|
|
166
191
|
data["query_confidence"] = 0.0
|
|
@@ -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.
|
|
1147
|
+
"User-Agent": "hebbrix-python/2.12.1",
|
|
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.
|
|
3
|
+
Version: 2.12.1
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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,7 +30,9 @@ 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
|
|
35
|
+
tests/test_closest_match_envelope.py
|
|
34
36
|
tests/test_compact_search_default.py
|
|
35
37
|
tests/test_customer_developer_experience.py
|
|
36
38
|
tests/test_evidence_loop_resource.py
|