nexo-brain 7.30.30 → 7.30.31

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexo-brain",
3
- "version": "7.30.29",
3
+ "version": "7.30.31",
4
4
  "description": "Local cognitive runtime for Claude Code \u2014 persistent memory, overnight learning, doctor diagnostics, personal scripts, recovery-aware jobs, startup preflight, and optional dashboard/power helper.",
5
5
  "author": {
6
6
  "name": "NEXO Brain",
package/README.md CHANGED
@@ -18,7 +18,11 @@
18
18
 
19
19
  [Watch the overview video](https://nexo-brain.com/watch/) · [Watch on YouTube](https://www.youtube.com/watch?v=i2lkGhKyVqI) · [Open the infographic](https://nexo-brain.com/assets/nexo-brain-infographic-v5.png)
20
20
 
21
- Version `7.30.28` is the current packaged-runtime line. Patch release over v7.30.27 - F0.6 runtime repairs now run through an existing post-install hook, so older updaters execute script-conflict recovery and `core/current` refresh on the first upgrade.
21
+ Version `7.30.31` is the current packaged-runtime line. Patch release over v7.30.30 - Core Rules now reach agents both through a compact managed bootstrap summary and task-specific `cortex/task_open` injection from the protected `core_rules` registry.
22
+
23
+ Previously in `7.30.30`: product-managed Core Rules now sync from `src/rules/core-rules.json` into protected DB rows for bootstrap and product behavior, with provenance, hashes, severity, and install/update synchronization.
24
+
25
+ Previously in `7.30.29`: runtime disk guards now bound hourly database backups and pause Local Memory indexing before disk pressure becomes unsafe.
22
26
 
23
27
  Previously in `7.30.27`: patch release over v7.30.26 - post-update repair now recovers core scripts archived by older F0.6 shim reconciliation and refreshes `core/current` from `core`, so same-version snapshots cannot keep stale watchdog code.
24
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexo-brain",
3
- "version": "7.30.30",
3
+ "version": "7.30.31",
4
4
  "mcpName": "io.github.wazionapps/nexo",
5
5
  "description": "NEXO Brain — Shared brain for AI agents. Persistent memory, semantic RAG, natural forgetting, metacognitive guard, trust scoring, 150+ MCP tools. Works with Claude Code, Codex, Claude Desktop & any MCP client. 100% local, free.",
6
6
  "homepage": "https://nexo-brain.com",
package/src/db/_schema.py CHANGED
@@ -3071,6 +3071,7 @@ def _m80_opportunity_orchestrator(conn):
3071
3071
 
3072
3072
  def _m81_core_rules_product_metadata(conn):
3073
3073
  """Add product-core provenance and protection metadata to core_rules."""
3074
+ _m15_core_rules_tables(conn)
3074
3075
  _migrate_add_column(conn, "core_rules", "source_artifact", "TEXT DEFAULT ''")
3075
3076
  _migrate_add_column(conn, "core_rules", "source_anchor", "TEXT DEFAULT ''")
3076
3077
  _migrate_add_column(conn, "core_rules", "content_hash", "TEXT DEFAULT ''")
@@ -31,25 +31,159 @@ def _get_db():
31
31
  return get_db()
32
32
 
33
33
 
34
+ _CLASSIC_RULE_CATEGORIES_BY_TASK = {
35
+ "edit": ["integrity", "execution"],
36
+ "execute": ["integrity", "execution", "delegation"],
37
+ "delegate": ["delegation"],
38
+ "analyze": ["execution", "memory"],
39
+ "answer": ["communication"],
40
+ }
41
+
42
+ _PRODUCT_RULE_IDS_BY_TASK = {
43
+ "answer": [
44
+ "PC1", # Context before asking
45
+ "PC2", # Capability before delegating work to the user
46
+ "PC4", # Evidence before closure claims
47
+ "PC8", # Do not invent product capabilities
48
+ "PC16", # Continuity of identity and sessions
49
+ "PC19", # Product language, not internal jargon
50
+ "PC24", # Read what NEXO already wrote before acting
51
+ "PC25", # External state claims require live evidence
52
+ "PC28", # Check real capability before denying
53
+ "PC29", # Operational explanation stays simple
54
+ "PC32", # Reuse prior work before researching from zero
55
+ "MEMORY_AUTHORITY",
56
+ "IDENTITY_CONTINUITY",
57
+ "SAFE_AUTONOMY_FIRST",
58
+ "DEFERRED_TOOL_DISCOVERY",
59
+ ],
60
+ "analyze": [
61
+ "PC1",
62
+ "PC2",
63
+ "PC5",
64
+ "PC16",
65
+ "PC24",
66
+ "PC25",
67
+ "PC28",
68
+ "PC31",
69
+ "PC32",
70
+ "MEMORY_AUTHORITY",
71
+ "CORE_SYSTEM_AWARENESS",
72
+ "SAFE_AUTONOMY_FIRST",
73
+ ],
74
+ "edit": [
75
+ "PC3",
76
+ "PC4",
77
+ "PC5",
78
+ "PC18",
79
+ "PC24",
80
+ "PC25",
81
+ "PC30",
82
+ "PC31",
83
+ "PC32",
84
+ "RUNTIME_CORE_PROTECTED",
85
+ "MEMORY_AUTHORITY",
86
+ "SAFE_AUTONOMY_FIRST",
87
+ ],
88
+ "execute": [
89
+ "PC2",
90
+ "PC3",
91
+ "PC4",
92
+ "PC10",
93
+ "PC11",
94
+ "PC12",
95
+ "PC13",
96
+ "PC14",
97
+ "PC15",
98
+ "PC17",
99
+ "PC25",
100
+ "PC26",
101
+ "PC27",
102
+ "RUNTIME_CORE_PROTECTED",
103
+ "SAFE_AUTONOMY_FIRST",
104
+ ],
105
+ "delegate": [
106
+ "PC1",
107
+ "PC2",
108
+ "PC10",
109
+ "PC11",
110
+ "PC12",
111
+ "PC16",
112
+ "PC24",
113
+ "PC31",
114
+ "PC32",
115
+ "MEMORY_AUTHORITY",
116
+ "IDENTITY_CONTINUITY",
117
+ ],
118
+ }
119
+
120
+ _DEFAULT_PRODUCT_RULE_IDS = [
121
+ "PC1",
122
+ "PC2",
123
+ "PC4",
124
+ "PC24",
125
+ "PC25",
126
+ "PC28",
127
+ "PC32",
128
+ "MEMORY_AUTHORITY",
129
+ "SAFE_AUTONOMY_FIRST",
130
+ ]
131
+
132
+
133
+ def _sync_core_rules_if_available() -> None:
134
+ try:
135
+ from plugins.core_rules import _sync_if_needed
136
+ _sync_if_needed()
137
+ except Exception:
138
+ pass
139
+
140
+
141
+ def _rule_rows_for_ids(conn, ids: list[str]) -> list:
142
+ unique_ids = list(dict.fromkeys(ids))
143
+ if not unique_ids:
144
+ return []
145
+ placeholders = ",".join("?" * len(unique_ids))
146
+ rows = conn.execute(
147
+ f"""SELECT id, rule
148
+ FROM core_rules
149
+ WHERE id IN ({placeholders}) AND is_active = 1 AND type = 'blocking'""",
150
+ unique_ids,
151
+ ).fetchall()
152
+ by_id = {row["id"]: row for row in rows}
153
+ return [by_id[rule_id] for rule_id in unique_ids if rule_id in by_id]
154
+
155
+
156
+ def _classic_rule_rows_for_task(conn, task_type: str, excluded_ids: set[str], limit: int = 5) -> list:
157
+ categories = _CLASSIC_RULE_CATEGORIES_BY_TASK.get(task_type, ["integrity", "execution"])
158
+ placeholders = ",".join("?" * len(categories))
159
+ rows = conn.execute(
160
+ f"""SELECT id, rule
161
+ FROM core_rules
162
+ WHERE category IN ({placeholders})
163
+ AND is_active = 1
164
+ AND type = 'blocking'
165
+ ORDER BY importance DESC, category, id
166
+ LIMIT ?""",
167
+ [*categories, limit + len(excluded_ids)],
168
+ ).fetchall()
169
+ filtered = [row for row in rows if row["id"] not in excluded_ids]
170
+ return filtered[:limit]
171
+
172
+
34
173
  def _get_core_rules_for_task(task_type: str) -> list[str]:
35
174
  """Get relevant Core Rules for the given task type."""
36
- conn = _get_db()
37
175
  try:
38
- # Map task type to rule categories
39
- category_map = {
40
- "edit": ["integrity", "execution"],
41
- "execute": ["integrity", "execution", "delegation"],
42
- "delegate": ["delegation"],
43
- "analyze": ["execution", "memory"],
44
- "answer": ["communication"],
45
- }
46
- categories = category_map.get(task_type, ["integrity", "execution"])
47
- placeholders = ",".join("?" * len(categories))
48
-
49
- rows = conn.execute(
50
- f"SELECT id, rule FROM core_rules WHERE category IN ({placeholders}) AND is_active = 1 AND type = 'blocking' ORDER BY importance DESC LIMIT 5",
51
- categories
52
- ).fetchall()
176
+ _sync_core_rules_if_available()
177
+ conn = _get_db()
178
+ clean_type = str(task_type or "").strip().lower()
179
+ product_ids = _PRODUCT_RULE_IDS_BY_TASK.get(clean_type, _DEFAULT_PRODUCT_RULE_IDS)
180
+ product_rows = _rule_rows_for_ids(conn, product_ids)
181
+ classic_rows = _classic_rule_rows_for_task(
182
+ conn,
183
+ clean_type,
184
+ {row["id"] for row in product_rows},
185
+ )
186
+ rows = classic_rows + product_rows
53
187
  return [f"{r['id']}: {r['rule']}" for r in rows]
54
188
  except Exception:
55
189
  return []
@@ -30,6 +30,22 @@ Claude Code may list `mcp__nexo__*` tools as **deferred** at session start (name
30
30
  - Diagnostic plane: `nexo_doctor plane='installation_live'` inspects client/install surfaces — consult it when tools appear missing on a fresh install.
31
31
  <!-- nexo:end:tools_at_startup -->
32
32
 
33
+ ## Core Rules Summary
34
+ The full protected registry lives in NEXO Brain `core_rules`. Keep this compact summary active from the first turn:
35
+
36
+ - Check existing context, memory, tickets, files, credentials, and prior work before asking the user.
37
+ - Do not ask the user to do work that NEXO can safely do with available tools.
38
+ - Prepare up to the safe boundary; ask only for real decisions, missing credentials, approvals, payments, destructive actions, or legally required consent.
39
+ - Verify current reality before claiming facts about external state, product capabilities, dates, versions, servers, routes, ports, schemas, or tickets.
40
+ - Do not invent or deny NEXO capabilities without checking the live product/source of truth first.
41
+ - Preserve one continuous user-facing identity across supported clients and sessions.
42
+ - Treat Brain, calibration, profile, decisions, learnings, diary, and followups as stronger authority than legacy client memory files.
43
+ - Keep product-managed `CORE` separate from tenant/operator-managed `USER`; updates may rewrite `CORE` but must preserve `USER`.
44
+ - Never leak personal or tenant-specific configuration into global product rules.
45
+ - Reuse recorded work, decisions, skills, and successful procedures before researching or building from zero.
46
+ - Review existing architecture before adding parallel queues, supervisors, recovery layers, or duplicate systems.
47
+ - Close work only with evidence, and keep actions, promises, followups, and ticket decisions in a single traceable ledger.
48
+
33
49
  ## Protocol (7 rules)
34
50
  1. `nexo_startup` once per session and keep the returned `SID`.
35
51
  2. `nexo_heartbeat` on every user message.
@@ -25,6 +25,22 @@ Codex (and Claude Code) may list `mcp__nexo__*` tools as **deferred** at session
25
25
  - If discovery still cannot resolve a `nexo_*` tool, then (and only then) treat it as a real runtime gap and surface it as a blocker.
26
26
  - Diagnostic plane: `nexo_doctor plane='installation_live'` inspects client/install surfaces — consult it when tools appear missing on a fresh install.
27
27
 
28
+ ## Core Rules Summary
29
+ The full protected registry lives in NEXO Brain `core_rules`. Keep this compact summary active from the first turn:
30
+
31
+ - Check existing context, memory, tickets, files, credentials, and prior work before asking the user.
32
+ - Do not ask the user to do work that NEXO can safely do with available tools.
33
+ - Prepare up to the safe boundary; ask only for real decisions, missing credentials, approvals, payments, destructive actions, or legally required consent.
34
+ - Verify current reality before claiming facts about external state, product capabilities, dates, versions, servers, routes, ports, schemas, or tickets.
35
+ - Do not invent or deny NEXO capabilities without checking the live product/source of truth first.
36
+ - Preserve one continuous user-facing identity across supported clients and sessions.
37
+ - Treat Brain, calibration, profile, decisions, learnings, diary, and followups as stronger authority than legacy client memory files.
38
+ - Keep product-managed `CORE` separate from tenant/operator-managed `USER`; updates may rewrite `CORE` but must preserve `USER`.
39
+ - Never leak personal or tenant-specific configuration into global product rules.
40
+ - Reuse recorded work, decisions, skills, and successful procedures before researching or building from zero.
41
+ - Review existing architecture before adding parallel queues, supervisors, recovery layers, or duplicate systems.
42
+ - Close work only with evidence, and keep actions, promises, followups, and ticket decisions in a single traceable ledger.
43
+
28
44
  ## Protocol (7 rules)
29
45
  1. `nexo_startup` once per session, then keep the returned `SID`.
30
46
  2. `nexo_heartbeat` on every user message.