From 13c24b7dbd8e2b7e93d1580c35030049fb647a41 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 00:46:18 +0000 Subject: [PATCH 1/3] test(drf-w3): an unordered write must agree with every positioned value of its facet Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- .../tests/integration/focus.rs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/crates/drf-focus-probe/tests/integration/focus.rs b/crates/drf-focus-probe/tests/integration/focus.rs index 40294daba..c64df2a35 100644 --- a/crates/drf-focus-probe/tests/integration/focus.rs +++ b/crates/drf-focus-probe/tests/integration/focus.rs @@ -586,3 +586,33 @@ fn w3_equal_positions_or_mixed_ordering_with_different_values_refuse() { 4i32.to_le_bytes() ); } + +#[test] +fn w3_an_unordered_write_conflicts_with_every_different_positioned_value_in_its_group() { + // Codex P2 on #1766: after the sort the unordered write sits next to the + // equal-valued position-5 write only, so a neighbour check never compares + // it with the value-2 write at position 6. Nothing orders 1 against 2. + let r = rows(); + let soa = Soa { + rows: &r, + id: sid(1, 1, 1, 9), + }; + let m = map_from(307, 9, |s| if s < 3 { 500 } else { (s % NROWS) as u16 }); + let mgr = FocusManager::new(); + let f = mgr.load(&soa, &m, Scope(1), facet()).unwrap(); + let mut wb = f.writeback(); + wb.stage(0, facet(), 1).unwrap(); + wb.stage_at(1, facet(), 1, 5).unwrap(); + wb.stage_at(2, facet(), 2, 6).unwrap(); + assert_eq!( + wb.flush(&soa).err(), + Some(Refusal::Conflict { ord: 500, offset: OFF }) + ); + // Silence twin: every positioned value equals the unordered one. + let mut wb = f.writeback(); + wb.stage(0, facet(), 1).unwrap(); + wb.stage_at(1, facet(), 1, 5).unwrap(); + wb.stage_at(2, facet(), 1, 6).unwrap(); + let imgs = wb.flush(&soa).unwrap(); + assert_eq!(imgs[0].row[OFF..OFF + 4], 1i32.to_le_bytes()); +} From 517f1b5c3e3e0a10b9420bcd28d28f3c1f160e97 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 00:46:55 +0000 Subject: [PATCH 2/3] lab(drf-w3): check an unordered write against its whole facet group Codex P2 on #1766 (merged): stage 1, stage_at 1@5, stage_at 2@6 passed, because after the sort the unordered write only neighbours the equal position-5 write. flush now carries the group's unordered value and refuses any positioned value that differs from it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- crates/drf-focus-probe/src/lib.rs | 11 +++++++++++ crates/drf-focus-probe/tests/integration/focus.rs | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/drf-focus-probe/src/lib.rs b/crates/drf-focus-probe/src/lib.rs index d704240bf..3de7d664e 100644 --- a/crates/drf-focus-probe/src/lib.rs +++ b/crates/drf-focus-probe/src/lib.rs @@ -386,7 +386,17 @@ impl Writeback<'_> { }); } self.patches.sort_by_key(|p| (p.ord, p.offset, p.pos)); + // Value of the current facet group's unordered writes. `None` sorts + // first, so they all precede the group's positioned writes; an + // unordered write has no order against ANY of them, not just the + // first, so every positioned value must equal it. + let mut unordered: Option = None; for w in self.patches.windows(2) { + if (w[0].ord, w[0].offset) != (w[1].ord, w[1].offset) { + unordered = None; + } else if w[0].pos.is_none() { + unordered = Some(w[0].value); + } if w[0].ord != w[1].ord { continue; } @@ -396,6 +406,7 @@ impl Writeback<'_> { let same = w[0].offset == w[1].offset; let ordered = matches!((w[0].pos, w[1].pos), (Some(a), Some(b)) if a != b); if (same && w[0].value != w[1].value && !ordered) + || (same && unordered.is_some_and(|u| u != w[1].value)) || (!same && w[1].offset < w[0].offset + Facet::WIDTH) { return Err(Refusal::Conflict { diff --git a/crates/drf-focus-probe/tests/integration/focus.rs b/crates/drf-focus-probe/tests/integration/focus.rs index c64df2a35..f9649cf7b 100644 --- a/crates/drf-focus-probe/tests/integration/focus.rs +++ b/crates/drf-focus-probe/tests/integration/focus.rs @@ -606,7 +606,10 @@ fn w3_an_unordered_write_conflicts_with_every_different_positioned_value_in_its_ wb.stage_at(2, facet(), 2, 6).unwrap(); assert_eq!( wb.flush(&soa).err(), - Some(Refusal::Conflict { ord: 500, offset: OFF }) + Some(Refusal::Conflict { + ord: 500, + offset: OFF + }) ); // Silence twin: every positioned value equals the unordered one. let mut wb = f.writeback(); From 1f5936777b10707fbbc970607e185929c3c4a3b2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 00:47:24 +0000 Subject: [PATCH 3/3] board: D-DRF-W3 unordered-group check recorded Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg --- .claude/board/entries/2026-10-25-drf-w3-ordered-apply.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.claude/board/entries/2026-10-25-drf-w3-ordered-apply.md b/.claude/board/entries/2026-10-25-drf-w3-ordered-apply.md index 575b1f0ef..49697b3a6 100644 --- a/.claude/board/entries/2026-10-25-drf-w3-ordered-apply.md +++ b/.claude/board/entries/2026-10-25-drf-w3-ordered-apply.md @@ -10,6 +10,8 @@ over 4 rows in a scrambled staging order match a scalar oracle (highest position per row). - **W3 PASS (refusal arm):** different values at one declared position, or an unordered `stage` next to a positioned one, refuse with `Conflict`. Equal values coalesce in both. + An unordered write is checked against every positioned value of its facet, not only its + sorted neighbour (`stage 1`, `stage_at 1@5`, `stage_at 2@6` refuses; codex P2 on #1766). - **Mechanism:** patches sort by `(ord, offset, pos)` and apply in that order, so the sort is the order of application; no second pass. - **Disables, each red on its own test:** sort without `pos` (staging order wins); treat