sum-engine 0.1.0__py3-none-any.whl
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.
- internal/__init__.py +8 -0
- internal/algorithms/__init__.py +1 -0
- internal/algorithms/causal_discovery.py +96 -0
- internal/algorithms/predicate_canon.py +137 -0
- internal/algorithms/semantic_arithmetic.py +890 -0
- internal/algorithms/syntactic_sieve.py +452 -0
- internal/algorithms/zk_semantics.py +90 -0
- internal/ensemble/__init__.py +1 -0
- internal/ensemble/automated_scientist.py +138 -0
- internal/ensemble/autonomous_agent.py +157 -0
- internal/ensemble/causal_triggers.py +121 -0
- internal/ensemble/confidence_calibrator.py +284 -0
- internal/ensemble/epistemic_arbiter.py +159 -0
- internal/ensemble/epistemic_loop.py +136 -0
- internal/ensemble/extraction_validator.py +172 -0
- internal/ensemble/gauge_orchestrator.py +150 -0
- internal/ensemble/live_llm_adapter.py +183 -0
- internal/ensemble/llm_entailment.py +117 -0
- internal/ensemble/mass_semantic_engine.py +138 -0
- internal/ensemble/ouroboros.py +281 -0
- internal/ensemble/semantic_dedup.py +261 -0
- internal/ensemble/tome_generator.py +286 -0
- internal/ensemble/tome_sliders.py +104 -0
- internal/ensemble/vector_bridge.py +195 -0
- internal/ensemble/venn_abers.py +211 -0
- internal/infrastructure/__init__.py +1 -0
- internal/infrastructure/akashic_ledger.py +812 -0
- internal/infrastructure/canonical_codec.py +452 -0
- internal/infrastructure/jcs.py +115 -0
- internal/infrastructure/key_manager.py +239 -0
- internal/infrastructure/p2p_mesh.py +168 -0
- internal/infrastructure/prov_o.py +159 -0
- internal/infrastructure/provenance.py +181 -0
- internal/infrastructure/rate_limiter.py +81 -0
- internal/infrastructure/resource_guards.py +117 -0
- internal/infrastructure/scheme_registry.py +136 -0
- internal/infrastructure/state_encoding.py +94 -0
- internal/infrastructure/telemetry.py +91 -0
- internal/infrastructure/tome_parser.py +55 -0
- internal/infrastructure/verifiable_credential.py +412 -0
- internal/infrastructure/zig_bridge.py +256 -0
- sum_cli/__init__.py +18 -0
- sum_cli/main.py +688 -0
- sum_engine-0.1.0.dist-info/METADATA +590 -0
- sum_engine-0.1.0.dist-info/RECORD +49 -0
- sum_engine-0.1.0.dist-info/WHEEL +5 -0
- sum_engine-0.1.0.dist-info/entry_points.txt +2 -0
- sum_engine-0.1.0.dist-info/licenses/LICENSE +201 -0
- sum_engine-0.1.0.dist-info/top_level.txt +2 -0
internal/__init__.py
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""Internal SUM engine modules — not a stable public API.
|
|
2
|
+
|
|
3
|
+
The CLI (``sum_cli.main``) imports from here; downstream integrations
|
|
4
|
+
should depend on the CLI contract (``sum attest`` / ``sum verify``
|
|
5
|
+
exit codes and the CanonicalBundle JSON schema) rather than import
|
|
6
|
+
these modules directly. Internal refactors may move or rename
|
|
7
|
+
submodules between minor versions.
|
|
8
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Prime-encoded semantic algebra + deterministic-sieve extractors."""
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Causal Discovery Engine — Topological Inference
|
|
3
|
+
|
|
4
|
+
Sweeps active axioms for transitive topological links (causality,
|
|
5
|
+
implication, inhibition) and computes transitive closures to
|
|
6
|
+
synthesize novel knowledge that the system was never explicitly taught.
|
|
7
|
+
|
|
8
|
+
If the algebra contains:
|
|
9
|
+
chemical_x → inhibits → enzyme_y
|
|
10
|
+
enzyme_y → causes → disease_z
|
|
11
|
+
|
|
12
|
+
The engine will deduce:
|
|
13
|
+
chemical_x → treats → disease_z
|
|
14
|
+
|
|
15
|
+
Author: ototao
|
|
16
|
+
License: Apache License 2.0
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from typing import List, Tuple
|
|
20
|
+
import networkx as nx
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CausalDiscoveryEngine:
|
|
24
|
+
"""
|
|
25
|
+
Horizon V: The Automated Scientist.
|
|
26
|
+
|
|
27
|
+
Sweeps active axioms for transitive topological links
|
|
28
|
+
and synthesizes novel knowledge via strict predicate rules.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
TRANSITIVE_PREDICATES = {"causes", "implies", "leads_to", "requires", "is_a"}
|
|
32
|
+
INVERSE_PREDICATES = {"inhibits": "treats", "prevents": "solves"}
|
|
33
|
+
|
|
34
|
+
def __init__(self, algebra):
|
|
35
|
+
self.algebra = algebra
|
|
36
|
+
|
|
37
|
+
def sweep_for_discoveries(
|
|
38
|
+
self, current_state: int
|
|
39
|
+
) -> List[Tuple[str, str, str]]:
|
|
40
|
+
"""
|
|
41
|
+
Extract directed graph from active axioms, compute transitive
|
|
42
|
+
closures, and return novel triplets not already in the state.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
current_state: The Gödel integer to analyze.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
List of (subject, predicate, object) triplets that are
|
|
49
|
+
logically entailed but not yet in the state.
|
|
50
|
+
"""
|
|
51
|
+
active_axioms = self.algebra.get_active_axioms(current_state)
|
|
52
|
+
|
|
53
|
+
# Build directed graph from causal/transitive predicates
|
|
54
|
+
G = nx.DiGraph()
|
|
55
|
+
for ax in active_axioms:
|
|
56
|
+
parts = ax.split("||")
|
|
57
|
+
if len(parts) == 3:
|
|
58
|
+
s, p, o = parts
|
|
59
|
+
if p in self.TRANSITIVE_PREDICATES or p in self.INVERSE_PREDICATES:
|
|
60
|
+
G.add_edge(s, o, predicate=p)
|
|
61
|
+
|
|
62
|
+
# Compute 2-hop transitive closures
|
|
63
|
+
discoveries = set()
|
|
64
|
+
|
|
65
|
+
for node in list(G.nodes()):
|
|
66
|
+
for neighbor in list(G.successors(node)):
|
|
67
|
+
p1 = G.edges[node, neighbor]["predicate"]
|
|
68
|
+
for target in list(G.successors(neighbor)):
|
|
69
|
+
if node == target:
|
|
70
|
+
continue # Skip self-loops
|
|
71
|
+
|
|
72
|
+
p2 = G.edges[neighbor, target]["predicate"]
|
|
73
|
+
|
|
74
|
+
# Same transitive predicate: A→B→C ⟹ A→C
|
|
75
|
+
if (
|
|
76
|
+
p1 in self.TRANSITIVE_PREDICATES
|
|
77
|
+
and p2 in self.TRANSITIVE_PREDICATES
|
|
78
|
+
):
|
|
79
|
+
discoveries.add((node, p1, target))
|
|
80
|
+
|
|
81
|
+
# Inverse + transitive: A inhibits B, B causes C ⟹ A treats C
|
|
82
|
+
elif (
|
|
83
|
+
p1 in self.INVERSE_PREDICATES
|
|
84
|
+
and p2 in self.TRANSITIVE_PREDICATES
|
|
85
|
+
):
|
|
86
|
+
inferred_pred = self.INVERSE_PREDICATES[p1]
|
|
87
|
+
discoveries.add((node, inferred_pred, target))
|
|
88
|
+
|
|
89
|
+
# Filter to only truly novel discoveries
|
|
90
|
+
novel_discoveries = []
|
|
91
|
+
for s, p, o in discoveries:
|
|
92
|
+
prime = self.algebra.get_or_mint_prime(s, p, o)
|
|
93
|
+
if current_state % prime != 0:
|
|
94
|
+
novel_discoveries.append((s, p, o))
|
|
95
|
+
|
|
96
|
+
return novel_discoveries
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Predicate Canonicalizer — Controlled Vocabulary for Semantic Primes
|
|
3
|
+
|
|
4
|
+
Maps free-form LLM predicates to a normalized vocabulary so that
|
|
5
|
+
semantically identical relationships produce the same Gödel prime.
|
|
6
|
+
|
|
7
|
+
Without this:
|
|
8
|
+
"sun||causes||warmth" → prime₁
|
|
9
|
+
"sun||leads_to||warmth" → prime₂ (different prime, same meaning!)
|
|
10
|
+
|
|
11
|
+
With this:
|
|
12
|
+
"sun||causes||warmth" → prime₁
|
|
13
|
+
"sun||leads_to||warmth" → prime₁ (same prime via canonicalization)
|
|
14
|
+
|
|
15
|
+
The canonical vocabulary is intentionally small — it maps the long tail
|
|
16
|
+
of LLM-generated predicates into the set that CausalDiscovery's
|
|
17
|
+
TRANSITIVE_PREDICATES and INVERSE_PREDICATES can reason over.
|
|
18
|
+
|
|
19
|
+
Author: ototao
|
|
20
|
+
License: Apache License 2.0
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# ─── Canonical Vocabulary ─────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
CANONICAL_MAP: dict[str, str] = {
|
|
27
|
+
# → causes family
|
|
28
|
+
"leads_to": "causes",
|
|
29
|
+
"triggers": "causes",
|
|
30
|
+
"results_in": "causes",
|
|
31
|
+
"produces": "causes",
|
|
32
|
+
"generates": "causes",
|
|
33
|
+
"creates": "causes",
|
|
34
|
+
"induces": "causes",
|
|
35
|
+
"drives": "causes",
|
|
36
|
+
"provokes": "causes",
|
|
37
|
+
"elicits": "causes",
|
|
38
|
+
"yields": "causes",
|
|
39
|
+
"brings_about": "causes",
|
|
40
|
+
|
|
41
|
+
# → inhibits family
|
|
42
|
+
"prevents": "inhibits",
|
|
43
|
+
"blocks": "inhibits",
|
|
44
|
+
"stops": "inhibits",
|
|
45
|
+
"suppresses": "inhibits",
|
|
46
|
+
"reduces": "inhibits",
|
|
47
|
+
"hinders": "inhibits",
|
|
48
|
+
"impedes": "inhibits",
|
|
49
|
+
"decreases": "inhibits",
|
|
50
|
+
"diminishes": "inhibits",
|
|
51
|
+
"constrains": "inhibits",
|
|
52
|
+
|
|
53
|
+
# → implies family
|
|
54
|
+
"suggests": "implies",
|
|
55
|
+
"indicates": "implies",
|
|
56
|
+
"means": "implies",
|
|
57
|
+
"entails": "implies",
|
|
58
|
+
"demonstrates": "implies",
|
|
59
|
+
"shows": "implies",
|
|
60
|
+
"proves": "implies",
|
|
61
|
+
"evidences": "implies",
|
|
62
|
+
|
|
63
|
+
# → requires family
|
|
64
|
+
"needs": "requires",
|
|
65
|
+
"depends_on": "requires",
|
|
66
|
+
"relies_on": "requires",
|
|
67
|
+
"necessitates": "requires",
|
|
68
|
+
|
|
69
|
+
# → is_a family (taxonomy)
|
|
70
|
+
"is_type_of": "is_a",
|
|
71
|
+
"is_kind_of": "is_a",
|
|
72
|
+
"belongs_to": "is_a",
|
|
73
|
+
"is_part_of": "has_part",
|
|
74
|
+
"contains": "has_part",
|
|
75
|
+
"includes": "has_part",
|
|
76
|
+
"comprises": "has_part",
|
|
77
|
+
|
|
78
|
+
# → has_property family
|
|
79
|
+
"has": "has_property",
|
|
80
|
+
"possesses": "has_property",
|
|
81
|
+
"exhibits": "has_property",
|
|
82
|
+
"displays": "has_property",
|
|
83
|
+
"features": "has_property",
|
|
84
|
+
"characterized_by": "has_property",
|
|
85
|
+
|
|
86
|
+
# → treats family (inverse of inhibits in CausalDiscovery)
|
|
87
|
+
"cures": "treats",
|
|
88
|
+
"heals": "treats",
|
|
89
|
+
"remedies": "treats",
|
|
90
|
+
"alleviates": "treats",
|
|
91
|
+
"mitigates": "treats",
|
|
92
|
+
|
|
93
|
+
# → enables family
|
|
94
|
+
"allows": "enables",
|
|
95
|
+
"permits": "enables",
|
|
96
|
+
"facilitates": "enables",
|
|
97
|
+
"supports": "enables",
|
|
98
|
+
"empowers": "enables",
|
|
99
|
+
|
|
100
|
+
# → uses family
|
|
101
|
+
"utilizes": "uses",
|
|
102
|
+
"employs": "uses",
|
|
103
|
+
"applies": "uses",
|
|
104
|
+
"leverages": "uses",
|
|
105
|
+
|
|
106
|
+
# → located_in family
|
|
107
|
+
"found_in": "located_in",
|
|
108
|
+
"exists_in": "located_in",
|
|
109
|
+
"resides_in": "located_in",
|
|
110
|
+
"occurs_in": "located_in",
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
# The set of canonical predicates (roots) — these are never remapped
|
|
114
|
+
CANONICAL_PREDICATES: frozenset[str] = frozenset({
|
|
115
|
+
"causes", "inhibits", "implies", "requires", "is_a",
|
|
116
|
+
"has_part", "has_property", "treats", "enables", "uses",
|
|
117
|
+
"located_in", "leads_to",
|
|
118
|
+
# Keep CausalDiscovery's originals
|
|
119
|
+
"solves",
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def canonicalize(predicate: str) -> str:
|
|
124
|
+
"""
|
|
125
|
+
Maps a free-form predicate string to its canonical form.
|
|
126
|
+
|
|
127
|
+
If the predicate is already canonical or has no mapping,
|
|
128
|
+
it is returned unchanged (the system remains open-world).
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
predicate: The raw predicate string (lowercased).
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
The canonical predicate.
|
|
135
|
+
"""
|
|
136
|
+
normalized = predicate.strip().lower().replace(" ", "_")
|
|
137
|
+
return CANONICAL_MAP.get(normalized, normalized)
|