You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add JSON-LD round-trip helpers, graph contracts, generated SHACL, graph diffing, incremental manifests, and build profile presets.
Add schema-aware local and federated SPARQL search with explainable evidence, source context, focused graph export, and production documentation.
Cover the new graph production flows with integration tests.
Use raw federated SPARQL when the caller knows the exact cross-service join. Use schema-aware federated search when the caller wants the library to compile a search profile into `SERVICE` blocks. Use local schema-aware search when all required data is already in one `KnowledgeGraph`.
110
+
111
+
## Raw Local Multi-Graph Example
112
+
113
+
This example federates across two in-memory graphs without network access. The endpoint URIs are logical service names owned by the host application.
The root graph does not need to contain the data being joined. It provides the execution boundary. Each `SERVICE` block is routed either to an allowlisted local binding or to a remote SPARQL endpoint.
172
+
173
+
## Raw Federated ASK Example
174
+
175
+
Use `ExecuteFederatedAskAsync` when the caller needs a boolean policy or readiness check across graph slices.
`SearchBySchemaFederatedAsync` compiles a `KnowledgeGraphSchemaSearchProfile` into one `SERVICE` block per configured endpoint. It is the right path when callers want SPARQL federation but do not want to hand-author the full query string.
Federated schema search returns primary matches and predicate evidence from service endpoints. It does not create a focused local graph because the related graph neighborhood may live only behind the remote service boundary.
244
+
245
+
## Remote Endpoint Example
246
+
247
+
Remote endpoints are allowed only when explicitly configured. Use a named profile when it matches the endpoint set, or construct an options object yourself.
Remote federation is query-time access only. It does not import remote triples into the local `KnowledgeGraph`; use JSON-LD/Turtle loading or a separate preprocessing step when the local graph needs to keep those facts.
267
+
268
+
## Allowlist Patterns
269
+
270
+
Recommended host policy:
271
+
272
+
- use stable logical service URIs for local graph slices, such as `https://kb.example/services/runbooks`
273
+
- allowlist every `SERVICE` endpoint, including local bindings
274
+
- bind local service endpoints with `FederatedSparqlLocalServiceBinding`
275
+
- keep remote endpoint options separate from local-only test options
276
+
- set `QueryExecutionTimeoutMilliseconds` for remote endpoints
277
+
- inspect `ServiceEndpointSpecifiers` on success and on `FederatedSparqlQueryException`
278
+
279
+
Avoid:
280
+
281
+
- passing user-authored arbitrary endpoint URIs directly into `AllowedServiceEndpoints`
282
+
- relying on variable `SERVICE ?endpoint` at the library boundary
283
+
- expecting local `ExecuteSelectAsync` or `ExecuteAskAsync` to run top-level `SERVICE`
284
+
- using federation as a hidden fallback when local schema search returns no matches
Graph creation contracts connect the graph build pipeline with schema-aware SPARQL search. A build can now carry a `KnowledgeGraphBuildProfile` that bundles graph build options, the recommended `KnowledgeGraphSchemaSearchProfile`, and optional SHACL shapes. The resulting `MarkdownKnowledgeBuildResult.Contract` describes the RDF shape that was actually produced and validates the bundled search profile against that graph.
6
+
7
+
This is what "self-describing graph" means in this library: the graph can expose its RDF types, predicates, literal predicates, resource predicates, and profile mismatch diagnostics without requiring the caller to guess the schema from documentation.
The focused graph export is intended for result handoff to UI, agents, follow-up SPARQL, and external preprocessing steps.
103
+
104
+
## Production Handoff
105
+
106
+
Contract artifacts are the durable companion to generated JSON-LD. Store the graph JSON-LD together with `KnowledgeGraphContract.SerializeJson()` or `SerializeYaml()`. A later process can reload both, validate the graph with `GenerateShacl()`, and run `SearchBySchemaAsync` through the contract profile without repeating Markdown parsing or AI extraction.
107
+
108
+
For the full production flow, including generated JSON-LD, source-backed evidence, graph diffing, presets, and incremental manifests, see [Graph Production Pipeline](GraphProductionPipeline.md).
109
+
110
+
## Verification
111
+
112
+
```bash
113
+
dotnet test --solution MarkdownLd.Kb.slnx --configuration Release -- --treenode-filter "/*/*/GraphContractAndAdvancedSearchFlowTests/*" --no-progress
114
+
```
115
+
116
+
Covered scenarios:
117
+
118
+
- pipeline build profile returns a search-ready contract
119
+
- schema introspection describes actual RDF types and predicates
120
+
- profile validation reports missing terms
121
+
- advanced search profiles support all-terms mode, inbound relationships, property paths, and facets
122
+
- focused graph snapshots export to JSON-LD, Turtle, Mermaid, and DOT
0 commit comments