Move LOD JSON behind diagnostics
This commit is contained in:
parent
320afc42c1
commit
94d6109bda
8 changed files with 34 additions and 15 deletions
|
|
@ -103,8 +103,8 @@ shape removes independent per-kind storage from the live foundation.
|
|||
## Next
|
||||
|
||||
1. Delete remaining production dependence on `scripts/diagnostic_live_sensor_fusion.py`,
|
||||
`localcast.diagnostics.spout_output`, JSON render-frame stores, JSON LOD
|
||||
stores, and Python reservoir-window clipping.
|
||||
`localcast.diagnostics.spout_output`, diagnostic JSON render-frame adapters,
|
||||
diagnostic JSON LOD adapters, and Python reservoir-window clipping.
|
||||
2. Bind Aquarium/Faust to the rolling-buffer `LocalcastRuntime`.
|
||||
3. Move camera/mic/loopback ingest into native capture workers that append
|
||||
typed sample handles.
|
||||
|
|
|
|||
|
|
@ -101,7 +101,15 @@ sensor observation
|
|||
|
||||
The cache is not a bucket. `TrackCache` has a TTL and confidence update rule so the system can buffer and converge without pretending stale points are fresh. The live frame reservoir is explicitly five seconds wide: frame history expires from the newest shared sample, LOD evidence is clipped to that same interval, and each `RenderFramePacket` reports the exact source window. Later GPU buffers should mirror this shape: observation SoA, track SoA, material/BRDF estimate SoA, brush packet SoA.
|
||||
|
||||
`visual-lod-cache.json` is the current CPU-authored shape for the next compute pass. It is not the final renderer. It groups stochastic/fused scene claims into multiple world-space voxel sizes, carrying center, radius, confidence, count, source-time bounds, and first-pass material estimates. The material channel is deliberately modest: weighted albedo plus roughness/metallic hints so Aquarium can start relighting brush/splat packets without treating screen-space color as the whole truth. A later shader pass should replace those hints with multi-view BRDF fitting inside the same reservoir.
|
||||
`visual-lod-cache.json` is the diagnostic CPU-authored shape for the next
|
||||
compute pass. JSON serialization lives under `localcast.diagnostics.lod_json`,
|
||||
not in the mapping model. It groups stochastic/fused scene claims into multiple
|
||||
world-space voxel sizes, carrying center, radius, confidence, count, source-time
|
||||
bounds, and first-pass material estimates. The material channel is deliberately
|
||||
modest: weighted albedo plus roughness/metallic hints so Aquarium can start
|
||||
relighting brush/splat packets without treating screen-space color as the whole
|
||||
truth. A later shader pass should replace those hints with multi-view BRDF
|
||||
fitting inside the same reservoir.
|
||||
|
||||
## Test Boundaries
|
||||
|
||||
|
|
|
|||
11
localcast/diagnostics/lod_json.py
Normal file
11
localcast/diagnostics/lod_json.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from localcast.sensor_fusion.stochastic_mapping import MultiLODSceneCache
|
||||
|
||||
|
||||
def write_lod_cache_json(path: Path, cache: MultiLODSceneCache) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(cache.to_dict(), indent=2), encoding="utf-8")
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Iterable, Sequence
|
||||
|
||||
import numpy as np
|
||||
|
|
@ -136,10 +134,6 @@ class MultiLODSceneCache:
|
|||
],
|
||||
}
|
||||
|
||||
def write_json(self, path: Path) -> None:
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(json.dumps(self.to_dict(), indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def pixel_scene_ray(camera: CameraModel, uv: np.ndarray, timestamp_ns: int, confidence: float = 1.0) -> SceneRay:
|
||||
point = np.asarray([float(uv[0]), float(uv[1]), 1.0], dtype=np.float64)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ from localcast.diagnostics.visual_cache import (
|
|||
put_live_clap_events,
|
||||
put_live_render_frame,
|
||||
)
|
||||
from localcast.diagnostics.lod_json import write_lod_cache_json
|
||||
from localcast.sensor_fusion.camera_control import AdaptiveCameraController, OpenCvCameraSettingPort
|
||||
from localcast.sensor_fusion.adapters import LatestFramePump, OpenCvCaptureConfig, OpenCvFrameSource
|
||||
from audio_field.cultcache_audio import frame_to_numpy, get_live_audio_phase_field, get_live_spatial_audio_frame
|
||||
|
|
@ -1290,11 +1291,12 @@ def main() -> None:
|
|||
reservoir_ns=reservoir_ns,
|
||||
)
|
||||
source_time_min_ns, source_time_max_ns = reservoir_window_ns(reservoir_edge_ns, reservoir_ns)
|
||||
multilod_cache_from_evidence(
|
||||
lod_cache = multilod_cache_from_evidence(
|
||||
evidence,
|
||||
levels=(0.01, 0.04, 0.16, 0.64),
|
||||
created_monotonic_ns=time.monotonic_ns(),
|
||||
).write_json(lod_cache_path)
|
||||
)
|
||||
write_lod_cache_json(lod_cache_path, lod_cache)
|
||||
frame = RenderFramePacket(
|
||||
schema=frame.schema,
|
||||
frame_id=frame.frame_id,
|
||||
|
|
|
|||
|
|
@ -60,3 +60,4 @@
|
|||
{"ts": "2026-05-19T09:11:35+01:00", "type": "implementation", "status": "ok", "note": "Native reservoir provenance guard added: LocalcastSampleHandle now carries flags/reserved fields, diagnostic samples are rejected by localcast_reservoir_push and LocalcastRuntime producer calls, and tests prove fallback/diagnostic handles cannot enter the live rolling buffer."}
|
||||
{"ts": "2026-05-19T09:25:00+01:00", "type": "implementation", "status": "partial", "note": "Python visual CultCache file adapter quarantined under localcast.diagnostics.visual_cache and removed from localcast.sensor_fusion exports; diagnostic producer/Spout/tests now import it explicitly. Import guard passed, but bundled Python cannot run visual-cache round-trip tests because msgpack is not installed."}
|
||||
{"ts": "2026-05-19T09:36:00+01:00", "type": "implementation", "status": "ok", "note": "RenderFramePacket no longer owns JSON file serialization. Compatibility JSON load/write moved to localcast.diagnostics.render_frame_json, diagnostic Spout and sparse-fusion scripts import it explicitly, and tests/import guards prove the production packet module is typed data only."}
|
||||
{"ts": "2026-05-19T09:45:00+01:00", "type": "implementation", "status": "ok", "note": "MultiLODSceneCache no longer owns JSON file serialization. Diagnostic LOD writes moved to localcast.diagnostics.lod_json, diagnostic_live_sensor_fusion imports that adapter explicitly, and tests/import guards prove stochastic_mapping is model/algorithm code only."}
|
||||
|
|
|
|||
|
|
@ -242,9 +242,11 @@ research:
|
|||
`localcast.visual.stream_status` in
|
||||
`calibration/runs/visual-stream-status.msgpack`. Production visual state
|
||||
crosses native/CultNet typed document boundaries; the Python file adapter
|
||||
is not live authority. Edge JSON may define schemas or export
|
||||
diagnostics, but runtime data should remain typed documents because every
|
||||
networked subsystem is under our control.
|
||||
is not live authority. Diagnostic JSON render-frame and LOD writers live
|
||||
under `localcast.diagnostics`; model modules do not own file
|
||||
serialization. Edge JSON may define schemas or export diagnostics, but
|
||||
runtime data should remain typed documents because every networked
|
||||
subsystem is under our control.
|
||||
|
||||
current_status:
|
||||
summary: >
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ from localcast.sensor_fusion.stochastic_mapping import (
|
|||
stochastic_transient_matches,
|
||||
)
|
||||
from localcast.sensor_fusion.surface_features import SurfaceFeatureObservation
|
||||
from localcast.diagnostics.lod_json import write_lod_cache_json
|
||||
|
||||
|
||||
def camera(sensor_id, x):
|
||||
|
|
@ -94,7 +95,7 @@ class StochasticMappingTests(unittest.TestCase):
|
|||
self.assertTrue(any(cell.level == 1 and cell.count == 2 for cell in cache.cells))
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
path = Path(tmp) / "lod.json"
|
||||
cache.write_json(path)
|
||||
write_lod_cache_json(path, cache)
|
||||
self.assertIn("multilod_scene_cache", path.read_text(encoding="utf-8"))
|
||||
|
||||
def test_multilod_evidence_prefers_leap_priority(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue