@orthograph/prove 0.0.0-stage → 0.1.0-next.1

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.
Files changed (245) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +32 -0
  4. package/dist/index.js +32 -0
  5. package/dist/modules/build/internal/manifest.d.ts +15 -0
  6. package/dist/modules/build/internal/manifest.js +38 -0
  7. package/dist/modules/build/service.d.ts +2 -0
  8. package/dist/modules/build/service.js +74 -0
  9. package/dist/modules/build/types.d.ts +39 -0
  10. package/dist/modules/build/types.js +4 -0
  11. package/dist/modules/environments/internal/collector.d.ts +2 -0
  12. package/dist/modules/environments/internal/collector.js +5 -0
  13. package/dist/modules/environments/internal/config.d.ts +32 -0
  14. package/dist/modules/environments/internal/config.js +42 -0
  15. package/dist/modules/environments/internal/identity.d.ts +3 -0
  16. package/dist/modules/environments/internal/identity.js +17 -0
  17. package/dist/modules/environments/internal/logbook.d.ts +10 -0
  18. package/dist/modules/environments/internal/logbook.js +23 -0
  19. package/dist/modules/environments/internal/process.d.ts +41 -0
  20. package/dist/modules/environments/internal/process.js +103 -0
  21. package/dist/modules/environments/internal/secrets.d.ts +9 -0
  22. package/dist/modules/environments/internal/secrets.js +23 -0
  23. package/dist/modules/environments/internal/status.d.ts +7 -0
  24. package/dist/modules/environments/internal/status.js +31 -0
  25. package/dist/modules/environments/service.d.ts +2 -0
  26. package/dist/modules/environments/service.js +97 -0
  27. package/dist/modules/environments/types.d.ts +80 -0
  28. package/dist/modules/environments/types.js +4 -0
  29. package/dist/modules/evals/internal/calls.d.ts +19 -0
  30. package/dist/modules/evals/internal/calls.js +168 -0
  31. package/dist/modules/evals/internal/evidence.d.ts +13 -0
  32. package/dist/modules/evals/internal/evidence.js +29 -0
  33. package/dist/modules/evals/internal/run.d.ts +12 -0
  34. package/dist/modules/evals/internal/run.js +85 -0
  35. package/dist/modules/evals/internal/secrets.d.ts +5 -0
  36. package/dist/modules/evals/internal/secrets.js +72 -0
  37. package/dist/modules/evals/service.d.ts +2 -0
  38. package/dist/modules/evals/service.js +29 -0
  39. package/dist/modules/evals/testing.d.ts +12 -0
  40. package/dist/modules/evals/testing.js +15 -0
  41. package/dist/modules/evals/types.d.ts +43 -0
  42. package/dist/modules/evals/types.js +1 -0
  43. package/dist/modules/impact/internal/changed.d.ts +6 -0
  44. package/dist/modules/impact/internal/changed.js +34 -0
  45. package/dist/modules/impact/internal/closure.d.ts +12 -0
  46. package/dist/modules/impact/internal/closure.js +69 -0
  47. package/dist/modules/impact/internal/digest.d.ts +1 -0
  48. package/dist/modules/impact/internal/digest.js +2 -0
  49. package/dist/modules/impact/internal/files.d.ts +11 -0
  50. package/dist/modules/impact/internal/files.js +48 -0
  51. package/dist/modules/impact/internal/ledger.d.ts +5 -0
  52. package/dist/modules/impact/internal/ledger.js +25 -0
  53. package/dist/modules/impact/internal/linked.d.ts +4 -0
  54. package/dist/modules/impact/internal/linked.js +56 -0
  55. package/dist/modules/impact/internal/scan.d.ts +12 -0
  56. package/dist/modules/impact/internal/scan.js +66 -0
  57. package/dist/modules/impact/service.d.ts +2 -0
  58. package/dist/modules/impact/service.js +88 -0
  59. package/dist/modules/impact/types.d.ts +109 -0
  60. package/dist/modules/impact/types.js +1 -0
  61. package/dist/modules/journeys/internal/checks.d.ts +25 -0
  62. package/dist/modules/journeys/internal/checks.js +155 -0
  63. package/dist/modules/journeys/internal/d1-facts.d.ts +10 -0
  64. package/dist/modules/journeys/internal/d1-facts.js +53 -0
  65. package/dist/modules/journeys/internal/database-facts.d.ts +2 -0
  66. package/dist/modules/journeys/internal/database-facts.js +41 -0
  67. package/dist/modules/journeys/internal/device.d.ts +16 -0
  68. package/dist/modules/journeys/internal/device.js +68 -0
  69. package/dist/modules/journeys/internal/keepers.d.ts +6 -0
  70. package/dist/modules/journeys/internal/keepers.js +6 -0
  71. package/dist/modules/journeys/internal/load.d.ts +4 -0
  72. package/dist/modules/journeys/internal/load.js +94 -0
  73. package/dist/modules/journeys/internal/stand-call.d.ts +10 -0
  74. package/dist/modules/journeys/internal/stand-call.js +22 -0
  75. package/dist/modules/journeys/internal/subject.d.ts +8 -0
  76. package/dist/modules/journeys/internal/subject.js +15 -0
  77. package/dist/modules/journeys/internal/world.d.ts +70 -0
  78. package/dist/modules/journeys/internal/world.js +133 -0
  79. package/dist/modules/journeys/service.d.ts +2 -0
  80. package/dist/modules/journeys/service.js +231 -0
  81. package/dist/modules/journeys/types.d.ts +132 -0
  82. package/dist/modules/journeys/types.js +5 -0
  83. package/dist/modules/portal-feed/internal/listen.d.ts +10 -0
  84. package/dist/modules/portal-feed/internal/listen.js +32 -0
  85. package/dist/modules/portal-feed/service.d.ts +2 -0
  86. package/dist/modules/portal-feed/service.js +6 -0
  87. package/dist/modules/portal-feed/types.d.ts +30 -0
  88. package/dist/modules/portal-feed/types.js +5 -0
  89. package/dist/modules/promote/internal/environment.d.ts +6 -0
  90. package/dist/modules/promote/internal/environment.js +10 -0
  91. package/dist/modules/promote/internal/gate.d.ts +9 -0
  92. package/dist/modules/promote/internal/gate.js +37 -0
  93. package/dist/modules/promote/internal/publishing.d.ts +23 -0
  94. package/dist/modules/promote/internal/publishing.js +21 -0
  95. package/dist/modules/promote/service.d.ts +2 -0
  96. package/dist/modules/promote/service.js +112 -0
  97. package/dist/modules/promote/types.d.ts +54 -0
  98. package/dist/modules/promote/types.js +8 -0
  99. package/dist/modules/prove/internal/changed-run.d.ts +9 -0
  100. package/dist/modules/prove/internal/changed-run.js +14 -0
  101. package/dist/modules/prove/internal/device-host.d.ts +16 -0
  102. package/dist/modules/prove/internal/device-host.js +60 -0
  103. package/dist/modules/prove/internal/empty-world.d.ts +5 -0
  104. package/dist/modules/prove/internal/empty-world.js +26 -0
  105. package/dist/modules/prove/internal/exercise.d.ts +35 -0
  106. package/dist/modules/prove/internal/exercise.js +47 -0
  107. package/dist/modules/prove/internal/proof-verdicts.d.ts +5 -0
  108. package/dist/modules/prove/internal/proof-verdicts.js +37 -0
  109. package/dist/modules/prove/internal/report.d.ts +35 -0
  110. package/dist/modules/prove/internal/report.js +169 -0
  111. package/dist/modules/prove/internal/staged.d.ts +9 -0
  112. package/dist/modules/prove/internal/staged.js +30 -0
  113. package/dist/modules/prove/internal/stand.d.ts +40 -0
  114. package/dist/modules/prove/internal/stand.js +155 -0
  115. package/dist/modules/prove/internal/structured.d.ts +78 -0
  116. package/dist/modules/prove/internal/structured.js +55 -0
  117. package/dist/modules/prove/internal/test-run.d.ts +7 -0
  118. package/dist/modules/prove/internal/test-run.js +63 -0
  119. package/dist/modules/prove/service.d.ts +2 -0
  120. package/dist/modules/prove/service.js +98 -0
  121. package/dist/modules/prove/types.d.ts +120 -0
  122. package/dist/modules/prove/types.js +5 -0
  123. package/dist/modules/publish/internal/bundle.d.ts +24 -0
  124. package/dist/modules/publish/internal/bundle.js +46 -0
  125. package/dist/modules/publish/internal/env.d.ts +3 -0
  126. package/dist/modules/publish/internal/env.js +2 -0
  127. package/dist/modules/publish/internal/plan.d.ts +28 -0
  128. package/dist/modules/publish/internal/plan.js +28 -0
  129. package/dist/modules/publish/internal/registry.d.ts +24 -0
  130. package/dist/modules/publish/internal/registry.js +55 -0
  131. package/dist/modules/publish/internal/sea.d.ts +20 -0
  132. package/dist/modules/publish/internal/sea.js +77 -0
  133. package/dist/modules/publish/internal/source.d.ts +4 -0
  134. package/dist/modules/publish/internal/source.js +41 -0
  135. package/dist/modules/publish/internal/stage.d.ts +14 -0
  136. package/dist/modules/publish/internal/stage.js +95 -0
  137. package/dist/modules/publish/internal/tap.d.ts +22 -0
  138. package/dist/modules/publish/internal/tap.js +61 -0
  139. package/dist/modules/publish/service.d.ts +2 -0
  140. package/dist/modules/publish/service.js +99 -0
  141. package/dist/modules/publish/types.d.ts +80 -0
  142. package/dist/modules/publish/types.js +4 -0
  143. package/dist/modules/releases/internal/http.d.ts +12 -0
  144. package/dist/modules/releases/internal/http.js +14 -0
  145. package/dist/modules/releases/internal/stale.d.ts +13 -0
  146. package/dist/modules/releases/internal/stale.js +43 -0
  147. package/dist/modules/releases/service.d.ts +2 -0
  148. package/dist/modules/releases/service.js +59 -0
  149. package/dist/modules/releases/types.d.ts +81 -0
  150. package/dist/modules/releases/types.js +6 -0
  151. package/dist/modules/secrets/internal/file.d.ts +5 -0
  152. package/dist/modules/secrets/internal/file.js +25 -0
  153. package/dist/modules/secrets/service.d.ts +2 -0
  154. package/dist/modules/secrets/service.js +38 -0
  155. package/dist/modules/secrets/types.d.ts +44 -0
  156. package/dist/modules/secrets/types.js +7 -0
  157. package/dist/modules/server-config/internal/jsonc.d.ts +2 -0
  158. package/dist/modules/server-config/internal/jsonc.js +29 -0
  159. package/dist/modules/server-config/service.d.ts +2 -0
  160. package/dist/modules/server-config/service.js +21 -0
  161. package/dist/modules/server-config/types.d.ts +22 -0
  162. package/dist/modules/server-config/types.js +3 -0
  163. package/dist/modules/sinks/internal/axiom.d.ts +29 -0
  164. package/dist/modules/sinks/internal/axiom.js +25 -0
  165. package/dist/modules/sinks/internal/keychain.d.ts +2 -0
  166. package/dist/modules/sinks/internal/keychain.js +13 -0
  167. package/dist/modules/sinks/service.d.ts +2 -0
  168. package/dist/modules/sinks/service.js +26 -0
  169. package/dist/modules/sinks/types.d.ts +37 -0
  170. package/dist/modules/sinks/types.js +5 -0
  171. package/dist/modules/telemetry/internal/axiom-source.d.ts +2 -0
  172. package/dist/modules/telemetry/internal/axiom-source.js +108 -0
  173. package/dist/modules/telemetry/internal/binary.d.ts +11 -0
  174. package/dist/modules/telemetry/internal/binary.js +66 -0
  175. package/dist/modules/telemetry/internal/config.d.ts +13 -0
  176. package/dist/modules/telemetry/internal/config.js +22 -0
  177. package/dist/modules/telemetry/internal/file-metrics.d.ts +2 -0
  178. package/dist/modules/telemetry/internal/file-metrics.js +60 -0
  179. package/dist/modules/telemetry/internal/file-source.d.ts +2 -0
  180. package/dist/modules/telemetry/internal/file-source.js +38 -0
  181. package/dist/modules/telemetry/internal/journey-root.d.ts +44 -0
  182. package/dist/modules/telemetry/internal/journey-root.js +36 -0
  183. package/dist/modules/telemetry/internal/local.d.ts +11 -0
  184. package/dist/modules/telemetry/internal/local.js +57 -0
  185. package/dist/modules/telemetry/internal/otlp.d.ts +15 -0
  186. package/dist/modules/telemetry/internal/otlp.js +53 -0
  187. package/dist/modules/telemetry/internal/private-keys.d.ts +7 -0
  188. package/dist/modules/telemetry/internal/private-keys.js +28 -0
  189. package/dist/modules/telemetry/internal/process.d.ts +27 -0
  190. package/dist/modules/telemetry/internal/process.js +96 -0
  191. package/dist/modules/telemetry/internal/runs.d.ts +17 -0
  192. package/dist/modules/telemetry/internal/runs.js +48 -0
  193. package/dist/modules/telemetry/service.d.ts +9 -0
  194. package/dist/modules/telemetry/service.js +48 -0
  195. package/dist/modules/telemetry/types.d.ts +138 -0
  196. package/dist/modules/telemetry/types.js +13 -0
  197. package/dist/modules/test-worlds/internal/lifetime.d.ts +3 -0
  198. package/dist/modules/test-worlds/internal/lifetime.js +19 -0
  199. package/dist/modules/test-worlds/service.d.ts +2 -0
  200. package/dist/modules/test-worlds/service.js +35 -0
  201. package/dist/modules/test-worlds/types.d.ts +41 -0
  202. package/dist/modules/test-worlds/types.js +4 -0
  203. package/dist/modules/trace-trees/service.d.ts +2 -0
  204. package/dist/modules/trace-trees/service.js +40 -0
  205. package/dist/modules/trace-trees/types.d.ts +9 -0
  206. package/dist/modules/trace-trees/types.js +1 -0
  207. package/dist/modules/verdicts/internal/proof.d.ts +24 -0
  208. package/dist/modules/verdicts/internal/proof.js +59 -0
  209. package/dist/modules/verdicts/service.d.ts +16 -0
  210. package/dist/modules/verdicts/service.js +71 -0
  211. package/dist/modules/verdicts/types.d.ts +80 -0
  212. package/dist/modules/verdicts/types.js +4 -0
  213. package/dist/modules/warm/internal/source.d.ts +7 -0
  214. package/dist/modules/warm/internal/source.js +27 -0
  215. package/dist/modules/warm/service.d.ts +2 -0
  216. package/dist/modules/warm/service.js +76 -0
  217. package/dist/modules/warm/types.d.ts +43 -0
  218. package/dist/modules/warm/types.js +4 -0
  219. package/dist/modules/watch/internal/choose.d.ts +20 -0
  220. package/dist/modules/watch/internal/choose.js +24 -0
  221. package/dist/modules/watch/internal/evidence.d.ts +9 -0
  222. package/dist/modules/watch/internal/evidence.js +26 -0
  223. package/dist/modules/watch/internal/report.d.ts +18 -0
  224. package/dist/modules/watch/internal/report.js +59 -0
  225. package/dist/modules/watch/internal/tasks.d.ts +5 -0
  226. package/dist/modules/watch/internal/tasks.js +35 -0
  227. package/dist/modules/watch/service.d.ts +2 -0
  228. package/dist/modules/watch/service.js +38 -0
  229. package/dist/modules/watch/types.d.ts +44 -0
  230. package/dist/modules/watch/types.js +4 -0
  231. package/dist/modules/world/internal/ports.d.ts +8 -0
  232. package/dist/modules/world/internal/ports.js +30 -0
  233. package/dist/modules/world/internal/wrangler.d.ts +46 -0
  234. package/dist/modules/world/internal/wrangler.js +112 -0
  235. package/dist/modules/world/service.d.ts +2 -0
  236. package/dist/modules/world/service.js +46 -0
  237. package/dist/modules/world/types.d.ts +97 -0
  238. package/dist/modules/world/types.js +4 -0
  239. package/dist/modules/world-clock/internal/door.d.ts +8 -0
  240. package/dist/modules/world-clock/internal/door.js +9 -0
  241. package/dist/modules/world-clock/service.d.ts +2 -0
  242. package/dist/modules/world-clock/service.js +9 -0
  243. package/dist/modules/world-clock/types.d.ts +34 -0
  244. package/dist/modules/world-clock/types.js +1 -0
  245. package/package.json +38 -3
@@ -0,0 +1,46 @@
1
+ import { Names } from "orthograph/server";
2
+ import { randomBytes } from "node:crypto";
3
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { join, resolve } from "node:path";
5
+ import { Effect } from "effect";
6
+ import { ServerConfig } from "#modules/server-config/service.js";
7
+ import { WorldFailed } from "./types.js";
8
+ import { anyPort } from "./internal/ports.js";
9
+ import { applyMigrations, bringUp, stop } from "./internal/wrangler.js";
10
+ export const Worlds = {
11
+ anyPort,
12
+ start: ({ root, port: asked, name, otlp, portalFeed, environment, secretEnv: given, chain, stands, nonce }) => Effect.gen(function* () {
13
+ const generated = resolve(root, "generated/server/wrangler.jsonc");
14
+ if (!existsSync(generated))
15
+ return yield* new WorldFailed({ message: `${generated} is missing: run nx sync first` });
16
+ // A fresh world each run: stage one has no migrations between versions.
17
+ const state = resolve(root, Names.folder, name);
18
+ rmSync(state, { recursive: true, force: true });
19
+ mkdirSync(state, { recursive: true });
20
+ // With the portal's built client in reach, the world runs a config derived from the generated one that serves it (K19).
21
+ const client = ServerConfig.clientOf(root);
22
+ const config = client === undefined ? generated : join(state, "wrangler.jsonc");
23
+ if (client !== undefined)
24
+ writeFileSync(config, ServerConfig.derive(root, readFileSync(generated, "utf8"), client));
25
+ yield* applyMigrations(config, state);
26
+ // The chain is acquired first, so it is released last: the Worker never outlives the chain it talks to.
27
+ const chained = chain === undefined ? undefined : yield* chain;
28
+ // So are the stand-ins, after the wipe so their folders under the state survive, and their addresses are the Worker's secrets.
29
+ const stood = stands === undefined ? undefined : yield* stands(state);
30
+ const standEnv = stood?.env ?? {};
31
+ const secretEnv = given === undefined && Object.keys(standEnv).length === 0 ? undefined : { ...given, ...standEnv };
32
+ const log = join(state, "wrangler.log");
33
+ const secret = randomBytes(32).toString("hex");
34
+ // Port 0 asks for any free port; wrangler is told a named one, and `url` is the one it got.
35
+ const port = asked === 0 ? yield* anyPort : asked;
36
+ const url = `http://127.0.0.1:${port}`;
37
+ const vars = { AUTH_SECRET: secret, [Names.variable("ENVIRONMENT")]: environment ?? "local", ...(otlp ? { OTLP_URL: otlp } : {}), ...(portalFeed ? { ORTHO_PORTAL_FEED: portalFeed } : {}), ...(nonce ? { ORTHO_WORLD_NONCE: nonce } : {}) };
38
+ yield* Effect.acquireRelease(bringUp({ config, state, port, log, vars, ...(secretEnv ? { secretEnv } : {}) }, "/_world/health"), stop);
39
+ return { url, log, ...(chained ? { chain: chained } : {}), ...(stood ? { stands: stood.addresses } : {}) };
40
+ }),
41
+ launch: ({ config, state, port, log, pidFile, envFile, secretEnv, ready }) => Effect.gen(function* () {
42
+ yield* applyMigrations(config, state);
43
+ const child = yield* bringUp({ config, state, port, log, pidFile, ...(envFile ? { envFile } : {}), ...(secretEnv ? { secretEnv } : {}), detached: true }, ready);
44
+ return { pid: child.pid, url: `http://127.0.0.1:${port}`, log };
45
+ }),
46
+ };
@@ -0,0 +1,97 @@
1
+ import { type Effect, type Redacted, type Scope } from "effect";
2
+ declare const WorldFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
3
+ readonly _tag: "WorldFailed";
4
+ } & Readonly<A>;
5
+ export declare class WorldFailed extends WorldFailed_base<{
6
+ readonly message: string;
7
+ /** wrangler exited because a socket it picked was already taken: starting again can work. */
8
+ readonly taken?: boolean;
9
+ }> {
10
+ }
11
+ /** A chain a world stands up beside its Worker (`Stand.process`, M1.31): where it answers, and which chain it is. */
12
+ export interface ChainStand {
13
+ readonly rpcUrl: string;
14
+ readonly chainId: number;
15
+ /** The funded accounts the world made, their keys redacted: what a journey's `s.world.chain` is built from. */
16
+ readonly accounts?: ReadonlyArray<{
17
+ readonly address: string;
18
+ readonly privateKey: Redacted.Redacted<string>;
19
+ }>;
20
+ }
21
+ /** The stand-ins a world stood up: what its Worker is told of them, and each one's address by mount (G16-adapter-mounts calls 3 and 4). */
22
+ export interface StandIns {
23
+ readonly env: Readonly<Record<string, string>>;
24
+ readonly addresses: Readonly<Record<string, string>>;
25
+ }
26
+ export interface Running {
27
+ readonly url: string;
28
+ /** The address of each stand-in the world stood up, by mount: where a journey's command to one goes. */
29
+ readonly stands?: Readonly<Record<string, string>>;
30
+ /** The world's chain, when it was asked for one. It lives exactly as long as the world. */
31
+ readonly chain?: ChainStand;
32
+ /** Where wrangler's own output goes, for when something looks wrong. */
33
+ readonly log: string;
34
+ }
35
+ /** A `wrangler dev` kept running by whoever asked for it: a long-lived environment. */
36
+ export interface Launched {
37
+ readonly pid: number;
38
+ readonly url: string;
39
+ readonly log: string;
40
+ }
41
+ export interface WorldsApi {
42
+ /** A port the system says is free on 127.0.0.1 now (what `port: 0` means), for callers that must name one. */
43
+ readonly anyPort: Effect.Effect<number, WorldFailed>;
44
+ /**
45
+ * Start `wrangler dev` on a config the caller made, detached in its own process group so it outlives this process:
46
+ * the local database's migrations applied first, then wrangler on `port` with its own `state` folder and inspector
47
+ * port, started again if a socket it picked was taken, and ready once `ready` (a path) answers. Stopping it is the
48
+ * caller's: the pid is theirs to keep.
49
+ */
50
+ readonly launch: (options: {
51
+ readonly config: string;
52
+ readonly state: string;
53
+ readonly port: number;
54
+ readonly log: string;
55
+ /** Written with wrangler's process id the moment it starts. */
56
+ readonly pidFile: string;
57
+ /** A file of secrets for wrangler's `--env-file`. */
58
+ readonly envFile?: string;
59
+ /** Secrets for the Worker that never touch a file or an argument (the telemetry sinks' tokens). */
60
+ readonly secretEnv?: Readonly<Record<string, string>>;
61
+ readonly ready: string;
62
+ }) => Effect.Effect<Launched, WorldFailed>;
63
+ /**
64
+ * Start the project at `root` (`port` 0: any free port, the one used is in `url`): a fresh local database with the model's tables, then `wrangler dev` with a new
65
+ * world secret (never written to a file). Ready once the world answers. Stopped when the scope closes.
66
+ */
67
+ readonly start: (options: {
68
+ readonly root: string;
69
+ readonly port: number;
70
+ /** Which folder under `.ortho/` holds this world's state: `dev` for `ortho dev`, `prove` for prove. */
71
+ readonly name: string;
72
+ /** The collector's OTLP/HTTP base URL; unset, the Worker exports nothing. */
73
+ readonly otlp?: string;
74
+ /** Where this world's starter answers its telemetry window (`PortalFeed.serve`): the Worker's portal reads it as `ORTHO_PORTAL_FEED`, so a run lights its own portal. */
75
+ readonly portalFeed?: string;
76
+ /** A random value the world says in its health answer and requires in a reset (`ortho dev`'s world, found by `warm`). */
77
+ readonly nonce?: string;
78
+ /** The environment this world stands for, written on every span as `deployment.environment`. Default `local`. */
79
+ readonly environment?: string;
80
+ /** Secrets for the Worker that never touch a file or an argument: `OTLP_SINKS`, from `Sinks.resolve`. */
81
+ readonly secretEnv?: Readonly<Record<string, string>>;
82
+ /**
83
+ * The world's chain, as an effect the caller supplies (the composition root wires `Anvil.start` from
84
+ * `@orthograph/chain-evm`). It is acquired in the world's scope before the Worker starts and released after the
85
+ * Worker stops, so the chain is gone when the world ends.
86
+ */
87
+ readonly chain?: Effect.Effect<ChainStand, WorldFailed, Scope.Scope>;
88
+ /**
89
+ * The mounts' stand-ins (G16-adapter-mounts call 3), given the world's state folder once it is wiped: the caller starts
90
+ * them under `<state>/stands/<mount>` and answers what the Worker is told of them (`ORTHO_STAND_<MOUNT>`,
91
+ * `<MOUNT>_API_KEY`), which joins `secretEnv`, and each one's address by mount, which the world's `stands` is.
92
+ * Acquired before the Worker and released after it, as the chain is.
93
+ */
94
+ readonly stands?: (state: string) => Effect.Effect<StandIns, WorldFailed, Scope.Scope>;
95
+ }) => Effect.Effect<Running, WorldFailed, Scope.Scope>;
96
+ }
97
+ export {};
@@ -0,0 +1,4 @@
1
+ // A local world: the generated Worker on real workerd, with its world Durable Object and a fresh local D1.
2
+ import { Data } from "effect";
3
+ export class WorldFailed extends Data.TaggedError("WorldFailed") {
4
+ }
@@ -0,0 +1,8 @@
1
+ import { Effect } from "effect";
2
+ /** Any answer, JSON or not: the status and the text. A world that does not answer is the message of why. */
3
+ export declare const asked: (url: string, init?: RequestInit) => Effect.Effect<{
4
+ status: number;
5
+ text: string;
6
+ }, string, never>;
7
+ /** A body that is JSON is parsed; one that is not is kept as text. */
8
+ export declare const bodyOf: (text: string) => unknown;
@@ -0,0 +1,9 @@
1
+ // Asking the world's clock door over HTTP.
2
+ import { Effect } from "effect";
3
+ /** Any answer, JSON or not: the status and the text. A world that does not answer is the message of why. */
4
+ export const asked = (url, init) => Effect.tryPromise({
5
+ try: () => fetch(url, init).then((r) => r.text().then((text) => ({ status: r.status, text }))),
6
+ catch: (e) => (e instanceof Error ? e.message : String(e)),
7
+ });
8
+ /** A body that is JSON is parsed; one that is not is kept as text. */
9
+ export const bodyOf = (text) => (text === "" ? null : Effect.runSync(Effect.try(() => JSON.parse(text)).pipe(Effect.orElseSucceed(() => text))));
@@ -0,0 +1,2 @@
1
+ import type { WorldClockApi } from "./types.ts";
2
+ export declare const WorldClock: WorldClockApi;
@@ -0,0 +1,9 @@
1
+ import { Effect } from "effect";
2
+ import { asked, bodyOf } from "./internal/door.js";
3
+ export const WorldClock = {
4
+ read: (url) => asked(`${url}/_world/clock`).pipe(Effect.map((r) => (r.status === 200 ? bodyOf(r.text) : undefined)), Effect.orElseSucceed(() => undefined)),
5
+ move: (url, move) => {
6
+ const [door, body] = "advance" in move ? ["advance", { span: move.advance }] : ["move-to", { to: move.moveTo }];
7
+ return asked(`${url}/_world/clock/${door}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).pipe(Effect.map((r) => ({ status: r.status, body: bodyOf(r.text) })), Effect.orElseSucceed(() => ({ status: 0, body: { _tag: "Unreachable", message: `the world at ${url} did not answer its clock door` } })));
8
+ },
9
+ };
@@ -0,0 +1,34 @@
1
+ import type { Effect } from "effect";
2
+ /** A timer that ran on the way, as the world's door lists it. */
3
+ export interface FiredTimer {
4
+ readonly due: string;
5
+ readonly owner: string;
6
+ readonly name: string;
7
+ }
8
+ /** What `GET /_world/clock` answers. */
9
+ export interface ClockReading {
10
+ readonly kind: "real" | "stepped" | "scaled";
11
+ readonly now: string;
12
+ readonly timers: ReadonlyArray<{
13
+ readonly due: string;
14
+ readonly owner: string;
15
+ readonly name: string;
16
+ }>;
17
+ }
18
+ /** What a clock step is asked to do: a span in words, or an instant. */
19
+ export type ClockMove = {
20
+ readonly advance: string;
21
+ } | {
22
+ readonly moveTo: string;
23
+ };
24
+ /** The door's answer: its status, and `{ now, fired }` on 200, or the refusal (`ClockNotMovable`, `NeverQuiet`, `BadMove`) with its words. */
25
+ export interface Moved {
26
+ readonly status: number;
27
+ readonly body: unknown;
28
+ }
29
+ export interface WorldClockApi {
30
+ /** The world's clock now; nothing when this world has no clock door (a deployed environment closes `/_world`) or does not answer. */
31
+ readonly read: (url: string) => Effect.Effect<ClockReading | undefined>;
32
+ /** Move the world's clock and settle it: the world answers once everything due on the way has run and it is quiet at the target. */
33
+ readonly move: (url: string, move: ClockMove) => Effect.Effect<Moved>;
34
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@orthograph/prove",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-next.1",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "dependencies": {
13
+ "effect": "4.1.4",
14
+ "esbuild": "0.28.2",
15
+ "postject": "1.0.0-alpha.6",
16
+ "wrangler": "4.156.1",
17
+ "orthograph": "0.1.0-next.1",
18
+ "@orthograph/chain-evm": "0.1.0-next.1",
19
+ "@orthograph/compiler": "0.1.0-next.1",
20
+ "@orthograph/language-effect": "0.1.0-next.1",
21
+ "@orthograph/generators": "0.1.0-next.1",
22
+ "@orthograph/logbook": "0.1.0-next.1"
23
+ },
24
+ "imports": {
25
+ "#modules/*.js": "./dist/modules/*.js"
26
+ },
27
+ "devDependencies": {
28
+ "@modelcontextprotocol/sdk": "1.32.2",
29
+ "nx": "24.0.3",
30
+ "@orthograph/logbook": "0.1.0-next.1",
31
+ "@orthograph/services": "0.0.0",
32
+ "@orthograph/generators": "0.1.0-next.1"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "tag": "next"
40
+ }
6
41
  }