@rotifer/playground 0.33.0 → 0.34.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 +36 -0
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/dist/cloud/client.d.ts +30 -0
- package/dist/cloud/client.d.ts.map +1 -1
- package/dist/cloud/client.js +118 -28
- package/dist/cloud/client.js.map +1 -1
- package/dist/commands/compare.d.ts.map +1 -1
- package/dist/commands/compare.js +3 -1
- package/dist/commands/compare.js.map +1 -1
- package/dist/commands/info.d.ts.map +1 -1
- package/dist/commands/info.js +3 -1
- package/dist/commands/info.js.map +1 -1
- package/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +3 -1
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/network.d.ts +57 -0
- package/dist/commands/network.d.ts.map +1 -1
- package/dist/commands/network.js +289 -21
- package/dist/commands/network.js.map +1 -1
- package/dist/commands/reputation.d.ts.map +1 -1
- package/dist/commands/reputation.js +3 -1
- package/dist/commands/reputation.js.map +1 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +3 -1
- package/dist/commands/stats.js.map +1 -1
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +4 -1
- package/dist/commands/versions.js.map +1 -1
- package/dist/utils/announce-table.d.ts +90 -0
- package/dist/utils/announce-table.d.ts.map +1 -0
- package/dist/utils/announce-table.js +212 -0
- package/dist/utils/announce-table.js.map +1 -0
- package/dist/utils/binding.d.ts +56 -2
- package/dist/utils/binding.d.ts.map +1 -1
- package/dist/utils/binding.js +4 -3
- package/dist/utils/binding.js.map +1 -1
- package/dist/utils/p2p-daemon.d.ts +2 -6
- package/dist/utils/p2p-daemon.d.ts.map +1 -1
- package/dist/utils/p2p-daemon.js +107 -9
- package/dist/utils/p2p-daemon.js.map +1 -1
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,42 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.34.0](https://github.com/rotifer-protocol/rotifer-playground/compare/v0.33.1...v0.34.0) (2026-11-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### ⚠ BREAKING CHANGES
|
|
12
|
+
|
|
13
|
+
* **p2p:** nodes on 0.27-0.33 still connect and gossip with this version, but no longer share its DHT. Upgrade the bootstrap node, or keep a remembered upgraded peer.
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **node-attestation:** Cloud-side PoR issuing reference implementation (not deployed, migration deferred) ([#536](https://github.com/rotifer-protocol/rotifer-playground/issues/536)) ([7f58f1a](https://github.com/rotifer-protocol/rotifer-playground/commit/7f58f1a704a13f830028da0d48b41c7454d6b0c0))
|
|
18
|
+
* **p2p:** A2 PR-2 — GeneStore inbound pipeline, abuse limits, expiring connection block ([#542](https://github.com/rotifer-protocol/rotifer-playground/issues/542)) ([d7664ce](https://github.com/rotifer-protocol/rotifer-playground/commit/d7664ce15cfa5a8d1eec0a98967e99cd2bad39ab))
|
|
19
|
+
* **p2p:** admit peers to the DHT only when Identify shows Rotifer's DHT (A2, PR-2b) ([#543](https://github.com/rotifer-protocol/rotifer-playground/issues/543)) ([4a618da](https://github.com/rotifer-protocol/rotifer-playground/commit/4a618da5d2528627c4728e9aab7d602f9d00b649))
|
|
20
|
+
* **p2p:** freeze the DHT gene record v1 and its receiving-side checks (A2, PR-1) ([#541](https://github.com/rotifer-protocol/rotifer-playground/issues/541)) ([83f6809](https://github.com/rotifer-protocol/rotifer-playground/commit/83f6809adf482b78ade5dc1699582e40bfa909dd))
|
|
21
|
+
* **p2p:** GossipSub peer scores from proof of registration (A1, PR-2) ([#539](https://github.com/rotifer-protocol/rotifer-playground/issues/539)) ([2173de3](https://github.com/rotifer-protocol/rotifer-playground/commit/2173de3c12a4f2fec265667abd65d73d9babb51a))
|
|
22
|
+
* **p2p:** NAT traversal client and RFC connection limits (A3) ([#537](https://github.com/rotifer-protocol/rotifer-playground/issues/537)) ([ed84a14](https://github.com/rotifer-protocol/rotifer-playground/commit/ed84a143736c9571a7ed2ca59fec63f77fe2b683))
|
|
23
|
+
* **p2p:** node heartbeats carrying a checked proof of registration (A1, PR-1) ([#538](https://github.com/rotifer-protocol/rotifer-playground/issues/538)) ([1da7e6d](https://github.com/rotifer-protocol/rotifer-playground/commit/1da7e6d86a736ae6c4d3bdfb21ff9e89e1de3819))
|
|
24
|
+
* **p2p:** republish every 12 h, keep the announce table, add network withdraw (A2, PR-4) ([#545](https://github.com/rotifer-protocol/rotifer-playground/issues/545)) ([a0b34f9](https://github.com/rotifer-protocol/rotifer-playground/commit/a0b34f96fbfd17d488b257b2083f605ab8200e67))
|
|
25
|
+
* **p2p:** rotifer network search; announce writes the DHT (A2, PR-3) ([#544](https://github.com/rotifer-protocol/rotifer-playground/issues/544)) ([3bcbfe2](https://github.com/rotifer-protocol/rotifer-playground/commit/3bcbfe2d7b3172dd8e81e537cd4998b9449a72f1))
|
|
26
|
+
* **p2p:** upgrade libp2p to 0.57 and discover LAN peers by mDNS ([#532](https://github.com/rotifer-protocol/rotifer-playground/issues/532)) ([ca590f2](https://github.com/rotifer-protocol/rotifer-playground/commit/ca590f2b3d258906e81a7b57ec1d30ed8b73eccd))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **p2p:** ignore gossip on topics with no registered validator ([#533](https://github.com/rotifer-protocol/rotifer-playground/issues/533)) ([f7b96d3](https://github.com/rotifer-protocol/rotifer-playground/commit/f7b96d39a52eb57e3027e638a262cb1bb93506ff))
|
|
32
|
+
* **p2p:** refuse publishing on unregistered topics; pin the non-Rotifer hang-up time (A4b) ([#535](https://github.com/rotifer-protocol/rotifer-playground/issues/535)) ([ab46b46](https://github.com/rotifer-protocol/rotifer-playground/commit/ab46b46df4db315b72325905de5042dc928b91b6))
|
|
33
|
+
|
|
34
|
+
## [0.33.1](https://github.com/rotifer-protocol/rotifer-playground/compare/v0.33.0...v0.33.1) (2026-11-01)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **cloud:** give the gene-name hint only when the registry says the gene does not exist ([#528](https://github.com/rotifer-protocol/rotifer-playground/issues/528)) ([a81b5ca](https://github.com/rotifer-protocol/rotifer-playground/commit/a81b5ca52aff0d4a19ff744e40284170c6fb3fdd))
|
|
40
|
+
* **cloud:** name the real cause when Rotifer Cloud can't be reached; run the registry suites against a recorded cloud ([#524](https://github.com/rotifer-protocol/rotifer-playground/issues/524)) ([b8ce9a1](https://github.com/rotifer-protocol/rotifer-playground/commit/b8ce9a1643859d242a2e701370c9aec20f0f5c93))
|
|
41
|
+
* **live-checks:** quote the runner's log as plain text in the issue excerpt ([#527](https://github.com/rotifer-protocol/rotifer-playground/issues/527)) ([ff9ee1e](https://github.com/rotifer-protocol/rotifer-playground/commit/ff9ee1e82f338263694fce6918fdbdcc6e807fb6))
|
|
42
|
+
* **package:** stop shipping rolldown's Linux binding as our optional dependency ([#522](https://github.com/rotifer-protocol/rotifer-playground/issues/522)) ([a8172d5](https://github.com/rotifer-protocol/rotifer-playground/commit/a8172d54834ab549db67d953c5bba346069dbb4c))
|
|
43
|
+
|
|
8
44
|
## [0.33.0](https://github.com/rotifer-protocol/rotifer-playground/compare/v0.32.1...v0.33.0) (2026-11-01)
|
|
9
45
|
|
|
10
46
|
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Development environment for the **Rotifer Protocol** — **WASM-Native, Polyglot by Design**: build genes in TypeScript / Rust / AssemblyScript / Go / C, compete in Arenas, share via Cloud, and simulate agent evolution.
|
|
11
11
|
|
|
12
|
-
> **Status:** v0.
|
|
12
|
+
> **Status:** v0.34.x — The experimental P2P node can now find genes across nodes, not only hear LAN announcements. `rotifer network announce` writes the gene to the DHT and republishes it every 12 hours; the announce list survives a daemon restart, and `rotifer network withdraw` stops republishing and serving a gene (copies other nodes already hold expire on their own within 48 hours). `rotifer network search <query>` matches keywords against announcements this node has heard and runs a Rotifer Cloud search alongside, as two separate lists; a v2 gene ID is looked up in the DHT, and the DHT is never searched by keyword. Records from other nodes are checked before they are stored, with per-publisher and total limits, and a peer that keeps breaking them is blocked for a while. Nodes started with `--host 0.0.0.0` find each other on the local network by mDNS without `--bootstrap` (`--no-mdns` turns that off); the node is on libp2p 0.57, can connect through a relay or by hole punching, and enforces connection and memory limits. Gossip on topics without a registered validator is ignored. Heartbeats can carry a Cloud-issued proof of registration that peers check and use in GossipSub scoring; the Cloud issuing side is in this repository but not deployed. Breaking: nodes on 0.27–0.33 still connect and gossip with this version but no longer share its DHT, so upgrade your bootstrap node. There is no public bootstrap node or relay yet, and the P2P node stays off unless you start it. Still true from v0.33: agents have memory (spec §38) that survives genome changes, stored in `.rotifer/playground.db` with every change logged to `.rotifer/audit.jsonl`; Rotifer Cloud does not store agent memory yet; `rotifer run` checks input and output against the gene's schema (`--no-validate` turns that off). Still true from v0.32: Arena F(g) is on a 0–1 scale (ADR-346) and scores from earlier versions are not converted; `arena submit --cloud` uploads the tier that actually ran; Hybrid genes must use https, and every redirect hop is checked against their allowed domains. Still true from v0.30: F(g) is scored against the season median and stays `estimated` and outside the ranking until coverage and robustness are measured (planned for v1.0); every CLI path runs a gene with exactly the permissions its phenotype declares; publishing enforces spec §47.5 T1. See [CHANGELOG.md](CHANGELOG.md) for full release history. Internet-wide reach and L4 Collective Immunity are later milestones — see [Implementation Status](#implementation-status) below.
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -298,7 +298,7 @@ bash demo.sh
|
|
|
298
298
|
| **L0** | Kernel | **~40%** | `L0Gate` pre-execution checks (domain, resource limits, filesystem) on every execution path, including genome steps and the Node.js fallback; audit log | Per-gene permission policy, network check, EthicalBoundary, State Anchoring, Trust Anchor |
|
|
299
299
|
| **L1** | Synthesis | **~70%** | WASM sandbox, IR compiler, TS→WASM compilation, native bridge | `Synthesizer` interface, full WASI capability negotiation |
|
|
300
300
|
| **L2** | Calibration | **~40%** | Schema validation, sandbox testing, `--compliance` checks | Static analysis, controlled field trial |
|
|
301
|
-
| **L3** | Competition | **~85%** | Arena ranking, F(g) multiplicative model, R(g) reputation, Cloud Registry, experimental P2P node (LAN gene announcements,
|
|
301
|
+
| **L3** | Competition | **~85%** | Arena ranking, F(g) multiplicative model, R(g) reputation, Cloud Registry, experimental P2P node (off by default: mDNS LAN discovery, gene announcements, DHT search) | Public bootstrap and relay nodes, internet-wide P2P, hot-loading, retirement |
|
|
302
302
|
| **L4** | Collective Immunity | **0%** | — | Threat broadcasting, emergency rollback, cross-node consensus |
|
|
303
303
|
| **Algebra** | Composition | **~90%** | All 5 operators in Rust; CLI supports Seq/Par/Cond/Try | DataFlowGraph |
|
|
304
304
|
|
package/README.zh.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
**Rotifer Protocol** 的开发环境——构建基因、运行 Arena 竞争、通过 Cloud 共享、模拟代理进化。
|
|
11
11
|
|
|
12
|
-
> **状态:** v0.
|
|
12
|
+
> **状态:** v0.34.x——实验性 P2P 节点现在能跨节点找基因,不再只是收听局域网公告。`rotifer network announce` 把基因写进 DHT,每 12 小时重发一次;公告清单在守护进程重启后仍保留,`rotifer network withdraw` 让本节点停止重发、停止提供某个基因(别的节点已经存下的副本会在 48 小时内自行过期)。`rotifer network search <关键词>` 用关键词匹配本节点收到过的公告,同时跑一次 Rotifer Cloud 搜索,两份结果分开列出;输入 v2 基因 ID 时到 DHT 里查,DHT 从不按关键词搜。收到的别家记录先检查再存,按发布者和总量设上限,反复越界的对端会被暂时拉黑。用 `--host 0.0.0.0` 启动的节点在局域网里靠 mDNS 互相发现,不用 `--bootstrap`(`--no-mdns` 可以关掉);节点已升级到 libp2p 0.57,能经 relay 或打洞连通,并执行连接数与内存上限。没有注册校验器的 topic 上的 gossip 一律忽略。心跳可以带上 Cloud 签发的注册证明,对端会校验并用于 GossipSub 打分;Cloud 签发端已在本仓库,但还没有部署。不兼容变化:0.27–0.33 的节点仍能和本版连接、收发 gossip,但不再共用它的 DHT,请先升级引导节点。目前还没有公共引导节点和 relay,P2P 节点不手动启动就不运行。v0.33 起的内容依然成立:Agent 有了记忆(规范 §38),换了基因组也不会丢,存在 `.rotifer/playground.db`,每次改动记进 `.rotifer/audit.jsonl`;Rotifer Cloud 目前还不保存 Agent 记忆;`rotifer run` 会按基因的 schema 检查输入和输出(加 `--no-validate` 可以关掉)。v0.32 起的内容依然成立:Arena 的 F(g) 是 0 到 1 的分数(ADR-346),之前版本算出的分数不做换算;`arena submit --cloud` 上传实际运行的档位;Hybrid 基因只许 https,每一次重定向都要重新对照基因允许的域名。v0.30 起的内容依然成立:F(g) 按赛季中位数打分,在覆盖度与健壮性真正测量之前(计划在 v1.0)仍标 `estimated`、不进排名;所有 CLI 路径都按基因 phenotype 声明的权限运行;发布执行规范 §47.5 T1。完整发布历史见 [CHANGELOG.md](CHANGELOG.md)。跨公网连接与 L4 集体免疫在之后的里程碑,见下方[实现状态](#实现状态)。
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -267,7 +267,7 @@ bash demo.sh
|
|
|
267
267
|
| **L0** | 内核层 | **~40%** | `L0Gate` 预执行检查(域、资源上限、文件系统),覆盖全部执行路径,含基因组内的每一步与 Node.js 降级路径;审计日志 | 逐基因权限策略、网络检查、伦理边界、状态锚定、信任根 |
|
|
268
268
|
| **L1** | 合成层 | **~70%** | WASM 沙箱(wasmtime)、IR 编译器、Javy TS→WASM、NAPI 桥接 | `Synthesizer` 接口、完整 WASI 能力协商 |
|
|
269
269
|
| **L2** | 校准层 | **~40%** | Schema 验证、沙箱测试、`--compliance` 检查 | 静态分析、受控试运行 |
|
|
270
|
-
| **L3** | 竞争与交换层 | **~85%** | Arena 排名、F(g) 乘法模型、R(g) 声誉、Cloud Registry、实验性 P2P
|
|
270
|
+
| **L3** | 竞争与交换层 | **~85%** | Arena 排名、F(g) 乘法模型、R(g) 声誉、Cloud Registry、实验性 P2P 节点(默认关闭:mDNS 局域网发现、基因公告、DHT 搜索) | 公共引导节点与 relay、跨公网 P2P、热加载、退役 |
|
|
271
271
|
| **L4** | 集体免疫层 | **0%** | — | 威胁广播、紧急回滚、跨节点共识 |
|
|
272
272
|
| **代数** | 组合代数 | **~90%** | Rust 五算子全实现;CLI 支持 Seq/Par/Cond/Try | DataFlowGraph |
|
|
273
273
|
|
package/dist/cloud/client.d.ts
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import type { CloudConfig, CloudGene, CloudGeneListResponse, CloudArenaEntry, FitnessReport, ContributionMetrics } from "./types.js";
|
|
2
2
|
import { type SeasonReferenceRow } from "../utils/fitness-formula.js";
|
|
3
3
|
export declare function loadCloudConfig(): CloudConfig;
|
|
4
|
+
/**
|
|
5
|
+
* Rotifer Cloud could not be reached at all: no HTTP status came back.
|
|
6
|
+
*
|
|
7
|
+
* Node's fetch reports every such failure as a bare `TypeError("fetch
|
|
8
|
+
* failed")` and keeps the reason in `err.cause`, so printing `err.message`
|
|
9
|
+
* told users nothing ("✗ fetch failed") during an outage. This carries the
|
|
10
|
+
* endpoint and the cause's code instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare class CloudNetworkError extends Error {
|
|
13
|
+
readonly endpoint: string;
|
|
14
|
+
readonly code: string | undefined;
|
|
15
|
+
constructor(endpoint: string, code: string | undefined, reason: string, options?: {
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export declare function toCloudNetworkError(url: string, err: TypeError): CloudNetworkError;
|
|
20
|
+
/** The registry answered and has no gene for this ref. */
|
|
21
|
+
export declare class GeneNotFoundError extends Error {
|
|
22
|
+
readonly ref: string;
|
|
23
|
+
constructor(ref: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What to tell the user after a failed cloud call. A hint about the gene's
|
|
27
|
+
* name (`notFound`) only when the registry said there is no such gene: with
|
|
28
|
+
* the cloud unreachable the name was never checked, and an error status says
|
|
29
|
+
* nothing about it either. Undefined means the error message stands alone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function cloudFailureHint(err: unknown, notFound: string): string | undefined;
|
|
4
32
|
export declare function listGenes(options: {
|
|
5
33
|
domain?: string;
|
|
6
34
|
query?: string;
|
|
@@ -9,6 +37,8 @@ export declare function listGenes(options: {
|
|
|
9
37
|
sort?: string;
|
|
10
38
|
page?: number;
|
|
11
39
|
perPage?: number;
|
|
40
|
+
/** Aborts the request(s), e.g. on a caller's timeout. */
|
|
41
|
+
signal?: AbortSignal;
|
|
12
42
|
}): Promise<CloudGeneListResponse>;
|
|
13
43
|
export declare function getGene(idOrName: string): Promise<CloudGene>;
|
|
14
44
|
export declare function publishGene(opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOlG,wBAAgB,eAAe,IAAI,WAAW,CAkB7C;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/cloud/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAOlG,wBAAgB,eAAe,IAAI,WAAW,CAkB7C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AM,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqB/F;AAID,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAoB/E;AAID,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAsB,uBAAuB,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAoB5F;AAID,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAkCzF;AAED,wBAAsB,wBAAwB,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAgB9F"}
|
package/dist/cloud/client.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GeneNotFoundError = exports.CloudNetworkError = void 0;
|
|
3
4
|
exports.loadCloudConfig = loadCloudConfig;
|
|
5
|
+
exports.toCloudNetworkError = toCloudNetworkError;
|
|
6
|
+
exports.cloudFailureHint = cloudFailureHint;
|
|
4
7
|
exports.listGenes = listGenes;
|
|
5
8
|
exports.getGene = getGene;
|
|
6
9
|
exports.publishGene = publishGene;
|
|
@@ -91,6 +94,92 @@ async function handleResponse(res) {
|
|
|
91
94
|
}
|
|
92
95
|
return res.json();
|
|
93
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Rotifer Cloud could not be reached at all: no HTTP status came back.
|
|
99
|
+
*
|
|
100
|
+
* Node's fetch reports every such failure as a bare `TypeError("fetch
|
|
101
|
+
* failed")` and keeps the reason in `err.cause`, so printing `err.message`
|
|
102
|
+
* told users nothing ("✗ fetch failed") during an outage. This carries the
|
|
103
|
+
* endpoint and the cause's code instead.
|
|
104
|
+
*/
|
|
105
|
+
class CloudNetworkError extends Error {
|
|
106
|
+
endpoint;
|
|
107
|
+
code;
|
|
108
|
+
constructor(endpoint, code, reason, options) {
|
|
109
|
+
super(`Cannot reach Rotifer Cloud (${endpoint}): ${reason}`, options);
|
|
110
|
+
this.endpoint = endpoint;
|
|
111
|
+
this.code = code;
|
|
112
|
+
this.name = "CloudNetworkError";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.CloudNetworkError = CloudNetworkError;
|
|
116
|
+
const NETWORK_REASONS = {
|
|
117
|
+
ECONNREFUSED: "connection refused",
|
|
118
|
+
ECONNRESET: "connection reset",
|
|
119
|
+
EPIPE: "connection reset",
|
|
120
|
+
ENOTFOUND: "host not found",
|
|
121
|
+
EAI_AGAIN: "DNS lookup failed",
|
|
122
|
+
ETIMEDOUT: "connection timed out",
|
|
123
|
+
ENETUNREACH: "network unreachable",
|
|
124
|
+
EHOSTUNREACH: "host unreachable",
|
|
125
|
+
UND_ERR_CONNECT_TIMEOUT: "connection timed out",
|
|
126
|
+
UND_ERR_HEADERS_TIMEOUT: "no response headers in time",
|
|
127
|
+
UND_ERR_SOCKET: "connection closed before a response",
|
|
128
|
+
};
|
|
129
|
+
function toCloudNetworkError(url, err) {
|
|
130
|
+
let endpoint = url;
|
|
131
|
+
try {
|
|
132
|
+
endpoint = new URL(url).origin;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// keep the raw URL
|
|
136
|
+
}
|
|
137
|
+
const cause = (err.cause ?? {});
|
|
138
|
+
// Happy-eyeballs connects fail with an AggregateError: the code is on it or
|
|
139
|
+
// on its first member.
|
|
140
|
+
const rawCode = cause.code ?? cause.errors?.[0]?.code;
|
|
141
|
+
const code = typeof rawCode === "string" ? rawCode : undefined;
|
|
142
|
+
const known = code ? NETWORK_REASONS[code] : undefined;
|
|
143
|
+
const detail = typeof cause.message === "string" && cause.message ? cause.message : err.message;
|
|
144
|
+
const reason = known ? `${known} (${code})` : code ? `${detail} (${code})` : detail;
|
|
145
|
+
return new CloudNetworkError(endpoint, code, reason, { cause: err });
|
|
146
|
+
}
|
|
147
|
+
/** The registry answered and has no gene for this ref. */
|
|
148
|
+
class GeneNotFoundError extends Error {
|
|
149
|
+
ref;
|
|
150
|
+
constructor(ref) {
|
|
151
|
+
super(`Gene '${ref}' not found`);
|
|
152
|
+
this.ref = ref;
|
|
153
|
+
this.name = "GeneNotFoundError";
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.GeneNotFoundError = GeneNotFoundError;
|
|
157
|
+
/**
|
|
158
|
+
* What to tell the user after a failed cloud call. A hint about the gene's
|
|
159
|
+
* name (`notFound`) only when the registry said there is no such gene: with
|
|
160
|
+
* the cloud unreachable the name was never checked, and an error status says
|
|
161
|
+
* nothing about it either. Undefined means the error message stands alone.
|
|
162
|
+
*/
|
|
163
|
+
function cloudFailureHint(err, notFound) {
|
|
164
|
+
if (err instanceof CloudNetworkError)
|
|
165
|
+
return "Check your network connection, or retry when Rotifer Cloud is reachable.";
|
|
166
|
+
if (err instanceof GeneNotFoundError)
|
|
167
|
+
return notFound;
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
/** `fetch`, with "fetch failed" turned into a CloudNetworkError that names its cause. */
|
|
171
|
+
async function cloudFetch(url, init) {
|
|
172
|
+
try {
|
|
173
|
+
return await fetch(url, init);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
// Network failures are TypeErrors carrying a cause; aborts and timeouts
|
|
177
|
+
// (AbortError / TimeoutError) pass through for callers that handle them.
|
|
178
|
+
if (err instanceof TypeError && err.cause !== undefined)
|
|
179
|
+
throw toCloudNetworkError(url, err);
|
|
180
|
+
throw err;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
94
183
|
function normalizeSearchSort(sort) {
|
|
95
184
|
const requested = (sort || "newest").toLowerCase();
|
|
96
185
|
switch (requested) {
|
|
@@ -135,11 +224,12 @@ function parseExactSearchTotal(rows) {
|
|
|
135
224
|
const parsed = typeof raw === "number" ? raw : parseInt(String(raw), 10);
|
|
136
225
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
|
|
137
226
|
}
|
|
138
|
-
async function fetchSearchGenes(body) {
|
|
139
|
-
const res = await
|
|
227
|
+
async function fetchSearchGenes(body, signal) {
|
|
228
|
+
const res = await cloudFetch(apiUrl("/rpc/search_genes"), {
|
|
140
229
|
method: "POST",
|
|
141
230
|
headers: authHeaders(),
|
|
142
231
|
body: JSON.stringify(body),
|
|
232
|
+
...(signal ? { signal } : {}),
|
|
143
233
|
});
|
|
144
234
|
return handleResponse(res);
|
|
145
235
|
}
|
|
@@ -161,7 +251,7 @@ async function listGenes(options) {
|
|
|
161
251
|
p_limit: limit,
|
|
162
252
|
p_offset: offset,
|
|
163
253
|
};
|
|
164
|
-
const rows = await fetchSearchGenes(requestBody);
|
|
254
|
+
const rows = await fetchSearchGenes(requestBody, options.signal);
|
|
165
255
|
const genes = rows.map(mapSearchGene);
|
|
166
256
|
let total = parseExactSearchTotal(rows);
|
|
167
257
|
let isTotalExact = total != null;
|
|
@@ -175,7 +265,7 @@ async function listGenes(options) {
|
|
|
175
265
|
isTotalExact = true;
|
|
176
266
|
}
|
|
177
267
|
else {
|
|
178
|
-
const countRows = await fetchSearchGenes({ ...requestBody, p_limit: 1, p_offset: 0 });
|
|
268
|
+
const countRows = await fetchSearchGenes({ ...requestBody, p_limit: 1, p_offset: 0 }, options.signal);
|
|
179
269
|
total = parseExactSearchTotal(countRows);
|
|
180
270
|
isTotalExact = total != null;
|
|
181
271
|
}
|
|
@@ -218,12 +308,12 @@ async function getGene(idOrName) {
|
|
|
218
308
|
params.set("limit", "1");
|
|
219
309
|
break;
|
|
220
310
|
}
|
|
221
|
-
const res = await
|
|
311
|
+
const res = await cloudFetch(apiUrl(`/genes?${params}`), {
|
|
222
312
|
headers: authHeaders(),
|
|
223
313
|
});
|
|
224
314
|
const data = await handleResponse(res);
|
|
225
315
|
if (data.length === 0)
|
|
226
|
-
throw new
|
|
316
|
+
throw new GeneNotFoundError(idOrName);
|
|
227
317
|
const row = data[0];
|
|
228
318
|
const config = loadCloudConfig();
|
|
229
319
|
const wasmUrl = row.wasm_path ? geneWasmUrl(row.wasm_path) : null;
|
|
@@ -252,7 +342,7 @@ async function publishGene(opts) {
|
|
|
252
342
|
const creds = (0, auth_js_1.loadCredentials)();
|
|
253
343
|
if (!creds)
|
|
254
344
|
throw new Error("Not logged in. Run 'rotifer login' first.");
|
|
255
|
-
const existCheck = await
|
|
345
|
+
const existCheck = await cloudFetch(apiUrl(`/genes?owner_id=eq.${creds.user.id}&name=eq.${opts.name}&version=eq.${opts.version}&select=id,published`), { headers: authHeaders() });
|
|
256
346
|
const existData = existCheck.ok ? (await existCheck.json()) : [];
|
|
257
347
|
const isUpdate = existData.length > 0;
|
|
258
348
|
if (isUpdate && existData[0].published) {
|
|
@@ -266,7 +356,7 @@ async function publishGene(opts) {
|
|
|
266
356
|
wasmPath = `${creds.user.id}/${opts.name}/${opts.version}/gene.ir.wasm`;
|
|
267
357
|
wasmSize = opts.wasmBytes.length;
|
|
268
358
|
wasmHash = (0, node_crypto_1.createHash)("sha256").update(opts.wasmBytes).digest("hex");
|
|
269
|
-
const uploadRes = await
|
|
359
|
+
const uploadRes = await cloudFetch(storageUrl(`/object/gene-wasm/${wasmPath}`), {
|
|
270
360
|
method: "POST",
|
|
271
361
|
headers: {
|
|
272
362
|
Authorization: `Bearer ${creds.access_token}`,
|
|
@@ -283,7 +373,7 @@ async function publishGene(opts) {
|
|
|
283
373
|
}
|
|
284
374
|
let previousVersionId = null;
|
|
285
375
|
if (!isUpdate) {
|
|
286
|
-
const prevCheck = await
|
|
376
|
+
const prevCheck = await cloudFetch(apiUrl(`/genes?owner_id=eq.${creds.user.id}&name=eq.${opts.name}&select=id&order=created_at.desc&limit=1`), { headers: authHeaders() });
|
|
287
377
|
const prevData = prevCheck.ok ? (await prevCheck.json()) : [];
|
|
288
378
|
if (prevData.length > 0) {
|
|
289
379
|
previousVersionId = prevData[0].id;
|
|
@@ -312,7 +402,7 @@ async function publishGene(opts) {
|
|
|
312
402
|
body.changelog = changelog;
|
|
313
403
|
if (previousVersionId)
|
|
314
404
|
body.previous_version_id = previousVersionId;
|
|
315
|
-
const res = await
|
|
405
|
+
const res = await cloudFetch(apiUrl("/genes"), {
|
|
316
406
|
method: "POST",
|
|
317
407
|
headers: {
|
|
318
408
|
...authHeaders(true),
|
|
@@ -366,7 +456,7 @@ async function fetchArenaAuditRows() {
|
|
|
366
456
|
params.set("order", "gene_id.asc");
|
|
367
457
|
params.set("limit", String(perPage));
|
|
368
458
|
params.set("offset", String(offset));
|
|
369
|
-
const res = await
|
|
459
|
+
const res = await cloudFetch(apiUrl(`/arena_entries?${params}`), { headers: authHeaders() });
|
|
370
460
|
const page = await handleResponse(res);
|
|
371
461
|
rows.push(...page);
|
|
372
462
|
if (page.length < perPage)
|
|
@@ -405,7 +495,7 @@ async function fetchArenaAuditRows() {
|
|
|
405
495
|
* it. Fixing that URL would have turned a silent no-op into real data loss.)
|
|
406
496
|
*/
|
|
407
497
|
async function unpublishGene(id, reason) {
|
|
408
|
-
const res = await
|
|
498
|
+
const res = await cloudFetch(apiUrl("/rpc/unpublish_gene"), {
|
|
409
499
|
method: "POST",
|
|
410
500
|
headers: {
|
|
411
501
|
...authHeaders(true),
|
|
@@ -450,7 +540,7 @@ async function unpublishGene(id, reason) {
|
|
|
450
540
|
* function cannot turn silence back into success.
|
|
451
541
|
*/
|
|
452
542
|
async function republishGene(id, reason) {
|
|
453
|
-
const res = await
|
|
543
|
+
const res = await cloudFetch(apiUrl("/rpc/republish_gene"), {
|
|
454
544
|
method: "POST",
|
|
455
545
|
headers: {
|
|
456
546
|
...authHeaders(true),
|
|
@@ -485,11 +575,11 @@ async function listOwnGeneVersions(name) {
|
|
|
485
575
|
params.set("name", `eq.${name}`);
|
|
486
576
|
params.set("select", "id,name,version,published,created_at");
|
|
487
577
|
params.set("order", "created_at.desc");
|
|
488
|
-
const res = await
|
|
578
|
+
const res = await cloudFetch(apiUrl(`/genes?${params}`), { headers: authHeaders(true) });
|
|
489
579
|
return handleResponse(res);
|
|
490
580
|
}
|
|
491
581
|
async function downloadGeneWasm(wasmUrl) {
|
|
492
|
-
const res = await
|
|
582
|
+
const res = await cloudFetch(wasmUrl);
|
|
493
583
|
if (!res.ok)
|
|
494
584
|
throw new Error(`Failed to download WASM (${res.status})`);
|
|
495
585
|
const arrayBuf = await res.arrayBuffer();
|
|
@@ -497,7 +587,7 @@ async function downloadGeneWasm(wasmUrl) {
|
|
|
497
587
|
}
|
|
498
588
|
async function trackDownload(geneId, source = "cli") {
|
|
499
589
|
try {
|
|
500
|
-
const res = await
|
|
590
|
+
const res = await cloudFetch(apiUrl("/rpc/track_download"), {
|
|
501
591
|
method: "POST",
|
|
502
592
|
headers: authHeaders(),
|
|
503
593
|
body: JSON.stringify({ p_gene_id: geneId, p_source: source }),
|
|
@@ -525,7 +615,7 @@ async function trackDownload(geneId, source = "cli") {
|
|
|
525
615
|
async function publishEvaluationRuns(geneId, submissionId, runs) {
|
|
526
616
|
if (runs.length === 0)
|
|
527
617
|
return;
|
|
528
|
-
const res = await
|
|
618
|
+
const res = await cloudFetch(apiUrl("/arena_evaluation_runs"), {
|
|
529
619
|
method: "POST",
|
|
530
620
|
headers: { ...authHeaders(true), Prefer: "return=minimal" },
|
|
531
621
|
body: JSON.stringify(runs.map((r) => ({ gene_id: geneId, submission_id: submissionId, ...r }))),
|
|
@@ -544,7 +634,7 @@ async function publishEvaluationRuns(geneId, submissionId, runs) {
|
|
|
544
634
|
* REFERENCE_FUNCTION_MISSING, because that registry cannot store the record.
|
|
545
635
|
*/
|
|
546
636
|
async function getFitnessReference(domain, fidelity, timeoutMs = 5_000) {
|
|
547
|
-
const res = await
|
|
637
|
+
const res = await cloudFetch(apiUrl("/rpc/get_fitness_reference"), {
|
|
548
638
|
method: "POST",
|
|
549
639
|
headers: authHeaders(),
|
|
550
640
|
body: JSON.stringify({ p_domain: domain, p_fidelity: fidelity }),
|
|
@@ -599,7 +689,7 @@ async function arenaSubmit(geneId, fitness) {
|
|
|
599
689
|
// and clears it when a write carries none, so a row's label always
|
|
600
690
|
// describes the write that put its score there (migration 20261027200000).
|
|
601
691
|
// A registry without that migration ignores the header.
|
|
602
|
-
const res = await
|
|
692
|
+
const res = await cloudFetch(apiUrl("/arena_entries?on_conflict=gene_id"), {
|
|
603
693
|
method: "POST",
|
|
604
694
|
headers: {
|
|
605
695
|
...authHeaders(true),
|
|
@@ -639,7 +729,7 @@ async function arenaSubmit(geneId, fitness) {
|
|
|
639
729
|
* as nine competitors.
|
|
640
730
|
*/
|
|
641
731
|
async function arenaLeaderboard(options) {
|
|
642
|
-
const res = await
|
|
732
|
+
const res = await cloudFetch(apiUrl("/rpc/get_arena_leaderboard"), {
|
|
643
733
|
method: "POST",
|
|
644
734
|
headers: authHeaders(),
|
|
645
735
|
body: JSON.stringify({
|
|
@@ -663,7 +753,7 @@ async function getProfileByUsername(username) {
|
|
|
663
753
|
params.set("username", `eq.${username}`);
|
|
664
754
|
params.set("select", "id,username,avatar_url");
|
|
665
755
|
params.set("limit", "1");
|
|
666
|
-
const res = await
|
|
756
|
+
const res = await cloudFetch(apiUrl(`/profiles?${params}`), {
|
|
667
757
|
headers: authHeaders(),
|
|
668
758
|
});
|
|
669
759
|
const data = await handleResponse(res);
|
|
@@ -681,7 +771,7 @@ async function getGeneReputation(geneId) {
|
|
|
681
771
|
params.set("select", "score,arena_score,usage_score,stability_score,epoch,computed_at,genes(name)");
|
|
682
772
|
params.set("order", "computed_at.desc");
|
|
683
773
|
params.set("limit", "1");
|
|
684
|
-
const res = await
|
|
774
|
+
const res = await cloudFetch(apiUrl(`/gene_reputation?${params}`), {
|
|
685
775
|
headers: authHeaders(),
|
|
686
776
|
});
|
|
687
777
|
const data = await handleResponse(res);
|
|
@@ -710,7 +800,7 @@ async function getGeneReputation(geneId) {
|
|
|
710
800
|
async function getDeveloperReputation(userId) {
|
|
711
801
|
const params = new URLSearchParams();
|
|
712
802
|
params.set("user_id", `eq.${userId}`);
|
|
713
|
-
const res = await
|
|
803
|
+
const res = await cloudFetch(apiUrl(`/developer_reputation?${params}`), {
|
|
714
804
|
headers: authHeaders(),
|
|
715
805
|
});
|
|
716
806
|
const data = await handleResponse(res);
|
|
@@ -738,7 +828,7 @@ async function listGeneVersions(owner, name) {
|
|
|
738
828
|
params.set("published", "eq.true");
|
|
739
829
|
params.set("select", "id,version,changelog,previous_version_id,created_at,profiles(username)");
|
|
740
830
|
params.set("order", "created_at.asc");
|
|
741
|
-
const res = await
|
|
831
|
+
const res = await cloudFetch(apiUrl(`/genes?${params}`), {
|
|
742
832
|
headers: authHeaders(),
|
|
743
833
|
});
|
|
744
834
|
const data = await handleResponse(res);
|
|
@@ -759,7 +849,7 @@ async function getGeneStats(idOrName) {
|
|
|
759
849
|
const gene = await getGene(idOrName);
|
|
760
850
|
geneId = gene.id;
|
|
761
851
|
}
|
|
762
|
-
const res = await
|
|
852
|
+
const res = await cloudFetch(apiUrl("/rpc/get_gene_stats"), {
|
|
763
853
|
method: "POST",
|
|
764
854
|
headers: authHeaders(),
|
|
765
855
|
body: JSON.stringify({ p_gene_id: geneId }),
|
|
@@ -779,7 +869,7 @@ async function getReputationComputeLog(limit = 10) {
|
|
|
779
869
|
params.set("select", "*");
|
|
780
870
|
params.set("order", "started_at.desc");
|
|
781
871
|
params.set("limit", String(limit));
|
|
782
|
-
const res = await
|
|
872
|
+
const res = await cloudFetch(apiUrl(`/reputation_compute_log?${params}`), {
|
|
783
873
|
headers: authHeaders(),
|
|
784
874
|
});
|
|
785
875
|
const data = await handleResponse(res);
|
|
@@ -798,7 +888,7 @@ async function getContributionMetrics(geneId) {
|
|
|
798
888
|
const params = new URLSearchParams();
|
|
799
889
|
params.set("gene_id", `eq.${geneId}`);
|
|
800
890
|
params.set("select", "*");
|
|
801
|
-
const res = await
|
|
891
|
+
const res = await cloudFetch(apiUrl(`/gene_contribution_metrics?${params}`), {
|
|
802
892
|
headers: authHeaders(),
|
|
803
893
|
});
|
|
804
894
|
const data = await handleResponse(res);
|
|
@@ -827,7 +917,7 @@ async function getContributionMetrics(geneId) {
|
|
|
827
917
|
};
|
|
828
918
|
}
|
|
829
919
|
async function getReputationLeaderboard(limit = 20) {
|
|
830
|
-
const res = await
|
|
920
|
+
const res = await cloudFetch(apiUrl("/rpc/get_reputation_leaderboard"), {
|
|
831
921
|
method: "POST",
|
|
832
922
|
headers: authHeaders(),
|
|
833
923
|
body: JSON.stringify({ p_limit: limit }),
|