mishkan-harness 0.1.0

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 (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +205 -0
  3. package/bin/mishkan.js +221 -0
  4. package/docs/design/MISHKAN_agent_aliases.md +140 -0
  5. package/docs/design/MISHKAN_decisions.md +172 -0
  6. package/docs/design/MISHKAN_harness_design.md +820 -0
  7. package/docs/design/MISHKAN_ontology.md +87 -0
  8. package/docs/design/MISHKAN_token_optimisation.md +181 -0
  9. package/docs/engineer/README.md +37 -0
  10. package/docs/engineer/profile.example.md +79 -0
  11. package/docs/usage/01-installation.md +178 -0
  12. package/docs/usage/02-project-init.md +151 -0
  13. package/docs/usage/03-orchestration.md +218 -0
  14. package/docs/usage/04-memory-layer.md +201 -0
  15. package/docs/usage/05-selective-ingest.md +177 -0
  16. package/docs/usage/06-llm-providers.md +195 -0
  17. package/docs/usage/07-troubleshooting.md +316 -0
  18. package/docs/usage/08-glossary.md +154 -0
  19. package/docs/usage/09-workflows.md +123 -0
  20. package/docs/usage/README.md +77 -0
  21. package/package.json +43 -0
  22. package/payload/install/settings.hooks.json +47 -0
  23. package/payload/mishkan/AGENT_SPEC.md +154 -0
  24. package/payload/mishkan/agents/ahikam.md +58 -0
  25. package/payload/mishkan/agents/aholiab.md +68 -0
  26. package/payload/mishkan/agents/asaph.md +73 -0
  27. package/payload/mishkan/agents/baruch.md +88 -0
  28. package/payload/mishkan/agents/benaiah.md +76 -0
  29. package/payload/mishkan/agents/bezalel.md +83 -0
  30. package/payload/mishkan/agents/caleb.md +74 -0
  31. package/payload/mishkan/agents/deborah.md +63 -0
  32. package/payload/mishkan/agents/elasah.md +58 -0
  33. package/payload/mishkan/agents/eliashib.md +68 -0
  34. package/payload/mishkan/agents/ezra.md +69 -0
  35. package/payload/mishkan/agents/hanun.md +64 -0
  36. package/payload/mishkan/agents/hiram.md +68 -0
  37. package/payload/mishkan/agents/hizkiah.md +76 -0
  38. package/payload/mishkan/agents/huldah.md +59 -0
  39. package/payload/mishkan/agents/huram.md +66 -0
  40. package/payload/mishkan/agents/hushai.md +59 -0
  41. package/payload/mishkan/agents/igal.md +58 -0
  42. package/payload/mishkan/agents/ira.md +86 -0
  43. package/payload/mishkan/agents/jahaziel.md +71 -0
  44. package/payload/mishkan/agents/jakin.md +66 -0
  45. package/payload/mishkan/agents/jehonathan.md +62 -0
  46. package/payload/mishkan/agents/jehoshaphat.md +68 -0
  47. package/payload/mishkan/agents/joab.md +71 -0
  48. package/payload/mishkan/agents/joah.md +62 -0
  49. package/payload/mishkan/agents/maaseiah.md +61 -0
  50. package/payload/mishkan/agents/meremoth.md +65 -0
  51. package/payload/mishkan/agents/meshullam.md +67 -0
  52. package/payload/mishkan/agents/nathan.md +70 -0
  53. package/payload/mishkan/agents/nehemiah.md +93 -0
  54. package/payload/mishkan/agents/obed.md +60 -0
  55. package/payload/mishkan/agents/oholiab.md +67 -0
  56. package/payload/mishkan/agents/palal.md +63 -0
  57. package/payload/mishkan/agents/phinehas.md +73 -0
  58. package/payload/mishkan/agents/rehum.md +60 -0
  59. package/payload/mishkan/agents/salma.md +69 -0
  60. package/payload/mishkan/agents/seraiah.md +73 -0
  61. package/payload/mishkan/agents/shallum.md +66 -0
  62. package/payload/mishkan/agents/shaphan.md +64 -0
  63. package/payload/mishkan/agents/shemaiah.md +67 -0
  64. package/payload/mishkan/agents/shevna.md +58 -0
  65. package/payload/mishkan/agents/uriah.md +70 -0
  66. package/payload/mishkan/agents/zaccur.md +58 -0
  67. package/payload/mishkan/agents/zadok.md +67 -0
  68. package/payload/mishkan/agents/zerubbabel.md +69 -0
  69. package/payload/mishkan/cognee/.env.curated.example +61 -0
  70. package/payload/mishkan/cognee/.env.example +165 -0
  71. package/payload/mishkan/cognee/Dockerfile +50 -0
  72. package/payload/mishkan/cognee/README.md +129 -0
  73. package/payload/mishkan/cognee/docker-compose.curated-ui.yml +61 -0
  74. package/payload/mishkan/cognee/docker-compose.curated.yml +85 -0
  75. package/payload/mishkan/cognee/docker-compose.hardening.yml +16 -0
  76. package/payload/mishkan/cognee/docker-compose.selfhosted.yml +114 -0
  77. package/payload/mishkan/cognee/docker-compose.ui.yml +70 -0
  78. package/payload/mishkan/cognee/docker-compose.yml +71 -0
  79. package/payload/mishkan/cognee/ingest-curated.py +92 -0
  80. package/payload/mishkan/commands/dep-audit.md +24 -0
  81. package/payload/mishkan/commands/mishkan-init.md +25 -0
  82. package/payload/mishkan/commands/mishkan-resume.md +21 -0
  83. package/payload/mishkan/commands/promote.md +19 -0
  84. package/payload/mishkan/commands/sefer-pull.md +19 -0
  85. package/payload/mishkan/commands/sprint-close.md +21 -0
  86. package/payload/mishkan/config/curated-library.yaml +113 -0
  87. package/payload/mishkan/config/improvement-queries.md +29 -0
  88. package/payload/mishkan/config/model-routing.yaml +87 -0
  89. package/payload/mishkan/config/projects.yaml +38 -0
  90. package/payload/mishkan/evals/baruch/README.md +93 -0
  91. package/payload/mishkan/evals/baruch/fixtures/invalid/bad-outcome-enum.json +15 -0
  92. package/payload/mishkan/evals/baruch/fixtures/invalid/bad-sprint-pattern.json +15 -0
  93. package/payload/mishkan/evals/baruch/fixtures/invalid/bad-trigger-enum.json +15 -0
  94. package/payload/mishkan/evals/baruch/fixtures/invalid/malformed-json.json +7 -0
  95. package/payload/mishkan/evals/baruch/fixtures/invalid/missing-required-field.json +14 -0
  96. package/payload/mishkan/evals/baruch/fixtures/valid/blocked-vendor.json +15 -0
  97. package/payload/mishkan/evals/baruch/fixtures/valid/curated-shortcircuit.json +15 -0
  98. package/payload/mishkan/evals/baruch/fixtures/valid/partial-no-write.json +14 -0
  99. package/payload/mishkan/evals/baruch/fixtures/valid/resolved-cross-harness.json +15 -0
  100. package/payload/mishkan/evals/baruch/golden_case/expected.yaml +35 -0
  101. package/payload/mishkan/evals/baruch/golden_case/input.yaml +47 -0
  102. package/payload/mishkan/evals/baruch/golden_case/produced.json +15 -0
  103. package/payload/mishkan/evals/baruch/run.sh +129 -0
  104. package/payload/mishkan/hooks/model-route.py +96 -0
  105. package/payload/mishkan/hooks/post-tool-observe.sh +45 -0
  106. package/payload/mishkan/hooks/pre-tool-security.sh +150 -0
  107. package/payload/mishkan/hooks/session-start.sh +20 -0
  108. package/payload/mishkan/hooks/stop-reporter.sh +29 -0
  109. package/payload/mishkan/ontology.md +87 -0
  110. package/payload/mishkan/rules/backend/yasad.md +23 -0
  111. package/payload/mishkan/rules/common/dependencies.md +53 -0
  112. package/payload/mishkan/rules/common/quality.md +16 -0
  113. package/payload/mishkan/rules/common/security.md +20 -0
  114. package/payload/mishkan/rules/documentation/sefer.md +19 -0
  115. package/payload/mishkan/rules/frontend/panim.md +21 -0
  116. package/payload/mishkan/rules/infrastructure/migdal.md +22 -0
  117. package/payload/mishkan/scripts/dependency-audit.sh +171 -0
  118. package/payload/mishkan/scripts/ensure-curated-box.sh +66 -0
  119. package/payload/mishkan/scripts/mishkan-ingest.sh +92 -0
  120. package/payload/mishkan/scripts/observability-aggregate.sh +57 -0
  121. package/payload/mishkan/scripts/seed-curated-library.sh +62 -0
  122. package/payload/mishkan/scripts/sync-profile.sh +65 -0
  123. package/payload/mishkan/scripts/validate-research-log.sh +108 -0
  124. package/payload/mishkan/skills/asaph-a11y-seo-craft/SKILL.md +289 -0
  125. package/payload/mishkan/skills/baruch-research-reporting-craft/SKILL.md +460 -0
  126. package/payload/mishkan/skills/benaiah-devsecops-craft/SKILL.md +329 -0
  127. package/payload/mishkan/skills/bezalel-cto-craft/SKILL.md +391 -0
  128. package/payload/mishkan/skills/caleb-web-research-craft/SKILL.md +306 -0
  129. package/payload/mishkan/skills/cognee-promote/SKILL.md +40 -0
  130. package/payload/mishkan/skills/cognee-quickstart/SKILL.md +66 -0
  131. package/payload/mishkan/skills/context-compress/SKILL.md +36 -0
  132. package/payload/mishkan/skills/deborah-ux-craft/SKILL.md +295 -0
  133. package/payload/mishkan/skills/dependency-audit/SKILL.md +59 -0
  134. package/payload/mishkan/skills/dependency-vetting/SKILL.md +59 -0
  135. package/payload/mishkan/skills/documentation-craft/SKILL.md +468 -0
  136. package/payload/mishkan/skills/ezra-research-formulation-craft/SKILL.md +319 -0
  137. package/payload/mishkan/skills/hanun-observability-craft/SKILL.md +312 -0
  138. package/payload/mishkan/skills/hiram-ui-craft/SKILL.md +334 -0
  139. package/payload/mishkan/skills/hizkiah-implementation-craft/SKILL.md +701 -0
  140. package/payload/mishkan/skills/hushai-security-advisor-craft/SKILL.md +282 -0
  141. package/payload/mishkan/skills/ira-code-security-craft/SKILL.md +553 -0
  142. package/payload/mishkan/skills/jakin-intent-clarification-craft/SKILL.md +299 -0
  143. package/payload/mishkan/skills/jehonathan-publication-craft/SKILL.md +262 -0
  144. package/payload/mishkan/skills/joab-app-security-craft/SKILL.md +266 -0
  145. package/payload/mishkan/skills/meremoth-devops-craft/SKILL.md +298 -0
  146. package/payload/mishkan/skills/meshullam-infra-design-craft/SKILL.md +302 -0
  147. package/payload/mishkan/skills/mishkan-ingest/SKILL.md +65 -0
  148. package/payload/mishkan/skills/mishkan-init/SKILL.md +65 -0
  149. package/payload/mishkan/skills/nathan-architecture-craft/SKILL.md +547 -0
  150. package/payload/mishkan/skills/nehemiah-pm-craft/SKILL.md +484 -0
  151. package/payload/mishkan/skills/obed-asset-pipeline-craft/SKILL.md +286 -0
  152. package/payload/mishkan/skills/oholiab-design-system-craft/SKILL.md +334 -0
  153. package/payload/mishkan/skills/palal-systems-craft/SKILL.md +281 -0
  154. package/payload/mishkan/skills/qa-evaluation-craft/SKILL.md +406 -0
  155. package/payload/mishkan/skills/rehum-sre-advisor-craft/SKILL.md +228 -0
  156. package/payload/mishkan/skills/reporter-discipline-craft/SKILL.md +351 -0
  157. package/payload/mishkan/skills/research-pipeline/SKILL.md +55 -0
  158. package/payload/mishkan/skills/salma-frontend-implementation-craft/SKILL.md +369 -0
  159. package/payload/mishkan/skills/sefer-pull/SKILL.md +37 -0
  160. package/payload/mishkan/skills/shallum-database-craft/SKILL.md +347 -0
  161. package/payload/mishkan/skills/shaphan-summarisation-craft/SKILL.md +271 -0
  162. package/payload/mishkan/skills/shemaiah-evaluation-craft/SKILL.md +342 -0
  163. package/payload/mishkan/skills/sprint-report/SKILL.md +28 -0
  164. package/payload/mishkan/skills/team-lead-craft/SKILL.md +457 -0
  165. package/payload/mishkan/skills/zadok-contract-craft/SKILL.md +520 -0
  166. package/payload/mishkan/templates/case-node.schema.json +22 -0
  167. package/payload/mishkan/templates/mcp.json +22 -0
  168. package/payload/mishkan/templates/observability-log.schema.json +24 -0
  169. package/payload/mishkan/templates/project-CLAUDE.md +47 -0
  170. package/payload/mishkan/templates/research-log.schema.json +40 -0
  171. package/payload/mishkan/templates/settings.json +12 -0
  172. package/payload/mishkan/templates/settings.local.json +6 -0
  173. package/payload/mishkan/templates/sprint-state.schema.json +47 -0
  174. package/payload/mishkan/templates/team-report.schema.json +50 -0
  175. package/payload/mishkan/templates/user-CLAUDE.md +62 -0
  176. package/payload/mishkan/workflows/README.md +88 -0
  177. package/payload/mishkan/workflows/mishkan-architecture-panel.js +156 -0
  178. package/payload/mishkan/workflows/mishkan-codebase-audit.js +188 -0
  179. package/payload/mishkan/workflows/mishkan-deep-research.js +251 -0
  180. package/payload/mishkan/workflows/mishkan-init.js +156 -0
  181. package/payload/mishkan/workflows/mishkan-migration-wave.js +180 -0
  182. package/payload/mishkan/workflows/mishkan-release-readiness.js +163 -0
  183. package/payload/mishkan/workflows/mishkan-sprint-close.js +112 -0
  184. package/payload/user/CLAUDE.md +62 -0
  185. package/payload/user/rules/engineer-standards.md +66 -0
  186. package/payload/user/rules/y4nn-standards.md +167 -0
@@ -0,0 +1,151 @@
1
+ # 02 — Project initialisation
2
+
3
+ > Goal: take a directory and turn it into a MISHKAN project: rules, deny-list,
4
+ > MCP connections, and a `CLAUDE.md` carrying sprint state.
5
+
6
+ ## When and where to run it
7
+
8
+ ```bash
9
+ cd <project root>
10
+ claude # opens a Claude Code session
11
+ /mishkan-init # invokes the init skill
12
+ ```
13
+
14
+ `/mishkan-init` is a **skill** (lives at
15
+ `~/.claude/mishkan/skills/mishkan-init/SKILL.md`) and also exposed as a
16
+ command. It is **not** something an agent should run unprompted — there is an
17
+ explicit precondition check.
18
+
19
+ ## The four artifacts it always writes
20
+
21
+ | File | Role | Tracked? |
22
+ |---|---|---|
23
+ | `CLAUDE.md` | project state: sprint slot, code orientation, two-store note | yes |
24
+ | `.mcp.json` | declares both cognee MCP servers (`cognee` + `cognee-curated`) | yes |
25
+ | `.claude/settings.json` | deny-list: `git push`, `ssh`, `sudo`, `docker exec` | yes |
26
+ | `.claude/settings.local.json` | local allow-list; gitignored | no (added to `.gitignore` if absent) |
27
+
28
+ Plus the **7 path-scoped team rules** copied to `.claude/rules/` so they JIT-load
29
+ only on matching files (see [Orchestration](./03-orchestration.md)).
30
+
31
+ ## Scope choice — greenfield vs brownfield
32
+
33
+ The skill detects whether the repo is empty or already mature and asks how much
34
+ of the spec spine to run. Two common answers:
35
+
36
+ - **Harness wiring only** — drop the four artifacts + rules, do not generate
37
+ PRD/SRS/CONTRACT/ARCHITECTURE/THREAT_MODEL. Right for a mature repo with
38
+ existing docs (the aiobi-mail case during the build).
39
+ - **Full init** — run the documented sequence with the right specialists writing
40
+ each spec. Right for greenfield. Slow on purpose: nothing is generated without
41
+ upstream artifacts existing.
42
+
43
+ The full sequence (when chosen):
44
+
45
+ 1. **Nehemiah** writes `docs/PRD.md`.
46
+ 2. **Nathan** (Yasad) writes `docs/SRS.md`.
47
+ 3. **Zadok** (Yasad) writes `docs/CONTRACT.md` — *invariants + guarantees*.
48
+ 4. **Bezalel + Nathan** write `docs/ARCHITECTURE.md`.
49
+ 5. **Benaiah** (Mishmar) writes `docs/THREAT_MODEL.md` (STRIDE).
50
+ 6. **Meshullam** (Migdal) writes `docs/diagrams/C4/` (Context, Container, Component).
51
+ 7. **Jehoshaphat** (Sefer) scaffolds `docs/README.md`, `docs/adr/`, `docs/runbooks/`.
52
+ 8. **Automated** cognee setup (see below).
53
+ 9. **Automated** project `CLAUDE.md` write + sprint S0.
54
+
55
+ Each step that touches a contract requires `/plan` to run first.
56
+
57
+ ## Step 8 in detail: cognee setup at init
58
+
59
+ Two parts run automatically at init:
60
+
61
+ 1. **Ensure the curated box** (global singleton, shared across projects).
62
+ `~/.claude/mishkan/scripts/ensure-curated-box.sh` is idempotent: it brings up
63
+ the curated stack if down, creates `curated_db`, and seeds only if the
64
+ curated graph is empty. It is safe to run repeatedly.
65
+
66
+ 2. **Selectively seed the work store** for this project, **never bulk-ingest**.
67
+ `/mishkan-init` runs:
68
+ ```bash
69
+ bash ~/.claude/mishkan/scripts/mishkan-ingest.sh --tagged-only
70
+ ```
71
+ That walks `./docs/` looking for files with a `mishkan: ingest` YAML
72
+ frontmatter tag and ingests *only* those. Untagged docs are ignored.
73
+ The whole point is memory is opt-in: see
74
+ [Selective ingest](./05-selective-ingest.md) and commit `6213611`.
75
+
76
+ ## What `CLAUDE.md` carries
77
+
78
+ A lean, dynamic file that loads **after** the user-level identity. It carries:
79
+
80
+ - Codebase orientation (stack, key directories) — concrete facts the
81
+ main session needs every turn.
82
+ - Sprint slot — *current sprint*, *what's in flight*, *blockers*. Updated by
83
+ `/mishkan-resume`, `/sprint-close`, and you.
84
+ - Note that there are two cognee stores (`cognee` = work, `cognee-curated` =
85
+ reference) and that `cognee-curated` is read-only.
86
+ - A pointer to the existing `docs/` if there is one (does not duplicate).
87
+
88
+ ## Brownfield handling — what does *not* happen
89
+
90
+ - **No overwrites.** Existing `README.md`, `CLAUDE.md`, and `docs/*` are left
91
+ alone. If a project `CLAUDE.md` already exists, the agent surfaces it and
92
+ asks before merging.
93
+ - **No translation.** If the existing docs are in another language (the
94
+ aiobi-mail repo was largely French), the MISHKAN docs are written in English
95
+ per rule 12 of `y4nn-standards.md`, alongside the existing corpus.
96
+ - **No reverse-engineered PRD.** If you pick "harness wiring only", no spec
97
+ spine is fabricated.
98
+
99
+ ## Confirming a clean init
100
+
101
+ After `/mishkan-init` completes:
102
+
103
+ ```bash
104
+ # the four artifacts
105
+ ls -la .mcp.json CLAUDE.md .claude/settings.json .claude/settings.local.json
106
+
107
+ # rules installed
108
+ find .claude/rules -type f | sort
109
+
110
+ # settings.local.json gitignored
111
+ grep -E '\.claude/settings\.local\.json' .gitignore
112
+
113
+ # the two cognee servers declared
114
+ python3 -c "import json; print(list(json.load(open('.mcp.json'))['mcpServers'].keys()))"
115
+ # expected: ['cognee', 'cognee-curated']
116
+ ```
117
+
118
+ ## Verifying the MCP connections (next session)
119
+
120
+ MCP servers connect **at session start** — so the session that ran
121
+ `/mishkan-init` does *not* yet have `mcp__cognee__*` tools available. Open a new
122
+ session in the same directory:
123
+
124
+ ```bash
125
+ exit # leave the current session
126
+ claude # fresh session
127
+ /mcp # in the session: should list 'cognee' and 'cognee-curated'
128
+ ```
129
+
130
+ ## Common edge cases
131
+
132
+ - **No remote / private repo:** `.mcp.json` is tracked; do not put secrets in
133
+ it. The cognee MCP URLs point at `http://localhost:7777` and `:7730` — your
134
+ own host, no third-party endpoints.
135
+ - **Multiple projects on one host:** safe. The curated box is shared
136
+ (singleton); the work store holds each project as its own dataset, keyed by
137
+ the project directory basename by default (see
138
+ [Selective ingest](./05-selective-ingest.md) for the dataset naming
139
+ rules).
140
+ - **Running init twice:** safe. The four artifacts are not overwritten; the
141
+ curated ensure step is idempotent; rules are re-copied verbatim.
142
+
143
+ ## See also
144
+
145
+ - The init skill source: `payload/mishkan/skills/mishkan-init/SKILL.md`
146
+ (commit `a9a4bf1` wired the curated-box step; commit `6213611` made step 8
147
+ selective).
148
+ - [Orchestration](./03-orchestration.md) — how the main session routes work
149
+ once init has run.
150
+ - [Memory layer](./04-memory-layer.md) — the two cognee stores and what they
151
+ hold.
@@ -0,0 +1,218 @@
1
+ # 03 — Orchestration
2
+
3
+ > Goal: explain how work actually flows once you've started a session in a
4
+ > MISHKAN-initialised project, with the platform constraints that shape it.
5
+
6
+ ## The single most important fact
7
+
8
+ **Claude Code has no nested delegation.** A subagent cannot spawn another
9
+ subagent — confirmed in the official subagent docs. The `Task` tool in a
10
+ subagent's frontmatter is **inert** when the subagent runs.
11
+
12
+ ```
13
+ You ──talk──▶ MAIN SESSION = leadership ← orchestrator
14
+
15
+ ├─Task→ Team Lead / Specialist ┐
16
+ ├─Task→ project-specific agent │ one level deep
17
+ └─Task→ research pipeline ┘ siblings, no nesting
18
+ then main session SYNTHESISES their outputs
19
+ ```
20
+
21
+ Three things follow:
22
+
23
+ 1. **The main session is leadership.** It loads the MISHKAN identity from
24
+ `~/.claude/CLAUDE.md` and acts as Nehemiah (PM) and Bezalel (CTO)
25
+ simultaneously. **Do not invoke the `nehemiah` subagent to orchestrate** —
26
+ a spawned Nehemiah can't delegate either.
27
+
28
+ 2. **Delegation is description-driven**, not config-table driven. There is no
29
+ "task → agent" YAML. The `Task` tool reads each agent's `description:`
30
+ frontmatter and picks one, guided by the `## Routing` prose in
31
+ `~/.claude/CLAUDE.md` and the main session's own judgement.
32
+
33
+ 3. **Team Lead agents (e.g. `eliashib` for Migdal infrastructure) advise and
34
+ plan**, they don't spawn specialists. The main session calls the Lead for
35
+ strategy and the specialists for execution.
36
+
37
+ ## The cast (one level deep, all callable by the main session)
38
+
39
+ **Two orchestrators** — these *inform* the main session's identity via
40
+ CLAUDE.md; you can also call them explicitly as subagents for second opinions.
41
+
42
+ | Alias | Role |
43
+ |---|---|
44
+ | `nehemiah` | PM — scope, delivery, sprint state |
45
+ | `bezalel` | CTO — technical standards, architecture, quality bar |
46
+
47
+ **Six teams.** Within each, `Lead → Specialists → QA → Reporter`. QA and
48
+ Reporters are structurally separate from the producing agents — no agent grades
49
+ its own work.
50
+
51
+ | Team | Domain | Notable agents |
52
+ |---|---|---|
53
+ | **Chosheb** | Design / UX | `aholiab` (lead), `hiram` (UI), `deborah` (cognitive UX) |
54
+ | **Panim** | Frontend | `huram` (lead), `oholiab` (design system), `salma` (impl), `asaph` (a11y), `jahaziel` (QA) |
55
+ | **Yasad** | Backend | `zerubbabel` (lead), `nathan` (architecture), `zadok` (contracts), `hizkiah` (impl), `shallum` (DB), `uriah` (QA) |
56
+ | **Mishmar** | Security (cross-cutting) | `phinehas` (lead), `ira` (code-sec, runs the security hook), `benaiah`, `joab` |
57
+ | **Migdal** | Infrastructure | `eliashib` (lead), `meshullam` (design), `palal` (systems), `meremoth` (devops), `hanun` (devsecops), `rehum` (SRE) |
58
+ | **Sefer** | Documentation (pull-based) | `jehoshaphat` (lead), `seraiah` / `joah` / `shevna` (org/project/team), `jehonathan` (publication) |
59
+
60
+ **Research pipeline** (6 stages): `jakin` → `ezra` → `caleb` → `shaphan` →
61
+ `shemaiah` → `baruch`. Each stage is a single-purpose agent. The pipeline is
62
+ also a skill (`research-pipeline`) the main session can invoke whole.
63
+
64
+ Full glossary including each agent's role: [Glossary](./08-glossary.md).
65
+ Naming rationale: [`docs/design/MISHKAN_agent_aliases.md`](../design/MISHKAN_agent_aliases.md).
66
+
67
+ ## Model routing — `model-routing.yaml` is authoritative
68
+
69
+ Every agent has a Claude model tier (`opus` / `sonnet` / `haiku`). The mapping
70
+ lives in [`payload/mishkan/config/model-routing.yaml`](../../payload/mishkan/config/model-routing.yaml)
71
+ and is **enforced at delegation time** by a `PreToolUse` hook that intercepts
72
+ the `Task` tool call and injects the right `model` via
73
+ `hookSpecificOutput.updatedInput`.
74
+
75
+ ```
76
+ config/model-routing.yaml ← edit here (single source of truth)
77
+
78
+ hooks/model-route.py ← PreToolUse on Task|Agent
79
+
80
+ Task tool input gets `model: <tier>` injected
81
+
82
+ subagent runs on the right tier, regardless of its frontmatter
83
+ ```
84
+
85
+ Important nuance baked into the hook (`c6c5645`): it **only injects for agents
86
+ explicitly listed in the YAML**. Foreign agents (e.g. `aiobi-ops`, `Explore`)
87
+ keep their own frontmatter model — never silently downgraded.
88
+
89
+ Tier rationale (from the YAML header):
90
+
91
+ | Tier | Who | Why |
92
+ |---|---|---|
93
+ | Opus | orchestrators, Team Leads, knowledge publication | judgement-heavy |
94
+ | Sonnet | senior specialists, anything that **writes code** | precision on the codebase |
95
+ | Haiku | QA (evaluate-only), Reporters (collect-only), pure advisors | cost-sensitive, no risk to code |
96
+
97
+ To change a tier: **edit the YAML**, not the agent frontmatter. The hook makes
98
+ the YAML win.
99
+
100
+ ## Skills — invoked on demand, never preloaded
101
+
102
+ Each agent has the `Skill` tool in its `tools:` allowlist. When the agent reads
103
+ a skill name in its prompt and decides it applies, it invokes the skill on the
104
+ fly. **No `skills:` frontmatter preload** is used — that would inject the full
105
+ SKILL.md text into the agent's context on every startup for every preloaded
106
+ skill, across 45 agents. The cost rationale is captured in
107
+ `~/.claude/mishkan/AGENTS_SKILLS.md`.
108
+
109
+ How an agent knows which skills to reach for: each agent's prompt carries a
110
+ short **"Skills (invoke on demand)"** section listing its specific skills.
111
+ Salma's, for example: `react-modernization`, `nextjs-app-router-patterns`,
112
+ `responsive-design`, `modern-javascript-patterns`.
113
+
114
+ Skills shipped by MISHKAN itself (orchestrating the 150+ user skills):
115
+
116
+ | Skill | Purpose |
117
+ |---|---|
118
+ | `mishkan-init` | scaffold a project (see [02](./02-project-init.md)) |
119
+ | `mishkan-ingest` | selectively add docs to the work cognee (see [05](./05-selective-ingest.md)) |
120
+ | `research-pipeline` | run Jakin→Ezra→Caleb→Shaphan→Shemaiah→Baruch |
121
+ | `sprint-report` | a Reporter assembles `team-report.json` at milestone |
122
+ | `cognee-promote` | promote knowledge with blast-radius routing |
123
+ | `cognee-quickstart` | bring cognee up if it's not running yet |
124
+ | `context-compress` | Cognee-offload helper for long sessions |
125
+ | `sefer-pull` | trigger doc updates at milestones or high-blast events |
126
+ | `dependency-vetting` | vet a single dep via the research pipeline |
127
+ | `dependency-audit` | per-project supply-chain audit |
128
+
129
+ ## Hooks — the binding layer
130
+
131
+ Hooks make the rules deterministic; rules and prompts alone wouldn't be enough.
132
+
133
+ | Event | Script | What it does |
134
+ |---|---|---|
135
+ | `PreToolUse: Write|Edit|MultiEdit` | `pre-tool-security.sh` (Ira) | scan writes for secrets, eval, SQL string-concat, unsafe execution; block on match |
136
+ | `PreToolUse: Task|Agent` | `model-route.py` | inject the model tier from `model-routing.yaml` |
137
+ | `PreToolUse: Bash` | the existing bun command-validator (preserved) | command validation |
138
+ | `PostToolUse: *` | `post-tool-observe.sh` | append one observability log entry per tool call |
139
+ | `Stop` | `stop-reporter.sh` | if the stopped agent declares `role: reporter`, fire the `sprint-report` skill |
140
+
141
+ The security hook is the one you'll notice — it caught the Gemini API key during
142
+ the build (commit `e17f2a9` added a documented exception path for runtime
143
+ secret injection into gitignored `.env` files).
144
+
145
+ ## MCP tools in subagents — explicit, not inherited
146
+
147
+ A real gotcha worth flagging: **Claude Code does not give a subagent access to
148
+ the main session's MCP servers automatically.** A subagent (anything spawned
149
+ via `Task`) can only call MCP tools that appear in its own `tools:` frontmatter
150
+ allowlist. If you see *"MCP tool not in subagent context"* during a research
151
+ run, this is the cause.
152
+
153
+ Tool names follow the pattern `mcp__<server>__<tool>`. The four MISHKAN agents
154
+ whose job *is* cognee work have the relevant entries pre-wired:
155
+
156
+ | Agent | Cognee tools in its allowlist |
157
+ |---|---|
158
+ | `ezra` (research formulator) | `mcp__cognee__search`, `mcp__cognee-curated__search` |
159
+ | `shemaiah` (research evaluator) | `mcp__cognee__search`, `mcp__cognee-curated__search` |
160
+ | `baruch` (research reporter) | `mcp__cognee__search`, `mcp__cognee__add`, `mcp__cognee__cognify`, `mcp__cognee__memify` |
161
+ | `jehonathan` (knowledge publication) | `mcp__cognee__search` |
162
+
163
+ The other 41 agents do not have cognee MCP access by default — they don't need
164
+ it. If you add a new agent whose work depends on cognee, add the specific MCP
165
+ tools to its `tools:` line. Don't grant the whole MCP server unless the agent
166
+ genuinely needs every operation; the principle is the same as the deny-list
167
+ philosophy below.
168
+
169
+ The fallback pattern when an agent legitimately needs cognee but doesn't have
170
+ the tools: **the main session does the MCP call**. The subagent returns a
171
+ structured payload; the main session reads it and calls `mcp__cognee__add` /
172
+ `mcp__cognee__cognify` itself. Slower than direct access but always available.
173
+
174
+ ## Deny-list and asymmetric delegation
175
+
176
+ Two layers of "the agent never does this":
177
+
178
+ - **Project `settings.json`** (seeded by init) — deny: `git push`, `ssh`,
179
+ `sudo`, `docker exec`.
180
+ - **Standards** (rules layer, baked in) — *"stateful operations stop at the
181
+ engineer's hands"*: schema-migration execution, log-forensics execution,
182
+ production access.
183
+
184
+ These are not soft preferences. They are the boundary between generative work
185
+ (safe to delegate one-shot) and stateful work (one mistake is not reversible
186
+ by re-prompting).
187
+
188
+ ## Routing in practice — a DevOps example
189
+
190
+ You: *"Get aiobi-mail off the staging stack's stale iptables rules without
191
+ touching production."*
192
+
193
+ Main session (acting as leadership):
194
+
195
+ 1. Reads the codebase orientation in `CLAUDE.md` for context.
196
+ 2. Searches cognee `work` store for past incidents touching this area.
197
+ 3. Spawns `eliashib` (Migdal lead) to plan the work — returns a routing
198
+ recommendation.
199
+ 4. Spawns `palal` (systems specialist) to inspect the iptables state — returns
200
+ findings.
201
+ 5. Spawns `aiobi-ops` (your project-specific ops agent) for the staging-stack
202
+ reality (servers, gotchas, incident history).
203
+ 6. Synthesises 3, 4, 5 into a concrete plan with exact commands.
204
+ 7. Hands you the commands. You run them.
205
+
206
+ Migdal agents and `aiobi-ops` did **not** talk to each other — they are
207
+ siblings, one level deep. The synthesis was the main session's job.
208
+
209
+ ## See also
210
+
211
+ - Plan / decision file behind the model-routing hook: commit `c6c5645`,
212
+ `payload/mishkan/hooks/model-route.py`.
213
+ - Skill wiring decisions: `~/.claude/mishkan/AGENTS_SKILLS.md` (instance-local).
214
+ - Research pipeline shape:
215
+ [`docs/design/MISHKAN_harness_design.md`](../design/MISHKAN_harness_design.md)
216
+ §5.
217
+ - Token economy / context architecture:
218
+ [`docs/design/MISHKAN_token_optimisation.md`](../design/MISHKAN_token_optimisation.md).
@@ -0,0 +1,201 @@
1
+ # 04 — Memory layer (cognee)
2
+
3
+ > Goal: explain what the harness stores, where, how it gets there, and how
4
+ > agents query it. This is the layer that makes MISHKAN *accumulate* rather
5
+ > than just function.
6
+
7
+ ## Two physically-isolated stores (decision D-007)
8
+
9
+ Cognee runs locally on the host as a Docker stack. The core architectural
10
+ choice (introduced in commit `418d10a`, documented in
11
+ [`docs/design/MISHKAN_decisions.md`](../design/MISHKAN_decisions.md) §D-007):
12
+
13
+ ```
14
+ shared Ollama (embeddings, local) ─┐ stateless, serves both
15
+ shared Postgres server ────────────┤ separate databases
16
+
17
+ WORK box :7777 (cognee) CURATED box :7730 (cognee-curated)
18
+ own Neo4j + cognee_db own Neo4j + curated_db
19
+ ── per-project knowledge ── ── cross-project reference ──
20
+ • aiobi-mail (project dataset) • curated_library (96 nodes seed)
21
+ • claude_code_memory (per-client memory) • read-mostly
22
+ UI :7724 · Neo4j :7716/:7709 UI :7734 · Neo4j :7731/:7732
23
+ ```
24
+
25
+ Why two stores and not one?
26
+
27
+ - **PII isolation.** Project ingestion pulls in code and docs that can contain
28
+ PII (real email addresses in incident reports were the trigger during the
29
+ build). The cross-project curated library must stay clean.
30
+ - **Logical tags aren't enough on Neo4j Community.** Community Edition allows
31
+ only one database per Neo4j instance, and with cognee's access control
32
+ disabled (the only mode that works against Neo4j today) all datasets share
33
+ one graph. So logical dataset tags commingle in one store. Physical
34
+ separation = a separate Neo4j container.
35
+
36
+ The `claude_code_memory` dataset is the **per-client session memory**, created
37
+ on demand by cognee-mcp when Claude Code connects. **It belongs in the work
38
+ store and must never be pruned** (D-007 calls this out explicitly).
39
+
40
+ ## The data flow
41
+
42
+ ```
43
+ docs / project content curated resources (small, static)
44
+ │ │
45
+ ▼ ▼
46
+ cognee.add() ← raw files staged add_data_points() ← structured
47
+ │ │
48
+ cognify() ← LLM extracts entities (no LLM — embeddings only)
49
+ │ + relationships │
50
+ ▼ ▼
51
+ memify() ← embeds the triplet layer memify() optional
52
+ │ into the vector store
53
+
54
+ search() ← retrieval (vector + graph)
55
+ ```
56
+
57
+ Each phase, in words:
58
+
59
+ - **`add`** stages files for processing. The raw file content is stored under
60
+ the cognee data root (must be on a volume — see [Troubleshooting](./07-troubleshooting.md)
61
+ and commit `e24fabf`).
62
+ - **`cognify`** is the LLM-heavy step. It chunks each document, calls the LLM
63
+ to extract entities and relationships as structured output (instructor mode),
64
+ embeds chunks + entities, and writes to Neo4j + pgvector. This is the step
65
+ that costs LLM tokens and runs into rate caps.
66
+ - **`memify`** is the enrichment step that runs **after** cognify. The default
67
+ enrichment embeds the **edge / triplet** layer into the vector store
68
+ (`EdgeType_relationship_name` and `graph_relationship_ledger` tables in
69
+ pgvector). After memify, retrieval becomes **relationship-aware** — graph
70
+ topology in Neo4j is unchanged; the vector store gains the triplet index.
71
+ - **`search`** retrieves (vector + optionally graph) and is exposed via the
72
+ cognee MCP. Agents call it.
73
+
74
+ The session's wiring commit (`210f92b`) makes `cognify → memify` automatic in
75
+ the curated seed and in `/mishkan-init` step 8 — extraction is always followed
76
+ by enrichment, never manually.
77
+
78
+ ## The MCP — how agents reach memory
79
+
80
+ Every MISHKAN-initialised project declares **both** servers in `.mcp.json`:
81
+
82
+ ```json
83
+ {
84
+ "mcpServers": {
85
+ "cognee": { "type": "http", "url": "http://localhost:7777/mcp" },
86
+ "cognee-curated": { "type": "http", "url": "http://localhost:7730/mcp" }
87
+ }
88
+ }
89
+ ```
90
+
91
+ So when an agent searches, it can target either store explicitly:
92
+
93
+ - `cognee` — read+write the project's own graph (typical).
94
+ - `cognee-curated` — read the cross-project reference library (typical for
95
+ Shemaiah cross-referencing curated resources).
96
+
97
+ MCP servers connect at **session start**. A fresh session is needed for
98
+ `/mishkan-init`-written `.mcp.json` to take effect.
99
+
100
+ ## Datasets — the logical layer inside each store
101
+
102
+ Datasets are cognee's logical partitioning. In the work store, every project
103
+ gets its own dataset (named after the project directory by convention). A
104
+ typical work store after a few projects:
105
+
106
+ ```
107
+ datasets (work / cognee_db)
108
+ ├── aiobi-mail (14 docs, project knowledge)
109
+ ├── claude_code_memory (per-client session memory)
110
+ └── <next-project> (created on its first ingest)
111
+ ```
112
+
113
+ In the curated store there is one dataset (`curated_library`) — the cross-project
114
+ reference seed.
115
+
116
+ To query a specific dataset, pass `datasets=[...]` to `cognee.search`. This is
117
+ the only way to keep retrieval *logically* clean within a store; the *physical*
118
+ isolation between work and curated is by separate Neo4j containers.
119
+
120
+ ## Visualising the graph
121
+
122
+ Two ways for each store:
123
+
124
+ ### Cognee Graph Explorer UI
125
+
126
+ - **Work**: `http://localhost:7724`, backend `:7737`.
127
+ Login = `DEFAULT_USER_EMAIL` / `DEFAULT_USER_PASSWORD` from `.env`.
128
+ - **Curated**: `http://localhost:7734`, backend `:7733` (added in commit `751f95e`).
129
+ Login = `DEFAULT_USER_EMAIL` / `DEFAULT_USER_PASSWORD` from `.env.curated`.
130
+
131
+ ### Neo4j Browser (raw graph)
132
+
133
+ | Store | HTTP | Bolt | Credentials |
134
+ |---|---|---|---|
135
+ | Work | `http://localhost:7716` | `bolt://localhost:7709` | `neo4j` + work `GRAPH_DATABASE_PASSWORD` |
136
+ | Curated | `http://localhost:7731` | `bolt://localhost:7732` | `neo4j` + curated `GRAPH_DATABASE_PASSWORD` |
137
+
138
+ Important: use the `bolt://` scheme in the browser's connect URL, **not**
139
+ `neo4j://`. The `neo4j://` scheme triggers routing discovery that fails over an
140
+ SSH tunnel — a real gotcha from the build (see
141
+ [Troubleshooting](./07-troubleshooting.md)).
142
+
143
+ A good Cypher to render the curated structure:
144
+
145
+ ```cypher
146
+ MATCH (t:Team)-[r:resources]->(c:CuratedResource) RETURN t, r, c
147
+ ```
148
+
149
+ ## Tunnelling from a remote host
150
+
151
+ If cognee runs on a remote VPS, forward the relevant ports:
152
+
153
+ ```bash
154
+ tsh ssh -N \
155
+ -L 7724:127.0.0.1:7724 -L 7737:127.0.0.1:7737 \
156
+ -L 7716:127.0.0.1:7716 -L 7709:127.0.0.1:7709 \
157
+ -L 7734:127.0.0.1:7734 -L 7733:127.0.0.1:7733 \
158
+ -L 7731:127.0.0.1:7731 -L 7732:127.0.0.1:7732 \
159
+ <user>@<host>
160
+ ```
161
+
162
+ Only what you want to look at. The MCP itself doesn't need a tunnel — the
163
+ agent runs on the host where cognee is, and the cognee MCP listens on
164
+ `127.0.0.1` already.
165
+
166
+ ## What gets written when, and what to back up
167
+
168
+ | Layer | Where | Persistence | Back up? |
169
+ |---|---|---|---|
170
+ | Graph (Neo4j) | volumes `cognee_neo4j_data`, `curated_neo4j_data` | docker volume | yes (high value) |
171
+ | Vector + relational (Postgres) | volume `cognee_pgdata` | docker volume | yes |
172
+ | Raw ingested files + cognee system metadata | volume `cognee_data` (mounted at `/app/cognee-mcp/.cognee_system`) | docker volume | yes (commit `e24fabf` made this volume-backed; before that, every `up --force-recreate` wiped the raw files) |
173
+ | Ollama models | volume `ollama_models` | docker volume | re-pullable |
174
+
175
+ `docker volume inspect mishkan-cognee_cognee_data` shows where on disk the
176
+ volume lives. Standard restic / rsync covers it.
177
+
178
+ ## Configuration anchors
179
+
180
+ - Work box env: `~/.claude/mishkan/cognee/.env` (gitignored, mode 600).
181
+ - Curated box env: `~/.claude/mishkan/cognee/.env.curated` (gitignored, mode 600).
182
+ - Compose entrypoint: `docker-compose.yml` + overlays (`hardening`, `selfhosted`,
183
+ `ui`, `curated`, `curated-ui`).
184
+ - Curated singleton helper: `scripts/ensure-curated-box.sh` (idempotent).
185
+ - Selective seeding from a project: `scripts/mishkan-ingest.sh` (see
186
+ [chapter 05](./05-selective-ingest.md)).
187
+
188
+ ## See also
189
+
190
+ - The two-store rationale: [D-007](../design/MISHKAN_decisions.md) and
191
+ commit `418d10a`.
192
+ - Curated UI overlay: commit `751f95e`.
193
+ - Storage persistence fix: commit `e24fabf`.
194
+ - Curated structured ingestion (low-level): commit `086e80e`,
195
+ `payload/mishkan/cognee/ingest-curated.py`.
196
+ - Ontology definitions:
197
+ [`docs/design/MISHKAN_ontology.md`](../design/MISHKAN_ontology.md).
198
+ - LLM/embedding strategy:
199
+ [LLM provider profiles](./06-llm-providers.md).
200
+ - How to add knowledge: [Selective ingest](./05-selective-ingest.md).
201
+ - When things break: [Troubleshooting](./07-troubleshooting.md).