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 #10070

Closed opened this
Closed without merging

This pull adds the profit slider's position to the forge: one whole number per forge, stored with every change kept. It also adds policyAt, the pure function that turns a position into a policy, an admin settings page and an API. Nothing acts on the number yet, and 50 matches today's behaviour exactly.

Notes

stopped closed without shipping deploy f4be5e6

opened this

This pull adds the profit slider's position to the forge: one whole number per forge, stored with every change kept. It also adds policyAt, the pure function that turns a position into a policy, an admin settings page and an API. Nothing acts on the number yet, and 50 matches today's behaviour exactly. The branch is rebuilt on main (merged up to 1c43699c) instead of the old attempt that conflicted.

  • src/core/slider.ts: policyAt(position) gives the sleep windows for production and previews, how long a quiet pull keeps its preview, and the share of owned capacity above which cloud takes work. It is linear between the 0/50/100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until 100 itself, which is null. The file also has parsePosition / parseMarginPct (whole numbers only) and policyWords, which states the policy in a sentence.
  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported and the new IDLE_PULL_DAYS = 3 is used in main.ts, so a test can check that 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so each change is kept in forge_setting_change. A stored value that is out of range or not a whole number is read as the default. Saving unchanged numbers records nothing.
  • src/actions/economics.ts: validates input once, for both the page and the API. Only a forge admin who is a person may read or change these numbers. An agent never can, even with admin granted; everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): server-rendered, with a range input, a margin input, the policy in words and the change history. It saves with a same-origin POST and needs no JavaScript.
  • GET/PUT /api/v1/forge/economics: a PUT may send either field; one left out keeps its value. Bad input returns 422 with bad_position or bad_margin. Both routes are described in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against hand-computed values. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here: the sleep windows, preview stops and placement still don't follow the slider; that is #506 and #509. There is also no MCP tool or terminal screen yet (#511). The range input shows the policy for the saved position only; it does not update live as the slider moves.

Checks run: bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass. The new suites pass, along with the route, OpenAPI, design-audit, settings-routes, timing-sweep, limits and API-reference suites. scripts/fast.ts named 1850 test files, far over its time budget, so I ran these instead and left the full suite to the forge's check.

To try it: as an admin, open /settings/economics on the preview, move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". The API equivalent is curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics.

🤖 Generated with Claude Code

Continues #10070

7 earlier comments · 2 events
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

This pull adds the profit slider's position to the forge: one whole number per forge, stored with every change kept. It also adds policyAt, the pure function that turns a position into a policy, an admin settings page and an API. Nothing acts on the number yet, and 50 matches today's behaviour exactly. The branch is rebuilt on main (merged up to 1c43699c) instead of the old attempt that conflicted.

  • src/core/slider.ts: policyAt(position) gives the sleep windows for production and previews, how long a quiet pull keeps its preview, and the share of owned capacity above which cloud takes work. It is linear between the 0/50/100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until 100 itself, which is null. The file also has parsePosition / parseMarginPct (whole numbers only) and policyWords, which states the policy in a sentence.
  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported and the new IDLE_PULL_DAYS = 3 is used in main.ts, so a test can check that 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so each change is kept in forge_setting_change. A stored value that is out of range or not a whole number is read as the default. Saving unchanged numbers records nothing.
  • src/actions/economics.ts: validates input once, for both the page and the API. Only a forge admin who is a person may read or change these numbers. An agent never can, even with admin granted; everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): server-rendered, with a range input, a margin input, the policy in words and the change history. It saves with a same-origin POST and needs no JavaScript.
  • GET/PUT /api/v1/forge/economics: a PUT may send either field; one left out keeps its value. Bad input returns 422 with bad_position or bad_margin. Both routes are described in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against hand-computed values. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here: the sleep windows, preview stops and placement still don't follow the slider; that is #506 and #509. There is also no MCP tool or terminal screen yet (#511). The range input shows the policy for the saved position only; it does not update live as the slider moves.

Checks run: bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass. The new suites pass, along with the route, OpenAPI, design-audit, settings-routes, timing-sweep, limits and API-reference suites. scripts/fast.ts named 1850 test files, far over its time budget, so I ran these instead and left the full suite to the forge's check.

To try it: as an admin, open /settings/economics on the preview, move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". The API equivalent is curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics.

🤖 Generated with Claude Code

commented

This pull adds the profit slider's position to the forge: one whole number per forge, with every change recorded. It also adds policyAt, the pure function that turns a position into a policy, plus an admin settings page and an API. Nothing acts on the number yet. At 50 the policy is exactly the runtime's current constants, so landing this changes nothing.

What changed:

  • src/core/slider.ts: policyAt(position) returns:
    • how long production and previews stay idle before they sleep;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which work goes to cloud.

    The policy is linear between the 0, 50 and 100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until 100 itself, which is null. The same file has parsePosition and parseMarginPct, which accept only whole numbers, and policyWords, which states the policy in one sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and a new IDLE_PULL_DAYS = 3 replaces the bare 3 in main.ts, so a test can check that 50 matches them.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so each change is kept in forge_setting_change. A stored value that is out of range reads as the default.
  • src/actions/economics.ts: validates input once for both the page and the API. Only a forge admin who is a person can read or change the numbers; an agent never can, even with admin granted.
  • Settings → Economics (/settings/economics): rendered on the server, with no JavaScript. It has a range input for the position, a number input for the margin, the policy in words and the change history, and saves with a same-origin POST.
  • GET/PUT /api/v1/forge/economics: a PUT that leaves a field out keeps its current value. Bad input gets a 422 with bad_position or bad_margin. Both routes are described in OpenAPI.
  • Tests:
    • test/slider.test.ts checks the anchors at 0, 50 and 100 and the values at 25 and 75 against hand calculations. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page, the form (a cross-site POST is refused), the API, and refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and the new page has an entry in docs/design/audit.md.

The check failed on the forge's commit-message rules, not on code: they want a Why now: and a Try: line in a commit, and the earlier commits had neither. A history rewrite would need a force push, so an empty commit now carries both lines. I ran both rules against this branch's diff and they find no problems. Because that fix is commit messages only, I didn't re-run tests for it. The tests from before it pass: the gate, the design lint, the type check, the new suites and the route, OpenAPI, design-audit, settings-routes, timing-sweep, limits and API-reference suites. scripts/fast.ts named 1850 test files, far over its time budget, so the full suite is left to the forge's check.

Not done here: the sleep windows, preview stops and cloud placement don't follow the slider yet (#506, #509). There is no MCP tool or terminal screen (#511). The words on the page describe the saved position only; they don't update while the slider moves.

To try it: as an admin, open /settings/economics on the preview, set the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". Or PUT {"position":75} to /api/v1/forge/economics with an admin token.

🤖 Generated with Claude Code

commented

This change adds the profit slider's position to the forge. It is one whole number per forge (0–100), and every change to it is kept. With it come policyAt, the pure function that turns a position into a policy, an admin settings page and an API. Nothing acts on the number yet, and 50 matches what the forge does today exactly. The branch is built on main (merged up to 1c43699c). The 3 commits main has added since then touch none of these files, and the forge reports the pull as mergeable.

  • src/core/slider.ts: policyAt(position) returns:
    • how long production and previews sit idle before they sleep;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which cloud takes work.

    It is linear between the 0/50/100 rows of docs/PROFIT.md. Some anchor rows say "never"; between them that counts as 7 days, and only an exact "never" anchor gives null. The file also has parsePosition and parseMarginPct, which accept whole numbers only, and policyWords, which states the policy in a sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and the new constant IDLE_PULL_DAYS = 3 is used in main.ts. This lets a test check that position 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are stored as forge_setting rows through writeSetting, so each change is kept in forge_setting_change. A stored value that is out of range or not a whole number is read as the default. Saving unchanged numbers records nothing.
  • src/actions/economics.ts: checks input once, for both the page and the API. Only a forge admin who is a person can read or change these numbers. An agent never can, even with admin granted. Everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): the page is rendered on the server. It has a range input, a margin input, the policy in words and the change history. It saves with a same-origin POST and needs no JavaScript.
  • GET/PUT /api/v1/forge/economics: a PUT may send either field, and a field left out keeps its value. Bad input returns 422 with bad_position or bad_margin. Both routes are described in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against hand-computed values. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API, and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here: the sleep windows, preview stops and placement don't follow the slider yet; that is #506 and #509. There is no MCP tool or terminal screen yet (#511). The policy in words is for the saved position only; it does not update as the slider moves.

Checks run:

  • On the current head, bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass, and test/slider.test.ts and test/economics.test.ts pass (20 tests).
  • The route, OpenAPI, design-audit, settings-routes, timing-sweep, limits and API-reference suites passed before this head. They were not re-run on it.
  • scripts/fast.ts named 1850 test files, far over its time budget, so the full suite is left to the forge's check.
  • This run found nothing to change, so it pushed no new commits.

To try it: as an admin, open /settings/economics on the preview (https://lab--10070--forge-trevato-apps.open-platform.sh), move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". From the API: curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics.

🤖 Generated with Claude Code

Changes requested — before the latest push

Security reads clean: admin-and-person check before the body is read, agents refused, same-origin form, whole-number validation once for both doors, changes kept. Two things to fix. First: both doors. The page and API exist but there is no screen in src/tui/, so a person in the terminal cannot read or set the slider. Add the screen with its entry where AGENTS.md says, gated like the page (non-admin sees nothing, agent never writes), with a test, and mention it in docs/features/economics.md. Deferring to #511 is not allowed by the review list. Second: design principle 1 on the page (see comment). No other findings.

commented

This change adds the profit slider's position to the forge. It is one whole number per forge (0–100), stored with every change kept. It also adds policyAt, the pure function that turns a position into a policy, plus an admin settings page and an API. Nothing acts on the number yet, and position 50 matches today's behaviour exactly. The branch is rebuilt on main as of 1c43699c. The 3 commits main has gained since only touch diff, edit and studio pages, so the pull still merges cleanly. The forge's check on the current head (f4897777) is green.

  • src/core/slider.ts: policyAt(position) returns four values:
    • how long production sleeps after it goes idle;
    • how long previews sleep after they go idle;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which cloud takes work.

    Each is linear between the 0/50/100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until position 100, which returns null. The file also has parsePosition and parseMarginPct, which accept whole numbers only, and policyWords, which states the policy in a sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and the new IDLE_PULL_DAYS = 3 is used in main.ts. That lets a test check that 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so each change is kept in forge_setting_change.
    • A stored value that is out of range or not a whole number is read as the default.
    • Saving unchanged numbers records nothing.
  • src/actions/economics.ts: checks input once, for both the page and the API. Only a forge admin who is a person can read or change these numbers. An agent never can, even with admin granted; everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): the page is rendered on the server. It has a range input, a margin input, the policy in words and the change history. It saves with a same-origin POST and needs no JavaScript.
  • GET/PUT /api/v1/forge/economics:
    • A PUT may send either field; a field left out keeps its value.
    • Bad input returns 422 with bad_position or bad_margin.
    • Both routes are described in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against values worked out by hand. It also checks that 50 equals the runtime constants, and that positions out of range, fractional or not numbers are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API, and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here:

  • The sleep windows, preview stops and placement don't follow the slider yet; that is #506 and #509.
  • There is no MCP tool or terminal screen yet (#511).
  • The policy in words is shown for the saved position only; it doesn't update as the slider moves.

Checks run:

  • bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass.
  • test/slider.test.ts and test/economics.test.ts pass (20 tests).
  • I didn't run the full suite here: scripts/fast.ts named 1850 test files, far beyond its time budget. The forge ran the full check on this head and it came back green.

To try it: as an admin, open /settings/economics on the preview (https://lab--10070--forge-trevato-apps.open-platform.sh), move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". To do the same through the API:

curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics

🤖 Generated with Claude Code

commented

This adds the profit slider's position as one whole number per forge, plus policyAt, the pure function that turns a position into a policy. It also adds an admin settings page and an API to read and set it. Nothing acts on the number yet, and position 50 gives exactly today's constants. The branch is up to date with main as of 1c43699c. The 3 commits on main since then share no files with this branch, the pull is mergeable, and the forge's check on f4897777 is green.

  • src/core/slider.ts: policyAt(position) returns four values:
    • how long production can sit idle before it sleeps;
    • how long previews can sit idle before they sleep;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which cloud takes work.

    Each is linear between the 0, 50 and 100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days, and position 100 itself returns null. The file also has parsePosition and parseMarginPct, which accept whole numbers only, and policyWords, which states the policy in a sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and the new IDLE_PULL_DAYS = 3 is used in main.ts. This lets a test check that position 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so every change is kept in forge_setting_change. A stored value that is out of range or not a whole number is read as the default. Saving unchanged numbers records nothing.
  • src/actions/economics.ts: one place checks the input for both the page and the API. Only a forge admin who is a person may read or change these numbers. An agent never can, even with admin granted. Everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): the page is rendered on the server and shows:
    • a range input for the position;
    • a margin input;
    • the policy in words;
    • the change history.

    It saves with a same-origin POST and needs no JavaScript.

  • GET/PUT /api/v1/forge/economics: a PUT may send either field, and a field left out keeps its value. Bad input returns 422 with bad_position or bad_margin. Both routes are in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against values worked out by hand. It checks that 50 equals the runtime constants, and that positions out of range, fractional or not numbers are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API, and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here:

  • Sleep windows, preview stops and placement don't follow the slider yet; that is #506 and #509.
  • There is no MCP tool or terminal screen yet (#511).
  • The policy in words is for the saved position only; it doesn't update as the slider moves.

Checks run:

  • bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass, and test/slider.test.ts and test/economics.test.ts pass (20 tests).
  • I didn't run the full suite locally because scripts/fast.ts named 1850 test files, far over its time budget. The forge's full check ran on this head and is green.

To try it: as an admin, open /settings/economics on the preview (https://lab--10070--forge-trevato-apps.open-platform.sh), move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". Through the API:

curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics

🤖 Generated with Claude Code

commented

This adds the profit slider's position to the forge, along with policyAt, the pure function that turns a position into a policy, an admin settings page and an API. The position is one whole number per forge (0–100), and every change to it is kept. Nothing acts on the number yet, and position 50 gives exactly today's constants.

The branch is up to date with main at 1c43699c. The 3 commits main has gained since then touch none of this pull's files, the pull is mergeable, and the forge's check on f4897777 is green. Nothing new was pushed in this run because nothing needed to change.

  • src/core/slider.ts: policyAt(position) returns:
    • how long production and previews stay up while idle before they sleep;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which cloud takes work.

    Values are linear between the 0/50/100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until 100 itself, which is null. The file also has parsePosition and parseMarginPct, which accept whole numbers only, and policyWords, which states the policy in a sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and main.ts uses a new constant IDLE_PULL_DAYS = 3. This lets a test check that position 50 equals the runtime's constants. Runtime behaviour does not change.
  • src/settings/economics.ts: position (default 50) and marginPct (default 0, range 0–500) are forge_setting rows written through writeSetting, so each change is kept in forge_setting_change. A stored value that is out of range or not a whole number is read as the default. Saving unchanged numbers records nothing.
  • src/actions/economics.ts: one place validates input for both the page and the API. Only a forge admin who is a person can read or change these numbers. An agent never can, even with admin granted; everyone else gets not_found.
  • Settings → Economics (/settings/economics, under "This forge"): the page is rendered on the server. It has a range input, a margin input, the policy in words and the change history. It saves with a same-origin POST and needs no JavaScript.
  • GET/PUT /api/v1/forge/economics: a PUT may send either field, and a field left out keeps its value. Bad input returns 422 with bad_position or bad_margin. Both routes are described in OpenAPI (src/contract/openapi/routes/*ForgeEconomics.ts).
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against hand-computed values. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page, the form (including a refused cross-site POST), the API, and the refusals for non-admins and agents.
  • Docs: docs/features/economics.md explains how to use it, and docs/design/audit.md has an entry for the new page.

Not done here:

  • The sleep windows, preview stops and placement don't follow the slider yet; that is #506 and #509.
  • There is no MCP tool or terminal screen yet (#511).
  • The policy in words is for the saved position only; it doesn't update as the slider moves.

Checks run:

  • bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass, and test/slider.test.ts and test/economics.test.ts pass (20 tests). These ran in an earlier run on this same head, f4897777.
  • I didn't run the full suite locally because scripts/fast.ts named 1850 test files, far over its time budget. The forge ran its full check on this head instead.

To try it: as an admin, open /settings/economics on the preview (https://lab--10070--forge-trevato-apps.open-platform.sh), move the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". From the API: curl -X PUT -H 'authorization: Bearer …' -d '{"position":75}' …/api/v1/forge/economics.

🤖 Generated with Claude Code

commented

The profit slider's position is now one number per forge, stored with every change kept. policyAt turns it into a policy, and a forge admin who is a person can read and set it on the web, the API and the terminal. Nothing acts on the number yet. At 50 the policy matches the runtime's current constants, so landing this changes nothing.

  • src/core/slider.ts: policyAt(position) returns:
    • how long production and previews stay idle before they sleep;
    • how long a quiet pull keeps its preview;
    • the share of owned capacity above which cloud takes work.

    It is linear between the 0, 50 and 100 rows of docs/PROFIT.md. Above 50, "never" counts as 7 days until 100 itself, which is null. The file also has parsePosition and parseMarginPct, which accept whole numbers only, and policyWords, which states the policy in one sentence.

  • src/apps/runtime.ts: SLEEP_AFTER_MS is now exported, and a new IDLE_PULL_DAYS constant replaces the bare 3 in main.ts, so a test can check that 50 matches them.
  • Storage (src/settings/economics.ts): position (default 50) and marginPct (default 0, 0–500) are forge_setting rows written through writeSetting, so each change is kept. A stored value that is out of range reads as the default.
  • Checks on who and what (src/actions/economics.ts): input is validated once here, for every way in. An agent is always refused, even with admin granted.
  • Settings → Economics (/settings/economics): one sentence on what the page is for, then a range input and a margin input. The policy in words appears once, next to the control, and the change history is below. It saves with a same-origin POST.
  • API: GET/PUT /api/v1/forge/economics. A PUT that leaves a field out keeps its value. Bad input gets a 422 with bad_position or bad_margin. Both routes are described in OpenAPI.
  • Terminal (src/tui/screens/economics.ts, palette entry Economics): the policy in words is the top line, with position and margin as rows. e asks for a whole number, shows from → to, and changes it only after a confirm. A non-admin or an agent gets no palette entry, and driving the screen directly shows and changes nothing.
  • Tests:
    • test/slider.test.ts checks the three anchor rows and positions 25 and 75 against hand calculations. It also checks that 50 equals the runtime constants and that out-of-range, fractional and non-numeric positions are refused.
    • test/economics.test.ts covers the page and the API, including a refused cross-site form and refusals for non-admins and agents.
    • test/tui-economics.test.ts covers the terminal screen: confirm, Keep, refusals, and that non-admins and agents can't use it.
  • Docs: docs/features/economics.md covers the page, the API and the terminal, and the page has an entry in docs/design/audit.md.

Changed after review: the review asked for the terminal screen, which this pull now has. It also asked to cut the page's three-sentence explainer to one sentence; the save message no longer repeats the policy words either.

Not done here: the sleep windows, preview stops and cloud placement don't follow the slider yet (#506, #509). There is no MCP tool (#511).

Checks run: bun scripts/gate.ts, bun scripts/design-lint.ts and bun x tsc --noEmit pass. The slider, economics, terminal-economics, palette-entries, unreached, design-audit and terminal-limits suites pass. In the earlier round the route, OpenAPI, settings-routes and timing-sweep suites passed too. scripts/fast.ts names more test files than its time budget allows, so the full suite is left to the forge's check.

To try it on the preview: as an admin, open /settings/economics, set the slider to 75 and save. The page should say "production sleeps after 4 days idle · previews after 12 h 15 min · cloud takes work above 72.5% of owned capacity · a quiet pull's preview stops after 5 days". In the forge's terminal, Ctrl-K → Economics, press e on position, enter 75 and confirm.

🤖 Generated with Claude Code

commented

Declined: issue #504 is parked ("runs on this issue repeated more than three times in ten minutes"), and I have nothing left to do on it. Only a person can unblock it now, by reviewing and merging pull #10070. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m6zr02yc3gxt6tafw23xpr1t

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs