@ancientpantheon/khronoton-core 0.10.0 → 0.12.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.
@@ -0,0 +1,197 @@
1
+ /**
2
+ * public — the public (unauthenticated-by-design) observability surface for a
3
+ * single codex-cronoton: a lazily-minted, stable lookup token, a by-token
4
+ * read gated on `public_observable`, whole-history fire counts, a pure
5
+ * traffic-light health rule, and the sanitizing projector that assembles the
6
+ * client-facing DTO.
7
+ *
8
+ * `toPublicCronotonView` is the ONLY place the privacy guarantee is enforced:
9
+ * it builds a brand-new object field-by-field from the (far more sensitive)
10
+ * `CodexCronotonRow`/`CodexCronotonFireRow` inputs, never spreading either —
11
+ * a raw `pact_code`, JSON config blob, `created_by`, or fire `errorMessage`/
12
+ * `chainResponse` must never ride along by accident.
13
+ */
14
+ import crypto from "node:crypto";
15
+ import { summariseSchedule } from "../../schedule.js";
16
+ import { getCodexCronoton } from "./cronoton.js";
17
+ import { CodexCronotonValidationError } from "./errors.js";
18
+ import { rowExternalFireable, rowRuntimeArgKeys } from "./mappers.js";
19
+ /**
20
+ * Flip a cronoton's public-observability flag. Minting is lazy and stable:
21
+ * a token is generated ONLY the first time a row is made observable (or when
22
+ * `regenerate: true` is explicitly passed) — disabling then re-enabling
23
+ * reuses the same token, so an embed URL built from it never has to be
24
+ * re-minted. Disabling never touches `public_token`.
25
+ */
26
+ export function setPublicObservable(id, opts, dep) {
27
+ const db = dep.db;
28
+ const row = getCodexCronoton(id, { db });
29
+ if (!row)
30
+ throw new CodexCronotonValidationError("not found");
31
+ let nextToken = row.public_token ?? null;
32
+ if (opts.observable && (!nextToken || opts.regenerate === true)) {
33
+ nextToken = crypto.randomBytes(20).toString("base64url");
34
+ }
35
+ db.prepare(`UPDATE codex_cronotons SET public_token = ?, public_observable = ?, modified_at = ? WHERE id = ?`).run(nextToken, opts.observable ? 1 : 0, new Date().toISOString(), id);
36
+ return { publicToken: nextToken, publicObservable: opts.observable };
37
+ }
38
+ /**
39
+ * Resolve a cronoton by its public token. Returns `null` for an unknown
40
+ * token AND for a known token whose row is currently non-observable — the
41
+ * single query makes the two cases indistinguishable on purpose (the public
42
+ * handler can't leak which one it is).
43
+ */
44
+ export function getCodexCronotonByPublicToken(token, dep) {
45
+ const row = dep.db
46
+ .prepare(`SELECT * FROM codex_cronotons WHERE public_token = ? AND public_observable = 1`)
47
+ .get(token);
48
+ return row ?? null;
49
+ }
50
+ /**
51
+ * Whole-history fire counts for a cronoton. Deliberately independent of any
52
+ * paginated fires window (a page of 20 out of 150 fires would under-report
53
+ * every aggregate): one aggregate query for the totals/last-timestamps, plus
54
+ * a second DESC-ordered scan (capped at 1000 rows) counting leading
55
+ * `'failure'` statuses for `currentFailStreak` — the scan stops at the first
56
+ * non-failure (or the cap), so a success anywhere further back never dilutes
57
+ * the trailing streak.
58
+ */
59
+ export function getCronotonFireCounts(id, dep) {
60
+ const db = dep.db;
61
+ const agg = db
62
+ .prepare(`SELECT
63
+ COUNT(*) AS fired,
64
+ SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) AS succeeded,
65
+ SUM(CASE WHEN status = 'failure' THEN 1 ELSE 0 END) AS failed,
66
+ MAX(CASE WHEN status = 'success' THEN fired_at ELSE NULL END) AS lastSuccessAt,
67
+ MAX(CASE WHEN status = 'failure' THEN fired_at ELSE NULL END) AS lastFailureAt
68
+ FROM codex_cronoton_fires
69
+ WHERE codex_cronoton_id = ?`)
70
+ .get(id);
71
+ const recent = db
72
+ .prepare(
73
+ // Tiebreak on SQLite's implicit `rowid`, NOT the `id` column — `id` is a
74
+ // `crypto.randomUUID()` (fires.ts's recordFire/createRunningFire), with
75
+ // zero correlation to insertion order, so an `id`-based tiebreak would
76
+ // pick "most recent" essentially at random on a genuine fired_at tie.
77
+ // `rowid` is safe here: this table has no `INTEGER PRIMARY KEY`/`WITHOUT
78
+ // ROWID` override, and rows are never deleted standalone (only
79
+ // cascade-deleted with their parent cronoton), so rowid reuse never
80
+ // becomes a factor for a still-alive cronoton's fire history.
81
+ `SELECT status FROM codex_cronoton_fires
82
+ WHERE codex_cronoton_id = ?
83
+ ORDER BY fired_at DESC, rowid DESC LIMIT 1000`)
84
+ .all(id);
85
+ let currentFailStreak = 0;
86
+ for (const r of recent) {
87
+ if (r.status !== "failure")
88
+ break;
89
+ currentFailStreak += 1;
90
+ }
91
+ return {
92
+ fired: agg.fired,
93
+ succeeded: agg.succeeded ?? 0,
94
+ failed: agg.failed ?? 0,
95
+ lastSuccessAt: agg.lastSuccessAt ?? null,
96
+ lastFailureAt: agg.lastFailureAt ?? null,
97
+ currentFailStreak,
98
+ };
99
+ }
100
+ /**
101
+ * The pure traffic-light health rule: `"down"` once the trailing streak hits
102
+ * 3, `"degraded"` for a 1-2 streak OR an overdue schedule, `"healthy"`
103
+ * otherwise. Exported standalone so a consumer can reason about it without a
104
+ * DB row.
105
+ */
106
+ export function deriveCronotonHealth(input) {
107
+ if (input.currentFailStreak >= 3)
108
+ return "down";
109
+ if (input.currentFailStreak >= 1 || input.isOverdue)
110
+ return "degraded";
111
+ return "healthy";
112
+ }
113
+ /** Best-effort parse of `schedule_config_json`; `null` on malformed/legacy data. */
114
+ function parseScheduleConfig(json) {
115
+ try {
116
+ return JSON.parse(json);
117
+ }
118
+ catch {
119
+ return null;
120
+ }
121
+ }
122
+ /**
123
+ * Pure projector (no DB access of its own) from a `CodexCronotonRow` +
124
+ * its `getCronotonFireCounts` result + a `listFires` page onto the sanitized
125
+ * public DTO. Builds the result field-by-field — never spreads the row or a
126
+ * fire — so `pact_code`/`payload_json`/`signers_json`/`gas_payer_json`/
127
+ * `server_resolver`/`created_by`/`config_json`, the internal `id`, and a
128
+ * fire's raw `errorMessage`/`chainResponse` can never leak through it.
129
+ */
130
+ export function toPublicCronotonView(row, counts, firesPage, now = new Date()) {
131
+ const parsedConfig = parseScheduleConfig(row.schedule_config_json);
132
+ const humanText = parsedConfig
133
+ ? summariseSchedule(row.schedule_mode, parsedConfig)
134
+ : row.schedule_mode;
135
+ const schedule = {
136
+ mode: row.schedule_mode,
137
+ humanText,
138
+ };
139
+ if (parsedConfig && parsedConfig.mode === "cron-expression") {
140
+ schedule.cron = parsedConfig.expression;
141
+ }
142
+ // A row committed/edited with ONLY `eventDriven: true` (no `externalFireable`,
143
+ // no `evented` server resolver) persists `external_fireable = 0` and
144
+ // `runtime_arg_keys = null` — `next_fire_at === null` is the ONLY signal
145
+ // store/cronoton.ts leaves for it (see editCodexCronoton's own
146
+ // "reliable, column-free marker" comment). But a null `next_fire_at` is ALSO
147
+ // how a spent terminal one-time row looks (applyTerminalIntent clears it on
148
+ // completion/error) despite never being trigger-only — so the null check is
149
+ // gated on the row NOT being terminal.
150
+ //
151
+ // KNOWN LIMITATION (not fully disambiguable without a dedicated persisted
152
+ // column — judged disproportionate for a read-only view's display label):
153
+ // `claimDueCodexCronoton` (./claim.js) ALSO nulls `next_fire_at` on an
154
+ // ORDINARY, non-trigger-only row while leaving `status = 'active'` — (a)
155
+ // transiently, for every one-time row, during the brief window between
156
+ // claim and the eventual terminal-intent write; (b) PERMANENTLY, for a
157
+ // recurring row whose `schedule_config_json` is corrupt (claim.ts's own
158
+ // "F-003" case — the row is stuck `active` with a null `next_fire_at`
159
+ // forever, since the due-query requires `next_fire_at IS NOT NULL`). Both
160
+ // cases read as `triggerOnly: true` here. Accepted: the corrupt-config row
161
+ // is already broken regardless of this label, and the one-time window is
162
+ // bounded and transient.
163
+ const triggerOnly = rowExternalFireable(row) ||
164
+ rowRuntimeArgKeys(row).length > 0 ||
165
+ (row.next_fire_at === null && row.status !== "completed" && row.status !== "error");
166
+ const isOverdue = row.status === "active" &&
167
+ row.next_fire_at !== null &&
168
+ new Date(row.next_fire_at) < now;
169
+ const successRatePercent = counts.fired > 0 ? Math.round((counts.succeeded / counts.fired) * 100) : null;
170
+ return {
171
+ name: row.name,
172
+ description: row.description,
173
+ status: row.status,
174
+ schedule,
175
+ triggerOnly,
176
+ nextFireAt: row.next_fire_at,
177
+ lastFireAt: row.last_fire_at,
178
+ isOverdue,
179
+ since: row.created_at,
180
+ counts: { ...counts, successRatePercent },
181
+ health: deriveCronotonHealth({ currentFailStreak: counts.currentFailStreak, isOverdue }),
182
+ fires: {
183
+ page: firesPage.fires.map((fire) => ({
184
+ firedAt: fire.firedAt,
185
+ status: fire.status,
186
+ chainId: fire.chainId,
187
+ requestKey: fire.requestKey,
188
+ txKeys: fire.txKeys,
189
+ recoveredAt: fire.recoveredAt,
190
+ mode: fire.mode,
191
+ })),
192
+ total: firesPage.total,
193
+ limit: firesPage.limit,
194
+ offset: firesPage.offset,
195
+ },
196
+ };
197
+ }
@@ -151,6 +151,19 @@ export interface CodexCronotonRow {
151
151
  * doubles (test fixtures) typecheck.
152
152
  */
153
153
  runtime_arg_keys?: string | null;
154
+ /**
155
+ * Stable, URL-safe public lookup token; null/absent until the row is first
156
+ * made observable. Optional so pre-migration row doubles (test fixtures)
157
+ * typecheck; real rows from `SELECT *` carry the column (value may be null).
158
+ */
159
+ public_token?: string | null;
160
+ /**
161
+ * When 1, this cronoton's sanitized state is readable via the public
162
+ * by-token endpoint, bypassing admin auth entirely. Optional so
163
+ * pre-migration row doubles (test fixtures) typecheck; real rows from
164
+ * `SELECT *` carry the column.
165
+ */
166
+ public_observable?: number;
154
167
  status: "active" | "paused" | "completed" | "error";
155
168
  next_fire_at: string | null;
156
169
  last_fire_at: string | null;
@@ -176,6 +176,19 @@ interface CodexCronotonRow {
176
176
  * doubles (test fixtures) typecheck.
177
177
  */
178
178
  runtime_arg_keys?: string | null;
179
+ /**
180
+ * Stable, URL-safe public lookup token; null/absent until the row is first
181
+ * made observable. Optional so pre-migration row doubles (test fixtures)
182
+ * typecheck; real rows from `SELECT *` carry the column (value may be null).
183
+ */
184
+ public_token?: string | null;
185
+ /**
186
+ * When 1, this cronoton's sanitized state is readable via the public
187
+ * by-token endpoint, bypassing admin auth entirely. Optional so
188
+ * pre-migration row doubles (test fixtures) typecheck; real rows from
189
+ * `SELECT *` carry the column.
190
+ */
191
+ public_observable?: number;
179
192
  status: "active" | "paused" | "completed" | "error";
180
193
  next_fire_at: string | null;
181
194
  last_fire_at: string | null;
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-DnFB1Yz-.js';
2
+ import { a as CodexCronotonFireRow, C as CodexCronotonRow, f as CodexFireMode } from '../types-uYSglFrJ.js';
3
3
 
4
4
  /**
5
5
  * The theming boundary. Every Khronoton UI surface renders inside a
@@ -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: _access, onDone, robots, }: BuilderProps): ReactNode;
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-UP3SYP2U.js';
2
- import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-KDCNWWWQ.js';
1
+ import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useServerResolvers, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-KQZYMPZS.js';
2
+ import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-GIGLXIMC.js';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
- import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useMemo, useContext } from 'react';
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
- autoGasLimit: false,
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
- const detail = typeof view.plannedCount === "number" ? ` \u2014 ${view.plannedCount} planned transaction${view.plannedCount === 1 ? "" : "s"}` : "";
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: _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("div", { style: EDIT_BANNER, children: [
3794
- /* @__PURE__ */ jsx("p", { style: { margin: 0 }, children: "Edits apply at the NEXT fire. Payload opens in raw-JSON mode. Re-run Simulate before saving." }),
3795
- editRow && /* @__PURE__ */ jsxs("p", { style: { margin: "0.35rem 0 0" }, children: [
3796
- "Current schedule: ",
3797
- editRow.schedule_mode,
3798
- " \xB7 Status: ",
3799
- editRow.status
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 BAR_STYLE = {
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: BAR_STYLE, children: PUBLIC_BAR_TEXT }),
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.10.0",
3
+ "version": "0.12.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",