diff --git a/docs/native-rebuild-plan.md b/docs/native-rebuild-plan.md index 5e5c1d0..0afdb66 100644 --- a/docs/native-rebuild-plan.md +++ b/docs/native-rebuild-plan.md @@ -65,7 +65,7 @@ sample has: - arrival timestamp - sequence - payload handle -- provenance flags +- provenance flags, which must be zero for live reservoir samples Typed ring views may exist as indexes over the rolling buffer, but they do not own retention. Expiry happens once, against the reservoir edge. No private diff --git a/docs/perfect-machine.md b/docs/perfect-machine.md index fe253bb..b014157 100644 --- a/docs/perfect-machine.md +++ b/docs/perfect-machine.md @@ -176,8 +176,8 @@ in `native/reservoir/include/localcast_reservoir.h`: - query total length and typed-view length; - read samples by total rolling-buffer index or typed-view index; - query the latest sample for a sensor hash. -- reject diagnostic/probe/fallback samples at the live reservoir boundary via - sample provenance flags. +- reject diagnostic/probe/fallback and unknown-flagged samples at the live + reservoir boundary via sample provenance flags. - create/destroy an opaque `LocalcastRuntime`; - append typed camera/audio/phase/event/render handles through producer calls; - query a native runtime status struct with shared edge, window start, total diff --git a/native/README.md b/native/README.md index 62b21aa..a6c5da2 100644 --- a/native/README.md +++ b/native/README.md @@ -20,8 +20,8 @@ The reservoir ABI is intentionally small: - `LocalcastReservoir` is opaque. - `LocalcastSampleHandle` is sample metadata plus a `payload_handle` and - provenance flags. Samples marked `LOCALCAST_SAMPLE_FLAG_DIAGNOSTIC` are - rejected by the live reservoir. + provenance flags. Live samples must have `flags == 0`; diagnostic or unknown + flagged samples are rejected by the live reservoir. - Sample kind ids match the Perfect Machine reservoir views: camera frame, camera feature, scene ray, surface claim, material claim, audio block, phase claim, event claim, and render packet. diff --git a/native/reservoir/src/lib.rs b/native/reservoir/src/lib.rs index 55d6f45..4d47c5e 100644 --- a/native/reservoir/src/lib.rs +++ b/native/reservoir/src/lib.rs @@ -261,7 +261,7 @@ fn sample_from_handle( } fn is_live_sample(sample: LocalcastSampleHandle) -> bool { - sample.flags & LOCALCAST_SAMPLE_FLAG_DIAGNOSTIC == 0 + sample.flags == 0 } #[unsafe(no_mangle)] @@ -834,6 +834,18 @@ mod tests { localcast_reservoir_destroy(reservoir); } + #[test] + fn c_abi_rejects_unknown_flagged_samples_from_live_reservoir() { + let reservoir = localcast_reservoir_create(DEFAULT_RESERVOIR_NS); + let mut sample = handle(66, 10, 11, 0, 666); + sample.flags = 1 << 30; + + assert!(!localcast_reservoir_push(reservoir, 0, sample)); + assert_eq!(0, localcast_reservoir_len(reservoir)); + + localcast_reservoir_destroy(reservoir); + } + #[test] fn c_abi_rejects_nulls_and_unknown_sample_kinds() { let sample = handle(1, 2, 3, 4, 5); @@ -918,4 +930,19 @@ mod tests { localcast_runtime_destroy(runtime); } + + #[test] + fn runtime_spine_rejects_unknown_flagged_samples() { + let runtime = localcast_runtime_create(DEFAULT_RESERVOIR_NS); + let mut sample = handle(1, 2, 3, 4, 5); + sample.flags = 1 << 30; + + assert!(!localcast_runtime_push_camera_frame(runtime, sample)); + + let mut status = LocalcastRuntimeStatus::default(); + assert!(localcast_runtime_status(runtime, &mut status)); + assert_eq!(0, status.total_sample_count); + + localcast_runtime_destroy(runtime); + } } diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 56deb26..a5eb342 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -61,3 +61,4 @@ {"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."} +{"ts": "2026-05-19T10:02:00+01:00", "type": "implementation", "status": "ok", "note": "Native reservoir tightened sample provenance: live samples must have flags == 0, so diagnostic and unknown future flags are rejected at both raw reservoir and LocalcastRuntime typed producer boundaries. Unknown flags no longer slip through as speculative metadata."}