bootstrap.py
python
sha256:cf6265cea8c21d9228d90dec13ef6ec2dab5103d466db9cc4590681832de4bf8
docs(KD-STAGING): sync governance after KD-6b DONE
Human
12 days ago
| 1 | """Runtime bootstrap for the knowtation MCP namespace (§KD-5a.A(c)).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import logging |
| 6 | import pathlib |
| 7 | |
| 8 | from muse.plugins.knowtation.attestation import ( |
| 9 | load_air_config, |
| 10 | register_knowtation_attestation_provider, |
| 11 | ) |
| 12 | from muse.plugins.knowtation.icp_push_hook import register_knowtation_icp_push_hook |
| 13 | |
| 14 | logger = logging.getLogger(__name__) |
| 15 | |
| 16 | _DOMAIN_IGNORE_BLOCK = """\ |
| 17 | [domain.knowtation] |
| 18 | patterns = [ |
| 19 | "data/", |
| 20 | ".obsidian/", |
| 21 | ] |
| 22 | """ |
| 23 | |
| 24 | |
| 25 | def ensure_knowtation_museignore(root: pathlib.Path) -> None: |
| 26 | """Ensure ``.museignore`` excludes ``data/`` and ``.obsidian/`` (§KD-5a.A(d)).""" |
| 27 | ignore_path = root / ".museignore" |
| 28 | if ignore_path.exists(): |
| 29 | text = ignore_path.read_text(encoding="utf-8") |
| 30 | if "[domain.knowtation]" in text and "data/" in text: |
| 31 | return |
| 32 | if "[domain.knowtation]" not in text: |
| 33 | merged = text.rstrip() + "\n\n" + _DOMAIN_IGNORE_BLOCK |
| 34 | ignore_path.write_text(merged, encoding="utf-8") |
| 35 | return |
| 36 | ignore_path.write_text( |
| 37 | "# Muse ignore patterns\n\n" + _DOMAIN_IGNORE_BLOCK, |
| 38 | encoding="utf-8", |
| 39 | ) |
| 40 | |
| 41 | |
| 42 | def bootstrap_knowtation_mcp(root: pathlib.Path) -> None: |
| 43 | """Register attestation + ICP push hook at MCP server start (not ``__init__.py``). |
| 44 | |
| 45 | Idempotent — safe to call on every server initialisation when the active |
| 46 | domain is ``knowtation``. |
| 47 | |
| 48 | Args: |
| 49 | root: Muse repository root (contains ``.muse/``). |
| 50 | """ |
| 51 | ensure_knowtation_museignore(root) |
| 52 | cfg = load_air_config(root / ".muse" / "air.yaml") |
| 53 | register_knowtation_attestation_provider(cfg) |
| 54 | register_knowtation_icp_push_hook() |
| 55 | logger.debug("knowtation MCP bootstrap: attestation + ICP push hook registered") |
| 56 | |
| 57 | |
| 58 | __all__ = ["bootstrap_knowtation_mcp", "ensure_knowtation_museignore"] |
File History
1 commit
sha256:cf6265cea8c21d9228d90dec13ef6ec2dab5103d466db9cc4590681832de4bf8
docs(KD-STAGING): sync governance after KD-6b DONE
Human
12 days ago