@ancientpantheon/khronoton-core 0.13.0 → 0.15.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/CHANGELOG.md +31 -0
- package/README.md +8 -0
- package/dist/{chunk-IAK4UEAA.js → chunk-24THBKR7.js} +188 -28
- package/dist/{chunk-7H5TM3CS.js → chunk-VPVEIDNN.js} +1 -1
- package/dist/{context-P-rCtBbJ.d.ts → context-ec4m0UBZ.d.ts} +1 -1
- package/dist/handlers/execute.js +28 -41
- package/dist/handlers/steps.js +51 -14
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/provider/index.d.ts +3 -3
- package/dist/provider/index.js +93 -45
- package/dist/server/fire-and-record.d.ts +47 -0
- package/dist/server/fire-and-record.js +85 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +9 -0
- package/dist/server/planners/registry.d.ts +41 -3
- package/dist/server/planners/registry.js +49 -5
- package/dist/server/planners/stoa-wrap.d.ts +11 -7
- package/dist/server/planners/stoa-wrap.js +61 -33
- package/dist/server/pure/yields.d.ts +57 -0
- package/dist/server/pure/yields.js +101 -0
- package/dist/server/resolvers.js +7 -1
- package/dist/server/runs-driver.js +89 -18
- package/dist/server/schema.d.ts +4 -3
- package/dist/server/schema.js +26 -1
- package/dist/server/single-tx.d.ts +44 -0
- package/dist/server/single-tx.js +143 -0
- package/dist/server/store/cronoton.d.ts +21 -0
- package/dist/server/store/cronoton.js +72 -5
- package/dist/server/store/index.d.ts +2 -1
- package/dist/server/store/index.js +3 -1
- package/dist/server/store/steps.d.ts +12 -0
- package/dist/server/store/steps.js +26 -3
- package/dist/server/store/yields.d.ts +46 -0
- package/dist/server/store/yields.js +73 -0
- package/dist/server/tick.js +38 -0
- package/dist/server/types.d.ts +31 -0
- package/dist/{types-uYSglFrJ.d.ts → types-DH7Ym8FQ.d.ts} +17 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +2 -2
- package/package.json +1 -1
package/dist/server/tick.js
CHANGED
|
@@ -43,6 +43,7 @@ import { createRun } from "./store/runs.js";
|
|
|
43
43
|
import { RunAlreadyInFlightError } from "./store/errors.js";
|
|
44
44
|
import { listStepsForCronoton } from "./store/steps.js";
|
|
45
45
|
import { driveRunOnce } from "./runs-driver.js";
|
|
46
|
+
import { attemptSingleTxFirst } from "./single-tx.js";
|
|
46
47
|
/**
|
|
47
48
|
* One multi-tx `onTx` collector + the `FireTxKey[]` it fills, threaded into
|
|
48
49
|
* {@link fireByServerResolver} so an INLINE multi-tx fire records the per-tx
|
|
@@ -83,6 +84,21 @@ export async function codexCronotonTickOnce(now, ctx) {
|
|
|
83
84
|
skippedIds.push(row.id);
|
|
84
85
|
continue;
|
|
85
86
|
}
|
|
87
|
+
// Try-single-tx-first decision — ahead of the chained/plain branch below,
|
|
88
|
+
// per docs/work/khronoton-single-tx-custom/design.md. `fired: false` means
|
|
89
|
+
// either the flag is off or the simulate was refused specifically for
|
|
90
|
+
// being too expensive; either way fall through to the existing
|
|
91
|
+
// chained/plain decision unchanged. `fired: true` means the single-tx
|
|
92
|
+
// variant was actually fired (successfully or not) — the chained/plain
|
|
93
|
+
// path below is never reached for this row.
|
|
94
|
+
const attempt = await attemptSingleTxFirst(row, ctx, { auditDetailExtra: { actor: "scheduler" } });
|
|
95
|
+
if (attempt.fired) {
|
|
96
|
+
if (attempt.result.ok)
|
|
97
|
+
firedIds.push(row.id);
|
|
98
|
+
else
|
|
99
|
+
failedIds.push(row.id);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
86
102
|
// Chained (≥1 codex_cronoton_steps row) vs plain — design.md §A/§B. A
|
|
87
103
|
// chained row never reaches the one-shot fire path below: its lifecycle
|
|
88
104
|
// lives in codex_cronoton_runs/..._run_legs, not codex_cronoton_fires.
|
|
@@ -218,6 +234,28 @@ export async function processDueManualBatchesOnce(now, ctx) {
|
|
|
218
234
|
cancelledIds.push(batch.id);
|
|
219
235
|
continue;
|
|
220
236
|
}
|
|
237
|
+
if (cronoton.try_single_tx_first) {
|
|
238
|
+
// A review finding caught this: this loop fires the parent's raw
|
|
239
|
+
// top-level definition directly via `fireByServerResolver`, with NO
|
|
240
|
+
// `attemptSingleTxFirst` gas-ceiling simulate-then-decide guard — the
|
|
241
|
+
// exact guard `codexCronotonTickOnce`'s due-row branch and
|
|
242
|
+
// `executeNow`'s manual-trigger branch both now apply ahead of this
|
|
243
|
+
// same definition. A `try_single_tx_first=1` row's top-level fields
|
|
244
|
+
// are no longer inert placeholder data (docs/work/
|
|
245
|
+
// khronoton-single-tx-custom/design.md) — they are the operator's
|
|
246
|
+
// real single-tx Pact code, so firing them here on a repeating timer
|
|
247
|
+
// with no gas check is a genuinely new, unsafe bypass this topic's
|
|
248
|
+
// own change in field semantics introduces. Stop the batch rather
|
|
249
|
+
// than risk an unmineable (or unintended) repeated submission; the
|
|
250
|
+
// operator can re-trigger via `executeNow`, which DOES apply the
|
|
251
|
+
// guard. (Manual batches on an ORDINARY chained row — zero
|
|
252
|
+
// `try_single_tx_first` — already bypass the step machinery
|
|
253
|
+
// entirely; that is a separate, pre-existing gap this fix does not
|
|
254
|
+
// attempt to close.)
|
|
255
|
+
cancelManualBatch(batch.id, { db: ctx.db });
|
|
256
|
+
cancelledIds.push(batch.id);
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
221
259
|
const claimed = claimManualBatchFire(batch, now, { db: ctx.db });
|
|
222
260
|
if (!claimed) {
|
|
223
261
|
skippedIds.push(batch.id);
|
package/dist/server/types.d.ts
CHANGED
|
@@ -126,6 +126,20 @@ export interface FireResult {
|
|
|
126
126
|
readonly error?: string;
|
|
127
127
|
/** Computed one-time terminal intent; `null` for recurring. */
|
|
128
128
|
readonly terminalIntent: TerminalIntent | null;
|
|
129
|
+
/**
|
|
130
|
+
* `true` only for `resolvers.ts`'s own `postponed(...)` results — a
|
|
131
|
+
* server-resolver-routed fire that was NEVER submitted to chain at all
|
|
132
|
+
* (a dispatch error, an unknown/multi-tx-mismatched resolver name, a
|
|
133
|
+
* resolver-side safety-guard simulate failure, or its gas guard being
|
|
134
|
+
* tripped). Absent/`undefined` for every other `FireResult`, including a
|
|
135
|
+
* GENUINE on-chain fire failure — the two are otherwise structurally
|
|
136
|
+
* identical (`ok: false`, `terminalIntent: null` for a recurring row
|
|
137
|
+
* either way), which is exactly the ambiguity this field exists to
|
|
138
|
+
* resolve: a caller deciding whether "didn't fire" should fall back to
|
|
139
|
+
* an alternate path (as `single-tx.ts`'s `attemptSingleTxFirst` does)
|
|
140
|
+
* must be able to tell the two apart without parsing `error` text.
|
|
141
|
+
*/
|
|
142
|
+
readonly postponed?: boolean;
|
|
129
143
|
}
|
|
130
144
|
/**
|
|
131
145
|
* Result of a `submit` run. Builds, signs, pre-flights, and submits — never
|
|
@@ -203,6 +217,23 @@ export interface CodexCronotonRow {
|
|
|
203
217
|
* `SELECT *` carry the column.
|
|
204
218
|
*/
|
|
205
219
|
public_observable?: number;
|
|
220
|
+
/**
|
|
221
|
+
* When 1, a chained row attempts a single-transaction variant of its own
|
|
222
|
+
* work (via `pact_code`/`payload_json`/`config_json`/`gas_payer_json`/
|
|
223
|
+
* `signers_json`, reinterpreted) before falling through to the step-by-step
|
|
224
|
+
* chain. Optional so pre-existing hand-constructed row doubles (test
|
|
225
|
+
* fixtures across the package, predating this column) still typecheck;
|
|
226
|
+
* real rows from `SELECT *` carry the column (value is never actually
|
|
227
|
+
* undefined at runtime — `installSchema`'s `ensureColumn` backfills
|
|
228
|
+
* `NOT NULL DEFAULT 0` on every row).
|
|
229
|
+
*/
|
|
230
|
+
try_single_tx_first?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Meaningful only when `try_single_tx_first` is 1: how the single-tx Pact
|
|
233
|
+
* code was produced. `null`/absent when unset. Optional for the same
|
|
234
|
+
* pre-existing-fixture-compatibility reason as `try_single_tx_first`.
|
|
235
|
+
*/
|
|
236
|
+
single_tx_mode?: "custom" | "default" | null;
|
|
206
237
|
status: "active" | "paused" | "completed" | "error";
|
|
207
238
|
next_fire_at: string | null;
|
|
208
239
|
last_fire_at: string | null;
|
|
@@ -189,6 +189,23 @@ interface CodexCronotonRow {
|
|
|
189
189
|
* `SELECT *` carry the column.
|
|
190
190
|
*/
|
|
191
191
|
public_observable?: number;
|
|
192
|
+
/**
|
|
193
|
+
* When 1, a chained row attempts a single-transaction variant of its own
|
|
194
|
+
* work (via `pact_code`/`payload_json`/`config_json`/`gas_payer_json`/
|
|
195
|
+
* `signers_json`, reinterpreted) before falling through to the step-by-step
|
|
196
|
+
* chain. Optional so pre-existing hand-constructed row doubles (test
|
|
197
|
+
* fixtures across the package, predating this column) still typecheck;
|
|
198
|
+
* real rows from `SELECT *` carry the column (value is never actually
|
|
199
|
+
* undefined at runtime — `installSchema`'s `ensureColumn` backfills
|
|
200
|
+
* `NOT NULL DEFAULT 0` on every row).
|
|
201
|
+
*/
|
|
202
|
+
try_single_tx_first?: number;
|
|
203
|
+
/**
|
|
204
|
+
* Meaningful only when `try_single_tx_first` is 1: how the single-tx Pact
|
|
205
|
+
* code was produced. `null`/absent when unset. Optional for the same
|
|
206
|
+
* pre-existing-fixture-compatibility reason as `try_single_tx_first`.
|
|
207
|
+
*/
|
|
208
|
+
single_tx_mode?: "custom" | "default" | null;
|
|
192
209
|
status: "active" | "paused" | "completed" | "error";
|
|
193
210
|
next_fire_at: string | null;
|
|
194
211
|
last_fire_at: string | null;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-
|
|
2
|
+
import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-DH7Ym8FQ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The theming boundary. Every Khronoton UI surface renders inside a
|
package/dist/ui/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-
|
|
2
|
-
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-
|
|
1
|
+
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-VPVEIDNN.js';
|
|
2
|
+
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-24THBKR7.js';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { lazy, forwardRef, createElement, useState, useEffect, useCallback, useMemo, Suspense, useContext } from 'react';
|
|
5
5
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancientpantheon/khronoton-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Headless framework-agnostic scheduler engine: pure schedule math plus an injectable tick engine. No database, no job queue, no framework — hosts inject storage and firing via hooks.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|