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

When a date moves, every party it reminds gets a drafted "date changed" notice the agent approves, so nobody works to the old date #60

Merged opened this

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

Merged

Moving an open date now drafts a "Date changed" notice for each party a day-of reminder goes to. The full suite passes (179 tests) and the new tests are in, but I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc just prints its help.

Notes

shipped production is serving it deploy d2eada7

opened this

Moving an open date now drafts a "Date changed" notice for each party a day-of reminder goes to. The full suite passes (179 tests) and the new tests are in, but I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc just prints its help. There is no scripts/gate.ts or scripts/fast.ts here, so I ran the whole suite once rather than a named subset. I did not start the app or open the preview.

What changed

  • The notice (src/reminders.ts): moved is a new moment, labelled "Date changed". It is dated the day of the move and shows under Reminders for today until it is sent or declined.
  • Wording: it names the date, the deal's address, the old date and the new date, then ends with the sign-off. The move's reason is left out. The agent can add it by editing.
  • Replacement on a second move: the notice is built only from the latest move, so a second move replaces any unsent notice with one from the latest old date to the latest new date. Notices already sent stay in Messages as sent.
  • Move back and forth: sent and declined rows for moved are keyed by the new date plus the move id (stamp). Without that, moving a date A→B, back to A and to B again would show the fresh notice as already sent.
  • Memoizing: the memoized drafts key off the deal print, and a move changes it, so no extra invalidation was needed.
  • Doors: no new route. Send, edit-before-send, Don't send and Undo take moment: "moved" on the page, the API, MCP and the terminal.
  • Done and closing: marking the date done or closing the deal stops an unsent notice, as for other moments.
  • Migration: two new migrations at the end of the list. One rebuilds reminder and reminder_declined so the CHECK accepts moved, keeping all rows. The other adds deadline_move.notify.
  • Docs and contract: README step 5 and docs/TECHNICAL.md describe the notice, and contract/openapi.json is re-emitted.

Decisions to check

  • notify column: moves made before this change get notify = 0. Otherwise every historical move in an existing database would suddenly sprout drafts. Moves made through moveDeadline and the sample seed get 1.
  • Sample deals: 9 Orchard Row's appraisal move carries notify = 1, so it has at most one notice per party, which is the "doesn't flood" requirement. Its move time is the seed time, so the notice shows as overdue rather than dated today. I did not change the sample refresh to re-date it.
  • Sent rows show a date: a sent moved row stores due as 2026-11-20#12. I added stampDate and use it where the deal page's Messages list and the terminal's sent list print that date.
  • Sending a nonexistent notice: sendReminder with moment: "moved" on a date that has no notice now returns not_found. I did this only for moved; other moments behave as before.

Tests: four in src/deals.test.ts cover the right parties and both dates, replacement on a second move, edit/decline/undo and marking done, and a date moved away and back. One in src/db.test.ts covers the migration.

To try it: open a deal, move a date, then open the sheet or the Reminders list. The Date changed notice is there to send, edit or decline.

No cell in contract.json was loosened.

Closes #57

1 earlier comment · 1 event
commented

Moving an open date now drafts a "Date changed" notice for each party a day-of reminder goes to. The full suite passes (179 tests) and the new tests are in, but I could not run bun x tsc --noEmit: the repo has no tsconfig.json, so tsc just prints its help. There is no scripts/gate.ts or scripts/fast.ts here, so I ran the whole suite once rather than a named subset. I did not start the app or open the preview.

What changed

  • The notice (src/reminders.ts): moved is a new moment, labelled "Date changed". It is dated the day of the move and shows under Reminders for today until it is sent or declined.
  • Wording: it names the date, the deal's address, the old date and the new date, then ends with the sign-off. The move's reason is left out. The agent can add it by editing.
  • Replacement on a second move: the notice is built only from the latest move, so a second move replaces any unsent notice with one from the latest old date to the latest new date. Notices already sent stay in Messages as sent.
  • Move back and forth: sent and declined rows for moved are keyed by the new date plus the move id (stamp). Without that, moving a date A→B, back to A and to B again would show the fresh notice as already sent.
  • Memoizing: the memoized drafts key off the deal print, and a move changes it, so no extra invalidation was needed.
  • Doors: no new route. Send, edit-before-send, Don't send and Undo take moment: "moved" on the page, the API, MCP and the terminal.
  • Done and closing: marking the date done or closing the deal stops an unsent notice, as for other moments.
  • Migration: two new migrations at the end of the list. One rebuilds reminder and reminder_declined so the CHECK accepts moved, keeping all rows. The other adds deadline_move.notify.
  • Docs and contract: README step 5 and docs/TECHNICAL.md describe the notice, and contract/openapi.json is re-emitted.

Decisions to check

  • notify column: moves made before this change get notify = 0. Otherwise every historical move in an existing database would suddenly sprout drafts. Moves made through moveDeadline and the sample seed get 1.
  • Sample deals: 9 Orchard Row's appraisal move carries notify = 1, so it has at most one notice per party, which is the "doesn't flood" requirement. Its move time is the seed time, so the notice shows as overdue rather than dated today. I did not change the sample refresh to re-date it.
  • Sent rows show a date: a sent moved row stores due as 2026-11-20#12. I added stampDate and use it where the deal page's Messages list and the terminal's sent list print that date.
  • Sending a nonexistent notice: sendReminder with moment: "moved" on a date that has no notice now returns not_found. I did this only for moved; other moments behave as before.

Tests: four in src/deals.test.ts cover the right parties and both dates, replacement on a second move, edit/decline/undo and marking done, and a date moved away and back. One in src/db.test.ts covers the migration.

To try it: open a deal, move a date, then open the sheet or the Reminders list. The Date changed notice is there to send, edit or decline.

No cell in contract.json was loosened.

Changes requested — before the latest push

The feature works in the domain layer, but three things need fixing in one round.

  1. (First) The stored due of a sent or declined moved row is 2026-11-20#12. That string leaks through the JSON API (DEAL.sent[].due and DEAL.declined[].due are declared DATE in routes.ts and openapi.json), MCP and any other reader of deal.sent and deal.declined. Only the deal page and the terminal were patched with stampDate. Clients get an invalid date, and the contract is broken. Fix it: keep due a plain date on the row and put the move id in its own column (for example move_id INTEGER NOT NULL DEFAULT 0, included in the UNIQUE key), or strip the stamp in view() so every reader sees a date. Add a test that the API's deal JSON has a YYYY-MM-DD due on a sent moved row.
  1. Both doors are untested for the new moment. Nothing exercises moment: "moved" through the HTTP routes (send, decline and undo in server.test.ts), the MCP tools (send_reminder and the decline and undo tools) or the terminal (the reminders list and the sent list, which now print stampDate). The builder also did not open the preview. Add a server test and a terminal test that move a date, find the Date changed draft, and send or decline it. Also add an MCP test.
  1. Housekeeping. sendOn(due, 'moved') returns the new due date, but the draft's on is the move day, so the two disagree. Remove moved from OFFSET and sendOn, or have sendOn take the move. The 9 Orchard Row sample notice shows as overdue rather than today; either re-date it on sample refresh or say in the README that it is a stale example. bun x tsc --noEmit was not run, so state in the pull how types were checked.

No cell in contract.json is loosened, and the migrations and the replacement and back-and-forth logic look right.

commented

All three points from the review are fixed and pushed to the same branch. The full suite passes (183 tests).

1. due stays a plain date

  • The move id now lives in its own move_id column on reminder and reminder_declined, and the UNIQUE key is (deadline_id, party_id, moment, due, move_id). move_id is the latest move's id for moved, 0 for every other moment.
  • A new migration at the end of the list rebuilds both tables. It splits any 2026-11-20#12 row from the earlier push into a plain date and a move_id, so a database that already ran the first version ends up clean.
  • stamp and stampDate are gone, and the deal page and terminal print due directly.
  • server.test.ts checks that every sent[].due in the API's deal JSON matches YYYY-MM-DD after a moved send. The moved row's due equals the new date.
  • move_id now appears on sent and declined rows in the API output, and contract/openapi.json was re-emitted.

2. Both doors are tested for moved

  • src/server.test.ts: one test moves a date, then sends with edited words, declines and undoes through the HTTP forms. It then declines, undoes and sends again through MCP decline_reminder, undo_decline_reminder and send_reminder. It also checks that a date which never moved has no notice to send.
  • src/terminal.test.ts: two tests find the "date changed" row on the reminders list, read it (both dates, no reason) and send it. They then check the sent list reads <date> · date changed, and that n declines the notice and u undoes it.
  • src/db.test.ts: the earlier migration test now also checks that due and move_id are stored separately.

3. Housekeeping

  • sendOn no longer takes moved; its type excludes it, so it can't disagree with the draft's on, which is the move day.
  • Sample notice: the 9 Orchard Row move is now seeded with at at the sample anchor day. The sample refresh shifts at along with the dates, so its notice is dated today instead of overdue.
  • Types: there is no tsconfig.json in the repo, so bun x tsc --noEmit only prints its help and I could not run it. Types were checked only by Bun running the code and the tests. The preview was not opened; the server, MCP and terminal tests run the app instead.

I made no changes in response to a point I disagreed with. No contract.json cell was touched.

Approved

Earlier asks are met. due is a plain date again, with the move id in its own move_id column and a migration that splits any # rows. The moved moment is tested through the page forms, MCP and the terminal (send, edit, decline, undo). sendOn no longer accepts moved. The sample notice is dated today. No new door, no contract.json cell changed, no dependency added, and the existing doors still go through permit. Non-blocking: a notice from an old move stays on the Reminders list until it is sent or declined. That fits the issue, but you could age it out later. I did not run the app or open the preview; this verdict rests on reading the diff.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs