coordinationhub 0.3.2__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 (63) hide show
  1. coordinationhub-0.3.2/PKG-INFO +301 -0
  2. coordinationhub-0.3.2/README.md +276 -0
  3. coordinationhub-0.3.2/coordinationhub/__init__.py +20 -0
  4. coordinationhub-0.3.2/coordinationhub/_storage.py +131 -0
  5. coordinationhub-0.3.2/coordinationhub/agent_registry.py +23 -0
  6. coordinationhub-0.3.2/coordinationhub/agent_status.py +225 -0
  7. coordinationhub-0.3.2/coordinationhub/assessment.py +241 -0
  8. coordinationhub-0.3.2/coordinationhub/assessment_scorers.py +304 -0
  9. coordinationhub-0.3.2/coordinationhub/cli.py +242 -0
  10. coordinationhub-0.3.2/coordinationhub/cli_agents.py +180 -0
  11. coordinationhub-0.3.2/coordinationhub/cli_commands.py +45 -0
  12. coordinationhub-0.3.2/coordinationhub/cli_locks.py +214 -0
  13. coordinationhub-0.3.2/coordinationhub/cli_utils.py +30 -0
  14. coordinationhub-0.3.2/coordinationhub/cli_vis.py +323 -0
  15. coordinationhub-0.3.2/coordinationhub/conflict_log.py +52 -0
  16. coordinationhub-0.3.2/coordinationhub/context.py +97 -0
  17. coordinationhub-0.3.2/coordinationhub/core.py +472 -0
  18. coordinationhub-0.3.2/coordinationhub/db.py +215 -0
  19. coordinationhub-0.3.2/coordinationhub/dispatch.py +50 -0
  20. coordinationhub-0.3.2/coordinationhub/graph.py +66 -0
  21. coordinationhub-0.3.2/coordinationhub/graph_loader.py +49 -0
  22. coordinationhub-0.3.2/coordinationhub/graph_validate.py +131 -0
  23. coordinationhub-0.3.2/coordinationhub/graphs.py +146 -0
  24. coordinationhub-0.3.2/coordinationhub/hooks/__init__.py +0 -0
  25. coordinationhub-0.3.2/coordinationhub/hooks/claude_code.py +314 -0
  26. coordinationhub-0.3.2/coordinationhub/lock_ops.py +119 -0
  27. coordinationhub-0.3.2/coordinationhub/mcp_server.py +275 -0
  28. coordinationhub-0.3.2/coordinationhub/mcp_stdio.py +175 -0
  29. coordinationhub-0.3.2/coordinationhub/notifications.py +94 -0
  30. coordinationhub-0.3.2/coordinationhub/paths.py +47 -0
  31. coordinationhub-0.3.2/coordinationhub/registry_ops.py +106 -0
  32. coordinationhub-0.3.2/coordinationhub/registry_query.py +152 -0
  33. coordinationhub-0.3.2/coordinationhub/responsibilities.py +35 -0
  34. coordinationhub-0.3.2/coordinationhub/scan.py +207 -0
  35. coordinationhub-0.3.2/coordinationhub/schemas.py +31 -0
  36. coordinationhub-0.3.2/coordinationhub/schemas_audit.py +43 -0
  37. coordinationhub-0.3.2/coordinationhub/schemas_change.py +77 -0
  38. coordinationhub-0.3.2/coordinationhub/schemas_coordination.py +59 -0
  39. coordinationhub-0.3.2/coordinationhub/schemas_identity.py +123 -0
  40. coordinationhub-0.3.2/coordinationhub/schemas_locking.py +160 -0
  41. coordinationhub-0.3.2/coordinationhub/schemas_visibility.py +156 -0
  42. coordinationhub-0.3.2/coordinationhub/visibility.py +15 -0
  43. coordinationhub-0.3.2/coordinationhub.egg-info/PKG-INFO +301 -0
  44. coordinationhub-0.3.2/coordinationhub.egg-info/SOURCES.txt +61 -0
  45. coordinationhub-0.3.2/coordinationhub.egg-info/dependency_links.txt +1 -0
  46. coordinationhub-0.3.2/coordinationhub.egg-info/entry_points.txt +2 -0
  47. coordinationhub-0.3.2/coordinationhub.egg-info/requires.txt +7 -0
  48. coordinationhub-0.3.2/coordinationhub.egg-info/top_level.txt +1 -0
  49. coordinationhub-0.3.2/pyproject.toml +51 -0
  50. coordinationhub-0.3.2/setup.cfg +4 -0
  51. coordinationhub-0.3.2/tests/test_agent_lifecycle.py +182 -0
  52. coordinationhub-0.3.2/tests/test_assessment.py +335 -0
  53. coordinationhub-0.3.2/tests/test_cli.py +145 -0
  54. coordinationhub-0.3.2/tests/test_concurrent.py +244 -0
  55. coordinationhub-0.3.2/tests/test_conflicts.py +99 -0
  56. coordinationhub-0.3.2/tests/test_coordination.py +60 -0
  57. coordinationhub-0.3.2/tests/test_core.py +282 -0
  58. coordinationhub-0.3.2/tests/test_graphs.py +247 -0
  59. coordinationhub-0.3.2/tests/test_integration.py +219 -0
  60. coordinationhub-0.3.2/tests/test_locking.py +151 -0
  61. coordinationhub-0.3.2/tests/test_notifications.py +59 -0
  62. coordinationhub-0.3.2/tests/test_scenario.py +203 -0
  63. coordinationhub-0.3.2/tests/test_visibility.py +417 -0
@@ -0,0 +1,301 @@
1
+ Metadata-Version: 2.4
2
+ Name: coordinationhub
3
+ Version: 0.3.2
4
+ Summary: Declarative multi-agent coordination hub — YAML/JSON graphs, file ownership, live visibility, assessment runner
5
+ Author-email: IronAdamant <18153828+IronAdamant@users.noreply.github.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/IronAdamant/coordinationhub
8
+ Project-URL: Repository, https://github.com/IronAdamant/coordinationhub
9
+ Keywords: mcp,multi-agent,coordination,swarm,claude-code
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ Provides-Extra: mcp
21
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
25
+
26
+ # CoordinationHub
27
+
28
+ **Coordination hub for multi-agent coding swarms — root agent as project manager, spawned agents as team members, zero third-party deps in core.**
29
+
30
+ CoordinationHub tracks who is doing what across a swarm. The root agent acts as project manager (top-level coordinator), spawning child agents that act as team leaders or team members. Files are locked and owned by Agent ID — every agent and human can see the full assignment tree at any time.
31
+
32
+ Works standalone or alongside **Stele + Chisel + Trammel + CoordinationHub**.
33
+
34
+ ## How It Works
35
+
36
+ ```
37
+ Root Agent (project manager)
38
+ ├── Child Agent A (team leader)
39
+ │ ├── Grandchild A.0 (team member — does the work)
40
+ │ └── Grandchild A.1 (team member)
41
+ ├── Child Agent B (team leader)
42
+ │ └── Grandchild B.0 (team member)
43
+ └── Child Agent C (team member)
44
+ ```
45
+
46
+ Every node in the tree is a registered agent with an Agent ID. Files are locked by Agent ID so the project manager can see who holds what. Children are re-parented to the grandparent if their parent dies (cascade orphaning) — no agent is permanently stranded.
47
+
48
+ ## Coordination Model
49
+
50
+ | Role | Description |
51
+ |------|-------------|
52
+ | **Root agent** | Project manager — top-level coordinator. Spawns team leaders. Does not do the work itself. |
53
+ | **Team leader** | Child of root (or grandchild). Spawns team members, assigns tasks, reviews work. |
54
+ | **Team member** | Leaf node. Does the work: writes code, runs tests, calls `notify_change` when done. |
55
+
56
+ **Agents communicate via change notifications, not messages.** A team member calls `notify_change(path, 'modified', agent_id)` after writing a shared file. Teammates poll `get_notifications` to discover what changed. `broadcast` checks sibling lock state before a significant action — it does not send or store messages; the calling agent decides what to do with the conflict data.
57
+
58
+ `acquire_lock` enforces exclusive access: a team member locks a file before writing, releases it when done. Review the full agent tree at any time:
59
+
60
+ ```bash
61
+ coordinationhub agent-tree # oldest root agent as root
62
+ coordinationhub agent-tree hub.12345.0 # specific agent as root
63
+ coordinationhub agent-status <agent_id> --tree
64
+ ```
65
+
66
+ - **Declarative coordination graphs** — agents, handoffs, escalation rules, and assessment
67
+ criteria defined in `coordination_spec.yaml` or `coordination_spec.json` at project root.
68
+ - **File ownership tracking** — SQLite `file_ownership` table populated by `scan_project`;
69
+ maps every tracked file to its responsible Agent ID.
70
+ - **Visibility layer** — MCP tools + `coordinationhub dashboard` CLI command for live
71
+ human/LLM-readable status.
72
+ - **Assessment runner** — `coordinationhub assess --suite <file>` scores graph fidelity
73
+ against MiniMax coordination test traces. 5 real metric scorers.
74
+ - **Agent identity & lineage** — Hierarchical agent IDs with parent-child relationships.
75
+ - **Document locking** — TTL-based exclusive/shared locks with force-steal and conflict recording.
76
+ - **Cascade orphaning** — Children re-parented to grandparent when parent dies.
77
+ - **Change notifications** — Polling-based change awareness across agents.
78
+ - **Zero third-party dependencies in core** — Supply chain security is non-negotiable.
79
+
80
+ ## Quickstart
81
+
82
+ ```bash
83
+ # HTTP server (stdlib only)
84
+ coordinationhub serve --port 9877
85
+
86
+ # Stdio MCP (requires optional mcp package):
87
+ pip install coordinationhub[mcp]
88
+ coordinationhub serve-mcp
89
+
90
+ # Scan project and assign file ownership
91
+ coordinationhub scan-project
92
+
93
+ # View live dashboard
94
+ coordinationhub dashboard
95
+ coordinationhub dashboard --json
96
+
97
+ # Run assessment suite
98
+ coordinationhub assess --suite my_minimax_tests.json
99
+ coordinationhub assess --suite my_minimax_tests.json --graph-agent-id planner
100
+ ```
101
+
102
+ ## Coordination Graph
103
+
104
+ Place `coordination_spec.yaml` (or `.json`) at your project root.
105
+ Example files are provided in the repo root:
106
+
107
+ - [`coordination_spec.yaml`](coordination_spec.yaml) — YAML format
108
+ - [`coordination_spec.json`](coordination_spec.json) — JSON format
109
+
110
+ ```yaml
111
+ agents:
112
+ - id: planner
113
+ role: decompose tasks
114
+ model: minimax-m2.7
115
+ responsibilities:
116
+ - break down user stories
117
+ - assign subtasks
118
+ - id: executor
119
+ role: implement
120
+ model: minimax-m2.7
121
+ responsibilities:
122
+ - write code
123
+ - run tests
124
+
125
+ handoffs:
126
+ - from: planner
127
+ to: executor
128
+ condition: task_size < 500 && no_blockers
129
+
130
+ escalation:
131
+ max_retries: 3
132
+ fallback: human_review
133
+
134
+ assessment:
135
+ metrics:
136
+ - role_stability
137
+ - handoff_latency
138
+ - outcome_verifiability
139
+ - protocol_adherence
140
+ - spawn_propagation
141
+ ```
142
+
143
+ ## 29 MCP Tools
144
+
145
+ | Tool | Purpose |
146
+ |------|---------|
147
+ | `register_agent` | Register and get coordination context + responsibilities from graph |
148
+ | `heartbeat` | Keep agent alive (updates timestamp only) |
149
+ | `deregister_agent` | Remove agent, orphan children, release locks |
150
+ | `list_agents` | List registered agents with staleness |
151
+ | `get_lineage` | Get ancestors and descendants of an agent |
152
+ | `get_siblings` | Get agents sharing the same parent |
153
+ | `acquire_lock` | Acquire exclusive or shared lock on a document |
154
+ | `release_lock` | Release a held lock |
155
+ | `refresh_lock` | Extend lock TTL without releasing |
156
+ | `get_lock_status` | Check if a document is locked |
157
+ | `list_locks` | List all active locks (optionally filtered by agent) |
158
+ | `release_agent_locks` | Release all locks held by an agent |
159
+ | `reap_expired_locks` | Clear all expired locks |
160
+ | `reap_stale_agents` | Mark stale agents as stopped |
161
+ | `broadcast` | Announce intention to siblings (checks lock state only) |
162
+ | `wait_for_locks` | Poll until locks are released |
163
+ | `notify_change` | Record a change event |
164
+ | `get_notifications` | Poll for change notifications |
165
+ | `prune_notifications` | Clean up old notifications |
166
+ | `get_conflicts` | Query the conflict log |
167
+ | `status` | System status summary (includes `graph_loaded`) |
168
+ | `load_coordination_spec` | Reload coordination spec from disk |
169
+ | `validate_graph` | Validate loaded graph schema |
170
+ | `scan_project` | Perform file ownership scan |
171
+ | `get_agent_status` | Full status for an agent (work, responsibilities, owned files) |
172
+ | `get_file_agent_map` | Map of all tracked files → agent + responsibility |
173
+ | `update_agent_status` | Broadcast what an agent is currently working on |
174
+ | `run_assessment` | Run an assessment suite against the loaded graph |
175
+ | `get_agent_tree` | Hierarchical agent tree for human/LLM review (nested + plain-text) |
176
+
177
+ ## CLI Commands
178
+
179
+ ```bash
180
+ # Server
181
+ coordinationhub serve --port 9877
182
+ coordinationhub serve-mcp
183
+
184
+ # Status & visibility
185
+ coordinationhub status
186
+ coordinationhub list-agents
187
+ coordinationhub dashboard
188
+ coordinationhub dashboard --json
189
+ coordinationhub agent-status <agent_id>
190
+ coordinationhub agent-status <agent_id> --json
191
+ coordinationhub agent-status <agent_id> --tree
192
+ coordinationhub agent-tree <agent_id>
193
+ coordinationhub agent-tree
194
+
195
+ # Graph
196
+ coordinationhub load-spec
197
+ coordinationhub validate-spec
198
+
199
+ # File ownership
200
+ coordinationhub scan-project
201
+
202
+ # Assessment
203
+ coordinationhub assess --suite my_minimax_tests.json
204
+
205
+ # Agent lifecycle
206
+ coordinationhub register <agent_id>
207
+ coordinationhub register <agent_id> --parent-id <parent>
208
+ coordinationhub heartbeat <agent_id>
209
+ coordinationhub deregister <agent_id>
210
+ coordinationhub lineage <agent_id>
211
+ coordinationhub siblings <agent_id>
212
+
213
+ # Locking
214
+ coordinationhub acquire-lock <path> <agent_id>
215
+ coordinationhub release-lock <path> <agent_id>
216
+ coordinationhub refresh-lock <path> <agent_id>
217
+ coordinationhub lock-status <path>
218
+ coordinationhub list-locks
219
+ coordinationhub list-locks --agent-id <agent_id>
220
+ coordinationhub release-agent-locks <agent_id>
221
+ coordinationhub reap-expired-locks
222
+ coordinationhub reap-stale-agents
223
+
224
+ # Coordination
225
+ coordinationhub broadcast <agent_id> [--document-path <path>]
226
+ coordinationhub wait-for-locks <agent_id> <paths...>
227
+ coordinationhub notify-change <path> <type> <agent_id>
228
+ coordinationhub get-notifications
229
+ coordinationhub prune-notifications
230
+ coordinationhub get-conflicts
231
+ ```
232
+
233
+ ## Agent ID Format
234
+
235
+ ```
236
+ hub.12345.0 — root agent (namespace.PID.sequence)
237
+ hub.12345.0.0 — child of hub.12345.0
238
+ hub.12345.0.1 — another child of hub.12345.0
239
+ hub.12345.0.0.0 — grandchild
240
+ ```
241
+
242
+ When a coordination graph is loaded, agents may also have a `graph_agent_id`
243
+ (e.g., `planner`) mapped via the `agent_responsibilities` table.
244
+
245
+ ## Architecture
246
+
247
+ ```
248
+ coordinationhub/
249
+ __init__.py — Package init, exports CoordinationEngine, CoordinationHubMCPServer
250
+ core.py — CoordinationEngine: all 28 tool methods (~431 LOC)
251
+ _storage.py — CoordinationStorage: SQLite pool, path resolution, lifecycle (~121 LOC)
252
+ paths.py — Project-root detection and path normalization (~48 LOC)
253
+ context.py — Context bundle builder for register_agent responses (~100 LOC)
254
+ schemas.py — Schema aggregator, re-exports TOOL_SCHEMAS (~31 LOC)
255
+ schemas_identity.py — Identity & Registration schemas (~123 LOC)
256
+ schemas_locking.py — Document Locking schemas (~145 LOC)
257
+ schemas_coordination.py — Coordination Action schemas (~59 LOC)
258
+ schemas_change.py — Change Awareness schemas (~77 LOC)
259
+ schemas_audit.py — Audit & Status schemas (~43 LOC)
260
+ schemas_visibility.py — Graph & Visibility schemas (8 tools, ~156 LOC)
261
+ dispatch.py — Tool dispatch table (~48 LOC)
262
+ graphs.py — Thin aggregator + graph auto-mapping (~105 LOC)
263
+ graph_validate.py — Pure validation functions (~131 LOC)
264
+ graph_loader.py — File loading (YAML/JSON) and spec auto-detection (~49 LOC)
265
+ graph.py — CoordinationGraph in-memory object (~66 LOC)
266
+ visibility.py — Thin re-export aggregator (~15 LOC)
267
+ scan.py — File ownership scan, graph-role-aware (~105 LOC)
268
+ agent_status.py — Agent status query, file map, and agent tree helpers (~225 LOC)
269
+ responsibilities.py — Agent role/responsibilities storage (~35 LOC)
270
+ agent_registry.py — Thin re-export aggregator (~23 LOC)
271
+ registry_ops.py — Agent lifecycle ops (~120 LOC)
272
+ registry_query.py — Agent registry queries (~142 LOC)
273
+ assessment.py — Assessment runner, 5 metric scorers (~394 LOC)
274
+ mcp_server.py — HTTP MCP server (ThreadedHTTPServer, stdlib only)
275
+ mcp_stdio.py — Stdio MCP server (requires optional mcp package)
276
+ cli.py — argparse CLI parser + lazy dispatch (~237 LOC)
277
+ cli_commands.py — Re-exports all CLI handlers (~44 LOC)
278
+ cli_agents.py — Agent identity & lifecycle CLI commands (~205 LOC)
279
+ cli_locks.py — Document locking & coordination CLI commands (~214 LOC)
280
+ cli_vis.py — Change awareness, audit, graph & assessment CLI + agent-tree (~346 LOC)
281
+ db.py — SQLite schema + thread-local ConnectionPool (~215 LOC)
282
+ lock_ops.py — Shared lock primitives (~119 LOC)
283
+ conflict_log.py — Conflict recording and querying (~53 LOC)
284
+ notifications.py — Change notification storage and retrieval (~115 LOC)
285
+ tests/ — pytest suite (187 tests, 12 test files)
286
+ ```
287
+
288
+ ## Zero-Dependency Guarantee
289
+
290
+ Core modules use **only the Python standard library**. The `mcp` package is
291
+ **optional** — only needed for `mcp_stdio.py`. Air-gapped install:
292
+ `pip install coordinationhub --no-deps`.
293
+
294
+ ## Port Allocation
295
+
296
+ | Server | Port |
297
+ |--------|------|
298
+ | Stele | 9876 |
299
+ | CoordinationHub | 9877 |
300
+ | Chisel | 8377 |
301
+ | Trammel | 8737 |
@@ -0,0 +1,276 @@
1
+ # CoordinationHub
2
+
3
+ **Coordination hub for multi-agent coding swarms — root agent as project manager, spawned agents as team members, zero third-party deps in core.**
4
+
5
+ CoordinationHub tracks who is doing what across a swarm. The root agent acts as project manager (top-level coordinator), spawning child agents that act as team leaders or team members. Files are locked and owned by Agent ID — every agent and human can see the full assignment tree at any time.
6
+
7
+ Works standalone or alongside **Stele + Chisel + Trammel + CoordinationHub**.
8
+
9
+ ## How It Works
10
+
11
+ ```
12
+ Root Agent (project manager)
13
+ ├── Child Agent A (team leader)
14
+ │ ├── Grandchild A.0 (team member — does the work)
15
+ │ └── Grandchild A.1 (team member)
16
+ ├── Child Agent B (team leader)
17
+ │ └── Grandchild B.0 (team member)
18
+ └── Child Agent C (team member)
19
+ ```
20
+
21
+ Every node in the tree is a registered agent with an Agent ID. Files are locked by Agent ID so the project manager can see who holds what. Children are re-parented to the grandparent if their parent dies (cascade orphaning) — no agent is permanently stranded.
22
+
23
+ ## Coordination Model
24
+
25
+ | Role | Description |
26
+ |------|-------------|
27
+ | **Root agent** | Project manager — top-level coordinator. Spawns team leaders. Does not do the work itself. |
28
+ | **Team leader** | Child of root (or grandchild). Spawns team members, assigns tasks, reviews work. |
29
+ | **Team member** | Leaf node. Does the work: writes code, runs tests, calls `notify_change` when done. |
30
+
31
+ **Agents communicate via change notifications, not messages.** A team member calls `notify_change(path, 'modified', agent_id)` after writing a shared file. Teammates poll `get_notifications` to discover what changed. `broadcast` checks sibling lock state before a significant action — it does not send or store messages; the calling agent decides what to do with the conflict data.
32
+
33
+ `acquire_lock` enforces exclusive access: a team member locks a file before writing, releases it when done. Review the full agent tree at any time:
34
+
35
+ ```bash
36
+ coordinationhub agent-tree # oldest root agent as root
37
+ coordinationhub agent-tree hub.12345.0 # specific agent as root
38
+ coordinationhub agent-status <agent_id> --tree
39
+ ```
40
+
41
+ - **Declarative coordination graphs** — agents, handoffs, escalation rules, and assessment
42
+ criteria defined in `coordination_spec.yaml` or `coordination_spec.json` at project root.
43
+ - **File ownership tracking** — SQLite `file_ownership` table populated by `scan_project`;
44
+ maps every tracked file to its responsible Agent ID.
45
+ - **Visibility layer** — MCP tools + `coordinationhub dashboard` CLI command for live
46
+ human/LLM-readable status.
47
+ - **Assessment runner** — `coordinationhub assess --suite <file>` scores graph fidelity
48
+ against MiniMax coordination test traces. 5 real metric scorers.
49
+ - **Agent identity & lineage** — Hierarchical agent IDs with parent-child relationships.
50
+ - **Document locking** — TTL-based exclusive/shared locks with force-steal and conflict recording.
51
+ - **Cascade orphaning** — Children re-parented to grandparent when parent dies.
52
+ - **Change notifications** — Polling-based change awareness across agents.
53
+ - **Zero third-party dependencies in core** — Supply chain security is non-negotiable.
54
+
55
+ ## Quickstart
56
+
57
+ ```bash
58
+ # HTTP server (stdlib only)
59
+ coordinationhub serve --port 9877
60
+
61
+ # Stdio MCP (requires optional mcp package):
62
+ pip install coordinationhub[mcp]
63
+ coordinationhub serve-mcp
64
+
65
+ # Scan project and assign file ownership
66
+ coordinationhub scan-project
67
+
68
+ # View live dashboard
69
+ coordinationhub dashboard
70
+ coordinationhub dashboard --json
71
+
72
+ # Run assessment suite
73
+ coordinationhub assess --suite my_minimax_tests.json
74
+ coordinationhub assess --suite my_minimax_tests.json --graph-agent-id planner
75
+ ```
76
+
77
+ ## Coordination Graph
78
+
79
+ Place `coordination_spec.yaml` (or `.json`) at your project root.
80
+ Example files are provided in the repo root:
81
+
82
+ - [`coordination_spec.yaml`](coordination_spec.yaml) — YAML format
83
+ - [`coordination_spec.json`](coordination_spec.json) — JSON format
84
+
85
+ ```yaml
86
+ agents:
87
+ - id: planner
88
+ role: decompose tasks
89
+ model: minimax-m2.7
90
+ responsibilities:
91
+ - break down user stories
92
+ - assign subtasks
93
+ - id: executor
94
+ role: implement
95
+ model: minimax-m2.7
96
+ responsibilities:
97
+ - write code
98
+ - run tests
99
+
100
+ handoffs:
101
+ - from: planner
102
+ to: executor
103
+ condition: task_size < 500 && no_blockers
104
+
105
+ escalation:
106
+ max_retries: 3
107
+ fallback: human_review
108
+
109
+ assessment:
110
+ metrics:
111
+ - role_stability
112
+ - handoff_latency
113
+ - outcome_verifiability
114
+ - protocol_adherence
115
+ - spawn_propagation
116
+ ```
117
+
118
+ ## 29 MCP Tools
119
+
120
+ | Tool | Purpose |
121
+ |------|---------|
122
+ | `register_agent` | Register and get coordination context + responsibilities from graph |
123
+ | `heartbeat` | Keep agent alive (updates timestamp only) |
124
+ | `deregister_agent` | Remove agent, orphan children, release locks |
125
+ | `list_agents` | List registered agents with staleness |
126
+ | `get_lineage` | Get ancestors and descendants of an agent |
127
+ | `get_siblings` | Get agents sharing the same parent |
128
+ | `acquire_lock` | Acquire exclusive or shared lock on a document |
129
+ | `release_lock` | Release a held lock |
130
+ | `refresh_lock` | Extend lock TTL without releasing |
131
+ | `get_lock_status` | Check if a document is locked |
132
+ | `list_locks` | List all active locks (optionally filtered by agent) |
133
+ | `release_agent_locks` | Release all locks held by an agent |
134
+ | `reap_expired_locks` | Clear all expired locks |
135
+ | `reap_stale_agents` | Mark stale agents as stopped |
136
+ | `broadcast` | Announce intention to siblings (checks lock state only) |
137
+ | `wait_for_locks` | Poll until locks are released |
138
+ | `notify_change` | Record a change event |
139
+ | `get_notifications` | Poll for change notifications |
140
+ | `prune_notifications` | Clean up old notifications |
141
+ | `get_conflicts` | Query the conflict log |
142
+ | `status` | System status summary (includes `graph_loaded`) |
143
+ | `load_coordination_spec` | Reload coordination spec from disk |
144
+ | `validate_graph` | Validate loaded graph schema |
145
+ | `scan_project` | Perform file ownership scan |
146
+ | `get_agent_status` | Full status for an agent (work, responsibilities, owned files) |
147
+ | `get_file_agent_map` | Map of all tracked files → agent + responsibility |
148
+ | `update_agent_status` | Broadcast what an agent is currently working on |
149
+ | `run_assessment` | Run an assessment suite against the loaded graph |
150
+ | `get_agent_tree` | Hierarchical agent tree for human/LLM review (nested + plain-text) |
151
+
152
+ ## CLI Commands
153
+
154
+ ```bash
155
+ # Server
156
+ coordinationhub serve --port 9877
157
+ coordinationhub serve-mcp
158
+
159
+ # Status & visibility
160
+ coordinationhub status
161
+ coordinationhub list-agents
162
+ coordinationhub dashboard
163
+ coordinationhub dashboard --json
164
+ coordinationhub agent-status <agent_id>
165
+ coordinationhub agent-status <agent_id> --json
166
+ coordinationhub agent-status <agent_id> --tree
167
+ coordinationhub agent-tree <agent_id>
168
+ coordinationhub agent-tree
169
+
170
+ # Graph
171
+ coordinationhub load-spec
172
+ coordinationhub validate-spec
173
+
174
+ # File ownership
175
+ coordinationhub scan-project
176
+
177
+ # Assessment
178
+ coordinationhub assess --suite my_minimax_tests.json
179
+
180
+ # Agent lifecycle
181
+ coordinationhub register <agent_id>
182
+ coordinationhub register <agent_id> --parent-id <parent>
183
+ coordinationhub heartbeat <agent_id>
184
+ coordinationhub deregister <agent_id>
185
+ coordinationhub lineage <agent_id>
186
+ coordinationhub siblings <agent_id>
187
+
188
+ # Locking
189
+ coordinationhub acquire-lock <path> <agent_id>
190
+ coordinationhub release-lock <path> <agent_id>
191
+ coordinationhub refresh-lock <path> <agent_id>
192
+ coordinationhub lock-status <path>
193
+ coordinationhub list-locks
194
+ coordinationhub list-locks --agent-id <agent_id>
195
+ coordinationhub release-agent-locks <agent_id>
196
+ coordinationhub reap-expired-locks
197
+ coordinationhub reap-stale-agents
198
+
199
+ # Coordination
200
+ coordinationhub broadcast <agent_id> [--document-path <path>]
201
+ coordinationhub wait-for-locks <agent_id> <paths...>
202
+ coordinationhub notify-change <path> <type> <agent_id>
203
+ coordinationhub get-notifications
204
+ coordinationhub prune-notifications
205
+ coordinationhub get-conflicts
206
+ ```
207
+
208
+ ## Agent ID Format
209
+
210
+ ```
211
+ hub.12345.0 — root agent (namespace.PID.sequence)
212
+ hub.12345.0.0 — child of hub.12345.0
213
+ hub.12345.0.1 — another child of hub.12345.0
214
+ hub.12345.0.0.0 — grandchild
215
+ ```
216
+
217
+ When a coordination graph is loaded, agents may also have a `graph_agent_id`
218
+ (e.g., `planner`) mapped via the `agent_responsibilities` table.
219
+
220
+ ## Architecture
221
+
222
+ ```
223
+ coordinationhub/
224
+ __init__.py — Package init, exports CoordinationEngine, CoordinationHubMCPServer
225
+ core.py — CoordinationEngine: all 28 tool methods (~431 LOC)
226
+ _storage.py — CoordinationStorage: SQLite pool, path resolution, lifecycle (~121 LOC)
227
+ paths.py — Project-root detection and path normalization (~48 LOC)
228
+ context.py — Context bundle builder for register_agent responses (~100 LOC)
229
+ schemas.py — Schema aggregator, re-exports TOOL_SCHEMAS (~31 LOC)
230
+ schemas_identity.py — Identity & Registration schemas (~123 LOC)
231
+ schemas_locking.py — Document Locking schemas (~145 LOC)
232
+ schemas_coordination.py — Coordination Action schemas (~59 LOC)
233
+ schemas_change.py — Change Awareness schemas (~77 LOC)
234
+ schemas_audit.py — Audit & Status schemas (~43 LOC)
235
+ schemas_visibility.py — Graph & Visibility schemas (8 tools, ~156 LOC)
236
+ dispatch.py — Tool dispatch table (~48 LOC)
237
+ graphs.py — Thin aggregator + graph auto-mapping (~105 LOC)
238
+ graph_validate.py — Pure validation functions (~131 LOC)
239
+ graph_loader.py — File loading (YAML/JSON) and spec auto-detection (~49 LOC)
240
+ graph.py — CoordinationGraph in-memory object (~66 LOC)
241
+ visibility.py — Thin re-export aggregator (~15 LOC)
242
+ scan.py — File ownership scan, graph-role-aware (~105 LOC)
243
+ agent_status.py — Agent status query, file map, and agent tree helpers (~225 LOC)
244
+ responsibilities.py — Agent role/responsibilities storage (~35 LOC)
245
+ agent_registry.py — Thin re-export aggregator (~23 LOC)
246
+ registry_ops.py — Agent lifecycle ops (~120 LOC)
247
+ registry_query.py — Agent registry queries (~142 LOC)
248
+ assessment.py — Assessment runner, 5 metric scorers (~394 LOC)
249
+ mcp_server.py — HTTP MCP server (ThreadedHTTPServer, stdlib only)
250
+ mcp_stdio.py — Stdio MCP server (requires optional mcp package)
251
+ cli.py — argparse CLI parser + lazy dispatch (~237 LOC)
252
+ cli_commands.py — Re-exports all CLI handlers (~44 LOC)
253
+ cli_agents.py — Agent identity & lifecycle CLI commands (~205 LOC)
254
+ cli_locks.py — Document locking & coordination CLI commands (~214 LOC)
255
+ cli_vis.py — Change awareness, audit, graph & assessment CLI + agent-tree (~346 LOC)
256
+ db.py — SQLite schema + thread-local ConnectionPool (~215 LOC)
257
+ lock_ops.py — Shared lock primitives (~119 LOC)
258
+ conflict_log.py — Conflict recording and querying (~53 LOC)
259
+ notifications.py — Change notification storage and retrieval (~115 LOC)
260
+ tests/ — pytest suite (187 tests, 12 test files)
261
+ ```
262
+
263
+ ## Zero-Dependency Guarantee
264
+
265
+ Core modules use **only the Python standard library**. The `mcp` package is
266
+ **optional** — only needed for `mcp_stdio.py`. Air-gapped install:
267
+ `pip install coordinationhub --no-deps`.
268
+
269
+ ## Port Allocation
270
+
271
+ | Server | Port |
272
+ |--------|------|
273
+ | Stele | 9876 |
274
+ | CoordinationHub | 9877 |
275
+ | Chisel | 8377 |
276
+ | Trammel | 8737 |
@@ -0,0 +1,20 @@
1
+ """CoordinationHub — multi-agent swarm coordination MCP server.
2
+
3
+ Exposes agent identity, document locking, lineage tracking, and change
4
+ awareness to any MCP-aware coding agent or IDE.
5
+
6
+ Stdlib-only core. Optional `mcp` package for stdio transport only.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from .core import CoordinationEngine
12
+ from .mcp_server import CoordinationHubMCPServer
13
+
14
+ __version__ = "0.3.2"
15
+
16
+ __all__ = [
17
+ "CoordinationEngine",
18
+ "CoordinationHubMCPServer",
19
+ "__version__",
20
+ ]