Advanced Interface Optimization System

Deterministic service kernel · cross‑flavor · enterprise‑grade

What is AIOS?

AIOS (Advanced Interface Optimization System) is a modular World of Warcraft addon kernel designed to replace legacy library stacks with a unified service‑oriented architecture.

✅ Lazy service loading & dependency‑safe init
✅ Cross‑flavor: Retail / MoP Classic / Classic Era
✅ Async coroutine engine & reactive streams
✅ Memory pooling (Lean) + compression framework
✅ Secure API wrapper (Protect) & versioned SavedVariables
✅ Structured logging, high‑performance timers, environment reflection

Kernel architecture specification

Boot sequence (deterministic order):

Meta reflection (BuildInfo + Environment)
 → ServiceRegistry initialization
 → Core services defined (Logger, EventBus, Lean, …)
 → Subsystems attach
 → Validation pass
 → AIOS_Core_Ready emitted

No service is accessible before its dependencies are satisfied. All access via ServiceRegistry:Get().

Service lifecycle

state = "none" | "pending" | "ready"

Boot sequence

Meta reflection (BuildInfo + Environment)
  → ServiceRegistry initialization
  → Core services defined (Logger, EventBus, Lean, …)
  → Subsystems attach
  → Validation pass
  → AIOS_Core_Ready emitted

ServiceRegistry internal model

Service entry = {
  name, version, factory, instance,
  state = "none" | "pending" | "ready",
  namespace, aliases
}

EventBus execution model

Synchronous emit · safe emit (pcall) · delayed · throttled · coroutine‑based async · reactive streams.

Stream(event) → Filter → Map → Throttle/Debounce → Subscribe

Lean memory engine

Pools: ObjectPool, TablePool, StringPool, Numeric, GUI. Borrow/Return must always pair.

Timer engine internals

Schedule → Active → Tick → Complete/Repeat → Release

Codec architecture

Registry‑based: RegisterEncoder/Decoder/Compression/Hasher. Compression engines are pluggable backends.

Protect layer

Isolates unsafe WoW API usage: safe context detection, deferred execution, combat lockdown safety.

Saved system

Namespaced storage · versioned schema · migration pipeline · optional reactive store.

Internal API classification

TierDescription
PublicStable, semver‑protected
AdvancedSemi‑stable, caution
InternalMay change anytime
ExperimentalNo stability guarantee

Fully indexed API reference

Grouped by subsystem – method names only, quick lookup.

ServiceRegistry
Define, Alias, List, Get, Has, TryGet, GetVersion, GetAll, Dump, DumpAll, DumpNamespace, DumpAliases, Summary, Search, NamespaceImpl, ListNamespaces, NamespaceCount, ClearNamespaces, ValidateImpl, ValidateAll, Diagnostics
EventBus
Init, IsReady, Listen, Once, Unlisten, ListenWoW, UnlistenWoW, Emit, EmitSafe, EmitDelayed, EmitThrottled, EmitBridge, Clear, Count, RunAsync, Await, Sequence, Delay, CancelAllAsync, DumpAsync, Stream, Filter, Map, Throttle, Debounce, Take, Subscribe, Emit, Destroy
Lean
Init, IsReady, AcquirePool, Acquire, Release, RegisterExtension, ObjectPool: Borrow, Return, GetStats, TablePool: Borrow, Return, GetStats, StringPool: Intern, Count, Numeric: BorrowArray, ReturnArray, Seed, Rand, RandInt, Clamp, Round, GUI: BorrowFrame, ReturnFrame, BorrowTexture, ReturnTexture, BorrowFontString, ReturnFontString, Inspect, Attach
Logger
Initialize, Info, Warn, Error, Debug, Print, ResolveAuthority, RingBuffer: New, Add, GetRecent, Clear, Size, AddToRing, GetRecentFromRing, ClearRing, Sink: RegisterSink, SetSink, GetActiveSink, GetSinks, Emit, Diagnostics, RunDiagnosticsTest
Timers
Schedule, After, Every, Throttle, Debounce, Cancel, CancelAll, CancelPattern, CancelGroup, CancelHandle, RegisterToGroup, PauseGroup, ResumeGroup, RemoveGroup, ListGroups, Tick, RecordGroup, Enqueue, ClearQueue
Saved
Init, Get, Set, Reset, GetAsync, SetAsync, GetProfile, SwitchProfile, CopyProfile, RegisterSchema, _ApplyDefaultsFor, _RunMigration, CreateReactiveStore, GetReactiveStore, GetDiagnostics, InspectNamespace, ExportRawData
Locale
Register, RegisterAddon, RegisterLanguage, RegisterAddonLocale, Translate, Format, OnMissingKey, ScanFrames, FlushLearned, ToggleLearning, DumpLearned, DumpLocaleStats, GetSystemLocale, GetRegionName
Protect
IsSafeContext, SetContext, Execute, Defer, FlushQueue, Wrap, Initialize, GetDiagnostics, Reset, GetLegacyCompatibility, UnitName, UnitHealth, UnitAura, CreateFrame, SendChatMessage
Codec
RegisterEncoder, RegisterDecoder, RegisterCompression, RegisterHasher, RegisterUtility, Encode, Decode, Compress, Decompress, Hash, GetStats, Dump, Huffman, BrotliLite, BrotliFull, LZ4, RLE, CRC32, Adler32, Hash32, Shannon, CompressionRatio, Redundancy, SymbolDiversity, Analyze, MD5, SHA1, SHA256, SHA512, Auto, Hex, Base64, Base85, TokenPack, TokenUnpack
Meta
BuildInfo: Reflect, Get, Summary, Environment: Reflect, Get, Summary, Init, GetMemoryUsage, GetUptime, GetServiceCount, PrintDebugSummary
Frames
CreateFrame, Fill, CreateOverlay, CreatePanel, CreateButton, SetOnClick

ServiceRegistry — complete API

Define(name, version, factory)
Alias(from, to)
List(pattern) → table
Get(name) → service
Has(name) → bool
TryGet(name) → service, ok
GetVersion(name) → string
GetAll() → table
Dump(), DumpAll(), DumpNamespace(ns), DumpAliases()
Summary() → string
Search(term) → table
NamespaceImpl(name), ListNamespaces(), NamespaceCount()
ClearNamespaces()  — use with care
ValidateImpl(name, service), ValidateAll()
Diagnostics()

EventBus · Async · Reactive streams

Init(), IsReady()
Listen(event, handler), Once(event, handler), Unlisten(event, handler)
ListenWoW(event, handler), UnlistenWoW(event)
Emit(event, ...), EmitSafe(event, ...), EmitDelayed(event, delay, ...)
EmitThrottled(event, interval, ...), EmitBridge(event, ...)
Clear(), Count(event)
RunAsync(fn, ...) → thread, Await(seconds), Sequence(tasks), Delay(fn, delay, ...)
CancelAllAsync(), DumpAsync()
Stream(event) → stream, Filter(fn), Map(fn), Throttle(sec), Debounce(sec), Take(limit)
Subscribe(fn), Emit(...), Destroy()

Lean — memory pooling system

Init(), IsReady()
AcquirePool(kind), Acquire(kind), Release(kind, obj)
RegisterExtension(name, extension)
ObjectPool: Borrow(), Return(obj), GetStats()
TablePool: Borrow(), Return(tbl), GetStats()
StringPool: Intern(s) → string, Count()

Logger — structured + ringbuffer + sinks

Initialize()
Info(tag, fmt, ...), Warn(tag, fmt, ...), Error(tag, fmt, ...), Debug(tag, fmt, ...)
Print(level, tag, msg), ResolveAuthority(tag)
RingBuffer: New(maxEntries), Add(msg), GetRecent(n), Clear(), Size()

Timers — scheduling, groups, profiler

Schedule(name, delay, callback)
After(delay, callback), Every(interval, callback)
Throttle(key, delay, callback), Debounce(key, delay, callback)
Cancel(name), CancelAll(), CancelPattern(pattern), CancelGroup(group), CancelHandle(handle)
RegisterToGroup(groupName, timerObj)
PauseGroup(groupName), ResumeGroup(groupName), RemoveGroup(groupName), ListGroups()
Tick(elapsed), RecordGroup(groupName, latency)
Enqueue(id, delay, callback, repeating, priority), ClearQueue()

Saved — namespaced storage, migrations, reactive

Init()
Get(namespace, key), Set(namespace, key, value), Reset(namespace)
GetAsync(namespace, key, callback), SetAsync(namespace, key, value, callback)
GetProfile(), SwitchProfile(profile), CopyProfile(source, target)
RegisterSchema(namespace, schema, version)
CreateReactiveStore(namespace, scope)

Locale — i18n, learning, frame scan

Register(lang, tbl)
RegisterAddon(addon, translations)
RegisterLanguage(lang, data)
RegisterAddonLocale(addon, lang, data)
Translate(key, fallback), Format(key, ...)
OnMissingKey(key)
ScanFrames(), FlushLearned(), ToggleLearning(state)
DumpLearned(), DumpLocaleStats()
GetSystemLocale(), GetRegionName()

Protect — secure execution & API wrapper

IsSafeContext()
SetContext(context, blocked)
Execute(func, ...), Defer(func, ...), FlushQueue()
Wrap(func)
UnitName(unit), UnitHealth(unit), UnitAura(unit, index, filter)
CreateFrame(frameType, name, parent, template)
SendChatMessage(msg, chatType, language, channel)
Initialize(), GetDiagnostics(), Reset(), GetLegacyCompatibility()

Codec — encoders, compression, hashing

RegisterEncoder(name, handler), RegisterDecoder(name, handler)
RegisterCompression(name, handler), RegisterHasher(name, handler)
RegisterUtility(name, handler)
Encode(name, data), Decode(name, data)
Compress(name, data), Decompress(name, blob)
Hash(name, data), GetStats(), Dump()

Meta — BuildInfo, Environment, debug

BuildInfo: Reflect(force), Get(field), Summary()
Environment: Reflect(force), Get(key), Summary(), Init()
GetMemoryUsage(), GetUptime(), GetServiceCount(), PrintDebugSummary()

Frames module — quick UI helpers

CreateFrame(frameType, parent, name)
Fill(frame, parent)
CreateOverlay()
CreatePanel(parent, width, height)
CreateButton(parent, name)
SetOnClick(handler)

AIOS Stability Contract

Effective for v1.x releases

What is guaranteed stable

What is NOT guaranteed stable

Versioning & Semantic Policy

AIOS strictly follows Semantic Versioning 2.0.0.

Diagnostics & system checks

Each module provides Diagnostics(), Dump() or GetStats(). The kernel also exports /aiosdiag command.

MyAddon — complete working example

A fully functional AIOS-powered addon demonstrating core framework features.

MyAddon.toc

## Interface: 110200
## Title: MyAddon
## Author: You
## Version: 1.0.0
## Dependencies: AIOS
## SavedVariables: MyAddonDB

MyAddon.lua

MyAddon.lua

--[[-----------------------------------------------------------------------------
MyAddon Demo - Complete AIOS example
-----------------------------------------------------------------------------]]--

local AIOS = _G.AIOS
if not AIOS then return end

local function Init()
    local SR = AIOS.ServiceRegistry
    local Logger = SR:Get("Logger")
    if not Logger then return end

    Logger:Info("MyAddon Demo initializing")

    -- Locale Setup
    local Locale = SR:Get("Locale")
    Locale:RegisterAddon("MyAddon")
    Locale:RegisterAddonLocale("MyAddon", "enUS", {
        TITLE = "AIOS Demo",
        CLOSE = "Close"
    })
    Locale:RegisterAddonLocale("MyAddon", "esES", {
        TITLE = "Demostración AIOS",
        CLOSE = "Cerrar"
    })
    Locale:RegisterAddonLocale("MyAddon", "frFR", {
        TITLE = "Démo AIOS",
        CLOSE = "Fermer"
    })
    local titleText = Locale:Translate("MyAddon", "TITLE")
    local closeText = Locale:Translate("MyAddon", "CLOSE")

    -- TablePool Test
    local TablePool = SR:Get("TablePool")
    if TablePool then
        local tbl = TablePool:Borrow()
        tbl.test = true
        TablePool:Return(tbl)
        Logger:Info("TablePool verified")
    end

    -- Create Frame
    local frame = CreateFrame("Frame", "MyAddon_DemoFrame", UIParent, "BackdropTemplate")
    frame:SetSize(320, 180)
    frame:SetPoint("CENTER")
    frame:SetMovable(true)
    frame:EnableMouse(true)
    frame:RegisterForDrag("LeftButton")
    frame:SetScript("OnDragStart", frame.StartMoving)
    frame:SetScript("OnDragStop", frame.StopMovingOrSizing)
    frame:SetBackdrop({
        bgFile = "Interface/Tooltips/UI-Tooltip-Background",
        edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
        edgeSize = 12,
        insets = { left = 4, right = 4, top = 4, bottom = 4 },
    })
    frame:SetBackdropColor(0, 0, 0, 0.9)

    local title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
    title:SetPoint("TOP", 0, -10)
    title:SetText(titleText)

    local counterText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge")
    counterText:SetPoint("CENTER")
    counterText:SetText("0")

    -- Timer
    local Timers = SR:Get("Timers")
    local counter = 0
    Timers:Every(1, function()
        counter = counter + 1
        counterText:SetText("Timer: " .. counter)
    end)

    -- Exit Button
    local closeBtn = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
    closeBtn:SetSize(80, 24)
    closeBtn:SetPoint("BOTTOM", 0, 10)
    closeBtn:SetText(closeText)
    closeBtn:SetScript("OnClick", function()
        frame:Hide()
        Logger:Info("Demo frame closed")
    end)

    -- EventBus Test
    local EventBus = SR:Get("EventBus")
    EventBus:Listen("MY_DEMO_EVENT", function(msg)
        Logger:Info("EventBus received: %s", msg)
    end)
    EventBus:Emit("MY_DEMO_EVENT", "EventBus Working")

    Logger:Info("MyAddon Demo ready")
end

-- Safe Boot Pattern
local hub = AIOS.SignalHub
if hub and hub.Listen then
    hub:Listen("AIOS_Core_Ready", Init)
else
    local f = CreateFrame("Frame")
    f:RegisterEvent("PLAYER_LOGIN")
    f:SetScript("OnEvent", Init)
end

What this demo shows

Building your first AIOS addon

See the MyAddon sample above for a complete working example. Key steps:

Code examples

AIOS.SignalHub:Listen("AIOS_Core_Ready", function()
  local SR = AIOS.ServiceRegistry
  local Logger = SR:Get("Core::Logger")
  local Lean = SR:Get("Core::Lean")
  
  Logger:Info("Example", "Addon loaded")
  
  SR:Define("Module::Greet", "1.0.0", function()
    return { say = function() print("hello") end }
  end)
  
  local t = Lean:Acquire("table")
  -- use table
  Lean:Release("table", t)
end)