Skin Architecture
Skins reuse the existing appearance configuration, lifecycle services, render loop, and semantic LED arbitration. They are declarative data, not executable renderer plugins.
Discovery and loading
SkinRepository combines three sources in order:
- Built-ins returned by
built_in_skins(). - Optional YAML catalog selected by
appearance.config_file, resolved beneath the active PHOS configuration directory. - Managed custom skins persisted in
skins.jsonbeside that configuration.
The catalog resolves inheritance from another catalog entry or a built-in, merges partial appearance overrides, validates the resolved definition, and checks its referenced backgrounds. IDs must be unique across all sources. Cycles, unknown parents, excessive inheritance depth, invalid YAML/JSON, and conflicting IDs raise configuration errors; the list does not silently discard bad definitions.
Portable packages are imported into managed storage before appearing in this
list. Import assigns a new custom-<uuid-hex> ID, rewrites background references,
and saves metadata atomically. The package does not execute code or fetch assets
from a URL. See structure and limits.
From selection to a rendered frame
flowchart TD
builtin[Built-in definitions] --> repository[SkinRepository]
catalog[Optional YAML catalog] --> repository
custom[Managed skins.json and assets] --> repository
package[Imported skin package] --> custom
repository --> services[Application and agent-management services]
global_mode[Global appearance mode] --> services
activity[Optional Follow Active Agent identity lease selects assigned skin] -.-> services
services --> lifecycle[LifecycleService validation and reconciliation]
lifecycle --> queue[Existing display-loop update queue]
queue --> renderer[EyeRenderer and appearance resolvers]
behavior[BehaviorEngine / FaceState] --> renderer
renderer --> display[Tk display composition]
lifecycle --> palette[SemanticLedService palette]
palette --> controller[Optional controller LED output]
classDef phos fill:#0F4C5C,stroke:#49E7FF,color:#fff
classDef aiAgent fill:#5B21B6,stroke:#C4B5FD,color:#fff
classDef hardware fill:#334155,stroke:#94A3B8,color:#fff
class builtin,catalog,custom,package,repository,global_mode,services,lifecycle,queue,renderer,behavior,display,palette phos
class activity aiAgent
class controller hardware
style activity stroke-dasharray: 5 4
PhosApplicationServicelists, imports, exports, previews, applies, and deletes skins through the shared application boundary.AgentManagementServiceresolves global or selected-agent appearance and its Physical Personality/LED palette without persisting temporary ownership.LifecycleServicevalidatesRuntimeConfig, applies supported visual changes, and reconciles the effective skin.EyeRenderLoopqueues appearance updates onto the existing display loop.EyeRendererconsumesFaceStateand validated iris/shape configuration. It interpolates visual targets while existing blink and expression logic run.- Background, Eye Safe, and State Effect resolvers select presentation for the effective state; they do not make behavior decisions.
SemanticLedServiceuses eligible theme colours while preserving runtime priority, animation parameters, controller availability, and protected colours.
Display composition
The Tk adapter composes the existing layers in this order:
- State background.
- Eye Safe Layer.
- State Effects.
- Animated eyes.
- Environmental decorations.
- Optional local camera preview.
- Transient semantic notice.
- Protected local Admin/recovery overlay.
Backgrounds are prepared and cached for a path/display-size combination. The image is proportionally scaled to fill the display and centre-cropped; it is not stretched. Decode failure falls back to the renderer's background and is logged. Skin packages cannot replace the protected overlays or assign arbitrary drawing code to these layers.
Preview, apply, and active-agent selection
Live Preview applies the four appearance blocks temporarily without saving or replacing the active configuration snapshot. It does not apply the skin's LED palette or Physical Personality. It has no automatic expiry timer; a later appearance application, reconciliation, or restart can replace it.
Apply builds and validates a complete configuration, saves appearance fields
and appearance.global_skin_id, then requests reload. On failure the application
attempts to restore the previous saved configuration. This is not a guarantee
that every already-applied live subsystem change is rolled back; inspect runtime
status after a failure.
Automatic reconciliation resolves the persisted global skin or the eligible active agent's assigned skin, applies visual settings through lifecycle, then applies Physical Personality and the effective LED palette. Unchanged resolved appearance is not repeatedly reapplied.
In follow_agent mode, accepted semantic MCP work renews the registered
identity's activity lease. Authentication alone, denied work, and transport
keepalives do not renew it. The highest-priority eligible active agent wins. On
a tie PHOS retains the previous winner if possible; otherwise it selects a
stable agent-ID order. Expiry returns selection to another eligible agent or the
global fallback. This does not grant exclusive ownership of physical outputs.
Fallback and failure handling
- Missing managed custom backgrounds are reported by state. Explicit live Preview/Apply can omit those assignments while retaining the stored skin.
- Automatic selection of a skin with missing backgrounds falls back to global appearance rather than partially applying that agent skin.
- An unavailable persisted global skin retains the saved display configuration
and uses
analyticalPhysical Personality. - Omitted eye shape resolves to
classic_oval; omitted Physical Personality resolves toanalyticalduring reconciliation. - Missing, disabled, or partial LED palettes use canonical fallback colours for unprovided intents; warning/error retain protected colours.
- Missing runtime appliers reject live activation. Corrupt catalogs or custom metadata can make the catalog unavailable until repaired.
The troubleshooting guide distinguishes these designed fallbacks from current importer, snapshot, and static-preview limitations.