oficina / docs Public

Docs native: the 200-page check follows the engine's new call sequence

Phase 1's long-document gate typed with a snapshot and a whole projection
per key, as CRDTReplica no longer does (review note on #145). It now types
as the replica does: display_edit on the source, the update on the
authority, both anchors resolved, project_delta (one block re-projected,
each update under 64 B); then a peer's change, a new source built from the
snapshot plus the updates since in a second envelope (which must show what
the authority shows), and a compaction snapshot and a whole projection, all
on the production fuel allowance.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 6c5f335feca51c5b5942044f8f8a98cfef52515b parent c4300c6
1 file changed, +34 −9
  • native/host/tests/sandbox.rs +34 −9
diff --git a/native/host/tests/sandbox.rs b/native/host/tests/sandbox.rs
index 6f3f1b3..1530513 100644
--- a/native/host/tests/sandbox.rs
+++ b/native/host/tests/sandbox.rs
@@ -58,7 +58,7 @@ fn generated_source_delta_applies_to_authority_with_protocol_client_ids() {
#[test]
fn native_boundary_rejects_client_ids_that_v1_decoder_would_truncate() {
let mut host = Host::new().unwrap();
- assert!(host.call(br#"{"op":"open","guid":"generation","client":6088656600138213}"#).is_err());
+ assert!(host.call(br#"{"op":"open","guid":"generation","client":1088656600138213}"#).is_err());
}
#[test]
@@ -119,19 +119,44 @@ fn long_edited_document_opens_and_types() {
source.call(br#"{"op":"open","guid":"long","client":4088656600}"#).unwrap();
let mut imported = vec![255]; imported.extend(&snapshot); source.call(&imported).unwrap();
source.call(br#"{"op":"clients"}"#).unwrap();
- // Typing (CRDTReplica.command, then presentation) deep in the document.
+ // Typing, as CRDTReplica does it now: the command on the displayed
+ // source, its update on the authority, the selection's two anchors
+ // resolved, and a presentation that re-projects only the touched block.
+ // No snapshot and no whole projection per key.
let at = 300_000u32;
+ let mut tail: Vec<Vec<u8>> = Vec::new();
for (i, ch) in "Typed".chars().enumerate() {
let at = at + i as u32;
let update = source.call(&serde_json::to_vec(&json!({"op":"display_edit","at":at,"length":0,"text":ch.to_string()})).unwrap()).unwrap().to_vec();
- source.call(br#"{"op":"snapshot"}"#).unwrap();
- let mut applied = vec![254]; applied.extend(update); authority.call(&applied).unwrap();
- authority.call(br#"{"op":"project"}"#).unwrap();
- authority.call(br#"{"op":"snapshot"}"#).unwrap();
- let anchor: serde_json::Value = serde_json::from_slice(source.call(&serde_json::to_vec(&json!({"op":"anchor","at":at + 1})).unwrap()).unwrap()).unwrap();
- let resolved = authority.call(&serde_json::to_vec(&json!({"op":"resolve","anchor":anchor})).unwrap()).unwrap();
- assert_eq!(resolved, (at + 1).to_string().as_bytes());
+ assert!(update.len() < 64, "a keystroke's update carries only its change: {} B", update.len());
+ let mut applied = vec![254]; applied.extend(&update); authority.call(&applied).unwrap();
+ tail.push(update);
+ for end in [at + 1, at + 1] {
+ let anchor: serde_json::Value = serde_json::from_slice(source.call(&serde_json::to_vec(&json!({"op":"anchor","at":end})).unwrap()).unwrap()).unwrap();
+ let resolved = authority.call(&serde_json::to_vec(&json!({"op":"resolve","anchor":anchor})).unwrap()).unwrap();
+ assert_eq!(resolved, end.to_string().as_bytes());
+ }
+ let delta: serde_json::Value = serde_json::from_slice(authority.call(br#"{"op":"project_delta"}"#).unwrap()).unwrap();
+ let inserted: usize = delta["ops"].as_array().unwrap().iter().filter_map(|op| op["insert"].as_array()).map(Vec::len).sum();
+ assert_eq!(inserted, 1, "one block re-projected");
}
+ // A peer's change, then a new source from the base and the updates since
+ // (two envelopes), and the occasional compaction snapshot.
+ let mut peer = Host::new().unwrap();
+ peer.call(br#"{"op":"open","guid":"long","client":2088656600}"#).unwrap();
+ let mut imported = vec![255]; imported.extend(&snapshot); peer.call(&imported).unwrap();
+ let remote = peer.call(br#"{"op":"display_edit","at":1000,"length":0,"text":"peer"}"#).unwrap().to_vec();
+ let mut applied = vec![255]; applied.extend(&remote); authority.call(&applied).unwrap();
+ tail.push(remote);
+ let mut fresh = Host::new().unwrap();
+ fresh.call(br#"{"op":"open","guid":"long","client":1088656600}"#).unwrap();
+ let mut imported = vec![255]; imported.extend(&snapshot); fresh.call(&imported).unwrap();
+ let mut rest = vec![255]; for update in &tail { rest.extend(update); } fresh.call(&rest).unwrap();
+ authority.call(br#"{"op":"project_delta"}"#).unwrap();
+ authority.call(br#"{"op":"snapshot"}"#).unwrap();
+ let a: serde_json::Value = serde_json::from_slice(authority.call(br#"{"op":"project"}"#).unwrap()).unwrap();
+ let b: serde_json::Value = serde_json::from_slice(fresh.call(br#"{"op":"project"}"#).unwrap()).unwrap();
+ assert_eq!(a["children"], b["children"], "a source from base plus tail shows what the authority does");
}
#[test]