Executable public contracts

Follow state, intent and evidence across component boundaries.

Seven deterministic examples call the same pure reducers used by the Node-RED adapters. Synthetic configuration keeps transport ownership visible without publishing installation topology.

Milestone completePackage 2.2.07 executable examplesTransport-neutral inputs

Contract examples

Each example declares configuration, applies deterministic inputs, asserts one consumer-visible invariant and returns its commands or outputs as JSON.

Sensor policy

Occupancy fusion

Motion establishes occupancy. Optional presence can hold it after motion clears, but cannot establish it alone.

presence:on  → no output
motion:on    → occupied:true
motion:off   → held
presence:off → occupied:false
Open executable example →

Motion policy

Occupancy to lighting intent

Dark, enabled occupancy produces semantic intent; it does not publish a device command.

{ occupied: true, trigger: "motion" }
→
{ kind: "intent", state: "ON",
  targets: ["ceiling", "worktop"] }
Open executable example →

Switch policy

Explicit manual brightness

A classified double action becomes one full-brightness intent with manual ownership.

{ action: "double" }
→
{ state: "ON", manual: true,
  values: { brightness: 254 } }
Open executable example →

Command owner

Room lighting boundary

The room controller converts semantic lighting intent into the sole transport command and records its policy source.

{ kind: "intent", state: "ON",
  source: "motion" }
→
{ topic: "demo/lighting/ceiling/set",
  lighting_command: { source: "motion" } }
Open executable example →

Readiness policy

Media-source evidence

Command success enters confirmation. Fresh active-application evidence is what satisfies application readiness.

activate → command_result:ok → confirming
observed:{ active, application, paused }
→ ready
Open executable example →

Command ownership

Bounded receiver volume

Rapid relative requests accumulate against one target. Fresh confirmation releases ownership so later external adjustment becomes the baseline.

relative:+1 → MV31
relative:+1 → MV32
observed:32 → ready · released
observed:28 → external baseline
Open executable example →

Coordination

Theatre activity

One activity request fans out semantic target intents and reaches ready only from fresh mandatory evidence.

movie_night request
→ display · receiver · source · lighting · backlighting
→ fresh target evidence
→ { phase: "ready", availability: "available" }
Open executable example →

Run the contracts

The aggregate command compiles the package, executes all seven examples and fails if an asserted invariant changes.

npm ci
npm run examples

What the examples preserve

Policy before transport

Sensor and user events become semantic outcomes before a target owner selects a protocol.

Evidence before ready

Command acceptance never substitutes for a fresh observation of the required state.

Finite state

Timers, retries, generations and traces remain bounded and stale work stays inert.

Privacy boundary

Every identifier, topic, profile, timestamp and coordinate in these examples is synthetic. The examples contain no device inventory, addresses, credentials, entity identifiers, flow exports or operational records.