@ancientpantheon/khronoton-core 0.8.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,45 @@ 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
+
24
+ ## 0.9.0 — 2026-09-07
25
+
26
+ **MINOR — scheduled transactions are priced against the chain's LIVE gas floor at fire time, not a static value stored at creation time.**
27
+
28
+ A cronoton's `gasPrice` was a plain ANU number persisted once at creation time and read back verbatim on every tick — never re-derived. Post-fork, chainweb validates a signed transaction's price against the **rising** Yin Engine floor as of that transaction's own `creationTime`, so a long-lived cronoton silently drifts below the floor and its fire is rejected. This is unattended automation: nobody is watching a 3am tick.
29
+
30
+ This was **live, not theoretical** — at the time of this release the floor stood at **11,569 ANU** while the builder's stored default was **10,000**, leaving every default-priced cronoton ~15.7% underpriced.
31
+
32
+ - **New OPTIONAL `ChainRuntime.gasMeta(floorAnu)` seam.** Returns `{ creationTime, gasPrice }` from **one** clock read. Optional so the package stays chain-POLYGLOT and `@stoachain/*` stays an optional peer dependency — a chain with no rising floor omits it. It is *not* optional in effect for a StoaChain fire: the executor **hard throws** when it is absent rather than falling back to the stored price, because a silent fallback ships the original bug to anyone who does not notice they must upgrade their runtime adapter.
33
+ - **The stored price is now a FLOOR, not a final price.** `max(stored, liveFloor(creationTime))` — an operator can still raise it above the minimum, and it can never hold a transaction below one. **Existing rows self-heal with no database migration.**
34
+ - **`creationTime` is now stamped explicitly.** `setMeta` previously omitted it, letting the Pact builder auto-stamp its own at `createTransaction()` — a second, independent clock read the price no longer corresponded to. Both fields now come from the same call, closing a tick-boundary race.
35
+ - **The AUTO-gas rebuild re-derives gas meta fresh.** The calibrated rebuild+re-sign calls the seam again rather than reusing the pre-flight build's values, so the two builds cannot straddle a tick boundary and underprice the transaction that actually gets submitted. Pinned by a regression spec that fails if the call is hoisted out of `buildTransaction`.
36
+ - **Precision.** Transaction meta now uses `anuToStoaNumber` (exact padded-decimal conversion) instead of `anuToStoa` (float division), which upstream documents as unsafe for a value chainweb hashes and validates exactly. Fixed at the meta site and at `ui/tx-size.ts`'s fee meter, whose whole job is predicting the real signed transaction's size.
37
+ - **`validateConfig` accepts an optional live floor.** `CommitGateOptions.minGasPriceAnu` replaces a hardcoded `>= 10000` gate that happily accepted an already-underpriced price; the message names the floor actually applied. Omitting it validates against the genesis floor as before — it under-rejects rather than over-rejects, and the executor raises the price at fire time regardless.
38
+ - **`blockchain/stoachain.ts` is the only place that knows the Yin Engine exists**, wrapping `@stoachain/stoa-core/gas` rather than reimplementing the arithmetic — a formula already independently reimplemented four times across the ecosystem.
39
+
40
+ **Dependencies — a coordinated family bump, not a standalone repin.** `@stoachain/stoa-core@4.4.0` peer-pins `@stoachain/kadena-stoic-legacy@4.4.0` exactly, and only `@ouronet/ouronet-core@4.6.0` accepts stoa-core 4.4.0; the three must move together or `npm install` fails to resolve. Peer + dev ranges: stoa-core `^4.3.6 → ^4.4.0`, kadena-stoic-legacy `^4.3.6 → ^4.4.0`, ouronet-core `^4.3.6 → ^4.6.0`.
41
+
42
+ New public surface — `StoaGasMeta`, the optional `ChainRuntime.gasMeta`, and `CommitGateOptions.minGasPriceAnu` — is entirely additive. A consumer injecting its own `ChainRuntime` for a StoaChain fire must add `gasMeta` (the bundled `createStoachainRuntime` supplies it); a consumer wrapping the adapter by spread picks it up with no change.
43
+
44
+ **907 specs pass, plus 5 real-runtime integration specs against the installed `@stoachain/*@4.4.0`.**
45
+
7
46
  ## 0.8.0 — 2026-08-03
8
47
 
9
48
  **MINOR — the last two evented-server-resolver UI fixes: DETAIL "Schedule" reads "Evented", and a system cronoton is deletable behind a confirm-gated warning.**
package/README.md CHANGED
@@ -6,6 +6,10 @@ 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
+
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).
12
+
9
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.**
10
14
 
11
15
  **`0.7.0` on public npmjs** — **MINOR.** Released 2026-08-03. Makes event-driven resolvers **server-authoritative**: `SingleTxResolver`/`MultiTxResolver` gain an `evented?` flag, and the **store** forces an evented resolver's cronoton scheduleless (`next_fire_at = NULL`, excluded from the due-query) **and `external_fireable = 1`** even when a schedule is sent — the guarantee no longer depends on the consumer. Adds `GET /resolvers` (+ an OPTIONAL `resolvers()` adapter method and `useServerResolvers` hook) so the Builder learns which resolvers are evented; the list shows **"Evented"** as the next-fire for a trigger-only row; and the store enforces **one resolver ↔ one cronoton** (a second bind is rejected). Deliberately reverses 0.6.0's HMAC stance — an evented row is now HMAC-fireable — codifying Pythia's shipped behavior (see version history). **871 specs pass.**
@@ -242,6 +246,10 @@ npm install @ancientpantheon/khronoton-core
242
246
 
243
247
  ## Version history
244
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
+
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).
252
+
245
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.**
246
254
 
247
255
  **v0.7.0** — Server-authoritative evented resolvers. `SingleTxResolver`/`MultiTxResolver` gain an optional `evented?` flag; the **store** (`createCodexCronoton`/`editCodexCronoton`, via an acyclic `getServerResolver` lookup) forces an evented resolver's cronoton `next_fire_at = NULL` **and `external_fireable = 1`** even when a real schedule is committed, so the scheduleless guarantee lives in the package rather than each consumer's proxy (`fetchDueCodexCronotons` skips it; an evented→non-evented edit re-arms `next_fire_at` and clears `external_fireable`; a genuine non-evented external-fireable row is never clobbered). A new `GET /resolvers` handler + `listServerResolvers()` expose `{ name, kind, evented }`; the `KhronotonAdapter` read tier gains an **OPTIONAL** `resolvers()` method (both reference adapters implement it, but it is **not** in `REQUIRED_METHODS`, so older adapters still pass `assertAdapter`), consumed by the new `useServerResolvers` hook. The Builder makes `eventDrivenResolver` server-authoritative (registry `evented` OR the 0.6.0 `serverResolverOptions.eventDriven` fallback), commits `externalFireable: true` for an evented resolver (derived at commit time — never stuck when switching away), and the `CronotonList` next-fire cell reads **"Evented"** for a trigger-only row (`external_fireable === 1` or runtime-arg keys). The store also enforces **one resolver ↔ one cronoton** — a second `createCodexCronoton` reusing a bound `server_resolver` throws `CodexCronotonValidationError` naming the existing id (→ 400). **Deliberate reversal of 0.6.0's HMAC stance:** an evented row is now `external_fireable = 1` and thus HMAC-fireable — a conscious choice codifying Pythia's already-shipped production behavior (v2.7.19/2.7.20), giving one persisted signal the store, Builder, and list all read; manually firing an evented resolver just re-runs its idempotent resolve (no-ops when nothing is ready). The published 0.6.0 `eventDriven` surface is kept intact as an additive fallback; ordinary scheduled resolvers are unchanged. Released 2026-08-03. **871 specs pass.**
@@ -1,4 +1,4 @@
1
- import { C as ChainRuntime } from '../seams-DapFZ4sM.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.
@@ -13,6 +13,13 @@ import { C as ChainRuntime } from '../seams-DapFZ4sM.js';
13
13
  * subpath costs nothing (the SDK imports are lazy, inside the factory), so a
14
14
  * consumer who never talks StoaChain never installs them. Only calling
15
15
  * `createStoachainRuntime()` pulls the SDK — and a StoaChain automaton has it.
16
+ *
17
+ * This adapter is also the ONLY place khronoton knows StoaChain's rising gas
18
+ * floor (the Yin Engine) exists. The `/server` executor asks for gas meta
19
+ * through the {@link ChainRuntime.gasMeta} seam and never imports the formula;
20
+ * `@stoachain/stoa-core/gas` owns the single canonical implementation, which is
21
+ * why this wraps it rather than reimplementing the arithmetic locally — that
22
+ * reimplementation has already happened four times across the ecosystem.
16
23
  */
17
24
  /**
18
25
  * Consumer-facing knobs for {@link createStoachainRuntime}. Every field is
@@ -17,6 +17,12 @@ async function createStoachainRuntime(config) {
17
17
  universalSignTransaction: signing.universalSignTransaction,
18
18
  calculateAutoGasLimit: gas.calculateAutoGasLimit,
19
19
  anuToStoa: gas.anuToStoa,
20
+ gasMeta: (floorAnu, bufferAnu = 0) => {
21
+ const { creationTime } = gas.stoaGasMeta();
22
+ const safeBufferAnu = Number.isFinite(bufferAnu) && bufferAnu > 0 ? bufferAnu : 0;
23
+ const anu = Math.max(floorAnu, gas.minGasPriceAnu(creationTime)) + safeBufferAnu;
24
+ return { creationTime, gasPrice: gas.anuToStoaNumber(anu) };
25
+ },
20
26
  getPactUrl,
21
27
  networkId,
22
28
  namespace,
@@ -226,11 +226,25 @@ function buildTransaction(runtime, definition, signers, gasLimitOverride) {
226
226
  const builder = runtime.Pact.builder.execution(
227
227
  definition.pactCode
228
228
  );
229
+ if (!runtime.gasMeta) {
230
+ throw new Error(
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
+ );
233
+ }
234
+ const { creationTime, gasPrice } = runtime.gasMeta(
235
+ 0,
236
+ definition.config.gasPriceBufferAnu ?? 0
237
+ );
229
238
  builder.setMeta({
230
239
  senderAccount,
231
240
  chainId: definition.config.chainId,
232
241
  gasLimit: gasLimitOverride ?? definition.config.gasLimit,
233
- gasPrice: runtime.anuToStoa(definition.config.gasPrice),
242
+ gasPrice,
243
+ // Stamped EXPLICITLY, from the same call that produced gasPrice. Left
244
+ // unset, the Pact builder auto-stamps its own creationTime at
245
+ // createTransaction() — a second, independent clock read that the price
246
+ // above would then no longer correspond to.
247
+ creationTime,
234
248
  ttl: definition.config.ttl
235
249
  }).setNetworkId(runtime.networkId);
236
250
  for (const [key, value] of Object.entries(definition.payload)) {
@@ -508,6 +522,14 @@ function assertAutoGasGate(config) {
508
522
  throw new AutoGasGateError();
509
523
  }
510
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
+ }
511
533
  function manualBatchView(row) {
512
534
  return {
513
535
  id: row.id,
@@ -1163,6 +1185,7 @@ function commitCodexCronoton(input, opts) {
1163
1185
  if (!input.config || typeof input.config.chainId !== "string") {
1164
1186
  throw new CodexCronotonValidationError("config.chainId must be a string");
1165
1187
  }
1188
+ assertGasPriceBufferAnu(input.config);
1166
1189
  if (!Array.isArray(input.signers)) {
1167
1190
  throw new CodexCronotonValidationError("signers must be an array");
1168
1191
  }
@@ -1278,6 +1301,7 @@ function editCodexCronoton(id, patch, opts) {
1278
1301
  changedFields.push("pactCode");
1279
1302
  }
1280
1303
  if (patch.config) {
1304
+ assertGasPriceBufferAnu(patch.config);
1281
1305
  assertAutoGasGate(patch.config);
1282
1306
  nextConfigJson = JSON.stringify(patch.config);
1283
1307
  changedFields.push("config");
@@ -1,4 +1,4 @@
1
- import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-WLZXX2SQ.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-DapFZ4sM.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-C1K08cmR.js';
2
- export { U as UseKhronotonResult, u as useKhronoton } from '../context-C1K08cmR.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-DapFZ4sM.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-NNR4MYI3.js';
2
- export { useKhronoton } from '../chunk-WLZXX2SQ.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-C1K08cmR.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-C1K08cmR.js';
4
- import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-DapFZ4sM.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-WLZXX2SQ.js';
2
- export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-WLZXX2SQ.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
 
@@ -571,6 +571,7 @@ function throwingRuntime() {
571
571
  universalSignTransaction: notWired,
572
572
  calculateAutoGasLimit: notWired,
573
573
  anuToStoa: notWired,
574
+ gasMeta: notWired,
574
575
  getPactUrl: notWired,
575
576
  networkId: "memory",
576
577
  namespace: "memory-ns",
@@ -102,6 +102,24 @@ interface ChainClient {
102
102
  }>;
103
103
  listen(desc: unknown): Promise<ListenResult>;
104
104
  }
105
+ /**
106
+ * The transaction gas meta produced by {@link ChainRuntime.gasMeta} — a
107
+ * `creationTime` (unix seconds) and the `gasPrice` (in the chain's own
108
+ * transaction units, NOT ANU) derived from that exact `creationTime`.
109
+ *
110
+ * Both fields come from ONE call, and both must be spread into the same
111
+ * `setMeta`. They are a matched pair: a chain whose minimum gas price rises
112
+ * over time validates a signed transaction's price against the transaction's
113
+ * OWN `creationTime`, so a price derived from a different clock read than the
114
+ * `creationTime` that ships with it can silently fall under the floor when the
115
+ * two reads straddle a tick boundary.
116
+ */
117
+ interface StoaGasMeta {
118
+ /** Unix seconds stamped into the transaction. */
119
+ creationTime: number;
120
+ /** Price for that creationTime, in chain transaction units (e.g. STOA). */
121
+ gasPrice: number;
122
+ }
105
123
  /**
106
124
  * The chain runtime seam — every `@stoachain/*` runtime value the executor
107
125
  * reaches for, inverted into one injectable object. Ported from the Hub's
@@ -110,6 +128,30 @@ interface ChainClient {
110
128
  * `STOA_AUTONOMIC_OURONETGASSTATION -> gasStationAccount`,
111
129
  * `KADENA_NAMESPACE -> namespace`. Deliberately excludes `pollRequestKeys`
112
130
  * (the executor confirms via `listen`, never polls).
131
+ *
132
+ * `gasMeta` is OPTIONAL so this package stays chain-POLYGLOT and
133
+ * `@stoachain/*` stays an optional peer dependency — a runtime for a chain with
134
+ * no rising gas floor simply omits it. It is NOT optional in effect for a
135
+ * StoaChain fire: the executor HARD THROWS when it is absent rather than
136
+ * falling back to the per-cronoton stored price. That fallback is precisely the
137
+ * bug this capability exists to kill — a stored price is captured once at
138
+ * cronoton-creation time and never re-derived, so it drifts below the live
139
+ * floor as the cronoton ages, and nobody is watching a 3am tick fire to notice
140
+ * the rejection. Failing loudly on an un-upgraded runtime adapter is the point.
141
+ *
142
+ * `floorAnu` is the caller's stored price in ANU, treated as a floor an
143
+ * operator may raise ABOVE the live minimum, never a cap that can hold a
144
+ * transaction below it. Implementations return
145
+ * `max(floorAnu, liveFloor(creationTime))`, converted to chain units.
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.
113
155
  */
114
156
  interface ChainRuntime {
115
157
  Pact: {
@@ -122,6 +164,7 @@ interface ChainRuntime {
122
164
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
123
165
  calculateAutoGasLimit(gas: number): number;
124
166
  anuToStoa(anu: number): number;
167
+ gasMeta?(floorAnu: number, bufferAnu?: number): StoaGasMeta;
125
168
  getPactUrl(chainId: string): string;
126
169
  networkId: string;
127
170
  namespace: string;
@@ -26,7 +26,15 @@ export { LISTEN_TIMEOUT_MS } from "./seams.js";
26
26
  /**
27
27
  * Build a Pact transaction from the definition:
28
28
  * `Pact.builder.execution().setMeta().setNetworkId()` + an `addData` loop over
29
- * the payload + pure-vs-scoped `addSigner`. Throws if no signers.
29
+ * the payload + pure-vs-scoped `addSigner`. Throws if no signers, and throws if
30
+ * the injected runtime cannot supply gas meta (see {@link ChainRuntime.gasMeta}).
31
+ *
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.
30
38
  */
31
39
  function buildTransaction(runtime, definition, signers, gasLimitOverride) {
32
40
  if (signers.length === 0) {
@@ -34,12 +42,30 @@ function buildTransaction(runtime, definition, signers, gasLimitOverride) {
34
42
  }
35
43
  const senderAccount = deriveSenderAccount(definition.gasPayer, runtime.gasStationAccount);
36
44
  const builder = runtime.Pact.builder.execution(definition.pactCode);
45
+ // Gas meta is derived HERE, once per build, and never hoisted out or cached
46
+ // by a caller: the AUTO-gas path calls this function a SECOND time to rebuild
47
+ // and re-sign at the calibrated limit, and that rebuild must re-derive both
48
+ // fields fresh. Reusing the pre-flight build's values would let creationTime
49
+ // and gasPrice drift apart across a tick boundary — underpricing the very
50
+ // transaction that gets submitted.
51
+ if (!runtime.gasMeta) {
52
+ throw new Error("ChainRuntime.gasMeta is required to price a transaction: without it the " +
53
+ "per-cronoton stored gasPrice would be used verbatim, which drifts below " +
54
+ "the chain's rising minimum as a cronoton ages and gets the fire rejected. " +
55
+ "Upgrade the injected runtime adapter (see blockchain/stoachain.ts).");
56
+ }
57
+ const { creationTime, gasPrice } = runtime.gasMeta(0, definition.config.gasPriceBufferAnu ?? 0);
37
58
  builder
38
59
  .setMeta({
39
60
  senderAccount,
40
61
  chainId: definition.config.chainId,
41
62
  gasLimit: gasLimitOverride ?? definition.config.gasLimit,
42
- gasPrice: runtime.anuToStoa(definition.config.gasPrice),
63
+ gasPrice,
64
+ // Stamped EXPLICITLY, from the same call that produced gasPrice. Left
65
+ // unset, the Pact builder auto-stamps its own creationTime at
66
+ // createTransaction() — a second, independent clock read that the price
67
+ // above would then no longer correspond to.
68
+ creationTime,
43
69
  ttl: definition.config.ttl,
44
70
  })
45
71
  .setNetworkId(runtime.networkId);
@@ -102,6 +102,24 @@ export interface ChainClient {
102
102
  }>;
103
103
  listen(desc: unknown): Promise<ListenResult>;
104
104
  }
105
+ /**
106
+ * The transaction gas meta produced by {@link ChainRuntime.gasMeta} — a
107
+ * `creationTime` (unix seconds) and the `gasPrice` (in the chain's own
108
+ * transaction units, NOT ANU) derived from that exact `creationTime`.
109
+ *
110
+ * Both fields come from ONE call, and both must be spread into the same
111
+ * `setMeta`. They are a matched pair: a chain whose minimum gas price rises
112
+ * over time validates a signed transaction's price against the transaction's
113
+ * OWN `creationTime`, so a price derived from a different clock read than the
114
+ * `creationTime` that ships with it can silently fall under the floor when the
115
+ * two reads straddle a tick boundary.
116
+ */
117
+ export interface StoaGasMeta {
118
+ /** Unix seconds stamped into the transaction. */
119
+ creationTime: number;
120
+ /** Price for that creationTime, in chain transaction units (e.g. STOA). */
121
+ gasPrice: number;
122
+ }
105
123
  /**
106
124
  * The chain runtime seam — every `@stoachain/*` runtime value the executor
107
125
  * reaches for, inverted into one injectable object. Ported from the Hub's
@@ -110,6 +128,30 @@ export interface ChainClient {
110
128
  * `STOA_AUTONOMIC_OURONETGASSTATION -> gasStationAccount`,
111
129
  * `KADENA_NAMESPACE -> namespace`. Deliberately excludes `pollRequestKeys`
112
130
  * (the executor confirms via `listen`, never polls).
131
+ *
132
+ * `gasMeta` is OPTIONAL so this package stays chain-POLYGLOT and
133
+ * `@stoachain/*` stays an optional peer dependency — a runtime for a chain with
134
+ * no rising gas floor simply omits it. It is NOT optional in effect for a
135
+ * StoaChain fire: the executor HARD THROWS when it is absent rather than
136
+ * falling back to the per-cronoton stored price. That fallback is precisely the
137
+ * bug this capability exists to kill — a stored price is captured once at
138
+ * cronoton-creation time and never re-derived, so it drifts below the live
139
+ * floor as the cronoton ages, and nobody is watching a 3am tick fire to notice
140
+ * the rejection. Failing loudly on an un-upgraded runtime adapter is the point.
141
+ *
142
+ * `floorAnu` is the caller's stored price in ANU, treated as a floor an
143
+ * operator may raise ABOVE the live minimum, never a cap that can hold a
144
+ * transaction below it. Implementations return
145
+ * `max(floorAnu, liveFloor(creationTime))`, converted to chain units.
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.
113
155
  */
114
156
  export interface ChainRuntime {
115
157
  Pact: {
@@ -122,6 +164,7 @@ export interface ChainRuntime {
122
164
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
123
165
  calculateAutoGasLimit(gas: number): number;
124
166
  anuToStoa(anu: number): number;
167
+ gasMeta?(floorAnu: number, bufferAnu?: number): StoaGasMeta;
125
168
  getPactUrl(chainId: string): string;
126
169
  networkId: string;
127
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-NNR4MYI3.js';
2
- import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-WLZXX2SQ.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: "Gas price must be at least 10000 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,7 +1362,10 @@ function makeEmptyBuilderState() {
1362
1362
  pactCode: "",
1363
1363
  config: {
1364
1364
  chainId: "0",
1365
- gasPriceAnu: 1e4,
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,
1366
1369
  gasLimit: 1500,
1367
1370
  autoGasLimit: false,
1368
1371
  ttl: 600
@@ -1384,8 +1387,9 @@ function makeEmptyBuilderState() {
1384
1387
  runtimeArgKeysText: ""
1385
1388
  };
1386
1389
  }
1387
- function maxTxFee(config) {
1388
- return config.gasPriceAnu * config.gasLimit;
1390
+ function maxTxFee(config, liveFloorAnu) {
1391
+ if (liveFloorAnu == null) return null;
1392
+ return (liveFloorAnu + config.gasPriceBufferAnu) * config.gasLimit;
1389
1393
  }
1390
1394
  function parseRuntimeArgKeysText(text) {
1391
1395
  return text.split(/[,\n]/).map((k) => k.trim()).filter((k) => k.length > 0);
@@ -1463,7 +1467,9 @@ function toSigner(row) {
1463
1467
  function builderToCommit(state, opts) {
1464
1468
  const config = {
1465
1469
  chainId: state.config.chainId,
1466
- gasPrice: state.config.gasPriceAnu,
1470
+ gasPrice: 0,
1471
+ // deprecated — kept as an honest 0 placeholder; never read for pricing
1472
+ gasPriceBufferAnu: state.config.gasPriceBufferAnu,
1467
1473
  gasLimit: state.config.gasLimit,
1468
1474
  autoGasLimit: state.config.autoGasLimit,
1469
1475
  ttl: state.config.ttl
@@ -1494,7 +1500,9 @@ function validateConfig(state, opts = {}) {
1494
1500
  const errors = [];
1495
1501
  const c = state.config;
1496
1502
  if (c.ttl < 60 || c.ttl > 86400) errors.push(MSG.ttl);
1497
- if (c.gasPriceAnu < 1e4) errors.push(MSG.gasPrice);
1503
+ if (!Number.isFinite(c.gasPriceBufferAnu) || c.gasPriceBufferAnu < 0) {
1504
+ errors.push(MSG.gasPriceBuffer);
1505
+ }
1498
1506
  if (c.gasLimit <= 0) errors.push(MSG.gasLimit);
1499
1507
  const autoGasWaived = Boolean(state.serverResolver) || isTriggerOnly2(state);
1500
1508
  if (c.autoGasLimit && !opts.simulateCalibrated && !autoGasWaived) errors.push(MSG.autoGas);
@@ -1601,7 +1609,7 @@ function detailToBuilderState(row) {
1601
1609
  pactCode: row.pact_code,
1602
1610
  config: {
1603
1611
  chainId: storedConfig.chainId,
1604
- gasPriceAnu: storedConfig.gasPrice,
1612
+ gasPriceBufferAnu: storedConfig.gasPriceBufferAnu ?? 0,
1605
1613
  gasLimit: storedConfig.gasLimit,
1606
1614
  autoGasLimit: storedConfig.autoGasLimit,
1607
1615
  ttl: storedConfig.ttl
@@ -1894,13 +1902,19 @@ var GAS_LABEL_STYLE = {
1894
1902
  function Hint({ children }) {
1895
1903
  return /* @__PURE__ */ jsx("p", { style: HINT_STYLE, children });
1896
1904
  }
1897
- function ConfigTab({ state, onChange, calibratedGasLimit }) {
1905
+ function ConfigTab({
1906
+ state,
1907
+ onChange,
1908
+ calibratedGasLimit,
1909
+ liveFloorAnu
1910
+ }) {
1898
1911
  const config = state.config;
1899
1912
  const patch = (next) => {
1900
1913
  onChange({ ...state, config: { ...config, ...next } });
1901
1914
  };
1902
1915
  const auto = config.autoGasLimit;
1903
1916
  const calibrated = typeof calibratedGasLimit === "number";
1917
+ const fee = maxTxFee(config, liveFloorAnu ?? null);
1904
1918
  return /* @__PURE__ */ jsxs("div", { children: [
1905
1919
  /* @__PURE__ */ jsx(Title, { children: "Transaction Configuration" }),
1906
1920
  /* @__PURE__ */ jsxs(Field, { label: "Chain ID", children: [
@@ -1915,18 +1929,22 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
1915
1929
  ),
1916
1930
  /* @__PURE__ */ jsx(Hint, { children: "Single chain per job (Stoa Network)." })
1917
1931
  ] }),
1918
- /* @__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: [
1919
1937
  /* @__PURE__ */ jsx(
1920
1938
  "input",
1921
1939
  {
1922
- "aria-label": "Gas Price (ANU)",
1940
+ "aria-label": "Priority Buffer (ANU above floor)",
1923
1941
  type: "number",
1924
1942
  style: INPUT_STYLE4,
1925
- value: config.gasPriceAnu,
1926
- onChange: (e) => patch({ gasPriceAnu: Number(e.target.value) })
1943
+ value: config.gasPriceBufferAnu,
1944
+ onChange: (e) => patch({ gasPriceBufferAnu: Number(e.target.value) })
1927
1945
  }
1928
1946
  ),
1929
- /* @__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." })
1930
1948
  ] }),
1931
1949
  /* @__PURE__ */ jsxs("div", { style: { marginBottom: "14px" }, children: [
1932
1950
  /* @__PURE__ */ jsxs("div", { style: GAS_HEAD_STYLE, children: [
@@ -1958,9 +1976,9 @@ function ConfigTab({ state, onChange, calibratedGasLimit }) {
1958
1976
  auto ? /* @__PURE__ */ jsx(Hint, { children: calibrated ? `Calibrated: ${formatThousands(calibratedGasLimit)} gas` : "Run Simulate to calibrate the auto gas limit." }) : null
1959
1977
  ] }),
1960
1978
  /* @__PURE__ */ jsx(Field, { label: "Max Tx Fee (ANU)", children: /* @__PURE__ */ jsxs("div", { style: DISPLAY_STYLE, children: [
1961
- formatThousands(maxTxFee(config)),
1962
- " ANU ",
1963
- /* @__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)" })
1964
1982
  ] }) }),
1965
1983
  /* @__PURE__ */ jsxs(Field, { label: "Time To Live (seconds)", children: [
1966
1984
  /* @__PURE__ */ jsx(
@@ -3326,10 +3344,14 @@ var REASONS_STYLE = {
3326
3344
  var TRIGGER_ONLY_SCHEDULE = "Trigger-only (external / manual)";
3327
3345
  var EVENT_DRIVEN_SCHEDULE = "Event-driven (host-fired)";
3328
3346
  var EVENT_DRIVEN_NOTICE = "Event-driven \u2014 the host application fires this when its trigger condition is met; there is no schedule.";
3329
- function gasLine(state) {
3347
+ function gasLine(state, liveFloorAnu) {
3330
3348
  const c = state.config;
3331
3349
  const suffix = c.autoGasLimit ? " (AUTO)" : "";
3332
- 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}`;
3333
3355
  }
3334
3356
  function gasPayerLabel(gasPayer) {
3335
3357
  if (gasPayer.type === "gas-station") return "Gas Station";
@@ -3365,15 +3387,19 @@ function ExecuteTab({
3365
3387
  onCommit,
3366
3388
  committing,
3367
3389
  eventDrivenResolver,
3368
- sim
3390
+ sim,
3391
+ liveFloorAnu
3369
3392
  }) {
3370
3393
  const [banner, setBanner] = useState(null);
3371
- const commit = builderToCommit(state);
3394
+ const commit = useMemo(() => builderToCommit(state), [state]);
3372
3395
  const payloadKeyCount = Object.keys(commit.envelope.payload ?? {}).length;
3373
3396
  const simulateCalibrated = Boolean(
3374
3397
  sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
3375
3398
  );
3376
- const gate = canCommit(state, { simulateCalibrated });
3399
+ const gate = useMemo(
3400
+ () => canCommit(state, { simulateCalibrated }),
3401
+ [state, simulateCalibrated]
3402
+ );
3377
3403
  const triggerOnly = isTriggerOnly2(state);
3378
3404
  const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
3379
3405
  const onSimulate = async () => {
@@ -3417,7 +3443,7 @@ function ExecuteTab({
3417
3443
  /* @__PURE__ */ jsxs(Panel, { style: { marginBottom: "16px" }, children: [
3418
3444
  /* @__PURE__ */ jsx("div", { style: { ...ROW_LABEL_STYLE, marginBottom: "4px" }, children: "Transaction Summary" }),
3419
3445
  /* @__PURE__ */ jsx(SummaryRow, { label: "Chain", value: state.config.chainId, testId: "summary-chain" }),
3420
- /* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state), testId: "summary-gas" }),
3446
+ /* @__PURE__ */ jsx(SummaryRow, { label: "Gas", value: gasLine(state, liveFloorAnu), testId: "summary-gas" }),
3421
3447
  /* @__PURE__ */ jsx(SummaryRow, { label: "TTL", value: `${state.config.ttl}s`, testId: "summary-ttl" }),
3422
3448
  /* @__PURE__ */ jsx(SummaryRow, { label: "Payload keys", value: String(payloadKeyCount), testId: "summary-payload" }),
3423
3449
  /* @__PURE__ */ jsx(SummaryRow, { label: "Gas payer", value: gasPayerLabel(state.gasPayer), testId: "summary-gaspayer" }),
@@ -3477,13 +3503,23 @@ async function estimateTxSize(state) {
3477
3503
  let bytes;
3478
3504
  try {
3479
3505
  const { Pact } = await import('@stoachain/kadena-stoic-legacy/client');
3480
- const { anuToStoa } = await import('@stoachain/stoa-core/gas');
3506
+ const { anuToStoaNumber, minGasPriceAnu } = await import('@stoachain/stoa-core/gas');
3481
3507
  const { KADENA_NETWORK } = await import('@stoachain/stoa-core/constants');
3482
3508
  const builder = Pact.builder.execution(pactCode || "").setMeta({
3483
3509
  senderAccount: state.gasPayer.type === "codex" ? state.gasPayer.address ?? "" : "c:gas-station",
3484
3510
  chainId: config.chainId,
3485
3511
  gasLimit: config.gasLimit,
3486
- gasPrice: anuToStoa(config.gasPrice),
3512
+ // `anuToStoaNumber`, not `anuToStoa`: this meter exists to predict the
3513
+ // SIZE of the real signed transaction, so it must serialize 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
+ ),
3487
3523
  ttl: config.ttl
3488
3524
  }).setNetworkId(KADENA_NETWORK);
3489
3525
  for (const [k, v] of Object.entries(payload ?? {})) {
@@ -3553,7 +3589,7 @@ function TxMeters({ state, sim }) {
3553
3589
  state.pactCode,
3554
3590
  state.config.chainId,
3555
3591
  state.config.gasLimit,
3556
- state.config.gasPriceAnu,
3592
+ state.config.gasPriceBufferAnu,
3557
3593
  state.config.ttl,
3558
3594
  state.payload,
3559
3595
  state.signers.length,
@@ -3603,6 +3639,37 @@ function TxMeters({ state, sim }) {
3603
3639
  ] })
3604
3640
  ] });
3605
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
+ }
3606
3673
  var DEFAULT_BUILDER_ROBOTS = "noindex,nofollow";
3607
3674
  var TABS = [
3608
3675
  { key: "config", label: "Config" },
@@ -3717,6 +3784,7 @@ function Builder({
3717
3784
  }
3718
3785
  }, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
3719
3786
  const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
3787
+ const liveFloorAnu = useLiveGasFloor();
3720
3788
  const handlePactCodeChange = useCallback((pactCode) => {
3721
3789
  setState((s) => ({ ...s, pactCode }));
3722
3790
  }, []);
@@ -3756,7 +3824,15 @@ function Builder({
3756
3824
  },
3757
3825
  t.key
3758
3826
  )) }),
3759
- 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
+ ),
3760
3836
  activeTab === "payload" && /* @__PURE__ */ jsx(PayloadTab, { state, onChange: (payload) => setState((s) => ({ ...s, payload })) }),
3761
3837
  activeTab === "gas-payer" && /* @__PURE__ */ jsx(GasPayerTab, { state, onChange: setState, signers }),
3762
3838
  activeTab === "signatures" && /* @__PURE__ */ jsx(SignaturesTab, { state, onChange: setState, signers }),
@@ -3768,7 +3844,8 @@ function Builder({
3768
3844
  onCommit: handleCommit,
3769
3845
  committing,
3770
3846
  eventDrivenResolver,
3771
- sim
3847
+ sim,
3848
+ liveFloorAnu
3772
3849
  }
3773
3850
  )
3774
3851
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancientpantheon/khronoton-core",
3
- "version": "0.8.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",
@@ -78,9 +78,9 @@
78
78
  "@codemirror/state": "^6.5.2",
79
79
  "@codemirror/view": "^6.36.4",
80
80
  "@lezer/highlight": "^1.2.3",
81
- "@ouronet/ouronet-core": "^4.3.6",
82
- "@stoachain/kadena-stoic-legacy": "^4.3.6",
83
- "@stoachain/stoa-core": "^4.3.6",
81
+ "@ouronet/ouronet-core": "^4.6.0",
82
+ "@stoachain/kadena-stoic-legacy": "^4.4.0",
83
+ "@stoachain/stoa-core": "^4.4.0",
84
84
  "@uiw/react-codemirror": "^4.23.10",
85
85
  "react": "^18 || ^19",
86
86
  "react-dom": "^18 || ^19"
@@ -125,9 +125,9 @@
125
125
  "@codemirror/state": "^6.5.2",
126
126
  "@codemirror/view": "^6.36.4",
127
127
  "@lezer/highlight": "^1.2.3",
128
- "@ouronet/ouronet-core": "^4.3.6",
129
- "@stoachain/kadena-stoic-legacy": "^4.3.6",
130
- "@stoachain/stoa-core": "^4.3.6",
128
+ "@ouronet/ouronet-core": "^4.6.0",
129
+ "@stoachain/kadena-stoic-legacy": "^4.4.0",
130
+ "@stoachain/stoa-core": "^4.4.0",
131
131
  "@testing-library/dom": "^10.4.1",
132
132
  "@testing-library/react": "^16.3.2",
133
133
  "@types/better-sqlite3": "^7.6.13",