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

A pure step remembers the governor's last change, so a reader can say "I lowered builders to 3 at 20:41" #6540

Merged opened this

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

Merged

I added `src/crew/governor_log.ts` and `test/governor-log.test.ts`. The new test passes (5 tests), but `bun x tsc --noEmit` failed here with `Cannot find type definition file for 'bun'`. I ran it right after a first `bun install` and didn't investigate, so the type check is unverified. `src/crew/governor.ts` is untouched, as the issue asked.

shipped production is serving it deploy aafe9dc

opened this

I added src/crew/governor_log.ts and test/governor-log.test.ts. The new test passes (5 tests), but bun x tsc --noEmit failed here with Cannot find type definition file for 'bun'. I ran it right after a first bun install and didn't investigate, so the type check is unverified. src/crew/governor.ts is untouched, as the issue asked.

  • governorStep(prev, governed, now) returns { last, changed }, where last is { from, to, why, at }. A reading with the same slot count returns the same last and changed: false.
  • governorSays(last) words a drop as "Builders 7 → 3 at 20:41: <why>" and a rise as "Builders back to 7 at 21:30". It returns an empty string when nothing has changed yet.
  • Tests cover lower, hold, raise, the first-reading baseline, and the words for each.

What I chose:

  • The first reading (prev null) is stored as a baseline with from equal to to and reports no change. Without that, the first drop could never be detected.
  • Any rise is worded "back to N", because governorStep isn't given the ceiling and can't tell a rise to the ceiling from a partial recovery.
  • Times are UTC, formatted as HH:MM.
  • Nothing calls this module yet; wiring it into the page is left for a follow-up.

To try it: bun test test/governor-log.test.ts.

🤖 Generated with Claude Code

Closes #6520

commented

I added src/crew/governor_log.ts and test/governor-log.test.ts. The new test passes (5 tests), but bun x tsc --noEmit failed here with Cannot find type definition file for 'bun'. I ran it right after a first bun install and didn't investigate, so the type check is unverified. src/crew/governor.ts is untouched, as the issue asked.

  • governorStep(prev, governed, now) returns { last, changed }, where last is { from, to, why, at }. A reading with the same slot count returns the same last and changed: false.
  • governorSays(last) words a drop as "Builders 7 → 3 at 20:41: <why>" and a rise as "Builders back to 7 at 21:30". It returns an empty string when nothing has changed yet.
  • Tests cover lower, hold, raise, the first-reading baseline, and the words for each.

What I chose:

  • The first reading (prev null) is stored as a baseline with from equal to to and reports no change. Without that, the first drop could never be detected.
  • Any rise is worded "back to N", because governorStep isn't given the ceiling and can't tell a rise to the ceiling from a partial recovery.
  • Times are UTC, formatted as HH:MM.
  • Nothing calls this module yet; wiring it into the page is left for a follow-up.

To try it: bun test test/governor-log.test.ts.

🤖 Generated with Claude Code

Approved

Matches issue #6520 exactly: two files, governor.ts untouched, pure functions, tests for lower, hold, raise, baseline and words. No input, write or UI surface, so the security, tty and web items do not apply here; no dependency added. Next two things: (1) a rise that stops short of the ceiling is worded "back to N", which overstates a partial recovery. Pass the ceiling to governorSays, or word a partial rise "Builders 3 → 5". (2) Nothing calls this yet, so it is not reachable. Wire it into the page and the terminal in the follow-up, and add a test that a reader sees the line. The scout could not verify tsc --noEmit; the forge check will.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs