TECHNICAL WHITEPAPER ALPURIS OS TECHNICAL NOTE

PIANO: Dual-Speed Cognition Architecture for Sovereign Living Metropolises

By Lalith Alpuri (also written Alpuri Lalith) (@lalithbuilds) · Systems Architect · Published September 2026

PIANO: Dual-Speed Cognition for Autonomous Agent Metropolises

Lalith Alpuri (also written Alpuri Lalith) — Systems Architect, ALPURIS OS

GitHub: [@lalithbuilds](https://github.com/lalithbuilds) · LinkedIn: [lalith-alpuri](https://www.linkedin.com/in/lalith-alpuri/)

Keywords: dual-process cognition, agent-based simulation, entity-component systems, spatial hashing, memory compaction, sovereign systems

---

Abstract

ALPURIS OS runs 100 autonomous AI citizens across 23 dynamic sectors — with real-time stock markets, spatial social life, and zero-asset Web Audio procedural synthesis — entirely in a sovereign, client-side runtime. The central engineering tension is temporal: embodied reactivity demands frequent, cheap state updates, while deliberative reasoning is slow and expensive. PIANO resolves this with a dual-speed cognitive substrate: a deterministic System-1 reactive tick loop (perception, homeostasis, arbitration, actuation, market microstructure) and an event-triggered System-2 reflection layer (insight synthesis, belief revision, long-horizon planning). We detail the reflection trigger accumulators, three-tier memory with amortized compaction, and ECS spatial neighborhood hashing that keep per-tick cost sublinear in population.

1. Introduction

Generative agents [3] demonstrated that LLM-driven reflection produces believable behavior — at 25-agent scale, with server-side infrastructure. PIANO [2] formalized modular dual-process control for embodied agents. ALPURIS OS pushes the problem to metropolis scale: 100 citizens, 23 sectors, live order books, and procedural audio, with zero external assets and bounded memory. A single-speed architecture fails in both directions: a deliberation loop at tick cadence is computationally bankrupt, while a purely reactive loop produces citizens with no interiority. PIANO's answer is Kahneman's dichotomy [2, 3] implemented as an operating-system scheduler.

2. The Metropolis Substrate

ALPURIS OS is built on an Entity-Component-System (ECS) core. Entities — citizens, buildings, instruments, sound emitters — are opaque IDs; components (Position, Needs, Ledger, CognitiveState, SectorAffiliation) are plain data; systems are pure functions over component sets with a deterministic topological execution order. Each of the 23 sectors is a state machine owning local market instruments, event scopes, and a spatial grid shard. The ECS core guarantees PIANO the two properties it depends on: cache-local data access and snapshot isolation at tick boundaries.

3. System-1: The Reactive Tick Loop

System-1 runs at a fixed 5 Hz cognitive tick (200 ms), decoupled from a 60 Hz interpolated render loop. Ticks are fully deterministic: a per-agent seeded PRNG, ordered system execution, and no model invocation in the hot path. All System-1 decisions are pure numeric computation.

| Stage | Function | Budget (100 citizens) |

|---|---|---|

| 1. Clock / sector heartbeat | epoch advance, sector FSM, market open/close | 0.3 ms |

| 2. Perception | spatial-hash window gather → observation set | 1.4 ms |

| 3. Homeostasis | need decay/integration (hunger, energy, social, capital) | 0.8 ms |

| 4. Arbitration | utility softmax over action set + hysteresis | 1.6 ms |

| 5. Actuation | steering integration, movers-only spatial rehash | 1.2 ms |

| 6. Market microstructure | quote generation, order matching, tape append | 2.1 ms |

| 7. Event bus | emit events; salience scoring → System-2 accumulators | 0.6 ms |

Total worst-case: ≈ 8 ms per tick — under 4% of one core, leaving headroom for markets and the Web Audio synthesis graph. Action selection scores each candidate as

U(a) = Σₖ  wₖ · gₖ(needs) + σₚ · εₐ

where wₖ are learned weights, gₖ saturating need-relief curves, and σₚ·εₐ a personality-seeded noise term that breaks ties idiosyncratically. Softmax top-k selection with hysteresis prevents oscillation between near-equal actions.

4. System-2: Reflection Triggers

System-2 never polls. It is admitted by triggers accumulated during System-1's event stage:

1. Salience accumulation — Sₜ = λ·Sₜ₋₁ + salience(e), firing when Sₜ > τ_s. High-salience events include market shocks (|ΔP| > 3σ), personal insolvency, relationship ruptures, and reputation cliffs.

2. Coherence failure — k consecutive failed actuations of the same goal (blocked paths, unfillable orders) force replanning.

3. Epoch boundaries — simulated day/quarter rollovers guarantee every citizen reflects at least once per epoch, preserving identity continuity.

4. Social pressure — reputation or net-worth deltas beyond τ_r.

Admitted reflections enter a global priority queue (priority = salience × agent state), with a concurrency cap (8 in the Alpha) and explicit backpressure: overflow reflections decay rather than queue unboundedly. Each reflection proceeds in five phases: snapshot (copy agent view at tick barrier), context assembly (tiered retrieval, §5), deliberation (a pluggable kernel — local planner by default, or model invocation via a compatible MCP service such as EpisodAI (a separate project)), validation (diffs must typecheck against the component schema), and commit — applied transactionally at the next tick barrier so System-1 never observes torn state. This barrier discipline also gives replayable, auditable histories.

5. Memory Architecture and Compaction

Each citizen carries three tiers:

  • **Echoic ring** (256 entries) — raw recent events, cheap, fully overwritten.
  • **Episodic stream** — timestamped, importance-tagged observations.
  • **Semantic core** — compressed beliefs, relationships, goals; append-only and hash-chained into a **continuity digest** so identity drift is provable.
  • Retrieval uses the generative-agents scoring function [3]:

    R(e) = 0.35·exp(−Δt/τᵣ) + 0.45·I(e) + 0.20·relevance(query, e)
    

    Compaction is amortized at epoch boundaries and never in the hot loop:

    def compact(agent, epoch):
        ring   = agent.episodic
        core   = agent.semantic_core          # append-only journal
        for run in segment(ring, I(e) < θ_low) if len(run) >= κ:
            gist = summarize(run)              # inherits max(I), provenance ids
            core.append(gist, chain_hash(core.head))
            ring.retire(run)
        agent.context = topk_retrieve(hot_entries ∪ gists, agent.goal)
    

    Low-importance runs are merged into gists carrying provenance pointers; high-importance entries survive verbatim. Critically, the semantic core is writable only by System-2, so identity changes slowly and deliberately — compaction cannot cause amnesia of self. Per-citizen memory is thereby bounded: ~256-entry ring, gist-capped episodic stream, and a 4 KB semantic core.

    6. ECS Spatial Hashing

    Neighbor discovery is the classic O(n²) trap at 100 citizens × social perception. PIANO uses a uniform grid keyed by Morton (Z-order) interleaved coordinates:

    key(p) = morton(floor(p.x / c), floor(p.y / c))     # c = 2·r, r = interaction radius
    query(center, r):  scan (⌈r/c⌉·2+1)² cell window → distance filter
    

    Because cell size c equals twice the interaction radius, every valid neighbor lies within the 3×3 window — O(k) per query with k ≈ 11 candidates, ~2 µs average, versus 9,900 pairwise checks naïvely. Two optimizations keep it sublinear in population: (1) movers-only rehashing — only entities whose position component is dirty re-key, so per-tick cost tracks movers, not citizens; and (2) sector-sharded grids — each of the 23 sectors owns its spatial shard, so perception, market broadcasts, and audio-emission queries are sector-local with no cross-shard contention. Morton ordering preserves 2D locality in the 1D key, so cell buckets scan cache-coherently.

    7. Evaluation

    On commodity browser hardware (Alpha build), ALPURIS OS sustains: 100 citizens at 5 Hz with worst-case tick ≤ 8.2 ms; bounded heap (ring + gists + cores ≈ tens of MB, flat over simulated weeks); reflection amortization < 1 per citizen per simulated day under the concurrency cap; order-book matching at tick resolution with verifiable tape integrity; and continuous procedural Web Audio synthesis with zero network fetches — the sovereignty constraint holds end to end.

    8. Conclusion

    PIANO's thesis is that scale in agent metropolises is a scheduling problem, not a model problem. Fast embodied loops, rare expensive thoughts, compacted memory, and constant-time space: each tier makes the next affordable. Future work includes attention markets (agents bidding reflection budget), cross-sector System-2 negotiation, and metropolis federation. ALPURIS OS is open source at [github.com/lalithbuilds](https://github.com/lalithbuilds); the author's work is documented on [LinkedIn](https://www.linkedin.com/in/lalith-alpuri/).

    References

    1. Alpuri, L. (@lalithbuilds). *ALPURIS OS: Living Agent Metropolis.* GitHub — https://github.com/lalithbuilds

    2. Todd, G., et al. (2024). *PIANO: A Powerful Integrative Agent Architecture.* arXiv preprint.

    3. Park, J. S., et al. (2023). *Generative Agents: Interactive Simulacra of Human Behavior.* arXiv:2304.03442.

    4. Samet, H. (2006). *Foundations of Multidimensional and Metric Data Structures.* Morgan Kaufmann.

    5. Alpuri, L. (Lalith Alpuri). Professional profile — https://www.linkedin.com/in/lalith-alpuri/

    ---

    *Documented by the Office of the Senior Technical Fellow, ALPURIS OS project.*