amfs-adapter-postgres 0.2.33__tar.gz → 0.2.35__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 (26) hide show
  1. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/PKG-INFO +2 -2
  2. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/pyproject.toml +2 -2
  3. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/adapter.py +28 -1
  4. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/.gitignore +0 -0
  5. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/__init__.py +0 -0
  6. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/_fts.py +0 -0
  7. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/async_adapter.py +0 -0
  8. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/knn.py +0 -0
  9. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/001_initial.sql +0 -0
  10. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/002_artifact_refs.sql +0 -0
  11. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/002_search_indexes.sql +0 -0
  12. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/003_knowledge_graph.sql +0 -0
  13. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/004_agent_groups.sql +0 -0
  14. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/005_configurable_embedding_dim.sql +0 -0
  15. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/006_is_artifact.sql +0 -0
  16. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/006_outcome_confidence_semantics.sql +0 -0
  17. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/007_outcome_propagation_row_copy.sql +0 -0
  18. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/008_outcome_evidence.sql +0 -0
  19. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/009_action_priors.sql +0 -0
  20. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/010_local_evidence.sql +0 -0
  21. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/migrations/011_outcome_task_text.sql +0 -0
  22. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/retention.py +0 -0
  23. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/schema.sql +0 -0
  24. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/tenant_context.py +0 -0
  25. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/tenant_gucs.py +0 -0
  26. {amfs_adapter_postgres-0.2.33 → amfs_adapter_postgres-0.2.35}/src/amfs_postgres/trace_partitions.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: amfs-adapter-postgres
3
- Version: 0.2.33
3
+ Version: 0.2.35
4
4
  Summary: AMFS Postgres adapter with back-propagation triggers
5
5
  License-Expression: Apache-2.0
6
6
  Requires-Python: >=3.11
7
- Requires-Dist: amfs-core>=0.3.44
7
+ Requires-Dist: amfs-core>=0.3.45
8
8
  Requires-Dist: psycopg-pool>=3.1
9
9
  Requires-Dist: psycopg[binary]<4,>=3.1
@@ -1,13 +1,13 @@
1
1
  [project]
2
2
  name = "amfs-adapter-postgres"
3
- version = "0.2.33"
3
+ version = "0.2.35"
4
4
  description = "AMFS Postgres adapter with back-propagation triggers"
5
5
  requires-python = ">=3.11"
6
6
  license = "Apache-2.0"
7
7
  dependencies = [
8
8
  # 0.3.14 adds the capture fields this adapter now persists and selects back,
9
9
  # tool_calls among them.
10
- "amfs-core>=0.3.44",
10
+ "amfs-core>=0.3.45",
11
11
  "psycopg[binary]>=3.1,<4",
12
12
  "psycopg-pool>=3.1",
13
13
  ]
@@ -701,6 +701,33 @@ def _jsonb(raw: Any, default: Any) -> Any:
701
701
  return raw
702
702
 
703
703
 
704
+ def _jsonb_safe(value: Any) -> Any:
705
+ """``value`` with the characters Postgres ``jsonb`` rejects removed from its strings.
706
+
707
+ ``jsonb`` is UTF-8 text: it has no representation for ``\\u0000`` and
708
+ rejects lone UTF-16 surrogates, and ``json.dumps`` happily emits both as
709
+ escapes. Either arrives in a compiled digest through an entry whose value
710
+ carried them (LLM output, pasted logs) and fails the upsert with
711
+ ``UntranslatableCharacter`` after the whole compile has been done. NULs are
712
+ dropped and lone surrogates replaced with U+FFFD; everything else is kept.
713
+ """
714
+ if isinstance(value, str):
715
+ if "\x00" in value:
716
+ value = value.replace("\x00", "")
717
+ try:
718
+ value.encode("utf-8")
719
+ except UnicodeEncodeError:
720
+ value = "".join(
721
+ "\ufffd" if "\ud800" <= ch <= "\udfff" else ch for ch in value
722
+ )
723
+ return value
724
+ if isinstance(value, dict):
725
+ return {_jsonb_safe(k): _jsonb_safe(v) for k, v in value.items()}
726
+ if isinstance(value, (list, tuple)):
727
+ return [_jsonb_safe(v) for v in value]
728
+ return value
729
+
730
+
704
731
  def _inherit_from_row(entry: MemoryEntry, row: Any) -> MemoryEntry:
705
732
  """Apply ``inherit_evidence`` against the live row fetched inside the write
706
733
  transaction, so the hot paths that bypass the engine honour the same rule."""
@@ -4952,7 +4979,7 @@ class PostgresAdapter(AdapterABC):
4952
4979
  branch,
4953
4980
  digest.digest_type.value,
4954
4981
  digest.scope,
4955
- json.dumps(digest.summary),
4982
+ json.dumps(_jsonb_safe(digest.summary)),
4956
4983
  digest.entry_count,
4957
4984
  digest.source_agents,
4958
4985
  digest.anticipation_score,