BitQuirky.Behavior.Authority
Public behavior trees and state machines: runtime symbols in BitQuirky.Behavior.Authority.
Source snapshot ad0983d00d77.
On this page
Assembly: BitQuirky.Behavior.Runtime
AuthorityContext
Section titled “AuthorityContext”Category: Low-level runtime
readonly struct BitQuirky.Behavior.Authority.AuthorityContextSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:129-297
Implements: IEquatable<AuthorityContext>
Per-instance execution role. Built once at boot and passed to the tick job; cheap value type so it can travel through Burst code paths without managed indirection.
Responsibilities:
- Carry the executing role for the running instance.
- Decide whether a node may tick given its declared AuthorityKind, per data-model.md section Authority Context.
- Provide a single Evaluateentry the runtime tick job calls for (“Runtime refuses to tick a node in a mismatching context”).
Does NOT:
- Hold mutable state - once constructed, the context is immutable.
- Allocate managed memory (Burst-compatible).
- Decide blackboard ownership - that lives in BakedAuthorityEntryand the validator.
Members
Section titled “Members”AlsoActsAsHost
Section titled “AlsoActsAsHost”public bool AlsoActsAsHost { get; }Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:169
Editor / test contexts can elect to act as host for the purposes of host-authoritative ticking. A non-host client never gets this.
InEditor
Section titled “InEditor”public bool InEditor { get; }Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:177
True when running in the Unity Editor process (editor play-mode or edit-mode). Required for ticking EditorTestOnlynodes - shipping builds set this to false and refuse those nodes .
public BitQuirky.Behavior.Authority.ExecutingRole Role { get; }Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:163
Role this instance executes as. Fixed when the context is constructed and never changes.
AuthorityContext(ExecutingRole role, bool alsoActsAsHost, bool inEditor)
Section titled “AuthorityContext(ExecutingRole role, bool alsoActsAsHost, bool inEditor)”public AuthorityContext(BitQuirky.Behavior.Authority.ExecutingRole role, bool alsoActsAsHost = false, bool inEditor = false)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:150-157
Build a context.alsoActsAsHostlets
EditorTesttick host-authoritative
- client-presentation nodes the way a host editor would (this matches macro-test runs that drive the live simulation in a single editor process).
CanTick(AuthorityKind nodeAuthority)
Section titled “CanTick(AuthorityKind nodeAuthority)”public bool CanTick(BitQuirky.Behavior.Authority.AuthorityKind nodeAuthority)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:235-236
Convenience: true whenEvaluatewould return Allowed.
CanTick(BakedAuthorityContext bakedAuthority)
Section titled “CanTick(BakedAuthorityContext bakedAuthority)”public bool CanTick(BitQuirky.Behavior.Baked.BakedAuthorityContext bakedAuthority)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:250-251
Convenience overload that accepts the baked authority code, so a caller can pass
BakedNode.Authoritystraight in; true when such a node may tick here.
Client(bool inEditor)
Section titled “Client(bool inEditor)”public static BitQuirky.Behavior.Authority.AuthorityContext Client(bool inEditor = false)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:188-189
Standard non-host client context: ticks client-presentation only.
EditorTest()
Section titled “EditorTest()”public static BitQuirky.Behavior.Authority.AuthorityContext EditorTest()Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:196-197
Editor / macro-test context. Acts as host so it can drive the full simulation locally and additionally permits EditorTestOnlynodes.
Equals(AuthorityContext other)
Section titled “Equals(AuthorityContext other)”public bool Equals(BitQuirky.Behavior.Authority.AuthorityContext other)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:257
Two contexts are equal when they carry the same role and the same host and editor flags.
Equals(object obj)
Section titled “Equals(object obj)”public override bool Equals(object obj)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:262
Equal only to anotherAuthorityContextwith the same role and flags.
Evaluate(AuthorityKind nodeAuthority)
Section titled “Evaluate(AuthorityKind nodeAuthority)”public BitQuirky.Behavior.Authority.AuthorityGateOutcome Evaluate(BitQuirky.Behavior.Authority.AuthorityKind nodeAuthority)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:203-229
Pure decision: may a node with the given declared authority tick in this context? Burst-callable.
Evaluate(BakedAuthorityContext bakedAuthority)
Section titled “Evaluate(BakedAuthorityContext bakedAuthority)”public BitQuirky.Behavior.Authority.AuthorityGateOutcome Evaluate(BitQuirky.Behavior.Baked.BakedAuthorityContext bakedAuthority)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:243-244
Convenience overload that accepts the baked authority code, so
the tick job can passBakedNode.Authoritystraight in
without translating.
FromBaked(BakedAuthorityContext baked)
Section titled “FromBaked(BakedAuthorityContext baked)”public static BitQuirky.Behavior.Authority.AuthorityKind FromBaked(BitQuirky.Behavior.Baked.BakedAuthorityContext baked)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:289
Map the baked numeric authority code back to the logical kind. Stable byte values across the three enums are deliberate so this is just a cast.
GetHashCode()
Section titled “GetHashCode()”public override int GetHashCode()Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:265
Hash over the role and flag bits, so equal contexts hash alike.
Host(bool inEditor)
Section titled “Host(bool inEditor)”public static BitQuirky.Behavior.Authority.AuthorityContext Host(bool inEditor = false)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:182-183
Standard host context: ticks host-authoritative + client-presentation.
ToBaked(AuthorityKind kind)
Section titled “ToBaked(AuthorityKind kind)”public static BitQuirky.Behavior.Baked.BakedAuthorityContext ToBaked(BitQuirky.Behavior.Authority.AuthorityKind kind)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:294
Inverse ofFromBaked.
ToString()
Section titled “ToString()”public override string ToString()Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:277-278
Returns a diagnostic string naming the role and both flags; intended for logs, not for parsing.
op_Equality(AuthorityContext a, AuthorityContext b)
Section titled “op_Equality(AuthorityContext a, AuthorityContext b)”public static bool operator ==(BitQuirky.Behavior.Authority.AuthorityContext a, BitQuirky.Behavior.Authority.AuthorityContext b)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:268
True when both contexts carry the same role and flags.
op_Inequality(AuthorityContext a, AuthorityContext b)
Section titled “op_Inequality(AuthorityContext a, AuthorityContext b)”public static bool operator !=(BitQuirky.Behavior.Authority.AuthorityContext a, BitQuirky.Behavior.Authority.AuthorityContext b)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:271
True when the contexts differ in role or in either flag.
AuthorityGateOutcome
Section titled “AuthorityGateOutcome”Category: Low-level runtime
enum BitQuirky.Behavior.Authority.AuthorityGateOutcomeSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:87-107
Underlying type: byte
Outcome reported by the runtime gate.
Members
Section titled “Members”Allowed
Section titled “Allowed”Allowed = 0Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:92
The node may tick on this instance.
AuthorityMismatch
Section titled “AuthorityMismatch”AuthorityMismatch = 1Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:99
The node’s authority does not match the executing context. The
node MUST reportauthority-mismatchand decline to tick
(section Tick contract).
UndeclaredAuthority
Section titled “UndeclaredAuthority”UndeclaredAuthority = 2Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:106
The node’s authority isUnknown; the runtime cannot decide. Bake-time validation should have rejected this - the gate refuses to tick to surface the regression.
AuthorityHandoffHandler
Section titled “AuthorityHandoffHandler”Category: Low-level runtime
class BitQuirky.Behavior.Authority.AuthorityHandoffHandlerSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:123-424
Coordinates host-migration handoff for one or more followers. Invoked by the host loop the moment authority changes (FishNet migration, lobby host swap, etc.) and BEFORE the next tick step.
Responsibilities:
- For every follower whose authority changed: enumerate every registeredIExternalServiceAdapterand call OnAuthorityHandoff. The default adapter response is Cancel; adapters that support replay returnResume.
- Apply the node author’s AuthorityHandoffResolutionto the follower’s runtime instance: Restart (default) cancels pending externals on the instance; Resume keeps them and lets adapter replay re-issue; Abort cancels pending externals AND stamps a typed AuthorityHandofffailure.
- Record a structuredAuthorityHandoffReportper
follower so diagnostics surfaces (e.g.
follower.behavior-report) can show what happened.
Does NOT:
- Reach into adapter internals: the contract is the IExternalServiceAdapterinterface only.
- Mutate consumer gameplay data directly: pending external cancellation flows through the completion ring.
- Log via
Log/LogTrace; reports surface through command surfaces.
Members
Section titled “Members”Adapters
Section titled “Adapters”public System.Collections.Generic.IReadOnlyList<BitQuirky.Behavior.ExternalService.IExternalServiceAdapter> Adapters { get; }Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:161
Adapters this handler consults on every handoff, in registration order. Fixed at construction.
AuthorityHandoffHandler(IEnumerable<IExternalServiceAdapter> adapters)
Section titled “AuthorityHandoffHandler(IEnumerable<IExternalServiceAdapter> adapters)”public AuthorityHandoffHandler(System.Collections.Generic.IEnumerable<BitQuirky.Behavior.ExternalService.IExternalServiceAdapter> adapters)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:138-155
Copies the registered adapter set the handler notifies on migration.
Exceptions
ArgumentNullException:adaptersis null.ArgumentException:adapterscontains a null adapter.
ResolveBatch(IReadOnlyList<FollowerHandoffRequest> requests, int frameNumber, ExternalServiceCompletionRing completionRing, BehaviorRuntimeInstance[] instances, List<AuthorityHandoffReport> reports)
Section titled “ResolveBatch(IReadOnlyList<FollowerHandoffRequest> requests, int frameNumber, ExternalServiceCompletionRing completionRing, BehaviorRuntimeInstance[] instances, List<AuthorityHandoffReport> reports)”public void ResolveBatch(System.Collections.Generic.IReadOnlyList<BitQuirky.Behavior.Authority.FollowerHandoffRequest> requests, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Execution.BehaviorRuntimeInstance[] instances, System.Collections.Generic.List<BitQuirky.Behavior.Authority.AuthorityHandoffReport> reports)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:301-331
Resolve a handoff for a batch of followers. Each follower gets its own report; the order matches the input order.
ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance)
Section titled “ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance)”public BitQuirky.Behavior.Authority.AuthorityHandoffReport ResolveForFollower(UnityEngine.EntityId entityId, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Nodes.AuthorityHandoffResolution resolution, ref BitQuirky.Behavior.Execution.BehaviorRuntimeInstance instance)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:175-189
Resolve a handoff for one follower. Mutates
instancein place per the node author’s
resolution.
The active node’s resolution (resolution)
is read by the runtime instance from the active baked node’s
authoring metadata; the handler accepts it as a parameter so
it can be unit-tested without round-tripping through the bake.
ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance, NativeArray<BehaviorActionRuntimeState> actionStates)
Section titled “ResolveForFollower(EntityId entityId, int frameNumber, ExternalServiceCompletionRing completionRing, AuthorityHandoffResolution resolution, ref BehaviorRuntimeInstance instance, NativeArray<BehaviorActionRuntimeState> actionStates)”public BitQuirky.Behavior.Authority.AuthorityHandoffReport ResolveForFollower(UnityEngine.EntityId entityId, int frameNumber, BitQuirky.Behavior.ExternalService.ExternalServiceCompletionRing completionRing, BitQuirky.Behavior.Nodes.AuthorityHandoffResolution resolution, ref BitQuirky.Behavior.Execution.BehaviorRuntimeInstance instance, Unity.Collections.NativeArray<BitQuirky.Behavior.Execution.BehaviorActionRuntimeState> actionStates)Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:196-295
Resolves a handoff while also reconciling the additive per-action progress table. Running action rows are retained only for an accepted Resume; every other outcome marks them interrupted exactly once before the list either restarts or reports failure.
AuthorityHandoffOutcome
Section titled “AuthorityHandoffOutcome”Category: Low-level runtime
enum BitQuirky.Behavior.Authority.AuthorityHandoffOutcomeSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:40-70
Underlying type: byte
Outcome of a handoff resolution for one follower. Surfaces back to the runtime instance as a typed AuthorityHandofffailure when the node author’s resolution isAbort, or asNoneafter a successful restart / resume.
Members
Section titled “Members”Aborted
Section titled “Aborted”Aborted = 3Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:69
Node author elected Abort. The node drops to a typedAuthorityHandoff failure on the next tick.
NoPending
Section titled “NoPending”NoPending = 0Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:46
No outstanding pending externals: the follower’s active node keeps ticking under the new authority unchanged.
Restarted
Section titled “Restarted”Restarted = 1Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:53
Pending externals were cancelled (default) and the active node will restart on the next tick. Adapters posted CancelledByHandoffrecords.
Resumed
Section titled “Resumed”Resumed = 2Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:61
Adapters supporting replay re-issued every outstanding pending id; the node resumes seamlessly. Bake validation guarantees this is reachable only when every awaited adapter SupportsReplay.
AuthorityHandoffReport
Section titled “AuthorityHandoffReport”Category: Low-level runtime
struct BitQuirky.Behavior.Authority.AuthorityHandoffReportSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:78-89
One row of handoff diagnostics: what happened to a follower’s
pending externals during the handoff. Surfaced via
follower.behavior-reportso the operator can see why a
node restarted / aborted.
Members
Section titled “Members”EntityId
Section titled “EntityId”public UnityEngine.EntityId EntityIdSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:81
Follower this row describes.
Outcome
Section titled “Outcome”public BitQuirky.Behavior.Authority.AuthorityHandoffOutcome OutcomeSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:83
What the handoff did to the follower’s in-flight work.
PendingExternalsResolved
Section titled “PendingExternalsResolved”public int PendingExternalsResolvedSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:88
How many of the follower’s pending external operations the handoff dealt with, whether they were cancelled, replayed, or aborted.
AuthorityKind
Section titled “AuthorityKind”Category: Low-level runtime
enum BitQuirky.Behavior.Authority.AuthorityKindSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:35-48
Underlying type: byte
Authority context declared on a behavior node. Numeric values are
stable across bakes and are kept in lock-step with
BakedAuthorityContextand the authoring-layer
BehaviorSourceAuthorityenum so a single byte round-trips
between parse, bake, native artifact, and runtime gate without
re-mapping.
Members
Section titled “Members”ClientPresentation
Section titled “ClientPresentation”ClientPresentation = 2Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:44
A client instance may tick the node, for presentation only.
EditorTestOnly
Section titled “EditorTestOnly”EditorTestOnly = 3Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:47
Only an editor test may tick the node, never a shipped session.
HostAuthoritative
Section titled “HostAuthoritative”HostAuthoritative = 1Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:41
Only the authoritative host instance may tick the node.
Unknown
Section titled “Unknown”Unknown = 0Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:38
No authority was declared; the gate refuses to tick the node.
ExecutingRole
Section titled “ExecutingRole”Category: Low-level runtime
enum BitQuirky.Behavior.Authority.ExecutingRoleSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:54-82
Underlying type: byte
Role of the executing instance. The runtime authority gate compares this against a node’s declaredAuthorityKind.
Members
Section titled “Members”Client
Section titled “Client”Client = 2Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:70
Non-host client (e.g. a remote peer). May tick ClientPresentationnodes only.
EditorTest
Section titled “EditorTest”EditorTest = 3Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:81
Editor play-mode + macro-test runs. May tick EditorTestOnlynodes (and is the ONLY role allowed to do so; player / headless / shipping builds refuse). Treated as host-equivalent for HostAuthoritative/ ClientPresentationnodes when AlsoActsAsHostis set.
Host = 1Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:64
Authoritative simulation. The host is also a client (it renders the same view), but only the host instance ticks HostAuthoritativenodes.
Unknown
Section titled “Unknown”Unknown = 0Source declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityContext.cs:57
The executing role was never set; the gate refuses every authority-bearing node.
FollowerHandoffRequest
Section titled “FollowerHandoffRequest”Category: Low-level runtime
struct BitQuirky.Behavior.Authority.FollowerHandoffRequestSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:433-442
One follower’s handoff request: which follower, and the active node’s declared resolution (read from the baked node’s authoring metadata by the host loop).
Members
Section titled “Members”EntityId
Section titled “EntityId”public UnityEngine.EntityId EntityIdSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:436
Follower whose authority changed.
Resolution
Section titled “Resolution”public BitQuirky.Behavior.Nodes.AuthorityHandoffResolution ResolutionSource declaration: Packages/io.bitquirky.behavior/Runtime/Authority/AuthorityHandoffHandler.cs:441
Resolution declared by the follower’s active node, which decides whether its pending external work restarts, resumes, or aborts.
Source fingerprint: sha256:ad0983d00d773d882bc61865e18d8c5559e009d181e5891575cd7f262515b23e