|
2 | 2 |
|
3 | 3 | Open-source Python system: AI agents coordinate through shared environmental |
4 | 4 | signals (pheromones), not direct messaging. Tree-structured data model. |
5 | | -Event-sourced (69 events, closed union). Single operator. Local-first with |
| 5 | +Event-sourced (70 events, closed union). Single operator. Local-first with |
6 | 6 | cloud model support. Bayesian knowledge metabolism with Thompson Sampling |
7 | 7 | retrieval. Federated knowledge exchange via Computational CRDTs. |
8 | | -Multi-colony orchestration via DelegationPlan DAG parallelism. |
9 | | -MCP developer bridge (27 tools, 9 resources, 6 prompts) for Claude Code |
10 | | -integration. Queen Command & Control surface with behavioral overrides, |
11 | | -display board, tool tracking, and context budget visibility. |
| 8 | +Multi-colony orchestration via DelegationPlan DAG parallelism with deferred |
| 9 | +group dispatch. MCP developer bridge (29 tools, 12 resources, 8 prompts) |
| 10 | +for Claude Code integration. Queen Command & Control surface with behavioral |
| 11 | +overrides, display board, tool tracking, and context budget visibility. |
| 12 | +Planning workbench with structural analysis, replay-derived capability |
| 13 | +calibration, deterministic reviewed-plan validation and dispatch, saved plan |
| 14 | +patterns, and DAG editing. Live planning policy (`planning_policy.py`) as |
| 15 | +the Queen routing authority with fast_path enforcement at the execution |
| 16 | +layer. Project binding with real-repo codebase indexing (14K+ chunks). |
| 17 | +Production local profile: Qwen3.5-35B MoE (0.804 quality on fast_path |
| 18 | +tasks, 5/5 real-repo tasks completed, zero hangs). |
| 19 | + |
| 20 | +## Knowledge base |
| 21 | + |
| 22 | +The FormicOS knowledge system contains 100+ entries covering agent |
| 23 | +architecture state of the art (loop patterns, tool calling, context |
| 24 | +engineering, multi-agent coordination, production deployment, evaluation). |
| 25 | +Before making architectural choices, search the knowledge base via the |
| 26 | +`search_knowledge` MCP tool or the Queen's `memory_search` tool. Cite |
| 27 | +relevant entries by title when they influence design decisions. |
12 | 28 |
|
13 | 29 | ## Architecture |
14 | 30 |
|
@@ -275,6 +291,48 @@ not a DAG; they are Queen scaffolding. When a colony completes a step, the |
275 | 291 | system prompts the Queen with the next pending step via the follow_up_colony |
276 | 292 | summary. |
277 | 293 |
|
| 294 | +### Metering and billing (Wave 75) |
| 295 | + |
| 296 | +Token metering aggregates `TokensConsumed` events per billing period with |
| 297 | +chain-hash integrity. `formicos billing` CLI subgroup (status, estimate, |
| 298 | +attest, history, self-test). Attestations are deterministic and stored in |
| 299 | +`data_dir/attestations/`. The `metering.py` surface module computes fees |
| 300 | +from tiered token thresholds. `scripts/attribution.py` computes contributor |
| 301 | +revenue-share proportions from git history. |
| 302 | + |
| 303 | +### A2A economic contracts (Wave 75) |
| 304 | + |
| 305 | +Task receipts (`surface/task_receipts.py`) produce deterministic cost/quality |
| 306 | +summaries for completed A2A work. `get_task_receipt` MCP tool and |
| 307 | +`formicos://receipt/{task_id}` resource expose receipts to clients. |
| 308 | +`search_knowledge` MCP tool provides full-pipeline retrieval from external |
| 309 | +clients (semantic + Thompson + freshness + co-occurrence + graph proximity). |
| 310 | + |
| 311 | +### Structural integrity (Wave 76) |
| 312 | + |
| 313 | +16 correctness fixes across 3 teams (data truth, operational safety, |
| 314 | +context integrity). No new features -- fixes silent errors and race |
| 315 | +conditions that would surface under real multi-client load. |
| 316 | + |
| 317 | +Data truth: `BudgetSnapshot.total_tokens` includes reasoning tokens. |
| 318 | +Agent-to-colony reverse index (`_agent_colony_index`) in ProjectionStore |
| 319 | +for O(1) token attribution. Daily spend persistence to disk with reload |
| 320 | +on restart. Budget reconciliation (estimated vs actual colony cost) |
| 321 | +wired through `_post_colony_hooks`. |
| 322 | + |
| 323 | +Operational safety: Action queue compaction preserves `pending_review` |
| 324 | +items. State transition validation via `_VALID_TRANSITIONS` map (409 on |
| 325 | +invalid). Operational sweep reentrancy guard (`asyncio.Lock`). |
| 326 | +Kill/completion race guard at both colony completion paths. Journal |
| 327 | +entries for all approval/execution branches. Operator-idle detection |
| 328 | +includes Queen thread messages. |
| 329 | + |
| 330 | +Context integrity: Budget caps on memory retrieval, notes, and thread |
| 331 | +context injections. Workspace-scoped session and plan paths with |
| 332 | +migration fallback. Queen chat workspace propagation across all 4 |
| 333 | +dispatch sites. Settings and queen-overview workspace resolution via |
| 334 | +`activeWorkspaceId` property. |
| 335 | + |
278 | 336 | ## Tech stack |
279 | 337 |
|
280 | 338 | Use Python 3.12+, uv, Pydantic v2 (sole serialization), asyncio, httpx, |
@@ -483,15 +541,28 @@ IMPORTANT: These are non-negotiable. Violating any of these requires operator ap |
483 | 541 | | `surface/self_maintenance.py` | MaintenanceDispatcher, autonomy policy, blast radius, autonomy scoring | Self-maintenance | |
484 | 542 | | `surface/project_plan.py` | Project plan parser/helper, milestone tools, plan rendering | Project plan | |
485 | 543 | | `surface/queen_budget.py` | 9-slot proportional Queen context budget (ADR-051) | Queen budget | |
486 | | -| `surface/queen_tools.py` | Queen tool dispatch (42 tools), spawn_parallel, DelegationPlan | Queen tools | |
| 544 | +| `surface/queen_tools.py` | Queen tool dispatch (~45 tools, dynamic toolsets), spawn_parallel, DelegationPlan | Queen tools | |
487 | 545 | | `surface/transcript_view.py` | Canonical colony transcript schema | A2A/MCP export | |
488 | 546 | | `surface/proactive_intelligence.py` | 17 deterministic briefing rules (7 knowledge + 4 performance + evaporation + branching + earned autonomy + template health + outcome digest + popular unexamined) | Proactive intel | |
489 | 547 | | `surface/routes/api.py` | REST endpoints: outcomes, create-demo, project-plan, autonomy-status, maintenance-policy, add-model | API surface | |
490 | 548 | | `surface/workflow_learning.py` | Deterministic workflow pattern recognition + procedure suggestions (Wave 72) | Workflow learning | |
491 | 549 | | `docs/AUTONOMOUS_OPERATIONS.md` | Autonomy operator runbook: action queue, levels, learning, controls | Reference | |
492 | 550 | | `docs/DEVELOPER_BRIDGE.md` | Developer onboarding guide for Claude Code integration | Reference | |
493 | | -| `surface/mcp_server.py` | MCP server (27 tools, 9 resources, 6 prompts) | MCP surface | |
| 551 | +| `surface/mcp_server.py` | MCP server (29 tools, 12 resources, 8 prompts) | MCP surface | |
494 | 552 | | `config/templates/demo-workspace.yaml` | Demo workspace template with seeded entries | Demo path | |
| 553 | +| `surface/workspace_roots.py` | Project/library/runtime root resolution (Wave 81) | Project binding | |
| 554 | +| `surface/parallel_plans.py` | Deferred group dispatch, honest plan aggregation (Wave 81) | Parallel execution | |
| 555 | +| `surface/planning_signals.py` | Structured planning signal builder (Wave 82) | Planning | |
| 556 | +| `surface/structural_planner.py` | File matching, import coupling, grouping hints (Wave 82) | Planning | |
| 557 | +| `surface/capability_profiles.py` | Replay-derived capability calibration (Wave 82) | Planning | |
| 558 | +| `surface/reviewed_plan.py` | Reviewed-plan validation and normalization (Wave 83) | Planning workbench | |
| 559 | +| `surface/plan_patterns.py` | YAML-backed saved plan-pattern store (Wave 83) | Planning workbench | |
| 560 | +| `surface/planning_policy.py` | Consolidated routing: `decide_planning_route()` + `PlanningDecision` (Wave 85) | Queen routing | |
| 561 | +| `surface/commands.py` | WebSocket command handlers incl. `confirm_reviewed_plan` | WS surface | |
| 562 | +| `surface/metering.py` | Token metering, fee computation, attestation generation | Billing | |
| 563 | +| `surface/task_receipts.py` | Deterministic task receipts for A2A economic contracts | A2A economics | |
| 564 | +| `scripts/attribution.py` | Contributor revenue-share attribution from git history | Billing | |
| 565 | +| `docs/waves/wave_81/real_repo_task_pack.md` | Real-repo evaluation tasks (rtp-01 through rtp-05) | Benchmark | |
495 | 566 |
|
496 | 567 | ## Common patterns |
497 | 568 |
|
|
0 commit comments