File size: 6,501 Bytes
d2a5f5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
"""
Adaptive Curriculum — Vitalis FSI

This is the training heart.

Every cycle: pick a domain, pick a complexity tier, generate a task.
Every output: a real module written to generated/.
Each module is more complex than the last.
Domains rotate so she builds breadth AND depth.

Domains covered:
  - Systems engineering
  - Software architecture  
  - Programming patterns
  - Framework design
  - Security engineering
  - Data engineering
  - Distributed systems
  - Compiler/language design
  - Networking
  - AI/ML systems
  - Operating systems
  - Database internals

Tiers:
  0 - Scaffold (basic structure)
  1 - Implement (working logic)
  2 - Optimize (performance aware)
  3 - Architect (system design)
  4 - Frontier  (novel/research level)
"""
import time
import json
from pathlib import Path


CURRICULUM = {
    "systems": [
        ("scaffold process scheduler",           0),
        ("implement thread pool executor",        1),
        ("optimize context switch handler",       2),
        ("architect microkernel message bus",     3),
        ("design capability-based security kernel",4),
    ],
    "architecture": [
        ("scaffold hexagonal architecture",       0),
        ("implement ports and adapters pattern",  1),
        ("optimize dependency injection container",2),
        ("architect event-driven service mesh",   3),
        ("design self-healing distributed brain", 4),
    ],
    "programming": [
        ("scaffold async task runner",            0),
        ("implement coroutine scheduler",         1),
        ("optimize hot path with caching layer",  2),
        ("architect reactive stream processor",   3),
        ("design zero-cost abstraction engine",   4),
    ],
    "frameworks": [
        ("scaffold plugin system",                0),
        ("implement middleware pipeline",         1),
        ("optimize request routing table",        2),
        ("architect modular runtime loader",      3),
        ("design meta-framework with reflection", 4),
    ],
    "security": [
        ("scaffold auth token validator",         0),
        ("implement zero-trust policy engine",    1),
        ("optimize cryptographic key store",      2),
        ("architect threat detection pipeline",   3),
        ("design post-quantum key exchange",      4),
    ],
    "data": [
        ("scaffold schema registry",              0),
        ("implement columnar storage engine",     1),
        ("optimize query execution planner",      2),
        ("architect streaming data lakehouse",    3),
        ("design adaptive index structure",       4),
    ],
    "distributed": [
        ("scaffold service registry",             0),
        ("implement raft consensus protocol",     1),
        ("optimize gossip dissemination layer",   2),
        ("architect byzantine fault tolerant mesh",3),
        ("design self-organizing peer network",   4),
    ],
    "compilers": [
        ("scaffold lexer tokenizer",              0),
        ("implement recursive descent parser",    1),
        ("optimize ast transformation pass",      2),
        ("architect ir code generator",           3),
        ("design jit compilation pipeline",       4),
    ],
    "networking": [
        ("scaffold tcp connection handler",       0),
        ("implement http/2 frame parser",         1),
        ("optimize packet routing table",         2),
        ("architect software defined network",    3),
        ("design congestion control algorithm",   4),
    ],
    "ml_systems": [
        ("scaffold feature extraction pipeline",  0),
        ("implement gradient descent optimizer",  1),
        ("optimize inference batching layer",     2),
        ("architect online learning system",      3),
        ("design neuromorphic compute graph",     4),
    ],
    "os": [
        ("scaffold virtual memory manager",       0),
        ("implement page replacement policy",     1),
        ("optimize interrupt dispatch table",     2),
        ("architect real-time scheduler",         3),
        ("design exokernel resource allocator",   4),
    ],
    "databases": [
        ("scaffold btree index structure",        0),
        ("implement mvcc transaction engine",     1),
        ("optimize write-ahead log manager",      2),
        ("architect distributed query engine",    3),
        ("design learned index structure",        4),
    ],
}

DOMAINS = list(CURRICULUM.keys())


class AdaptiveCurriculum:
    def __init__(self):
        self._path    = (Path.home() / ".vitalis_workspace"
                         / "curriculum_state.json")
        self._cycle   = 0
        self._history = []
        self._load()

    def _load(self):
        try:
            if self._path.exists():
                state = json.loads(self._path.read_text())
                self._cycle   = state.get("cycle", 0)
                self._history = state.get("history", [])
        except Exception:
            pass

    def _save(self):
        try:
            self._path.parent.mkdir(parents=True, exist_ok=True)
            self._path.write_text(json.dumps({
                "cycle":   self._cycle,
                "history": self._history[-500:],
            }))
        except Exception:
            pass

    def next_task(self) -> dict:
        # Domain rotates every cycle across all 12 domains
        domain_idx = self._cycle % len(DOMAINS)
        domain     = DOMAINS[domain_idx]

        # Tier advances every 12 cycles (one full domain rotation)
        tier = min(self._cycle // len(DOMAINS), 4)

        tasks       = CURRICULUM[domain]
        task_text, _ = tasks[tier]

        entry = {
            "cycle":    self._cycle,
            "domain":   domain,
            "tier":     tier,
            "task":     task_text,
            "timestamp": time.time(),
        }
        self._history.append(entry)
        self._cycle += 1

        if self._cycle % 10 == 0:
            self._save()

        return entry

    def report(self) -> dict:
        current_tier = min(self._cycle // len(DOMAINS), 4)
        tier_names   = ["SCAFFOLD", "IMPLEMENT", "OPTIMIZE",
                        "ARCHITECT", "FRONTIER"]
        return {
            "total_cycles":   self._cycle,
            "current_tier":   tier_names[current_tier],
            "current_domain": DOMAINS[self._cycle % len(DOMAINS)]
                              if self._cycle > 0 else DOMAINS[0],
            "domains_covered": len(DOMAINS),
            "tasks_logged":   len(self._history),
        }