@rotifer/playground 0.28.0 → 0.30.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 +45 -0
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/dist/cloud/capability-candidates.d.ts +2 -0
- package/dist/cloud/capability-candidates.d.ts.map +1 -1
- package/dist/cloud/capability-candidates.js +83 -31
- package/dist/cloud/capability-candidates.js.map +1 -1
- package/dist/cloud/client.d.ts +10 -0
- package/dist/cloud/client.d.ts.map +1 -1
- package/dist/cloud/client.js +41 -2
- package/dist/cloud/client.js.map +1 -1
- package/dist/cloud/types.d.ts +10 -0
- package/dist/cloud/types.d.ts.map +1 -1
- package/dist/cloud/types.js.map +1 -1
- package/dist/commands/agent-run.d.ts.map +1 -1
- package/dist/commands/agent-run.js +13 -4
- package/dist/commands/agent-run.js.map +1 -1
- package/dist/commands/arena-submit.d.ts.map +1 -1
- package/dist/commands/arena-submit.js +48 -10
- package/dist/commands/arena-submit.js.map +1 -1
- package/dist/commands/genome-format.d.ts +180 -0
- package/dist/commands/genome-format.d.ts.map +1 -0
- package/dist/commands/genome-format.js +774 -0
- package/dist/commands/genome-format.js.map +1 -0
- package/dist/commands/genome-import.d.ts +23 -27
- package/dist/commands/genome-import.d.ts.map +1 -1
- package/dist/commands/genome-import.js +91 -250
- package/dist/commands/genome-import.js.map +1 -1
- package/dist/commands/genome.d.ts +7 -138
- package/dist/commands/genome.d.ts.map +1 -1
- package/dist/commands/genome.js +31 -245
- package/dist/commands/genome.js.map +1 -1
- package/dist/utils/fitness-formula.d.ts +75 -17
- package/dist/utils/fitness-formula.d.ts.map +1 -1
- package/dist/utils/fitness-formula.js +97 -22
- package/dist/utils/fitness-formula.js.map +1 -1
- package/dist/utils/run-fuel-ladder.d.ts +6 -3
- package/dist/utils/run-fuel-ladder.d.ts.map +1 -1
- package/dist/utils/run-fuel-ladder.js +6 -3
- package/dist/utils/run-fuel-ladder.js.map +1 -1
- package/package.json +5 -5
|
@@ -7,10 +7,17 @@
|
|
|
7
7
|
* sit in the denominator and a slower, costlier gene scores lower. The
|
|
8
8
|
* implementation does not divide by raw values — an unbounded denominator
|
|
9
9
|
* drives F(g) to zero for any gene with a realistic latency, which is what
|
|
10
|
-
* ADR-215 P1 set out to avoid. It normalizes each into a (0, 1] score first
|
|
10
|
+
* ADR-215 P1 set out to avoid. It normalizes each into a (0, 1] score first,
|
|
11
|
+
* against a reference scale (ADR-318 D2):
|
|
11
12
|
*
|
|
12
|
-
* L_score = 1 / (1 + avg_latency_ms /
|
|
13
|
-
* Cost_score = 1 / (1 + avg_cost /
|
|
13
|
+
* L_score = 1 / (1 + avg_latency_ms / L_ref)
|
|
14
|
+
* Cost_score = 1 / (1 + avg_cost / Cost_ref)
|
|
15
|
+
*
|
|
16
|
+
* L_ref / Cost_ref are the current-season median of the gene's own domain and
|
|
17
|
+
* fidelity, computed by the registry (`get_fitness_reference`); a gene exactly
|
|
18
|
+
* at its peers' median scores 1/2 on each. While the season has too few
|
|
19
|
+
* measured genes, or the registry cannot be reached, the fixed constants below
|
|
20
|
+
* stand in (FALLBACK_REFERENCE).
|
|
14
21
|
*
|
|
15
22
|
* Those scores are already *inverted* — lower latency means a score nearer 1 —
|
|
16
23
|
* so they belong in the numerator. Dividing by them, as this code did until
|
|
@@ -19,18 +26,19 @@
|
|
|
19
26
|
* tests in `tests/unit/fitness-formula.test.ts` hold the direction.
|
|
20
27
|
*/
|
|
21
28
|
/**
|
|
22
|
-
*
|
|
29
|
+
* Fallback L_ref: latency at which L_score halves when no season median is
|
|
30
|
+
* available. `[N]` — provisional, uncalibrated.
|
|
23
31
|
*
|
|
24
|
-
* ADR-318 D2
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* fixed constants are the stand-ins until it does.
|
|
32
|
+
* ADR-318 D2 defines `L_ref` / `Cost_ref` as the season median for the gene's
|
|
33
|
+
* own domain and fidelity, which is what makes F(g) dimensionless and
|
|
34
|
+
* comparable across bindings. The registry computes it (v0.9.3 #6); these two
|
|
35
|
+
* fixed constants are used only while that median does not exist for a group
|
|
36
|
+
* — too few measured genes this season — or cannot be fetched.
|
|
30
37
|
*/
|
|
31
38
|
export declare const LATENCY_SCALE_MS = 1000;
|
|
32
39
|
/**
|
|
33
|
-
*
|
|
40
|
+
* Fallback Cost_ref: resource cost (fuel units) at which Cost_score halves
|
|
41
|
+
* when no season median is available. `[N]` — provisional.
|
|
34
42
|
*
|
|
35
43
|
* Badly out of scale, and known to be: ADR-318 recorded both constants as
|
|
36
44
|
* guesses, and measured 7.7e9 fuel on a leaderboard gene from its reported
|
|
@@ -46,6 +54,55 @@ export declare const LATENCY_SCALE_MS = 1000;
|
|
|
46
54
|
* protocol-parameter change under RFC-001 §0, not a code cleanup.
|
|
47
55
|
*/
|
|
48
56
|
export declare const RESOURCE_SCALE_UNITS = 10000;
|
|
57
|
+
/** The scale the two efficiency terms are measured against (ADR-318 D2). */
|
|
58
|
+
export interface ReferenceScale {
|
|
59
|
+
/** L_ref, in milliseconds. */
|
|
60
|
+
latencyMs: number;
|
|
61
|
+
/** Cost_ref, in fuel units. */
|
|
62
|
+
resourceCost: number;
|
|
63
|
+
}
|
|
64
|
+
/** The fixed constants, used whenever no season median is available. */
|
|
65
|
+
export declare const FALLBACK_REFERENCE: Readonly<ReferenceScale>;
|
|
66
|
+
/** Both values finite and positive; anything else would divide by zero or flip a sign. */
|
|
67
|
+
export declare function isUsableReference(reference: ReferenceScale): boolean;
|
|
68
|
+
/** One row of `get_fitness_reference`: the season median for a (domain, fidelity) group. */
|
|
69
|
+
export interface SeasonReferenceRow {
|
|
70
|
+
l_ref_ms: number;
|
|
71
|
+
cost_ref: number;
|
|
72
|
+
sample_genes: number;
|
|
73
|
+
season_number: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `code` on the error a reference fetcher throws when the registry has no
|
|
77
|
+
* `get_fitness_reference` (HTTP 404): a registry from before the migration,
|
|
78
|
+
* whose arena_entries has no reference columns either. A code rather than an
|
|
79
|
+
* error class, so the check survives two copies of this module.
|
|
80
|
+
*/
|
|
81
|
+
export declare const REFERENCE_FUNCTION_MISSING = "REFERENCE_FUNCTION_MISSING";
|
|
82
|
+
export interface ResolvedReference {
|
|
83
|
+
scale: ReferenceScale;
|
|
84
|
+
source: "season-median" | "fallback";
|
|
85
|
+
/**
|
|
86
|
+
* Whether a submission may record this reference in the row. False only
|
|
87
|
+
* when the registry said it has no `get_fitness_reference` (404): the
|
|
88
|
+
* columns ship in the same migration as the function, so that registry
|
|
89
|
+
* would reject them. Any other failure — a timeout, a 500 — still records
|
|
90
|
+
* the fallback with its constants: the upsert keeps columns it is not sent,
|
|
91
|
+
* so leaving them out would leave an older median on a row whose F(g) used
|
|
92
|
+
* the constants, and the row could no longer be recomputed on its own.
|
|
93
|
+
*/
|
|
94
|
+
isRecordable: boolean;
|
|
95
|
+
/** Why the fallback was used; absent for a season median. */
|
|
96
|
+
reason?: string;
|
|
97
|
+
sampleGenes?: number;
|
|
98
|
+
seasonNumber?: number;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The reference scale for one gene's F(g): its group's season median when the
|
|
102
|
+
* registry has one, the fixed constants otherwise. Never throws — a missing
|
|
103
|
+
* median is a reason to fall back, not to fail the evaluation.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveFitnessReference(domain: string, fidelity: string, fetchReference: (domain: string, fidelity: string) => Promise<SeasonReferenceRow | null>): Promise<ResolvedReference>;
|
|
49
106
|
export interface FitnessInputs {
|
|
50
107
|
/** S_r — fraction of evaluation runs that passed, in [0, 1]. */
|
|
51
108
|
successRate: number;
|
|
@@ -74,15 +131,16 @@ export interface FitnessBreakdown {
|
|
|
74
131
|
/** Cost_score — 1 at zero cost, falling monotonically as cost rises. */
|
|
75
132
|
resourceEfficiency: number;
|
|
76
133
|
}
|
|
77
|
-
/** L_score: 1 at zero latency, strictly decreasing, never zero. */
|
|
78
|
-
export declare function latencyScoreFor(avgLatencyMs: number): number;
|
|
79
|
-
/** Cost_score: 1 at zero cost, strictly decreasing, never zero. */
|
|
80
|
-
export declare function resourceEfficiencyFor(avgResourceCost: number): number;
|
|
134
|
+
/** L_score: 1 at zero latency, 1/2 at L_ref, strictly decreasing, never zero. */
|
|
135
|
+
export declare function latencyScoreFor(avgLatencyMs: number, latencyRefMs?: number): number;
|
|
136
|
+
/** Cost_score: 1 at zero cost, 1/2 at Cost_ref, strictly decreasing, never zero. */
|
|
137
|
+
export declare function resourceEfficiencyFor(avgResourceCost: number, costRef?: number): number;
|
|
81
138
|
/**
|
|
82
|
-
* F(g) from one batch of evaluation measurements
|
|
139
|
+
* F(g) from one batch of evaluation measurements, against `reference` (the
|
|
140
|
+
* fixed constants when omitted, or when the given scale is not usable).
|
|
83
141
|
*
|
|
84
142
|
* Multiplicative throughout: a zero in any factor collapses the score, with no
|
|
85
143
|
* mutual compensation between a gene's strengths and its weaknesses.
|
|
86
144
|
*/
|
|
87
|
-
export declare function computeBaseFitness(inputs: FitnessInputs): FitnessBreakdown;
|
|
145
|
+
export declare function computeBaseFitness(inputs: FitnessInputs, reference?: ReferenceScale): FitnessBreakdown;
|
|
88
146
|
//# sourceMappingURL=fitness-formula.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fitness-formula.d.ts","sourceRoot":"","sources":["../../src/utils/fitness-formula.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fitness-formula.d.ts","sourceRoot":"","sources":["../../src/utils/fitness-formula.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,8BAA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,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,GAAE,MAAyB,GAAG,MAAM,CAErG;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,MAA6B,GAAG,MAAM,CAE7G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,SAAS,GAAE,cAAmC,GAC7C,gBAAgB,CAWlB"}
|
|
@@ -8,10 +8,17 @@
|
|
|
8
8
|
* sit in the denominator and a slower, costlier gene scores lower. The
|
|
9
9
|
* implementation does not divide by raw values — an unbounded denominator
|
|
10
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
|
|
11
|
+
* ADR-215 P1 set out to avoid. It normalizes each into a (0, 1] score first,
|
|
12
|
+
* against a reference scale (ADR-318 D2):
|
|
12
13
|
*
|
|
13
|
-
* L_score = 1 / (1 + avg_latency_ms /
|
|
14
|
-
* Cost_score = 1 / (1 + avg_cost /
|
|
14
|
+
* L_score = 1 / (1 + avg_latency_ms / L_ref)
|
|
15
|
+
* Cost_score = 1 / (1 + avg_cost / Cost_ref)
|
|
16
|
+
*
|
|
17
|
+
* L_ref / Cost_ref are the current-season median of the gene's own domain and
|
|
18
|
+
* fidelity, computed by the registry (`get_fitness_reference`); a gene exactly
|
|
19
|
+
* at its peers' median scores 1/2 on each. While the season has too few
|
|
20
|
+
* measured genes, or the registry cannot be reached, the fixed constants below
|
|
21
|
+
* stand in (FALLBACK_REFERENCE).
|
|
15
22
|
*
|
|
16
23
|
* Those scores are already *inverted* — lower latency means a score nearer 1 —
|
|
17
24
|
* so they belong in the numerator. Dividing by them, as this code did until
|
|
@@ -20,23 +27,26 @@
|
|
|
20
27
|
* tests in `tests/unit/fitness-formula.test.ts` hold the direction.
|
|
21
28
|
*/
|
|
22
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.RESOURCE_SCALE_UNITS = exports.LATENCY_SCALE_MS = void 0;
|
|
30
|
+
exports.REFERENCE_FUNCTION_MISSING = exports.FALLBACK_REFERENCE = exports.RESOURCE_SCALE_UNITS = exports.LATENCY_SCALE_MS = void 0;
|
|
31
|
+
exports.isUsableReference = isUsableReference;
|
|
32
|
+
exports.resolveFitnessReference = resolveFitnessReference;
|
|
24
33
|
exports.latencyScoreFor = latencyScoreFor;
|
|
25
34
|
exports.resourceEfficiencyFor = resourceEfficiencyFor;
|
|
26
35
|
exports.computeBaseFitness = computeBaseFitness;
|
|
27
36
|
/**
|
|
28
|
-
*
|
|
37
|
+
* Fallback L_ref: latency at which L_score halves when no season median is
|
|
38
|
+
* available. `[N]` — provisional, uncalibrated.
|
|
29
39
|
*
|
|
30
|
-
* ADR-318 D2
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* fixed constants are the stand-ins until it does.
|
|
40
|
+
* ADR-318 D2 defines `L_ref` / `Cost_ref` as the season median for the gene's
|
|
41
|
+
* own domain and fidelity, which is what makes F(g) dimensionless and
|
|
42
|
+
* comparable across bindings. The registry computes it (v0.9.3 #6); these two
|
|
43
|
+
* fixed constants are used only while that median does not exist for a group
|
|
44
|
+
* — too few measured genes this season — or cannot be fetched.
|
|
36
45
|
*/
|
|
37
46
|
exports.LATENCY_SCALE_MS = 1000;
|
|
38
47
|
/**
|
|
39
|
-
*
|
|
48
|
+
* Fallback Cost_ref: resource cost (fuel units) at which Cost_score halves
|
|
49
|
+
* when no season median is available. `[N]` — provisional.
|
|
40
50
|
*
|
|
41
51
|
* Badly out of scale, and known to be: ADR-318 recorded both constants as
|
|
42
52
|
* guesses, and measured 7.7e9 fuel on a leaderboard gene from its reported
|
|
@@ -52,23 +62,88 @@ exports.LATENCY_SCALE_MS = 1000;
|
|
|
52
62
|
* protocol-parameter change under RFC-001 §0, not a code cleanup.
|
|
53
63
|
*/
|
|
54
64
|
exports.RESOURCE_SCALE_UNITS = 10_000;
|
|
55
|
-
/**
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
/** The fixed constants, used whenever no season median is available. */
|
|
66
|
+
exports.FALLBACK_REFERENCE = Object.freeze({
|
|
67
|
+
latencyMs: exports.LATENCY_SCALE_MS,
|
|
68
|
+
resourceCost: exports.RESOURCE_SCALE_UNITS,
|
|
69
|
+
});
|
|
70
|
+
/** Both values finite and positive; anything else would divide by zero or flip a sign. */
|
|
71
|
+
function isUsableReference(reference) {
|
|
72
|
+
return (Number.isFinite(reference.latencyMs) && reference.latencyMs > 0 &&
|
|
73
|
+
Number.isFinite(reference.resourceCost) && reference.resourceCost > 0);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `code` on the error a reference fetcher throws when the registry has no
|
|
77
|
+
* `get_fitness_reference` (HTTP 404): a registry from before the migration,
|
|
78
|
+
* whose arena_entries has no reference columns either. A code rather than an
|
|
79
|
+
* error class, so the check survives two copies of this module.
|
|
80
|
+
*/
|
|
81
|
+
exports.REFERENCE_FUNCTION_MISSING = "REFERENCE_FUNCTION_MISSING";
|
|
82
|
+
/**
|
|
83
|
+
* The reference scale for one gene's F(g): its group's season median when the
|
|
84
|
+
* registry has one, the fixed constants otherwise. Never throws — a missing
|
|
85
|
+
* median is a reason to fall back, not to fail the evaluation.
|
|
86
|
+
*/
|
|
87
|
+
async function resolveFitnessReference(domain, fidelity, fetchReference) {
|
|
88
|
+
let row;
|
|
89
|
+
try {
|
|
90
|
+
row = await fetchReference(domain, fidelity);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const isFunctionMissing = err?.code === exports.REFERENCE_FUNCTION_MISSING;
|
|
94
|
+
return {
|
|
95
|
+
scale: { ...exports.FALLBACK_REFERENCE },
|
|
96
|
+
source: "fallback",
|
|
97
|
+
isRecordable: !isFunctionMissing,
|
|
98
|
+
reason: isFunctionMissing
|
|
99
|
+
? "the registry has no season median yet (get_fitness_reference is not deployed)"
|
|
100
|
+
: `the registry's season median could not be read (${err.message})`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (row === null) {
|
|
104
|
+
return {
|
|
105
|
+
scale: { ...exports.FALLBACK_REFERENCE },
|
|
106
|
+
source: "fallback",
|
|
107
|
+
isRecordable: true,
|
|
108
|
+
reason: `too few measured ${domain} / ${fidelity} genes this season for a median`,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const scale = { latencyMs: Number(row.l_ref_ms), resourceCost: Number(row.cost_ref) };
|
|
112
|
+
if (!isUsableReference(scale)) {
|
|
113
|
+
return {
|
|
114
|
+
scale: { ...exports.FALLBACK_REFERENCE },
|
|
115
|
+
source: "fallback",
|
|
116
|
+
isRecordable: true,
|
|
117
|
+
reason: "the registry returned a median that is not a positive number",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
scale,
|
|
122
|
+
source: "season-median",
|
|
123
|
+
isRecordable: true,
|
|
124
|
+
sampleGenes: row.sample_genes,
|
|
125
|
+
seasonNumber: row.season_number,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** L_score: 1 at zero latency, 1/2 at L_ref, strictly decreasing, never zero. */
|
|
129
|
+
function latencyScoreFor(avgLatencyMs, latencyRefMs = exports.LATENCY_SCALE_MS) {
|
|
130
|
+
return 1.0 / (1.0 + Math.max(avgLatencyMs, 0) / latencyRefMs);
|
|
58
131
|
}
|
|
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) /
|
|
132
|
+
/** Cost_score: 1 at zero cost, 1/2 at Cost_ref, strictly decreasing, never zero. */
|
|
133
|
+
function resourceEfficiencyFor(avgResourceCost, costRef = exports.RESOURCE_SCALE_UNITS) {
|
|
134
|
+
return 1.0 / (1.0 + Math.max(avgResourceCost, 0) / costRef);
|
|
62
135
|
}
|
|
63
136
|
/**
|
|
64
|
-
* F(g) from one batch of evaluation measurements
|
|
137
|
+
* F(g) from one batch of evaluation measurements, against `reference` (the
|
|
138
|
+
* fixed constants when omitted, or when the given scale is not usable).
|
|
65
139
|
*
|
|
66
140
|
* Multiplicative throughout: a zero in any factor collapses the score, with no
|
|
67
141
|
* mutual compensation between a gene's strengths and its weaknesses.
|
|
68
142
|
*/
|
|
69
|
-
function computeBaseFitness(inputs) {
|
|
70
|
-
const
|
|
71
|
-
const
|
|
143
|
+
function computeBaseFitness(inputs, reference = exports.FALLBACK_REFERENCE) {
|
|
144
|
+
const scale = isUsableReference(reference) ? reference : exports.FALLBACK_REFERENCE;
|
|
145
|
+
const latencyScore = latencyScoreFor(inputs.avgLatencyMs, scale.latencyMs);
|
|
146
|
+
const resourceEfficiency = resourceEfficiencyFor(inputs.avgResourceCost, scale.resourceCost);
|
|
72
147
|
const quality = inputs.successRate * Math.log1p(inputs.coverage) * (1 + inputs.robustness);
|
|
73
148
|
// Multiplied, not divided: L_score and Cost_score are already inverted, so
|
|
74
149
|
// multiplying by them is what makes slower and costlier score lower. No cap —
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fitness-formula.js","sourceRoot":"","sources":["../../src/utils/fitness-formula.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"fitness-formula.js","sourceRoot":"","sources":["../../src/utils/fitness-formula.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AA+CH,8CAKC;AA0CD,0DA2CC;AAiCD,0CAEC;AAGD,sDAEC;AASD,gDAcC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,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC3E,MAAM,kBAAkB,GAAG,qBAAqB,CAAC,MAAM,CAAC,eAAe,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7F,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"}
|
|
@@ -10,9 +10,12 @@
|
|
|
10
10
|
* A ladder keeps both properties we care about:
|
|
11
11
|
* - completion: a run that dies of fuel alone is retried with more, up to a
|
|
12
12
|
* hard cap, so "expensive" stops reading as "broken";
|
|
13
|
-
* - honesty:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - honesty: what lands in resource_cost is the fuel actually burned plus
|
|
14
|
+
* any host-call surcharges (ADR-327 D4, billed on top, not drawn from the
|
|
15
|
+
* budget), and F(g)'s efficiency term prices all of it — a Gene that
|
|
16
|
+
* needs 8e9 fuel pays for 8e9 fuel. Nothing here makes an expensive Gene
|
|
17
|
+
* look cheap. A rung's budget bounds guest computation only, so
|
|
18
|
+
* resource_cost can exceed it; that is not a fuel-exhausted failure.
|
|
16
19
|
*
|
|
17
20
|
* The cap is finite on purpose: a Gene that exhausts the top rung records a
|
|
18
21
|
* fuel-exhausted failure, because at some point "needs more fuel" is the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-fuel-ladder.d.ts","sourceRoot":"","sources":["../../src/utils/run-fuel-ladder.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"run-fuel-ladder.d.ts","sourceRoot":"","sources":["../../src/utils/run-fuel-ladder.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAQxC,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,iBAAiB,GACjB,SAAS,GACT,OAAO,CAAC;AAEZ;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,cAAc,GAAG,IAAI,CAWvB;AAED,uDAAuD;AACvD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE1D"}
|
|
@@ -16,9 +16,12 @@ const sandbox_defaults_js_1 = require("./sandbox-defaults.js");
|
|
|
16
16
|
* A ladder keeps both properties we care about:
|
|
17
17
|
* - completion: a run that dies of fuel alone is retried with more, up to a
|
|
18
18
|
* hard cap, so "expensive" stops reading as "broken";
|
|
19
|
-
* - honesty:
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* - honesty: what lands in resource_cost is the fuel actually burned plus
|
|
20
|
+
* any host-call surcharges (ADR-327 D4, billed on top, not drawn from the
|
|
21
|
+
* budget), and F(g)'s efficiency term prices all of it — a Gene that
|
|
22
|
+
* needs 8e9 fuel pays for 8e9 fuel. Nothing here makes an expensive Gene
|
|
23
|
+
* look cheap. A rung's budget bounds guest computation only, so
|
|
24
|
+
* resource_cost can exceed it; that is not a fuel-exhausted failure.
|
|
22
25
|
*
|
|
23
26
|
* The cap is finite on purpose: a Gene that exhausts the top rung records a
|
|
24
27
|
* fuel-exhausted failure, because at some point "needs more fuel" is the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-fuel-ladder.js","sourceRoot":"","sources":["../../src/utils/run-fuel-ladder.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"run-fuel-ladder.js","sourceRoot":"","sources":["../../src/utils/run-fuel-ladder.ts"],"names":[],"mappings":";;;AAgDA,gDAaC;AAGD,gDAEC;AAlED,+DAAoE;AAEpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACU,QAAA,WAAW,GAAsB;IAC5C,iDAA2B,CAAC,QAAQ,EAAE,+BAA+B;IACrE,aAAa;IACb,wEAAwE;IACxE,wEAAwE;IACxE,yEAAyE;IACzE,2EAA2E;IAC3E,cAAc;CACf,CAAC;AAQF;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,YAAuC;IAEvC,IAAI,CAAC,YAAY;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,GAAG,GAAG,YAAY,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACxE,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,iBAAiB,CAAC;IACrD,IAAI,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC5F,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,uDAAuD;AACvD,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,iDAA2B,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rotifer/playground",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.0",
|
|
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",
|
|
@@ -92,10 +92,10 @@
|
|
|
92
92
|
},
|
|
93
93
|
"optionalDependencies": {
|
|
94
94
|
"@rolldown/binding-linux-x64-gnu": "1.1.1",
|
|
95
|
-
"@rotifer/playground-darwin-arm64": "0.
|
|
96
|
-
"@rotifer/playground-darwin-x64": "0.
|
|
97
|
-
"@rotifer/playground-linux-x64-gnu": "0.
|
|
98
|
-
"@rotifer/playground-win32-x64-msvc": "0.
|
|
95
|
+
"@rotifer/playground-darwin-arm64": "0.30.0",
|
|
96
|
+
"@rotifer/playground-darwin-x64": "0.30.0",
|
|
97
|
+
"@rotifer/playground-linux-x64-gnu": "0.30.0",
|
|
98
|
+
"@rotifer/playground-win32-x64-msvc": "0.30.0"
|
|
99
99
|
},
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=22.18.0"
|