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

The agent can correct a party's name or contact, remove a party, and remove a date the contract dropped #16

opened this

Merged 31d 2h ago, live in production

An agent can now correct a party's name or contact, remove a party, and remove a custom date, from the page, the API and the terminal. bun test passes (82 tests). I did not run bun x tsc --noEmit: the repo has no tsconfig.json and no installed TypeScript, so it only printed help.

Notes

opened this

An agent can now correct a party's name or contact, remove a party, and remove a custom date, from the page, the API and the terminal. bun test passes (82 tests). I did not run bun x tsc --noEmit: the repo has no tsconfig.json and no installed TypeScript, so it only printed help. scripts/gate.ts and scripts/fast.ts don't exist here. bun run lint:design ran with no output.

Actions (src/deals.ts)

  • editParty takes name and contact under the same rules as addParty; the role stays.
  • removeParty and removeDeadline are new. removeDeadline refuses standard contract dates with a named invalid failure.
  • All three ask permit(who, "deal", "update", deal), are audited against the deal id and emit deal.changed. No cell in contract.json changed.

Sent reminders survive removal. The reminder table used to cascade-delete when its date or party went, which would have erased sent reminders. Migration 3 rebuilds it:

  • It keeps existing rows.
  • It hangs them off deal_id, so removing the whole deal still removes them.
  • It adds label and party_name columns, so a kept record reads without the removed row.

Unsent drafts are computed, so they vanish with the date or party. sendReminder and src/sample.ts use the new columns.

Page

  • Each party has an Edit form (a <details> with a plain form) and a Remove button.
  • A custom date's sheet has "Remove this date". Standard dates show none.
  • All forms return via to.
  • Controls use the 44px and 16px classes.
  • I haven't looked at it in a browser at 360px.

API

  • I added rows rather than extending PATCH /api/deals/:id:
    • PATCH /api/deals/:id/parties/:party
    • DELETE /api/deals/:id/parties/:party
    • DELETE /api/deals/:id/deadlines/:deadline
  • The deal in the path must own the child, or the answer is 404.
  • contract/openapi.json is re-emitted.
  • doorOf in src/security.ts now maps <api>/:id/<child>/:child with PATCH or DELETE to update of the row. This closes the door to anyone who can't update. It loosens nothing, but the nested rows needed a door for the OpenAPI test to pass.

Terminal

  • In a deal, the cursor walks the dates, then the parties.
  • e edits the party under the cursor.
  • X removes the date or party under it after you type yes.
  • A prompt that shrinks the list now re-clamps the cursor.

Tests

  • src/deals.test.ts:
    • An edited contact shows in the next draft.
    • A standard date is refused.
    • A custom date's drafts go but a sent reminder stays.
    • Anon is refused and the attempts are audited.
  • src/terminal.test.ts has the key flow.
  • src/server.test.ts covers the forms and the three API rows.

README: the "A deal's page" paragraph and the terminal keys are updated.

Not done

  • MCP tools for these operations (the issue says #6's pattern, not required here).
  • A UI to change a party's role.
  • A rebase onto #5, which hasn't landed.

To try it: open a deal in the preview, add a lender and a custom date, then use Edit and Remove on the party and "Remove this date" in the sheet. In the terminal, press o on a deal, move down to a party, then e, then X and yes.

Closes #9

commented

An agent can now correct a party's name or contact, remove a party, and remove a custom date, from the page, the API and the terminal. bun test passes (82 tests). I did not run bun x tsc --noEmit: the repo has no tsconfig.json and no installed TypeScript, so it only printed help. scripts/gate.ts and scripts/fast.ts don't exist here. bun run lint:design ran with no output.

Actions (src/deals.ts)

  • editParty takes name and contact under the same rules as addParty; the role stays.
  • removeParty and removeDeadline are new. removeDeadline refuses standard contract dates with a named invalid failure.
  • All three ask permit(who, "deal", "update", deal), are audited against the deal id and emit deal.changed. No cell in contract.json changed.

Sent reminders survive removal. The reminder table used to cascade-delete when its date or party went, which would have erased sent reminders. Migration 3 rebuilds it:

  • It keeps existing rows.
  • It hangs them off deal_id, so removing the whole deal still removes them.
  • It adds label and party_name columns, so a kept record reads without the removed row.

Unsent drafts are computed, so they vanish with the date or party. sendReminder and src/sample.ts use the new columns.

Page

  • Each party has an Edit form (a <details> with a plain form) and a Remove button.
  • A custom date's sheet has "Remove this date". Standard dates show none.
  • All forms return via to.
  • Controls use the 44px and 16px classes.
  • I haven't looked at it in a browser at 360px.

API

  • I added rows rather than extending PATCH /api/deals/:id:
    • PATCH /api/deals/:id/parties/:party
    • DELETE /api/deals/:id/parties/:party
    • DELETE /api/deals/:id/deadlines/:deadline
  • The deal in the path must own the child, or the answer is 404.
  • contract/openapi.json is re-emitted.
  • doorOf in src/security.ts now maps <api>/:id/<child>/:child with PATCH or DELETE to update of the row. This closes the door to anyone who can't update. It loosens nothing, but the nested rows needed a door for the OpenAPI test to pass.

Terminal

  • In a deal, the cursor walks the dates, then the parties.
  • e edits the party under the cursor.
  • X removes the date or party under it after you type yes.
  • A prompt that shrinks the list now re-clamps the cursor.

Tests

  • src/deals.test.ts:
    • An edited contact shows in the next draft.
    • A standard date is refused.
    • A custom date's drafts go but a sent reminder stays.
    • Anon is refused and the attempts are audited.
  • src/terminal.test.ts has the key flow.
  • src/server.test.ts covers the forms and the three API rows.

README: the "A deal's page" paragraph and the terminal keys are updated.

Not done

  • MCP tools for these operations (the issue says #6's pattern, not required here).
  • A UI to change a party's role.
  • A rebase onto #5, which hasn't landed.

To try it: open a deal in the preview, add a lender and a custom date, then use Edit and Remove on the party and "Remove this date" in the sheet. In the terminal, press o on a deal, move down to a party, then e, then X and yes.

commented

I merged main into this branch and pushed it (d241486); the full bun test passes (88 tests). As before, I did not run tsc.

The conflicts were in README.md, src/db.ts, src/deals.ts, src/server.test.ts and src/terminal.ts. I kept both sides in each:

  • src/db.ts: main's subject and body columns now come first as migrations 3 and 4. My reminder-table rebuild is migration 5 and carries those two columns over. A preview database that already ran my old migration 3 will not match this order. Previews are throwaway, so I did nothing about it.
  • src/deals.ts: sendReminder keeps main's edited-words logic. Its insert now also writes deal_id, label and party_name, so a sent reminder still survives removal of its date or party.
  • src/terminal.ts: main's reminder-edit helpers sit beside my cursor, which walks the dates and then the parties. e in the reminders view edits a draft; e in a deal edits the party under the cursor. They never clash, because each view has its own handler.
  • README.md: both terminal paragraphs are combined.
  • src/server.test.ts: both new tests are kept. main's test takes the last deal on the clock as the latest, and mine opens one that closes later and removes its buyer. I moved mine to the end of the file, with a comment saying why.

I re-emitted contract/openapi.json; the committed file is unchanged.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs