Spaces:
Runtime error
Runtime error
Add Extropy XP formula demo
Browse files- README.md +29 -7
- app.py +143 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -1,13 +1,35 @@
|
|
| 1 |
---
|
| 2 |
-
title: Extropy Engine Demo
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Extropy Engine XP Formula Demo
|
| 3 |
+
emoji: ♻️
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Extropy Engine, XP formula demo
|
| 14 |
+
|
| 15 |
+
The unit of value is entropy reduction. This is not a metaphor.
|
| 16 |
+
|
| 17 |
+
This Space runs the canonical Extropy XP formula, faithfully ported from the
|
| 18 |
+
TypeScript source of record in
|
| 19 |
+
[`packages/xp-formula`](https://github.com/00ranman/extropy-engine/blob/main/packages/xp-formula/src/index.ts):
|
| 20 |
+
|
| 21 |
+
XP = R x F x dS x (w . E) x log(1 / Ts)
|
| 22 |
+
|
| 23 |
+
Move the sliders to score a contribution. Set dS to 0 or push Ts out of range
|
| 24 |
+
to watch the mint preconditions fail closed. Reputation never enters this
|
| 25 |
+
formula, which is the entire design intent.
|
| 26 |
+
|
| 27 |
+
## Links
|
| 28 |
+
|
| 29 |
+
- Source: [github.com/00ranman/extropy-engine](https://github.com/00ranman/extropy-engine)
|
| 30 |
+
- Paper: [An Emergence-First Grand Unified Theory](https://www.academia.edu/167360291)
|
| 31 |
+
- Discussion: [open thread](https://www.academia.edu/s/b1ff6dbe50)
|
| 32 |
+
|
| 33 |
+
## License
|
| 34 |
+
|
| 35 |
+
MIT, Copyright (c) 2026 Randall Gossett.
|
app.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Extropy Engine, XP formula demo.
|
| 3 |
+
|
| 4 |
+
This Space runs the canonical Extropy XP formula faithfully ported from the
|
| 5 |
+
TypeScript source of record at:
|
| 6 |
+
github.com/00ranman/extropy-engine -> packages/xp-formula/src/index.ts
|
| 7 |
+
|
| 8 |
+
XP = R * F * dS * (w . E) * log(1 / Ts)
|
| 9 |
+
|
| 10 |
+
where
|
| 11 |
+
R Rarity multiplier (action-class scarcity, NOT actor reputation)
|
| 12 |
+
F Frequency-of-decay penalty (1.0 = first occurrence of this action class)
|
| 13 |
+
dS Verified entropy reduction, must be > 0 to mint
|
| 14 |
+
w Weight vector over effort dimensions
|
| 15 |
+
E Energy/effort vector (same length as w)
|
| 16 |
+
Ts Timestamp decay factor in (0, 1], computed as exp(-lambda * dt)
|
| 17 |
+
|
| 18 |
+
Reputation never enters XP minting. That is the whole point.
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
import math
|
| 22 |
+
import gradio as gr
|
| 23 |
+
|
| 24 |
+
# Eight canonical entropy domains and their causal-closure speeds c_L,
|
| 25 |
+
# from packages/contracts/src/types.ts. The irreducible value form is
|
| 26 |
+
# XP = dS / c_L^2: slower closure (smaller c_L) means higher value per unit dS.
|
| 27 |
+
CAUSAL_CLOSURE_SPEEDS = {
|
| 28 |
+
"cognitive": 1e-6,
|
| 29 |
+
"code": 1e-4,
|
| 30 |
+
"social": 1e-3,
|
| 31 |
+
"economic": 1e-2,
|
| 32 |
+
"thermodynamic": 1e-4,
|
| 33 |
+
"informational": 1e-5,
|
| 34 |
+
"governance": 1e-3,
|
| 35 |
+
"temporal": 1e-6,
|
| 36 |
+
}
|
| 37 |
+
DOMAINS = list(CAUSAL_CLOSURE_SPEEDS.keys())
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def compute_xp(R, F, dS, w, E, Ts):
|
| 41 |
+
"""Faithful port of computeXP. Returns (xp, breakdown, valid, reason)."""
|
| 42 |
+
if dS <= 0:
|
| 43 |
+
return 0.0, {"R": R, "F": F, "deltaS": dS, "wDotE": 0.0, "logDecay": 0.0}, False, "deltaS must be > 0"
|
| 44 |
+
if Ts <= 0 or Ts > 1:
|
| 45 |
+
return 0.0, {"R": R, "F": F, "deltaS": dS, "wDotE": 0.0, "logDecay": 0.0}, False, "Ts must be in (0, 1]"
|
| 46 |
+
if len(w) != len(E):
|
| 47 |
+
return 0.0, {"R": R, "F": F, "deltaS": dS, "wDotE": 0.0, "logDecay": 0.0}, False, "w and E must have equal length"
|
| 48 |
+
|
| 49 |
+
w_dot_e = sum(wi * ei for wi, ei in zip(w, E))
|
| 50 |
+
log_decay = math.log(1.0 / Ts)
|
| 51 |
+
xp = R * F * dS * w_dot_e * log_decay
|
| 52 |
+
return max(0.0, xp), {
|
| 53 |
+
"R": R, "F": F, "deltaS": dS, "wDotE": w_dot_e, "logDecay": log_decay,
|
| 54 |
+
}, True, None
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def timestamp_decay(dt_seconds, lam=0.001):
|
| 58 |
+
return math.exp(-lam * dt_seconds)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def run(R, F, dS, w_cog, w_phys, w_temp, e_cog, e_phys, e_temp, dt_hours, lam, domain):
|
| 62 |
+
w = [w_cog, w_phys, w_temp]
|
| 63 |
+
E = [e_cog, e_phys, e_temp]
|
| 64 |
+
Ts = timestamp_decay(dt_hours * 3600.0, lam)
|
| 65 |
+
xp, bd, valid, reason = compute_xp(R, F, dS, w, E, Ts)
|
| 66 |
+
|
| 67 |
+
c_l = CAUSAL_CLOSURE_SPEEDS[domain]
|
| 68 |
+
irreducible = dS / (c_l ** 2)
|
| 69 |
+
|
| 70 |
+
if not valid:
|
| 71 |
+
verdict = f"NO MINT. Precondition failed: {reason}"
|
| 72 |
+
else:
|
| 73 |
+
verdict = f"MINT: {xp:,.4f} XP"
|
| 74 |
+
|
| 75 |
+
lines = [
|
| 76 |
+
f"### {verdict}",
|
| 77 |
+
"",
|
| 78 |
+
f"Ts (timestamp decay) = exp(-{lam} x {dt_hours*3600:.0f}s) = **{Ts:.6f}**",
|
| 79 |
+
"",
|
| 80 |
+
"_Note: production xp-mint caps the log(1/Ts) recency term to prevent runaway values on long-settled loops. This demo shows the raw formula._",
|
| 81 |
+
"",
|
| 82 |
+
"| Term | Value |",
|
| 83 |
+
"| --- | --- |",
|
| 84 |
+
f"| R (rarity) | {bd['R']:.4f} |",
|
| 85 |
+
f"| F (frequency-of-decay) | {bd['F']:.4f} |",
|
| 86 |
+
f"| dS (entropy reduction) | {bd['deltaS']:.4f} |",
|
| 87 |
+
f"| w . E (effort) | {bd['wDotE']:.4f} |",
|
| 88 |
+
f"| log(1/Ts) (recency) | {bd['logDecay']:.4f} |",
|
| 89 |
+
f"| **XP** | **{xp:,.4f}** |",
|
| 90 |
+
"",
|
| 91 |
+
f"Domain **{domain}** has causal-closure speed c_L = {c_l:g}. "
|
| 92 |
+
f"Irreducible value form XP = dS / c_L^2 = **{irreducible:,.3g}**. "
|
| 93 |
+
"Slower-closing domains (cognitive, temporal) reward the same dS far more "
|
| 94 |
+
"than fast-closing ones (economic), because the loop is harder to close.",
|
| 95 |
+
]
|
| 96 |
+
return "\n".join(lines)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
INTRO = """
|
| 100 |
+
# Extropy Engine, XP formula demo
|
| 101 |
+
|
| 102 |
+
The unit of value is entropy reduction. This is not a metaphor.
|
| 103 |
+
|
| 104 |
+
This demo runs the **canonical XP formula** straight from the source of record,
|
| 105 |
+
[`packages/xp-formula`](https://github.com/00ranman/extropy-engine/blob/main/packages/xp-formula/src/index.ts).
|
| 106 |
+
Move the sliders and watch a contribution get scored. Set dS to 0 or push Ts out
|
| 107 |
+
of range to see the mint preconditions fail closed.
|
| 108 |
+
|
| 109 |
+
XP = R x F x dS x (w . E) x log(1 / Ts). Reputation never enters this formula.
|
| 110 |
+
|
| 111 |
+
Paper: [An Emergence-First Grand Unified Theory](https://www.academia.edu/167360291).
|
| 112 |
+
Discussion: [open thread](https://www.academia.edu/s/b1ff6dbe50).
|
| 113 |
+
"""
|
| 114 |
+
|
| 115 |
+
with gr.Blocks(title="Extropy Engine, XP formula demo") as demo:
|
| 116 |
+
gr.Markdown(INTRO)
|
| 117 |
+
with gr.Row():
|
| 118 |
+
with gr.Column():
|
| 119 |
+
R = gr.Slider(0.0, 10.0, value=2.0, step=0.1, label="R, rarity (action-class scarcity)")
|
| 120 |
+
F = gr.Slider(0.0, 1.0, value=1.0, step=0.01, label="F, frequency-of-decay (1.0 = first time)")
|
| 121 |
+
dS = gr.Slider(-1.0, 50.0, value=12.0, step=0.5, label="dS, verified entropy reduction (must be > 0)")
|
| 122 |
+
gr.Markdown("**Effort: weights w and energy E over (cognitive, physical, temporal)**")
|
| 123 |
+
with gr.Row():
|
| 124 |
+
w_cog = gr.Slider(0.0, 1.0, value=0.5, step=0.05, label="w cognitive")
|
| 125 |
+
w_phys = gr.Slider(0.0, 1.0, value=0.3, step=0.05, label="w physical")
|
| 126 |
+
w_temp = gr.Slider(0.0, 1.0, value=0.2, step=0.05, label="w temporal")
|
| 127 |
+
with gr.Row():
|
| 128 |
+
e_cog = gr.Slider(0.0, 10.0, value=6.0, step=0.5, label="E cognitive")
|
| 129 |
+
e_phys = gr.Slider(0.0, 10.0, value=2.0, step=0.5, label="E physical")
|
| 130 |
+
e_temp = gr.Slider(0.0, 10.0, value=4.0, step=0.5, label="E temporal")
|
| 131 |
+
dt_hours = gr.Slider(0.0, 48.0, value=2.0, step=0.5, label="Elapsed time since trigger (hours)")
|
| 132 |
+
lam = gr.Slider(0.0001, 0.01, value=0.001, step=0.0001, label="lambda, decay constant")
|
| 133 |
+
domain = gr.Dropdown(DOMAINS, value="cognitive", label="Entropy domain")
|
| 134 |
+
btn = gr.Button("Score contribution", variant="primary")
|
| 135 |
+
with gr.Column():
|
| 136 |
+
out = gr.Markdown()
|
| 137 |
+
|
| 138 |
+
inputs = [R, F, dS, w_cog, w_phys, w_temp, e_cog, e_phys, e_temp, dt_hours, lam, domain]
|
| 139 |
+
btn.click(run, inputs=inputs, outputs=out)
|
| 140 |
+
demo.load(run, inputs=inputs, outputs=out)
|
| 141 |
+
|
| 142 |
+
if __name__ == "__main__":
|
| 143 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
gradio==4.44.1
|