Skip to content

rulvar API reference


rulvar API reference / @rulvar/rulvar / TerminationAccount

Class: TerminationAccount

Defined in: packages/core/dist/index.d.ts

The single per-run TerminationAccount: debit ONLY. No credit operation exists by construction; reclaim never replenishes anything (DEF-5 interaction). Live: the engine debits the in-memory account, writes the carrying entry with the balance-after, then applies effects. Resume state is rebuilt by TerminationFold from the journal, never from live config.

Constructors

Constructor

ts
new TerminationAccount(options): TerminationAccount;

Defined in: packages/core/dist/index.d.ts

Parameters

ParameterType
options{ deniedWriter?: TerminationDeniedWriter; limits: TerminationLimits; }
options.deniedWriter?TerminationDeniedWriter
options.limitsTerminationLimits

Returns

TerminationAccount

Properties

PropertyModifierTypeDefined in
limitsreadonlyTerminationLimitspackages/core/dist/index.d.ts

Accessors

revisionUnitsRemaining

Get Signature

ts
get revisionUnitsRemaining(): number;

Defined in: packages/core/dist/index.d.ts

Returns

number


spawnUnitsExhausted

Get Signature

ts
get spawnUnitsExhausted(): boolean;

Defined in: packages/core/dist/index.d.ts

True when a spawn-unit debit would underflow (pre-reserve check).

Returns

boolean

Methods

bindDeniedWriter()

ts
bindDeniedWriter(writer): void;

Defined in: packages/core/dist/index.d.ts

Binds the denied-entry appender onto an account rebuilt by the fold (resume path): the fold is pure and cannot own I/O. Never rebinds an existing writer.

Parameters

ParameterType
writerTerminationDeniedWriter

Returns

void


debit()

ts
debit(
   resource, 
   lineage?, 
context?): Promise<DebitResult>;

Defined in: packages/core/dist/index.d.ts

The unified debit surface: attempts the named resource and, on underflow, writes termination.denied strictly BEFORE resolving with the typed failure (the caller surfaces the error only after this settles). Requires a deniedWriter; pure-fold contexts use the synchronous per-resource methods instead.

Parameters

ParameterType
resource"revisionUnits" | "spawnUnits" | "escalationUnits" | "rungs"
lineage?string
context?{ reasonCode?: string; requestedByRef?: number; }
context.reasonCode?string
context.requestedByRef?number

Returns

Promise&lt;DebitResult&gt;


debitEscalation()

ts
debitEscalation(logicalTaskId): 
  | {
  escalationUnitsAfter: number;
  ok: true;
}
  | {
  ok: false;
  resource: "escalationUnits";
};

Defined in: packages/core/dist/index.d.ts

The escalation debit: minus one escalationUnit of the affected lineage, including EACH lineage of a class-level decision and timeout defaultDecisions. Conditioned on the countsAgainstLimit flag embedded in the decision entry by the caller.

Parameters

ParameterType
logicalTaskIdstring

Returns

| { escalationUnitsAfter: number; ok: true; } | { ok: false; resource: "escalationUnits"; }


debitRevision()

ts
debitRevision(): 
  | {
  ok: true;
  revisionUnitsAfter: number;
}
  | {
  ok: false;
  resource: "revisionUnits";
};

Defined in: packages/core/dist/index.d.ts

The plan_revise debit: minus one revisionUnit on EVERY journaled plan.revision, regardless of the op count, guard verdicts, or the auto-rebase outcome; conflict spam is never a free retry.

Returns

| { ok: true; revisionUnitsAfter: number; } | { ok: false; resource: "revisionUnits"; }


debitRung()

ts
debitRung(logicalTaskId): 
  | {
  ok: true;
  rungIndexAfter: number;
  rungsRemainingAfter: number;
}
  | {
  ok: false;
  resource: "rungs";
};

Defined in: packages/core/dist/index.d.ts

The ladder-raise debit: minus one rung of the lineage; rungIndex is strictly monotone, there are no demotions and no runtime startTier promotion in v1.

Parameters

ParameterType
logicalTaskIdstring

Returns

| { ok: true; rungIndexAfter: number; rungsRemainingAfter: number; } | { ok: false; resource: "rungs"; }


debitSpawn()

ts
debitSpawn(lineage?): 
  | {
  ok: true;
  spawnUnitsAfter: number;
}
  | {
  ok: false;
  resource: "spawnUnits";
};

Defined in: packages/core/dist/index.d.ts

The spawn-admission debit: minus one spawnUnit for an admitted spawn of ANY origin; a NEW lineage receives E0 escalation units and (K_l - 1) rung transitions in the same atomic step, so the lemma's per-spawn decrease is C - (E0 + K_l - 1) = kMax - K_l + 1, at least 1. Synchronous: the caller embeds spawnUnitsAfter in the decision entry it appends next.

Parameters

ParameterType
lineage?{ isNew: boolean; ladderLength?: number; logicalTaskId: string; }
lineage.isNew?boolean
lineage.ladderLength?number
lineage.logicalTaskId?string

Returns

| { ok: true; spawnUnitsAfter: number; } | { ok: false; resource: "spawnUnits"; }


phi()

ts
phi(): number;

Defined in: packages/core/dist/index.d.ts

Phi = V + C * S + sum over live lineages (E + R).

Returns

number


restoreCounters()

ts
restoreCounters(state): void;

Defined in: packages/core/dist/index.d.ts

Fold use only: restores the run counters from journaled balances.

Parameters

ParameterType
state{ revisionUnitsRemaining?: number; spawnUnitsRemaining?: number; }
state.revisionUnitsRemaining?number
state.spawnUnitsRemaining?number

Returns

void


restoreLineage()

ts
restoreLineage(logicalTaskId, state): void;

Defined in: packages/core/dist/index.d.ts

Restores one lineage's counters from journaled balances (fold use only): never a credit path, the fold consumes recorded balances.

Parameters

ParameterType
logicalTaskIdstring
stateLineageCounters & { rungIndex?: number; }

Returns

void


rungIndexOf()

ts
rungIndexOf(logicalTaskId): number;

Defined in: packages/core/dist/index.d.ts

The current rung index of a lineage (0 before any raise).

Parameters

ParameterType
logicalTaskIdstring

Returns

number


snapshot()

ts
snapshot(): TerminationAccountSnapshot;

Defined in: packages/core/dist/index.d.ts

Returns

TerminationAccountSnapshot