Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/synapse/blob/main/evidence/g3-shm-ring/red-green/red1-stub.diff # synapse A component of the AienOS ecosystem. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `synapse / evidence / g3-shm-ring / red-green / red1-stub.diff` 95 lines ยท 3718 bytes Raw Blame History 1 --- /tmp/g3red/ring.rs.orig 2026-10-16 03:46:19.`566396941` -0500 2 +++ /tmp/g3red/ring.rs.red1 2026-10-16 03:46:19.`568696686` -0500 3 @@ -600,75 +600,17 @@ 4 5 /// Copy the next record into `out` (replacing its contents) if one is published. 6 pub fn try_recv(&mut self, out: &mut Vec) -> Result { 7 - if let Some(r) = &self.poisoned { 8 - return Err(r.clone()); 9 - } 10 - // Closed first, then head: a sender stores head before closed (both release), so 11 - // seeing closed means the head loaded next is final. 12 + // RED STUB 1: trusts the writer (no index, length, torn or sequence checks). 13 let closed = self.view.ctl(layout::CLOSED).load(Ordering::Acquire) != 0; 14 let head = self.view.ctl(layout::HEAD).load(Ordering::Acquire); 15 - if !head.is_multiple_of(8) { 16 - return Err(self.poison(RingRefusal::IndexMisaligned { 17 - which: "head", 18 - found: head, 19 - })); 20 - } 21 - let cap = self.cfg.capacity as u64; 22 - let available = head.wrapping_sub(self.tail); 23 - if available > cap { 24 - return Err(self.poison(RingRefusal::IndexOutOfRange { 25 - which: "head", 26 - found: head, 27 - low: self.tail, 28 - high: self.tail.wrapping_add(cap), 29 - })); 30 - } 31 - if available < self.head_seen.wrapping_sub(self.tail) { 32 - return Err(self.poison(RingRefusal::IndexRegressed { 33 - found: head, 34 - seen: self.head_seen, 35 - })); 36 - } 37 - self.head_seen = head; 38 - if available == 0 { 39 + if head == self.tail { 40 return Ok(if closed { 41 RecvStatus::Closed 42 } else { 43 RecvStatus::Empty 44 }); 45 } 46 - if available < RECORD_HEADER_LEN as u64 { 47 - return Err(self.poison(RingRefusal::TornRecord { 48 - need: RECORD_HEADER_LEN as u64, 49 - available, 50 - })); 51 - } 52 - // Each header word is loaded once; the checks and the copy use these locals. 53 - let len = self.view.data(self.tail).load(Ordering::Relaxed); 54 - let seq = self 55 - .view 56 - .data(self.tail.wrapping_add(8)) 57 - .load(Ordering::Relaxed); 58 - if len > self.cfg.max_record as u64 { 59 - return Err(self.poison(RingRefusal::LengthOverCap { 60 - declared: len, 61 - cap: self.cfg.max_record as u64, 62 - })); 63 - } 64 - let len = len as usize; 65 - let span = record_span(len) as u64; 66 - if span > available { 67 - return Err(self.poison(RingRefusal::TornRecord { 68 - need: span, 69 - available, 70 - })); 71 - } 72 - if seq != self.seq { 73 - return Err(self.poison(RingRefusal::SequenceMismatch { 74 - expected: self.seq, 75 - found: seq, 76 - })); 77 - } 78 + let len = self.view.data(self.tail).load(Ordering::Relaxed) as usize; 79 out.clear(); 80 out.reserve(len); 81 let mut at = self.tail.wrapping_add(RECORD_HEADER_LEN as u64); 82 @@ -680,11 +622,9 @@ 83 left -= n; 84 at = at.wrapping_add(8); 85 } 86 - self.tail = self.tail.wrapping_add(span); 87 + self.tail = self.tail.wrapping_add((RECORD_HEADER_LEN + len.div_ceil(8) * 8) as u64); 88 self.seq += 1; 89 - self.view 90 - .ctl(layout::TAIL) 91 - .store(self.tail, Ordering::Release); 92 + self.view.ctl(layout::TAIL).store(self.tail, Ordering::Release); 93 Ok(RecvStatus::Record) 94 } 95