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 #520
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 7b0c7ff
Sign in to join this conversation.
new above
offline
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.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 hasparsePosition/parseMarginPct(whole numbers only) andpolicyWords. At 50 it reads: "production sleeps after 24 h idle · previews after 30 min · cloud takes work above 85% of owned capacity · a quiet pull's preview stops after 3 days".SLEEP_AFTER_MSand a newIDLE_PULL_DAYS = 3are now exported fromsrc/apps/runtime.ts, andsrc/main.tsuses that constant. The values haven't changed; a test checks that position 50 matches them.forge_settingkey/value table, read and written bysrc/core/economics.ts. An empty table means position 50 and margin 0. Reads go back through the same parsers, so 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.forge.*events are now admin-only inevent_audience.ts./settings/economics, admins only): a range input, a margin field and the policy in words, posted to the same origin. A table shows what positions 0 / 25 / 50 / 75 / 100 mean, so you can choose before saving without any JavaScript.GETandPUT /api/v1/forge/economics.PUTtakespositionand/ormarginPct; a field you leave out keeps its value, and any invalid value refuses the whole change with a 422.What to look at:
src/web/pages/economics.ts, notsettings.tsas the issue says.settings.tsholds per-repository settings; forge-wide admin pages each have their own module, likesecrets.tsandcloud.ts.docs/PROFIT.mdisn't in this branch. It arrives with #513, which this follows.test/slider.test.tsis new and added to theforge.jsoncheck. It covers the three anchors, 25 and 75 worked out by hand, 99, 50 against the runtime constants, refusal of out-of-range, fractional and non-numeric positions, admin-only access, the same-origin rule, and the event. The full check ran tsc cleanly and 630 of 632 tests passed. The two failures are in code this pull doesn't touch:checks > when a slot frees…passes when run alone.fork-flow > a mirror whose git is not ready yet…failed once more alone, then passed 3 of 3 on this branch and passed onmain. #513 already noted it as flaky under load.To try it: sign in as the admin, open Settings → Economics, move the slider and save. Or run
curl -X PUT -H "authorization: Bearer $TOKEN" -d '{"position":75}' $URL/api/v1/forge/economics.🤖 Generated with Claude Code
Closes #504