brainpick 0.8.0__tar.gz → 0.8.2__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.
Files changed (124) hide show
  1. {brainpick-0.8.0 → brainpick-0.8.2}/PKG-INFO +1 -1
  2. {brainpick-0.8.0 → brainpick-0.8.2}/pyproject.toml +1 -1
  3. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/__init__.py +1 -1
  4. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_releases/releases.yaml +48 -0
  5. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/cli.py +10 -4
  6. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/federation.py +22 -6
  7. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/PKG-INFO +1 -1
  8. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_cli.py +12 -3
  9. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_e2e_serve.py +37 -0
  10. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_federation.py +18 -0
  11. {brainpick-0.8.0 → brainpick-0.8.2}/README.md +0 -0
  12. {brainpick-0.8.0 → brainpick-0.8.2}/setup.cfg +0 -0
  13. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/__main__.py +0 -0
  14. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_ritual/RITUAL.md +0 -0
  15. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_skill/SKILL.md +0 -0
  16. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/Editor-K9XANZX_.js +0 -0
  17. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/index-DOjNNQV2.js +0 -0
  18. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/index-Dn6TTKMy.css +0 -0
  19. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/virtual_pwa-register-vAnKLON8.js +0 -0
  20. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/workbox-window.prod.es5-BBnX5xw4.js +0 -0
  21. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/assets/worker-CVB4_RMu.js +0 -0
  22. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/icons/apple-touch-icon.png +0 -0
  23. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/icons/favicon.svg +0 -0
  24. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/icons/icon-192.png +0 -0
  25. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/icons/icon-512.png +0 -0
  26. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/icons/icon-maskable-512.png +0 -0
  27. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/index.html +0 -0
  28. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/manifest.webmanifest +0 -0
  29. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/sw.js +0 -0
  30. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/_static/workbox-a3c94b52.js +0 -0
  31. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/auth.py +0 -0
  32. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/__init__.py +0 -0
  33. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/conventions.py +0 -0
  34. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/pipeline.py +0 -0
  35. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/similarity_gaps.py +0 -0
  36. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/skills.py +0 -0
  37. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/t1.py +0 -0
  38. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/t2.py +0 -0
  39. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/t3.py +0 -0
  40. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/compile/todos.py +0 -0
  41. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/config.py +0 -0
  42. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/__init__.py +0 -0
  43. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/bundle.py +0 -0
  44. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/canonical.py +0 -0
  45. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/frontmatter.py +0 -0
  46. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/fs.py +0 -0
  47. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/core/links.py +0 -0
  48. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/deltas.py +0 -0
  49. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/detect.py +0 -0
  50. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/embed.py +0 -0
  51. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/integrate.py +0 -0
  52. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/kg.py +0 -0
  53. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/kgadapt/__init__.py +0 -0
  54. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/kgadapt/algorithmic.py +0 -0
  55. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/kgadapt/protocol.py +0 -0
  56. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/llm.py +0 -0
  57. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/mcp_server.py +0 -0
  58. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/merge.py +0 -0
  59. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/migrate.py +0 -0
  60. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/__init__.py +0 -0
  61. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/half_life.py +0 -0
  62. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/keyword.py +0 -0
  63. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/present.py +0 -0
  64. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/router.py +0 -0
  65. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/query/vectors.py +0 -0
  66. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/releases.py +0 -0
  67. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/scaffold.py +0 -0
  68. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/__init__.py +0 -0
  69. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/app.py +0 -0
  70. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/live.py +0 -0
  71. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/rest.py +0 -0
  72. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/state.py +0 -0
  73. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/serve/watcher.py +0 -0
  74. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/skill_cmd.py +0 -0
  75. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/sync.py +0 -0
  76. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/timeline.py +0 -0
  77. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/update.py +0 -0
  78. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick/vectorstore.py +0 -0
  79. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/SOURCES.txt +0 -0
  80. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/dependency_links.txt +0 -0
  81. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/entry_points.txt +0 -0
  82. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/requires.txt +0 -0
  83. {brainpick-0.8.0 → brainpick-0.8.2}/src/brainpick.egg-info/top_level.txt +0 -0
  84. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_auth.py +0 -0
  85. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_bundle.py +0 -0
  86. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_config.py +0 -0
  87. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_conformance.py +0 -0
  88. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_conventions.py +0 -0
  89. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_deltas.py +0 -0
  90. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_detect.py +0 -0
  91. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_e2e_mcp.py +0 -0
  92. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_frontmatter.py +0 -0
  93. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_half_life.py +0 -0
  94. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_integrate.py +0 -0
  95. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_keyword.py +0 -0
  96. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_kg.py +0 -0
  97. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_links.py +0 -0
  98. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_llm.py +0 -0
  99. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_mcp_tools.py +0 -0
  100. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_merge.py +0 -0
  101. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_migrate.py +0 -0
  102. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_pipeline.py +0 -0
  103. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_present.py +0 -0
  104. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_releases.py +0 -0
  105. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_report.py +0 -0
  106. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_router.py +0 -0
  107. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_scaffold.py +0 -0
  108. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_serve_state.py +0 -0
  109. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_similarity_gaps.py +0 -0
  110. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_similarity_gaps_stage.py +0 -0
  111. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_skills.py +0 -0
  112. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_sync.py +0 -0
  113. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t1.py +0 -0
  114. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t2_chunker.py +0 -0
  115. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t2_embed.py +0 -0
  116. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t2_stage.py +0 -0
  117. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t2_store.py +0 -0
  118. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t3_algorithmic.py +0 -0
  119. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t3_backend.py +0 -0
  120. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t3_export.py +0 -0
  121. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_t3_stage.py +0 -0
  122. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_timeline.py +0 -0
  123. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_todos.py +0 -0
  124. {brainpick-0.8.0 → brainpick-0.8.2}/tests/test_update.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brainpick
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain.
5
5
  Author: Benquemax
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "brainpick"
7
- version = "0.8.0"
7
+ version = "0.8.2"
8
8
  description = "A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,4 +1,4 @@
1
1
  """brainpick — a turn-key brain stack for agents."""
2
2
 
3
- __version__ = "0.8.0"
3
+ __version__ = "0.8.2"
4
4
  SPEC_VERSION = "0.1"
@@ -15,6 +15,54 @@
15
15
  # area: brain | cli | mcp | search | config | compile | webui | docs
16
16
 
17
17
  releases:
18
+ - version: 0.8.2
19
+ date: 2026-09-25
20
+ brain_format: 3
21
+ summary: >-
22
+ `brainpick mcp --root <repo>` reads the repo's `brainpick.toml` again when
23
+ `[bundle] root` points below it. The brain set resolved the root down to
24
+ the bundle and then loaded the config from the bundle, found nothing there
25
+ and used defaults — so over MCP `[serve] git` stayed off (no sync verbs in
26
+ tools/list), `[half_life]` never faded and `[bundle] exclude` never hid.
27
+ agent_action: >-
28
+ Upgrade and restart any `brainpick mcp` server whose `--root` is a repo
29
+ root above its bundle, then check tools/list for brain_status / brain_sync
30
+ / brain_push if `[serve] git` is set. A stderr line "no brainpick.toml at
31
+ …/<bundle> — using defaults" on server start was this bug.
32
+ changes:
33
+ - kind: fixed
34
+ area: mcp
35
+ text: >-
36
+ `Brain` carries a `config_root` — the `--root` argument, or a registry
37
+ entry's repo — and `BrainSet.state_for` plus the mcp writes-refusal
38
+ load the config from there instead of from the bundle. Same family as
39
+ the 0.8.1 `serve` double-join: one path was made to mean two roots.
40
+ The Node engine never resolves `[bundle] root` inside its brain set,
41
+ so it is unchanged.
42
+ - version: 0.8.1
43
+ date: 2026-09-24
44
+ brain_format: 3
45
+ summary: >-
46
+ `brainpick serve` serves the bundle again when `[bundle] root` points
47
+ below the repo root: the CLI applied that path twice and served a
48
+ `<repo>/_brain/_brain` that does not exist, so the UI showed one
49
+ generated index, no links, and T2 reported off.
50
+ agent_action: >-
51
+ Upgrade and restart any running `brainpick serve`. If you worked around
52
+ this by serving from inside the bundle directory, drop the workaround —
53
+ that route reads no repo-root `brainpick.toml`, so it silently loses
54
+ `[bundle] exclude`, `[brain]` and the embedding backend.
55
+ changes:
56
+ - kind: fixed
57
+ area: cli
58
+ text: >-
59
+ `serve` pre-resolved `--root` with `resolve_bundle()` and handed the
60
+ result to `build_app()`, which joins `[bundle] root` itself — so a
61
+ repo-root config pointing at `_brain` was served as `_brain/_brain`.
62
+ The CLI now passes the raw `--root`, matching the Node engine, and
63
+ prints the resolved bundle. A brain whose bundle IS the repo root
64
+ (`root = "."`) was never affected, which is why this survived a
65
+ release.
18
66
  - version: 0.8.0
19
67
  date: 2026-09-19
20
68
  brain_format: 3
@@ -82,10 +82,15 @@ def _cmd_serve(args: argparse.Namespace) -> int:
82
82
 
83
83
  import uvicorn
84
84
 
85
- from brainpick.config import resolve_bundle
85
+ from brainpick.config import load_config
86
86
  from brainpick.serve.app import build_app
87
87
 
88
- root, config = resolve_bundle(args.root) # --root may be a repo root above the bundle (spec/80)
88
+ # --root may be a repo root above the bundle (spec/80). build_app resolves
89
+ # `root / [bundle] root` itself, so hand it the raw --root: pre-resolving
90
+ # with resolve_bundle() here would apply [bundle] root twice and serve a
91
+ # bundle/_brain that does not exist. The Node engine does the same.
92
+ root = Path(args.root).resolve()
93
+ config = load_config(root)
89
94
  if args.host is not None:
90
95
  config.serve.host = args.host
91
96
  if args.port is not None:
@@ -96,7 +101,8 @@ def _cmd_serve(args: argparse.Namespace) -> int:
96
101
  app = build_app(root, config)
97
102
  display_host = "127.0.0.1" if config.serve.host in ("0.0.0.0", "::") else config.serve.host
98
103
  url = f"http://{display_host}:{config.serve.port}/"
99
- print(f"serving {root} at {url} — UI /, REST /api, live /api/live, MCP /mcp (Ctrl-C stops)",
104
+ bundle = (root / config.bundle.root).resolve()
105
+ print(f"serving {bundle} at {url} — UI /, REST /api, live /api/live, MCP /mcp (Ctrl-C stops)",
100
106
  flush=True)
101
107
  if args.open:
102
108
  threading.Timer(0.8, webbrowser.open, [url]).start()
@@ -437,7 +443,7 @@ def _cmd_mcp(args: argparse.Namespace) -> int:
437
443
  if brain_set.federated:
438
444
  target = brain_set
439
445
  refusal = WRITES_OFF_REFUSAL if all(
440
- load_config(b.root).serve.writes == "off" for b in brain_set.brains) else None
446
+ load_config(b.config_root or b.root).serve.writes == "off" for b in brain_set.brains) else None
441
447
  else:
442
448
  target = brain_set.state_for(brain_set.brains[0])
443
449
  refusal = WRITES_OFF_REFUSAL if target.config.serve.writes == "off" else None
@@ -202,12 +202,18 @@ def entry_root(entry: dict, env: dict | None = None) -> Path | None:
202
202
  """Where a registry entry's bundle lives on THIS machine: a local repo directly,
203
203
  a remote one from its daemon clone — None when that clone does not exist
204
204
  (federation never clones)."""
205
- repo = entry["repo"]
206
- base = Path(repo).expanduser() if is_local_repo(repo) else data_dir(env) / "brains" / entry["id"]
205
+ base = _entry_base(entry, env)
207
206
  root = base / entry["bundle_path"] if entry.get("bundle_path") else base
208
207
  return root.resolve() if root.is_dir() else None
209
208
 
210
209
 
210
+ def _entry_base(entry: dict, env: dict | None = None) -> Path:
211
+ """The repo (or daemon clone) a registry entry points at — where its
212
+ brainpick.toml lives, one level above a `bundle_path` bundle."""
213
+ repo = entry["repo"]
214
+ return Path(repo).expanduser() if is_local_repo(repo) else data_dir(env) / "brains" / entry["id"]
215
+
216
+
211
217
  def _split_root(root: Path) -> tuple[str, str]:
212
218
  """(repo, bundle_path) for a local bundle — the git repo above it when there is
213
219
  one, so the registry entry matches what the daemon would write."""
@@ -295,10 +301,17 @@ class Brain:
295
301
  root: Path
296
302
  role: str | None = None
297
303
  here: bool = False
304
+ # Where brainpick.toml lives when the bundle is a subdirectory of its repo
305
+ # ([bundle] root, spec/80). `root` is the bundle; the config is NOT there, so
306
+ # loading it from `root` silently yields defaults (no [serve] git, no
307
+ # [half_life], no [bundle] exclude). None means the bundle is its own root.
308
+ config_root: Path | None = None
298
309
  state: object = field(default=None, repr=False)
299
310
 
300
311
  def __post_init__(self) -> None:
301
312
  self.root = Path(self.root).resolve()
313
+ if self.config_root is not None:
314
+ self.config_root = Path(self.config_root).resolve()
302
315
 
303
316
  @property
304
317
  def loaded(self) -> bool:
@@ -351,7 +364,7 @@ class BrainSet:
351
364
  from brainpick.config import load_config
352
365
  from brainpick.serve.state import ServeState
353
366
 
354
- state = ServeState(brain.root, load_config(brain.root))
367
+ state = ServeState(brain.root, load_config(brain.config_root or brain.root))
355
368
  state.load()
356
369
  brain.state = state
357
370
  return brain.state
@@ -482,8 +495,10 @@ def resolve_brain_set(roots: list[str], cwd: str | Path | None = None,
482
495
  brains = []
483
496
  for arg in roots:
484
497
  alias, path = _parse_root_arg(arg)
485
- root, _ = resolve_bundle(cwd / path, env) # --root may be a repo root above the bundle (spec/80)
486
- brains.append(Brain(alias=alias, root=root, here=(root == discover_here(cwd))))
498
+ config_root = (cwd / path).resolve()
499
+ root, _ = resolve_bundle(config_root, env) # --root may be a repo root above the bundle (spec/80)
500
+ brains.append(Brain(alias=alias, root=root, here=(root == discover_here(cwd)),
501
+ config_root=config_root))
487
502
  return BrainSet(brains)
488
503
 
489
504
  here = discover_here(cwd)
@@ -498,7 +513,8 @@ def resolve_brain_set(roots: list[str], cwd: str | Path | None = None,
498
513
  is_here = (cwd.resolve().is_relative_to(root) if here is None
499
514
  else root == here or here.is_relative_to(root))
500
515
  alias = entry.get("alias") or alias_for_repo(entry["repo"])
501
- brains.append(Brain(alias=alias, root=root, role=entry.get("role"), here=is_here))
516
+ brains.append(Brain(alias=alias, root=root, role=entry.get("role"), here=is_here,
517
+ config_root=_entry_base(entry, env)))
502
518
  if here is not None and not any(b.here for b in brains):
503
519
  brains.insert(0, Brain(alias=None, root=here, here=True))
504
520
  if not brains:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: brainpick
3
- Version: 0.8.0
3
+ Version: 0.8.2
4
4
  Summary: A turn-key brain stack for agents: compile an OKF markdown bundle into a queryable, servable, visualizable brain.
5
5
  Author: Benquemax
6
6
  License: MIT
@@ -49,7 +49,14 @@ def test_serve_root_may_be_a_repo_root_above_the_bundle(tmp_path, monkeypatch):
49
49
  just the bundle directory itself. Regression for the 2026-09-10 incident:
50
50
  `brainpick serve --root <bundle>` silently never read the repo-root
51
51
  brainpick.toml (no exclude, no [brain] config), while every other
52
- subcommand resolved it correctly via the same resolve_bundle."""
52
+ subcommand resolved it correctly via the same resolve_bundle.
53
+
54
+ And for the follow-on incident that fix caused: build_app joins
55
+ `root / [bundle] root` ITSELF, so _cmd_serve must hand it the raw --root.
56
+ Pre-resolving with resolve_bundle() applied [bundle] root twice and served
57
+ `<repo>/_brain/_brain` — a path that does not exist — so the UI showed one
58
+ generated index and nothing else, with T2 reported off. The Node engine
59
+ passes the raw root to buildApp; this asserts the Python CLI matches."""
53
60
  (tmp_path / "brainpick.toml").write_text(
54
61
  '[bundle]\nroot = "_brain"\nexclude = ["raw/*"]\n', encoding="utf-8",
55
62
  )
@@ -66,8 +73,10 @@ def test_serve_root_may_be_a_repo_root_above_the_bundle(tmp_path, monkeypatch):
66
73
  main(["serve", "--root", str(tmp_path), "--port", "0"])
67
74
 
68
75
  assert len(calls) == 1
69
- resolved_root, config = calls[0]
70
- assert resolved_root == bundle.resolve() # descended into _brain/, not tmp_path itself
76
+ passed_root, config = calls[0]
77
+ # build_app joins [bundle] root itself — hand it the repo root, undescended.
78
+ assert passed_root == tmp_path.resolve()
79
+ assert (passed_root / config.bundle.root).resolve() == bundle.resolve()
71
80
  assert config.bundle.exclude == ["raw/*"] # the repo-root brainpick.toml was actually read
72
81
 
73
82
 
@@ -18,6 +18,7 @@ import httpx
18
18
  import uvicorn
19
19
  from starlette.testclient import TestClient
20
20
 
21
+ from brainpick.cli import main as cli_main
21
22
  from brainpick.compile.pipeline import run_compile
22
23
  from brainpick.config import load_config
23
24
  from brainpick.core.canonical import sha256_hex
@@ -1019,3 +1020,39 @@ def test_cleared_presentation_replays_as_the_empty_shape(kotiaurinko):
1019
1020
  assert json.loads(replayed["data"]) == {
1020
1021
  "annotation": None, "focus": None, "mode": None, "nodes": [], "seq": 2,
1021
1022
  }
1023
+
1024
+
1025
+ def test_serve_cli_serves_a_bundle_below_the_repo_root(tmp_path, monkeypatch):
1026
+ """End-to-end guard for the double-resolution incident: with a repo-root
1027
+ brainpick.toml whose [bundle] root points at _brain/, `brainpick serve
1028
+ --root <repo>` must serve the bundle's real docs.
1029
+
1030
+ _cmd_serve used to pre-resolve with resolve_bundle() and hand the result to
1031
+ build_app, which joins [bundle] root again — serving <repo>/_brain/_brain.
1032
+ That path does not exist, so the API reported a single generated index and
1033
+ the UI looked empty. The unit test in test_cli.py mocks build_app and so
1034
+ cannot see a wrong path; this one runs the real thing.
1035
+ """
1036
+ (tmp_path / "brainpick.toml").write_text(
1037
+ '[bundle]\nroot = "_brain"\n', encoding="utf-8",
1038
+ )
1039
+ bundle = tmp_path / "_brain"
1040
+ bundle.mkdir()
1041
+ (bundle / "index.md").write_text("# Brain\n\nSee [Kuu](kuu.md).\n", encoding="utf-8")
1042
+ (bundle / "kuu.md").write_text(
1043
+ "---\ntype: Concept\ntitle: Kuu\ndescription: The moon.\n---\n\n"
1044
+ "# Kuu\n\nBack to [index](index.md).\n", encoding="utf-8",
1045
+ )
1046
+ run_compile(tmp_path)
1047
+
1048
+ captured = {}
1049
+ monkeypatch.setattr("uvicorn.run", lambda app, **k: captured.setdefault("app", app))
1050
+ cli_main(["serve", "--root", str(tmp_path), "--port", "0", "--no-watch"])
1051
+
1052
+ assert "app" in captured, "serve never reached uvicorn.run"
1053
+ with running_server(captured["app"]) as base_url:
1054
+ status = httpx.get(f"{base_url}/api/status").json()
1055
+ assert status["bundle_root"] == str(bundle.resolve())
1056
+ assert status["docs"] > 1, "served the doubled path, not the real bundle"
1057
+ ids = {n["id"] for n in httpx.get(f"{base_url}/api/graph").json()["nodes"]}
1058
+ assert "kuu.md" in ids
@@ -769,3 +769,21 @@ def test_permission_denied_implant_degrades_instead_of_raising(tmp_path):
769
769
  "reason": "permission denied reading the bundle"}]
770
770
  finally:
771
771
  broken.root.chmod(0o755)
772
+
773
+
774
+ def test_state_for_reads_the_config_above_a_subdirectory_bundle(tmp_path):
775
+ # `mcp --root REPO` resolves to REPO/<bundle> (spec/80), but the brain's config
776
+ # still lives at REPO: loading it from the bundle dir found no brainpick.toml and
777
+ # silently used defaults — [serve] git stayed off, [half_life] and [bundle]
778
+ # exclude did not apply, and stderr said "no brainpick.toml at …/bundle".
779
+ from brainpick.cli import main
780
+
781
+ bundle = copy_bundle(tmp_path, "kotiaurinko", under="repo/_brain")
782
+ repo = bundle.parent
783
+ (repo / "brainpick.toml").write_text('[bundle]\nroot = "_brain"\n\n[serve]\ngit = "push"\n', encoding="utf-8")
784
+ main(["compile", "--root", str(repo)])
785
+
786
+ brain_set = resolve_brain_set([str(repo)], cwd=repo, registry_path=tmp_path / "none.toml")
787
+ brain = brain_set.brains[0]
788
+ assert brain.root == bundle.resolve()
789
+ assert brain_set.state_for(brain).config.serve.git == "push"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes