Skip to content

Physical observations, provenance and temporal evidence

Status: internal ingress validation, bounded diagnostics and conservative clock assessment implemented. Existing public payloads remain unchanged. See the audit and world projection for ownership and consumption.

Current implementation

robot.physical.PhysicalObservation now includes a generated observation ID, schema version, optional device/entity/zone and observation time, explicit status, receipt clocks, limitations, provenance and quality metadata. The native adapter uses normalize_measurement for its numeric observations. Supported conversions are Fahrenheit to Celsius, pascals to hectopascals and centimetres to metres; other unsupported units are rejected. Direct CO2 and estimated CO2 have separate quantity identifiers. IDs are generated per accepted envelope; they do not prove upstream message identity. Source availability and staleness remain owned by the existing domain services. No independent observation store is introduced.

The provider ingress performs bounded duplicate and ordering checks. A PHOS observation ID identifies one envelope; an optional upstream_id identifies a message only within the provider, source, device, entity, zone and generation. The latest 512 IDs are retained in RAM per provider. Matching ID and content is dropped; the same ID with different content emits an internal conflict event and is withheld. After eviction, or when no upstream ID is supplied, duplicate detection is unavailable. Equal values are never by themselves duplicates.

The runtime-owned ClockTrustPolicy defaults to no trusted domains. A provider's reliability flag and clock-domain name are claims, not trust. A timestamp is unknown when absent and untrusted unless the locally supplied allowlist, provider declaration and skew against PHOS's independently obtained UTC receipt time all agree. Such a clock is conditionally trusted, not proven accurate. The trusted vocabulary is reserved; the current policy never awards it. Clock decisions accompany the internal Core event and are returned in the internal IngressResult; the observation's source_time_reliable remains the provider's unverified claim, not the assessment. No new runtime configuration is provided. Adapters requiring trusted source-time ordering must be composed with an explicitly reviewed local policy and a meaningful skew bound. No monotonic timestamp is persisted or compared across processes. Receipt-order fallback for untrusted clocks does not establish capture chronology.

Only conditionally trusted timestamps in a named clock domain are compared. Per provider, at most 512 source/entity/zone/generation/quantity keys retain their most recent timestamp and fingerprint. Older arrivals are withheld; equal timestamps with the same content remain accepted when no message identity establishes a duplicate. Equal timestamps with different content, changed clock domain, or missing/unreliable time after reliable time emit a conflict and are withheld. Timezone offsets are normalized by Python's aware datetime comparison. The skew check cannot establish clock synchronization or infer chronology from receipt time. A process restart loses ordering evidence, and a generation change starts a new scope. At capacity, new timestamped scopes are rejected with an ordering_capacity conflict rather than evicting ordering evidence. Late observations do not enter the current history or produce transitions. The provider behavior retains up to 128 detached in-memory conflict/rejection records, with reason, identity, time, and for conflicts bounded incoming and previous fingerprints. Its internal diagnostics() returns copies. Entries are evicted oldest first and cleared when the runtime object is discarded; they are not persisted or exposed via MCP/REST. The existing Core event still provides the immediate conflict cue.

Native serial messages provide neither source timestamps nor reliable message IDs. Their capture time and upstream ID remain unknown, identical periodic values are accepted, and order is receipt order. A future backward-compatible protocol revision could add optional device boot/session identity, sequence and timestamp with explicitly documented clock semantics; no such extension is implemented.

Validated vocabulary and limitations

normalize_measurement validates numeric scalar values and explicit units; validate_semantic_value additionally checks enumerated and three-axis values. Validation availability does not advertise a device capability. Existing native temperature, humidity, pressure, estimated CO2, TVOC and AQI identifiers retain their meanings. The generic particulate_ug_m3 identifier does not specify a size and cannot substitute for a PM1, PM2.5 or PM10 observation.

Quantities Type and canonical unit Accepted alternative units and limitations
temperature_c, aht21_temperature_c finite number, c f converted by (f-32)*5/9; no calibration claim
humidity_percent finite number 0–100, %rh relative humidity only
pressure_hpa finite number, hpa pa divided by 100; atmospheric pressure
co2_ppm, eco2_ppm nonnegative number, ppm direct measurement and estimate remain distinct
voc_ppb, tvoc_ppb nonnegative number, ppb individual VOC and aggregate TVOC remain distinct; no chemistry inferred
pm1_ug_m3, pm2_5_ug_m3, pm10_ug_m3, particulate_ug_m3 nonnegative number, ug/m3 no size inferred for generic particulate
aqi_uba integer 1–5, index existing UBA scale only
illuminance_lux, distance_m nonnegative number, lx or m distance accepts cm divided by 100
acceleration_m_s2, angular_velocity_dps, vibration_m_s2 finite scalar, m/s2, deg/s, m/s2 vibration is nonnegative; frame and filtering are source-specific
acceleration_vector_m_s2, angular_velocity_vector_dps, orientation finite three-number tuple, m/s2, deg/s, deg orientation is three angles; reference frame/convention must be supplied separately
presence, occupancy, motion enumerated strings, no unit respectively present/absent, occupied/unoccupied, moving/stationary, plus unknown; no cross-inference
contact, proximity enumerated strings, no unit open/closed and near/far respectively, plus unknown; thresholds source-specific

PhysicalProviderBehavior applies validate_observation before duplicate tracking, events, domain state, history or transition handling. It validates numeric, enumerated and vector quantities, plus existing native motion, orientation and ENS160 availability shapes. It rejects unsupported quantities; additional types require an explicit mapping, validator and tests. Unit conversions preserve original value/unit when they differ, and an already canonical value is not converted again. Invalid input produces a bounded IngressResult and a rejection diagnostic without retaining the input value. Unavailable and unknown measurements require no value; invalid status is rejected. Native runtime sensor handlers ignore unavailable, unknown and stale measurement/motion payloads rather than treating them as current values. Unknown, unavailable, stale and invalid are distinct status values; this foundation does not invent missing observations, values, confidence or capture timestamps.

src/robot/sensors.py holds typed readings, per-family availability and freshness, including partial ENS160/AHT21 usability. src/robot/vision/pipeline.py and vision/object_awareness.py distinguish captured frames, snapshot freshness and bounded semantic observations. These types are useful existing domain models; they need not be replaced with a single universal dictionary.

services/temporal_history.py::Measurement retains metric, numeric value, unit, observed_at, source, and quality. Current source values such as environmental and air_quality identify semantic domains, not unique physical devices. Sampling is keyed by metric. observed_at is PHOS receipt/retention time, not a verified sensor capture time. Transition records confirmed semantic state changes. PhysicalContextAssessmentService explicitly reports receipt-time semantics and checks continuity; retain that distinction.

Proposed internal envelope

Keep existing domain reading types. Add enough validated metadata at ingress to track the following conceptual fields; exact Python types/names require the first implementation review. This is not a new API schema.

Field Meaning and constraint
Observation ID PHOS-assigned bounded opaque reference, unique within runtime epoch; upstream packet IDs cannot select it
Physical source ID Stable configured logical source; independent of protocol/endpoint and distinct from an agent ID
Provider instance and generation Administrative provenance and replay boundary, not proof of physical authenticity
Upstream entity/message reference Optional bounded private metadata used for mapping/deduplication; no raw topic/host leakage to agents
Quantity and typed value Approved metric/event vocabulary and compatible finite scalar, enum or domain object; never executable content
Unit Canonical unit and conversion revision; reject unknown or dimensionally incompatible conversions
Space binding Optional configured space ID plus binding revision; unknown when not configured
Received time PHOS UTC for display/correlation and monotonic time for freshness/order within this process
Source time Optional device-reported capture time with explicit trust/skew classification; never silently substituted for receipt time
Validity/quality Distinguish accepted value, unavailable, stale, invalid, cached/unverified and evidence loss; quality is not a synthetic confidence percentage
Sequence/lineage Optional device sequence plus PHOS receipt order; aliases identify the same physical upstream source
Privacy class Explicit configured restriction for environmental versus occupancy/perception evidence; not an upstream permission grant

Availability/status transitions carry no fabricated numeric value. An invalid packet does not replace a last known value with zero or refresh its TTL. Last known values may remain diagnostically accessible only with their actual stale or unavailable status. Freshness and accuracy are separate: a fresh measurement may be biased or poorly located.

Observation flow and validation

flowchart TD
  packet[Untrusted provider candidate] --> bounds[Bound framing and parse cost]
  bounds --> binding[Validate source mapping and active generation]
  binding --> types[Validate types units ranges and clocks]
  types --> accepted[Accepted typed observation with provenance]
  accepted --> current[Existing domain current snapshot]
  accepted --> retained[Existing history admission and bounds]
  current --> semantics[Deterministic domain interpretation]
  semantics --> transition[Existing qualified semantic transition]
  retained --> evidence[Evidence readiness assessment]
  types -->|Rejected| diagnostics[Redacted bounded diagnostic counters]

Require maximum frame/payload/string/nesting/source limits before allocating large structures. Reject booleans as numbers, NaN/infinity, incompatible units, unknown mappings and retired sessions. Apply domain plausibility/range rules without pretending a plausible value proves a trusted sensor. Native protocol validation remains in its adapter; do not broaden or tighten the wire contract incidentally while introducing internal metadata.

Identical accepted periodic values still refresh source freshness. Deduplicate transport replays using identity/sequence when available, separately from the existing semantic event deduplication. Repeated “23 degrees” measurements and a repeated confirmed transition have different meanings.

Time, continuity and history evolution

Use monotonic receipt clocks for TTLs, backoff and in-process ordering. Use UTC timestamps for human/agent correlation; wall-clock corrections cannot extend validity. An untrusted future source timestamp cannot keep data fresh forever. Missing/old/implausibly future device time is explicitly unverified. Device boot, session retirement, sequence reset, mapping/location revision and queue loss can break evidence continuity even when numerical values match.

Current history bounds are defined in temporal_history.py: six hours, at most one retained sample per metric per minute, 360 samples per metric, at most 16 metrics, and 500 transitions. Queries return at most 360 records. Preserve current public behavior until a documented migration is implemented.

Multi-source support must extend the same service to key sampling/retention by source plus metric and runtime epoch as needed. It must introduce an explicit global sample/source/memory budget rather than granting every new source the full old allowance. Eviction, truncation and ingress loss must be visible to assessment. No new historian/database or durable event store is proposed.

Legacy metric-only history calls must resolve the existing canonical source by an explicit compatibility mapping. They must not mix room temperatures or switch sources silently. Source-aware calls, if needed later, require an additive versioned contract. Existing domain source strings retain their meaning in legacy responses; do not quietly redefine them as device IDs.

summary.coverage == sufficient currently means more than one returned sample; it is not a continuity guarantee. pci-01a requires stronger sample/coverage/gap checks and verifies recovery boundaries where possible. Keep these contracts; new readiness rules need their own version and must disclose whether evidence was dropped or a recovery boundary is unknown.

Facts, assessments and unknown information

Category Example Required qualification
Observed fact A mapped sensor reported a temperature value Source/space, canonical unit, receipt age, validity and source-time trust
Confirmed semantic observation Existing presence interpreter changed to person_present Confirmation policy and camera visibility limits; no person identity or exact arrival claim
Derived mathematical evidence Retained samples have a positive last-minus-first delta Window, count, source continuity and gaps; no inferred cause
Derived condition Existing environmental policy reports an air-quality warning Rule/version and contributing observations; not a certified safety assessment
Unknown No current mapped observation, conflicting values, or insufficient retained evidence Explicit reason; never “normal”, “absent”, or zero by default

Do not treat eCO2 as directly measured CO2, IMU intensity as speed, expression labels as human emotions, or a camera's no-face result as room vacancy. Interpretations must retain evidence lineage; an external agent's explanation must not be written back as a sensor fact.

Privacy, compatibility and acceptance

Retain only compact approved observations and transitions in RAM. Do not add frames, audio, transcripts, credentials, person identity, raw packets, network addresses or topic payloads to history. Agent-visible provenance uses opaque evidence references and permitted semantic source/space labels, filtered by policy. Administrative provenance stays behind existing administrative access.

Extend tests/test_physical_context.py, test_temporal_history.py, test_physical_assessment.py, and controller generation/freshness tests using injected monotonic/UTC clocks. Cover independent equal-metric sources, alias duplicates, equal periodic values, clock jumps, replay/out-of-order delivery, source relocation, partial sensor updates, retention eviction, unknown units, global memory bounds and recovery gaps. Assert unchanged legacy serialization and no media/secrets in returned evidence.