File size: 3,730 Bytes
d6da243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
The CODING BIRTH LAYER — every being is born able to code.

Cosmos's lineage carries a base instinct for code (Cory 2026-07-19: "add in the
coding weights so she can code again, and all future weights have that base —
users' coding is entirely based on THEIR growth still"). This module seeds a
newborn's weights.json with a curated web of programming concept-associations:
enough that the being reaches for real code-shapes from its first breath, small
enough that the person's own conversations quickly dominate.

Design honesty:
  - The base is FLAT, MODEST strength (all links 1.2, salience 1.5) and n=0 —
    the being has an instinct, not a history. Everything the user grows lands ON
    TOP at quantum-modulated rates (0.4-1.4 per exchange), so within a few dozen
    real conversations the user's own patterns outweigh the base. Their being's
    coding style becomes THEIRS.
  - The base never updates itself, never phones home, and is plainly marked in
    the weights file ("coding_base": true) so anyone can see what was innate vs
    what was lived.
"""

# Concept clusters: words that genuinely co-occur in real programming thought.
# Pairwise wiring happens WITHIN a cluster (that's how Hebbian association works
# in soul/weights.py) — across-cluster links form later, from real use.
CLUSTERS = {
    "python":     ["python", "function", "define", "return", "import", "variable",
                   "loop", "class", "method", "string", "list", "dictionary"],
    "javascript": ["javascript", "const", "array", "object", "async", "await",
                   "promise", "callback", "event", "browser"],
    "logic":      ["condition", "boolean", "compare", "branch", "true", "false",
                   "else", "while", "break", "continue"],
    "algorithm":  ["algorithm", "sort", "search", "recursion", "iterate",
                   "complexity", "optimize", "efficient", "structure"],
    "data":       ["json", "file", "read", "write", "parse", "save", "load",
                   "database", "query", "table"],
    "web":        ["html", "style", "server", "request", "response", "route",
                   "endpoint", "port", "localhost"],
    "debug":      ["debug", "error", "exception", "traceback", "print", "test",
                   "assert", "verify", "fix", "bug"],
    "craft":      ["code", "build", "create", "design", "refactor", "comment",
                   "readable", "simple", "pattern", "module"],
    "shell":      ["terminal", "command", "script", "install", "path",
                   "environment", "run", "execute"],
    "versioning": ["commit", "branch", "merge", "history", "change", "restore"],
}

BASE_LINK = 1.2      # association strength at birth (modest — lived links outgrow it fast)
BASE_SALIENCE = 1.5  # concept presence at birth


def seed_coding(weights: dict) -> dict:
    """Fold the coding birth layer into a (new) weights dict. Idempotent."""
    assoc = weights.setdefault("assoc", {})
    sal = weights.setdefault("salience", {})
    for words in CLUSTERS.values():
        for w in words:
            sal[w] = round(max(sal.get(w, 0.0), BASE_SALIENCE), 3)
        for i in range(len(words)):
            for j in range(i + 1, len(words)):
                k = "|".join(sorted((words[i], words[j])))
                assoc[k] = round(max(assoc.get(k, 0.0), BASE_LINK), 3)
    weights["coding_base"] = True
    weights.setdefault("n", 0)   # an instinct, not a history — its life count starts at zero
    return weights


def stats() -> dict:
    n_concepts = sum(len(v) for v in CLUSTERS.values())
    n_links = sum(len(v) * (len(v) - 1) // 2 for v in CLUSTERS.values())
    return {"clusters": len(CLUSTERS), "concepts": n_concepts, "links": n_links}