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
Copy file name to clipboardExpand all lines: AGENTS.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,8 +62,8 @@ Target capabilities:
62
62
- Tests must verify the real Markdown -> graph -> query/search flow, including success, malformed input, and empty/no-match paths where relevant.
63
63
- Tests must not use mocks, stubs, or fakes, except one local test implementation of `Microsoft.Extensions.AI.IChatClient` used to prove the LLM extraction boundary without network access.
64
64
- Use TUnit for tests and Shouldly for assertions.
65
-
-Fallbacks are forbidden. Do not silently substitute generic/default behaviour when parsing, extraction, graph building, query execution, or AI extraction fails; fail explicitly or skip the invalid fact with a caller-visible test.
66
-
-Legacy or leftover old code is forbidden. Do not keep deprecated duplicate paths, compatibility shims, or unused old implementations; remove them immediately unless an ADR documents a temporary migration path.
65
+
-Silent substitution paths are forbidden. Do not replace parsing, extraction, graph building, query execution, or AI extraction failures with generic/default behaviour; fail explicitly or skip the invalid fact with a caller-visible test.
66
+
-Old leftover code is forbidden. Do not keep deprecated duplicate paths, compatibility shims, or unused old implementations; remove them immediately unless an ADR documents a temporary migration path.
67
67
68
68
## Global Skills
69
69
@@ -87,9 +87,9 @@ List only the skills this solution actually uses.
Markdown-LD Knowledge Bank is a .NET 10 library for turning Markdown knowledge-base files into an in-memory RDF graph that can be searched and queried with read-only SPARQL.
3
+
Markdown-LD Knowledge Bank is a .NET 10 library for turning Markdown knowledge-base files into an in-memory RDF graph that can be searched, queried with read-only SPARQL, exported as RDF, and rendered as a diagram.
4
4
5
5
It ports the core idea from [lqdev/markdown-ld-kb](https://github.com/lqdev/markdown-ld-kb) into a C# library package. The runtime is local and in-memory: no localhost server, no Azure Functions host, no database server, and no hosted graph service are required.
6
6
7
+
Use it when you want plain Markdown notes to become a queryable knowledge graph without making your application depend on a specific model provider, graph server, or hosted indexing service.
**Deterministic extraction** produces facts without any network call:
24
28
25
29
- article identity, title, summary, dates, tags, authors, and topics from YAML front matter
26
-
- heading sections and document identity from Markdown
30
+
- heading sections and document identity from Markdown structure
27
31
- Markdown links such as `[SPARQL](https://www.w3.org/TR/sparql11-query/)`
28
32
- optional wikilinks such as `[[RDF]]`
29
33
- optional assertion arrows such as `article --mentions--> RDF`
30
-
- optional LLM-produced entities and assertions through `Microsoft.Extensions.AI.IChatClient`
34
+
35
+
**Optional AI extraction** enriches the graph with LLM-produced entities and assertions through `Microsoft.Extensions.AI.IChatClient`. No provider-specific SDK is required in the core library.
36
+
37
+
**Graph outputs:**
38
+
39
+
-`ToSnapshot()` — stable `KnowledgeGraphSnapshot` with `Nodes` and `Edges`
-`SearchAsync(term)` — case-insensitive search across `schema:name`, `schema:description`, and `schema:keywords`, returning matching graph subjects as `SparqlQueryResult`
47
+
48
+
All async methods accept an optional `CancellationToken`.
31
49
32
50
## Install
33
51
@@ -122,11 +140,11 @@ internal static class FileGraphDemo
122
140
}
123
141
```
124
142
125
-
`KnowledgeSourceDocumentConverter` supports Markdown and other text-like knowledge inputs: `.md`, `.markdown`, `.mdx`, `.txt`, `.text`, `.log`, `.csv`, `.json`, `.jsonl`, `.yaml`, and `.yml`.
143
+
`KnowledgeSourceDocumentConverter` supports Markdown and other text-like knowledge inputs: `.md`, `.markdown`, `.mdx`, `.txt`, `.text`, `.log`, `.csv`, `.json`, `.jsonl`, `.yaml`, and `.yml`. Non-Markdown files are accepted as text sources and run through the same parsing, extraction, and graph build pipeline.
126
144
127
145
You do not need to pass a base URI for normal use. Document identity is resolved in this order:
128
146
129
-
-`canonicalUrl` or `canonical_url` in Markdown front matter
147
+
-`KnowledgeDocumentConversionOptions.CanonicalUri` when you provide one
130
148
- the file path, normalized the same way as the upstream project: `content/notes/rdf.md` becomes a stable document IRI
131
149
- the generated inline document path when `BuildFromMarkdownAsync` is called without a path
132
150
@@ -179,12 +197,12 @@ ASK WHERE {
179
197
180
198
The built-in chat extractor requests structured output through `GetResponseAsync<T>()`, normalizes the returned entity/assertion payload, merges it with deterministic facts, and then builds the same in-memory RDF graph used by search and SPARQL. Tests use one local non-network `IChatClient` implementation so the full extraction-to-graph flow is covered without a live model.
SPARQL execution is intentionally read-only. `SELECT` and `ASK` are allowed; mutation forms such as `INSERT`, `DELETE`, `LOAD`, `CLEAR`, `DROP`, and `CREATE` are rejected before execution.
SPARQL execution is intentionally read-only. `SELECT` and `ASK` are allowed; mutation forms such as `INSERT`, `DELETE`, `LOAD`, `CLEAR`, `DROP`, and `CREATE` are rejected before execution.
265
+
`ToSnapshot()` returns a stable object graph with `Nodes` and `Edges` so callers can build their own UI, JSON endpoint, or visualization layer without touching dotNetRDF internals. URI node labels are resolved from `schema:name` when available, so diagram output is readable by default.
266
+
267
+
Example Mermaid output shape:
268
+
269
+
```mermaid
270
+
graph LR
271
+
n0["Zero Cost Knowledge Graph"]
272
+
n1["RDF"]
273
+
n0 -->|"schema:mentions"| n1
274
+
```
275
+
276
+
Example DOT output shape:
277
+
278
+
```dot
279
+
digraph KnowledgeGraph {
280
+
rankdir=LR;
281
+
"n0" [label="Zero Cost Knowledge Graph"];
282
+
"n1" [label="RDF"];
283
+
"n0" -> "n1" [label="schema:mentions"];
284
+
}
285
+
```
225
286
226
287
## Thread Safety
227
288
228
-
`KnowledgeGraph` is safe for shared in-memory read/write use through its public API. Search, read-only SPARQL, and serialization run under a read lock; `MergeAsync` snapshots a built graph and merges it under a write lock.
289
+
`KnowledgeGraph` is safe for shared in-memory read/write use through its public API. Search, read-only SPARQL, snapshot export, diagram serialization, and RDF serialization run under a read lock; `MergeAsync` snapshots a built graph and merges it under a write lock.
229
290
230
291
Use this when many workers convert Markdown independently and publish their results into one graph:
Copy file name to clipboardExpand all lines: src/MarkdownLd.Kb/AGENTS.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,14 @@ Purpose: Production library for Markdown-LD Knowledge Bank.
19
19
- Do not add localhost, HTTP server, background service, database server, or hosted API dependencies. The production pipeline must build, store, query, and serialize graphs in memory.
20
20
- Do not add embedding/vector provider dependencies to the core pipeline. Future semantic/vector search must be optional and provider-neutral.
21
21
- Keep the root namespace, assembly name, and package ID as `ManagedCode.MarkdownLd.Kb`.
22
-
- Do not implement fallbacks. Invalid parsing, extraction, graph, or query inputs must fail explicitly or be skipped by a documented validation rule with tests.
23
-
- Do not keep legacy or leftover implementation paths in this project. Remove obsolete code instead of wrapping or preserving it.
22
+
- Do not implement silent substitution paths. Invalid parsing, extraction, graph, or query inputs must fail explicitly or be skipped by a documented validation rule with tests.
23
+
- Do not keep old leftover implementation paths in this project. Remove obsolete code instead of wrapping or preserving it.
0 commit comments