@unson/brainbase-mcp 0.3.1 → 0.4.1

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.
@@ -0,0 +1,313 @@
1
+ ---
2
+ title: Brainbase Judgment DAG Core
3
+ status: accepted
4
+ date: 2026-08-20
5
+ scope: OSS Brainbase / shared core
6
+ supersedes_in_part: docs/architecture/brainbase-memory-loop-product-boundary.md
7
+ ---
8
+
9
+ # Brainbase Judgment DAG Core
10
+
11
+ ## Decision
12
+
13
+ Brainbase OSS and organization deployments share the same Judgment DAG semantic model and runtime core.
14
+
15
+ Brainbase is not only a memory/knowledge store. Its core responsibility is to externalize, preserve, replay, evaluate, and improve the structure by which a person or organization turns context into judgment and action.
16
+
17
+ The prior product boundary that limited OSS Brainbase to `Remember / Organize / Retrieve / Learn` is revised. Brainbase owns the **judgment substrate**; Mana may own autonomous operating loops, continuous follow-through, and outcome ownership on top of that substrate.
18
+
19
+ ```text
20
+ Brainbase = Remember / Organize / Retrieve / Judge / Replay / Learn
21
+ Mana = Operate / Prioritize continuously / Act autonomously / Follow-through
22
+ ```
23
+
24
+ Brainbase may represent and execute judgment nodes. It does not become an always-on autonomous operator merely because it can execute a DAG.
25
+
26
+ ## Core hypothesis
27
+
28
+ A person or organization can be modeled as a stateful system that repeatedly executes a directed judgment graph:
29
+
30
+ ```text
31
+ State(t)
32
+ ↓
33
+ Context / Observation DAG
34
+ ↓
35
+ Judgment DAG
36
+ ↓
37
+ Resource / Risk DAG
38
+ ↓
39
+ Execution DAG
40
+ ↓
41
+ Outcome
42
+ ↓
43
+ Evaluation DAG
44
+ ↓
45
+ State(t+1) + DAG update
46
+ ```
47
+
48
+ The durable asset is not the document corpus itself. It is the reusable structure connecting evidence, assumptions, judgments, decisions, commitments, actions, outcomes, and updates.
49
+
50
+ ## Shared five-layer model
51
+
52
+ ### Layer 1: Context DAG
53
+ Produces normalized observations and state required by downstream judgment.
54
+
55
+ Allowed:
56
+ - facts and observations
57
+ - metrics and snapshots
58
+ - entity resolution
59
+ - source provenance
60
+ - temporal validity
61
+
62
+ Forbidden:
63
+ - strategic choice
64
+ - resource allocation
65
+ - external action
66
+
67
+ ### Layer 2: Judgment DAG
68
+ Produces reusable interpretations and decisions from Context outputs.
69
+
70
+ Examples:
71
+ - priority judgment
72
+ - pricing judgment
73
+ - product fit judgment
74
+ - go/no-go judgment
75
+ - policy selection
76
+
77
+ Forbidden:
78
+ - direct mutation of execution state
79
+ - hidden reads from raw sources that bypass Context contracts
80
+ - direct resource commitment
81
+
82
+ ### Layer 3: Resource / Risk DAG
83
+ Converts judgments into bounded commitments.
84
+
85
+ Examples:
86
+ - budget
87
+ - time allocation
88
+ - staffing
89
+ - risk limit
90
+ - approval threshold
91
+ - scope
92
+
93
+ Forbidden:
94
+ - reimplementing upstream business judgment
95
+ - performing the external action itself
96
+
97
+ ### Layer 4: Execution DAG
98
+ Turns approved commitments into actions and records execution artifacts.
99
+
100
+ An **outcome** is the result that the Execution DAG generates and records. It is
101
+ an execution-layer node, not an independent sixth layer. The canonical node
102
+ type-to-layer mapping is `observation -> context`, `judgment/decision ->
103
+ judgment`, `resource -> resource`, `execution/outcome -> execution`, and
104
+ `evaluation -> evaluation`.
105
+
106
+ Examples:
107
+ - create task
108
+ - send proposal
109
+ - deploy software
110
+ - sign/route contract
111
+ - schedule meeting
112
+
113
+ Forbidden:
114
+ - silently changing upstream judgment or policy
115
+ - acquiring authority that was not granted by the DAG
116
+
117
+ ### Layer 5: Evaluation DAG
118
+ Compares outcomes against explicit goals and evaluation criteria.
119
+
120
+ Examples:
121
+ - forecast error
122
+ - KPI pass/fail
123
+ - decision quality
124
+ - resource efficiency
125
+ - user value confirmation
126
+
127
+ Evaluation can propose an update to a judgment/policy/DAG version; it does not silently rewrite canonical judgment without the required authority.
128
+
129
+ ## Node contract
130
+
131
+ A shared Judgment DAG node SHOULD converge on the following semantic contract:
132
+
133
+ ```text
134
+ id
135
+ node_type
136
+ layer
137
+ scope
138
+ version
139
+ description
140
+
141
+ depends_on[]
142
+ input_contract
143
+ output_contract
144
+
145
+ runner_type
146
+ deterministic
147
+ agent
148
+ human
149
+ committee
150
+ external
151
+
152
+ authority
153
+ confidence
154
+ valid_from
155
+ valid_to
156
+ provenance
157
+
158
+ evaluation
159
+ ```
160
+
161
+ Initial node types should stay intentionally small:
162
+
163
+ ```text
164
+ observation
165
+ judgment
166
+ decision
167
+ resource
168
+ execution
169
+ outcome
170
+ evaluation
171
+ ```
172
+
173
+ The `outcome` node type therefore remains in the Execution layer even though
174
+ the flow diagram shows it between Execution and Evaluation.
175
+
176
+ Ontology growth must be driven by failed real use cases, not by speculative completeness.
177
+
178
+ ## Edge contract
179
+
180
+ Knowledge/identity relations and judgment dependencies are different concepts and must not be collapsed.
181
+
182
+ Judgment DAG edges include:
183
+
184
+ ```text
185
+ depends_on
186
+ supports
187
+ contradicts
188
+ gates
189
+ supersedes
190
+ produces
191
+ evaluated_by
192
+ triggers
193
+ ```
194
+
195
+ `depends_on` defines executable DAG topology. `node.depends_on` is the
196
+ topology SSOT: every dependency pair must have exactly one matching
197
+ `relation=depends_on` edge, and every `relation=depends_on` edge must have
198
+ exactly one matching node dependency. The edge is a required complete mirror,
199
+ not an optional duplicate declaration; a one-sided or mismatched
200
+ representation is `invalid_contract`. Relations such as `member_of`,
201
+ `owned_by`, or `accountable_for` remain graph semantics and can be referenced
202
+ by DAG nodes.
203
+
204
+ ## Scope model: personal and organization use the same DAG
205
+
206
+ Do not create separate `PersonalDecision` and `CompanyDecision` schemas.
207
+
208
+ A node is scoped instead:
209
+
210
+ ```text
211
+ scope:
212
+ type: personal | project | organization
213
+ id: <scope-id>
214
+ ```
215
+
216
+ This enables promotion:
217
+
218
+ ```text
219
+ Personal Judgment
220
+ ↓ evidence / repeated success
221
+ Project Judgment
222
+ ↓ promotion / authority
223
+ Organization Policy
224
+ ```
225
+
226
+ A judgment can therefore move from an individual's learned heuristic into an organizational capability without translation into a separate schema.
227
+
228
+ J0-1 does not implement cross-scope promotion or authority evidence. Before
229
+ execution, both nodes in every dependency pair must have exactly equal
230
+ `scope.type` and `scope.id`; otherwise validation fails closed with the
231
+ machine-readable code `scope_boundary_violation`. A structurally valid DAG is
232
+ not evidence of execution authority, approval, or promotion. Those governance
233
+ boundaries remain later-scope work.
234
+
235
+ ## Runtime principles inherited from FX / keiba DAG work
236
+
237
+ Brainbase adopts the architecture lessons proven in the `sintariran/FX` and `sintariran/keiba` DAG systems:
238
+
239
+ 1. **Layer ownership is explicit.** A downstream layer must not reimplement an upstream decision.
240
+ 2. **Inputs and outputs cross typed contracts.** No hidden state side channels.
241
+ 3. **Dependencies are validated before execution.** Missing or reverse-layer dependencies are errors.
242
+ 4. **Every run produces artifacts and an execution log.** A judgment must be replayable and auditable.
243
+ 5. **DAG versions are first-class.** A changed judgment structure is a new version, not an invisible mutation.
244
+ 6. **Evaluation is separate from execution.** Metrics must not be gamed by modifying the system under evaluation.
245
+
246
+ ## OSS / organization boundary
247
+
248
+ The Judgment DAG core is OSS-level product capability.
249
+
250
+ OSS includes:
251
+ - node/edge semantic model
252
+ - dependency validation
253
+ - local execution runtime
254
+ - human and agent runners
255
+ - local artifact/execution log
256
+ - versioning
257
+ - replay/evaluation primitives
258
+ - personal/project/organization scope primitives
259
+ - basic authority metadata
260
+
261
+ Organization/Enterprise adds operational concerns rather than a different brain model:
262
+ - organization identity and directory integration
263
+ - robust RBAC / authority graph
264
+ - approval and escalation workflows
265
+ - multi-user concurrency
266
+ - managed connectors
267
+ - audit/compliance retention
268
+ - hosted runtime and HA
269
+ - cross-project governance
270
+ - enterprise security boundaries
271
+
272
+ ## Mana boundary after this decision
273
+
274
+ Mana is no longer defined as the only place where judgment can occur.
275
+
276
+ Brainbase owns **what the judgment graph is, what it depends on, who/what can run it, what it produced, and how it evaluated**.
277
+
278
+ Mana owns the higher-order operating behavior that repeatedly decides *when* to run graphs, prioritizes across goals, initiates work, monitors progress, follows through, and intervenes over time.
279
+
280
+ ```text
281
+ Brainbase: executable organizational cognition
282
+ Mana: autonomous organizational operation
283
+ ```
284
+
285
+ ## Non-goals
286
+
287
+ - Do not migrate the entire Brainbase ontology to a large Company Ontology in one release.
288
+ - Do not make all knowledge executable.
289
+ - Do not let an LLM infer authority implicitly.
290
+ - Do not create a single monolithic company DAG.
291
+ - Do not auto-promote personal judgments into organization policy without explicit evidence and authority.
292
+
293
+ ## First proving ground
294
+
295
+ `Brainbase Deployment` is the first dogfooding domain.
296
+
297
+ The initial DAG should capture:
298
+
299
+ ```text
300
+ Customer Context
301
+ ↓
302
+ Maturity / Problem Structure Judgment
303
+ ↓
304
+ Deployment Pattern Selection
305
+ ↓
306
+ Scope / Resource Decision
307
+ ↓
308
+ Proposal / Implementation
309
+ ↓
310
+ Outcome Evaluation
311
+ ```
312
+
313
+ Human judgment can initially be a runner. Each repeated decision should then be tested for delegation to an agent. The key success signal is a falling count of decisions that still require the original expert directly.
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: Brainbase Judgment DAG Milestones
3
+ status: active
4
+ date: 2026-08-20
5
+ scope: OSS Brainbase
6
+ ---
7
+
8
+ # Brainbase Judgment DAG Milestones
9
+
10
+ This roadmap replaces any implicit assumption that OSS Brainbase stops at memory retrieval. The next milestones make the shared Judgment DAG core real without prematurely building a complete enterprise ontology.
11
+
12
+ ## M0 — Architecture lock
13
+
14
+ Goal: freeze semantic boundaries before implementation.
15
+
16
+ Exit criteria:
17
+ - `judgment-dag-core.md` is accepted.
18
+ - Personal and organization scopes share one node/edge model.
19
+ - Brainbase/Mana boundary is documented as cognition vs autonomous operation.
20
+ - FX/keiba lessons are explicitly adopted: layered ownership, typed boundaries, artifact logs, versioning, evaluation separation.
21
+
22
+ ## M1 — Local DAG kernel
23
+
24
+ Goal: execute a small deterministic DAG locally.
25
+
26
+ Deliverables:
27
+ - `JudgmentDAGNode` / edge types
28
+ - `depends_on` validation
29
+ - layer validation
30
+ - deterministic runner
31
+ - execution artifact store
32
+ - execution log
33
+ - DAG version identifier
34
+
35
+ Exit criteria:
36
+ - A DAG with Context → Judgment → Resource → Execution → Evaluation runs deterministically.
37
+ - Missing dependency and reverse-layer dependency fail before execution.
38
+ - Every node output is inspectable after execution.
39
+ - Existing Brainbase Graph/Decision storage remains compatible.
40
+
41
+ ## M2 — Human + Agent judgment runners
42
+
43
+ Goal: allow a judgment node to be performed by a human or an agent without changing DAG semantics.
44
+
45
+ Deliverables:
46
+ - `runner_type = human | agent | deterministic | external`
47
+ - pending human-step representation
48
+ - agent input/output contract
49
+ - explicit authority metadata
50
+ - confidence/provenance recording
51
+
52
+ Exit criteria:
53
+ - The same judgment node can be run manually and by an agent.
54
+ - Outputs can be compared without hidden context.
55
+ - Agent execution cannot silently acquire additional authority.
56
+
57
+ ## M3 — Replay and evaluation
58
+
59
+ Goal: make judgment quality testable rather than anecdotal.
60
+
61
+ Deliverables:
62
+ - immutable run snapshot / artifact reference
63
+ - replay against historical context
64
+ - explicit goal/evaluation criteria
65
+ - outcome attachment
66
+ - pass/fail or scored evaluation
67
+ - node-level comparison between versions
68
+
69
+ Exit criteria:
70
+ - A prior DAG version can be replayed against a recorded context.
71
+ - A new version can be compared with the prior version without rewriting historical artifacts.
72
+ - Evaluation cannot mutate the event set it evaluates.
73
+
74
+ ## M4 — Brainbase Deployment dogfood
75
+
76
+ Goal: externalize the first real expert judgment process.
77
+
78
+ Initial flow:
79
+
80
+ ```text
81
+ Customer Context
82
+ -> Maturity Judgment
83
+ -> Problem Structure Judgment
84
+ -> Deployment Pattern
85
+ -> Scope / Resource Decision
86
+ -> Proposal / Implementation
87
+ -> Outcome Evaluation
88
+ ```
89
+
90
+ Exit criteria:
91
+ - At least one real deployment is represented end-to-end.
92
+ - Human-only judgment nodes are explicit.
93
+ - Each expert escalation is logged as a missing/uncertain DAG capability rather than disappearing into chat.
94
+ - KPI: number of decisions requiring the original expert is measurable per deployment.
95
+
96
+ ## M5 — Scope promotion
97
+
98
+ Goal: prove Personal → Project → Organization judgment promotion using one schema.
99
+
100
+ Deliverables:
101
+ - scope metadata
102
+ - promotion candidate workflow
103
+ - evidence links
104
+ - authority/approval gate
105
+ - supersession handling
106
+
107
+ Exit criteria:
108
+ - A personal judgment can become project guidance and then organization policy without schema conversion.
109
+ - The historical personal/project records remain queryable.
110
+ - Promotion never occurs solely because an LLM repeats the same output.
111
+
112
+ ## M6 — Organization-ready primitives
113
+
114
+ Goal: keep the core reusable while allowing enterprise products to extend it.
115
+
116
+ Deliverables in OSS core:
117
+ - authority references
118
+ - approval hooks
119
+ - organization scope primitives
120
+ - audit event contract
121
+ - connector/runtime adapter interfaces
122
+
123
+ Not required in OSS M6:
124
+ - SSO/SCIM
125
+ - enterprise directory sync
126
+ - HA hosted runtime
127
+ - compliance retention policies
128
+ - full multi-user approval UI
129
+
130
+ Exit criteria:
131
+ - `brainbase-unson` can implement enterprise authority/governance without forking the DAG semantic model.
132
+
133
+ ## Product metric hierarchy
134
+
135
+ The roadmap is not complete merely because graph/node counts increase. Measure:
136
+
137
+ 1. **Replayability** — can Brainbase explain and rerun why a judgment occurred?
138
+ 2. **Delegatability** — can an agent/another human run the node using explicit contracts?
139
+ 3. **Expert escalation count** — how often is tacit expert judgment still required?
140
+ 4. **Outcome calibration** — do judgment versions improve against declared goals?
141
+ 5. **Promotion quality** — are reusable judgments correctly distinguished from case-specific decisions?
142
+
143
+ The primary dogfood KPI is **expert escalation count per deployment**, not total stored knowledge.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unson/brainbase-mcp",
3
- "version": "0.3.1",
4
- "description": "Local-first Brainbase MCP server and personal onboarding kit.",
3
+ "version": "0.4.1",
4
+ "description": "Local-first Brainbase MCP for preserving decision context and helping humans and AI work from the same judgment criteria.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -10,12 +10,31 @@
10
10
  },
11
11
  "main": "dist/index.js",
12
12
  "types": "dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ },
18
+ "./judgment-dag": {
19
+ "types": "./dist/judgment-dag.d.ts",
20
+ "import": "./dist/judgment-dag.js"
21
+ },
22
+ "./dist/*": "./dist/*",
23
+ "./contracts/judgment-dag/schema.json": "./contracts/judgment-dag/schema.json",
24
+ "./contracts/judgment-dag/fixture.json": "./contracts/judgment-dag/fixture.json",
25
+ "./contracts/judgment-dag/source-lock.json": "./contracts/judgment-dag/source-lock.json",
26
+ "./contracts/judgment-dag/digest.json": "./contracts/judgment-dag/digest.json",
27
+ "./package.json": "./package.json"
28
+ },
13
29
  "bin": {
14
30
  "brainbase-mcp": "dist/index.js",
15
31
  "brainbase": "dist/cli.js"
16
32
  },
17
33
  "files": [
18
34
  "dist",
35
+ "contracts",
36
+ "docs/architecture/judgment-dag-core.md",
37
+ "docs/management/judgment-dag-milestones.md",
19
38
  "README.md",
20
39
  "LICENSE",
21
40
  "SECURITY.md"
@@ -25,13 +44,19 @@
25
44
  },
26
45
  "scripts": {
27
46
  "build": "tsc -p tsconfig.json",
28
- "test": "vitest run",
47
+ "test": "vitest run --exclude tests/npm-prepublication-evidence.integration.test.ts",
29
48
  "test:integration": "vitest run tests/mcp-contract.test.ts tests/ontology-cli.test.ts tests/npm-release-validation.integration.test.ts tests/npm-consumer-smoke.integration.test.ts",
30
49
  "test:consumer-smoke": "vitest run tests/npm-consumer-smoke.integration.test.ts",
31
50
  "test:integration:release-evidence": "vitest run tests/npm-release-validation.integration.test.ts tests/npm-prepublication-evidence.integration.test.ts",
32
51
  "test:e2e": "vitest run tests/e2e/brainbase-mcp-only-acceptance.spec.ts tests/e2e/story-brainbase-portable-ontology-kernel-acceptance.spec.ts",
33
52
  "docs:dev": "vitepress dev docs",
53
+ "docs:sync": "node scripts/sync-public-message.mjs --write",
54
+ "docs:check": "node scripts/check-public-docs.mjs",
34
55
  "docs:build": "vitepress build docs",
56
+ "docs:smoke": "node scripts/check-built-docs.mjs",
57
+ "docs:verify-public": "node scripts/verify-public-site.mjs",
58
+ "docs:promotion:plan": "node scripts/promote-public-message.mjs --plan",
59
+ "docs:promotion:apply": "node scripts/promote-public-message.mjs --apply",
35
60
  "docs:preview": "vitepress preview docs",
36
61
  "start": "node dist/index.js",
37
62
  "doctor": "node dist/cli.js doctor",
@@ -40,6 +65,7 @@
40
65
  "onboard:seed": "node dist/cli.js onboard:seed",
41
66
  "onboard:demo": "node dist/cli.js onboard:demo",
42
67
  "onboard:install": "node dist/cli.js onboard:install",
68
+ "contracts:generate": "node scripts/generate-judgment-dag-contract-artifacts.mjs",
43
69
  "release:plan": "node scripts/npm-release.mjs plan",
44
70
  "release:validate": "node scripts/npm-release.mjs validate",
45
71
  "release:publish": "node scripts/npm-release.mjs publish",
@@ -62,5 +88,5 @@
62
88
  "engines": {
63
89
  "node": ">=20"
64
90
  },
65
- "gitHead": "0ff2753a492aef09235be2792570000ef03dfa4b"
91
+ "gitHead": "b6210adfb43cf4321148e06dc48e94f200b805a5"
66
92
  }