@ancientpantheon/khronoton-core 0.6.1 → 0.8.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 +31 -0
- package/README.md +8 -0
- package/dist/blockchain/stoachain.d.ts +1 -1
- package/dist/{chunk-J7P2NCO4.js → chunk-NNR4MYI3.js} +44 -6
- package/dist/{chunk-5SUNXUSH.js → chunk-WLZXX2SQ.js} +149 -117
- package/dist/{context-D7LCfXdC.d.ts → context-C1K08cmR.d.ts} +93 -1
- package/dist/handlers/cronoton.d.ts +4 -1
- package/dist/handlers/cronoton.js +7 -3
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +2 -2
- package/dist/handlers/read.d.ts +6 -0
- package/dist/handlers/read.js +9 -1
- package/dist/hooks/index.d.ts +18 -4
- package/dist/hooks/index.js +2 -2
- package/dist/provider/index.d.ts +3 -3
- package/dist/provider/index.js +22 -6
- package/dist/{seams-BvPnTSmg.d.ts → seams-DapFZ4sM.d.ts} +11 -1
- package/dist/server/resolvers.d.ts +26 -0
- package/dist/server/resolvers.js +12 -0
- package/dist/server/store/cronoton.js +54 -15
- package/dist/ui/index.js +36 -26
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,37 @@ 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.8.0 — 2026-08-03
|
|
8
|
+
|
|
9
|
+
**MINOR — the last two evented-server-resolver UI fixes: DETAIL "Schedule" reads "Evented", and a system cronoton is deletable behind a confirm-gated warning.**
|
|
10
|
+
|
|
11
|
+
Finalizes the Pythia automatic-link work. 0.7.0 made the store server-authoritative for evented resolvers; two UI gaps remained (verified live against Pythia v2.7.22–2.7.25).
|
|
12
|
+
|
|
13
|
+
- **Fix 1 — the cronoton DETAIL card's "Schedule" now reads "Evented" for a trigger-only/evented row.** It previously rendered the stored `schedule_config` ("Daily at 12:00 UTC") for a row that never fires on a clock — while Next Fire already showed "—" and the edit form already disabled the scheduler. Root cause: `Detail.tsx` computed `triggerOnly` from runtime-arg keys only, ignoring `external_fireable`. The list's trigger-only predicate is now extracted to a shared `isTriggerOnly(row)` (`external_fireable === 1 || runtime-arg keys present`) used by **both** the list next-fire cell and the detail Schedule cell, so they can never drift again.
|
|
14
|
+
- **Fix 2 — a system (server-resolver) cronoton is deletable with a warning, not hard-blocked.** `DELETE /[id]` previously refused any `server_resolver` row with `409 { protected: true }`. It now accepts a confirm-gated `?force=1` that permits the delete (the 409 still stands without force). Threaded end-to-end: `ConfirmOpts.force` → both reference adapters send `?force=1` → the widened `remove.run({ force })` action. In the bundled Builder, the Delete button is now **enabled** for an admin on a system cronoton (still admin-only) and, on click, shows a warning naming the resolver — *"This is the automaton's `<name>` template. Deleting it stops that capability until it's recreated. Delete anyway?"* — before the existing password confirm. The audit trail is preserved and a forced system delete records `forced: true`.
|
|
15
|
+
|
|
16
|
+
Behavior for ordinary scheduled cronotons is unchanged; a non-system delete and a `delete(id)`/`remove.run()` without force are byte-identical to 0.7.0, and a system delete without force still 409s. New public surface: `ConfirmOpts.force`, the widened `DeleteAction` run arg (`DeleteRunOpts`), the `deleteSystemConfirm` export, and the shared `isTriggerOnly`/`row-derive` module — all additive.
|
|
17
|
+
|
|
18
|
+
**893 specs pass.**
|
|
19
|
+
|
|
20
|
+
## 0.7.0 — 2026-08-03
|
|
21
|
+
|
|
22
|
+
**MINOR — server-authoritative evented resolvers: scheduleless + external-fireable enforced in the store, `GET /resolvers`, one-resolver-one-cronoton.**
|
|
23
|
+
|
|
24
|
+
0.6.0 shipped event-driven resolvers behind a **client-side** `eventDriven` flag — the guarantee lived in each consumer's proxy, not the package. 0.7.0 makes the **resolver registry** the source of truth and enforces the scheduleless contract in the **store**, so it holds for every consumer regardless of what the client sends.
|
|
25
|
+
|
|
26
|
+
- **`evented` on the resolver registry.** `SingleTxResolver` and `MultiTxResolver` gain an optional `evented?: boolean`. `createCodexCronoton`/`editCodexCronoton` derive it via `getServerResolver(name)?.evented` (a safe, acyclic store→resolvers import) and force the persisted row **scheduleless** (`next_fire_at = NULL`, excluded from `fetchDueCodexCronotons`) **and `external_fireable = 1`** — even when the caller sends a real schedule. An evented→non-evented edit correctly re-arms `next_fire_at` from the stored schedule and clears `external_fireable`; a genuine (non-evented) external-fireable row is never clobbered.
|
|
27
|
+
- **`GET /resolvers`.** New `listServerResolvers()` + `resolversHandler` return `{ ok: true, resolvers: [{ name, kind, evented }] }` listing every registered resolver with its flag. Exposed as a new **OPTIONAL** `resolvers()` method on the `KhronotonAdapter` read tier (implemented by both reference adapters) — deliberately **not** added to `REQUIRED_METHODS`, so pre-0.7.0 adapters still pass `assertAdapter` and the Builder degrades gracefully (falls back to the 0.6.0 `serverResolverOptions.eventDriven`) via the new `useServerResolvers` hook.
|
|
28
|
+
- **Builder is server-authoritative.** `eventDrivenResolver` is now `registry.evented(name) || serverResolverOptions.eventDriven` — a resolver the server marks evented hides the schedule editor, shows the event-driven notice, and commits `externalFireable: true` (derived at commit time, so switching to a non-evented resolver never leaves the flag stuck on).
|
|
29
|
+
- **List shows "Evented".** `CronotonList`'s next-fire cell reads **"Evented"** for a trigger-only row (`external_fireable === 1` or runtime-arg keys) instead of a blank/timestamp.
|
|
30
|
+
- **One resolver, one cronoton.** `createCodexCronoton` rejects a second commit reusing an already-bound `server_resolver` with `CodexCronotonValidationError` naming the existing cronoton id (→ HTTP 400).
|
|
31
|
+
|
|
32
|
+
**Note — deliberate HMAC-exposure reversal.** An evented resolver now forces `external_fireable = 1`, which makes the row HMAC-fireable. This reverses 0.6.0's "don't reuse `externalFireable`" stance and is a conscious choice: it **codifies Pythia's already-shipped production behavior** (v2.7.19/2.7.20 already force this) rather than introducing new exposure, and gives one persisted signal that the store, Builder, and list all read consistently. Manually HMAC-firing an evented resolver just re-runs its idempotent resolve, which no-ops when nothing is ready.
|
|
33
|
+
|
|
34
|
+
The published 0.6.0 `eventDriven` surface (`ServerResolverOption.eventDriven`, `CommitEnvelope.eventDriven`, the store input/patch fields, `builderToCommit` opts) is kept intact as an additive fallback; no breaking removals. Ordinary scheduled resolvers are unchanged.
|
|
35
|
+
|
|
36
|
+
**871 specs pass.**
|
|
37
|
+
|
|
7
38
|
## 0.6.1 — 2026-08-02
|
|
8
39
|
|
|
9
40
|
**PATCH — fix a CronotonList crash (white-screen) on any non-empty list.**
|
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Khronoton is the "When do I act?" Constructor of the Pantheon architecture — t
|
|
|
6
6
|
|
|
7
7
|
## Status
|
|
8
8
|
|
|
9
|
+
**`0.8.0` on public npmjs** — **MINOR.** Released 2026-08-03. Finalizes the evented-resolver UI. **(1)** The cronoton **DETAIL** card's "Schedule" field now reads **"Evented"** for a trigger-only/evented row (it previously showed the stored schedule like "Daily at 12:00 UTC" while Next Fire already read "—"); the list and detail now share one `isTriggerOnly(row)` predicate (`external_fireable === 1 || runtime-arg keys`) so they can't drift. **(2)** A system (`server_resolver`) cronoton is now **deletable behind a confirm-gated warning** instead of a hard 409: `DELETE /[id]?force=1` permits the delete (the 409 still stands without force), threaded via `ConfirmOpts.force` + both reference adapters + the widened `remove.run({ force })`; the bundled Builder's Delete button is enabled for an admin on a system row and shows a warning naming the resolver before deleting, with the audit recording `forced: true`. Ordinary scheduled cronotons and non-forced deletes are unchanged. **893 specs pass.**
|
|
10
|
+
|
|
11
|
+
**`0.7.0` on public npmjs** — **MINOR.** Released 2026-08-03. Makes event-driven resolvers **server-authoritative**: `SingleTxResolver`/`MultiTxResolver` gain an `evented?` flag, and the **store** forces an evented resolver's cronoton scheduleless (`next_fire_at = NULL`, excluded from the due-query) **and `external_fireable = 1`** even when a schedule is sent — the guarantee no longer depends on the consumer. Adds `GET /resolvers` (+ an OPTIONAL `resolvers()` adapter method and `useServerResolvers` hook) so the Builder learns which resolvers are evented; the list shows **"Evented"** as the next-fire for a trigger-only row; and the store enforces **one resolver ↔ one cronoton** (a second bind is rejected). Deliberately reverses 0.6.0's HMAC stance — an evented row is now HMAC-fireable — codifying Pythia's shipped behavior (see version history). **871 specs pass.**
|
|
12
|
+
|
|
9
13
|
**`0.6.1` on public npmjs** — **PATCH.** Released 2026-08-02. Fixes a crash that white-screened the Khronoton admin list whenever it held ≥1 cronoton: `listCodexCronotons` returned a camelCase 9-field projection while `CronotonList` renders full snake_case rows, so `pact_code` was `undefined` and crashed `pactPreview`. The list now returns full `CodexCronotonRow`s (`SELECT *`, like `getCodexCronoton`) and `pactPreview` guards a missing `pact_code`. **850 specs pass.**
|
|
10
14
|
|
|
11
15
|
**`0.6.0` on public npmjs** — **MINOR.** Released 2026-08-02. Server resolvers can now declare themselves **event-driven** (`ServerResolverOption.eventDriven`): selecting one in the Builder commits the cronoton scheduler-off (`next_fire_at = NULL`, never auto-fired) and swaps the schedule editor for an event-driven notice — the host fires it in-process via the existing `executeNow` (not the HMAC endpoint). Ordinary scheduled resolvers are unchanged. **848 specs pass.**
|
|
@@ -238,6 +242,10 @@ npm install @ancientpantheon/khronoton-core
|
|
|
238
242
|
|
|
239
243
|
## Version history
|
|
240
244
|
|
|
245
|
+
**v0.8.0** — Finalizes the evented-resolver UI (the last two gaps after 0.7.0). **Fix 1 — DETAIL "Schedule" reads "Evented".** The read-only cronoton detail card rendered the stored `schedule_config` (e.g. "Daily at 12:00 UTC") for a trigger-only/evented row even though Next Fire already showed "—" and the edit form already disabled the scheduler; root cause was `Detail.tsx` deriving `triggerOnly` from runtime-arg keys only, ignoring `external_fireable`. The list's predicate is extracted to a shared `isTriggerOnly(row)` (`row.external_fireable === 1 || parseRuntimeArgKeys(row.runtime_arg_keys).length > 0`) in `ui/row-derive.ts`, used by both the list next-fire cell and the detail Schedule cell so they can't drift; the detail Schedule cell now reads **"Evented"** for a trigger-only row. **Fix 2 — confirm-gated system delete.** `DELETE /[id]` hard-refused any `server_resolver` ("system") cronoton with `409 { protected: true }`; it now accepts `?force=1` (still behind the admin confirm gate) to permit the delete, while the 409 stands without force. Threaded end-to-end: `ConfirmOpts.force` → `createFetchAdapter` sends `?force=1` / `createMemoryAdapter` passes `query: { force: "1" }` → the widened `DeleteAction`/`remove.run({ force })` action hook. In the bundled Builder, `deleteDisabled` now **enables** the Delete button for an admin on a system cronoton (non-admins still blocked), and both the detail and list `handleDelete` show a `deleteSystemConfirm` warning naming the resolver — *"This is the automaton's `<name>` template. Deleting it stops that capability until it's recreated. Delete anyway?"* — as the first prompt, keeping the existing in-gate password confirm. The delete audit is preserved and records `forced: true` for a forced system delete. Ordinary scheduled cronotons, non-system deletes, and `delete(id)`/`remove.run()` without force are byte-identical to 0.7.0; a system delete without force still 409s. All new surface (`ConfirmOpts.force`, `DeleteRunOpts`, `deleteSystemConfirm`, `row-derive`'s `isTriggerOnly`) is additive. Released 2026-08-03. **893 specs pass.**
|
|
246
|
+
|
|
247
|
+
**v0.7.0** — Server-authoritative evented resolvers. `SingleTxResolver`/`MultiTxResolver` gain an optional `evented?` flag; the **store** (`createCodexCronoton`/`editCodexCronoton`, via an acyclic `getServerResolver` lookup) forces an evented resolver's cronoton `next_fire_at = NULL` **and `external_fireable = 1`** even when a real schedule is committed, so the scheduleless guarantee lives in the package rather than each consumer's proxy (`fetchDueCodexCronotons` skips it; an evented→non-evented edit re-arms `next_fire_at` and clears `external_fireable`; a genuine non-evented external-fireable row is never clobbered). A new `GET /resolvers` handler + `listServerResolvers()` expose `{ name, kind, evented }`; the `KhronotonAdapter` read tier gains an **OPTIONAL** `resolvers()` method (both reference adapters implement it, but it is **not** in `REQUIRED_METHODS`, so older adapters still pass `assertAdapter`), consumed by the new `useServerResolvers` hook. The Builder makes `eventDrivenResolver` server-authoritative (registry `evented` OR the 0.6.0 `serverResolverOptions.eventDriven` fallback), commits `externalFireable: true` for an evented resolver (derived at commit time — never stuck when switching away), and the `CronotonList` next-fire cell reads **"Evented"** for a trigger-only row (`external_fireable === 1` or runtime-arg keys). The store also enforces **one resolver ↔ one cronoton** — a second `createCodexCronoton` reusing a bound `server_resolver` throws `CodexCronotonValidationError` naming the existing id (→ 400). **Deliberate reversal of 0.6.0's HMAC stance:** an evented row is now `external_fireable = 1` and thus HMAC-fireable — a conscious choice codifying Pythia's already-shipped production behavior (v2.7.19/2.7.20), giving one persisted signal the store, Builder, and list all read; manually firing an evented resolver just re-runs its idempotent resolve (no-ops when nothing is ready). The published 0.6.0 `eventDriven` surface is kept intact as an additive fallback; ordinary scheduled resolvers are unchanged. Released 2026-08-03. **871 specs pass.**
|
|
248
|
+
|
|
241
249
|
**v0.6.1** — Fix a CronotonList white-screen crash on any non-empty list. `listCodexCronotons` returned a camelCase 9-field projection while the read handler declares `CodexCronotonRow[]` and `CronotonList` renders full snake_case fields — so `pact_code`/`schedule_mode`/`schedule_config_json`/`next_fire_at`/`last_fire_at`/`runtime_arg_keys`/`description`/`server_resolver` were all `undefined` and `pactPreview(row.pact_code).replace(...)` crashed. The list now returns full `CodexCronotonRow`s via `SELECT *` (matching the declared type and what the UI reads), and `pactPreview` guards a missing/non-string `pact_code` → `"(empty)"`. `CodexCronotonListItem` is now a deprecated alias of `CodexCronotonRow`. Released 2026-08-02. **850 specs pass.**
|
|
242
250
|
|
|
243
251
|
**v0.6.0** — Event-driven server resolvers. `ServerResolverOption` gains an optional `eventDriven` flag; a cronoton on an event-driven resolver commits scheduler-off (`next_fire_at = NULL`, excluded from the tick due-query) and the Builder shows an "Event-driven (host-fired)" notice instead of a schedule editor. The host fires it via the existing `executeNow` primitive, in-process — event-driven is a dedicated commit-envelope flag, deliberately NOT `externalFireable`, so it never exposes the public HMAC trigger endpoint. `server_resolver` + event-driven is allowed; `server_resolver` + `runtime_arg_keys` stays forbidden. No new DB column (the `next_fire_at = NULL` state carries it; edit and pause/resume keep it NULL). Ordinary scheduled resolvers unchanged; a non-event-driven commit body is byte-identical to 0.5.0. Released 2026-08-02. **848 specs pass.**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-
|
|
1
|
+
import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-WLZXX2SQ.js';
|
|
2
2
|
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
|
|
4
4
|
function useCronotons(query) {
|
|
@@ -203,6 +203,41 @@ function useManualBatch(id) {
|
|
|
203
203
|
}, [active, adapter, id, config.pollCadenceMs]);
|
|
204
204
|
return { batch, active, loading, error, refetch };
|
|
205
205
|
}
|
|
206
|
+
function useServerResolvers() {
|
|
207
|
+
const adapter = useKhronotonAdapter();
|
|
208
|
+
const [resolvers, setResolvers] = useState([]);
|
|
209
|
+
const [loading, setLoading] = useState(true);
|
|
210
|
+
const [error, setError] = useState(null);
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
const fetchResolvers = adapter.resolvers;
|
|
213
|
+
if (typeof fetchResolvers !== "function") {
|
|
214
|
+
setResolvers([]);
|
|
215
|
+
setError(null);
|
|
216
|
+
setLoading(false);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
let active = true;
|
|
220
|
+
setLoading(true);
|
|
221
|
+
setError(null);
|
|
222
|
+
void (async () => {
|
|
223
|
+
try {
|
|
224
|
+
const view = await fetchResolvers();
|
|
225
|
+
if (!active) return;
|
|
226
|
+
setResolvers(view.ok ? view.resolvers : []);
|
|
227
|
+
} catch (err) {
|
|
228
|
+
if (!active) return;
|
|
229
|
+
setResolvers([]);
|
|
230
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
231
|
+
} finally {
|
|
232
|
+
if (active) setLoading(false);
|
|
233
|
+
}
|
|
234
|
+
})();
|
|
235
|
+
return () => {
|
|
236
|
+
active = false;
|
|
237
|
+
};
|
|
238
|
+
}, [adapter]);
|
|
239
|
+
return { resolvers, loading, error };
|
|
240
|
+
}
|
|
206
241
|
function useGatedAction(makeCall, onNeedConfirm, onSuccess) {
|
|
207
242
|
const [pending, setPending] = useState(false);
|
|
208
243
|
const [error, setError] = useState(null);
|
|
@@ -283,10 +318,13 @@ function useCronotonActions(id, options = {}) {
|
|
|
283
318
|
onSuccess
|
|
284
319
|
);
|
|
285
320
|
const remove = useGatedAction(
|
|
286
|
-
useCallback(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
321
|
+
useCallback(
|
|
322
|
+
(runOpts) => {
|
|
323
|
+
const target = requireId(id, "delete");
|
|
324
|
+
return (opts) => adapter.delete(target, { ...opts, force: runOpts?.force });
|
|
325
|
+
},
|
|
326
|
+
[adapter, id]
|
|
327
|
+
),
|
|
290
328
|
onNeedConfirm,
|
|
291
329
|
onSuccess
|
|
292
330
|
);
|
|
@@ -376,4 +414,4 @@ function useRecoverFire() {
|
|
|
376
414
|
);
|
|
377
415
|
}
|
|
378
416
|
|
|
379
|
-
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useSimulate, useStartBatch, useTrigger };
|
|
417
|
+
export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useServerResolvers, useSimulate, useStartBatch, useTrigger };
|
|
@@ -1023,6 +1023,121 @@ function recoverFire(fireId, requestKey, dep) {
|
|
|
1023
1023
|
).run(requestKey, (/* @__PURE__ */ new Date()).toISOString(), fireId);
|
|
1024
1024
|
return res.changes > 0;
|
|
1025
1025
|
}
|
|
1026
|
+
|
|
1027
|
+
// src/server/resolvers.ts
|
|
1028
|
+
var SERVER_RESOLVERS = {};
|
|
1029
|
+
function getServerResolver(name) {
|
|
1030
|
+
return SERVER_RESOLVERS[name];
|
|
1031
|
+
}
|
|
1032
|
+
function listServerResolvers() {
|
|
1033
|
+
return Object.entries(SERVER_RESOLVERS).map(([name, r]) => ({ name, kind: r.kind, evented: r.evented === true })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
1034
|
+
}
|
|
1035
|
+
function resolveServerVars(name, dep) {
|
|
1036
|
+
const r = SERVER_RESOLVERS[name];
|
|
1037
|
+
return r && r.kind === "single-tx" ? r.resolve(dep) : null;
|
|
1038
|
+
}
|
|
1039
|
+
async function dispatchMultiTxResolver(name, opts) {
|
|
1040
|
+
const r = SERVER_RESOLVERS[name];
|
|
1041
|
+
if (!r) throw new Error(`unknown server resolver: ${name}`);
|
|
1042
|
+
if (r.kind !== "multi-tx") {
|
|
1043
|
+
throw new Error(`server resolver "${name}" is not a multi-tx resolver (kind=${r.kind})`);
|
|
1044
|
+
}
|
|
1045
|
+
return r.run(opts);
|
|
1046
|
+
}
|
|
1047
|
+
function postponed(error) {
|
|
1048
|
+
return { ok: false, mode: "fire", error, terminalIntent: null };
|
|
1049
|
+
}
|
|
1050
|
+
function adaptMultiTxSummary(summary) {
|
|
1051
|
+
const s = summary ?? {};
|
|
1052
|
+
const firstBatchKey = Array.isArray(s.batches) && s.batches.length > 0 ? s.batches[0]?.requestKey : void 0;
|
|
1053
|
+
return {
|
|
1054
|
+
ok: true,
|
|
1055
|
+
mode: "fire",
|
|
1056
|
+
requestKey: firstBatchKey,
|
|
1057
|
+
rawResult: summary,
|
|
1058
|
+
terminalIntent: null
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
function resolveExec(opts) {
|
|
1062
|
+
if (opts.exec) return opts.exec;
|
|
1063
|
+
const ctx = {
|
|
1064
|
+
runtime: opts.runtime,
|
|
1065
|
+
resolver: opts.resolver,
|
|
1066
|
+
config: opts.config
|
|
1067
|
+
};
|
|
1068
|
+
const bound = (definition, mode) => mode === "simulate" ? executeCodexTransaction(definition, "simulate", ctx) : executeCodexTransaction(definition, "fire", ctx);
|
|
1069
|
+
return bound;
|
|
1070
|
+
}
|
|
1071
|
+
async function fireByServerResolver(definition, row, opts = {}) {
|
|
1072
|
+
if (!definition.serverResolver) {
|
|
1073
|
+
const exec = resolveExec(opts);
|
|
1074
|
+
return exec(definition, "fire");
|
|
1075
|
+
}
|
|
1076
|
+
const registered = SERVER_RESOLVERS[definition.serverResolver];
|
|
1077
|
+
if (registered && registered.kind === "multi-tx") {
|
|
1078
|
+
try {
|
|
1079
|
+
const dispatchOpts = opts.deps ?? (opts.db ? { db: opts.db } : {});
|
|
1080
|
+
const summary = await dispatchMultiTxResolver(definition.serverResolver, dispatchOpts);
|
|
1081
|
+
return adaptMultiTxSummary(summary);
|
|
1082
|
+
} catch (err2) {
|
|
1083
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
1084
|
+
return postponed(`multi-tx dispatch error: ${message}`);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return fireWithServerResolver(definition, row, opts);
|
|
1088
|
+
}
|
|
1089
|
+
async function fireWithServerResolver(definition, _row, opts = {}) {
|
|
1090
|
+
const exec = resolveExec(opts);
|
|
1091
|
+
if (!definition.serverResolver) {
|
|
1092
|
+
return exec(definition, "fire");
|
|
1093
|
+
}
|
|
1094
|
+
const registered = SERVER_RESOLVERS[definition.serverResolver];
|
|
1095
|
+
if (registered && registered.kind !== "single-tx") {
|
|
1096
|
+
return postponed(
|
|
1097
|
+
`server resolver "${definition.serverResolver}" is multi-tx \u2014 dispatch via the orchestrator, not the single-tx fire path`
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
const resolve = opts.resolve ?? registered?.resolve;
|
|
1101
|
+
const settle = opts.settle ?? registered?.settle;
|
|
1102
|
+
if (!resolve || !settle) {
|
|
1103
|
+
return postponed(`unknown server resolver: ${definition.serverResolver}`);
|
|
1104
|
+
}
|
|
1105
|
+
const { plan, payload } = resolve(opts.db ? { db: opts.db } : void 0);
|
|
1106
|
+
const fired = {
|
|
1107
|
+
...definition,
|
|
1108
|
+
payload: { ...definition.payload, ...payload }
|
|
1109
|
+
};
|
|
1110
|
+
const sim = await exec(fired, "simulate");
|
|
1111
|
+
if (!sim.ok) {
|
|
1112
|
+
opts.onEvent?.({ kind: "postponed", reason: "simulate failed", error: sim.error });
|
|
1113
|
+
return postponed(`postponed: simulate failed: ${sim.error ?? "unknown"}`);
|
|
1114
|
+
}
|
|
1115
|
+
const guard = opts.config?.singleTxGasGuard ?? SINGLE_TX_GAS_GUARD;
|
|
1116
|
+
const gasUsed = sim.gasUsed ?? 0;
|
|
1117
|
+
if (gasUsed > guard) {
|
|
1118
|
+
opts.onEvent?.({ kind: "postponed", reason: "gas over single-tx guard", gasUsed, guard });
|
|
1119
|
+
return postponed(
|
|
1120
|
+
`postponed: gas ${gasUsed} exceeds single-tx guard ${guard} (multi-tx split deferred)`
|
|
1121
|
+
);
|
|
1122
|
+
}
|
|
1123
|
+
const result = await exec(fired, "fire");
|
|
1124
|
+
if (result.ok) {
|
|
1125
|
+
try {
|
|
1126
|
+
settle(plan, { db: opts.db, requestKey: result.requestKey });
|
|
1127
|
+
opts.onEvent?.({ kind: "settled", count: plan.length, requestKey: result.requestKey });
|
|
1128
|
+
} catch (err2) {
|
|
1129
|
+
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
1130
|
+
opts.onEvent?.({
|
|
1131
|
+
kind: "settlement-needs-attention",
|
|
1132
|
+
error: message,
|
|
1133
|
+
requestKey: result.requestKey
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return result;
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// src/server/store/cronoton.ts
|
|
1026
1141
|
function computeNextOrReject(mode, config, now) {
|
|
1027
1142
|
let next;
|
|
1028
1143
|
try {
|
|
@@ -1066,8 +1181,20 @@ function commitCodexCronoton(input, opts) {
|
|
|
1066
1181
|
"server-resolver rows cannot declare runtime args"
|
|
1067
1182
|
);
|
|
1068
1183
|
}
|
|
1184
|
+
if (input.serverResolver) {
|
|
1185
|
+
const existing = findCodexCronotonIdByServerResolver(input.serverResolver, {
|
|
1186
|
+
db: opts.db
|
|
1187
|
+
});
|
|
1188
|
+
if (existing) {
|
|
1189
|
+
throw new CodexCronotonValidationError(
|
|
1190
|
+
`server resolver "${input.serverResolver}" is already bound to cronoton ${existing} \u2014 delete it first`
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1069
1194
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
1070
|
-
const
|
|
1195
|
+
const evented = getServerResolver(input.serverResolver ?? "")?.evented === true;
|
|
1196
|
+
const externalFireable = input.externalFireable === true || evented;
|
|
1197
|
+
const triggerOnly = externalFireable || runtimeArgKeys.length > 0 || input.eventDriven === true;
|
|
1071
1198
|
const nextFireAt = triggerOnly ? null : computeNextOrReject(input.scheduleMode, input.scheduleConfig, now).toISOString();
|
|
1072
1199
|
const id = crypto2.randomUUID();
|
|
1073
1200
|
const nowIso = now.toISOString();
|
|
@@ -1090,7 +1217,7 @@ function commitCodexCronoton(input, opts) {
|
|
|
1090
1217
|
input.scheduleMode,
|
|
1091
1218
|
JSON.stringify(input.scheduleConfig),
|
|
1092
1219
|
input.serverResolver ?? null,
|
|
1093
|
-
|
|
1220
|
+
externalFireable ? 1 : 0,
|
|
1094
1221
|
runtimeArgKeys.length > 0 ? JSON.stringify(runtimeArgKeys) : null,
|
|
1095
1222
|
nextFireAt,
|
|
1096
1223
|
nowIso,
|
|
@@ -1103,6 +1230,13 @@ function getCodexCronoton(id, dep) {
|
|
|
1103
1230
|
const row = dep.db.prepare("SELECT * FROM codex_cronotons WHERE id = ?").get(id);
|
|
1104
1231
|
return row ?? null;
|
|
1105
1232
|
}
|
|
1233
|
+
function findCodexCronotonIdByServerResolver(serverResolver, dep) {
|
|
1234
|
+
const row = dep.db.prepare(
|
|
1235
|
+
`SELECT id FROM codex_cronotons WHERE server_resolver = ?
|
|
1236
|
+
ORDER BY created_at DESC LIMIT 1`
|
|
1237
|
+
).get(serverResolver);
|
|
1238
|
+
return row?.id ?? null;
|
|
1239
|
+
}
|
|
1106
1240
|
function listCodexCronotons(params, dep) {
|
|
1107
1241
|
const limit = Math.min(Math.max(params.limit ?? 50, 1), 200);
|
|
1108
1242
|
const offset = Math.max(params.offset ?? 0, 0);
|
|
@@ -1176,29 +1310,36 @@ function editCodexCronoton(id, patch, opts) {
|
|
|
1176
1310
|
scheduleChanged = true;
|
|
1177
1311
|
changedFields.push("schedule");
|
|
1178
1312
|
}
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1313
|
+
const resolverName = patch.serverResolver !== void 0 ? patch.serverResolver : row.server_resolver;
|
|
1314
|
+
const evented = getServerResolver(resolverName ?? "")?.evented === true;
|
|
1315
|
+
const prevEvented = getServerResolver(row.server_resolver ?? "")?.evented === true;
|
|
1316
|
+
const genuineExternalFireable = Boolean(rowExternalFireable(row)) && !prevEvented;
|
|
1317
|
+
const rowSchedulerOff = evented || rowRuntimeArgKeys(row).length > 0 || genuineExternalFireable;
|
|
1318
|
+
const eventedDeparted = prevEvented && !evented;
|
|
1319
|
+
if (patch.eventDriven === true || evented) {
|
|
1181
1320
|
if (nextFireAt !== null && !changedFields.includes("schedule")) {
|
|
1182
1321
|
changedFields.push("schedule");
|
|
1183
1322
|
}
|
|
1184
1323
|
nextFireAt = null;
|
|
1185
|
-
} else if (scheduleChanged && !
|
|
1324
|
+
} else if ((scheduleChanged || eventedDeparted) && !rowSchedulerOff) {
|
|
1186
1325
|
const next = computeNextOrReject(
|
|
1187
1326
|
nextScheduleMode,
|
|
1188
1327
|
JSON.parse(nextScheduleConfigJson),
|
|
1189
1328
|
opts.now ?? /* @__PURE__ */ new Date()
|
|
1190
1329
|
);
|
|
1191
1330
|
nextFireAt = next.toISOString();
|
|
1331
|
+
if (!changedFields.includes("schedule")) changedFields.push("schedule");
|
|
1192
1332
|
}
|
|
1193
1333
|
if (changedFields.length === 0) {
|
|
1194
1334
|
return { changedFields, nextFireAt };
|
|
1195
1335
|
}
|
|
1336
|
+
const nextExternalFireable = evented ? 1 : genuineExternalFireable ? 1 : 0;
|
|
1196
1337
|
db.prepare(
|
|
1197
1338
|
`UPDATE codex_cronotons
|
|
1198
1339
|
SET name = ?, description = ?, pact_code = ?, config_json = ?,
|
|
1199
1340
|
payload_json = ?, gas_payer_json = ?, signers_json = ?,
|
|
1200
1341
|
schedule_mode = ?, schedule_config_json = ?, server_resolver = ?,
|
|
1201
|
-
next_fire_at = ?, modified_at = ?
|
|
1342
|
+
external_fireable = ?, next_fire_at = ?, modified_at = ?
|
|
1202
1343
|
WHERE id = ?`
|
|
1203
1344
|
).run(
|
|
1204
1345
|
nextName,
|
|
@@ -1211,6 +1352,7 @@ function editCodexCronoton(id, patch, opts) {
|
|
|
1211
1352
|
nextScheduleMode,
|
|
1212
1353
|
nextScheduleConfigJson,
|
|
1213
1354
|
nextServerResolver,
|
|
1355
|
+
nextExternalFireable,
|
|
1214
1356
|
nextFireAt,
|
|
1215
1357
|
(opts.now ?? /* @__PURE__ */ new Date()).toISOString(),
|
|
1216
1358
|
id
|
|
@@ -1355,116 +1497,6 @@ function computeDefinitionFingerprint(row) {
|
|
|
1355
1497
|
return crypto2.createHash("sha256").update(canonical).digest("hex");
|
|
1356
1498
|
}
|
|
1357
1499
|
|
|
1358
|
-
// src/server/resolvers.ts
|
|
1359
|
-
var SERVER_RESOLVERS = {};
|
|
1360
|
-
function getServerResolver(name) {
|
|
1361
|
-
return SERVER_RESOLVERS[name];
|
|
1362
|
-
}
|
|
1363
|
-
function resolveServerVars(name, dep) {
|
|
1364
|
-
const r = SERVER_RESOLVERS[name];
|
|
1365
|
-
return r && r.kind === "single-tx" ? r.resolve(dep) : null;
|
|
1366
|
-
}
|
|
1367
|
-
async function dispatchMultiTxResolver(name, opts) {
|
|
1368
|
-
const r = SERVER_RESOLVERS[name];
|
|
1369
|
-
if (!r) throw new Error(`unknown server resolver: ${name}`);
|
|
1370
|
-
if (r.kind !== "multi-tx") {
|
|
1371
|
-
throw new Error(`server resolver "${name}" is not a multi-tx resolver (kind=${r.kind})`);
|
|
1372
|
-
}
|
|
1373
|
-
return r.run(opts);
|
|
1374
|
-
}
|
|
1375
|
-
function postponed(error) {
|
|
1376
|
-
return { ok: false, mode: "fire", error, terminalIntent: null };
|
|
1377
|
-
}
|
|
1378
|
-
function adaptMultiTxSummary(summary) {
|
|
1379
|
-
const s = summary ?? {};
|
|
1380
|
-
const firstBatchKey = Array.isArray(s.batches) && s.batches.length > 0 ? s.batches[0]?.requestKey : void 0;
|
|
1381
|
-
return {
|
|
1382
|
-
ok: true,
|
|
1383
|
-
mode: "fire",
|
|
1384
|
-
requestKey: firstBatchKey,
|
|
1385
|
-
rawResult: summary,
|
|
1386
|
-
terminalIntent: null
|
|
1387
|
-
};
|
|
1388
|
-
}
|
|
1389
|
-
function resolveExec(opts) {
|
|
1390
|
-
if (opts.exec) return opts.exec;
|
|
1391
|
-
const ctx = {
|
|
1392
|
-
runtime: opts.runtime,
|
|
1393
|
-
resolver: opts.resolver,
|
|
1394
|
-
config: opts.config
|
|
1395
|
-
};
|
|
1396
|
-
const bound = (definition, mode) => mode === "simulate" ? executeCodexTransaction(definition, "simulate", ctx) : executeCodexTransaction(definition, "fire", ctx);
|
|
1397
|
-
return bound;
|
|
1398
|
-
}
|
|
1399
|
-
async function fireByServerResolver(definition, row, opts = {}) {
|
|
1400
|
-
if (!definition.serverResolver) {
|
|
1401
|
-
const exec = resolveExec(opts);
|
|
1402
|
-
return exec(definition, "fire");
|
|
1403
|
-
}
|
|
1404
|
-
const registered = SERVER_RESOLVERS[definition.serverResolver];
|
|
1405
|
-
if (registered && registered.kind === "multi-tx") {
|
|
1406
|
-
try {
|
|
1407
|
-
const dispatchOpts = opts.deps ?? (opts.db ? { db: opts.db } : {});
|
|
1408
|
-
const summary = await dispatchMultiTxResolver(definition.serverResolver, dispatchOpts);
|
|
1409
|
-
return adaptMultiTxSummary(summary);
|
|
1410
|
-
} catch (err2) {
|
|
1411
|
-
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
1412
|
-
return postponed(`multi-tx dispatch error: ${message}`);
|
|
1413
|
-
}
|
|
1414
|
-
}
|
|
1415
|
-
return fireWithServerResolver(definition, row, opts);
|
|
1416
|
-
}
|
|
1417
|
-
async function fireWithServerResolver(definition, _row, opts = {}) {
|
|
1418
|
-
const exec = resolveExec(opts);
|
|
1419
|
-
if (!definition.serverResolver) {
|
|
1420
|
-
return exec(definition, "fire");
|
|
1421
|
-
}
|
|
1422
|
-
const registered = SERVER_RESOLVERS[definition.serverResolver];
|
|
1423
|
-
if (registered && registered.kind !== "single-tx") {
|
|
1424
|
-
return postponed(
|
|
1425
|
-
`server resolver "${definition.serverResolver}" is multi-tx \u2014 dispatch via the orchestrator, not the single-tx fire path`
|
|
1426
|
-
);
|
|
1427
|
-
}
|
|
1428
|
-
const resolve = opts.resolve ?? registered?.resolve;
|
|
1429
|
-
const settle = opts.settle ?? registered?.settle;
|
|
1430
|
-
if (!resolve || !settle) {
|
|
1431
|
-
return postponed(`unknown server resolver: ${definition.serverResolver}`);
|
|
1432
|
-
}
|
|
1433
|
-
const { plan, payload } = resolve(opts.db ? { db: opts.db } : void 0);
|
|
1434
|
-
const fired = {
|
|
1435
|
-
...definition,
|
|
1436
|
-
payload: { ...definition.payload, ...payload }
|
|
1437
|
-
};
|
|
1438
|
-
const sim = await exec(fired, "simulate");
|
|
1439
|
-
if (!sim.ok) {
|
|
1440
|
-
opts.onEvent?.({ kind: "postponed", reason: "simulate failed", error: sim.error });
|
|
1441
|
-
return postponed(`postponed: simulate failed: ${sim.error ?? "unknown"}`);
|
|
1442
|
-
}
|
|
1443
|
-
const guard = opts.config?.singleTxGasGuard ?? SINGLE_TX_GAS_GUARD;
|
|
1444
|
-
const gasUsed = sim.gasUsed ?? 0;
|
|
1445
|
-
if (gasUsed > guard) {
|
|
1446
|
-
opts.onEvent?.({ kind: "postponed", reason: "gas over single-tx guard", gasUsed, guard });
|
|
1447
|
-
return postponed(
|
|
1448
|
-
`postponed: gas ${gasUsed} exceeds single-tx guard ${guard} (multi-tx split deferred)`
|
|
1449
|
-
);
|
|
1450
|
-
}
|
|
1451
|
-
const result = await exec(fired, "fire");
|
|
1452
|
-
if (result.ok) {
|
|
1453
|
-
try {
|
|
1454
|
-
settle(plan, { db: opts.db, requestKey: result.requestKey });
|
|
1455
|
-
opts.onEvent?.({ kind: "settled", count: plan.length, requestKey: result.requestKey });
|
|
1456
|
-
} catch (err2) {
|
|
1457
|
-
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
1458
|
-
opts.onEvent?.({
|
|
1459
|
-
kind: "settlement-needs-attention",
|
|
1460
|
-
error: message,
|
|
1461
|
-
requestKey: result.requestKey
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
return result;
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
1500
|
// src/handlers/http.ts
|
|
1469
1501
|
function json(status, body) {
|
|
1470
1502
|
return { status, body };
|
|
@@ -1626,4 +1658,4 @@ async function runGated2(fn, options = {}) {
|
|
|
1626
1658
|
}
|
|
1627
1659
|
}
|
|
1628
1660
|
|
|
1629
|
-
export { CodexCronotonValidationError, DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, InvalidScheduleConfigError, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, applyRuntimeArgs, applyTerminalIntent, assertAdapter, cancelManualBatch, commitCodexCronoton, computeDefinitionFingerprint, computeNextFire, createManualBatch, defaultOpenAuth, defaultSignerSource, deleteCodexCronoton, editCodexCronoton, emptySnapshot, err, executeCodexTransaction, fireByServerResolver, getActiveManualBatchForCronoton, getCodexCronoton, getServerResolver, installSchema, json, listCodexCronotons, listFires, manualBatchView, parseRuntimeArgKeys, pauseCodexCronoton, recordFire, recoverFire, resolveConfig, resolveServerVars, resumeCodexCronoton, rowRuntimeArgKeys, rowToDefinition, runGated2 as runGated, summariseSchedule, useKhronoton, useKhronotonAdapter, useKhronotonConfig, validateRuntimeArgs, withConfirm, withRead };
|
|
1661
|
+
export { CodexCronotonValidationError, DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, InvalidScheduleConfigError, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, applyRuntimeArgs, applyTerminalIntent, assertAdapter, cancelManualBatch, commitCodexCronoton, computeDefinitionFingerprint, computeNextFire, createManualBatch, defaultOpenAuth, defaultSignerSource, deleteCodexCronoton, editCodexCronoton, emptySnapshot, err, executeCodexTransaction, fireByServerResolver, getActiveManualBatchForCronoton, getCodexCronoton, getServerResolver, installSchema, json, listCodexCronotons, listFires, listServerResolvers, manualBatchView, parseRuntimeArgKeys, pauseCodexCronoton, recordFire, recoverFire, resolveConfig, resolveServerVars, resumeCodexCronoton, rowRuntimeArgKeys, rowToDefinition, runGated2 as runGated, summariseSchedule, useKhronoton, useKhronotonAdapter, useKhronotonConfig, validateRuntimeArgs, withConfirm, withRead };
|
|
@@ -1,9 +1,83 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { b as CodexTxConfig, c as CodexGasPayer, d as CodexSigner, S as ScheduleMode, e as ScheduleConfig, C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from './types-u_nUX1Bg.js';
|
|
3
|
+
import { b as DbDep, D as Database } from './seams-DapFZ4sM.js';
|
|
3
4
|
|
|
4
5
|
/** A validated bag of runtime args — every value is a string (Pact `read-string`). */
|
|
5
6
|
type RuntimeArgs = Record<string, string>;
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Generic server-resolver registry + the kind-routed fire dispatcher.
|
|
10
|
+
*
|
|
11
|
+
* A "server resolver" is a named hook consulted at fire time. Two kinds are
|
|
12
|
+
* distinguished by a `kind` discriminator so the tick can route each to the
|
|
13
|
+
* right execution path:
|
|
14
|
+
*
|
|
15
|
+
* - 'single-tx' — fills designated payload keys from live server data, merges
|
|
16
|
+
* them into ONE {@link CodexTxDefinition}, runs a safety-guard simulate,
|
|
17
|
+
* fires ONE transaction, then settles the server ledger. Dispatched through
|
|
18
|
+
* {@link fireWithServerResolver} (resolve → simulate-guard → fire → settle).
|
|
19
|
+
*
|
|
20
|
+
* - 'multi-tx' — an orchestrator that owns its own fire cardinality and guard
|
|
21
|
+
* (N independent fires). It does NOT ride the single-merge fire path; it is
|
|
22
|
+
* dispatched to its own `run` orchestrator via {@link dispatchMultiTxResolver}.
|
|
23
|
+
* The `run` implementation is supplied by the registering module.
|
|
24
|
+
*
|
|
25
|
+
* This module carries NO consumer-domain coupling: the concrete resolvers and
|
|
26
|
+
* their settlement-event sinks belong to the host, which registers them and may
|
|
27
|
+
* observe settlement outcomes through the optional `onEvent` hook on the fire
|
|
28
|
+
* opts. The only runtime dependency is the Phase-3 executor, bound at the
|
|
29
|
+
* dispatch boundary via an injectable `exec` seam (default: a ctx-bound closure).
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/** The plan + payload a single-tx resolver produces for one fire. */
|
|
33
|
+
interface ServerResolverResolution {
|
|
34
|
+
/** Opaque per-entry settlement plan, forwarded verbatim to `settle`. */
|
|
35
|
+
plan: unknown[];
|
|
36
|
+
/** Payload keys merged into the fired definition before simulate/fire. */
|
|
37
|
+
payload: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** Opts passed to a single-tx resolver's `settle` after a successful fire. */
|
|
40
|
+
interface SettleOpts {
|
|
41
|
+
db?: Database;
|
|
42
|
+
/** The landed on-chain request key, so the ledger write links to the tx. */
|
|
43
|
+
requestKey?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A single-tx server resolver: how to fill the payload + how to settle on
|
|
47
|
+
* success. The resolve/settle pair is consumed by {@link fireWithServerResolver}.
|
|
48
|
+
*/
|
|
49
|
+
interface SingleTxResolver {
|
|
50
|
+
kind: "single-tx";
|
|
51
|
+
/**
|
|
52
|
+
* When true, this resolver is fired by an in-process EVENT, never by a
|
|
53
|
+
* schedule — a cronoton bound to it is scheduleless (the store forces
|
|
54
|
+
* `external_fireable = 1` / `next_fire_at = NULL`) and the Builder hides its
|
|
55
|
+
* schedule controls.
|
|
56
|
+
*/
|
|
57
|
+
evented?: boolean;
|
|
58
|
+
resolve(dep?: DbDep): ServerResolverResolution;
|
|
59
|
+
settle(plan: unknown[], opts?: SettleOpts): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A multi-tx server resolver: a net-new orchestrator that owns its own fire
|
|
63
|
+
* cardinality and guard. `run` is the seam the tick dispatches to; its concrete
|
|
64
|
+
* signature/return is defined by the orchestrator that registers it. The
|
|
65
|
+
* registry only knows it is an async orchestrator taking an injected opts bag.
|
|
66
|
+
*/
|
|
67
|
+
interface MultiTxResolver {
|
|
68
|
+
kind: "multi-tx";
|
|
69
|
+
/**
|
|
70
|
+
* When true, this resolver is fired by an in-process EVENT, never by a
|
|
71
|
+
* schedule — a cronoton bound to it is scheduleless (the store forces
|
|
72
|
+
* `external_fireable = 1` / `next_fire_at = NULL`) and the Builder hides its
|
|
73
|
+
* schedule controls.
|
|
74
|
+
*/
|
|
75
|
+
evented?: boolean;
|
|
76
|
+
run(opts: unknown): Promise<unknown>;
|
|
77
|
+
}
|
|
78
|
+
/** Either resolver kind; the `kind` field discriminates the union. */
|
|
79
|
+
type ServerResolver = SingleTxResolver | MultiTxResolver;
|
|
80
|
+
|
|
7
81
|
/**
|
|
8
82
|
* The framework-agnostic HTTP contract for `@ancientpantheon/khronoton-core/handlers`.
|
|
9
83
|
*
|
|
@@ -146,6 +220,8 @@ interface CommitBody {
|
|
|
146
220
|
*/
|
|
147
221
|
interface ConfirmOpts {
|
|
148
222
|
confirmed?: boolean;
|
|
223
|
+
/** Permits deleting a server-resolver/system row (sent as ?force=1 to DELETE). Ignored by non-delete methods. */
|
|
224
|
+
force?: boolean;
|
|
149
225
|
}
|
|
150
226
|
/** Optional filters for the cronoton list (all default in the read handler). */
|
|
151
227
|
interface ListCronotonsQuery {
|
|
@@ -191,6 +267,15 @@ interface SignersView {
|
|
|
191
267
|
ok: true;
|
|
192
268
|
signers: CodexSignerDescriptor[];
|
|
193
269
|
}
|
|
270
|
+
/** `GET /resolvers` body — the registered server resolvers + their `evented` flag. */
|
|
271
|
+
interface ResolversView {
|
|
272
|
+
ok: true;
|
|
273
|
+
resolvers: {
|
|
274
|
+
name: string;
|
|
275
|
+
kind: ServerResolver["kind"];
|
|
276
|
+
evented: boolean;
|
|
277
|
+
}[];
|
|
278
|
+
}
|
|
194
279
|
/** `POST /` body — the new id + its first scheduled fire. */
|
|
195
280
|
interface CommitView {
|
|
196
281
|
ok: true;
|
|
@@ -272,6 +357,13 @@ interface KhronotonAdapter {
|
|
|
272
357
|
get(id: string): Promise<GetCronotonView>;
|
|
273
358
|
fires(query: FiresQuery): Promise<FiresView>;
|
|
274
359
|
signers(): Promise<SignersView>;
|
|
360
|
+
/**
|
|
361
|
+
* `GET /resolvers` — OPTIONAL. Added in 0.7.0; an adapter predating it (or one
|
|
362
|
+
* whose backend can't serve it) simply omits it, and the provider degrades
|
|
363
|
+
* gracefully. Deliberately NOT in `REQUIRED_METHODS` — requiring it would be a
|
|
364
|
+
* breaking change for every existing consumer/fake adapter on upgrade.
|
|
365
|
+
*/
|
|
366
|
+
resolvers?(): Promise<ResolversView>;
|
|
275
367
|
commit(body: CommitBody, opts?: ConfirmOpts): Promise<CommitView>;
|
|
276
368
|
edit(id: string, patch: EditPatch, opts?: ConfirmOpts): Promise<EditView>;
|
|
277
369
|
pause(id: string, opts?: ConfirmOpts): Promise<ToggleView>;
|
|
@@ -368,4 +460,4 @@ interface UseKhronotonResult {
|
|
|
368
460
|
*/
|
|
369
461
|
declare function useKhronoton(): UseKhronotonResult;
|
|
370
462
|
|
|
371
|
-
export {
|
|
463
|
+
export { assertAdapter as A, emptySnapshot as B, type CommitBody as C, type DeleteView as D, type EditPatch as E, type FiresQuery as F, type GetBatchView as G, type HandlerRequest as H, type KhronotonProviderProps as K, type ListCronotonsQuery as L, type ResolversView as R, type SimulateEnvelope as S, type ToggleView as T, type UseKhronotonResult as U, type CommitView as a, type EditView as b, type CancelBatchView as c, type ExecuteView as d, type RecoverView as e, type SimulateView as f, type StartBatchView as g, type RuntimeArgs as h, type HandlerResponse as i, type KhronotonAdapter as j, type SignerSource as k, type CodexSignerDescriptor as l, type ConfirmGate as m, type ConfirmOpts as n, DEFAULT_EXPLORER_BASE as o, DEFAULT_PAGE_SIZE as p, DEFAULT_POLL_CADENCE_MS as q, type FiresView as r, type GetCronotonView as s, type KhronotonConfig as t, useKhronoton as u, type KhronotonSnapshot as v, type ListCronotonsView as w, type RenderMultiTx as x, type ServerResolverOption as y, type SignersView as z };
|
|
@@ -66,6 +66,9 @@ export declare function resumeCodexCronoton(ctx: HandlerContext, req: HandlerReq
|
|
|
66
66
|
* DELETE /[id] — remove a codex cronoton. Confirm-gated. A row bound to a server
|
|
67
67
|
* resolver is a SYSTEM cronoton: it is delete-locked (pause to disable instead),
|
|
68
68
|
* so the handler loads the row first and refuses with 409 before the store's
|
|
69
|
-
* unconditional delete would run (REQ-H05)
|
|
69
|
+
* unconditional delete would run (REQ-H05) — UNLESS an explicit `?force=1`
|
|
70
|
+
* (`"1"`/`"true"`) query param accompanies the request, which the operator sets
|
|
71
|
+
* only after accepting the system-delete warning; a forced delete is recorded in
|
|
72
|
+
* the audit trail as `forced: true`.
|
|
70
73
|
*/
|
|
71
74
|
export declare function deleteCodexCronoton(ctx: HandlerContext, req: HandlerRequest): Promise<HandlerResponse>;
|