Public: anyone can read this; the crew can change it.

Sleep windows follow the slider: the runtime reads its idle windows from the position, live #10181

Parked opened this
Closed without merging

Moving the profit slider now changes when apps go to sleep, starting with the next sweep (once a minute) and with no restart. app.alwayson: true in an app's forge.json keeps its production awake at any slider position.

Notes

stopped parked by the crew deploy 8ff01c2

opened this

Moving the profit slider now changes when apps go to sleep, starting with the next sweep (once a minute) and with no restart. app.always_on: true in an app's forge.json keeps its production awake at any slider position.

  • Sweep (src/apps/runtime.ts): every pass reads the slider position and picks each environment's idle window from it, using the new src/apps/sleep_window.ts. Previews of quiet pulls also follow the slider: 1 day at 0, 3 at 50, never at 100. Setting FORGE_PREVIEW_IDLE_DAYS still fixes that age, as before (src/main.ts). At the default position of 50, nothing changes.
  • Fixed override: the runtime's sleepAfterMs option, when set, still fixes the window (tests use it); the forge itself never sets it. A new clock option lets a test move the sweep's time forward, so a 10-minute window takes milliseconds to test.
  • Log line: it now names the window and the slider position: asleep: nothing asked for it in 10 min (economy 0); the next request wakes it. The issue's example said "10 minutes"; this uses the slider's own short form, "10 min". The line for apps kept awake while busy (apps/busy.ts) is unchanged.
  • always_on: the issue says app.yaml, but apps here declare themselves in forge.json, so the field is app.always_on. Only true or false is accepted; anything else fails the deploy with a reason. It applies to production only; previews still follow the slider. When it is set, the app page shows "always on: its forge.json sets app.always_on, so it never sleeps whatever the profit slider says".
  • Docs: docs/APPS.md covers the slider-driven windows, always_on and the new FORGE_PREVIEW_IDLE_DAYS default.

Not done: production's line saying how long until it sleeps under the current position. Only the always_on exception is shown on the app page.

Tests

  • test/apps-sleep-slider.test.ts runs a real app. At position 100, an app idle for 11 minutes stays up; moved to 0, the next sweep puts it to sleep and the log has the new line. After a push that sets always_on, it stays up at 0 and its status says so.
  • test/sleep-window.test.ts covers the windows at 0, 50 and 100, always_on beating 0, the log wording, forge.json checking the field, and the app-page line.
  • Both pass, as do the existing sleep, busy, idle, slider, economics, meter, running-quota, adversarial-apps and live-pages tests. The gate, tsc --noEmit and design-lint are clean.
  • scripts/fast.ts named 1,902 test files for this change, too many to run here, so I picked the ones that cover it.
  • No existing test was changed.

The keep_plan tool was not available in this session, so the issue has no plan posted.

To try it: set the slider to 0 on the economics page and leave an app's production alone for 10 minutes. It goes to sleep and its deploy log names the window. Add "always_on": true under app in its forge.json, push, and it stays up.

🤖 Generated with Claude Code

Closes #506

3 earlier comments
commented

Moving the profit slider now changes when apps go to sleep, starting with the next sweep (once a minute) and with no restart. app.always_on: true in an app's forge.json keeps its production awake at any slider position.

  • Sweep (src/apps/runtime.ts): every pass reads the slider position and picks each environment's idle window from it, using the new src/apps/sleep_window.ts. Previews of quiet pulls also follow the slider: 1 day at 0, 3 at 50, never at 100. Setting FORGE_PREVIEW_IDLE_DAYS still fixes that age, as before (src/main.ts). At the default position of 50, nothing changes.
  • Fixed override: the runtime's sleepAfterMs option, when set, still fixes the window (tests use it); the forge itself never sets it. A new clock option lets a test move the sweep's time forward, so a 10-minute window takes milliseconds to test.
  • Log line: it now names the window and the slider position: asleep: nothing asked for it in 10 min (economy 0); the next request wakes it. The issue's example said "10 minutes"; this uses the slider's own short form, "10 min". The line for apps kept awake while busy (apps/busy.ts) is unchanged.
  • always_on: the issue says app.yaml, but apps here declare themselves in forge.json, so the field is app.always_on. Only true or false is accepted; anything else fails the deploy with a reason. It applies to production only; previews still follow the slider. When it is set, the app page shows "always on: its forge.json sets app.always_on, so it never sleeps whatever the profit slider says".
  • Docs: docs/APPS.md covers the slider-driven windows, always_on and the new FORGE_PREVIEW_IDLE_DAYS default.

Not done: production's line saying how long until it sleeps under the current position. Only the always_on exception is shown on the app page.

Tests

  • test/apps-sleep-slider.test.ts runs a real app. At position 100, an app idle for 11 minutes stays up; moved to 0, the next sweep puts it to sleep and the log has the new line. After a push that sets always_on, it stays up at 0 and its status says so.
  • test/sleep-window.test.ts covers the windows at 0, 50 and 100, always_on beating 0, the log wording, forge.json checking the field, and the app-page line.
  • Both pass, as do the existing sleep, busy, idle, slider, economics, meter, running-quota, adversarial-apps and live-pages tests. The gate, tsc --noEmit and design-lint are clean.
  • scripts/fast.ts named 1,902 test files for this change, too many to run here, so I picked the ones that cover it.
  • No existing test was changed.

The keep_plan tool was not available in this session, so the issue has no plan posted.

To try it: set the slider to 0 on the economics page and leave an app's production alone for 10 minutes. It goes to sleep and its deploy log names the window. Add "always_on": true under app in its forge.json, push, and it stays up.

🤖 Generated with Claude Code

commented

Moving the profit slider now changes when apps go to sleep, starting with the next sweep (once a minute) and with no restart. app.always_on: true in an app's forge.json keeps its production awake at any slider position.

  • Sweep (src/apps/runtime.ts): every pass reads the slider position and picks each environment's idle window from it, using the new src/apps/sleep_window.ts. Previews of quiet pulls also follow the slider: 1 day at 0, 3 at 50, never at 100. Setting FORGE_PREVIEW_IDLE_DAYS still fixes that age, as before (src/main.ts). At the default position of 50, nothing changes.
  • Fixed override: the runtime's sleepAfterMs option, when set, still fixes the window (tests use it); the forge itself never sets it. A new clock option lets a test move the sweep's time forward, so a 10-minute window takes milliseconds to test.
  • Log line: it now names the window and the slider position: asleep: nothing asked for it in 10 min (economy 0); the next request wakes it. The issue's example said "10 minutes"; this uses the slider's own short form, "10 min". The line for apps kept awake while busy (apps/busy.ts) is unchanged.
  • always_on: the issue says app.yaml, but apps here declare themselves in forge.json, so the field is app.always_on. Only true or false is accepted; anything else fails the deploy with a reason. It applies to production only; previews still follow the slider. When it is set, the app page shows "always on: its forge.json sets app.always_on, so it never sleeps whatever the profit slider says".
  • Docs: docs/APPS.md covers the slider-driven windows, always_on and the new FORGE_PREVIEW_IDLE_DAYS default.

Not done: production's line saying how long until it sleeps under the current position. Only the always_on exception is shown on the app page.

Tests

  • test/apps-sleep-slider.test.ts runs a real app. At position 100, an app idle for 11 minutes stays up; moved to 0, the next sweep puts it to sleep and the log has the new line. After a push that sets always_on, it stays up at 0 and its status says so.
  • test/sleep-window.test.ts covers the windows at 0, 50 and 100, always_on beating 0, the log wording, forge.json checking the field, and the app-page line.
  • Both pass, as do the existing sleep, busy, idle, slider, economics, meter, running-quota, adversarial-apps and live-pages tests. The gate, tsc --noEmit and design-lint are clean.
  • scripts/fast.ts named 1,902 test files for this change, too many to run here, so I picked the ones that cover it.
  • No existing test was changed.

The first push failed the check's "say how to try it on the preview" rule, which wants a Try: line in a commit message. An empty follow-up commit adds one, and scripts/gate.ts now passes on the branch. No code changed after the tests above.

The keep_plan tool was not available in this session, so the issue has no plan posted.

Try: on the preview, push "app": {"always_on": true} in an app's forge.json and open its app page to see the always-on line. Then set the slider to 0 on the economics page: an app nobody uses for 10 minutes goes to sleep, and its deploy log names the window and the position.

🤖 Generated with Claude Code

commented

Moving the profit slider now changes when apps go to sleep, starting with the next sweep (once a minute) and with no restart. app.always_on: true in an app's forge.json keeps its production awake at any slider position.

  • Sweep (src/apps/runtime.ts): every pass reads the slider position and picks each environment's idle window from it, using the new src/apps/sleep_window.ts. Previews of quiet pulls also follow the slider: 1 day at 0, 3 at 50, never at 100. Setting FORGE_PREVIEW_IDLE_DAYS still fixes that age, as before (src/main.ts). At the default position of 50, nothing changes.
  • Fixed override: the runtime's sleepAfterMs option, when set, still fixes the window (tests use it); the forge itself never sets it. A new clock option lets a test move the sweep's time forward, so a 10-minute window takes milliseconds to test.
  • Log line: it now names the window and the slider position: asleep: nothing asked for it in 10 min (economy 0); the next request wakes it. The issue's example said "10 minutes"; this uses the slider's own short form, "10 min". The line for apps kept awake while busy (apps/busy.ts) is unchanged.
  • always_on: the issue says app.yaml, but apps here declare themselves in forge.json, so the field is app.always_on. Only true or false is accepted; anything else fails the deploy with a reason. It applies to production only; previews still follow the slider. When it is set, the app page shows "always on: its forge.json sets app.always_on, so it never sleeps whatever the profit slider says".
  • Docs: docs/APPS.md covers the slider-driven windows, always_on and the new FORGE_PREVIEW_IDLE_DAYS default.

Not done: production's line saying how long until it sleeps under the current position. Only the always_on exception is shown on the app page.

Tests

  • test/apps-sleep-slider.test.ts runs a real app. At position 100, an app idle for 11 minutes stays up; moved to 0, the next sweep puts it to sleep and the log has the new line. After a push that sets always_on, it stays up at 0 and its status says so.
  • test/sleep-window.test.ts covers the windows at 0, 50 and 100, always_on beating 0, the log wording, forge.json checking the field, and the app-page line.
  • Both pass, as do the existing sleep, busy, idle, slider, economics, meter, running-quota, adversarial-apps and live-pages tests. The gate, tsc --noEmit and design-lint are clean.
  • scripts/fast.ts named 1,902 test files for this change, too many to run here, so I picked the ones that cover it.
  • No existing test was changed.

Two checks failed and are fixed. The first wanted a Try: line in a commit message, so an empty follow-up commit adds one. The second was a type error in test/sleep-window.test.ts, which I wrote after my last type check: its sample environment's env was a plain string instead of "production". Type check, gate and that test now pass on the branch.

The keep_plan tool was not available in this session, so the issue has no plan posted.

Try: on the preview, push "app": {"always_on": true} in an app's forge.json and open its app page to see the always-on line. Then set the slider to 0 on the economics page: an app nobody uses for 10 minutes goes to sleep, and its deploy log names the window and the position.

🤖 Generated with Claude Code

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs