kogwistar-llm-wiki 0.2.0__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.
- kogwistar_llm_wiki-0.2.0/PKG-INFO +155 -0
- kogwistar_llm_wiki-0.2.0/README.md +129 -0
- kogwistar_llm_wiki-0.2.0/pyproject.toml +76 -0
- kogwistar_llm_wiki-0.2.0/setup.cfg +4 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/__init__.py +25 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/__main__.py +100 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/contracts.py +46 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/daemon.py +127 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/ingest_pipeline.py +539 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/maintenance_designs.py +133 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/models.py +75 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/namespaces.py +63 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/projection.py +132 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/projection_worker.py +212 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/utils.py +119 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki/worker.py +443 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/PKG-INFO +155 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/SOURCES.txt +23 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/dependency_links.txt +1 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/entry_points.txt +2 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/requires.txt +10 -0
- kogwistar_llm_wiki-0.2.0/src/kogwistar_llm_wiki.egg-info/top_level.txt +1 -0
- kogwistar_llm_wiki-0.2.0/tests/test_identities.py +12 -0
- kogwistar_llm_wiki-0.2.0/tests/test_models.py +43 -0
- kogwistar_llm_wiki-0.2.0/tests/test_namespaces.py +31 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kogwistar-llm-wiki
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: LLM-Wiki: a continuously-learning knowledge system built on Kogwistar
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: knowledge-graph,llm,obsidian,kogwistar,wiki
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
Provides-Extra: chromadb
|
|
20
|
+
Requires-Dist: chromadb>=0.6; extra == "chromadb"
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
23
|
+
Requires-Dist: pytest-anyio; extra == "test"
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: kogwistar-llm-wiki[chromadb,test]; extra == "dev"
|
|
26
|
+
|
|
27
|
+
# Kogwistar LLM-Wiki
|
|
28
|
+
|
|
29
|
+
A **continuously-learning knowledge system** built on [Kogwistar](https://github.com/humblemat810/kogwistar).
|
|
30
|
+
|
|
31
|
+
Feed it documents. It extracts entities, promotes knowledge, distills wisdom, and projects an interlinked Obsidian vault — automatically, in the background.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
raw sources → kg-doc-parser → conversation graph → promote → knowledge graph → Obsidian vault
|
|
35
|
+
→ wisdom engine
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## What it is
|
|
41
|
+
|
|
42
|
+
| Layer | Role |
|
|
43
|
+
|---|---|
|
|
44
|
+
| **conversation** | Working memory — parsed artifacts, candidate links, maintenance jobs |
|
|
45
|
+
| **knowledge graph** | Stabilized, promoted truth |
|
|
46
|
+
| **wisdom engine** | Reusable patterns derived from execution history |
|
|
47
|
+
| **Obsidian vault** | Human-facing projection (markdown + canvas) |
|
|
48
|
+
|
|
49
|
+
> It is **not** a chatbot, a note app, or a RAG wrapper.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
### Option A — Local development (recommended)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bash scripts/bootstrap-dev.sh
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The script:
|
|
62
|
+
1. Clones `kogwistar`, `kogwistar-obsidian-sink`, `kg-doc-parser` from GitHub if not already present locally
|
|
63
|
+
2. Installs all three as **editable** from the local checkout
|
|
64
|
+
3. Installs this package last
|
|
65
|
+
|
|
66
|
+
After running, the venv always uses local editable sources — re-running is safe (existing checkouts are kept).
|
|
67
|
+
|
|
68
|
+
### Option B — GitHub-only (CI / no local edits needed)
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install git+https://github.com/humblemat810/kogwistar.git
|
|
72
|
+
pip install git+https://github.com/humblemat810/kogwistar-obsidian-sink.git
|
|
73
|
+
pip install git+https://github.com/humblemat810/kg-doc-parser.git
|
|
74
|
+
pip install -e ".[dev]"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> `kogwistar` and `kogwistar-obsidian-sink` are **not on PyPI** — both options install them from source.
|
|
78
|
+
|
|
79
|
+
> **Windows**: Run the bootstrap from Git Bash or WSL.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## Quick demo
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# 1. Bootstrap (first time only)
|
|
87
|
+
bash scripts/bootstrap-dev.sh
|
|
88
|
+
|
|
89
|
+
# 2. Ingest a document
|
|
90
|
+
python -c "
|
|
91
|
+
from kogwistar_llm_wiki.ingest_pipeline import IngestPipeline
|
|
92
|
+
p = IngestPipeline(workspace_id='demo')
|
|
93
|
+
p.run('my_document.md')
|
|
94
|
+
"
|
|
95
|
+
|
|
96
|
+
# 3. Run the background workers
|
|
97
|
+
llm-wiki daemon maintenance --workspace demo
|
|
98
|
+
llm-wiki daemon projection --workspace demo --vault ~/obsidian/wiki
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
See [QUICKSTART.md](QUICKSTART.md) for the full step-by-step tutorial.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## CLI reference
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
llm-wiki daemon projection --workspace <id> --vault <path> [--interval <s>]
|
|
109
|
+
llm-wiki daemon maintenance --workspace <id> [--interval <s>]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Full reference: [doc/cli_reference.md](doc/cli_reference.md)
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Docs
|
|
117
|
+
|
|
118
|
+
### System Documentation
|
|
119
|
+
|
|
120
|
+
| Document | Purpose |
|
|
121
|
+
|---|---|
|
|
122
|
+
| [QUICKSTART.md](QUICKSTART.md) | Step-by-step tutorial |
|
|
123
|
+
| [doc/cli_reference.md](doc/cli_reference.md) | CLI cheatsheet |
|
|
124
|
+
| [doc/diagrams.md](doc/diagrams.md) | CLI spider map, pipeline, algorithm & data-flow diagrams |
|
|
125
|
+
| [doc/architecture.md](doc/architecture.md) | System design |
|
|
126
|
+
| [doc/core_workflows.md](doc/core_workflows.md) | Workflow graph designs |
|
|
127
|
+
| [doc/lane_namespace_convention.md](doc/lane_namespace_convention.md) | Namespace/lane conventions |
|
|
128
|
+
| [doc/maintenance_job_taxonomy.md](doc/maintenance_job_taxonomy.md) | Maintenance job types |
|
|
129
|
+
| [doc/glossary.md](doc/glossary.md) | Term definitions |
|
|
130
|
+
| [doc/distillation_core_migration.md](doc/distillation_core_migration.md) | Notes on migrating distillation to kogwistar core |
|
|
131
|
+
| [STATUS.md](STATUS.md) | Implementation status |
|
|
132
|
+
|
|
133
|
+
### Ecosystem Analysis
|
|
134
|
+
|
|
135
|
+
| Document | Purpose |
|
|
136
|
+
|---|---|
|
|
137
|
+
| [doc/engineering_assessment.md](doc/engineering_assessment.md) | Engineering-level assessment of the author and ecosystem |
|
|
138
|
+
| [doc/ai_os_gap_analysis.md](doc/ai_os_gap_analysis.md) | Gap analysis: what is missing to become a genuine AI-native OS |
|
|
139
|
+
| [doc/ai_os_roadmap.md](doc/ai_os_roadmap.md) | Executable plan: polish to production + AI OS build order |
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pytest tests/unit/ # fast unit tests (in-memory, no services)
|
|
147
|
+
pytest -m integration # Obsidian vault + other on-disk integration checks
|
|
148
|
+
pytest -m manual # opt-in smoke tests requiring local services
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
After a successful ingest/projection run, the most useful manual checks are:
|
|
152
|
+
- maintenance jobs in the durable meta-store should be `DONE`
|
|
153
|
+
- projection jobs in the durable meta-store should be `DONE`
|
|
154
|
+
- the projection manifest row should be `ready`
|
|
155
|
+
- the Obsidian vault should contain the expected `.md` files
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Kogwistar LLM-Wiki
|
|
2
|
+
|
|
3
|
+
A **continuously-learning knowledge system** built on [Kogwistar](https://github.com/humblemat810/kogwistar).
|
|
4
|
+
|
|
5
|
+
Feed it documents. It extracts entities, promotes knowledge, distills wisdom, and projects an interlinked Obsidian vault — automatically, in the background.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
raw sources → kg-doc-parser → conversation graph → promote → knowledge graph → Obsidian vault
|
|
9
|
+
→ wisdom engine
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## What it is
|
|
15
|
+
|
|
16
|
+
| Layer | Role |
|
|
17
|
+
|---|---|
|
|
18
|
+
| **conversation** | Working memory — parsed artifacts, candidate links, maintenance jobs |
|
|
19
|
+
| **knowledge graph** | Stabilized, promoted truth |
|
|
20
|
+
| **wisdom engine** | Reusable patterns derived from execution history |
|
|
21
|
+
| **Obsidian vault** | Human-facing projection (markdown + canvas) |
|
|
22
|
+
|
|
23
|
+
> It is **not** a chatbot, a note app, or a RAG wrapper.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### Option A — Local development (recommended)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
bash scripts/bootstrap-dev.sh
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The script:
|
|
36
|
+
1. Clones `kogwistar`, `kogwistar-obsidian-sink`, `kg-doc-parser` from GitHub if not already present locally
|
|
37
|
+
2. Installs all three as **editable** from the local checkout
|
|
38
|
+
3. Installs this package last
|
|
39
|
+
|
|
40
|
+
After running, the venv always uses local editable sources — re-running is safe (existing checkouts are kept).
|
|
41
|
+
|
|
42
|
+
### Option B — GitHub-only (CI / no local edits needed)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install git+https://github.com/humblemat810/kogwistar.git
|
|
46
|
+
pip install git+https://github.com/humblemat810/kogwistar-obsidian-sink.git
|
|
47
|
+
pip install git+https://github.com/humblemat810/kg-doc-parser.git
|
|
48
|
+
pip install -e ".[dev]"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
> `kogwistar` and `kogwistar-obsidian-sink` are **not on PyPI** — both options install them from source.
|
|
52
|
+
|
|
53
|
+
> **Windows**: Run the bootstrap from Git Bash or WSL.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick demo
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 1. Bootstrap (first time only)
|
|
61
|
+
bash scripts/bootstrap-dev.sh
|
|
62
|
+
|
|
63
|
+
# 2. Ingest a document
|
|
64
|
+
python -c "
|
|
65
|
+
from kogwistar_llm_wiki.ingest_pipeline import IngestPipeline
|
|
66
|
+
p = IngestPipeline(workspace_id='demo')
|
|
67
|
+
p.run('my_document.md')
|
|
68
|
+
"
|
|
69
|
+
|
|
70
|
+
# 3. Run the background workers
|
|
71
|
+
llm-wiki daemon maintenance --workspace demo
|
|
72
|
+
llm-wiki daemon projection --workspace demo --vault ~/obsidian/wiki
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
See [QUICKSTART.md](QUICKSTART.md) for the full step-by-step tutorial.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## CLI reference
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
llm-wiki daemon projection --workspace <id> --vault <path> [--interval <s>]
|
|
83
|
+
llm-wiki daemon maintenance --workspace <id> [--interval <s>]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Full reference: [doc/cli_reference.md](doc/cli_reference.md)
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Docs
|
|
91
|
+
|
|
92
|
+
### System Documentation
|
|
93
|
+
|
|
94
|
+
| Document | Purpose |
|
|
95
|
+
|---|---|
|
|
96
|
+
| [QUICKSTART.md](QUICKSTART.md) | Step-by-step tutorial |
|
|
97
|
+
| [doc/cli_reference.md](doc/cli_reference.md) | CLI cheatsheet |
|
|
98
|
+
| [doc/diagrams.md](doc/diagrams.md) | CLI spider map, pipeline, algorithm & data-flow diagrams |
|
|
99
|
+
| [doc/architecture.md](doc/architecture.md) | System design |
|
|
100
|
+
| [doc/core_workflows.md](doc/core_workflows.md) | Workflow graph designs |
|
|
101
|
+
| [doc/lane_namespace_convention.md](doc/lane_namespace_convention.md) | Namespace/lane conventions |
|
|
102
|
+
| [doc/maintenance_job_taxonomy.md](doc/maintenance_job_taxonomy.md) | Maintenance job types |
|
|
103
|
+
| [doc/glossary.md](doc/glossary.md) | Term definitions |
|
|
104
|
+
| [doc/distillation_core_migration.md](doc/distillation_core_migration.md) | Notes on migrating distillation to kogwistar core |
|
|
105
|
+
| [STATUS.md](STATUS.md) | Implementation status |
|
|
106
|
+
|
|
107
|
+
### Ecosystem Analysis
|
|
108
|
+
|
|
109
|
+
| Document | Purpose |
|
|
110
|
+
|---|---|
|
|
111
|
+
| [doc/engineering_assessment.md](doc/engineering_assessment.md) | Engineering-level assessment of the author and ecosystem |
|
|
112
|
+
| [doc/ai_os_gap_analysis.md](doc/ai_os_gap_analysis.md) | Gap analysis: what is missing to become a genuine AI-native OS |
|
|
113
|
+
| [doc/ai_os_roadmap.md](doc/ai_os_roadmap.md) | Executable plan: polish to production + AI OS build order |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
pytest tests/unit/ # fast unit tests (in-memory, no services)
|
|
121
|
+
pytest -m integration # Obsidian vault + other on-disk integration checks
|
|
122
|
+
pytest -m manual # opt-in smoke tests requiring local services
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
After a successful ingest/projection run, the most useful manual checks are:
|
|
126
|
+
- maintenance jobs in the durable meta-store should be `DONE`
|
|
127
|
+
- projection jobs in the durable meta-store should be `DONE`
|
|
128
|
+
- the projection manifest row should be `ready`
|
|
129
|
+
- the Obsidian vault should contain the expected `.md` files
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "kogwistar-llm-wiki"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "LLM-Wiki: a continuously-learning knowledge system built on Kogwistar"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
keywords = ["knowledge-graph", "llm", "obsidian", "kogwistar", "wiki"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
"Topic :: Text Processing :: Indexing",
|
|
24
|
+
]
|
|
25
|
+
# The three sibling repos are NOT on PyPI and must be installed via the bootstrap:
|
|
26
|
+
# scripts/bootstrap-dev.sh
|
|
27
|
+
#
|
|
28
|
+
# kogwistar — imported at runtime (from kogwistar.engine_core / kogwistar.runtime)
|
|
29
|
+
# kogwistar-obsidian-sink — called by ProjectionManager at runtime
|
|
30
|
+
# kg-doc-parser — upstream ingestion tool; NOT a Python import dep of this package
|
|
31
|
+
# (it runs as a separate process/CLI, not imported in src/)
|
|
32
|
+
#
|
|
33
|
+
# Listing kogwistar / kogwistar-obsidian-sink here as hard deps would cause pip to fail
|
|
34
|
+
# on a clean install (not on PyPI). The bootstrap installs all siblings editable first.
|
|
35
|
+
dependencies = []
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
chromadb = ["chromadb>=0.6"]
|
|
39
|
+
test = [
|
|
40
|
+
"pytest>=8.0",
|
|
41
|
+
"pytest-anyio",
|
|
42
|
+
]
|
|
43
|
+
dev = [
|
|
44
|
+
"kogwistar-llm-wiki[test,chromadb]",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
llm-wiki = "kogwistar_llm_wiki.__main__:main"
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------------------
|
|
51
|
+
# uv-specific: when using `uv`, resolve sibling packages from local paths.
|
|
52
|
+
# This section is ignored by pip/setuptools.
|
|
53
|
+
# ---------------------------------------------------------------------------
|
|
54
|
+
[tool.uv.sources]
|
|
55
|
+
# uv resolves these from local paths when available. Ignored by pip/setuptools.
|
|
56
|
+
kogwistar = { path = "kogwistar", editable = true }
|
|
57
|
+
kogwistar-obsidian-sink = { path = "kogwistar-obsidian-sink", editable = true }
|
|
58
|
+
# kg-doc-parser is a sibling tool (not a Python import dep) but included here
|
|
59
|
+
# so uv users get the local version when working across repos.
|
|
60
|
+
kg-doc-parser = { path = "kg-doc-parser", editable = true }
|
|
61
|
+
|
|
62
|
+
[tool.setuptools]
|
|
63
|
+
package-dir = {"" = "src"}
|
|
64
|
+
|
|
65
|
+
[tool.setuptools.packages.find]
|
|
66
|
+
where = ["src"]
|
|
67
|
+
|
|
68
|
+
[tool.pytest.ini_options]
|
|
69
|
+
testpaths = ["tests"]
|
|
70
|
+
pythonpath = ["src"]
|
|
71
|
+
norecursedirs = ["kogwistar-llm-wiki-tests-*"]
|
|
72
|
+
markers = [
|
|
73
|
+
"manual: tests that are opt-in and may require local services",
|
|
74
|
+
"integration: tests that require real external backends (Chroma, Obsidian vault)",
|
|
75
|
+
]
|
|
76
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from .ingest_pipeline import (
|
|
2
|
+
IngestPipeline,
|
|
3
|
+
build_in_memory_namespace_engines,
|
|
4
|
+
)
|
|
5
|
+
from .models import (
|
|
6
|
+
IngestPipelineArtifacts,
|
|
7
|
+
IngestPipelineRequest,
|
|
8
|
+
ObsidianBuildResult,
|
|
9
|
+
NamespaceEngines,
|
|
10
|
+
ProjectionEntity,
|
|
11
|
+
ProjectionSnapshot,
|
|
12
|
+
)
|
|
13
|
+
from .namespaces import WorkspaceNamespaces
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"IngestPipeline",
|
|
17
|
+
"IngestPipelineArtifacts",
|
|
18
|
+
"IngestPipelineRequest",
|
|
19
|
+
"NamespaceEngines",
|
|
20
|
+
"ObsidianBuildResult",
|
|
21
|
+
"ProjectionEntity",
|
|
22
|
+
"ProjectionSnapshot",
|
|
23
|
+
"WorkspaceNamespaces",
|
|
24
|
+
"build_in_memory_namespace_engines",
|
|
25
|
+
]
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""CLI entry point: ``python -m kogwistar_llm_wiki``
|
|
2
|
+
|
|
3
|
+
Sub-commands
|
|
4
|
+
------------
|
|
5
|
+
daemon projection --workspace <id> --vault <path> [--interval <s>]
|
|
6
|
+
Run the Obsidian projection daemon (blocking).
|
|
7
|
+
|
|
8
|
+
daemon maintenance --workspace <id> [--interval <s>]
|
|
9
|
+
Run the maintenance distillation daemon (blocking).
|
|
10
|
+
|
|
11
|
+
Both commands expect KOGWISTAR_DATA_DIR (or --data-dir) to point at a
|
|
12
|
+
directory containing the SQLite meta-store and any persistent backend state.
|
|
13
|
+
"""
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
import logging
|
|
18
|
+
import signal
|
|
19
|
+
import sys
|
|
20
|
+
|
|
21
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s")
|
|
22
|
+
logger = logging.getLogger("kogwistar_llm_wiki")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _build_engines(workspace_id: str, data_dir: str | None):
|
|
26
|
+
"""Construct a NamespaceEngines bundle from the given data directory."""
|
|
27
|
+
from kogwistar_llm_wiki.ingest_pipeline import build_in_memory_namespace_engines
|
|
28
|
+
|
|
29
|
+
return build_in_memory_namespace_engines(base_dir=data_dir or None)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _cmd_daemon_projection(args: argparse.Namespace) -> None:
|
|
33
|
+
from kogwistar_llm_wiki.daemon import ProjectionDaemon
|
|
34
|
+
|
|
35
|
+
engines = _build_engines(args.workspace, args.data_dir)
|
|
36
|
+
daemon = ProjectionDaemon(
|
|
37
|
+
engines=engines,
|
|
38
|
+
workspace_id=args.workspace,
|
|
39
|
+
vault_root=args.vault,
|
|
40
|
+
poll_interval=args.interval,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def _stop(sig, frame): # noqa: ANN001
|
|
44
|
+
logger.info("Received signal %s — stopping ProjectionDaemon…", sig)
|
|
45
|
+
daemon.stop()
|
|
46
|
+
|
|
47
|
+
signal.signal(signal.SIGINT, _stop)
|
|
48
|
+
signal.signal(signal.SIGTERM, _stop)
|
|
49
|
+
daemon.run()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def _cmd_daemon_maintenance(args: argparse.Namespace) -> None:
|
|
53
|
+
from kogwistar_llm_wiki.daemon import MaintenanceDaemon
|
|
54
|
+
|
|
55
|
+
engines = _build_engines(args.workspace, args.data_dir)
|
|
56
|
+
daemon = MaintenanceDaemon(
|
|
57
|
+
engines=engines,
|
|
58
|
+
workspace_id=args.workspace,
|
|
59
|
+
poll_interval=args.interval,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
def _stop(sig, frame): # noqa: ANN001
|
|
63
|
+
logger.info("Received signal %s — stopping MaintenanceDaemon…", sig)
|
|
64
|
+
daemon.stop()
|
|
65
|
+
|
|
66
|
+
signal.signal(signal.SIGINT, _stop)
|
|
67
|
+
signal.signal(signal.SIGTERM, _stop)
|
|
68
|
+
daemon.run()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main() -> None:
|
|
72
|
+
parser = argparse.ArgumentParser(
|
|
73
|
+
prog="python -m kogwistar_llm_wiki",
|
|
74
|
+
description="LLM-Wiki background worker CLI",
|
|
75
|
+
)
|
|
76
|
+
parser.add_argument("--data-dir", default=None, help="Path to persistent data directory")
|
|
77
|
+
|
|
78
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
79
|
+
|
|
80
|
+
# daemon sub-command
|
|
81
|
+
daemon_p = sub.add_parser("daemon", help="Run a background daemon")
|
|
82
|
+
daemon_sub = daemon_p.add_subparsers(dest="daemon_type", required=True)
|
|
83
|
+
|
|
84
|
+
proj_p = daemon_sub.add_parser("projection", help="Obsidian projection daemon")
|
|
85
|
+
proj_p.add_argument("--workspace", required=True, help="Workspace ID")
|
|
86
|
+
proj_p.add_argument("--vault", required=True, help="Obsidian vault root path")
|
|
87
|
+
proj_p.add_argument("--interval", type=float, default=5.0, help="Poll interval (seconds)")
|
|
88
|
+
proj_p.set_defaults(func=_cmd_daemon_projection)
|
|
89
|
+
|
|
90
|
+
maint_p = daemon_sub.add_parser("maintenance", help="Maintenance distillation daemon")
|
|
91
|
+
maint_p.add_argument("--workspace", required=True, help="Workspace ID")
|
|
92
|
+
maint_p.add_argument("--interval", type=float, default=10.0, help="Poll interval (seconds)")
|
|
93
|
+
maint_p.set_defaults(func=_cmd_daemon_maintenance)
|
|
94
|
+
|
|
95
|
+
args = parser.parse_args()
|
|
96
|
+
args.func(args)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == "__main__":
|
|
100
|
+
sys.exit(main())
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Literal, Optional
|
|
4
|
+
from pydantic import BaseModel, Field
|
|
5
|
+
from pydantic_extension.model_slicing import ModeSlicingMixin, DtoType, BackendType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MessageEnvelope(ModeSlicingMixin, BaseModel):
|
|
9
|
+
target: DtoType[Literal["foreground", "background"]] | DtoType[str]
|
|
10
|
+
payload: DtoType[Any]
|
|
11
|
+
intent: DtoType[Literal["request", "notification", "alert"]] = "notification"
|
|
12
|
+
provenance_id: DtoType[Optional[str]] = None
|
|
13
|
+
|
|
14
|
+
# Internal metadata not shared with DTO by default if we want
|
|
15
|
+
internal_trace_id: BackendType[Optional[str]] = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class MessageChannel:
|
|
19
|
+
"""
|
|
20
|
+
Generalized message channel helper for cross-lane and cross-system messaging.
|
|
21
|
+
Facilitates future external channel integrations with shape fixing.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def wrap_message(
|
|
26
|
+
payload: Any,
|
|
27
|
+
target: Literal["foreground", "background"] | str,
|
|
28
|
+
intent: Literal["request", "notification", "alert"] = "notification",
|
|
29
|
+
provenance_id: Optional[str] = None
|
|
30
|
+
) -> Dict[str, Any]:
|
|
31
|
+
"""
|
|
32
|
+
Wraps a payload into a MessageEnvelope and returns its DTO view.
|
|
33
|
+
"""
|
|
34
|
+
envelope = MessageEnvelope(
|
|
35
|
+
target=target,
|
|
36
|
+
payload=payload,
|
|
37
|
+
intent=intent,
|
|
38
|
+
provenance_id=provenance_id
|
|
39
|
+
)
|
|
40
|
+
# Return the DTO slice as a dict for external consumption
|
|
41
|
+
return envelope["dto"](
|
|
42
|
+
target=envelope.target,
|
|
43
|
+
payload=envelope.payload,
|
|
44
|
+
intent=envelope.intent,
|
|
45
|
+
provenance_id=envelope.provenance_id
|
|
46
|
+
).model_dump()
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""Long-running daemon loops for background workers.
|
|
2
|
+
|
|
3
|
+
Usage (foreground, blocking):
|
|
4
|
+
python -m kogwistar_llm_wiki daemon projection --workspace demo --vault /path/to/vault
|
|
5
|
+
python -m kogwistar_llm_wiki daemon maintenance --workspace demo
|
|
6
|
+
|
|
7
|
+
Both daemons can also be imported and embedded in any host process:
|
|
8
|
+
|
|
9
|
+
from kogwistar_llm_wiki.daemon import ProjectionDaemon, MaintenanceDaemon
|
|
10
|
+
|
|
11
|
+
Design notes
|
|
12
|
+
------------
|
|
13
|
+
- Each daemon is a single-threaded polling loop with configurable sleep.
|
|
14
|
+
- They share the caller-provided ``NamespaceEngines`` — no daemon-internal
|
|
15
|
+
engine construction. The caller owns engine lifecycle.
|
|
16
|
+
- ``stop()`` is thread-safe (sets a threading.Event) so a signal handler or
|
|
17
|
+
supervisor thread can gracefully shut down the loop.
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
import logging
|
|
22
|
+
import threading
|
|
23
|
+
import time
|
|
24
|
+
from typing import Optional
|
|
25
|
+
|
|
26
|
+
from .models import NamespaceEngines
|
|
27
|
+
from .projection_worker import ProjectionWorker
|
|
28
|
+
from .worker import MaintenanceWorker
|
|
29
|
+
|
|
30
|
+
logger = logging.getLogger(__name__)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ProjectionDaemon:
|
|
34
|
+
"""Polls and drains the Obsidian projection queue for one workspace.
|
|
35
|
+
|
|
36
|
+
Parameters
|
|
37
|
+
----------
|
|
38
|
+
engines:
|
|
39
|
+
Shared ``NamespaceEngines`` bundle (caller owns lifecycle).
|
|
40
|
+
workspace_id:
|
|
41
|
+
The workspace this daemon is responsible for.
|
|
42
|
+
vault_root:
|
|
43
|
+
Filesystem path to the Obsidian vault root.
|
|
44
|
+
poll_interval:
|
|
45
|
+
Seconds to sleep between poll cycles when the queue is empty.
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
def __init__(
|
|
49
|
+
self,
|
|
50
|
+
engines: NamespaceEngines,
|
|
51
|
+
workspace_id: str,
|
|
52
|
+
vault_root: str,
|
|
53
|
+
poll_interval: float = 5.0,
|
|
54
|
+
) -> None:
|
|
55
|
+
self.engines = engines
|
|
56
|
+
self.workspace_id = workspace_id
|
|
57
|
+
self.vault_root = vault_root
|
|
58
|
+
self.poll_interval = poll_interval
|
|
59
|
+
self._worker = ProjectionWorker(engines)
|
|
60
|
+
self._stop_event = threading.Event()
|
|
61
|
+
|
|
62
|
+
def stop(self) -> None:
|
|
63
|
+
"""Signal the daemon to exit after the current poll cycle."""
|
|
64
|
+
self._stop_event.set()
|
|
65
|
+
|
|
66
|
+
def run(self) -> None:
|
|
67
|
+
"""Block and poll until ``stop()`` is called."""
|
|
68
|
+
logger.info(
|
|
69
|
+
"ProjectionDaemon started — workspace=%s vault=%s interval=%.1fs",
|
|
70
|
+
self.workspace_id,
|
|
71
|
+
self.vault_root,
|
|
72
|
+
self.poll_interval,
|
|
73
|
+
)
|
|
74
|
+
while not self._stop_event.is_set():
|
|
75
|
+
try:
|
|
76
|
+
self._worker.process_pending_projections(
|
|
77
|
+
self.workspace_id, self.vault_root
|
|
78
|
+
)
|
|
79
|
+
except Exception:
|
|
80
|
+
logger.exception("ProjectionDaemon: unhandled error in poll cycle")
|
|
81
|
+
self._stop_event.wait(timeout=self.poll_interval)
|
|
82
|
+
logger.info("ProjectionDaemon stopped — workspace=%s", self.workspace_id)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class MaintenanceDaemon:
|
|
86
|
+
"""Polls and drains the maintenance job queue for one workspace.
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
engines:
|
|
91
|
+
Shared ``NamespaceEngines`` bundle (caller owns lifecycle).
|
|
92
|
+
workspace_id:
|
|
93
|
+
The workspace this daemon is responsible for.
|
|
94
|
+
poll_interval:
|
|
95
|
+
Seconds to sleep between poll cycles when the queue is empty.
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
def __init__(
|
|
99
|
+
self,
|
|
100
|
+
engines: NamespaceEngines,
|
|
101
|
+
workspace_id: str,
|
|
102
|
+
poll_interval: float = 10.0,
|
|
103
|
+
) -> None:
|
|
104
|
+
self.engines = engines
|
|
105
|
+
self.workspace_id = workspace_id
|
|
106
|
+
self.poll_interval = poll_interval
|
|
107
|
+
self._worker = MaintenanceWorker(engines)
|
|
108
|
+
self._stop_event = threading.Event()
|
|
109
|
+
|
|
110
|
+
def stop(self) -> None:
|
|
111
|
+
"""Signal the daemon to exit after the current poll cycle."""
|
|
112
|
+
self._stop_event.set()
|
|
113
|
+
|
|
114
|
+
def run(self) -> None:
|
|
115
|
+
"""Block and poll until ``stop()`` is called."""
|
|
116
|
+
logger.info(
|
|
117
|
+
"MaintenanceDaemon started — workspace=%s interval=%.1fs",
|
|
118
|
+
self.workspace_id,
|
|
119
|
+
self.poll_interval,
|
|
120
|
+
)
|
|
121
|
+
while not self._stop_event.is_set():
|
|
122
|
+
try:
|
|
123
|
+
self._worker.process_pending_jobs(self.workspace_id)
|
|
124
|
+
except Exception:
|
|
125
|
+
logger.exception("MaintenanceDaemon: unhandled error in poll cycle")
|
|
126
|
+
self._stop_event.wait(timeout=self.poll_interval)
|
|
127
|
+
logger.info("MaintenanceDaemon stopped — workspace=%s", self.workspace_id)
|