chakra-research 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. chakra_research-0.3.0/LICENSE +21 -0
  2. chakra_research-0.3.0/PKG-INFO +356 -0
  3. chakra_research-0.3.0/README.md +321 -0
  4. chakra_research-0.3.0/pyproject.toml +72 -0
  5. chakra_research-0.3.0/setup.cfg +4 -0
  6. chakra_research-0.3.0/src/chakra/__init__.py +5 -0
  7. chakra_research-0.3.0/src/chakra/__main__.py +5 -0
  8. chakra_research-0.3.0/src/chakra/chakra_cli.py +338 -0
  9. chakra_research-0.3.0/src/chakra/cli.py +159 -0
  10. chakra_research-0.3.0/src/chakra/core/__init__.py +9 -0
  11. chakra_research-0.3.0/src/chakra/core/chakra_logger.py +85 -0
  12. chakra_research-0.3.0/src/chakra/core/domain_registry.py +85 -0
  13. chakra_research-0.3.0/src/chakra/core/interfaces.py +87 -0
  14. chakra_research-0.3.0/src/chakra/core/lifecycle.py +326 -0
  15. chakra_research-0.3.0/src/chakra/core/tracker.py +146 -0
  16. chakra_research-0.3.0/src/chakra/core/utils.py +261 -0
  17. chakra_research-0.3.0/src/chakra/domains/__init__.py +1 -0
  18. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/__init__.py +5 -0
  19. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/dataset.py +291 -0
  20. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/domain.yaml +15 -0
  21. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/evaluate_runner.py +144 -0
  22. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/export_samples.py +30 -0
  23. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/lifecycle.py +267 -0
  24. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/metrics.py +86 -0
  25. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/models.py +146 -0
  26. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/notebook_contract.py +122 -0
  27. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/train_runner.py +161 -0
  28. chakra_research-0.3.0/src/chakra/domains/hndsr_vr/utils.py +21 -0
  29. chakra_research-0.3.0/src/chakra/domains/nlp_lm/__init__.py +5 -0
  30. chakra_research-0.3.0/src/chakra/domains/nlp_lm/dataset.py +121 -0
  31. chakra_research-0.3.0/src/chakra/domains/nlp_lm/domain.yaml +15 -0
  32. chakra_research-0.3.0/src/chakra/domains/nlp_lm/evaluate_runner.py +126 -0
  33. chakra_research-0.3.0/src/chakra/domains/nlp_lm/lifecycle.py +368 -0
  34. chakra_research-0.3.0/src/chakra/domains/nlp_lm/metrics.py +31 -0
  35. chakra_research-0.3.0/src/chakra/domains/nlp_lm/models.py +110 -0
  36. chakra_research-0.3.0/src/chakra/domains/nlp_lm/train_runner.py +170 -0
  37. chakra_research-0.3.0/src/chakra/domains/nlp_lm/utils.py +20 -0
  38. chakra_research-0.3.0/src/chakra/domains/tabular_cls/__init__.py +1 -0
  39. chakra_research-0.3.0/src/chakra/domains/tabular_cls/dataset.py +155 -0
  40. chakra_research-0.3.0/src/chakra/domains/tabular_cls/domain.yaml +15 -0
  41. chakra_research-0.3.0/src/chakra/domains/tabular_cls/evaluate_runner.py +130 -0
  42. chakra_research-0.3.0/src/chakra/domains/tabular_cls/lifecycle.py +310 -0
  43. chakra_research-0.3.0/src/chakra/domains/tabular_cls/metrics.py +32 -0
  44. chakra_research-0.3.0/src/chakra/domains/tabular_cls/models.py +42 -0
  45. chakra_research-0.3.0/src/chakra/domains/tabular_cls/train_runner.py +186 -0
  46. chakra_research-0.3.0/src/chakra/domains/tabular_cls/utils.py +13 -0
  47. chakra_research-0.3.0/src/chakra/hndsr_vr/__init__.py +6 -0
  48. chakra_research-0.3.0/src/chakra/hndsr_vr/dataset.py +9 -0
  49. chakra_research-0.3.0/src/chakra/hndsr_vr/evaluate_runner.py +8 -0
  50. chakra_research-0.3.0/src/chakra/hndsr_vr/export_samples.py +3 -0
  51. chakra_research-0.3.0/src/chakra/hndsr_vr/lifecycle.py +33 -0
  52. chakra_research-0.3.0/src/chakra/hndsr_vr/metrics.py +12 -0
  53. chakra_research-0.3.0/src/chakra/hndsr_vr/models.py +9 -0
  54. chakra_research-0.3.0/src/chakra/hndsr_vr/notebook_contract.py +8 -0
  55. chakra_research-0.3.0/src/chakra/hndsr_vr/tracker.py +3 -0
  56. chakra_research-0.3.0/src/chakra/hndsr_vr/train_runner.py +8 -0
  57. chakra_research-0.3.0/src/chakra/hndsr_vr/utils.py +24 -0
  58. chakra_research-0.3.0/src/chakra_research.egg-info/PKG-INFO +356 -0
  59. chakra_research-0.3.0/src/chakra_research.egg-info/SOURCES.txt +69 -0
  60. chakra_research-0.3.0/src/chakra_research.egg-info/dependency_links.txt +1 -0
  61. chakra_research-0.3.0/src/chakra_research.egg-info/entry_points.txt +2 -0
  62. chakra_research-0.3.0/src/chakra_research.egg-info/requires.txt +11 -0
  63. chakra_research-0.3.0/src/chakra_research.egg-info/top_level.txt +1 -0
  64. chakra_research-0.3.0/tests/test_cli_dispatch.py +45 -0
  65. chakra_research-0.3.0/tests/test_core.py +191 -0
  66. chakra_research-0.3.0/tests/test_domain_registry.py +56 -0
  67. chakra_research-0.3.0/tests/test_lifecycle_review.py +90 -0
  68. chakra_research-0.3.0/tests/test_nlp_domain.py +67 -0
  69. chakra_research-0.3.0/tests/test_notebook_contract.py +25 -0
  70. chakra_research-0.3.0/tests/test_runtime_contract.py +100 -0
  71. chakra_research-0.3.0/tests/test_tabular_domain.py +108 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Harsh Vardhan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: chakra-research
3
+ Version: 0.3.0
4
+ Summary: Chakra — Autonomous Research System. A cyclic, domain-agnostic ML research engine.
5
+ Author: Harsh Vardhan
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System
8
+ Project-URL: Repository, https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System
9
+ Project-URL: Documentation, https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System/blob/main/docs/how_to_use.md
10
+ Project-URL: Issues, https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System/issues
11
+ Keywords: machine-learning,autonomous-research,experiment-tracking,mlops,research-automation,pytorch
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: pillow>=10.0.0
25
+ Requires-Dist: pyyaml>=6.0.0
26
+ Requires-Dist: scikit-image>=0.22.0
27
+ Requires-Dist: scikit-learn>=1.4.0
28
+ Requires-Dist: torch>=2.2.0
29
+ Requires-Dist: torchvision>=0.17.0
30
+ Requires-Dist: tqdm>=4.66.0
31
+ Requires-Dist: wandb>=0.17.0
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ <p align="center">
37
+ <img src="assets/chakra_logo_white.png" alt="Chakra Logo" width="200"/>
38
+ </p>
39
+
40
+ # Chakra — Autonomous Research System
41
+
42
+ [![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
43
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10+-green.svg)](https://python.org)
44
+ [![PyTorch 2.2+](https://img.shields.io/badge/PyTorch-2.2+-ee4c2c.svg)](https://pytorch.org)
45
+ [![W&B Tracking](https://img.shields.io/badge/W%26B-Tracked-orange.svg)](https://wandb.ai)
46
+ [![47 Tests Passed](https://img.shields.io/badge/Tests-47%20Passed-brightgreen.svg)](#testing)
47
+ [![3 Domains](https://img.shields.io/badge/Domains-3%20Shipped-purple.svg)](#shipped-domains)
48
+
49
+ **A cyclic, autonomous research engine that plans, trains, guards, reviews, and improves ML experiments — then repeats.**
50
+
51
+ Chakra eliminates manual experiment management. You define a research domain once. Chakra handles the rest: scaffolding configs, running baselines, training models, evaluating checkpoints, validating contracts, generating reviews, and proposing the next iteration. One command runs the entire loop.
52
+
53
+ > 📖 **[Read the Journey](JOURNEY.md)** — How this project evolved from a single Kaggle notebook to a cyclic autonomous system.
54
+
55
+ ```bash
56
+ chakra aavart --domain tabular_cls --version v1.0 --device cpu --force
57
+ ```
58
+
59
+ This single command executes the full research cycle — from creating the experiment plan to proposing improvements for v1.1.
60
+
61
+ ---
62
+
63
+ ## The Cycle
64
+
65
+ Every experiment in Chakra follows a five-stage loop:
66
+
67
+ ```
68
+ ┌──────────────────────────────────────────┐
69
+ │ │
70
+ ▼ │
71
+ Plan ──→ Execute ──→ Guard ──→ Review ──→ Improve
72
+ │ │
73
+ └──────────────────────────────────────────┘
74
+ ```
75
+
76
+ | # | Stage | What Happens |
77
+ |---|-------|-------------|
78
+ | 1 | **Plan** | Scaffold version assets. Freeze configs. Define the hypothesis. |
79
+ | 2 | **Execute** | Train control baseline → smoke test → full training → evaluate. |
80
+ | 3 | **Guard** | Validate that all required files and contracts are satisfied. |
81
+ | 4 | **Review** | Sync results. Generate metric deltas. Produce a structured roast. |
82
+ | 5 | **Improve** | Analyze findings. Propose bounded ablation suggestions for next version. |
83
+
84
+ When the cycle completes, the system either **freezes** the version (if results are good) or **forks** a new version with proposed improvements. Then the cycle repeats.
85
+
86
+ ### Chakra Identity
87
+
88
+ Each stage has a Sanskrit name that reflects its purpose:
89
+
90
+ | Chakra Term | Meaning | Stage |
91
+ |-------------|---------|-------|
92
+ | **Sutra** (सूत्र) | Thread / Formula | Plan |
93
+ | **Yantra** (यन्त्र) | Instrument / Machine | Execute |
94
+ | **Rakshak** (रक्षक) | Guardian | Guard |
95
+ | **Vimarsh** (विमर्श) | Reflection / Analysis | Review |
96
+ | **Manthan** (मन्थन) | Churning (of the ocean) | Improve |
97
+ | **Aavart** (आवर्त) | Cycle / Revolution | Full Loop |
98
+
99
+ > *Chakra* (चक्र) means *wheel* — the cycle that never stops turning.
100
+
101
+ ---
102
+
103
+ ## Shipped Domains & Real Results
104
+
105
+ | Domain | Task | Metric | Control Baseline | Trained Model | Δ |
106
+ |--------|------|--------|-----------------|--------------|---|
107
+ | **`hndsr_vr`** | Satellite super-resolution | PSNR ↑ | Bicubic baseline | SR3 diffusion | — |
108
+ | **`nlp_lm`** | Character-level language model | BPB ↓ | Bigram: **6.38** | GPT-nano: **3.59** | **44% ↓** |
109
+ | **`tabular_cls`** (Iris) | Flower classification | Accuracy ↑ | Logistic: **16.7%** | MLP: **93.3%** | **+76.7pp** |
110
+ | **`tabular_cls`** (Titanic) | Survival prediction | Accuracy ↑ | Logistic: **58.3%** | MLP: **83.6%** | **+25.3pp** |
111
+
112
+ > All results above are real, measured outputs from runs executed during development — not estimates.
113
+
114
+ ---
115
+
116
+ ## Quick Start
117
+
118
+ > 📖 **For the full guide** see [How to Use Chakra](docs/how_to_use.md) — covers every command, config option, W&B setup, troubleshooting, and how to add your own domain. For a 5-minute walkthrough, see the [Quickstart](docs/quickstart.md). For the project's evolution story, see the [Journey](JOURNEY.md).
119
+
120
+ ### 1. Install
121
+
122
+ ```bash
123
+ git clone https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System.git
124
+ cd Chakra-Autonomous-Research-System
125
+ python -m venv .venv && .venv/Scripts/activate # Windows
126
+ pip install -e ".[dev]"
127
+ ```
128
+
129
+ ### 2. Run the Full Cycle (One Command)
130
+
131
+ ```bash
132
+ chakra aavart --domain tabular_cls --version v1.0 --device cpu --force
133
+ ```
134
+
135
+ This runs the complete Aavart (Full Cycle):
136
+
137
+ ```
138
+ 🔁 [Chakra] Starting Aavart (Full Cycle) — tabular_cls v1.0
139
+ 📜 Sutra (Plan): Scaffolding version assets...
140
+ 📜 Sutra (Plan): ✓ Configs frozen
141
+ ⚙️ Yantra (Execute): Running control baseline...
142
+ ⚙️ Yantra (Execute): ✓ Control baseline complete
143
+ ⚙️ Yantra (Execute): Running smoke test...
144
+ ⚙️ Yantra (Execute): ✓ Smoke test complete
145
+ ⚙️ Yantra (Execute): Running full training...
146
+ ⚙️ Yantra (Execute): ✓ Training complete
147
+ ⚙️ Yantra (Execute): Evaluating best checkpoint...
148
+ ⚙️ Yantra (Execute): ✓ Evaluation complete
149
+ 🔍 Vimarsh (Review): Syncing results...
150
+ 🔍 Vimarsh (Review): ✓ Review written
151
+ 🛡️ Rakshak (Guard): Validating version contract...
152
+ 🛡️ Rakshak (Guard): ✓ Contract passed
153
+ 🔄 Manthan (Improve): Generating ablation suggestions...
154
+ 🔄 Manthan (Improve): ✓ Ablations proposed
155
+ ✅ [Chakra] Aavart complete — tabular_cls v1.0. Decision: freeze and fork next version.
156
+ ```
157
+
158
+ ### 3. Or Use Individual Stages
159
+
160
+ ```bash
161
+ # Plan
162
+ chakra sutra --domain tabular_cls --version v1.0 --force
163
+
164
+ # Execute
165
+ chakra yantra --domain tabular_cls --version v1.0 --stage train --device cpu
166
+
167
+ # Guard
168
+ chakra rakshak --domain tabular_cls --version v1.0
169
+
170
+ # Review
171
+ chakra vimarsh --domain tabular_cls --version v1.0
172
+
173
+ # Improve
174
+ chakra manthan --domain tabular_cls --version v1.0
175
+ ```
176
+
177
+ ### 4. Traditional CLI (Still Works)
178
+
179
+ All original commands remain available through `python -m chakra`:
180
+
181
+ ```bash
182
+ python -m chakra list-domains
183
+ python -m chakra --domain tabular_cls scaffold-version --version v1.0 --force
184
+ python -m chakra --domain tabular_cls validate-version --version v1.0
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Architecture
190
+
191
+ ```
192
+ chakra/
193
+ ├── core/ # Domain-agnostic engine (Chakra kernel)
194
+ │ ├── interfaces.py # DomainLifecycleHooks protocol
195
+ │ ├── domain_registry.py # Auto-discovers domains from domain.yaml
196
+ │ ├── lifecycle.py # Generic scaffold → sync → review → promote
197
+ │ ├── chakra_logger.py # Structured stage-aware logging
198
+ │ ├── tracker.py # W&B tracker + NullTracker fallback
199
+ │ └── utils.py # Config loading, seeding, path helpers
200
+
201
+ ├── domains/ # Each domain is a self-contained plugin
202
+ │ ├── hndsr_vr/ # Satellite image super-resolution
203
+ │ ├── nlp_lm/ # Character-level language model
204
+ │ └── tabular_cls/ # Tabular classification (Iris, Titanic)
205
+
206
+ ├── cli.py # Traditional CLI (python -m chakra)
207
+ └── chakra_cli.py # Chakra CLI (chakra sutra/yantra/...)
208
+ ```
209
+
210
+ ### Chakra ↔ System Mapping
211
+
212
+ | Subsystem | Chakra Role | Code |
213
+ |-----------|-------------|------|
214
+ | `core/lifecycle.py` | Orchestrates the cycle | `scaffold_version`, `sync_run`, `review_run` |
215
+ | `core/chakra_logger.py` | Emits stage-aware logs | `ChakraLogger` |
216
+ | `core/tracker.py` | Records telemetry | `WandbTracker`, `NullTracker` |
217
+ | `core/domain_registry.py` | Discovers research lanes | `discover_domains()` |
218
+ | `core/interfaces.py` | Defines the domain contract | `DomainLifecycleHooks` |
219
+ | `domains/*/train_runner.py` | Yantra (Execute) — training | Per-domain subprocess |
220
+ | `domains/*/evaluate_runner.py` | Yantra (Execute) — evaluation | Per-domain subprocess |
221
+ | `chakra_cli.py` | Entry point for the Chakra interface | `run_aavart()` |
222
+
223
+ ---
224
+
225
+ ## CLI Reference
226
+
227
+ ### Chakra Commands
228
+
229
+ | Command | Stage | Description |
230
+ |---------|-------|-------------|
231
+ | `chakra sutra` | Plan | Create and freeze experiment plan (scaffold assets + configs) |
232
+ | `chakra yantra` | Execute | Run training or evaluation (`--stage control\|smoke\|train\|eval`) |
233
+ | `chakra rakshak` | Guard | Validate that all version files and contracts exist |
234
+ | `chakra vimarsh` | Review | Sync training results and generate structured review |
235
+ | `chakra manthan` | Improve | Propose bounded ablation suggestions for next iteration |
236
+ | `chakra aavart` | Full Cycle | Run the complete Plan → Execute → Guard → Review → Improve loop |
237
+ | `chakra list-domains` | Discovery | List all auto-discovered research domains |
238
+
239
+ ### Traditional Commands
240
+
241
+ | Command | Description |
242
+ |---------|-------------|
243
+ | `python -m chakra list-domains` | List all domains |
244
+ | `python -m chakra --domain D scaffold-version --version V` | Scaffold version assets |
245
+ | `python -m chakra --domain D validate-version --version V` | Validate version contract |
246
+ | `python -m chakra --domain D sync-run --version V` | Index results into manifest |
247
+ | `python -m chakra --domain D review-run --version V` | Generate review and roast |
248
+ | `python -m chakra --domain D next-ablation --version V` | Write ablation suggestions |
249
+ | `python -m chakra --domain D push-kaggle --version V` | Push notebook to Kaggle |
250
+ | `python -m chakra --domain D pull-kaggle --version V` | Pull Kaggle outputs |
251
+
252
+ ---
253
+
254
+ ## W&B Experiment Tracking
255
+
256
+ ```bash
257
+ # Create .env in repo root
258
+ echo WANDB_API_KEY=your_key_here > .env
259
+ ```
260
+
261
+ When a key is present, all runners stream metrics to W&B automatically. Without it, everything still works — metrics save to local JSON via `NullTracker`.
262
+
263
+ ---
264
+
265
+ ## Configuration System
266
+
267
+ Configs use YAML with an `inherits:` key for layered configuration:
268
+
269
+ ```yaml
270
+ # configs/tabular_cls/v1.0_train.yaml
271
+ inherits: configs/tabular_cls/base.yaml
272
+
273
+ project:
274
+ group: v1.0-train
275
+
276
+ training:
277
+ epochs: 30
278
+ checkpoint_name: v1.0_train_best.pt
279
+ ```
280
+
281
+ Each version always has three config variants:
282
+
283
+ | Variant | Purpose |
284
+ |---------|---------|
285
+ | `*_control.yaml` | Baseline model (establishes the floor) |
286
+ | `*_smoke.yaml` | Quick pipeline sanity check (3 epochs, 5 batches) |
287
+ | `*_train.yaml` | Full training run |
288
+
289
+ ---
290
+
291
+ ## Adding a New Domain
292
+
293
+ Chakra is designed for zero-code-change domain addition:
294
+
295
+ ```
296
+ src/chakra/domains/my_domain/
297
+ ├── __init__.py
298
+ ├── domain.yaml # Domain manifest (name, metrics, entrypoints)
299
+ ├── lifecycle.py # Implements DomainLifecycleHooks protocol
300
+ ├── models.py # Domain-specific models
301
+ ├── dataset.py # Data loading and preprocessing
302
+ ├── metrics.py # Evaluation metrics
303
+ ├── train_runner.py # Training script with W&B tracking
304
+ └── evaluate_runner.py # Evaluation script with W&B tracking
305
+ ```
306
+
307
+ Register in `pyproject.toml`:
308
+
309
+ ```toml
310
+ "chakra.domains.my_domain" = ["domain.yaml"]
311
+ ```
312
+
313
+ Then:
314
+
315
+ ```bash
316
+ chakra list-domains # Your domain appears automatically
317
+ chakra aavart --domain my_domain --version v1.0 --device cpu
318
+ ```
319
+
320
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full tutorial.
321
+
322
+ ---
323
+
324
+ ## Testing
325
+
326
+ ```bash
327
+ python -m pytest tests/ -v
328
+ ```
329
+
330
+ 47 tests across all domains and core infrastructure:
331
+
332
+ | Suite | Tests | Coverage |
333
+ |-------|-------|----------|
334
+ | `test_core.py` | 16 | Config, utils, seeding, registry |
335
+ | `test_tabular_domain.py` | 9 | Discovery, protocol, models, dataset, metrics |
336
+ | `test_nlp_domain.py` | 6 | GPT-nano, bigram, dataset, metrics |
337
+ | `test_domain_registry.py` | 5 | Multi-domain discovery, manifests |
338
+ | `test_runtime_contract.py` | 6 | Path resolution, workspace isolation |
339
+ | `test_cli_dispatch.py` | 3 | CLI argument parsing |
340
+ | `test_lifecycle_review.py` | 1 | Full sync → review pipeline |
341
+ | `test_notebook_contract.py` | 1 | Notebook JSON structure |
342
+
343
+ ---
344
+
345
+ ## Inspirations
346
+
347
+ - **Chakra** (चक्र) — The wheel that represents cyclical, self-sustaining motion
348
+ - **[Sakana AI's AI Scientist](https://github.com/sakanaai/ai-scientist)** — Automated scientific discovery
349
+ - **[AutoKaggle](https://github.com/multimodal-art-projection/AutoKaggle)** — Multi-agent Kaggle orchestration
350
+ - **[W&B Experiment Tracking](https://wandb.ai/)** — MLOps telemetry backbone
351
+
352
+ ---
353
+
354
+ ## License
355
+
356
+ [MIT](LICENSE) — Use it, fork it, extend it.
@@ -0,0 +1,321 @@
1
+ <p align="center">
2
+ <img src="assets/chakra_logo_white.png" alt="Chakra Logo" width="200"/>
3
+ </p>
4
+
5
+ # Chakra — Autonomous Research System
6
+
7
+ [![MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+ [![Python 3.10+](https://img.shields.io/badge/Python-3.10+-green.svg)](https://python.org)
9
+ [![PyTorch 2.2+](https://img.shields.io/badge/PyTorch-2.2+-ee4c2c.svg)](https://pytorch.org)
10
+ [![W&B Tracking](https://img.shields.io/badge/W%26B-Tracked-orange.svg)](https://wandb.ai)
11
+ [![47 Tests Passed](https://img.shields.io/badge/Tests-47%20Passed-brightgreen.svg)](#testing)
12
+ [![3 Domains](https://img.shields.io/badge/Domains-3%20Shipped-purple.svg)](#shipped-domains)
13
+
14
+ **A cyclic, autonomous research engine that plans, trains, guards, reviews, and improves ML experiments — then repeats.**
15
+
16
+ Chakra eliminates manual experiment management. You define a research domain once. Chakra handles the rest: scaffolding configs, running baselines, training models, evaluating checkpoints, validating contracts, generating reviews, and proposing the next iteration. One command runs the entire loop.
17
+
18
+ > 📖 **[Read the Journey](JOURNEY.md)** — How this project evolved from a single Kaggle notebook to a cyclic autonomous system.
19
+
20
+ ```bash
21
+ chakra aavart --domain tabular_cls --version v1.0 --device cpu --force
22
+ ```
23
+
24
+ This single command executes the full research cycle — from creating the experiment plan to proposing improvements for v1.1.
25
+
26
+ ---
27
+
28
+ ## The Cycle
29
+
30
+ Every experiment in Chakra follows a five-stage loop:
31
+
32
+ ```
33
+ ┌──────────────────────────────────────────┐
34
+ │ │
35
+ ▼ │
36
+ Plan ──→ Execute ──→ Guard ──→ Review ──→ Improve
37
+ │ │
38
+ └──────────────────────────────────────────┘
39
+ ```
40
+
41
+ | # | Stage | What Happens |
42
+ |---|-------|-------------|
43
+ | 1 | **Plan** | Scaffold version assets. Freeze configs. Define the hypothesis. |
44
+ | 2 | **Execute** | Train control baseline → smoke test → full training → evaluate. |
45
+ | 3 | **Guard** | Validate that all required files and contracts are satisfied. |
46
+ | 4 | **Review** | Sync results. Generate metric deltas. Produce a structured roast. |
47
+ | 5 | **Improve** | Analyze findings. Propose bounded ablation suggestions for next version. |
48
+
49
+ When the cycle completes, the system either **freezes** the version (if results are good) or **forks** a new version with proposed improvements. Then the cycle repeats.
50
+
51
+ ### Chakra Identity
52
+
53
+ Each stage has a Sanskrit name that reflects its purpose:
54
+
55
+ | Chakra Term | Meaning | Stage |
56
+ |-------------|---------|-------|
57
+ | **Sutra** (सूत्र) | Thread / Formula | Plan |
58
+ | **Yantra** (यन्त्र) | Instrument / Machine | Execute |
59
+ | **Rakshak** (रक्षक) | Guardian | Guard |
60
+ | **Vimarsh** (विमर्श) | Reflection / Analysis | Review |
61
+ | **Manthan** (मन्थन) | Churning (of the ocean) | Improve |
62
+ | **Aavart** (आवर्त) | Cycle / Revolution | Full Loop |
63
+
64
+ > *Chakra* (चक्र) means *wheel* — the cycle that never stops turning.
65
+
66
+ ---
67
+
68
+ ## Shipped Domains & Real Results
69
+
70
+ | Domain | Task | Metric | Control Baseline | Trained Model | Δ |
71
+ |--------|------|--------|-----------------|--------------|---|
72
+ | **`hndsr_vr`** | Satellite super-resolution | PSNR ↑ | Bicubic baseline | SR3 diffusion | — |
73
+ | **`nlp_lm`** | Character-level language model | BPB ↓ | Bigram: **6.38** | GPT-nano: **3.59** | **44% ↓** |
74
+ | **`tabular_cls`** (Iris) | Flower classification | Accuracy ↑ | Logistic: **16.7%** | MLP: **93.3%** | **+76.7pp** |
75
+ | **`tabular_cls`** (Titanic) | Survival prediction | Accuracy ↑ | Logistic: **58.3%** | MLP: **83.6%** | **+25.3pp** |
76
+
77
+ > All results above are real, measured outputs from runs executed during development — not estimates.
78
+
79
+ ---
80
+
81
+ ## Quick Start
82
+
83
+ > 📖 **For the full guide** see [How to Use Chakra](docs/how_to_use.md) — covers every command, config option, W&B setup, troubleshooting, and how to add your own domain. For a 5-minute walkthrough, see the [Quickstart](docs/quickstart.md). For the project's evolution story, see the [Journey](JOURNEY.md).
84
+
85
+ ### 1. Install
86
+
87
+ ```bash
88
+ git clone https://github.com/The-Harsh-Vardhan/Chakra-Autonomous-Research-System.git
89
+ cd Chakra-Autonomous-Research-System
90
+ python -m venv .venv && .venv/Scripts/activate # Windows
91
+ pip install -e ".[dev]"
92
+ ```
93
+
94
+ ### 2. Run the Full Cycle (One Command)
95
+
96
+ ```bash
97
+ chakra aavart --domain tabular_cls --version v1.0 --device cpu --force
98
+ ```
99
+
100
+ This runs the complete Aavart (Full Cycle):
101
+
102
+ ```
103
+ 🔁 [Chakra] Starting Aavart (Full Cycle) — tabular_cls v1.0
104
+ 📜 Sutra (Plan): Scaffolding version assets...
105
+ 📜 Sutra (Plan): ✓ Configs frozen
106
+ ⚙️ Yantra (Execute): Running control baseline...
107
+ ⚙️ Yantra (Execute): ✓ Control baseline complete
108
+ ⚙️ Yantra (Execute): Running smoke test...
109
+ ⚙️ Yantra (Execute): ✓ Smoke test complete
110
+ ⚙️ Yantra (Execute): Running full training...
111
+ ⚙️ Yantra (Execute): ✓ Training complete
112
+ ⚙️ Yantra (Execute): Evaluating best checkpoint...
113
+ ⚙️ Yantra (Execute): ✓ Evaluation complete
114
+ 🔍 Vimarsh (Review): Syncing results...
115
+ 🔍 Vimarsh (Review): ✓ Review written
116
+ 🛡️ Rakshak (Guard): Validating version contract...
117
+ 🛡️ Rakshak (Guard): ✓ Contract passed
118
+ 🔄 Manthan (Improve): Generating ablation suggestions...
119
+ 🔄 Manthan (Improve): ✓ Ablations proposed
120
+ ✅ [Chakra] Aavart complete — tabular_cls v1.0. Decision: freeze and fork next version.
121
+ ```
122
+
123
+ ### 3. Or Use Individual Stages
124
+
125
+ ```bash
126
+ # Plan
127
+ chakra sutra --domain tabular_cls --version v1.0 --force
128
+
129
+ # Execute
130
+ chakra yantra --domain tabular_cls --version v1.0 --stage train --device cpu
131
+
132
+ # Guard
133
+ chakra rakshak --domain tabular_cls --version v1.0
134
+
135
+ # Review
136
+ chakra vimarsh --domain tabular_cls --version v1.0
137
+
138
+ # Improve
139
+ chakra manthan --domain tabular_cls --version v1.0
140
+ ```
141
+
142
+ ### 4. Traditional CLI (Still Works)
143
+
144
+ All original commands remain available through `python -m chakra`:
145
+
146
+ ```bash
147
+ python -m chakra list-domains
148
+ python -m chakra --domain tabular_cls scaffold-version --version v1.0 --force
149
+ python -m chakra --domain tabular_cls validate-version --version v1.0
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Architecture
155
+
156
+ ```
157
+ chakra/
158
+ ├── core/ # Domain-agnostic engine (Chakra kernel)
159
+ │ ├── interfaces.py # DomainLifecycleHooks protocol
160
+ │ ├── domain_registry.py # Auto-discovers domains from domain.yaml
161
+ │ ├── lifecycle.py # Generic scaffold → sync → review → promote
162
+ │ ├── chakra_logger.py # Structured stage-aware logging
163
+ │ ├── tracker.py # W&B tracker + NullTracker fallback
164
+ │ └── utils.py # Config loading, seeding, path helpers
165
+
166
+ ├── domains/ # Each domain is a self-contained plugin
167
+ │ ├── hndsr_vr/ # Satellite image super-resolution
168
+ │ ├── nlp_lm/ # Character-level language model
169
+ │ └── tabular_cls/ # Tabular classification (Iris, Titanic)
170
+
171
+ ├── cli.py # Traditional CLI (python -m chakra)
172
+ └── chakra_cli.py # Chakra CLI (chakra sutra/yantra/...)
173
+ ```
174
+
175
+ ### Chakra ↔ System Mapping
176
+
177
+ | Subsystem | Chakra Role | Code |
178
+ |-----------|-------------|------|
179
+ | `core/lifecycle.py` | Orchestrates the cycle | `scaffold_version`, `sync_run`, `review_run` |
180
+ | `core/chakra_logger.py` | Emits stage-aware logs | `ChakraLogger` |
181
+ | `core/tracker.py` | Records telemetry | `WandbTracker`, `NullTracker` |
182
+ | `core/domain_registry.py` | Discovers research lanes | `discover_domains()` |
183
+ | `core/interfaces.py` | Defines the domain contract | `DomainLifecycleHooks` |
184
+ | `domains/*/train_runner.py` | Yantra (Execute) — training | Per-domain subprocess |
185
+ | `domains/*/evaluate_runner.py` | Yantra (Execute) — evaluation | Per-domain subprocess |
186
+ | `chakra_cli.py` | Entry point for the Chakra interface | `run_aavart()` |
187
+
188
+ ---
189
+
190
+ ## CLI Reference
191
+
192
+ ### Chakra Commands
193
+
194
+ | Command | Stage | Description |
195
+ |---------|-------|-------------|
196
+ | `chakra sutra` | Plan | Create and freeze experiment plan (scaffold assets + configs) |
197
+ | `chakra yantra` | Execute | Run training or evaluation (`--stage control\|smoke\|train\|eval`) |
198
+ | `chakra rakshak` | Guard | Validate that all version files and contracts exist |
199
+ | `chakra vimarsh` | Review | Sync training results and generate structured review |
200
+ | `chakra manthan` | Improve | Propose bounded ablation suggestions for next iteration |
201
+ | `chakra aavart` | Full Cycle | Run the complete Plan → Execute → Guard → Review → Improve loop |
202
+ | `chakra list-domains` | Discovery | List all auto-discovered research domains |
203
+
204
+ ### Traditional Commands
205
+
206
+ | Command | Description |
207
+ |---------|-------------|
208
+ | `python -m chakra list-domains` | List all domains |
209
+ | `python -m chakra --domain D scaffold-version --version V` | Scaffold version assets |
210
+ | `python -m chakra --domain D validate-version --version V` | Validate version contract |
211
+ | `python -m chakra --domain D sync-run --version V` | Index results into manifest |
212
+ | `python -m chakra --domain D review-run --version V` | Generate review and roast |
213
+ | `python -m chakra --domain D next-ablation --version V` | Write ablation suggestions |
214
+ | `python -m chakra --domain D push-kaggle --version V` | Push notebook to Kaggle |
215
+ | `python -m chakra --domain D pull-kaggle --version V` | Pull Kaggle outputs |
216
+
217
+ ---
218
+
219
+ ## W&B Experiment Tracking
220
+
221
+ ```bash
222
+ # Create .env in repo root
223
+ echo WANDB_API_KEY=your_key_here > .env
224
+ ```
225
+
226
+ When a key is present, all runners stream metrics to W&B automatically. Without it, everything still works — metrics save to local JSON via `NullTracker`.
227
+
228
+ ---
229
+
230
+ ## Configuration System
231
+
232
+ Configs use YAML with an `inherits:` key for layered configuration:
233
+
234
+ ```yaml
235
+ # configs/tabular_cls/v1.0_train.yaml
236
+ inherits: configs/tabular_cls/base.yaml
237
+
238
+ project:
239
+ group: v1.0-train
240
+
241
+ training:
242
+ epochs: 30
243
+ checkpoint_name: v1.0_train_best.pt
244
+ ```
245
+
246
+ Each version always has three config variants:
247
+
248
+ | Variant | Purpose |
249
+ |---------|---------|
250
+ | `*_control.yaml` | Baseline model (establishes the floor) |
251
+ | `*_smoke.yaml` | Quick pipeline sanity check (3 epochs, 5 batches) |
252
+ | `*_train.yaml` | Full training run |
253
+
254
+ ---
255
+
256
+ ## Adding a New Domain
257
+
258
+ Chakra is designed for zero-code-change domain addition:
259
+
260
+ ```
261
+ src/chakra/domains/my_domain/
262
+ ├── __init__.py
263
+ ├── domain.yaml # Domain manifest (name, metrics, entrypoints)
264
+ ├── lifecycle.py # Implements DomainLifecycleHooks protocol
265
+ ├── models.py # Domain-specific models
266
+ ├── dataset.py # Data loading and preprocessing
267
+ ├── metrics.py # Evaluation metrics
268
+ ├── train_runner.py # Training script with W&B tracking
269
+ └── evaluate_runner.py # Evaluation script with W&B tracking
270
+ ```
271
+
272
+ Register in `pyproject.toml`:
273
+
274
+ ```toml
275
+ "chakra.domains.my_domain" = ["domain.yaml"]
276
+ ```
277
+
278
+ Then:
279
+
280
+ ```bash
281
+ chakra list-domains # Your domain appears automatically
282
+ chakra aavart --domain my_domain --version v1.0 --device cpu
283
+ ```
284
+
285
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full tutorial.
286
+
287
+ ---
288
+
289
+ ## Testing
290
+
291
+ ```bash
292
+ python -m pytest tests/ -v
293
+ ```
294
+
295
+ 47 tests across all domains and core infrastructure:
296
+
297
+ | Suite | Tests | Coverage |
298
+ |-------|-------|----------|
299
+ | `test_core.py` | 16 | Config, utils, seeding, registry |
300
+ | `test_tabular_domain.py` | 9 | Discovery, protocol, models, dataset, metrics |
301
+ | `test_nlp_domain.py` | 6 | GPT-nano, bigram, dataset, metrics |
302
+ | `test_domain_registry.py` | 5 | Multi-domain discovery, manifests |
303
+ | `test_runtime_contract.py` | 6 | Path resolution, workspace isolation |
304
+ | `test_cli_dispatch.py` | 3 | CLI argument parsing |
305
+ | `test_lifecycle_review.py` | 1 | Full sync → review pipeline |
306
+ | `test_notebook_contract.py` | 1 | Notebook JSON structure |
307
+
308
+ ---
309
+
310
+ ## Inspirations
311
+
312
+ - **Chakra** (चक्र) — The wheel that represents cyclical, self-sustaining motion
313
+ - **[Sakana AI's AI Scientist](https://github.com/sakanaai/ai-scientist)** — Automated scientific discovery
314
+ - **[AutoKaggle](https://github.com/multimodal-art-projection/AutoKaggle)** — Multi-agent Kaggle orchestration
315
+ - **[W&B Experiment Tracking](https://wandb.ai/)** — MLOps telemetry backbone
316
+
317
+ ---
318
+
319
+ ## License
320
+
321
+ [MIT](LICENSE) — Use it, fork it, extend it.