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.
A lawyer sends a contract version to one of its parties with a link. On
it the other side marks the text up in an editor that keeps every change
visible, as tracked changes do: deleting our text crosses it out in red,
typing is marked as added in green, and the highlighter marks a passage
in yellow with a comment. Restore and Undo take marks back. They send it
back once a round; each later version comes on the same link.
- Migration 0014: review_links (token kept as a SHA-256, one open link a
party) and review_rounds (the reply written once: their pieces, text,
SHA-256, name, message; a trigger refuses any other change and every
delete). Journal entries "sent for review", "review returned" (with the
fingerprint of their text) and "review link closed"; audit entity
"review".
- The reply is a list of pieces (same, ins, del, mark). The server checks
that the pieces without the added ones are exactly the version sent, so
nothing changes unseen (reviews::check).
- Our review page: their message, the changes numbered with the words
around them and a box each, the highlights with comments, a git-style
diff (line numbers, - and + lines, the changed words marked, three lines
of context per hunk) and their markup. "Take the ticked changes" opens
the contract page with the version form filled with our text plus those
changes.
- static/review-editor.js: edits work on the pieces and redraw, so our
text cannot vanish; keyboard compositions and edits the browser will not
cancel are compared with the text and taken as edits.
- Property tests (any markup is accepted and taken back exactly; markup
that changes our text unseen is refused), the fuzz text target runs
reviews::check, integration tests, and the demo has the label's review
of the recording agreement.
- PLAN: phase 13.
.gitea/workflows/fuzz.yml runs cargo-fuzz (libFuzzer, nightly Rust) at
03:00 Chiang Mai time on runner02 on cnx01 (runs-on: cnx01; the label
comes with cnx-network-clan PR #170), 10 minutes a target, under nice -n
19 (.gitea/scripts/fuzz.sh). Targets, bodies in src/fuzzing.rs:
- text: passport zones and OCR output (whatever from_ocr returns must
parse), positions, names, dates, Thai numbers, agreement texts and the
contract diff.
- upload: a file as files::sniff types it, through the pack's image and
PDF code to a finished A4 page (pack::pdf::sides), EXIF orientation.
- signed_copy: the drawn signature's PNG, or any text as the agreement,
in the signed copy's PDF.
fuzz/seeds/ holds small real files to start from (JPEG with JFIF and
EXIF, PNG with pHYs, palette PNG, WebP lossy and lossless, A4 and
landscape PDF, a drawn signature, zone, OCR, map links, Thai names). The
grown corpus stays in the runner's cache; a crash fails the job and
leaves its input as the artifact fuzz-findings, which goes into
tests/fuzz_cases/<target>/ with the fix. tests/fuzz_cases.rs replays
those and the seeds on every push, on stable. No sanitizer (safe Rust,
about three times the inputs), debug assertions on, 10 s and 2 GB per
input count as findings.
DRAWING_LIMIT moved to agreements so the target uses the client page's
limit. A local run of 60 s each in a Linux container: 635,522 / 9,763 /
4,089 inputs, peak 62 MB, nothing found.