Synaptic Core foundation and persistence layer for graph-backed memory.
Project description
synaptic-core
synaptic-core v0.3.1 ships a clean canonical API for graph memory:
- Client:
Synaptic(async) - Core methods:
remember,recall,set,get,find,delete,clear,connect,related - Session-first helpers:
client.session("...") - Structured errors:
SynapticError { code, message, hint }
Install
pip install synaptic-core
Happy Path (Async, Session-First)
import asyncio
from synaptic_core import Synaptic, SynapticError
from synaptic_core.types import OutcomeSignalType
def embed(text: str) -> list[float]:
normalized = text.lower().strip()
return [
float(len(normalized.split())),
float(len(normalized)) / 100.0,
float(sum(ord(ch) for ch in normalized) % 257) / 257.0,
]
async def main() -> None:
client = Synaptic(db_path="synaptic.db", embedding_fn=embed)
session = client.session("chat-42")
await session.remember("Customer asked for monthly usage CSV export")
recall = await session.recall("How do I export monthly usage as CSV?", top_k=5)
if recall.nodes:
await session.feedback(
recall.query_id,
outcome=OutcomeSignalType.EXPLICIT_POSITIVE,
provider="app",
)
print("nodes", [str(node.id) for node in recall.nodes])
print("stats", await client.stats())
try:
asyncio.run(main())
except SynapticError as exc:
print(exc.as_dict())
Constructor Runtime Options Contract
Synaptic(...) now validates runtime options before engine initialization:
- Unknown option names raise
SynapticErrorwith codeINVALID_CONSTRUCTOR_OPTIONS. - Invalid option values raise
SynapticErrorwith codeINVALID_CONSTRUCTOR_OPTIONS. - Conflicting alias/canonical pairs raise
SynapticErrorwith codeINVALID_CONSTRUCTOR_OPTIONS(pass only one name per canonical option). - Legacy aliases are accepted:
retrieval_top_k->top_k_retrievalactivation_seed_top_k->top_k_activation_seedsweekly_digest_ttl_seconds->weekly_digest_cache_ttl_secondsgraph_confidence_refresh_interval->graph_confidence_refresh_query_interval
Supported runtime options:
backendclassifiercross_tier_similarity_thresholdcross_tier_initial_weightcross_tier_seed_top_kcross_tier_seed_max_edgestop_k_retrievaltop_k_activation_seedstelemetry_collectoractivation_engineoutcome_detectorconnection_learnerdeployment_idweekly_digest_cache_ttl_secondsgraph_confidence_refresh_query_intervalgraduation_enginegraduation_scheduler_enabledgraduation_check_interval_queriesgraduation_check_interval_secondsgraduation_min_access_countgraduation_min_positive_outcome_ratiograduation_min_age_hoursgraduation_min_reinforced_edgesgraduation_reinforced_edge_weight_thresholdgraduation_edge_transfer_thresholdinstance_optimizerinstance_optimizer_enabledinstance_optimizer_step_sizeinstance_optimizer_min_sample_countinstance_optimizer_update_intervalsession_deserializer
Practical invalid-option example:
from synaptic_core import Synaptic, SynapticError
try:
Synaptic(db_path="synaptic.db", unknown_runtime_option=True)
except SynapticError as exc:
assert exc.code == "INVALID_CONSTRUCTOR_OPTIONS"
Canonical API
remember(content, *, session_id="default", memory_type=None, external_id=None, source_type=None, metadata=None) -> Noderecall(query, *, session_id="default", top_k=None) -> RetrievalResultfeedback(query_id, outcome, *, session_id=None, agent_response=None, user_next_message=None, dwell_time_ms=None, active_nodes=None, corrected_nodes=None, provider="unknown") -> CompositeOutcomeset(key, value, *, namespace=None, metadata=None, ttl=None) -> Noneget(key, *, namespace=None) -> Any | Nonedelete(key, *, namespace=None) -> boolclear(*, namespace=None) -> intfind(query, *, namespace=None, limit=10, filters=None) -> list[dict]connect(node_a_id, node_b_id, *, weight=0.3, connection_type="excitatory", formation_trigger="explicit", is_cross_tier=None) -> dictrelated(node_id, *, limit=None) -> list[dict]stats() -> dictgraph_status() -> dictweekly_digest(force_refresh=False) -> dictsession_summary(session_id) -> dictsessions_recent(limit=20) -> list[dict]queries_recent(session_id=None, limit=20) -> list[dict]outcomes_recent(session_id=None, limit=20) -> list[dict]
Session-First Helpers
client.session(session_id).remember(...)client.session(session_id).recall(...)client.session(session_id).feedback(...)client.session(session_id).summary()client.session(session_id).queries_recent(limit=20)client.session(session_id).outcomes_recent(limit=20)
CLI
synaptic doctor --db-path synaptic.db
synaptic stats --db-path synaptic.db --json
synaptic graph status --db-path synaptic.db --json
synaptic sessions recent --db-path synaptic.db --limit 20 --json
synaptic queries recent --db-path synaptic.db --session-id chat-42 --limit 20 --json
synaptic outcomes recent --db-path synaptic.db --session-id chat-42 --limit 20 --json
synaptic weekly-digest --db-path synaptic.db --json
Test Marker Presets
Use marker-driven subsets for faster local validation loops:
.venv/bin/python -m pytest tests/synaptic_core -m public_api -q
.venv/bin/python -m pytest tests/synaptic_core -m service_unit -q
.venv/bin/python -m pytest tests/synaptic_core -m engine_contract -q
.venv/bin/python -m pytest tests/synaptic_core -m integration -q
.venv/bin/python -m pytest tests/synaptic_core -m durability -q
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file synaptic_core-0.3.1.tar.gz.
File metadata
- Download URL: synaptic_core-0.3.1.tar.gz
- Upload date:
- Size: 87.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d44ad5b8832e98b4192faff0c6e416c27766d05752ea3117b71338e1c9a3b26b
|
|
| MD5 |
13db665d55a04f872c70851704b405c1
|
|
| BLAKE2b-256 |
1a3bd41e57a36d1e5f4236d37cc2ec5b726cfcc40d268b956721f9931d835c18
|
File details
Details for the file synaptic_core-0.3.1-py3-none-any.whl.
File metadata
- Download URL: synaptic_core-0.3.1-py3-none-any.whl
- Upload date:
- Size: 99.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db7bb1ba8b461936560d55bf26db14c43af3c5ebe65922907ccae420b548b77
|
|
| MD5 |
7add0d86b6ea920ab000f9c51b25694e
|
|
| BLAKE2b-256 |
63aeee5eae7e8a1f4aeb75e7633b6d59640f0b630c31e20b6fbb3544712716c0
|