@rulvar/core 1.212.0 → 1.214.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.
Files changed (2) hide show
  1. package/dist/index.js +59 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23919,24 +23919,73 @@ function makeOrchestratorWorkflow(goal, opts) {
23919
23919
  }
23920
23920
  });
23921
23921
  internals.budget.markExhausted();
23922
- const fold = {
23922
+ const foldEnvelope = () => ({
23923
23923
  forcedFinishFallback: true,
23924
23924
  completion: "partial",
23925
23925
  planHash: "",
23926
23926
  completed: [...byOrdinal.values()].filter((record) => record.settled !== void 0).sort((a, b) => a.spawnOrdinal - b.spawnOrdinal).map((record) => digestOf(record, record.settled))
23927
- };
23927
+ });
23928
23928
  const synthesisReserveStillCommitted = orchestratorAccount !== void 0 && (internals.budget.accountView(orchestratorAccount)?.synthesisReserveUsd ?? 0) > 0;
23929
23929
  const anySettled = [...byOrdinal.values()].some((record) => record.settled !== void 0);
23930
- if (opts?.synthesis !== void 0 && synthesisReserveStillCommitted && anySettled) try {
23931
- const synthesized = await runSynthesis(void 0);
23932
- return {
23933
- ...fold,
23934
- result: synthesized
23930
+ if (opts?.synthesis !== void 0 && synthesisReserveStillCommitted && anySettled) {
23931
+ const stragglers = [...byOrdinal.values()].filter((record) => record.settled === void 0);
23932
+ for (const record of stragglers) record.abort();
23933
+ await Promise.all(stragglers.map((record) => record.result));
23934
+ const synthesisTerminalOf = (declined) => {
23935
+ if (!(declined instanceof BudgetExhaustedError)) return;
23936
+ const entryRef = declined.data?.entryRef;
23937
+ if (typeof entryRef !== "number") return;
23938
+ return internals.replayer.snapshot().find((entry) => entry.seq === entryRef);
23935
23939
  };
23936
- } catch {
23937
- return fold;
23940
+ let synthesisTransportRetried = false;
23941
+ for (;;) try {
23942
+ const synthesized = await runSynthesis(void 0);
23943
+ return {
23944
+ ...foldEnvelope(),
23945
+ result: synthesized
23946
+ };
23947
+ } catch (declined) {
23948
+ const terminal = synthesisTerminalOf(declined);
23949
+ if (!synthesisTransportRetried && terminal !== void 0 && terminal.error !== void 0 && terminal.error.data?.kind === "transport" && terminal.error.retryable === true) {
23950
+ synthesisTransportRetried = true;
23951
+ const retryKey = deriverV2.deriveKey({ kind: "orchestrator-synthesis-redemption-retry" });
23952
+ if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === retryKey)) await internals.replayer.appendSinglePhase({
23953
+ scope: callingState.scope,
23954
+ key: retryKey,
23955
+ kind: "decision",
23956
+ status: "ok",
23957
+ spanId: internals.spans.mint(callingState.spanId),
23958
+ site: "orchestrator-budget",
23959
+ value: {
23960
+ decisionType: "orchestrator_synthesis_redemption_retry",
23961
+ reason: terminal.error.message.slice(0, 300),
23962
+ terminalRef: terminal.seq,
23963
+ remainingUsd: internals.budget.remainingUsd() ?? null
23964
+ }
23965
+ });
23966
+ continue;
23967
+ }
23968
+ const declineKey = deriverV2.deriveKey({ kind: "orchestrator-synthesis-redemption-declined" });
23969
+ if (!internals.replayer.snapshot().some((entry) => entry.kind === "decision" && entry.key === declineKey)) await internals.replayer.appendSinglePhase({
23970
+ scope: callingState.scope,
23971
+ key: declineKey,
23972
+ kind: "decision",
23973
+ status: "ok",
23974
+ spanId: internals.spans.mint(callingState.spanId),
23975
+ site: "orchestrator-budget",
23976
+ value: {
23977
+ decisionType: "orchestrator_synthesis_redemption_declined",
23978
+ reason: (terminal?.error?.message ?? (declined instanceof Error ? declined.message : String(declined))).slice(0, 300),
23979
+ ...terminal === void 0 ? {} : { terminalRef: terminal.seq },
23980
+ remainingUsd: internals.budget.remainingUsd() ?? null,
23981
+ stragglersDrained: stragglers.length,
23982
+ transportRetries: synthesisTransportRetried ? 1 : 0
23983
+ }
23984
+ });
23985
+ return foldEnvelope();
23986
+ }
23938
23987
  }
23939
- return fold;
23988
+ return foldEnvelope();
23940
23989
  }
23941
23990
  const liveTermination = extensionTermination;
23942
23991
  if (liveTermination !== void 0) throw liveTermination;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/core",
3
- "version": "1.212.0",
3
+ "version": "1.214.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",