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

Removing a forge leaves it counted and leaves its files: children.max, reach/ and beats/ #13828

Merged opened this in answer to

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

Merged

Removing a forge now takes it out of the children.max count and deletes its reach, beat and credit records. I did not change the default for children.max. What changed removeForge (src/spawn/manage.ts) now retires the forge's body through the placement.

Notes

shipped production is serving it deploy 59903fa

opened this

Removing a forge now takes it out of the children.max count and deletes its reach, beat and credit records. I did not change the default for children.max.

What changed

  • removeForge (src/spawn/manage.ts) now retires the forge's body through the placement. The in-memory store that room() counts therefore drops it at once, not at the next restart. This goes through a new retireBody in src/spawn/door.ts.
  • removeForge also deletes reach/<name>.json, beats/<name>.json and credit/<name>.json under the data directory. A removed forge can no longer be alarmed by reachAlarms, and a new forge of the same name no longer inherits the old proof, beat or credit.
  • The stop record (stopped.json) lives in the forge's own directory, which removal already deleted, so it needed no change.
  • The extended test in test/forge-sleep.test.ts (the owner stops a forge, then removes it with its data) fails without this change. It checks that retire is called once with the forge's body id and that the three files are gone.

Checks

  • bun x tsc --noEmit is clean.
  • test/forge-sleep.test.ts and test/boundary-tokens-follow.test.ts pass (28 tests).
  • scripts/gate.ts --fix reported it rewrapped comments in 2 files. After that, git status showed nothing left to commit, so nothing further was pushed.
  • I did not run the full suite; the forge's check does that on the push.

Left out

  • Setting the children.max default from disk and the measured sleeping cost (165 MB), not from memory. It changes the capacity model and needs its own decision and tests.
  • Clearing the 20 existing scale-*.json files in production reach/ and beats/. Nothing in this change sweeps files for forges that were already removed, so an operator has to delete them.

Closes #13821

commented

Removing a forge now takes it out of the children.max count and deletes its reach, beat and credit records. I did not change the default for children.max.

What changed

  • removeForge (src/spawn/manage.ts) now retires the forge's body through the placement. The in-memory store that room() counts therefore drops it at once, not at the next restart. This goes through a new retireBody in src/spawn/door.ts.
  • removeForge also deletes reach/<name>.json, beats/<name>.json and credit/<name>.json under the data directory. A removed forge can no longer be alarmed by reachAlarms, and a new forge of the same name no longer inherits the old proof, beat or credit.
  • The stop record (stopped.json) lives in the forge's own directory, which removal already deleted, so it needed no change.
  • The extended test in test/forge-sleep.test.ts (the owner stops a forge, then removes it with its data) fails without this change. It checks that retire is called once with the forge's body id and that the three files are gone.

Checks

  • bun x tsc --noEmit is clean.
  • test/forge-sleep.test.ts and test/boundary-tokens-follow.test.ts pass (28 tests).
  • scripts/gate.ts --fix reported it rewrapped comments in 2 files. After that, git status showed nothing left to commit, so nothing further was pushed.
  • I did not run the full suite; the forge's check does that on the push.

Left out

  • Setting the children.max default from disk and the measured sleeping cost (165 MB), not from memory. It changes the capacity model and needs its own decision and tests.
  • Clearing the 20 existing scale-*.json files in production reach/ and beats/. Nothing in this change sweeps files for forges that were already removed, so an operator has to delete them.
Approved

Removing a forge now retires its body from the placement store, so the children.max count drops at once. It also deletes reach/, beats/ and credit/ <name>.json. I checked the paths against src/spawn/reach.ts, heartbeat.ts and credit.ts and they match. The name is validated by CHILD_NAME before it reaches the path. The test fails without the change. I did not run the code or the preview, because this is back-end only with no UI. Two things I would do next: (1) sweep the existing orphan scale-*.json files in production reach/ and beats/, since nothing here clears forges that were already removed; (2) make retireBody failure visible to the owner, because it is only a log warning and the count stays inflated if it fails.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs