hive-agent 0.1.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 (131) hide show
  1. hive_agent-0.1.0/.context/execution-plan.md +210 -0
  2. hive_agent-0.1.0/.context/incomplete-areas-audit.md +178 -0
  3. hive_agent-0.1.0/.context/plans/phase1-remaining.md +90 -0
  4. hive_agent-0.1.0/.context/plans/phase2-plan.md +289 -0
  5. hive_agent-0.1.0/.context/plans/simulation-plan.md +82 -0
  6. hive_agent-0.1.0/.context/results/batch-a-run-2.md +90 -0
  7. hive_agent-0.1.0/.context/results/batch-a-run.md +112 -0
  8. hive_agent-0.1.0/.env.example +19 -0
  9. hive_agent-0.1.0/.gitignore +222 -0
  10. hive_agent-0.1.0/CLAUDE.md +121 -0
  11. hive_agent-0.1.0/LICENSE +21 -0
  12. hive_agent-0.1.0/PKG-INFO +195 -0
  13. hive_agent-0.1.0/README.md +157 -0
  14. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/agents/coder-486ec8ce/decisions.jsonl +1 -0
  15. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/agents/coder-486ec8ce/goals.jsonl +2 -0
  16. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/agents/coder-486ec8ce/suffering.jsonl +2 -0
  17. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/cycles/cycle_0001.jsonl +1 -0
  18. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/cycles/cycle_0002.jsonl +1 -0
  19. hive_agent-0.1.0/logs/runs/run-20260509-083237-e6f64e/run.json +19 -0
  20. hive_agent-0.1.0/models.yaml +70 -0
  21. hive_agent-0.1.0/profiles/coder.yaml +32 -0
  22. hive_agent-0.1.0/profiles/oracle.yaml +24 -0
  23. hive_agent-0.1.0/profiles/researcher.yaml +30 -0
  24. hive_agent-0.1.0/profiles/reviewer.yaml +29 -0
  25. hive_agent-0.1.0/profiles/tester.yaml +29 -0
  26. hive_agent-0.1.0/pyproject.toml +89 -0
  27. hive_agent-0.1.0/scenarios/detective/clues/clue_01_body.md +7 -0
  28. hive_agent-0.1.0/scenarios/detective/clues/clue_02_paper.md +5 -0
  29. hive_agent-0.1.0/scenarios/detective/clues/clue_03_locked_room.md +7 -0
  30. hive_agent-0.1.0/scenarios/detective/clues/clue_04_diana_alibi.md +7 -0
  31. hive_agent-0.1.0/scenarios/detective/clues/clue_05_leo_alibi.md +9 -0
  32. hive_agent-0.1.0/scenarios/detective/clues/clue_06_petra_alibi.md +9 -0
  33. hive_agent-0.1.0/scenarios/detective/clues/clue_07_champagne.md +9 -0
  34. hive_agent-0.1.0/scenarios/detective/clues/clue_08_red_herring.md +7 -0
  35. hive_agent-0.1.0/scenarios/detective/config.yaml +29 -0
  36. hive_agent-0.1.0/scenarios/detective/crime_scene.md +35 -0
  37. hive_agent-0.1.0/scenarios/detective/results/run-20260508-044043.json +208 -0
  38. hive_agent-0.1.0/scenarios/detective/results/run-20260508-044806.json +218 -0
  39. hive_agent-0.1.0/scenarios/detective/results/run-20260508-050208.json +234 -0
  40. hive_agent-0.1.0/scenarios/detective/results/run-20260509-090153.json +235 -0
  41. hive_agent-0.1.0/scenarios/detective/results/run-20260509-095447.json +237 -0
  42. hive_agent-0.1.0/scenarios/detective/results/run-20260509-234836.json +247 -0
  43. hive_agent-0.1.0/scenarios/detective/run.py +325 -0
  44. hive_agent-0.1.0/scenarios/runtime_test.py +151 -0
  45. hive_agent-0.1.0/scripts/start.sh +6 -0
  46. hive_agent-0.1.0/scripts/stop.sh +5 -0
  47. hive_agent-0.1.0/src/hive/__init__.py +86 -0
  48. hive_agent-0.1.0/src/hive/agents/__init__.py +0 -0
  49. hive_agent-0.1.0/src/hive/agents/delegation.py +101 -0
  50. hive_agent-0.1.0/src/hive/agents/existence.py +221 -0
  51. hive_agent-0.1.0/src/hive/agents/identity.py +206 -0
  52. hive_agent-0.1.0/src/hive/agents/profile.py +93 -0
  53. hive_agent-0.1.0/src/hive/agents/specialization.py +131 -0
  54. hive_agent-0.1.0/src/hive/agents/state.py +42 -0
  55. hive_agent-0.1.0/src/hive/agents/suffering.py +174 -0
  56. hive_agent-0.1.0/src/hive/agents/swarm.py +202 -0
  57. hive_agent-0.1.0/src/hive/checkpoint.py +124 -0
  58. hive_agent-0.1.0/src/hive/cli/__init__.py +0 -0
  59. hive_agent-0.1.0/src/hive/cli/main.py +559 -0
  60. hive_agent-0.1.0/src/hive/config.py +153 -0
  61. hive_agent-0.1.0/src/hive/context.py +26 -0
  62. hive_agent-0.1.0/src/hive/daemon/__init__.py +0 -0
  63. hive_agent-0.1.0/src/hive/daemon/lifecycle.py +144 -0
  64. hive_agent-0.1.0/src/hive/daemon/loop.py +508 -0
  65. hive_agent-0.1.0/src/hive/daemon/setup.py +39 -0
  66. hive_agent-0.1.0/src/hive/interactions/__init__.py +48 -0
  67. hive_agent-0.1.0/src/hive/interactions/base.py +184 -0
  68. hive_agent-0.1.0/src/hive/interactions/exchange.py +172 -0
  69. hive_agent-0.1.0/src/hive/interactions/loader.py +114 -0
  70. hive_agent-0.1.0/src/hive/interactions/memory/__init__.py +0 -0
  71. hive_agent-0.1.0/src/hive/interactions/memory/full.py +18 -0
  72. hive_agent-0.1.0/src/hive/interactions/memory/persona.py +43 -0
  73. hive_agent-0.1.0/src/hive/interactions/memory/selective.py +39 -0
  74. hive_agent-0.1.0/src/hive/interactions/participants.py +154 -0
  75. hive_agent-0.1.0/src/hive/interactions/patterns/__init__.py +0 -0
  76. hive_agent-0.1.0/src/hive/interactions/patterns/freeform.py +102 -0
  77. hive_agent-0.1.0/src/hive/interactions/patterns/pairs.py +87 -0
  78. hive_agent-0.1.0/src/hive/interactions/patterns/round_table.py +62 -0
  79. hive_agent-0.1.0/src/hive/interactions/presets.py +48 -0
  80. hive_agent-0.1.0/src/hive/interactions/runner.py +142 -0
  81. hive_agent-0.1.0/src/hive/interactions/transcript.py +48 -0
  82. hive_agent-0.1.0/src/hive/logging/__init__.py +0 -0
  83. hive_agent-0.1.0/src/hive/logging/models.py +76 -0
  84. hive_agent-0.1.0/src/hive/logging/reader.py +127 -0
  85. hive_agent-0.1.0/src/hive/logging/writer.py +88 -0
  86. hive_agent-0.1.0/src/hive/mcp/__init__.py +5 -0
  87. hive_agent-0.1.0/src/hive/mcp/client.py +147 -0
  88. hive_agent-0.1.0/src/hive/mcp/server.py +393 -0
  89. hive_agent-0.1.0/src/hive/memory/__init__.py +0 -0
  90. hive_agent-0.1.0/src/hive/memory/events.py +196 -0
  91. hive_agent-0.1.0/src/hive/memory/goals.py +135 -0
  92. hive_agent-0.1.0/src/hive/memory/semantic.py +248 -0
  93. hive_agent-0.1.0/src/hive/memory/store.py +256 -0
  94. hive_agent-0.1.0/src/hive/models/__init__.py +13 -0
  95. hive_agent-0.1.0/src/hive/models/registry.py +100 -0
  96. hive_agent-0.1.0/src/hive/models/router.py +91 -0
  97. hive_agent-0.1.0/src/hive/runtime/__init__.py +56 -0
  98. hive_agent-0.1.0/src/hive/runtime/agent.py +309 -0
  99. hive_agent-0.1.0/src/hive/runtime/bridge.py +45 -0
  100. hive_agent-0.1.0/src/hive/runtime/memory.py +150 -0
  101. hive_agent-0.1.0/src/hive/runtime/providers.py +499 -0
  102. hive_agent-0.1.0/src/hive/runtime/structured.py +143 -0
  103. hive_agent-0.1.0/src/hive/runtime/toolkits.py +192 -0
  104. hive_agent-0.1.0/src/hive/runtime/tools.py +189 -0
  105. hive_agent-0.1.0/src/hive/runtime/types.py +123 -0
  106. hive_agent-0.1.0/src/hive/runtime/workflow.py +63 -0
  107. hive_agent-0.1.0/src/hive/world/__init__.py +0 -0
  108. hive_agent-0.1.0/src/hive/world/event_catalog.py +449 -0
  109. hive_agent-0.1.0/src/hive/world/event_engine.py +175 -0
  110. hive_agent-0.1.0/src/hive/world/events.py +43 -0
  111. hive_agent-0.1.0/src/hive/world/life_summary.py +207 -0
  112. hive_agent-0.1.0/src/hive/world/state.py +250 -0
  113. hive_agent-0.1.0/src/hive/world/stats.py +95 -0
  114. hive_agent-0.1.0/tests/conftest.py +21 -0
  115. hive_agent-0.1.0/tests/mcp/__init__.py +0 -0
  116. hive_agent-0.1.0/tests/mcp/test_client.py +205 -0
  117. hive_agent-0.1.0/tests/runtime/__init__.py +0 -0
  118. hive_agent-0.1.0/tests/runtime/test_agent.py +308 -0
  119. hive_agent-0.1.0/tests/runtime/test_structured.py +217 -0
  120. hive_agent-0.1.0/tests/runtime/test_toolkits.py +55 -0
  121. hive_agent-0.1.0/tests/runtime/test_tools.py +176 -0
  122. hive_agent-0.1.0/tests/runtime/test_types.py +147 -0
  123. hive_agent-0.1.0/tests/test_config.py +57 -0
  124. hive_agent-0.1.0/tests/test_daemon_integration.py +228 -0
  125. hive_agent-0.1.0/tests/test_event_engine.py +187 -0
  126. hive_agent-0.1.0/tests/test_events.py +76 -0
  127. hive_agent-0.1.0/tests/test_interactions.py +183 -0
  128. hive_agent-0.1.0/tests/test_model_registry.py +36 -0
  129. hive_agent-0.1.0/tests/test_suffering.py +102 -0
  130. hive_agent-0.1.0/tests/test_world_state.py +122 -0
  131. hive_agent-0.1.0/uv.lock +1653 -0
@@ -0,0 +1,210 @@
1
+ # Hive Execution Plan
2
+
3
+ ## What's Done
4
+
5
+ - [x] README.md (project pitch, quick start, features)
6
+ - [x] CLAUDE.md (dev conventions, architecture)
7
+ - [x] pyproject.toml (dependencies, scripts, packaging)
8
+ - [x] CLI stub (all commands defined, imports stubbed)
9
+ - [x] Agent profiles (5 presets with personalities)
10
+ - [x] Core protocols (ModelProvider, ToolExecutor, AgentProfile, AgentState)
11
+ - [x] Project structure (all modules created)
12
+ - [x] LICENSE (MIT)
13
+ - [x] Launcher scripts (start.sh, stop.sh)
14
+
15
+ ---
16
+
17
+ ## Phase 1: Single Agent Working (Priority: HIGH)
18
+
19
+ Goal: `hive spawn coder --task "write hello world"` actually works end-to-end.
20
+
21
+ ### 1.1 Memory Store
22
+ **File:** `src/hive/memory/store.py`
23
+ - SQLite database initialization (create tables on first run)
24
+ - Tables: agents, tasks, messages, tool_results
25
+ - CRUD operations for each table
26
+ - Async via aiosqlite
27
+
28
+ ### 1.2 Event Log
29
+ **File:** `src/hive/memory/events.py`
30
+ - JSONL append-only writer
31
+ - Event types: agent_spawned, task_started, step_executed, task_completed, error
32
+ - Stream reader (for `hive logs`)
33
+ - Replay function (for `hive replay`)
34
+
35
+ ### 1.3 Claude Model Provider
36
+ **File:** `src/hive/models/claude.py`
37
+ - Implement ModelProvider protocol
38
+ - `complete()`: call Anthropic API with messages + tools
39
+ - `plan()`: given objective + tools, return list of PlanSteps
40
+ - Handle streaming, token counting, error handling
41
+ - Auto-detect API key from env
42
+
43
+ ### 1.4 Built-in Tools (core set)
44
+ **Files:** `src/hive/execution/tools/filesystem.py`, `shell.py`, `git.py`, `memory_tools.py`
45
+ - `file_read(path)` - read file contents
46
+ - `file_write(path, content)` - write file
47
+ - `file_list(directory)` - list directory
48
+ - `shell_exec(command)` - run shell command (with allowlist)
49
+ - `git_status()`, `git_commit(message)`, `git_branch(name)`
50
+ - `memory_set(key, value)`, `memory_get(key)`
51
+
52
+ ### 1.5 Tool Registry
53
+ **File:** `src/hive/execution/registry.py`
54
+ - Auto-discover tools from `execution/tools/` package
55
+ - Register by name, store ToolDefinition
56
+ - `execute(tool_name, agent_id, **params) -> ToolResult`
57
+ - `list_tools() -> list[ToolDefinition]`
58
+
59
+ ### 1.6 Agent Loop
60
+ **File:** `src/hive/agents/loop.py`
61
+ - Core function: `async run_task(profile, task, store, model, tools) -> TaskResult`
62
+ - Steps:
63
+ 1. Build system prompt from profile
64
+ 2. Call model.plan(task, available_tools)
65
+ 3. For each step: execute tool, collect result
66
+ 4. Substitute {result} into next step params
67
+ 5. On failure: replan from failed step (max 2 retries)
68
+ 6. Validate output (did something actually get produced?)
69
+ 7. Log everything to event store
70
+
71
+ ### 1.7 Daemon Setup
72
+ **File:** `src/hive/daemon/setup.py`
73
+ - `initialize_hive()`: create .hive/ directory, config.yaml, state.db
74
+ - Detect available models (check API keys, binaries, endpoints)
75
+ - Copy default profiles
76
+
77
+ ### 1.8 Daemon Lifecycle
78
+ **File:** `src/hive/daemon/lifecycle.py`
79
+ - `spawn_agent(name, task, model_override)` - load profile, create state, start loop
80
+ - `kill_agent(name)` - mark dead, stop execution
81
+ - `get_all_agents()` - list current states
82
+
83
+ ### 1.9 Wire CLI to Real Implementations
84
+ - Connect CLI commands to lifecycle/store/events
85
+ - `hive init` -> setup.initialize_hive()
86
+ - `hive spawn` -> lifecycle.spawn_agent()
87
+ - `hive status` -> lifecycle.get_all_agents()
88
+ - `hive logs` -> events.stream_agent_events()
89
+
90
+ ---
91
+
92
+ ## Phase 2: Multi-Model + Detection
93
+
94
+ ### 2.1 LM Studio Provider
95
+ **File:** `src/hive/models/local.py`
96
+ - OpenAI-compatible API (localhost:1234)
97
+ - Detect if LM Studio is running
98
+ - List available models from endpoint
99
+
100
+ ### 2.2 Codex CLI Provider
101
+ **File:** `src/hive/models/codex.py`
102
+ - Wrap `codex` CLI via subprocess
103
+ - Detect if codex binary exists
104
+ - Parse output
105
+
106
+ ### 2.3 Model Router
107
+ **File:** `src/hive/models/router.py`
108
+ - `detect_models()` - scan for all available providers
109
+ - `get_model(preference, task_complexity)` - return best available
110
+ - Fallback logic: local -> sonnet -> opus
111
+ - Cost estimation per provider
112
+
113
+ ### 2.4 Config System
114
+ **File:** `src/hive/daemon/config.py`
115
+ - Load `.hive/config.yaml`
116
+ - Merge with defaults
117
+ - Validate schema (pydantic)
118
+ - Support env var substitution (${ANTHROPIC_API_KEY})
119
+
120
+ ---
121
+
122
+ ## Phase 3: Multi-Agent + Rooms
123
+
124
+ ### 3.1 Agent Messaging
125
+ **File:** `src/hive/rooms/messaging.py`
126
+ - `send_message(from_agent, to_agent, content)`
127
+ - `get_inbox(agent_id) -> list[Message]`
128
+ - Messages stored in SQLite
129
+
130
+ ### 3.2 Rooms
131
+ **File:** `src/hive/rooms/room.py`
132
+ - Create room with named agents
133
+ - Post messages to room (visible to all members)
134
+ - Agent picks up messages that match its role
135
+ - Turn-based or event-driven collaboration
136
+
137
+ ### 3.3 Oracle Review
138
+ **File:** `src/hive/agents/oracle.py`
139
+ - `request_review(agent_id, proposal, context) -> Approval|Rejection`
140
+ - Oracle uses Opus model
141
+ - Injected into agent loop when autonomy=medium and action is high-risk
142
+
143
+ ### 3.4 Concurrent Agent Execution
144
+ - Thread pool or asyncio tasks for parallel agents
145
+ - Shared state via SQLite (serialized access)
146
+ - Event bus for real-time notifications
147
+
148
+ ---
149
+
150
+ ## Phase 4: Skills + Tool Synthesis
151
+
152
+ ### 4.1 Skill Loader
153
+ **File:** `src/hive/skills/loader.py`
154
+ - Load SKILL.md files from `.hive/skills/` and `profiles/skills/`
155
+ - Parse YAML frontmatter for triggers
156
+ - Inject skill content into agent system prompt when relevant
157
+
158
+ ### 4.2 Tool Synthesis
159
+ **File:** `src/hive/execution/synthesis.py`
160
+ - Agent calls `create_tool(name, description, code)`
161
+ - Write Python to `.hive/tools/{name}.py`
162
+ - Validate (parse AST, basic test)
163
+ - Hot-load into registry
164
+
165
+ ### 4.3 MCP Server
166
+ **File:** `src/hive/mcp/server.py`
167
+ - Expose Hive as MCP tools for Claude Code
168
+ - Tools: spawn_agent, kill_agent, chat_agent, get_status, list_agents
169
+ - Users can manage Hive agents from within Claude Code sessions
170
+
171
+ ---
172
+
173
+ ## Phase 5: Polish + Launch
174
+
175
+ ### 5.1 Demo GIF
176
+ - Record terminal session showing agents collaborating
177
+ - Keep under 15 seconds
178
+ - Show: spawn, task assignment, agent working, result
179
+
180
+ ### 5.2 CONTRIBUTING.md
181
+ - How to add tools, models, agent presets
182
+ - Dev setup instructions
183
+
184
+ ### 5.3 GitHub Actions
185
+ - CI: lint + type check + tests on push
186
+ - Release: publish to PyPI on tag
187
+
188
+ ### 5.4 Launch
189
+ - Hacker News / Reddit post
190
+ - Tweet thread showing the demo
191
+ - Cross-post to AI/agent communities
192
+
193
+ ---
194
+
195
+ ## Estimated LOC per Phase
196
+
197
+ | Phase | Files | LOC | Time |
198
+ |-------|-------|-----|------|
199
+ | Phase 1 | 9 files | ~1500 | 2-3 days |
200
+ | Phase 2 | 4 files | ~600 | 1-2 days |
201
+ | Phase 3 | 4 files | ~800 | 2-3 days |
202
+ | Phase 4 | 3 files | ~500 | 1-2 days |
203
+ | Phase 5 | misc | ~200 | 1 day |
204
+ | **Total** | **~20 files** | **~3600** | **~10 days** |
205
+
206
+ ---
207
+
208
+ ## Key Principle
209
+
210
+ Every phase must leave the project in a working state. Phase 1 alone should be demoable. Don't build Phase 2 features into Phase 1 code "for later" - keep each phase minimal and functional.
@@ -0,0 +1,178 @@
1
+ # Hive Repo — Incomplete Areas Audit
2
+
3
+ ## Repository Snapshot
4
+
5
+ - **Branch**: `dev` (ahead of `origin/dev` by 1 commit)
6
+ - **Untracked artifacts**: `logs/`, `scenarios/detective/results/run-*.json`
7
+ - **Tests**: `uv run pytest` — 122 passed
8
+ - **Lint**: `uv run ruff check src tests scenarios` — 7 errors (all in `scenarios/`)
9
+ - **Types**: `uv run mypy src` — 82 errors in 24 files (65 checked)
10
+
11
+ ---
12
+
13
+ ## Findings
14
+
15
+ ### 1. Packaging: YAML data files excluded from wheel
16
+
17
+ **Severity**: High
18
+ **Files**: `pyproject.toml`, `profiles/*.yaml`, `models.yaml`, `dist/hive_agent-0.1.0-py3-none-any.whl`
19
+
20
+ `pyproject.toml` has no `[tool.setuptools.package-data]` or equivalent config. The existing wheel at `dist/` contains zero `.yaml` files. This means `pip install hive-agent` from the wheel works only when run from the project root (where `profiles/` and `models.yaml` are in CWD).
21
+
22
+ Code has fallback logic (`profile.py:10-19` checks CWD then `importlib.resources`, `registry.py:11-13` checks CWD then relative path), but neither fallback works from an arbitrary install location.
23
+
24
+ **Affected files**:
25
+ - `profiles/coder.yaml`, `oracle.yaml`, `researcher.yaml`, `reviewer.yaml`, `tester.yaml`
26
+ - `models.yaml` (model registry with pricing/routing)
27
+
28
+ **Fix**: Add package-data config to `pyproject.toml` to bundle YAML files, or copy them into `src/hive/` and adjust paths.
29
+
30
+ **Verify**: `uv build && unzip -l dist/*.whl | grep yaml`
31
+
32
+ ---
33
+
34
+ ### 2. README architecture section references deleted module
35
+
36
+ **Severity**: Low
37
+ **File**: `README.md:57`
38
+
39
+ Line 57 shows `├── execution/ # Tool system` in the architecture diagram, but `src/hive/execution/` was deleted in this branch. The `runtime/` module that replaced it is not shown. Line 47 says `├── agents/ # Agent runtime` which is vague.
40
+
41
+ **Fix**: Update the architecture tree to replace `execution/` with `runtime/` and add a line for `context.py`.
42
+
43
+ **Verify**: `ls src/hive/ | sort` and compare with README.
44
+
45
+ ---
46
+
47
+ ### 3. Launcher scripts
48
+
49
+ **Severity**: None (not a real issue)
50
+
51
+ `scripts/start.sh` and `scripts/stop.sh` exist and reference `hive.daemon.server`, which still exists. No broken imports or deleted module references. This was a false positive from the other agent's checklist.
52
+
53
+ ---
54
+
55
+ ### 4. Mypy strict typing failures — 82 errors
56
+
57
+ **Severity**: Medium
58
+ **File**: `pyproject.toml` (mypy config at `[tool.mypy]` with `strict = true`)
59
+
60
+ Breakdown by error code:
61
+ | Code | Count | Description |
62
+ |------|-------|-------------|
63
+ | `type-arg` | 35 | Missing generic type args (`dict` → `dict[str, Any]`) |
64
+ | `no-untyped-call` | 17 | Calling untyped functions in typed context |
65
+ | `no-any-return` | 7 | Returning `Any` from typed function |
66
+ | `arg-type` | 6 | Wrong argument type (includes `WorldState \| None` issues) |
67
+ | `import-untyped` | 4 | Missing stubs (yaml) |
68
+ | `attr-defined` | 4 | Attribute not found on type |
69
+ | `union-attr` | 3 | Accessing attr on union without narrowing |
70
+ | `abstract` | 2 | Instantiating abstract class |
71
+ | `no-untyped-def` | 2 | Missing function annotation |
72
+ | `return-value` | 1 | Wrong return type |
73
+ | `assignment` | 1 | Incompatible assignment |
74
+
75
+ Most impactful clusters:
76
+ - **`daemon/loop.py`** (6 errors): `WorldState | None` passed where non-optional `WorldState` expected — real type-safety gap from the economy-toggle refactor
77
+ - **`interactions/runner.py`** (7 errors): Type mismatches with `GenerateResult` vs old `ScenarioResult`
78
+ - **`mcp/server.py`** (4 errors): Bare `dict` without type params
79
+
80
+ **Fix**: Address in priority order — `arg-type` and `union-attr` errors are real safety gaps; `type-arg` errors are annotation noise.
81
+
82
+ **Verify**: `uv run mypy src`
83
+
84
+ ---
85
+
86
+ ### 5. Persistent memory wrapper — SemanticMemory integration
87
+
88
+ **Severity**: Was Critical — now fixed
89
+ **Files**: `src/hive/runtime/memory.py`, `src/hive/memory/semantic.py`
90
+
91
+ Three bugs were fixed earlier in this session:
92
+ - Constructor arg order was reversed (`agent_name, hive_dir` → `hive_dir, agent_name`)
93
+ - Called non-existent `add_observation()` instead of `store()`
94
+ - Called non-existent `query()` instead of `search()`
95
+ - `clear()` didn't delete persisted data
96
+ - `store()` returned meaningless ID in semantic path
97
+
98
+ All fixed. No remaining issues.
99
+
100
+ **Verify**: `uv run pytest tests/runtime/test_agent.py -x`
101
+
102
+ ---
103
+
104
+ ### 6. Model availability detection — key-only check
105
+
106
+ **Severity**: Low
107
+ **Files**: `src/hive/runtime/providers.py:52-54`, `src/hive/runtime/providers.py:210-212`
108
+
109
+ Both `AnthropicRuntimeProvider.available` and `OpenAIRuntimeProvider.available` return `bool(api_key)` — they don't test connectivity. Invalid/revoked keys or network issues aren't detected until generation time.
110
+
111
+ This is standard practice for SDK wrappers (the old deleted providers did the same thing). Not a regression, and adding connectivity checks would introduce latency on startup. Acceptable as-is.
112
+
113
+ **Fix**: None needed. Could optionally add a `ping()`/`verify()` method for explicit health checks.
114
+
115
+ ---
116
+
117
+ ### 7. Runtime Agent doesn't use structured LogWriter
118
+
119
+ **Severity**: Medium
120
+ **Files**: `src/hive/runtime/agent.py`, `src/hive/logging/writer.py`, `src/hive/logging/models.py`
121
+
122
+ `Agent.run()` uses only Python `logging` (debug/error/warning). The structured logging infrastructure (`LogWriter` with `DecisionLog`, `ToolLog`, `CycleLog`, `GoalLog`) exists and is used by `ExistenceLoop` and the daemon, but the runtime `Agent` doesn't emit any structured logs.
123
+
124
+ This means tool calls, model generation metadata (tokens, cost, duration), and step-by-step traces from `Agent.run()` are invisible to the log analysis pipeline.
125
+
126
+ **Fix**: Accept an optional `LogWriter` in Agent constructor. Log `DecisionLog` after each `generate()` call and `ToolLog` after each tool execution.
127
+
128
+ **Verify**: Run a scenario and check `logs/` for agent-level structured entries.
129
+
130
+ ---
131
+
132
+ ### 8. Two parallel interaction APIs coexist
133
+
134
+ **Severity**: Low
135
+ **Files**: `src/hive/interactions/base.py`, `src/hive/interactions/runner.py`, `src/hive/interactions/exchange.py`
136
+
137
+ Two systems live in `interactions/`:
138
+ - **Old**: `Scenario`, `ScenarioRunner`, `InteractionPattern`, `MemoryStrategy`, `AgentSlot` — used by `scenarios/detective/run.py`
139
+ - **New**: `Participant`, `ExchangeRunner`, `ExchangeConfig`, `InteractionMessage` — used by tests and presets
140
+
141
+ Both are exported from `interactions/__init__.py`. The old system still works (provider calls were updated to `create_runtime_provider`). Neither is dead code — `ScenarioRunner` powers the detective scenario, `ExchangeRunner` is the new primary API.
142
+
143
+ **Fix**: Not urgent. When the old scenario system is no longer needed, remove it. Until then, coexistence is fine — they don't conflict.
144
+
145
+ ---
146
+
147
+ ### 9. Scenario lint issues — 7 ruff errors
148
+
149
+ **Severity**: Low
150
+ **File**: `scenarios/detective/run.py`, `scenarios/runtime_test.py`
151
+
152
+ All 7 errors are in `scenarios/` (zero in `src/`):
153
+ - 4x `E402` in `detective/run.py`: imports after `sys.path.insert` — necessary for standalone scripts
154
+ - 1x `F841` in `detective/run.py:288`: unused `correct_answer` variable
155
+ - 1x `F541` in `runtime_test.py:78`: f-string with no placeholders
156
+ - 1x `F841` in `runtime_test.py:88`: unused `expected` variable
157
+
158
+ The `E402` errors are inherent to the `sys.path` pattern and can be suppressed with `# noqa: E402`. The `F841` and `F541` are trivial cleanups.
159
+
160
+ **Fix**: Add `# noqa: E402` to the post-sys.path imports, remove unused variables, drop the stray `f` prefix.
161
+
162
+ **Verify**: `uv run ruff check scenarios/`
163
+
164
+ ---
165
+
166
+ ## Priority Summary
167
+
168
+ | # | Finding | Severity | Action |
169
+ |---|---------|----------|--------|
170
+ | 1 | YAML files excluded from wheel | High | Fix pyproject.toml packaging |
171
+ | 4 | 82 mypy errors (6 real type-safety gaps) | Medium | Fix arg-type/union-attr errors in daemon/loop.py and interactions/runner.py |
172
+ | 7 | Runtime Agent missing structured logging | Medium | Wire LogWriter into Agent |
173
+ | 2 | README stale architecture diagram | Low | Update tree |
174
+ | 8 | Dual interaction APIs | Low | Document; deprecate old when ready |
175
+ | 9 | 7 ruff errors in scenarios/ | Low | Quick cleanup |
176
+ | 3 | Launcher scripts | None | No issue found |
177
+ | 5 | PersistentMemory semantic bugs | None | Already fixed |
178
+ | 6 | Model availability key-only check | None | By design |
@@ -0,0 +1,90 @@
1
+ # Phase 1 — Remaining Work
2
+
3
+ ## Status Audit (2026-05-11)
4
+
5
+ Most of Phase 1 is done. Tests pass (122/122), lint is clean, YAML packaging is fixed,
6
+ `replay`, `inspect`, `nudge`, `runs`, `status` all work. Runtime Agent has structured
7
+ logging wired in.
8
+
9
+ ### What's left
10
+
11
+ | # | Task | Severity | Est. |
12
+ |---|------|----------|------|
13
+ | 1 | Fix `hive watch` async bugs | Critical | 30 min |
14
+ | 2 | Fix mypy type errors | Medium | 45 min |
15
+ | 3 | Update README architecture diagram | Low | 5 min |
16
+ | 4 | Integration test for daemon loop | Medium | 30 min |
17
+
18
+ ---
19
+
20
+ ## Task 1: Fix `hive watch` — Async Bugs
21
+
22
+ **File:** `src/hive/cli/main.py` lines 241-374
23
+
24
+ **Problem:** `_build_dashboard()` (sync) calls `asyncio.run()` for store queries (lines 261,
25
+ 276), but it's called from inside `_run()` (async, line 367), which runs inside another
26
+ `asyncio.run()` (line 372). Nested `asyncio.run()` crashes with
27
+ `RuntimeError: asyncio.run() cannot be called from a running event loop`.
28
+
29
+ Same issue in `_poll_events()` (line 328) — it's async but calls `asyncio.run()`.
30
+
31
+ **Fix approach:**
32
+ - Make `_build_dashboard()` async — use `await store.list_agents()` and
33
+ `await store.get_active_goal()` directly
34
+ - In `_poll_events()`, replace `asyncio.run(store.list_agents())` with
35
+ `await store.list_agents()`
36
+ - The outer `_run()` orchestrates both `_poll_events()` and dashboard refresh as
37
+ concurrent async tasks
38
+ - Keep the `Live` context manager — it works fine with periodic `live.update()` calls
39
+ from an async loop
40
+
41
+ **Verify:** `hive init && hive start -b 5 -p coder` in one terminal, `hive watch` in
42
+ another. Dashboard should update without crashing.
43
+
44
+ ---
45
+
46
+ ## Task 2: Fix Mypy Errors
47
+
48
+ **Current:** 79 errors across 24 files. Most are annotation noise, but some are real.
49
+
50
+ **Priority fixes (real type-safety gaps):**
51
+ - `daemon/loop.py`: `WorldState | None` passed where non-optional `WorldState` expected
52
+ - `interactions/runner.py`: type mismatches with `GenerateResult` vs old return types
53
+ - Missing `types-PyYAML` stub — add to dev dependencies
54
+
55
+ **Lower priority (annotation noise):**
56
+ - Bare `dict` / `list` without type params throughout
57
+ - `Any` return types in world/stats.py, runtime/workflow.py, etc.
58
+
59
+ **Verify:** `uv run mypy src` — target zero `arg-type` and `union-attr` errors. The
60
+ `type-arg` noise can stay for now.
61
+
62
+ ---
63
+
64
+ ## Task 3: Update README Architecture Diagram
65
+
66
+ **File:** `README.md` line ~57
67
+
68
+ **Problem:** Shows `execution/` which was deleted. Should show `runtime/` instead.
69
+ Also missing entries for `context.py`, `checkpoint.py`, `world/`.
70
+
71
+ **Verify:** `ls src/hive/ | sort` matches the diagram.
72
+
73
+ ---
74
+
75
+ ## Task 4: Integration Test — End-to-End Daemon Loop
76
+
77
+ **Goal:** Prove the daemon loop actually works: spawn agent → existence loop generates
78
+ goal → suffering updates → events logged → state persisted.
79
+
80
+ **Approach:**
81
+ - Use `researcher` profile with a mocked model provider (don't call real LLMs)
82
+ - Short heartbeat (0.5s), run 3 cycles, then stop
83
+ - Assert: goal was generated, suffering state updated, events written to JSONL,
84
+ agent state in SQLite
85
+ - Use temp directories for `.hive/` and `logs/`
86
+ - Existing test patterns in `tests/` — match the style
87
+
88
+ **File:** `tests/test_daemon_integration.py`
89
+
90
+ **Verify:** `uv run pytest tests/test_daemon_integration.py -v`