Intelligence · class

AuthoritativeAgent

An agent whose model decisions are taken in one place.

Explained in Agents and behaviour.

class AuthoritativeAgent
import { AuthoritativeAgent } from '@driftengine/ai';

In depth

Wraps the two sessions the package already has and picks between them. It adds no policy, no provider handling and no replay logic; all three exist and are reused.

Constructor

new

constructor(session: AgentSession<unknown>, replay: ReplaySession, options: AuthoritativeAgentOptions)
ParameterTypeDescription
sessionAgentSession<unknown>
replayReplaySession
optionsAuthoritativeAgentOptions

Accessors

NameTypeDescription
publishedDecisionsgetnumberDecisions this peer put on the wire. Zero on a participant, always.
acceptedDecisionsgetnumberDecisions taken off the wire. Zero on the authority, always.
earliestLateTickgetnumberThe oldest tick a decision arrived for after that tick had already run, or -1.
More

A consumer holding a RewindLoop reads this, rewinds to it and replays. Cleared by clearLate once they have.

Methods

clearLate

clearLate(): void

tick

tick(tickNumber: number, nowMs: number): Intent

Advance one tick and return what the agent is doing.

ParameterTypeDescription
tickNumbernumber
nowMsnumber
More

Arriving decisions are drained before the tick runs, so a command for this tick is in the log by the time the replay reads it. A command for an earlier tick is recorded anyway — the log is keyed by acceptance tick, so it lands where a later rewind will find it — and noted in earliestLateTick.