mcp-osiris 0.1.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.
- mcp_osiris-0.1.0/.gitignore +37 -0
- mcp_osiris-0.1.0/AGENTS.md +118 -0
- mcp_osiris-0.1.0/CHANGELOG.md +45 -0
- mcp_osiris-0.1.0/LICENSE +21 -0
- mcp_osiris-0.1.0/PKG-INFO +384 -0
- mcp_osiris-0.1.0/PUBLISH.md +142 -0
- mcp_osiris-0.1.0/README.md +352 -0
- mcp_osiris-0.1.0/bench/__init__.py +4 -0
- mcp_osiris-0.1.0/bench/fixtures/src/Profile.psm1 +359 -0
- mcp_osiris-0.1.0/bench/fixtures/tests/Profile.Tests.ps1 +36 -0
- mcp_osiris-0.1.0/bench/run_bench.py +569 -0
- mcp_osiris-0.1.0/dashboard/__init__.py +8 -0
- mcp_osiris-0.1.0/dashboard/server.py +825 -0
- mcp_osiris-0.1.0/dashboard/web/app.js +420 -0
- mcp_osiris-0.1.0/dashboard/web/index.html +144 -0
- mcp_osiris-0.1.0/dashboard/web/logo.svg +21 -0
- mcp_osiris-0.1.0/dashboard/web/styles.css +196 -0
- mcp_osiris-0.1.0/mcp.example.json +16 -0
- mcp_osiris-0.1.0/npm/LICENSE +21 -0
- mcp_osiris-0.1.0/npm/README.md +72 -0
- mcp_osiris-0.1.0/npm/bin/osiris-mcp.js +83 -0
- mcp_osiris-0.1.0/npm/package.json +50 -0
- mcp_osiris-0.1.0/pyproject.toml +105 -0
- mcp_osiris-0.1.0/scripts/measure_schemas.py +94 -0
- mcp_osiris-0.1.0/scripts/smoke_stdio.py +85 -0
- mcp_osiris-0.1.0/server.json +54 -0
- mcp_osiris-0.1.0/smithery.yaml +31 -0
- mcp_osiris-0.1.0/src/osiris/__init__.py +9 -0
- mcp_osiris-0.1.0/src/osiris/__main__.py +28 -0
- mcp_osiris-0.1.0/src/osiris/audit.py +366 -0
- mcp_osiris-0.1.0/src/osiris/cli.py +175 -0
- mcp_osiris-0.1.0/src/osiris/config.py +171 -0
- mcp_osiris-0.1.0/src/osiris/core/__init__.py +24 -0
- mcp_osiris-0.1.0/src/osiris/core/adaptive.py +213 -0
- mcp_osiris-0.1.0/src/osiris/core/compaction.py +126 -0
- mcp_osiris-0.1.0/src/osiris/core/compass.py +147 -0
- mcp_osiris-0.1.0/src/osiris/core/db.py +218 -0
- mcp_osiris-0.1.0/src/osiris/core/errors.py +27 -0
- mcp_osiris-0.1.0/src/osiris/core/events.py +275 -0
- mcp_osiris-0.1.0/src/osiris/core/fileops.py +94 -0
- mcp_osiris-0.1.0/src/osiris/core/handoff.py +166 -0
- mcp_osiris-0.1.0/src/osiris/core/ids.py +89 -0
- mcp_osiris-0.1.0/src/osiris/core/invariants.py +195 -0
- mcp_osiris-0.1.0/src/osiris/core/ledger.py +303 -0
- mcp_osiris-0.1.0/src/osiris/core/loopguard.py +276 -0
- mcp_osiris-0.1.0/src/osiris/core/manifest.py +70 -0
- mcp_osiris-0.1.0/src/osiris/core/memory.py +162 -0
- mcp_osiris-0.1.0/src/osiris/core/policy.py +105 -0
- mcp_osiris-0.1.0/src/osiris/core/prefix.py +374 -0
- mcp_osiris-0.1.0/src/osiris/core/pressure.py +101 -0
- mcp_osiris-0.1.0/src/osiris/core/prune.py +215 -0
- mcp_osiris-0.1.0/src/osiris/core/query.py +277 -0
- mcp_osiris-0.1.0/src/osiris/core/redact.py +83 -0
- mcp_osiris-0.1.0/src/osiris/core/refs.py +251 -0
- mcp_osiris-0.1.0/src/osiris/core/runtime.py +191 -0
- mcp_osiris-0.1.0/src/osiris/core/task_state.py +311 -0
- mcp_osiris-0.1.0/src/osiris/core/tokens.py +58 -0
- mcp_osiris-0.1.0/src/osiris/server.py +1597 -0
- mcp_osiris-0.1.0/src/osiris/tools/__init__.py +39 -0
- mcp_osiris-0.1.0/tests/conftest.py +65 -0
- mcp_osiris-0.1.0/tests/test_audit.py +70 -0
- mcp_osiris-0.1.0/tests/test_core_invariants.py +88 -0
- mcp_osiris-0.1.0/tests/test_core_loopguard.py +62 -0
- mcp_osiris-0.1.0/tests/test_core_prefix.py +179 -0
- mcp_osiris-0.1.0/tests/test_core_refs.py +73 -0
- mcp_osiris-0.1.0/tests/test_core_state.py +95 -0
- mcp_osiris-0.1.0/tests/test_mcp_tools.py +563 -0
- mcp_osiris-0.1.0/tests/test_smoke.py +30 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Environnement virtuel isolé
|
|
2
|
+
.venv/
|
|
3
|
+
|
|
4
|
+
# Python
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.egg-info/
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
|
|
11
|
+
# Outils
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.ruff_cache/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
coverage.xml
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# Données runtime (conservées localement, non versionnées)
|
|
19
|
+
data/*
|
|
20
|
+
!data/.gitkeep
|
|
21
|
+
|
|
22
|
+
# Secrets
|
|
23
|
+
.env
|
|
24
|
+
.env.*
|
|
25
|
+
|
|
26
|
+
# Packaging / publication
|
|
27
|
+
node_modules/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
dist/
|
|
30
|
+
npm/*.tgz
|
|
31
|
+
|
|
32
|
+
# Sauvegardes et logs locaux (jamais dans la distribution)
|
|
33
|
+
*.bak*
|
|
34
|
+
_backup_*/
|
|
35
|
+
_livetest/
|
|
36
|
+
*.log
|
|
37
|
+
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# AGENTS.md — OSIRIS
|
|
2
|
+
|
|
3
|
+
## ⛔ Règle de périmètre — PRIORITÉ ABSOLUE
|
|
4
|
+
|
|
5
|
+
**Ce projet est 100% AUTONOME. Ne jamais toucher aux autres projets de l'utilisateur.**
|
|
6
|
+
|
|
7
|
+
Interdits absolus, sans exception ni autorisation implicite :
|
|
8
|
+
|
|
9
|
+
- ❌ Modifier, refactorer, restructurer, migrer, renommer ou supprimer un autre projet
|
|
10
|
+
- ❌ `pip install` d'un autre projet de l'utilisateur (ex. `loom-mcp`) ou dépendance par chemin
|
|
11
|
+
- ❌ `import` d'un module d'un autre projet
|
|
12
|
+
- ❌ Référencer un chemin absolu vers un autre dossier de projet
|
|
13
|
+
- ❌ Partager une base de données, un schéma ou un fichier avec un autre projet
|
|
14
|
+
- ❌ Proposer ou appliquer une « absorption », « fusion » ou « migration » d'un autre projet
|
|
15
|
+
- ❌ Modifier la configuration MCP globale (`C:\Users\Tech\.minimax\mcp.json`) sans accord explicite
|
|
16
|
+
|
|
17
|
+
Projets existants protégés : `D:\Loom`, `D:\AI-Stack` (SuperLocalMemory),
|
|
18
|
+
`D:\CacheForge`, `D:\IcyCache`, `D:\MCP`, `D:\MCP_TEST` — et tout autre dossier
|
|
19
|
+
du disque hors de `D:\MCP-Osiris`.
|
|
20
|
+
|
|
21
|
+
**Zone d'écriture autorisée : `D:\MCP-Osiris` uniquement.**
|
|
22
|
+
|
|
23
|
+
L'inspection **en lecture seule** d'un projet existant doit être **demandée**,
|
|
24
|
+
jamais présumée. En cas de doute, demander avant de lire.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Ce qui est autonome ici
|
|
29
|
+
|
|
30
|
+
Tout le code est écrit from scratch dans `src/osiris/`. Les seules dépendances
|
|
31
|
+
autorisées sont des **paquets PyPI publics** : `mcp`, `fastmcp`, `pydantic`,
|
|
32
|
+
`httpx`, `PyYAML`, `rich`, `tiktoken`.
|
|
33
|
+
|
|
34
|
+
| Besoin | Implémentation locale |
|
|
35
|
+
|---|---|
|
|
36
|
+
| Comptage de tokens | `core/tokens.py` (tiktoken, repli heuristique) |
|
|
37
|
+
| Stockage des refs | `core/refs.py` (SQLite local, content-addressed) |
|
|
38
|
+
| Masquage des secrets | `core/redact.py` (avant le hash) |
|
|
39
|
+
| Lecture de fichiers | `core/fileops.py` (sandbox, racines autorisées) |
|
|
40
|
+
| Mémoire typée | `core/memory.py` + `core/task_state.py` |
|
|
41
|
+
| Journal / checkpoints | `core/events.py` |
|
|
42
|
+
| Coût / économies | `core/ledger.py` |
|
|
43
|
+
| Cache / drift | `core/prefix.py` |
|
|
44
|
+
| Filtrage serveur des payloads | `core/query.py` (grep, range, outline, aggregate, jsonl) |
|
|
45
|
+
| Compaction (trim/compact/clear) | `core/compaction.py` |
|
|
46
|
+
| Pression contexte | `core/pressure.py` |
|
|
47
|
+
| Anti-boucle | `core/loopguard.py` |
|
|
48
|
+
| Invariants | `core/invariants.py` |
|
|
49
|
+
| Handoff | `core/handoff.py` |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Invariants du produit (à ne pas casser)
|
|
54
|
+
|
|
55
|
+
1. **Le prune déplace, il ne supprime jamais.** Il n'existe aucun chemin de code
|
|
56
|
+
qui supprime un payload. C'est ce qui rend la preuve LOSSLESS possible.
|
|
57
|
+
2. **Les décisions et les contraintes sont append-only, et leur réécriture est
|
|
58
|
+
détectée.** Elles vivent dans la queue (`tail_hash`), pas dans le head :
|
|
59
|
+
les ajouter ne doit **jamais** déclencher un drift critique (le prefixe
|
|
60
|
+
cache est intact). Réécrire un élément épinglé est détecté par comparaison
|
|
61
|
+
des collections elles-mêmes (`core/prefix.py::rewritten_pins`) et signalé
|
|
62
|
+
comme rupture **sémantique** (`verdict: critical`, `cause: pinned_rewrite`,
|
|
63
|
+
`semantic_break: true`). Le cache n'est pas invalidé, l'état de la tâche si.
|
|
64
|
+
*Avant correction, les contraintes étaient dans le head et la réécriture
|
|
65
|
+
d'une décision n'était pas détectée du tout : l'invariant n°2 était
|
|
66
|
+
documentaire, pas implémenté.*
|
|
67
|
+
3. **L'agent ne calcule jamais de hash.** Il transmet les arguments bruts ;
|
|
68
|
+
OSIRIS canonicalise et digeste.
|
|
69
|
+
4. **Les réponses des outils restent courtes.** Garde-fou dans
|
|
70
|
+
`tests/test_mcp_tools.py` : `plan` < 260 tokens, `observe` < 110,
|
|
71
|
+
`checkpoint` < 110. OSIRIS ne doit pas devenir un consommateur de contexte.
|
|
72
|
+
5. **Le surcoût d'OSIRIS est mesuré** (ledger kind `overhead`) et le gain net
|
|
73
|
+
est exposé dans le rapport. Si le net est négatif, `osiris.plan` prévient
|
|
74
|
+
l'agent.
|
|
75
|
+
6. **Aucun prix provider n'est codé en dur** : la table de prix vient de
|
|
76
|
+
`~/.osiris/pricing.json`.
|
|
77
|
+
7. **Le TTL du cache est un paramètre**, pas une dépendance provider. Le TTL
|
|
78
|
+
est **déterministe** : `P(cache_mort)` est un seuil (0 avant, 1 après), pas
|
|
79
|
+
une rampe `Δt/TTL`.
|
|
80
|
+
8. **Déplacé ≠ gagné.** `tokens_moved` = payload déplacé vers un ref ;
|
|
81
|
+
`tokens_saved` = tokens dont la sortie du contexte est **prouvée** par
|
|
82
|
+
l'accusé de réception de l'agent (`observe(kind="dropped")`). Invariant
|
|
83
|
+
garanti par un test : `tokens_saved ≤ tokens_in`.
|
|
84
|
+
9. **Le tableau `tools` exposé ne change pas** (6 outils, ou 1 en mode
|
|
85
|
+
`OSIRIS_DISPATCH_ONLY=1`) : il fait partie du prefixe mis en cache.
|
|
86
|
+
10. **Un serveur MCP ne peut pas compacter la fenêtre de l'hôte** : OSIRIS
|
|
87
|
+
fournit les artefacts (`compact`/`trim`/`clear`, resources), la réduction
|
|
88
|
+
reste une décision de l'hôte.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Environnement
|
|
93
|
+
|
|
94
|
+
- Venv : `D:\MCP-Osiris\.venv` (CPython 3.12.10, via `uv`)
|
|
95
|
+
- Interpréteur : `.venv\Scripts\python.exe`
|
|
96
|
+
- Ne jamais installer dans le Python système.
|
|
97
|
+
- `OSIRIS_HOME` par défaut : `~/.osiris`. Pour un essai isolé :
|
|
98
|
+
`OSIRIS_HOME=D:\MCP-Osiris\data\home`.
|
|
99
|
+
|
|
100
|
+
## Commandes
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
.venv\Scripts\python.exe -m pytest tests -q # 76 tests
|
|
104
|
+
.venv\Scripts\python.exe -m ruff check src tests bench scripts
|
|
105
|
+
.venv\Scripts\python.exe -m osiris health
|
|
106
|
+
.venv\Scripts\python.exe scripts\smoke_stdio.py # E2E stdio
|
|
107
|
+
.venv\Scripts\python.exe bench\run_bench.py # benchmark + rentabilité
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Cycle de développement
|
|
111
|
+
|
|
112
|
+
1. Modifier dans `src/osiris/`.
|
|
113
|
+
2. `pytest` doit rester vert (76 tests) et `ruff check` propre.
|
|
114
|
+
3. Si le comportement des outils change : mettre à jour `README.md` (section
|
|
115
|
+
correspondante) et `tests/test_mcp_tools.py`.
|
|
116
|
+
4. Ne jamais casser la preuve LOSSLESS (`tests/test_audit.py`).
|
|
117
|
+
5. Ne jamais publier un chiffre qui ne sort pas de `bench/run_bench.py` : le
|
|
118
|
+
README §12 est regénéré depuis la sortie réelle, pas recopié.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-10-31
|
|
9
|
+
|
|
10
|
+
First public release.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **6 MCP tools** (`plan`, `precheck`, `observe`, `recall`, `checkpoint`, `handoff`),
|
|
15
|
+
stable table (invariant: the exposed tool array never changes, it is part of
|
|
16
|
+
the cached prefix).
|
|
17
|
+
- **Server-side payload filtering** (`recall(op=…)`): `grep`, `range`, `head`,
|
|
18
|
+
`tail`, `outline`, `aggregate`, `jsonl` — the agent only pays for the slice
|
|
19
|
+
it selects, not for the whole payload.
|
|
20
|
+
- **Honest ledger**: `tokens_moved` (payload relocated to a ref) is tracked
|
|
21
|
+
separately from `tokens_saved` (proved by the agent's withdrawal
|
|
22
|
+
acknowledgement or by a measured filtered access). Enforced invariant:
|
|
23
|
+
`tokens_saved ≤ tokens_in + tokens_moved`.
|
|
24
|
+
- **Cache-aware pruning**: the prune moves, never deletes; `cache_mort_probability`
|
|
25
|
+
is a threshold (0 before TTL, 1 after), and the elapsed time is measured from
|
|
26
|
+
the event journal.
|
|
27
|
+
- **Append-only decision/constraint queue** with rewrite detection
|
|
28
|
+
(`verdict: critical`, `cause: pinned_rewrite`, `semantic_break: true`).
|
|
29
|
+
- **LoopGuard** (duplicate and loop protection), **precheck** (invariants,
|
|
30
|
+
budget, duplicate refusal with `suggest_alternative`).
|
|
31
|
+
- **Context pressure** (`plan(mode="status")`), **reversible compaction**
|
|
32
|
+
(`checkpoint(mode="compact"|"trim"|"clear")`).
|
|
33
|
+
- **MCP resources** (`osiris://task/{task_id}/manifest`, `osiris://task/{task_id}/status`,
|
|
34
|
+
`osiris://ref/{ref}`) and the `osiris/task-resume` prompt.
|
|
35
|
+
- **Control Plane dashboard** (`osiris-dashboard`): live KPIs, ledger, integrity.
|
|
36
|
+
- **Verified benchmarks** (`bench/run_bench.py`): the README §10 table is
|
|
37
|
+
regenerated from the real bench output, never hand-written.
|
|
38
|
+
|
|
39
|
+
### Notes
|
|
40
|
+
|
|
41
|
+
- Measured on the reference machine: +15 % (800 tok prompt) to +71 % (20 000 tok
|
|
42
|
+
prompt) net context reduction; access cost 1 019 tokens of tool schemas.
|
|
43
|
+
- A server-side filter cannot replace an LLM, and an MCP server cannot shrink
|
|
44
|
+
the host's context window retroactively: OSIRIS provides the artefacts, the
|
|
45
|
+
host decides.
|
mcp_osiris-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Malik Belkacemi (MLKBLK-IT)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mcp-osiris
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OSIRIS — context engine cache-aware pour agents IA (serveur MCP local, provider-agnostic).
|
|
5
|
+
Project-URL: Homepage, https://github.com/MlkBlk-IT/osiris
|
|
6
|
+
Project-URL: Repository, https://github.com/MlkBlk-IT/osiris
|
|
7
|
+
Project-URL: Issues, https://github.com/MlkBlk-IT/osiris/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/MlkBlk-IT/osiris/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Malik Belkacemi
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,context-engine,cost,mcp,memory,osiris,prompt-cache
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: fastmcp>=2.0.0
|
|
21
|
+
Requires-Dist: httpx>=0.27.0
|
|
22
|
+
Requires-Dist: mcp>=1.2.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Requires-Dist: pyyaml>=6.0
|
|
25
|
+
Requires-Dist: rich>=13.0.0
|
|
26
|
+
Requires-Dist: tiktoken>=0.7.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.5.0; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<p align="center">
|
|
34
|
+
<img src="https://raw.githubusercontent.com/MlkBlk-IT/osiris/main/docs/mlkblk-banner-v2.svg" width="100%" alt="OSIRIS — Cache-aware context engine & state governor for AI agents" />
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
# OSIRIS
|
|
38
|
+
|
|
39
|
+
**Cache-aware context engine & state governor for AI agents.** Standard MCP server, local-first, independent of any model provider.
|
|
40
|
+
|
|
41
|
+
> OSIRIS makes AI agents cheaper, faster, and more reliable: fewer tokens, fewer loops, zero unnecessary tools, and zero loss of context.
|
|
42
|
+
|
|
43
|
+
OSIRIS does not replace your other MCP servers (filesystem, Git, GitHub, shell, browser…). It **coexists** alongside them and drastically cuts what they cost in prompt context.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 1. The Core Architectural Constraint
|
|
48
|
+
|
|
49
|
+
An MCP server **never sees** the final prompt assembled by the client host. It only sees what the agent sends to it. Therefore, OSIRIS cannot:
|
|
50
|
+
|
|
51
|
+
| What we would want | What a standard MCP server can actually do |
|
|
52
|
+
|---|---|
|
|
53
|
+
| Write directly into the prompt | Produce canonical state and **have the agent carry it** |
|
|
54
|
+
| Erase past conversation turns | Decide what to externalize **for future turns** |
|
|
55
|
+
| Hide another MCP server's tools | **Recommend** via Tool Compass |
|
|
56
|
+
| Hard-cap prompt tokens | Block an **action** (invariants, budget enforcement) |
|
|
57
|
+
|
|
58
|
+
The promise is honest: OSIRIS provides **stable state and an enforceable safety contract**, not a client prompt builder.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 2. Sealed Manifest — The Core Design
|
|
63
|
+
|
|
64
|
+
`osiris.plan` returns a deterministic block (~120 tokens) that the agent carries at a fixed position in its context window:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
OSIRIS/1 task=7c3f obj="fix PowerShell profile bug" plan=3/7
|
|
68
|
+
inv=4 files=6 refs=9 dec=2 budget=ok
|
|
69
|
+
SEAL=sha256:3f9a1c…c21b
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The `SEAL` is a SHA256 digest of stable zones. The agent passes it on every turn to `osiris.observe`: OSIRIS recomputes and detects any state drift immediately.
|
|
73
|
+
|
|
74
|
+
**This is OSIRIS's passive transport**: even if the agent stops calling tools, it carries the essential state cleanly.
|
|
75
|
+
|
|
76
|
+
### Three Hashes Because Prompt Cache is Prefix-Based
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
head_hash = sha256(system_head ‖ rules) immutable
|
|
80
|
+
zoneB_hash = sha256(objective ‖ global_plan ‖ tool_contract) quasi-stable
|
|
81
|
+
tail_hash = sha256(constraints ‖ pinned_decisions) append-only
|
|
82
|
+
prefix_hash = sha256(head_hash ‖ zoneB_hash) ← cached prefix
|
|
83
|
+
zoneA_hash = sha256(head_hash ‖ tail_hash) ← full ZONE A
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
| Change | Verdict | Cache Cost |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| `head_hash` | **CRITICAL DRIFT** | Full re-prefill |
|
|
89
|
+
| `zoneB_hash` | Minor drift | Re-prefill delta only |
|
|
90
|
+
| `tail_hash` (append) | **Normal growth** | Re-prefill delta only |
|
|
91
|
+
| Pinned item **rewritten** | **CRITICAL DRIFT (semantic)** | Cache intact, task state corrupted |
|
|
92
|
+
|
|
93
|
+
> **Appending** a constraint or decision changes `tail_hash` but **not** `prefix_hash`: the prompt cache holds, only the new tokens are prefilled.
|
|
94
|
+
>
|
|
95
|
+
> **Rewriting** a pinned decision is explicitly caught: OSIRIS checks collection identity, flagging a semantic break (`semantic_break: true`, `cause: pinned_rewrite`).
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 3. The 6 MCP Tools
|
|
100
|
+
|
|
101
|
+
Access footprint: **1,019 tokens** of schemas and descriptions in model context (measured via `bench/run_bench.py`). Paid on task start, amortized across the session — pays off on the very first turn with ≥800 token payloads.
|
|
102
|
+
|
|
103
|
+
| Tool | Role | Typical Response |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `osiris.plan` | Start / update / resume / status of a task; produces sealed manifest | ~160 tok |
|
|
106
|
+
| `osiris.precheck` | Authorize or deny an action (invariants, budget, deduplication) | ~70 tok |
|
|
107
|
+
| `osiris.observe` | Log actions, loop detection, offload large data, update memory | ~50 tok |
|
|
108
|
+
| `osiris.recall` | Rehydrate refs (**server-side filtered**: grep, range, outline) | variable |
|
|
109
|
+
| `osiris.checkpoint` | Snapshot, resume, completion report, reversible compaction | ~80 tok |
|
|
110
|
+
| `osiris.handoff` | Executable delegation contracts and structured results | ~200 tok |
|
|
111
|
+
|
|
112
|
+
`osiris.observe` combines logging, loop protection, payload externalization, memory registry, and automated pruning in a single call so the agent always reports back seamlessly.
|
|
113
|
+
|
|
114
|
+
### Extended Operations
|
|
115
|
+
|
|
116
|
+
| Call | Behavior |
|
|
117
|
+
|---|---|
|
|
118
|
+
| `osiris.observe(kind="dropped", result=<ref>)` | **Drop receipt**: agent confirms payload was evicted from prompt → token savings are **proven** and credited |
|
|
119
|
+
| `osiris.observe(kind="head"\|"contract", result=…)` | Records system prompt head / client contract and detects cache-busting volatile tokens (timestamps, UUIDs) |
|
|
120
|
+
| `osiris.recall(op="grep"\|"range"\|"head"\|"tail"\|"outline"\|"aggregate"\|"jsonl")` | **Server-side filtering**: only requested matches enter the context window |
|
|
121
|
+
| `osiris.plan(mode="status")` | Context pressure breakdown (measured vs declared vs unknown) |
|
|
122
|
+
| `osiris.checkpoint(mode="compact"\|"trim"\|"clear")` | Reversible session compaction preparation |
|
|
123
|
+
| `osiris.precheck` → `suggest_alternative` | Active collision resolution for duplicate operations |
|
|
124
|
+
|
|
125
|
+
### Resources & Prompts
|
|
126
|
+
|
|
127
|
+
- `osiris://task/{task_id}/manifest` — Active zones, drift status, objective
|
|
128
|
+
- `osiris://task/{task_id}/status` — Real-time context pressure
|
|
129
|
+
- `osiris://ref/{ref}` — Raw byte content of any referenced payload
|
|
130
|
+
- Prompt `osiris/task-resume` — Clean agent recovery template after crashes
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 4. Architecture
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
138
|
+
│ Agent (Claude Code, Cursor, MiniMax Code, Codex, Cline…) │
|
|
139
|
+
│ Context: system │ tools │ OSIRIS MANIFEST │ history │
|
|
140
|
+
└───────────────────────────┬──────────────────────────────────┘
|
|
141
|
+
│ MCP stdio — 6 tools, ~1,019 tok schema
|
|
142
|
+
▼
|
|
143
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
144
|
+
│ osiris-mcp (server.py) │
|
|
145
|
+
│ plan · precheck · observe · recall · checkpoint · handoff │
|
|
146
|
+
└───────────────────────────┬──────────────────────────────────┘
|
|
147
|
+
│
|
|
148
|
+
┌───────────────────────────▼──────────────────────────────────┐
|
|
149
|
+
│ core/ │
|
|
150
|
+
│ task_state Typed TaskState (objective, plan, decisions) │
|
|
151
|
+
│ memory Typed memory registry by kind and scope │
|
|
152
|
+
│ refs Content-addressed store (verified on read) │
|
|
153
|
+
│ prefix Zones, 3-hash system, drift, PrefillPlan │
|
|
154
|
+
│ prune Reversible externalization, 4 modes │
|
|
155
|
+
│ query Server-side payload filtering (grep, range...) │
|
|
156
|
+
│ compaction trim / compact / clear (lossless) │
|
|
157
|
+
│ pressure Context pressure metrics & tracking │
|
|
158
|
+
│ loopguard Fingerprinting, 5 loop patterns detection │
|
|
159
|
+
│ invariants TOML rule engine (guard rails) │
|
|
160
|
+
│ compass Tool Compass (dynamic relevance scoring) │
|
|
161
|
+
│ handoff Executable agent delegation contracts │
|
|
162
|
+
│ events Append-only event journal + checkpoints │
|
|
163
|
+
│ ledger Tokens / cost / savings / OSIRIS overhead │
|
|
164
|
+
│ fileops Sandboxed file inspection (roots, size limits) │
|
|
165
|
+
│ redact Secret scrubbing before any hashing │
|
|
166
|
+
│ policy Budget policies & token enforcement │
|
|
167
|
+
└───────────────────────────┬──────────────────────────────────┘
|
|
168
|
+
▼
|
|
169
|
+
~/.osiris/osiris.db + ~/.osiris/reports/
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 5. Memory Model
|
|
175
|
+
|
|
176
|
+
Deterministic, typed, content-addressable memory — **not** an opaque vector database.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
TaskState
|
|
180
|
+
├── objective immutable
|
|
181
|
+
├── constraints[] append-only
|
|
182
|
+
├── decisions[] append-only, pinned verbatim
|
|
183
|
+
├── plan completed / active / remaining steps
|
|
184
|
+
├── files{} path, SHA-256 hash, mtime, last access, ref
|
|
185
|
+
├── tool_results{} cache_key, ref, size, token cost, TTL
|
|
186
|
+
├── failures{} error signature, tool, args hash, attempts, lesson
|
|
187
|
+
├── lessons[] general behavioral rules learned
|
|
188
|
+
├── handoffs{} cross-agent delegation contracts
|
|
189
|
+
└── budget estimated vs consumed tokens and cost
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Scopes: `task` → `project` → `agent` → `global`.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## 6. Cache-Aware Pruning
|
|
197
|
+
|
|
198
|
+
**Security Invariant: Pruning moves payload data to content-addressed refs (`mem://sha256:…`). It NEVER deletes.**
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
ZONE_A_pruning_cost = pruned_tokens
|
|
202
|
+
ZONE_C_or_D_pruning_cost = 0 ← always zero cost
|
|
203
|
+
net_savings = pruned_tokens − (prefix_tokens × P(cache_dead) × prefix_pruned)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
| Mode | Trigger | Evicts | Cache Impact | Use Case |
|
|
207
|
+
|---|---|---|---|---|
|
|
208
|
+
| `cache_ttl` (default) | `Δt > TTL` | C/D, and A/B only if cache expired | Neutral | **Recommended default** |
|
|
209
|
+
| `conservative` | Very high threshold | Working zone (C/D) only | Zero | High-cost API models |
|
|
210
|
+
| `balanced` | Moderate threshold | C/D + cold historical turns | Zero | Standard agent workflows |
|
|
211
|
+
| `aggressive` | Low threshold | Everything rehydratable | Minor prefill risk | Fast local LLMs |
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 7. LoopGuard Protection
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
fingerprint = sha256(tool ‖ canonical_args ‖ result_signature)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
| Detection | Trigger Signal | Verdict |
|
|
222
|
+
|---|---|---|
|
|
223
|
+
| Exact duplicate | Identical fingerprint | `suggest_alternative` |
|
|
224
|
+
| Repeated failure | Same error signature (≥3 times) | `block` + `required_action` |
|
|
225
|
+
| Loop pattern | Same error across varying args | `warn` |
|
|
226
|
+
| Oscillation | Alternating A/B/A/B pattern | `warn` |
|
|
227
|
+
| Runaway | N calls with zero state progress | `warn` / `block` |
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 8. Invariants (Guard Rails)
|
|
232
|
+
|
|
233
|
+
Define project safety rules in `.osiris/invariants.toml`:
|
|
234
|
+
|
|
235
|
+
```toml
|
|
236
|
+
[[invariant]]
|
|
237
|
+
id = "tests-before-commit"
|
|
238
|
+
when = { tool = "git.commit" }
|
|
239
|
+
require = { state = "tests_passed" }
|
|
240
|
+
message = "Cannot commit while tests are failing"
|
|
241
|
+
|
|
242
|
+
[[invariant]]
|
|
243
|
+
id = "no-test-edit"
|
|
244
|
+
when = { path_glob = "tests/**" }
|
|
245
|
+
verdict = "block"
|
|
246
|
+
message = "Modifying test suites requires explicit approval"
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 9. Lossless Verification & Non-Loss Proof
|
|
252
|
+
|
|
253
|
+
OSIRIS guarantees full auditability for offloaded data:
|
|
254
|
+
|
|
255
|
+
1. **Self-verifying refs**: `mem://sha256:<hash>`. Reads re-verify data integrity against the hash before returning.
|
|
256
|
+
2. **Zero deletion paths**: data is relocated to the local store, never pruned permanently.
|
|
257
|
+
3. **Reproducible audit**:
|
|
258
|
+
```bash
|
|
259
|
+
python -m osiris audit --task <task_id>
|
|
260
|
+
```
|
|
261
|
+
Outputs cryptographic proof of non-loss:
|
|
262
|
+
```json
|
|
263
|
+
{"lossless": true, "items_externalized": 14, "items_verified": 14, "items_missing": 0, "integrity_violations": []}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 10. Verified Benchmarks
|
|
269
|
+
|
|
270
|
+
Real measurements from `python bench\run_bench.py` running an automated coding workflow:
|
|
271
|
+
|
|
272
|
+
| Payload Size | Baseline Context | Fixed OSIRIS | Adaptive OSIRIS | Net Improvement | OSIRIS Mode | Overhead |
|
|
273
|
+
|---|---|---|---|---|---|---|
|
|
274
|
+
| **200 tok** | 1,583 | 2,687 | **1,651** | **−4.30%** | bystander | 34 tok |
|
|
275
|
+
| **800 tok** | 3,851 | 3,755 | **3,261** | **+15.32%** | light | 1,810 tok |
|
|
276
|
+
| **2,000 tok** | 9,015 | 5,229 | **5,233** | **+41.95%** | standard | 2,492 tok |
|
|
277
|
+
| **5,000 tok** | 20,979 | 8,171 | **8,168** | **+61.07%** | standard | 2,439 tok |
|
|
278
|
+
| **20,000 tok** | 82,135 | 23,427 | **23,440** | **+71.46%** | full | 2,422 tok |
|
|
279
|
+
|
|
280
|
+
- **Access Cost**: 1,019 tokens of schemas, amortized across session tasks.
|
|
281
|
+
- **Session Net Gate**: PASS (Worst-case net across full suite: **+951 tokens**).
|
|
282
|
+
- **At 20,000 tokens**: **+71.46% net savings** on context usage.
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 11. Quick Start
|
|
287
|
+
|
|
288
|
+
```powershell
|
|
289
|
+
cd D:\MCP-Osiris
|
|
290
|
+
uv venv --python 3.12 .venv
|
|
291
|
+
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### CLI Verification
|
|
295
|
+
|
|
296
|
+
```powershell
|
|
297
|
+
.venv\Scripts\python.exe -m pytest tests -q # Run test suite (76 passed)
|
|
298
|
+
.venv\Scripts\python.exe -m ruff check src tests # Code linting
|
|
299
|
+
.venv\Scripts\python.exe -m osiris health # Server health check
|
|
300
|
+
.venv\Scripts\python.exe -m osiris audit --task t_1 # Cryptographic non-loss proof
|
|
301
|
+
.venv\Scripts\python.exe bench\run_bench.py # Reproduce benchmarks
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Registration as MCP Server
|
|
305
|
+
|
|
306
|
+
Add to your client configuration (`mcp.json`):
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"mcpServers": {
|
|
311
|
+
"osiris": {
|
|
312
|
+
"command": "D:\\mcp-osiris\\.venv\\Scripts\\python.exe",
|
|
313
|
+
"args": ["-m", "osiris"],
|
|
314
|
+
"env": {
|
|
315
|
+
"OSIRIS_HOME": "C:\\Users\\Tech\\.osiris",
|
|
316
|
+
"OSIRIS_ROOTS": "D:\\mcp-osiris"
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## 12. Installation
|
|
326
|
+
|
|
327
|
+
### From PyPI (recommended)
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
pip install mcp-osiris # or: uv pip install mcp-osiris
|
|
331
|
+
mcp-osiris # runs the MCP server on stdio
|
|
332
|
+
osiris health # CLI verification
|
|
333
|
+
osiris-dashboard --port 8770 # Control Plane (dashboard)
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### From npm (no Python setup)
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
npx -y osiris-mcp
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
The npm package is a stdio launcher. It resolves the Python runtime in this
|
|
343
|
+
order — `OSIRIS_PYTHON` → `uvx` → `python3` → `python` — and runs the PyPI
|
|
344
|
+
package `mcp-osiris`.
|
|
345
|
+
|
|
346
|
+
### From source
|
|
347
|
+
|
|
348
|
+
```powershell
|
|
349
|
+
git clone https://github.com/MlkBlk-IT/osiris.git
|
|
350
|
+
cd osiris
|
|
351
|
+
uv venv --python 3.12 .venv
|
|
352
|
+
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### MCP client configuration
|
|
356
|
+
|
|
357
|
+
```json
|
|
358
|
+
{
|
|
359
|
+
"mcpServers": {
|
|
360
|
+
"osiris": {
|
|
361
|
+
"command": "npx",
|
|
362
|
+
"args": ["-y", "osiris-mcp"],
|
|
363
|
+
"env": {
|
|
364
|
+
"OSIRIS_HOME": "~/.osiris",
|
|
365
|
+
"OSIRIS_ROOTS": "/path/to/project"
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
| Variable | Default | Role |
|
|
373
|
+
|---|---|---|
|
|
374
|
+
| `OSIRIS_HOME` | `~/.osiris` | SQLite database, reports, caches |
|
|
375
|
+
| `OSIRIS_ROOTS` | *(empty)* | Roots allowed for file reading (`;` separated) |
|
|
376
|
+
| `OSIRIS_CACHE_TTL_S` | `300` | Cache TTL (seconds) |
|
|
377
|
+
| `OSIRIS_PRUNE_THRESHOLD_TOKENS` | `40000` | Prune threshold |
|
|
378
|
+
| `OSIRIS_DISPATCH_ONLY` | `0` | `1` → exposes only `osiris.call` |
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## License
|
|
383
|
+
|
|
384
|
+
MIT © 2026 Malik Belkacemi (MLKBLK-IT)
|