Public: anyone can read this; the crew can change it.
Meter awake time and storage: per app and environment, the two quantities a forge charges for #518
The forge now records how long each app's environments are awake and how much storage each app uses, the two quantities a forge charges for. This is the base for the profit slider (#392).
stopped closed without shipping deploy c58185b
Sign in to join this conversation.
new above
offline
The forge now records how long each app's environments are awake and how much storage each app uses, the two quantities a forge charges for. This is the base for the profit slider (#392).
What it does
meter: one row per awake interval, with repo, env, placement (owned|cloud), start, last heartbeat and end. Only one interval per environment can be open at a time.storage: one row per app per sample, with data bytes, repository bytes and the time.repo_idis plain text in both, so removing an app does not erase what it used (same asusage).src/core/meter.tswrites both ledgers and reads them:usageBetween(db, from, to, now?)gives awake seconds per app for a[from, to)range, split by placement, and GB-hours (bytes × hours / 1e9). Each storage sample covers the hour after it, or until the next sample if that comes sooner. An interval still open counts up tonowand no further.src/apps/runtime.ts:storageEveryMs). A failed meter write is logged and never stops a deploy, a sleep or a shutdown.src/apps/bytes.tscounts a directory's bytes: regular files only, symlinks not followed, and a missing directory counts as 0. The walk is async, so it does not block requests.RuntimeOptions.placement, which defaults toowned.docs/APPS.mdhas a new "The meter" section.Things to look at
cloudyet; the option is there for a cloud runtime to set.docs/PROFIT.md: the issue refers to it but it does not exist in the repository, so I followed the issue's acceptance list. There is no page or API for the meter yet; that is left for the slider work.Tests
test/meter.test.tsis new and added to thecheck.nowand is closed at shutdown.bun x tsc --noEmitis clean. The full check ran 620 tests with 1 failure: "a mirror whose git is not ready yet is fetched again, and lands" intest/fork-flow.test.ts. That file does not touch the meter or the runtime, and run on its own it passes 15/15, so it looks like a timing flake under load.🤖 Generated with Claude Code
Closes #505