m2-harness 0.6.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.
- m2_harness-0.6.0/LICENSE +17 -0
- m2_harness-0.6.0/PKG-INFO +227 -0
- m2_harness-0.6.0/README.md +181 -0
- m2_harness-0.6.0/pyproject.toml +85 -0
- m2_harness-0.6.0/setup.cfg +4 -0
- m2_harness-0.6.0/src/m1_m2_agent/__init__.py +159 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/__init__.py +33 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/evaluator.py +143 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/manifests.py +63 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/metrics.py +192 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/models.py +161 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/__init__.py +21 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/ast.py +69 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/base.py +34 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/composite.py +49 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/diff.py +57 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/files.py +47 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/integrity.py +76 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/oracles/pytest.py +63 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/reports.py +122 -0
- m2_harness-0.6.0/src/m1_m2_agent/benchmark/runner.py +200 -0
- m2_harness-0.6.0/src/m1_m2_agent/contracts/__init__.py +18 -0
- m2_harness-0.6.0/src/m1_m2_agent/contracts/models.py +322 -0
- m2_harness-0.6.0/src/m1_m2_agent/dashboard/__init__.py +8 -0
- m2_harness-0.6.0/src/m1_m2_agent/dashboard/assets.py +1379 -0
- m2_harness-0.6.0/src/m1_m2_agent/dashboard/broadcaster.py +158 -0
- m2_harness-0.6.0/src/m1_m2_agent/dashboard/server.py +236 -0
- m2_harness-0.6.0/src/m1_m2_agent/doctor/__init__.py +24 -0
- m2_harness-0.6.0/src/m1_m2_agent/doctor/checks.py +248 -0
- m2_harness-0.6.0/src/m1_m2_agent/doctor/runner.py +110 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/__init__.py +36 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/client.py +236 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/config.py +331 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/context_budget.py +138 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/llm_client.py +228 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/output_normalizer.py +136 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/prompts.py +91 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/retry.py +132 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/session_manager.py +657 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/test_normalizers.py +128 -0
- m2_harness-0.6.0/src/m1_m2_agent/engine/working_state.py +273 -0
- m2_harness-0.6.0/src/m1_m2_agent/escalation/__init__.py +8 -0
- m2_harness-0.6.0/src/m1_m2_agent/escalation/manager.py +186 -0
- m2_harness-0.6.0/src/m1_m2_agent/events/__init__.py +15 -0
- m2_harness-0.6.0/src/m1_m2_agent/events/bus.py +177 -0
- m2_harness-0.6.0/src/m1_m2_agent/events/models.py +104 -0
- m2_harness-0.6.0/src/m1_m2_agent/events/types.py +43 -0
- m2_harness-0.6.0/src/m1_m2_agent/evidence/__init__.py +18 -0
- m2_harness-0.6.0/src/m1_m2_agent/evidence/collector.py +169 -0
- m2_harness-0.6.0/src/m1_m2_agent/evidence/models.py +97 -0
- m2_harness-0.6.0/src/m1_m2_agent/evidence/scorer.py +125 -0
- m2_harness-0.6.0/src/m1_m2_agent/harness/__init__.py +12 -0
- m2_harness-0.6.0/src/m1_m2_agent/harness/agent_runner.py +218 -0
- m2_harness-0.6.0/src/m1_m2_agent/harness/m2_worker_tool.py +61 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/__init__.py +3 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/budget.py +193 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/controller.py +70 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/events.py +67 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/planner.py +80 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/policy.py +37 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/replay.py +61 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/stop_policy.py +88 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/tool.py +22 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/verifier.py +407 -0
- m2_harness-0.6.0/src/m1_m2_agent/kernel/workspace.py +311 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/__init__.py +15 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/ast_parser.py +243 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/call_graph.py +425 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/git_diff.py +90 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/project.py +171 -0
- m2_harness-0.6.0/src/m1_m2_agent/l0/repo_map.py +197 -0
- m2_harness-0.6.0/src/m1_m2_agent/mcp/__init__.py +1 -0
- m2_harness-0.6.0/src/m1_m2_agent/mcp/server.py +193 -0
- m2_harness-0.6.0/src/m1_m2_agent/pricing/__init__.py +10 -0
- m2_harness-0.6.0/src/m1_m2_agent/pricing/models.py +42 -0
- m2_harness-0.6.0/src/m1_m2_agent/pricing/registry.py +197 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/__init__.py +18 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/base.py +68 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/litellm_provider.py +86 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/registry.py +67 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/replay_provider.py +117 -0
- m2_harness-0.6.0/src/m1_m2_agent/providers/zen_provider.py +117 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/__init__.py +50 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/canonicalize.py +80 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/hashing.py +72 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/loader.py +169 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/migration.py +70 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/recorder.py +239 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/replayer.py +189 -0
- m2_harness-0.6.0/src/m1_m2_agent/replay/schema.py +228 -0
- m2_harness-0.6.0/src/m1_m2_agent/runtime/__init__.py +30 -0
- m2_harness-0.6.0/src/m1_m2_agent/runtime/errors.py +33 -0
- m2_harness-0.6.0/src/m1_m2_agent/runtime/events.py +20 -0
- m2_harness-0.6.0/src/m1_m2_agent/runtime/runtime.py +1395 -0
- m2_harness-0.6.0/src/m1_m2_agent/runtime/state_machine.py +136 -0
- m2_harness-0.6.0/src/m1_m2_agent/scaffold.py +267 -0
- m2_harness-0.6.0/src/m1_m2_agent/security/__init__.py +17 -0
- m2_harness-0.6.0/src/m1_m2_agent/security/policy_engine.py +145 -0
- m2_harness-0.6.0/src/m1_m2_agent/security/redaction.py +68 -0
- m2_harness-0.6.0/src/m1_m2_agent/security/sandbox.py +324 -0
- m2_harness-0.6.0/src/m1_m2_agent/standalone/__init__.py +1 -0
- m2_harness-0.6.0/src/m1_m2_agent/standalone/cli.py +524 -0
- m2_harness-0.6.0/src/m1_m2_agent/standalone/config_wizard.py +242 -0
- m2_harness-0.6.0/src/m1_m2_agent/telemetry/__init__.py +28 -0
- m2_harness-0.6.0/src/m1_m2_agent/telemetry/metrics.py +276 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/__init__.py +24 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/command_tools.py +30 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/dispatcher.py +596 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/file_tools.py +415 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/interceptor.py +103 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/lsp_client.py +100 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/schema_converter.py +93 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/search_tools.py +289 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/spec.py +299 -0
- m2_harness-0.6.0/src/m1_m2_agent/tools/test_lint_tools.py +137 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/PKG-INFO +227 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/SOURCES.txt +167 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/dependency_links.txt +1 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/entry_points.txt +8 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/requires.txt +21 -0
- m2_harness-0.6.0/src/m2_harness.egg-info/top_level.txt +1 -0
- m2_harness-0.6.0/tests/test_antigravity_parity.py +174 -0
- m2_harness-0.6.0/tests/test_benchmark_harness.py +134 -0
- m2_harness-0.6.0/tests/test_call_graph_extraction.py +45 -0
- m2_harness-0.6.0/tests/test_call_graph_incremental.py +38 -0
- m2_harness-0.6.0/tests/test_chatgpt_53_points.py +177 -0
- m2_harness-0.6.0/tests/test_cold_start_budget.py +33 -0
- m2_harness-0.6.0/tests/test_concurrent_cold_init.py +28 -0
- m2_harness-0.6.0/tests/test_contracts.py +85 -0
- m2_harness-0.6.0/tests/test_dashboard_server.py +73 -0
- m2_harness-0.6.0/tests/test_delete_rename_cleanup.py +60 -0
- m2_harness-0.6.0/tests/test_end_to_end.py +38 -0
- m2_harness-0.6.0/tests/test_enhanced_dashboard.py +100 -0
- m2_harness-0.6.0/tests/test_escalation.py +29 -0
- m2_harness-0.6.0/tests/test_external_change_reconciliation.py +48 -0
- m2_harness-0.6.0/tests/test_fault_injection.py +57 -0
- m2_harness-0.6.0/tests/test_full_tool_autonomy.py +33 -0
- m2_harness-0.6.0/tests/test_gate2_verification.py +398 -0
- m2_harness-0.6.0/tests/test_gate3_context_security.py +302 -0
- m2_harness-0.6.0/tests/test_gate4_providers_zen.py +307 -0
- m2_harness-0.6.0/tests/test_gate5_replay_bench.py +350 -0
- m2_harness-0.6.0/tests/test_gate6_production_polish.py +274 -0
- m2_harness-0.6.0/tests/test_gemini_deepseek_claude_reviews.py +120 -0
- m2_harness-0.6.0/tests/test_indexing_guards.py +29 -0
- m2_harness-0.6.0/tests/test_interception_layer.py +39 -0
- m2_harness-0.6.0/tests/test_l0_deterministic.py +39 -0
- m2_harness-0.6.0/tests/test_live_deepseek.py +43 -0
- m2_harness-0.6.0/tests/test_live_streaming_trace.py +122 -0
- m2_harness-0.6.0/tests/test_lsp_client.py +39 -0
- m2_harness-0.6.0/tests/test_m1_m2_agent_package.py +54 -0
- m2_harness-0.6.0/tests/test_m2_runtime.py +126 -0
- m2_harness-0.6.0/tests/test_m2_trace_visibility.py +101 -0
- m2_harness-0.6.0/tests/test_multi_provider.py +212 -0
- m2_harness-0.6.0/tests/test_policy_enforcement.py +37 -0
- m2_harness-0.6.0/tests/test_result_contract_helper.py +47 -0
- m2_harness-0.6.0/tests/test_routing_and_escalation.py +61 -0
- m2_harness-0.6.0/tests/test_schema_converter.py +28 -0
- m2_harness-0.6.0/tests/test_schema_migration.py +25 -0
- m2_harness-0.6.0/tests/test_security_sandbox.py +200 -0
- m2_harness-0.6.0/tests/test_session_manager.py +101 -0
- m2_harness-0.6.0/tests/test_sqlite_wal_concurrency.py +41 -0
- m2_harness-0.6.0/tests/test_subagents.py +63 -0
- m2_harness-0.6.0/tests/test_tdd_diagnostic_loop.py +50 -0
- m2_harness-0.6.0/tests/test_telemetry.py +91 -0
- m2_harness-0.6.0/tests/test_tool_dispatcher.py +136 -0
- m2_harness-0.6.0/tests/test_unsupported_language_fallback.py +25 -0
- m2_harness-0.6.0/tests/test_verifier.py +48 -0
- m2_harness-0.6.0/tests/test_worktree_workspace.py +60 -0
- m2_harness-0.6.0/tests/test_write_contention.py +38 -0
m2_harness-0.6.0/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2024 Hamza
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: m2-harness
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Cost-Aware Hierarchical Coding Agent & Context Firewall — Universal MCP Server, CLI, and Python SDK
|
|
5
|
+
Author-email: Hamza <ameerhamzakhan1305@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/HamzaDevv/hierarchical-coding-agent
|
|
8
|
+
Project-URL: Repository, https://github.com/HamzaDevv/hierarchical-coding-agent
|
|
9
|
+
Project-URL: Documentation, https://github.com/HamzaDevv/hierarchical-coding-agent/tree/main/docs
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/HamzaDevv/hierarchical-coding-agent/issues
|
|
11
|
+
Keywords: ai-agent,mcp,coding-agent,context-firewall,deepseek,hierarchical-agent,model-context-protocol,llm
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: openai>=1.0.0
|
|
27
|
+
Requires-Dist: mcp<2.0.0,>=1.2.0
|
|
28
|
+
Requires-Dist: litellm>=1.30.0
|
|
29
|
+
Requires-Dist: diskcache>=5.6.0
|
|
30
|
+
Requires-Dist: tree-sitter>=0.24.0
|
|
31
|
+
Requires-Dist: tree-sitter-python
|
|
32
|
+
Requires-Dist: tree-sitter-javascript
|
|
33
|
+
Requires-Dist: tree-sitter-typescript
|
|
34
|
+
Requires-Dist: tree-sitter-go
|
|
35
|
+
Requires-Dist: tree-sitter-rust
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
|
|
39
|
+
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: wheel>=0.40.0; extra == "dev"
|
|
41
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
42
|
+
Provides-Extra: providers
|
|
43
|
+
Requires-Dist: anthropic>=0.18.0; extra == "providers"
|
|
44
|
+
Requires-Dist: google-genai>=0.1.0; extra == "providers"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# M2 Harness 🚀 — Cost-Aware Hierarchical Coding Agent & Context Firewall
|
|
48
|
+
|
|
49
|
+
[](https://www.python.org/)
|
|
50
|
+
[](LICENSE)
|
|
51
|
+
[](tests/)
|
|
52
|
+
[](https://modelcontextprotocol.io/)
|
|
53
|
+
|
|
54
|
+
**M2 Harness** is a high-throughput, cost-aware Autonomous Worker and Context Firewall framework. It enables **Frontier Reasoners (M1)** (such as Claude 3.7 Sonnet, Gemini 2.0 Pro, Cursor, or Google Antigravity) to delegate noisy, token-heavy tool loops (searches, test iterations, multi-file refactoring) to a **Cheap Worker (M2)** (DeepSeek V4-Flash, OpenCode Zen, or local models), filtering raw context by **80%–98% (CCR)** before returning verified structured evidence to M1.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 🏛️ Architecture Overview
|
|
59
|
+
|
|
60
|
+
```mermaid
|
|
61
|
+
flowchart TD
|
|
62
|
+
User([User Prompt / M1 Frontier]) --> Router{M1 Orchestrator Router}
|
|
63
|
+
|
|
64
|
+
subgraph Path_A ["Path A: Delegated Worker (85%+ of Tasks)"]
|
|
65
|
+
Router -->|Heavy Search / Multi-file / Test Loop| M2Runtime[M2 Worker Engine]
|
|
66
|
+
M2Runtime --> L0[Zero-Token L0 Layer: AST & Git]
|
|
67
|
+
M2Runtime --> SandboxedTools[Execution Sandbox & Symlink Jail]
|
|
68
|
+
M2Runtime --> ContextFirewall[Context Firewall: 80-98% CCR]
|
|
69
|
+
ContextFirewall --> ResultContract[Structured ResultContract JSON]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
subgraph Path_B ["Path B: Direct Precision Fallback"]
|
|
73
|
+
Router -->|Subtle Race / Exact Bytecode / Review| DirectInspection[Direct Inspection & Precision Edits]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
subgraph Path_C ["Path C: Autonomous Diagnostic Loop"]
|
|
77
|
+
Router -->|Investigate Bug / TDD Repro| DiagnosticLoop[M2 Diagnostic Hypothesis Loop]
|
|
78
|
+
DiagnosticLoop --> TestOracles[Independent Test & AST Oracles]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
ResultContract --> Synthesis[M1 Final Synthesis & User Response]
|
|
82
|
+
DirectInspection --> Synthesis
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 🌟 Key Features
|
|
88
|
+
|
|
89
|
+
1. **Context Firewall & Active Working Memory**: Filters thousands of characters of verbose logs, greps, and test traces down to high-signal structured evidence ($CCR \ge 80\%–98\%$).
|
|
90
|
+
2. **Zero-Token L0 Deterministic Layer**: Instant Python AST outlines, symbol definitions, and git diff summaries consuming **0 LLM tokens**.
|
|
91
|
+
3. **Tri-Modal Execution**:
|
|
92
|
+
* **Path A (Delegated)**: Offloads heavy tool loops to cheap workers.
|
|
93
|
+
* **Path B (Direct)**: Precision fallback for subtle race conditions or exact reviews.
|
|
94
|
+
* **Path C (Diagnostic)**: Autonomous TDD failure reproduction and repair loops.
|
|
95
|
+
4. **Deterministic Tri-Level Replay**: 100% offline, zero-network regression testing across Provider, Runtime, and Semantic ($Hash_A = Hash_B = Hash_C$) layers.
|
|
96
|
+
5. **M2-Bench & Independent Oracles**: Multi-oracle evaluation (`TestOracle`, `ASTOracle`, `FileOracle`, `IntegrityOracle` anti-tampering) with mathematically rigorous metrics (VSR, FSR, Verification Gap, FTAR, ROI).
|
|
97
|
+
6. **Release-Grade Diagnostics (`m2 doctor`)**: Deep environment inspection across Python, Git, Tree-sitter parsers, sandbox jails, and providers.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 📦 Installation
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
pip install m2-harness
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Or install from source:
|
|
108
|
+
```bash
|
|
109
|
+
git clone https://github.com/HamzaDevv/hierarchical-coding-agent.git
|
|
110
|
+
cd hierarchical-coding-agent
|
|
111
|
+
pip install -e .
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🩺 Environment Diagnostics (`m2 doctor`)
|
|
117
|
+
|
|
118
|
+
Verify your environment and workspace health in one command:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
m2 doctor
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
=========================================================================
|
|
126
|
+
🩺 M2 WORKER DIAGNOSTIC HEALTH REPORT (m2 doctor)
|
|
127
|
+
=========================================================================
|
|
128
|
+
[✓ PASS] Python Environment : Python 3.13.3 with all dependencies ready
|
|
129
|
+
[✓ PASS] Git & Workspace : Workspace writable and valid Git repository
|
|
130
|
+
[✓ PASS] L0 AST Engine : L0 zero-token AST parser operational
|
|
131
|
+
[✓ PASS] Security Sandbox : Execution sandbox path jail and env sanitization active
|
|
132
|
+
[✓ PASS] LLM Providers : Providers ready (Replay, Zen, DeepSeek, Gemini)
|
|
133
|
+
[✓ PASS] Deterministic Replay : Deterministic replay fixtures and schema v2.0 verified
|
|
134
|
+
-------------------------------------------------------------------------
|
|
135
|
+
Summary: 6 Passed | 0 Warnings | 0 Failures
|
|
136
|
+
Overall Status: ✅ READY FOR PRODUCTION
|
|
137
|
+
=========================================================================
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Use `--strict` in CI/CD pipelines to fail on any warning:
|
|
141
|
+
```bash
|
|
142
|
+
m2 doctor --strict --json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🚀 Quick Start (CLI)
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Execute one-shot task
|
|
151
|
+
m2 "Find all references to ResultContract and outline their symbols"
|
|
152
|
+
|
|
153
|
+
# Launch instant zero-token AST code outline (0 LLM tokens)
|
|
154
|
+
m2 outline
|
|
155
|
+
|
|
156
|
+
# Launch instant zero-token git diff summary (0 LLM tokens)
|
|
157
|
+
m2 diff
|
|
158
|
+
|
|
159
|
+
# Scaffold cognitive rule files (AGENTS.md, .cursorrules) into project
|
|
160
|
+
m2 init
|
|
161
|
+
|
|
162
|
+
# Launch local Webview HUD live dashboard
|
|
163
|
+
m2 hud --port 4040
|
|
164
|
+
|
|
165
|
+
# Replay an execution trace offline
|
|
166
|
+
m2 replay tests/replay/golden_task --mode semantic
|
|
167
|
+
|
|
168
|
+
# Run benchmark suite
|
|
169
|
+
m2 bench run --suite dev --baselines C
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 🔌 Model Context Protocol (FastMCP) Integration
|
|
175
|
+
|
|
176
|
+
M2 exposes a high-performance FastMCP server for IDEs (Cursor, Windsurf, Claude Desktop, Antigravity):
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"mcpServers": {
|
|
181
|
+
"m2-worker-agent": {
|
|
182
|
+
"command": "m2-mcp-server",
|
|
183
|
+
"env": {
|
|
184
|
+
"DEEPSEEK_API_KEY": "sk-...",
|
|
185
|
+
"WORKSPACE_ROOT": "/path/to/your/project"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 🐍 Python SDK Usage
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from m1_m2_agent import M1OrchestratorAgent, TaskContract
|
|
198
|
+
|
|
199
|
+
# Initialize M1/M2 Hierarchical Agent
|
|
200
|
+
agent = M1OrchestratorAgent(workspace_root=".")
|
|
201
|
+
|
|
202
|
+
# Route and execute task through Context Firewall
|
|
203
|
+
result = agent.route_and_execute(
|
|
204
|
+
objective="Analyze contracts/models.py and verify ResultContract fields"
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
print(f"Status: {result['contract']['status']}")
|
|
208
|
+
print(f"Evidence: {result['contract']['evidence']}")
|
|
209
|
+
print(f"Context Compression: {agent.get_telemetry_report()['context_compression_ratio']}%")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 📊 Documentation Index
|
|
215
|
+
|
|
216
|
+
* 📐 [Architecture Guide](docs/architecture.md)
|
|
217
|
+
* ⚙️ [Runtime & Event Subsystem](docs/runtime.md)
|
|
218
|
+
* 🛡️ [Context Firewall & Memory](docs/context-firewall.md)
|
|
219
|
+
* ⚡ [Deterministic Replay](docs/replay.md)
|
|
220
|
+
* 🧪 [M2-Bench & Multi-Oracle Evaluation](docs/benchmarking.md)
|
|
221
|
+
* 🌐 [Model Providers](docs/providers.md)
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 📄 License
|
|
226
|
+
|
|
227
|
+
Licensed under the [Apache License, Version 2.0](LICENSE).
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# M2 Harness 🚀 — Cost-Aware Hierarchical Coding Agent & Context Firewall
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](tests/)
|
|
6
|
+
[](https://modelcontextprotocol.io/)
|
|
7
|
+
|
|
8
|
+
**M2 Harness** is a high-throughput, cost-aware Autonomous Worker and Context Firewall framework. It enables **Frontier Reasoners (M1)** (such as Claude 3.7 Sonnet, Gemini 2.0 Pro, Cursor, or Google Antigravity) to delegate noisy, token-heavy tool loops (searches, test iterations, multi-file refactoring) to a **Cheap Worker (M2)** (DeepSeek V4-Flash, OpenCode Zen, or local models), filtering raw context by **80%–98% (CCR)** before returning verified structured evidence to M1.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🏛️ Architecture Overview
|
|
13
|
+
|
|
14
|
+
```mermaid
|
|
15
|
+
flowchart TD
|
|
16
|
+
User([User Prompt / M1 Frontier]) --> Router{M1 Orchestrator Router}
|
|
17
|
+
|
|
18
|
+
subgraph Path_A ["Path A: Delegated Worker (85%+ of Tasks)"]
|
|
19
|
+
Router -->|Heavy Search / Multi-file / Test Loop| M2Runtime[M2 Worker Engine]
|
|
20
|
+
M2Runtime --> L0[Zero-Token L0 Layer: AST & Git]
|
|
21
|
+
M2Runtime --> SandboxedTools[Execution Sandbox & Symlink Jail]
|
|
22
|
+
M2Runtime --> ContextFirewall[Context Firewall: 80-98% CCR]
|
|
23
|
+
ContextFirewall --> ResultContract[Structured ResultContract JSON]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
subgraph Path_B ["Path B: Direct Precision Fallback"]
|
|
27
|
+
Router -->|Subtle Race / Exact Bytecode / Review| DirectInspection[Direct Inspection & Precision Edits]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
subgraph Path_C ["Path C: Autonomous Diagnostic Loop"]
|
|
31
|
+
Router -->|Investigate Bug / TDD Repro| DiagnosticLoop[M2 Diagnostic Hypothesis Loop]
|
|
32
|
+
DiagnosticLoop --> TestOracles[Independent Test & AST Oracles]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
ResultContract --> Synthesis[M1 Final Synthesis & User Response]
|
|
36
|
+
DirectInspection --> Synthesis
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🌟 Key Features
|
|
42
|
+
|
|
43
|
+
1. **Context Firewall & Active Working Memory**: Filters thousands of characters of verbose logs, greps, and test traces down to high-signal structured evidence ($CCR \ge 80\%–98\%$).
|
|
44
|
+
2. **Zero-Token L0 Deterministic Layer**: Instant Python AST outlines, symbol definitions, and git diff summaries consuming **0 LLM tokens**.
|
|
45
|
+
3. **Tri-Modal Execution**:
|
|
46
|
+
* **Path A (Delegated)**: Offloads heavy tool loops to cheap workers.
|
|
47
|
+
* **Path B (Direct)**: Precision fallback for subtle race conditions or exact reviews.
|
|
48
|
+
* **Path C (Diagnostic)**: Autonomous TDD failure reproduction and repair loops.
|
|
49
|
+
4. **Deterministic Tri-Level Replay**: 100% offline, zero-network regression testing across Provider, Runtime, and Semantic ($Hash_A = Hash_B = Hash_C$) layers.
|
|
50
|
+
5. **M2-Bench & Independent Oracles**: Multi-oracle evaluation (`TestOracle`, `ASTOracle`, `FileOracle`, `IntegrityOracle` anti-tampering) with mathematically rigorous metrics (VSR, FSR, Verification Gap, FTAR, ROI).
|
|
51
|
+
6. **Release-Grade Diagnostics (`m2 doctor`)**: Deep environment inspection across Python, Git, Tree-sitter parsers, sandbox jails, and providers.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 📦 Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install m2-harness
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or install from source:
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/HamzaDevv/hierarchical-coding-agent.git
|
|
64
|
+
cd hierarchical-coding-agent
|
|
65
|
+
pip install -e .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## 🩺 Environment Diagnostics (`m2 doctor`)
|
|
71
|
+
|
|
72
|
+
Verify your environment and workspace health in one command:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
m2 doctor
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
=========================================================================
|
|
80
|
+
🩺 M2 WORKER DIAGNOSTIC HEALTH REPORT (m2 doctor)
|
|
81
|
+
=========================================================================
|
|
82
|
+
[✓ PASS] Python Environment : Python 3.13.3 with all dependencies ready
|
|
83
|
+
[✓ PASS] Git & Workspace : Workspace writable and valid Git repository
|
|
84
|
+
[✓ PASS] L0 AST Engine : L0 zero-token AST parser operational
|
|
85
|
+
[✓ PASS] Security Sandbox : Execution sandbox path jail and env sanitization active
|
|
86
|
+
[✓ PASS] LLM Providers : Providers ready (Replay, Zen, DeepSeek, Gemini)
|
|
87
|
+
[✓ PASS] Deterministic Replay : Deterministic replay fixtures and schema v2.0 verified
|
|
88
|
+
-------------------------------------------------------------------------
|
|
89
|
+
Summary: 6 Passed | 0 Warnings | 0 Failures
|
|
90
|
+
Overall Status: ✅ READY FOR PRODUCTION
|
|
91
|
+
=========================================================================
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Use `--strict` in CI/CD pipelines to fail on any warning:
|
|
95
|
+
```bash
|
|
96
|
+
m2 doctor --strict --json
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 🚀 Quick Start (CLI)
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Execute one-shot task
|
|
105
|
+
m2 "Find all references to ResultContract and outline their symbols"
|
|
106
|
+
|
|
107
|
+
# Launch instant zero-token AST code outline (0 LLM tokens)
|
|
108
|
+
m2 outline
|
|
109
|
+
|
|
110
|
+
# Launch instant zero-token git diff summary (0 LLM tokens)
|
|
111
|
+
m2 diff
|
|
112
|
+
|
|
113
|
+
# Scaffold cognitive rule files (AGENTS.md, .cursorrules) into project
|
|
114
|
+
m2 init
|
|
115
|
+
|
|
116
|
+
# Launch local Webview HUD live dashboard
|
|
117
|
+
m2 hud --port 4040
|
|
118
|
+
|
|
119
|
+
# Replay an execution trace offline
|
|
120
|
+
m2 replay tests/replay/golden_task --mode semantic
|
|
121
|
+
|
|
122
|
+
# Run benchmark suite
|
|
123
|
+
m2 bench run --suite dev --baselines C
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 🔌 Model Context Protocol (FastMCP) Integration
|
|
129
|
+
|
|
130
|
+
M2 exposes a high-performance FastMCP server for IDEs (Cursor, Windsurf, Claude Desktop, Antigravity):
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"mcpServers": {
|
|
135
|
+
"m2-worker-agent": {
|
|
136
|
+
"command": "m2-mcp-server",
|
|
137
|
+
"env": {
|
|
138
|
+
"DEEPSEEK_API_KEY": "sk-...",
|
|
139
|
+
"WORKSPACE_ROOT": "/path/to/your/project"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 🐍 Python SDK Usage
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from m1_m2_agent import M1OrchestratorAgent, TaskContract
|
|
152
|
+
|
|
153
|
+
# Initialize M1/M2 Hierarchical Agent
|
|
154
|
+
agent = M1OrchestratorAgent(workspace_root=".")
|
|
155
|
+
|
|
156
|
+
# Route and execute task through Context Firewall
|
|
157
|
+
result = agent.route_and_execute(
|
|
158
|
+
objective="Analyze contracts/models.py and verify ResultContract fields"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
print(f"Status: {result['contract']['status']}")
|
|
162
|
+
print(f"Evidence: {result['contract']['evidence']}")
|
|
163
|
+
print(f"Context Compression: {agent.get_telemetry_report()['context_compression_ratio']}%")
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 📊 Documentation Index
|
|
169
|
+
|
|
170
|
+
* 📐 [Architecture Guide](docs/architecture.md)
|
|
171
|
+
* ⚙️ [Runtime & Event Subsystem](docs/runtime.md)
|
|
172
|
+
* 🛡️ [Context Firewall & Memory](docs/context-firewall.md)
|
|
173
|
+
* ⚡ [Deterministic Replay](docs/replay.md)
|
|
174
|
+
* 🧪 [M2-Bench & Multi-Oracle Evaluation](docs/benchmarking.md)
|
|
175
|
+
* 🌐 [Model Providers](docs/providers.md)
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 📄 License
|
|
180
|
+
|
|
181
|
+
Licensed under the [Apache License, Version 2.0](LICENSE).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "m2-harness"
|
|
7
|
+
version = "0.6.0"
|
|
8
|
+
description = "Cost-Aware Hierarchical Coding Agent & Context Firewall — Universal MCP Server, CLI, and Python SDK"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "Apache-2.0"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Hamza", email = "ameerhamzakhan1305@gmail.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"ai-agent",
|
|
17
|
+
"mcp",
|
|
18
|
+
"coding-agent",
|
|
19
|
+
"context-firewall",
|
|
20
|
+
"deepseek",
|
|
21
|
+
"hierarchical-agent",
|
|
22
|
+
"model-context-protocol",
|
|
23
|
+
"llm"
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 5 - Production/Stable",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
30
|
+
"Programming Language :: Python :: 3",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"License :: OSI Approved :: Apache Software License",
|
|
36
|
+
"Operating System :: OS Independent",
|
|
37
|
+
]
|
|
38
|
+
dependencies = [
|
|
39
|
+
"openai>=1.0.0",
|
|
40
|
+
"mcp>=1.2.0,<2.0.0",
|
|
41
|
+
"litellm>=1.30.0",
|
|
42
|
+
"diskcache>=5.6.0",
|
|
43
|
+
"tree-sitter>=0.24.0",
|
|
44
|
+
"tree-sitter-python",
|
|
45
|
+
"tree-sitter-javascript",
|
|
46
|
+
"tree-sitter-typescript",
|
|
47
|
+
"tree-sitter-go",
|
|
48
|
+
"tree-sitter-rust",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[project.optional-dependencies]
|
|
52
|
+
dev = [
|
|
53
|
+
"pytest>=8.0.0",
|
|
54
|
+
"pytest-asyncio>=0.24.0",
|
|
55
|
+
"build>=1.0.0",
|
|
56
|
+
"wheel>=0.40.0",
|
|
57
|
+
"twine>=4.0.0",
|
|
58
|
+
]
|
|
59
|
+
providers = [
|
|
60
|
+
"anthropic>=0.18.0",
|
|
61
|
+
"google-genai>=0.1.0",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[project.urls]
|
|
65
|
+
Homepage = "https://github.com/HamzaDevv/hierarchical-coding-agent"
|
|
66
|
+
Repository = "https://github.com/HamzaDevv/hierarchical-coding-agent"
|
|
67
|
+
Documentation = "https://github.com/HamzaDevv/hierarchical-coding-agent/tree/main/docs"
|
|
68
|
+
"Bug Tracker" = "https://github.com/HamzaDevv/hierarchical-coding-agent/issues"
|
|
69
|
+
|
|
70
|
+
[project.scripts]
|
|
71
|
+
m2 = "m1_m2_agent.standalone.cli:main"
|
|
72
|
+
m1-m2-cli = "m1_m2_agent.standalone.cli:main"
|
|
73
|
+
m2-mcp-server = "m1_m2_agent.mcp.server:main"
|
|
74
|
+
m2-hud = "m1_m2_agent.standalone.cli:hud_main"
|
|
75
|
+
m2-init = "m1_m2_agent.scaffold:main"
|
|
76
|
+
m2-config = "m1_m2_agent.standalone.config_wizard:config_main"
|
|
77
|
+
m2-doctor = "m1_m2_agent.standalone.cli:doctor_main"
|
|
78
|
+
|
|
79
|
+
[tool.setuptools.packages.find]
|
|
80
|
+
where = ["src"]
|
|
81
|
+
include = ["m1_m2_agent*"]
|
|
82
|
+
|
|
83
|
+
[tool.pytest.ini_options]
|
|
84
|
+
pythonpath = ["src", "."]
|
|
85
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""
|
|
2
|
+
M2 Harness — Hierarchical Coding Agent Architecture
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "0.6.0"
|
|
6
|
+
|
|
7
|
+
# Clean top-level exports
|
|
8
|
+
from m1_m2_agent.runtime.runtime import M2Runtime
|
|
9
|
+
from m1_m2_agent.engine.client import M2WorkerEngine
|
|
10
|
+
from m1_m2_agent.engine.config import M2Config
|
|
11
|
+
from m1_m2_agent.tools.dispatcher import ToolDispatcher
|
|
12
|
+
from m1_m2_agent.harness.agent_runner import M1OrchestratorAgent
|
|
13
|
+
from m1_m2_agent.contracts.models import (
|
|
14
|
+
TaskContract,
|
|
15
|
+
ResultContract,
|
|
16
|
+
TaskStatus,
|
|
17
|
+
BudgetSpec,
|
|
18
|
+
VerificationSpec,
|
|
19
|
+
SecuritySpec
|
|
20
|
+
)
|
|
21
|
+
from m1_m2_agent.runtime.state_machine import StateMachine, RuntimeState
|
|
22
|
+
|
|
23
|
+
# GATE 2: Evidence module
|
|
24
|
+
from m1_m2_agent.evidence.models import EvidenceBundle, EvidenceItem, CitationRef
|
|
25
|
+
from m1_m2_agent.evidence.collector import EvidenceCollector
|
|
26
|
+
from m1_m2_agent.evidence.scorer import ConfidenceScorer
|
|
27
|
+
from m1_m2_agent.kernel.budget import BudgetTracker, ContextBudget
|
|
28
|
+
|
|
29
|
+
# GATE 3: Context Firewall V3 & Security
|
|
30
|
+
from m1_m2_agent.engine.working_state import WorkingState, Fact, Hypothesis, Action
|
|
31
|
+
from m1_m2_agent.engine.context_budget import ContextBudgetManager, ContextBudgetSnapshot
|
|
32
|
+
from m1_m2_agent.tools.spec import ToolSpec, ToolCapability, ToolRisk, DEFAULT_TOOL_SPECS
|
|
33
|
+
from m1_m2_agent.security.sandbox import ExecutionSandbox
|
|
34
|
+
from m1_m2_agent.security.policy_engine import PolicyEngine, PolicyDecision, PolicyEvaluationResult
|
|
35
|
+
|
|
36
|
+
# GATE 4: Model-Agnostic Providers & Escalation V2
|
|
37
|
+
from m1_m2_agent.providers.base import ModelProvider, ProviderCapabilities
|
|
38
|
+
from m1_m2_agent.providers.litellm_provider import LiteLLMProvider
|
|
39
|
+
from m1_m2_agent.providers.zen_provider import ZenProvider
|
|
40
|
+
from m1_m2_agent.providers.replay_provider import ReplayProvider
|
|
41
|
+
from m1_m2_agent.providers.registry import ProviderRegistry
|
|
42
|
+
from m1_m2_agent.engine.retry import RetryPolicy
|
|
43
|
+
from m1_m2_agent.escalation.manager import EscalationReason, EscalationManager, EscalationPacket
|
|
44
|
+
|
|
45
|
+
# GATE 5: Deterministic Replay & M2-Bench Suite
|
|
46
|
+
from m1_m2_agent.replay.schema import DeterminismContract, ReplayMode, TraceManifest, ReplayResultReport
|
|
47
|
+
from m1_m2_agent.replay.recorder import TraceRecorder
|
|
48
|
+
from m1_m2_agent.replay.loader import TraceLoader
|
|
49
|
+
from m1_m2_agent.replay.replayer import DeterministicReplayer
|
|
50
|
+
from m1_m2_agent.replay.hashing import compute_canonical_semantic_hash
|
|
51
|
+
from m1_m2_agent.benchmark.models import (
|
|
52
|
+
BenchmarkTask,
|
|
53
|
+
BenchmarkTaskResult,
|
|
54
|
+
BenchmarkOutcome,
|
|
55
|
+
TaskCategory,
|
|
56
|
+
DifficultyTier,
|
|
57
|
+
FailureType,
|
|
58
|
+
)
|
|
59
|
+
from m1_m2_agent.benchmark.evaluator import IndependentBenchmarkEvaluator
|
|
60
|
+
from m1_m2_agent.benchmark.metrics import BenchmarkMetrics, MetricsCalculator
|
|
61
|
+
from m1_m2_agent.benchmark.runner import BenchmarkRunner, BenchmarkSuiteLoader
|
|
62
|
+
|
|
63
|
+
# GATE 6: Production Polish, EventBus V2, Pricing & Diagnostics
|
|
64
|
+
from m1_m2_agent.events.types import RuntimeEventType
|
|
65
|
+
from m1_m2_agent.events.models import EventRecord, RuntimeEvent, redact_secrets
|
|
66
|
+
from m1_m2_agent.events.bus import EventBus, global_event_bus
|
|
67
|
+
from m1_m2_agent.pricing.models import ModelPricing
|
|
68
|
+
from m1_m2_agent.pricing.registry import PricingRegistry
|
|
69
|
+
from m1_m2_agent.doctor.checks import DiagnosticCheckResult
|
|
70
|
+
from m1_m2_agent.doctor.runner import DoctorRunner
|
|
71
|
+
|
|
72
|
+
# Convenient aliases
|
|
73
|
+
M2 = M2WorkerEngine
|
|
74
|
+
Task = TaskContract
|
|
75
|
+
Result = ResultContract
|
|
76
|
+
|
|
77
|
+
__all__ = [
|
|
78
|
+
"M2",
|
|
79
|
+
"M2Runtime",
|
|
80
|
+
"M2WorkerEngine",
|
|
81
|
+
"M1OrchestratorAgent",
|
|
82
|
+
"ToolDispatcher",
|
|
83
|
+
"TaskContract",
|
|
84
|
+
"ResultContract",
|
|
85
|
+
"TaskStatus",
|
|
86
|
+
"BudgetSpec",
|
|
87
|
+
"VerificationSpec",
|
|
88
|
+
"SecuritySpec",
|
|
89
|
+
"StateMachine",
|
|
90
|
+
"RuntimeState",
|
|
91
|
+
"Task",
|
|
92
|
+
"Result",
|
|
93
|
+
"M2Config",
|
|
94
|
+
# GATE 2
|
|
95
|
+
"EvidenceBundle",
|
|
96
|
+
"EvidenceItem",
|
|
97
|
+
"CitationRef",
|
|
98
|
+
"EvidenceCollector",
|
|
99
|
+
"ConfidenceScorer",
|
|
100
|
+
"BudgetTracker",
|
|
101
|
+
"ContextBudget",
|
|
102
|
+
# GATE 3
|
|
103
|
+
"WorkingState",
|
|
104
|
+
"Fact",
|
|
105
|
+
"Hypothesis",
|
|
106
|
+
"Action",
|
|
107
|
+
"ContextBudgetManager",
|
|
108
|
+
"ContextBudgetSnapshot",
|
|
109
|
+
"ToolSpec",
|
|
110
|
+
"ToolCapability",
|
|
111
|
+
"ToolRisk",
|
|
112
|
+
"DEFAULT_TOOL_SPECS",
|
|
113
|
+
"ExecutionSandbox",
|
|
114
|
+
"PolicyEngine",
|
|
115
|
+
"PolicyDecision",
|
|
116
|
+
"PolicyEvaluationResult",
|
|
117
|
+
# GATE 4
|
|
118
|
+
"ModelProvider",
|
|
119
|
+
"ProviderCapabilities",
|
|
120
|
+
"LiteLLMProvider",
|
|
121
|
+
"ZenProvider",
|
|
122
|
+
"ReplayProvider",
|
|
123
|
+
"ProviderRegistry",
|
|
124
|
+
"RetryPolicy",
|
|
125
|
+
"EscalationReason",
|
|
126
|
+
"EscalationManager",
|
|
127
|
+
"EscalationPacket",
|
|
128
|
+
# GATE 5
|
|
129
|
+
"DeterminismContract",
|
|
130
|
+
"ReplayMode",
|
|
131
|
+
"TraceManifest",
|
|
132
|
+
"ReplayResultReport",
|
|
133
|
+
"TraceRecorder",
|
|
134
|
+
"TraceLoader",
|
|
135
|
+
"DeterministicReplayer",
|
|
136
|
+
"compute_canonical_semantic_hash",
|
|
137
|
+
"BenchmarkTask",
|
|
138
|
+
"BenchmarkTaskResult",
|
|
139
|
+
"BenchmarkOutcome",
|
|
140
|
+
"TaskCategory",
|
|
141
|
+
"DifficultyTier",
|
|
142
|
+
"FailureType",
|
|
143
|
+
"IndependentBenchmarkEvaluator",
|
|
144
|
+
"BenchmarkMetrics",
|
|
145
|
+
"MetricsCalculator",
|
|
146
|
+
"BenchmarkRunner",
|
|
147
|
+
"BenchmarkSuiteLoader",
|
|
148
|
+
# GATE 6
|
|
149
|
+
"RuntimeEventType",
|
|
150
|
+
"EventRecord",
|
|
151
|
+
"RuntimeEvent",
|
|
152
|
+
"redact_secrets",
|
|
153
|
+
"EventBus",
|
|
154
|
+
"global_event_bus",
|
|
155
|
+
"ModelPricing",
|
|
156
|
+
"PricingRegistry",
|
|
157
|
+
"DiagnosticCheckResult",
|
|
158
|
+
"DoctorRunner",
|
|
159
|
+
]
|