@ancientpantheon/khronoton-core 0.9.0 → 0.10.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 CHANGED
@@ -4,6 +4,23 @@ 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.10.0 — 2026-09-08
8
+
9
+ **MINOR — the Builder's absolute "Gas Price (ANU)" field is gone; a cronoton now always pays the live network floor plus an optional priority buffer.**
10
+
11
+ 0.9.0 made the executor floor a *stored* absolute price against the live Yin Engine floor, so a fire could no longer underprice — but the Builder UI still framed gas price as something an operator *sets*, which is the wrong model for a recurring transaction: any absolute number typed today is guaranteed to go stale as the live floor keeps rising. This finishes the redesign: the UI shows a read-only, live-refreshing "Live Network Floor" display plus an editable "Priority Buffer (ANU above floor)" (default 0), and every fire prices as `liveFloor(creationTime) + buffer`, derived fresh at build time.
12
+
13
+ - **`CodexTxConfig.gasPriceBufferAnu`** (optional, additive) — ANU to pay above the live floor; absent (every pre-migration row) defaults to 0, so existing cronotons self-heal with no DB migration. `gasPrice` is kept, `@deprecated`, read-only, for parsing historical `config_json`.
14
+ - **`ChainRuntime.gasMeta(floorAnu, bufferAnu?)`** — the buffer is a new optional 2nd parameter, non-breaking. The adapter (`blockchain/stoachain.ts`) sums `floorAnu + bufferAnu` **in ANU**, inside the adapter, before the **one** `anuToStoaNumber` conversion — summing two independently-converted STOA floats instead produces a different serialized value in roughly 1 in 5 floor/buffer pairs, reintroducing exactly the precision bug 0.9.0 fixed. `buildTransaction` always calls `gasMeta(0, config.gasPriceBufferAnu ?? 0)` now — there is no more stored absolute value to raise to a floor.
15
+ - **A negative or non-finite buffer can never underprice a fire — enforced at three independent layers**, not just the UI: `ui/builder-state.ts`'s `validateConfig` blocks commit client-side; `server/store/cronoton.ts`'s `commitCodexCronoton`/`editCodexCronoton` reject a present-and-invalid `gasPriceBufferAnu` before any write (so a caller reaching the store directly, bypassing the Builder UI, can't persist a row that silently underprices every future fire); and `blockchain/stoachain.ts`'s `gasMeta` clamps a bad buffer to 0 as a third line of defense for any `CodexTxDefinition` built outside the store entirely.
16
+ - **New `useLiveGasFloor()` hook** (`ui/builder/live-gas-floor.ts`) polls the live floor every 30s plus a `visibilitychange`/`focus` refresh (browsers throttle `setInterval` in backgrounded tabs, and this screen is routinely left open for hours) — called once in `Builder.tsx`, threaded to `ConfigTab` and `ExecuteTab`.
17
+ - **Precision fix applied a second place**: `ui/tx-size.ts`'s size estimator now computes the same floor+buffer-summed-in-ANU-then-converted-once formula the executor uses, instead of the deprecated absolute `gasPrice`.
18
+ - **Not purely additive at the UI-type layer**: `BuilderConfig.gasPriceAnu` and `CommitGateOptions.minGasPriceAnu` are **removed**, not deprecated-in-place — both lose all meaning once there is no absolute price to floor-check, and keeping them would be actively misleading. `CodexTxConfig` itself stays additive.
19
+
20
+ Reviewed via nectar (3 rounds, 5 lenses each, adversarial validation): round 1 found and fixed a HIGH gap (a negative buffer could underprice below the live floor — server-side validation was entirely absent) plus 5 lower-severity gaps in the fix's own test coverage and a minor UI re-render inefficiency; round 2 re-verified round 1's fixes and found 3 more small issues (a misleading UI label for a transient invalid state, duplicated validation logic, a test-loop robustness nit) plus 2 STYLISTIC items the validator concluded were actually already-consistent with each file's own convention; round 3 caught one last barrel-export asymmetry. All CONFIRMED findings fixed; full history in `docs/work/gas-price-buffer/review.md`.
21
+
22
+ **938 specs pass**, plus 5 real-runtime integration specs against the installed `@stoachain/*@4.4.0`. Behavioral verification against the real compiled package + a real SQLite DB confirms: a pre-migration row self-heals to buffer 0; a negative buffer is rejected at commit AND edit time with the row genuinely left unwritten/unchanged, not just "throws".
23
+
7
24
  ## 0.9.0 — 2026-09-07
8
25
 
9
26
  **MINOR — scheduled transactions are priced against the chain's LIVE gas floor at fire time, not a static value stored at creation time.**
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.10.0` on public npmjs** — **MINOR.** Released 2026-09-08. The Builder's absolute "Gas Price (ANU)" field is gone: the UI now shows a read-only, live-refreshing "Live Network Floor" plus an editable "Priority Buffer (ANU above floor)" (default 0), and every fire prices as `liveFloor(creationTime) + buffer`. New optional `CodexTxConfig.gasPriceBufferAnu` (absent/pre-migration rows default to 0, self-healing with no DB migration); `gasPrice` stays, `@deprecated`, for reading historical rows. `ChainRuntime.gasMeta` gains an optional 2nd `bufferAnu` param (non-breaking) — the adapter sums floor+buffer **in ANU** before the one conversion, not two summed STOA floats. A negative/non-finite buffer can never underprice a fire — enforced at three layers: client `validateConfig`, the store's `commitCodexCronoton`/`editCodexCronoton` (reject before any write), and the seam's own defensive clamp. New `useLiveGasFloor()` hook polls every 30s plus visibilitychange/focus. `BuilderConfig.gasPriceAnu` and `CommitGateOptions.minGasPriceAnu` are **removed** (not deprecated-in-place) — both lost all meaning once there's no absolute price to floor-check. **938 specs pass** (+5 real-runtime integration specs).
10
+
9
11
  **`0.9.0` on public npmjs** — **MINOR.** Released 2026-09-07. Scheduled transactions are now priced against the chain's **live** gas floor at fire time instead of a static value stored at creation time. A cronoton's `gasPrice` was persisted once at creation and read back verbatim on every tick, so as chainweb's post-fork Yin Engine floor rises, a long-lived cronoton silently drifts below it and its fire is rejected — with nobody watching a 3am tick. (Live, not theoretical: at release the floor was **11,569 ANU** against a stored default of **10,000**.) Adds an **optional** `ChainRuntime.gasMeta(floorAnu)` seam returning `{ creationTime, gasPrice }` from one clock read; the stored price becomes a **floor an operator can raise, never a cap**, so existing rows **self-heal with no migration**. `creationTime` is now stamped explicitly from the same call that produced the price (it was previously auto-stamped by the Pact builder from a second, independent clock read), and the AUTO-gas rebuild re-derives both fresh. Transaction meta uses the precision-safe `anuToStoaNumber` rather than float division. A StoaChain fire on a runtime lacking `gasMeta` **fails loudly** rather than silently reusing the stale price. Requires a coordinated bump of `@stoachain/stoa-core@^4.4.0`, `@stoachain/kadena-stoic-legacy@^4.4.0`, `@ouronet/ouronet-core@^4.6.0`. **907 specs pass** (+5 real-runtime integration specs).
10
12
 
11
13
  **`0.8.0` on public npmjs** — **MINOR.** Released 2026-08-03. Finalizes the evented-resolver UI. **(1)** The cronoton **DETAIL** card's "Schedule" field now reads **"Evented"** for a trigger-only/evented row (it previously showed the stored schedule like "Daily at 12:00 UTC" while Next Fire already read "—"); the list and detail now share one `isTriggerOnly(row)` predicate (`external_fireable === 1 || runtime-arg keys`) so they can't drift. **(2)** A system (`server_resolver`) cronoton is now **deletable behind a confirm-gated warning** instead of a hard 409: `DELETE /[id]?force=1` permits the delete (the 409 still stands without force), threaded via `ConfirmOpts.force` + both reference adapters + the widened `remove.run({ force })`; the bundled Builder's Delete button is enabled for an admin on a system row and shows a warning naming the resolver before deleting, with the audit recording `forced: true`. Ordinary scheduled cronotons and non-forced deletes are unchanged. **893 specs pass.**
@@ -244,6 +246,8 @@ npm install @ancientpantheon/khronoton-core
244
246
 
245
247
  ## Version history
246
248
 
249
+ **v0.10.0** — Locked live-floor gas + priority buffer. 0.9.0 made the executor floor a *stored* absolute price against the live Yin Engine floor so a fire could no longer underprice, but the Builder UI still framed gas price as something an operator *sets* — the wrong model for a recurring transaction, since any absolute number typed today is guaranteed to go stale as the live floor keeps rising every ~3h. This finishes the redesign: the UI shows a read-only, live-refreshing "Live Network Floor" display plus an editable "Priority Buffer (ANU above floor)" (default 0), and every fire prices as `liveFloor(creationTime) + buffer`, derived fresh at build time — never a cached/stored absolute value. **Schema.** `CodexTxConfig` gains optional `gasPriceBufferAnu`; `gasPrice` stays, `@deprecated`, read-only, so historical `config_json` still parses — absence (every pre-migration row) defaults to 0, self-healing with no DB migration. **Seam.** `ChainRuntime.gasMeta(floorAnu, bufferAnu?)` — the buffer is a new optional 2nd parameter (non-breaking: TypeScript accepts a shorter existing implementation as satisfying the widened optional signature). The adapter (`blockchain/stoachain.ts`) sums `floorAnu + bufferAnu` **in ANU**, inside the adapter, before the **one** `anuToStoaNumber` conversion at the end — summing two independently-converted STOA floats instead produces a different serialized value in roughly 1 in 5 floor/buffer pairs, reintroducing the exact precision bug 0.9.0 fixed. `buildTransaction` always calls `gasMeta(0, config.gasPriceBufferAnu ?? 0)` now — there is no more stored absolute value to raise to a floor, so the seam's first argument is always 0. **Defense in depth.** A negative or non-finite buffer can never underprice a fire, enforced at three independent layers: `ui/builder-state.ts`'s `validateConfig` blocks commit client-side; `server/store/cronoton.ts`'s `commitCodexCronoton`/`editCodexCronoton` reject a present-and-invalid `gasPriceBufferAnu` before any write, so a caller reaching the store directly (bypassing the Builder UI) can't persist a row that silently underprices every future fire; and `blockchain/stoachain.ts`'s `gasMeta` clamps a bad buffer to 0 as a third line of defense for any `CodexTxDefinition` built outside the store entirely. **Live display.** New `useLiveGasFloor()` hook (`ui/builder/live-gas-floor.ts`) polls the live floor every 30s plus a `visibilitychange`/`focus` refresh — browsers throttle `setInterval` in backgrounded tabs, and this Builder screen is routinely left open for hours — called once in `Builder.tsx`, threaded to `ConfigTab` and `ExecuteTab`. **Precision fix applied a second place.** `ui/tx-size.ts`'s size estimator now uses the same floor+buffer-summed-in-ANU-then-converted-once formula the executor uses, instead of the deprecated absolute `gasPrice`. **Breaking at the UI-type layer.** `BuilderConfig.gasPriceAnu` and `CommitGateOptions.minGasPriceAnu` are **removed**, not deprecated-in-place — both lose all meaning once there is no absolute price to floor-check against, and keeping them would be actively misleading; `CodexTxConfig` itself stays additive. Reviewed via nectar across 3 rounds (5 lenses each, adversarial validation): round 1 found and fixed a HIGH gap (server-side validation of the buffer was entirely absent) plus 5 lower-severity test-coverage/UI gaps; round 2 re-verified those fixes and caught 3 more small issues (a misleading UI label, duplicated validation logic, a test-loop robustness nit); round 3 caught one last barrel-export asymmetry — all fixed, full history in `docs/work/gas-price-buffer/review.md`. Released 2026-09-08. **938 specs pass** (+5 real-runtime integration specs).
250
+
247
251
  **v0.9.0** — Live gas floor at fire time. `buildTransaction` priced every fire off `definition.config.gasPrice`, a plain ANU number persisted in `codex_cronotons` at creation time and read back verbatim on every tick (`server/tick.ts`, `server/store/mappers.ts`) — never re-derived. Post-fork, chainweb-node validates a signed transaction's price against the rising Yin Engine floor **as of that transaction's own `creationTime`**, so a cronoton created at the builder's 10,000 ANU default is already underpriced and drifts further as it ages; because this is unattended automation, the rejection surfaces at 3am with nobody watching. **The seam.** `ChainRuntime` gains an **optional** `gasMeta(floorAnu): { creationTime, gasPrice }`. Optional keeps the package chain-POLYGLOT and `@stoachain/*` an optional peer dependency — a chain without a rising floor omits it — but the executor **hard throws** when a StoaChain fire finds it missing, because a silent fallback to the stored value would ship the original bug to anyone who did not notice they must upgrade their adapter. In `fire` mode that throw is caught by the existing F-002 wrapper and returned as a structured `{ ok: false, error }`, so a one-time entry still records its spent attempt instead of re-firing forever. **Floor, not cap.** The implementation returns `max(storedAnu, minGasPriceAnu(creationTime))`, so an operator may still price above the minimum and existing stored rows self-heal with **no database migration**. **One clock read.** `setMeta` previously omitted `creationTime` entirely, letting the Pact builder auto-stamp its own at `createTransaction()` — an independent second read the price no longer corresponded to. Both fields now come from a single `stoaGasMeta()`-derived call, and the AUTO-gas calibrated rebuild+re-sign re-enters the seam rather than reusing the pre-flight values, so the two builds cannot straddle a 3-hour tick boundary and underprice the transaction that actually ships (pinned by a regression spec that fails if the call is hoisted out of `buildTransaction`). **Precision.** Transaction meta now converts via `anuToStoaNumber` (exact padded-decimal) instead of `anuToStoa` (float division), which upstream documents as unsafe for a value chainweb hashes and validates exactly; the same fix lands in `ui/tx-size.ts`'s fee meter, whose purpose is predicting the real signed transaction's byte size. **Builder gate.** `validateConfig` accepts `CommitGateOptions.minGasPriceAnu` in place of a hardcoded `>= 10000` check that accepted already-underpriced values, and names the applied floor in its message; omitting it falls back to the genesis floor, under-rejecting rather than over-rejecting since the executor raises the price at fire time regardless. **Boundary.** `blockchain/stoachain.ts` is the only module that knows the Yin Engine exists, wrapping `@stoachain/stoa-core/gas` rather than reimplementing a formula already independently reimplemented four times across the ecosystem; `/server` stays free of any `@stoachain/*` import. Requires a coordinated dependency bump — stoa-core 4.4.0 peer-pins kadena-stoic-legacy 4.4.0 exactly, and only ouronet-core 4.6.0 accepts stoa-core 4.4.0, so the three move together. All new surface (`StoaGasMeta`, `ChainRuntime.gasMeta`, `CommitGateOptions.minGasPriceAnu`) is additive. Released 2026-09-07. **907 specs pass** (+5 real-runtime integration specs).
248
252
 
249
253
  **v0.8.0** — Finalizes the evented-resolver UI (the last two gaps after 0.7.0). **Fix 1 — DETAIL "Schedule" reads "Evented".** The read-only cronoton detail card rendered the stored `schedule_config` (e.g. "Daily at 12:00 UTC") for a trigger-only/evented row even though Next Fire already showed "—" and the edit form already disabled the scheduler; root cause was `Detail.tsx` deriving `triggerOnly` from runtime-arg keys only, ignoring `external_fireable`. The list's predicate is extracted to a shared `isTriggerOnly(row)` (`row.external_fireable === 1 || parseRuntimeArgKeys(row.runtime_arg_keys).length > 0`) in `ui/row-derive.ts`, used by both the list next-fire cell and the detail Schedule cell so they can't drift; the detail Schedule cell now reads **"Evented"** for a trigger-only row. **Fix 2 — confirm-gated system delete.** `DELETE /[id]` hard-refused any `server_resolver` ("system") cronoton with `409 { protected: true }`; it now accepts `?force=1` (still behind the admin confirm gate) to permit the delete, while the 409 stands without force. Threaded end-to-end: `ConfirmOpts.force` → `createFetchAdapter` sends `?force=1` / `createMemoryAdapter` passes `query: { force: "1" }` → the widened `DeleteAction`/`remove.run({ force })` action hook. In the bundled Builder, `deleteDisabled` now **enables** the Delete button for an admin on a system cronoton (non-admins still blocked), and both the detail and list `handleDelete` show a `deleteSystemConfirm` warning naming the resolver — *"This is the automaton's `<name>` template. Deleting it stops that capability until it's recreated. Delete anyway?"* — as the first prompt, keeping the existing in-gate password confirm. The delete audit is preserved and records `forced: true` for a forced system delete. Ordinary scheduled cronotons, non-system deletes, and `delete(id)`/`remove.run()` without force are byte-identical to 0.7.0; a system delete without force still 409s. All new surface (`ConfirmOpts.force`, `DeleteRunOpts`, `deleteSystemConfirm`, `row-derive`'s `isTriggerOnly`) is additive. Released 2026-08-03. **893 specs pass.**
@@ -1,4 +1,4 @@
1
- import { C as ChainRuntime } from '../seams-CPj31tJJ.js';
1
+ import { C as ChainRuntime } from '../seams-BL_ntGK_.js';
2
2
 
3
3
  /**
4
4
  * `@ancientpantheon/khronoton-core/blockchain/stoachain` — the StoaChain edge.
@@ -17,9 +17,10 @@ async function createStoachainRuntime(config) {
17
17
  universalSignTransaction: signing.universalSignTransaction,
18
18
  calculateAutoGasLimit: gas.calculateAutoGasLimit,
19
19
  anuToStoa: gas.anuToStoa,
20
- gasMeta: (floorAnu) => {
20
+ gasMeta: (floorAnu, bufferAnu = 0) => {
21
21
  const { creationTime } = gas.stoaGasMeta();
22
- const anu = Math.max(floorAnu, gas.minGasPriceAnu(creationTime));
22
+ const safeBufferAnu = Number.isFinite(bufferAnu) && bufferAnu > 0 ? bufferAnu : 0;
23
+ const anu = Math.max(floorAnu, gas.minGasPriceAnu(creationTime)) + safeBufferAnu;
23
24
  return { creationTime, gasPrice: gas.anuToStoaNumber(anu) };
24
25
  },
25
26
  getPactUrl,
@@ -231,7 +231,10 @@ function buildTransaction(runtime, definition, signers, gasLimitOverride) {
231
231
  "ChainRuntime.gasMeta is required to price a transaction: without it the per-cronoton stored gasPrice would be used verbatim, which drifts below the chain's rising minimum as a cronoton ages and gets the fire rejected. Upgrade the injected runtime adapter (see blockchain/stoachain.ts)."
232
232
  );
233
233
  }
234
- const { creationTime, gasPrice } = runtime.gasMeta(definition.config.gasPrice);
234
+ const { creationTime, gasPrice } = runtime.gasMeta(
235
+ 0,
236
+ definition.config.gasPriceBufferAnu ?? 0
237
+ );
235
238
  builder.setMeta({
236
239
  senderAccount,
237
240
  chainId: definition.config.chainId,
@@ -519,6 +522,14 @@ function assertAutoGasGate(config) {
519
522
  throw new AutoGasGateError();
520
523
  }
521
524
  }
525
+ function assertGasPriceBufferAnu(config) {
526
+ if (config.gasPriceBufferAnu == null) return;
527
+ if (!Number.isFinite(config.gasPriceBufferAnu) || config.gasPriceBufferAnu < 0) {
528
+ throw new CodexCronotonValidationError(
529
+ "config.gasPriceBufferAnu must be a non-negative finite number"
530
+ );
531
+ }
532
+ }
522
533
  function manualBatchView(row) {
523
534
  return {
524
535
  id: row.id,
@@ -1174,6 +1185,7 @@ function commitCodexCronoton(input, opts) {
1174
1185
  if (!input.config || typeof input.config.chainId !== "string") {
1175
1186
  throw new CodexCronotonValidationError("config.chainId must be a string");
1176
1187
  }
1188
+ assertGasPriceBufferAnu(input.config);
1177
1189
  if (!Array.isArray(input.signers)) {
1178
1190
  throw new CodexCronotonValidationError("signers must be an array");
1179
1191
  }
@@ -1289,6 +1301,7 @@ function editCodexCronoton(id, patch, opts) {
1289
1301
  changedFields.push("pactCode");
1290
1302
  }
1291
1303
  if (patch.config) {
1304
+ assertGasPriceBufferAnu(patch.config);
1292
1305
  assertAutoGasGate(patch.config);
1293
1306
  nextConfigJson = JSON.stringify(patch.config);
1294
1307
  changedFields.push("config");
@@ -1,4 +1,4 @@
1
- import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-5LYT7ZLA.js';
1
+ import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-KDCNWWWQ.js';
2
2
  import { useState, useRef, useEffect, useCallback } from 'react';
3
3
 
4
4
  function useCronotons(query) {
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { b as CodexTxConfig, c as CodexGasPayer, d as CodexSigner, S as ScheduleMode, e as ScheduleConfig, C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from './types-u_nUX1Bg.js';
3
- import { b as DbDep, D as Database } from './seams-CPj31tJJ.js';
2
+ import { b as CodexTxConfig, c as CodexGasPayer, d as CodexSigner, S as ScheduleMode, e as ScheduleConfig, C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from './types-DnFB1Yz-.js';
3
+ import { b as DbDep, D as Database } from './seams-BL_ntGK_.js';
4
4
 
5
5
  /** A validated bag of runtime args — every value is a string (Pact `read-string`). */
6
6
  type RuntimeArgs = Record<string, string>;
@@ -1,8 +1,8 @@
1
- import { L as ListCronotonsQuery, R as ResolversView, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, e as RecoverView, S as SimulateEnvelope, f as SimulateView, g as StartBatchView, h as RuntimeArgs } from '../context-Cv3H82B5.js';
2
- export { U as UseKhronotonResult, u as useKhronoton } from '../context-Cv3H82B5.js';
3
- import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
1
+ import { L as ListCronotonsQuery, R as ResolversView, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, e as RecoverView, S as SimulateEnvelope, f as SimulateView, g as StartBatchView, h as RuntimeArgs } from '../context-CMk8bLsF.js';
2
+ export { U as UseKhronotonResult, u as useKhronoton } from '../context-CMk8bLsF.js';
3
+ import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-DnFB1Yz-.js';
4
4
  import 'react';
5
- import '../seams-CPj31tJJ.js';
5
+ import '../seams-BL_ntGK_.js';
6
6
 
7
7
  /** The `useCronotons()` return shape — the list, its load state, and a refetch. */
8
8
  interface UseCronotonsView {
@@ -1,2 +1,2 @@
1
- export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useServerResolvers, useSimulate, useStartBatch, useTrigger } from '../chunk-5OB5NQ4S.js';
2
- export { useKhronoton } from '../chunk-5LYT7ZLA.js';
1
+ export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useServerResolvers, useSimulate, useStartBatch, useTrigger } from '../chunk-UP3SYP2U.js';
2
+ export { useKhronoton } from '../chunk-KDCNWWWQ.js';
@@ -1,8 +1,8 @@
1
1
  import { ReactNode } from 'react';
2
- import { H as HandlerRequest, i as HandlerResponse, K as KhronotonProviderProps, j as KhronotonAdapter, k as SignerSource } from '../context-Cv3H82B5.js';
3
- export { c as CancelBatchView, l as CodexSignerDescriptor, C as CommitBody, a as CommitView, m as ConfirmGate, n as ConfirmOpts, o as DEFAULT_EXPLORER_BASE, p as DEFAULT_PAGE_SIZE, q as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, r as FiresView, G as GetBatchView, s as GetCronotonView, t as KhronotonConfig, v as KhronotonSnapshot, L as ListCronotonsQuery, w as ListCronotonsView, e as RecoverView, x as RenderMultiTx, h as RuntimeArgs, y as ServerResolverOption, z as SignersView, S as SimulateEnvelope, f as SimulateView, g as StartBatchView, T as ToggleView, U as UseKhronotonResult, A as assertAdapter, B as emptySnapshot, u as useKhronoton } from '../context-Cv3H82B5.js';
4
- import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-CPj31tJJ.js';
5
- export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
2
+ import { H as HandlerRequest, i as HandlerResponse, K as KhronotonProviderProps, j as KhronotonAdapter, k as SignerSource } from '../context-CMk8bLsF.js';
3
+ export { c as CancelBatchView, l as CodexSignerDescriptor, C as CommitBody, a as CommitView, m as ConfirmGate, n as ConfirmOpts, o as DEFAULT_EXPLORER_BASE, p as DEFAULT_PAGE_SIZE, q as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, r as FiresView, G as GetBatchView, s as GetCronotonView, t as KhronotonConfig, v as KhronotonSnapshot, L as ListCronotonsQuery, w as ListCronotonsView, e as RecoverView, x as RenderMultiTx, h as RuntimeArgs, y as ServerResolverOption, z as SignersView, S as SimulateEnvelope, f as SimulateView, g as StartBatchView, T as ToggleView, U as UseKhronotonResult, A as assertAdapter, B as emptySnapshot, u as useKhronoton } from '../context-CMk8bLsF.js';
4
+ import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-BL_ntGK_.js';
5
+ export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-DnFB1Yz-.js';
6
6
 
7
7
  /**
8
8
  * The per-request handler context + the injectable auth/confirm seam + the two
@@ -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, listServerResolvers, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-5LYT7ZLA.js';
2
- export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-5LYT7ZLA.js';
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, listServerResolvers, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-KDCNWWWQ.js';
2
+ export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-KDCNWWWQ.js';
3
3
  import { useRef, useState, useEffect } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
@@ -144,6 +144,14 @@ interface StoaGasMeta {
144
144
  * transaction below it. Implementations return
145
145
  * `max(floorAnu, liveFloor(creationTime))`, converted to chain units.
146
146
  * See `blockchain/stoachain.ts` for the StoaChain implementation.
147
+ *
148
+ * `bufferAnu` (default 0) is added to `floorAnu` **in ANU**, before the
149
+ * implementation's one `anuToStoaNumber` conversion — summing two
150
+ * independently-converted STOA numbers instead produces a different
151
+ * serialized value in roughly 1 in 5 floor/buffer pairs (verified:
152
+ * `anuToStoaNumber(11569) + anuToStoaNumber(500)` !== `anuToStoaNumber(12069)`
153
+ * as JSON strings), which is exactly the class of bug `anuToStoaNumber`
154
+ * exists to prevent.
147
155
  */
148
156
  interface ChainRuntime {
149
157
  Pact: {
@@ -156,7 +164,7 @@ interface ChainRuntime {
156
164
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
157
165
  calculateAutoGasLimit(gas: number): number;
158
166
  anuToStoa(anu: number): number;
159
- gasMeta?(floorAnu: number): StoaGasMeta;
167
+ gasMeta?(floorAnu: number, bufferAnu?: number): StoaGasMeta;
160
168
  getPactUrl(chainId: string): string;
161
169
  networkId: string;
162
170
  namespace: string;
@@ -29,10 +29,12 @@ export { LISTEN_TIMEOUT_MS } from "./seams.js";
29
29
  * the payload + pure-vs-scoped `addSigner`. Throws if no signers, and throws if
30
30
  * the injected runtime cannot supply gas meta (see {@link ChainRuntime.gasMeta}).
31
31
  *
32
- * The per-cronoton `config.gasPrice` is a FLOOR, not a final price: it is passed
33
- * to the runtime's `gasMeta`, which raises it to the chain's live minimum when
34
- * the stored value has gone stale. This is what lets a cronoton stored years ago
35
- * at the genesis default still fire today with no database migration.
32
+ * Every fire prices at the chain's live network floor plus
33
+ * `config.gasPriceBufferAnu` (default 0, ANU above the floor). `floorAnu` is
34
+ * always passed as `0` — there is no more stored absolute value to raise to a
35
+ * floor; the deprecated `config.gasPrice` is never read here at all. This is
36
+ * what lets a cronoton stored years ago at the genesis default still fire
37
+ * today with no database migration.
36
38
  */
37
39
  function buildTransaction(runtime, definition, signers, gasLimitOverride) {
38
40
  if (signers.length === 0) {
@@ -52,7 +54,7 @@ function buildTransaction(runtime, definition, signers, gasLimitOverride) {
52
54
  "the chain's rising minimum as a cronoton ages and gets the fire rejected. " +
53
55
  "Upgrade the injected runtime adapter (see blockchain/stoachain.ts).");
54
56
  }
55
- const { creationTime, gasPrice } = runtime.gasMeta(definition.config.gasPrice);
57
+ const { creationTime, gasPrice } = runtime.gasMeta(0, definition.config.gasPriceBufferAnu ?? 0);
56
58
  builder
57
59
  .setMeta({
58
60
  senderAccount,
@@ -144,6 +144,14 @@ export interface StoaGasMeta {
144
144
  * transaction below it. Implementations return
145
145
  * `max(floorAnu, liveFloor(creationTime))`, converted to chain units.
146
146
  * See `blockchain/stoachain.ts` for the StoaChain implementation.
147
+ *
148
+ * `bufferAnu` (default 0) is added to `floorAnu` **in ANU**, before the
149
+ * implementation's one `anuToStoaNumber` conversion — summing two
150
+ * independently-converted STOA numbers instead produces a different
151
+ * serialized value in roughly 1 in 5 floor/buffer pairs (verified:
152
+ * `anuToStoaNumber(11569) + anuToStoaNumber(500)` !== `anuToStoaNumber(12069)`
153
+ * as JSON strings), which is exactly the class of bug `anuToStoaNumber`
154
+ * exists to prevent.
147
155
  */
148
156
  export interface ChainRuntime {
149
157
  Pact: {
@@ -156,7 +164,7 @@ export interface ChainRuntime {
156
164
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
157
165
  calculateAutoGasLimit(gas: number): number;
158
166
  anuToStoa(anu: number): number;
159
- gasMeta?(floorAnu: number): StoaGasMeta;
167
+ gasMeta?(floorAnu: number, bufferAnu?: number): StoaGasMeta;
160
168
  getPactUrl(chainId: string): string;
161
169
  networkId: string;
162
170
  namespace: string;
@@ -20,7 +20,7 @@ import { computeNextFire, InvalidScheduleConfigError, } from "../../schedule.js"
20
20
  import { runtimeArgKeysCollide } from "../pure/runtime-args.js";
21
21
  import { getServerResolver } from "../resolvers.js";
22
22
  import { CodexCronotonValidationError, TerminalCronotonError } from "./errors.js";
23
- import { assertAutoGasGate, rowExternalFireable, rowRuntimeArgKeys, } from "./mappers.js";
23
+ import { assertAutoGasGate, assertGasPriceBufferAnu, rowExternalFireable, rowRuntimeArgKeys, } from "./mappers.js";
24
24
  /** Compute the first next-fire, mapping engine errors to a typed reject. */
25
25
  function computeNextOrReject(mode, config, now) {
26
26
  let next;
@@ -48,6 +48,10 @@ export function commitCodexCronoton(input, opts) {
48
48
  if (!input.config || typeof input.config.chainId !== "string") {
49
49
  throw new CodexCronotonValidationError("config.chainId must be a string");
50
50
  }
51
+ // See `assertGasPriceBufferAnu`'s doc: rejected here, not just in the
52
+ // Builder UI's `validateConfig`, so a caller reaching this store directly
53
+ // can't persist a row that silently underprices every future fire.
54
+ assertGasPriceBufferAnu(input.config);
51
55
  if (!Array.isArray(input.signers)) {
52
56
  throw new CodexCronotonValidationError("signers must be an array");
53
57
  }
@@ -188,6 +192,7 @@ export function editCodexCronoton(id, patch, opts) {
188
192
  changedFields.push("pactCode");
189
193
  }
190
194
  if (patch.config) {
195
+ assertGasPriceBufferAnu(patch.config);
191
196
  assertAutoGasGate(patch.config);
192
197
  nextConfigJson = JSON.stringify(patch.config);
193
198
  changedFields.push("config");
@@ -15,7 +15,7 @@
15
15
  * public source for those constants.
16
16
  */
17
17
  export { CodexCronotonValidationError, AutoGasGateError, TerminalCronotonError, ManualBatchActiveError, } from "./errors.js";
18
- export { rowToDefinition, rowExternalFireable, rowRuntimeArgKeys, assertAutoGasGate, manualBatchView, } from "./mappers.js";
18
+ export { rowToDefinition, rowExternalFireable, rowRuntimeArgKeys, assertAutoGasGate, assertGasPriceBufferAnu, manualBatchView, } from "./mappers.js";
19
19
  export { fetchDueCodexCronotons, claimDueCodexCronoton, applyTerminalIntent, advanceRecurring, } from "./claim.js";
20
20
  export { recordFire, createRunningFire, setFireJobId, appendFireTxKeys, finalizeFire, listFires, recoverFire, } from "./fires.js";
21
21
  export type { RecordFireInput, FireDep } from "./fires.js";
@@ -17,7 +17,7 @@
17
17
  // ── Typed errors (classes — values, not types) ───────────────────────────────
18
18
  export { CodexCronotonValidationError, AutoGasGateError, TerminalCronotonError, ManualBatchActiveError, } from "./errors.js";
19
19
  // ── Pure mappers / gates ─────────────────────────────────────────────────────
20
- export { rowToDefinition, rowExternalFireable, rowRuntimeArgKeys, assertAutoGasGate, manualBatchView, } from "./mappers.js";
20
+ export { rowToDefinition, rowExternalFireable, rowRuntimeArgKeys, assertAutoGasGate, assertGasPriceBufferAnu, manualBatchView, } from "./mappers.js";
21
21
  // ── Atomic claim + due selection + terminal/advance writes ───────────────────
22
22
  export { fetchDueCodexCronotons, claimDueCodexCronoton, applyTerminalIntent, advanceRecurring, } from "./claim.js";
23
23
  // ── Fires: record / running / append / finalize / list / recover ─────────────
@@ -17,5 +17,18 @@ export declare function rowRuntimeArgKeys(row: CodexCronotonRow): string[];
17
17
  * autonomous fire always has one (the tick never has a human to calibrate).
18
18
  */
19
19
  export declare function assertAutoGasGate(config: CodexTxConfig): void;
20
+ /**
21
+ * `gasPriceBufferAnu` is a PREMIUM above the live network floor, never a
22
+ * discount — a negative or non-finite value would let a fire underprice
23
+ * below the floor (the guarantee the whole buffer redesign exists to
24
+ * provide). Called identically at commit and edit time, same as
25
+ * {@link assertAutoGasGate}, so a caller reaching the store directly
26
+ * (bypassing the Builder UI's own `validateConfig`) can't persist a row that
27
+ * silently underprices every future fire. `blockchain/stoachain.ts`'s
28
+ * `gasMeta` seam also clamps defensively as a second line of defense for any
29
+ * `CodexTxDefinition` built outside this store. Absent is fine — only a
30
+ * present-and-invalid value is rejected.
31
+ */
32
+ export declare function assertGasPriceBufferAnu(config: CodexTxConfig): void;
20
33
  /** Project a raw batch row onto the client-facing view (clamping remaining). */
21
34
  export declare function manualBatchView(row: CodexManualBatchRow): ManualBatchView;
@@ -1,5 +1,5 @@
1
1
  import { parseRuntimeArgKeys } from '../pure/runtime-args.js';
2
- import { AutoGasGateError } from './errors.js';
2
+ import { AutoGasGateError, CodexCronotonValidationError } from './errors.js';
3
3
  function parseJson(json, fallback) {
4
4
  if (json == null)
5
5
  return fallback;
@@ -45,6 +45,25 @@ export function assertAutoGasGate(config) {
45
45
  throw new AutoGasGateError();
46
46
  }
47
47
  }
48
+ /**
49
+ * `gasPriceBufferAnu` is a PREMIUM above the live network floor, never a
50
+ * discount — a negative or non-finite value would let a fire underprice
51
+ * below the floor (the guarantee the whole buffer redesign exists to
52
+ * provide). Called identically at commit and edit time, same as
53
+ * {@link assertAutoGasGate}, so a caller reaching the store directly
54
+ * (bypassing the Builder UI's own `validateConfig`) can't persist a row that
55
+ * silently underprices every future fire. `blockchain/stoachain.ts`'s
56
+ * `gasMeta` seam also clamps defensively as a second line of defense for any
57
+ * `CodexTxDefinition` built outside this store. Absent is fine — only a
58
+ * present-and-invalid value is rejected.
59
+ */
60
+ export function assertGasPriceBufferAnu(config) {
61
+ if (config.gasPriceBufferAnu == null)
62
+ return;
63
+ if (!Number.isFinite(config.gasPriceBufferAnu) || config.gasPriceBufferAnu < 0) {
64
+ throw new CodexCronotonValidationError('config.gasPriceBufferAnu must be a non-negative finite number');
65
+ }
66
+ }
48
67
  /** Project a raw batch row onto the client-facing view (clamping remaining). */
49
68
  export function manualBatchView(row) {
50
69
  return {
@@ -48,8 +48,22 @@ export interface CodexGasPayer {
48
48
  /** Transaction config — chain, gas, ttl. `gasPrice` is in ANU. */
49
49
  export interface CodexTxConfig {
50
50
  readonly chainId: string;
51
- /** Gas price in ANU (converted to STOA via `anuToStoa` at build time). */
51
+ /**
52
+ * @deprecated Superseded by `gasPriceBufferAnu`. Kept only so historical rows'
53
+ * `config_json` still parses; no longer used to price new fires — see
54
+ * `server/executor.ts`'s `buildTransaction`, which always prices from the live
55
+ * network floor plus `gasPriceBufferAnu`.
56
+ */
52
57
  readonly gasPrice: number;
58
+ /**
59
+ * ANU to pay ABOVE the live network floor at fire time. 0 (default, and the
60
+ * value used when absent — e.g. every pre-migration row) = exactly the floor.
61
+ * The only gas-price knob an operator sets — never an absolute price, since
62
+ * the floor rises roughly every 3h and any absolute number set today is
63
+ * guaranteed to go stale. Absence self-heals a historical row with no DB
64
+ * migration.
65
+ */
66
+ readonly gasPriceBufferAnu?: number;
53
67
  readonly gasLimit: number;
54
68
  /** When true, the executor calibrates the gas limit from a dirty-read. */
55
69
  readonly autoGasLimit: boolean;
@@ -125,8 +125,22 @@ interface CodexGasPayer {
125
125
  /** Transaction config — chain, gas, ttl. `gasPrice` is in ANU. */
126
126
  interface CodexTxConfig {
127
127
  readonly chainId: string;
128
- /** Gas price in ANU (converted to STOA via `anuToStoa` at build time). */
128
+ /**
129
+ * @deprecated Superseded by `gasPriceBufferAnu`. Kept only so historical rows'
130
+ * `config_json` still parses; no longer used to price new fires — see
131
+ * `server/executor.ts`'s `buildTransaction`, which always prices from the live
132
+ * network floor plus `gasPriceBufferAnu`.
133
+ */
129
134
  readonly gasPrice: number;
135
+ /**
136
+ * ANU to pay ABOVE the live network floor at fire time. 0 (default, and the
137
+ * value used when absent — e.g. every pre-migration row) = exactly the floor.
138
+ * The only gas-price knob an operator sets — never an absolute price, since
139
+ * the floor rises roughly every 3h and any absolute number set today is
140
+ * guaranteed to go stale. Absence self-heals a historical row with no DB
141
+ * migration.
142
+ */
143
+ readonly gasPriceBufferAnu?: number;
130
144
  readonly gasLimit: number;
131
145
  /** When true, the executor calibrates the gas limit from a dirty-read. */
132
146
  readonly autoGasLimit: boolean;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-u_nUX1Bg.js';
2
+ import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-DnFB1Yz-.js';
3
3
 
4
4
  /**
5
5
  * The theming boundary. Every Khronoton UI surface renders inside a
package/dist/ui/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-5OB5NQ4S.js';
2
- import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-5LYT7ZLA.js';
1
+ import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-UP3SYP2U.js';
2
+ import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-KDCNWWWQ.js';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useContext } from 'react';
4
+ import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useMemo, useContext } from 'react';
5
5
 
6
6
  function KhronotonUiRoot({ children, className }) {
7
7
  const cls = className ? `khronoton-ui ${className}` : "khronoton-ui";
@@ -1347,7 +1347,7 @@ function Loaded({
1347
1347
  var MSG = {
1348
1348
  name: "Name is required.",
1349
1349
  ttl: "TTL must be between 60 and 86400 seconds.",
1350
- gasPrice: (floorAnu) => `Gas price must be at least ${floorAnu} ANU (the protocol floor).`,
1350
+ gasPriceBuffer: "Priority buffer cannot be negative.",
1351
1351
  gasLimit: "Gas limit must be greater than zero.",
1352
1352
  autoGas: "AUTO gas requires a successful Simulate to calibrate, or switch to manual.",
1353
1353
  signers: "At least one signer is required.",
@@ -1362,10 +1362,10 @@ function makeEmptyBuilderState() {
1362
1362
  pactCode: "",
1363
1363
  config: {
1364
1364
  chainId: "0",
1365
- // The GENESIS floor, and deliberately a FLOOR rather than a final price:
1366
- // the executor raises it to the chain's live minimum at fire time, so a
1367
- // cronoton created at this default does not underprice as it ages.
1368
- gasPriceAnu: GENESIS_MIN_GAS_ANU,
1365
+ // 0 = pay exactly the live floor at fire time. The executor always
1366
+ // prices from the live network floor plus this buffer, so a cronoton
1367
+ // created at this default never underprices as the floor rises.
1368
+ gasPriceBufferAnu: 0,
1369
1369
  gasLimit: 1500,
1370
1370
  autoGasLimit: false,
1371
1371
  ttl: 600
@@ -1387,8 +1387,9 @@ function makeEmptyBuilderState() {
1387
1387
  runtimeArgKeysText: ""
1388
1388
  };
1389
1389
  }
1390
- function maxTxFee(config) {
1391
- return config.gasPriceAnu * config.gasLimit;
1390
+ function maxTxFee(config, liveFloorAnu) {
1391
+ if (liveFloorAnu == null) return null;
1392
+ return (liveFloorAnu + config.gasPriceBufferAnu) * config.gasLimit;
1392
1393
  }
1393
1394
  function parseRuntimeArgKeysText(text) {
1394
1395
  return text.split(/[,\n]/).map((k) => k.trim()).filter((k) => k.length > 0);
@@ -1466,7 +1467,9 @@ function toSigner(row) {
1466
1467
  function builderToCommit(state, opts) {
1467
1468
  const config = {
1468
1469
  chainId: state.config.chainId,
1469
- gasPrice: state.config.gasPriceAnu,
1470
+ gasPrice: 0,
1471
+ // deprecated — kept as an honest 0 placeholder; never read for pricing
1472
+ gasPriceBufferAnu: state.config.gasPriceBufferAnu,
1470
1473
  gasLimit: state.config.gasLimit,
1471
1474
  autoGasLimit: state.config.autoGasLimit,
1472
1475
  ttl: state.config.ttl
@@ -1490,7 +1493,6 @@ function builderToCommit(state, opts) {
1490
1493
  if (runtimeArgKeys.length > 0) body.envelope.runtimeArgKeys = runtimeArgKeys;
1491
1494
  return body;
1492
1495
  }
1493
- var GENESIS_MIN_GAS_ANU = 1e4;
1494
1496
  function validateName(state) {
1495
1497
  return state.name.trim().length === 0 ? [MSG.name] : [];
1496
1498
  }
@@ -1498,8 +1500,9 @@ function validateConfig(state, opts = {}) {
1498
1500
  const errors = [];
1499
1501
  const c = state.config;
1500
1502
  if (c.ttl < 60 || c.ttl > 86400) errors.push(MSG.ttl);
1501
- const minGasAnu = opts.minGasPriceAnu ?? GENESIS_MIN_GAS_ANU;
1502
- if (c.gasPriceAnu < minGasAnu) errors.push(MSG.gasPrice(minGasAnu));
1503
+ if (!Number.isFinite(c.gasPriceBufferAnu) || c.gasPriceBufferAnu < 0) {
1504
+ errors.push(MSG.gasPriceBuffer);
1505
+ }
1503
1506
  if (c.gasLimit <= 0) errors.push(MSG.gasLimit);
1504
1507
  const autoGasWaived = Boolean(state.serverResolver) || isTriggerOnly2(state);
1505
1508
  if (c.autoGasLimit && !opts.simulateCalibrated && !autoGasWaived) errors.push(MSG.autoGas);
@@ -1606,7 +1609,7 @@ function detailToBuilderState(row) {
1606
1609
  pactCode: row.pact_code,
1607
1610
  config: {
1608
1611
  chainId: storedConfig.chainId,
1609
- gasPriceAnu: storedConfig.gasPrice,
1612
+ gasPriceBufferAnu: storedConfig.gasPriceBufferAnu ?? 0,
1610
1613
  gasLimit: storedConfig.gasLimit,
1611
1614
  autoGasLimit: storedConfig.autoGasLimit,
1612
1615
  ttl: storedConfig.ttl
@@ -1899,13 +1902,19 @@ var GAS_LABEL_STYLE = {
1899
1902
  function Hint({ children }) {
1900
1903
  return /* @__PURE__ */ jsx("p", { style: HINT_STYLE, children });
1901
1904
  }
1902
- function ConfigTab({ state, onChange, calibratedGasLimit }) {
1905
+ function ConfigTab({
1906
+ state,
1907
+ onChange,
1908
+ calibratedGasLimit,
1909
+ liveFloorAnu
1910
+ }) {
1903
1911
  const config = state.config;
1904
1912
  const patch = (next) => {
1905
1913
  onChange({ ...state, config: { ...config, ...next } });
1906
1914
  };
1907
1915
  const auto = config.autoGasLimit;
1908
1916
  const calibrated = typeof calibratedGasLimit === "number";
1917
+ const fee = maxTxFee(config, liveFloorAnu ?? null);
1909
1918
  return /* @__PURE__ */ jsxs("div", { children: [
1910
1919
  /* @__PURE__ */ jsx(Title, { children: "Transaction Configuration" }),
1911
1920
  /* @__PURE__ */ jsxs(Field, { label: "Chain ID", children: [
@@ -1920,18 +1929,22 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
1920
1929
  ),
1921
1930
  /* @__PURE__ */ jsx(Hint, { children: "Single chain per job (Stoa Network)." })
1922
1931
  ] }),
1923
- /* @__PURE__ */ jsxs(Field, { label: "Gas Price (ANU)", children: [
1932
+ /* @__PURE__ */ jsxs(Field, { label: "Live Network Floor (ANU)", children: [
1933
+ /* @__PURE__ */ jsx("div", { style: DISPLAY_STYLE, children: liveFloorAnu != null ? `${formatThousands(liveFloorAnu)} ANU` : "Loading\u2026" }),
1934
+ /* @__PURE__ */ jsx(Hint, { children: "The chain's live minimum gas price right now. Refreshes automatically." })
1935
+ ] }),
1936
+ /* @__PURE__ */ jsxs(Field, { label: "Priority Buffer (ANU above floor)", children: [
1924
1937
  /* @__PURE__ */ jsx(
1925
1938
  "input",
1926
1939
  {
1927
- "aria-label": "Gas Price (ANU)",
1940
+ "aria-label": "Priority Buffer (ANU above floor)",
1928
1941
  type: "number",
1929
1942
  style: INPUT_STYLE4,
1930
- value: config.gasPriceAnu,
1931
- onChange: (e) => patch({ gasPriceAnu: Number(e.target.value) })
1943
+ value: config.gasPriceBufferAnu,
1944
+ onChange: (e) => patch({ gasPriceBufferAnu: Number(e.target.value) })
1932
1945
  }
1933
1946
  ),
1934
- /* @__PURE__ */ jsx(Hint, { children: "Minimum 10,000 ANU (protocol floor)." })
1947
+ /* @__PURE__ */ jsx(Hint, { children: "The transaction always pays the live floor at fire time, plus this. Leave at 0 unless you need priority over other pending transactions." })
1935
1948
  ] }),
1936
1949
  /* @__PURE__ */ jsxs("div", { style: { marginBottom: "14px" }, children: [
1937
1950
  /* @__PURE__ */ jsxs("div", { style: GAS_HEAD_STYLE, children: [
@@ -1963,9 +1976,9 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
1963
1976
  auto ? /* @__PURE__ */ jsx(Hint, { children: calibrated ? `Calibrated: ${formatThousands(calibratedGasLimit)} gas` : "Run Simulate to calibrate the auto gas limit." }) : null
1964
1977
  ] }),
1965
1978
  /* @__PURE__ */ jsx(Field, { label: "Max Tx Fee (ANU)", children: /* @__PURE__ */ jsxs("div", { style: DISPLAY_STYLE, children: [
1966
- formatThousands(maxTxFee(config)),
1967
- " ANU ",
1968
- /* @__PURE__ */ jsx("span", { style: MUTED_STYLE, children: "(gas price x gas limit)" })
1979
+ fee != null ? `${formatThousands(fee)} ANU` : "\u2026",
1980
+ " ",
1981
+ /* @__PURE__ */ jsx("span", { style: MUTED_STYLE, children: "((floor + buffer) x gas limit)" })
1969
1982
  ] }) }),
1970
1983
  /* @__PURE__ */ jsxs(Field, { label: "Time To Live (seconds)", children: [
1971
1984
  /* @__PURE__ */ jsx(
@@ -3331,10 +3344,14 @@ var REASONS_STYLE = {
3331
3344
  var TRIGGER_ONLY_SCHEDULE = "Trigger-only (external / manual)";
3332
3345
  var EVENT_DRIVEN_SCHEDULE = "Event-driven (host-fired)";
3333
3346
  var EVENT_DRIVEN_NOTICE = "Event-driven \u2014 the host application fires this when its trigger condition is met; there is no schedule.";
3334
- function gasLine(state) {
3347
+ function gasLine(state, liveFloorAnu) {
3335
3348
  const c = state.config;
3336
3349
  const suffix = c.autoGasLimit ? " (AUTO)" : "";
3337
- return `${formatThousands(c.gasLimit)} @ ${c.gasPriceAnu} ANU${suffix}`;
3350
+ const buffer = c.gasPriceBufferAnu;
3351
+ if (liveFloorAnu == null) return `${formatThousands(c.gasLimit)} @ \u2026 ANU${suffix}`;
3352
+ const total = liveFloorAnu + buffer;
3353
+ const priceLabel = buffer > 0 ? `${formatThousands(total)} ANU (floor + ${formatThousands(buffer)})` : buffer < 0 ? `${formatThousands(total)} ANU (floor - ${formatThousands(Math.abs(buffer))})` : `${formatThousands(total)} ANU (floor)`;
3354
+ return `${formatThousands(c.gasLimit)} @ ${priceLabel}${suffix}`;
3338
3355
  }
3339
3356
  function gasPayerLabel(gasPayer) {
3340
3357
  if (gasPayer.type === "gas-station") return "Gas Station";
@@ -3370,15 +3387,19 @@ function ExecuteTab({
3370
3387
  onCommit,
3371
3388
  committing,
3372
3389
  eventDrivenResolver,
3373
- sim
3390
+ sim,
3391
+ liveFloorAnu
3374
3392
  }) {
3375
3393
  const [banner, setBanner] = useState(null);
3376
- const commit = builderToCommit(state);
3394
+ const commit = useMemo(() => builderToCommit(state), [state]);
3377
3395
  const payloadKeyCount = Object.keys(commit.envelope.payload ?? {}).length;
3378
3396
  const simulateCalibrated = Boolean(
3379
3397
  sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
3380
3398
  );
3381
- const gate = canCommit(state, { simulateCalibrated });
3399
+ const gate = useMemo(
3400
+ () => canCommit(state, { simulateCalibrated }),
3401
+ [state, simulateCalibrated]
3402
+ );
3382
3403
  const triggerOnly = isTriggerOnly2(state);
3383
3404
  const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
3384
3405
  const onSimulate = async () => {
@@ -3422,7 +3443,7 @@ function ExecuteTab({
3422
3443
  /* @__PURE__ */ jsxs(Panel, { style: { marginBottom: "16px" }, children: [
3423
3444
  /* @__PURE__ */ jsx("div", { style: { ...ROW_LABEL_STYLE, marginBottom: "4px" }, children: "Transaction Summary" }),
3424
3445
  /* @__PURE__ */ jsx(SummaryRow, { label: "Chain", value: state.config.chainId, testId: "summary-chain" }),
3425
- /* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state), testId: "summary-gas" }),
3446
+ /* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state, liveFloorAnu), testId: "summary-gas" }),
3426
3447
  /* @__PURE__ */ jsx(SummaryRow, { label: "TTL", value: `${state.config.ttl}s`, testId: "summary-ttl" }),
3427
3448
  /* @__PURE__ */ jsx(SummaryRow, { label: "Payload keys", value: String(payloadKeyCount), testId: "summary-payload" }),
3428
3449
  /* @__PURE__ */ jsx(SummaryRow, { label: "Gas payer", value: gasPayerLabel(state.gasPayer), testId: "summary-gaspayer" }),
@@ -3482,7 +3503,7 @@ async function estimateTxSize(state) {
3482
3503
  let bytes;
3483
3504
  try {
3484
3505
  const { Pact } = await import('@stoachain/kadena-stoic-legacy/client');
3485
- const { anuToStoaNumber } = await import('@stoachain/stoa-core/gas');
3506
+ const { anuToStoaNumber, minGasPriceAnu } = await import('@stoachain/stoa-core/gas');
3486
3507
  const { KADENA_NETWORK } = await import('@stoachain/stoa-core/constants');
3487
3508
  const builder = Pact.builder.execution(pactCode || "").setMeta({
3488
3509
  senderAccount: state.gasPayer.type === "codex" ? state.gasPayer.address ?? "" : "c:gas-station",
@@ -3490,9 +3511,15 @@ async function estimateTxSize(state) {
3490
3511
  gasLimit: config.gasLimit,
3491
3512
  // `anuToStoaNumber`, not `anuToStoa`: this meter exists to predict the
3492
3513
  // SIZE of the real signed transaction, so it must serialize gasPrice
3493
- // exactly the way the executor does. Plain float division can render a
3494
- // different number of characters than the value that actually ships.
3495
- gasPrice: anuToStoaNumber(config.gasPrice),
3514
+ // exactly the way the executor does — the live network floor plus
3515
+ // `gasPriceBufferAnu`, summed IN ANU before the ONE conversion below
3516
+ // (same precision fix as `blockchain/stoachain.ts`'s `gasMeta`: two
3517
+ // independently-converted STOA floats summed can produce a different
3518
+ // serialized value than converting the summed ANU once). The
3519
+ // deprecated `config.gasPrice` field is never read here.
3520
+ gasPrice: anuToStoaNumber(
3521
+ minGasPriceAnu(Math.floor(Date.now() / 1e3)) + (config.gasPriceBufferAnu ?? 0)
3522
+ ),
3496
3523
  ttl: config.ttl
3497
3524
  }).setNetworkId(KADENA_NETWORK);
3498
3525
  for (const [k, v] of Object.entries(payload ?? {})) {
@@ -3562,7 +3589,7 @@ function TxMeters({ state, sim }) {
3562
3589
  state.pactCode,
3563
3590
  state.config.chainId,
3564
3591
  state.config.gasLimit,
3565
- state.config.gasPriceAnu,
3592
+ state.config.gasPriceBufferAnu,
3566
3593
  state.config.ttl,
3567
3594
  state.payload,
3568
3595
  state.signers.length,
@@ -3612,6 +3639,37 @@ function TxMeters({ state, sim }) {
3612
3639
  ] })
3613
3640
  ] });
3614
3641
  }
3642
+ var POLL_INTERVAL_MS = 3e4;
3643
+ function useLiveGasFloor() {
3644
+ const [floorAnu, setFloorAnu] = useState(null);
3645
+ useEffect(() => {
3646
+ if (typeof window === "undefined") return;
3647
+ let active = true;
3648
+ const refresh = async () => {
3649
+ try {
3650
+ const { minGasPriceAnu } = await import('@stoachain/stoa-core/gas');
3651
+ const value = minGasPriceAnu(Math.floor(Date.now() / 1e3));
3652
+ if (active) setFloorAnu(value);
3653
+ } catch {
3654
+ }
3655
+ };
3656
+ void refresh();
3657
+ const timer = setInterval(() => void refresh(), POLL_INTERVAL_MS);
3658
+ const onVisibilityChange = () => {
3659
+ if (document.visibilityState === "visible") void refresh();
3660
+ };
3661
+ const onFocus = () => void refresh();
3662
+ document.addEventListener("visibilitychange", onVisibilityChange);
3663
+ window.addEventListener("focus", onFocus);
3664
+ return () => {
3665
+ active = false;
3666
+ clearInterval(timer);
3667
+ document.removeEventListener("visibilitychange", onVisibilityChange);
3668
+ window.removeEventListener("focus", onFocus);
3669
+ };
3670
+ }, []);
3671
+ return floorAnu;
3672
+ }
3615
3673
  var DEFAULT_BUILDER_ROBOTS = "noindex,nofollow";
3616
3674
  var TABS = [
3617
3675
  { key: "config", label: "Config" },
@@ -3726,6 +3784,7 @@ function Builder({
3726
3784
  }
3727
3785
  }, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
3728
3786
  const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
3787
+ const liveFloorAnu = useLiveGasFloor();
3729
3788
  const handlePactCodeChange = useCallback((pactCode) => {
3730
3789
  setState((s) => ({ ...s, pactCode }));
3731
3790
  }, []);
@@ -3765,7 +3824,15 @@ function Builder({
3765
3824
  },
3766
3825
  t.key
3767
3826
  )) }),
3768
- activeTab === "config" && /* @__PURE__ */ jsx(ConfigTab, { state, onChange: setState, calibratedGasLimit }),
3827
+ activeTab === "config" && /* @__PURE__ */ jsx(
3828
+ ConfigTab,
3829
+ {
3830
+ state,
3831
+ onChange: setState,
3832
+ calibratedGasLimit,
3833
+ liveFloorAnu
3834
+ }
3835
+ ),
3769
3836
  activeTab === "payload" && /* @__PURE__ */ jsx(PayloadTab, { state, onChange: (payload) => setState((s) => ({ ...s, payload })) }),
3770
3837
  activeTab === "gas-payer" && /* @__PURE__ */ jsx(GasPayerTab, { state, onChange: setState, signers }),
3771
3838
  activeTab === "signatures" && /* @__PURE__ */ jsx(SignaturesTab, { state, onChange: setState, signers }),
@@ -3777,7 +3844,8 @@ function Builder({
3777
3844
  onCommit: handleCommit,
3778
3845
  committing,
3779
3846
  eventDrivenResolver,
3780
- sim
3847
+ sim,
3848
+ liveFloorAnu
3781
3849
  }
3782
3850
  )
3783
3851
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancientpantheon/khronoton-core",
3
- "version": "0.9.0",
3
+ "version": "0.10.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",