The other side reviews a draft (phase 13, step 1)
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.
This commit is contained in:
1 parent
ff716eb9d3
commit
a4155548b8
24 files changed
+3004
-6
No files matched your search
+62
-1
@@ -8,7 +8,7 @@
|
||||
use chrono::{DateTime, Datelike, NaiveDate, Utc};
|
||||
use proptest::prelude::*;
|
||||
|
||||
use crate::{agreements, conflicts, dates, gps, journal, legal, mrz, records};
|
||||
use crate::{agreements, conflicts, dates, gps, journal, legal, mrz, records, reviews};
|
||||
|
||||
fn today() -> NaiveDate {
|
||||
NaiveDate::from_ymd_opt(2026, 11, 17).unwrap()
|
||||
@@ -436,3 +436,64 @@ proptest! {
|
||||
prop_assert_ne!(hash(&a), hash(&b));
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- review markup
|
||||
|
||||
/// A text cut into pieces, each kept, crossed out or highlighted, with the
|
||||
/// other side's typing between them: any markup the editor can make.
|
||||
fn markup() -> impl Strategy<Value = (String, Vec<reviews::Piece>)> {
|
||||
let part = (any_text(), 0u8..3, any_text(), "[a-z ]{0,12}");
|
||||
prop::collection::vec(part, 0..12).prop_map(|parts| {
|
||||
let mut sent = String::new();
|
||||
let mut pieces = Vec::new();
|
||||
for (ours, kind, typed, comment) in parts {
|
||||
let ours = ours.replace('\r', "");
|
||||
sent.push_str(&ours);
|
||||
let op = [reviews::Op::Same, reviews::Op::Del, reviews::Op::Mark][kind as usize];
|
||||
pieces.push(reviews::Piece {
|
||||
op,
|
||||
text: ours,
|
||||
comment: if op == reviews::Op::Mark {
|
||||
comment.trim().to_string()
|
||||
} else {
|
||||
String::new()
|
||||
},
|
||||
});
|
||||
pieces.push(reviews::Piece {
|
||||
op: reviews::Op::Ins,
|
||||
text: typed.replace('\r', ""),
|
||||
comment: String::new(),
|
||||
});
|
||||
}
|
||||
(sent, pieces)
|
||||
})
|
||||
}
|
||||
|
||||
proptest! {
|
||||
#[test]
|
||||
fn any_markup_of_the_sent_text_is_accepted_and_taken_back_exactly((sent, pieces) in markup()) {
|
||||
let json = reviews::to_json(&pieces).to_string();
|
||||
let checked = reviews::check(&json, &sent).unwrap();
|
||||
prop_assert_eq!(reviews::ours(&checked), sent.clone());
|
||||
let theirs = reviews::theirs(&checked);
|
||||
let all: std::collections::BTreeSet<usize> =
|
||||
reviews::changes(&checked).iter().map(|c| c.n).collect();
|
||||
prop_assert_eq!(reviews::apply(&checked, &Default::default()), sent.clone());
|
||||
prop_assert_eq!(reviews::apply(&checked, &all), theirs.clone());
|
||||
// what is stored reads back the same
|
||||
prop_assert_eq!(reviews::from_json(&reviews::to_json(&checked)), checked.clone());
|
||||
if let Some(git) = reviews::git_view(&checked)
|
||||
&& sent == theirs
|
||||
{
|
||||
prop_assert!(git.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn markup_that_changes_our_text_unseen_is_refused((sent, pieces) in markup(), extra in "[a-z]{1,5}") {
|
||||
let mut changed = pieces.clone();
|
||||
changed.push(reviews::Piece { op: reviews::Op::Same, text: extra, comment: String::new() });
|
||||
let json = reviews::to_json(&changed).to_string();
|
||||
prop_assert!(reviews::check(&json, &sent).is_err());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user