@ancientpantheon/khronoton-core 0.10.0 → 0.11.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 +12 -0
- package/README.md +4 -0
- package/dist/blockchain/stoachain.d.ts +1 -22
- package/dist/blockchain/stoachain.js +41 -1
- package/dist/{chunk-KDCNWWWQ.js → chunk-GNQ2IVXA.js} +46 -9
- package/dist/{chunk-UP3SYP2U.js → chunk-LX6T2BDL.js} +1 -1
- package/dist/{context-CMk8bLsF.d.ts → context-89YS4xT3.d.ts} +1 -1
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +2 -2
- package/dist/provider/index.d.ts +3 -3
- package/dist/provider/index.js +2 -2
- package/dist/{seams-BL_ntGK_.d.ts → seams-DUtxDw_U.d.ts} +20 -0
- package/dist/server/executor.d.ts +28 -8
- package/dist/server/executor.js +99 -15
- package/dist/server/seams.d.ts +20 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +149 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ 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.11.0 — 2026-09-17
|
|
8
|
+
|
|
9
|
+
**MINOR — a discoverable edit-mode Save affordance, and auto self-calibrating gas as the default for every new cronoton.**
|
|
10
|
+
|
|
11
|
+
Two independent handoffs, built and shipped together. **(1) Editor Save.** Editing an existing cronoton had no discoverable Save — the only save action was the "Commit Codex Cronoton" button on the last (Execute) tab, silently disabled under AUTO gas until a Simulate ran, with no explanation visible from any other tab. Adds an always-visible edit-mode **`SaveBar`** — Simulate, Save changes, and a live status line — rendered above the Pact editor/tabs on every tab, gated on the edited row having actually loaded (`editReady`) so it can never fire a Simulate against a blank default state during the load window. The Execute tab's own Commit button is now edit-aware ("Save changes" / "Saving…"); create mode is unaffected. A new shared `useCommitGate(state, sim)` hook (called once in `Builder.tsx`, threaded as props) keeps `SaveBar` and `ExecuteTab` reading the identical commit body and gate — no risk of two independent `builderToCommit`/`canCommit` call sites drifting apart, and no duplicate computation on every keystroke. `SaveBar`'s Save AND Simulate buttons are both `canMutate(access)`-gated in their click handlers, not just their `disabled` attribute.
|
|
12
|
+
|
|
13
|
+
**(2) Auto self-calibrating gas.** Khronoton transactions defaulted to a fixed, manually-set gas limit, so fires over-reserved gas wildly (a real pool-payout fire measured 594 gas used against a 600,000 limit). `makeEmptyBuilderState()` now defaults `autoGasLimit` to `true`. `ChainClient` gains two new optional methods: `preflightRead` (the SDK's `local` with `{preflight:true, signatureVerification:false}` — accurate gas including the transaction-size charge that plain `dirtyRead` omits) and `getBlockGasLimit` (a live `/config` fetch, best-effort with the existing static fallback). AUTO-gas fires now calibrate from `preflightRead` instead of `dirtyRead`; a runtime missing it hard-throws on an AUTO-gas fire (mirroring the 0.9.0 `gasMeta` precedent) while a MANUAL-gas fire on the same runtime is completely unaffected. A new refuse-unmineable check returns a structured failure — never a silent cap or submit — when measured gas exceeds the resolved ceiling, for both AUTO and MANUAL fires. The ceiling itself is validated (`Number.isFinite && > 0`) before use, so a buggy adapter returning `NaN`/`0`/negative can never silently defeat the refuse check.
|
|
14
|
+
|
|
15
|
+
Reviewed via nectar (2 rounds, 5 lenses then a targeted 2-lens re-pass, adversarial validation throughout): 9 CONFIRMED findings fixed — two initially-HIGH findings (SaveBar's pre-load readiness gap; its unguarded Simulate click) were validated down to MEDIUM once the actual blast radius was traced (Save itself stayed correctly disabled; the server has its own independent auth gate); the rest were MEDIUM/LOW test-coverage, duplication, and stale-doc gaps. Zero REFUTED, zero STYLISTIC. Full history in `docs/work/khronoton-editor-save-and-auto-gas/review.md`.
|
|
16
|
+
|
|
17
|
+
**980 specs pass.**
|
|
18
|
+
|
|
7
19
|
## 0.10.0 — 2026-09-08
|
|
8
20
|
|
|
9
21
|
**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.**
|
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.11.0` on public npmjs** — **MINOR.** Released 2026-09-17. Two independent handoffs, shipped together. **Editor Save:** an always-visible edit-mode `SaveBar` (Simulate + Save changes + live status) now renders on every tab, gated on the edited row having actually loaded so it can never fire a Simulate against a blank default state; the Execute tab's own Commit button is edit-aware ("Save changes"); a new shared `useCommitGate(state, sim)` hook keeps both surfaces reading the identical commit body and gate, computed once. **Auto self-calibrating gas:** `autoGasLimit` now defaults to `true` for new cronotons; `ChainClient` gains optional `preflightRead` (accurate gas via the SDK's preflight mode, replacing `dirtyRead`'s execution-only measurement for AUTO fires) and `getBlockGasLimit` (a live block-ceiling fetch with a static fallback); a transaction whose measured gas exceeds the resolved ceiling is now refused with a structured error — never silently capped or submitted — for both AUTO and MANUAL fires, with the ceiling itself validated against `NaN`/non-finite/non-positive values before use. **980 specs pass.**
|
|
10
|
+
|
|
9
11
|
**`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
12
|
|
|
11
13
|
**`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).
|
|
@@ -246,6 +248,8 @@ npm install @ancientpantheon/khronoton-core
|
|
|
246
248
|
|
|
247
249
|
## Version history
|
|
248
250
|
|
|
251
|
+
**v0.11.0** — Discoverable edit-mode Save + auto self-calibrating gas. Two independent handoffs built and shipped together. **Editor Save.** Editing an existing cronoton had no discoverable Save — the only action was the "Commit Codex Cronoton" button on the last (Execute) tab, silently disabled under AUTO gas until a Simulate ran, with the reason invisible from any other tab. Adds an always-visible edit-mode `SaveBar` (`ui/builder/SaveBar.tsx`) — Simulate, Save changes, and a live status line — rendered above the Pact editor/tabs on every tab, gated on `Builder.tsx`'s `editReady` (the edited row having actually finished loading) so it can never fire a Simulate against the blank default `makeEmptyBuilderState()` during the load window. The Execute tab's own Commit button is now edit-aware ("Save changes" / "Saving…"); create mode is byte-identical to before. A new shared `useCommitGate(state, sim)` hook (`ui/builder/use-commit-gate.ts`), extracted from `ExecuteTab.tsx`'s own prior inline logic, is called ONCE in `Builder.tsx` and threaded as `commit`/`gate` props to both `SaveBar` and `ExecuteTab` — no risk of two independent `builderToCommit`/`canCommit` call sites drifting apart, and no duplicate computation on every keystroke when both are mounted. Both of `SaveBar`'s buttons are `canMutate(access)`-gated in their CLICK HANDLERS, not just their `disabled` attribute (a directly-dispatched click event still reaches a React handler regardless of the DOM disabled state). **Auto self-calibrating gas.** Khronoton transactions defaulted to a fixed, manually-set gas limit, so fires over-reserved gas wildly — a real pool-payout fire measured 594 gas used against a 600,000 limit. `makeEmptyBuilderState()`'s `config.autoGasLimit` now defaults to `true`. `ChainClient` (`server/seams.ts`) gains two new optional methods: `preflightRead` — implemented in `blockchain/stoachain.ts` via the SDK's raw `local(tx, {preflight:true, signatureVerification:false})`, NOT its `.preflight` convenience alias (which also forces `signatureVerification:true`) — measures the TRUE gas including the transaction-size charge that plain `dirtyRead` omits; `getBlockGasLimit` does a best-effort `/config` fetch (mirroring OuronetUI's `gas-limits.ts`, ported without its browser-oriented module-level mutable-singleton cache — this package fetches fresh per fire instead, since a Node server core handling concurrent fires can't safely share that kind of global state) falling back to the existing static `AUTO_GAS_CEILING` on any failure. `executor.ts`'s `runSimulate`/`runFire` were reordered so the `ChainClient` is constructed BEFORE ceiling resolution (ceiling resolution needs it) — a real sequencing fix, not just an addition. AUTO-gas fires now calibrate from `preflightRead`; a runtime missing it hard-throws on an AUTO-gas fire only (mirroring the 0.9.0 `gasMeta` precedent — silent fallback would ship the exact over-reservation bug this exists to fix), while a MANUAL-gas fire on the same un-upgraded runtime is completely unaffected. A new refuse-unmineable check returns a structured `{ok:false, error}` — never a silent cap, never a submit — when measured gas exceeds the resolved ceiling, for BOTH AUTO and MANUAL fires. The ceiling itself (from either the live fetch or an explicit `Config.autoGasCeiling` override) is validated via a new `isSaneCeiling` check (`Number.isFinite && > 0`) before use — `NaN` in particular would otherwise silently defeat the refuse check entirely, since every `gasUsed > NaN` comparison is `false` in JS. Reviewed via nectar (2 rounds, 5 lenses then a targeted 2-lens re-pass, adversarial validation throughout): 9 CONFIRMED findings fixed, including two initially-HIGH findings (the `SaveBar` pre-load readiness gap; its originally-unguarded Simulate click) validated down to MEDIUM once the actual blast radius was traced against the code (Save itself stayed correctly disabled during the load window; the server independently re-authorizes via its own `withConfirm`/`auth.requireConfirm` gate regardless of what the UI allows). Full history in `docs/work/khronoton-editor-save-and-auto-gas/review.md`. Released 2026-09-17. **980 specs pass.**
|
|
252
|
+
|
|
249
253
|
**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
254
|
|
|
251
255
|
**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).
|
|
@@ -1,26 +1,5 @@
|
|
|
1
|
-
import { C as ChainRuntime } from '../seams-
|
|
1
|
+
import { C as ChainRuntime } from '../seams-DUtxDw_U.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* `@ancientpantheon/khronoton-core/blockchain/stoachain` — the StoaChain edge.
|
|
5
|
-
*
|
|
6
|
-
* khronoton is chain-POLYGLOT, not chain-agnostic: the root `.` schedule engine
|
|
7
|
-
* and the `/server` tick/store engine orchestrate, and each `/blockchain/<chain>`
|
|
8
|
-
* subpath teaches them to speak one chain's language. This one wraps the
|
|
9
|
-
* `@stoachain/*` runtime into the core {@link ChainRuntime} seam so a StoaChain
|
|
10
|
-
* automaton injects one object instead of reaching for `@stoachain/*` directly.
|
|
11
|
-
*
|
|
12
|
-
* The `@stoachain/*` packages are OPTIONAL PEER DEPENDENCIES: importing this
|
|
13
|
-
* subpath costs nothing (the SDK imports are lazy, inside the factory), so a
|
|
14
|
-
* consumer who never talks StoaChain never installs them. Only calling
|
|
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.
|
|
23
|
-
*/
|
|
24
3
|
/**
|
|
25
4
|
* Consumer-facing knobs for {@link createStoachainRuntime}. Every field is
|
|
26
5
|
* optional; an omitted field falls back to the corresponding `@stoachain/*`
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
// src/blockchain/stoachain.ts
|
|
2
|
+
var AUTO_GAS_CEILING_FALLBACK = 2e6;
|
|
3
|
+
function findBlockGasLimit(obj, depth = 0) {
|
|
4
|
+
if (depth > 8 || obj == null || typeof obj !== "object") return null;
|
|
5
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
6
|
+
if (typeof v === "number" && /block.?gas.?limit|gas.?limit.?of.?block/i.test(k) && v >= 5e4 && v <= 5e7) {
|
|
7
|
+
return Math.floor(v);
|
|
8
|
+
}
|
|
9
|
+
if (v && typeof v === "object") {
|
|
10
|
+
const found = findBlockGasLimit(v, depth + 1);
|
|
11
|
+
if (found) return found;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
2
16
|
async function createStoachainRuntime(config) {
|
|
3
17
|
const client = await import('@stoachain/kadena-stoic-legacy/client');
|
|
4
18
|
const signing = await import('@stoachain/stoa-core/signing');
|
|
@@ -12,7 +26,33 @@ async function createStoachainRuntime(config) {
|
|
|
12
26
|
const getPactUrl = nodeBaseUrl ? (chainId) => `${nodeBaseUrl}/chainweb/0.0/${networkId}/chain/${chainId}/pact` : constants.getPactUrl;
|
|
13
27
|
return {
|
|
14
28
|
Pact: client.Pact,
|
|
15
|
-
|
|
29
|
+
// The SDK client is no longer returned by identity: it's wrapped so the
|
|
30
|
+
// two new optional ChainClient capabilities (preflightRead,
|
|
31
|
+
// getBlockGasLimit) ride alongside the real dirtyRead/submit/listen,
|
|
32
|
+
// which stay byte-identical pass-throughs.
|
|
33
|
+
createClient: ((url) => {
|
|
34
|
+
const real = client.createClient(url);
|
|
35
|
+
return {
|
|
36
|
+
...real,
|
|
37
|
+
preflightRead: (tx) => real.local(tx, {
|
|
38
|
+
preflight: true,
|
|
39
|
+
signatureVerification: false
|
|
40
|
+
}),
|
|
41
|
+
getBlockGasLimit: async () => {
|
|
42
|
+
try {
|
|
43
|
+
const origin = url.replace(/\/chainweb\/.*$/, "");
|
|
44
|
+
const res = await fetch(`${origin}/config`, {
|
|
45
|
+
headers: { accept: "application/json" }
|
|
46
|
+
});
|
|
47
|
+
if (!res.ok) return AUTO_GAS_CEILING_FALLBACK;
|
|
48
|
+
const found = findBlockGasLimit(await res.json());
|
|
49
|
+
return found ?? AUTO_GAS_CEILING_FALLBACK;
|
|
50
|
+
} catch {
|
|
51
|
+
return AUTO_GAS_CEILING_FALLBACK;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}),
|
|
16
56
|
isSignedTransaction: client.isSignedTransaction,
|
|
17
57
|
universalSignTransaction: signing.universalSignTransaction,
|
|
18
58
|
calculateAutoGasLimit: gas.calculateAutoGasLimit,
|
|
@@ -213,6 +213,14 @@ function effectiveSigners(definition, kadenaNamespace) {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
// src/server/executor.ts
|
|
216
|
+
function isSaneCeiling(v) {
|
|
217
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
218
|
+
}
|
|
219
|
+
async function resolveCeiling(ctx, client) {
|
|
220
|
+
if (isSaneCeiling(ctx.config?.autoGasCeiling)) return ctx.config.autoGasCeiling;
|
|
221
|
+
const live = await client.getBlockGasLimit?.();
|
|
222
|
+
return isSaneCeiling(live) ? live : AUTO_GAS_CEILING;
|
|
223
|
+
}
|
|
216
224
|
function buildTransaction(runtime, definition, signers, gasLimitOverride) {
|
|
217
225
|
if (signers.length === 0) {
|
|
218
226
|
throw new Error(
|
|
@@ -313,8 +321,9 @@ async function listenWithTimeout(listen, descriptor, timeoutMs) {
|
|
|
313
321
|
}
|
|
314
322
|
async function runSimulate(ctx, definition, signers) {
|
|
315
323
|
const { runtime, resolver } = ctx;
|
|
316
|
-
const ceiling = ctx.config?.autoGasCeiling ?? AUTO_GAS_CEILING;
|
|
317
324
|
const { autoGasLimit } = definition.config;
|
|
325
|
+
const client = runtime.createClient(runtime.getPactUrl(definition.config.chainId));
|
|
326
|
+
const ceiling = await resolveCeiling(ctx, client);
|
|
318
327
|
const tx = buildTransaction(
|
|
319
328
|
runtime,
|
|
320
329
|
definition,
|
|
@@ -322,10 +331,12 @@ async function runSimulate(ctx, definition, signers) {
|
|
|
322
331
|
autoGasLimit ? ceiling : void 0
|
|
323
332
|
);
|
|
324
333
|
const signed = await signTransaction(runtime, resolver, signers, tx);
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
334
|
+
if (autoGasLimit && !client.preflightRead) {
|
|
335
|
+
throw new Error(
|
|
336
|
+
"ChainRuntime.preflightRead is required to auto-size gas for an AUTO-gas transaction: without it the calibration would use dirtyRead's execution-only gas figure, which omits the transaction-size charge and reproduces the exact over-reservation bug this capability exists to fix. Upgrade the injected runtime adapter (see blockchain/stoachain.ts), or switch this cronoton to manual gas."
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
const simulation = autoGasLimit ? await client.preflightRead(signed) : await client.dirtyRead(signed);
|
|
329
340
|
if (simulation.result.status === "failure") {
|
|
330
341
|
return {
|
|
331
342
|
ok: false,
|
|
@@ -336,6 +347,16 @@ async function runSimulate(ctx, definition, signers) {
|
|
|
336
347
|
};
|
|
337
348
|
}
|
|
338
349
|
const gasUsed = simulation.gas || 0;
|
|
350
|
+
if (gasUsed > ceiling) {
|
|
351
|
+
return {
|
|
352
|
+
ok: false,
|
|
353
|
+
mode: "simulate",
|
|
354
|
+
gasUsed,
|
|
355
|
+
error: `Transaction needs ${gasUsed} gas, over the block limit of ${ceiling} \u2014 no gas setting can mine it. Reduce the transaction's size or complexity.`,
|
|
356
|
+
rawResult: simulation.result,
|
|
357
|
+
terminalIntent: null
|
|
358
|
+
};
|
|
359
|
+
}
|
|
339
360
|
const calibratedGasLimit = autoGasLimit && gasUsed > 0 ? runtime.calculateAutoGasLimit(gasUsed) : void 0;
|
|
340
361
|
return {
|
|
341
362
|
ok: true,
|
|
@@ -348,10 +369,10 @@ async function runSimulate(ctx, definition, signers) {
|
|
|
348
369
|
}
|
|
349
370
|
async function runFire(ctx, definition, signers) {
|
|
350
371
|
const { runtime, resolver } = ctx;
|
|
351
|
-
const ceiling = ctx.config?.autoGasCeiling ?? AUTO_GAS_CEILING;
|
|
352
372
|
const listenMs = ctx.config?.listenTimeoutMs ?? LISTEN_TIMEOUT_MS;
|
|
353
373
|
const { chainId, autoGasLimit } = definition.config;
|
|
354
374
|
const client = runtime.createClient(runtime.getPactUrl(chainId));
|
|
375
|
+
const ceiling = await resolveCeiling(ctx, client);
|
|
355
376
|
let tx = buildTransaction(
|
|
356
377
|
runtime,
|
|
357
378
|
definition,
|
|
@@ -359,7 +380,12 @@ async function runFire(ctx, definition, signers) {
|
|
|
359
380
|
autoGasLimit ? ceiling : void 0
|
|
360
381
|
);
|
|
361
382
|
let signed = await signTransaction(runtime, resolver, signers, tx);
|
|
362
|
-
|
|
383
|
+
if (autoGasLimit && !client.preflightRead) {
|
|
384
|
+
throw new Error(
|
|
385
|
+
"ChainRuntime.preflightRead is required to auto-size gas for an AUTO-gas transaction: without it the calibration would use dirtyRead's execution-only gas figure, which omits the transaction-size charge and reproduces the exact over-reservation bug this capability exists to fix. Upgrade the injected runtime adapter (see blockchain/stoachain.ts), or switch this cronoton to manual gas."
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
const preflight = autoGasLimit ? await client.preflightRead(signed) : await client.dirtyRead(signed);
|
|
363
389
|
if (preflight.result.status === "failure") {
|
|
364
390
|
return {
|
|
365
391
|
ok: false,
|
|
@@ -370,8 +396,19 @@ async function runFire(ctx, definition, signers) {
|
|
|
370
396
|
terminalIntent: computeTerminalIntent(definition.scheduleKind, "fire", false)
|
|
371
397
|
};
|
|
372
398
|
}
|
|
373
|
-
|
|
374
|
-
|
|
399
|
+
const gasUsed = preflight.gas || 0;
|
|
400
|
+
if (gasUsed > ceiling) {
|
|
401
|
+
return {
|
|
402
|
+
ok: false,
|
|
403
|
+
mode: "fire",
|
|
404
|
+
chainId,
|
|
405
|
+
error: `Transaction needs ${gasUsed} gas, over the block limit of ${ceiling} \u2014 no gas setting can mine it. Reduce the transaction's size or complexity.`,
|
|
406
|
+
rawResult: preflight.result,
|
|
407
|
+
terminalIntent: computeTerminalIntent(definition.scheduleKind, "fire", false)
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (autoGasLimit && gasUsed > 0) {
|
|
411
|
+
const calibrated = runtime.calculateAutoGasLimit(gasUsed);
|
|
375
412
|
tx = buildTransaction(runtime, definition, signers, calibrated);
|
|
376
413
|
signed = await signTransaction(runtime, resolver, signers, tx);
|
|
377
414
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-
|
|
1
|
+
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-GNQ2IVXA.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-DnFB1Yz-.js';
|
|
3
|
-
import { b as DbDep, D as Database } from './seams-
|
|
3
|
+
import { b as DbDep, D as Database } from './seams-DUtxDw_U.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>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -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-
|
|
2
|
-
export { U as UseKhronotonResult, u as useKhronoton } from '../context-
|
|
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-89YS4xT3.js';
|
|
2
|
+
export { U as UseKhronotonResult, u as useKhronoton } from '../context-89YS4xT3.js';
|
|
3
3
|
import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-DnFB1Yz-.js';
|
|
4
4
|
import 'react';
|
|
5
|
-
import '../seams-
|
|
5
|
+
import '../seams-DUtxDw_U.js';
|
|
6
6
|
|
|
7
7
|
/** The `useCronotons()` return shape — the list, its load state, and a refetch. */
|
|
8
8
|
interface UseCronotonsView {
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useServerResolvers, useSimulate, useStartBatch, useTrigger } from '../chunk-
|
|
2
|
-
export { useKhronoton } from '../chunk-
|
|
1
|
+
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useServerResolvers, useSimulate, useStartBatch, useTrigger } from '../chunk-LX6T2BDL.js';
|
|
2
|
+
export { useKhronoton } from '../chunk-GNQ2IVXA.js';
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
4
|
-
import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-
|
|
2
|
+
import { H as HandlerRequest, i as HandlerResponse, K as KhronotonProviderProps, j as KhronotonAdapter, k as SignerSource } from '../context-89YS4xT3.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-89YS4xT3.js';
|
|
4
|
+
import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-DUtxDw_U.js';
|
|
5
5
|
export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-DnFB1Yz-.js';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/provider/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, listServerResolvers, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-
|
|
2
|
-
export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-
|
|
1
|
+
import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, listServerResolvers, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-GNQ2IVXA.js';
|
|
2
|
+
export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-GNQ2IVXA.js';
|
|
3
3
|
import { useRef, useState, useEffect } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -97,6 +97,26 @@ interface ListenResult {
|
|
|
97
97
|
/** A network client bound to a single Pact endpoint URL. */
|
|
98
98
|
interface ChainClient {
|
|
99
99
|
dirtyRead(tx: unknown): Promise<DirtyReadResult>;
|
|
100
|
+
/**
|
|
101
|
+
* `local` with `{ preflight: true, signatureVerification: false }` — measures
|
|
102
|
+
* the TRUE gas a transaction will consume, including the transaction-size
|
|
103
|
+
* charge that a plain `dirtyRead` (execution gas only) omits. Optional so the
|
|
104
|
+
* package stays non-breaking for any custom `ChainClient`; the executor HARD
|
|
105
|
+
* THROWS when it's absent on an AUTO-gas fire — a silent fallback to the
|
|
106
|
+
* inaccurate `dirtyRead` measurement would ship the exact over-reservation bug
|
|
107
|
+
* this capability exists to fix (mirrors `ChainRuntime.gasMeta`'s precedent).
|
|
108
|
+
* A MANUAL-gas fire never needs this and is unaffected by its absence.
|
|
109
|
+
*/
|
|
110
|
+
preflightRead?(tx: unknown): Promise<DirtyReadResult>;
|
|
111
|
+
/**
|
|
112
|
+
* The live block gas limit, read from the node. Optional and BEST-EFFORT —
|
|
113
|
+
* unlike `preflightRead`, a stale/failed read here only degrades the
|
|
114
|
+
* simulate-at-ceiling sizing and the refuse-unmineable threshold, since the
|
|
115
|
+
* real chainweb node is still the authoritative validator of what actually
|
|
116
|
+
* fits; the executor falls back to `Config.autoGasCeiling`/`AUTO_GAS_CEILING`
|
|
117
|
+
* on any failure or absence, matching OuronetUI's own documented choice here.
|
|
118
|
+
*/
|
|
119
|
+
getBlockGasLimit?(): Promise<number>;
|
|
100
120
|
submit(tx: unknown): Promise<{
|
|
101
121
|
requestKey: string;
|
|
102
122
|
}>;
|
|
@@ -13,10 +13,26 @@
|
|
|
13
13
|
* - fire NEVER throws (F-002) — every failure returns a structured result;
|
|
14
14
|
* - the dirty-read pre-flight gate (F-001) — a failing pre-flight never submits;
|
|
15
15
|
* - AUTO-gas calibrate — build at the ceiling, rebuild + re-sign at the
|
|
16
|
-
*
|
|
16
|
+
* preflight-derived limit;
|
|
17
17
|
* - the 504/derived-request-key recovery (REQ-23) — the request key is derived
|
|
18
18
|
* from the signed command hash UP FRONT so a lost submit response or a listen
|
|
19
19
|
* timeout never discards a tx that may already be on-chain.
|
|
20
|
+
*
|
|
21
|
+
* Auto self-calibrating gas (khronoton-auto-gas) adds three more:
|
|
22
|
+
* - AUTO-gas calibration sources its measurement from `ChainClient.preflightRead`
|
|
23
|
+
* (the TRUE gas, including the transaction-size charge) instead of the plain
|
|
24
|
+
* `dirtyRead` (execution gas only) — the executor HARD THROWS when
|
|
25
|
+
* `autoGasLimit` is true and `preflightRead` is absent from the injected
|
|
26
|
+
* runtime, mirroring the `gasMeta` hard-throw precedent above. A MANUAL-gas
|
|
27
|
+
* fire never needs this and stays on `dirtyRead`, unaffected by its absence;
|
|
28
|
+
* - the simulate/fire ceiling is resolved live via `resolveCeiling`: an
|
|
29
|
+
* explicit `config.autoGasCeiling` override wins outright, else a
|
|
30
|
+
* best-effort `client.getBlockGasLimit()` read, else the static
|
|
31
|
+
* `AUTO_GAS_CEILING` fallback;
|
|
32
|
+
* - refuse-unmineable — a transaction whose measured gas exceeds the resolved
|
|
33
|
+
* ceiling is refused with a structured `{ ok: false, error }` (never a
|
|
34
|
+
* throw, matching F-002) BEFORE any calibration/rebuild or submit, for both
|
|
35
|
+
* AUTO and MANUAL fires.
|
|
20
36
|
*/
|
|
21
37
|
import type { ChainRuntime, KeyResolver, Config } from "./seams.js";
|
|
22
38
|
import type { CodexTxDefinition, FireResult, SimulateResult } from "./types.js";
|
|
@@ -35,19 +51,23 @@ export interface ExecutorCtx {
|
|
|
35
51
|
config?: Partial<Config>;
|
|
36
52
|
}
|
|
37
53
|
/**
|
|
38
|
-
* Execute a codex transaction in `simulate` (sign +
|
|
39
|
-
* `fire` (pre-flight
|
|
40
|
-
* {@link ExecutorCtx}.
|
|
54
|
+
* Execute a codex transaction in `simulate` (sign + pre-submit read, NO
|
|
55
|
+
* submit) or `fire` (pre-flight read → submit → listen) mode against the
|
|
56
|
+
* injected {@link ExecutorCtx}. That pre-submit/pre-flight read is
|
|
57
|
+
* `ChainClient.preflightRead` for an AUTO-gas transaction (accurate gas,
|
|
58
|
+
* including the transaction-size charge) and plain `ChainClient.dirtyRead`
|
|
59
|
+
* for a MANUAL-gas one (see the module doc above for why) — both modes
|
|
60
|
+
* inherit whichever the definition's `autoGasLimit` selects.
|
|
41
61
|
*
|
|
42
62
|
* `fire` mode NEVER throws on chain/sign/decrypt failure (F-002): every failure
|
|
43
|
-
* mode —
|
|
44
|
-
* and resolver/decrypt rejection — returns a structured
|
|
63
|
+
* mode — pre-flight-read failure, sign-incompletion, submit error, listen
|
|
64
|
+
* timeout, and resolver/decrypt rejection — returns a structured
|
|
45
65
|
* `{ ok: false, error, terminalIntent }`. A one-time entry whose fire threw
|
|
46
66
|
* would otherwise get no terminalIntent and re-fire on the next tick.
|
|
47
67
|
*
|
|
48
68
|
* `simulate` mode surfaces build errors (zero signers, gas-station with no
|
|
49
|
-
* signing key) as throws to the caller, but converts chain-side
|
|
50
|
-
* failures into structured results.
|
|
69
|
+
* signing key) as throws to the caller, but converts chain-side pre-submit-
|
|
70
|
+
* read failures into structured results.
|
|
51
71
|
*/
|
|
52
72
|
export declare function executeCodexTransaction(definition: CodexTxDefinition, mode: "simulate", ctx: ExecutorCtx): Promise<SimulateResult>;
|
|
53
73
|
export declare function executeCodexTransaction(definition: CodexTxDefinition, mode: "fire", ctx: ExecutorCtx): Promise<FireResult>;
|
package/dist/server/executor.js
CHANGED
|
@@ -13,16 +13,57 @@
|
|
|
13
13
|
* - fire NEVER throws (F-002) — every failure returns a structured result;
|
|
14
14
|
* - the dirty-read pre-flight gate (F-001) — a failing pre-flight never submits;
|
|
15
15
|
* - AUTO-gas calibrate — build at the ceiling, rebuild + re-sign at the
|
|
16
|
-
*
|
|
16
|
+
* preflight-derived limit;
|
|
17
17
|
* - the 504/derived-request-key recovery (REQ-23) — the request key is derived
|
|
18
18
|
* from the signed command hash UP FRONT so a lost submit response or a listen
|
|
19
19
|
* timeout never discards a tx that may already be on-chain.
|
|
20
|
+
*
|
|
21
|
+
* Auto self-calibrating gas (khronoton-auto-gas) adds three more:
|
|
22
|
+
* - AUTO-gas calibration sources its measurement from `ChainClient.preflightRead`
|
|
23
|
+
* (the TRUE gas, including the transaction-size charge) instead of the plain
|
|
24
|
+
* `dirtyRead` (execution gas only) — the executor HARD THROWS when
|
|
25
|
+
* `autoGasLimit` is true and `preflightRead` is absent from the injected
|
|
26
|
+
* runtime, mirroring the `gasMeta` hard-throw precedent above. A MANUAL-gas
|
|
27
|
+
* fire never needs this and stays on `dirtyRead`, unaffected by its absence;
|
|
28
|
+
* - the simulate/fire ceiling is resolved live via `resolveCeiling`: an
|
|
29
|
+
* explicit `config.autoGasCeiling` override wins outright, else a
|
|
30
|
+
* best-effort `client.getBlockGasLimit()` read, else the static
|
|
31
|
+
* `AUTO_GAS_CEILING` fallback;
|
|
32
|
+
* - refuse-unmineable — a transaction whose measured gas exceeds the resolved
|
|
33
|
+
* ceiling is refused with a structured `{ ok: false, error }` (never a
|
|
34
|
+
* throw, matching F-002) BEFORE any calibration/rebuild or submit, for both
|
|
35
|
+
* AUTO and MANUAL fires.
|
|
20
36
|
*/
|
|
21
37
|
import { LISTEN_TIMEOUT_MS, AUTO_GAS_CEILING } from "./seams.js";
|
|
22
38
|
import { parseCapabilityLine, computeTerminalIntent } from "./pure/capability.js";
|
|
23
39
|
import { effectiveSigners, deriveSenderAccount } from "./executor-signers.js";
|
|
24
40
|
/** Listen (confirmation) timeout default: 5 minutes. Overridable via `ctx.config.listenTimeoutMs`. */
|
|
25
41
|
export { LISTEN_TIMEOUT_MS } from "./seams.js";
|
|
42
|
+
/** A ceiling value is only trusted if it's a genuine positive number — `NaN`
|
|
43
|
+
* passes `typeof === "number"` but every `gasUsed > ceiling` comparison
|
|
44
|
+
* against it is `false`, which would silently defeat the refuse-unmineable
|
|
45
|
+
* check below rather than falling back as documented. Applied uniformly to
|
|
46
|
+
* BOTH the config override and the live-fetched value: `ChainClient` is an
|
|
47
|
+
* injectable, chain-polyglot seam (per `seams.ts`'s own "BEST-EFFORT" doc on
|
|
48
|
+
* `getBlockGasLimit`), so the executor must not trust an adapter — any
|
|
49
|
+
* adapter, not just the one shipped in `blockchain/stoachain.ts` — to hand
|
|
50
|
+
* back a sane number unchecked. */
|
|
51
|
+
function isSaneCeiling(v) {
|
|
52
|
+
return typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
53
|
+
}
|
|
54
|
+
/** Resolves the effective simulate/fire ceiling: an explicit config override
|
|
55
|
+
* wins outright (no network call); else a best-effort live fetch off the
|
|
56
|
+
* ALREADY-CONSTRUCTED client for this fire's own chain; else the static
|
|
57
|
+
* fallback. Never throws — `getBlockGasLimit` failures are absorbed by the
|
|
58
|
+
* adapter itself (see `blockchain/stoachain.ts`), and an out-of-range value
|
|
59
|
+
* from EITHER source falls back to `AUTO_GAS_CEILING` rather than being
|
|
60
|
+
* trusted verbatim. */
|
|
61
|
+
async function resolveCeiling(ctx, client) {
|
|
62
|
+
if (isSaneCeiling(ctx.config?.autoGasCeiling))
|
|
63
|
+
return ctx.config.autoGasCeiling;
|
|
64
|
+
const live = await client.getBlockGasLimit?.();
|
|
65
|
+
return isSaneCeiling(live) ? live : AUTO_GAS_CEILING;
|
|
66
|
+
}
|
|
26
67
|
/**
|
|
27
68
|
* Build a Pact transaction from the definition:
|
|
28
69
|
* `Pact.builder.execution().setMeta().setNetworkId()` + an `addData` loop over
|
|
@@ -140,12 +181,22 @@ async function listenWithTimeout(listen, descriptor, timeoutMs) {
|
|
|
140
181
|
}
|
|
141
182
|
async function runSimulate(ctx, definition, signers) {
|
|
142
183
|
const { runtime, resolver } = ctx;
|
|
143
|
-
const ceiling = ctx.config?.autoGasCeiling ?? AUTO_GAS_CEILING;
|
|
144
184
|
const { autoGasLimit } = definition.config;
|
|
185
|
+
const client = runtime.createClient(runtime.getPactUrl(definition.config.chainId));
|
|
186
|
+
const ceiling = await resolveCeiling(ctx, client);
|
|
145
187
|
const tx = buildTransaction(runtime, definition, signers, autoGasLimit ? ceiling : undefined);
|
|
146
188
|
const signed = await signTransaction(runtime, resolver, signers, tx);
|
|
147
|
-
|
|
148
|
-
|
|
189
|
+
if (autoGasLimit && !client.preflightRead) {
|
|
190
|
+
throw new Error("ChainRuntime.preflightRead is required to auto-size gas for an AUTO-gas " +
|
|
191
|
+
"transaction: without it the calibration would use dirtyRead's execution-" +
|
|
192
|
+
"only gas figure, which omits the transaction-size charge and reproduces " +
|
|
193
|
+
"the exact over-reservation bug this capability exists to fix. Upgrade the " +
|
|
194
|
+
"injected runtime adapter (see blockchain/stoachain.ts), or switch this " +
|
|
195
|
+
"cronoton to manual gas.");
|
|
196
|
+
}
|
|
197
|
+
const simulation = autoGasLimit
|
|
198
|
+
? await client.preflightRead(signed)
|
|
199
|
+
: await client.dirtyRead(signed);
|
|
149
200
|
if (simulation.result.status === "failure") {
|
|
150
201
|
return {
|
|
151
202
|
ok: false,
|
|
@@ -156,9 +207,17 @@ async function runSimulate(ctx, definition, signers) {
|
|
|
156
207
|
};
|
|
157
208
|
}
|
|
158
209
|
const gasUsed = simulation.gas || 0;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
210
|
+
if (gasUsed > ceiling) {
|
|
211
|
+
return {
|
|
212
|
+
ok: false,
|
|
213
|
+
mode: "simulate",
|
|
214
|
+
gasUsed,
|
|
215
|
+
error: `Transaction needs ${gasUsed} gas, over the block limit of ${ceiling} — no gas setting can mine it. Reduce the transaction's size or complexity.`,
|
|
216
|
+
rawResult: simulation.result,
|
|
217
|
+
terminalIntent: null,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const calibratedGasLimit = autoGasLimit && gasUsed > 0 ? runtime.calculateAutoGasLimit(gasUsed) : undefined;
|
|
162
221
|
return {
|
|
163
222
|
ok: true,
|
|
164
223
|
mode: "simulate",
|
|
@@ -170,16 +229,27 @@ async function runSimulate(ctx, definition, signers) {
|
|
|
170
229
|
}
|
|
171
230
|
async function runFire(ctx, definition, signers) {
|
|
172
231
|
const { runtime, resolver } = ctx;
|
|
173
|
-
const ceiling = ctx.config?.autoGasCeiling ?? AUTO_GAS_CEILING;
|
|
174
232
|
const listenMs = ctx.config?.listenTimeoutMs ?? LISTEN_TIMEOUT_MS;
|
|
175
233
|
const { chainId, autoGasLimit } = definition.config;
|
|
176
234
|
const client = runtime.createClient(runtime.getPactUrl(chainId));
|
|
177
|
-
|
|
235
|
+
const ceiling = await resolveCeiling(ctx, client);
|
|
236
|
+
// Build + sign for the pre-flight read.
|
|
178
237
|
let tx = buildTransaction(runtime, definition, signers, autoGasLimit ? ceiling : undefined);
|
|
179
238
|
let signed = await signTransaction(runtime, resolver, signers, tx);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
239
|
+
if (autoGasLimit && !client.preflightRead) {
|
|
240
|
+
throw new Error("ChainRuntime.preflightRead is required to auto-size gas for an AUTO-gas " +
|
|
241
|
+
"transaction: without it the calibration would use dirtyRead's execution-" +
|
|
242
|
+
"only gas figure, which omits the transaction-size charge and reproduces " +
|
|
243
|
+
"the exact over-reservation bug this capability exists to fix. Upgrade the " +
|
|
244
|
+
"injected runtime adapter (see blockchain/stoachain.ts), or switch this " +
|
|
245
|
+
"cronoton to manual gas.");
|
|
246
|
+
}
|
|
247
|
+
// (F-001) Pre-submit pre-flight — never submit a tx a pre-flight would
|
|
248
|
+
// catch (saves a one-time terminal fire + gas). AUTO-gas fires source this
|
|
249
|
+
// from the accurate `preflightRead`; MANUAL-gas fires stay on `dirtyRead`.
|
|
250
|
+
const preflight = autoGasLimit
|
|
251
|
+
? await client.preflightRead(signed)
|
|
252
|
+
: await client.dirtyRead(signed);
|
|
183
253
|
if (preflight.result.status === "failure") {
|
|
184
254
|
return {
|
|
185
255
|
ok: false,
|
|
@@ -190,9 +260,23 @@ async function runFire(ctx, definition, signers) {
|
|
|
190
260
|
terminalIntent: computeTerminalIntent(definition.scheduleKind, "fire", false),
|
|
191
261
|
};
|
|
192
262
|
}
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
263
|
+
// Refuse the unmineable case BEFORE any rebuild/resubmit — a transaction
|
|
264
|
+
// whose measured gas exceeds the resolved block ceiling can never mine, for
|
|
265
|
+
// either an AUTO-gas or a manually-set-limit fire.
|
|
266
|
+
const gasUsed = preflight.gas || 0;
|
|
267
|
+
if (gasUsed > ceiling) {
|
|
268
|
+
return {
|
|
269
|
+
ok: false,
|
|
270
|
+
mode: "fire",
|
|
271
|
+
chainId,
|
|
272
|
+
error: `Transaction needs ${gasUsed} gas, over the block limit of ${ceiling} — no gas setting can mine it. Reduce the transaction's size or complexity.`,
|
|
273
|
+
rawResult: preflight.result,
|
|
274
|
+
terminalIntent: computeTerminalIntent(definition.scheduleKind, "fire", false),
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
// Auto-gas: rebuild + re-sign with the calibrated limit from the pre-flight read.
|
|
278
|
+
if (autoGasLimit && gasUsed > 0) {
|
|
279
|
+
const calibrated = runtime.calculateAutoGasLimit(gasUsed);
|
|
196
280
|
tx = buildTransaction(runtime, definition, signers, calibrated);
|
|
197
281
|
signed = await signTransaction(runtime, resolver, signers, tx);
|
|
198
282
|
}
|
package/dist/server/seams.d.ts
CHANGED
|
@@ -97,6 +97,26 @@ export interface ListenResult {
|
|
|
97
97
|
/** A network client bound to a single Pact endpoint URL. */
|
|
98
98
|
export interface ChainClient {
|
|
99
99
|
dirtyRead(tx: unknown): Promise<DirtyReadResult>;
|
|
100
|
+
/**
|
|
101
|
+
* `local` with `{ preflight: true, signatureVerification: false }` — measures
|
|
102
|
+
* the TRUE gas a transaction will consume, including the transaction-size
|
|
103
|
+
* charge that a plain `dirtyRead` (execution gas only) omits. Optional so the
|
|
104
|
+
* package stays non-breaking for any custom `ChainClient`; the executor HARD
|
|
105
|
+
* THROWS when it's absent on an AUTO-gas fire — a silent fallback to the
|
|
106
|
+
* inaccurate `dirtyRead` measurement would ship the exact over-reservation bug
|
|
107
|
+
* this capability exists to fix (mirrors `ChainRuntime.gasMeta`'s precedent).
|
|
108
|
+
* A MANUAL-gas fire never needs this and is unaffected by its absence.
|
|
109
|
+
*/
|
|
110
|
+
preflightRead?(tx: unknown): Promise<DirtyReadResult>;
|
|
111
|
+
/**
|
|
112
|
+
* The live block gas limit, read from the node. Optional and BEST-EFFORT —
|
|
113
|
+
* unlike `preflightRead`, a stale/failed read here only degrades the
|
|
114
|
+
* simulate-at-ceiling sizing and the refuse-unmineable threshold, since the
|
|
115
|
+
* real chainweb node is still the authoritative validator of what actually
|
|
116
|
+
* fits; the executor falls back to `Config.autoGasCeiling`/`AUTO_GAS_CEILING`
|
|
117
|
+
* on any failure or absence, matching OuronetUI's own documented choice here.
|
|
118
|
+
*/
|
|
119
|
+
getBlockGasLimit?(): Promise<number>;
|
|
100
120
|
submit(tx: unknown): Promise<{
|
|
101
121
|
requestKey: string;
|
|
102
122
|
}>;
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -166,7 +166,7 @@ interface BuilderProps {
|
|
|
166
166
|
* header + five-tab bar full-width below it, feeding every tab the shared state
|
|
167
167
|
* and folding its `onChange` back in.
|
|
168
168
|
*/
|
|
169
|
-
declare function Builder({ editId, access
|
|
169
|
+
declare function Builder({ editId, access, onDone, robots, }: BuilderProps): ReactNode;
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
172
|
* `<Public>` — the read-only public transparency wrapper over `<Detail>`.
|
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-
|
|
2
|
-
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-
|
|
1
|
+
import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-LX6T2BDL.js';
|
|
2
|
+
import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-GNQ2IVXA.js';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { lazy, forwardRef, createElement, useState, useEffect, useCallback,
|
|
4
|
+
import { lazy, forwardRef, createElement, useState, useEffect, useCallback, useMemo, Suspense, useContext } from 'react';
|
|
5
5
|
|
|
6
6
|
function KhronotonUiRoot({ children, className }) {
|
|
7
7
|
const cls = className ? `khronoton-ui ${className}` : "khronoton-ui";
|
|
@@ -1367,7 +1367,11 @@ function makeEmptyBuilderState() {
|
|
|
1367
1367
|
// created at this default never underprices as the floor rises.
|
|
1368
1368
|
gasPriceBufferAnu: 0,
|
|
1369
1369
|
gasLimit: 1500,
|
|
1370
|
-
|
|
1370
|
+
// AUTO is now the default per the auto-gas handoff: a fixed manual
|
|
1371
|
+
// limit was the prior default's failure mode (real fires over-reserve
|
|
1372
|
+
// gas wildly against a static number). Manual stays available as a
|
|
1373
|
+
// deliberate toggle for the operators who want it.
|
|
1374
|
+
autoGasLimit: true,
|
|
1371
1375
|
ttl: 600
|
|
1372
1376
|
},
|
|
1373
1377
|
payload: {
|
|
@@ -1832,6 +1836,10 @@ function BuilderHeader({
|
|
|
1832
1836
|
function formatThousands(n) {
|
|
1833
1837
|
return n.toLocaleString("en-US");
|
|
1834
1838
|
}
|
|
1839
|
+
function postponedMessage(plannedCount) {
|
|
1840
|
+
const detail = typeof plannedCount === "number" ? ` \u2014 ${plannedCount} planned transaction${plannedCount === 1 ? "" : "s"}` : "";
|
|
1841
|
+
return `Simulation postponed${detail}.`;
|
|
1842
|
+
}
|
|
1835
1843
|
var INPUT_STYLE4 = {
|
|
1836
1844
|
display: "block",
|
|
1837
1845
|
width: "100%",
|
|
@@ -3388,18 +3396,13 @@ function ExecuteTab({
|
|
|
3388
3396
|
committing,
|
|
3389
3397
|
eventDrivenResolver,
|
|
3390
3398
|
sim,
|
|
3391
|
-
liveFloorAnu
|
|
3399
|
+
liveFloorAnu,
|
|
3400
|
+
isEdit,
|
|
3401
|
+
commit,
|
|
3402
|
+
gate
|
|
3392
3403
|
}) {
|
|
3393
3404
|
const [banner, setBanner] = useState(null);
|
|
3394
|
-
const commit = useMemo(() => builderToCommit(state), [state]);
|
|
3395
3405
|
const payloadKeyCount = Object.keys(commit.envelope.payload ?? {}).length;
|
|
3396
|
-
const simulateCalibrated = Boolean(
|
|
3397
|
-
sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
|
|
3398
|
-
);
|
|
3399
|
-
const gate = useMemo(
|
|
3400
|
-
() => canCommit(state, { simulateCalibrated }),
|
|
3401
|
-
[state, simulateCalibrated]
|
|
3402
|
-
);
|
|
3403
3406
|
const triggerOnly = isTriggerOnly2(state);
|
|
3404
3407
|
const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
|
|
3405
3408
|
const onSimulate = async () => {
|
|
@@ -3409,8 +3412,7 @@ function ExecuteTab({
|
|
|
3409
3412
|
return;
|
|
3410
3413
|
}
|
|
3411
3414
|
if (view.postponed) {
|
|
3412
|
-
|
|
3413
|
-
setBanner(renderBanner("var(--khr-accent)", `Simulation postponed${detail}.`));
|
|
3415
|
+
setBanner(renderBanner("var(--khr-accent)", postponedMessage(view.plannedCount)));
|
|
3414
3416
|
return;
|
|
3415
3417
|
}
|
|
3416
3418
|
if (view.ok) {
|
|
@@ -3472,7 +3474,7 @@ function ExecuteTab({
|
|
|
3472
3474
|
style: commitEnabled ? COMMIT_ENABLED_STYLE : COMMIT_DISABLED_STYLE,
|
|
3473
3475
|
disabled: !commitEnabled,
|
|
3474
3476
|
onClick: onCommitClick,
|
|
3475
|
-
children: "Commit Codex Cronoton"
|
|
3477
|
+
children: isEdit ? committing ? "Saving\u2026" : "Save changes" : "Commit Codex Cronoton"
|
|
3476
3478
|
}
|
|
3477
3479
|
),
|
|
3478
3480
|
!gate.ok ? /* @__PURE__ */ jsx("ul", { style: REASONS_STYLE, children: gate.reasons.map((reason) => /* @__PURE__ */ jsx("li", { children: reason }, reason)) }) : null
|
|
@@ -3489,6 +3491,98 @@ function renderBanner(color, message) {
|
|
|
3489
3491
|
}
|
|
3490
3492
|
);
|
|
3491
3493
|
}
|
|
3494
|
+
var BAR_STYLE = {
|
|
3495
|
+
display: "flex",
|
|
3496
|
+
alignItems: "center",
|
|
3497
|
+
gap: "12px",
|
|
3498
|
+
padding: "10px 12px",
|
|
3499
|
+
marginBottom: "12px",
|
|
3500
|
+
border: "1px solid var(--khr-border)",
|
|
3501
|
+
borderRadius: "var(--khr-radius)",
|
|
3502
|
+
background: "var(--khr-panel)"
|
|
3503
|
+
};
|
|
3504
|
+
var SIMULATE_BUTTON_STYLE2 = {
|
|
3505
|
+
border: "1px solid var(--khr-border)",
|
|
3506
|
+
background: "var(--khr-panel)",
|
|
3507
|
+
color: "var(--khr-text)",
|
|
3508
|
+
padding: "7px 14px",
|
|
3509
|
+
borderRadius: "6px",
|
|
3510
|
+
cursor: "pointer",
|
|
3511
|
+
font: "inherit",
|
|
3512
|
+
fontSize: "12px"
|
|
3513
|
+
};
|
|
3514
|
+
var SAVE_ENABLED_STYLE = {
|
|
3515
|
+
padding: "7px 14px",
|
|
3516
|
+
border: "1px solid var(--khr-accent)",
|
|
3517
|
+
background: "var(--khr-accent-tint)",
|
|
3518
|
+
color: "var(--khr-accent)",
|
|
3519
|
+
borderRadius: "6px",
|
|
3520
|
+
cursor: "pointer",
|
|
3521
|
+
font: "inherit",
|
|
3522
|
+
fontSize: "12px",
|
|
3523
|
+
fontWeight: 600
|
|
3524
|
+
};
|
|
3525
|
+
var SAVE_DISABLED_STYLE = {
|
|
3526
|
+
...SAVE_ENABLED_STYLE,
|
|
3527
|
+
borderColor: "var(--khr-border)",
|
|
3528
|
+
background: "var(--khr-panel)",
|
|
3529
|
+
color: "var(--khr-text-dim)",
|
|
3530
|
+
cursor: "not-allowed",
|
|
3531
|
+
opacity: 0.7
|
|
3532
|
+
};
|
|
3533
|
+
var STATUS_STYLE = {
|
|
3534
|
+
margin: 0,
|
|
3535
|
+
fontSize: "12px",
|
|
3536
|
+
color: "var(--khr-text-dim)"
|
|
3537
|
+
};
|
|
3538
|
+
function saveBarStatus(sim, gate) {
|
|
3539
|
+
if (sim.pending) return "Running dry-run\u2026";
|
|
3540
|
+
const result = sim.result;
|
|
3541
|
+
if (result?.postponed) return postponedMessage(result.plannedCount);
|
|
3542
|
+
if (result && !result.ok) {
|
|
3543
|
+
return `Simulation failed \u2014 ${result.error ?? "unknown error"}`;
|
|
3544
|
+
}
|
|
3545
|
+
if (result?.ok && typeof result.calibratedGasLimit === "number") {
|
|
3546
|
+
return `Calibrated gas ${formatThousands(result.calibratedGasLimit)} \u2014 ready to save.`;
|
|
3547
|
+
}
|
|
3548
|
+
if (!gate.ok && gate.reasons.length > 0) return gate.reasons[0];
|
|
3549
|
+
return "Changes apply at the next fire.";
|
|
3550
|
+
}
|
|
3551
|
+
function SaveBar({ commit, gate, sim, onSave, committing, access }) {
|
|
3552
|
+
const mutable = canMutate(access);
|
|
3553
|
+
const onSimulate = () => {
|
|
3554
|
+
if (!mutable || sim.pending) return;
|
|
3555
|
+
void sim.run(commit.envelope);
|
|
3556
|
+
};
|
|
3557
|
+
const saveEnabled = gate.ok && !committing && mutable;
|
|
3558
|
+
const onSaveClick = () => {
|
|
3559
|
+
if (gate.ok && !committing && mutable) onSave();
|
|
3560
|
+
};
|
|
3561
|
+
const status = mutable ? saveBarStatus(sim, gate) : ADMIN_ONLY_TITLE;
|
|
3562
|
+
return /* @__PURE__ */ jsxs("div", { style: BAR_STYLE, children: [
|
|
3563
|
+
/* @__PURE__ */ jsx(
|
|
3564
|
+
"button",
|
|
3565
|
+
{
|
|
3566
|
+
type: "button",
|
|
3567
|
+
style: SIMULATE_BUTTON_STYLE2,
|
|
3568
|
+
disabled: sim.pending || !mutable,
|
|
3569
|
+
onClick: onSimulate,
|
|
3570
|
+
children: sim.pending ? "Simulating\u2026" : "Simulate"
|
|
3571
|
+
}
|
|
3572
|
+
),
|
|
3573
|
+
/* @__PURE__ */ jsx(
|
|
3574
|
+
"button",
|
|
3575
|
+
{
|
|
3576
|
+
type: "button",
|
|
3577
|
+
style: saveEnabled ? SAVE_ENABLED_STYLE : SAVE_DISABLED_STYLE,
|
|
3578
|
+
disabled: !saveEnabled,
|
|
3579
|
+
onClick: onSaveClick,
|
|
3580
|
+
children: committing ? "Saving\u2026" : "Save changes"
|
|
3581
|
+
}
|
|
3582
|
+
),
|
|
3583
|
+
/* @__PURE__ */ jsx("p", { style: STATUS_STYLE, children: status })
|
|
3584
|
+
] });
|
|
3585
|
+
}
|
|
3492
3586
|
|
|
3493
3587
|
// src/ui/tx-size.ts
|
|
3494
3588
|
var STOA_TX_BYTE_CEILING = 2 * 1024 * 1024;
|
|
@@ -3670,6 +3764,17 @@ function useLiveGasFloor() {
|
|
|
3670
3764
|
}, []);
|
|
3671
3765
|
return floorAnu;
|
|
3672
3766
|
}
|
|
3767
|
+
function useCommitGate(state, sim) {
|
|
3768
|
+
const commit = useMemo(() => builderToCommit(state), [state]);
|
|
3769
|
+
const simulateCalibrated = Boolean(
|
|
3770
|
+
sim.result?.ok && typeof sim.result.calibratedGasLimit === "number"
|
|
3771
|
+
);
|
|
3772
|
+
const gate = useMemo(
|
|
3773
|
+
() => canCommit(state, { simulateCalibrated }),
|
|
3774
|
+
[state, simulateCalibrated]
|
|
3775
|
+
);
|
|
3776
|
+
return { commit, gate, simulateCalibrated };
|
|
3777
|
+
}
|
|
3673
3778
|
var DEFAULT_BUILDER_ROBOTS = "noindex,nofollow";
|
|
3674
3779
|
var TABS = [
|
|
3675
3780
|
{ key: "config", label: "Config" },
|
|
@@ -3714,7 +3819,7 @@ var EDIT_BANNER = {
|
|
|
3714
3819
|
};
|
|
3715
3820
|
function Builder({
|
|
3716
3821
|
editId,
|
|
3717
|
-
access
|
|
3822
|
+
access,
|
|
3718
3823
|
onDone,
|
|
3719
3824
|
robots = DEFAULT_BUILDER_ROBOTS
|
|
3720
3825
|
}) {
|
|
@@ -3785,18 +3890,32 @@ function Builder({
|
|
|
3785
3890
|
}, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
|
|
3786
3891
|
const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
|
|
3787
3892
|
const liveFloorAnu = useLiveGasFloor();
|
|
3893
|
+
const { commit, gate } = useCommitGate(state, sim);
|
|
3788
3894
|
const handlePactCodeChange = useCallback((pactCode) => {
|
|
3789
3895
|
setState((s) => ({ ...s, pactCode }));
|
|
3790
3896
|
}, []);
|
|
3791
3897
|
return /* @__PURE__ */ jsxs("div", { className: "khronoton-ui", children: [
|
|
3792
3898
|
/* @__PURE__ */ jsx("meta", { name: "robots", content: robots }),
|
|
3793
|
-
isEdit && /* @__PURE__ */ jsxs(
|
|
3794
|
-
/* @__PURE__ */ jsx(
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3899
|
+
isEdit && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3900
|
+
editReady && /* @__PURE__ */ jsx(
|
|
3901
|
+
SaveBar,
|
|
3902
|
+
{
|
|
3903
|
+
commit,
|
|
3904
|
+
gate,
|
|
3905
|
+
sim,
|
|
3906
|
+
onSave: handleCommit,
|
|
3907
|
+
committing,
|
|
3908
|
+
access
|
|
3909
|
+
}
|
|
3910
|
+
),
|
|
3911
|
+
/* @__PURE__ */ jsxs("div", { style: EDIT_BANNER, children: [
|
|
3912
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0 }, children: "Edits apply at the NEXT fire. Payload opens in raw-JSON mode. Re-run Simulate before saving." }),
|
|
3913
|
+
editRow && /* @__PURE__ */ jsxs("p", { style: { margin: "0.35rem 0 0" }, children: [
|
|
3914
|
+
"Current schedule: ",
|
|
3915
|
+
editRow.schedule_mode,
|
|
3916
|
+
" \xB7 Status: ",
|
|
3917
|
+
editRow.status
|
|
3918
|
+
] })
|
|
3800
3919
|
] })
|
|
3801
3920
|
] }),
|
|
3802
3921
|
editReady ? /* @__PURE__ */ jsxs("div", { style: PANE_WRAP, children: [
|
|
@@ -3845,7 +3964,10 @@ function Builder({
|
|
|
3845
3964
|
committing,
|
|
3846
3965
|
eventDrivenResolver,
|
|
3847
3966
|
sim,
|
|
3848
|
-
liveFloorAnu
|
|
3967
|
+
liveFloorAnu,
|
|
3968
|
+
isEdit,
|
|
3969
|
+
commit,
|
|
3970
|
+
gate
|
|
3849
3971
|
}
|
|
3850
3972
|
)
|
|
3851
3973
|
] })
|
|
@@ -3856,7 +3978,7 @@ var DEFAULT_PUBLIC_ROBOTS = DEFAULT_DETAIL_ROBOTS;
|
|
|
3856
3978
|
var PUBLIC_ACCESS = { tier: "logged-out" };
|
|
3857
3979
|
var PUBLIC_BAR_TEXT = "Public view \u2014 read-only transparency into this codex cronoton's schedule and fire history.";
|
|
3858
3980
|
var PUBLIC_FOOTER_TEXT = "Public view \u2014 read only. Sign in as an Ancient admin to manage.";
|
|
3859
|
-
var
|
|
3981
|
+
var BAR_STYLE2 = {
|
|
3860
3982
|
marginBottom: "16px",
|
|
3861
3983
|
padding: "10px 14px",
|
|
3862
3984
|
borderRadius: "8px",
|
|
@@ -3872,7 +3994,7 @@ var FOOTER_STYLE = {
|
|
|
3872
3994
|
};
|
|
3873
3995
|
function Public({ id, robots = DEFAULT_PUBLIC_ROBOTS }) {
|
|
3874
3996
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3875
|
-
/* @__PURE__ */ jsx("div", { style:
|
|
3997
|
+
/* @__PURE__ */ jsx("div", { style: BAR_STYLE2, children: PUBLIC_BAR_TEXT }),
|
|
3876
3998
|
/* @__PURE__ */ jsx(Detail, { id, access: PUBLIC_ACCESS, robots }),
|
|
3877
3999
|
/* @__PURE__ */ jsx("p", { style: FOOTER_STYLE, children: PUBLIC_FOOTER_TEXT })
|
|
3878
4000
|
] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancientpantheon/khronoton-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|