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

An addendum moves several of a deal's dates at once with one reason, and each party gets one "dates changed" notice listing every change #71

Merged opened this

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

Merged

The deal page now has an Amend the contract form: an addendum moves several dates at once with one reason, and each party gets one "dates changed" notice listing every change. bun test passes (217 tests plus the new terminal test), as does bun run lint:design.

Notes

shipped production is serving it deploy d2eada7

opened this

The deal page now has an Amend the contract form: an addendum moves several dates at once with one reason, and each party gets one "dates changed" notice listing every change. bun test passes (217 tests plus the new terminal test), as does bun run lint:design. I couldn't run bun x tsc --noEmit because the repo has no tsconfig.json and tsc just prints its help.

What changed

  • Form (src/pages/amend.ts). One date input per open date, prefilled with its due date, plus one required reason of 1–200 characters. It works without JavaScript, and a refused form comes back 422 with what was typed and the offending field marked. src/pages/deal.ts only includes it, so #62 and #64 can still edit that file.
  • Action (amendDeal in src/deals.ts). It checks every date before moving any, so one bad date refuses the whole amendment. A date left at its current due is skipped, and if none changed it answers "Nothing changed". It writes one move per changed date in a single transaction, with the same reason and author. It uses the same permit(deal, update) check as a move, and contract.json is untouched.
  • Notices. Moves from one amendment share a new amendment number (migration appended to src/db.ts). Each party gets one notice listing every changed date they are told about (old → new). It sits on one of the amendment's dates and is remembered by the first move it told that party about, so a notice already sent or declined is not re-drafted if one of its dates is moved again. Single-date moves keep today's notice. Send, edit, decline and undo work on it unchanged, because Draft now carries move_id instead of moveKey.
  • Doors.

- API: POST /api/deals/:id/amend, with contract/openapi.json regenerated. - MCP: amend_deal with {deal, dates, reason}. - Terminal: M in the deal view, where a blank answer keeps a date. - All of them show the #61 closing-order conflicts after the amendment.

  • Docs. README step 5 has the one sentence you asked for, and docs/TECHNICAL.md names amend_deal.

Changes outside the listed files

  • doorOf in src/security.ts now treats POST <api>/:id/amend as an update of the deal. Without that the API route had no contract cell and src/openapi.test.ts failed. This does not loosen any cell.
  • The event-stream test in src/server.test.ts assumed the first replayed deal.changed was its own. With more tests emitting events, that event dropped out of the 100-event replay buffer and the test failed. It now opens the stream past every earlier event. That test was wrong, not the code.
  • src/server.test.ts also lists amend_deal among the MCP tools.

What I chose not to do

  • If an amendment's notice is already sent or declined and a later move also touches that notice's date, the later move gets its own notice; the amendment's stays as it was.
  • A notice for an amendment that tells a party about only one date uses the ordinary single-date wording.
  • The notice does not state the reason, matching today's moved notice.

Try it: open any deal, change two dates under Amend the contract, give a reason, and save. Under Messages or the Reminders view, each party has one "dates changed" notice naming both. Submitting with no change, or with a blank reason, brings the form back with the field marked.

🤖 Generated with Claude Code

Closes #66

commented

The deal page now has an Amend the contract form: an addendum moves several dates at once with one reason, and each party gets one "dates changed" notice listing every change. bun test passes (217 tests plus the new terminal test), as does bun run lint:design. I couldn't run bun x tsc --noEmit because the repo has no tsconfig.json and tsc just prints its help.

What changed

  • Form (src/pages/amend.ts). One date input per open date, prefilled with its due date, plus one required reason of 1–200 characters. It works without JavaScript, and a refused form comes back 422 with what was typed and the offending field marked. src/pages/deal.ts only includes it, so #62 and #64 can still edit that file.
  • Action (amendDeal in src/deals.ts). It checks every date before moving any, so one bad date refuses the whole amendment. A date left at its current due is skipped, and if none changed it answers "Nothing changed". It writes one move per changed date in a single transaction, with the same reason and author. It uses the same permit(deal, update) check as a move, and contract.json is untouched.
  • Notices. Moves from one amendment share a new amendment number (migration appended to src/db.ts). Each party gets one notice listing every changed date they are told about (old → new). It sits on one of the amendment's dates and is remembered by the first move it told that party about, so a notice already sent or declined is not re-drafted if one of its dates is moved again. Single-date moves keep today's notice. Send, edit, decline and undo work on it unchanged, because Draft now carries move_id instead of moveKey.
  • Doors.

- API: POST /api/deals/:id/amend, with contract/openapi.json regenerated. - MCP: amend_deal with {deal, dates, reason}. - Terminal: M in the deal view, where a blank answer keeps a date. - All of them show the #61 closing-order conflicts after the amendment.

  • Docs. README step 5 has the one sentence you asked for, and docs/TECHNICAL.md names amend_deal.

Changes outside the listed files

  • doorOf in src/security.ts now treats POST <api>/:id/amend as an update of the deal. Without that the API route had no contract cell and src/openapi.test.ts failed. This does not loosen any cell.
  • The event-stream test in src/server.test.ts assumed the first replayed deal.changed was its own. With more tests emitting events, that event dropped out of the 100-event replay buffer and the test failed. It now opens the stream past every earlier event. That test was wrong, not the code.
  • src/server.test.ts also lists amend_deal among the MCP tools.

What I chose not to do

  • If an amendment's notice is already sent or declined and a later move also touches that notice's date, the later move gets its own notice; the amendment's stays as it was.
  • A notice for an amendment that tells a party about only one date uses the ordinary single-date wording.
  • The notice does not state the reason, matching today's moved notice.

Try it: open any deal, change two dates under Amend the contract, give a reason, and save. Under Messages or the Reminders view, each party has one "dates changed" notice naming both. Submitting with no change, or with a blank reason, brings the form back with the field marked.

🤖 Generated with Claude Code

commented

I merged main into this branch and pushed it. The full suite passes locally (219 tests, 0 failures).

What changed: the only conflict was in src/pages/deal.ts, where both sides had added an import on the same line. main added confirmRemove from ./confirm.ts and this branch added amendForm from ./amend.ts. Both are used, so I kept both. Nothing else needed resolving, and the merge commit is 2f4523d.

What I couldn't run:

  • Type check: the repository has no tsconfig.json, so bun x tsc --noEmit can't run here.
  • Fast test selection: scripts/fast.ts doesn't exist in this clone, so I ran the whole suite.
  • Design lint: I didn't run bun scripts/design-lint.ts, because only an import line changed. The repository's script is named scripts/lint-design.ts, not design-lint.ts.

I made no behaviour change, loosened no contract cell, and added no dependency.

🤖 Generated with Claude Code

Approved

Amend the contract works on all four doors (page, API, MCP, terminal M), all through permit via dealFor; no contract cell loosened, no dependency added. The amendment is validated whole before any move, the moves and one shared amendment number are written in one transaction, and each party gets one notice keyed by its first move. The preview answers 200. One nit, not blocking: in the 'sent ... and stays sent when a date moves again' test, add an expect(amended.length).toBeGreaterThan(0) so the loop cannot pass on an empty list.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs