Skip to content

Development Guide

Local development

The application should support a development mode that does not require Raspberry Pi hardware.

Use interfaces and fakes/mocks for hardware.

Start contributing

This repository does not define a single reproducible environment for every optional subsystem. The package metadata declares Python >=3.10: the base source uses Python 3.10 union syntax. Feature requirements are intentionally more specific:

Scope Minimum Python Support status
Base package and MQTT 3.10 Metadata-compatible; the MQTT library itself supports older Python, but PHOS does not.
Vision and voice extras 3.10 Platform/provider dependencies still determine whether the feature can run. Python 3.13 additionally installs audioop-lts.
MCP and ESPHome Native API extras 3.11 Enforced by dependency markers.
Full Raspberry Pi installer, CI, and documented Pi baseline 3.11 The installer enforces this version; this is the tested baseline.

The Raspberry Pi OS installation has platform-specific camera and hardware dependencies; a workstation can run hardware-independent tests and selected services with their optional dependencies, but cannot establish physical acceptance. The matrix does not claim that every OS or Python version in a metadata range has been tested.

The repository's documented web-development environment uses a virtual environment and the web extra with pytest. From a checkout, the commands are:

python3 -m venv .venv
.venv/bin/python -m pip install -e '.[web]' pytest
.venv/bin/python -m pytest -q

The last command runs the configured test suite; it is not the CI's exact validation invocation. CI installs .[web,mcp,aws,voice], pytest and the documentation requirements before running the full suite. Add the optional dependency group needed by the subsystem under development. The repository has no separate dev extra, dependency lock file, or declared cross-platform matrix. Do not copy deployment secrets into a working configuration. The canonical config/phos.yaml is a complete example and may enable behavior that is unsuitable for a workstation; tests should use their temporary configs and fakes where available.

Repository orientation

Start with Architecture, then use the subsystem guide for the area being changed. The robot package is under src/robot/; tests mirror the main boundaries under tests/. The broad ownership map is:

Area Source location Useful starting point
Composition and runtime src/robot/main.py, src/robot/runtime.py build_runtime() and PhosRuntime
Core state and behavior src/robot/core/ RobotCore, EventBus, BehaviorEngine
Configuration and lifecycle src/robot/config.py, src/robot/lifecycle.py RuntimeConfig, ConfigRepository, LifecycleService
Application and physical semantics src/robot/services/, src/robot/physical.py PhosApplicationService, PhysicalProvider
Hardware adapters src/robot/hardware/, src/robot/sensors.py provider protocols and sensor services
Vision and voice src/robot/vision/, src/robot/voice/, src/robot/interaction/ provider interfaces and pipelines
User interfaces src/robot/ui/, src/robot/web/, src/robot/mcp/ renderer, Web Admin adapter and MCP adapter
Tests tests/, tests/core/, tests/ui/, tests/vision/, tests/ai/ focused tests for the changed boundary

This is an orientation aid, not a promise that every subsystem is active in the default configuration. Keep new adapter work behind the existing application and provider boundaries; Architecture and accepted decisions describe their responsibilities.

Workstation development and Raspberry Pi validation

Most unit and service tests use fakes and do not require a Pi. Use the focused test module for the changed area, for example:

.venv/bin/python -m pytest -q tests/test_config.py

pyproject.toml configures pytest to discover tests/ and add src to the import path. Tests that exercise optional SDKs or Pi devices may need the corresponding extra or platform packages. A passing hardware-free test does not verify camera, display, GPIO, I2C, audio, serial wiring, timing, or physical performance. Record those checks separately on the target Raspberry Pi using the relevant subsystem procedure.

For a source-checkout runtime invocation, the existing entry point is:

PYTHONPATH=src python3 -m robot.main --config config/phos.yaml

This starts the configured runtime and is not a hardware-free smoke test; the selected configuration and installed providers determine what it attempts to open. Do not run it against a production configuration as a substitute for focused tests.

Logging and debugging

Runtime logging uses the canonical logging.level and optional logging.file settings. Startup writes logs to standard output and, when configured, to the selected file. Consult the sanitized startup, subsystem, and availability messages first; targeted subsystem diagnostics are controlled by their existing configuration where provided. Never include credentials, bearer tokens, raw camera/audio data, or secret-bearing configuration in issue reports. See the security policy for private vulnerability reporting and Contributing for sanitized defect reports.

Extension and contribution path

Extend the closest existing boundary and its tests instead of introducing a parallel mechanism. Examples include PhysicalProvider implementations registered through runtime composition, typed sensor-provider protocols, CameraProvider and ExpressionProvider, LLMProvider, TTSProvider and STTProvider, and the existing skin manifest/catalogue lifecycle. These are implemented extension points, but their public stability is not guaranteed unless documented as a contract. Hardware and external integrations require their own dependencies and, when applicable, physical or service-side evidence.

Use the repository's contribution guide for focused issue and pull-request expectations. Public contracts and architecture changes should be proposed against accepted decisions before implementation. For documentation edits, follow the documentation guide. There is no repository-defined formatter, linter, type checker, pre-commit hook, or mandatory branch-name convention in the checked-in tooling.

Configuration

The dedicated Skins configuration reference distinguishes portable skin.yaml manifests, the local YAML catalog, and runtime skin-selection settings. Follow Installing and Activating Skins for the supported lifecycle paths.

config/phos.yaml is the canonical configuration and complete example. It is the source for configuration values and defaults; RuntimeConfig in src/robot/config.py defines the typed validation surface. The current file contains these top-level sections: web, mqtt, esphome, mcp, agents, appearance, display, led_ring, presence, attention, interaction, voice, tts, touch, hardware_controller, startup, behavior, vision, expression, expression_reactions, object_awareness, sensors, and logging. Optional capabilities are controlled by their configuration; their presence in the schema does not mean they are enabled.

See the canonical file for the complete structure and defaults. To start from the repository root:

PYTHONPATH=src python3 -m robot.main --config config/phos.yaml

Runtime settings are loaded from one selected YAML file; PHOS does not merge multiple runtime configuration files or automatically overlay settings from environment variables. The CLI retains deprecated, explicit per-setting override flags for compatibility. SDKs may resolve credentials through their own external credential providers. With no --config argument, a source checkout uses its repository config/phos.yaml; an installed package uses its bundled YAML file. A custom --config selects that YAML file instead. Skin catalogues and credentials have their own documented boundaries and are not runtime configuration overlays. To keep a separate deployment copy, copy the full canonical file, edit it and pass its path explicitly. Keep deployment changes out of commits if inappropriate.

The supplied file is the safest starting point for a new installation. The loader applies only explicit compatibility defaults for selected older configuration shapes; it is not a general partial-file merge. Required fields and types are validated, and unknown fields are rejected. The schema includes current runtime, interaction, voice, TTS, hardware-controller, MCP, MQTT and ESPHome settings as well as display and sensor settings. Consult the canonical YAML for values rather than copying an incomplete list of sections. Secret values are stored through SecretsService and must not be put in YAML. Web Admin uses the same canonical model and validation boundary when saving configuration; secret values remain in the separate secret store.

Selected field reference

The table below documents selected sensor, display and behavior fields; it is not a complete schema listing. The complete current field set and defaults are in config/phos.yaml and the typed mapping/validation in src/robot/config.py.

ENS160 and AHT21 are controller-acquired. sensors.ens160 configures the controller-backed air-quality family; public status exposes sensors.ens160 and sensors.aht21. There is no Raspberry Pi ENS160/AHT21 I2C provider or legacy migration path.

Values/defaults are maintained in config/phos.yaml. All numeric values must be finite; booleans must be YAML booleans, not quoted strings or numbers.

Section Fields and purpose
sensors.environmental type: "bme280" or "bmp280"; enabled: boolean; i2c_address: string "0x76" or "0x77" on bus 1; poll_interval_seconds: finite 1–3600 seconds; stale_after_seconds: finite, greater than poll interval and at most 86400 seconds. Freshness is evaluated independently for this sensor family and applies to either local or controller providers; set it comfortably above the controller publication interval when controller-backed. All five require PHOS restart.
sensors.ens160 Controller-backed ENS160 telemetry: enabled, provider: controller, I2C address "0x52" or "0x53", poll and stale timing. ENS160 reports estimated eCO2/TVOC, AQI-UBA (1–5), validity and compensation; AHT21 temperature/humidity arrives through the same controller session.
sensors.imu enabled: boolean; i2c_address: canonical lowercase "0x68" or "0x69", bus 1; poll_interval_seconds: finite 0.05–3600 seconds; stale_after_seconds: finite, greater than poll interval and at most 86400 seconds. Freshness is evaluated independently for this sensor family and applies to either local or controller providers; set it comfortably above the controller publication interval when controller-backed. All four require PHOS restart.
sensors.imu.motion movement_threshold_m_s2, tilt_threshold_m_s2, shake_threshold_deg_s, impact_threshold_m_s2, confirmation_seconds, cooldown_seconds: finite thresholds/timing. Impact must exceed movement. Also required: tilt_exit_threshold_m_s2 (positive, below enter; both at most standard gravity), and distinct signed lateral_axis / forward_axis mounting axes. All motion fields are live-reloadable and do not reinitialize I2C. See installation for normalized threshold semantics.
led_ring (legacy) Retained configuration for the older local LED consumer; it is not the ESP32 semantic LED configuration. Keep enabled: false for the current hardware build. Fields such as gpio_pin, led_count, brightness and per-pixel motion mapping remain validated for compatibility, but do not select the ESP32 data pin, count, or protocol behavior. Configure hardware_controller for the current ring connection; see the controller guide.
behavior IMU fields imu_reaction_strength, imu_tilt_gaze_strength, imu_shake_reaction_strength, and imu_impact_reaction_strength: 0–1; impact strength must exceed shake strength. imu_tilt_eye_asymmetry_strength: 0–0.5 signed-eye delta. Shake/impact duration: 0.1–30 seconds; cooldown: 0–3600 seconds. These eight fields are live-reloadable.
behavior.environmental Optional temperature/eCO2/TVOC interpretation. Temperature enter/exit values provide hysteresis; warning/bad eCO2 and TVOC thresholds ascend. Confirmation and recovery are positive seconds. All fields are live-reloadable and never reopen sensor hardware.
web enabled: start the administration worker; host: IPv4/IPv6 bind address; port: integer 1–65535. See the web manual.
display width, height: positive integer pixel dimensions; fps: positive integer display cadence; fullscreen: fullscreen startup; transition_seconds: positive renderer interpolation duration; iris_color: canonical #RRGGBB; existing presets cyan, blue, green, turquoise, amber, violet and white are accepted as compatibility input and normalized. eye_shape is classic_oval, round, expressive, angular, or compact; effective Skins supply it through the shared appearance lifecycle. base_visual_source is manual, environment, or state. environment_overlays_enabled controls semantic sweat/snow/haze decorations; they never change eye geometry, iris, or LED output. These display fields are live-reloadable.
behavior blink_interval_seconds, gaze_interval_seconds: positive ascending [minimum, maximum] timing ranges; face_gaze_smoothing: gaze smoothing coefficient in (0,1]; reaction_decay_per_second: positive visual reaction decay.
vision face_tracking_enabled: camera/tracking without expression inference; camera_resolution: positive integer [width,height]; capture_fps, detection_fps: positive capture/detection cadences. camera_preview controls optional display-only picture-in-picture, disabled by default; all its fields (enabled, corner position, scale 0.1–0.4, maximum FPS 1–10 and three diagnostic toggles) are live-reloadable.
vision.detector cascade_path: custom readable Haar file or null for existing platform discovery; scale_factor: pyramid scale greater than 1; min_neighbors: nonnegative integer detection support; min_size: positive pixel pair no larger than the camera resolution.
expression enabled: expression processing, also enabling local tracking; provider: local/aws; inference_fps: positive local inference/cloud polling cadence; crop_margin: extra square-crop margin per side in [0,0.5].
expression.smoothing minimum_confidence: additional evidence floor in [0,1]; minimum_observations: positive integer count of distinct samples; local_maximum_gap_seconds: positive maximum gap for local evidence; neutral_enabled: enable neutral perception only after calibration. Cloud maximum gap is derived from its TTL.
expression.local model_path: ONNX path or null; labels: unique, nonempty strings in output order (array may be empty only when local inference is inactive); input_size: positive [width,height]; scale: positive preprocessing multiplier; mean: three finite channel means; swap_rb: swap BGR/RGB; grayscale: existing grayscale preprocessing. When grayscale is true, provider behavior ignores swap_rb.
expression.aws region: nonempty region string or null for external SDK/environment resolution; no credentials.
expression.aws cooldown_seconds: minimum request interval; stable_seconds: eligible local continuity before requesting; refresh_seconds: refresh unchanged input; cache_ttl_seconds: maximum sample age. All positive; refresh must be less than TTL.
expression.aws max_requests_per_minute: positive rate implemented as minimum spacing; max_requests_per_session: nonnegative integer cap, zero means unlimited; change_threshold: normalized crop difference threshold in [0,1]; minimum_face_confidence: AWS face-confidence floor in [0,1].
expression.aws retry_initial_seconds, retry_max_seconds: positive backoff limits, maximum at least initial; connect_timeout_seconds, read_timeout_seconds: positive SDK timeouts.
logging level: DEBUG/INFO/WARNING/ERROR/CRITICAL; file: output path or null for console only; expression_diagnostics: detailed Vision/cloud diagnostics. SDK debug output is suppressed to avoid exposing request/credential metadata.

All configuration paths resolve relative to the selected configuration file's directory. The canonical local path therefore starts with ../models/, and its log path points back to the checkout root. Active local models and explicit active cascades must be readable files. Inactive models need not exist; AWS mode needs no ONNX file. The log parent must already exist and be writable. PHOS does not create arbitrary configuration/model/log directories. ONNX content/model-output compatibility and physical device availability still require runtime verification.

Provider examples

Edit these fields inside the complete file, preserving the other fields. These are illustrative fragments, not additional partial configuration files:

{ "expression": { "enabled": true, "provider": "local" } }

The canonical expression.local block already contains the MobileFaceNet input contract. Download its model using installation. For FER+ rollback use the block in Vision, replacing every preprocessing field rather than depending on former CLI defaults.

{ "expression": { "enabled": true, "provider": "aws" } }

Keep the existing expression.aws block; optionally edit region and request policy. No fallback is supported. All camera selection/cropping stays local; AWS receives selected crops only. See Vision for privacy and policy. AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY and, for temporary credentials, AWS_SESSION_TOKEN are external environment credentials. AWS_REGION / AWS_DEFAULT_REGION, shared SDK profiles and roles are also supported. A null JSON region defers resolution to the external environment/SDK. Parsing never imports boto3, searches for credentials or contacts AWS.

Validation, precedence and migration

MCP agent configuration

agents is a canonical configuration section. Web Admin agent management uses ConfigRepository persistence and replaces the validated runtime registry for subsequent MCP requests; manual configuration edits still follow the normal configuration/reload workflow:

agents:
  default_agent: local-agent
  entries:
    - id: local-agent
      display_name: Local MCP agent
      permission_profile: standard

Each entry has a stable id, optional display name, and one existing permission profile. In credential mode it may also contain a non-secret bearer reference:

credential:
  type: bearer
  secret_ref: mcp.agent_standard.token

secret_ref is resolved only by SecretsService; the actual token must never appear in this file, RuntimeConfig, AgentIdentity, logs, test fixtures, or Web/API responses. If the entire section is absent, compatibility resolves local-agent/standard; if present, malformed entries, duplicate ids, unknown profiles, duplicate credential references, malformed credential records, or an unknown default agent fail configuration loading. When any credential reference is configured, MCP requires a matching bearer token for every request.

MCP credential lifecycle

AgentCredentialService is the administration boundary for MCP bearer credentials. It uses the existing encrypted SecretsService store; there is no second credential database and the configured secret_ref remains stable across rotation. It creates bearer values with secrets.token_urlsafe(32) (256 bits from the operating-system CSPRNG), returning the new value only from the create or rotate operation. Status reports only agent ID, credential type, secret reference, and configured/active state; stored values cannot be read back through this service.

Create rejects an already-active credential, rotate atomically replaces the secret-store value (the old bearer becomes invalid), and revoke removes the secret while retaining the configured agent identity and permission profile. SecretsService is read at authentication time, so these operations take effect without a PHOS restart. Expiry and policy controls remain future hardening work.

Web Admin lifecycle operations must call AgentCredentialService only. They may display a freshly issued bearer once for create/rotate, but status/list APIs and subsequent HTML responses must never retrieve or serialize stored values.

Startup reads one YAML file, applies explicit deprecated CLI overrides, validates schema/types/ranges and active paths, then builds typed settings and constructs subsystems. Invalid YAML, duplicate keys, unknown keys (including secret fields), missing required values and invalid ranges are rejected before camera/display startup. Selected older configuration shapes receive only the explicit compatibility defaults described above; unrelated missing fields are not silently filled. Finite numeric validation also rejects NaN/infinity.

Precedence for supported legacy flags is explicit CLI value > selected YAML value. CLI values have no independent defaults and do not overwrite the file. --expression-provider or --expression-model also enables expression processing for compatibility; --face-tracking enables tracking without changing expression enablement. --aws-region takes precedence over the YAML region; when that value is null, the AWS SDK's environment/profile resolution applies. Configuration paths resolve relative to the selected YAML file; deprecated CLI model-path overrides are resolved from the process working directory.

Retained but deprecated: --face-tracking, --expression-provider, --aws-region, --expression-model, --expression-labels, --expression-input-size, --expression-scale, --expression-mean, --expression-no-swap-rb, --expression-grayscale, --expression-debug, --expression-crop-margin. Help and startup warn about this transition. --config and --help remain the supported primary interface. No runtime flags were removed in this migration. Migrate launch scripts now; remove compatibility flags only in a separately announced breaking change after consumers migrate.

Normal startup accepts only YAML; it does not read or merge JSON configuration. Use the explicit JSON-to-YAML migration tool for a legacy JSON document that already matches the supported RuntimeConfig schema. The tool validates that schema and does not translate arbitrary flat JSON settings. The following table records older flat field names and their canonical YAML destinations for manual conversion; it is not a second schema:

Former field(s) Canonical destination
display_fps, fullscreen display.fps, display.fullscreen
face_tracking_enabled, camera_resolution same names under vision
vision_capture_fps, face_detection_fps vision.capture_fps, vision.detection_fps
expression_provider expression.provider; set expression.enabled explicitly
expression_inference_fps, expression_crop_margin expression.inference_fps, expression.crop_margin
expression_minimum_confidence expression.smoothing.minimum_confidence
expression_model_path, expression_labels, expression_input_size, expression_scale, expression_mean, expression_swap_rb, expression_grayscale expression.local with the expression_ prefix removed
cloud_expression expression.aws (same member names)
expression_diagnostics logging.expression_diagnostics

The current runtime previously combined flat dataclass defaults, CLI overrides, provider configuration, renderer/behavior/detector constructor defaults and hard-coded logging setup. Composition now passes all applicable settings explicitly from the canonical file. Standalone library/demo/benchmark constructor fallbacks remain for compatibility, but are not application configuration sources. Geometric face association gates, class-specific semantic safeguards, visual profiles and SDK JPEG implementation details remain implementation constants. Voice and TTS have canonical configuration sections, while general conversational LLM settings and a composed conversational runtime are not implemented.

Presence and attention configuration

presence.led_reactions controls optional LED-only semantic reactions. Its enabled flag gates the feature; entered defaults to an 800 ms clockwise sweep and left to a 900 ms counter-clockwise sweep. Each nested block has a positive duration_ms and a direction of clockwise or counter_clockwise. attention.lost_hold_ms is a non-negative millisecond hold between a confirmed departure and attention=idle. Presence is below error/sleep and IMU shake/impact transient priority; after a sweep completes, the LED controller resolves the current persistent visual state rather than a cached pre-sweep state.

Older full configuration documents that predate these two known blocks are migrated in memory by explicit default injection before normal exact-key validation. The file is not rewritten merely at startup; the migrated canonical blocks are persisted by the next ordinary configuration save. This is a scoped schema evolution rule: unknown/misspelled keys and unrelated missing fields continue to fail strict validation.

Expression reaction configuration

expression_reactions is a provider-neutral policy for the uncertain ObservedExpression read model. enabled, min_confidence, confirmation_ms, cooldown_ms, and reaction_duration_ms bound whether a supported observation may produce a transient PHOS response. It is not an emotion inference or a direct classifier-to-renderer mapping. Existing complete documents missing this known block receive the scoped default injection above; strict validation still rejects all other missing or unknown fields.

Startup experience configuration

startup.splash.enabled keeps the local face display on a lightweight PHOS startup screen until the runtime reaches ready or acceptable degraded state. startup.splash.image, title, and subtitle configure the deep-navy branded screen. A null image/file selects PHOS's installed robot.assets PNG/WAV; non-null overrides are resolved relative to the loaded phos.yaml, never the process working directory. The screen is deliberately unlike normal eyes and is flushed once before synchronous subsystem startup continues. failed remains on that screen. startup.ready_sound is an optional local WAV file played once with the lightweight system aplay command after the transition; when enabled its file must be readable. The cursor is hidden only on the local Tk face canvas, without disabling touch/pointer events or changing Web Admin. player is currently aplay; optional device is passed as aplay -D DEVICE. At startup, STARTUP ASSETS logs the configured and resolved splash/sound paths plus existence and readability. The Tk loader then logs the image format and dimensions, or its loader exception. The ready-sound log includes the resolved aplay binary, full command, return code, and stderr. For Pi troubleshooting, run that logged command manually (for example aplay -q -D default path/to/ready.wav). The phos.service unit runs python -m robot.main with the explicit canonical %h/phos/config/phos.yaml path and PYTHONPATH=%h/phos/src; it sets no audio-session environment variables. Package defaults therefore do not depend on either the working directory or a developer home directory; ALSA selection is limited to the optional startup.ready_sound.device value. The repository configuration selects the packaged robot.assets/images/neon_phos_logo-startup-800x600.png and robot.assets/audio/phos-startup.wav. run_pi.sh transfers them as part of src/, and a wheel includes them as package data. The helper deliberately preserves an existing Pi configuration; merge the startup block from the repository configuration into an already deployed configuration before expecting these defaults to take effect.

Reusable configuration API and web layer

robot.config.RuntimeConfig is the current typed surface. Cloud settings retain CloudExpressionConfig. Canonical YAML section names are mapped to typed fields at the boundary; raw dictionaries never reach providers or behaviors.

  • load_document(path) reads YAML for an editor without hardware/SDK imports.
  • RuntimeConfig.from_file(path) loads and validates a full file.
  • RuntimeConfig.from_dict(document, base_dir=...) validates edited settings with the same schema/rules, including config-relative paths.
  • config.to_dict() returns the full serializable non-secret structure.
  • config.save(path) validates and atomically replaces a file, rebasing paths if the file moves; a failed validation preserves the old file.

Existing RuntimeConfig(**overrides) and CloudExpressionConfig(**overrides) Python calls overlay the canonical file for compatibility; they contain no independent numeric defaults. Runtime construction revalidates before hardware starts. New application code should use full-file/dict loading instead.

The optional web administration adapter reuses this read/edit/validate/save boundary. It never accepts/stores/displays AWS credentials as normal settings. Its separate password store is not runtime configuration. Provider credentials use the separate SecretsService encrypted store instead: they are not configuration values and are accessed by runtime code only. The web adapter has a deliberately write-only facade that can report whether a known slot is configured, replace it, or remove it; it cannot retrieve the value. General configuration Save does not apply settings. The dedicated MQTT page validates/persists and reconciles broker changes live through the application and lifecycle services; see MQTT broker administration. The lifecycle service can reload logging level, display.iris_color, display.eye_shape, and all vision.camera_preview fields through runtime and display boundaries; MQTT also uses its registered runtime applier on Reload. Other persisted changes require restart. Preview reload waits for runtime acceptance and preserves config-relative paths. The IPC client bounds its response wait to five seconds; a slow native camera start can finish after that timeout, so an unavailable response explicitly reports uncertainty and retires the channel until PHOS restarts. A hardware apply failure is reported; earlier successful appearance changes remain active and pending fields remain visible. This differs from an invalid configuration, which applies nothing. The editor may call from_dict(..., check_paths=False) to repair a removed model path; schema/types/ranges are still validated. Startup and saves always validate active paths. robot.web.domains maps canonical field paths into navigation and presentation only. Page saves merge the selected area's fields into the full document, reject out-of-area fields and run normal full-document validation/atomic persistence. The registry defines no defaults, types or validation rules. New implemented settings must be assigned to a domain; coverage tests require every canonical field to appear exactly once. Read-only General/Status pages cannot save settings. New non-secret runtime options must extend this canonical model/file, not add standalone CLI arguments or another configuration mechanism.

Dependencies

Before adding a dependency, consider:

  1. Is the standard library sufficient?
  2. Is the dependency maintained?
  3. Does it work on Raspberry Pi 3?
  4. Does it materially simplify the implementation?

Testing

Test:

  • state transitions
  • event handling
  • AI tool contracts
  • hardware adapters through fakes
  • error handling

Do not make ordinary unit tests depend on physical GPIO/audio/display hardware.

For web development install .[web] plus pytest in a virtual environment and run python -m pytest -q. Web tests exercise real password hashing, CSRF, configuration persistence and an isolated local WSGI worker without hardware.

Release version and installation

robot.__version__ in src/robot/__init__.py is authoritative. Setuptools derives metadata from that literal, and the checked-in OpenAPI document must declare the same value; the release consistency test enforces both relationships. Do not add another independently maintained application version. Git tags and historical release records identify published history and are not running-version inputs. Source checkouts use config/phos.yaml; wheels install the same YAML asset under the environment's share/phos/config/ data directory. Explicit --config remains the supported deployment boundary; no alternate schema is introduced. The pinned Python 3.11+ web snapshot is requirements-web.txt; platform camera dependencies remain managed by Raspberry Pi OS. See the release record.

robot.lifecycle is the reusable lifecycle policy boundary. Its fixed operations are status/reload/restart; it never accepts arbitrary commands or configuration paths from callers. The web worker uses robot.lifecycle_channel to reach the parent-owned service. Confirmation/authentication remain adapter responsibilities; validation and restart capability policy are shared. Test both the service and adapter guards. Infrastructure service markers are deployment metadata, not ordinary JSON settings. No new runtime configuration section is needed.

Environmental configuration migration

For an existing BME280 deployment, rename sensors.bme280 to sensors.environmental, retain its four existing values and add "type": "bme280". Do not retain both blocks. To use BMP280 choose "type": "bmp280"; humidity is unsupported. The Python RuntimeConfig fields now use the environmental_ prefix.

When updating a deployment without sensor settings, merge the complete sensors object from config/phos.yaml into its existing configuration, preserving other settings. The new section and all five fields are required even when disabled. As with previous schema additions, missing fields fail validation; no silent overlay/migration or second set of defaults is introduced. run_pi.sh preserves deployed JSON and does not perform this merge. Validate locally before restarting the service. No new CLI flags are added. Save/Reload classify every sensor difference as restart-required; unrelated services are not restarted by either action.

Hardware-free sensor checks: .venv/bin/python -m pytest -q tests/test_sensors.py. The adapter uses lazy optional imports; disabled operation and ordinary tests need neither Linux I2C access nor the driver packages. Fake drivers test address, chip ID, calibration and unit mapping; the service tests failure recovery, staleness, polling and bounded shutdown independently of physical hardware.

ENS160/AHT21 controller telemetry

ENS160 and AHT21 are acquired by the ESP32 and delivered through the controller protocol. sensors.ens160 configures controller-backed air-quality enablement; the public runtime records are sensors.ens160 and sensors.aht21. Tests should exercise protocol decoding, validity, per-measurement freshness and controller generation retirement rather than direct Pi I2C drivers.

MPU-6050 configuration migration

Merge the complete sensors.imu block from canonical YAML into an existing deployment, preserving the environmental configuration. The typed surface uses the imu_ prefix. All four fields are required even when disabled and are restart-only. IMUReading contains finite acceleration values in m/s² and angular velocity values in °/s. It has no persisted calibration state: the adapter applies fixed factory scale factors only. Run .venv/bin/python -m pytest -q tests/test_imu.py before Pi validation.

Tilt interpretation configuration migration

Add tilt_exit_threshold_m_s2, lateral_axis and forward_axis from canonical sensors.imu.motion to existing deployments; missing fields fail validation. The existing tilt enter key is preserved but now refers to a normalized gravity component. Review enter/exit together. For responsive operation, adopt the canonical IMU poll interval and confirmation duration; polling requires restart, motion thresholds/mounting require only reload. See the installation guide for axis verification and DEBUG diagnostics.

External hardware controller administration

Web Admin's Hardware Controller page edits the canonical hardware_controller configuration through the application/lifecycle boundary. Changing the enabled state, serial device, or baud rate closes the prior session and starts a fresh reconnect/handshake session without restarting PHOS; timing changes are applied to the existing service. It discovers serial ports only through the parent application service; the browser never inspects device files. The canonical settings are enabled, transport (currently serial only), serial.device, serial.baud_rate, reconnect.delay_seconds, and heartbeat interval_seconds/timeout_seconds; timeout must exceed interval. These are connection settings, not controller-firmware or LED-animation settings. The page also exposes controller-owned read-only connection state and a bounded, in-memory RX/TX diagnostic buffer. Diagnostics are not persisted, heartbeat rows are hidden by default, and raw frames are bounded to the phos-hw frame limit.

GitHub Actions software validation

PHOS CI runs on pull requests targeting dev or main, every push to dev, and after a GitHub Release is published. It runs the complete software-compatible pytest suite, Python compilation, and a strict MkDocs build. Reports are available from the workflow run as a JUnit XML file and a 30-day artifact, including command output and execution environment details.

Release validation checks out the published tag, resolves its commit, and fails unless that commit is reachable from main. It runs after publication, so it reports invalid release provenance but cannot prevent the initial publication. PASS means the automated software checks completed; FAIL means one failed; SKIPPED is reported by pytest; INCOMPLETE means a report was not produced. Every summary explicitly states that Raspberry Pi hardware validation was not run. Test GPIO, camera, display, audio, I2C wiring, and physical performance manually on the Pi.

Repository administrators must enable required pull requests, require the software-tests check, require branches to be current, and restrict direct pushes on dev and main. The separate MCP bridge repository is not checked out by PHOS CI; add bridge CI only once a pinned, CI-accessible source revision is available.