@ancientpantheon/khronoton-core 0.8.0 → 0.9.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,28 @@ 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.9.0 — 2026-09-07
8
+
9
+ **MINOR — scheduled transactions are priced against the chain's LIVE gas floor at fire time, not a static value stored at creation time.**
10
+
11
+ 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.
12
+
13
+ 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.
14
+
15
+ - **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.
16
+ - **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.**
17
+ - **`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.
18
+ - **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`.
19
+ - **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.
20
+ - **`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.
21
+ - **`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.
22
+
23
+ **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`.
24
+
25
+ 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.
26
+
27
+ **907 specs pass, plus 5 real-runtime integration specs against the installed `@stoachain/*@4.4.0`.**
28
+
7
29
  ## 0.8.0 — 2026-08-03
8
30
 
9
31
  **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,8 @@ Khronoton is the "When do I act?" Constructor of the Pantheon architecture — t
6
6
 
7
7
  ## Status
8
8
 
9
+ **`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
+
9
11
  **`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
12
 
11
13
  **`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 +244,8 @@ npm install @ancientpantheon/khronoton-core
242
244
 
243
245
  ## Version history
244
246
 
247
+ **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
+
245
249
  **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
250
 
247
251
  **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-CPj31tJJ.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,11 @@ async function createStoachainRuntime(config) {
17
17
  universalSignTransaction: signing.universalSignTransaction,
18
18
  calculateAutoGasLimit: gas.calculateAutoGasLimit,
19
19
  anuToStoa: gas.anuToStoa,
20
+ gasMeta: (floorAnu) => {
21
+ const { creationTime } = gas.stoaGasMeta();
22
+ const anu = Math.max(floorAnu, gas.minGasPriceAnu(creationTime));
23
+ return { creationTime, gasPrice: gas.anuToStoaNumber(anu) };
24
+ },
20
25
  getPactUrl,
21
26
  networkId,
22
27
  namespace,
@@ -226,11 +226,22 @@ 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(definition.config.gasPrice);
229
235
  builder.setMeta({
230
236
  senderAccount,
231
237
  chainId: definition.config.chainId,
232
238
  gasLimit: gasLimitOverride ?? definition.config.gasLimit,
233
- gasPrice: runtime.anuToStoa(definition.config.gasPrice),
239
+ gasPrice,
240
+ // Stamped EXPLICITLY, from the same call that produced gasPrice. Left
241
+ // unset, the Pact builder auto-stamps its own creationTime at
242
+ // createTransaction() — a second, independent clock read that the price
243
+ // above would then no longer correspond to.
244
+ creationTime,
234
245
  ttl: definition.config.ttl
235
246
  }).setNetworkId(runtime.networkId);
236
247
  for (const [key, value] of Object.entries(definition.payload)) {
@@ -1,4 +1,4 @@
1
- import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-WLZXX2SQ.js';
1
+ import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-5LYT7ZLA.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
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';
3
+ import { b as DbDep, D as Database } from './seams-CPj31tJJ.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';
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
3
  import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
4
4
  import 'react';
5
- import '../seams-DapFZ4sM.js';
5
+ import '../seams-CPj31tJJ.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-5OB5NQ4S.js';
2
+ export { useKhronoton } from '../chunk-5LYT7ZLA.js';
@@ -1,7 +1,7 @@
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';
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
5
  export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
6
6
 
7
7
  /**
@@ -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-5LYT7ZLA.js';
2
+ export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-5LYT7ZLA.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,22 @@ 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.
113
147
  */
114
148
  interface ChainRuntime {
115
149
  Pact: {
@@ -122,6 +156,7 @@ interface ChainRuntime {
122
156
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
123
157
  calculateAutoGasLimit(gas: number): number;
124
158
  anuToStoa(anu: number): number;
159
+ gasMeta?(floorAnu: number): StoaGasMeta;
125
160
  getPactUrl(chainId: string): string;
126
161
  networkId: string;
127
162
  namespace: string;
@@ -26,7 +26,13 @@ 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
+ * 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.
30
36
  */
31
37
  function buildTransaction(runtime, definition, signers, gasLimitOverride) {
32
38
  if (signers.length === 0) {
@@ -34,12 +40,30 @@ function buildTransaction(runtime, definition, signers, gasLimitOverride) {
34
40
  }
35
41
  const senderAccount = deriveSenderAccount(definition.gasPayer, runtime.gasStationAccount);
36
42
  const builder = runtime.Pact.builder.execution(definition.pactCode);
43
+ // Gas meta is derived HERE, once per build, and never hoisted out or cached
44
+ // by a caller: the AUTO-gas path calls this function a SECOND time to rebuild
45
+ // and re-sign at the calibrated limit, and that rebuild must re-derive both
46
+ // fields fresh. Reusing the pre-flight build's values would let creationTime
47
+ // and gasPrice drift apart across a tick boundary — underpricing the very
48
+ // transaction that gets submitted.
49
+ if (!runtime.gasMeta) {
50
+ throw new Error("ChainRuntime.gasMeta is required to price a transaction: without it the " +
51
+ "per-cronoton stored gasPrice would be used verbatim, which drifts below " +
52
+ "the chain's rising minimum as a cronoton ages and gets the fire rejected. " +
53
+ "Upgrade the injected runtime adapter (see blockchain/stoachain.ts).");
54
+ }
55
+ const { creationTime, gasPrice } = runtime.gasMeta(definition.config.gasPrice);
37
56
  builder
38
57
  .setMeta({
39
58
  senderAccount,
40
59
  chainId: definition.config.chainId,
41
60
  gasLimit: gasLimitOverride ?? definition.config.gasLimit,
42
- gasPrice: runtime.anuToStoa(definition.config.gasPrice),
61
+ gasPrice,
62
+ // Stamped EXPLICITLY, from the same call that produced gasPrice. Left
63
+ // unset, the Pact builder auto-stamps its own creationTime at
64
+ // createTransaction() — a second, independent clock read that the price
65
+ // above would then no longer correspond to.
66
+ creationTime,
43
67
  ttl: definition.config.ttl,
44
68
  })
45
69
  .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,22 @@ 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.
113
147
  */
114
148
  export interface ChainRuntime {
115
149
  Pact: {
@@ -122,6 +156,7 @@ export interface ChainRuntime {
122
156
  universalSignTransaction(tx: IUnsignedCommand, keypairs: UniversalKeypair[]): Promise<unknown>;
123
157
  calculateAutoGasLimit(gas: number): number;
124
158
  anuToStoa(anu: number): number;
159
+ gasMeta?(floorAnu: number): StoaGasMeta;
125
160
  getPactUrl(chainId: string): string;
126
161
  networkId: string;
127
162
  namespace: string;
package/dist/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-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-5OB5NQ4S.js';
2
+ import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-5LYT7ZLA.js';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useContext } from 'react';
5
5
 
@@ -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
+ gasPrice: (floorAnu) => `Gas price must be at least ${floorAnu} ANU (the protocol floor).`,
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
+ // 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,
1366
1369
  gasLimit: 1500,
1367
1370
  autoGasLimit: false,
1368
1371
  ttl: 600
@@ -1487,6 +1490,7 @@ function builderToCommit(state, opts) {
1487
1490
  if (runtimeArgKeys.length > 0) body.envelope.runtimeArgKeys = runtimeArgKeys;
1488
1491
  return body;
1489
1492
  }
1493
+ var GENESIS_MIN_GAS_ANU = 1e4;
1490
1494
  function validateName(state) {
1491
1495
  return state.name.trim().length === 0 ? [MSG.name] : [];
1492
1496
  }
@@ -1494,7 +1498,8 @@ function validateConfig(state, opts = {}) {
1494
1498
  const errors = [];
1495
1499
  const c = state.config;
1496
1500
  if (c.ttl < 60 || c.ttl > 86400) errors.push(MSG.ttl);
1497
- if (c.gasPriceAnu < 1e4) errors.push(MSG.gasPrice);
1501
+ const minGasAnu = opts.minGasPriceAnu ?? GENESIS_MIN_GAS_ANU;
1502
+ if (c.gasPriceAnu < minGasAnu) errors.push(MSG.gasPrice(minGasAnu));
1498
1503
  if (c.gasLimit <= 0) errors.push(MSG.gasLimit);
1499
1504
  const autoGasWaived = Boolean(state.serverResolver) || isTriggerOnly2(state);
1500
1505
  if (c.autoGasLimit && !opts.simulateCalibrated && !autoGasWaived) errors.push(MSG.autoGas);
@@ -3477,13 +3482,17 @@ async function estimateTxSize(state) {
3477
3482
  let bytes;
3478
3483
  try {
3479
3484
  const { Pact } = await import('@stoachain/kadena-stoic-legacy/client');
3480
- const { anuToStoa } = await import('@stoachain/stoa-core/gas');
3485
+ const { anuToStoaNumber } = await import('@stoachain/stoa-core/gas');
3481
3486
  const { KADENA_NETWORK } = await import('@stoachain/stoa-core/constants');
3482
3487
  const builder = Pact.builder.execution(pactCode || "").setMeta({
3483
3488
  senderAccount: state.gasPayer.type === "codex" ? state.gasPayer.address ?? "" : "c:gas-station",
3484
3489
  chainId: config.chainId,
3485
3490
  gasLimit: config.gasLimit,
3486
- gasPrice: anuToStoa(config.gasPrice),
3491
+ // `anuToStoaNumber`, not `anuToStoa`: this meter exists to predict the
3492
+ // 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),
3487
3496
  ttl: config.ttl
3488
3497
  }).setNetworkId(KADENA_NETWORK);
3489
3498
  for (const [k, v] of Object.entries(payload ?? {})) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancientpantheon/khronoton-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.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",