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

A child forge cannot bring back an ask the owner put aside by flooding new ones #15058

Merged opened this

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

Merged

A child forge can no longer get rid of an ask the owner put aside by flooding new asks. When the per-forge cap (ASKSPERFORGE, 20) is passed, only waiting asks are evicted; an ask put aside less than 24 h ago is kept, so its put-aside holds.

Notes

shipped production is serving it deploy 9504585

opened this

A child forge can no longer get rid of an ask the owner put aside by flooding new asks. When the per-forge cap (ASKS_PER_FORGE, 20) is passed, only waiting asks are evicted; an ask put aside less than 24 h ago is kept, so its put-aside holds.

The finding, confirmed: the eviction in keepAsk (src/core/child_reach.ts) sorted every one of the forge's asks by last_at and never looked at state. Sending 20 new names pushed the put-aside row out. Re-sending its name then created a fresh asked row, so the owner was asked again straight away.

The fix: the eviction query now skips rows where state = 'later' AND answered_at > now − RAISE_AGAIN_MS. That is the same 24 h test the update path already uses. Once its day has passed, a put-aside ask can be evicted like any other. The child cannot add rows to the protected set: a row only enters it when an admin puts an ask aside, one per name. The doc comment on keepAsk now says this.

Test: a new case in test/ask-to-reach.test.ts puts an ask aside, sends ASKS_PER_FORGE + 5 new names, and checks three things:

  • the put-aside row is still later;
  • exactly ASKS_PER_FORGE asks are waiting;
  • re-sending the name keeps it later, and after 24 h it comes back as asked.

Without the fix this test fails.

Checks run: bun scripts/gate.ts --fix changed nothing, bun x tsc --noEmit is clean, and test/ask-to-reach.test.ts and test/spawn-reach.test.ts pass (35 tests). I didn't run the full suite; the forge runs it on push.

Not done: I added no separate cap on how many put-aside rows a forge can have, because only admin actions create them.

🤖 Generated with Claude Code

Closes #15042

commented

A child forge can no longer get rid of an ask the owner put aside by flooding new asks. When the per-forge cap (ASKS_PER_FORGE, 20) is passed, only waiting asks are evicted; an ask put aside less than 24 h ago is kept, so its put-aside holds.

The finding, confirmed: the eviction in keepAsk (src/core/child_reach.ts) sorted every one of the forge's asks by last_at and never looked at state. Sending 20 new names pushed the put-aside row out. Re-sending its name then created a fresh asked row, so the owner was asked again straight away.

The fix: the eviction query now skips rows where state = 'later' AND answered_at > now − RAISE_AGAIN_MS. That is the same 24 h test the update path already uses. Once its day has passed, a put-aside ask can be evicted like any other. The child cannot add rows to the protected set: a row only enters it when an admin puts an ask aside, one per name. The doc comment on keepAsk now says this.

Test: a new case in test/ask-to-reach.test.ts puts an ask aside, sends ASKS_PER_FORGE + 5 new names, and checks three things:

  • the put-aside row is still later;
  • exactly ASKS_PER_FORGE asks are waiting;
  • re-sending the name keeps it later, and after 24 h it comes back as asked.

Without the fix this test fails.

Checks run: bun scripts/gate.ts --fix changed nothing, bun x tsc --noEmit is clean, and test/ask-to-reach.test.ts and test/spawn-reach.test.ts pass (35 tests). I didn't run the full suite; the forge runs it on push.

Not done: I added no separate cap on how many put-aside rows a forge can have, because only admin actions create them.

🤖 Generated with Claude Code

Approved

Small, single-purpose, no page change. The eviction in keepAsk now skips a put-aside ask still inside its 24 h, using the same test as the update path, so a flood cannot wipe it. The waiting asks stay capped at ASKS_PER_FORGE. The new test fails without the fix and covers the flood, the cap, the re-send and expiry after a day. Next, two things I would do: (1) a put-aside row with a NULL answered_at would be neither protected nor evictable under the NOT(...) NULL logic, so make the predicate NULL-safe, e.g. COALESCE(answered_at, "") > ?3; (2) consider a hard ceiling on put-aside rows per forge, if any path other than an admin click can ever create them.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs