@rotifer/playground 0.24.0 → 0.25.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.
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * The §5.1 fitness formula, in one place.
4
+ *
5
+ * F(g) = [S_r · ln(1 + C_util) · (1 + R_rob)] / [L · Resource_Cost]
6
+ *
7
+ * `L` and `Resource_Cost` in the spec are the *raw* latency and cost, so both
8
+ * sit in the denominator and a slower, costlier gene scores lower. The
9
+ * implementation does not divide by raw values — an unbounded denominator
10
+ * drives F(g) to zero for any gene with a realistic latency, which is what
11
+ * ADR-215 P1 set out to avoid. It normalizes each into a (0, 1] score first:
12
+ *
13
+ * L_score = 1 / (1 + avg_latency_ms / LATENCY_SCALE_MS)
14
+ * Cost_score = 1 / (1 + avg_cost / RESOURCE_SCALE_UNITS)
15
+ *
16
+ * Those scores are already *inverted* — lower latency means a score nearer 1 —
17
+ * so they belong in the numerator. Dividing by them, as this code did until
18
+ * this module existed, flips the penalty into a reward: F(g) rose with latency
19
+ * and every gene slower than a second pinned at the 1.0 cap. The regression
20
+ * tests in `tests/unit/fitness-formula.test.ts` hold the direction.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.RESOURCE_SCALE_UNITS = exports.LATENCY_SCALE_MS = void 0;
24
+ exports.latencyScoreFor = latencyScoreFor;
25
+ exports.resourceEfficiencyFor = resourceEfficiencyFor;
26
+ exports.computeBaseFitness = computeBaseFitness;
27
+ /**
28
+ * Latency at which L_score halves. `[N]` — provisional, uncalibrated.
29
+ *
30
+ * ADR-318 D2 replaces both constants with `L_ref` / `Cost_ref` — the season
31
+ * median for the gene's own domain and fidelity, which is what makes F(g)
32
+ * dimensionless and comparable across bindings — and marks their values `[N]`
33
+ * pending ABM / measured calibration under RFC-001 §0. That reference scale
34
+ * needs a season-median pipeline that does not exist yet (v0.9.3 #6); these two
35
+ * fixed constants are the stand-ins until it does.
36
+ */
37
+ exports.LATENCY_SCALE_MS = 1000;
38
+ /**
39
+ * Resource cost (fuel units) at which Cost_score halves. `[N]` — provisional.
40
+ *
41
+ * Badly out of scale, and known to be: ADR-318 recorded both constants as
42
+ * guesses, and measured 7.7e9 fuel on a leaderboard gene from its reported
43
+ * efficiency score. Locally, three
44
+ * sandbox runs each over the bundled Native corpus burn 1.2M–83M fuel
45
+ * (url-extractor 1.22M, debugger 1.44M, citation-manager 1.80M,
46
+ * particle-spatial 83.3M), so at a 10k scale every real gene lands at a
47
+ * Cost_score of 0.008 or below and F(g) collapses to ~0.003 — far under
48
+ * τ = 0.3. While it divided, the same mismatch was invisible: it inflated F(g)
49
+ * past the 1.0 cap instead. This is why `arena submit` does not gate on F(g)
50
+ * while `hasCompleteFitnessInputs` is false: a threshold comparison against a
51
+ * provisional scale is not an admission decision. Picking new values is a
52
+ * protocol-parameter change under RFC-001 §0, not a code cleanup.
53
+ */
54
+ exports.RESOURCE_SCALE_UNITS = 10_000;
55
+ /** L_score: 1 at zero latency, strictly decreasing, never zero. */
56
+ function latencyScoreFor(avgLatencyMs) {
57
+ return 1.0 / (1.0 + Math.max(avgLatencyMs, 0) / exports.LATENCY_SCALE_MS);
58
+ }
59
+ /** Cost_score: 1 at zero cost, strictly decreasing, never zero. */
60
+ function resourceEfficiencyFor(avgResourceCost) {
61
+ return 1.0 / (1.0 + Math.max(avgResourceCost, 0) / exports.RESOURCE_SCALE_UNITS);
62
+ }
63
+ /**
64
+ * F(g) from one batch of evaluation measurements.
65
+ *
66
+ * Multiplicative throughout: a zero in any factor collapses the score, with no
67
+ * mutual compensation between a gene's strengths and its weaknesses.
68
+ */
69
+ function computeBaseFitness(inputs) {
70
+ const latencyScore = latencyScoreFor(inputs.avgLatencyMs);
71
+ const resourceEfficiency = resourceEfficiencyFor(inputs.avgResourceCost);
72
+ const quality = inputs.successRate * Math.log1p(inputs.coverage) * (1 + inputs.robustness);
73
+ // Multiplied, not divided: L_score and Cost_score are already inverted, so
74
+ // multiplying by them is what makes slower and costlier score lower. No cap —
75
+ // every factor is bounded, so the product is too.
76
+ const value = quality * latencyScore * resourceEfficiency;
77
+ return { value, latencyScore, resourceEfficiency };
78
+ }
79
+ //# sourceMappingURL=fitness-formula.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fitness-formula.js","sourceRoot":"","sources":["../../src/utils/fitness-formula.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AA8DH,0CAEC;AAGD,sDAEC;AAQD,gDAUC;AArFD;;;;;;;;;GASG;AACU,QAAA,gBAAgB,GAAG,IAAI,CAAC;AACrC;;;;;;;;;;;;;;;GAeG;AACU,QAAA,oBAAoB,GAAG,MAAM,CAAC;AAgC3C,mEAAmE;AACnE,SAAgB,eAAe,CAAC,YAAoB;IAClD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC,GAAG,wBAAgB,CAAC,CAAC;AACpE,CAAC;AAED,mEAAmE;AACnE,SAAgB,qBAAqB,CAAC,eAAuB;IAC3D,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,4BAAoB,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAqB;IACtD,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IACzE,MAAM,OAAO,GACX,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7E,2EAA2E;IAC3E,8EAA8E;IAC9E,kDAAkD;IAClD,MAAM,KAAK,GAAG,OAAO,GAAG,YAAY,GAAG,kBAAkB,CAAC;IAC1D,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;AACrD,CAAC"}
@@ -1,6 +1,10 @@
1
1
  export interface UserConfig {
2
2
  "update-check"?: boolean;
3
+ /** Pre-multi-package rollback target; still written for @rotifer/playground
4
+ * so an older CLI and `rotifer config get last-version` keep working. */
3
5
  "last-version"?: string;
6
+ /** Per-package rollback targets, written by `rotifer self-update`. */
7
+ "last-versions"?: Record<string, string>;
4
8
  "default-publish"?: boolean;
5
9
  }
6
10
  export declare function isValidKey(key: string): key is keyof UserConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"user-config.d.ts","sourceRoot":"","sources":["../../src/utils/user-config.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAUD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,MAAM,UAAU,CAE/D;AAED,wBAAgB,cAAc,IAAI,UAAU,CAQ3C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAGvD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAAU,GAAG,MAAM,CAIhE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQ7E;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C"}
1
+ {"version":3,"file":"user-config.d.ts","sourceRoot":"","sources":["../../src/utils/user-config.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;8EAC0E;IAC1E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sEAAsE;IACtE,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAYD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,MAAM,UAAU,CAE/D;AAED,wBAAgB,cAAc,IAAI,UAAU,CAQ3C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAGvD;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAAU,GAAG,MAAM,CAIhE;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQ7E;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAO3C"}
@@ -18,6 +18,8 @@ function getUserConfigFile() {
18
18
  const DEFAULTS = {
19
19
  "update-check": true,
20
20
  "last-version": "",
21
+ // Not exposed through `rotifer config` (see VALID_KEYS) — self-update owns it.
22
+ "last-versions": {},
21
23
  "default-publish": true,
22
24
  };
23
25
  const VALID_KEYS = new Set(["update-check", "last-version", "default-publish"]);
@@ -1 +1 @@
1
- {"version":3,"file":"user-config.js","sourceRoot":"","sources":["../../src/utils/user-config.ts"],"names":[],"mappings":";;AA0BA,gCAEC;AAED,wCAQC;AAED,wCAGC;AAED,gDAIC;AAED,gDAQC;AAED,8CAOC;AApED,qCAA6E;AAC7E,yCAAiC;AACjC,qCAAkC;AAElC,SAAS,YAAY;IACnB,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,IAAA,gBAAI,EAAC,YAAY,EAAE,EAAE,aAAa,CAAC,CAAC;AAC7C,CAAC;AAQD,MAAM,QAAQ,GAAyB;IACrC,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,EAAE;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AAc,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC;AAED,SAAgB,iBAAiB;IAC/B,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IACrD,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,KAAK,OAAO,IAAI,WAAW,KAAK,GAAG,CAAC;IACxD,CAAC;IACD,MAAM,MAAM,GAAG,cAAc,EAAE,CAAC;IAChC,OAAO,MAAM,CAAC,iBAAiB,CAAC,IAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAClE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rotifer/playground",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "description": "Rotifer Protocol Playground — local development environment for gene development, Arena competition, and protocol simulation",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Rotifer Protocol Contributors",
@@ -87,10 +87,10 @@
87
87
  },
88
88
  "optionalDependencies": {
89
89
  "@rolldown/binding-linux-x64-gnu": "1.1.1",
90
- "@rotifer/playground-darwin-arm64": "0.24.0",
91
- "@rotifer/playground-darwin-x64": "0.24.0",
92
- "@rotifer/playground-linux-x64-gnu": "0.24.0",
93
- "@rotifer/playground-win32-x64-msvc": "0.24.0"
90
+ "@rotifer/playground-darwin-arm64": "0.25.1",
91
+ "@rotifer/playground-darwin-x64": "0.25.1",
92
+ "@rotifer/playground-linux-x64-gnu": "0.25.1",
93
+ "@rotifer/playground-win32-x64-msvc": "0.25.1"
94
94
  },
95
95
  "engines": {
96
96
  "node": ">=22.18.0"