@mindrian_os/install 1.13.0-beta.12 → 1.13.0-beta.13

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.
@@ -1174,6 +1174,41 @@ const TEST_FILES = [
1174
1174
  // (migration used to crash openRoomDb for any room.db carrying the Phase-89
1175
1175
  // rs_discoveries view: "error in view rs_discoveries: no such table: main.nodes").
1176
1176
  path.join(REPO_ROOT, 'tests', 'test-navigation-migration-views.cjs'),
1177
+ // Phase 109 SQL Context-Memory Navigation Spine: the 15 test suites that the
1178
+ // Plan 109-00 Task 4 registration originally specified but that a later refactor
1179
+ // dropped from this array before main HEAD (the originals ran via direct
1180
+ // `node tests/test-*.cjs` and `bash tests/run-all.sh` throughout the phase).
1181
+ // Re-registered by Plan 109-12 (bookkeeping reconciliation). Mapping:
1182
+ // test-navigation-acceptance.cjs -> 109-10 (NAV-109-09 load-bearing acceptance gate; zero non-SQLite reads)
1183
+ // test-navigation-focus.cjs -> 109-02 (NAV-109-01 session_focus + auto-focus cascade)
1184
+ // test-navigation-neighborhood.cjs -> 109-04 (NAV-109-02 recursive-CTE ranking correctness)
1185
+ // test-navigation-perf-10k.cjs -> 109-04 (NAV-109-02 perf: cold p95 <200ms / warm <50ms)
1186
+ // test-navigation-memory-events.cjs -> 109-03 (NAV-109-03 closed-15 event enum + findRecentChanges)
1187
+ // test-navigation-insights.cjs -> 109-05 (NAV-109-04 7 insight primitives + templated explanations)
1188
+ // test-navigation-chokepoint-hook.cjs -> 109-06 (NAV-109-05 no direct room-db.cjs imports outside allow-list)
1189
+ // test-navigation-packet-builder.cjs -> 109-07 (NAV-109-06 buildBrainPacket shape per D-06)
1190
+ // test-navigation-packet-part8-leak.cjs -> 109-07 (NAV-109-06 Part 8 JSON.stringify leak tripwires)
1191
+ // test-brain-ingestion-part-9-invariant.cjs -> 109-08 (NAV-109-07 storeBrainSuggestions proposed-only + invariant SQL = 0)
1192
+ // test-room-home-vs-brain-derivation-regression.cjs -> 109-09 (NAV-109-08 getRoomHomeView + Phase 90 deriveSection regression fence)
1193
+ // test-canon-part-9-ratification.cjs -> 109-11 (NAV-109-09 Canon Part 9 structural assertions)
1194
+ // test-navigation-migration-idempotent.cjs -> 109-01 (migration twice = no-op; 12-column nodes schema)
1195
+ // test-navigation-migration-backfill.cjs -> 109-01 (properties JSON backfill + status_aliases mapping)
1196
+ // test-navigation-migration-coexistence.cjs -> 109-01 (navigation API + assumptions.validity coexist mid-migration)
1197
+ path.join(REPO_ROOT, 'tests', 'test-navigation-acceptance.cjs'),
1198
+ path.join(REPO_ROOT, 'tests', 'test-navigation-focus.cjs'),
1199
+ path.join(REPO_ROOT, 'tests', 'test-navigation-neighborhood.cjs'),
1200
+ path.join(REPO_ROOT, 'tests', 'test-navigation-perf-10k.cjs'),
1201
+ path.join(REPO_ROOT, 'tests', 'test-navigation-memory-events.cjs'),
1202
+ path.join(REPO_ROOT, 'tests', 'test-navigation-insights.cjs'),
1203
+ path.join(REPO_ROOT, 'tests', 'test-navigation-chokepoint-hook.cjs'),
1204
+ path.join(REPO_ROOT, 'tests', 'test-navigation-packet-builder.cjs'),
1205
+ path.join(REPO_ROOT, 'tests', 'test-navigation-packet-part8-leak.cjs'),
1206
+ path.join(REPO_ROOT, 'tests', 'test-brain-ingestion-part-9-invariant.cjs'),
1207
+ path.join(REPO_ROOT, 'tests', 'test-room-home-vs-brain-derivation-regression.cjs'),
1208
+ path.join(REPO_ROOT, 'tests', 'test-canon-part-9-ratification.cjs'),
1209
+ path.join(REPO_ROOT, 'tests', 'test-navigation-migration-idempotent.cjs'),
1210
+ path.join(REPO_ROOT, 'tests', 'test-navigation-migration-backfill.cjs'),
1211
+ path.join(REPO_ROOT, 'tests', 'test-navigation-migration-coexistence.cjs'),
1177
1212
  // Phase 89-07 Wave 0 (graph-native HARD RULE; ReverseSalientAgent dual-surface).
1178
1213
  path.join(REPO_ROOT, 'tests', 'test-reverse-salient-agent.cjs'),
1179
1214
  path.join(REPO_ROOT, 'tests', 'test-reverse-salient-cascade-emit.cjs'),
@@ -1225,6 +1260,56 @@ const TEST_FILES = [
1225
1260
  // -> validateChainAutonomy stop-point) + the Canon Part 8 zero-Brain-mutation
1226
1261
  // grep sweep.
1227
1262
  path.join(REPO_ROOT, 'lib', 'memory', 'workflow-layer-e2e.test.cjs'),
1263
+ // Phase 110-00: Brain Context Packet Contract Wave 0 substrate (4 stubs filled by Plans 110-01 / 110-04 / 110-05).
1264
+ // test-brain-packet-schema-check.cjs -> 110-01 (PACKET-110-01 + -02: the --check schema tripwire)
1265
+ // test-brain-packet-validation-per-job.cjs -> 110-05 (PACKET-110-03 + -04 + -07 + -08: 12-job in/out + privacy + dual-path)
1266
+ // test-brain-packet-part8-invariant-per-job.cjs -> 110-05 (PACKET-110-06 round-trip + D-11(d) adversarial sweep)
1267
+ // test-brain-packet-precommit-hook.cjs -> 110-04 (PACKET-110-05 D-08 layer-2 hook)
1268
+ path.join(REPO_ROOT, 'tests', 'test-brain-packet-schema-check.cjs'),
1269
+ path.join(REPO_ROOT, 'tests', 'test-brain-packet-validation-per-job.cjs'),
1270
+ path.join(REPO_ROOT, 'tests', 'test-brain-packet-part8-invariant-per-job.cjs'),
1271
+ path.join(REPO_ROOT, 'tests', 'test-brain-packet-precommit-hook.cjs'),
1272
+ // Phase 123 (install-lifecycle-harness) block.
1273
+ // Plan 123-01: release.sh semver bump algebra + two-commit form + dirty-repo guard + Step 9.5 rename.
1274
+ // Tests A-E (semver assertions) GREEN immediately; Tests F/G (release.sh
1275
+ // structural) RED until Plan 123-01 Task 2 rewrites release.sh -- intended RED->GREEN.
1276
+ // Plan 123-02: install-state record + data/deployment-surfaces.json manifest +
1277
+ // active-plugin-root.cjs topology classification. Tests 1+4+6 (topology /
1278
+ // Canon Part 8 / early-write ordering) GREEN after Task 1; Tests 2+3
1279
+ // (record write hermetic / idempotent re-run) GREEN after Task 2;
1280
+ // Test 5 (manifest schema) GREEN after Task 3.
1281
+ // Plan 123-03: doctor classes I (install-state + topology + 6-way version-
1282
+ // of-record consistency) + J (deployment-surface manifest reconciliation)
1283
+ // + aggressive --fix (legacy migration backup-verify-remove; never
1284
+ // touches a dev-clone) + Bug-7 fix (marketplace-cache topology is
1285
+ // HEALTHY, not drift). Tests RED until Task 2 lands class I + class J
1286
+ // in scripts/doctor.cjs -- intended RED->GREEN.
1287
+ // Plan 123-04: doctor --acceptance (release-gate-as-a-command) -- 5-point
1288
+ // pre-tag checklist + 7-point full checklist + --light-npx opt-in; wired
1289
+ // into release.sh as hard aborts (Step 6.6 pre-tag, Step 9.6 post-publish);
1290
+ // scripts/release-beta-smoke.sh retired. Tests RED until Task 2 lands
1291
+ // --acceptance in scripts/doctor.cjs AND Task 3 wires release.sh + deletes
1292
+ // release-beta-smoke.sh -- intended RED->GREEN.
1293
+ // Plan 123-05: cache-prune helper (HARNESS-123-13) + doc/test sweep
1294
+ // (HARNESS-123-14). 6 hermetic scenarios for pruneMarketplaceCache
1295
+ // (active + N most-recent kept; corrupt installed_plugins.json -> skip;
1296
+ // dryRun -> no mutation; belt+suspenders active-dir protection; Canon
1297
+ // Part 8 grep clean). Tests GREEN after Task 1 lands
1298
+ // lib/core/cache-prune.cjs.
1299
+ // Plan 123-07: resolve-brain-key.cjs (HARNESS-123-15) + brain-client.cjs
1300
+ // getApiKey() delegation (HARNESS-123-16). 9 hermetic scenarios cover
1301
+ // order (env -> ~/.mindrian.env -> CWD .env -> not-found), SEC-02
1302
+ // POSIX 0o077 reject, Canon Part 8 zero-network grep, the brain-client
1303
+ // delegation spy, brain-client preconditions, and the FLAG-3
1304
+ // env-aware-home structural assertion. rbk.1-6 + rbk.9 GREEN after
1305
+ // Task 1; rbk.7 + rbk.8 GREEN after Task 2 (brain-client rewire).
1306
+ path.join(REPO_ROOT, 'tests', 'test-release-bump-algebra.cjs'),
1307
+ path.join(REPO_ROOT, 'tests', 'test-install-state-record.cjs'),
1308
+ path.join(REPO_ROOT, 'tests', 'test-doctor-class-i.cjs'),
1309
+ path.join(REPO_ROOT, 'tests', 'test-doctor-class-j.cjs'),
1310
+ path.join(REPO_ROOT, 'tests', 'test-doctor-acceptance.cjs'),
1311
+ path.join(REPO_ROOT, 'tests', 'test-cache-prune.cjs'),
1312
+ path.join(REPO_ROOT, 'tests', 'test-resolve-brain-key.cjs'),
1228
1313
  ];
1229
1314
 
1230
1315
  // Exit code convention for child tests:
@@ -290,14 +290,31 @@ test('brain-client.cjs has zero legacy .replace(/"/g, ...) injection patterns',
290
290
  );
291
291
  });
292
292
 
293
- test('brain-client.cjs guards .env reads with checkFilePermissions', () => {
293
+ test('SEC-02 .env gating lives in resolve-brain-key.cjs (Phase 123 Plan-07)', () => {
294
+ // Phase 123 Plan-07: getApiKey() now delegates to lib/core/resolve-brain-key.cjs,
295
+ // which owns the SEC-02 POSIX 0o077 permission check for both ~/.mindrian.env
296
+ // and CWD .env. The brain-client.cjs::checkFilePermissions() helper remains
297
+ // exported via _test for backward-compat (and unit-test surface above), but
298
+ // the live gating call sites moved one layer down. The invariant is:
299
+ // 1. brain-client.cjs requires resolve-brain-key.cjs (delegation lives).
300
+ // 2. resolve-brain-key.cjs contains the 0o077 mask check (SEC-02 lives).
301
+ // Both must hold; either failure is a regression that re-introduces the
302
+ // pre-Plan-07 multiple-resolver disease.
294
303
  const brainPath = path.resolve(__dirname, '..', 'core', 'brain-client.cjs');
295
- const src = fs.readFileSync(brainPath, 'utf8');
296
- const matches = src.match(/checkFilePermissions\s*\(/g) || [];
297
- // 1 definition + 2 getApiKey call sites (cwd .env + ~/.mindrian.env) = 3.
304
+ const resolverPath = path.resolve(__dirname, '..', 'core', 'resolve-brain-key.cjs');
305
+ const brainSrc = fs.readFileSync(brainPath, 'utf8');
306
+ const resolverSrc = fs.readFileSync(resolverPath, 'utf8');
298
307
  assert.ok(
299
- matches.length >= 3,
300
- `expected >= 3 checkFilePermissions occurrences, got ${matches.length}`
308
+ /require\(['"][^'"]*resolve-brain-key[^'"]*['"]\)/.test(brainSrc),
309
+ 'brain-client.cjs must require resolve-brain-key.cjs (Phase 123 Plan-07 delegation)'
310
+ );
311
+ assert.ok(
312
+ /0o077/.test(resolverSrc),
313
+ 'resolve-brain-key.cjs must contain the SEC-02 0o077 mask check'
314
+ );
315
+ assert.ok(
316
+ /process\.platform/.test(resolverSrc),
317
+ 'resolve-brain-key.cjs must short-circuit the SEC-02 check on Windows (process.platform)'
301
318
  );
302
319
  });
303
320
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindrian_os/install",
3
- "version": "1.13.0-beta.12",
3
+ "version": "1.13.0-beta.13",
4
4
  "description": "Install MindrianOS into Claude Code with one command -- `npx @mindrian_os/install`. Ships the MindrianOS plugin (Larry + PWS methodology + Data Room) plus a setup/diagnostics CLI (install/doctor/update).",
5
5
  "scripts": {
6
6
  "mcp": "node bin/mindrian-mcp-server.cjs",
@@ -37,6 +37,9 @@
37
37
  "markdown-it": "^14.1.0",
38
38
  "zod": "^3.25.76"
39
39
  },
40
+ "devDependencies": {
41
+ "semver": "^7.7.4"
42
+ },
40
43
  "engines": {
41
44
  "node": ">=22.5.0"
42
45
  },
@@ -12,7 +12,10 @@ activation: "env:MINDRIAN_BRAIN_KEY"
12
12
  ## Detection
13
13
 
14
14
  Check Brain availability in order:
15
- 1. `MINDRIAN_BRAIN_KEY` env var (CLI users)
15
+
16
+ **Step 0 -- HTTP-path detection (Phase 123, the standard install).** Run `node $PLUGIN_ROOT/lib/core/resolve-brain-key.cjs` (or in JS: `require('./lib/core/resolve-brain-key.cjs').resolveBrainKey()`). If the resolver returns `available: true`, the Brain is active via the **HTTP path** -- call into `lib/core/brain-client.cjs`'s `query() / search() / schema() / ask()`, NOT an MCP tool. The HTTP path is the standard install path on Claude Code CLI; the MCP path (steps 1-3 below) is an alternative for operators who bundle `mcp-server-brain/` or point an external Neo4j MCP at the canonical `mindrian-brain` server name. The resolver also surfaces SEC-02 permission failures explicitly (`available: false, reason: 'permissions too open: ...'`) -- treat those as "not loaded, user action needed", not as silent unavailability.
17
+
18
+ 1. `MINDRIAN_BRAIN_KEY` env var (CLI users -- subsumed by step 0; kept for legacy detection)
16
19
  2. `mcp__mindrian-brain__brain_schema` tool (Desktop/Cowork MCP)
17
20
  3. `mcp__neo4j-brain__get_neo4j_schema` tool (legacy)
18
21
 
@@ -108,5 +111,8 @@ Always use `brain_ask` first -- natural language, auto-routes Pinecone/Neo4j, ha
108
111
 
109
112
  | Surface | Smart | Neo4j | Pinecone | Schema |
110
113
  |---------|-------|-------|----------|--------|
111
- | mindrian-brain | brain_ask | brain_query | brain_search | brain_schema |
112
- | neo4j-brain (legacy) | N/A | read_neo4j_cypher | search-records | get_neo4j_schema |
114
+ | CLI (HTTP via brain-client.cjs) | `brain-client.ask()` | `brain-client.query()` | `brain-client.search()` | `brain-client.schema()` |
115
+ | mindrian-brain (MCP) | brain_ask | brain_query | brain_search | brain_schema |
116
+ | neo4j-brain (legacy MCP) | N/A | read_neo4j_cypher | search-records | get_neo4j_schema |
117
+
118
+ The first row is the HTTP path (Phase 123 step 0). When `lib/core/resolve-brain-key.cjs` resolves a key, call directly into `lib/core/brain-client.cjs` -- no MCP server required. The bottom two rows are the MCP-path alternatives.