@drupflare/spool 0.3.0 → 1.0.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/README.md +279 -1607
- package/dist/angular/index.d.ts +13 -0
- package/dist/angular/index.js +25 -0
- package/dist/angular/pages.d.ts +28 -0
- package/dist/angular/pages.js +85 -0
- package/dist/cdn/client.js +1 -1
- package/dist/cdn/location.d.ts +6 -0
- package/dist/cdn/location.js +8 -0
- package/dist/cdn/manifest.json +7 -7
- package/dist/cdn/spool-sw.js +1 -1
- package/dist/client/bootstrap.d.ts +57 -0
- package/dist/client/bootstrap.js +307 -0
- package/dist/client/contact.d.ts +24 -0
- package/dist/client/contact.js +66 -0
- package/dist/client/declared.d.ts +23 -0
- package/dist/client/declared.js +68 -0
- package/dist/client/entry.js +123 -2
- package/dist/client/gate.d.ts +1 -0
- package/dist/client/gate.js +148 -0
- package/dist/client/index.d.ts +25 -0
- package/dist/client/index.js +1 -0
- package/dist/client/live.d.ts +66 -0
- package/dist/client/live.js +225 -0
- package/dist/client/navigate-entry.d.ts +1 -0
- package/dist/client/navigate-entry.js +4 -0
- package/dist/client/navigate.d.ts +54 -0
- package/dist/client/navigate.js +272 -0
- package/dist/client/persist.d.ts +2 -0
- package/dist/client/persist.js +9 -0
- package/dist/client/register.d.ts +34 -2
- package/dist/client/register.js +64 -7
- package/dist/express/index.d.ts +11 -0
- package/dist/express/index.js +209 -0
- package/dist/hono/index.d.ts +19 -0
- package/dist/hono/index.js +49 -0
- package/dist/next/index.d.ts +33 -0
- package/dist/next/index.js +41 -0
- package/dist/next/pages.d.ts +22 -0
- package/dist/next/pages.js +39 -0
- package/dist/node/listener.d.ts +3 -0
- package/dist/node/listener.js +57 -2
- package/dist/nuxt/index.d.ts +22 -0
- package/dist/nuxt/index.js +104 -0
- package/dist/nuxt/pages.d.ts +26 -0
- package/dist/nuxt/pages.js +48 -0
- package/dist/nuxt/runtime/index.d.ts +24 -0
- package/dist/nuxt/runtime/index.js +58 -0
- package/dist/plugins/coverage.d.ts +14 -0
- package/dist/plugins/coverage.js +27 -0
- package/dist/plugins/mode.d.ts +19 -0
- package/dist/plugins/mode.js +20 -0
- package/dist/plugins/path.d.ts +16 -0
- package/dist/plugins/path.js +139 -0
- package/dist/plugins/report.d.ts +22 -0
- package/dist/plugins/report.js +18 -0
- package/dist/plugins/routes.d.ts +38 -0
- package/dist/plugins/routes.js +52 -0
- package/dist/plugins/static.d.ts +42 -0
- package/dist/plugins/static.js +97 -0
- package/dist/protocol/bundle.d.ts +111 -0
- package/dist/protocol/bundle.js +428 -0
- package/dist/protocol/config.d.ts +80 -1
- package/dist/protocol/config.js +31 -1
- package/dist/protocol/dataset.d.ts +189 -0
- package/dist/protocol/dataset.js +212 -0
- package/dist/protocol/envelope.d.ts +34 -1
- package/dist/protocol/envelope.js +16 -1
- package/dist/protocol/errors.d.ts +1 -1
- package/dist/protocol/graph.d.ts +23 -4
- package/dist/protocol/graph.js +34 -3
- package/dist/protocol/index-rows.d.ts +22 -0
- package/dist/protocol/index-rows.js +53 -0
- package/dist/protocol/index.d.ts +5 -0
- package/dist/protocol/index.js +5 -0
- package/dist/protocol/normalise.d.ts +4 -4
- package/dist/protocol/normalise.js +9 -5
- package/dist/protocol/plan.d.ts +100 -0
- package/dist/protocol/plan.js +661 -0
- package/dist/protocol/provision.d.ts +46 -0
- package/dist/protocol/provision.js +38 -0
- package/dist/protocol/query.d.ts +66 -5
- package/dist/protocol/query.js +103 -4
- package/dist/protocol/ring.d.ts +58 -0
- package/dist/protocol/ring.js +6 -0
- package/dist/protocol/route.d.ts +63 -13
- package/dist/protocol/route.js +126 -6
- package/dist/protocol/tag.d.ts +22 -2
- package/dist/protocol/tag.js +25 -4
- package/dist/protocol/view.d.ts +2 -0
- package/dist/protocol/view.js +8 -2
- package/dist/protocol/views.d.ts +6 -0
- package/dist/protocol/views.js +15 -0
- package/dist/protocol/write.d.ts +234 -0
- package/dist/protocol/write.js +343 -0
- package/dist/proxy/eligible.d.ts +22 -1
- package/dist/proxy/eligible.js +62 -15
- package/dist/proxy/proxy.js +28 -18
- package/dist/react-router/index.d.ts +20 -0
- package/dist/react-router/index.js +60 -0
- package/dist/react-router/pages.d.ts +34 -0
- package/dist/react-router/pages.js +83 -0
- package/dist/report/dataset.d.ts +48 -0
- package/dist/report/dataset.js +93 -0
- package/dist/report/demand.d.ts +49 -0
- package/dist/report/demand.js +60 -0
- package/dist/report/derive.d.ts +285 -0
- package/dist/report/derive.js +676 -1
- package/dist/report/economics.d.ts +66 -1
- package/dist/report/economics.js +208 -1
- package/dist/report/headline.d.ts +158 -0
- package/dist/report/headline.js +473 -0
- package/dist/report/index.d.ts +4 -0
- package/dist/report/index.js +4 -0
- package/dist/report/inputs.d.ts +176 -0
- package/dist/report/inputs.js +248 -0
- package/dist/report/institution.d.ts +188 -1
- package/dist/report/institution.js +146 -0
- package/dist/report/loops.d.ts +73 -0
- package/dist/report/loops.js +101 -0
- package/dist/report/measurement.d.ts +1 -1
- package/dist/report/measurement.js +7 -1
- package/dist/report/model.d.ts +2 -0
- package/dist/report/model.js +4 -0
- package/dist/report/thirdparty.d.ts +57 -0
- package/dist/report/thirdparty.js +111 -0
- package/dist/report/traffic.d.ts +8 -0
- package/dist/report/traffic.js +7 -0
- package/dist/report/trim.d.ts +56 -0
- package/dist/report/trim.js +83 -1
- package/dist/server/bundle.d.ts +55 -0
- package/dist/server/bundle.js +172 -0
- package/dist/server/dataset.d.ts +54 -0
- package/dist/server/dataset.js +355 -0
- package/dist/server/embedded.d.ts +7 -3
- package/dist/server/embedded.js +7 -3
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +6 -0
- package/dist/server/live-sockets.d.ts +54 -0
- package/dist/server/live-sockets.js +131 -0
- package/dist/server/live.d.ts +146 -0
- package/dist/server/live.js +228 -0
- package/dist/server/ring.d.ts +77 -0
- package/dist/server/ring.js +311 -0
- package/dist/server/spool.d.ts +158 -3
- package/dist/server/spool.js +578 -41
- package/dist/server/static.d.ts +42 -0
- package/dist/server/static.js +29 -0
- package/dist/server/stub.d.ts +43 -5
- package/dist/server/stub.js +126 -8
- package/dist/server/write.d.ts +49 -0
- package/dist/server/write.js +223 -0
- package/dist/stores/durable-object.d.ts +46 -0
- package/dist/stores/durable-object.js +114 -0
- package/dist/sw/analytics.d.ts +7 -1
- package/dist/sw/analytics.js +16 -2
- package/dist/sw/coverage.d.ts +6 -0
- package/dist/sw/coverage.js +34 -0
- package/dist/sw/dataset-sync.d.ts +76 -0
- package/dist/sw/dataset-sync.js +149 -0
- package/dist/sw/dataset.d.ts +91 -0
- package/dist/sw/dataset.js +318 -0
- package/dist/sw/family.d.ts +15 -0
- package/dist/sw/family.js +48 -0
- package/dist/sw/graph/index.d.ts +31 -1
- package/dist/sw/graph/index.js +57 -5
- package/dist/sw/graph/invalidate.d.ts +15 -3
- package/dist/sw/graph/invalidate.js +42 -4
- package/dist/sw/idb.d.ts +2 -0
- package/dist/sw/idb.js +80 -11
- package/dist/sw/index.d.ts +2 -0
- package/dist/sw/index.js +1 -0
- package/dist/sw/pack/store.d.ts +128 -0
- package/dist/sw/pack/store.js +737 -0
- package/dist/sw/partition.d.ts +6 -1
- package/dist/sw/partition.js +21 -2
- package/dist/sw/policy.d.ts +2 -0
- package/dist/sw/policy.js +11 -0
- package/dist/sw/principal-dataset.d.ts +64 -0
- package/dist/sw/principal-dataset.js +254 -0
- package/dist/sw/probe.d.ts +16 -0
- package/dist/sw/probe.js +25 -0
- package/dist/sw/render.d.ts +7 -2
- package/dist/sw/render.js +19 -5
- package/dist/sw/replica.d.ts +12 -3
- package/dist/sw/replica.js +40 -5
- package/dist/sw/router.d.ts +3 -2
- package/dist/sw/router.js +15 -2
- package/dist/sw/runtime.d.ts +90 -2
- package/dist/sw/runtime.js +857 -61
- package/dist/sw/scheduler.d.ts +6 -1
- package/dist/sw/scheduler.js +22 -5
- package/dist/sw/seal.d.ts +13 -0
- package/dist/sw/seal.js +13 -4
- package/dist/sw/static.d.ts +18 -0
- package/dist/sw/static.js +84 -1
- package/dist/sw/storage.d.ts +51 -1
- package/dist/sw/storage.js +33 -1
- package/dist/sw/write.d.ts +147 -0
- package/dist/sw/write.js +625 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -2
- package/dist/vite/index.d.ts +26 -0
- package/dist/vite/index.js +66 -0
- package/dist/vue/index.d.ts +36 -0
- package/dist/vue/index.js +53 -0
- package/package.json +65 -4
package/dist/report/inputs.js
CHANGED
|
@@ -214,3 +214,251 @@ export const PANTHEON_OVERAGE = {
|
|
|
214
214
|
};
|
|
215
215
|
/** the three tiers, named by the share of annual views served with zero network */
|
|
216
216
|
export const TIERS = { meaningful: 0.3, major: 0.65, transformative: 0.9 };
|
|
217
|
+
/** grams per pound, the mass conversion behind eGRID's lb/MWh rates */
|
|
218
|
+
export const G_PER_LB = 453.59237;
|
|
219
|
+
const cents = (value) => ({
|
|
220
|
+
value,
|
|
221
|
+
unit: 'cents/kWh',
|
|
222
|
+
layer: 'L0',
|
|
223
|
+
source: 'EIA Electric Power Annual 2025, Table 2.10, https://www.eia.gov/electricity/annual/html/epa_02_10.html (raw HTML read 2026-11-05)'
|
|
224
|
+
});
|
|
225
|
+
/**
|
|
226
|
+
* Average retail electricity price in cents per kWh for 2025, from EIA Electric Power Annual Table
|
|
227
|
+
* 2.10 (L0). The table holds these five states. Any other state has no price here, and
|
|
228
|
+
* `electricityPrice` throws on it rather than guessing.
|
|
229
|
+
*/
|
|
230
|
+
export const ELECTRICITY_PRICE = {
|
|
231
|
+
US: { commercial: cents(13.37), industrial: cents(8.51) },
|
|
232
|
+
NH: { commercial: cents(20.11), industrial: cents(16.82) },
|
|
233
|
+
MA: { commercial: cents(23.1), industrial: cents(19.04) },
|
|
234
|
+
AZ: { commercial: cents(12.45), industrial: cents(8.05) },
|
|
235
|
+
WA: { commercial: cents(10.97), industrial: cents(7) }
|
|
236
|
+
};
|
|
237
|
+
const egrid = (value) => ({
|
|
238
|
+
value,
|
|
239
|
+
unit: 'lb/MWh',
|
|
240
|
+
layer: 'L0',
|
|
241
|
+
source: 'EPA eGRID2023, eGRID subregion total output emission rates, CO2e (https://www.epa.gov/egrid/summary-data), one WebFetch excerpt not cross-checked against the xlsx'
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* eGRID2023 total output CO2e per subregion, lb per MWh (L0). The boundary is stack emissions at the
|
|
245
|
+
* plant: no transmission or distribution losses and no upstream or construction emissions (eGRID
|
|
246
|
+
* Technical Guide, read in full).
|
|
247
|
+
*/
|
|
248
|
+
export const EGRID_LB_PER_MWH = {
|
|
249
|
+
US: egrid(770.884),
|
|
250
|
+
NEWE: egrid(543.178),
|
|
251
|
+
AZNM: egrid(706.189),
|
|
252
|
+
NWPP: egrid(635.267),
|
|
253
|
+
SRVC: egrid(596.326),
|
|
254
|
+
ERCT: egrid(736.629)
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Ember's US carbon intensity of electricity generation, 2025, in gCO2e per kWh (L0). Ember states no
|
|
258
|
+
* boundary. It is printed beside the eGRID figure and never in its place.
|
|
259
|
+
*/
|
|
260
|
+
export const EMBER_US_G_PER_KWH = {
|
|
261
|
+
value: 384,
|
|
262
|
+
unit: 'gCO2e/kWh',
|
|
263
|
+
layer: 'L0',
|
|
264
|
+
source: 'Ember, Global Electricity Review 2026, major countries and regions (https://ember-energy.org/latest-insights/global-electricity-review-2026/major-countries-and-regions), WebFetch excerpt; another Ember page prints the same figure as 2024'
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Litres of water per kWh of data-centre electricity, consumed on site (L2, derived from LBNL 2024:
|
|
268
|
+
* 66 billion L in 2023 over 176 TWh). drupflare's worker docs use the same value.
|
|
269
|
+
*/
|
|
270
|
+
export const WATER_DIRECT = {
|
|
271
|
+
value: 0.375,
|
|
272
|
+
unit: 'L/kWh',
|
|
273
|
+
layer: 'L2',
|
|
274
|
+
source: 'drupflare/worker docs/impact/water.md, from LBNL 2024 (2023 data)'
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Litres of water per kWh of electricity through generation (L2). drupflare's worker docs round
|
|
278
|
+
* LBNL's figure to 4.55.
|
|
279
|
+
*/
|
|
280
|
+
export const WATER_INDIRECT = {
|
|
281
|
+
value: 4.55,
|
|
282
|
+
unit: 'L/kWh',
|
|
283
|
+
layer: 'L2',
|
|
284
|
+
source: 'drupflare/worker docs/impact/water.md, from LBNL 2024 (nearly 800 billion L through generation)'
|
|
285
|
+
};
|
|
286
|
+
/** LBNL 2024's printed indirect water for data centres, 4.52 L/kWh (L0), shown beside `WATER_INDIRECT` */
|
|
287
|
+
export const WATER_INDIRECT_LBNL = {
|
|
288
|
+
value: 4.52,
|
|
289
|
+
unit: 'L/kWh',
|
|
290
|
+
layer: 'L0',
|
|
291
|
+
source: 'LBNL 2024 United States Data Center Energy Usage Report, full text (4.35 for the whole US grid)'
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Median bytes of a first view's home page (L0). The Web Almanac chapter's own figures conflict, from
|
|
295
|
+
* 2.16 to 2.41 MB; the midpoint is used here.
|
|
296
|
+
*/
|
|
297
|
+
export const FIRST_VIEW_BYTES = {
|
|
298
|
+
value: 2_200_000,
|
|
299
|
+
unit: 'B',
|
|
300
|
+
layer: 'L0',
|
|
301
|
+
source: 'Web Almanac 2025, home-page weight median (mobile and desktop)'
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* Median bytes of a whole repeat view, pooled over every repeat-navigation reading (L1).
|
|
305
|
+
* `scripts/impact.ts` refuses to run if the readings give another median.
|
|
306
|
+
*/
|
|
307
|
+
export const REPEAT_VIEW_BYTES = {
|
|
308
|
+
value: 66_343,
|
|
309
|
+
unit: 'B',
|
|
310
|
+
layer: 'L1',
|
|
311
|
+
source: 'measurements/repeat-nav, pooled whole-repeat-view median'
|
|
312
|
+
};
|
|
313
|
+
/** the high case of the ceiling scenario: every cut at its high value (L3) */
|
|
314
|
+
export const GOAL_HIGH_SHARE = {
|
|
315
|
+
value: 0.415,
|
|
316
|
+
unit: 'fraction',
|
|
317
|
+
layer: 'L3',
|
|
318
|
+
source: 'scenario, SPOOL_PLAN "How high can the share go" (2026-11-03): every cut at its high value'
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Proposed goal shares of a site's own page-view footprint (L3). Proposed in the plan on 2026-11-03
|
|
322
|
+
* and not adopted; they are a research target, not a business figure.
|
|
323
|
+
*/
|
|
324
|
+
export const GOAL_SHARES = [0.025, 0.05, 0.1, 0.25];
|
|
325
|
+
/**
|
|
326
|
+
* drupflare's hosting saving per site a year against three deployments (L2, modelled). The
|
|
327
|
+
* production-baseline page of the worker docs prints these three; the peak-sized figure is the
|
|
328
|
+
* headline.
|
|
329
|
+
*/
|
|
330
|
+
export const HOSTING_KWH_PER_SITE = {
|
|
331
|
+
peak: {
|
|
332
|
+
value: 390,
|
|
333
|
+
unit: 'kWh/site/yr',
|
|
334
|
+
layer: 'L2',
|
|
335
|
+
source: 'drupflare/worker docs/impact/energy/production-baseline.md: peak-sized, 3 regions, 12 nodes, 8 vCPU, 10%'
|
|
336
|
+
},
|
|
337
|
+
production: {
|
|
338
|
+
value: 224.2,
|
|
339
|
+
unit: 'kWh/site/yr',
|
|
340
|
+
layer: 'L2',
|
|
341
|
+
source: 'drupflare/worker docs/impact/energy/production-baseline.md: production, 3 regions, 12 nodes, 4 vCPU, 15%'
|
|
342
|
+
},
|
|
343
|
+
floor: {
|
|
344
|
+
value: 9.34,
|
|
345
|
+
unit: 'kWh/site/yr',
|
|
346
|
+
layer: 'L2',
|
|
347
|
+
source: 'drupflare/worker docs/impact/energy/production-baseline.md: worst case, one small VPS, 2 vCPU, 15%'
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
const count = (value, column, term) => ({
|
|
351
|
+
value,
|
|
352
|
+
unit: 'requests',
|
|
353
|
+
layer: 'L1',
|
|
354
|
+
source: `review/model.json, column "${column}", ${term}`
|
|
355
|
+
});
|
|
356
|
+
const review = (value, what) => ({
|
|
357
|
+
value,
|
|
358
|
+
unit: 'requests',
|
|
359
|
+
layer: 'L1',
|
|
360
|
+
source: `review/REVIEW.md section 3, ${what}; Chromium, Firefox and WebKit; measured on 2026-11-18`
|
|
361
|
+
});
|
|
362
|
+
/** the request-law constants of `Q`, each a count from review/model.json or the review's constants table */
|
|
363
|
+
export const DEMAND = {
|
|
364
|
+
bootstrapWorker: count(2, 'min worker, Chromium', 'k'),
|
|
365
|
+
bootstrapNoWorker: count(1, 'min no worker, any engine', 'k'),
|
|
366
|
+
contact: count(1, 'min worker, Chromium', 'x'),
|
|
367
|
+
contactInLease: review(0, '"contact inside the lease", min worker column'),
|
|
368
|
+
write: review(1, '"write" row, min worker column'),
|
|
369
|
+
inPage: review(0, '"in-page view" row, min worker column'),
|
|
370
|
+
coldChromium: count(1, 'min worker, Chromium', 'cold'),
|
|
371
|
+
coldRoute: count(0, 'min worker + route, Chromium', 'cold'),
|
|
372
|
+
coldFirefox: count(0, 'min worker, Firefox', 'cold'),
|
|
373
|
+
coldWebkitMac: count(2, 'min worker, WebKit macOS', 'cold'),
|
|
374
|
+
coldWebkitLinux: count(1, 'min worker, WebKit Linux', 'cold'),
|
|
375
|
+
coldTls: {
|
|
376
|
+
value: 0,
|
|
377
|
+
unit: 'requests',
|
|
378
|
+
layer: 'L1',
|
|
379
|
+
source: 'review/REVIEW.md section 8, six cold restarts per engine against the deployed Worker; Chromium, Firefox and WebKit; measured on 2026-11-18; the count is Worker invocations'
|
|
380
|
+
},
|
|
381
|
+
warmChromium: count(0, 'min worker, Chromium', 'warm'),
|
|
382
|
+
warmFirefox: count(0, 'min worker, Firefox', 'warm'),
|
|
383
|
+
warmWebkitMac: count(1, 'min worker, WebKit macOS', 'warm'),
|
|
384
|
+
warmWebkitLinux: count(0, 'min worker, WebKit Linux', 'warm')
|
|
385
|
+
};
|
|
386
|
+
const retrofit = (value, unit, what) => ({
|
|
387
|
+
value,
|
|
388
|
+
unit,
|
|
389
|
+
layer: 'L1',
|
|
390
|
+
source: `drupflare Worker retrofit reading, ${what}`
|
|
391
|
+
});
|
|
392
|
+
/** counted views of the retrofit reading: one bootstrap, then the in-page and document views below */
|
|
393
|
+
export const RETROFIT_VIEWS = retrofit(121, 'views', 'counted views, warm static assets');
|
|
394
|
+
export const RETROFIT_IN_PAGE = retrofit(100, 'views', 'in-page views');
|
|
395
|
+
export const RETROFIT_DOCUMENTS = retrofit(20, 'views', 'document navigations');
|
|
396
|
+
/** requests that reached the origin over the retrofit views; WebKit includes its script check per navigation */
|
|
397
|
+
export const RETROFIT_ORIGIN = {
|
|
398
|
+
chromium: retrofit(4, 'requests', 'origin requests, Chromium'),
|
|
399
|
+
firefox: retrofit(4, 'requests', 'origin requests, Firefox'),
|
|
400
|
+
webkit: retrofit(23, 'requests', 'origin requests, WebKit')
|
|
401
|
+
};
|
|
402
|
+
/** Worker invocations over the retrofit views, per engine */
|
|
403
|
+
export const RETROFIT_WORKER = {
|
|
404
|
+
chromium: retrofit(4, 'calls', 'Worker invocations, Chromium'),
|
|
405
|
+
firefox: retrofit(4, 'calls', 'Worker invocations, Firefox'),
|
|
406
|
+
webkit: retrofit(6, 'calls', 'Worker invocations, WebKit')
|
|
407
|
+
};
|
|
408
|
+
const session = (value, what) => ({
|
|
409
|
+
value,
|
|
410
|
+
unit: 'views',
|
|
411
|
+
layer: 'L1',
|
|
412
|
+
source: `review/deploy/runs/2026-11-18T09-36-16-583Z/reading.json, ${what}; three engines; measured on 2026-11-18`
|
|
413
|
+
});
|
|
414
|
+
/** the deployed session of section 8: the rig's phases, one Worker invocation each for the first document */
|
|
415
|
+
export const SESSION = {
|
|
416
|
+
views: session(108, 'phases first-document, second-view-bootstrap, 100-held-reads, 5-documents and restart-document'),
|
|
417
|
+
heldReads: session(100, 'phase 100-held-reads'),
|
|
418
|
+
documents: session(5, 'phase 5-documents'),
|
|
419
|
+
restarts: session(1, 'phase restart-document')
|
|
420
|
+
};
|
|
421
|
+
const bench = (value, unit, what) => ({
|
|
422
|
+
value,
|
|
423
|
+
unit,
|
|
424
|
+
layer: 'L1',
|
|
425
|
+
source: `review/storage RESULTS.md, ${what}`
|
|
426
|
+
});
|
|
427
|
+
/** the device layouts at 1,000, 10,000 and 100,000 rows, on the M2 Pro bench */
|
|
428
|
+
export const STORAGE = {
|
|
429
|
+
rowsSmall: bench(1000, 'rows', 'synthetic site, 1,000 rows'),
|
|
430
|
+
rowsLarge: bench(10000, 'rows', 'synthetic site, 10,000 rows'),
|
|
431
|
+
rowsXl: bench(100000, 'rows', 'synthetic site, 100,000 rows, Chromium only'),
|
|
432
|
+
plainRowChromium: bench(794.3, 'B a row', '10k, usage, codex, Chromium'),
|
|
433
|
+
plainRowFirefox: bench(9373.2, 'B a row', '10k, usage, codex, Firefox'),
|
|
434
|
+
plainRowWebkit: bench(1754.5, 'B a row', '10k, usage, codex, WebKit'),
|
|
435
|
+
packedRowChromium: bench(121.2, 'B a row', '10k, usage, packed, Chromium'),
|
|
436
|
+
packedRowFirefox: bench(396.3, 'B a row', '10k, usage, packed, Firefox'),
|
|
437
|
+
packedRowWebkit: bench(115.4, 'B a row', '10k, usage, packed, WebKit'),
|
|
438
|
+
plainItemChromium: bench(61.7, 'ms', '10k, item p50, codex, Chromium'),
|
|
439
|
+
plainItemFirefox: bench(112, 'ms', '10k, item p50, codex, Firefox'),
|
|
440
|
+
plainItemWebkit: bench(65, 'ms', '10k, item p50, codex, WebKit'),
|
|
441
|
+
packedItemChromium: bench(1.7, 'ms', '10k, item p50, packed, Chromium'),
|
|
442
|
+
packedItemFirefox: bench(2, 'ms', '10k, item p50, packed, Firefox'),
|
|
443
|
+
packedItemWebkit: bench(2, 'ms', '10k, item p50, packed, WebKit'),
|
|
444
|
+
plainItemChromium100k: bench(675.3, 'ms', '100k, item p50, codex, Chromium'),
|
|
445
|
+
packedItemChromium100k: bench(2.7, 'ms', '100k, item p50, packed, Chromium'),
|
|
446
|
+
wirePacked: bench(1146591, 'B', '10k, wire, packed gzip blocks'),
|
|
447
|
+
wireBrotli: bench(293408, 'B', '10k, wire, one brotli stream of the plain seed')
|
|
448
|
+
};
|
|
449
|
+
const crawl = (value, unit, what) => ({
|
|
450
|
+
value,
|
|
451
|
+
unit,
|
|
452
|
+
layer: 'L1',
|
|
453
|
+
source: `review/radius RESULTS.md, ${what}`
|
|
454
|
+
});
|
|
455
|
+
/** the 300-page crawls behind the real-page figures; each total is summed over the pages */
|
|
456
|
+
export const CRAWL = {
|
|
457
|
+
pages: crawl(300, 'pages', 'max-pages cap, docs.drupflare.com and MDN Service Worker API'),
|
|
458
|
+
docsText: crawl(326886, 'B', 'solidBrotliBytes text, docs.drupflare.com, one stream'),
|
|
459
|
+
mdnText: crawl(532348, 'B', 'solidBrotliBytes text, MDN, one stream'),
|
|
460
|
+
docsHtml: crawl(505352, 'B', 'solidBrotliBytes html, docs.drupflare.com, one stream'),
|
|
461
|
+
mdnHtml: crawl(991858, 'B', 'solidBrotliBytes html, MDN, one stream'),
|
|
462
|
+
docsHtmlEach: crawl(1027054, 'B', 'brotliBytes per page, summed, docs.drupflare.com'),
|
|
463
|
+
mdnHtmlEach: crawl(5711674, 'B', 'brotliBytes per page, summed, MDN')
|
|
464
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { TimedView } from '../protocol/view.js';
|
|
1
2
|
import type { CapacityPlan } from './capacity.js';
|
|
3
|
+
import { type EgridSubregion, type Input } from './inputs.js';
|
|
2
4
|
/**
|
|
3
5
|
* A server or instance the institution retired because spool made it unneeded. `watts` is the
|
|
4
6
|
* draw of one unit; without it an instance has no energy figure and is listed as unpriced.
|
|
@@ -41,6 +43,38 @@ export type Observed = {
|
|
|
41
43
|
/** metric value with spool, in unit; non-negative */
|
|
42
44
|
after: number;
|
|
43
45
|
};
|
|
46
|
+
/** a campus and the sites its host serves; what the economics and research blocks price */
|
|
47
|
+
export type InstitutionProfile = {
|
|
48
|
+
/** two-letter state code for the electricity price; a state the price table lacks throws */
|
|
49
|
+
state: string;
|
|
50
|
+
/** the eGRID2023 subregion the campus's electricity comes from */
|
|
51
|
+
subregion: EgridSubregion;
|
|
52
|
+
/** sites the host serves for the institution; the hosting saving is per site */
|
|
53
|
+
sites: number;
|
|
54
|
+
/** the institution's page views a year; the basis of the goal ladder */
|
|
55
|
+
viewsPerYear: number;
|
|
56
|
+
/** spool's attributional saving a year across all three boundaries, in MWh, from the caller's views channel */
|
|
57
|
+
attributionalMwh: number;
|
|
58
|
+
};
|
|
59
|
+
/** bytes one dataset holds on the device or on the server */
|
|
60
|
+
export type Holding = {
|
|
61
|
+
/** the dataset's name in the site's manifest */
|
|
62
|
+
dataset: string;
|
|
63
|
+
/** where the bytes sit */
|
|
64
|
+
where: 'device' | 'server';
|
|
65
|
+
/** bytes held; non-negative */
|
|
66
|
+
bytes: number;
|
|
67
|
+
};
|
|
68
|
+
/** the bytes held per dataset against the declared budget for each side */
|
|
69
|
+
export type StorageInputs = {
|
|
70
|
+
/** the declared budget in bytes, for the device and for the server */
|
|
71
|
+
budget: {
|
|
72
|
+
device: number;
|
|
73
|
+
server: number;
|
|
74
|
+
};
|
|
75
|
+
/** what each dataset holds; a side with no holding reads zero */
|
|
76
|
+
holdings: readonly Holding[];
|
|
77
|
+
};
|
|
44
78
|
export type InstitutionInputs = {
|
|
45
79
|
/** the capacity plan behind the potential channel */
|
|
46
80
|
plan?: CapacityPlan;
|
|
@@ -52,10 +86,132 @@ export type InstitutionInputs = {
|
|
|
52
86
|
invoices?: Invoices;
|
|
53
87
|
/** servers and instances the institution retired */
|
|
54
88
|
ledger?: readonly RetirementEntry[];
|
|
89
|
+
/** the campus and its sites, for the economics and research blocks */
|
|
90
|
+
institution?: InstitutionProfile;
|
|
91
|
+
/** bytes held per dataset on the device and the server, for the storage block */
|
|
92
|
+
storage?: StorageInputs;
|
|
93
|
+
/** the views spool recorded, for the trust block; read the worker's own counters from these */
|
|
94
|
+
views?: readonly TimedView[];
|
|
55
95
|
};
|
|
56
96
|
/** an observed change, then the three results of the capacity plan; none is added to another and any can be null or read zero */
|
|
57
97
|
export type InstitutionReport = {
|
|
58
|
-
/**
|
|
98
|
+
/** host-meter energy and its dollars; null without an institution profile */
|
|
99
|
+
economics: {
|
|
100
|
+
/** the state the prices are for */
|
|
101
|
+
state: string;
|
|
102
|
+
/** average industrial price, EIA 2025 */
|
|
103
|
+
industrial: Input;
|
|
104
|
+
/** average commercial price, EIA 2025 */
|
|
105
|
+
commercial: Input;
|
|
106
|
+
/** the hosting saving at each deployment, headline first; priced at both sector rates */
|
|
107
|
+
cases: {
|
|
108
|
+
/** the deployment the saving is against */
|
|
109
|
+
name: 'peak' | 'production' | 'floor';
|
|
110
|
+
/** kWh a site a year */
|
|
111
|
+
kwhPerSite: number;
|
|
112
|
+
/** the host-meter energy a year, in MWh */
|
|
113
|
+
mwh: number;
|
|
114
|
+
/** dollars at the industrial rate */
|
|
115
|
+
usdIndustrial: number;
|
|
116
|
+
/** dollars at the commercial rate */
|
|
117
|
+
usdCommercial: number;
|
|
118
|
+
}[];
|
|
119
|
+
/** the data-centre share of spool's attributional saving; it is already inside the hosting saving, so it is not added */
|
|
120
|
+
dataCentreMwh: number;
|
|
121
|
+
/** spool's attributional share outside the institution's meter: visitors' devices and networks */
|
|
122
|
+
offMeterMwh: number;
|
|
123
|
+
/** L2, derived from the profile and the hosting model */
|
|
124
|
+
layer: 'L2';
|
|
125
|
+
} | null;
|
|
126
|
+
/** bytes held against the declared budget; null without storage inputs */
|
|
127
|
+
storage: {
|
|
128
|
+
/** the declared budget, in bytes */
|
|
129
|
+
budget: {
|
|
130
|
+
device: number;
|
|
131
|
+
server: number;
|
|
132
|
+
};
|
|
133
|
+
/** bytes the holdings sum to, per side */
|
|
134
|
+
held: {
|
|
135
|
+
device: number;
|
|
136
|
+
server: number;
|
|
137
|
+
};
|
|
138
|
+
/** whether each side is within its budget */
|
|
139
|
+
within: {
|
|
140
|
+
device: boolean;
|
|
141
|
+
server: boolean;
|
|
142
|
+
};
|
|
143
|
+
/** the holdings as given */
|
|
144
|
+
holdings: readonly Holding[];
|
|
145
|
+
/** L1, measured here */
|
|
146
|
+
layer: 'L1';
|
|
147
|
+
} | null;
|
|
148
|
+
/** correctness counters from the views; null without views */
|
|
149
|
+
trust: {
|
|
150
|
+
/** views counted */
|
|
151
|
+
views: number;
|
|
152
|
+
/** shadow views the worker compared with the network's answer */
|
|
153
|
+
sampled: number;
|
|
154
|
+
/** sampled views whose local answer differed from the network's */
|
|
155
|
+
mismatches: number;
|
|
156
|
+
/** views the worker declined to answer locally or to render */
|
|
157
|
+
refused: number;
|
|
158
|
+
/** views answered from the network because a stored copy was outdated */
|
|
159
|
+
fallbacks: number;
|
|
160
|
+
/** counters the worker does not keep; read each as unknown, not as zero */
|
|
161
|
+
notCounted: readonly string[];
|
|
162
|
+
/** L1, measured here */
|
|
163
|
+
layer: 'L1';
|
|
164
|
+
} | null;
|
|
165
|
+
/** energy by meter boundary, carbon, water and the goal ladder; null without an institution profile */
|
|
166
|
+
research: {
|
|
167
|
+
/** spool's attributional saving by boundary; only the data-centre part is on a host's meter */
|
|
168
|
+
boundary: {
|
|
169
|
+
devices: {
|
|
170
|
+
mwh: number;
|
|
171
|
+
share: number;
|
|
172
|
+
};
|
|
173
|
+
networks: {
|
|
174
|
+
mwh: number;
|
|
175
|
+
share: number;
|
|
176
|
+
};
|
|
177
|
+
dataCentres: {
|
|
178
|
+
mwh: number;
|
|
179
|
+
share: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/** tonnes CO2e of the whole attributional saving, at the campus subregion and at Ember's national figure */
|
|
183
|
+
carbon: {
|
|
184
|
+
subregion: EgridSubregion;
|
|
185
|
+
gPerKwh: number;
|
|
186
|
+
tonnes: number;
|
|
187
|
+
ember: {
|
|
188
|
+
gPerKwh: number;
|
|
189
|
+
tonnes: number;
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
/** litres for the data-centre share; a locality figure, never summed across institutions */
|
|
193
|
+
water: {
|
|
194
|
+
directLitres: number;
|
|
195
|
+
indirectLitres: number;
|
|
196
|
+
indirectLbnlLitres: number;
|
|
197
|
+
};
|
|
198
|
+
/** the goal ladder: the saving at each share of the institution's own page-view footprint, kWh a year */
|
|
199
|
+
goal: {
|
|
200
|
+
viewsPerYear: number;
|
|
201
|
+
footprintMwh: number;
|
|
202
|
+
rungs: {
|
|
203
|
+
share: number;
|
|
204
|
+
kwh: number;
|
|
205
|
+
}[];
|
|
206
|
+
high: {
|
|
207
|
+
share: number;
|
|
208
|
+
kwh: number;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
/** L2, derived from the profile and the published factors */
|
|
212
|
+
layer: 'L2';
|
|
213
|
+
} | null;
|
|
214
|
+
/** an observed change, read from the caller's measurement */
|
|
59
215
|
observed: (Observed & {
|
|
60
216
|
/** fractional drop from before to after; null when before is zero */
|
|
61
217
|
reduction: number | null;
|
|
@@ -94,4 +250,35 @@ export type InstitutionReport = {
|
|
|
94
250
|
/** sentence stating the physical saving, or that none was shown */
|
|
95
251
|
statement: string;
|
|
96
252
|
};
|
|
253
|
+
/** the page-view footprint of `viewsPerYear` views, in MWh a year, on the attributional basis */
|
|
254
|
+
export declare function footprintMwh(viewsPerYear: number): number;
|
|
255
|
+
/** one institution in a roll-up: its attributional saving and the subregion its electricity comes from */
|
|
256
|
+
export type InstitutionRow = {
|
|
257
|
+
/** a label for the row; the report prints it beside the institution's own litres */
|
|
258
|
+
name: string;
|
|
259
|
+
/** the eGRID2023 subregion the institution's electricity comes from */
|
|
260
|
+
subregion: EgridSubregion;
|
|
261
|
+
/** spool's attributional saving a year across all three boundaries, in MWh */
|
|
262
|
+
attributionalMwh: number;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* A roll-up across institutions. Energy and carbon add up. Water does not add up: it is local, so
|
|
266
|
+
* each institution keeps its own litres and the type has no total.
|
|
267
|
+
*/
|
|
268
|
+
export type Rollup = {
|
|
269
|
+
/** rows summed */
|
|
270
|
+
institutions: number;
|
|
271
|
+
/** attributional MWh a year, summed */
|
|
272
|
+
mwh: number;
|
|
273
|
+
/** tonnes CO2e a year, summed; each row uses its own subregion */
|
|
274
|
+
tonnes: number;
|
|
275
|
+
/** litres for each row's data-centre share, one entry per institution */
|
|
276
|
+
water: {
|
|
277
|
+
name: string;
|
|
278
|
+
directLitres: number;
|
|
279
|
+
indirectLitres: number;
|
|
280
|
+
}[];
|
|
281
|
+
};
|
|
282
|
+
/** sums energy and carbon across institutions and keeps water per institution */
|
|
283
|
+
export declare function rollUpInstitutions(rows: readonly InstitutionRow[]): Rollup;
|
|
97
284
|
export declare function institutionReport(inputs: InstitutionInputs): InstitutionReport;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { egridGPerKwh, electricityPrice, tonnesFromMwh, usdForMwh } from './economics.js';
|
|
2
|
+
import { EMBER_US_G_PER_KWH, FIRST_VIEW_BYTES, FIRST_VIEW_SHARE, GOAL_HIGH_SHARE, GOAL_SHARES, HOSTING_KWH_PER_SITE, REPEAT_VIEW_BYTES, SWD_V4, WATER_DIRECT, WATER_INDIRECT, WATER_INDIRECT_LBNL } from './inputs.js';
|
|
1
3
|
import { serverYearMWh } from './model.js';
|
|
4
|
+
import { mismatchesByRoute } from './traffic.js';
|
|
5
|
+
/** what the worker does not count; the trust block reads each as unknown, not as zero */
|
|
6
|
+
const NOT_COUNTED = ['proof failures', 'reseeds', 'rollbacks'];
|
|
2
7
|
/** the priced part of the ledger, or only the unpriced ids when no entry has an energy figure */
|
|
3
8
|
function physicalFrom(ledger) {
|
|
4
9
|
if (ledger.length === 0)
|
|
@@ -48,15 +53,155 @@ function financialFrom(invoices) {
|
|
|
48
53
|
layer: 'L1'
|
|
49
54
|
};
|
|
50
55
|
}
|
|
56
|
+
const SWD_TOTAL = SWD_V4.network.value + SWD_V4.datacentre.value + SWD_V4.device.value;
|
|
57
|
+
/** the share of spool's attributional saving that is data-centre energy: 0.055 of 0.194 kWh/GB */
|
|
58
|
+
const DATA_CENTRE_SHARE = SWD_V4.datacentre.value / SWD_TOTAL;
|
|
59
|
+
const DEVICE_SHARE = SWD_V4.device.value / SWD_TOTAL;
|
|
60
|
+
const NETWORK_SHARE = SWD_V4.network.value / SWD_TOTAL;
|
|
61
|
+
/** joules per byte at the SWD v4 total: kWh per GB, times J per kWh, over bytes per GB */
|
|
62
|
+
const J_PER_BYTE = (SWD_TOTAL * 3.6e6) / 1e9;
|
|
63
|
+
/** joules an average page view costs on the attributional basis: first views at their share, repeat views the rest */
|
|
64
|
+
function footprintJoulesPerView() {
|
|
65
|
+
const first = FIRST_VIEW_SHARE.central.value;
|
|
66
|
+
return J_PER_BYTE * (first * FIRST_VIEW_BYTES.value + (1 - first) * REPEAT_VIEW_BYTES.value);
|
|
67
|
+
}
|
|
68
|
+
/** the page-view footprint of `viewsPerYear` views, in MWh a year, on the attributional basis */
|
|
69
|
+
export function footprintMwh(viewsPerYear) {
|
|
70
|
+
return (viewsPerYear * footprintJoulesPerView()) / 3.6e9;
|
|
71
|
+
}
|
|
72
|
+
function economicsFrom(profile) {
|
|
73
|
+
if (!profile)
|
|
74
|
+
return null;
|
|
75
|
+
const industrial = electricityPrice(profile.state, 'industrial');
|
|
76
|
+
const commercial = electricityPrice(profile.state, 'commercial');
|
|
77
|
+
const dataCentreMwh = profile.attributionalMwh * DATA_CENTRE_SHARE;
|
|
78
|
+
return {
|
|
79
|
+
state: profile.state,
|
|
80
|
+
industrial,
|
|
81
|
+
commercial,
|
|
82
|
+
cases: [
|
|
83
|
+
['peak', HOSTING_KWH_PER_SITE.peak],
|
|
84
|
+
['production', HOSTING_KWH_PER_SITE.production],
|
|
85
|
+
['floor', HOSTING_KWH_PER_SITE.floor]
|
|
86
|
+
].map(([name, perSite]) => {
|
|
87
|
+
const mwh = (profile.sites * perSite.value) / 1000;
|
|
88
|
+
return {
|
|
89
|
+
name,
|
|
90
|
+
kwhPerSite: perSite.value,
|
|
91
|
+
mwh,
|
|
92
|
+
usdIndustrial: usdForMwh(mwh, industrial.value),
|
|
93
|
+
usdCommercial: usdForMwh(mwh, commercial.value)
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
dataCentreMwh,
|
|
97
|
+
offMeterMwh: profile.attributionalMwh - dataCentreMwh,
|
|
98
|
+
layer: 'L2'
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function storageFrom(inputs) {
|
|
102
|
+
if (!inputs)
|
|
103
|
+
return null;
|
|
104
|
+
for (const h of inputs.holdings) {
|
|
105
|
+
if (!Number.isFinite(h.bytes) || h.bytes < 0) {
|
|
106
|
+
throw new RangeError(`${h.dataset}: bytes must be a non-negative finite number`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const held = { device: 0, server: 0 };
|
|
110
|
+
for (const h of inputs.holdings)
|
|
111
|
+
held[h.where] += h.bytes;
|
|
112
|
+
return {
|
|
113
|
+
budget: inputs.budget,
|
|
114
|
+
held,
|
|
115
|
+
within: {
|
|
116
|
+
device: held.device <= inputs.budget.device,
|
|
117
|
+
server: held.server <= inputs.budget.server
|
|
118
|
+
},
|
|
119
|
+
holdings: inputs.holdings,
|
|
120
|
+
layer: 'L1'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function trustFrom(views) {
|
|
124
|
+
if (!views)
|
|
125
|
+
return null;
|
|
126
|
+
const routes = mismatchesByRoute(views);
|
|
127
|
+
return {
|
|
128
|
+
views: views.length,
|
|
129
|
+
sampled: routes.reduce((n, r) => n + r.compared, 0),
|
|
130
|
+
mismatches: routes.reduce((n, r) => n + r.mismatches, 0),
|
|
131
|
+
refused: views.filter((v) => v.reason === 'refused' || v.reason === 'hard-refused').length,
|
|
132
|
+
fallbacks: views.filter((v) => v.reason === 'invalidated' || v.reason === 'stale-after-sync').length,
|
|
133
|
+
notCounted: NOT_COUNTED,
|
|
134
|
+
layer: 'L1'
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function waterLitres(dataCentreMwh) {
|
|
138
|
+
const kwh = dataCentreMwh * 1000;
|
|
139
|
+
return {
|
|
140
|
+
directLitres: kwh * WATER_DIRECT.value,
|
|
141
|
+
indirectLitres: kwh * WATER_INDIRECT.value,
|
|
142
|
+
indirectLbnlLitres: kwh * WATER_INDIRECT_LBNL.value
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function researchFrom(profile) {
|
|
146
|
+
if (!profile)
|
|
147
|
+
return null;
|
|
148
|
+
const att = profile.attributionalMwh;
|
|
149
|
+
const gPerKwh = egridGPerKwh(profile.subregion);
|
|
150
|
+
const footprint = footprintMwh(profile.viewsPerYear);
|
|
151
|
+
const goal = (share) => ({ share, kwh: footprint * share * 1000 });
|
|
152
|
+
return {
|
|
153
|
+
boundary: {
|
|
154
|
+
devices: { mwh: att * DEVICE_SHARE, share: DEVICE_SHARE },
|
|
155
|
+
networks: { mwh: att * NETWORK_SHARE, share: NETWORK_SHARE },
|
|
156
|
+
dataCentres: { mwh: att * DATA_CENTRE_SHARE, share: DATA_CENTRE_SHARE }
|
|
157
|
+
},
|
|
158
|
+
carbon: {
|
|
159
|
+
subregion: profile.subregion,
|
|
160
|
+
gPerKwh,
|
|
161
|
+
tonnes: tonnesFromMwh(att, gPerKwh),
|
|
162
|
+
ember: {
|
|
163
|
+
gPerKwh: EMBER_US_G_PER_KWH.value,
|
|
164
|
+
tonnes: tonnesFromMwh(att, EMBER_US_G_PER_KWH.value)
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
water: waterLitres(att * DATA_CENTRE_SHARE),
|
|
168
|
+
goal: {
|
|
169
|
+
viewsPerYear: profile.viewsPerYear,
|
|
170
|
+
footprintMwh: footprint,
|
|
171
|
+
rungs: GOAL_SHARES.map(goal),
|
|
172
|
+
high: goal(GOAL_HIGH_SHARE.value)
|
|
173
|
+
},
|
|
174
|
+
layer: 'L2'
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/** sums energy and carbon across institutions and keeps water per institution */
|
|
178
|
+
export function rollUpInstitutions(rows) {
|
|
179
|
+
let mwh = 0;
|
|
180
|
+
let tonnes = 0;
|
|
181
|
+
const water = rows.map((row) => {
|
|
182
|
+
mwh += row.attributionalMwh;
|
|
183
|
+
tonnes += tonnesFromMwh(row.attributionalMwh, egridGPerKwh(row.subregion));
|
|
184
|
+
const { directLitres, indirectLitres } = waterLitres(row.attributionalMwh * DATA_CENTRE_SHARE);
|
|
185
|
+
return { name: row.name, directLitres, indirectLitres };
|
|
186
|
+
});
|
|
187
|
+
return { institutions: rows.length, mwh, tonnes, water };
|
|
188
|
+
}
|
|
51
189
|
export function institutionReport(inputs) {
|
|
52
190
|
const ledger = inputs.ledger ?? [];
|
|
53
191
|
const potential = inputs.plan
|
|
54
192
|
? { plan: inputs.plan, layer: inputs.planLayer ?? 'L3' }
|
|
55
193
|
: null;
|
|
194
|
+
const blocks = {
|
|
195
|
+
economics: economicsFrom(inputs.institution),
|
|
196
|
+
storage: storageFrom(inputs.storage),
|
|
197
|
+
trust: trustFrom(inputs.views),
|
|
198
|
+
research: researchFrom(inputs.institution)
|
|
199
|
+
};
|
|
56
200
|
const found = physicalFrom(ledger);
|
|
57
201
|
if (!found || !('mwh' in found)) {
|
|
58
202
|
const unpriced = found?.unpriced ?? [];
|
|
59
203
|
return {
|
|
204
|
+
...blocks,
|
|
60
205
|
observed: observedFrom(inputs.observed),
|
|
61
206
|
potential,
|
|
62
207
|
financial: financialFrom(inputs.invoices),
|
|
@@ -70,6 +215,7 @@ export function institutionReport(inputs) {
|
|
|
70
215
|
const years = servers === '1' ? 'server-year' : 'server-years';
|
|
71
216
|
const entries = priced === 1 ? 'entry' : 'entries';
|
|
72
217
|
return {
|
|
218
|
+
...blocks,
|
|
73
219
|
observed: observedFrom(inputs.observed),
|
|
74
220
|
potential,
|
|
75
221
|
financial: financialFrom(inputs.invoices),
|