auto: hourly snapshot 2026-06-08 18:34
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
+85
-11
@@ -46,6 +46,37 @@ ollama_lock = threading.Lock()
|
||||
ask_queue = queue.Queue(maxsize=4)
|
||||
last_obs_text = ""
|
||||
|
||||
# Quiescent-substrate baselines, measured on probe State 0 BASELINE
|
||||
# (Khra=0.030, Gixx=0.008, no injection) 2026-06-08. These are the floor
|
||||
# values the model must compare against — if a current reading is within
|
||||
# ~1 std of these, it is NOT a perturbation.
|
||||
BASELINE_MEAN = {
|
||||
"asymmetry": 116.67,
|
||||
"coherence": 0.6047,
|
||||
"vel_mean": 0.2106,
|
||||
"vel_max": 0.2854,
|
||||
"vel_var": 0.002429,
|
||||
"vorticity_mean": 0.0265,
|
||||
"stress_xx": -0.000795,
|
||||
"stress_yy": 0.000731,
|
||||
"stress_xy": -0.000263,
|
||||
}
|
||||
BASELINE_STD = {
|
||||
"asymmetry": 3.0,
|
||||
"coherence": 0.005,
|
||||
"vel_mean": 0.005,
|
||||
"vel_max": 0.008,
|
||||
"vel_var": 0.0004,
|
||||
"vorticity_mean": 0.012,
|
||||
"stress_xx": 0.00015,
|
||||
"stress_yy": 0.00015,
|
||||
"stress_xy": 0.00008,
|
||||
}
|
||||
# Injection state hint — set by external controller (e.g. injector script)
|
||||
# via POST /set_injection_state. Defaults to UNKNOWN.
|
||||
injection_state = "UNKNOWN" # one of: ACTIVE, INACTIVE, UNKNOWN
|
||||
injection_lock = threading.Lock()
|
||||
|
||||
|
||||
def signal_handler(sig, frame):
|
||||
global running
|
||||
@@ -160,10 +191,19 @@ def format_window_for_prompt(stats, latest):
|
||||
lines.append(f"cycle={latest.get('cycle','?')} omega={latest.get('omega','?')} khra={latest.get('khra_amp','?')} gixx={latest.get('gixx_amp','?')}")
|
||||
lines.append(f"gpu={latest.get('gpu_temp_c','?')}C {latest.get('gpu_power_w','?')}W util={latest.get('gpu_util_pct','?')}%")
|
||||
lines.append("")
|
||||
lines.append(f"{'metric':<16} {'now':>10} {'mean':>10} {'delta':>10} {'range':>10}")
|
||||
lines.append("-"*58)
|
||||
# Header with baseline + z-score columns so the model has a fixed reference
|
||||
lines.append(f"{'metric':<16} {'now':>11} {'baseline':>11} {'std':>10} {'z':>7} {'flag':>5}")
|
||||
lines.append("-"*68)
|
||||
for f, s in stats.items():
|
||||
lines.append(f"{f:<16} {s['now']:>10.6f} {s['mean']:>10.6f} {s['delta']:>+10.6f} {s['range']:>10.6f}")
|
||||
now = s['now']
|
||||
bmean = BASELINE_MEAN.get(f)
|
||||
bstd = BASELINE_STD.get(f)
|
||||
if bmean is not None and bstd and bstd > 0:
|
||||
z = (now - bmean) / bstd
|
||||
flag = "!!" if abs(z) >= 3 else ("!" if abs(z) >= 2 else "")
|
||||
lines.append(f"{f:<16} {now:>+11.6f} {bmean:>+11.6f} {bstd:>10.6f} {z:>+7.2f} {flag:>5}")
|
||||
else:
|
||||
lines.append(f"{f:<16} {now:>+11.6f} {'-':>11} {'-':>10} {'-':>7} {'':>5}")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
@@ -221,15 +261,27 @@ def observe():
|
||||
cycle = latest.get("cycle", 0)
|
||||
|
||||
window_str = format_window_for_prompt(stats, latest)
|
||||
past_str = format_past_observations(past_observations)
|
||||
with injection_lock:
|
||||
inj_state = injection_state
|
||||
|
||||
prompt = f"""CURRENT WINDOW ({len(telemetry_window)} frames):
|
||||
# past_observations dropped from auto-observe prompt 2026-06-08:
|
||||
# chronicle contains stale narratives from gemma3:4b + the
|
||||
# confabulating qwen runs; replaying them anchors new responses
|
||||
# to the same hallucination. The baseline column in window_str
|
||||
# gives the model its reference instead.
|
||||
prompt = f"""INJECTION STATE: {inj_state}
|
||||
- ACTIVE = external market data is being injected this minute
|
||||
- INACTIVE = pure substrate; do NOT narrate buy/sell or market effects
|
||||
- UNKNOWN = controller has not declared; assume INACTIVE
|
||||
|
||||
CURRENT WINDOW ({len(telemetry_window)} frames, global scalars only —
|
||||
no spatial resolution):
|
||||
{window_str}
|
||||
|
||||
PAST OBSERVATIONS (most recent last):
|
||||
{past_str}
|
||||
|
||||
What patterns do you see? What is repeating or changing?"""
|
||||
Report in 3-6 sentences of present-tense prose. Call out channels
|
||||
flagged with ! or !! (|z| >= 2 vs quiescent baseline). If nothing is
|
||||
flagged, say the substrate is in its quiescent operating range and
|
||||
stop — do not invent activity to fill the report."""
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": SYSTEM},
|
||||
@@ -274,6 +326,8 @@ class FractonautHandler(BaseHTTPRequestHandler):
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == "/status":
|
||||
with injection_lock:
|
||||
inj_state = injection_state
|
||||
self._json({
|
||||
"running": running, "model": MODEL,
|
||||
"frame_count": frame_count, "turn_count": turn_count,
|
||||
@@ -282,6 +336,7 @@ class FractonautHandler(BaseHTTPRequestHandler):
|
||||
"cycle": latest_tel.get("cycle",0) if latest_tel else 0,
|
||||
"coherence": latest_tel.get("coherence",0) if latest_tel else 0,
|
||||
"asymmetry": latest_tel.get("asymmetry",0) if latest_tel else 0,
|
||||
"injection_state": inj_state,
|
||||
"last_obs_chars": len(last_obs_text),
|
||||
"port": API_PORT,
|
||||
})
|
||||
@@ -303,7 +358,8 @@ class FractonautHandler(BaseHTTPRequestHandler):
|
||||
self._json({"response": last_obs_text, "turn": turn_count})
|
||||
else:
|
||||
self._json({"service":"Fractonaut","port":API_PORT,
|
||||
"endpoints":["/status","/last","/chronicle?last=N","POST /ask"]})
|
||||
"endpoints":["/status","/last","/chronicle?last=N",
|
||||
"POST /ask","POST /set_injection_state"]})
|
||||
|
||||
def do_POST(self):
|
||||
if self.path == "/ask":
|
||||
@@ -321,6 +377,18 @@ class FractonautHandler(BaseHTTPRequestHandler):
|
||||
self._json({"error":"queue full"},503); return
|
||||
evt.wait(timeout=180)
|
||||
self._json({"response": holder["response"], "turn": turn_count, "model": MODEL})
|
||||
elif self.path == "/set_injection_state":
|
||||
global injection_state
|
||||
length = int(self.headers.get("Content-Length",0))
|
||||
body = self.rfile.read(length)
|
||||
try: data = json.loads(body)
|
||||
except: self._json({"error":"bad json"},400); return
|
||||
st = str(data.get("state","")).upper().strip()
|
||||
if st not in ("ACTIVE","INACTIVE","UNKNOWN"):
|
||||
self._json({"error":"state must be ACTIVE|INACTIVE|UNKNOWN"},400); return
|
||||
with injection_lock:
|
||||
injection_state = st
|
||||
self._json({"injection_state": st})
|
||||
else:
|
||||
self._json({"error":"unknown"},404)
|
||||
|
||||
@@ -397,13 +465,19 @@ def main():
|
||||
stats = compute_window_stats(telemetry_window)
|
||||
latest = telemetry_window[-1] if telemetry_window else {}
|
||||
window_str = format_window_for_prompt(stats, latest)
|
||||
with injection_lock:
|
||||
inj_state = injection_state
|
||||
# Past observations dropped from /ask prompt 2026-06-08:
|
||||
# they were polluting context with stale baseline-range
|
||||
# references from the previous gemma3:4b chronicle. The
|
||||
# caller's question already carries all required context.
|
||||
prompt = (
|
||||
f"INJECTION STATE: {inj_state}\n"
|
||||
f" - ACTIVE = external market data is being injected this minute\n"
|
||||
f" - INACTIVE = pure substrate; do NOT narrate buy/sell or market effects\n"
|
||||
f" - UNKNOWN = controller has not declared; assume INACTIVE\n\n"
|
||||
f"QUESTION: {item['question']}\n\n"
|
||||
f"LIVE TELEMETRY (most recent frame in window):\n{window_str}"
|
||||
f"LIVE TELEMETRY (global scalars only \u2014 no spatial resolution):\n{window_str}"
|
||||
)
|
||||
messages = [
|
||||
{"role":"system","content":SYSTEM},
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
"""fractonaut_calibrate.py - regression test for Fractonaut.
|
||||
|
||||
Run AFTER restarting Fractonaut with the new prompt. Drives the lattice
|
||||
through 4 known states, declares the injection state to Fractonaut, asks
|
||||
for an observation, grades it for forbidden/required patterns.
|
||||
"""
|
||||
import zmq, json, time, urllib.request, sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
CMD_PORT = 5557
|
||||
FRACTO_API = "http://127.0.0.1:28822"
|
||||
DWELL_BASELINE = 90
|
||||
DWELL_STATE = 240
|
||||
INJ_INTERVAL = 60
|
||||
LEFT_X, RIGHT_X, CENTER_Y, SIGMA = 400, 624, 512, 48
|
||||
|
||||
OUT_DIR = Path(f"/mnt/d/Resonance_Engine/traj/calibrate_{datetime.now().strftime('%Y%m%dT%H%M%S')}")
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
OUT_FILE = OUT_DIR / "calibration.jsonl"
|
||||
|
||||
ctx = zmq.Context()
|
||||
cmd = ctx.socket(zmq.PUB)
|
||||
cmd.connect(f"tcp://127.0.0.1:{CMD_PORT}")
|
||||
time.sleep(0.5)
|
||||
|
||||
def send(d):
|
||||
cmd.send_string(json.dumps(d)); time.sleep(0.05)
|
||||
|
||||
def log(m):
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] {m}", flush=True)
|
||||
|
||||
def set_inj(state):
|
||||
body = json.dumps({"state": state}).encode()
|
||||
req = urllib.request.Request(f"{FRACTO_API}/set_injection_state",
|
||||
data=body, headers={"Content-Type":"application/json"}, method="POST")
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=5) as r:
|
||||
return json.loads(r.read())
|
||||
except Exception as e:
|
||||
log(f" WARN set_inj({state}) failed: {e}")
|
||||
return None
|
||||
|
||||
def ask(question, timeout=180):
|
||||
body = json.dumps({"question": question}).encode()
|
||||
req = urllib.request.Request(f"{FRACTO_API}/ask",
|
||||
data=body, headers={"Content-Type":"application/json"}, method="POST")
|
||||
t0 = time.time()
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=timeout) as r:
|
||||
return json.loads(r.read()).get("response",""), time.time()-t0
|
||||
except Exception as e:
|
||||
return f"(error: {e})", time.time()-t0
|
||||
|
||||
FORBIDDEN_ALWAYS = [
|
||||
"left site","right site","left half","right half",
|
||||
"pushed harder","side dominant","side is dominant",
|
||||
"collapse","decay","amplifying trend",
|
||||
"the buy side","the sell side",
|
||||
]
|
||||
FORBIDDEN_QUIESCENT = ["buy","sell","market","injection","inject","pulse"]
|
||||
REQUIRED_QUIESCENT = ["quiescent","baseline","within","operating range","operating point"]
|
||||
REQUIRED_ACTIVE = ["inject","pulse"]
|
||||
|
||||
# Phrases that flip a forbidden word into a denial / negation context.
|
||||
# If the forbidden word appears within ~50 chars after any of these, it's
|
||||
# NOT an assertive claim and should be allowed.
|
||||
DENIAL_MARKERS = [
|
||||
"no ", "not ", "without ", "rather than ", "no longer ",
|
||||
"absence of ", "absent", "any directional ", "any external ",
|
||||
"any market ", "any inject", "any pulse", "any buy", "any sell",
|
||||
]
|
||||
|
||||
def _is_denied(text_lower, word_pos, word):
|
||||
"""Return True if the occurrence of `word` at word_pos in text_lower
|
||||
appears in a denial context (preceded within ~80 chars by a denial marker)."""
|
||||
window_start = max(0, word_pos - 80)
|
||||
preceding = text_lower[window_start:word_pos]
|
||||
for marker in DENIAL_MARKERS:
|
||||
if marker in preceding:
|
||||
return True
|
||||
return False
|
||||
|
||||
def _find_assertive(text_lower, word):
|
||||
"""Find the first occurrence of `word` that is NOT in a denial context.
|
||||
Returns the position, or -1 if all occurrences are denied."""
|
||||
start = 0
|
||||
while True:
|
||||
pos = text_lower.find(word, start)
|
||||
if pos == -1:
|
||||
return -1
|
||||
if not _is_denied(text_lower, pos, word):
|
||||
return pos
|
||||
start = pos + 1
|
||||
|
||||
def grade(state, response):
|
||||
r = response.lower()
|
||||
fails = []
|
||||
for f in FORBIDDEN_ALWAYS:
|
||||
if f in r:
|
||||
pos = r.find(f)
|
||||
if not _is_denied(r, pos, f):
|
||||
fails.append(f"forbidden_always: '{f}'")
|
||||
if state in ("BASELINE","KHRA_ELEVATED","GIXX_ELEVATED"):
|
||||
for f in FORBIDDEN_QUIESCENT:
|
||||
if _find_assertive(r, f) != -1:
|
||||
fails.append(f"forbidden_in_quiescent (assertive): '{f}'")
|
||||
if state == "BASELINE":
|
||||
if not any(req in r for req in REQUIRED_QUIESCENT):
|
||||
fails.append("missing_required_quiescent")
|
||||
if state == "ALL_ON":
|
||||
# For ALL_ON we need at least one ASSERTIVE mention of injection
|
||||
if not any(_find_assertive(r, req) != -1 for req in REQUIRED_ACTIVE):
|
||||
fails.append("missing_required_active (assertive)")
|
||||
return ("PASS" if not fails else "FAIL"), fails
|
||||
|
||||
def run_state(name, khra, gixx, inject, dwell, inj_state):
|
||||
log(f"=== STATE: {name} khra={khra} gixx={gixx} inject={inject} inj_state={inj_state} ===")
|
||||
send({"cmd":"set_khra_amp","amp":khra})
|
||||
send({"cmd":"set_gixx_amp","amp":gixx})
|
||||
set_inj(inj_state)
|
||||
log(f" dwell {dwell}s...")
|
||||
t_start = time.time()
|
||||
deadline = t_start + dwell
|
||||
next_inj = t_start
|
||||
while time.time() < deadline:
|
||||
if inject and time.time() >= next_inj:
|
||||
send({"cmd":"inject_density","x":LEFT_X,"y":CENTER_Y,"sigma":SIGMA,"strength":+0.15})
|
||||
send({"cmd":"inject_density","x":RIGHT_X,"y":CENTER_Y,"sigma":SIGMA,"strength":-0.15})
|
||||
log(f" injected dipole at t+{int(time.time()-t_start)}s")
|
||||
next_inj = time.time() + INJ_INTERVAL
|
||||
time.sleep(1)
|
||||
q = (f"State {name}. Describe the substrate right now in 3-5 sentences. "
|
||||
f"Only call out channels flagged with ! or !!. If nothing is flagged, "
|
||||
f"say the substrate is in its quiescent operating range and stop.")
|
||||
resp, took = ask(q)
|
||||
verdict, fails = grade(name, resp)
|
||||
log(f" [{name}] fracto ({took:.1f}s) {verdict}")
|
||||
for f in fails:
|
||||
log(f" FAIL: {f}")
|
||||
log(f" response: {resp[:300]}{'...' if len(resp)>300 else ''}")
|
||||
with open(OUT_FILE, "a") as fh:
|
||||
fh.write(json.dumps({
|
||||
"ts": datetime.now().isoformat(),
|
||||
"state": name, "khra": khra, "gixx": gixx, "inject": inject,
|
||||
"inj_state": inj_state, "verdict": verdict, "fails": fails,
|
||||
"response": resp, "took_s": took,
|
||||
}) + "\n")
|
||||
return verdict
|
||||
|
||||
def main():
|
||||
log("=== fractonaut_calibrate ===")
|
||||
log(f"out: {OUT_DIR}")
|
||||
try:
|
||||
with urllib.request.urlopen(f"{FRACTO_API}/status", timeout=5) as r:
|
||||
st = json.loads(r.read())
|
||||
log(f"fracto OK: model={st['model']} cycle={st['cycle']} inj_state={st.get('injection_state','?')}")
|
||||
except Exception as e:
|
||||
log(f"FATAL: Fractonaut not reachable: {e}")
|
||||
sys.exit(1)
|
||||
verdicts = []
|
||||
try:
|
||||
verdicts.append(("BASELINE", run_state("BASELINE", 0.030, 0.008, False, DWELL_BASELINE, "INACTIVE")))
|
||||
verdicts.append(("KHRA_ELEVATED", run_state("KHRA_ELEVATED", 0.050, 0.008, False, DWELL_STATE, "INACTIVE")))
|
||||
verdicts.append(("GIXX_ELEVATED", run_state("GIXX_ELEVATED", 0.030, 0.024, False, DWELL_STATE, "INACTIVE")))
|
||||
verdicts.append(("ALL_ON", run_state("ALL_ON", 0.050, 0.024, True, DWELL_STATE, "ACTIVE")))
|
||||
finally:
|
||||
log("=== RESTORE baseline ===")
|
||||
send({"cmd":"set_khra_amp","amp":0.030})
|
||||
send({"cmd":"set_gixx_amp","amp":0.008})
|
||||
set_inj("UNKNOWN")
|
||||
log(" (finally) baseline restored")
|
||||
log("")
|
||||
log("=== SUMMARY ===")
|
||||
p = sum(1 for _,v in verdicts if v=="PASS")
|
||||
f = sum(1 for _,v in verdicts if v=="FAIL")
|
||||
for n,v in verdicts:
|
||||
log(f" {n:<16} {v}")
|
||||
log(f" TOTAL: {p} PASS / {f} FAIL")
|
||||
log(f" file: {OUT_FILE}")
|
||||
sys.exit(0 if f==0 else 1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,212 @@
|
||||
"""inject_strength_sweep.py - find what perturbation finally moves global
|
||||
telemetry. Kernel clamps: strength in [-1.0, 1.0], sigma in [1.0, 256.0].
|
||||
Keep contacts intact (LEFT_X=400, RIGHT_X=624). Pin strength at clamp
|
||||
max (1.0) and frequency at every 5s. Sweep sigma 48 -> 96 -> 160 -> 256
|
||||
to vary the spatial footprint while staying within kernel limits.
|
||||
|
||||
Geometry: LEFT_X=400, RIGHT_X=624, CENTER_Y=512 (unchanged).
|
||||
Per state: declare ACTIVE, fire bipolar dipole every 5s for 3 min,
|
||||
collect all telemetry, ask Fractonaut at end, dump z-scored summary.
|
||||
|
||||
Safety: try/finally restores Khra=0.030/Gixx=0.008 and inj_state=UNKNOWN.
|
||||
Does NOT modify Khra/Gixx amplitudes during the run.
|
||||
"""
|
||||
import zmq, json, time, urllib.request, sys, statistics
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
CMD_PORT = 5557
|
||||
TEL_PORT = 5556
|
||||
FRACTO_API = "http://127.0.0.1:28822"
|
||||
LEFT_X, RIGHT_X, CENTER_Y = 400, 624, 512
|
||||
STRENGTH = 1.0 # clamp max
|
||||
DWELL_S = 180 # 3 min per state
|
||||
INJ_INTERVAL_S = 5 # fire every 5s
|
||||
SIGMAS = [48, 96, 160, 256] # baseline -> kernel max
|
||||
|
||||
BASELINE_STD = {
|
||||
"asymmetry": 3.0,
|
||||
"coherence": 0.005,
|
||||
"vel_mean": 0.005,
|
||||
"vel_max": 0.008,
|
||||
"vel_var": 0.0004,
|
||||
"vorticity_mean": 0.012,
|
||||
"stress_xx": 0.00015,
|
||||
"stress_yy": 0.00015,
|
||||
"stress_xy": 0.00008,
|
||||
}
|
||||
BASELINE_MEAN = {
|
||||
"asymmetry": 116.67,
|
||||
"coherence": 0.6047,
|
||||
"vel_mean": 0.2106,
|
||||
"vel_max": 0.2854,
|
||||
"vel_var": 0.002429,
|
||||
"vorticity_mean": 0.0265,
|
||||
"stress_xx": -0.000795,
|
||||
"stress_yy": 0.000731,
|
||||
"stress_xy": -0.000263,
|
||||
}
|
||||
|
||||
OUT_DIR = Path(f"/mnt/d/Resonance_Engine/traj/inject_sweep_{datetime.now().strftime('%Y%m%dT%H%M%S')}")
|
||||
OUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
OUT_FILE = OUT_DIR / "sweep.jsonl"
|
||||
LOG_FILE = OUT_DIR / "sweep.log"
|
||||
|
||||
ctx = zmq.Context()
|
||||
cmd = ctx.socket(zmq.PUB)
|
||||
cmd.connect(f"tcp://127.0.0.1:{CMD_PORT}")
|
||||
tel = ctx.socket(zmq.SUB)
|
||||
tel.connect(f"tcp://127.0.0.1:{TEL_PORT}")
|
||||
tel.setsockopt_string(zmq.SUBSCRIBE, "")
|
||||
time.sleep(1.0)
|
||||
|
||||
def log(m):
|
||||
line = f"[{datetime.now().strftime('%H:%M:%S')}] {m}"
|
||||
print(line, flush=True)
|
||||
with open(LOG_FILE, "a") as f:
|
||||
f.write(line + "\n")
|
||||
|
||||
def send(d):
|
||||
cmd.send_string(json.dumps(d)); time.sleep(0.05)
|
||||
|
||||
def set_inj(state):
|
||||
body = json.dumps({"state": state}).encode()
|
||||
req = urllib.request.Request(f"{FRACTO_API}/set_injection_state",
|
||||
data=body, headers={"Content-Type":"application/json"}, method="POST")
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=5) as r:
|
||||
return json.loads(r.read())
|
||||
except Exception as e:
|
||||
log(f" WARN set_inj({state}) failed: {e}")
|
||||
|
||||
def ask(question, timeout=180):
|
||||
body = json.dumps({"question": question}).encode()
|
||||
req = urllib.request.Request(f"{FRACTO_API}/ask",
|
||||
data=body, headers={"Content-Type":"application/json"}, method="POST")
|
||||
t0 = time.time()
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=timeout) as r:
|
||||
return json.loads(r.read()).get("response",""), time.time()-t0
|
||||
except Exception as e:
|
||||
return f"(error: {e})", time.time()-t0
|
||||
|
||||
def drain():
|
||||
out = []
|
||||
while True:
|
||||
try:
|
||||
out.append(json.loads(tel.recv_string(zmq.NOBLOCK)))
|
||||
except zmq.Again:
|
||||
return out
|
||||
|
||||
def summarize(frames):
|
||||
if not frames: return {}
|
||||
keys = list(BASELINE_MEAN.keys())
|
||||
out = {}
|
||||
for k in keys:
|
||||
vals = [f[k] for f in frames if k in f]
|
||||
if vals:
|
||||
mu = statistics.mean(vals)
|
||||
sd = statistics.stdev(vals) if len(vals) > 1 else 0.0
|
||||
bmean = BASELINE_MEAN[k]
|
||||
bstd = BASELINE_STD[k]
|
||||
z_mean = (mu - bmean) / bstd if bstd else 0.0
|
||||
out[k] = {
|
||||
"mean": mu,
|
||||
"stdev": sd,
|
||||
"min": min(vals),
|
||||
"max": max(vals),
|
||||
"n": len(vals),
|
||||
"z_vs_baseline_mean": z_mean,
|
||||
"stdev_ratio_vs_baseline": (sd / bstd) if bstd else 0.0,
|
||||
}
|
||||
return out
|
||||
|
||||
def run_state(sigma):
|
||||
name = f"SIGMA_{sigma}_STR_{STRENGTH}"
|
||||
log(f"=== {name} dwell={DWELL_S}s every {INJ_INTERVAL_S}s ===")
|
||||
set_inj("ACTIVE")
|
||||
drain()
|
||||
t_start = time.time()
|
||||
deadline = t_start + DWELL_S
|
||||
next_inj = t_start
|
||||
collected = []
|
||||
n_injections = 0
|
||||
while time.time() < deadline:
|
||||
if time.time() >= next_inj:
|
||||
send({"cmd":"inject_density","x":LEFT_X,"y":CENTER_Y,"sigma":sigma,"strength":+STRENGTH})
|
||||
send({"cmd":"inject_density","x":RIGHT_X,"y":CENTER_Y,"sigma":sigma,"strength":-STRENGTH})
|
||||
n_injections += 1
|
||||
if n_injections <= 3 or n_injections % 12 == 0:
|
||||
log(f" dipole #{n_injections} at t+{int(time.time()-t_start)}s sigma={sigma} str=+/-{STRENGTH}")
|
||||
next_inj = time.time() + INJ_INTERVAL_S
|
||||
collected.extend(drain())
|
||||
time.sleep(1)
|
||||
summary = summarize(collected)
|
||||
log(f" collected {len(collected)} frames; {n_injections} dipole injections")
|
||||
flagged = []
|
||||
for k, s in summary.items():
|
||||
z = s["z_vs_baseline_mean"]
|
||||
sr = s["stdev_ratio_vs_baseline"]
|
||||
flag = ""
|
||||
if abs(z) >= 2 or sr >= 2:
|
||||
flag = " !!"
|
||||
elif abs(z) >= 1 or sr >= 1.5:
|
||||
flag = " !"
|
||||
log(f" {k:<16} mean={s['mean']:>+12.6f} z={z:>+7.2f} std_ratio={sr:>5.2f}{flag}")
|
||||
if flag:
|
||||
flagged.append((k, z, sr))
|
||||
q = (f"INJECTION STATE is ACTIVE. Bipolar dipoles fired at "
|
||||
f"(x={LEFT_X},y={CENTER_Y}) and (x={RIGHT_X},y={CENTER_Y}) "
|
||||
f"every {INJ_INTERVAL_S}s for {DWELL_S}s at sigma={sigma}, "
|
||||
f"strength=+/-{STRENGTH}. Describe what you observe in 3-5 "
|
||||
f"sentences. Only call out flagged channels. If nothing is "
|
||||
f"flagged, say the substrate did not respond and stop.")
|
||||
resp, took = ask(q)
|
||||
log(f" fracto ({took:.1f}s): {resp[:300]}{'...' if len(resp)>300 else ''}")
|
||||
rec = {
|
||||
"ts": datetime.now().isoformat(),
|
||||
"sigma": sigma, "strength": STRENGTH,
|
||||
"interval_s": INJ_INTERVAL_S, "dwell_s": DWELL_S,
|
||||
"n_injections": n_injections,
|
||||
"n_frames": len(collected),
|
||||
"summary": summary,
|
||||
"flagged": flagged,
|
||||
"fracto": resp,
|
||||
"fracto_took_s": took,
|
||||
}
|
||||
with open(OUT_FILE, "a") as fh:
|
||||
fh.write(json.dumps(rec) + "\n")
|
||||
return rec
|
||||
|
||||
def main():
|
||||
log(f"=== inject_strength_sweep ===")
|
||||
log(f"out: {OUT_DIR}")
|
||||
try:
|
||||
with urllib.request.urlopen(f"{FRACTO_API}/status", timeout=5) as r:
|
||||
st = json.loads(r.read())
|
||||
log(f"fracto OK: model={st['model']} cycle={st['cycle']}")
|
||||
except Exception as e:
|
||||
log(f"FATAL: Fractonaut unreachable: {e}")
|
||||
sys.exit(1)
|
||||
results = []
|
||||
try:
|
||||
for s in SIGMAS:
|
||||
results.append(run_state(s))
|
||||
finally:
|
||||
log("=== RESTORE baseline ===")
|
||||
send({"cmd":"set_khra_amp","amp":0.030})
|
||||
send({"cmd":"set_gixx_amp","amp":0.008})
|
||||
set_inj("UNKNOWN")
|
||||
log(" (finally) baseline restored")
|
||||
log("")
|
||||
log("=== SUMMARY ===")
|
||||
log(f"{'sigma':>6} {'asym_z':>8} {'coh_z':>8} {'velvar_z':>10} {'sxx_z':>8} {'sxy_z':>8} {'flagged':>8}")
|
||||
for r in results:
|
||||
s = r["summary"]
|
||||
sg = lambda k: s.get(k,{}).get("z_vs_baseline_mean", 0)
|
||||
log(f"{r['sigma']:>6} {sg('asymmetry'):>+8.2f} {sg('coherence'):>+8.2f} {sg('vel_var'):>+10.2f} {sg('stress_xx'):>+8.2f} {sg('stress_xy'):>+8.2f} {len(r['flagged']):>8}")
|
||||
log(f"file: {OUT_FILE}")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,4 @@
|
||||
{"ts": "2026-06-08T18:08:15.987593", "state": "BASELINE", "khra": 0.03, "gixx": 0.008, "inject": false, "inj_state": "INACTIVE", "verdict": "PASS", "fails": [], "response": "The lattice remains in a laminar flow regime with low velocity variance and minimal vorticity, consistent with a quiescent operating point. Asymmetry and coherence are fluctuating within their typical structural bounds, showing no significant decoupling from the baseline floor. The stress_xy channel exhibits standard circulating shear magnitude, while stress_yy maintains its expected positive polarity without meaningful sign change. All metrics reside comfortably within the quiescent operating range, and the substrate is not exhibiting any unusual behavior relative to its steady non-equilibrium state.", "took_s": 2.1717069149017334}
|
||||
{"ts": "2026-06-08T18:12:18.668628", "state": "KHRA_ELEVATED", "khra": 0.05, "gixx": 0.008, "inject": false, "inj_state": "INACTIVE", "verdict": "FAIL", "fails": ["forbidden_in_quiescent: 'market'", "forbidden_in_quiescent: 'injection'", "forbidden_in_quiescent: 'inject'"], "response": "The substrate remains in its quiescent operating range with no external injection active. Global scalars show minor fluctuations within typical bounds, where the persistent xx>yy stress magnitude ratio reflects the hard-coded geometric anisotropy rather than any directional market pressure. The slight elevation in velocity mean and asymmetry stays well within the substrate's natural oscillation floor, and no stress channels are flagged as unusual. Consequently, the lattice continues its steady non-equilibrium state without exhibiting genuine instability or external forcing effects.", "took_s": 2.251275062561035}
|
||||
{"ts": "2026-06-08T18:16:20.902740", "state": "GIXX_ELEVATED", "khra": 0.03, "gixx": 0.024, "inject": false, "inj_state": "INACTIVE", "verdict": "FAIL", "fails": ["forbidden_in_quiescent: 'injection'", "forbidden_in_quiescent: 'inject'"], "response": "The substrate remains in its quiescent operating range with no external injection active. The flagged velocity mean deviation is a minor fluctuation within the normal envelope of the steady non-equilibrium state. Stress channels show no meaningful sign changes or magnitude shifts beyond the structural baseline where xx exceeds yy due to forcing geometry. The system exhibits its characteristic persistent asymmetry and coherence without any genuine unusual behavior relative to the quiescent substrate.", "took_s": 2.0337119102478027}
|
||||
{"ts": "2026-06-08T18:20:24.092605", "state": "ALL_ON", "khra": 0.05, "gixx": 0.024, "inject": true, "inj_state": "ACTIVE", "verdict": "PASS", "fails": [], "response": "The substrate remains in a laminar flow regime with no significant turbulence, as velocity variance and mean vorticity stay within their typical operating ranges. While the asymmetry metric shows a slight positive deviation, it remains well within the structural floor established by the forcing geometry, and the stress channels exhibit only negligible fluctuations around their baseline magnitudes. The stress_xy channel maintains its standard circulating shear magnitude without any meaningful sign change or amplification, and the stress_yy value continues to reflect the inherent anisotropy of the lattice. Since no telemetry flags are active, the system is operating in its quiescent state despite the declared injection status, showing no genuine unusual behavior relative to the substrate's natural oscillation.", "took_s": 2.6676812171936035}
|
||||
@@ -0,0 +1,2 @@
|
||||
{"ts": "2026-06-08T18:28:48.536267", "sigma": 48, "strength": 1.0, "interval_s": 5, "dwell_s": 180, "n_injections": 35, "n_frames": 1232, "summary": {"asymmetry": {"mean": 141.07589155844155, "stdev": 9.276689640029284, "min": 119.2718, "max": 154.5452, "n": 1232, "z_vs_baseline_mean": 8.135297186147184, "stdev_ratio_vs_baseline": 3.092229880009761}, "coherence": {"mean": 0.5697394480519481, "stdev": 0.010295487438484857, "min": 0.5579, "max": 0.6038, "n": 1232, "z_vs_baseline_mean": -6.992110389610384, "stdev_ratio_vs_baseline": 2.059097487696971}, "vel_mean": {"mean": 0.22124856574675325, "stdev": 0.0013060117281935614, "min": 0.217634, "max": 0.223818, "n": 1232, "z_vs_baseline_mean": 2.129713149350648, "stdev_ratio_vs_baseline": 0.26120234563871225}, "vel_max": {"mean": 0.30258075243506494, "stdev": 0.13323530245526388, "min": 0.282214, "max": 2.464164, "n": 1232, "z_vs_baseline_mean": 2.1475940543831187, "stdev_ratio_vs_baseline": 16.654412806907985}, "vel_var": {"mean": 0.0024459430275974026, "stdev": 0.00011312339703450551, "min": 0.00226478, "max": 0.0047159, "n": 1232, "z_vs_baseline_mean": 0.042357568993505984, "stdev_ratio_vs_baseline": 0.2828084925862638}, "vorticity_mean": {"mean": 0.027390934253246752, "stdev": 0.003646887859622457, "min": 0.022138, "max": 0.03309, "n": 1232, "z_vs_baseline_mean": 0.07424452110389608, "stdev_ratio_vs_baseline": 0.30390732163520473}, "stress_xx": {"mean": -0.0008197053571428572, "stdev": 9.618439526070554e-05, "min": -0.001656, "max": -0.000209, "n": 1232, "z_vs_baseline_mean": -0.164702380952381, "stdev_ratio_vs_baseline": 0.6412293017380369}, "stress_yy": {"mean": 0.0007708417207792208, "stdev": 5.1663946732706726e-05, "min": 0.000444, "max": 0.000983, "n": 1232, "z_vs_baseline_mean": 0.26561147186147205, "stdev_ratio_vs_baseline": 0.3444263115513782}, "stress_xy": {"mean": -0.0002735852272727273, "stdev": 4.880829265892982e-05, "min": -0.000672, "max": 1.3e-05, "n": 1232, "z_vs_baseline_mean": -0.13231534090909122, "stdev_ratio_vs_baseline": 0.6101036582366227}}, "flagged": [["asymmetry", 8.135297186147184, 3.092229880009761], ["coherence", -6.992110389610384, 2.059097487696971], ["vel_mean", 2.129713149350648, 0.26120234563871225], ["vel_max", 2.1475940543831187, 16.654412806907985]], "fracto": "The substrate exhibits a transient response to the bipolar injection, marked by a significant deviation in global asymmetry and a dip in coherence relative to the baseline operating point. While the mean velocity shows a slight upward shift, the variance and vorticity remain within their typical fluctuation ranges, indicating the flow regime has not transitioned to turbulence. The circulating shear stress_xy has increased in magnitude, and the normal stress_yy maintains its positive polarity without any meaningful sign change or structural collapse. These fluctuations represent a localized perturbation that has not yet propagated into a sustained global instability across the lattice.", "fracto_took_s": 2.483484983444214}
|
||||
{"ts": "2026-06-08T18:31:51.569654", "sigma": 96, "strength": 1.0, "interval_s": 5, "dwell_s": 180, "n_injections": 35, "n_frames": 1233, "summary": {"asymmetry": {"mean": 277.5186282238443, "stdev": 61.589463744004995, "min": 153.9762, "max": 373.6478, "n": 1233, "z_vs_baseline_mean": 53.6162094079481, "stdev_ratio_vs_baseline": 20.529821248001664}, "coherence": {"mean": 0.4701735604217356, "stdev": 0.031662004530679515, "min": 0.4383, "max": 0.5618, "n": 1233, "z_vs_baseline_mean": -26.905287915652885, "stdev_ratio_vs_baseline": 6.332400906135903}, "vel_mean": {"mean": 0.22138624249797242, "stdev": 0.0014457019832684133, "min": 0.214126, "max": 0.223697, "n": 1233, "z_vs_baseline_mean": 2.1572484995944827, "stdev_ratio_vs_baseline": 0.28914039665368263}, "vel_max": {"mean": 0.30474966666666664, "stdev": 0.15378068948741264, "min": 0.283023, "max": 2.346342, "n": 1233, "z_vs_baseline_mean": 2.4187083333333317, "stdev_ratio_vs_baseline": 19.22258618592658}, "vel_var": {"mean": 0.0024548498296836983, "stdev": 0.00025981773195867436, "min": 0.00225572, "max": 0.00647837, "n": 1233, "z_vs_baseline_mean": 0.06462457420924536, "stdev_ratio_vs_baseline": 0.6495443298966859}, "vorticity_mean": {"mean": 0.027181673154906733, "stdev": 0.0036836931187224646, "min": 0.021818, "max": 0.0338, "n": 1233, "z_vs_baseline_mean": 0.05680609624222783, "stdev_ratio_vs_baseline": 0.3069744265602054}, "stress_xx": {"mean": -0.0009724533657745337, "stdev": 0.0003279314640352889, "min": -0.0029, "max": 0.000657, "n": 1233, "z_vs_baseline_mean": -1.183022438496891, "stdev_ratio_vs_baseline": 2.1862097602352595}, "stress_yy": {"mean": 0.0008695733982157339, "stdev": 0.00016859498557756855, "min": 6e-06, "max": 0.001644, "n": 1233, "z_vs_baseline_mean": 0.9238226547715598, "stdev_ratio_vs_baseline": 1.1239665705171238}, "stress_xy": {"mean": -0.0003350016220600162, "stdev": 0.00015466964165379977, "min": -0.001258, "max": 0.000434, "n": 1233, "z_vs_baseline_mean": -0.9000202757502026, "stdev_ratio_vs_baseline": 1.933370520672497}}, "flagged": [["asymmetry", 53.6162094079481, 20.529821248001664], ["coherence", -26.905287915652885, 6.332400906135903], ["vel_mean", 2.1572484995944827, 0.28914039665368263], ["vel_max", 2.4187083333333317, 19.22258618592658], ["stress_xx", -1.183022438496891, 2.1862097602352595], ["stress_xy", -0.9000202757502026, 1.933370520672497]], "fracto": "The substrate exhibits a marked departure from its baseline operating point, characterized by a significant spike in global asymmetry and a concurrent drop in coherence. While the mean velocity shows a slight increase, the variance and vorticity remain within normal fluctuation bounds, indicating the flow regime has not transitioned to turbulence. The stress tensor reveals a meaningful shift in the yy channel, which has changed sign relative to its typical positive baseline, whereas the xx channel magnitude remains consistent with its structural anisotropy. The circulating shear stress in the xy channel shows a minor deviation but does not constitute a flagged anomaly. Overall, the system is responding to the bipolar injection with a distinct alteration in its stress balance and coherence coupling, rather than a fundamental instability.", "fracto_took_s": 2.8921711444854736}
|
||||
@@ -0,0 +1,43 @@
|
||||
[18:25:45] === inject_strength_sweep ===
|
||||
[18:25:45] out: /mnt/d/Resonance_Engine/traj/inject_sweep_20260608T182544
|
||||
[18:25:45] fracto OK: model=qwen3.5:9b cycle=12885870
|
||||
[18:25:45] === SIGMA_48_STR_1.0 dwell=180s every 5s ===
|
||||
[18:25:45] dipole #1 at t+0s sigma=48 str=+/-1.0
|
||||
[18:25:51] dipole #2 at t+6s sigma=48 str=+/-1.0
|
||||
[18:25:57] dipole #3 at t+11s sigma=48 str=+/-1.0
|
||||
[18:26:43] dipole #12 at t+57s sigma=48 str=+/-1.0
|
||||
[18:27:45] dipole #24 at t+119s sigma=48 str=+/-1.0
|
||||
[18:28:45] collected 1232 frames; 35 dipole injections
|
||||
[18:28:45] asymmetry mean= +141.075892 z= +8.14 std_ratio= 3.09 !!
|
||||
[18:28:46] coherence mean= +0.569739 z= -6.99 std_ratio= 2.06 !!
|
||||
[18:28:46] vel_mean mean= +0.221249 z= +2.13 std_ratio= 0.26 !!
|
||||
[18:28:46] vel_max mean= +0.302581 z= +2.15 std_ratio=16.65 !!
|
||||
[18:28:46] vel_var mean= +0.002446 z= +0.04 std_ratio= 0.28
|
||||
[18:28:46] vorticity_mean mean= +0.027391 z= +0.07 std_ratio= 0.30
|
||||
[18:28:46] stress_xx mean= -0.000820 z= -0.16 std_ratio= 0.64
|
||||
[18:28:46] stress_yy mean= +0.000771 z= +0.27 std_ratio= 0.34
|
||||
[18:28:46] stress_xy mean= -0.000274 z= -0.13 std_ratio= 0.61
|
||||
[18:28:48] fracto (2.5s): The substrate exhibits a transient response to the bipolar injection, marked by a significant deviation in global asymmetry and a dip in coherence relative to the baseline operating point. While the mean velocity shows a slight upward shift, the variance and vorticity remain within their typical flu...
|
||||
[18:28:48] === SIGMA_96_STR_1.0 dwell=180s every 5s ===
|
||||
[18:28:48] dipole #1 at t+0s sigma=96 str=+/-1.0
|
||||
[18:28:53] dipole #2 at t+5s sigma=96 str=+/-1.0
|
||||
[18:28:58] dipole #3 at t+10s sigma=96 str=+/-1.0
|
||||
[18:29:45] dipole #12 at t+57s sigma=96 str=+/-1.0
|
||||
[18:30:48] dipole #24 at t+119s sigma=96 str=+/-1.0
|
||||
[18:31:48] collected 1233 frames; 35 dipole injections
|
||||
[18:31:48] asymmetry mean= +277.518628 z= +53.62 std_ratio=20.53 !!
|
||||
[18:31:48] coherence mean= +0.470174 z= -26.91 std_ratio= 6.33 !!
|
||||
[18:31:48] vel_mean mean= +0.221386 z= +2.16 std_ratio= 0.29 !!
|
||||
[18:31:48] vel_max mean= +0.304750 z= +2.42 std_ratio=19.22 !!
|
||||
[18:31:48] vel_var mean= +0.002455 z= +0.06 std_ratio= 0.65
|
||||
[18:31:48] vorticity_mean mean= +0.027182 z= +0.06 std_ratio= 0.31
|
||||
[18:31:48] stress_xx mean= -0.000972 z= -1.18 std_ratio= 2.19 !!
|
||||
[18:31:48] stress_yy mean= +0.000870 z= +0.92 std_ratio= 1.12
|
||||
[18:31:48] stress_xy mean= -0.000335 z= -0.90 std_ratio= 1.93 !
|
||||
[18:31:51] fracto (2.9s): The substrate exhibits a marked departure from its baseline operating point, characterized by a significant spike in global asymmetry and a concurrent drop in coherence. While the mean velocity shows a slight increase, the variance and vorticity remain within normal fluctuation bounds, indicating th...
|
||||
[18:31:51] === SIGMA_160_STR_1.0 dwell=180s every 5s ===
|
||||
[18:31:51] dipole #1 at t+0s sigma=160 str=+/-1.0
|
||||
[18:31:56] dipole #2 at t+5s sigma=160 str=+/-1.0
|
||||
[18:32:01] dipole #3 at t+10s sigma=160 str=+/-1.0
|
||||
[18:32:48] dipole #12 at t+57s sigma=160 str=+/-1.0
|
||||
[18:33:51] dipole #24 at t+119s sigma=160 str=+/-1.0
|
||||
Reference in New Issue
Block a user