Runtime architecture note · Companion to HAIG

Two truths and pure functions

Keeping desired and observed state apart, and computing behavior as pure functions of facts.

Core equation
actual != wanted → send the difference
Wanted function
wanted = f(config, events, t)
Relation to HAIG
Extracted from the HAIG thesis as a separate runtime concern
Audience
Software engineers building systems that act on the real world
Abstract

HAIG governs how an AI configures software and how people watch it. This note governs how the runtime itself works, regardless of whether configuration comes from an AI, a UI, or hand-edited files. The two ideas pair well because pure functions and explicit desired versus actual state make previews real, explanations provable, and recovery automatic, though neither requires the other.

1Two truths: wanted and actual

actual != wanted  ->  send the difference

A system that acts on the real world keeps two sources of truth apart on purpose:

The runtime runs one reconcile loop between them:

  1. Observe: read actual state as it is, read-only.
  2. Compute: evaluate wanted = f(now) from configuration and recorded events.
  3. Decide: a pure function decide(wanted, actual, recent_sends, now) returns send, wait, or nothing.
  4. Act: pace writes with a cooldown and backoff. Slightly wrong for a moment is fine; flapping is not.
  5. Repeat on a timer and on every hint (a config change, a new reading, a device reconnecting).

Because the loop is level-triggered and recomputes from scratch on every pass, a lost write, a device returning from offline, a hub restart, and a schedule edit are all just a gap. None of them needs a special case.

2Some events are new ASoT

The reconcile loop always brings actual toward wanted, never the other way. Actual state is never copied directly into wanted. If f(t) copied whatever a device reported, the two truths would collapse into one and the system would agree with every glitch, reboot, or drift.

Instead, some observed events become new ASoT.

When a person acts outside the system (flips a wall switch, turns a thermostat dial, presses a TV remote), the system asks one question of the incoming reading: do my own recent sends explain it?

Modeling human overrides as events inside f(t) rather than silent mutations of desired state solves three problems at once: the system knows why the value changed, the layer carries its own rule for when it ends, and the underlying plan remains untouched underneath.

2.1Run versus ask

Not every thing in the real world should be held continuously (Table 1). Which mode applies comes from the configuration, not from hardcoded device types.

Table 1. Continuous convergence (run) versus one-off commands (ask).
ModeExamplesHow wanted behaves
RunLights in a routine, a thermostat band, a shade positionKept as wanted over a stretch. The loop closes gaps continuously; a person's change becomes a new wanted layer until overridden.
AskTurning a TV on once at wake-up, a button press, a device that never reportsWanted only until a reading confirms it (or for an explicit hold window, such as holding audio volume for 30 s while a TV starts). After that, nothing is wanted and whatever anyone does stands.

3Rules for keeping two truths honest

4Pure functions of facts: same input, same output

Design behavior as a pure function of explicit inputs wherever possible: what the system wants now depends only on its configuration, its append-only events, and the timestamp t, never on hidden history or the order passes happened to run.

Why this property pays off across the whole system:

How to hold to it:

Where the real world is impure (a sensor misreads, an external service is down), record what was observed as an input so even impure situations can be replayed afterward.

5Litmus tests

End of runtime note