Add vector infrastructure maps and persistent location experience

This commit is contained in:
DCCONSTRUCTIONS
2026-10-10 14:35:50 +03:00
parent e095a43f00
commit 55f64f195b
38 changed files with 2317 additions and 14 deletions
+26
View File
@@ -93,6 +93,15 @@ def publish_previews(client, episode, run_id, stopped):
stopped.wait(1)
def publish_experience(client, episode, world_id):
"""Publish the last bounded summary, including the child writer's final flush."""
from k1link.simulation.ai_polygon.spatial_experience import read as read_experience
path = episode / "spatial-experience.json"
if path.exists():
client.request("/worker/worlds/" + world_id + "/spatial-experience", read_experience(path))
def preparation_heartbeat(client, hello, run_id):
"""One-thread lease/control pulse; reconnect only this same expired owner."""
last_poll = -float("inf")
@@ -189,6 +198,7 @@ def main():
"project_assets.py",
"decode_collision.cjs",
"navigation_client.py",
"experience_adapter.py",
"route_view.py",
"observer_camera.py",
"inference_preview.py",
@@ -384,6 +394,7 @@ def main():
raise RuntimeError("An existing episode must never be replayed")
episode = create_episode(args.state, run["run_id"], args.evidence_root)
run_file = episode / "run.json"
run["_spatial_experience_root"] = str(args.state / "spatial-experience")
write_json(run_file, run)
channel = StateChannel(episode)
channel.write("control", run)
@@ -438,6 +449,7 @@ def main():
):
raise ValueError("Saved task and simulation surface identities differ")
run["terrain_manifest"] = str(terrain_path)
run["_spatial_experience_root"] = str(args.state / "spatial-experience")
write_json(run_file, run)
with (episode / "isaac.log").open("wb") as output:
child = subprocess.Popen(
@@ -484,6 +496,8 @@ def main():
stop_deadline = None
last_snapshot = -1
experience_stamp = None
experience_checked = -float("inf")
preview_sender = threading.Thread(
target=publish_previews,
args=(client, episode, run["run_id"], preview_stopped),
@@ -531,6 +545,14 @@ def main():
if snapshot and snapshot["sequence"] > last_snapshot:
client.request("/worker/runs/" + run["run_id"] + "/snapshot", snapshot)
last_snapshot = snapshot["sequence"]
if now-experience_checked >= 5:
experience_checked = now
memory_file = episode / "spatial-experience.json"
if memory_file.exists():
stamp = memory_file.stat().st_mtime_ns
if stamp != experience_stamp:
publish_experience(client, episode, run["world"]["world_id"])
experience_stamp = stamp
except Exception as exc:
registered = False
logging.warning(
@@ -595,6 +617,10 @@ def main():
while True:
try:
client.request("/worker/register", hello)
try:
publish_experience(client, episode, run["world"]["world_id"])
except Exception:
logging.exception("Final location experience sync pending; worker copy retained")
client.request(
"/worker/runs/" + run["run_id"] + "/finish",
finish,