tzero-mcp 10.7.3 → 11.0.0

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 (127) hide show
  1. package/CHANGELOG.md +44 -577
  2. package/CONTRIBUTING.md +71 -71
  3. package/README.md +64 -64
  4. package/bin/tzero-mcp.js +62 -65
  5. package/bin/tzero.js +61 -64
  6. package/index.d.ts +25 -25
  7. package/index.js +15 -15
  8. package/package.json +88 -67
  9. package/src/addmcp.py +14 -11
  10. package/src/app.py +1810 -0
  11. package/src/main.py +1 -1
  12. package/src/pc_fixer_mcp.py +25 -0
  13. package/src/tzero/__init__.py +54 -0
  14. package/src/tzero/__main__.py +6 -0
  15. package/src/tzero/siber_akademi.ico +0 -0
  16. package/src/tzero/tzero_arch_test.py +463 -0
  17. package/src/{tzero_benchmark.py → tzero/tzero_benchmark.py} +475 -475
  18. package/src/tzero/tzero_blackboard.py +257 -0
  19. package/src/{tzero_bridge.py → tzero/tzero_bridge.py} +546 -362
  20. package/src/tzero/tzero_budget.py +195 -0
  21. package/src/{tzero_ci.py → tzero/tzero_ci.py} +153 -153
  22. package/src/{tzero_commit.py → tzero/tzero_commit.py} +192 -192
  23. package/src/tzero/tzero_contracts.py +1093 -0
  24. package/src/{tzero_cost.py → tzero/tzero_cost.py} +166 -163
  25. package/src/{tzero_dashboard.py → tzero/tzero_dashboard.py} +531 -19
  26. package/src/tzero/tzero_debt.py +461 -0
  27. package/src/{tzero_deps.py → tzero/tzero_deps.py} +179 -4
  28. package/src/{tzero_drift.py → tzero/tzero_drift.py} +208 -208
  29. package/src/{tzero_explain.py → tzero/tzero_explain.py} +73 -7
  30. package/src/{tzero_features.py → tzero/tzero_features.py} +19 -17
  31. package/src/tzero/tzero_federation.py +299 -0
  32. package/src/{tzero_fix.py → tzero/tzero_fix.py} +228 -228
  33. package/src/{tzero_fixer → tzero/tzero_fixer}/__init__.py +63 -63
  34. package/src/{tzero_fixer → tzero/tzero_fixer}/ast_syntax_healer.py +464 -464
  35. package/src/{tzero_fixer → tzero/tzero_fixer}/ast_type_modernizer.py +288 -288
  36. package/src/{tzero_fixer → tzero/tzero_fixer}/async_io_modernizer.py +127 -127
  37. package/src/{tzero_fixer → tzero/tzero_fixer}/automated_regression_suite.py +600 -600
  38. package/src/{tzero_fixer → tzero/tzero_fixer}/benchmarks_and_diagnostics.py +174 -174
  39. package/src/{tzero_fixer → tzero/tzero_fixer}/ci_cd_self_healing_gate.py +246 -246
  40. package/src/{tzero_fixer → tzero/tzero_fixer}/code_duplicity_and_refactorer.py +151 -151
  41. package/src/{tzero_fixer → tzero/tzero_fixer}/code_smells_healer.py +260 -260
  42. package/src/{tzero_fixer → tzero/tzero_fixer}/cwe_remediator.py +171 -171
  43. package/src/{tzero_fixer → tzero/tzero_fixer}/dead_code_eliminator.py +150 -150
  44. package/src/{tzero_fixer → tzero/tzero_fixer}/dependency_vulnerability_auditor.py +309 -309
  45. package/src/{tzero_fixer → tzero/tzero_fixer}/git_advanced_surgeon.py +1 -1
  46. package/src/{tzero_fixer → tzero/tzero_fixer}/hardware_and_disk_doctor.py +1 -1
  47. package/src/{tzero_fixer → tzero/tzero_fixer}/import_graph_healer.py +412 -412
  48. package/src/{tzero_fixer → tzero/tzero_fixer}/interactive_tui.py +91 -91
  49. package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base.py +295 -295
  50. package/src/{tzero_fixer → tzero/tzero_fixer}/knowledge_base_extended.py +940 -940
  51. package/src/{tzero_fixer → tzero/tzero_fixer}/linters_and_static_analyzer.py +307 -307
  52. package/src/{tzero_fixer → tzero/tzero_fixer}/mcp_server.py +49 -7
  53. package/src/{tzero_fixer → tzero/tzero_fixer}/os_doctor.py +502 -502
  54. package/src/{tzero_fixer → tzero/tzero_fixer}/packaging_abi_surgeon.py +1 -1
  55. package/src/{tzero_fixer → tzero/tzero_fixer}/pc_fixer_doctor.py +600 -599
  56. package/src/{tzero_fixer → tzero/tzero_fixer}/performance_and_memory_profiler.py +274 -274
  57. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_ast_parsers.py +313 -313
  58. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_build_healer.py +1 -1
  59. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_config_healer.py +318 -318
  60. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_doctor.py +372 -372
  61. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_linters.py +1 -1
  62. package/src/{tzero_fixer → tzero/tzero_fixer}/polyglot_schema_validator.py +305 -305
  63. package/src/{tzero_fixer → tzero/tzero_fixer}/security_cwe_database.py +444 -444
  64. package/src/{tzero_fixer → tzero/tzero_fixer}/security_deep_rules.py +114 -114
  65. package/src/{tzero_fixer → tzero/tzero_fixer}/security_rules_catalog.py +110 -110
  66. package/src/{tzero_fixer → tzero/tzero_fixer}/security_zero_leak.py +326 -326
  67. package/src/{tzero_fixer → tzero/tzero_fixer}/smart_patch_recommender.py +223 -223
  68. package/src/{tzero_fixer → tzero/tzero_fixer}/synthetic_workspace_generator.py +220 -220
  69. package/src/{tzero_fixer → tzero/tzero_fixer}/system_diagnostics_extended.py +1 -1
  70. package/src/{tzero_fixer → tzero/tzero_fixer}/system_repair_recipes.py +447 -447
  71. package/src/{tzero_fixer → tzero/tzero_fixer}/venv_doctor.py +309 -309
  72. package/src/tzero/tzero_golden.py +319 -0
  73. package/src/tzero/tzero_graph_hud.html +338 -0
  74. package/src/tzero/tzero_graph_rag.py +263 -0
  75. package/src/{tzero_guard.py → tzero/tzero_guard.py} +243 -243
  76. package/src/tzero/tzero_hooks.py +565 -0
  77. package/src/{tzero_infra.py → tzero/tzero_infra.py} +274 -274
  78. package/src/{tzero_jarvis → tzero/tzero_jarvis}/__init__.py +124 -124
  79. package/src/{tzero_jarvis → tzero/tzero_jarvis}/causal_graph.py +310 -310
  80. package/src/{tzero_jarvis → tzero/tzero_jarvis}/graph_visualizer.py +395 -395
  81. package/src/{tzero_jarvis → tzero/tzero_jarvis}/hybrid_search.py +214 -214
  82. package/src/{tzero_jarvis → tzero/tzero_jarvis}/latent_press.py +137 -137
  83. package/src/{tzero_jarvis → tzero/tzero_jarvis}/memory_consolidation.py +212 -212
  84. package/src/{tzero_jarvis → tzero/tzero_jarvis}/minhash_lsh.py +184 -184
  85. package/src/{tzero_jarvis → tzero/tzero_jarvis}/orchestrator.py +335 -335
  86. package/src/{tzero_jarvis → tzero/tzero_jarvis}/self_healing.py +308 -308
  87. package/src/{tzero_jarvis → tzero/tzero_jarvis}/semantic_compressor.py +887 -887
  88. package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm.py +261 -261
  89. package/src/{tzero_jarvis → tzero/tzero_jarvis}/swarm_bft.py +144 -144
  90. package/src/{tzero_jarvis → tzero/tzero_jarvis}/workspace_orchestrator.py +1167 -1167
  91. package/src/{tzero_jarvis → tzero/tzero_jarvis}/zero_key_router.py +173 -173
  92. package/src/tzero/tzero_lsp.py +634 -0
  93. package/src/{tzero_mcp.py → tzero/tzero_mcp.py} +479 -100
  94. package/src/tzero/tzero_mutation.py +358 -0
  95. package/src/tzero/tzero_packer.py +577 -0
  96. package/src/{tzero_patch.py → tzero/tzero_patch.py} +624 -624
  97. package/src/{tzero_pc_fixer.py → tzero/tzero_pc_fixer.py} +12699 -12657
  98. package/src/{tzero_pipe.py → tzero/tzero_pipe.py} +95 -95
  99. package/src/tzero/tzero_polyglot.py +799 -0
  100. package/src/tzero/tzero_proxy.py +127 -0
  101. package/src/{tzero_reachability.py → tzero/tzero_reachability.py} +272 -272
  102. package/src/{tzero_replay.py → tzero/tzero_replay.py} +141 -141
  103. package/src/tzero/tzero_rust_bridge.py +198 -0
  104. package/src/tzero/tzero_scip.py +368 -0
  105. package/src/{tzero_security.py → tzero/tzero_security.py} +5 -2
  106. package/src/tzero/tzero_semantic_merge.py +189 -0
  107. package/src/tzero/tzero_snapshot.py +471 -0
  108. package/src/{tzero_stubs.py → tzero/tzero_stubs.py} +313 -313
  109. package/src/tzero/tzero_subagent_engine.py +459 -0
  110. package/src/{tzero_superdesign.py → tzero/tzero_superdesign.py} +774 -774
  111. package/src/{tzero_sync.py → tzero/tzero_sync.py} +241 -241
  112. package/src/{tzero_task_benchmark.py → tzero/tzero_task_benchmark.py} +458 -363
  113. package/src/{tzero_tui.py → tzero/tzero_tui.py} +91 -22
  114. package/src/tzero/tzero_turbo.py +264 -0
  115. package/src/{tzero_v3.py → tzero/tzero_v3.py} +628 -163
  116. package/src/tzero.py +2 -54
  117. package/test/package.test.js +55 -19
  118. package/src/tzero/jarvis/semantic_compressor.py +0 -373
  119. package/src/tzero_gateway.py +0 -885
  120. package/src/tzero_packer.py +0 -370
  121. package/src/tzero_polyglot.py +0 -422
  122. package/src/tzero_snapshot.py +0 -258
  123. /package/src/{siber_akademi_icon.py → tzero/siber_akademi_icon.py} +0 -0
  124. /package/src/{tzero_fixer → tzero/tzero_fixer}/amalgamation.py +0 -0
  125. /package/src/{tzero_fixer → tzero/tzero_fixer}/models.py +0 -0
  126. /package/src/{tzero_fixer → tzero/tzero_fixer}/orchestrator.py +0 -0
  127. /package/src/{tzero_neural_cortex.py → tzero/tzero_neural_cortex.py} +0 -0
@@ -1,220 +1,220 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- T-Zero Synthetic Workspace Generator & End-to-End Stress Testbed
4
- ===============================================================
5
- Generates fully functional, realistic multi-tier workspaces with deliberate
6
- synthetic defects across all 6 diagnostic categories to verify self-healing,
7
- zero-regression stability, transactional rollback, and performance under load.
8
-
9
- Author: Siber Akademi T-Zero R&D Team
10
- License: MIT (100% Free, Local Offline, Zero-Leak)
11
- """
12
-
13
- from __future__ import annotations
14
-
15
- import os
16
- import shutil
17
- import tempfile
18
- import time
19
- from dataclasses import dataclass, field
20
- from pathlib import Path
21
- from typing import Dict, List, Optional, Tuple, Any
22
-
23
- from tzero_fixer.models import (
24
- DiagnosticCategory,
25
- DiagnosticIssue,
26
- DiagnosticReport,
27
- HealReport,
28
- SeverityLevel,
29
- )
30
- from tzero_fixer.orchestrator import FixerOrchestrator
31
-
32
-
33
- @dataclass
34
- class E2EVerificationReport:
35
- workspace_dir: str
36
- initial_issues_count: int
37
- initial_health_score: float
38
- healed_actions_count: int
39
- remaining_issues_count: int
40
- final_health_score: float
41
- rollback_verified: bool
42
- execution_time_ms: float
43
- passed: bool
44
- details: List[str] = field(default_factory=list)
45
-
46
-
47
- class SyntheticWorkspaceGenerator:
48
- """
49
- Constructs high-fidelity synthetic repositories with deliberate defects for automated verification.
50
- """
51
-
52
- @classmethod
53
- def create_synthetic_workspace(cls, target_dir: Optional[str] = None) -> str:
54
- """
55
- Creates a temporary directory populated with realistic project files containing
56
- deliberate defects across syntax, imports, secrets, configs, and environment.
57
- """
58
- if not target_dir:
59
- temp_root = tempfile.mkdtemp(prefix="tzero_synthetic_")
60
- else:
61
- temp_root = target_dir
62
- os.makedirs(temp_root, exist_ok=True)
63
-
64
- root = Path(temp_root)
65
-
66
- # 1. Python source files with syntax defects
67
- src_dir = root / "src" / "api"
68
- src_dir.mkdir(parents=True, exist_ok=True)
69
-
70
- # Defect 1: Missing colon on def
71
- with open(src_dir / "service.py", "w", encoding="utf-8") as f:
72
- f.write(
73
- "def calculate_total(a: int, b: int)\n"
74
- " return a + b\n\n"
75
- "def process_order(order_id: str):\n"
76
- " print('Processing order:', order_id)\n"
77
- )
78
-
79
- # Defect 2: Legacy Python 2 print and dict.has_key
80
- with open(src_dir / "legacy_handler.py", "w", encoding="utf-8") as f:
81
- f.write(
82
- "def run_legacy(data):\n"
83
- " if data.has_key('auth'):\n"
84
- " print 'Authorized access'\n"
85
- " return True\n"
86
- )
87
-
88
- # Defect 3: Mutable default argument & bare except
89
- with open(src_dir / "models.py", "w", encoding="utf-8") as f:
90
- f.write(
91
- "def append_item(item, items=[]):\n"
92
- " try:\n"
93
- " items.append(item)\n"
94
- " except:\n"
95
- " pass\n"
96
- " return items\n"
97
- )
98
-
99
- # 2. Corrupted JSON file (trailing comma & single quotes)
100
- config_dir = root / "config"
101
- config_dir.mkdir(parents=True, exist_ok=True)
102
- with open(config_dir / "settings.json", "w", encoding="utf-8") as f:
103
- f.write(
104
- "{\n"
105
- " 'app_name': 'T-Zero Enterprise',\n"
106
- " 'debug_mode': true,\n"
107
- " 'port': 8080,\n"
108
- "}\n"
109
- )
110
-
111
- # 3. Corrupted Makefile (spaces instead of TAB)
112
- with open(root / "Makefile", "w", encoding="utf-8") as f:
113
- f.write(
114
- ".PHONY: all build test\n\n"
115
- "all: build\n\n"
116
- "build:\n"
117
- " python -m build\n\n"
118
- "test:\n"
119
- " python -m unittest discover tests\n"
120
- )
121
-
122
- # 4. GitHub Actions CI workflow with deprecated action
123
- workflows_dir = root / ".github" / "workflows"
124
- workflows_dir.mkdir(parents=True, exist_ok=True)
125
- with open(workflows_dir / "ci.yml", "w", encoding="utf-8") as f:
126
- f.write(
127
- "name: CI Pipeline\n"
128
- "on: [push, pull_request]\n"
129
- "jobs:\n"
130
- " build:\n"
131
- " runs-on: ubuntu-latest\n"
132
- " steps:\n"
133
- " - uses: actions/checkout@v2\n"
134
- " - uses: actions/setup-python@v2\n"
135
- " with:\n"
136
- " python-version: '3.11'\n"
137
- " - run: python -m unittest\n"
138
- )
139
-
140
- # 5. Stale git lockfile
141
- git_dir = root / ".git"
142
- git_dir.mkdir(parents=True, exist_ok=True)
143
- lock_file = git_dir / "index.lock"
144
- with open(lock_file, "w", encoding="utf-8") as f:
145
- f.write("mock lockfile")
146
- # Set modification time to 2 hours ago
147
- stale_time = time.time() - 7200
148
- os.utime(lock_file, (stale_time, stale_time))
149
-
150
- # 6. Orphaned bytecode file
151
- cache_dir = src_dir / "__pycache__"
152
- cache_dir.mkdir(parents=True, exist_ok=True)
153
- with open(cache_dir / "orphaned_module.cpython-312.pyc", "wb") as f:
154
- f.write(b"mock bytecode content")
155
-
156
- return str(root)
157
-
158
- @classmethod
159
- def run_e2e_self_healing_verification(cls, workspace_dir: Optional[str] = None) -> E2EVerificationReport:
160
- """
161
- Executes end-to-end diagnosis, auto-healing, re-diagnosis, and atomic rollback verification.
162
- """
163
- start_t = time.time()
164
- temp_dir = cls.create_synthetic_workspace(workspace_dir)
165
- details: List[str] = []
166
-
167
- try:
168
- # Step 1: Initial Diagnosis
169
- initial_report: DiagnosticReport = FixerOrchestrator.diagnose_workspace(temp_dir)
170
- init_count = len(initial_report.issues)
171
- init_score = FixerOrchestrator.calculate_health_score(initial_report.issues)
172
- details.append(f"Initial diagnosis detected {init_count} defects. Health score: {init_score:.1f}%")
173
-
174
- # Step 2: Auto-Heal Execution (with transaction backup)
175
- heal_report: HealReport = FixerOrchestrator.auto_heal(temp_dir, dry_run=False)
176
- healed_count = len([a for a in heal_report.actions if a.success])
177
- details.append(f"Auto-healer executed {healed_count} surgical repairs successfully.")
178
-
179
- # Step 3: Post-Heal Verification
180
- post_report: DiagnosticReport = FixerOrchestrator.diagnose_workspace(temp_dir)
181
- remaining_count = len([i for i in post_report.issues if i.auto_fixable])
182
- final_score = FixerOrchestrator.calculate_health_score(post_report.issues)
183
- details.append(f"Post-heal remaining auto-fixable defects: {remaining_count}. New health score: {final_score:.1f}%")
184
-
185
- # Step 4: Transaction Rollback Verification
186
- rollback_ok = False
187
- if heal_report.transaction_id:
188
- rollback_success = FixerOrchestrator.rollback_transaction(temp_dir, heal_report.transaction_id)
189
- if rollback_success:
190
- rollback_report = FixerOrchestrator.diagnose_workspace(temp_dir)
191
- # Verify issues returned back to pre-heal state
192
- if len(rollback_report.issues) >= init_count - 2:
193
- rollback_ok = True
194
- details.append(f"Atomic rollback verified: files cleanly restored to pre-repair state.")
195
- else:
196
- details.append(f"Rollback partially restored ({len(rollback_report.issues)}/{init_count} defects).")
197
-
198
- elapsed_ms = (time.time() - start_t) * 1000.0
199
- passed = (healed_count > 0 and final_score > init_score and rollback_ok)
200
-
201
- return E2EVerificationReport(
202
- workspace_dir=temp_dir,
203
- initial_issues_count=init_count,
204
- initial_health_score=init_score,
205
- healed_actions_count=healed_count,
206
- remaining_issues_count=remaining_count,
207
- final_health_score=final_score,
208
- rollback_verified=rollback_ok,
209
- execution_time_ms=elapsed_ms,
210
- passed=passed,
211
- details=details,
212
- )
213
-
214
- finally:
215
- if not workspace_dir and os.path.exists(temp_dir):
216
- try:
217
- shutil.rmtree(temp_dir)
218
- except Exception:
219
- pass
220
-
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ T-Zero Synthetic Workspace Generator & End-to-End Stress Testbed
4
+ ===============================================================
5
+ Generates fully functional, realistic multi-tier workspaces with deliberate
6
+ synthetic defects across all 6 diagnostic categories to verify self-healing,
7
+ zero-regression stability, transactional rollback, and performance under load.
8
+
9
+ Author: Siber Akademi T-Zero R&D Team
10
+ License: MIT (100% Free, Local Offline, Zero-Leak)
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ import os
16
+ import shutil
17
+ import tempfile
18
+ import time
19
+ from dataclasses import dataclass, field
20
+ from pathlib import Path
21
+ from typing import Dict, List, Optional, Tuple, Any
22
+
23
+ from tzero.tzero_fixer.models import (
24
+ DiagnosticCategory,
25
+ DiagnosticIssue,
26
+ DiagnosticReport,
27
+ HealReport,
28
+ SeverityLevel,
29
+ )
30
+ from tzero.tzero_fixer.orchestrator import FixerOrchestrator
31
+
32
+
33
+ @dataclass
34
+ class E2EVerificationReport:
35
+ workspace_dir: str
36
+ initial_issues_count: int
37
+ initial_health_score: float
38
+ healed_actions_count: int
39
+ remaining_issues_count: int
40
+ final_health_score: float
41
+ rollback_verified: bool
42
+ execution_time_ms: float
43
+ passed: bool
44
+ details: List[str] = field(default_factory=list)
45
+
46
+
47
+ class SyntheticWorkspaceGenerator:
48
+ """
49
+ Constructs high-fidelity synthetic repositories with deliberate defects for automated verification.
50
+ """
51
+
52
+ @classmethod
53
+ def create_synthetic_workspace(cls, target_dir: Optional[str] = None) -> str:
54
+ """
55
+ Creates a temporary directory populated with realistic project files containing
56
+ deliberate defects across syntax, imports, secrets, configs, and environment.
57
+ """
58
+ if not target_dir:
59
+ temp_root = tempfile.mkdtemp(prefix="tzero_synthetic_")
60
+ else:
61
+ temp_root = target_dir
62
+ os.makedirs(temp_root, exist_ok=True)
63
+
64
+ root = Path(temp_root)
65
+
66
+ # 1. Python source files with syntax defects
67
+ src_dir = root / "src" / "api"
68
+ src_dir.mkdir(parents=True, exist_ok=True)
69
+
70
+ # Defect 1: Missing colon on def
71
+ with open(src_dir / "service.py", "w", encoding="utf-8") as f:
72
+ f.write(
73
+ "def calculate_total(a: int, b: int)\n"
74
+ " return a + b\n\n"
75
+ "def process_order(order_id: str):\n"
76
+ " print('Processing order:', order_id)\n"
77
+ )
78
+
79
+ # Defect 2: Legacy Python 2 print and dict.has_key
80
+ with open(src_dir / "legacy_handler.py", "w", encoding="utf-8") as f:
81
+ f.write(
82
+ "def run_legacy(data):\n"
83
+ " if data.has_key('auth'):\n"
84
+ " print 'Authorized access'\n"
85
+ " return True\n"
86
+ )
87
+
88
+ # Defect 3: Mutable default argument & bare except
89
+ with open(src_dir / "models.py", "w", encoding="utf-8") as f:
90
+ f.write(
91
+ "def append_item(item, items=[]):\n"
92
+ " try:\n"
93
+ " items.append(item)\n"
94
+ " except:\n"
95
+ " pass\n"
96
+ " return items\n"
97
+ )
98
+
99
+ # 2. Corrupted JSON file (trailing comma & single quotes)
100
+ config_dir = root / "config"
101
+ config_dir.mkdir(parents=True, exist_ok=True)
102
+ with open(config_dir / "settings.json", "w", encoding="utf-8") as f:
103
+ f.write(
104
+ "{\n"
105
+ " 'app_name': 'T-Zero Enterprise',\n"
106
+ " 'debug_mode': true,\n"
107
+ " 'port': 8080,\n"
108
+ "}\n"
109
+ )
110
+
111
+ # 3. Corrupted Makefile (spaces instead of TAB)
112
+ with open(root / "Makefile", "w", encoding="utf-8") as f:
113
+ f.write(
114
+ ".PHONY: all build test\n\n"
115
+ "all: build\n\n"
116
+ "build:\n"
117
+ " python -m build\n\n"
118
+ "test:\n"
119
+ " python -m unittest discover tests\n"
120
+ )
121
+
122
+ # 4. GitHub Actions CI workflow with deprecated action
123
+ workflows_dir = root / ".github" / "workflows"
124
+ workflows_dir.mkdir(parents=True, exist_ok=True)
125
+ with open(workflows_dir / "ci.yml", "w", encoding="utf-8") as f:
126
+ f.write(
127
+ "name: CI Pipeline\n"
128
+ "on: [push, pull_request]\n"
129
+ "jobs:\n"
130
+ " build:\n"
131
+ " runs-on: ubuntu-latest\n"
132
+ " steps:\n"
133
+ " - uses: actions/checkout@v2\n"
134
+ " - uses: actions/setup-python@v2\n"
135
+ " with:\n"
136
+ " python-version: '3.11'\n"
137
+ " - run: python -m unittest\n"
138
+ )
139
+
140
+ # 5. Stale git lockfile
141
+ git_dir = root / ".git"
142
+ git_dir.mkdir(parents=True, exist_ok=True)
143
+ lock_file = git_dir / "index.lock"
144
+ with open(lock_file, "w", encoding="utf-8") as f:
145
+ f.write("mock lockfile")
146
+ # Set modification time to 2 hours ago
147
+ stale_time = time.time() - 7200
148
+ os.utime(lock_file, (stale_time, stale_time))
149
+
150
+ # 6. Orphaned bytecode file
151
+ cache_dir = src_dir / "__pycache__"
152
+ cache_dir.mkdir(parents=True, exist_ok=True)
153
+ with open(cache_dir / "orphaned_module.cpython-312.pyc", "wb") as f:
154
+ f.write(b"mock bytecode content")
155
+
156
+ return str(root)
157
+
158
+ @classmethod
159
+ def run_e2e_self_healing_verification(cls, workspace_dir: Optional[str] = None) -> E2EVerificationReport:
160
+ """
161
+ Executes end-to-end diagnosis, auto-healing, re-diagnosis, and atomic rollback verification.
162
+ """
163
+ start_t = time.time()
164
+ temp_dir = cls.create_synthetic_workspace(workspace_dir)
165
+ details: List[str] = []
166
+
167
+ try:
168
+ # Step 1: Initial Diagnosis
169
+ initial_report: DiagnosticReport = FixerOrchestrator.diagnose_workspace(temp_dir)
170
+ init_count = len(initial_report.issues)
171
+ init_score = FixerOrchestrator.calculate_health_score(initial_report.issues)
172
+ details.append(f"Initial diagnosis detected {init_count} defects. Health score: {init_score:.1f}%")
173
+
174
+ # Step 2: Auto-Heal Execution (with transaction backup)
175
+ heal_report: HealReport = FixerOrchestrator.auto_heal(temp_dir, dry_run=False)
176
+ healed_count = len([a for a in heal_report.actions if a.success])
177
+ details.append(f"Auto-healer executed {healed_count} surgical repairs successfully.")
178
+
179
+ # Step 3: Post-Heal Verification
180
+ post_report: DiagnosticReport = FixerOrchestrator.diagnose_workspace(temp_dir)
181
+ remaining_count = len([i for i in post_report.issues if i.auto_fixable])
182
+ final_score = FixerOrchestrator.calculate_health_score(post_report.issues)
183
+ details.append(f"Post-heal remaining auto-fixable defects: {remaining_count}. New health score: {final_score:.1f}%")
184
+
185
+ # Step 4: Transaction Rollback Verification
186
+ rollback_ok = False
187
+ if heal_report.transaction_id:
188
+ rollback_success = FixerOrchestrator.rollback_transaction(temp_dir, heal_report.transaction_id)
189
+ if rollback_success:
190
+ rollback_report = FixerOrchestrator.diagnose_workspace(temp_dir)
191
+ # Verify issues returned back to pre-heal state
192
+ if len(rollback_report.issues) >= init_count - 2:
193
+ rollback_ok = True
194
+ details.append(f"Atomic rollback verified: files cleanly restored to pre-repair state.")
195
+ else:
196
+ details.append(f"Rollback partially restored ({len(rollback_report.issues)}/{init_count} defects).")
197
+
198
+ elapsed_ms = (time.time() - start_t) * 1000.0
199
+ passed = (healed_count > 0 and final_score > init_score and rollback_ok)
200
+
201
+ return E2EVerificationReport(
202
+ workspace_dir=temp_dir,
203
+ initial_issues_count=init_count,
204
+ initial_health_score=init_score,
205
+ healed_actions_count=healed_count,
206
+ remaining_issues_count=remaining_count,
207
+ final_health_score=final_score,
208
+ rollback_verified=rollback_ok,
209
+ execution_time_ms=elapsed_ms,
210
+ passed=passed,
211
+ details=details,
212
+ )
213
+
214
+ finally:
215
+ if not workspace_dir and os.path.exists(temp_dir):
216
+ try:
217
+ shutil.rmtree(temp_dir)
218
+ except Exception:
219
+ pass
220
+
@@ -31,7 +31,7 @@ from typing import Dict, List, Optional, Tuple, Any, Set
31
31
  from dataclasses import dataclass, field
32
32
  from pathlib import Path
33
33
 
34
- from tzero_fixer.models import (
34
+ from tzero.tzero_fixer.models import (
35
35
  DiagnosticCategory,
36
36
  DiagnosticIssue,
37
37