@rulvar/core 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +77 -4
- package/dist/index.js +112 -10
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1800,7 +1800,16 @@ interface ResumeReport {
|
|
|
1800
1800
|
misses: number;
|
|
1801
1801
|
skipped: number;
|
|
1802
1802
|
reruns: number;
|
|
1803
|
-
/**
|
|
1803
|
+
/**
|
|
1804
|
+
* Effect roots that genuinely need recovery under the entry-type
|
|
1805
|
+
* pairing rules: dangling dispatches (status 'running' with no
|
|
1806
|
+
* terminal) and suspensions with no resolution, neither consumed by a
|
|
1807
|
+
* live call nor covered by abandon. Complete operations are NEVER
|
|
1808
|
+
* listed: settled roots, single-entry kinds (decisions, facts, plan
|
|
1809
|
+
* and termination entries), and resolved suspensions are whole by
|
|
1810
|
+
* construction. A call deleted from the code is silently skipped and
|
|
1811
|
+
* never re-paid; it appears here only while its effect is dangling.
|
|
1812
|
+
*/
|
|
1804
1813
|
orphaned: number[];
|
|
1805
1814
|
}
|
|
1806
1815
|
/**
|
|
@@ -1813,6 +1822,8 @@ declare class JournalMatcher {
|
|
|
1813
1822
|
private readonly byScope;
|
|
1814
1823
|
private readonly all;
|
|
1815
1824
|
private readonly consumed;
|
|
1825
|
+
/** Suspension seqs holding at least one resolution ref-entry. */
|
|
1826
|
+
private readonly resolvedRefs;
|
|
1816
1827
|
private readonly keyRing;
|
|
1817
1828
|
private disposition;
|
|
1818
1829
|
private aliasDisposition?;
|
|
@@ -3114,9 +3125,14 @@ interface TerminationLimits {
|
|
|
3114
3125
|
kMax: number;
|
|
3115
3126
|
/** B0; immutable after start, no API including HITL can top up. */
|
|
3116
3127
|
runBudgetUsdCeiling: number;
|
|
3117
|
-
/**
|
|
3128
|
+
/**
|
|
3129
|
+
* The resolved orchestrator cap in absolute USD (DEF-7; XF-09),
|
|
3130
|
+
* frozen with the counters. Journals recorded before v1.8 store 0
|
|
3131
|
+
* ("not yet resolved"); for them the orchestrator_budget_reserve
|
|
3132
|
+
* decision is the authority and is recovered on resume.
|
|
3133
|
+
*/
|
|
3118
3134
|
orchestratorCapUsd: number;
|
|
3119
|
-
/**
|
|
3135
|
+
/** The finalize reserve carved out of the cap; 0 in pre-v1.8 journals. */
|
|
3120
3136
|
finalizeReserveUsd: number;
|
|
3121
3137
|
}
|
|
3122
3138
|
/** Appendix A committed defaults for the countable resources. */
|
|
@@ -3441,7 +3457,7 @@ declare class RunBudget {
|
|
|
3441
3457
|
parentScope?: string;
|
|
3442
3458
|
ceilingUsd?: number;
|
|
3443
3459
|
finalizeReserveUsd?: number;
|
|
3444
|
-
kind?: "orchestrator-cap";
|
|
3460
|
+
kind?: "orchestrator-cap" | "child-allowance";
|
|
3445
3461
|
}): void;
|
|
3446
3462
|
/**
|
|
3447
3463
|
* The diagnostic projection behind a ceiling error: the first CLOSED
|
|
@@ -3462,6 +3478,18 @@ declare class RunBudget {
|
|
|
3462
3478
|
* fractions never eat finalization money). Undefined when uncapped.
|
|
3463
3479
|
*/
|
|
3464
3480
|
remainderOf(scope: string): number | undefined;
|
|
3481
|
+
/**
|
|
3482
|
+
* The tightest allowance headroom on the chain of `scope`: the minimum
|
|
3483
|
+
* remainder across 'child-allowance' accounts. An allowance ceiling
|
|
3484
|
+
* bounds the child's LIFETIME spend, so projected admission must never
|
|
3485
|
+
* hold more than this against the chain (the layer-2 mirror lives in
|
|
3486
|
+
* the orchestrator admission's childCeiling clamp): a reserve above
|
|
3487
|
+
* the allowance would deny work that the allowance itself already
|
|
3488
|
+
* bounds. Undefined when no allowance account is on the chain; the
|
|
3489
|
+
* clamp never applies to the run root or an orchestrator cap, whose
|
|
3490
|
+
* headroom is shared money that projected admission must protect.
|
|
3491
|
+
*/
|
|
3492
|
+
allowanceHeadroomOf(scope: string): number | undefined;
|
|
3465
3493
|
/** Layer 3 ceiling signal of the run root; live streams sever through it. */
|
|
3466
3494
|
get signal(): AbortSignal;
|
|
3467
3495
|
/** The layer-3 signal of one sub-account's subtree, when it exists. */
|
|
@@ -3750,6 +3778,23 @@ type AdmitRejectReason = {
|
|
|
3750
3778
|
code: "osc_guard";
|
|
3751
3779
|
spawnKey: SpawnKey;
|
|
3752
3780
|
oscillationCount: number;
|
|
3781
|
+
} | {
|
|
3782
|
+
/**
|
|
3783
|
+
* The declared estimate cannot fit the child's own ceiling: the
|
|
3784
|
+
* host said the work costs more than the budget buys, so the op
|
|
3785
|
+
* is bounced with the actionable correction BEFORE it changes
|
|
3786
|
+
* plan state or consumes a spawn unit (the v1.7.0 follow-up
|
|
3787
|
+
* review's P1). Heuristic reserves never produce this code; they
|
|
3788
|
+
* clamp to the allowance instead.
|
|
3789
|
+
*/
|
|
3790
|
+
code: "reserve_exceeds_budget";
|
|
3791
|
+
agentType: string;
|
|
3792
|
+
childAccount: string;
|
|
3793
|
+
estCostUsd: number;
|
|
3794
|
+
resolvedReserveUsd: number;
|
|
3795
|
+
childCeilingUsd: number;
|
|
3796
|
+
minimumBudgetUsd: number;
|
|
3797
|
+
message: string;
|
|
3753
3798
|
};
|
|
3754
3799
|
/** Every spawn origin routed through the single admission point. */
|
|
3755
3800
|
type SpawnOrigin = "ctx.workflow" | "ctx.orchestrate" | "spawn_agent" | "parallel_agents" | "escalation-decomposition" | "rung-respawn" | "reuse-link";
|
|
@@ -3767,6 +3812,13 @@ interface AdmitSpec {
|
|
|
3767
3812
|
/** Reserve hint; falls back to the flat engine default. */
|
|
3768
3813
|
estCostUsd?: number;
|
|
3769
3814
|
/**
|
|
3815
|
+
* Same-batch reserves already admitted read-only but not yet
|
|
3816
|
+
* committed (a multi-op plan revision): the read-only branch adds
|
|
3817
|
+
* them to this spawn's reserve so every embedded admit of one batch
|
|
3818
|
+
* is dispatchable under the same snapshot, not just the first.
|
|
3819
|
+
*/
|
|
3820
|
+
pendingReserveUsd?: number;
|
|
3821
|
+
/**
|
|
3770
3822
|
* Lineage continuation (DEF-3); absence mints a fresh lineage root. A
|
|
3771
3823
|
* continuation demands a causeRef: the seq of the entry that caused the
|
|
3772
3824
|
* rebirth.
|
|
@@ -3917,6 +3969,17 @@ declare class AdmissionController {
|
|
|
3917
3969
|
* journaled by the caller so replay re-delivers it without
|
|
3918
3970
|
* re-evaluation.
|
|
3919
3971
|
*/
|
|
3972
|
+
/**
|
|
3973
|
+
* The reserve the DISPATCH layer will actually commit for this spec:
|
|
3974
|
+
* the estimate (or the flat default) clamped by the explicit child
|
|
3975
|
+
* budget when one exists, because only an explicit budget opens a
|
|
3976
|
+
* child-allowance account at dispatch; the childBudgetFraction cap
|
|
3977
|
+
* never materializes as an account and must not shrink the
|
|
3978
|
+
* projection. The token-count-priced estimate of ctx.agent is
|
|
3979
|
+
* unreachable here (async); a divergence there lands as a journaled
|
|
3980
|
+
* dispatch rejection instead of a strand.
|
|
3981
|
+
*/
|
|
3982
|
+
projectedDispatchReserveUsd(spec: Pick<AdmitSpec, "estCostUsd" | "budgetUsd">): number;
|
|
3920
3983
|
admit(spec: AdmitSpec, options?: {
|
|
3921
3984
|
commitReserve?: boolean;
|
|
3922
3985
|
}): AdmissionDecision;
|
|
@@ -4818,6 +4881,16 @@ interface OrchestratorExtensionIO {
|
|
|
4818
4881
|
readonly gates: Record<string, unknown>;
|
|
4819
4882
|
/** The run USD ceiling (B0), when one exists. */
|
|
4820
4883
|
readonly runCeilingUsd?: number;
|
|
4884
|
+
/**
|
|
4885
|
+
* The resolved orchestrator cap in absolute USD (DEF-7; XF-09):
|
|
4886
|
+
* min(budget.capUsd, capFraction x B0) on a fresh run, the frozen
|
|
4887
|
+
* orchestrator_budget_reserve dollars on resume. Resolved strictly
|
|
4888
|
+
* before boot so an extension can freeze it into termination.init;
|
|
4889
|
+
* always present under PlanRunner (an unresolvable cap refuses boot).
|
|
4890
|
+
*/
|
|
4891
|
+
readonly orchestratorCapUsd?: number;
|
|
4892
|
+
/** The finalize reserve carved out of the cap, resolved with it. */
|
|
4893
|
+
readonly finalizeReserveUsd?: number;
|
|
4821
4894
|
/** ULID minting for engine-owned identifiers (NodeIds). */
|
|
4822
4895
|
mintId(): string;
|
|
4823
4896
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5054,6 +5054,8 @@ var JournalMatcher = class {
|
|
|
5054
5054
|
byScope = /* @__PURE__ */ new Map();
|
|
5055
5055
|
all = [];
|
|
5056
5056
|
consumed = /* @__PURE__ */ new Set();
|
|
5057
|
+
/** Suspension seqs holding at least one resolution ref-entry. */
|
|
5058
|
+
resolvedRefs = /* @__PURE__ */ new Set();
|
|
5057
5059
|
keyRing;
|
|
5058
5060
|
disposition;
|
|
5059
5061
|
aliasDisposition;
|
|
@@ -5069,7 +5071,10 @@ var JournalMatcher = class {
|
|
|
5069
5071
|
this.disposition = options?.disposition ?? roundOneDisposition;
|
|
5070
5072
|
const terminalsByRef = /* @__PURE__ */ new Map();
|
|
5071
5073
|
for (const entry of entries) {
|
|
5072
|
-
if (REF_ENTRY_KINDS.has(entry.kind))
|
|
5074
|
+
if (REF_ENTRY_KINDS.has(entry.kind)) {
|
|
5075
|
+
if (entry.kind === "resolution" && entry.ref !== void 0) this.resolvedRefs.add(entry.ref);
|
|
5076
|
+
continue;
|
|
5077
|
+
}
|
|
5073
5078
|
if (entry.ref !== void 0) terminalsByRef.set(entry.ref, entry);
|
|
5074
5079
|
}
|
|
5075
5080
|
for (const entry of entries) {
|
|
@@ -5246,7 +5251,12 @@ var JournalMatcher = class {
|
|
|
5246
5251
|
misses: this.missesInternal,
|
|
5247
5252
|
skipped: this.skippedInternal,
|
|
5248
5253
|
reruns: this.rerunsInternal,
|
|
5249
|
-
orphaned: this.all.filter((op) =>
|
|
5254
|
+
orphaned: this.all.filter((op) => {
|
|
5255
|
+
if (this.consumed.has(op.running.seq) || op.terminal !== void 0) return false;
|
|
5256
|
+
if (op.running.status === "running") return true;
|
|
5257
|
+
if (op.running.status === "suspended") return !this.resolvedRefs.has(op.running.seq);
|
|
5258
|
+
return false;
|
|
5259
|
+
}).map((op) => op.running.seq)
|
|
5250
5260
|
};
|
|
5251
5261
|
}
|
|
5252
5262
|
};
|
|
@@ -7285,7 +7295,7 @@ var NoProgressDetector = class {
|
|
|
7285
7295
|
return this.streakInternal >= this.threshold;
|
|
7286
7296
|
}
|
|
7287
7297
|
describe() {
|
|
7288
|
-
return `no-progress abort after ${this.streakInternal} consecutive turns without tool calls or artifact deltas (threshold ${this.threshold}; docs/
|
|
7298
|
+
return `no-progress abort after ${this.streakInternal} consecutive turns without tool calls or artifact deltas (threshold ${this.threshold}; https://docs.rulvar.com/guide/agents#the-agent-loop-and-turns)`;
|
|
7289
7299
|
}
|
|
7290
7300
|
};
|
|
7291
7301
|
//#endregion
|
|
@@ -9059,6 +9069,26 @@ var RunBudget = class {
|
|
|
9059
9069
|
if (account?.ceilingUsd === void 0) return;
|
|
9060
9070
|
return Math.max(0, account.ceilingUsd - account.spentUsd - account.committedReserveUsd - account.finalizeReserveUsd);
|
|
9061
9071
|
}
|
|
9072
|
+
/**
|
|
9073
|
+
* The tightest allowance headroom on the chain of `scope`: the minimum
|
|
9074
|
+
* remainder across 'child-allowance' accounts. An allowance ceiling
|
|
9075
|
+
* bounds the child's LIFETIME spend, so projected admission must never
|
|
9076
|
+
* hold more than this against the chain (the layer-2 mirror lives in
|
|
9077
|
+
* the orchestrator admission's childCeiling clamp): a reserve above
|
|
9078
|
+
* the allowance would deny work that the allowance itself already
|
|
9079
|
+
* bounds. Undefined when no allowance account is on the chain; the
|
|
9080
|
+
* clamp never applies to the run root or an orchestrator cap, whose
|
|
9081
|
+
* headroom is shared money that projected admission must protect.
|
|
9082
|
+
*/
|
|
9083
|
+
allowanceHeadroomOf(scope) {
|
|
9084
|
+
let headroom;
|
|
9085
|
+
for (const account of this.chainOf(scope)) {
|
|
9086
|
+
if (account.kind !== "child-allowance" || account.ceilingUsd === void 0) continue;
|
|
9087
|
+
const remainder = Math.max(0, account.ceilingUsd - account.spentUsd - account.committedReserveUsd - account.finalizeReserveUsd);
|
|
9088
|
+
headroom = headroom === void 0 ? remainder : Math.min(headroom, remainder);
|
|
9089
|
+
}
|
|
9090
|
+
return headroom;
|
|
9091
|
+
}
|
|
9062
9092
|
/** Layer 3 ceiling signal of the run root; live streams sever through it. */
|
|
9063
9093
|
get signal() {
|
|
9064
9094
|
return this.root.controller.signal;
|
|
@@ -9416,6 +9446,20 @@ var AdmissionController = class {
|
|
|
9416
9446
|
* journaled by the caller so replay re-delivers it without
|
|
9417
9447
|
* re-evaluation.
|
|
9418
9448
|
*/
|
|
9449
|
+
/**
|
|
9450
|
+
* The reserve the DISPATCH layer will actually commit for this spec:
|
|
9451
|
+
* the estimate (or the flat default) clamped by the explicit child
|
|
9452
|
+
* budget when one exists, because only an explicit budget opens a
|
|
9453
|
+
* child-allowance account at dispatch; the childBudgetFraction cap
|
|
9454
|
+
* never materializes as an account and must not shrink the
|
|
9455
|
+
* projection. The token-count-priced estimate of ctx.agent is
|
|
9456
|
+
* unreachable here (async); a divergence there lands as a journaled
|
|
9457
|
+
* dispatch rejection instead of a strand.
|
|
9458
|
+
*/
|
|
9459
|
+
projectedDispatchReserveUsd(spec) {
|
|
9460
|
+
const base = spec.estCostUsd ?? this.flatReserveUsd;
|
|
9461
|
+
return spec.budgetUsd === void 0 ? base : Math.min(base, spec.budgetUsd);
|
|
9462
|
+
}
|
|
9419
9463
|
admit(spec, options) {
|
|
9420
9464
|
const commitReserve = options?.commitReserve ?? true;
|
|
9421
9465
|
const nodeKey = spec.nodeKey ?? spec.parentAccountScope;
|
|
@@ -9502,7 +9546,8 @@ var AdmissionController = class {
|
|
|
9502
9546
|
}
|
|
9503
9547
|
else {
|
|
9504
9548
|
const remainder = this.budget.remainderOf(spec.parentAccountScope);
|
|
9505
|
-
|
|
9549
|
+
const projection = this.projectedDispatchReserveUsd(spec);
|
|
9550
|
+
if (remainder !== void 0 && (remainder <= 0 || remainder < projection + (spec.pendingReserveUsd ?? 0))) return {
|
|
9506
9551
|
verdict: {
|
|
9507
9552
|
kind: "reject",
|
|
9508
9553
|
reason: { code: "budget" }
|
|
@@ -10485,7 +10530,8 @@ function createCtx(internals, rootWorkflow) {
|
|
|
10485
10530
|
if (internals.flatReserveUsd !== void 0) reserveOptions.flatReserveUsd = internals.flatReserveUsd;
|
|
10486
10531
|
const reserve = internals.pricingOf !== void 0 && internals.pricingOf(loopResolved.ref) === void 0 && opts.estCost === void 0 && profile?.estCost === void 0 ? 0 : admissionReserveUsd(reserveOptions);
|
|
10487
10532
|
const budgetAccount = state.budgetScope ?? "run";
|
|
10488
|
-
internals.budget.
|
|
10533
|
+
const allowanceHeadroomUsd = internals.budget.allowanceHeadroomOf(budgetAccount);
|
|
10534
|
+
internals.budget.admitSpawn(allowanceHeadroomUsd === void 0 ? reserve : Math.min(reserve, allowanceHeadroomUsd), budgetAccount);
|
|
10489
10535
|
let acquired;
|
|
10490
10536
|
if (typeof isolation === "object" && isolation.kind === "worktree") {
|
|
10491
10537
|
const acquireInput = {
|
|
@@ -11129,7 +11175,10 @@ function createCtx(internals, rootWorkflow) {
|
|
|
11129
11175
|
if (verdict.kind !== "admit") throw new ConfigError(`admission verdict '${verdict.kind}' has no producer before M7 (DEF-5)`);
|
|
11130
11176
|
const reserve = verdict.reserve;
|
|
11131
11177
|
const openOptions = { parentScope: budgetAccount };
|
|
11132
|
-
if (reserve.childCeilingUsd !== void 0)
|
|
11178
|
+
if (reserve.childCeilingUsd !== void 0) {
|
|
11179
|
+
openOptions.ceilingUsd = reserve.childCeilingUsd;
|
|
11180
|
+
openOptions.kind = "child-allowance";
|
|
11181
|
+
}
|
|
11133
11182
|
internals.budget.openAccount(childScope, openOptions);
|
|
11134
11183
|
const running = danglingRunning ?? await internals.replayer.appendRunning({
|
|
11135
11184
|
scope: state.scope,
|
|
@@ -11419,6 +11468,8 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11419
11468
|
const cardText = declaredLadderNames.length === 0 ? profileCard(advertisedProfiles) : `${profileCard(spawnableProfiles)}\nDeclared ladders (tier context for the knowledge card; NOT agentType values, never spawn them): ${declaredLadderNames.join(", ")}.`;
|
|
11420
11469
|
const extension = opts?.extension;
|
|
11421
11470
|
let orchestratorAccount;
|
|
11471
|
+
/** DEF-2 cap drift found in the sync prologue; emitted after boot. */
|
|
11472
|
+
const pendingCapDrifts = [];
|
|
11422
11473
|
let capState;
|
|
11423
11474
|
{
|
|
11424
11475
|
const runCeiling = internals.budget.accountView(callingState.budgetScope ?? "run")?.ceilingUsd;
|
|
@@ -11427,8 +11478,45 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11427
11478
|
if (fraction > 1) throw new OrchestratorCapConfigError(`capFraction ${String(fraction)} exceeds 1.0 (opting out of the cap is explicit only, up to 1.0 inclusive)`);
|
|
11428
11479
|
const fromFraction = runCeiling === void 0 ? void 0 : fraction * runCeiling;
|
|
11429
11480
|
const bounds = [spec?.capUsd, fromFraction].filter((bound) => bound !== void 0);
|
|
11430
|
-
|
|
11431
|
-
|
|
11481
|
+
const priorReserveDecision = internals.replayer.snapshot().find((entry) => {
|
|
11482
|
+
if (entry.kind !== "decision" || entry.scope !== callingState.scope) return false;
|
|
11483
|
+
return entry.value?.decisionType === "orchestrator_budget_reserve";
|
|
11484
|
+
});
|
|
11485
|
+
if (priorReserveDecision !== void 0) {
|
|
11486
|
+
const frozen = priorReserveDecision.value;
|
|
11487
|
+
const turnEstimateUsd = internals.flatReserveUsd ?? .5;
|
|
11488
|
+
const liveFinalizeReserveUsd = spec?.finalizeReserveUsd ?? (spec?.finalizeTurns ?? 2) * turnEstimateUsd;
|
|
11489
|
+
pendingCapDrifts.push(...bounds.length > 0 && Math.min(...bounds) !== frozen.capUsd ? [{
|
|
11490
|
+
field: "orchestratorCapUsd",
|
|
11491
|
+
frozenValue: frozen.capUsd,
|
|
11492
|
+
liveValue: Math.min(...bounds)
|
|
11493
|
+
}] : [], ...liveFinalizeReserveUsd !== frozen.finalizeReserveUsd ? [{
|
|
11494
|
+
field: "finalizeReserveUsd",
|
|
11495
|
+
frozenValue: frozen.finalizeReserveUsd,
|
|
11496
|
+
liveValue: liveFinalizeReserveUsd
|
|
11497
|
+
}] : [], ...frozen.pricingVersion !== void 0 && frozen.pricingVersion !== (internals.pricingVersion ?? "unpriced") ? [{
|
|
11498
|
+
field: "pricingVersion",
|
|
11499
|
+
frozenValue: frozen.pricingVersion,
|
|
11500
|
+
liveValue: internals.pricingVersion ?? "unpriced"
|
|
11501
|
+
}] : []);
|
|
11502
|
+
orchestratorAccount = callingState.scope === "" ? "orchestrator" : `${callingState.scope}/orchestrator`;
|
|
11503
|
+
internals.budget.openAccount(orchestratorAccount, {
|
|
11504
|
+
parentScope: callingState.budgetScope ?? "run",
|
|
11505
|
+
ceilingUsd: frozen.capUsd,
|
|
11506
|
+
kind: "orchestrator-cap"
|
|
11507
|
+
});
|
|
11508
|
+
if (extension !== void 0) internals.budget.commitFinalizeReserve(orchestratorAccount, frozen.finalizeReserveUsd);
|
|
11509
|
+
capState = {
|
|
11510
|
+
effectiveCapUsd: frozen.capUsd,
|
|
11511
|
+
finalizeReserveUsd: frozen.finalizeReserveUsd,
|
|
11512
|
+
finalizeTurns: frozen.finalizeTurns,
|
|
11513
|
+
turnEstimateUsd,
|
|
11514
|
+
atCap: spec?.atCap ?? "finish-with-partial",
|
|
11515
|
+
source: frozen.source
|
|
11516
|
+
};
|
|
11517
|
+
}
|
|
11518
|
+
if (capState === void 0 && extension !== void 0 && bounds.length === 0) throw new OrchestratorCapConfigError("the orchestrator cap is unresolvable: the run has no USD ceiling and no explicit budget.capUsd; PlanRunner requires a resolved effectiveCap");
|
|
11519
|
+
if (capState === void 0 && bounds.length > 0) {
|
|
11432
11520
|
const effectiveCapUsd = Math.min(...bounds);
|
|
11433
11521
|
const turnEstimateUsd = internals.flatReserveUsd ?? .5;
|
|
11434
11522
|
const finalizeTurns = spec?.finalizeTurns ?? 2;
|
|
@@ -11505,7 +11593,10 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11505
11593
|
const scope = placement?.childScope ?? childScopeOf();
|
|
11506
11594
|
if (placement?.ownAccount === true) internals.budget.openAccount(scope, {
|
|
11507
11595
|
parentScope: callingState.budgetScope ?? "run",
|
|
11508
|
-
...placement.childCeilingUsd === void 0 ? {} : {
|
|
11596
|
+
...placement.childCeilingUsd === void 0 ? {} : {
|
|
11597
|
+
ceilingUsd: placement.childCeilingUsd,
|
|
11598
|
+
kind: "child-allowance"
|
|
11599
|
+
}
|
|
11509
11600
|
});
|
|
11510
11601
|
const childState = {
|
|
11511
11602
|
scope,
|
|
@@ -11574,6 +11665,10 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11574
11665
|
profiles: advertisedProfiles,
|
|
11575
11666
|
gates: internals.defaults.gates ?? {},
|
|
11576
11667
|
...internals.budget.ceilingUsd === void 0 ? {} : { runCeilingUsd: internals.budget.ceilingUsd },
|
|
11668
|
+
...capState === void 0 ? {} : {
|
|
11669
|
+
orchestratorCapUsd: capState.effectiveCapUsd,
|
|
11670
|
+
finalizeReserveUsd: capState.finalizeReserveUsd
|
|
11671
|
+
},
|
|
11577
11672
|
mintId: createCanonicalIdMinter(),
|
|
11578
11673
|
random: (key) => runtime.runInScope(callingState, () => Promise.resolve(ctx.random(key))),
|
|
11579
11674
|
append: (input) => internals.replayer.appendSinglePhase({
|
|
@@ -11831,6 +11926,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11831
11926
|
parentAccountScope: callingState.budgetScope ?? "run",
|
|
11832
11927
|
nodeKey: scope,
|
|
11833
11928
|
...params.budgetUsd === void 0 ? {} : { budgetUsd: params.budgetUsd },
|
|
11929
|
+
...profile?.estCost === void 0 ? {} : { estCostUsd: profile.estCost },
|
|
11834
11930
|
...params.lineage === void 0 ? {} : { lineage: {
|
|
11835
11931
|
continues: params.lineage.continues,
|
|
11836
11932
|
causeRef: params.lineage.causeRef,
|
|
@@ -11994,6 +12090,12 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
11994
12090
|
}
|
|
11995
12091
|
};
|
|
11996
12092
|
if (extension?.boot !== void 0) await extension.boot(io);
|
|
12093
|
+
for (const drift of pendingCapDrifts) internals.events.emit({
|
|
12094
|
+
type: "termination:config-drift",
|
|
12095
|
+
field: drift.field,
|
|
12096
|
+
frozenValue: drift.frozenValue,
|
|
12097
|
+
liveValue: drift.liveValue
|
|
12098
|
+
}, callingState.spanId);
|
|
11997
12099
|
let kbCardText;
|
|
11998
12100
|
const appendKbPin = async (decisionType, key) => {
|
|
11999
12101
|
const handle = internals.knowledge;
|
|
@@ -12037,7 +12139,7 @@ function makeOrchestratorWorkflow(goal, opts) {
|
|
|
12037
12139
|
}
|
|
12038
12140
|
const fullCardText = kbCardText === void 0 ? cardText : `${cardText}\n${kbCardText}`;
|
|
12039
12141
|
const reserveKey = deriverV2.deriveKey({ kind: "orchestrator-budget-reserve" });
|
|
12040
|
-
if (extension !== void 0 && capState !== void 0 && !internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === reserveKey)) {
|
|
12142
|
+
if (extension !== void 0 && capState !== void 0 && !internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.scope === callingState.scope && entry.key === reserveKey)) {
|
|
12041
12143
|
const initRef = internals.replayer.snapshot().find((entry) => entry.kind === "termination.init")?.seq;
|
|
12042
12144
|
await internals.replayer.appendSinglePhase({
|
|
12043
12145
|
scope: callingState.scope,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|