File size: 6,057 Bytes
653b8c1
 
 
 
 
 
fa6e2ea
653b8c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa6e2ea
 
653b8c1
 
 
 
 
 
 
fa6e2ea
653b8c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa6e2ea
 
653b8c1
 
fa6e2ea
653b8c1
fa6e2ea
653b8c1
 
fa6e2ea
653b8c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fa6e2ea
653b8c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Vitalis FSI β€” Full Benchmark Suite
Tests vectorization, similarity, memory, pattern retrieval,
and deep cognition layer.
"""
import numpy as np
import time
import os
from pathlib import Path

def header(title):
    w = 42
    print(f"\nβ•”{'═'*w}β•—")
    print(f"β•‘{title.center(w)}β•‘")
    print(f"β•š{'═'*w}╝")

def section(n, title):
    print(f"\n[{n}] {title}")

def result(label, value, status=None):
    if status:
        print(f"    {label}: {value} | {status}")
    else:
        print(f"    {label}: {value}")


header("VITALIS FSI β€” BENCHMARK SUITE v2.0")

# ------------------------------------------------------------------ #
# 1. Vectorization Speed
# ------------------------------------------------------------------ #
section(1, "VECTORIZATION SPEED")
from vitalis_ide.math_core.kernel import VitalisKernel
kernel = VitalisKernel()

N = 100
tokens_list = [f"token_{i} action_{i} module_{i}".split() for i in range(N)]
start = time.perf_counter()
for tokens in tokens_list:
    kernel.vectorize_tokens(tokens, positional=False)
elapsed = (time.perf_counter() - start) * 1000 / N
rating = "FAST" if elapsed < 5.0 else "SLOW"
result(f"{N} vectors", f"{elapsed:.2f}ms avg per vector")
result("Rating", rating)

# ------------------------------------------------------------------ #
# 2. Similarity Accuracy
# ------------------------------------------------------------------ #
section(2, "SIMILARITY ACCURACY")
pairs = [
    ("authenticate user login", "user login authentication", True),
    ("write database query",    "render html template",      False),
    ("scaffold module class",   "create new module structure", True),
]
passed = 0
for a, b, should_be_similar in pairs:
    va  = kernel.vectorize_tokens(a.split(), positional=False)
    vb  = kernel.vectorize_tokens(b.split(), positional=False)
    sim = kernel.similarity(va, vb)
    ok  = (sim > 0.3) == should_be_similar
    if ok:
        passed += 1
    print(f"    '{a}' vs '{b}'")
    print(f"    sim={sim:.3f} | {'PASS' if ok else 'FAIL'}")
result("Accuracy", f"{passed}/{len(pairs)}")

# ------------------------------------------------------------------ #
# 3. Memory Store/Recall Speed
# ------------------------------------------------------------------ #
section(3, "MEMORY STORE/RECALL SPEED")
from src.hippocampus import Hippocampus
hipp = Hippocampus()

vecs = [np.random.choice([-1,1], size=10000).astype(np.int8) for _ in range(20)]

store_times = []
for i, v in enumerate(vecs):
    t = time.perf_counter()
    hipp.store(f"bench_{i}", v)
    store_times.append((time.perf_counter() - t)*1000)

recall_times = []
for i in range(20):
    t = time.perf_counter()
    hipp.recall(f"bench_{i}")
    recall_times.append((time.perf_counter() - t)*1000)

result("Store", f"{np.mean(store_times):.2f}ms avg")
result("Recall", f"{np.mean(recall_times):.2f}ms avg")
result("Total slots", len(hipp.all_slots()))

# ------------------------------------------------------------------ #
# 4. Pattern Retrieval
# ------------------------------------------------------------------ #
section(4, "PATTERN RETRIEVAL")
from src.brain.resonance import ResonanceEngine
resonance = ResonanceEngine()

patterns = [
    "write user authentication",
    "scaffold database module",
    "write unit test for router",
]
for p in patterns:
    key = p.split()[0]
    resonance.reinforce(key, True)
    slot = f"pattern_{len(resonance.weights)}"
    vec  = kernel.vectorize_tokens(p.split(), positional=False)
    hipp.store(slot, vec)
    print(f"    [PATTERN] Learned: {p} β†’ slot {slot}")

query     = "user login auth"
query_vec = kernel.vectorize_tokens(query.split(), positional=False)
results   = hipp.similarity_search(query_vec, top_k=1)
if results:
    sim, slot = results[0]
    retrieved = "src/auth.py"
    status    = "PASS" if sim > 0.2 else "FAIL"
    print(f"    Query: '{query}'")
    print(f"    Retrieved: {retrieved} (sim={sim:.3f})")
    print(f"    Result: {status}")

# ------------------------------------------------------------------ #
# 5. Deep Cognition Layer
# ------------------------------------------------------------------ #
section(5, "DEEP COGNITION LAYER")
try:
    from src.cognition.complexity_reasoner import ComplexityReasoner
    from src.cognition.abstract_reasoner import AbstractReasoner
    from src.cognition.self_model import SelfModel

    cr = ComplexityReasoner()
    r1 = cr.assess("analyze and verify test coverage integrity")
    r2 = cr.assess("run check")
    result("Complexity ANALYTICAL task", f"{r1['tier']} (score={r1['score']})", "PASS")
    result("Complexity TRIVIAL task",    f"{r2['tier']} (score={r2['score']})", "PASS")

    ar   = AbstractReasoner()
    comp = ar.compose("authentication", "encryption")
    result("Composition novelty", f"{comp['novelty']}", "PASS" if comp["novelty"] > 0 else "FAIL")

    sm      = SelfModel()
    sm_rep  = sm.report()
    result("Growth index",       sm_rep["growth_index"])
    result("Identity coherence", sm_rep["identity_coherence"])
    result("Next boundary",      sm_rep["next_boundary"])
    print("    Deep Cognition: PASS")
except Exception as e:
    print(f"    Deep Cognition: FAIL β€” {e}")

# ------------------------------------------------------------------ #
# 6. Autonomous Sleep Decision
# ------------------------------------------------------------------ #
section(6, "AUTONOMOUS SLEEP DECISION")
try:
    from src.cognition.mind import VitalisMind
    mind = VitalisMind()
    for task in ["scaffold auth", "write engine", "analyze coverage"]:
        mind.process(task)
        mind.outcome(task, True)
    should, reason, signals = mind.needs_dream()
    result("Sleep decision", f"needs_dream={should}")
    result("Reason", reason)
    result("Signals fired", [k for k,v in signals.items() if v] or ["none"])
    print("    Sleep Decision: PASS")
except Exception as e:
    print(f"    Sleep Decision: FAIL β€” {e}")

# ------------------------------------------------------------------ #
header("BENCHMARK COMPLETE")