v0.4.0
Semantica v0.4.0 β Release Notes
Released: 2026-04-08
PyPI: pip install semantica==0.4.0
Tag: v0.4.0
Full Changelog: CHANGELOG.md
v0.4.0 is the largest feature release to date. It ships a complete bi-temporal intelligence stack, a production-ready Knowledge Explorer API, first-class SHACL validation, SKOS vocabulary management, ontology alignment & diff, an Agno agentic framework integration, a Datalog reasoning engine, and a broad sweep of reliability, performance, and security fixes.
Test suite: 886 passed Β· 9 skipped Β· 0 failed
What's New
Temporal Intelligence
A full bi-temporal model is now baked into the core. Every entity, relationship, decision, and provenance record can carry valid time (when a fact was true in the world) and transaction time (when it was recorded in the system).
Core Temporal Data Model (PR #396)
- New
semantica.kg.temporal_modelwith shared parsing, normalization, and serialization helpers used across all temporal APIs TemporalBoundandBiTemporalFactexported fromsemantica.kgvalid,transaction, andbothtime-axis filtering in all temporal queriesTemporalValidationErrorraised consistently on invalid inputs β no silent coercions- History-preserving revisions in
TemporalVersionManager.apply_revision()with supersession semantics
Temporal Query Engine: Point-in-Time Correctness (PR #397)
TemporalGraphQuery.reconstruct_at_time(graph, at_time)β builds a consistent point-in-time subgraph without mutating the sourcequery_at_time()uses reconstruction internally so returned subgraphs never contain dangling edgesTemporalConsistencyReportβ detects inverted intervals, relationships outside entity lifetimes, missing endpoints, overlapping same-type relationships, and temporal gapsvalidate_temporal_consistency(graph)available as a top-level module function- Sequence and cycle pattern detection with
pattern_type,signature,frequency, and per-occurrence detail - Calendar-aligned temporal evolution bucketing via
temporal_granularity - Causal ordering controls on
find_temporal_paths()βenforce_causal_ordering,ordering_strategy(strict,overlap,loose)
Deterministic Temporal Reasoning Engine (PR #398)
- New
semantica.kg.temporal_reasoningβ zero LLM calls, pure deterministic reasoning - Full Allen interval algebra via
IntervalRelationβ all 13 relations (before,meets,overlaps,starts,during,finishes,equals, and inverses) TemporalReasoningEnginewith helpers for interval merging, gap analysis, coverage calculation, timelines, and retroactive coverage- Circular import risk between
semantica.reasoningandsemantica.kgeliminated;semantica.reasoningaccess preserved via re-exports
Temporal Awareness in Context Graph (PR #399)
Decisiondataclass carriesvalid_from/valid_untilvalidity windows β superseded decisions remain in the graph (immutable history)find_precedents_by_scenario(include_superseded=False, as_of=None)β defaults exclude expired decisions;as_ofenables point-in-time queriesContextGraph.state_at(timestamp)β serializable point-in-time snapshot; source graph never mutatedCausalChainAnalyzer.trace_at_time(event_id, at_time)β reconstructs causal chain using only edges recorded up toat_timeAgentContext.checkpoint(label),diff_checkpoints(label1, label2),flush_checkpoint(label)β named in-memory snapshots with structured diffs
Temporal Metadata Extraction from Text (PR #400)
extract_relations_llm(extract_temporal_bounds=True)β each returnedRelationgainsvalid_from,valid_until,temporal_confidence(0.0β1.0), andtemporal_source_text; defaultFalseis 100% backward-compatible- Calibrated confidence anchors baked into the prompt:
1.00= full ISO date β0.00= no temporal signal - New
TemporalNormalizerβ zero LLM calls, pure regex +dateutil:normalize(value)β(valid_from, valid_until)UTC datetime tuple orNonenormalize_phrase(phrase)β domain metadata dict orNone- 13-domain default phrase map covering General/Policy, Healthcare, Cybersecurity, Supply Chain, Finance, and Energy
- Ambiguous
DD/MM/YYYYinputs issueTemporalAmbiguityWarningβ never silently guesses locale - User-supplied
phrase_mapmerged over defaults at construction
Temporal Provenance & Export (PR #401)
ProvenanceTracker.track_entity()auto-stampsrecorded_aton every new recordquery_recorded_between(start, end)β returns all provenance records within an inclusive time rangerevision_history(fact_id)β complete revision chain ordered byrecorded_atascendingexport_audit_log(fact_ids, format)β"json"(pretty-printed) or"csv"(with header row)RDFExporter.export_to_rdf(include_temporal=True, time_axis="valid"|"transaction"|"both")β emits OWL-Time triples for all temporally-annotated relationshipscreate_snapshot()stamps"format_version": "1.0";validate_snapshot()andmigrate_snapshot()for stable snapshot lifecycle management
Temporal GraphRAG Integration (PR #402)
TemporalGraphRetrieverβ drop-in wrapper for anyContextRetriever; filters retrieved entities and relationships to a point in time;at_time=Noneis a true passthroughContextRetriever.query_with_reasoning(at_time=..., header_template=...)β structured temporal header prepended to LLM context; format-string injection guard viastr.replaceTemporalQueryRewriterβ extractstemporal_intent,at_time,start_time,end_time, andrewritten_queryfrom natural language; regex-only by default, optional LLM-assisted mode
Ontology & Knowledge Representation
SHACL Shape Generation & Validation (PR #318)
SHACLGeneratorderives SHACL node and property shapes from any Semantica ontology dict β zero hand-authoring required- Three quality tiers:
"basic"(structure + cardinality),"standard"(addssh:in,sh:pattern, inheritance),"strict"(addssh:closed true+sh:ignoredProperties) - Output formats: Turtle, JSON-LD, N-Triples; iterative multi-level inheritance propagation, cycle-safe
OntologyEngine.to_shacl(),export_shacl(), andvalidate_graph(explain=True)β plain-English explanations for all 7 SHACL constraint typesSHACLValidationReportwithconforms,violations,warnings,summary(),explain_violations(),to_dict()- Install:
pip install semantica[shacl]
SKOS Vocabulary Module (PR #319)
TripletStore.add_skos_concept()β assembles and stores all required SKOS triples automatically via existingadd_triplets()APITripletStore.get_skos_concepts(scheme_uri=None)β SPARQL-backed retrieval with multi-valuealtLabel/broader/narrowercollapsingOntologyEngine.list_vocabularies(),list_concepts(scheme_uri),search_concepts(query, scheme_uri=None)β injection-safe SPARQL throughoutNamespaceManager.get_skos_uri(local_name)andbuild_concept_scheme_uri(name)namespace helpers
Ontology Alignment API (PR #361)
OntologyEngine.create_alignment(source_uri, target_uri, predicate)β stores triples using standard OWL/SKOS predicates (owl:equivalentClass,skos:exactMatch,skos:relatedMatch, etc.)get_alignments(entity_uri)β bidirectional retrieval of all alignments for an entityReuseManager.suggest_alignments(target, source)β O(N+M) hashmap heuristic over exact label matchesQueryEngine.expand_entity_uri(uri, store, use_alignments=True)β SPARQL expansion to automatically include aligned equivalents in queries- SPARQL injection hardened in
list_alignmentsandbuild_values_clause
Ontology Diff & Migration (PR #367)
VersionManager.diff_ontologies(base, target)β structured diff covering classes, properties, individuals, and axiomsChangeLogAnalyzer.analyze(diff)β classifies impact:CRITICAL/BREAKING,HIGH/BREAKING,MEDIUM/POTENTIALLY_BREAKING,INFO/NON_BREAKINGImpactReportandgenerate_change_report(diff)β structured output withsummary,impact_classification, andrecommendationsOntologyEngine.compare_versions(base_id, target_id, run_validation=True, graph_data=...)β end-to-end orchestrator with optional validation and graph-instance checks
Knowledge Explorer
A full FastAPI backend for the Semantica dashboard. Install with pip install semantica[explorer] and launch via semantica-explorer --graph my_graph.json.
Graph API (PR #384)
GET /api/graph/nodes|edges|statsβ type/keyword filter, skip/limit paginationGET /api/graph/node/{id}/neighborsβ BFS traversal, configurable depth 1β5GET /api/graph/node/{id}/pathβ BFS or Dijkstra, dispatched viaalgorithmparamPOST /api/graph/searchβ full-text search across node content and metadata
Analytics, Decisions & Temporal (PR #384)
GET /api/analyticsβ centrality, community detection, connectivity (comma-separatedmetricsparam)GET /api/decisions/{id}/chain|precedents|complianceβ causal chain BFS, ranked precedent retrieval, in-graph compliance edge scanGET /api/temporal/snapshot|diff|patternsβ point-in-time snapshots, node-set diffs between timestamps, pattern detection
Enrichment & Export (PR #384)
POST /api/enrich/extract|links|dedup|reasonβ NLP extraction, link prediction, deduplication, forward/backward inferencePOST /api/exportβ 12 formats: JSON, Turtle, RDF-XML, N-Triples, CSV, GraphML, GEXF, OWL, Cypher, AQL, YAML; temp files always cleaned viatry/finallyPOST /api/importβ JSON/JSON-LD multipart upload with WebSocket real-time progress events
SKOS Vocabulary REST API (PR #426)
GET /api/vocabulary/schemesβ allskos:ConceptSchemenodesGET /api/vocabulary/hierarchy?scheme=<uri>β full broader/narrower concept tree with cycle detectionPOST /api/vocabulary/importβ accepts.ttl,.rdf,.owluploads; invalid files return HTTP 422
Infrastructure
- Thread-safe
GraphSessionwith 8 lazily-initialized analytics components underRLock(PR #385) - WebSocket
ConnectionManagerfor real-time broadcast and per-client messaging - 28 Pydantic v2 request/response models; 99 integration tests, all passing
Integrations
Agno Agentic Framework (Issue #249)
Five components making Semantica the memory and knowledge layer for Agno agents. All degrade gracefully when agno is not installed.
AgnoContextStoreβ graph-backed agent memory implementingagno.memory.db.base.MemoryDb; supports full CRUD plusrecord_decision(),find_precedents(),retrieve()AgnoKnowledgeGraphβ multi-hop GraphRAG knowledge base implementingagno.knowledge.base.AgentKnowledge; ingests files, directories, URLs, and raw text via NER β relation extraction β graph β vector index pipelineAgnoDecisionKitβ AgnoToolkitexposing 6 decision-intelligence tools:record_decision,find_precedents,trace_causal_chain,analyze_impact,check_policy,get_decision_summaryAgnoKGToolkitβ AgnoToolkitexposing 7 KG pipeline tools:extract_entities,extract_relations,add_to_graph,query_graph,find_related,infer_facts,export_subgraphAgnoSharedContextβ team-level coordinator with a single sharedContextGraph;bind_agent(role)returns a role-scoped view with cross-agent memory visibility; thread-safe viaRLock
Install: pip install semantica[agno]
Cookbooks: cookbook/integrations/agno_decision_intelligence.ipynb, agno_graphrag_context.ipynb, agno_multi_agent_shared_context.ipynb
Novita AI Provider (PR #374)
create_provider("novita")β OpenAI-compatible integration; default modeldeepseek/deepseek-v3.2; configured viaNOVITA_API_KEY
Reasoning
Native Datalog Reasoning Engine (PR #371)
DatalogReasonerβ pure-Python bottom-up semi-naive fixpoint engine with guaranteed termination on finite graphs- Supports recursive Horn clause rules (e.g.
ancestor(X,Y) :- parent(X,Z), ancestor(Z,Y).) β handles cases that loop the existing forward/backward engine indefinitely query("pred(?X, ?Y)")returns variable-binding dicts;bindings={"Y": "val"}for pre-bound verificationload_from_graph(ContextGraph)β one-call conversion of all graph edges and nodes to Datalog facts- O(1) delta-index lookup per iteration;
derive_all()skips re-evaluation when inputs are unchanged DatalogReasoner,DatalogFact,DatalogRuleexported fromsemantica.reasoning
Pattern Matcher Restored (PR #387)
- Dead code silently overwrote
_match_pattern's full regex (pre-bound variable embedding, repeated-variable backreferences(?P=var)) with a simplere.escapepattern β breaking transitivity, symmetry, and self-join rules entirely - Removed;
re.errorexceptions now surfaced instead of swallowed
Performance & Reliability
ContextGraph O(N) β O(limit) Pagination (PR #431)
find_nodesandfind_edgesnow use generator expressions consumed viaitertools.isliceβ on a 50k-node / 100k-edge graph, each paginated request previously allocated up to 2.5M dicts and caused 502 timeouts; now O(limit) in both time and space- Ghost-node fix:
add_edgesaccepts both"source_id"/"target_id"and"source"/"target"key names β edges fromfind_edgesno longer silently produceNone β Noneentries - Deterministic page boundaries:
find_nodesandfind_active_nodescallsorted()on index sets before iterating stats()applies the same validity filters asfind_nodes/find_edgesso counts always match what pagination returns
ContextGraph Thread Safety (PR #385)
threading.RLockadded toContextGraph.__init__; all mutation and read/query paths protectedGraphSessionlazy analytics properties initialized underRLockβ no double-instantiation under concurrent FastAPI workers
ContextGraph Traversal Fallbacks (PR #386)
- All 7
DecisionQuerymethods and 4DecisionRecordermethods have nativeContextGraphfallback paths β in-memory usage no longer requires a graph database backend
Snapshot & Audit Trail (PRs #393, #394)
restore_snapshot()requires explicit confirmation before destructive restore β rollback protectionget_node_history()for per-entity audit inspection;diff()as a Git-like alias over version comparisons- Both
nodes/edgesandentities/relationshipssnapshot schemas accepted transparently
Named Graph Support (PR #432)
enable_named_graphsconfig flag correctly forwarded throughTripletStore.execute_query()- Duplicate
FROM <...>/FROM NAMED <...>clause prevention inQueryEngine.prepare_query() default_graph_uriconfig alias added alongside existingdefault_graph- Graph URIs percent-encoded before SPARQL interpolation in version-pruning
DROP SILENT GRAPHstatements
Bug Fixes
OllamaProviderignoredbase_url(PR #408) β all requests silently hitlocalhost:11434; fixed by instantiatingollama.Client(host=self.base_url)instead of assigning the raw moduleCentralityCalculatorcrash β_build_adjacency()failed onContextGraphedges (dataclass objects vs plain dicts); fixed to handle both shapesfind_pathalways used BFS (PR #384) βalgorithmquery param was parsed but never dispatched; now correctly routes todijkstra_shortest_pathorbfs_shortest_path/api/enrich/linksblocked the event loop (PR #385) βscore_linkscoring loop ran inline inasync def; wrapped inasyncio.to_thread- Temp file leak in
export_graph(PR #384) β file not deleted on exception; fixed withtry/finallycleanup - spaCy NER crash β
NERExtractorcrashed in environments where spaCy is installed but broken at runtime; fallback now catches runtime initialization failures, not just missing-model errors ChangeCategoryenum typo (PR #367) β"potenitally_breaking"β"potentially_breaking"
Security
- CWE-312/359/532 β Sensitive data in logs β Removed debug
printblocks inrelation_extractor.pyandtriplet_extractor.pythat wroteapi_keyvalues to stdout in verbose mode - CWE-20 β Incomplete URL sanitization β
"url" in urlsreplaced withany(url == "url" for url in urls)β eliminates substring match that could match attacker-controlled URLs at arbitrary positions - Overpermissioned CI workflows β
permissions: contents: readadded tobenchmark.ymlandsecurity.yml; both previously inherited repo-default (potentially read-write) permissions - SHACL path traversal β Replaced
len < 500 and "\n" not in spath-vs-content heuristic withos.path.exists(); prevents attacker-controlled SHACL strings from being silently interpreted as file paths - SHACL inheritance mutation β
_propagate_inheritancenow usesdataclasses.replace()instead of appending parentPropertyShapeobjects by reference; child mutations no longer silently corrupt parent shapes - SPARQL injection β Hardened
search_concepts,list_alignments, andbuild_values_clausewith full character escaping and_sanitize_uriguards on all user-controlled inputs
Installation
pip install semantica==0.4.0
pip install semantica[shacl] # SHACL validation (requires pyshacl)
pip install semantica[explorer] # Knowledge Explorer API (requires FastAPI)
pip install semantica[agno] # Agno framework integration
pip install semantica[llm-all] # All LLM providers
pip install semantica[all] # EverythingContributors
- Authored the full temporal intelligence stack β data model (#396), point-in-time query engine (#397), deterministic reasoning engine (#398), context graph temporal awareness (#399), text-to-temporal extraction +
TemporalNormalizer(#400), provenance & OWL-Time export (#401), GraphRAG integration (#402) - Authored SHACL shape generation & validation (#318) and SKOS vocabulary module (#319)
- Security hardening β CodeQL alert remediation, SPARQL injection fixes, context explainability output fixes
- Review patches and follow-up fixes across all contributor PRs
- Knowledge Explorer API backend (#384), thread safety & pagination (#385), ContextGraph traversal fallbacks (#386)
- SKOS vocabulary REST API (#426) and RDF parsing utility (#425)
- ContextGraph pagination & edge integrity fixes (#431)
- Snapshot schema compatibility (#393), audit trail & rollback protection (#394)
- Ontology alignment API (#361), ontology diff & migration (#367)
- Native Datalog reasoning engine (#371)
- Named graph support (#432)
@Alex-wuhu
- Novita AI provider integration (#374)
- OllamaProvider
base_urlfix (#408)
PyPI Β· GitHub Release Β· Documentation