@ancientpantheon/khronoton-core 0.5.0 → 0.6.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 +15 -0
- package/README.md +4 -0
- package/dist/{chunk-U3F5HEHO.js → chunk-FBQTTDOZ.js} +9 -4
- package/dist/{chunk-DK4CDPXH.js → chunk-ZVMHHW53.js} +1 -1
- package/dist/{context-BKtdrA2B.d.ts → context-D7LCfXdC.d.ts} +8 -0
- package/dist/handlers/cronoton.d.ts +1 -0
- package/dist/handlers/cronoton.js +3 -0
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +2 -2
- package/dist/provider/index.d.ts +2 -2
- package/dist/provider/index.js +5 -3
- package/dist/server/store/cronoton.d.ts +7 -0
- package/dist/server/store/cronoton.js +34 -11
- package/dist/ui/index.js +21 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ All notable changes to `@ancientpantheon/khronoton-core`.
|
|
|
4
4
|
|
|
5
5
|
The engine's pre-extraction history lives in the AncientHoldings hub, whose inline scheduler ("Cronoton") this package extracts and generalises.
|
|
6
6
|
|
|
7
|
+
## 0.6.0 — 2026-08-02
|
|
8
|
+
|
|
9
|
+
**MINOR — event-driven server resolvers (scheduler-off, host-fired).**
|
|
10
|
+
|
|
11
|
+
Some server-resolver cronotons are conceptually event-driven, not time-based (they fire when an external condition becomes ready, on no meaningful clock). Previously such a resolver had to masquerade as a scheduled cronoton that polls every tick, and the Builder misleadingly showed a schedule editor for it.
|
|
12
|
+
|
|
13
|
+
- **`ServerResolverOption` gains an optional `eventDriven?: boolean`.** A consumer tags a resolver option event-driven; selecting it in the Builder commits the cronoton **scheduler-off** (`next_fire_at = NULL`, so the tick loop never auto-fires it) and replaces the schedule editor with an honest "Event-driven — the host application fires this when its trigger condition is met; there is no schedule." notice, with the schedule summary reading "Event-driven (host-fired)".
|
|
14
|
+
- **The host fires such a cronoton via the existing `executeNow` primitive** — no new firing primitive, no change to `executeNow`. Event-driven is threaded as its own dedicated `eventDriven` flag on the commit envelope (NOT by reusing `externalFireable`, which would wrongly expose the public HMAC trigger endpoint) — an event-driven cronoton is fired in-process by the host, never over HMAC. No new DB column: `next_fire_at = NULL` already carries the scheduler-off state, and the edit/resume paths keep it NULL correctly.
|
|
15
|
+
- **`server_resolver` + event-driven is allowed** (the whole feature); `server_resolver` + `runtime_arg_keys` stays forbidden.
|
|
16
|
+
- Also fixed in the same pass: pausing then resuming an event-driven cronoton no longer resurrects a schedule (resume now recognizes a scheduler-off row by its `next_fire_at = NULL`); and the Builder's trigger-only notice no longer wrongly claims an externally-fireable-only cronoton "declares runtime arguments".
|
|
17
|
+
|
|
18
|
+
Ordinary scheduled resolver cronotons (e.g. `pyth-flush`) are unchanged — same schedule, same UI. A non-event-driven commit body is byte-identical to 0.5.0.
|
|
19
|
+
|
|
20
|
+
**848 specs pass.**
|
|
21
|
+
|
|
7
22
|
## 0.5.0 — 2026-08-02
|
|
8
23
|
|
|
9
24
|
**MINOR — Builder screen: syntax-highlighted Pact editor, top/bottom layout, live tx-size/gas meter.**
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Khronoton is the "When do I act?" Constructor of the Pantheon architecture — t
|
|
|
6
6
|
|
|
7
7
|
## Status
|
|
8
8
|
|
|
9
|
+
**`0.6.0` on public npmjs** — **MINOR.** Released 2026-08-02. Server resolvers can now declare themselves **event-driven** (`ServerResolverOption.eventDriven`): selecting one in the Builder commits the cronoton scheduler-off (`next_fire_at = NULL`, never auto-fired) and swaps the schedule editor for an event-driven notice — the host fires it in-process via the existing `executeNow` (not the HMAC endpoint). Ordinary scheduled resolvers are unchanged. **848 specs pass.**
|
|
10
|
+
|
|
9
11
|
**`0.5.0` on public npmjs** — **MINOR.** Released 2026-08-02. The Builder screen's Pact-code editor is now syntax-highlighted (via the package's `--khr-*` theme tokens, five new ones added), moved to a full-width top strip (~7 lines, internal scroll) with the header/tabs/tab content full-width below it, and gained a live tx-size/gas metering strip. `@uiw/react-codemirror` + the CodeMirror/Lezer packages it now depends on for highlighting are real optional `peerDependencies`. **832 specs pass.**
|
|
10
12
|
|
|
11
13
|
**`0.4.2` on public npmjs** — **PATCH.** Released 2026-07-22. Aligns the `peerDependenciesMeta` key with the `@ouronet/ouronet-core` peer renamed in 0.4.1 (the meta entry still named the old `@stoachain` peer). No code change. **799 specs pass.**
|
|
@@ -234,6 +236,8 @@ npm install @ancientpantheon/khronoton-core
|
|
|
234
236
|
|
|
235
237
|
## Version history
|
|
236
238
|
|
|
239
|
+
**v0.6.0** — Event-driven server resolvers. `ServerResolverOption` gains an optional `eventDriven` flag; a cronoton on an event-driven resolver commits scheduler-off (`next_fire_at = NULL`, excluded from the tick due-query) and the Builder shows an "Event-driven (host-fired)" notice instead of a schedule editor. The host fires it via the existing `executeNow` primitive, in-process — event-driven is a dedicated commit-envelope flag, deliberately NOT `externalFireable`, so it never exposes the public HMAC trigger endpoint. `server_resolver` + event-driven is allowed; `server_resolver` + `runtime_arg_keys` stays forbidden. No new DB column (the `next_fire_at = NULL` state carries it; edit and pause/resume keep it NULL). Ordinary scheduled resolvers unchanged; a non-event-driven commit body is byte-identical to 0.5.0. Released 2026-08-02. **848 specs pass.**
|
|
240
|
+
|
|
237
241
|
**v0.5.0** — Builder screen upgrade: the Pact-code editor is syntax-highlighted (keywords, definitions, types, strings, numbers, booleans, comments, `@doc`/`@model` annotations, parens/atoms — colored via new `--khr-syntax-*`/`--khr-selection` tokens, not hardcoded), moved to a full-width top strip (~7 lines, internal scroll) with the header/tab bar/tab content full-width below it as the one standard layout, and gained a live tx-size/gas metering strip (local byte estimate against StoaChain's 2 MB ceiling; gas-used-vs-limit once Simulate runs). `@uiw/react-codemirror`, `@codemirror/state`, `@codemirror/view`, `@codemirror/language`, `@lezer/highlight` are now real optional `peerDependencies` instead of silently relied upon via hoisting. Released 2026-08-02. **832 specs pass.**
|
|
238
242
|
|
|
239
243
|
**v0.4.2** — fix dangling `peerDependenciesMeta` key (was still `@stoachain/ouronet-core`). Released 2026-07-22. **799 specs pass.**
|
|
@@ -1067,7 +1067,7 @@ function commitCodexCronoton(input, opts) {
|
|
|
1067
1067
|
);
|
|
1068
1068
|
}
|
|
1069
1069
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
1070
|
-
const triggerOnly = input.externalFireable === true || runtimeArgKeys.length > 0;
|
|
1070
|
+
const triggerOnly = input.externalFireable === true || runtimeArgKeys.length > 0 || input.eventDriven === true;
|
|
1071
1071
|
const nextFireAt = triggerOnly ? null : computeNextOrReject(input.scheduleMode, input.scheduleConfig, now).toISOString();
|
|
1072
1072
|
const id = crypto2.randomUUID();
|
|
1073
1073
|
const nowIso = now.toISOString();
|
|
@@ -1192,7 +1192,12 @@ function editCodexCronoton(id, patch, opts) {
|
|
|
1192
1192
|
changedFields.push("schedule");
|
|
1193
1193
|
}
|
|
1194
1194
|
const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
|
|
1195
|
-
if (
|
|
1195
|
+
if (patch.eventDriven === true) {
|
|
1196
|
+
if (nextFireAt !== null && !changedFields.includes("schedule")) {
|
|
1197
|
+
changedFields.push("schedule");
|
|
1198
|
+
}
|
|
1199
|
+
nextFireAt = null;
|
|
1200
|
+
} else if (scheduleChanged && !rowTriggerOnly) {
|
|
1196
1201
|
const next = computeNextOrReject(
|
|
1197
1202
|
nextScheduleMode,
|
|
1198
1203
|
JSON.parse(nextScheduleConfigJson),
|
|
@@ -1248,8 +1253,8 @@ function resumeCodexCronoton(id, opts) {
|
|
|
1248
1253
|
if (!row) throw new CodexCronotonValidationError("not found");
|
|
1249
1254
|
assertNotTerminal(row);
|
|
1250
1255
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
1251
|
-
const
|
|
1252
|
-
const nextFireAt =
|
|
1256
|
+
const rowSchedulerOff = row.next_fire_at === null;
|
|
1257
|
+
const nextFireAt = rowSchedulerOff ? null : computeNextOrReject(
|
|
1253
1258
|
row.schedule_mode,
|
|
1254
1259
|
JSON.parse(row.schedule_config_json),
|
|
1255
1260
|
now
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-
|
|
1
|
+
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-FBQTTDOZ.js';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useCronotons(query) {
|
|
@@ -94,6 +94,7 @@ interface CommitEnvelope {
|
|
|
94
94
|
serverResolver?: string;
|
|
95
95
|
externalFireable?: boolean;
|
|
96
96
|
runtimeArgKeys?: string[];
|
|
97
|
+
eventDriven?: boolean;
|
|
97
98
|
}
|
|
98
99
|
/** The schedule half of a {@link CommitBody}: mode + its config. */
|
|
99
100
|
interface CommitSchedule {
|
|
@@ -315,6 +316,13 @@ interface ServerResolverOption {
|
|
|
315
316
|
label: string;
|
|
316
317
|
/** Optional gold side-note shown in the builder when this resolver is selected. */
|
|
317
318
|
note?: string;
|
|
319
|
+
/**
|
|
320
|
+
* When true, a cronoton using this resolver is EVENT-DRIVEN — the scheduler never
|
|
321
|
+
* auto-fires it (persisted scheduler-off); the host application fires it on its own
|
|
322
|
+
* trigger via `executeNow`. Selecting such a resolver in the Builder replaces the
|
|
323
|
+
* schedule UI with an event-driven notice. Omit/false = ordinary scheduled cronoton.
|
|
324
|
+
*/
|
|
325
|
+
eventDriven?: boolean;
|
|
318
326
|
}
|
|
319
327
|
/** A pluggable multi-tx breakdown renderer (the Hub's pool-payout is one impl). */
|
|
320
328
|
type RenderMultiTx = (fire: CodexCronotonFireRow) => ReactNode;
|
|
@@ -40,6 +40,7 @@ export interface CommitEnvelope {
|
|
|
40
40
|
serverResolver?: string;
|
|
41
41
|
externalFireable?: boolean;
|
|
42
42
|
runtimeArgKeys?: string[];
|
|
43
|
+
eventDriven?: boolean;
|
|
43
44
|
}
|
|
44
45
|
/** The schedule half of a {@link CommitBody}: mode + its config. */
|
|
45
46
|
export interface CommitSchedule {
|
|
@@ -60,6 +60,7 @@ function toCommitInput(body, createdBy) {
|
|
|
60
60
|
serverResolver: envelope.serverResolver,
|
|
61
61
|
externalFireable: envelope.externalFireable,
|
|
62
62
|
runtimeArgKeys: envelope.runtimeArgKeys,
|
|
63
|
+
eventDriven: envelope.eventDriven,
|
|
63
64
|
};
|
|
64
65
|
}
|
|
65
66
|
/** Adapt a `Partial<CommitBody>` into a store edit patch (apply-at-next-fire). */
|
|
@@ -85,6 +86,8 @@ function toEditPatch(body) {
|
|
|
85
86
|
patch.signers = e.signers;
|
|
86
87
|
if (e.serverResolver !== undefined)
|
|
87
88
|
patch.serverResolver = e.serverResolver;
|
|
89
|
+
if (e.eventDriven !== undefined)
|
|
90
|
+
patch.eventDriven = e.eventDriven;
|
|
88
91
|
}
|
|
89
92
|
const sched = b.schedule;
|
|
90
93
|
if (sched && typeof sched === "object") {
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as ListCronotonsQuery, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, R as RecoverView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, g as RuntimeArgs } from '../context-
|
|
2
|
-
export { U as UseKhronotonResult, u as useKhronoton } from '../context-
|
|
1
|
+
import { L as ListCronotonsQuery, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, R as RecoverView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, g as RuntimeArgs } from '../context-D7LCfXdC.js';
|
|
2
|
+
export { U as UseKhronotonResult, u as useKhronoton } from '../context-D7LCfXdC.js';
|
|
3
3
|
import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useSimulate, useStartBatch, useTrigger } from '../chunk-
|
|
2
|
-
export { useKhronoton } from '../chunk-
|
|
1
|
+
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useSimulate, useStartBatch, useTrigger } from '../chunk-ZVMHHW53.js';
|
|
2
|
+
export { useKhronoton } from '../chunk-FBQTTDOZ.js';
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { H as HandlerRequest, h as HandlerResponse, K as KhronotonProviderProps, i as KhronotonAdapter, j as SignerSource } from '../context-
|
|
3
|
-
export { c as CancelBatchView, k as CodexSignerDescriptor, C as CommitBody, a as CommitView, l as ConfirmGate, m as ConfirmOpts, n as DEFAULT_EXPLORER_BASE, o as DEFAULT_PAGE_SIZE, p as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, q as FiresView, G as GetBatchView, r as GetCronotonView, s as KhronotonConfig, t as KhronotonSnapshot, L as ListCronotonsQuery, v as ListCronotonsView, R as RecoverView, w as RenderMultiTx, g as RuntimeArgs, x as ServerResolverOption, y as SignersView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, T as ToggleView, U as UseKhronotonResult, z as assertAdapter, A as emptySnapshot, u as useKhronoton } from '../context-
|
|
2
|
+
import { H as HandlerRequest, h as HandlerResponse, K as KhronotonProviderProps, i as KhronotonAdapter, j as SignerSource } from '../context-D7LCfXdC.js';
|
|
3
|
+
export { c as CancelBatchView, k as CodexSignerDescriptor, C as CommitBody, a as CommitView, l as ConfirmGate, m as ConfirmOpts, n as DEFAULT_EXPLORER_BASE, o as DEFAULT_PAGE_SIZE, p as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, q as FiresView, G as GetBatchView, r as GetCronotonView, s as KhronotonConfig, t as KhronotonSnapshot, L as ListCronotonsQuery, v as ListCronotonsView, R as RecoverView, w as RenderMultiTx, g as RuntimeArgs, x as ServerResolverOption, y as SignersView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, T as ToggleView, U as UseKhronotonResult, z as assertAdapter, A as emptySnapshot, u as useKhronoton } from '../context-D7LCfXdC.js';
|
|
4
4
|
import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-BvPnTSmg.js';
|
|
5
5
|
export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
|
|
6
6
|
|
package/dist/provider/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-
|
|
2
|
-
export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-
|
|
1
|
+
import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-FBQTTDOZ.js';
|
|
2
|
+
export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-FBQTTDOZ.js';
|
|
3
3
|
import { useRef, useState, useEffect } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -266,7 +266,8 @@ function toCommitInput(body, createdBy) {
|
|
|
266
266
|
createdBy,
|
|
267
267
|
serverResolver: envelope.serverResolver,
|
|
268
268
|
externalFireable: envelope.externalFireable,
|
|
269
|
-
runtimeArgKeys: envelope.runtimeArgKeys
|
|
269
|
+
runtimeArgKeys: envelope.runtimeArgKeys,
|
|
270
|
+
eventDriven: envelope.eventDriven
|
|
270
271
|
};
|
|
271
272
|
}
|
|
272
273
|
function toEditPatch(body) {
|
|
@@ -283,6 +284,7 @@ function toEditPatch(body) {
|
|
|
283
284
|
if (e.gasPayer !== void 0) patch.gasPayer = e.gasPayer;
|
|
284
285
|
if (e.signers !== void 0) patch.signers = e.signers;
|
|
285
286
|
if (e.serverResolver !== void 0) patch.serverResolver = e.serverResolver;
|
|
287
|
+
if (e.eventDriven !== void 0) patch.eventDriven = e.eventDriven;
|
|
286
288
|
}
|
|
287
289
|
const sched = b.schedule;
|
|
288
290
|
if (sched && typeof sched === "object") {
|
|
@@ -19,6 +19,9 @@ export interface CommitCodexCronotonInput {
|
|
|
19
19
|
/** env-data keys supplied by a trigger at fire time (default none). Must be
|
|
20
20
|
* DISJOINT from the fixed payload keys — a runtime arg must never override a keyset. */
|
|
21
21
|
runtimeArgKeys?: string[];
|
|
22
|
+
/** When true, the row is host-fired on an event (via executeNow) rather than on a
|
|
23
|
+
* timer — a THIRD trigger-only reason: it commits scheduler-off (next_fire_at NULL). */
|
|
24
|
+
eventDriven?: boolean;
|
|
22
25
|
}
|
|
23
26
|
interface CommitOpts extends DbDep {
|
|
24
27
|
now?: Date;
|
|
@@ -53,6 +56,10 @@ export interface EditCodexCronotonPatch {
|
|
|
53
56
|
scheduleConfig?: ScheduleConfig;
|
|
54
57
|
/** Set/clear the fire-time server resolver. `null` clears it. */
|
|
55
58
|
serverResolver?: string | null;
|
|
59
|
+
/** When true, force the row scheduler-off (next_fire_at NULL) — an event-driven
|
|
60
|
+
* edit or a scheduled→event-driven conversion. There is no persisted column, so
|
|
61
|
+
* the edit path relies on this patch signal (the persisted row can't reveal it). */
|
|
62
|
+
eventDriven?: boolean;
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
58
65
|
* Apply-at-next-fire edit. Recomputes next_fire_at when the schedule changes,
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* Schedule math is imported, never reimplemented (REQ-16): {@link computeNextFire}
|
|
11
11
|
* runs at commit/edit/resume time through {@link computeNextOrReject}, which maps
|
|
12
12
|
* an {@link InvalidScheduleConfigError} to a typed {@link CodexCronotonValidationError}
|
|
13
|
-
* and treats a null next-fire as a "no future fires" reject. A
|
|
14
|
-
* (externally fireable OR declaring runtime args
|
|
15
|
-
*
|
|
13
|
+
* and treats a null next-fire as a "no future fires" reject. A SCHEDULER-OFF row
|
|
14
|
+
* (externally fireable, OR declaring runtime args, OR event-driven — a
|
|
15
|
+
* server-resolver the host fires via `executeNow`) carries NO schedule at all —
|
|
16
|
+
* its `next_fire_at` stays NULL and the schedule engine is never consulted for it.
|
|
16
17
|
*/
|
|
17
18
|
import crypto from "node:crypto";
|
|
18
19
|
import { computeNextFire, InvalidScheduleConfigError, } from "../../schedule.js";
|
|
@@ -65,11 +66,14 @@ export function commitCodexCronoton(input, opts) {
|
|
|
65
66
|
throw new CodexCronotonValidationError("server-resolver rows cannot declare runtime args");
|
|
66
67
|
}
|
|
67
68
|
const now = opts.now ?? new Date();
|
|
68
|
-
// A
|
|
69
|
-
//
|
|
69
|
+
// A SCHEDULER-OFF cronoton (externally fireable, OR declaring runtime args, OR
|
|
70
|
+
// event-driven — a server-resolver the host fires via `executeNow`) fires on
|
|
71
|
+
// demand, never on a timer — so it carries NO schedule: skip the next-fire
|
|
70
72
|
// computation and store next_fire_at = NULL. The scheduler's
|
|
71
73
|
// `next_fire_at IS NOT NULL` gate then skips it.
|
|
72
|
-
const triggerOnly = input.externalFireable === true ||
|
|
74
|
+
const triggerOnly = input.externalFireable === true ||
|
|
75
|
+
runtimeArgKeys.length > 0 ||
|
|
76
|
+
input.eventDriven === true;
|
|
73
77
|
const nextFireAt = triggerOnly
|
|
74
78
|
? null
|
|
75
79
|
: computeNextOrReject(input.scheduleMode, input.scheduleConfig, now).toISOString();
|
|
@@ -210,7 +214,19 @@ export function editCodexCronoton(id, patch, opts) {
|
|
|
210
214
|
// next_fire_at is NULL and the scheduler skips it) — never resurrect a next-fire
|
|
211
215
|
// for it, even if a schedule patch slips through. Keep next_fire_at as-is (NULL).
|
|
212
216
|
const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
|
|
213
|
-
|
|
217
|
+
// An event-driven edit forces the row scheduler-off (next_fire_at NULL). There is
|
|
218
|
+
// no persisted event_driven column, so `rowTriggerOnly` can't see it — this patch
|
|
219
|
+
// signal takes precedence and covers BOTH an event-driven→event-driven edit (keep
|
|
220
|
+
// NULL) and a scheduled→event-driven conversion (clear the row's stale non-null
|
|
221
|
+
// next_fire_at). Marking "schedule" ensures the UPDATE runs even when the clear is
|
|
222
|
+
// the only change (a pure conversion), so the early-out below doesn't skip the write.
|
|
223
|
+
if (patch.eventDriven === true) {
|
|
224
|
+
if (nextFireAt !== null && !changedFields.includes("schedule")) {
|
|
225
|
+
changedFields.push("schedule");
|
|
226
|
+
}
|
|
227
|
+
nextFireAt = null;
|
|
228
|
+
}
|
|
229
|
+
else if (scheduleChanged && !rowTriggerOnly) {
|
|
214
230
|
const next = computeNextOrReject(nextScheduleMode, JSON.parse(nextScheduleConfigJson), opts.now ?? new Date());
|
|
215
231
|
nextFireAt = next.toISOString();
|
|
216
232
|
}
|
|
@@ -248,10 +264,17 @@ export function resumeCodexCronoton(id, opts) {
|
|
|
248
264
|
throw new CodexCronotonValidationError("not found");
|
|
249
265
|
assertNotTerminal(row);
|
|
250
266
|
const now = opts.now ?? new Date();
|
|
251
|
-
// A
|
|
252
|
-
//
|
|
253
|
-
|
|
254
|
-
|
|
267
|
+
// A scheduler-off row has no schedule — resume it to 'active' but keep
|
|
268
|
+
// next_fire_at NULL so the scheduler still never picks it up. Every scheduler-off
|
|
269
|
+
// row (externally fireable, runtime-arg, OR event-driven — a server-resolver the
|
|
270
|
+
// host fires via executeNow) is committed with next_fire_at NULL, pause preserves
|
|
271
|
+
// it, and every genuinely-scheduled active row carries a NON-null next_fire_at —
|
|
272
|
+
// so the row's own current next_fire_at is the reliable, column-free marker here.
|
|
273
|
+
// (Event-driven persists no distinguishing column; this is what keeps resume from
|
|
274
|
+
// resurrecting a schedule for it. The edit path keys off the incoming patch signal
|
|
275
|
+
// instead, because an edit may be CONVERTING a row to or from a schedule.)
|
|
276
|
+
const rowSchedulerOff = row.next_fire_at === null;
|
|
277
|
+
const nextFireAt = rowSchedulerOff
|
|
255
278
|
? null
|
|
256
279
|
: computeNextOrReject(row.schedule_mode, JSON.parse(row.schedule_config_json), now).toISOString();
|
|
257
280
|
db.prepare(`UPDATE codex_cronotons SET status = 'active', next_fire_at = ?, modified_at = ? WHERE id = ?`).run(nextFireAt, now.toISOString(), id);
|
package/dist/ui/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-
|
|
2
|
-
import { useKhronotonAdapter, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-
|
|
1
|
+
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-ZVMHHW53.js';
|
|
2
|
+
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-FBQTTDOZ.js';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useContext } from 'react';
|
|
5
5
|
|
|
@@ -1453,7 +1453,7 @@ function toSigner(row) {
|
|
|
1453
1453
|
capabilities: row.capabilityMode === "scoped" ? row.capabilities : ""
|
|
1454
1454
|
};
|
|
1455
1455
|
}
|
|
1456
|
-
function builderToCommit(state) {
|
|
1456
|
+
function builderToCommit(state, opts) {
|
|
1457
1457
|
const config = {
|
|
1458
1458
|
chainId: state.config.chainId,
|
|
1459
1459
|
gasPrice: state.config.gasPriceAnu,
|
|
@@ -1476,6 +1476,7 @@ function builderToCommit(state) {
|
|
|
1476
1476
|
if (state.description.trim().length > 0) body.description = state.description;
|
|
1477
1477
|
if (state.serverResolver) body.envelope.serverResolver = state.serverResolver;
|
|
1478
1478
|
if (state.externalFireable) body.envelope.externalFireable = true;
|
|
1479
|
+
if (opts?.eventDriven) body.envelope.eventDriven = true;
|
|
1479
1480
|
if (runtimeArgKeys.length > 0) body.envelope.runtimeArgKeys = runtimeArgKeys;
|
|
1480
1481
|
return body;
|
|
1481
1482
|
}
|
|
@@ -3316,6 +3317,8 @@ var REASONS_STYLE = {
|
|
|
3316
3317
|
lineHeight: 1.6
|
|
3317
3318
|
};
|
|
3318
3319
|
var TRIGGER_ONLY_SCHEDULE = "Trigger-only (external / manual)";
|
|
3320
|
+
var EVENT_DRIVEN_SCHEDULE = "Event-driven (host-fired)";
|
|
3321
|
+
var EVENT_DRIVEN_NOTICE = "Event-driven \u2014 the host application fires this when its trigger condition is met; there is no schedule.";
|
|
3319
3322
|
function gasLine(state) {
|
|
3320
3323
|
const c = state.config;
|
|
3321
3324
|
const suffix = c.autoGasLimit ? " (AUTO)" : "";
|
|
@@ -3334,8 +3337,10 @@ function scopedCapLineCount(state) {
|
|
|
3334
3337
|
function signersLine(state) {
|
|
3335
3338
|
return `${effectiveSignerCount(state)} (${scopedCapLineCount(state)} caps)`;
|
|
3336
3339
|
}
|
|
3337
|
-
function scheduleLine3(state) {
|
|
3338
|
-
|
|
3340
|
+
function scheduleLine3(state, eventDrivenResolver) {
|
|
3341
|
+
if (eventDrivenResolver) return EVENT_DRIVEN_SCHEDULE;
|
|
3342
|
+
if (isTriggerOnly2(state) || state.externalFireable) return TRIGGER_ONLY_SCHEDULE;
|
|
3343
|
+
return summariseSchedule(state.schedule.mode, state.schedule.config);
|
|
3339
3344
|
}
|
|
3340
3345
|
function SummaryRow({
|
|
3341
3346
|
label,
|
|
@@ -3352,6 +3357,7 @@ function ExecuteTab({
|
|
|
3352
3357
|
onChange,
|
|
3353
3358
|
onCommit,
|
|
3354
3359
|
committing,
|
|
3360
|
+
eventDrivenResolver,
|
|
3355
3361
|
sim
|
|
3356
3362
|
}) {
|
|
3357
3363
|
const [banner, setBanner] = useState(null);
|
|
@@ -3362,6 +3368,7 @@ function ExecuteTab({
|
|
|
3362
3368
|
);
|
|
3363
3369
|
const gate = canCommit(state, { simulateCalibrated });
|
|
3364
3370
|
const triggerOnly = isTriggerOnly2(state);
|
|
3371
|
+
const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
|
|
3365
3372
|
const onSimulate = async () => {
|
|
3366
3373
|
const view = await sim.run(commit.envelope);
|
|
3367
3374
|
if (!view) {
|
|
@@ -3408,7 +3415,7 @@ function ExecuteTab({
|
|
|
3408
3415
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Payload keys", value: String(payloadKeyCount), testId: "summary-payload" }),
|
|
3409
3416
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Gas payer", value: gasPayerLabel(state.gasPayer), testId: "summary-gaspayer" }),
|
|
3410
3417
|
/* @__PURE__ */ jsx(SummaryRow, { label: "Signers", value: signersLine(state), testId: "summary-signers" }),
|
|
3411
|
-
/* @__PURE__ */ jsx(SummaryRow, { label: "Schedule", value: scheduleLine3(state), testId: "summary-schedule" })
|
|
3418
|
+
/* @__PURE__ */ jsx(SummaryRow, { label: "Schedule", value: scheduleLine3(state, eventDrivenResolver), testId: "summary-schedule" })
|
|
3412
3419
|
] }),
|
|
3413
3420
|
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
3414
3421
|
/* @__PURE__ */ jsx(
|
|
@@ -3423,7 +3430,7 @@ function ExecuteTab({
|
|
|
3423
3430
|
),
|
|
3424
3431
|
banner
|
|
3425
3432
|
] }),
|
|
3426
|
-
/* @__PURE__ */ jsx("div", { style: { marginBottom: "16px" }, children:
|
|
3433
|
+
/* @__PURE__ */ jsx("div", { style: { marginBottom: "16px" }, children: schedulerOff ? eventDrivenResolver ? /* @__PURE__ */ jsx("div", { style: TRIGGER_BOX_STYLE, children: EVENT_DRIVEN_NOTICE }) : /* @__PURE__ */ jsx("div", { style: TRIGGER_BOX_STYLE, children: "Trigger-only. This cronoton never runs on a timer \u2014 it fires only via the external trigger endpoint or a manual run." }) : /* @__PURE__ */ jsx(ScheduleStep, { state, onChange }) }),
|
|
3427
3434
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
3428
3435
|
/* @__PURE__ */ jsx(
|
|
3429
3436
|
"button",
|
|
@@ -3638,6 +3645,7 @@ function Builder({
|
|
|
3638
3645
|
robots = DEFAULT_BUILDER_ROBOTS
|
|
3639
3646
|
}) {
|
|
3640
3647
|
const adapter = useKhronotonAdapter();
|
|
3648
|
+
const config = useKhronotonConfig();
|
|
3641
3649
|
const actions = useCronotonActions(editId);
|
|
3642
3650
|
const sim = useSimulate();
|
|
3643
3651
|
const [state, setState] = useState(() => makeEmptyBuilderState());
|
|
@@ -3648,6 +3656,9 @@ function Builder({
|
|
|
3648
3656
|
const [loadedEditId, setLoadedEditId] = useState(void 0);
|
|
3649
3657
|
const isEdit = Boolean(editId);
|
|
3650
3658
|
const editReady = !editId || loadedEditId === editId;
|
|
3659
|
+
const eventDrivenResolver = Boolean(
|
|
3660
|
+
state.serverResolver && config.serverResolverOptions.find((o) => o.value === state.serverResolver)?.eventDriven
|
|
3661
|
+
);
|
|
3651
3662
|
useEffect(() => {
|
|
3652
3663
|
let active = true;
|
|
3653
3664
|
void (async () => {
|
|
@@ -3681,7 +3692,7 @@ function Builder({
|
|
|
3681
3692
|
const handleCommit = useCallback(async () => {
|
|
3682
3693
|
setCommitting(true);
|
|
3683
3694
|
try {
|
|
3684
|
-
const body = builderToCommit(state);
|
|
3695
|
+
const body = builderToCommit(state, { eventDriven: eventDrivenResolver });
|
|
3685
3696
|
if (isEdit && editId) {
|
|
3686
3697
|
const res = await actions.edit.run(body);
|
|
3687
3698
|
if (res.ok) onDone?.(editId);
|
|
@@ -3694,7 +3705,7 @@ function Builder({
|
|
|
3694
3705
|
} finally {
|
|
3695
3706
|
setCommitting(false);
|
|
3696
3707
|
}
|
|
3697
|
-
}, [state, isEdit, editId, actions, onDone]);
|
|
3708
|
+
}, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
|
|
3698
3709
|
const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
|
|
3699
3710
|
const handlePactCodeChange = useCallback((pactCode) => {
|
|
3700
3711
|
setState((s) => ({ ...s, pactCode }));
|
|
@@ -3746,6 +3757,7 @@ function Builder({
|
|
|
3746
3757
|
onChange: setState,
|
|
3747
3758
|
onCommit: handleCommit,
|
|
3748
3759
|
committing,
|
|
3760
|
+
eventDrivenResolver,
|
|
3749
3761
|
sim
|
|
3750
3762
|
}
|
|
3751
3763
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancientpantheon/khronoton-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|