feat: finalize corrected-route planning and Rerun recording review

This commit is contained in:
DCCONSTRUCTIONS
2026-09-22 10:10:03 +03:00
parent c804d89b18
commit 2e5d52521f
132 changed files with 14141 additions and 898 deletions
+51 -9
View File
@@ -6,13 +6,13 @@ not prove SLAM frame continuity; this remains a laboratory-only protocol.
import numpy as np
from .causal_tracking import CausalTracking
from .causal_tracking import TRACKING_POLICY, CausalTracking
from .live_buffer import LiveCloudBuffer
from .registration import rigid
from .stationary_entry import STATIONARY_POLICY, StationaryPrefix
BOOTSTRAP_POLICY = dict(
version="stationary-fresh-bootstrap/v3",
version="stationary-fresh-bootstrap/v4",
prefix_seconds=10.0,
maximum_motion_m=0.10,
maximum_search_wall_s=30.0,
@@ -58,6 +58,15 @@ class StationaryBootstrap:
self.candidate_index = None
self.dense_start_prior = False
self.retry_route_search = False
self.last_pose_ns = None
self.last_cloud_ns = None
self.search_continuity_proven = False
@property
def continuous_search(self):
return self.initialization_policy.get("hypothesis_freshness") == (
"stationary-receipts-and-disjoint-confirmation/v1"
)
def stop(self, reason):
self.prior = None
@@ -66,6 +75,7 @@ class StationaryBootstrap:
self.candidate_queue = []
self.retry_route_search = False
self.gate.clear(reason)
self.search_continuity_proven = False
self.phase = "lost"
self.reason = reason
@@ -82,6 +92,16 @@ class StationaryBootstrap:
self.stop("source-order-changed")
raise ValueError("Source sequence or receipt clock regressed.")
self.last_event_ns, self.last_sequence = event.monotonic_ns, event.sequence
if event.kind == "pose":
self.last_pose_ns = event.monotonic_ns
if self.phase == "searching" and self.continuous_search:
motion = float(np.linalg.norm(
np.asarray(event.position) - self.prefix.first_position
))
if not np.isfinite(motion) or motion > BOOTSTRAP_POLICY["maximum_motion_m"]:
self.stop("search-motion")
elif event.kind == "points":
self.last_cloud_ns = event.monotonic_ns
if segment != self.segment:
# Worker completion is not a data receipt. A gap straddling that
# instant may finish before the first fresh cloud. No validation has
@@ -99,7 +119,9 @@ class StationaryBootstrap:
if awaiting_first_cloud:
self.segment = segment
self._reset_fresh(self.floor_ns)
elif self.phase in {"refreshing", "validating", "tracking"}:
elif self.phase in {"refreshing", "validating", "tracking"} or (
self.phase == "searching" and self.continuous_search
):
self.stop("receipt-gap")
self.segment = segment
if self.phase == "collecting":
@@ -109,6 +131,16 @@ class StationaryBootstrap:
def tick(self, now_ns, segment):
self.gate.tick(now_ns, segment)
if self.phase == "searching" and self.continuous_search:
# Old geometry may propose a place only while the live scanner is
# still stationary in the same receipt segment. Neither a cloud-only
# nor a pose-only stream can keep a long search alive.
if segment != self.initialization_sample["segment"]:
self.stop("receipt-gap")
elif any(stamp is None or not 0 <= (now_ns - stamp) / 1e9
<= TRACKING_POLICY["maximum_age_s"]
for stamp in (self.last_pose_ns, self.last_cloud_ns)):
self.stop("search-source-stale")
if self.phase in {"validating", "tracking"} and self.gate.reason == "stale":
self.stop("stale")
if self.phase == "refreshing" and (
@@ -129,8 +161,10 @@ class StationaryBootstrap:
return sample, initial, forward, meta
def offer_prior(self, result, now_ns, segment):
self.tick(now_ns, segment)
if self.phase != "searching":
return dict(accepted=False, reason="inactive-initialization", provisional=False)
return dict(accepted=False, reason=self.reason if self.phase == "lost"
else "inactive-initialization", provisional=False)
sample = self.initialization_sample
age = (now_ns - sample["monotonic_ns"]) / 1e9
initialization = result.get("initialization", {})
@@ -158,11 +192,14 @@ class StationaryBootstrap:
or initialization.get("expected_attempts") != len(initialization.get("attempts", []))
):
reason = "initialization-incomplete"
elif not 0 <= (now_ns - self.search_started_ns) / 1e9 <= self.initialization_policy.get(
"maximum_search_wall_s", BOOTSTRAP_POLICY["maximum_search_wall_s"]
elif not self.continuous_search and not (
0 <= (now_ns - self.search_started_ns) / 1e9 <= self.initialization_policy.get(
"maximum_search_wall_s", BOOTSTRAP_POLICY["maximum_search_wall_s"]
)
):
reason = "initialization-expired"
elif not 0 <= age <= BOOTSTRAP_POLICY["maximum_prior_source_age_s"]:
elif age < 0 or (not self.continuous_search
and age > BOOTSTRAP_POLICY["maximum_prior_source_age_s"]):
reason = "prior-source-expired"
elif not 0 <= segment - sample["segment"] <= BOOTSTRAP_POLICY["maximum_pre_ready_gaps"]:
reason = "too-many-receipt-gaps"
@@ -178,6 +215,7 @@ class StationaryBootstrap:
self.stop("initialization-incomplete")
return dict(accepted=False, reason=self.reason, provisional=False, age_s=age)
self.candidate_queue = [dict(item) for item in queue[1:]]
self.search_continuity_proven = self.continuous_search
self.candidate_trial = 1
self.candidate_index = initialization.get("selected_candidate_index")
stages = initialization.get("stages", [])
@@ -196,6 +234,7 @@ class StationaryBootstrap:
provisional=True,
source_segment=sample["segment"],
validation_segment=segment,
stationary_search_continuity=self.search_continuity_proven,
)
def _reset_fresh(self, floor_ns):
@@ -208,10 +247,13 @@ class StationaryBootstrap:
This is available only before tracking. Once tracking is established,
loss must use the ordinary last-confirmed-place recovery instead.
The original prefix's source-age fence is never extended by retries.
The legacy local protocol retains its source-age fence. Whole-route
hypotheses have proved stationary receipt continuity and still need a
new, disjoint current-data trial for EACH candidate.
"""
age = (now_ns - self.initialization_sample["monotonic_ns"]) / 1e9
if not 0 <= age <= BOOTSTRAP_POLICY["maximum_prior_source_age_s"]:
if age < 0 or (not self.search_continuity_proven
and age > BOOTSTRAP_POLICY["maximum_prior_source_age_s"]):
self.stop("prior-source-expired")
return
candidate = self.candidate_queue.pop(0)