goobwerx

Technical

Engineering the party

Runtime contracts, live Lua, spatial geometry, and the measurements behind the field reports.

Runtime architecture

One character, one policy session, a ledger of effects

The local agent works through a headless game client. Go handles transport, observations, capability discovery, and validated execution. Editable Lua owns gameplay choices as the remaining compiled selectors are retired. The model can inspect and revise that policy while the character remains connected.

AzerothCore realmworld state and game events
↓ observations · ↑ actions
Go client + module runtimetyped capabilities · identity · current facts
↓ frames · ↑ proposals
Persistent Lua policytarget ranking · healing · spatial tactics
Logical data flow. The agent host edits policy and supplies objectives through the exposed development API. The copied stock viewer follows observed game traffic on a separate presentation path.

The types that carry the contract

This diagram selects actual Go types and fields from the public runtime. Arrows describe ownership or returned state. Methods and fields are abbreviated to keep the relationships readable.

modrt.SessionPolicy

vm       *behavior.Session
manager  *Manager
body     string

Reload(ctx, source, revision)

binds the runtime to a character
owns → behavior.Session

behavior.Session

state    map[string]any
latest   *DecisionSnapshot
rev      string
epoch    uint64

Reload(ctx, source, revision)
State(ctx)

owns the VM and committed state
returns → behavior.SessionState

behavior.SessionState

Status         SessionStatus
Checkpoint     map[string]any
LatestDecision *DecisionSnapshot
Pending        []ActionReceipt

detached state readback
contains → behavior.ActionReceipt

behavior.ActionReceipt

SessionID       string
ActionID        uint64
Outcome         ActionOutcome
Payload         map[string]any
NeverDispatched bool

ties an outcome to its reserved action

Source map — SessionPolicy · Session · SessionState · ActionReceipt

An action has a history

reserved→transport_accepted→unknown→confirmed / failed

One possible progression through the receipt ledger. A correlated result can settle an uncertain action. The host keeps its reservation through reloads so the next policy tick cannot casually issue the same action again. Other terminal outcomes include not_dispatched and settled_unverified.

Receipt outcomes and admitted transitions

A policy you can inspect

How a healer chooses a patient and a rank

The healing observation supplies caster readiness, mana, learned ranks, patient health, and distances in yards. Lua ranks eligible patients and chooses a spell. Native admission rechecks the exact cast against current conditions.

Patient priority from the public Lua policy

local function patient_priority(patient, selfGuid)
  if patient.guid == selfGuid and patient.health * 100 < patient.maxHealth * tuning.self_urgent_percent then
    return 1
  end
  if patient.health * 100 < patient.maxHealth * tuning.critical_percent then return 2 end
  if patient.underAttack then return 3 end
  return 4
end

Self below 50% is first, then a patient below 40%, then a patient under attack. The full selector breaks ties using health fraction, owner/self preference, and canonical decimal GUIDs. Those GUIDs stay strings to avoid numeric rounding.

Useful healing per resource

effective healing = min(observed spell amount, missing health)
normal score      = effective healing / max(1, mana cost)
urgent score      = effective healing / max(1500, cast time in ms)

The policy uses the urgent score when a patient is under attack or below its critical threshold. A configured largest rank mode instead scores effective healing directly.

Worked example

A hypothetical patient is missing 900 HP. Both ranks are affordable, ready, and in range. These numbers illustrate the scoring rule.

RankHeal amountManaEffective HPHP / mana
A6001506004.00
B1,2004009002.25

With normal resource scoring, A wins. At the same 1,500 ms cast time under urgent scoring, B wins because it restores more useful health per unit time.

Full healing selector, affordability checks, and rank scoring

Concurrent systems

Replace the playbook while events keep arriving

The reload call includes the source revision the editor read. Another edit can invalidate that expectation while compilation is in progress. The host checks the revision again at the swap boundary.

func (s *Session) Reload(ctx context.Context, source, expectedRevision string) (string, error) {
	return s.reload(ctx, source, expectedRevision, nil)
}

func (s *Session) reload(ctx context.Context, source, expectedRevision string, afterFence func()) (string, error) {
	s.mu.Lock()
	rev, epoch := s.rev, s.epoch
	if s.closed {
		s.mu.Unlock()
		return rev, ErrSessionClosed
	}
	if rev != expectedRevision || s.swapping || s.staging {
		s.mu.Unlock()
		return rev, ErrRevisionConflict
	}
  1. Compile a candidate. Create a separate VM under the session's resource limits while ingress remains available.
  2. Enter the boundary. Recheck revision and epoch, then fence earlier decision tickets.
  3. Transfer committed state. Import the detached checkpoint and pending action frame. Catch up the queued events.
  4. Commit the replacement. Publish the accepted revision at the decision boundary. Read back state and then observe the resulting game effects.

Compilation, import, or replay can reject the candidate. The active revision and committed state are retained. A candidate that reached the fence can still retire earlier decision tickets, which matters to concurrent callers.

Reload implementation · Policy state readback

Geometry meets gameplay

A doorway with zero radius still has volume

Maraudon's entrance references use rotated boxes. Treating a radius of zero as an absent trigger loses the doorway. The reference provides length, width, height, and orientation.

Rotated rectangular footprints of Maraudon entrance triggers 3133 and 3134.
Reference footprints plotted from the retained trigger dimensions. These describe static trigger geometry. A fresh body position, traversable route, and observed server transfer each need their own evidence.
// Rotate a point into the box's local coordinate frame.
dx = playerX - centerX
dy = playerY - centerY
localX =  cos(angle) * dx + sin(angle) * dy
localY = -sin(angle) * dx + cos(angle) * dy

inside = abs(localX) <= length / 2
      && abs(localY) <= width  / 2
      && abs(playerZ - centerZ) <= height / 2

Geometry pseudocode with coordinates centered on the trigger. Trigger 3133 has length 24.69, width 15.78, height 35.19, and orientation 4.538 radians. Lua chooses an allowed entrance and requests the route. Execution requires the companion's own observed position inside the volume before normal trigger notification.

Read the portal investigation · Source and geometry regressions in PR 241

Measurement lab

Inspect the timeline before trusting the file

The viewer drives a separate copied stock client from observed game traffic. A growing recording file can conceal frozen video while audio continues. Presentation timestamps expose that failure.

Largest video presentation timestamp gap fell from 9.975 seconds to 0.044 seconds in one paired recording test.
Same synthetic scene, one paired test. Removing FFmpeg's -shortest changed the largest video PTS gap from 9.975 s to 0.044 s. Corrected capture delivered 458 frames in 19.089 s, or 23.99 fps. The two tracks ended 11 ms apart.
Failed preflight video ended at 4.560 seconds while audio reached 295.615 seconds. A separate controlled qualification ended video at 118.060 and audio at 118.044 seconds.
A failed live preflight and a separate controlled qualification under different workloads. The incident contained 109 video frames. The replacement produced sustained video and stopped on an operator marker. These samples establish their individual outcomes.

Reproduce the timestamp inspection on your own recording

python3 - recording.mp4 <<'PYTHON'
import json
import math
import subprocess
import sys

probe = subprocess.run([
    "ffprobe", "-v", "error", "-select_streams", "v:0",
    "-show_entries", "packet=pts_time", "-of", "json", sys.argv[1]
], check=True, capture_output=True, text=True)
packets = json.loads(probe.stdout).get("packets", [])
pts = [float(packet["pts_time"]) for packet in packets]
if len(pts) < 2 or not all(math.isfinite(t) for t in pts):
    raise ValueError("Need at least two finite video timestamps")
pts.sort()
gaps = [b - a for a, b in zip(pts, pts[1:])]
print("largest video PTS gap (s):", max(gaps))
PYTHON

Offline inspection recipe requiring a readable video stream and complete, finite packet timestamps. A probe error, missing timestamp, or insufficient sample stops the calculation. Sorting packet timestamps measures presentation gaps even when the file uses reordered frames. Decode failures, image fidelity, and audio synchronization need additional checks.

Paired FFmpeg experiment · Recording ownership investigation · Download the curated chart data (JSON)

Does moving decisions to Lua shrink Go?

Per-change Go and Lua line deltas, including a Stealth port that increased Go by 111 lines and Lua by 18.
Historical source diffs. PRs 265/268 removed 1,144 net production Go lines and added 237 Lua lines. PR 275 added 111 Go and 18 Lua lines because execution and reconciliation required work. Line counts measure code changes. The caller path establishes who owns the gameplay choice.

The migration ledger and public PRs

What this system has demonstrated

EvidenceEstablished outcomeNext observation needed
Public source and regression suitesAccepted Lua edits can change real caller choices; reload and uncertain-action cases have explicit checks.Verify the matching installed revision and its effect in the connected character.
Dire Maul East field reportAll five survived the final Alzzin push with Bronzebeard leading through tools.Movement recovery remained necessary after knockback.
Dire Maul West first pullSeven observed attackers; two tank heals totaling 2,062 effective HP; the party wiped.A successful repeat pull and the cause of the extra engagement remain unverified.
Viewer fixtures and capture testsGround gait, camera controls, event attribution, and sustained recording were exercised in bounded cases.Current-run visual fidelity and reliable operation across dungeon workloads.

Fully local autonomous five-person leadership remains a development goal. This journal records source tests, controlled fixtures, and witnessed gameplay with their respective scope.

The work builds on the upstream agent-wow project. Our changes and experiments live in the public fork. For build and setup instructions, visit About.