nava-agent 0.2.0__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 (95) hide show
  1. nava_agent-0.2.0/MANIFEST.in +35 -0
  2. nava_agent-0.2.0/PKG-INFO +548 -0
  3. nava_agent-0.2.0/README.md +534 -0
  4. nava_agent-0.2.0/nava.yaml +112 -0
  5. nava_agent-0.2.0/pyproject.toml +29 -0
  6. nava_agent-0.2.0/setup.cfg +4 -0
  7. nava_agent-0.2.0/src/nava/agents/factory.py +141 -0
  8. nava_agent-0.2.0/src/nava/agents/planner.py +146 -0
  9. nava_agent-0.2.0/src/nava/agents/runtime/browser_agent.py +171 -0
  10. nava_agent-0.2.0/src/nava/agents/runtime/coding_agent.py +117 -0
  11. nava_agent-0.2.0/src/nava/agents/runtime/computer_agent.py +123 -0
  12. nava_agent-0.2.0/src/nava/agents/runtime/dynamic_agent.py +122 -0
  13. nava_agent-0.2.0/src/nava/agents/runtime/file_agent.py +127 -0
  14. nava_agent-0.2.0/src/nava/agents/runtime/file_agent_variants.py +24 -0
  15. nava_agent-0.2.0/src/nava/agents/runtime/nava_agent.py +212 -0
  16. nava_agent-0.2.0/src/nava/agents/runtime/research_agent.py +119 -0
  17. nava_agent-0.2.0/src/nava/agents/runtime/reviewer_agent.py +114 -0
  18. nava_agent-0.2.0/src/nava/agents/runtime/terminal_agent.py +113 -0
  19. nava_agent-0.2.0/src/nava/agents/templates.py +137 -0
  20. nava_agent-0.2.0/src/nava/cli.py +17 -0
  21. nava_agent-0.2.0/src/nava/core/boot.py +154 -0
  22. nava_agent-0.2.0/src/nava/core/ledger.py +145 -0
  23. nava_agent-0.2.0/src/nava/core/llm.py +51 -0
  24. nava_agent-0.2.0/src/nava/core/message_bus.py +174 -0
  25. nava_agent-0.2.0/src/nava/core/sanitizer.py +40 -0
  26. nava_agent-0.2.0/src/nava/core/schemas.py +246 -0
  27. nava_agent-0.2.0/src/nava/credentials/broker.py +102 -0
  28. nava_agent-0.2.0/src/nava/credentials/vault.py +133 -0
  29. nava_agent-0.2.0/src/nava/gateway/pipeline.py +314 -0
  30. nava_agent-0.2.0/src/nava/gateway/schema_validator.py +75 -0
  31. nava_agent-0.2.0/src/nava/governance/budget_engine.py +101 -0
  32. nava_agent-0.2.0/src/nava/governance/compensation_engine.py +94 -0
  33. nava_agent-0.2.0/src/nava/governance/dom_sanitizer.py +122 -0
  34. nava_agent-0.2.0/src/nava/governance/hitl_manager.py +74 -0
  35. nava_agent-0.2.0/src/nava/governance/lock_manager.py +161 -0
  36. nava_agent-0.2.0/src/nava/governance/policy_engine.py +65 -0
  37. nava_agent-0.2.0/src/nava/governance/risk_engine.py +128 -0
  38. nava_agent-0.2.0/src/nava/governance/rollback_engine.py +122 -0
  39. nava_agent-0.2.0/src/nava/governance/state_observer.py +50 -0
  40. nava_agent-0.2.0/src/nava/memory/ai_twin.py +105 -0
  41. nava_agent-0.2.0/src/nava/memory/bm25.py +129 -0
  42. nava_agent-0.2.0/src/nava/memory/embeddings.py +129 -0
  43. nava_agent-0.2.0/src/nava/memory/hybrid_rag.py +227 -0
  44. nava_agent-0.2.0/src/nava/memory/store.py +202 -0
  45. nava_agent-0.2.0/src/nava/orchestrator.py +1033 -0
  46. nava_agent-0.2.0/src/nava/prompts/browser_prompt.txt +93 -0
  47. nava_agent-0.2.0/src/nava/prompts/coding_agent_prompt.txt +99 -0
  48. nava_agent-0.2.0/src/nava/prompts/computer_agent_prompt.txt +15 -0
  49. nava_agent-0.2.0/src/nava/prompts/dynamic_agent_prompt.txt +74 -0
  50. nava_agent-0.2.0/src/nava/prompts/file_agent_prompt.txt +52 -0
  51. nava_agent-0.2.0/src/nava/prompts/nava_agent_prompt.txt +61 -0
  52. nava_agent-0.2.0/src/nava/prompts/planner_prompt.txt +65 -0
  53. nava_agent-0.2.0/src/nava/prompts/research_agent_prompt.txt +19 -0
  54. nava_agent-0.2.0/src/nava/prompts/reviewer_agent_prompt.txt +105 -0
  55. nava_agent-0.2.0/src/nava/prompts/terminal_agent_prompt.txt +12 -0
  56. nava_agent-0.2.0/src/nava/skills/manager.py +218 -0
  57. nava_agent-0.2.0/src/nava/skills/promotion.py +168 -0
  58. nava_agent-0.2.0/src/nava/tools/browser.py +232 -0
  59. nava_agent-0.2.0/src/nava/tools/desktop.py +187 -0
  60. nava_agent-0.2.0/src/nava/tools/executor.py +1050 -0
  61. nava_agent-0.2.0/src/nava/tools/mcp_client.py +368 -0
  62. nava_agent-0.2.0/src/nava/tools/mcp_gmail_server.py +130 -0
  63. nava_agent-0.2.0/src/nava/tools/registry.py +40 -0
  64. nava_agent-0.2.0/src/nava/ui/cowork_tui.py +376 -0
  65. nava_agent-0.2.0/src/nava/ui/terminal.py +245 -0
  66. nava_agent-0.2.0/src/nava/workspace/__init__.py +9 -0
  67. nava_agent-0.2.0/src/nava/workspace/indexer.py +170 -0
  68. nava_agent-0.2.0/src/nava/workspace/project_manager.py +340 -0
  69. nava_agent-0.2.0/src/nava_agent.egg-info/PKG-INFO +548 -0
  70. nava_agent-0.2.0/src/nava_agent.egg-info/SOURCES.txt +93 -0
  71. nava_agent-0.2.0/src/nava_agent.egg-info/dependency_links.txt +1 -0
  72. nava_agent-0.2.0/src/nava_agent.egg-info/entry_points.txt +2 -0
  73. nava_agent-0.2.0/src/nava_agent.egg-info/requires.txt +6 -0
  74. nava_agent-0.2.0/src/nava_agent.egg-info/top_level.txt +1 -0
  75. nava_agent-0.2.0/tests/test_21_invariants.py +400 -0
  76. nava_agent-0.2.0/tests/test_agent_message_bus.py +130 -0
  77. nava_agent-0.2.0/tests/test_cowork_ui.py +138 -0
  78. nava_agent-0.2.0/tests/test_credentials.py +113 -0
  79. nava_agent-0.2.0/tests/test_hybrid_rag.py +161 -0
  80. nava_agent-0.2.0/tests/test_phase0.py +158 -0
  81. nava_agent-0.2.0/tests/test_phase1.py +104 -0
  82. nava_agent-0.2.0/tests/test_phase2.py +124 -0
  83. nava_agent-0.2.0/tests/test_phase3.py +70 -0
  84. nava_agent-0.2.0/tests/test_phase4.py +97 -0
  85. nava_agent-0.2.0/tests/test_phase4c.py +99 -0
  86. nava_agent-0.2.0/tests/test_phase4d.py +139 -0
  87. nava_agent-0.2.0/tests/test_project_workspace.py +159 -0
  88. nava_agent-0.2.0/tests/test_specialized_agents.py +214 -0
  89. nava_agent-0.2.0/tests/test_step1_fixes.py +256 -0
  90. nava_agent-0.2.0/tests/test_step2_parallel.py +280 -0
  91. nava_agent-0.2.0/tests/test_step3_mcp_hardening.py +171 -0
  92. nava_agent-0.2.0/tests/test_step4_skill_promotion.py +180 -0
  93. nava_agent-0.2.0/tests/test_step5_kill_switch_injection.py +182 -0
  94. nava_agent-0.2.0/tests/test_step6_memory_ai_twin.py +173 -0
  95. nava_agent-0.2.0/tests/test_tier1_real.py +101 -0
@@ -0,0 +1,35 @@
1
+ include README.md
2
+ include nava.yaml
3
+ recursive-include src/nava/prompts *.txt
4
+ recursive-include src/nava *.py
5
+
6
+ # Exclude local user workspaces, tasks, memory, and audit ledgers
7
+ prune tasks
8
+ prune projects
9
+ prune memory
10
+ prune scratch
11
+ prune .nava/checkpoints
12
+
13
+ # Exclude secret keys, credentials, and audit logs
14
+ exclude .env*
15
+ exclude .vault_key
16
+ exclude vault.json
17
+ exclude credentials.json
18
+ exclude token*.json
19
+ exclude nava_audit.jsonl
20
+ exclude memory.md
21
+ exclude fix.md
22
+ exclude nava_arch.md
23
+ exclude Modelfile
24
+
25
+ # Exclude root test scripts and documents from the build
26
+ exclude *.pdf
27
+ exclude *.docx
28
+ exclude *.pptx
29
+ exclude *.xlsx
30
+ exclude *.html
31
+ exclude calculator.py
32
+ exclude merge_sort.py
33
+ exclude cleanup_old_agents.py
34
+ exclude generate_invoice.py
35
+ exclude get_top_story.py
@@ -0,0 +1,548 @@
1
+ Metadata-Version: 2.4
2
+ Name: nava-agent
3
+ Version: 0.2.0
4
+ Summary: NAVA: Autonomous Personal Agent OS with Governed Execution & Rich Cowork Studio
5
+ Author: NAVA Team
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: pydantic>=2.0
9
+ Requires-Dist: langgraph>=0.1.0
10
+ Requires-Dist: langchain-core>=0.2.0
11
+ Requires-Dist: cryptography>=41.0.0
12
+ Requires-Dist: duckduckgo-search>=6.0.0
13
+ Requires-Dist: reportlab>=4.0.0
14
+
15
+ # NAVA: Personal Agent Operating System
16
+
17
+ NAVA is a deterministic, multi-agent personal operating system designed for autonomous workspace execution, secure computer use, deep research synthesis, and persistent human-AI collaboration.
18
+
19
+ Built around a 12-step mutation gateway, a 4-tier memory hierarchy, an inter-agent message bus, and 21 mathematically verified system invariants, NAVA guarantees strict least-privilege bounding, tamper-evident audit receipts, and transactional rollback across all filesystem, terminal, browser, and OS desktop interactions.
20
+
21
+ ---
22
+
23
+ ## Table of Contents
24
+ 1. [System Architecture Overview](#system-architecture-overview)
25
+ 2. [The NAVA Root Agent (Kernel Controller)](#the-nava-root-agent-kernel-controller)
26
+ 3. [Dynamic Agents & Just-In-Time (JIT) Synthesis](#dynamic-agents--just-in-time-jit-synthesis)
27
+ 4. [Specialized Static Agent Suite](#specialized-static-agent-suite)
28
+ 5. [The 12-Step Chokepoint Action Gateway](#the-12-step-chokepoint-action-gateway)
29
+ 6. [Real-Time Multi-Agent Collaboration (AgentMessageBus)](#real-time-multi-agent-collaboration-agentmessagebus)
30
+ 7. [Project Workspace Memory (.nava/)](#project-workspace-memory-nava)
31
+ 8. [Four-Tier Memory Architecture & AI Twin](#four-tier-memory-architecture--ai-twin)
32
+ 9. [The 21 Certified System Invariants](#the-21-certified-system-invariants)
33
+ 10. [Configuration & Security Switches](#configuration--security-switches)
34
+ 11. [Repository Structure](#repository-structure)
35
+ 12. [Getting Started & Quickstart](#getting-started--quickstart)
36
+ 13. [Verification & Test Suite](#verification--test-suite)
37
+
38
+ ---
39
+
40
+ ## System Architecture Overview
41
+
42
+ NAVA replaces unconstrained prompt chains with a deterministic operating system kernel. Every tool call—whether writing a file, running a shell command, clicking an OS desktop window, or drafting an email via Model Context Protocol (MCP)—is treated as a managed system call subject to policy validation, risk scoring, resource quotas, and concurrency locking.
43
+
44
+ ```
45
+ USER OBJECTIVE / SHELL
46
+
47
+
48
+ ┌─────────────────────────────────┐
49
+ │ NAVA ROOT ORCHESTRATOR │
50
+ │ (Executive Kernel Controller) │
51
+ └────────────────┬────────────────┘
52
+
53
+ Decompose Objective
54
+
55
+
56
+ [ GoalPlanner ]
57
+ Stage 1 (Parallel) ──► Stage 2 (Sequential)
58
+
59
+
60
+ [ AgentFactory ]
61
+ JIT Dynamic Synthesis & Scope Intersect:
62
+ Child_Scope = Parent_Scope ∩ Spec_Scope ∩ Policy_Scope
63
+
64
+ ┌───────────────────────┴───────────────────────┐
65
+ │ │
66
+ ▼ ▼
67
+ ┌──────────────────────────┐ ┌──────────────────────────┐
68
+ │ SPECIALIZED STATIC AGENTS│ │ JUST-IN-TIME DYNAMIC │
69
+ │ • CodingAgent │◄─────────────────►│ AGENTS │
70
+ │ • ReviewerAgent │ Inter-Agent │ • WebResearchAgent │
71
+ │ • ResearchAgent │ Message Bus │ • ASTRefactorAgent │
72
+ │ • TerminalAgent │ (Pub/Sub) │ • DataExtractionAgent │
73
+ │ • ComputerAgent │ │ • PDFCompilationAgent │
74
+ └────────────┬─────────────┘ └─────────────┬────────────┘
75
+ │ │
76
+ └───────────────────────┬───────────────────────┘
77
+
78
+ Tool Request RPC Call
79
+
80
+
81
+ ┌────────────────────────────────────────────────────────┐
82
+ │ 12-STEP ACTION GATEWAY PIPELINE │
83
+ │ 1. Auth & Lineage Check 7. Pre-State Snapshot │
84
+ │ 2. Policy Engine (ALLOW) 8. Sandboxed Tool Dispatch │
85
+ │ 3. Additive Risk Engine 9. Post-State Verification │
86
+ │ 4. Budget & Quota Check 10. Cryptographic Receipt │
87
+ │ 5. Concurrency Locks 11. Lock Release & Teardown │
88
+ │ 6. HITL Gatekeeper 12. Episodic Memory Sync │
89
+ └───────────────────────────┬────────────────────────────┘
90
+
91
+
92
+ ┌────────────────────────────────────────────────────────┐
93
+ │ HOST SYSTEM BOUNDARIES │
94
+ │ • Local Filesystem Root • Playwright Browser │
95
+ │ • OS Desktop GUI Driver • MCP External Servers │
96
+ └────────────────────────────────────────────────────────┘
97
+ ```
98
+
99
+ ---
100
+
101
+ ## The NAVA Root Agent (Kernel Controller)
102
+
103
+ At the apex of the operating system resides the **NAVA Root Agent** (`src/nava/orchestrator.py`), serving as the privileged executive supervisor of the agent collective:
104
+
105
+ ```
106
+ ┌────────────────────────────────────────────────────────────────────────┐
107
+ │ NAVA ROOT AGENT KERNEL │
108
+ ├────────────────────────────────────────────────────────────────────────┤
109
+ │ • Root Security Ceilings (nava.yaml) │
110
+ │ • Executive Stage & Parallel Goal Decomposition (GoalPlanner) │
111
+ │ • Subagent Lifecycle Supervisor (Spawn -> Observe -> Teardown) │
112
+ │ • Global Task Budget Enforcement (Tokens, Steps, Depth, Retries) │
113
+ │ • Project Workspace Context Continuator (.nava/project_memory.md) │
114
+ │ • Out-of-Band Emergency Kill Switch Circuit Breaker │
115
+ └────────────────────────────────────────────────────────────────────────┘
116
+ ```
117
+
118
+ ### 1. Root Security Ceilings (Blueprint Section 26)
119
+ The Root Agent acts as the maximum security ceiling for all operations. Subagents spawned during task execution can never acquire permissions, credentials, or tool access beyond what is granted to the Root Agent in `nava.yaml`.
120
+
121
+ ### 2. Hierarchical Execution Supervision
122
+ * **Autonomous Task Staging**: Decomposes complex human instructions into isolated stages ($1, 2, \dots, N$).
123
+ * **Concurrent Subagent Dispatch**: Executes independent sub-goals concurrently in parallel worker threads while maintaining shared state consistency.
124
+ * **Deterministic Teardown**: Upon task completion or failure, the root controller flushes thread locks, revokes temporary OAuth tokens, and transitions child states to `TERMINATED`.
125
+
126
+ ### 3. Context Continuity & Crash Recovery
127
+ The Root Agent automatically reads `.nava/project_memory.md` on startup, detecting unfinished objectives from previous sessions and enabling single-word resumption (`continue`) without loss of architectural decisions.
128
+
129
+ ---
130
+
131
+ ## Dynamic Agents & Just-In-Time (JIT) Synthesis
132
+
133
+ While static agents handle dedicated operational domains, real-world development requires adaptable, task-specific workers. NAVA's **Dynamic Agent Engine** (`src/nava/agents/factory.py` & `src/nava/agents/runtime/dynamic_agent.py`) synthesizes specialized agents just-in-time.
134
+
135
+ ```
136
+ USER OBJECTIVE: "Parse 50 PDFs and index into Qdrant"
137
+
138
+
139
+ 1. SPECIFICATION (AgentSpec)
140
+ - Role: PDFIndexerAgent
141
+ - Required Tools: ['file.read', 'memory.semantic_ingest']
142
+ - Stage: 1 (Parallel)
143
+
144
+
145
+ 2. DEDUPLICATION HASHING (Invariant #7)
146
+ dedup_hash = SHA256("PDFIndexerAgent:goal:tools")
147
+
148
+
149
+ 3. PERMISSION INTERSECTION (Invariant #5)
150
+ Child_Scope = Parent_Scope ∩ Requested_Scope ∩ Policy_Scope
151
+
152
+
153
+ 4. ISOLATED RUNTIME INSTANTIATION
154
+ Cyclic Multi-Step Graph (Plan ◄──► Act)
155
+
156
+
157
+ 5. AUTOMATIC SKILL PROMOTION (Sec 9.6)
158
+ Promotes successful novel workflows to SKILL.md
159
+ ```
160
+
161
+ ### 1. Non-Increasing Permission Inheritance (Invariant #5)
162
+ Dynamic agents can never escalate privileges. The `AgentFactory` enforces mathematical intersection:
163
+
164
+ $$\text{Child Scope} = \text{Parent Scope} \cap \text{Requested Scope} \cap \text{Policy Allowed Scope}$$
165
+
166
+ If a dynamically synthesized agent requests `terminal.execute` but its parent or active policy prohibits terminal execution, the capability is stripped before instantiation.
167
+
168
+ ### 2. Deduplication & Runaway Loop Prevention (Invariant #7)
169
+ Every dynamic agent spec is hashed with its role, objective, and tool grant:
170
+
171
+ $$\text{Dedup Hash} = \text{SHA256}(\text{role} \parallel \text{clean\_goal} \parallel \text{tools})[:16]$$
172
+
173
+ If an agent fails identically 3 times, the 4th identical failure triggers an automatic task abort and routes to `CompensationEngine`, preventing infinite execution loops and runaway token consumption.
174
+
175
+ ### 3. Dynamic Skill Promotion (Section 9.6)
176
+ When a Dynamic Agent solves a novel problem sequence successfully, NAVA's `SkillPromoter` can extract the successful action trajectory, package it into a standard `SKILL.md` with SHA-256 integrity locking, and save it to `.nava/local_skills/` for future instant reuse across projects.
177
+
178
+ ---
179
+
180
+ ## Specialized Static Agent Suite
181
+
182
+ NAVA includes a core suite of purpose-built static agents configured for dedicated workflows:
183
+
184
+ ```
185
+ ┌────────────────────────────────────────────────────────────────────────┐
186
+ │ SPECIALIZED STATIC AGENT SUITE │
187
+ ├────────────────────────────────────────────────────────────────────────┤
188
+ │ 1. CodingAgent Cyclic code refactoring, AST edits, batch patches│
189
+ │ 2. ReviewerAgent Diff analysis, quality audits, peer review │
190
+ │ 3. ResearchAgent Deep web search, text extraction, semantic RAG │
191
+ │ 4. TerminalAgent Sandboxed shell execution, git, test runners │
192
+ │ 5. ComputerAgent OS desktop GUI control, DPI scaling, coordinates │
193
+ │ 6. UniversalFileAgent Single-shot PDF/DOCX/PPTX report compilation │
194
+ └────────────────────────────────────────────────────────────────────────┘
195
+ ```
196
+
197
+ | Agent | Core Capabilities | Tool & Scope Grant |
198
+ | :--- | :--- | :--- |
199
+ | **`CodingAgent`** | Multi-step code analysis, AST symbol exploration, transactional multi-file batch patching, and syntax validation. | `code.search`, `code.replace_content`, `code.replace_content_batch`, `filesystem.write` |
200
+ | **`ReviewerAgent`** | AST linting, structural diff review, and closed-loop peer review feedback on the message bus. | `code.diff_review`, `filesystem.read`, `git.read` |
201
+ | **`ResearchAgent`** | Multi-source web crawling, noise stripping, fact cross-referencing, and Tier 3 Semantic RAG ingestion. | `search.web`, `browser.navigate`, `browser.extract_text`, `browser.save_to_scratch`, `memory.semantic_ingest` |
202
+ | **`TerminalAgent`** | Sandboxed shell commands, git branch/diff inspection, test suite execution (`pytest`, `unittest`, `npm test`), and compilation diagnostics. | `terminal.execute`, `shell.execute`, `test.run`, `git.status`, `git.diff` |
203
+ | **`ComputerAgent`** | OS desktop perception (Per-Monitor DPI scaling, region screenshots) and grounded mouse/keyboard automation with credential blockers. | `desktop.screenshot`, `desktop.click`, `desktop.drag`, `desktop.scroll`, `desktop.type`, `desktop.hotkey` |
204
+ | **`UniversalFileAgent`** | Single-shot document compilation, converting structured text into formatted PDF, Word (`.docx`), and PowerPoint (`.pptx`) deliverables. | `file.write`, `file.create_pdf`, `file.create_docx`, `file.create_pptx` |
205
+
206
+ ---
207
+
208
+ ## The 12-Step Chokepoint Action Gateway
209
+
210
+ Every mutating action in NAVA must pass sequentially through the 12-step `ActionGateway` chokepoint (`src/nava/gateway/pipeline.py`):
211
+
212
+ ```
213
+ INCOMING MUTATION REQUEST
214
+
215
+
216
+ [ Step 1: Authentication & Lineage ] ──► Validates UUID & Active TTL
217
+
218
+
219
+ [ Step 2: Policy Engine (ALLOW) ] ──► Checks Static Rules & Switches
220
+
221
+
222
+ [ Step 3: Additive Risk Engine ] ──► Computes Additive Risk Score
223
+
224
+
225
+ [ Step 4: Task Budget Engine ] ──► Verifies Tokens, Steps & Depth
226
+
227
+
228
+ [ Step 5: Concurrency Lock Manager ] ──► Acquires Shared/Exclusive Locks
229
+
230
+
231
+ [ Step 6: HITL Approval Gate ] ──► Triggers User Prompt if HIGH Risk
232
+
233
+
234
+ [ Step 7: State Observer Snapshot ] ──► Captures Pre-Execution File Hash
235
+
236
+
237
+ [ Step 8: Execution Sandbox ] ──► Dispatches Tool Locally or via MCP
238
+
239
+
240
+ [ Step 9: Post-State Verification ] ──► Validates Size, Path & Integrity
241
+
242
+
243
+ [ Step 10: Audit Receipt Ledger ] ──► Emits Signed JSON Receipt
244
+
245
+
246
+ [ Step 11: Teardown & Lock Release ] ──► Releases Concurrency Locks
247
+
248
+
249
+ [ Step 12: Episodic Memory Sync ] ──► Syncs Task Outcome to Tier 2 Store
250
+
251
+
252
+ EXECUTION COMPLETE
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Real-Time Multi-Agent Collaboration (AgentMessageBus)
258
+
259
+ NAVA coordinates multi-agent swarms using a high-throughput, thread-safe Pub/Sub broker (`src/nava/core/message_bus.py`):
260
+
261
+ ### 1. Channel-Based Communication
262
+ Agents subscribe and publish to isolated channels:
263
+ * `task:<stage_id>:<topic>`: Ephemeral channel for agents collaborating on a shared stage.
264
+ * `peer_review`: Dedicated channel for code submission and review feedback.
265
+ * `broadcast:progress`: Global streaming channel broadcasting step metrics and reasoning thoughts.
266
+
267
+ ### 2. Closed-Loop Peer Review Protocol
268
+ When `CodingAgent` generates code changes, it initiates a closed-loop review handshake:
269
+
270
+ ```
271
+ [ CodingAgent ] [ ReviewerAgent ]
272
+ │ │
273
+ │─── 1. PEER_REVIEW_REQUEST(diff, file_path) ───►│
274
+ │ │ Evaluates AST & Tests
275
+ │◄── 2. PEER_REVIEW_FEEDBACK(approved, fixes) ───│
276
+
277
+ [ If Changes Requested ]
278
+ Applies fixes & resubmits
279
+ ```
280
+
281
+ ### 3. Real-Time UI Streaming
282
+ The `AgentMessageBus` exposes an `add_global_listener` hook that feeds directly into WebSocket and Server-Sent Event (SSE) streams for real-time frontend visualization.
283
+
284
+ ---
285
+
286
+ ## Project Workspace Memory (.nava/)
287
+
288
+ Every project directory managed by NAVA contains a persistent `.nava/` workspace context ledger:
289
+
290
+ ```
291
+ <Project_Root>/
292
+ ├── .nava/
293
+ │ ├── project_memory.md ◄── Human & machine-readable context ledger
294
+ │ ├── project_index.json ◄── Function & Class AST Symbol Knowledge Graph
295
+ │ └── checkpoints/ ◄── Snapshot diff restore points for fast rollbacks
296
+ ├── src/ ...
297
+ └── tests/ ...
298
+ ```
299
+
300
+ ### Structure of `project_memory.md`
301
+ 1. **Project Overview & Architecture**: Tech stack, primary goal, file index stats.
302
+ 2. **Current Execution State (Live Checkpoint)**: Active objective, last active agent, timestamp, touched files.
303
+ 3. **Architectural Decisions & Constraints**: Append-only log of technical decisions (e.g. "Using RS256 for JWT").
304
+ 4. **Resume Queue**: Ordered checklist of completed and pending sub-tasks for cross-session continuity.
305
+
306
+ ---
307
+
308
+ ## Four-Tier Memory Architecture & AI Twin
309
+
310
+ ```
311
+ ┌────────────────────────────────────────────────────────────────────────┐
312
+ │ 4-TIER MEMORY HIERARCHY │
313
+ ├────────────────────────────────────────────────────────────────────────┤
314
+ │ Tier 1: Working Memory │ Ephemeral task-scoped scratchpad │
315
+ │ Tier 2: Episodic Memory │ Append-only task receipts & execution logs│
316
+ │ Tier 3: Semantic Memory │ Chunked knowledge graph & RAG embeddings │
317
+ │ Tier 4: Profile Memory │ AI Twin verified facts & user preferences │
318
+ └────────────────────────────────────────────────────────────────────────┘
319
+ ```
320
+
321
+ ### Memory Security & Invariant #20
322
+ * **Profile Trust Escalation Gate**: External content (scraped web pages, downloaded documents, LLM inferences) can never silently write or upgrade memories to `VERIFIED` status in Tier 4.
323
+ * **Conflict Flagging**: If a new observation contradicts an existing verified profile fact, NAVA marks the fact with `CONFLICT_DETECTED` and requests user clarification instead of overwriting.
324
+
325
+ ---
326
+
327
+ ## The 21 Certified System Invariants
328
+
329
+ NAVA adheres to 21 system invariants validated through continuous unit and adversarial test suites:
330
+
331
+ 1. **Mutation Gate Chokepoint**: 100% of state-mutating requests must pass through the 12-step Gateway.
332
+ 2. **Append-Only Audit Ledger**: `nava_audit.jsonl` is strictly append-only; past records cannot be modified or truncated.
333
+ 3. **Receipt Immutability**: Cryptographic execution receipts are immutable once written.
334
+ 4. **Root Ceiling Enforcement**: Dynamic subagents cannot exceed the root security ceiling in `nava.yaml`.
335
+ 5. **Non-Increasing Permission Scoping**: $\text{Child Scope} = \text{Parent Scope} \cap \text{Requested Scope} \cap \text{Policy Allowed Scope}$.
336
+ 6. **Maximum Spawn Depth Bound**: Dynamic agent spawn trees are strictly limited to $\text{depth} \le 10$.
337
+ 7. **Runaway Loop Bound**: Maximum 3 retries on identical failure state; 4th identical failure halts execution.
338
+ 8. **Short-Lived Credential Isolation**: Scoped credentials have a 5-minute TTL; raw tokens are isolated from agent context.
339
+ 9. **Write-Exclusive Locking**: Exclusive write locks block concurrent read and write operations on the same resource.
340
+ 10. **Shared-Read Concurrency**: Multiple subagents can acquire non-conflicting shared read locks concurrently.
341
+ 11. **Automatic Reversible Rollback**: Tool failures on reversible operations trigger automatic pre-snapshot state restoration.
342
+ 12. **Irreversible Compensation Routing**: Non-reversible failures route to `CompensationEngine` for designated compensation workflows.
343
+ 13. **Bounded Cleanup Budget**: Rollback and compensation routines execute under a strict resource ceiling ($\le 5$ steps).
344
+ 14. **HITL Escalation Gate**: Operations returning policy outcome `APPROVAL` strictly mandate a signed user approval record.
345
+ 15. **Critical Risk Hard-Block**: Tools scoring in the `CRITICAL` risk tier are blocked from automated execution.
346
+ 16. **Deterministic Resource Teardown**: Agent termination releases locks, revokes temporary credentials, and sets `TERMINATED` status.
347
+ 17. **Skill Hash-Locking**: Modifying `SKILL.md` on disk triggers an `UNTRUSTED_MODIFIED` state, halting execution until re-hashed.
348
+ 18. **Out-of-Band Emergency Kill Switch**: Invoking the kill switch immediately halts running threads, revokes credentials, and cancels approvals.
349
+ 19. **Untrusted Delimiter Boundary**: External untrusted content is strictly wrapped in `<untrusted_content>` tags with tag escaping.
350
+ 20. **Profile Trust Escalation Gate**: Inferred facts cannot promote themselves to `VERIFIED` tier without explicit user confirmation.
351
+ 21. **Scope Alignment Invariant**: $\text{Agent Permission} \supseteq \text{Credential Scope} \supseteq \text{Tool Scope}$.
352
+
353
+ ---
354
+
355
+ ## Configuration & Security Switches
356
+
357
+ Global resource budgets, capabilities, and master security feature switches are defined in `nava.yaml`:
358
+
359
+ ```yaml
360
+ # Root Agent Security Ceilings
361
+ root_agent:
362
+ ceiling_permissions:
363
+ - filesystem.write
364
+ - filesystem.read
365
+ - data.analyze
366
+ - test.run
367
+ - terminal.execute
368
+ - shell.execute
369
+ - browser.*
370
+ - desktop.*
371
+ - search.web
372
+ - memory.semantic
373
+
374
+ ceiling_tools:
375
+ - file.read
376
+ - file.write
377
+ - file.delete
378
+ - file.create_pdf
379
+ - file.create_docx
380
+ - file.create_pptx
381
+ - code.search
382
+ - code.replace_content
383
+ - code.replace_content_batch
384
+ - terminal.execute
385
+ - shell.execute
386
+ - test.run
387
+ - git.status
388
+ - git.diff
389
+ - search.web
390
+ - memory.semantic_ingest
391
+ - browser.navigate
392
+ - browser.extract_text
393
+ - browser.save_to_scratch
394
+ - desktop.screenshot
395
+ - desktop.click
396
+ - desktop.type
397
+ - desktop.hotkey
398
+
399
+ # Global Resource Budgets
400
+ budget:
401
+ max_agents: 50
402
+ max_depth: 10
403
+ max_steps: 1000
404
+ max_tokens: 1000000
405
+
406
+ # User-Configurable Security Feature Switches
407
+ security_switches:
408
+ enable_terminal_execution: true # Toggle shell/terminal execution
409
+ enable_desktop_gui_control: true # Toggle mouse/keyboard automation (false = screenshot-only mode)
410
+ enable_external_integrations: true # Toggle external MCP/Gmail integrations
411
+ ```
412
+
413
+ ---
414
+
415
+ ## Repository Structure
416
+
417
+ ```
418
+ .
419
+ ├── .nava/ # Project Workspace context ledger & checkpoints
420
+ │ ├── project_memory.md # Live execution state and architectural decisions
421
+ │ ├── project_index.json # Python AST code symbols index
422
+ │ └── checkpoints/ # Ephemeral pre-mutation snapshot backups
423
+ ├── memory/ # Persistent JSON memory tiers
424
+ │ ├── profile.json # Tier 4: AI Twin verified facts
425
+ │ ├── semantic.json # Tier 3: Knowledge base & RAG records
426
+ │ └── episodic.json # Tier 2: Task execution receipts
427
+ ├── src/
428
+ │ └── nava/
429
+ │ ├── agents/
430
+ │ │ ├── factory.py # AgentFactory with permission intersection
431
+ │ │ ├── planner.py # GoalPlanner stage decomposition
432
+ │ │ ├── templates.py # Static agent template definitions
433
+ │ │ └── runtime/ # LangGraph agent execution runtimes
434
+ │ │ ├── coding_agent.py
435
+ │ │ ├── reviewer_agent.py
436
+ │ │ ├── research_agent.py
437
+ │ │ ├── terminal_agent.py
438
+ │ │ ├── computer_agent.py
439
+ │ │ └── dynamic_agent.py
440
+ │ ├── core/
441
+ │ │ ├── boot.py # System bootstrap & initialization
442
+ │ │ ├── ledger.py # Append-only audit ledger
443
+ │ │ ├── llm.py # Frontier LLM interface
444
+ │ │ ├── message_bus.py # Inter-agent Pub/Sub broker
445
+ │ │ ├── sanitizer.py # Prompt injection & delimiter sanitizer
446
+ │ │ └── schemas.py # Pydantic schemas and models
447
+ │ ├── credentials/
448
+ │ │ ├── vault.py # Encrypted credential storage
449
+ │ │ └── broker.py # Short-lived credential broker
450
+ │ ├── gateway/
451
+ │ │ └── pipeline.py # 12-step ActionGateway implementation
452
+ │ ├── governance/
453
+ │ │ ├── policy_engine.py # Rule evaluation & security switches
454
+ │ │ ├── risk_engine.py # Additive scoring risk engine
455
+ │ │ ├── budget_engine.py # Quota tracking & loop detection
456
+ │ │ ├── lock_manager.py # Read/write concurrency control
457
+ │ │ ├── hitl_manager.py # Human-in-the-Loop approval queues
458
+ │ │ ├── rollback_engine.py # Reversible state rollback
459
+ │ │ ├── compensation_engine.py # Irreversible compensation routines
460
+ │ │ ├── dom_sanitizer.py # HTML tripwire & injection cleaner
461
+ │ │ └── state_observer.py # Resource hash snapshotting
462
+ │ ├── memory/
463
+ │ │ └── store.py # Working, Episodic, Semantic, Profile stores
464
+ │ ├── skills/
465
+ │ │ ├── manager.py # SKILL.md parsing & hash verification
466
+ │ │ └── promotion.py # Dynamic skill promotion pipeline
467
+ │ ├── tools/
468
+ │ │ ├── executor.py # Local tool execution engine
469
+ │ │ ├── registry.py # Tool definitions & schemas
470
+ │ │ ├── browser.py # Playwright Chromium browser driver
471
+ │ │ ├── desktop.py # DPI-aware OS desktop GUI engine
472
+ │ │ └── mcp_client.py # Model Context Protocol stdio client
473
+ │ ├── workspace/
474
+ │ │ ├── indexer.py # AST symbol parser
475
+ │ │ └── project_manager.py # Workspace context continuity engine
476
+ │ └── orchestrator.py # End-to-end task orchestration kernel
477
+ ├── tests/ # Complete test suite (39 verified tests)
478
+ │ ├── test_21_invariants.py # 21 System Invariants verification
479
+ │ ├── test_project_workspace.py # Workspace memory & AST indexer tests
480
+ │ ├── test_specialized_agents.py # Specialized agents & security switches tests
481
+ │ └── test_agent_message_bus.py # Pub/Sub broker & peer review loop tests
482
+ ├── nava.yaml # OS configuration & security policy
483
+ ├── nava_shell.py # Interactive CLI shell
484
+ └── requirements.txt # Dependencies
485
+ ```
486
+
487
+ ---
488
+
489
+ ## Getting Started & Quickstart
490
+
491
+ ### Prerequisites
492
+ * Python 3.10 or higher
493
+ * Google Gemini API key (or local OpenAI-compatible endpoint)
494
+
495
+ ### Installation
496
+ ```bash
497
+ # Clone the repository
498
+ git clone https://github.com/your-org/nava.git
499
+ cd nava
500
+
501
+ # Create and activate virtual environment
502
+ python -m venv venv
503
+ source venv/bin/activate # Windows: .\venv\Scripts\activate
504
+
505
+ # Install dependencies
506
+ pip install -r requirements.txt
507
+
508
+ # Install Playwright browser binaries (optional, for browser automation)
509
+ playwright install chromium
510
+ ```
511
+
512
+ ### Environment Configuration
513
+ Create a `.env` file in the root directory:
514
+ ```env
515
+ GEMINI_API_KEY=your_gemini_api_key_here
516
+ NAVA_ENV=development
517
+ ```
518
+
519
+ ### Launching the Interactive Shell
520
+ ```bash
521
+ python nava_shell.py
522
+ ```
523
+
524
+ ---
525
+
526
+ ## Verification & Test Suite
527
+
528
+ Run the full automated test suite:
529
+
530
+ ```bash
531
+ # 1. Verify all 21 certified system invariants
532
+ python -m unittest tests/test_21_invariants.py -v
533
+
534
+ # 2. Verify specialized agents and security switches
535
+ python -m unittest tests/test_specialized_agents.py -v
536
+
537
+ # 3. Verify project workspace memory and AST indexer
538
+ python -m unittest tests/test_project_workspace.py -v
539
+
540
+ # 4. Verify inter-agent message bus & peer review loop
541
+ python -m unittest tests/test_agent_message_bus.py -v
542
+ ```
543
+
544
+ ---
545
+
546
+ ## License
547
+
548
+ Apache 2.0 License. See `LICENSE` for details.