One shared draft a contract, locked when all agree (phase 13, step 2)
CI / secret scan (push) Successful in 6s
CI / fmt, clippy, tests (push) Successful in 1m27s
CI / release (push) Skipped

Until a contract is set, it is one open text for every side, as Alex
asked: our team edits it in the app, each other party on its link. Edits
are tracked changes in the author's color (crossed out, added,
highlighted with a comment) until the other side accepts or rejects
them. When no change or highlight is open and Lanna Desk and every party
agree, the text becomes a contract version that never changes, and the
draft locks.

- One side edits at a time: Edit takes the draft for 45 seconds, which
  every save renews; Done editing, leaving the page or silence gives it
  up. The editor saves 0.7 s after the last keystroke; the other pages
  ask for news every 3 s, so each side sees edits, who edits, agreements
  and the lock without reloading.
- A save may only touch the saver's own marks (reviews::check_save);
  accept, reject (or withdraw) and resolve are their own steps, journaled
  with the text concerned. A later change voids the agreements given.
- Notices: the other side's edits (one a half hour of editing), settled
  changes, agreements, the lock. The bell in the top bar counts the
  unseen (every 15 s); Notices lists them and marks them seen.
- The draft as a diff: the standing text against every open change taken.
- Migration 0015: contract_drafts, draft_saves and draft_agreements (both
  kept unchanged by a trigger), notices, notice_reads; drops step 1's
  review_rounds (only the demo held any). The review links stay as each
  party's way in.
- Property tests for the save rule and settling, the fuzz text target
  runs the parser, the save check and settling; integration tests play
  both sides to the lock. The demo's recording agreement has an open
  draft with the label's changes and a notice.
- PLAN: phase 13 rewritten; step 3 is the PDF and signing.
This commit is contained in:
grabowski committed 2026-11-23 16:14:14 +07:00
1 parent a4155548b8
commit 3dd9ab60e8
36 files changed
+3812 -2161

No files matched your search

+64 -33
View File
@@ -248,7 +248,7 @@ dark at desktop and phone width, a commit and a push.
| 10 | One client list: a visa record becomes part of a client; People becomes the visa clients | planned Nov 21, 2026 |
| 11 | The conflict check and the other parties of a contract; the journal's last hash sent outside the server each day | built Nov 22, 2026 |
| 12 | Originals in our care (passports, signed contracts, deeds: where each one is) and the inbox that files a pile of scans | step 1 built Nov 23, 2026 |
| 13 | The other side reviews a draft through a link: crosses out, adds, highlights; we take their changes one by one | step 1 built Nov 23, 2026 |
| 13 | One shared draft per contract: every side edits with tracked changes, one at a time; it locks as a version when all agree; then a PDF to sign | steps 1 and 2 built Nov 23, 2026 |
| later | Thai user interface, agency cases and fees, other visa categories' packs | |
### Phase 1: app, login, people
@@ -844,43 +844,74 @@ and record, with a suggestion to confirm.
reminders once phase 8 sends them.
- Phase 10 (one client list) turns an original's person into a client.
## Phase 13: the other side reviews a draft (planned Nov 23, 2026)
## Phase 13: the shared draft (planned and built Nov 23, 2026)
Alex: when our lawyers draft a version, they send it to the other party
with a link; there the other party edits it and sends it back. It should
have an editor that crosses out words and highlights passages, and in the
end read like a git diff.
Alex: when our lawyers draft a version, the other party should edit it
through a link, with an editor that crosses out words and highlights
passages and reads like a git diff in the end. Then, the same day: the
team should see the other side's work in the app without looking for it,
and until the contract is set, it is one open document for edits, like
CryptPad; once both parties agree it becomes a version that never
changes, and a PDF that can be signed. His choices: saved as you type and
seen by the others within seconds, one editor at a time; an edit is a
tracked change in its author's color until the other side accepts or
rejects it; our lawyer and every other party must agree; signing in the
app with a drawn signature, or on paper with the scan uploaded.
### Step 1: the review link and the marking editor (built)
### Step 1: review rounds (built, then replaced)
- A lawyer sends a version with a text to one of the contract's parties
(Contract, Review by the other side). This makes a link for that party
(`/r/<token>`, shown once, as the client links; 30 days) or, when the
party has an open one, a new round on the same link, so the other side
keeps one address for the whole negotiation.
- The other side's page shows our version in an editor that keeps every
change visible, as tracked changes do: what they delete stays in place,
crossed out in red; what they type is marked in green; the highlighter
marks a passage in yellow with an optional comment. Restore takes a mark
back. They send it back with their name and a covering message, once per
round; the page then shows what they sent until our next version.
- What they send is a list of pieces (same, added, crossed out,
highlighted). The server checks that the pieces without the added ones
give exactly the version we sent: nothing can change unseen. Their text
and its SHA-256 are kept unchanged (migration 0014, a trigger), and the
journal records each send and each reply with the fingerprints.
- Our review page shows their markup and a git-style diff (lines taken out
and added, the changed words marked), with each change numbered. The
lawyer ticks the changes to take; the contract page then opens with the
version form filled with our text plus those changes, to finish and add
as the next version, which can go back to them in the next round.
A version sent to a party on a link, marked up and sent back once a round.
Step 2 replaced it the same day; migration 0015 drops its table, which
only the demo ever held.
### Step 2: later
### Step 2: the shared draft (built)
- Comments both ways on a highlighted passage (a thread per mark).
- Mail the link and each new round from reminders@ (phase 8 mail).
- Signing the agreed text on the link (with the agreements' drawing pad).
- Versions kept only as a file (a PDF draft): the editor works on text.
- A lawyer starts the draft from a version with a text (Contract, Shared
draft), and makes a link for each other party (shown once; it works 30
days after its last use). The text then lives in `contract_drafts`
(migration 0015) as pieces: agreed text, and changes by a side (us, or
a party): added, crossed out, highlighted with a comment.
- One side edits at a time. Edit takes the draft for 45 seconds, which
every save renews; Done editing, leaving the page or silence gives it
up. The editor saves 0.7 seconds after the last keystroke; every other
page of the draft asks for news every 3 seconds, so each side sees the
other's edits, who is editing, agreements and the lock without
reloading. A save may only touch the saver's own marks: the server
refuses any that changes the text as it stands or another side's marks.
- Each change is listed with its author's color: the other side accepts
or rejects it, its author can withdraw it. Anyone resolves a highlight.
Each is a journal entry.
- Agree to this text is possible once no change and no highlight is open,
and a later change voids the agreements given. When Lanna Desk and every
party on the contract agree, the text becomes a new contract version,
which never changes, and the draft locks. A locked draft can start over
from a newer version (an amendment).
- Notices: the other side's edits (one notice per half hour of editing),
accepted and rejected changes, agreements and the lock. The bell in the
top bar counts the unseen ones (asked every 15 seconds); Notices lists
them and marks them seen. A colleague's actions show too; one's own do
not.
- The draft as a diff: the text as it stands against the text with every
open change taken, as `git diff --word-diff` shows it.
### Step 3: the PDF and signing (next)
- The locked version as a PDF (the agreements' renderer: code, version,
SHA-256 of the text on every page), downloadable on both sides.
- Signing in the app: each signer (our client, each party's signatory)
types their name and draws the signature on the link (the agreements'
drawing pad); when all have signed, the signed PDF (with a page of who
signed when, from where) is kept as the contract's document and the
contract's status moves to signed. Our client signs on their own link
or on the lawyer's device in the office.
- On paper: print the PDF, sign, upload the scan as the signed version
(the version form takes a file already).
### Later
- Mail the link and the notices (phase 8 mail, from reminders@).
- A party who agreed by email: a lawyer records the agreement for them.
- Comment threads on a highlight.
## Open questions