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

A sleeping forge wakes when its app's own timer falls due #17105

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A sleeping cell child now wakes when its app's own timer falls due, through the same wakeWhenDue path as a paused crew run. That path keeps the awake ceiling, the disk floor and the billing limits. The new test and the rest of test/spawn-cell.test.ts and the test/child-db.test.ts files pass (50 tests).

Notes

opened this

A sleeping cell child now wakes when its app's own timer falls due, through the same wakeWhenDue path as a paused crew run. That path keeps the awake ceiling, the disk floor and the billing limits. The new test and the rest of test/spawn-cell.test.ts and the test/child-db*.test.ts files pass (50 tests). bun x tsc --noEmit is clean. I did not run the full suite, and the forge's check will run it on the push.

What changed

  • nextRunDue in src/spawn/child_runs.ts now returns the earliest of two times. One is the earliest paused run (run.not_before). The other is the earliest unpaused app timer (timer.due_at).
  • The three places that arm the wake already call childNextRunDue: the idle sweep, sleeping to make room, and the boot pass over children that were already asleep. They now arm a wake for a timer with no further change.
  • The new test is in test/spawn-cell.test.ts. It arms a real one-shot timer in a child's database with armTimer, using a proper Arm record and no cast. It puts the cell to sleep and checks that the cell is not started before the timer's time and is started once it falls due.

What I reused

  • I did not add a function. I extended nextRunDue and kept the existing wakeWhenDue, wakeDue and childNextRunDue.
  • I added no module-level state and no new export.
  • I did not run scripts/similar.ts.

What I left out

  • The timer query is not in the TABLES check in child_db_reader.ts. nextRunDue opens its own read-only connection, and a child database with no timer table still answers from its runs alone.
  • A timer being fired right now (awaiting) counts as due. The worst case is a harmless early wake.
  • Forges running inside this process (hosted) are not armed. That matches how the code worked before, where only cells wake for a due run.
  • Door: I did not touch any page, action, route or tool, so there is no terminal side or how-to change. The commit line says No door:.

To try it: bun test test/spawn-cell.test.ts.

Closes #16918

commented

A sleeping cell child now wakes when its app's own timer falls due, through the same wakeWhenDue path as a paused crew run. That path keeps the awake ceiling, the disk floor and the billing limits. The new test and the rest of test/spawn-cell.test.ts and the test/child-db*.test.ts files pass (50 tests). bun x tsc --noEmit is clean. I did not run the full suite, and the forge's check will run it on the push.

What changed

  • nextRunDue in src/spawn/child_runs.ts now returns the earliest of two times. One is the earliest paused run (run.not_before). The other is the earliest unpaused app timer (timer.due_at).
  • The three places that arm the wake already call childNextRunDue: the idle sweep, sleeping to make room, and the boot pass over children that were already asleep. They now arm a wake for a timer with no further change.
  • The new test is in test/spawn-cell.test.ts. It arms a real one-shot timer in a child's database with armTimer, using a proper Arm record and no cast. It puts the cell to sleep and checks that the cell is not started before the timer's time and is started once it falls due.

What I reused

  • I did not add a function. I extended nextRunDue and kept the existing wakeWhenDue, wakeDue and childNextRunDue.
  • I added no module-level state and no new export.
  • I did not run scripts/similar.ts.

What I left out

  • The timer query is not in the TABLES check in child_db_reader.ts. nextRunDue opens its own read-only connection, and a child database with no timer table still answers from its runs alone.
  • A timer being fired right now (awaiting) counts as due. The worst case is a harmless early wake.
  • Forges running inside this process (hosted) are not armed. That matches how the code worked before, where only cells wake for a due run.
  • Door: I did not touch any page, action, route or tool, so there is no terminal side or how-to change. The commit line says No door:.

To try it: bun test test/spawn-cell.test.ts.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs