Public: anyone can read this; the crew can change it.
The profit slider's position: one number per forge, and the pure function from position to policy #529
Each forge now stores one profit-slider position (a whole number 0–100), and a pure policyAt(position) turns it into sleep windows, how long a quiet pull keeps its preview, and when cloud takes work. Position 50 gives exactly today's values, and nothing reads the position yet, so landing this changes nothing.
stopped closed without shipping deploy fe12c54
The forge rejected the check because check.run in forge.json was over its 1000-character limit; it is now 793. The command still lists every test file, but by bare name (crew.test.ts rather than test/crew.test.ts).
scripts/shards.ts: a newtestPathfunction reads a bare name as a file intest/and leaves any name with a directory in it as given.scripts/test-shards.tsruns every file name it is given through it, so the shard runner still finds the files.test/shards.test.ts: one test coverstestPath. Another reads the repository's ownforge.jsonthrough the manifest parser the forge uses (parseCheck) and checks that every test file it names exists. That catches both a check over the length limit and a misspelled file name before a push.
Testing: a full run of the check command gave 663 tests across 43 files with 1 failure: "apps that are busy > an app whose child is still working survives the sweep, then sleeps once it is done". It passes when test/apps-busy.test.ts runs on its own, and nothing it touches changed here, so it looks like a timing flake when the shards run together. No test was changed to get a pass.
To try: bun scripts/test-shards.ts shards.test.ts, or run check.run from forge.json directly.
🤖 Generated with Claude Code
Each forge now stores one profit-slider position (a whole number 0–100), and a pure
policyAt(position)turns it into sleep windows, how long a quiet pull keeps its preview, and when cloud takes work. Position 50 gives exactly today's values, and nothing reads the position yet, so landing this changes nothing.Why #520's preview failed, and the fix: the preview's database applied
forge_settingas migration 40. Then the merge withmainrenumbered it to 41, behind fleet operations' 40. On the next boot, 40 was skipped as already applied, so the database never got the fleet-operation tables, and 41 stopped withSQLiteError: table forge_setting already exists. Migration 41 now createsfleet_operation, its index,fleet_operation_rowandforge_settingonly if they are missing, the same way migration 37 handlesshare. On a normal database it does nothing extra; on that preview's database it adds what was missing. A new test intest/slider.test.tsbuilds a database the way the preview's was (1–39, thenforge_settingas 40), saves a position, and boots it with today's migrations. It checks that all the tables exist and the saved row survives.What the branch adds:
src/core/slider.ts:policyAtinterpolates in a straight line between the 0 / 50 / 100 rows ofdocs/PROFIT.md. On the way to 100, "never" counts as 7 days, so 99 still sleeps and only 100 returnsnull. The same file hasparsePositionandparseMarginPct(whole numbers only) andpolicyWords, which describes the policy in words.SLEEP_AFTER_MSandIDLE_PULL_DAYS = 3are exported fromsrc/apps/runtime.ts, with values unchanged. A test checks that position 50 matches them.src/core/economics.tsreads and writes theforge_settingkey/value table. An empty table means position 50 and margin 0, and a row edited into nonsense reads as the default.src/actions/economics.tslets only a forge admin read or set the numbers; anyone else getsnot_found. Each change records aforge.economics_updatedevent with the values before and after./settings/economics): a server-rendered page with the slider, the margin and the policy in words, saved by a same-origin POST. It has its own module like the other forge-wide admin pages, notsettings.ts, which holds per-repository settings.GETandPUT /api/v1/forge/economics, with the same validation. An invalid value refuses the whole change with a 422.Not done:
docs/PROFIT.mdarrives with #513.Check: the full
forge.jsoncheck ran: tsc was clean and 660 of 661 tests passed. The one failure wasapps that are busy > an app whose child is still working survives the sweep…, in a file this pull doesn't touch; run alone, it passed 3 of 3.To try it: sign in as the admin, open Settings → Economics, move the slider and save. Or:
curl -X PUT -H "authorization: Bearer $TOKEN" -d '{"position":75}' $URL/api/v1/forge/economics.🤖 Generated with Claude Code
Closes #504
Closes #504