1#[path = "support/typing.rs"]
2mod typing;
3
4use onestore::*;
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let source =
7 std::fs::read("corpus/native/20260905-05/snapshots/02-text/notebook/synthetic.one")?;
8 let store = Store::parse(&source)?;
9 let index = RevisionIndex::parse(&store)?;
10 let document = document::Document::parse(&index)?;
11 let (osid, oid) = document
12 .spaces
13 .iter()
14 .find_map(|(sid, space)| {
15 space.active()?.nodes.iter().find_map(|(oid, node)| {
16 matches!(&node.kind, document::Kind::RichText { text, .. } if text == "Fictitious plain text.")
17 .then_some((*sid, *oid))
18 })
19 })
20 .ok_or("Missing native fixture text")?;
21 let end = "Fictitious plain text.".encode_utf16().count() as u32;
22 let edit = typing::text(osid, oid, 0..end, "A durable edit.");
23 let transaction = typing::sealed(&source, "Header faults", &edit)?.ok_or("No change")?;
24 let mut output = source.clone();
25 transaction.apply(&mut output)?;
26 let mut invalid = Vec::new();
27 for prefix in 0..=1024 {
28 let mut torn = output.clone();
29 torn[prefix..1024].copy_from_slice(&source[prefix..1024]);
30 let result = Store::parse(&torn).and_then(|store| {
31 let index = RevisionIndex::parse(&store)?;
32 index.validate_current()
33 });
34 if result.is_err() {
35 invalid.push(prefix);
36 }
37 }
38 println!(
39 "Header prefix tears: {} invalid out of 1025; offsets {:?}",
40 invalid.len(),
41 invalid
42 );
43 Ok(())
44}